bm-core-ui 2.11.6 → 2.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- var BMCoreUI="2.5.0",YES=!0,NO=!1;if(!("remove"in Element.prototype)){Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}}var _BMScrollBarSize,BMIsTouchDevice=!(!("ontouchstart"in window)&&!navigator.maxTouchPoints);function BMScrollBarGetSize(){if(void 0!==_BMScrollBarSize)return _BMScrollBarSize;var t=document.createElement("div");return t.style.cssText="width: 100px; height: 100px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(t),_BMScrollBarSize=t.offsetWidth-t.clientWidth,t.remove(),_BMScrollBarSize}function BMCSSRuleWithSelector(t,e){let i=e.properties,o=t+" {\n";return Object.keys(i).forEach((t=>{o+=t+": "+i[t]+(e.important?" !important":"")+";\n"})),o+="\n}\n",o}function BMAddSmoothMousewheelInteractionToNode(t,e){let i,o,n=NO,s=0,a=0,r=(e=e||{}).withDeceleration||3,l=0,h=0,c=e.baseAcceleration||6,d=e.speedIncrement||20;function u(){let e=Math.sign(s),i=Math.sign(a);if(s&&(s-=e*r),a&&(a-=i*r),s&&(s+=e*l),a&&(a+=i*h),l&&(l-=.5),h&&(h-=.5),Math.sign(s)!=e&&(s=0),Math.sign(a)!=i&&(a=0),(a||s)&&requestAnimationFrame(u),!s&&!a)return;let n=new WheelEvent("wheel",{deltaX:s,deltaY:a,deltaZ:0,deltaMode:0,clientX:o.clientX,cientY:o.clientY,offsetX:o.offsetX,offsetY:o.offsetY,layerX:o.layerX,layerY:o.layerY,target:o.target,altKey:o.altKey,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey});n._BMIsCustomScrollEvent=YES,t.dispatchEvent(n)}t.addEventListener("mousedown",(function(){s=0,a=0})),t.addEventListener("wheel",(function(t){i&&window.clearTimeout(i),i=window.setTimeout((t=>{i=void 0,n=NO}),200),t._BMIsCustomScrollEvent||n||(0==t.deltaMode&&Math.abs(t.deltaX)<50&&Math.abs(t.deltaY)<50&&Math.floor(t.deltaY)-t.deltaY==0?n=YES:(o=t,t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),0==s&&0==a&&(r=0,requestAnimationFrame(u)),Math.sign(t.deltaX)!=Math.sign(s)||0==s?(s=c*Math.sign(t.deltaX),l=c):s+=t.deltaX?Math.sign(t.deltaX)*d:0,Math.sign(t.deltaY)!=Math.sign(a)||0==a?(a=c*Math.sign(t.deltaY),h=c):a+=t.deltaY?Math.sign(t.deltaY)*d:0,r+=r?(e.withDeceleration||3)/3:e.withDeceleration||3))}))}function BMExtend(t){void 0===t&&(t={});var e=arguments.length;if("function"==typeof Object.getOwnPropertyDescriptors)for(var i=1;i<e;i++){var o=Object.getOwnPropertyDescriptors(arguments[i]);Object.defineProperties(t,o)}else for(i=1;i<e;i++)for(var n=Object.getOwnPropertyNames(arguments[i]),s=0;s<n.length;s++){var a=Object.getOwnPropertyDescriptor(arguments[i],n[s]);a&&Object.defineProperty(t,n[s],a)}return t}function BMCopyProperties(t){var e=arguments.length,i=arguments;void 0===t&&(t={});for(var o=1;o<e;o++)Object.getOwnPropertyNames(arguments[o]).forEach((function(e){t[e]=i[o][e]}));return t}function BMShadowForElevation(t,e){var i=void 0===(e=e||{}).opacity?.1:e.opacity;return"0px "+4*t+"px "+6*t+"px"+" rgba(0, 0, 0, "+i+"), "+("0px "+8*t+"px "+12*t+"px")+" rgba(0, 0, 0, "+i+")"+(e.drawOutline||NO?", 0px 0px 1px 1px rgba(0, 0, 0, "+i+")":"")}function BMNumberByInterpolatingNumbersWithFraction(t,e,i){return(e-t)*i+t}function BMNumberByConstrainingNumberToBounds(t,e,i){return Math.max(e,Math.min(t,i))}function BMStringByCapitalizingString(t){return t.charAt(0).toUpperCase()+t.slice(1)}function BMKeysForValue(t,e){var i=[];return Object.getOwnPropertyNames(e.inObject).forEach((function(o){e.inObject[o]==t&&i.push(o)})),i}function BMUUIDMake(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))}var BMHTMLEntity=Object.freeze({Control:"&#8963;",Command:"&#8984;",Option:"&#8997;",Shift:"&#8679;",CapsLock:"&#8682;",Delete:"&#9003;",Return:"&#9166;",Escape:"&#9099;",Tab:"&#8677;"}),BMScrollingDirectionVertical=Object.freeze({Stationary:0,Top:1,Bottom:-1}),BMScrollingDirectionHorizontal=Object.freeze({Stationary:0,Left:1,Right:-1});function BMInset(t,e,i,o){this.left=t||0,this.top=e||0,this.right=i||0,this.bottom=o||0}function BMInsetMakeWithEqualInsets(t){return BMInsetMake(t=t||0,t,t,t)}function BMInsetMake(t,e,i,o){return new BMInset(t,e,i,o)}function BMInsetMakeWithLeft(t,e){return new BMInset(t||0,(e=e||{}).top||0,e.right||0,e.bottom||0)}function BMPoint(t,e){t=t||0,e=e||0,this.x=t,this.y=e}function BMPointMake(t,e){return new BMPoint(t,e)}function BMPointMakeWithX(t,e){return new BMPoint(t||0,e&&e.y||0)}function BMPointMakeWithRadius(t=0,{angle:e=0}={angle:0}){return BMPointMake(t*Math.cos(e),t*Math.sin(e))}function BMDistanceBetweenPoints(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function BMSlopeAngleBetweenPoints(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}BMInset.prototype={left:0,top:0,right:0,bottom:0,initWithInset(t){return this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom,this},isEqualToInset(t){return this.left===t.left&&this.top===t.top&&this.right===t.right&&this.bottom===t.bottom},copy:function(){return new BMInset(this.left,this.top,this.right,this.bottom)}},BMInset.insetWithEqualInsets=BMInsetMakeWithEqualInsets,BMInset.insetWithLeft=BMInsetMakeWithLeft,BMPoint.prototype={x:0,y:0,get r(){return BMDistanceBetweenPoints(this,BMOriginPoint)},set r(t){const e=this.t;this.x=t*Math.cos(e),this.y=t*Math.sin(e)},get t(){return BMSlopeAngleBetweenPoints(BMOriginPoint,this)},set t(t){const e=this.r;this.x=e*Math.cos(t),this.y=e*Math.sin(t)},initWithPoint(t){return this.x=t.x,this.y=t.y,this},get stringValue(){return this.x+","+this.y},get integerStringValue(){return(0|this.x)+","+(0|this.y)},get integerPointValue(){return BMPointMake(0|this.x,0|this.y)},get integralPoint(){return this.integerPointValue},isEqualToPoint:function(t){return this.x==t.x&&this.y==t.y},copy:function(){return BMPointMake(this.x,this.y)},multiplyWithScalar(t){this.x*=t,this.y*=t},pointByMultiplyingWithScalar(t){const e=this.copy();return e.multiplyWithScalar(t),e},pointByAddingPoint(t){return BMPointMake(this.x+t.x,this.y+t.y)},pointBySubtractingPoint(t){return BMPointMake(this.x-t.x,this.y-t.y)},distanceToPoint:function(t){return BMDistanceBetweenPoints(this,t)},slopeAngleToPoint:function(t){return BMSlopeAngleBetweenPoints(this,t)},interpolatedValueWithFraction(t,e){var i=e.toValue;return BMPointMake(BMNumberByInterpolatingNumbersWithFraction(this.x,i.x,t),BMNumberByInterpolatingNumbersWithFraction(this.y,i.y,t))},toString(){return`(${this.x}:${this.y})`}},BMPoint.pointWithX=BMPointMakeWithX,BMPoint.pointWithRadius=BMPointMakeWithRadius;const BMOriginPoint=BMPointMake(0,0);function BMSize(t,e){t=t||0,e=e||0,this.width=t,this.height=e}function BMSizeMake(t,e){return new BMSize(t,e)}function BMRect(t,e){t=t||new BMPoint,e=e||new BMSize,this.origin=t,this.size=e}function BMRectByInterpolatingRect(t,e){var i=e.toRect,o=e.withFraction;return BMRectMake(BMNumberByInterpolatingNumbersWithFraction(t.origin.x,i.origin.x,o),BMNumberByInterpolatingNumbersWithFraction(t.origin.y,i.origin.y,o),BMNumberByInterpolatingNumbersWithFraction(t.size.width,i.size.width,o),BMNumberByInterpolatingNumbersWithFraction(t.size.height,i.size.height,o))}function BMRectMake(t,e,i,o){return new BMRect(new BMPoint(t,e),new BMSize(i,o))}function BMRectMakeWithX(t,e){return new BMRect(new BMPoint(t,e&&e.y),new BMSize(e&&e.width,e&&e.height))}function BMRectMakeWithOrigin(t,e){return new BMRect(t||new BMPoint,e&&e.size||new BMSize)}function BMRectMakeWithNodeFrame(t){var e=t.getBoundingClientRect();return new BMRect(new BMPoint(e.left,e.top),new BMSize(e.width,e.height))}function BMFunctionCollectionMake(){var t=[],e=function(){var e,i=this;return t.forEach((t=>e=t.apply(i,arguments))),e};return Object.getOwnPropertyNames(Array.prototype).forEach((function(i){i in e||(e[i]=function(){return t[i].apply(t,arguments)})})),BMExtend(e,{get length(){return t.length},set length(e){t.length=e},functionAtIndex:e=>t[e],setfunction:(e,i)=>t[i.atIndex]=e,_isFunctionCollection:YES}),e}BMSize.prototype={width:0,height:0,initWithSize(t){return this.width=t.width,this.height=t.height,this},newRectWithSize:function(){return new BMRect(new BMPoint,this)},copy:function(){return new BMSize(this.width,this.height)},isEqualToSize:function(t){return t.width===this.width&&t.height===this.height},isGreaterThanSize:function(t){return this.width>=t.width&&this.height>=t.height},isLessThanSize:function(t){return this.width<=t.width&&this.height<=t.height},interpolatedValueWithFraction(t,e){var i=e.toValue;return BMSizeMake(BMNumberByInterpolatingNumbersWithFraction(this.width,i.width,t),BMNumberByInterpolatingNumbersWithFraction(this.height,i.height,t))},toString(){return`[${this.width}:${this.height}]`}},BMRect.prototype={origin:void 0,size:void 0,get right(){return this.origin.x+this.size.width},get bottom(){return this.origin.y+this.size.height},get left(){return this.origin.x},get top(){return this.origin.y},get width(){return this.size.width},get height(){return this.size.height},get center(){return new BMPoint(this.origin.x+this.size.width/2,this.origin.y+this.size.height/2)},set center(t){var e=this.center;this.offset(t.x-e.x,t.y-e.y)},get integralRect(){return BMRectMake(0|this.origin.x,0|this.origin.y,0|this.size.width,0|this.size.height)},initWithRect(t){return this.origin=t.origin.copy(),this.size=t.size.copy(),this},isEqualToRect:function(t){return t.origin.x==this.origin.x&&t.origin.y==this.origin.y&&this.size.width==t.size.width&&this.size.height==t.size.height},intersectsRect:function(t){return this.isEqualToRect(t)?YES:!(t.left>this.right||t.right<this.left||t.top>this.bottom||t.bottom<this.top)},intersectsContentOfRect:function(t){return this.isEqualToRect(t)?YES:!(t.left>=this.right||t.right<=this.left||t.top>=this.bottom||t.bottom<=this.top)},rectByIntersectingWithRect:function(t){var e=new BMPoint(Math.max(this.left,t.left),Math.max(this.top,t.top)),i=new BMSize(Math.min(this.right,t.right)-e.x,Math.min(this.bottom,t.bottom)-e.y);if(!(i.width<=0||i.height<=0))return new BMRect(e,i)},rectByUnionWithRect(t){let e=Math.min(this.origin.x,t.origin.x),i=Math.min(this.origin.y,t.origin.y);return BMRectMake(e,i,Math.max(this.right,t.right)-e,Math.max(this.bottom,t.bottom)-i)},rectsByExclusiveOrWithRect:function(t){throw new Error("This method is not available.")},rectsWithDifferenceFromRect:function(t){if(!this.isEqualToRect(t)){var e=this.rectByIntersectingWithRect(t);if(!e)return[this];if(!e.isEqualToRect(this)){if(e.size.height==this.size.height)return[BMRectMake(e.origin.x==this.origin.x?e.right:this.origin.x,this.origin.y,this.size.width-e.size.width,this.size.height)];if(e.size.width==this.size.width)return[BMRectMake(this.origin.x,e.origin.y==this.origin.y?e.bottom:this.origin.y,this.size.width,this.size.height-e.size.height)];var i=BMRectMake(e.origin.x==this.origin.x?e.right:this.origin.x,this.origin.y,this.size.width-e.size.width,this.size.height);return[i,BMRectMake(i.origin.x==this.origin.x?i.right:this.origin.x,e.origin.y==this.origin.y?e.bottom:this.origin.y,this.size.width-i.size.width,this.size.height-e.size.height)]}}},containsRect:function(t){return t.left>=this.left&&t.top>=this.top&&t.right<=this.right&&t.bottom<=this.bottom},containsPoint:function(t){return t.x>this.left&&t.x<this.right&&t.y>this.top&&t.y<this.bottom},intersectsPoint:function(t){return t.x>=this.left&&t.x<=this.right&&t.y>=this.top&&t.y<=this.bottom},offset:function(t,e){this.origin.x+=t,this.origin.y+=e},offsetWithX:function(t,e){this.origin.x+=t||0,this.origin.y+=e&&e.y||0},multiplyWithScalar(t){this.origin.x*=t,this.origin.y*=t,this.size.width*=t,this.size.height*=t},rectByMultiplyingWithScalar(t){const e=this.copy();return e.multiplyWithScalar(t),e},scaleWithFactor(t,e){const i=e&&e.aroundPoint||this.center,o=BMPointMake((i.x-this.origin.x)/this.size.width,(i.y-this.origin.y)/this.size.height);this.size.width*=t,this.size.height*=t,this.origin.x=i.x-o.x*this.size.width,this.origin.y=i.y-o.y*this.size.height},rectByScalingWithFactor(t,e){const i=this.copy();return i.scaleWithFactor(t,e),i},inset:function(t,e){void 0===e?(this.origin.x+=t.left,this.origin.y+=t.top,this.size.width-=t.left+t.right,this.size.height-=t.top+t.bottom):(this.origin.x+=t,this.origin.y+=e,this.size.width-=2*t,this.size.height-=2*e)},insetWithWidth:function(t,e){var i=e.height;this.origin.x+=t,this.origin.y+=i,this.size.width-=2*t,this.size.height-=2*i},insetWithInset:function(t){this.origin.x+=t.left,this.origin.y+=t.top,this.size.width-=t.left+t.right,this.size.height-=t.top+t.bottom},rectWithInset:function(t){var e=this.copy();return e.insetWithInset(t),e},rectWithTransformToRect:function(t){var e=BMRectMake();e.size.width=t.size.width/this.size.width,e.size.height=t.size.height/this.size.height;var i=t.center.x-this.center.x,o=t.center.y-this.center.y;return e.origin.x=i,e.origin.y=o,e},copy:function(){var t=new BMRect;return t.origin.x=this.origin.x,t.origin.y=this.origin.y,t.size.width=this.size.width,t.size.height=this.size.height,t},interpolatedValueWithFraction(t,e){return BMRectByInterpolatingRect(this,{toRect:e.toValue,withFraction:t})},toString(){return`(${this.origin.x}:${this.origin.y})=>[${this.size.width}:${this.size.height}]`}};const BM_USE_VELOCITY2=NO;var BM_USE_WEB_ANIMATIONS=NO;function BMAnimatable(t,e,i){if(!i.set)throw new Error("[BMCoreUI] Incorrectly applied BMAnimatable to property "+e+" that doesn't have a setter");if(i.get){o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerAnimatableProperty(e,{targetValue:t.copy(),startingValue:this[e].copy()})}else o.call(this,t)}}else{i.get=function(){return this["_"+e]};var o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerAnimatableProperty(e,{targetValue:t.copy(),startingValue:this[e].copy()})}else o.call(this,t),this["_"+e]=t.copy()}}}function BMAnimatableNumber(t,e,i){if(!i.set)throw new Error("[BMCoreUI] Incorrectly applied BMAnimatable to property "+e+" that doesn't have a setter");if(i.get){o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerOwnProperty(e,{targetValue:t,startingValue:this[e]||0})}else o.call(this,t)}}else{i.get=function(){return this["_"+e]};var o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerOwnProperty(e,{targetValue:t,startingValue:this[e]||0})}else o.call(this,t),this["_"+e]=t}}}function BMAnimationController(){}BMAnimationController.prototype={_animation:void 0,_owner:void 0,_node:void 0,_promise:void 0,get promise(){return this._promise},_resolve:void 0,_properties:void 0,initWithAnimation(t,e){return this._animation=t,this._owner=e.owner,this._node=e.node,this._properties={},this._promise=new Promise((t=>this._resolve=t)),this},registerBuiltInProperty(t,e){this._properties[t]=e.withValue},registerBuiltInPropertiesWithDictionary(t){for(let e in t)this.registerBuiltInProperty(e,{withValue:t[e]})},registerCustomProperty(t,e){this._properties.tween||(this._properties.tween={}),BM_USE_WEB_ANIMATIONS&&console.warn(`[BMAnimationController] Registering custom property ${t} with handler ${e.withHandler} which will run in legacy mode.`),this._properties.tween[t]={handler:e.withHandler,startingValue:e.startingValue,targetValue:e.targetValue,BMAnimatable:NO}},registerOwnProperty(t,e){this._properties.tween||(this._properties.tween={}),BM_USE_WEB_ANIMATIONS&&console.warn(`[BMAnimationController] Registering own property ${t} which will run in legacy mode.`);var i=this;this._properties.tween[t]={handler:(e,o)=>{i._owner[t]=o},startingValue:e.startingValue,targetValue:e.targetValue,name:t,BMAnimatable:NO}},registerAnimatableProperty(t,e){this._properties.tween||(this._properties.tween={}),BM_USE_WEB_ANIMATIONS&&console.warn(`[BMAnimationController] Registering animatable property ${t} which will run in legacy mode.`);var i=this;this._properties.tween[t]={handler:(e,o)=>{i._owner[t]=o},startingValue:e.startingValue,targetValue:e.targetValue,name:t,BMAnimatable:YES}},apply(t){if(this._options={complete:()=>{this._resolve()}},"tween"in this._properties){var e=this._properties.tween;this._properties.tween=[1,0];var i=this,o=BMFunctionCollectionMake();Object.getOwnPropertyNames(e).forEach((t=>{var n=e[t];if(n.name)if(n.BMAnimatable){(s=n.startingValue)||(s=i._owner[n.name].copy()),o.push(((t,e,i,o,a)=>{n.handler(a,s.interpolatedValueWithFraction(a,{toValue:n.targetValue}))}))}else{var s;void 0===(s=n.startingValue)&&(s=i._owner[n.name]),o.push(((t,e,i,o,a)=>{n.handler(a,BMNumberByInterpolatingNumbersWithFraction(s,n.targetValue,a))}))}else"number"==typeof n.startingValue&&"number"==typeof n.targetValue?o.push(((t,e,i,o,s)=>{n.handler(s,BMNumberByInterpolatingNumbersWithFraction(n.startingValue,n.targetValue,s))})):o.push(((t,e,i,o,s)=>{n.handler(s)}))})),this._options.progress=o}t.targets.push({element:this._node,properties:this._properties,options:this._options})}};const BMAnimationEasing=Object.freeze({ease:"cubic-bezier(0.25, 0.1, 0.25, 1)",easeIn:"cubic-bezier(0.42, 0, 1, 1)",easeOut:"cubic-bezier(0, 0, 0.58, 1)",easeInOut:"cubic-bezier(0.42, 0, 0.58, 1)",easeInSine:"cubic-bezier(0.47, 0, 0.745, 0.715)",easeOutSine:"cubic-bezier(0.39, 0.575, 0.565, 1)",easeInOutSine:"cubic-bezier(0.445, 0.05, 0.55, 0.95)",easeInQuad:"cubic-bezier(0.55, 0.085, 0.68, 0.53)",easeOutQuad:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",easeInOutQuad:"cubic-bezier(0.455, 0.03, 0.515, 0.955)",easeInCubic:"cubic-bezier(0.55, 0.055, 0.675, 0.19)",easeOutCubic:"cubic-bezier(0.215, 0.61, 0.355, 1)",easeInOutCubic:"cubic-bezier(0.645, 0.045, 0.355, 1)",easeInQuart:"cubic-bezier(0.895, 0.03, 0.685, 0.22)",easeOutQuart:"cubic-bezier(0.165, 0.84, 0.44, 1)",easeInOutQuart:"cubic-bezier(0.77, 0, 0.175, 1)",easeInQuint:"cubic-bezier(0.755, 0.05, 0.855, 0.06)",easeOutQuint:"cubic-bezier(0.23, 1, 0.32, 1)",easeInOutQuint:"cubic-bezier(0.86, 0, 0.07, 1)",easeInExpo:"cubic-bezier(0.95, 0.05, 0.795, 0.035)",easeOutExpo:"cubic-bezier(0.19, 1, 0.22, 1)",easeInOutExpo:"cubic-bezier(1, 0, 0, 1)",easeInCirc:"cubic-bezier(0.6, 0.04, 0.98, 0.335)",easeOutCirc:"cubic-bezier(0.075, 0.82, 0.165, 1)",easeInOutCirc:"cubic-bezier(0.785, 0.135, 0.15, 0.86)"}),BMAnimationTransformPropertyDefaults=Object.freeze({scaleX:1,scaleY:1,scaleZ:1,rotate:0,rotateX:0,rotateY:0,rotateZ:0,skewX:0,skewY:0,skewZ:0,translateZ:0,translateX:0,translateY:0}),BMAnimationFilterPropertyDefaults=Object.freeze({blur:1,brightness:1,contrast:1,"drop-shadow":0,grayscale:0,"hue-rotate":0,invert:0,saturate:0,sepia:0});function __BMVelocityAnimate(t,e,i,o){return BMAnimateWithBlock((()=>{BMAnimationContextGetCurrent().controllerForObject(t,{node:t}).registerBuiltInPropertiesWithDictionary(e),o&&BMAnimationContextEnableWebAnimations()}),i)}function BMHook(t,e){if(BM_USE_VELOCITY2){let i=t;window.$&&t instanceof window.$&&(i=t[0]);let o={},n="";for(let t in e)t in BMAnimationTransformPropertyDefaults?n+=`${t}(${e[t]}) `:o[t]=e[t];n&&(o.transform=n);let s="";for(let t in e)t in BMAnimationFilterPropertyDefaults&&(s+=`${t}(${e[t]}) `);s&&(o.filter=s),BMCopyProperties(i.style,o)}else for(var i in e)(window.Velocity||$.Velocity).hook(t,i,e[i])}function BMAnimationContext(){throw new Error("Animation contexts may not be created manually. To create an animation context, invoke the BMAnimationBeginWithDuration() function.")}BMAnimationContext.prototype={options:{},subscribers:void 0,controllerForObject(t,e){let i=this.subscribers.get(t);return i||(i=Object.create(BMAnimationController.prototype).initWithAnimation(this,{owner:t,node:e.node}),this.subscribers.set(t,i)),i},targets:void 0,registerAnimationForTarget:function(t,e){this.targets.push({element:t,properties:e.properties,options:e.options})},registerSubscriber:function(t,e){}},BMAnimationContext._pendingAnimations=new Map;var _BMAnimationStack=[];function BMAnimationContextGetCurrent(){let t=_BMAnimationStack[_BMAnimationStack.length-1];return t&&t._isDisabled?void 0:t}function BMAnimationContextEnableWebAnimations(){let t=BMAnimationContextGetCurrent();t&&(t._useWebAnimations=YES)}function BMAnimationContextBeginStatic(){var t=Object.create(BMAnimationContext.prototype);return t.options={duration:0,easing:"linear"},t.targets=[],t._isDisabled=YES,t.subscribers=new Map,_BMAnimationStack.push(t),t}function BMAnimationBeginWithDuration(t,e){(e=e||{}).duration=t;var i=Object.create(BMAnimationContext.prototype);return i.options=e,i.targets=[],i.subscribers=new Map,_BMAnimationStack.push(i),i}function BMAnimationContextAddCompletionHandler(t){let e;if(e=BMAnimationContextGetCurrent())if(e.options.complete)if(e.options.complete._isFunctionCollection)e.options.complete.push(t);else{let i=BMFunctionCollectionMake();i.push(e.options.complete),i.push(t),e.options.complete=i}else e.options.complete=BMFunctionCollectionMake(),e.options.complete.push(t);else t()}function BMAnimationApply(){return BMAnimationApplyBlocking(NO)}var BM_WEB_ANIMATIONS_DISABLED=NO;function BMAnimationApplyBlocking(t){let e=_BMAnimationStack[_BMAnimationStack.length-1];if(!e)return console.error("Attempted to apply an animation while there was no animation context active. This method call will be ignored."),Promise.resolve(void 0);if(e._isDisabled)return _BMAnimationStack.pop(),Promise.resolve(void 0);void 0===t&&(t=YES),new Map(BMAnimationContextGetCurrent().subscribers).forEach((function(t,e,i){t.prepare&&t.prepare(o)}));var i,o=_BMAnimationStack.pop(),n=o.targets;o.subscribers.forEach((function(t,e,i){t.apply(o)}));var s=NO;if(o.options.complete){var a=o.options.complete;i=async function(t){if(!s){s=YES,await 0,a(t);for(var e=0;e<u;e++)n[e].options&&n[e].options.complete?n[e].options.complete(t):n[e].complete&&n[e].complete(t)}}}else i=async function(t){if(!s){s=YES,await 0;for(var e=0;e<u;e++)n[e].options&&n[e].options.complete?n[e].options.complete(t):n[e].complete&&n[e].complete(t)}};o.options.complete=i;var r=o.options.stride,l=o.options.delay||0,h=window.Velocity||$.Velocity,c=[];let d=[];for(var u=o.targets.length,p=0;p<u;p++){var g=n[p].element;const t=(e._useWebAnimations||BM_USE_WEB_ANIMATIONS)&&document.body.animate&&!BM_WEB_ANIMATIONS_DISABLED;var w=n[p].options?BMCopyProperties({},o.options,n[p].options):BMCopyProperties({},o.options);if(r&&(w=BMCopyProperties({},w),p<u-1&&delete w.complete,w.delay=l,l+=r),!h||t||l||BMAnimationContext._prepareAnimationForNode(g,{withProperties:n[p].properties,options:w}),delete w.complete,t){w.queue&&console.warn("[BMCoreUI] Using the queue animation option with web animations which is not supported. This argument will be ignored.");let t={},e="",i="";for(let t in n[p].properties)t in BMAnimationTransformPropertyDefaults&&(Array.isArray(n[p].properties[t])?(i+=`${t}(${n[p].properties[t][0]}) `,e+=`${t}(${n[p].properties[t][1]}) `):i+=`${t}(${n[p].properties[t]}) `);i&&(t.transform=e?[i,e]:i);let o="";for(let t in n[p].properties)t in BMAnimationFilterPropertyDefaults&&(o+=`${t}(${n[p].properties[t]}) `);o&&(t.filter=o);for(let e in n[p].properties)e in BMAnimationTransformPropertyDefaults||e in BMAnimationFilterPropertyDefaults||"tween"!=e&&(t[e]=n[p].properties[e]);let s=g;window.$&&g instanceof window.$&&(s=g[0]),"block"==w.display&&(s.style.display="block");let a={};for(let e in t)Array.isArray(t[e])?(a[e]=t[e][1],t[e]=t[e][0],w.delay&&(s.style[e]=t[e][1])):a[e]=s.style[e];const r=Array.isArray(w.easing)?`cubic-bezier(${w.easing.join(",")})`:BMAnimationEasing[w.easing];let l;try{l=s.animate([a,t],{duration:w.duration*(window.BMAnimationMultiplier||1),easing:r||"linear",delay:w.delay&&w.delay*(window.BMAnimationMultiplier||1),composite:"replace",iterationComposite:"replace"})}catch(t){console.error("[BMCoreUI] This environment does not fully support web animations and use of this API will be disabled."),BM_WEB_ANIMATIONS_DISABLED=YES,p--;continue}let u=NO;l.finished&&(u=YES,l.finished.then((async()=>{for(let e in t)s.style[e]=t[e]}))),d.push(l);let y=new Promise(((e,i)=>{let o=NO;l.onfinish=function(){if(!o){if(o=YES,!u)for(let e in t)s.style[e]=t[e];"none"==w.display&&(s.style.display="none"),e()}},l.oncancel=function(){e()}}));c.push(y),w.progress&&c.push(h.animate(g,{tween:1},w))}else if(BM_USE_VELOCITY2)window.$&&g instanceof window.$?c.push(g[0].velocity(n[p].properties,w)):c.push(g.velocity(n[p].properties,w));else if(w.queue&&console.warn('Ignoring deprecated property "queue" for animation context.'),w.queue=!1,w.delay){const t=g,i=n[p].properties,o=w;Object.keys(i).length||(i.tween=[1,0]),c.push(new Promise((async n=>{const s=w.delay;w.delay=void 0;const a={node:t,properties:i,options:o,animationContext:e},r=(setTimeout((async()=>{const e=BMAnimationContext._pendingAnimations.get(g)||[],s=e?.indexOf(a)??-1;-1!=s&&e.splice(s,1),a?.length||BMAnimationContext._pendingAnimations.delete(g),BMAnimationContext._prepareAnimationForNode(t,{withProperties:i,options:o});const r=await h.animate(t,i,o);n(r)}),s),BMAnimationContext._pendingAnimations.get(g)||[]);r.push(a),BMAnimationContext._pendingAnimations.set(g,r)})))}else Object.keys(n[p].properties).length||(n[p].properties.tween=[1,0]),c.push(h.animate(g,n[p].properties,w))}if(window.Promise){let t=Promise.all(c);return t.then((function(){o.options.complete&&o.options.complete()})),t}}function BMAnimateWithBlock(t,e){BMAnimationBeginWithDuration(e.duration,e);return t(),e.blocking?BMAnimationApplyBlocking(YES):BMAnimationApply()}function BMRippleMakeWithElement(t,e){var i=e.forTarget;t[0].classList.add("BMRipple");var o=BMIsTouchDevice?"touchstart.ripple":"mousedown.ripple",n=BMIsTouchDevice?"touchend.ripple":"mouseup.ripple";i.on(o,(function(e){var o=i.outerWidth(),s=i.outerHeight(),a=(Math.max(o,s),Math.sqrt(Math.pow(o,2)+Math.pow(s,2))),r=i[0].getBoundingClientRect(),l=r.left,h=r.top;e.pageX=BMIsTouchDevice?e.originalEvent.touches[0].screenX:e.originalEvent.clientX,e.pageY=BMIsTouchDevice?e.originalEvent.touches[0].screenY:e.originalEvent.clientY,t.velocity("stop",!0).css({width:"0px",height:"0px",opacity:0}),BMHook(t,{translateX:e.pageX-l+"px",translateY:e.pageY-h+"px"}),t.velocity({translateX:(o-a)/2+"px",translateY:(s-a)/2+"px",width:a+"px",height:a+"px",opacity:1},{duration:400,easing:"ease-out",display:"block",queue:NO});let c=BMUUIDMake();$(window).on(n+c,(function(e){$(window).off(n+c),t.velocity({opacity:0},{duration:300,easing:"ease-in-out",display:"none",queue:NO})}))}))}function BMRippleMakeForTarget(t,e){var i=e&&e.withColor||"rgba(0, 0, 0, .1)";i=i.RGBAString||i;var o=$('<div style="position: absolute; display: block; top: 0px; left: 0px; border-radius: 50%;"></div>');return o.css({backgroundColor:i}),BMRippleMakeWithElement(o,{forTarget:t}),o}function BMIndexPath(){}BMAnimationContext._prepareAnimationForNode=function(t,{withProperties:e,options:i}){const o=window.Velocity||window.$?.Velocity;if(!o)return;const n=o.State.calls.filter((e=>e[1]?.[0]==t));for(const t of n)for(const i in e)"element"!=i&&"tween"!=i&&delete t[0]?.[0]?.[i]},BMIndexPath.prototype={object:void 0,indexes:void 0,initWithIndexPath(t){return this.object=t.object,this.indexes=t.indexes.slice(),this},get row(){return this.indexes[1]},set row(t){this.indexes[1]=t},get section(){return this.indexes[0]},set section(t){this.indexes[0]=t},copy:function(){var t=new BMIndexPath;return t.object=this.object,t.indexes=this.indexes.slice(),t},isEqualToIndexPath:function(t,e){if(!t||t==BMIndexPathNone)return NO;if(t.indexes.length!=this.indexes.length)return NO;for(var i=0;i<this.indexes.length;i++)if(this.indexes[i]!=t.indexes[i])return NO;return e.usingComparator(this.object,t.object)},isLooselyEqualToIndexPath:function(t,e){if(!t||t==BMIndexPathNone)return NO;if(void 0===t.object&&void 0===this.object){if(t.indexes.length!=this.indexes.length)return NO;for(var i=0;i<this.indexes.length;i++)if(this.indexes[i]!=t.indexes[i])return NO;return YES}return e.usingComparator(this.object,t.object)}};var BMIndexPathNone=BMIndexPathMakeWithRow(NaN,{section:NaN,forObject:NaN});function BMIndexPathMakeWithRow(t,e){var i=new BMIndexPath;return i.indexes=[e&&e.section||0,t],i.object=e&&e.forObject,i}function BMIndexPathMakeWithIndexes(t,e){var i=new BMIndexPath;return i.indexes=t,i.object=e?e.forObject:void 0,i}function BMKeyPath(){}function BMKeyPathMakeWithString(t){return(new BMKeyPath).initWithString(t)}function BMKeyPathMakeWithComponents(t){return(new BMKeyPath).initWithComponents(t)}function BMColor(){}function BMColorMake(){return BMColorMakeWithRed(0,{green:0,blue:0,alpha:0})}function BMColorMakeWithString(t){return t?_BMColorKeywords[t]?BMColorMakeWithHexString(_BMColorKeywords[t]):0==t.indexOf("#")?BMColorMakeWithHexString(t):0==t.indexOf("rgba")?BMColorMakeWithRGBAString(t):0==t.indexOf("rgb")?BMColorMakeWithRGBString(t):0==t.indexOf("hsla")?BMColorMakeWithHSLAString(t):0==t.indexOf("hsl")?BMColorMakeWithHSLString(t):void 0:BMColorMakeWithRed(0,{green:0,blue:0,alpha:0})}function BMColorMakeWithRed(t,e){var i=new BMColor;return i._storage=new _BMRGBAColor,i._storage._color=i,i._storage._red=BMNumberByConstrainingNumberToBounds(0|t,0,255),i._storage._green=BMNumberByConstrainingNumberToBounds(0|e.green,0,255),i._storage._blue=BMNumberByConstrainingNumberToBounds(0|e.blue,0,255),i._storage._alpha=BMNumberByConstrainingNumberToBounds("alpha"in e?e.alpha:1,0,1),i}function BMColorMakeWithHue(t,e){var i=new BMColor;return i._storage=new _BMHSLAColor,i._storage._color=i,i._storage._hue=BMNumberByConstrainingNumberToBounds(0|t,0,360),i._storage._saturation=BMNumberByConstrainingNumberToBounds(0|e.saturation,0,100),i._storage._lightness=BMNumberByConstrainingNumberToBounds(0|e.lightness,0,100),i._storage._alpha=BMNumberByConstrainingNumberToBounds("alpha"in e?e.alpha:1,0,1),i}function BMColorMakeWithHexString(t){var e=new BMColor;return e._storage=new _BMRGBAColor,e._storage._color=e,"#"==t.charAt(0)?(e._storage._red=parseInt(t.substring(1,3),16),e._storage._green=parseInt(t.substring(3,5),16),e._storage._blue=parseInt(t.substring(5,7),16)):(e._storage._red=parseInt(t.substring(0,2),16),e._storage._green=parseInt(t.substring(2,4),16),e._storage._blue=parseInt(t.substring(4,6),16)),e}function BMColorMakeWithRGBAString(t){var e=new BMColor;e._storage=new _BMRGBAColor,e._storage._color=e;var i=t.split(",");return e._storage.red=parseInt(i[0].substring(5),10),e._storage.green=parseInt(i[1],10),e._storage.blue=parseInt(i[2],10),e._storage.alpha=parseFloat(i[3]),e}function BMColorMakeWithRGBString(t){var e=new BMColor;e._storage=new _BMRGBAColor,e._storage._color=e;var i=t.split(",");return e._storage.red=parseInt(i[0].substring(4),10),e._storage.green=parseInt(i[1],10),e._storage.blue=parseInt(i[2],10),e}function BMColorMakeWithHSLAString(t){var e=new BMColor;e._storage=new _BMHSLAColor,e._storage._color=e;var i=t.split(",");return e._storage.hue=parseInt(i[0].substring(5),10),e._storage.saturation=parseInt(i[1],10),e._storage.luminosity=parseInt(i[2],10),e._storage.alpha=parseFloat(i[3]),e}function BMColorMakeWithHSLString(t){var e=new BMColor;e._storage=new _BMHSLAColor,e._storage._color=e;var i=t.split(",");return e._storage.hue=parseInt(i[0].substring(4),10),e._storage.saturation=parseInt(i[1],10),e._storage.luminosity=parseInt(i[2],10),e}function BMColorByInterpolatingRGBAColor(t,e){var i=e.toColor,o=e.withFraction;return BMColorMakeWithRed(BMNumberByInterpolatingNumbersWithFraction(t.red,i.red,o),{green:BMNumberByInterpolatingNumbersWithFraction(t.green,i.green,o),blue:BMNumberByInterpolatingNumbersWithFraction(t.blue,i.blue,o),alpha:BMNumberByInterpolatingNumbersWithFraction(t.alpha,i.alpha,o)})}function BMColorByInterpolatingHSLAColor(t,e){var i=e.toColor,o=e.withFraction;return BMColorMakeWithHue(BMNumberByInterpolatingNumbersWithFraction(t.hue,i.hue,o),{saturation:BMNumberByInterpolatingNumbersWithFraction(t.saturation,i.saturation,o),luminosity:BMNumberByInterpolatingNumbersWithFraction(t.luminosity,i.luminosity,o),alpha:BMNumberByInterpolatingNumbersWithFraction(t.alpha,i.alpha,o)})}function BMHexStringWithNumber(t,e){for(var i=t.toString(16),o=e&&e.minDigits||0;i.length<o;)i="0"+i;return i}function _BMRGBAColor(){}function _BMHSLAColor(){}function _BMHueToRGB(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}BMIndexPathNone.section=NaN,BMIndexPathNone.isEqualToIndexPath=function(){return NO},BMIndexPathNone.isLooselyEqualToIndexPath=function(){return NO},BMKeyPath.prototype={_components:void 0,get components(){return this._components.slice()},initWithString:function(t){this._components=t.split(".")},initWithComponents:function(t){this._components=t.slice()},valueForObject:function(t,e){for(var i=t,o=Math.min(this._components.length,e&&e.withLimit||this._components.length),n=0;n<o;n++)if(void 0===(i=i[this._components[n]]))return;return i}},BMColor.prototype={_storage:void 0,get red(){return this._storage.red},set red(t){this._storage.red=t},get green(){return this._storage.green},set green(t){this._storage.green=t},get blue(){return this._storage.blue},set blue(t){this._storage.blue=t},get alpha(){return this._storage.alpha},set alpha(t){this._storage.alpha=t},get hue(){return this._storage.hue},set hue(t){this._storage.hue=t},get saturation(){return this._storage.saturation},set saturation(t){this._storage.saturation=t},get luminosity(){return this._storage.luminosity},set luminosity(t){this._storage.luminosity=t},get RGBAString(){return this._storage.RGBAString},get RGBString(){return this._storage.RGBString},get hexString(){return this._storage.hexString},get HSLAString(){return this._storage.HSLAString},get HSLString(){return this._storage.HSLString},copy:function(){var t=new BMColor;return t._storage=this._storage.copy(),t},interpolatedValueWithFraction(t,e){return BMColorByInterpolatingRGBAColor(this,{toColor:e.toValue,withFraction:t})}},_BMRGBAColor.prototype={_color:void 0,_red:0,get red(){return this._red},set red(t){this._red=BMNumberByConstrainingNumberToBounds(0|t,0,255)},_green:0,get green(){return this._green},set green(t){this._green=BMNumberByConstrainingNumberToBounds(0|t,0,255)},_blue:0,get blue(){return this._blue},set blue(t){this._blue=BMNumberByConstrainingNumberToBounds(0|t,0,255)},_alpha:1,get alpha(){return this._alpha},set alpha(t){this._alpha=BMNumberByConstrainingNumberToBounds(t,0,1)},get hue(){return this.BMHSLAColor.hue},set hue(t){var e=this.BMHSLAColor;this._color._storage=e,e.hue=t},get saturation(){return this.BMHSLAColor.saturation},set saturation(t){var e=this.BMHSLAColor;this._color._storage=e,e.saturation=t},get luminosity(){return this.BMHSLAColor.luminosity},set luminosity(t){var e=this.BMHSLAColor;this._color._storage=e,e.luminosity=t},get BMHSLAColor(){var t=new _BMHSLAColor,e=this._red/255,i=this._green/255,o=this._blue/255,n=Math.max(e,i,o),s=Math.min(e,i,o),a=(n+s)/2;if(t._luminosity=100*a|0,n==s)t._saturation=0,t._hue=0;else{var r,l=n-s,h=a>.5?l/(2-n-s):l/(n+s);switch(n){case e:r=(i-o)/l+(i<o?6:0);break;case i:r=(o-e)/l+2;break;case o:r=(e-i)/l+4}r/=6,t._saturation=100*h|0,t._hue=360*r|0}return t._alpha=this._alpha,t},get RGBAString(){return"rgba("+this._red+","+this._green+","+this._blue+","+this._alpha+")"},get RGBString(){return"rgb("+this._red+","+this._green+","+this._blue+")"},get hexString(){return"#"+BMHexStringWithNumber(this._red,{minDigits:2})+BMHexStringWithNumber(this._green,{minDigits:2})+BMHexStringWithNumber(this._blue,{minDigits:2})},get HSLAString(){return this.BMHSLAColor.HSLAString},get HSLString(){return this.BMHSLAColor.HSLString},copy:function(){var t=new _BMRGBAColor;return t._red=this._red,t._green=this._green,t._blue=this._blue,t._alpha=this._alpha,t}},_BMHSLAColor.prototype={_color:void 0,get red(){return this.BMRGBAColor.red},set red(t){var e=this.BMRGBAColor;this._color._storage=e,e.red=t},get green(){return this.BMRGBAColor.green},set green(t){var e=this.BMRGBAColor;this._color._storage=e,e.green=t},get blue(){return this.BMRGBAColor.blue},set blue(t){var e=this.BMRGBAColor;this._color._storage=e,e.blue=t},_alpha:1,get alpha(){return this._alpha},set alpha(t){this._alpha=BMNumberByConstrainingNumberToBounds(t,0,1)},_hue:0,get hue(){return this._hue},set hue(t){this._hue=BMNumberByConstrainingNumberToBounds(0|t,0,360)},_saturation:0,get saturation(){return this._saturation},set saturation(t){this._saturation=BMNumberByConstrainingNumberToBounds(0|t,0,100)},_luminosity:0,get luminosity(){return this._luminosity},set luminosity(t){this._luminosity=BMNumberByConstrainingNumberToBounds(0|t,0,100)},get BMRGBAColor(){var t=new _BMRGBAColor;if(0==this._saturation)t._red=t._green=t._blue=this._luminosity/100*255|0;else{var e=this._hue/360,i=this._luminosity/100,o=this._saturation/100,n=i<.5?i*(1+o):i+o-i*o,s=2*i-n;t._red=255*_BMHueToRGB(s,n,e+1/3)|0,t._green=255*_BMHueToRGB(s,n,e)|0,t._blue=255*_BMHueToRGB(s,n,e-1/3)|0}return t._alpha=this._alpha,t},get RGBAString(){return this.BMRGBAColor.RGBAString},get RGBString(){return this.BMRGBAColor.RGBString},get hexString(){return this.BMRGBAColor.hexString},get HSLAString(){return"hsl("+this._hue+","+this._saturation+"%,"+this._luminosity+"%,"+this._alpha+")"},get HSLString(){return"hsl("+this._hue+","+this._saturation+"%,"+this._luminosity+"%)"},copy:function(){var t=new _BMRGBAColor;return t._hue=this._hue,t._saturation=this._saturation,t._luminosity=this._luminosity,t._alpha=this._alpha,t}};var _BMColorKeywords={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},BMLayoutDimensionClass=Object.freeze({Compact:"C",Regular:"R",Extended:"E",Any:"_"});function BMLayoutDimensionClassForSize(t){return t?t<600?BMLayoutDimensionClass.Compact:t<=1024?BMLayoutDimensionClass.Regular:BMLayoutDimensionClass.Extended:BMLayoutDimensionClass.Extended}function BMSizeForLayoutDimensionClass(t){return t==BMLayoutDimensionClass.Compact?600:t==BMLayoutDimensionClass.Regular?1024:0}var BMLayoutSizeClassDeviceKind=Object.freeze({Phone:"S",Tablet:"T",Extended:"_"}),BMLayoutOrientation=Object.freeze({Portrait:"P",Landscape:"L",Any:"_"});function BMLayoutSizeClass(){}BMLayoutSizeClass.prototype={_widthSizeClass:BMLayoutSizeClass.Extended,get widthSizeClass(){return this._widthSizeClass},_maximumWidth:0,get maximumWidth(){return this._maximumWidth},_heightSizeClass:BMLayoutSizeClass.Extended,get heightSizeClass(){return this._heightSizeClass},_maximumHeight:0,get maximumHeight(){return this._maximumHeight},_orientation:BMLayoutOrientation.Any,get orientation(){return this._orientation},_deviceKind:BMLayoutSizeClassDeviceKind.Extended,get deviceType(){return this._deviceKind},_maximumDiagonal:0,get maximumDiagonal(){return this._maximumDiagonal},_priority:0,get priority(){return this._priority},_hashString:void 0,_createHashString(){let t=[];this._maximumWidth&&t.push("w"+this._maximumWidth.toFixed()),this._maximumHeight&&t.push("h"+this._maximumWidth.toFixed()),this._maximumDiagonal&&t.push("d"+this._maximumDiagonal.toFixed()),this._orientation!=BMLayoutOrientation.Any&&t.push(this._orientation),this._hashString=t.join(" ")},isEqualToSizeClass(t){return t?this._hashString==t._hashString:NO},toString(){return this._hashString}};var _BMActiveLayoutSizeClasses=new Map;function BMViewport(){}BMLayoutSizeClass.layoutSizeClassWithMaximumWidth=function(t,e){let i=new BMLayoutSizeClass;i._widthSizeClass=BMLayoutDimensionClassForSize(t),i._maximumWidth=t,i._heightSizeClass=BMLayoutDimensionClassForSize(e.maximumHeight),i._maximumHeight=e.maximumHeight,i._orientation=e.orientation||BMLayoutOrientation.Any,i._maximumDiagonal=e.maximumDiagonal||0;let o=0;return i._maximumWidth&&(o+=10),i._maximumHeight&&(o+=10),e.orientation!==BMLayoutOrientation.Any&&(o+=1),i._priority=o,i._createHashString(),_BMActiveLayoutSizeClasses[i._hashString]?_BMActiveLayoutSizeClasses[i._hashString]:(_BMActiveLayoutSizeClasses[i._hashString]=i,i)},BMLayoutSizeClass.layoutSizeClassWithWidthClass=function(t,e){let i=new BMLayoutSizeClass;i._widthSizeClass=t,i._maximumWidth=BMSizeForLayoutDimensionClass(t),i._heightSizeClass=e.heightSizeClass,i._maximumHeight=BMSizeForLayoutDimensionClass(e.heightSizeClass),i._orientation=e.orientation||BMLayoutOrientation.Any,i._maximumDiagonal=0;let o=0;return i._maximumWidth&&(o+=10),i._maximumHeight&&(o+=10),e.orientation!==BMLayoutOrientation.Any&&(o+=1),i._priority=o,i._createHashString(),_BMActiveLayoutSizeClasses[i._hashString]?_BMActiveLayoutSizeClasses[i._hashString]:(_BMActiveLayoutSizeClasses[i._hashString]=i,i)},BMLayoutSizeClass.phoneSizeClass=function(){return this.phoneSizeClassWithOrientation(BMLayoutOrientation.Any)},BMLayoutSizeClass.phoneSizeClassWithOrientation=function(t){let e=new BMLayoutSizeClass;return e._maximumDiagonal=1e3,e._orientation=t||BMLayoutOrientation.Any,e._createHashString(),_BMActiveLayoutSizeClasses[e._hashString]?_BMActiveLayoutSizeClasses[e._hashString]:(_BMActiveLayoutSizeClasses[e._hashString]=e,e)},BMLayoutSizeClass.tabletSizeClass=function(){return this.tabletSizeClassWithOrientation(BMLayoutOrientation.Any)},BMLayoutSizeClass.tabletSizeClassWithOrientation=function(t){let e=new BMLayoutSizeClass;return e._maximumDiagonal=1450,e._orientation=t||BMLayoutOrientation.Any,e._createHashString(),_BMActiveLayoutSizeClasses[e._hashString]?_BMActiveLayoutSizeClasses[e._hashString]:(_BMActiveLayoutSizeClasses[e._hashString]=e,e)},BMLayoutSizeClass._layoutSizeClassForHashString=function(t){if(_BMActiveLayoutSizeClasses[t])return _BMActiveLayoutSizeClasses[t];let e=t.split(" "),i=new BMLayoutSizeClass;i._hashString=t;for(let t of e){switch(t.charAt(0)){case"w":i._maximumWidth=parseInt(t.substring(1,t.length)),i._widthSizeClass=BMLayoutDimensionClassForSize(i._maximumWidth);break;case"h":i._maximumHeight=parseInt(t.substring(1,t.length)),i._heightSizeClass=BMLayoutDimensionClassForSize(i._maximumHeight);break;case"d":i._maximumDiagonal=parseInt(t.substring(1,t.length));break;case"P":i._orientation=BMLayoutOrientation.Portrait;break;case"L":i._orientation=BMLayoutOrientation.Landscape;break;case"p":i._priority=parseInt(t.substring(1,t.length))}}return _BMActiveLayoutSizeClasses[i._hashString]=i,i},BMViewport.prototype={_width:void 0,get width(){return this._width},_height:void 0,get height(){return this._height},_orientation:void 0,get orientation(){return this._orientation},_diagonal:void 0,get diagonal(){return this._diagonal},_smallestDimension:void 0,get smallestDimension(){return this._smallestDimension},_surfaceArea:void 0,get surfaceArea(){return this._surfaceArea},_measurements:void 0,init(){this._measurements={}},_measureCompatibilityWithSizeClass(t){let e={},i=YES;if(t._maximumWidth&&this._width>t._maximumWidth&&(i=NO),t._maximumHeight&&this._height>t._maximumHeight&&(i=NO),t._maximumDiagonal&&this._diagonal>t._maximumDiagonal&&(i=NO),t._maximumSurfaceArea&&this._surfaceArea>t._maximumSurfaceArea&&(i=NO),t._orientation!=BMLayoutOrientation.Any&&this._orientation!=t._orientation&&(i=NO),e.matches=i,i){let i=[];t._maximumWidth&&i.push(t._maximumWidth/this._width),t._maximumHeight&&i.push(t._maximumHeight/this._height),t._maximumDiagonal&&i.push(t._maximumDiagonal/this._diagonal),t._maximumSurfaceArea&&i.push(t._maximumSurfaceArea/this._surfaceArea),i.length?e.matchPriority=i.reduce(((t,e)=>t+e))/i.length:e.matchPriority=2}else e.matchPriority=0;this._measurements[t._hashString]=e},matchesSizeClass(t){return this._measurements[t._hashString]||this._measureCompatibilityWithSizeClass(t),this._measurements[t._hashString].matches},matchPriorityForSizeClass(t){return this._measurements[t._hashString]||this._measureCompatibilityWithSizeClass(t),this._measurements[t._hashString].matchPriority},isEqualToViewport(t){return this._width==t._width&&this._height==t._height}},BMViewport.currentViewport=function(){let t=new BMViewport;return t.init(),t._width=window.innerWidth,t._height=window.innerHeight,t._diagonal=Math.sqrt(Math.pow(window.innerWidth,2)+Math.pow(window.innerHeight,2)),t._orientation=t._width>=t._height?BMLayoutOrientation.Landscape:BMLayoutOrientation.Portrait,t._surfaceArea=window.innerWidth*window.innerHeight,t};var BMLayoutAttribute=Object.freeze({Leading:"Leading",Trailing:"Trailing",Left:"Left",Right:"Right",Top:"Top",Bottom:"Bottom",CenterX:"CenterX",CenterY:"CenterY",Width:"Width",Height:"Height",AspectRatio:"AspectRatio"}),BMLayoutConstraintRelation=Object.freeze({Equals:kiwi.Operator.Eq,LessThanOrEquals:kiwi.Operator.Le,GreaterThanOrEquals:kiwi.Operator.Ge}),BMLayoutConstraintKind=Object.freeze({Horizontal:"BMLayoutConstraintKindHorizontal",Vertical:"BMLayoutConstraintKindVertical",AspectRatio:"BMLayoutConstraintKindAspectRatio"});const _BMLayoutConstraintClasses={BMLayoutConstraint:BMLayoutConstraint,BMEqualAttributeLayoutConstraint:BMEqualAttributeLayoutConstraint,BMEqualSpacingLayoutConstraint:BMEqualSpacingLayoutConstraint};function BMLayoutConstraint(){}var BMLayoutConstraintPriorityRequired=1e3;function BMEqualAttributeLayoutConstraint(){}function BMEqualSpacingLayoutConstraint(){}BMLayoutConstraint.internalConstraintWithView=function(t,e){return e._internal=YES,BMLayoutConstraint.constraintWithView(t,e)},BMLayoutConstraint.constraintWithView=function(t,e){var i=new BMLayoutConstraint;return i._identifier=BMUUIDMake(),i._sourceView=t,i._sourceViewAttribute=e.attribute,i._relation=void 0===e.relatedBy?BMLayoutConstraintRelation.Equals:e.relatedBy,i._targetView=e.toView,i._targetViewAttribute=e.secondAttribute,i._multiplier=isNaN(e.multiplier)?1:e.multiplier,i._constant=e.constant||0,e.priority?i._priority=e.priority:i._priority=BMLayoutConstraintPriorityRequired,e.attribute===BMLayoutAttribute.AspectRatio?i._kind=BMLayoutConstraintKind.AspectRatio:e.attribute===BMLayoutAttribute.Top||e.attribute==BMLayoutAttribute.Bottom||e.attribute===BMLayoutAttribute.Height||e.attribute===BMLayoutAttribute.CenterY?i._kind=BMLayoutConstraintKind.Vertical:i._kind=BMLayoutConstraintKind.Horizontal,i._variations={},i._configuration={constant:i._constant,priority:i._priority,isActive:i._isActive},"string"==typeof i._constant?i._configuration.constantValue=t.rootView.valueForLayoutVariable(i._constant):i._configuration.constantValue=i._constant,e._internal?i._internal=YES:i._install(),i},BMLayoutConstraint.constraintWithSerializedConstraint=function(t,e){return Object.create(_BMLayoutConstraintClasses[t._class||"BMLayoutConstraint"].prototype).initWithSerializedConstraint(t,e)},BMLayoutConstraint.prototype={_identifier:void 0,get identifier(){return this._identifier},set identifier(t){this._identifier=t},_solver:void 0,_constraint:void 0,initWithSerializedConstraint(t,e){if(this._sourceViewAttribute=t._sourceViewAttribute,this._relation=t._relation,this._targetViewAttribute=t._targetViewAttribute,this._multiplier=t._multiplier,this._constant=t._constant,this._kind=t._kind,this._priority=t._priority,this._sourceView=e.viewIDs(t._sourceView),this._identifier=t._identifier||BMUUIDMake(),this._isActive=void 0===t._isActive?YES:t._isActive,this._sourceView&&(!t._targetView||(this._targetView=e.viewIDs(t._targetView),this._targetView))){this._variations=t._variations||{};for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t);return this._configuration={constant:t._constant,priority:t._priority,isActive:t._isActive},this._updateConfiguration(),this._install(),this}},affectedAttributesForView(t){return t==this._sourceView?[this._sourceViewAttribute]:t==this._targetView?[this._targetViewAttribute]:[]},get isConstraintCollection(){return NO},get constituentConstraints(){return[this]},get _hasEditableConstant(){return YES},_sourceView:void 0,_sourceViewAttribute:void 0,_targetView:void 0,_targetViewAttribute:void 0,_multiplier:1,_configuration:void 0,activeSizeClassesDidChange(t){this._updateConfiguration()},layoutVariablesDidChange(){"string"==typeof this._configuration.constant&&this._updateConfiguration()},_updateConfiguration(){return this._updateConfigurationSilently(NO)},_updateConfigurationSilently(t){let e={constant:this._constant,priority:this._priority,isActive:this._isActive},i=(this._sourceView||this._views[0]).viewport;for(let t in this._variations)this._variations[t]._matchPriority=i.matchPriorityForSizeClass(this._variations[t].sizeClass);Object.keys(this._variations).map((t=>this._variations[t])).sort(((t,e)=>e._matchPriority-t._matchPriority)).forEach((t=>{t._matchPriority&&("constant"in t&&(e.constant=t.constant),"priority"in t&&(e.priority=t.priority),"isActive"in t&&(e.isActive=t.isActive))}));let o=NO;"string"==typeof e.constant?e.constantValue=this._sourceView.valueForLayoutVariable(e.constant):e.constantValue=e.constant;let n=this._configuration||e;if(this._configuration=e,this._reversesConstant&&(e.constantValue=-e.constantValue),this.isConstraintCollection)for(let t of this.constituentConstraints)t._updateConfiguration();else if(!t&&(n.isActive!=e.isActive&&(this._sourceView.needsLayout=YES,this._sourceView.rootView._invalidatedConstraints=YES,this._sourceView._checkConstraints(),this._targetView&&this._targetView._checkConstraints(),o=YES),n.priority!=e.priority&&(this._sourceView.needsLayout=YES,this._sourceView.rootView._invalidatedConstraints=YES,o=YES),n.constantValue!=e.constantValue&&!o)){if(o=YES,this._solver){if(this._constraint){try{this._solver.hasConstraint(this._constraint)&&this._solver.removeConstraint(this._constraint)}catch(t){this._cassowaryConstraint=void 0,this._sourceView.rootView._invalidatedConstraints=YES,this._sourceView.needsLayout=YES}this._constraint=void 0}try{this._solver.addConstraint(this._cassowaryConstraint)}catch(t){this._cassowaryConstraint=void 0,this._sourceView.rootView._invalidatedConstraints=YES,this._sourceView.needsLayout=YES}}e.isActive&&(this._sourceView.needsLayout=YES)}},get _activeConfiguration(){let t={constant:this._constant,priority:this._priority,isActive:this._isActive},e=this._sourceView.sizeClass,i=[];for(let t in this._variations){this._variations[t].sizeClass.matchesSizeClass(e)&&i.push(this._variations[t])}return i.sort(((t,e)=>e.sizeClass._priority-t.sizeClass._priority)).forEach((e=>{BMCopyProperties(t,e)})),t},_constant:0,get constant(){return this._constant},set constant(t){if(t!=this._constant)return this._constant=t,this._updateConfiguration()},setConstant(t,e){this._variations[e.forSizeClass._hashString]||(this._variations[e.forSizeClass._hashString]={sizeClass:e.forSizeClass},this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),this._variations[e.forSizeClass._hashString].constant=t,(this._sourceView||this._views[0]).viewport.matchesSizeClass(e.forSizeClass)&&this._updateConfiguration()},removeConstantVariationForSizeClass(t){this._variations[t._hashString]&&(delete this._variations[t._hashString].constant,1==Object.keys(this._variations[t._hashString]).length&&(delete this._variations[t._hashString],this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),(this._sourceView||this._views[0]).viewport.matchesSizeClass(t)&&this._updateConfiguration())},hasConstantVariationForSizeClass(t){return this._variations[t._hashString]?"constant"in this._variations[t._hashString]:NO},get activeConstant(){return this._configuration.constant},_priority:BMLayoutConstraintPriorityRequired,get priority(){return this._priority},set priority(t){if(this._priority!=t)return this._priority=t,this._updateConfiguration()},setPriority(t,e){this._variations[e.forSizeClass._hashString]||(this._variations[e.forSizeClass._hashString]={sizeClass:e.forSizeClass},this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),this._variations[e.forSizeClass._hashString].priority=t,(this._sourceView||this._views[0]).viewport.matchesSizeClass(e.forSizeClass)&&this._updateConfiguration()},removePriorityVariationForSizeClass(t){this._variations[t._hashString]&&(delete this._variations[t._hashString].priority,1==Object.keys(this._variations[t._hashString]).length&&(delete this._variations[t._hashString],this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),(this._sourceView||this._views[0]).viewport.matchesSizeClass(t)&&this._updateConfiguration())},hasPriorityVariationForSizeClass(t){return this._variations[t._hashString]?"priority"in this._variations[t._hashString]:NO},get activePriority(){return this._configuration.priority},_relation:BMLayoutConstraintRelation.Equals,_kind:void 0,get categoryKind(){return this._kind==BMLayoutConstraintKind.Vertical?this._sourceViewAttribute==BMLayoutAttribute.Height?"Height":"Vertical Position":this._sourceViewAttribute==BMLayoutAttribute.Width?"Width":"Horizontal Position"},_isActive:NO,get isActive(){return this._isActive},set isActive(t){if(t!=this._isActive)return this._isActive=t,this._updateConfiguration()},setIsActive(t,e){this._variations[e.forSizeClass._hashString]||(this._variations[e.forSizeClass._hashString]={sizeClass:e.forSizeClass},this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),this._variations[e.forSizeClass._hashString].isActive=t,(this._sourceView||this._views[0]).viewport.matchesSizeClass(e.forSizeClass)&&this._updateConfiguration()},removeIsActiveVariationForSizeClass(t){this._variations[t._hashString]&&(delete this._variations[t._hashString].isActive,1==Object.keys(this._variations[t._hashString]).length&&(delete this._variations[t._hashString],this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),(this._sourceView||this._views[0]).viewport.matchesSizeClass(t)&&this._updateConfiguration())},hasIsActiveVariationForSizeClass(t){return this._variations[t._hashString]?"isActive"in this._variations[t._hashString]:NO},get affectsLayout(){return this._configuration.isActive},_install(){this._sourceView._addConstraint(this),this._targetView&&this._targetView._addConstraint(this),this._sourceView.rootView._invalidatedConstraints=YES},remove(){this._isActive&&(this._sourceView.needsLayout=YES),this._isActive=NO,this._sourceView._removeConstraint(this),this._sourceView.rootView._invalidatedConstraints=YES,this._targetView&&(this._targetView.needsLayout=YES,this._targetView._removeConstraint(this),this._sourceView.rootView._invalidatedConstraints=YES),this._sourceView=void 0,this._targetView=void 0},get _cassowaryExpression(){let t=this._configuration.constantValue||0;if(this._targetView){if(this._sourceViewAttribute==BMLayoutAttribute.AspectRatio){if(this._targetViewAttribute!=BMLayoutAttribute.AspectRatio)throw new Error("[BMCoreUI] Aspect ratio constraints must affect both views' aspect ratio.");throw new Error("[BMCoreUI] Non-constant aspect ratio constraint are currently not supported.")}var e=new kiwi.Expression(this._sourceView._cassowaryExpressionForLayoutAttribute(this._sourceViewAttribute)).minus(this._targetView._cassowaryExpressionForLayoutAttribute(this._targetViewAttribute,{withMultiplier:this._multiplier}));return t&&(e=this._sourceView.LTRLayout||this._kind!=BMLayoutConstraintKind.Horizontal||this._sourceViewAttribute==BMLayoutAttribute.Width?e.minus(t):e.plus(t)),e}return this._sourceViewAttribute==BMLayoutAttribute.AspectRatio?new kiwi.Expression([t,this._sourceView._variables[BMLayoutAttribute.Height]],[-1,this._sourceView._variables[BMLayoutAttribute.Width]]):t?this._sourceView._cassowaryExpressionForLayoutAttribute(this._sourceViewAttribute).plus(-t):this._sourceView._cassowaryExpressionForLayoutAttribute(this._sourceViewAttribute)},get _cassowaryConstraint(){if(this._constraint)return this._constraint;var t=this._cassowaryExpression,e=this._configuration.priority==BMLayoutConstraintPriorityRequired?kiwi.Strength.required:this._configuration.priority/1e3*kiwi.Strength.required;let i=this._relation;return this._sourceView.LTRLayout||this._kind!=BMLayoutConstraintKind.Horizontal||this._sourceViewAttribute==BMLayoutAttribute.Width||(this._relation==BMLayoutConstraintRelation.GreaterThanOrEquals?i=BMLayoutConstraintRelation.LessThanOrEquals:this._relation==BMLayoutConstraintRelation.LessThanOrEquals&&(i=BMLayoutConstraintRelation.GreaterThanOrEquals)),this._constraint=new kiwi.Constraint(t,i,void 0,e),this._constraint},_variations:void 0,get _serializedVariations(){let t={};return this._variations&&Object.keys(this._variations).forEach((e=>{t[e]={},Object.keys(this._variations[e]).forEach((i=>{"sizeClass"!=i&&(t[e][i]=this._variations[e][i])}))})),t},toString(){let t={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≥",[BMLayoutConstraintRelation.LessThanOrEquals]:"≤"};if(this._targetView){let e=this._configuration.constant?`${this._configuration.constant<0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"";return`${this._sourceView.debuggingName||this._sourceView.node.id}.${this._sourceViewAttribute} ${t[this._relation]} \t\t\t${1!=this._multiplier?this._multiplier+"* ":""}${this._targetView.debuggingName||this._targetView.node.id}.${this._targetViewAttribute} \t\t\t${e}`}return`${this._sourceView.debuggingName||this._sourceView.node.id}.${this._sourceViewAttribute} ${t[this._relation]} ${this._configuration.constant} (${this._configuration.priority})`},toCompactString(){let t={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≥",[BMLayoutConstraintRelation.LessThanOrEquals]:"≤"},e=this._sourceViewAttribute.charAt(0);if(this._sourceViewAttribute==BMLayoutAttribute.Left&&(e="Lf"),this._targetView){let i=this._targetViewAttribute.charAt(0);this._targetViewAttribute==BMLayoutAttribute.Left&&(i="Lf");let o=this._configuration.constant?`${this._configuration.constant<0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"";return`${this._sourceView.debuggingName||this._sourceView.node.id}.${e} ${t[this._relation]} \t\t\t${1!=this._multiplier?this._multiplier+"* ":""}${this._targetView.debuggingName||this._targetView.node.id}.${i} \t\t\t${o}`}return`${this._sourceView.debuggingName||this._sourceView.node.id}.${e} ${t[this._relation]} ${this._configuration.constant}`},descriptionRelativeToView(t){let e={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≥",[BMLayoutConstraintRelation.LessThanOrEquals]:"≤"};if(this._sourceView!==t&&this._targetView!==t)return this.toString();if(this._targetView){this._configuration.constant&&(this._configuration.constant,this._configuration.constant<0?this._configuration.constant:this._configuration.constant);if(this._sourceView===t){const t=this._configuration.constant?`${this._configuration.constant<0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"";return`${this._sourceViewAttribute} ${e[this._relation]} \t\t\t\t\t\t${1!=this._multiplier?this._multiplier+"* ":""}${this._targetView.debuggingName||this._targetView.node.id}.${this._targetViewAttribute} \t\t\t\t\t\t${t}`}{const t=this._configuration.constant?`${this._configuration.constant>0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"",e={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≤",[BMLayoutConstraintRelation.LessThanOrEquals]:"≥"};return`${this._targetViewAttribute} ${e[this._relation]} \t\t\t\t\t\t${1!=this._multiplier?"(":""}${this._sourceView.debuggingName||this._sourceView.node.id}.${this._sourceViewAttribute} \t\t\t\t\t\t${t}${1!=this._multiplier?") / "+this._multiplier:""}`}}return`${this._sourceViewAttribute} ${e[this._relation]} ${this._configuration.constant}`},serializedConstraintWithViewIDs(t){return{_class:"BMLayoutConstraint",_sourceViewAttribute:this._sourceViewAttribute,_relation:this._relation,_targetViewAttribute:this._targetViewAttribute,_constant:this._constant,_multiplier:this._multiplier,_priority:this._priority,_sourceView:t(this._sourceView),_targetView:this._targetView?t(this._targetView):void 0,_kind:this._kind,_identifier:this._identifier,_variations:this._serializedVariations,_isActive:this._isActive}}},BMEqualAttributeLayoutConstraint.constraintWithAttribute=function(t,e){let i=new BMEqualAttributeLayoutConstraint;return i._identifier=BMUUIDMake(),i._views=e.forViews.slice(),i._attribute=t,i._priority=e.priority||BMLayoutConstraintPriorityRequired,t===BMLayoutAttribute.Top||t==BMLayoutAttribute.Bottom||t===BMLayoutAttribute.Height||t===BMLayoutAttribute.CenterY?i._kind=BMLayoutConstraintKind.Vertical:i._kind=BMLayoutConstraintKind.Horizontal,i._variations={},i._configuration={constant:i._constant,priority:i._priority,isActive:i._isActive},e._internal?i._internal=YES:i._install(),i},BMEqualAttributeLayoutConstraint.prototype=BMExtend({},BMLayoutConstraint.prototype,{initWithSerializedConstraint(t,e){this._views=t._views.map((t=>e.viewIDs(t)));for(var i=0;i<this._views.length;i++)if(!this._views[i])return;this._attribute=t._attribute,this._kind=t._kind,this._priority=t._priority,this._identifier=t._identifier||BMUUIDMake(),this._isActive=void 0===t._isActive?YES:t._isActive,this._variations=t._variations||{};for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t);return this._updateConfiguration(),this._install(),this},_views:void 0,_attribute:void 0,affectedAttributesForView(t){return-1!=this._views.indexOf(t)?[this._attribute]:[]},get isConstraintCollection(){return YES},_constituentConstraints:void 0,get constituentConstraints(){if(this._constituentConstraints)return this._constituentConstraints;let t,e=[];for(let i=1;i<this._views.length;i++)e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[i-1],{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._views[i],secondAttribute:this._attribute,constant:0,multiplier:1,priority:this._priority})),t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES);return this._constituentConstraints=e,e},get constant(){return this._constant},set constant(t){if(t!=this._constant)return this._constant=t,this._updateConfiguration()},get _hasEditableConstant(){return NO},get categoryKind(){return this._kind==BMLayoutConstraintKind.Vertical?this._attribute==BMLayoutAttribute.Height?"Height":"Vertical Position":this._attribute==BMLayoutAttribute.Width?"Width":"Horizontal Position"},_isActive:NO,get isActive(){return this._isActive},set isActive(t){if(t!=this._isActive)return this._isActive=t,this._updateConfiguration()},_install(){this._views.forEach((t=>t._addConstraint(this))),this._views[0].rootView._invalidatedConstraints=YES},remove(){this._isActive&&(this._isActive=NO),this._views.forEach((t=>{t._removeConstraint(this),t._checkConstraints(),t.needsLayout=YES})),this._views[0].rootView._invalidatedConstraints=YES,this._views=void 0},toString(){return"Equal "+this._attribute},toCompactString(){return"Equal "+this._attribute},serializedConstraintWithViewIDs(t){return{_class:"BMEqualAttributeLayoutConstraint",_attribute:this._attribute,_priority:this._priority,_views:this._views.map((e=>t(e))),_kind:this._kind,_identifier:this._identifier,_variations:this._serializedVariations,_isActive:this._isActive}}}),BMEqualSpacingLayoutConstraint.constraintOfKind=function(t,e){let i=new BMEqualSpacingLayoutConstraint;if(i._views=e.forViews.slice(),i._kind=t,i._priority=e.priority||BMLayoutConstraintPriorityRequired,i._constant=e.constant||0,i._identifier=BMUUIDMake(),e.withSuperview){i._withSuperview=e.withSuperview;let t=e.forViews[0].superview;e.forViews.forEach((e=>{if(e.superview!=t)throw new Error("The views must have the same superview.")})),i._superview=t}return t==BMLayoutConstraintKind.Horizontal?(i._firstAttribute=BMLayoutAttribute.Leading,i._secondAttribute=BMLayoutAttribute.Trailing):(i._firstAttribute=BMLayoutAttribute.Top,i._secondAttribute=BMLayoutAttribute.Bottom),i._variations={},i._configuration={constant:i._constant,priority:i._priority,isActive:i._isActive},"string"==typeof i._constant?i._configuration.constantValue=e.forViews[0].rootView.valueForLayoutVariable(i._constant):i._configuration.constantValue=i._constant,e._internal?i._internal=YES:i._install(),i},BMEqualSpacingLayoutConstraint.prototype=BMExtend({},BMLayoutConstraint.prototype,{initWithSerializedConstraint(t,e){this._views=t._views.map((t=>e.viewIDs(t)));for(var i=0;i<this._views.length;i++)if(!this._views[i])return;if(!t._superview||(this._superview=e.viewIDs(t._superview),this._superview)){this._firstAttribute=t._firstAttribute,this._secondAttribute=t._secondAttribute,this._constant=t._constant,this._kind=t._kind,this._priority=t._priority,this._identifier=t._identifier||BMUUIDMake(),this._isActive=void 0===t._isActive?YES:t._isActive,this._variations=t._variations||{};for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t);return this._updateConfiguration(),this._install(),this}},_views:void 0,_superview:void 0,_firstAttribute:void 0,_secondAttribute:void 0,_kind:void 0,affectedAttributesForView(t){let e=0;return t==this._superview?[this._firstAttribute,this._secondAttribute]:-1!=(e=this._views.indexOf(t))?this._superview?0==e?[this._secondAttribute]:e==this._views.length-1?[this._firstAttribute]:[this._firstAttribute,this._secondAttribute]:[this._firstAttribute,this._secondAttribute]:[]},get isConstraintCollection(){return YES},_constituentConstraints:void 0,get constituentConstraints(){if(this._constituentConstraints)return this._constituentConstraints;let t,e=[];for(let i=1;i<this._views.length;i++)e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[i-1],{attribute:this._secondAttribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._views[i],secondAttribute:this._firstAttribute,constant:this._constant,multiplier:1,priority:this._priority})),t._reversesConstant=YES,t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES);return this._superview&&(e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[0],{attribute:this._firstAttribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._superview,secondAttribute:this._firstAttribute,constant:this._constant,multiplier:1,priority:this._priority})),t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES),e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[this._views.length-1],{attribute:this._secondAttribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._superview,secondAttribute:this._secondAttribute,constant:this._constant,multiplier:1,priority:this._priority})),t._reversesConstant=YES,t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES)),this._constituentConstraints=e,e},get constant(){return this._constant},set constant(t){if(t!=this._constant)return this._constant=t,this._updateConfiguration()},get _hasEditableConstant(){return YES},get categoryKind(){return this._kind==BMLayoutConstraintKind.Vertical?"Vertical Position":"Horizontal Position"},_isActive:NO,get isActive(){return this._isActive},set isActive(t){if(t!=this._isActive)return this._isActive=t,this._updateConfiguration()},_install(){this._views.forEach((t=>t._addConstraint(this))),this._views[0].rootView._invalidatedConstraints=YES,this._superview&&this._superview._addConstraint(this)},remove(){this._isActive&&(this._isActive=NO),this._views.forEach((t=>{t._removeConstraint(this),t._checkConstraints(),t.needsLayout=YES})),this._views[0].rootView._invalidatedConstraints=YES,this._superview&&(this._superview._removeConstraint(this),this._superview._checkConstraints(),this._superview.needsLayout=YES),this._views=void 0},toString:()=>"Equal Spacing",toCompactString:()=>"Equal Spacing",serializedConstraintWithViewIDs(t){return{_class:"BMEqualSpacingLayoutConstraint",_priority:this._priority,_views:this._views.map((e=>t(e))),_superview:this._superview?t(this._superview):void 0,_constant:this._constant,_firstAttribute:this._firstAttribute,_secondAttribute:this._secondAttribute,_kind:this._kind,_identifier:this._identifier,_variations:this._serializedVariations,_isActive:this._isActive}}});const BM_VIEW_USE_TRANSFORM=NO,BM_VIEW_DEBUG_AUTOMATIC_INTRINSIC_SIZE=NO,BM_VIEW_DEBUG_LAYOUT_QUEUE=NO;function BMViewConstraintAttribute(){}function BMViewLayoutQueue(){}BMViewConstraintAttribute.prototype={_attribute:void 0,_view:void 0,equalTo(t,{times:e=1,plus:i=0,priority:o=BMLayoutConstraintPriorityRequired}={}){return"number"==typeof t?BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.Equals,constant:t,priority:o}):BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:t._view,secondAttribute:t._attribute,constant:i,multiplier:e,priority:o})},lessThanOrEqualTo(t,{times:e=1,plus:i=0,priority:o=BMLayoutConstraintPriorityRequired}={}){return"number"==typeof t?BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:t,priority:o}):BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,toView:t._view,secondAttribute:t._attribute,constant:i,multiplier:e,priority:o})},greaterThanOrEqualTo(t,{times:e=1,plus:i=0,priority:o=BMLayoutConstraintPriorityRequired}={}){return"number"==typeof t?BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,constant:t,priority:o}):BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,toView:t._view,secondAttribute:t._attribute,constant:i,multiplier:e,priority:o})}},BMViewLayoutQueue.prototype={_views:void 0,_enqueueView(t){if(BM_VIEW_DEBUG_LAYOUT_QUEUE&&this._views.has(t)){console.error("[BMViewLayoutQueue] Enqueueing view "+t.debuggingName+" into queue "+this._identifier+".");let e=document.createElement("div");e.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: yellow; pointer-events: none;",t.node.appendChild(e),requestAnimationFrame((()=>e.remove()))}this._views.add(t)},_removeView(t){this._views.delete(t)},dequeue(){if(BM_VIEW_DEBUG_LAYOUT_QUEUE&&this._views.size){console.error("[BMViewLayoutQueue] Dequeueing queue "+this._identifier+" with "+this._views.size+" view hierarchies.");for(let t of this._views){let e=document.createElement("div");e.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: blue; pointer-events: none;",t.node.appendChild(e),requestAnimationFrame((()=>e.remove()))}}_BMViewDequeueLayoutQueue(this)}},BMViewLayoutQueue.layoutQueue=function(){let t=new BMViewLayoutQueue;return t._views=new Set,t._identifier=BMUUIDMake(),t};var BMViewColorScheme=Object.freeze({Auto:"auto",Dark:"dark",Light:"light"});const BMViewDebug=NO,_BMViewLayoutQueue=BMViewLayoutQueue.layoutQueue(),_BMViewDequeueLayoutQueue=function(t){let e;t?(e=[...t._views],t._views=new Set):(e=[..._BMViewLayoutQueue._views],_BMViewLayoutQueue._views=new Set),e=e.map((t=>t._layoutSubviewsGenerator()));let i=YES;for(;i;)i=!e.reduce(((t,e)=>e.next().done&&t),YES)};function BMView(){}function BMScrollView(){}function BMScrollContentView(){}function BMLayoutGuide(){}!function(){var t=new WeakMap;BMView.viewForNode=function(e){let i=t.get(e);return i||(i=Object.create(this.prototype),i.initWithDOMNode(e))},BMView.view=function(){const t=document.createElement("div");return Object.create(this.prototype).initWithDOMNode(t)};const e=new Set;BMView._markAsRootView=function(t){e.add(t)},BMView._markAsNonRootView=function(t){e.delete(t)};const i={},o={};Object.defineProperty(BMView,"layoutVariables",{get:()=>BMCopyProperties({},i)}),BMView.prepareLayoutVariables=function(){},BMView.canUseLayoutVariables=function(){return YES},BMView.variationsForLayoutVariableNamed=function(t){const e=[];let i;for(let n in o)t in o[n]&&(i=o[n][t],e.push({name:t,sizeClass:o[n].sizeClass,value:i}));return e},BMView.registerLayoutVariableNamed=function(t,{withValue:o}){i[t]=o;for(const t of e)t._layoutVariablesDidUpdate()},BMView.renameLayoutVariableNamed=function(t,{toName:n}){if(t in i){if(n in i)throw new Error("A layout variable with the given name already exists.");i[n]=i[t],delete i[t];for(let e in o)t in o[e]&&(o[e][n]=o[e][t],delete o[e][t]);for(const t of e)t._layoutVariablesDidUpdate()}},BMView.unregisterLayoutVariableNamed=function(t){delete i[t];for(const t of e)t._layoutVariablesDidUpdate()},BMView.setLayoutVariableValue=function(t,{named:i,inSizeClass:n}){o[n._hashString]=o[n._hashString]||{sizeClass:n},o[n._hashString][i]=t;for(const t of e)t._layoutVariablesDidUpdate()},BMView.removeVariationForLayoutVariableNamed=function(t,{inSizeClass:i}){if(o[i._hashString]){delete o[i._hashString][t],1==Object.keys(o[i._hashString]).length&&delete o[i._hashString];for(const t of e)t._layoutVariablesDidUpdate()}},BMView.removeVariationsForLayoutVariableNamed=function(t){for(let e in o)delete o[e][t],1==Object.keys(o[e]).length&&delete o[e];for(const t of e)t._layoutVariablesDidUpdate()},BMView.persistLayoutVariables=function(){},BMView.prototype._layoutVariableValuesForViewport=function(t){let e={};for(let t of Object.keys(i))e[t]=i[t];for(let e in o)o[e]._matchPriority=t.matchPriorityForSizeClass(o[e].sizeClass);return Object.keys(o).map((t=>o[t])).sort(((t,e)=>e._matchPriority-t._matchPriority)).forEach((t=>{if(t._matchPriority)for(let o in i)o in t&&(e[o]=t[o])})),this._layoutVariables=e,e};const n=new WeakMap,s=function(t){this.node=t,this._keyboardShortcuts={}};s.prototype={node:void 0,_keyboardShortcuts:void 0,registerKeyboardShortcut(t){return BMView.prototype.registerKeyboardShortcut.apply(this,arguments)},unregisterKeyboardShortcut(t){return BMView.prototype.unregisterKeyboardShortcut.apply(this,arguments)},keyPressedWithEvent(t){return BMView.prototype.keyPressedWithEvent.apply(this,arguments)},_keyboardShortcutsEnabled:NO,_enableKeyboardShortcuts(){return BMView.prototype._enableKeyboardShortcuts.apply(this,arguments)},_disableKeyboardShortcuts(){return BMView.prototype._disableKeyboardShortcuts.apply(this,arguments)}},BMView.registerKeyboardShortcut=function(t,{forNode:e}){let i=n.get(e);i||(i=new s(e),n.set(e,i)),i.registerKeyboardShortcut(t)},BMView.unregisterKeyboardShortcut=function(t,{forNode:e}){const i=n.get(e);i&&i.unregisterKeyboardShortcut(t)},BMView.prototype._releaseRecursive=function(){if(!this.__released){this.__released=YES;for(const t of this._subviews)t._releaseRecursive();t.delete(this._node),e.delete(this)}},BMView.prototype.release=function(){if(!this.__released){this.__released=YES,this.layoutQueue._removeView(this);for(const t of this._subviews.slice())t._releaseRecursive();t.delete(this._node),this._superview&&this.removeFromSuperview(),e.delete(this)}},BMView.prototype.initWithDOMNode=function(e){var i;if(this._node=e,this._constraints=[],this._subviews=[],i=t.get(e)){if(i!=this)throw new Error("There is already a view associated with the given node.")}else t.set(e,this);this._variables={[BMLayoutAttribute.Left]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Left),[BMLayoutAttribute.Width]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Width),[BMLayoutAttribute.Top]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Top),[BMLayoutAttribute.Height]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Height)};for(let t in BMLayoutAttribute){let e=t.substring(0,1).toLowerCase()+t.substring(1,t.length),i=Object.create(BMViewConstraintAttribute.prototype);i._view=this,i._attribute=BMLayoutAttribute[t],this[e]=i}return this._sizeClasses=new Set,this._variations={},this._configuration={opacity:this._opacity,isVisible:this._isVisible,contentInsets:this.__activeInsets},this._variableProperties={},this._keyboardShortcuts={},this}}(),BMView.prototype=BMExtend(BMView.prototype,{_node:void 0,get node(){return this._node},get contentNode(){return this._node},debuggingName:"",leading:void 0,trailing:void 0,left:void 0,right:void 0,top:void 0,bottom:void 0,centerX:void 0,centerY:void 0,width:void 0,height:void 0,_layoutEditor:void 0,get layoutEditor(){return this._layoutEditor},set layoutEditor(t){this._layoutEditor=t},_layoutQueue:_BMViewLayoutQueue,get layoutQueue(){return this._layoutQueue},set layoutQueue(t){const e=this._layoutQueue._views.has(this);this._layoutQueue._removeView(this),this._layoutQueue=t||_BMViewLayoutQueue,e&&this._layoutQueue._enqueueView(this)},_layoutAnimator:void 0,_frame:void 0,get frame(){return this._frame||BMRectMakeWithNodeFrame(this._node)},set frame(t){this._frame||(this._node.style.position="absolute",this._node.style.contain="layout",this._node.style.right="auto",this._node.style.bottom="auto",this._node.style.left="0px",this._node.style.top="0px");let e,i=NO;if(this._frame&&this._frame.size.isEqualToSize(t.size)||(e=t.copy(),e.origin=BMPointMake(),this.boundsWillChangeToBounds(e),i=YES),this.isRootView)this._frame?(this._node.style.width="100%",this._node.style.height="100%"):(BM_VIEW_USE_TRANSFORM?BMHook(this._node,{translateX:"0px",translateY:"0px"}):(this._node.style.top="0px",this._node.style.left="0px"),this._node.style.width="100%",this._node.style.height="100%"),this._frame=t.copy(),this._layoutEditor&&this._layoutEditor.viewDidLayoutSubviews(this);else if(BMAnimationContextGetCurrent()){this._frame||(this._frame=BMRectMakeWithNodeFrame(this.node)),BMHook(this._node,BM_VIEW_USE_TRANSFORM?{translateX:this._frame.origin.x+"px",translateY:this._frame.origin.y+"px"}:{left:this._frame.origin.x+"px",top:this._frame.origin.y+"px"}),this._node.style.width=this._frame.size.width+"px",this._node.style.height=this._frame.size.height+"px";let o=BMAnimationContextGetCurrent().controllerForObject(this,{node:this._node});BM_VIEW_USE_TRANSFORM?(o.registerBuiltInProperty("translateX",{withValue:t.origin.x+"px"}),o.registerBuiltInProperty("translateY",{withValue:t.origin.y+"px"})):(o.registerBuiltInProperty("left",{withValue:t.origin.x+"px"}),o.registerBuiltInProperty("top",{withValue:t.origin.y+"px"})),o.registerBuiltInProperty("width",{withValue:t.size.width+"px"}),o.registerBuiltInProperty("height",{withValue:t.size.height+"px"}),this._layoutAnimator=o.promise,o.promise.then((o=>{this._layoutAnimator=void 0,this.didSetFrame(t),i&&this.boundsDidChangeToBounds(e)})),this._frame=t.copy()}else this._frame=t.copy(),BMHook(this._node,BM_VIEW_USE_TRANSFORM?{translateX:t.origin.x+"px",translateY:t.origin.y+"px"}:{left:t.origin.x+"px",top:t.origin.y+"px"}),this._node.style.width=t.size.width+"px",this._node.style.height=t.size.height+"px",i&&this.boundsDidChangeToBounds(e);this.didSetFrame(t)},get frameRelativeToRootView(){let t=BMPointMake(),e=this.superview;for(;e&&e.superview;)t.x+=e.frame.origin.x,t.y+=e.frame.origin.y,e=e.superview;let i=this.frame.copy();return i.origin.x+=t.x,i.origin.y+=t.y,i},set frameRelativeToRootView(t){let e=BMPointMake(),i=this.superview;for(;i&&i.superview;)e.x+=i.frame.origin.x,e.y+=i.frame.origin.y,i=i.superview;let o=t.copy();o.origin.x-=e.x,o.origin.y-=e.y,this.frame=o},didSetFrame(t){},get bounds(){let t=this._frame.copy();return t.origin=BMPointMake(),t},set bounds(t){let e=this.bounds;if(e.size.width!=t.size.width||e.size.height!=t.size.height){let e=this.frame.copy();e.size=t.size.copy(),this.frame=e}},boundsWillChangeToBounds(t){},boundsDidChangeToBounds(t){},LTRLayout:YES,get _serializedVariations(){let t={};return this._variations&&Object.keys(this._variations).forEach((e=>{t[e]={},Object.keys(this._variations[e]).forEach((i=>{"sizeClass"!=i&&(t[e][i]=this._variations[e][i])}))})),t},set _serializedVariations(t){if(t){this._variations=t;for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t)}},_variableProperties:void 0,_configuration:void 0,registerVariablePropertyNamed(t,e){if(this[t])throw new Error("Unable to register the property "+t+" as a variable property. This property duplicates an existing property of this view.");let i=t[0].toUpperCase()+t.substring(1),o=e.forTarget;this._variableProperties[t]=o,this[t]=o[t],this[`set${i}`]=(e,i)=>this._setVariation(e,{forProperty:t,inSizeClass:i.forSizeClass}),this[`remove${i}VariationForSizeClass`]=e=>this._removeVariationForProperty(t,{inSizeClass:e}),this[`has${i}VariationForSizeClass`]=e=>this._hasVariationForProperty(t,{inSizeClass:e})},unregisterVariablePropertyNamed(t){this._variableProperties[t]&&delete this._variableProperties[t]},activeSizeClassesDidChange(t){this._updateConfiguration()},_updateConfiguration(){let t={opacity:this._opacity,isVisible:this._isVisible,contentInsets:this._contentInsets,CSSClass:this._CSSClass},e=this.viewport;for(let t in this._variations)this._variations[t]._matchPriority=e.matchPriorityForSizeClass(this._variations[t].sizeClass);Object.keys(this._variations).map((t=>this._variations[t])).sort(((t,e)=>e._matchPriority-t._matchPriority)).forEach((e=>{if(e._matchPriority){"opacity"in e&&(t.opacity=e.opacity),"isVisible"in e&&(t.isVisible=e.isVisible),"contentInsets"in e&&(t.contentInsets=e.contentInsets),"CSSClass"in e&&(t.CSSClass=e.CSSClass);for(let i in this._variableProperties)i in e&&(t[i]=e[i])}}));let i=this._configuration||t;this._configuration=t,i.opacity!=t.opacity&&(this._activeOpacity=t.opacity),i.isVisible!=t.isVisible&&(this._activeVisibility=t.isVisible),i.CSSClass!=t.CSSClass&&(this._activeCSSClass=t.CSSClass),i.contentInsets.isEqualToInset(t.contentInsets)||(this._activeInsets=t.contentInsets)},_setVariation(t,e){this._variations[e.inSizeClass._hashString]||(this._variations[e.inSizeClass._hashString]={sizeClass:e.inSizeClass},this.rootView._invalidatedSizeClasses=YES),this._variations[e.inSizeClass._hashString][e.forProperty]=t,this.viewport.matchesSizeClass(e.inSizeClass)&&this._updateConfiguration()},_removeVariationForProperty(t,e){this._variations[e.inSizeClass._hashString]&&(delete this._variations[e.inSizeClass._hashString][t],1==Object.keys(this._variations[e.inSizeClass._hashString]).length&&(delete this._variations[e.inSizeClass._hashString],this.rootView._invalidatedSizeClasses=YES),this.viewport.matchesSizeClass(e.inSizeClass)&&this._updateConfiguration())},_hasVariationForProperty(t,e){return this._variations[e.inSizeClass._hashString]?t in this._variations[e.inSizeClass._hashString]:NO},__activeInsets:BMInsetMake(),set _activeInsets(t){this.__activeInsets=t?t.copy():BMInsetMake(),t=this.__activeInsets;const e=this.contentNode;e.style.paddingLeft=t.left+"px",e.style.paddingTop=t.top+"px",e.style.paddingRight=t.right+"px",e.style.paddingBottom=t.bottom+"px",this.supportsIntrinsicSize&&this.invalidateIntrinsicSize()},_contentInsets:BMInsetMake(),get contentInsets(){return this._contentInsets.copy()},set contentInsets(t){this._contentInsets=t?t.copy():BMInsetMake(),this._updateConfiguration()},setContentInsets(t,e){return this._setVariation(t||BMInsetMake(),{forProperty:"contentInsets",inSizeClass:e.forSizeClass})},removeContentInsetsVariationForSizeClass(t){return this._removeVariationForProperty("contentInsets",{inSizeClass:t})},hasContentInsetsVariationForSizeClass(t){return this._hasVariationForProperty("contentInsets",{inSizeClass:t})},__activeCSSClass:"",set _activeCSSClass(t){t=t||"";const e=this.__activeCSSClass.split(" "),i=t.split(" ");for(const t of e)t&&(i.includes(t)||this.node.classList.remove(t));for(const t of i)t&&(e.includes(t)||this.node.classList.add(t));this.__activeCSSClass=t,this.supportsIntrinsicSize&&this.invalidateIntrinsicSize()},_CSSClass:"",get CSSClass(){return this._CSSClass},set CSSClass(t){this._CSSClass=t,this._updateConfiguration()},setCSSClass(t,e){return this._setVariation(t,{forProperty:"CSSClass",inSizeClass:e.forSizeClass})},removeCSSClassVariationForSizeClass(t){return this._removeVariationForProperty("CSSClass",{inSizeClass:t})},hasCSSClassVariationForSizeClass(t){return this._hasVariationForProperty("CSSClass",{inSizeClass:t})},__activeOpacity:1,set _activeOpacity(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this._node}).registerBuiltInProperty("opacity",{withValue:this._opacity})}else this.__activeOpacity=t,this.node.style.opacity=t},get currentOpacity(){return this.__activeOpacity},_opacity:1,get opacity(){return this._opacity},set opacity(t){this._opacity=t,this._updateConfiguration()},setOpacity(t,e){return this._setVariation(t,{forProperty:"opacity",inSizeClass:e.forSizeClass})},removeOpacityVariationForSizeClass(t){return this._removeVariationForProperty("opacity",{inSizeClass:t})},hasOpacityVariationForSizeClass(t){return this._hasVariationForProperty("opacity",{inSizeClass:t})},__activeVisibility:YES,set _activeVisibility(t){if(t!=this.__activeVisibility){const e=this.isCurrentlyVisible;this.__activeVisibility=t,t?(this.rootView._layoutEditor?this.node.classList.remove("BMLayoutEditorInvisibleView"):this.node.style.display="block",e||this.viewDidBecomeVisible()):(this.rootView._layoutEditor?this.node.classList.add("BMLayoutEditorInvisibleView"):this.node.style.display="none",e||this.viewDidBecomeInvisible());for(const e of this._subviews)e._parentVisible=t;this.invalidateIntrinsicSize()}},get _activeVisibility(){return this.__activeVisibility},__parentVisible:YES,get _parentVisible(){return this.__parentVisible},set _parentVisible(t){const e=t&&this.__activeVisibility,i=this.isCurrentlyVisible;if(e!=this.__parentVisible)for(const e of this._subviews)e._parentVisible=t;this.__parentVisible=e,this.isCurrentlyVisible!=i&&(this.isCurrentlyVisible?this.viewDidBecomeVisible():this.viewDidBecomeInvisible())},get isCurrentlyVisible(){return this.__activeVisibility&&this.__parentVisible},viewDidBecomeVisible(){this.supportsIntrinsicSize&&this.invalidateIntrinsicSize()},viewDidBecomeInvisible(){},_isVisible:YES,get isVisible(){return this._isVisible},set isVisible(t){this._isVisible=t,this._updateConfiguration()},setIsVisible(t,e){return this._setVariation(t,{forProperty:"isVisible",inSizeClass:e.forSizeClass})},removeIsVisibleVariationForSizeClass(t){return this._removeVariationForProperty("isVisible",{inSizeClass:t})},hasIsVisibleVariationForSizeClass(t){return this._hasVariationForProperty("isVisible",{inSizeClass:t})},_colorScheme:BMViewColorScheme.Auto,get colorScheme(){return this._colorScheme},set colorScheme(t){const e=this._colorScheme;this._colorScheme=t,this.colorSchemeDidChange(e)},colorSchemeDidChange(t){},_supportsAutomaticIntrinsicSize:NO,get supportsAutomaticIntrinsicSize(){return this._supportsAutomaticIntrinsicSize},set supportsAutomaticIntrinsicSize(t){this._supportsAutomaticIntrinsicSize=t},get supportsIntrinsicSize(){return this.supportsAutomaticIntrinsicSize},_requiredWidth:void 0,get requiredWidth(){return this._requiredWidth},_needsIntrinsicSizeMeasurement:YES,get needsIntrinsicSizeMeasurement(){if(this._needsIntrinsicSizeMeasurement&&this.supportsAutomaticIntrinsicSize)return YES;if(!this._hasDeterministicSize&&this._preferredIntrinsicSize&&this._intrinsicSize&&!this._preferredIntrinsicSize.isEqualToSize(this._instrinsicSize))return YES;let t=this._subviews.length;for(let e=0;e<t;e++)if(this._subviews[e].needsIntrinsicSizeMeasurement)return YES;return NO},invalidateIntrinsicSize(){this._preferredIntrinsicSize=void 0,this._needsIntrinsicSizeMeasurement=YES;const t=this.rootView;t._needsLayout=YES,t._scheduleImmediateLayout()},_intrinsicSize:void 0,_preferredIntrinsicSize:void 0,_getIntrinsicSize(){let t;return this._needsIntrinsicSizeMeasurement?t=this.requiredWidth?this._instrinsicSize=this.intrinsicSize:this._instrinsicSize=this._preferredIntrinsicSize=this.intrinsicSize:this.requiredWidth&&this._intrinsicSize&&!this._intrinsicSize.isEqualToSize(this._preferredIntrinsicSize)&&(t=this._instrinsicSize=this.intrinsicSize),t||(t=this._instrinsicSize),t},get intrinsicSize(){if(this.supportsAutomaticIntrinsicSize){if(this._needsIntrinsicSizeMeasurement){let t=this._node;if(this._intrinsicSize=BMSizeMake(t.offsetWidth-t.clientWidth+t.scrollWidth+1,t.offsetHeight-t.clientHeight+t.offsetHeight),BM_VIEW_DEBUG_AUTOMATIC_INTRINSIC_SIZE){let e=document.createElement("div");e.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",t.appendChild(e),requestAnimationFrame((()=>e.remove()))}}return this._intrinsicSize}},_compressionResistance:750,get compressionResistance(){return this._compressionResistance},set compressionResistance(t){this._compressionResistance=t,this._widthCompressionConstraint=void 0,this._heightCompressionConstraint=void 0,this.needsLayout=YES,this.rootView._invalidatedConstraints=YES},_expansionResistance:250,get expansionResistance(){return this._expansionResistance},set expansionResistance(t){this._expansionResistance=t,this._widthExpansionConstraint=void 0,this._heightExpansionConstraint=void 0,this.needsLayout=YES,this.rootView._invalidatedConstraints=YES},_invalidatedSizeClasses:NO,_sizeClasses:void 0,_matchingSizeClasses:void 0,_updateSizeClasses(){this._sizeClasses=new Set,this.allSubviews.forEach((t=>{for(let e in t._variations){let i=t._variations[e].sizeClass;this._sizeClasses.has(i)||this._sizeClasses.add(i)}})),this.allConstraints.forEach((t=>{for(let e in t._variations){let i=t._variations[e].sizeClass;this._sizeClasses.has(i)||this._sizeClasses.add(i)}}))},_viewport:void 0,get viewport(){return this.isRootView?(!this._viewport&&this._updateViewport(),this._requiredViewport||this._viewport):this.rootView.viewport},_requiredViewport:void 0,get _currentViewport(){if(this._requiredViewport)return this._requiredViewport;let t=new BMViewport;return t.init(),t._width=window.innerWidth,t._height=window.innerHeight,t._diagonal=Math.sqrt(Math.pow(window.innerWidth,2)+Math.pow(window.innerHeight,2)),t._orientation=t._width>=t._height?BMLayoutOrientation.Landscape:BMLayoutOrientation.Portrait,t._surfaceArea=t._width*t._height,t},_layoutVariablesDidUpdate(){if(!this._viewport)return;const t=this._layoutVariables||{};this._layoutVariableValuesForViewport(this._viewport);let e=NO;for(let i in this._layoutVariables)if(t[i]!=this._layoutVariables[i]){e=YES;break}e&&this.allConstraints.forEach((t=>t.layoutVariablesDidChange()))},_updateViewport(){let t=this._currentViewport;this._viewport=t;let e=this._layoutVariables||{};this._layoutVariableValuesForViewport(t);let i=NO;for(let t in this._layoutVariables)if(e[t]!=this._layoutVariables[t]){i=YES;break}let o=new Set;for(let e of this._sizeClasses.keys())t.matchesSizeClass(e)&&o.add(e);if(this._matchingSizeClasses){let t=NO;if(this._matchingSizeClasses.size!=o.size)t=YES;else for(let e of this._matchingSizeClasses)o.has(e)||(t=YES);if(t){this._matchingSizeClasses=o;let t=Array.from(o);this.allConstraints.forEach((e=>e.activeSizeClassesDidChange(t))),this.allSubviews.forEach((e=>e.activeSizeClassesDidChange(t)))}else i&&this.allConstraints.forEach((t=>t.layoutVariablesDidChange()))}else{this._matchingSizeClasses=o;let t=Array.from(o);this.allConstraints.forEach((e=>e.activeSizeClassesDidChange(t))),this.allSubviews.forEach((e=>e.activeSizeClassesDidChange(t)))}},valueForLayoutVariable(t){const e=this.rootView;return e!=this?e.valueForLayoutVariable(t):"-"==t.charAt(0)?-(this._layoutVariables[t.substring(1)]||0):this._layoutVariables[t]||0},_keyboardShortcuts:void 0,registerKeyboardShortcut(t){Object.keys(this._keyboardShortcuts).length||this._enableKeyboardShortcuts(),this._keyboardShortcuts[t.keyCode]||(this._keyboardShortcuts[t.keyCode]=[]),this._keyboardShortcuts[t.keyCode].push(t)},unregisterKeyboardShortcut(t){const e=this._keyboardShortcuts[t.keyCode];if(e){for(let i=0;i<e.length;i++)if(e[i]==t){e.splice(i,1);break}e.length||delete this._keyboardShortcuts[t.keyCode]}Object.keys(this._keyboardShortcuts).length||this._disableKeyboardShortcuts()},keyPressedWithEvent(t){if(this._keyboardShortcuts[t.code])for(const e of this._keyboardShortcuts[t.code]){let i=0;for(const e in BMKeyboardShortcutModifier)t[BMKeyboardShortcutModifier[e].key]&&(i|=BMKeyboardShortcutModifier[e].value);i==e._modifierBitmap&&(e.preventsDefault&&t.preventDefault(),e.target[e.action](t,{forKeyboardShortcut:e}))}},_keyboardShortcutsEnabled:NO,_enableKeyboardShortcuts(){this.node.hasAttribute("tabIndex")||(this.node.tabIndex=-1),this._keypressHandler=t=>{this.keyPressedWithEvent(t)},this.node.addEventListener("keydown",this._keypressHandler),this._keyboardShortcutsEnabled=YES},_disableKeyboardShortcuts(){this.node.removeEventListener("keydown",this._keypressHandler),this._keyboardShortcutsEnabled=NO},_constraints:void 0,_variables:void 0,constraintWithIdentifier(t){for(let e of this._constraints)if(e.identifier==t)return e;for(let e of this._subviews){let i=e.constraintWithIdentifier(t);if(i)return i}},get allConstraints(){let t=this._constraints.slice();return this._subviews.forEach((e=>{t=t.concat(e.allConstraints)})),t},get activeConstraints(){let t=[];return this._hasDeterministicConstraints&&(t=this._constraints.filter((t=>t.affectsLayout))),this._subviews.forEach((e=>{t=t.concat(e.activeConstraints)})),t},get localConstraints(){return this._constraints.slice()},_invalidatedConstraints:NO,_addConstraint(t){this._constraints.push(t),this.rootView._invalidatedConstraints=YES,this._checkConstraints()},_removeConstraint(t){var e=this._constraints.indexOf(t);this.rootView._invalidatedConstraints=YES,-1!=e&&this._constraints.splice(e,1),this._checkConstraints()},_hasDeterministicConstraints:NO,_checkConstraints(){let t=NO,e=NO,i=new Set,o=new Set,n=NO,s=NO,a=NO;this.supportsIntrinsicSize&&(i.add(BMLayoutAttribute.Width),o.add(BMLayoutAttribute.Height));let r=this._constraints;for(var l=0;l<r.length;l++){let h=r[l];if(h.affectsLayout){switch(h._kind){case BMLayoutConstraintKind.Horizontal:h.affectedAttributesForView(this).forEach((t=>i.add(t))),i.size>1&&(t=YES),h._sourceViewAttribute==BMLayoutAttribute.Width&&!h._targetView&&!h.isConstraintCollection&&h._relation==BMLayoutConstraintRelation.Equals&&h.activePriority>this._compressionResistance&&h.activePriority>this._expansionResistance&&(s=YES);break;case BMLayoutConstraintKind.Vertical:h.affectedAttributesForView(this).forEach((t=>o.add(t))),o.size>1&&(e=YES),h._sourceViewAttribute==BMLayoutAttribute.Height&&!h._targetView&&!h.isConstraintCollection&&h._relation==BMLayoutConstraintRelation.Equals&&h.activePriority>this._compressionResistance&&h.activePriority>this._expansionResistance&&(a=YES)}if(a&&s&&(n=YES),t&&e&&n)break}}if(n&&(this._hasDeterministicSize=YES),t&&e)return this._hasDeterministicConstraints=YES;r=this.internalConstraints();for(l=0;l<r.length;l++){let n=r[l];switch(n._kind){case BMLayoutConstraintKind.Horizontal:n.affectedAttributesForView(this).forEach((t=>i.add(t))),i.size>1&&(t=YES);break;case BMLayoutConstraintKind.Vertical:n.affectedAttributesForView(this).forEach((t=>o.add(t))),o.size>1&&(e=YES)}if(t&&e)break}this._hasDeterministicConstraints=t&&e},_clearConstraints(){this.localConstraints.forEach((t=>t.remove())),this._subviews.forEach((t=>t._clearConstraints()))},_leftExpressionWithMultiplier(t){return t=t||1,this.isRootView?new kiwi.Expression([t,this._variables[BMLayoutAttribute.Left]]):new kiwi.Expression(this.superview._leftExpressionWithMultiplier(),[t,this._variables[BMLayoutAttribute.Left]])},_topExpressionWithMultiplier(t){return t=t||1,this.isRootView?new kiwi.Expression([t,this._variables[BMLayoutAttribute.Top]]):new kiwi.Expression(this.superview._topExpressionWithMultiplier(),[t,this._variables[BMLayoutAttribute.Top]])},_cassowaryExpressionForLayoutAttribute(t,e){var i=e&&e.withMultiplier||1;if(t in this._variables)return t==BMLayoutAttribute.Left?this._leftExpressionWithMultiplier(i):t==BMLayoutAttribute.Top?this._topExpressionWithMultiplier(i):new kiwi.Expression(1!=i?[i,this._variables[t]]:this._variables[t]);switch(t){case BMLayoutAttribute.Leading:return this.LTRLayout?this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Left,e):this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Right,e);case BMLayoutAttribute.Trailing:return this.LTRLayout?this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Right,e):this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Left,e);case BMLayoutAttribute.Right:return 1!=i?new kiwi.Expression([i,this._variables[BMLayoutAttribute.Width]],this._leftExpressionWithMultiplier(i)):new kiwi.Expression(this._variables[BMLayoutAttribute.Width],this._leftExpressionWithMultiplier(i));case BMLayoutAttribute.CenterX:return 1!=i?new kiwi.Expression([i/2,this._variables[BMLayoutAttribute.Width]],this._leftExpressionWithMultiplier(i)):new kiwi.Expression([.5,this._variables[BMLayoutAttribute.Width]],this._leftExpressionWithMultiplier(i));case BMLayoutAttribute.Bottom:return 1!=i?new kiwi.Expression([i,this._variables[BMLayoutAttribute.Height]],this._topExpressionWithMultiplier(i)):new kiwi.Expression(this._variables[BMLayoutAttribute.Height],this._topExpressionWithMultiplier(i));case BMLayoutAttribute.CenterY:return 1!=i?new kiwi.Expression([i/2,this._variables[BMLayoutAttribute.Height]],this._topExpressionWithMultiplier(i)):new kiwi.Expression([.5,this._variables[BMLayoutAttribute.Height]],this._topExpressionWithMultiplier(i));case BMLayoutAttribute.AspectRatio:throw new Error("Aspect ratio constraints are currently unsupported!")}},get builtInConstraints(){var t=this._getIntrinsicSize(),e=[];return(t||this.supportsAutomaticIntrinsicSize)&&(this._widthCompressionConstraint?(this._widthCompressionConstraint.constant=t.width,this._heightCompressionConstraint.constant=t.height,e.push(this._widthCompressionConstraint,this._heightCompressionConstraint)):e.push(this._widthCompressionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,constant:t.width,priority:this.compressionResistance}),this._heightCompressionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,constant:t.height,priority:this.compressionResistance})),this._widthExpansionConstraint?(this._widthExpansionConstraint.constant=t.width,this._heightExpansionConstraint.constant=t.height,e.push(this._widthExpansionConstraint,this._heightExpansionConstraint)):e.push(this._widthExpansionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:t.width,priority:this.expansionResistance}),this._heightExpansionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:t.height,priority:this.expansionResistance}))),e=e.concat(this.internalConstraints()),this._internalConstraints=e,this._subviews.forEach((t=>{e=e.concat(t.builtInConstraints)})),e},internalConstraints(){var t=[];if(this.isRootView){if(!this.node.parentNode)return t;this._rootViewLeftConstraint?(this._layoutEditor?(this._rootViewHeightConstraint.constant=this._layoutEditor._staticWorkspaceHeight,this._rootViewWidthConstraint.constant=this._layoutEditor._staticWorkspaceWidth):(this._rootViewHeightConstraint.constant=this._node.parentNode.offsetHeight,this._rootViewWidthConstraint.constant=this._node.parentNode.offsetWidth),t.push(this._rootViewLeftConstraint,this._rootViewTopConstraint,this._rootViewWidthConstraint,this._rootViewHeightConstraint)):t.push(this._rootViewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Left,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Top,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewWidthConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.Equals,constant:this._node.parentNode.offsetWidth}),this._rootViewHeightConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.Equals,constant:this._node.parentNode.offsetHeight}))}return t},_assignWidth(){this._requiredWidth=this._variables[BMLayoutAttribute.Width].value(),!this._hasDeterministicSize&&this._intrinsicSize&&this._preferredIntrinsicSize&&!this._instrinsicSize.isEqualToSize(this._preferredIntrinsicSize)&&this._intrinsicSize.width!=this._requiredWidth&&(this._needsIntrinsicSizeMeasurement=YES),this._subviews.forEach((t=>t._assignWidth()))},_acquireReferenceFrames(){if(this._frame)this._referenceFrame=this._frame.copy();else{let t=BMRectMake(this.node.offsetLeft,this.node.offsetTop,this.node.offsetWidth,this.node.offsetHeight);(t.width&&t.height||!this._referenceFrame)&&(this._referenceFrame=t)}!this._hasDeterministicSize&&this._intrinsicSize&&this._preferredIntrinsicSize&&!this._instrinsicSize.isGreaterThanSize(this._preferredIntrinsicSize)&&(this._needsIntrinsicSizeMeasurement=YES),this._subviews.forEach((t=>t._acquireReferenceFrames()))},_resizeForAutomaticInstricSize(){this.supportsAutomaticIntrinsicSize&&this.needsIntrinsicSizeMeasurement?this._requiredWidth?this._node.style.width=this._requiredWidth+"px":BMCopyProperties(this._node.style,{width:"auto",height:"auto",left:"0px",top:"0px",position:"absolute"}):this.needsIntrinsicSizeMeasurement&&BMCopyProperties(this._node.style,{width:"100%",height:"100%"}),this._subviews.forEach((t=>t._resizeForAutomaticInstricSize()))},_prepareForAutomaticIntrinsicSize(){void 0===this._requiredWidth&&this._acquireReferenceFrames(),this._resizeForAutomaticInstricSize()},_updateInternalHeightConstraints(){var t=this._getIntrinsicSize();t&&this._heightCompressionConstraint&&(this._heightCompressionConstraint.constant=t.height,this._heightExpansionConstraint.constant=t.height),this._subviews.forEach((t=>t._updateInternalHeightConstraints()))},get _horizontalLayoutVariables(){var t=[this._variables[BMLayoutAttribute.Left],this._variables[BMLayoutAttribute.Width]];return this._subviews.forEach((e=>t=t.concat(e._horizontalLayoutVariables))),t},get _verticalLayoutVariables(){var t=[this._variables[BMLayoutAttribute.Top],this._variables[BMLayoutAttribute.Height]];return this._subviews.forEach((e=>t=t.concat(e._verticalLayoutVariables))),t},_isPerformingLayoutPass:NO,_layoutAnimationFrameIdentifier:void 0,_cancelLayout(){this._layoutQueue._removeView(this),this._layoutAnimationFrameIdentifier&&window.cancelAnimationFrame(this._layoutAnimationFrameIdentifier),this._layoutAnimationFrameIdentifier=void 0,this._layoutIntrisicSizeInvalidationIdentifier=void 0},_registerLayout(){this._layoutQueue._enqueueView(this)},async _scheduleLayout(){if(this!=this.rootView)return this.rootView._scheduleLayout();this._layoutAnimator&&await this._layoutAnimator,this._layoutAnimationFrameIdentifier||this._layoutIntrisicSizeInvalidationIdentifier||(this._registerLayout(),this._layoutAnimationFrameIdentifier=window.requestAnimationFrame((t=>{this._layoutAnimationFrameIdentifier=void 0,this._layoutQueue.dequeue()})))},_layoutIntrisicSizeInvalidationIdentifier:void 0,async _scheduleImmediateLayout(){if(this!=this.rootView)return this.rootView._scheduleImmediateLayout();if(this._layoutAnimator&&await this._layoutAnimator,this._layoutAnimationFrameIdentifier&&(window.cancelAnimationFrame(this._layoutAnimationFrameIdentifier),this._layoutAnimationFrameIdentifier=void 0),!this._layoutIntrisicSizeInvalidationIdentifier){this._layoutIntrisicSizeInvalidationIdentifier=BMUUIDMake();var t=this._layoutIntrisicSizeInvalidationIdentifier;this._registerLayout(),await 0,this._layoutIntrisicSizeInvalidationIdentifier&&t==this._layoutIntrisicSizeInvalidationIdentifier&&(this._layoutIntrisicSizeInvalidationIdentifier=void 0,this._layoutQueue.dequeue())}},layout:function(){return this.layoutIfNeeded()},layoutIfNeeded:async function(){if(this!=this.rootView)return this.rootView.layout();this._needsLayout&&(this._layoutAnimator&&await this._layoutAnimator,this._registerLayout(),this._layoutQueue.dequeue())},layoutSubviews(){let t=this._layoutSubviewsGenerator(),e=NO;for(;!e;)e=t.next().done},*_layoutSubviewsGenerator(){if(this._layoutAnimationFrameIdentifier&&(window.cancelAnimationFrame(this._layoutAnimationFrameIdentifier),this._layoutAnimationFrameIdentifier=void 0),this._layoutIntrisicSizeInvalidationIdentifier&&(window.removeEventListener("message",this._layoutIntrisicSizeInvalidationHandler),this._layoutIntrisicSizeInvalidationHandler=void 0,this._layoutIntrisicSizeInvalidationIdentifier=void 0),!this._node||!this._node.parentNode)return;if(this.superview)return;BMViewDebug&&console.log("\n ***********************************************************************************************************\n [BMCoreUI] Layout pass began\n ***********************************************************************************************************\n ");var t,e=new Set;this._invalidatedSizeClasses&&this._updateSizeClasses(),this._updateViewport();let i=NO;if(!this._solver||this._layoutEditor||this._invalidatedConstraints?(t=new kiwi.Solver,this._solver=t,i=YES,this._layoutEditor&&this.allSubviews.forEach((t=>t._needsIntrinsicSizeMeasurement=YES)),this._invalidatedConstraints=NO):(t=this._solver,i=NO),this._prepareForAutomaticIntrinsicSize(),yield,i){let i;for(this.activeConstraints.forEach((t=>{e.add(t)})),this.builtInConstraints.forEach((t=>{e.add(t)})),this._horizontalLayoutVariables.forEach((e=>t.addEditVariable(e,kiwi.Strength.strong)));YES;){let o,n=[],s=[];try{e.forEach((e=>{i&&i.includes(e)||e._kind===BMLayoutConstraintKind.Horizontal&&(o=e,n.push(e),BMViewDebug&&console.log(`[BMCoreUI] Horizontal constraint: ${e}`),e.constituentConstraints.forEach((e=>{e._constraint=void 0;let i=e._cassowaryConstraint;s.push(i),t.addConstraint(i),e._solver=t})))}));break}catch(e){if(console.error(`[BMCoreUI] Unsatisfiable constraints. The following constraints are not satisfiable and the\n layout operation cannot be completed. Will attempt to solve the layout by breaking constraint \n ${o}. Please check the following constraints at design-time to resolve the problem:\n`),n.forEach((t=>{console.error(`${t}`)})),this._layoutEditor)return;i=i||[],i.push(o),s.forEach((e=>{t.hasConstraint(e)&&t.removeConstraint(e)}))}}}else this.builtInConstraints||console.log();try{t.suggestValue(this._variables[BMLayoutAttribute.Left],0)}catch(t){console.log(t)}let o=this.allSubviews;if(o.forEach((e=>{if(e._widthCompressionConstraint)try{t.suggestValue(e._variables[BMLayoutAttribute.Width],e._widthCompressionConstraint._constant)}catch(t){console.log(t)}})),t.updateVariables(),yield,this.supportsAutomaticIntrinsicSize&&!this._subviews.length?(this._assignWidth(),this._prepareForAutomaticIntrinsicSize(),this._updateInternalHeightConstraints()):this._subviews.forEach((t=>{t._assignWidth(),t._prepareForAutomaticIntrinsicSize(),t._updateInternalHeightConstraints()})),yield,i){let i;for(this._verticalLayoutVariables.forEach((e=>t.addEditVariable(e,kiwi.Strength.strong)));YES;){let o,n=[],s=[];try{e.forEach((e=>{i&&i.includes(e)||(o=e,s.push(e),e._kind===BMLayoutConstraintKind.Vertical&&e.constituentConstraints.forEach((e=>{e._constraint=void 0;let i=e._cassowaryConstraint;n.push(i),t.addConstraint(i),e._solver=t})))}));break}catch(e){if(console.error(`[BMCoreUI] Unsatisfiable constraints. The following constraints are not satisfiable and the\n layout operation cannot be completed. Will attempt to solve the layout by breaking constraint \n ${o}. Please check the following constraints at design-time to resolve the problem:\n`),s.forEach((t=>{console.error(`${t}`)})),this._layoutEditor)return;i=i||[],i.push(o),n.forEach((e=>{t.hasConstraint(e)&&t.removeConstraint(e)}))}}}try{t.suggestValue(this._variables[BMLayoutAttribute.Top],0)}catch(t){console.log(t)}o.forEach((e=>{if(e._heightCompressionConstraint)try{t.suggestValue(e._variables[BMLayoutAttribute.Height],e._heightCompressionConstraint._constant)}catch(t){console.log(t)}})),t.updateVariables(),this.frame=BMRectMake(0,0,0|this._variables[BMLayoutAttribute.Width].value(),0|this._variables[BMLayoutAttribute.Height].value()),this._needsIntrinsicSizeMeasurement=NO,this.supportsAutomaticIntrinsicSize&&!this._subviews.length?(this._requiredWidth=void 0,this._needsLayout=NO,this._needsIntrinsicSizeMeasurement=NO):this._subviews.forEach((t=>t._updateFrames())),BMViewDebug&&console.log("\n ***********************************************************************************************************\n [BMCoreUI] Layout pass finished\n ***********************************************************************************************************\n ")},frameForDescendant:t=>(t._constraints.length||t._internalConstraints.length)&&t._hasDeterministicConstraints?BMRectMake(0|t._variables[BMLayoutAttribute.Left].value(),0|t._variables[BMLayoutAttribute.Top].value(),0|t._variables[BMLayoutAttribute.Width].value(),0|t._variables[BMLayoutAttribute.Height].value()):t._referenceFrame,_updateFrames(){this._requiredWidth=void 0,this._needsLayout=NO,this._needsIntrinsicSizeMeasurement=NO,this.frame=this.rootView.frameForDescendant(this),this._subviews.forEach((t=>t._updateFrames()))},_needsLayout:NO,get needsLayout(){return this._needsLayout},set needsLayout(t){this._needsLayout=t,t&&(this.rootView._needsLayout=YES,this.rootView._scheduleLayout())},_rootView:void 0,get rootView(){for(var t=this;t;){if(!t.superview)return t;t=t.superview}},get isRootView(){return void 0===this.superview},_superview:void 0,get superview(){return this._superview},_subviews:void 0,get subviews(){return this._subviews.slice()},addToSuperview(t,e){return t.addSubview(this,e)},addSubview(t,e){if(t.superview==this)return;this.superview||BMView._markAsRootView(this),BMView._markAsNonRootView(t);var i=e&&e.toPosition;void 0===i&&(i=this._subviews.length);var o=this._subviews[i];if(this._subviews.splice(i,0,t),t.superview&&t.superview._detachSubview(t),t._superview=this,o)if(o.node.parentNode!=this.contentNode){let e=this.contentNode.children[i];e?this.contentNode.insertBefore(t.node,e):this.contentNode.appendChild(t.node)}else this.contentNode.insertBefore(t.node,o.node);else t.node.parentNode!=this.contentNode&&this.contentNode.appendChild(t.node);const n=this.rootView;n._invalidatedConstraints=YES,n._invalidatedSizeClasses=YES,n.needsLayout=YES},removeSubview(t){var e=this._subviews.indexOf(t);if(-1!=e){this._subviews.splice(e,1),t._node.parentNode==this.contentNode&&t._node.remove(),t._superview=void 0,this._removeInvalidConstraints(),this._subviews.length||BMView._markAsNonRootView(this),t._subviews.length&&BMView._markAsRootView(t);const i=this.rootView;i._invalidatedConstraints=YES,i._invalidatedSizeClasses=YES,i.needsLayout=YES}},removeFromSuperview(){this._superview&&this._superview.removeSubview(this)},isDescendantOfView(t){let e=this.superview;for(;e;){if(e==t)return YES;e=e.superview}return NO},_removeInvalidConstraints(){let t=new Set;this.activeConstraints.forEach((e=>{t.add(e)})),t.forEach((t=>{if(t.isConstraintCollection){for(let e of t.constituentConstraints)if(e._targetView&&e._sourceView.rootView!=e._targetView.rootView){t.remove();break}}else t._targetView&&t._sourceView.rootView!=t._targetView.rootView&&t.remove()}))},_detachSubview(t){var e=this._subviews.indexOf(t);-1!=e&&this._subviews.splice(e,1)},get allSubviews(){let t=[this];return this._subviews.forEach((e=>t=t.concat(e.allSubviews))),t},_prepareForCloning(){this._BMTempID=BMUUIDMake(),this._BMOriginalID=this.node.id,this.node.id=this._BMTempID,this._subviews.each((t=>t._prepareForCloning()))},_clone(){this._prepareForCloning();let t=this.node.cloneNode(YES);this._cloneForNode(t)},_cloneForNode(t,e){BMView.viewForNode.call(this.constructor,t)._BMOriginalView=this,this.node.id=this._BMOriginalID},additionalSettingTabsForLayoutEditor:t=>[],additionalSettingSectionsForTab:(t,{layoutEditor:e})=>[]}),BMScrollView.scrollView=function(){return BMView.view.call(this)},BMScrollView.scrollViewForNode=function(t,e){return Object.create(BMScrollView.prototype).initWithWrapperDOMNode(t,e)},BMScrollView.prototype=BMExtend({},BMView.prototype,{get contentNode(){return this._node},set contentNode(t){},_contentView:void 0,get contentView(){return this._contentView},_iScroll:void 0,_scrollOffset:void 0,get supportsAutomaticIntrinsicSize(){return NO},initWithDOMNode(t){let e=document.createElement("div");return this.initWithWrapperDOMNode(t,{contentNode:e})},initWithWrapperDOMNode(t,e){return BMView.prototype.initWithDOMNode.call(this,t),this._contentView=BMView.viewForNode.call(BMScrollContentView,e.contentNode),BMView.prototype.addSubview.call(this,this._contentView),t.style.overflow="hidden",t.className="BMScrollView",BMAddSmoothMousewheelInteractionToNode(t),this._iScroll=new IScroll(t,{mouseWheel:YES,scrollbars:YES,probeType:3,click:NO,deceleration:.001,resizePolling:999999999999,scrollX:YES,freeScroll:YES,interactiveScrollbars:!BMIsTouchDevice,disableMouse:YES,disablePointer:YES,fadeScrollbars:BMIsTouchDevice}),this._iScroll.on("scroll",(()=>this._iScrollDidScroll())),this._scrollOffset=BMPointMake(),this},_iScrollDidScroll(){this._scrollOffset=BMPointMake(this._iScroll.x,this._iScroll.y),this.layout()},get bounds(){let t=this._frame.copy();return t.origin=this._scrollOffset,t},addSubview(t,e){this._contentView.addSubview(t,e)},release(){this._contentView.release(),this._iScroll&&this._iScroll.destroy(),BMView.prototype.release.call(this)}}),BMScrollContentView.prototype=BMExtend({},BMView.prototype,{get contentNode(){return this._node},set contentNode(t){},_hasDeterministicConstraints:YES,debuggingName:"Scroll View Content",get supportsAutomaticIntrinsicSize(){return NO},_frame:void 0,get frame(){return this._frame||BMRectMakeWithNodeFrame(this._node)},set frame(t){t.origin=BMPointMake(),Object.getOwnPropertyDescriptor(BMView.prototype,"frame").set.call(this,t),BMAnimationContextGetCurrent()?BMAnimationContextAddCompletionHandler((()=>{this.superview._iScroll.refresh()})):this.superview._iScroll&&this.superview._iScroll.refresh()},internalConstraints(){let t=BMView.prototype.internalConstraints.call(this);return this._superviewLeftConstraint?(this._superviewLeftConstraint.constant=this.superview._scrollOffset.x,this._superviewTopConstraint.constant=this.superview._scrollOffset.y,t.push(this._superviewWidthConstraint,this._superviewHeightConstraint,this._superviewLeftConstraint,this._superviewTopConstraint)):(t.push(this._superviewWidthConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,toView:this.superview,secondAttribute:BMLayoutAttribute.Width})),t.push(this._superviewHeightConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,toView:this.superview,secondAttribute:BMLayoutAttribute.Height})),t.push(this._superviewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Leading,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:BMLayoutAttribute.Leading,constant:this.superview._scrollOffset.x})),t.push(this._superviewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Top,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:BMLayoutAttribute.Top,constant:this.superview._scrollOffset.y}))),t}}),BMLayoutGuide.prototype=BMExtend({},BMView.prototype,{get supportsAutomaticIntrinsicSize(){return NO},_position:BMPointMake(),_dragged:NO,_horizontalConstraintAnchor:BMLayoutAttribute.Leading,_verticalConstraintAnchor:BMLayoutAttribute.Top,initWithDOMNode(t){let e;return BMView.prototype.initWithDOMNode.call(this,t),t.addEventListener("mousedown",(t=>{let e;this._dragged=YES,this._horizontalConstraintAnchor==BMLayoutAttribute.Trailing?(this._position=BMPointMake(this.node.offsetLeft+this.node.offsetWidth-this.node.parentNode.offsetWidth,this.node.offsetTop+this.node.offsetHeight-this.node.parentNode.offsetHeight),e=BMPointMake(t.clientX,t.clientY)):(this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop),e=BMPointMake(t.clientX,t.clientY));let i=t=>{let i=BMPointMake(t.clientX,t.clientY);this._position=BMPointMake(this._position.x+i.x-e.x,this._position.y+i.y-e.y),e=i,this.superview&&this.layout(),t.preventDefault()},o=window.getComputedStyle(this.node).cursor,n=document.createElement("div");n.className="BMLayoutGuideMask",n.style.cursor=o,document.body.appendChild(n);let s=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",s,YES),n.remove()};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",s,YES),t.preventDefault()})),t.addEventListener("touchstart",(t=>{if(void 0!==e)return;let i;e=t.changedTouches[0].identifier,this._dragged=YES,this._horizontalConstraintAnchor==BMLayoutAttribute.Trailing?(this._position=BMPointMake(this.node.offsetLeft+this.node.offsetWidth-this.node.parentNode.offsetWidth,this.node.offsetTop+this.node.offsetHeight-this.node.parentNode.offsetHeight),i=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY)):(this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop),i=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY));let o=t=>{let o;for(let i of t.changedTouches)if(i.identifier==e){o=i;break}if(!o)return;let n=BMPointMake(o.clientX,o.clientY);this._position=BMPointMake(this._position.x+n.x-i.x,this._position.y+n.y-i.y),i=n,this.superview&&this.layout(),t.preventDefault()},n=t=>{e=void 0,window.removeEventListener("touchmove",o),window.removeEventListener("touchend",n),window.removeEventListener("touchcancel",n)};window.addEventListener("touchmove",o),window.addEventListener("touchend",n),window.removeEventListener("touchcancel",n),t.preventDefault()})),this},set initialPosition(t){this._dragged||(this._position=t.copy(),this.superview&&this.layout())},internalConstraints(){let t=BMView.prototype.internalConstraints.call(this);return this._superviewLeftConstraint?(this._superviewLeftConstraint.constant=this._position.x,this._superviewTopConstraint.constant=this._position.y,t.push(this._superviewLeftConstraint,this._superviewTopConstraint)):(t.push(this._superviewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:this._horizontalConstraintAnchor,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:this._horizontalConstraintAnchor,constant:this._position.x,priority:500})),t.push(this._superviewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:this._verticalConstraintAnchor,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:this._verticalConstraintAnchor,constant:this._position.y,priority:500}))),t}});const BM_LABEL_VIEW_DEBUG_INTRINSIC_SIZE=NO;function BMAttributedLabelView(){}const _BMAttributedLabelViewRegex=/\${([a-zA-Z0-9]+)}/g;function BMAttributedLabelViewArgument(){}BMAttributedLabelView.prototype=BMExtend(Object.create(BMView.prototype),{_supportsAutomaticIntrinsicSize:YES,get intrinsicSize(){let t=Object.getOwnPropertyDescriptor(BMView.prototype,"intrinsicSize").get.call(this);return BM_LABEL_VIEW_DEBUG_INTRINSIC_SIZE&&console.log("[BMAttributedLabelView] Intrinsic size is "+t),BM_LABEL_VIEW_DEBUG_INTRINSIC_SIZE&&t&&t.width,t},initWithDOMNode(){return BMView.prototype.initWithDOMNode.apply(this,arguments),this.arguments={},this},_contentNode:void 0,get contentNode(){return this._contentNode||this.node},_classPrefix:void 0,get classPrefix(){return this._classPrefix},set classPrefix(t){t=t||"";for(let e in this.arguments){this.arguments[e]._node.className=t+e}},_template:void 0,get template(){return this._template},set template(t){this._template=t,_BMAttributedLabelViewRegex.lastIndex=0;let e,i={},o=0;for(;e=_BMAttributedLabelViewRegex.exec(t);){let t,n=e[1];this.arguments[n]?(t=this.arguments[n],t._index=o,i[n]=t):(t=Object.create(BMAttributedLabelViewArgument.prototype),t._name=n,t._index=o,t._view=this,i[n]=t),o++}t=t.replace(_BMAttributedLabelViewRegex,`<span class=${this._classPrefix}$1></span>`),this.contentNode.innerHTML=t,this.arguments=i;for(let t in i){i[t]._setNode(this._node.querySelectorAll(`.${this._classPrefix+t}`)[0])}this.invalidateIntrinsicSize()},arguments:void 0}),BMAttributedLabelView.labelViewWithTemplate=function(t,e){let i=BMView.view.call(BMAttributedLabelView);i._classPrefix="",i.template=t;for(let t in e)i.arguments[t]&&(i.arguments[t].value=e[t]);return i},BMAttributedLabelView.labelViewForNode=function(t,e){let i=BMView.viewForNode.call(BMAttributedLabelView,t);i._contentNode=e.contentNode,i._classPrefix="",i.template=e.template;for(let t in e.arguments)i.arguments[t]&&(i.arguments[t].value=e.arguments[t]);return i},BMAttributedLabelViewArgument.prototype={_view:void 0,_name:void 0,_index:void 0,_value:"",get value(){return this._value},set value(t){(t=void 0===t?"":t)!=this._value&&(this._value=t,this._node&&(this._node.innerText=t,this._view.invalidateIntrinsicSize()))},_style:void 0,get style(){return this._style},set style(t){if(this._node){if(t=t||{},this._style)for(let e in this._style)e in t||this._node.style.removeProperty(e);this._style=t;for(let t in this._style)this._node.style[t]=this._style[t];this._view.invalidateIntrinsicSize()}else this._style=t||{}},_node:void 0,get node(){return this._node},_setNode:function(t){this._node=t,t.innerText=this._value,BMCopyProperties(t.style,this._style||{})}};const BM_TEXT_FIELD_MAX_SUGGESTIONS=10;function BMTextField(){}BMTextField.prototype=BMExtend(Object.create(BMView.prototype),{constructor:BMTextField,supportsAutomaticIntrinsicSize:NO,supportsIntrinsicSize:NO,_autoCompletes:YES,get autoCompletes(){return this._autoCompletes},set autoCompletes(t){this._autoCompletes=t},_usesSuggestions:YES,get usesSuggestions(){return this._usesSuggestions},set usesSuggestions(t){t!=this._usesSuggestions&&(this._usesSuggestions=t,t?this._setUpEventHandlers():this._clearEventHandlers())},maxSuggestions:10,delegate:void 0,initWithDOMNode(t){return BMView.prototype.initWithDOMNode.apply(this,arguments),this._usesSuggestions&&this._setUpEventHandlers(),this},_focusHandler:void 0,_blurHandler:void 0,_keydownHandler:void 0,_inputHandler:void 0,_pasteHandler:void 0,_setUpEventHandlers(){const t=this.node;let e,i,o=[],n=[];t.addEventListener("focus",this._focusHandler=async s=>{if(!this._usesSuggestions)return;let a=[];if(!this.delegate||!this.delegate.textFieldSuggestionsForText)return;o=this.delegate.textFieldSuggestionsForText(this,this.value),n=o,i=-1;let r=this.maxSuggestions;for(const i of o)if(a.push(this._menuItemWithLabel(i,{action:()=>{e=void 0,t.value=i,this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this),t.blur()}})),r--,!r)break;let l=YES;if(this.delegate.textFieldShouldShowSuggestions&&(l=this.delegate.textFieldShouldShowSuggestions(this)),l&&o.length){let i=BMRectMakeWithNodeFrame(t),o=BMPointMake(i.origin.x,i.bottom);e=this._showMenuAtPoint(o,{withOptions:a,kind:BMMenuKind.PullDownMenu}),e.classList.add("BMLayoutEditorConstantSuggestions"),e.parentNode.classList.add("BMLayoutEditorConstantSuggestionsOverlay"),e.addEventListener("mousedown",(t=>t.preventDefault()),YES)}const h=t=>t.preventDefault();t.addEventListener("mouseup",h),await new Promise((t=>setTimeout(t,200))),t.removeEventListener("mouseup",h)});let s=NO;t.addEventListener("keydown",this._keydownHandler=o=>{if(this._usesSuggestions){if("ArrowDown"==o.code||"ArrowUp"==o.code){if(o.preventDefault(),0==n.length)return;if(i="ArrowUp"==o.code?Math.max((i||0)-1,0):Math.min((isNaN(i)?-1:i)+1,n.length-1,this.maxSuggestions-1),e){for(const t of e.querySelectorAll(".BMLayoutEditorConstraintPopupOptionHighlighted"))t.classList.remove("BMLayoutEditorConstraintPopupOptionHighlighted");e.childNodes[i].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted")}}if("Enter"==o.code){let e=YES;if(this.delegate&&this.delegate.textFieldShouldReturn&&(e=this.delegate.textFieldShouldReturn(this)),void 0===e&&(e=YES),!e)return;let o=NO;!isNaN(i)&&n.length&&n[i]&&(this.delegate&&this.delegate.textFieldShouldAutocompleteText&&(o=this.delegate.textFieldShouldAutocompleteText(this,t.value,{withSuggestion:n[i]})),o&&(t.value=n[i],this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this))),t.blur()}"Backspace"!=o.code&&"Delete"!=o.code||(s=YES)}}),t.addEventListener("input",this._inputHandler=a=>{let r=NO;this._usesSuggestions||r||this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this),this.delegate&&this.delegate.textFieldSuggestionsForText&&(o=this.delegate.textFieldSuggestionsForText(this,this.value)),n=o.filter((e=>e.toLowerCase().startsWith(t.value.toLowerCase()))),n.length=Math.min(n.length,this.maxSuggestions),e&&(e.innerHTML=""),i=0;let l=this.maxSuggestions;if(e)for(const i of n)if(e.appendChild(this._menuItemWithLabel(i,{action:()=>{e=void 0,t.value=i,this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this)}})),l--,!l)break;if(n.length){if(e){e.childNodes[0].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted"),e.style.display="block";let i=BMRectMakeWithNodeFrame(t),o=BMPointMake(i.origin.x,i.bottom);this._repositionMenu(e,{atPoint:o})}if(this._autoCompletes&&!s){const e=t.selectionStart;e==t.value.length&&(r=YES,t.value=n[0],t.setSelectionRange(e,t.value.length,"backward"),this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this))}s&&(s=NO)}else e&&(e.style.display="none");r||this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this)}),t.addEventListener("blur",this._blurHandler=t=>{e&&e.parentNode.dispatchEvent(new Event("click"))}),t.addEventListener("paste",this._pasteHandler=t=>{this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this)})},_clearEventHandlers(){this.node.removeEventListener("focus",this._focusHandler),this.node.removeEventListener("blur",this._blurHandler),this.node.removeEventListener("keydown",this._keydownHandler),this.node.removeEventListener("input",this._inputHandler),this.node.removeEventListener("input",this._pasteHandler)},_menuItemWithLabel(t,e){let i=document.createElement("div");return i.className="BMLayoutEditorConstraintPopupOption",i.innerText=t,i.addEventListener("click",e.action),i},_showMenuAtPoint(t,e){let i=document.createElement("div");i.className="BMLayoutEditorConstraintPopup BMTextFieldSuggestions";let o=i,n=document.createElement("div");n.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(i.style.backgroundColor="white"),n.appendChild(i),e.withOptions.forEach((t=>i.appendChild(t))),BMHook(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0}),document.body.appendChild(n),this._repositionMenu(o,{atPoint:t}),i.addEventListener("click",(t=>t.preventDefault())),(window.Velocity||$.Velocity).animate(i,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>(i.style.pointerEvents="all",n.style.pointerEvents="all")});let s=0;for(let t of i.childNodes)BMHook(t,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(t,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:s}),s+=16;return n.addEventListener("click",(t=>{i.style.pointerEvents="none",n.style.pointerEvents="none";let o=16*i.childNodes.length+100-200;o=o<0?0:o,(window.Velocity||$.Velocity).animate(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0,translateZ:0},{duration:200,easing:"easeInQuad",delay:o,complete:t=>n.remove()}),o=0;for(let t=i.childNodes.length-1;t>=0;t--){let e=i.childNodes[t];(window.Velocity||$.Velocity).animate(e,{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:o}),o+=16}})),i},_repositionMenu(t,{atPoint:e}){let i=t.offsetHeight;t.style.transformOrigin="50% 0%",i+e.y>document.documentElement.clientHeight&&(t.style.transformOrigin="50% 100%",e.y-=i+this.frame.size.height),t.style.left=e.x+"px",t.style.top=e.y+"px"}}),BMTextField.textField=function(){const t=document.createElement("input");t.type="text";return Object.create(BMTextField.prototype).initWithDOMNode(t)},BMTextField.textFieldForInputNode=function(t){return Object.create(BMTextField.prototype).initWithDOMNode(t)};var BMCollectionViewLayoutAttributesType=Object.freeze({Cell:{},SupplementaryView:{},DecorationView:{}}),BMCellAttributesType=BMCollectionViewLayoutAttributesType,BMCollectionViewLayoutAttributesStyleDefaults=Object.freeze({opacity:1,scaleX:1,scaleY:1,rotate:0,rotateX:0,rotateY:0,rotateZ:0,skewX:0,skewY:0,skewZ:0,transformOriginX:"50%",transformOriginY:"50%",translateZ:0,blur:"0px"}),BMCellAttributesStyleDefaults=BMCollectionViewLayoutAttributesStyleDefaults;function BMCollectionViewLayoutAttributes(){}var BMCellAttributes=BMCollectionViewLayoutAttributes;function BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t){var e=new BMCollectionViewLayoutAttributes;return e.indexPath=t,e._itemType=BMCollectionViewLayoutAttributesType.Cell,e._style={},e}BMCollectionViewLayoutAttributes.prototype={_cell:void 0,get cell(){return this._cell},set cell(t){this._cell=t,t&&t.element&&(t._previousFrame&&t._previousFrame.isEqualToRect(this.frame)&&t.retainCount||this._hookFrame(),this._style&&Object.keys(this._style).length&&(this._style.translateX=this.frame.origin.x+"px",this._style.translateY=this.frame.origin.y+"px",this.hook(this._style)))},_itemType:BMCollectionViewLayoutAttributesType.Cell,get itemType(){return this._itemType},identifier:void 0,_frame:void 0,get frame(){return this._frame},set frame(t){this._frame=t.copy(),this._hookFrame()},_hookFrame:function(){var t=this.frame;if(this._cell&&this._cell.element){var e={translateX:t.origin.x+"px",translateY:t.origin.y+"px"};this._cell._lastAssignedWidth!=t.size.width&&(e.width=t.size.width+"px"),this._cell._lastAssignedHeight!=t.size.height&&(e.height=t.size.height+"px"),(e.width||e.height)&&this._cell.collectionView.delegate&&this._cell.collectionView.delegate.collectionViewWillResizeCell&&this._cell.collectionView.delegate.collectionViewWillResizeCell(this._cell.collectionView,this._cell,{toSize:t.size.copy()}),this.hook(e)}},_flatten:function(){this._cell&&(this.style={},this._cell.element[0].style.transform="",BMCopyProperties(this._cell.element[0].style,{left:this._frame.origin.x+"px",top:this._frame.origin.y+"px"}))},_style:void 0,get style(){return this._style||(this._style={}),this._style},set style(t){delete(t=t||{}).width,delete t.height,delete t.left,delete t.right,delete t.translateX,delete t.translateY;var e=this._style;for(i in this._style={translateX:this.frame.origin.x+"px",translateY:this.frame.origin.y+"px"},t)this._style[i]=t[i];if(e)for(var i in e)void 0===t[i]&&(t[i]=BMCollectionViewLayoutAttributesStyleDefaults[i]);this.hook(t)},addStyle:function(t){for(var e in delete t.width,delete t.height,delete t.left,delete t.right,delete t.translateX,delete t.translateY,t)this._style[e]=t[e];this.hook(t)},_isHidden:NO,get isHidden(){return this._isHidden},set isHidden(t){this._isHidden=t},hook:function(t){if(this._cell&&this._cell.element){var e=this;if(BMAnimationContextGetCurrent()){var i=BMAnimationContextGetCurrent(),o=i.subscribers.get(this);this._cell._isHidden==this._isHidden||this._isHidden||(this._cell.isHidden=NO),o||(o={prepare(){if(e._cell){for(var i={},o=0;o<this.properties.length;o++){var n=this.properties[o];for(var s in n)i[s]=n[s]}if(this._propertyMap=i,t.width||t.height){var a=BMRectMakeWithOrigin(BMPointMake(),{size:e.frame.size.copy()});e._cell.boundsWillChangeToBounds(a)}}},apply:function(i){if(!e._cell)return;var o=this._propertyMap,n=e._cell;let s;n._layoutAnimator=new Promise((t=>s=t));e._cell._bounds;if(t.width||t.height){var a=BMRectMakeWithOrigin(BMPointMake(),{size:e.frame.size.copy()});YES,a.copy()}var r=NO,l=e.frame.size.width,h=e.frame.size.height;i.targets.push({element:e._cell.element[0],properties:o,complete:function(){if(!r&&(r=YES,o.width&&(n._lastAssignedWidth=l),o.height&&(n._lastAssignedHeight=h),n._isHidden!=e._isHidden&&e._isHidden&&(n.isHidden=YES),s(),n._layoutAnimator=void 0,t.width||t.height)){var i=BMRectMakeWithOrigin(BMPointMake(),{size:e.frame.size.copy()}),a=n._bounds;n._bounds=i,n.boundsDidChangeFromBounds(a),n.collectionView.delegate&&n.collectionView.delegate.collectionViewDidResizeCell&&n.collectionView.delegate.collectionViewDidResizeCell(n.collectionView,n,{toSize:e.frame.size.copy()})}}})},properties:[]},i.subscribers.set(this,o)),o.properties.push(t),(t.width||t.height)&&(e._cell.needsLayout=YES)}else{if(BMHook(this._cell.element[0],t),t.width&&(this._cell._lastAssignedWidth=this.frame.size.width),t.height&&(this._cell._lastAssignedHeight=this.frame.size.height),t.width||t.height){this._fraction||(e._cell.needsLayout=YES);var n=BMRectMakeWithOrigin(BMPointMake(),{size:this.frame.size.copy()});this._cell.boundsWillChangeToBounds(n);var s=this._cell._bounds;this._cell._bounds=n,this._cell.boundsDidChangeFromBounds(s),this._cell.collectionView.delegate&&this._cell.collectionView.delegate.collectionViewDidResizeCell&&this._cell.collectionView.delegate.collectionViewDidResizeCell(this._cell.collectionView,this._cell,{toSize:this.frame.size.copy()})}this._isHidden!=this._cell._isHidden&&(this._cell.isHidden=this._isHidden)}}},indexPath:void 0,copy:function(){var t=new BMCollectionViewLayoutAttributes;return t._frame=this._frame.copy(),t.indexPath=this.indexPath.copy(),t._style=BMCopyProperties({},this._style),t._itemType=this._itemType,t.identifier=this.identifier,t}};var BMCellAttributesMakeForCellAtIndexPath=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath;function BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(t,e){var i=new BMCollectionViewLayoutAttributes;return i.indexPath=e.atIndexPath,i._itemType=BMCollectionViewLayoutAttributesType.SupplementaryView,i.identifier=t,i._style={},i}var BMCellAttributesMakeForSupplementaryViewWithIdentifier=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier,_BMCollectionViewTransitionLayoutAttributesUnitRegex=/\-?\+?\d*\.?\d*(\D*)/,_BMCollectionViewTransitionCellAttributesUnitRegex=_BMCollectionViewTransitionLayoutAttributesUnitRegex;function _BMCollectionViewTransitionLayoutAttributes(){}function _BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(t,e){var i=new _BMCollectionViewTransitionLayoutAttributes;return i.indexPath=t.indexPath.copy(),i._itemType=t._itemType,i.identifier=t.identifier,i._sourceAttributes=t,i._targetAttributes=e.targetAttributes,i.fraction=0,i._frame=t._frame,i}_BMCollectionViewTransitionLayoutAttributes.prototype=BMExtend({},BMCollectionViewLayoutAttributes.prototype,{_sourceAttributes:void 0,get sourceAttributes(){return this._sourceAttributes},_targetAttributes:void 0,get targetAttributes(){return this._targetAttributes},_fraction:0,get fraction(){return this._fraction},set fraction(t){this._sourceAttributes.isHidden&&this._targetAttributes.isHidden?this.isHidden=YES:this.isHidden=NO,this._fraction=t,this._frame=BMRectByInterpolatingRect(this._sourceAttributes._frame,{toRect:this._targetAttributes._frame,withFraction:t}),this._hookFrame();var e=BMCopyProperties(this._sourceAttributes.style,{translateX:this._sourceAttributes._frame.origin.x+"px",translateY:this._sourceAttributes._frame.origin.y+"px"}),i=BMCopyProperties(this._targetAttributes.style,{translateX:this._targetAttributes._frame.origin.x+"px",translateY:this._targetAttributes._frame.origin.y+"px"});if(this._style||(this._style={}),!this._intermediateTransitionStyle){for(var o in this._intermediateTransitionStyle={},e){this._intermediateTransitionStyle[o]={source:parseFloat(e[o])};var n=parseFloat(i[o]);isNaN(n)&&(n=parseFloat(BMCollectionViewLayoutAttributesStyleDefaults[o])),this._intermediateTransitionStyle[o].target=n;var s=_BMCollectionViewTransitionLayoutAttributesUnitRegex.exec(e[o])[1]||"";this._intermediateTransitionStyle[o].unit=s}for(var o in i)if(!this._intermediateTransitionStyle[o]){this._intermediateTransitionStyle[o]={target:parseFloat(i[o])};var a=parseFloat(e[o]);isNaN(a)&&(a=parseFloat(BMCollectionViewLayoutAttributesStyleDefaults[o])),this._intermediateTransitionStyle[o].source=a;s=_BMCollectionViewTransitionCellAttributesUnitRegex.exec(i[o])[1]||"";this._intermediateTransitionStyle[o].unit=s}}var r=this._intermediateTransitionStyle;for(var o in r){var l=r[o];this._style[o]=BMNumberByInterpolatingNumbersWithFraction(l.source,l.target,t)+l.unit}this.hook(this._style)},_applyFinalAttributes:function(){this._cell&&(this._cell.attributes=this._targetAttributes)},_layout(){this._cell&&(this._frame=this._targetAttributes.frame,this._cell.needsLayout=YES)}});var _BMCollectionViewTransitionCellAttributesMakeWithSourceAttributes=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes;function BMJQueryShim(){}BMJQueryShim.prototype={0:document.body,css(t,e){if("string"==typeof t)this[0].style[t]=e;else for(const e in t)this[0].style[e]=t[e]},width(){return this[0].offsetWidth},height(){return this[0].offsetHeight},offset(){return{left:this[0].offsetLeft,top:this[0].offsetTop}},append(t){"string"!=typeof t?this[0].append(t[0]):this[0].insertAdjacentHTML("beforeend",t)},empty(){this[0].innerHTML=""},remove(){this[0].remove()}},BMJQueryShim.shimWithDOMNode=function(t){if("$"in window)return $(t);const e=new BMJQueryShim;return e[0]=t,e};const BM_USE_BMVIEW_SUBCLASS=YES,BMCollectionViewCellReuseState=Object.freeze({InUse:"InUse",InQueue:"InQueue",Deleting:"Deleting",Discarded:"Discarded"});function BMCollectionViewCell(){}var BMCell=BMCollectionViewCell;function BMCollectionViewCellMakeForCollectionView(t,e){return(new BMCollectionViewCell).initWithCollectionView(t,e)}BMCollectionViewCell.prototype=BMExtend(BM_USE_BMVIEW_SUBCLASS?Object.create(BMView.prototype):{},{get retainCount(){return this._retainCount+this._manageCount},get isManaged(){return this._manageCount>0},get isRetained(){return this.retainCount>0},get _frame(){return this._attributes&&this._attributes.frame},get frame(){return this._attributes&&this._attributes.frame},set frame(t){},get supportsAutomaticIntrinsicSize(){return this._isMeasuring&&!this._subviews.length?YES:NO},collectionView:void 0,_element:void 0,get element(){return this._element||(this._element=BMJQueryShim.shimWithDOMNode(this.node))},itemType:BMCollectionViewLayoutAttributesType.Cell,_reuseIdentifier:void 0,get reuseIdentifier(){return this._reuseIdentifier},set reuseIdentifier(t){t!=this._reuseIdentifier&&this.collectionView.assignsReuseIdentifierAsClass&&(this._reuseIdentifier&&this.node.classList.remove(`BMCollectionViewCell-${this._reuseIdentifier}`),t&&this.node.classList.add(`BMCollectionViewCell-${t}`),this._reuseIdentifier=t)},_bounds:BMRectMake(),get bounds(){return this._bounds},boundsWillChangeToBounds(t){},boundsDidTransitionToBounds(t){},boundsDidChangeFromBounds(t){},_attributes:void 0,get attributes(){return this._attributes},set attributes(t){var e=this._attributes;if(this._attributes?(this._attributes.cell=void 0,this._previousFrame=e.frame.copy()):this._previousFrame=void 0,this._attributes=t,t){if(t.cell=void 0,e&&e.style)for(var i in t.style=t.style||{},e.style)void 0===t.style[i]&&(t.style[i]=BMCollectionViewLayoutAttributesStyleDefaults[i]);t&&(t.cell=this)}},get indexPath(){return this._attributes?this._attributes.indexPath:void 0},_manage:function(){return this._manageCount||(this._manageCount++,this.collectionView.cellWasManaged(this),1===this.retainCount&&(this.prepareForDisplay(),this.collectionView.cellShouldRender(this))),this},_unmanage:function(){this._manageCount&&(this._manageCount--,this.collectionView.cellWasUnmanaged(this),0===this.retainCount&&(this.prepareForReuse(),this.collectionView.cellWasReleased(this)))},retain:function(){return this._retainCount++,1==this.retainCount&&(this.prepareForDisplay(),this.collectionView.cellShouldRender(this)),this},release:function(){this._retainCount--,0==this.retainCount&&(this.prepareForReuse(),this.collectionView.cellWasReleased(this))},recycle:function(){this._unmanage(),this.retainCount>0&&(this.invalidate(),this.collectionView.cellWasInvalidated(this),this.destroy(),this._manage=function(){},this._unmanage=this._manage,this.retain=this._manage,this.release=this.retain,this.recycle=this.retain,this.releaseRecycledCell=this.retain)},releaseRecycledCell:function(){this.release(),this.retainCount>0&&(this.invalidate(),this.collectionView.cellWasInvalidated(this),this.destroy(),this._manage=function(){},this._unmanage=this._manage,this.retain=this._manage,this.release=this.retain,this.recycle=this.retain,this.releaseRecycledCell=this.retain)},_reuseState:BMCollectionViewCellReuseState.InQueue,get reuseState(){return this._reuseState},_isHidden:NO,get isHidden(){return this._isHidden},set isHidden(t){this._isHidden!=t&&(t?this._hide():this._show())},_hide:function(){this._isHidden=YES,this.node.classList.add("BMCollectionViewCellHidden")},_show:function(){this._isHidden=NO,this.node.classList.remove("BMCollectionViewCellHidden")},_prepareForAutomaticIntrinsicSize(){for(let t of this._subviews)t._prepareForAutomaticIntrinsicSize();this._isMeasuring&&(this._subviews.length?BMCopyProperties(this._node.style,{width:"100%",height:"100%"}):this._requiredWidth?BMCopyProperties(this._node.style,{width:this._requiredWidth+"px",height:"auto"}):BMCopyProperties(this._node.style,{width:"auto",height:"auto"}))},_supportsAutomaticIntrinsicSize:NO,_isMeasuring:NO,internalConstraints(){var t=[];return this._isMeasuring||(this._rootViewLeftConstraint?(this.attributes&&(this._rootViewWidthConstraint.constant=this.attributes.frame.size.width,this._rootViewHeightConstraint.constant=this.attributes.frame.size.height),t.push(this._rootViewLeftConstraint,this._rootViewTopConstraint,this._rootViewWidthConstraint,this._rootViewHeightConstraint)):t.push(this._rootViewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Left,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Top,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewWidthConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.Equals,constant:this.attributes?this.attributes.frame.size.width:0}),this._rootViewHeightConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.Equals,constant:this.attributes?this.attributes.frame.size.height:0}))),t},prepareForAnimatedUpdate(){},prepareForReuse(){this._reuseState=BMCollectionViewCellReuseState.InQueue},prepareForDisplay(){this._reuseState=BMCollectionViewCellReuseState.InUse},invalidate(){},destroy(){BMView.prototype.release.call(this)},get initializesAtomically(){return YES},initWithCollectionView(t,e){return this._retainCount=0,this._manageCount=0,this.collectionView=t,BM_USE_BMVIEW_SUBCLASS?BMView.prototype.initWithDOMNode.call(this,e.node):this.node=e.node,this.reuseIdentifier=e.reuseIdentifier,e.kind&&(this.itemType=e.kind),this},_collectionViewDidBecomeVisible(){for(const t of this.allSubviews)t.viewDidBecomeVisible()},_collectionViewDidBecomeInvisible(){for(const t of this.allSubviews)t.viewDidBecomeInvisible()},initNonatomic:async function(){}});var BMCellMakeForCollectionView=BMCollectionViewCellMakeForCollectionView;function BMCollectionViewLayout(){}function BMCollectionViewLayoutInvalidationContext(){}BMCollectionViewLayout.prototype={_collectionView:void 0,get collectionView(){return this._collectionView},set collectionView(t){this._collectionView=t},attributesForCellAtIndexPath:function(t){throw new Error("attributesForCellAtIndexPath() must be implemented by layout objects.")},attributesForElementsInRect:function(t){throw new Error("attributesForCellsInRect() must be implemented by layout objects.")},contentSize:function(){throw new Error("contentSize() must be implemented by layout objects.")},attributesForSupplementaryViewWithIdentifier:function(t,e){throw new Error("attributesForSupplementaryViewWithIdentifier(_, {atIndexPath}) must be implemented by layout objects that define supplementary views.")},prepareLayout:function(){},get invalidationContextType(){return BMCollectionViewLayoutInvalidationContext},get supportsCopying(){return NO},beginUpdates(){this._copy=this.copy()},applyUpdates(){this._collectionView&&this._collectionView.invalidateLayout(),this._copy=void 0},firstIndexPath(){const t=this.collectionView.numberOfSections();for(let e=0;e<t;e++){if(this.collectionView.numberOfObjectsInSectionAtIndex(e))return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e})}},indexPathToTheLeftOfIndexPath(t){if(t.row>0)return this.collectionView.indexPathForObjectAtRow(t.row-1,{inSectionAtIndex:t.section});if(t.section>0){let e=t.section-1;do{const t=this.collectionView.numberOfObjectsInSectionAtIndex(e);if(t)return this.collectionView.indexPathForObjectAtRow(t-1,{inSectionAtIndex:e});e-=1}while(e>=0)}return t},indexPathAboveIndexPath(t){return this.indexPathToTheLeftOfIndexPath(t)},indexPathToTheRightOfIndexPath(t){const e=this.collectionView.numberOfObjectsInSectionAtIndex(t.section);if(t.row<e-1)return this.collectionView.indexPathForObjectAtRow(t.row+1,{inSectionAtIndex:t.section});const i=this.collectionView.numberOfSections();if(t.section<i-1){let e=t.section+1;do{if(this.collectionView.numberOfObjectsInSectionAtIndex(e))return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e});e+=1}while(e<i)}return t},indexPathBelowIndexPath(t){return this.indexPathToTheRightOfIndexPath(t)},indexPathsFromIndexPath(t,{toIndexPath:e}){const i=[];if(e.section<t.section){const i=e;e=t,t=i}else if(t.section==e.section&&e.row<t.row){const i=e;e=t,t=i}let o=t.row;const n=e.section;for(let s=t.section;s<n+1;s++){let t=this.collectionView.numberOfObjectsInSectionAtIndex(s);for(s==n&&(t=e.row+1);o<t;o++)i.push(this.collectionView.indexPathForObjectAtRow(o,{inSectionAtIndex:s}));o=0}return i},collectionViewWillStartUpdates:function(t){},collectionViewDidStartUpdates:function(){},preferredScrollOffsetWithOffset:function(t){return t},preferredScrollOffsetForTransitionFromLayout:function(t,e){return this.preferredScrollOffsetWithOffset(e.withOffset)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={opacity:0},i},initialAttributesForMovingSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={opacity:0},i},initialAttributesForAppearingCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},initialAttributesForAppearingSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},initialAttributesForRevealingCellAtIndexPath:function(t,e){return this.initialAttributesForAppearingCellAtIndexPath(t,e)},initialAttributesForRevealingSupplementaryViewWithIdentifier:function(t,e){return this.initialAttributesForAppearingSupplementaryViewWithIdentifier(t,e)},initialAttributesForPresentedCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},initialAttributesForPresentedSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},supplementaryViewsToInsert:function(){return[]},finalAttributesForDisappearingCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},finalAttributesForDisappearingSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},finalAttributesForHidingCellAtIndexPath:function(t,e){return this.finalAttributesForDisappearingCellAtIndexPath(t,e)},finalAttributesForHidingSupplementaryViewWithIdentifier:function(t,e){return this.finalAttributesForDisappearingSupplementaryViewWithIdentifier(t,e)},supplementaryViewsToDelete:function(){return[]},invalidateLayout:function(){this._copy||this._collectionView&&this._collectionView.invalidateLayout()},invalidateContentSize:function(){this._copy||this._collectionView&&this._collectionView.invalidateContentSize()},invalidateLayoutWithContext:function(t,e){this._collectionView&&this._collectionView.invalidateLayoutWithContext(t,e)},shouldInvalidateLayoutForFrameChange:function(t,e){return YES},shouldInvalidateLayoutForBoundsChange:function(t,{fromBounds:e}){return NO},didInvalidateLayoutForBoundsChange:function(){},rectWithScrollingPositionOfCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t);return e?e.frame:BMRectMake()},rectWithScrollingPositionOfSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,e);return i?i.frame:BMRectMake()},get snapsScrollPosition(){return NO},snappingScrollOffsetForScrollOffset:function(t,e){return t},prepareForDragOperation(){},dragOperationWillRollback(){},dragOperationDidFinish(){},constraintsForMeasuringCell:(t,{atIndexPath:e})=>[],copy:function(){throw new Error("Layout objects that support copying should implement the copy() method.")},get supportsStatefulCopying(){return NO},statefulCopy(){return this.copy()}},BMCollectionViewLayoutInvalidationContext.prototype={invalidateEverything:NO,invalidateDataSetCounts:NO,contentSizeAdjustment:void 0,invalidatedCellIndexPaths:void 0,invalidatedSupplementaryViewIndexPaths:void 0};var _BMCollectionViewTransitionLayout=function(t,e,i,o){this.transitionAttributes=t,this.initialSize=e,this.targetSize=i,this.targetLayout=o};_BMCollectionViewTransitionLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{_fraction:0,get fraction(){return this._fraction},set fraction(t){if(this.collectionView){this._fraction=t;for(var e=this.transitionAttributes.length,i=0;i<e;i++)this.transitionAttributes[i].fraction=t}},attributesForElementsInRect:function(t){return this.transitionAttributes},contentSize:function(){return BMSizeMake(BMNumberByInterpolatingNumbersWithFraction(this.initialSize.width,this.targetSize.width,this._fraction),BMNumberByInterpolatingNumbersWithFraction(this.initialSize.height,this.targetSize.height,this._fraction))},attributesForCellAtIndexPath:function(t,e){for(let e of this.transitionAttributes)if(e.indexPath.isEqualToIndexPath(t,{usingComparator:this.collectionView.identityComparator}))return e;return this.targetLayout.attributesForCellAtIndexPath(t,e)},attributesForSupplementaryViewWithIdentifier:function(t,e){return this.targetLayout.attributesForSupplementaryViewWithIdentifier(t,e)},_applyFinalAttributes:function(){for(var t=this.transitionAttributes.length,e=0;e<t;e++)this.transitionAttributes[e]._applyFinalAttributes()},_layout(){for(var t=this.transitionAttributes.length,e=0;e<t;e++)this.transitionAttributes[e]._layout();this.collectionView._cellLayoutQueue.dequeue()}});const BM_AUTOMATIC_CELL_SIZE_MESSAGES=NO;var BMCollectionViewTableLayoutSupplementaryView=Object.freeze({Footer:"Footer",Header:"Header",Empty:"Empty"});function BMCollectionViewTableLayout(){}var BMCollectionViewTableLayoutRowHeightVariable=-1;function BMCollectionViewTreeLayout(){}BMCollectionViewTableLayout.prototype=BMExtend(Object.create(BMCollectionViewLayout.prototype),{constructor:BMCollectionViewTableLayout,get supportsCopying(){return YES},_rowHeight:44,get rowHeight(){return this._rowHeight},set rowHeight(t){this._rowHeight=t,this.invalidateLayout()},_minimumWidth:0,get minimumWidth(){return this._minimumWidth},set minimumWidth(t){this._minimumWidth=t,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},_cachedContentSize:void 0,constraintsForMeasuringCell(t,{atIndexPath:e}){return[BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,constant:this.collectionView.frame.size.width})]},prepareLayout(){return this.contentSize()},contentSize:function(){var t=this._sectionInsets.top,e=this._sectionInsets.bottom,i=this.headerHeight,o=this.footerHeight,n=0,s=this.collectionView.numberOfSections();if(n+=s*(i+o+t+e),this._rowHeight>=0)for(var a=0;a<s;a++)n+=this._rowHeight*this.collectionView.numberOfObjectsInSectionAtIndex(a);else for(a=0;a<s;a++)for(var r=this.collectionView.numberOfObjectsInSectionAtIndex(a),l=0;l<r;l++)n+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(l,{inSectionAtIndex:a}));return this._cachedContentSize=BMSizeMake(Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize),Math.max(this.collectionView.frame.size.height,n)),this._cachedContentSize},shouldInvalidateLayoutForBoundsChange:function(t){return this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge},shouldInvalidateLayoutForFrameChange(){return this.collectionView.invalidateMeasuredSizeOfCells(),YES},attributesForCellAtIndexPath:function(t){var e=t.row,i=t.section,o=(i+1)*(this._sectionInsets.top+this.headerHeight)+i*(this._sectionInsets.bottom+this.footerHeight),n=this._cachedContentSize.height>this.collectionView.frame.size.height;if(this._rowHeight>=0)for(var s=0;s<=i;s++){var a=s==i?e:this.collectionView.numberOfObjectsInSectionAtIndex(s);o+=this._rowHeight*a}else for(s=0;s<=i;s++){a=s==i?e:this.collectionView.numberOfObjectsInSectionAtIndex(s);for(var r=0;r<a;r++)o+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(r,{inSectionAtIndex:s}))}var l=BMRectMake(this._sectionInsets.left,o,Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize)-this._sectionInsets.left-this._sectionInsets.right-(n?this.collectionView.scrollBarSize:0),this._rowHeight>=0?this._rowHeight:this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,t)),h=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);return h.frame=l,h},attributesForSupplementaryViewWithIdentifier:function(t,e){var i=this._cachedContentSize.height>this.collectionView.frame.size.height;if(t===BMCollectionViewTableLayoutSupplementaryView.Empty){var o=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return o.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),o}var n=e.atIndexPath.section;if(!(n>=this.collectionView.numberOfSections())){for(var s,a=this.sectionInsets.top,r=this._rowHeight<0,l=this.sectionInsets.top+this.sectionInsets.bottom,h=this.sectionInsets.left,c=Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize)-this.sectionInsets.left-this.sectionInsets.right-(i?this.collectionView.scrollBarSize:0),d=NO,u=NO,p=this.collectionView.scrollOffset,g=this.collectionView.frame,w=0;w<n;w++){s=a+l,a+=this.headerHeight+this.footerHeight+l;var y=this.collectionView.numberOfObjectsInSectionAtIndex(w);if(r)for(var m=0;m<y;m++)a+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(m,{inSectionAtIndex:w}));else a+=y*this._rowHeight}if(d=s<p.y&&a>p.y?YES:NO,u=s>p.y&&a>p.y+g.size.height?YES:NO,t===BMCollectionViewTableLayoutSupplementaryView.Header)return(_=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:e.atIndexPath})).frame=BMRectMake(h,a,c,this.headerHeight),this._pinsHeadersToContentEdge&&d&&(_.frame.origin.y=Math.max(_.frame.origin.y,p.y),_.style.zIndex=1),_;if(t===BMCollectionViewTableLayoutSupplementaryView.Footer){var _;y=this.collectionView.numberOfObjectsInSectionAtIndex(w);if(r)for(m=0;m<y;m++)a+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(m,{inSectionAtIndex:w}));else a+=y*this._rowHeight;return a+=this.headerHeight,(_=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:e.atIndexPath})).frame=BMRectMake(h,a,c,this.footerHeight),this._pinsHeadersToContentEdge&&u&&(_.frame.origin.y=Math.min(_.frame.origin.y,p.y+this.collectionView.frame.size.height-_.frame.size.height),_.style.zIndex=1),_}}},indexPathAtPoint:function(t,e){var i=(e=e||{}).directionNext,o=t.y,n=0,s=this._sectionInsets.top+this.headerHeight,a=this._sectionInsets.bottom+this.footerHeight;if(o<=s)return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:0});n=s;var r=this.collectionView.numberOfSections();if(this._rowHeight>=0){for(var l=0;l<r;l++){if(o<=n+(d=this.collectionView.numberOfObjectsInSectionAtIndex(l))*this._rowHeight){var h=o-n,c=0|Math.floor(h/this._rowHeight);return this.collectionView.indexPathForObjectAtRow(c,{inSectionAtIndex:l})}if(o<=(n+=d*this._rowHeight)+a+s)return i&&l<r-1?this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:l+1}):this.collectionView.indexPathForObjectAtRow(d-1,{inSectionAtIndex:l});n+=a+s}return this.collectionView.indexPathForObjectAtRow(this.collectionView.numberOfObjectsInSectionAtIndex(r-1),{inSectionAtIndex:r-1})}for(l=0;l<r;l++){for(var d=this.collectionView.numberOfObjectsInSectionAtIndex(l),u=0;u<d;u++){var p=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(u,{inSectionAtIndex:l}));if(o<=n+p)return this.collectionView.indexPathForObjectAtRow(u,{inSectionAtIndex:l});n+=p}if(o<=n+a+s)return i&&l<r-1?this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:l+1}):this.collectionView.indexPathForObjectAtRow(d-1,{inSectionAtIndex:l});n+=a+s}return this.collectionView.indexPathForObjectAtRow(this.collectionView.numberOfObjectsInSectionAtIndex(r-1),{inSectionAtIndex:r-1})},attributesForElementsInRect:function(t){var e=this._cachedContentSize.height>this.collectionView.frame.size.height;if(0==this.collectionView.numberOfSections())return(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})).frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),[C];for(var i=this._sectionInsets.top,o=this._rowHeight<0,n=(this._sectionInsets.top,this.headerHeight,this._sectionInsets.bottom,this.footerHeight,this.sectionInsets.left),s=Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize)-this.sectionInsets.left-this.sectionInsets.right-(e?this.collectionView.scrollBarSize:0),a=t.origin.y,r=t.bottom,l=0,h=-1;!(i+this.headerHeight>a);){if(i+=this.headerHeight,h=0,o){for(var c=this.collectionView.numberOfObjectsInSectionAtIndex(l),d=0;d<c;d++){var u=this.collectionView.indexPathForObjectAtRow(d,{inSectionAtIndex:l}),p=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,u);if(i+p>a){h=d;break}i+=p}h=d}else{var g=this.collectionView.numberOfObjectsInSectionAtIndex(l)*this._rowHeight;if(i+g>a){var w=Math.floor((a-i)/this._rowHeight);h=w,i+=w*this._rowHeight;break}h=this.collectionView.numberOfObjectsInSectionAtIndex(l),i+=g}if(i+this.footerHeight>a)break;if(i+=this.footerHeight+this.sectionInsets.top+this.sectionInsets.bottom,h=-1,++l>=this.collectionView.numberOfSections())return[]}var y=[],m=l;this._pinsHeadersToContentEdge&&h>-1&&((C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([l])})).frame=BMRectMake(n,this.collectionView.scrollOffset.y,s,this.headerHeight),C.style.zIndex=1,y.push(C));for(var _,f,v=l;i<r&&!(l>=this.collectionView.numberOfSections());)if(v=l,-1!=h)if(h!=this.collectionView.numberOfObjectsInSectionAtIndex(l)){if(l>=this.collectionView.numberOfSections())return y;(C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(u=this.collectionView.indexPathForObjectAtRow(h,{inSectionAtIndex:l}))).frame=BMRectMake(n,i,s,o?this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,u):this._rowHeight),y.push(C),i+=C.frame.size.height,h++}else{if(!this.showsFooters){h=-1,l++,i+=this.footerHeight+this.sectionInsets.top+this.sectionInsets.bottom;continue}(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([l])})).frame=BMRectMake(n,i,s,this.footerHeight),y.push(C),_=C,f=l,i+=this.footerHeight+this.sectionInsets.top+this.sectionInsets.bottom,h=-1,l++}else{if(!this.showsHeaders){h=0;continue}if((C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([l])})).frame=BMRectMake(n,i,s,this.headerHeight),this._pinsHeadersToContentEdge&&l===m){if(C.frame.origin.y>this.collectionView.scrollOffset.y)if(l-1>-1){var M=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([l-1])});M.frame=BMRectMake(n,Math.min(this.collectionView.scrollOffset.y,C.frame.origin.y-this.headerHeight),s,this.headerHeight),M.style.zIndex=1,y.push(M)}C.frame.origin.y=Math.max(this.collectionView.scrollOffset.y,C.frame.origin.y),C.style.zIndex=1}y.push(C),i+=this.headerHeight,h=0}if(this._pinsFootersToContentEdge)if(v===f){if(_.frame.origin.y<this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-this.footerHeight)if(f+1<this.collectionView.numberOfSections()){var S=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([f+1])});S.frame=BMRectMake(n,Math.max(this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-this.footerHeight,_.frame.bottom),s,this.footerHeight),y.push(S)}_.frame.origin.y=Math.min(_.frame.origin.y,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-_.frame.size.height),_.style.zIndex=1}else{var C;(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([v])})).frame=BMRectMake(n,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-this.footerHeight,s,this.footerHeight),C.style.zIndex=1,y.push(C)}return y},initialAttributesForPresentedCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.x+=e.frame.size.width/2,e.style={opacity:0,translateZ:0},e)},initialAttributesForPresentedSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x+=i.frame.size.width/2,i.style={opacity:0,translateZ:0},i)},initialAttributesForAppearingCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.x+=e.frame.size.width/2,e.style={opacity:0,translateZ:0},e)},initialAttributesForAppearingSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x+=i.frame.size.width/2,i.style={opacity:0,translateZ:0},i)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.attributesForCellAtIndexPath(t)})),i},initialAttributesForMovingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath})})),i},supplementaryViewsToInsert:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=t;n<e;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return t>0&&0==e&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},supplementaryViewsToDelete:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=e;n<t;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return 0==t&&e>0&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},finalAttributesForDisappearingCellAtIndexPath:function(t){var e,i=this;return this.collectionView.usingOldDataSet((function(){e=i.attributesForCellAtIndexPath(t).copy(),i.collectionView.delegate&&i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath?e=i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath(i.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.x-=e.frame.size.width/2,e.style={opacity:0,translateZ:0})})),e},finalAttributesForDisappearingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy(),o.collectionView.delegate&&o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier?i=o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier(o.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x-=i.frame.size.width/2,i.style={opacity:0,translateZ:0})})),i},copy:function(){var t=new BMCollectionViewTableLayout;return t.rowHeight=this.rowHeight,t.showsHeaders=this.showsHeaders,t.headerHeight=this.headerHeight,t.showsFooters=this.showsFooters,t.footerHeight=this.footerHeight,t.sectionInsets=this.sectionInsets,t.pinsHeadersToContentEdge=this.pinsHeadersToContentEdge,t.pinsFootersToContentEdge=this.pinsFootersToContentEdge,t}}),BMExtend(BMCollectionViewTreeLayout.prototype,BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_rowHeight:44,get rowHeight(){return this._rowHeight},set rowHeight(t){this._rowHeight=t,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_indentWidth:22,get indentWidth(){return this._indentWidth},set indentWidth(t){this._indentWidth=t,this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},_layoutCache:void 0,prepareLayout:function(){if(!this.collectionView.invalidationContext)return this.rebuildLayout()},contentSize:function(){return this._layoutCache.contentSize},shouldInvalidateLayoutForBoundsChange:function(t){return this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge},copy(){let t=new BMCollectionViewTreeLayout;return t._rowHeight=this._rowHeight,t._showsHeaders=this._showsHeaders,t._headerHeight=this._headerHeight,t._pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,t._showsFooters=this._showsFooters,t._footerHeight=this._footerHeight,t._pinsFootersToContentEdge=this._pinsFootersToContentEdge,t._indentWidth=this._indentWidth,t._sectionInsets=this.sectionInsets.copy(),t}});var BMCollectionViewFlowLayoutGravity=Object.freeze({Center:{},Start:{},End:{},Edge:{},Spaced:{},Expand:{}}),BMCollectionViewFlowLayoutAlignment=function(){const t={},e={};return Object.freeze({Top:t,Start:t,Center:{},Bottom:e,End:e,Expand:{}})}(),BMCollectionViewFlowLayoutOrientation=Object.freeze({Horizontal:{},Vertical:{}}),BMCollectionViewFlowLayoutSupplementaryView=BMCollectionViewTableLayoutSupplementaryView;function BMCollectionViewFlowLayout(){}function BMCollectionViewMasonryLayout(){}function BMCollectionViewStackLayout(){}BMCollectionViewFlowLayout.prototype=BMExtend(Object.create(BMCollectionViewLayout.prototype),{get supportsCopying(){return YES},_cellSize:void 0,get cellSize(){return this._cellSize},set cellSize(t){this._cellSize=t,this.invalidateLayout()},_expectedCellSize:void 0,get expectedCellSize(){return this._expectedCellSize},set expectedCellSize(t){this._expectedCellSize=t,this.invalidateLayout()},_rowSpacing:44,get rowSpacing(){return this._rowSpacing},set rowSpacing(t){this._rowSpacing=t,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_gravity:BMCollectionViewFlowLayoutGravity.Spaced,get gravity(){return this._gravity},set gravity(t){this._gravity=t,this.invalidateLayout()},_minimumSpacing:0,get minimumSpacing(){return this._minimumSpacing},set minimumSpacing(t){this._minimumSpacing=t,this.invalidateLayout()},_maximumCellsPerRow:0,get maximumCellsPerRow(){return this._maximumCellsPerRow},set maximumCellsPerRow(t){t<0&&(t=0),this._maximumCellsPerRow=t,this.invalidateLayout()},_leftAlignFinalRow:NO,get leftAlignFinalRow(){return this._leftAlignFinalRow},set leftAlignFinalRow(t){this._leftAlignFinalRow=t,this.invalidateLayout()},_alignment:BMCollectionViewFlowLayoutAlignment.Center,get alignment(){return this._alignment},set alignment(t){this._alignment=t,this.invalidateLayout()},_orientation:BMCollectionViewFlowLayoutOrientation.Vertical,get orientation(){return this._orientation},set orientation(t){this._orientation=t,this.invalidateLayout()},_topPadding:0,get topPadding(){return this._topPadding},set topPadding(t){this._topPadding=t,this.invalidateLayout()},_bottomPadding:0,get bottomPadding(){return this._bottomPadding},set bottomPadding(t){this._bottomPadding=t,this.invalidateLayout()},_contentGravity:BMCollectionViewFlowLayoutAlignment.Center,get contentGravity(){return this._contentGravity},set contentGravity(t){this._contentGravity=t,this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},cachedLayout:void 0,collectionViewWillStartUpdates:function(t){this.prepareLayout(),this._expectedCellSize&&this.cachedLayout.iterator.next({rect:this.collectionView.bounds})},collectionViewDidStartUpdates:function(){this.previousLayout=void 0},prepareLayout:function(){return this._prepareLayoutWithScrollbarOffset(NO)},_prepareLayoutWithScrollbarOffset:function(t){if(this.isChangingBounds)return;if(this._expectedCellSize&&this._collectionView.scrollBarSize)if(this.orientation===BMCollectionViewFlowLayoutOrientation.Horizontal){const t=this._sectionInsets.top+this._sectionInsets.bottom,e=this._topPadding+this._bottomPadding,i=this._collectionView.frame.size.height-t-e-this._collectionView.scrollBarSize;this._collectionView.invalidateMeasuredSizeOfCellsWithBlock((t=>t.height>i))}else{const t=this._sectionInsets.left+this._sectionInsets.right,e=this._collectionView.frame.size.width-t-this.collectionView.scrollBarSize;this._collectionView.invalidateMeasuredSizeOfCellsWithBlock((t=>t.width>e))}let e=this._prepareLayoutWithScrollbarOffsetGenerator(t);const i=this.collectionView.numberOfSections(),o=i?this.collectionView.numberOfObjectsInSectionAtIndex(i-1):0;let n=!this._expectedCellSize||!i||this.cachedLayout?.sections?.length==i&&this.cachedLayout?.sections[i-1].rows?.length==o;if(e.next().done){if(!this.cachedLayout.iterator){if(n){this.cachedLayout.resolvedIndexPath=BMIndexPathMakeWithRow(o-1,{inSectionAtIndex:i-1});const t=this.contentSize();this.cachedLayout.resolvedWidth=t.width,this.cachedLayout.resolvedHeight=t.height}this._layoutIterator||(this._layoutIterator={next(){}}),this.cachedLayout.iterator={next(){}}}}else this._layoutIterator=e,this.cachedLayout.iterator=e},*_prepareLayoutWithScrollbarOffsetGenerator(t,e){if(this.isChangingBounds)return;this.previousLayout=t?this.previousLayout:this.cachedLayout;var i=this.collectionView.frame.size.height,o=this.collectionView.frame.size.width;let n=this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?i:o;if(!this._cellSize||this._expectedCellSize){this.cachedLayout={sections:[]},this._expectedCellSize&&this._copy&&((e=e||{}).targetRect?e.targetRect=e.targetRect.rectByUnionWithRect(this.collectionView.bounds):e.targetRect=this.collectionView.bounds),(T=this.cachedLayout).pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,T.pinsFootersToContentEdge=this._pinsFootersToContentEdge;let G=this._orientation;T.orientation=G;var s=this._sectionInsets.top,a=this._sectionInsets.bottom,r=this._sectionInsets.left,l=this._sectionInsets.right,h=this._topPadding,c=this._bottomPadding,d=this.headerHeight,u=this.footerHeight,p=this._sectionInsets.left;this._sectionInsets.right;var g=G==BMCollectionViewFlowLayoutOrientation.Vertical?h:this.collectionView.frame.size.height-this._sectionInsets.top-this._sectionInsets.bottom-(t?this.collectionView.scrollBarSize:0)-h-c;T.availableHeight=g;var w=G==BMCollectionViewFlowLayoutOrientation.Vertical?this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right-(t?this.collectionView.scrollBarSize:0):p;T.availableWidth=w;var y=this.showsHeaders,m=this.showsFooters,_=(d=this.headerHeight,u=this.footerHeight,this.collectionView.numberOfSections()),f=this._rowSpacing,v=this._minimumSpacing;const Q=[],Z=this;function M(t){if(T.resolvedIndexPath){let t,e=T.resolvedIndexPath.section;-1==T.resolvedIndexPath.row&&e--;for(let i=0;i<=e;i++){let o=Q[i],n=T.sections[i];if(i<e||n.resolved)o.start=G==BMCollectionViewFlowLayoutOrientation.Vertical?n.top:n.left,o.preliminaryEnd=o.end,o.end=G==BMCollectionViewFlowLayoutOrientation.Vertical?n.bottom:n.right,o.preliminaryRows=o.rows,o.rows=n.rows.map((t=>G==BMCollectionViewFlowLayoutOrientation.Vertical?{start:t.top,end:t.bottom,indexStart:t.startIndex,indexEnd:t.endIndex}:{start:t.left,end:t.right,indexStart:t.startIndex,indexEnd:t.endIndex}));else{o.preliminaryRows=o.rows,o.rows=[],o.start=G==BMCollectionViewFlowLayoutOrientation.Vertical?n.top:n.left;let e=o.start,i=0;for(const t of n.rows){let n=G==BMCollectionViewFlowLayoutOrientation.Vertical?{start:t.top,end:t.bottom,indexStart:t.startIndex,indexEnd:t.endIndex}:{start:t.left,end:t.right,indexStart:t.startIndex,indexEnd:t.endIndex};o.rows.push(n),e=n.end,i=n.indexEnd}e+=f;for(const n of o.preliminaryRows)if(n.indexEnd>i){t=e-n.start;break}for(const e of o.preliminaryRows)e.indexEnd>i&&(e.start+=t,e.end+=t)}}for(let i=e+1;i<c;i++){void 0===t&&(t=(G==BMCollectionViewFlowLayoutOrientation.Vertical?T.sections[e].bottom:T.sections[e].right)-Q[e].end);const o=Q[i];o.start+=t,o.end+=t;for(const e of o.row)e.start+=t,e.end+=t}}let e=[];var i=t.origin.y,o=t.bottom,n=t.origin.x,s=t.right,a=G==BMCollectionViewFlowLayoutOrientation.Vertical?o:s;const r=G==BMCollectionViewFlowLayoutOrientation.Vertical?i:n;for(var l,h=0,c=Q.length;h<c&&!((l=Q[h]).end>r);h++);if(h!=c){var d=0;for(const t of l.rows){if(t.end>r)break;d++}for(;YES;){if(!(l=Q[h]))return Z.collectionView.measureSizesOfCellsAtIndexPaths(e);const t=l.rows.length;for(let i=d;i<t;i++){const t=l.rows[i];if(t.start>a)return Z.collectionView.measureSizesOfCellsAtIndexPaths(e);const o=Math.min(t.indexEnd+1,Z.collectionView.numberOfObjectsInSectionAtIndex(h));for(let i=t.indexStart;i<o;i++)e.push(Z.collectionView.indexPathForObjectAtRow(i,{inSectionAtIndex:h}))}h++,d=0}}}if(this._expectedCellSize){T.resolvedHeight=0,T.resolvedWidth=0,T.resolvedIndexPath=BMIndexPathMakeWithRow(-1,{inSectionAtIndex:-1}),T.sectionCount=this.collectionView.numberOfSections();let J=this._maximumCellsPerRow,tt=this._expectedCellSize.width,et=this._expectedCellSize.height,it=G==BMCollectionViewFlowLayoutOrientation.Vertical?tt:et,ot=G==BMCollectionViewFlowLayoutOrientation.Vertical?et:tt,nt=G==BMCollectionViewFlowLayoutOrientation.Vertical?w:g;if(!J){if(T.minimumSpacing){J=0;let st=0;this._gravity===BMCollectionViewFlowLayoutGravity.Spaced&&(st=2*v);do{if(st&&st+it+v>nt)break;J&&(st+=v),st+=it,J++}while(st<nt&&it)}else J=nt/it|0;J=Math.max(J,1)}for(let at=0;at<_;at++){let rt=this.collectionView.numberOfObjectsInSectionAtIndex(at),lt=0|Math.ceil(rt/J),ht=(lt-1)*f;if(d&&(ht+=f),u&&(ht+=f),G==BMCollectionViewFlowLayoutOrientation.Vertical){let ct={top:g,start:g,bottom:g+u+d+ot*lt+ht,end:g+u+d+ot*lt+ht,numberOfObjects:rt,numberOfRows:lt,rows:[]},dt=d?g+d+f:g,ut=0;for(let pt=0;pt<lt;pt++)ct.rows.push({start:dt,end:dt+ot,indexStart:ut,indexEnd:ut+J-1}),dt+=ot+f,ut+=J;if((g=ct.bottom+s+a)>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);Q.push(ct)}else{let gt={left:w,start:w,right:w+ot*lt+ht,end:w+ot*lt+ht,numberOfObjects:rt,numberOfRows:lt,rows:[]},wt=w,yt=0;for(let mt=0;mt<lt;mt++)gt.rows.push({start:wt,end:wt+ot,indexStart:yt,indexEnd:yt+J-1}),wt+=ot+f,yt+=J;if((w=gt.right+r+l)>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);Q.push(gt)}}if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if((g+=this._bottomPadding)>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);T.size=BMSizeMake(this.collectionView.frame.size.width,g),e||(e=yield),e.rect&&M(e.rect),g=h}else{if(w>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);T.size=BMSizeMake(w,this.collectionView.frame.size.height),e||(e=yield),e.rect&&M(e.rect),w=0}}for(var S=0;S<_;S++){var C,b={rows:[]};if(T.sections.push(b),G==BMCollectionViewFlowLayoutOrientation.Vertical?(g+=s,b.top=g):(w+=r,b.left=w),y)if(G==BMCollectionViewFlowLayoutOrientation.Vertical)(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(p,g,w,d),this.pinsHeadersToContentEdge&&(C.style={zIndex:1}),b.headerAttributes=C,g+=d+f;else(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(w,h+s,d,g),this.pinsHeadersToContentEdge&&(C.style={zIndex:1}),b.headerAttributes=C,w+=d+f;var B=this.collectionView.numberOfObjectsInSectionAtIndex(S),E=0;let _t=G==BMCollectionViewFlowLayoutOrientation.Vertical?w:g,ft=G==BMCollectionViewFlowLayoutOrientation.Vertical?"width":"height",vt=G==BMCollectionViewFlowLayoutOrientation.Vertical?"height":"width",Mt=G==BMCollectionViewFlowLayoutOrientation.Vertical?"top":"left";for(;E<B;){var V={top:g,left:w,attributes:[],startIndex:E},L=0,x=0;for(this._gravity===BMCollectionViewFlowLayoutGravity.Spaced&&(L=2*v);L<_t||_t<=0;){var A=this.collectionView.indexPathForObjectAtRow(E,{inSectionAtIndex:S}),I=this._expectedCellSize&&this.collectionView.measuredSizeOfCellAtIndexPath(A)||this.collectionView.delegate.collectionViewSizeForCellAtIndexPath(this.collectionView,A);if(I[ft]+L+v>_t&&V.attributes.length)break;var P=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(A);if(P._requireMeasurement=YES,G==BMCollectionViewFlowLayoutOrientation.Vertical?P.frame=BMRectMake(L,g,I.width,I.height):P.frame=BMRectMake(w,L,I.width,I.height),x<I[vt]&&(x=I[vt]),V.attributes.push(P),L+=I[ft],V.attributes.length>1&&(L+=v),E++,V[Mt]+x>n&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if(E>=B||0==w)break}else if(E>=B||0==g)break;if(this._maximumCellsPerRow&&V.attributes.length==this._maximumCellsPerRow)break}if(V.attributes.length&&(G==BMCollectionViewFlowLayoutOrientation.Vertical?(this._reflowRow(V,{forLength:w,breadth:x,withOccupiedLength:L,spacing:v}),g+=x,V.bottom=g,V.endIndex=E-1,b.rows.push(V),g+=f):(this._reflowRow(V,{forLength:g,breadth:x,withOccupiedLength:L,spacing:v}),w+=x,V.right=w,V.endIndex=E-1,b.rows.push(V),w+=f)),e){if(m&&this.pinsFootersToContentEdge)if(G==BMCollectionViewFlowLayoutOrientation.Vertical){let St=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])});St.frame=BMRectMake(p,g,w,u),St.style={zIndex:1},b.footerAttributes=St}else{let Ct=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])});Ct.frame=BMRectMake(w,h+s,u,g),this.pinsFootersToContentEdge&&(Ct.style={zIndex:1}),b.footerAttributes=Ct}if(e.indexPath){let bt=e.indexPath;(bt.section<S||bt.section==S&&bt.row<V.endIndex)&&(T.resolvedHeight=g,T.resolvedWidth=w,T.resolvedIndexPath=V.attributes[V.attributes.length-1].indexPath,G==BMCollectionViewFlowLayoutOrientation.Vertical?g>T.size.height&&(T.size.height=g+f+a+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout height has changed to "+g)):w>T.size.width&&(T.size.width=w+f+l+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout width has changed to "+w)),b.bottom=g,b.right=w,(e=yield).rect&&M(e.rect))}if(e.rect){g>e.rect.bottom&&(T.resolvedHeight=g,T.resolvedWidth=w,T.resolvedIndexPath=V.attributes[V.attributes.length-1].indexPath,G==BMCollectionViewFlowLayoutOrientation.Vertical?g>T.size.height&&(T.size.height=g+f+a+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout height has changed to "+g)):w>T.size.width&&(T.size.width=w+f+l+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout width has changed to "+w)),b.bottom=g,b.right=w,(e=yield).rect&&M(e.rect))}}}var W;if(b.resolved,G==BMCollectionViewFlowLayoutOrientation.Vertical?g-=f:w-=f,m)if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if(g+=f,(W=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(p,g,w,u),this.pinsFootersToContentEdge&&(W.style={zIndex:1}),b.footerAttributes=W,(g+=u)>i&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES)}else if(w+=f,(W=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(w,h+s,u,g),this.pinsFootersToContentEdge&&(W.style={zIndex:1}),b.footerAttributes=W,(w+=u)>o&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if(b.bottom=g,(g+=a)>i&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES)}else if(b.right=w,(w+=l)>o&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES)}if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if((g+=c)>i&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(g<this.collectionView.frame.size.height){let Bt=0;this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?Bt=(this.collectionView.frame.size.height-g)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&(Bt=this.collectionView.frame.size.height-g);let Et=0;if(0!=Bt||this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let Vt=T.sections.length;for(let Lt=0;Lt<Vt;Lt++){let xt=T.sections[Lt];xt.top+=Bt,xt.bottom+=Bt;let At=xt.rows.length;for(let It=0;It<At;It++){let Pt=xt.rows[It];Pt.top+=Bt,Pt.bottom+=Bt,Et+=Pt.bottom-Pt.top;for(let Wt=0;Wt<Pt.attributes.length;Wt++)Pt.attributes[Wt].frame.origin.y+=Bt}xt.headerAttributes&&(xt.headerAttributes.frame.origin.y+=Bt),xt.footerAttributes&&(xt.footerAttributes.frame.origin.y+=Bt)}}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){const Tt=g-Et,zt=(this.collectionView.frame.size.height-Tt)/Et;let kt=0;for(const Ot of this.cachedLayout.sections){Ot.top+=kt,Ot.headerAttributes&&(Ot.headerAttributes.frame.origin.y+=kt);for(const Nt of Ot.rows){const Ft=Nt.bottom-Nt.top;Nt.top+=kt;const Dt=Ft*zt|0;for(const Yt of Nt.attributes)Yt.frame.origin.y+=kt,Yt.frame.size.height=Yt.frame.size.height*zt|0;kt+=Dt-Ft,Nt.bottom+=kt}Ot.bottom+=kt,Ot.footerAttributes&&(Ot.footerAttributes.frame.origin.y+=kt)}}}T.size=BMSizeMake(this.collectionView.frame.size.width,Math.max(g,this.collectionView.frame.size.height))}else{if(w>o&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(w<this.collectionView.frame.size.width){let Rt=0;this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?Rt=(this.collectionView.frame.size.width-w)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&(Rt=this.collectionView.frame.size.width-w);let Ht=0;if(0!=Rt||this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let qt=T.sections.length;for(let Kt=0;Kt<qt;Kt++){let Xt=T.sections[Kt];Xt.left+=Rt,Xt.right+=Rt;let jt=Xt.rows.length;for(let Ut=0;Ut<jt;Ut++){let $t=Xt.rows[Ut];$t.left+=Rt,$t.right+=Rt,Ht+=$t.right-$t.left;for(let Gt=0;Gt<$t.attributes.length;Gt++)$t.attributes[Gt].frame.origin.x+=Rt}Xt.headerAttributes&&(Xt.headerAttributes.frame.origin.x+=Rt),Xt.footerAttributes&&(Xt.footerAttributes.frame.origin.x+=Rt)}}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){const Qt=w-Ht,Zt=(this.collectionView.frame.size.width-Qt)/Ht;let Jt=0;for(const te of this.cachedLayout.sections){te.left+=Jt,te.headerAttributes&&(te.headerAttributes.frame.origin.x+=Jt);for(const ee of te.rows){const ie=ee.right-ee.left;ee.left+=Jt;const oe=ie*Zt|0;for(const ne of ee.attributes)ne.frame.origin.x+=Jt,ne.frame.size.width=ne.frame.size.width*Zt|0;Jt+=oe-ie,ee.right+=Jt}te.right+=Jt,te.footerAttributes&&(te.footerAttributes.frame.origin.x+=Jt)}}}T.size=BMSizeMake(Math.max(w,this.collectionView.frame.size.width),this.collectionView.frame.size.height)}this._expectedCellSize&&e&&this.invalidateContentSize()}else{this.cachedLayout={sections:[],prototypeRows:[]};var T=this.cachedLayout;let se=this._orientation;T.orientation=se,T.sectionInsets=this.sectionInsets,T.rowSpacing=this.rowSpacing,T.showsHeaders=this.showsHeaders,T.showsFooters=this.showsFooters,T.headerHeight=this.headerHeight,T.footerHeight=this.footerHeight,T.minimumSpacing=this.minimumSpacing,T.topPadding=this.topPadding,T.bottomPadding=this.bottomPadding;let ae=this.topPadding,re=this.bottomPadding;T.pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,T.pinsFootersToContentEdge=this._pinsFootersToContentEdge;let le=this.cellSize.width,he=this.cellSize.height,ce=se==BMCollectionViewFlowLayoutOrientation.Vertical?le:he,de=se==BMCollectionViewFlowLayoutOrientation.Vertical?he:le,ue=de;T.cellWidth=le,T.rowHeight=he,T.rowBreadth=de;f=this.rowSpacing,v=this.minimumSpacing,g=se==BMCollectionViewFlowLayoutOrientation.Vertical?ae:this.collectionView.frame.size.height-this._sectionInsets.top-this._sectionInsets.bottom-(t?this.collectionView.scrollBarSize:0)-ae-re;T.availableHeight=g;w=se==BMCollectionViewFlowLayoutOrientation.Vertical?this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right-(t?this.collectionView.scrollBarSize:0):p;T.availableWidth=w;var z=se==BMCollectionViewFlowLayoutOrientation.Vertical?w:g,k=this._maximumCellsPerRow;if(!k){if(T.minimumSpacing){k=0;var O=0;this._gravity===BMCollectionViewFlowLayoutGravity.Spaced&&(O=2*v);do{if(O&&O+ce+v>z)break;k&&(O+=v),O+=ce,k++}while(O<z&&ce)}else k=z/ce|0;k=Math.max(k,1)}T.numberOfColumns=k;for(S=0;S<k;S++){for(var N={attributes:[]},F=this.leftAlignFinalRow?k-1:S,D=ce*(F+1)+v*F,Y=0;Y<=F;Y++)N.attributes.push({frame:BMRectMake(0,0,le,he)});this._reflowRow(N,{forLength:z,breadth:de,withOccupiedLength:D,spacing:v}),T.prototypeRows.push(N)}var R=this.collectionView.numberOfSections();s=this._sectionInsets.top,a=this._sectionInsets.bottom;let pe=this._sectionInsets.left,ge=this._sectionInsets.right;d=this.headerHeight,u=this.footerHeight;if(se==BMCollectionViewFlowLayoutOrientation.Vertical){let we=s+this._topPadding;for(S=0;S<R;S++){var H=this.collectionView.numberOfObjectsInSectionAtIndex(S),q=((j=0|Math.ceil(H/k))-1)*f;d&&(q+=f),u&&(q+=f);let ye={top:we,bottom:we+u+d+ue*j+q,numberOfObjects:H,numberOfRows:j};if(T.sections.push(ye),we=ye.bottom+s+a,we>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES)}if(we+=this._bottomPadding,we>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);if(we<this.collectionView.frame.size.height){var K=0;if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?K=(this.collectionView.frame.size.height-we)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&(K=this.collectionView.frame.size.height-we),0!=K){var X=T.sections.length;for(S=0;S<X;S++){(b=T.sections[S]).top+=K,b.bottom+=K}}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let me=0;for(const Me of T.sections)me+=Me.numberOfRows*ue;const _e=we-me,fe=(this.collectionView.frame.size.height-_e)/me;for(const Se of T.prototypeRows)for(const Ce of Se.attributes)Ce.frame.size.height=Ce.frame.size.height*fe|0;let ve=0;for(const be of T.sections){be.top+=ve;const Be=be.numberOfRows*ue;ve+=(Be*fe|0)-Be,be.bottom+=ve}T.rowHeight=T.rowHeight*fe|0,T.rowBreadth=T.rowBreadth*fe|0}}}else{let Ee=pe;for(S=0;S<R;S++){H=this.collectionView.numberOfObjectsInSectionAtIndex(S);var j,U=((j=0|Math.ceil(H/k))-1)*f;d&&(U+=f),u&&(U+=f);let Ve={left:Ee,right:Ee+de*j+U,numberOfObjects:H,numberOfRows:j};if(T.sections.push(Ve),Ee=Ve.right+pe+ge,Ee>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES)}if(Ee>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);if(Ee<this.collectionView.frame.size.width){var $=0;if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?$=(this.collectionView.frame.size.width-Ee)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&($=this.collectionView.frame.size.width-Ee),0!=$)for(X=T.sections.length,S=0;S<X;S++){(b=T.sections[S]).left+=$,b.right+=$}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let Le=0;for(const Pe of T.sections)Le+=Pe.numberOfRows*ue;const xe=Ee-Le,Ae=(this.collectionView.frame.size.width-xe)/Le;for(const We of T.prototypeRows)for(const Te of We.attributes)Te.frame.size.width=Te.frame.size.width*Ae|0;let Ie=0;for(const ze of T.sections){ze.left+=Ie;const ke=ze.numberOfRows*ue;Ie+=(ke*Ae|0)-ke,ze.right+=Ie}T.cellWidth=T.cellWidth*Ae|0,T.rowBreadth=T.rowBreadth*Ae|0}}}}},constraintsForMeasuringCell(t,{atIndexPath:e}){return[BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:this.collectionView.frame.size.width-this.sectionInsets.left-this.sectionInsets.right})]},reflowRow:function(t,e){var i=e.forWidth,o=e.withOccupiedWidth,n=e.height,s=e.spacing,a=s*(t.attributes.length-1),r=o-a,l=this._gravity,h=this._alignment,c=t.attributes.length,d=l==BMCollectionViewFlowLayoutGravity.Expand?(i-a)/r:1,u=0;if(l==BMCollectionViewFlowLayoutGravity.Expand){for(var p=0,g=0;g<c;g++)p+=t.attributes[g].frame.size.width*d|0;u=(i-a|0)%(0|p)}var w=0,y=this._sectionInsets.left;l===BMCollectionViewFlowLayoutGravity.Center?y=y+(i-o)/2|0:l===BMCollectionViewFlowLayoutGravity.End?y=y+i-o|0:l===BMCollectionViewFlowLayoutGravity.Edge?w=i-((s=(i-r)/(c-1)|0)*(c-1)+r):l===BMCollectionViewFlowLayoutGravity.Spaced&&(w=i-((s=(i-r)/(c+1)|0)*(c+1)+r),y+=s);for(g=0;g<c;g++){var m=t.attributes[g];m.frame.origin.x=y,m.frame.size.width*=d,m.frame.size.width=0|m.frame.size.width,u&&(m.frame.size.width+=1,u--),y+=s+m.frame.size.width,w&&(y+=1,w--),h===BMCollectionViewFlowLayoutAlignment.Center?m.frame.origin.y+=(n-m.frame.size.height)/2|0:h===BMCollectionViewFlowLayoutAlignment.Bottom?m.frame.origin.y+=n-m.frame.size.height:h===BMCollectionViewFlowLayoutAlignment.Expand&&(m.frame.size.height=n)}},_reflowRow:function(t,{forLength:e,breadth:i,withOccupiedLength:o,spacing:n}){var s=n*(t.attributes.length-1),a=o-s,r=this._gravity,l=this._alignment;let h=this._orientation,c=h==BMCollectionViewFlowLayoutOrientation.Vertical?"width":"height",d=h==BMCollectionViewFlowLayoutOrientation.Vertical?"height":"width",u=h==BMCollectionViewFlowLayoutOrientation.Vertical?"x":"y",p=h==BMCollectionViewFlowLayoutOrientation.Vertical?"y":"x";var g=t.attributes.length,w=r==BMCollectionViewFlowLayoutGravity.Expand?(e-s)/a:1,y=0;if(r==BMCollectionViewFlowLayoutGravity.Expand){for(var m=0,_=0;_<g;_++)m+=t.attributes[_].frame.size[c]*w|0;y=(e-s|0)%(0|m)}var f=0,v=h==BMCollectionViewFlowLayoutOrientation.Vertical?this._sectionInsets.left:this._sectionInsets.top+this.topPadding;r===BMCollectionViewFlowLayoutGravity.Center?v=v+(e-o)/2|0:r===BMCollectionViewFlowLayoutGravity.End?v=v+e-o|0:r===BMCollectionViewFlowLayoutGravity.Edge?f=e-((n=(e-a)/(g-1)|0)*(g-1)+a):r===BMCollectionViewFlowLayoutGravity.Spaced&&(f=e-((n=(e-a)/(g+1)|0)*(g+1)+a),v+=n);for(_=0;_<g;_++){var M=t.attributes[_];M.frame.origin[u]=v,M.frame.size[c]*=w,M.frame.size[c]=0|M.frame.size[c],y&&(M.frame.size[c]+=1,y--),v+=n+M.frame.size[c],f&&(v+=1,f--),l===BMCollectionViewFlowLayoutAlignment.Center?M.frame.origin[p]+=(i-M.frame.size[d])/2|0:l===BMCollectionViewFlowLayoutAlignment.Bottom?M.frame.origin[p]+=i-M.frame.size[d]:l===BMCollectionViewFlowLayoutAlignment.Expand&&(M.frame.size[d]=i)}},contentSize:function(){return!this._cellSize||this._expectedCellSize?this.cachedLayout.size:this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?this.cachedLayout.sections.length?BMSizeMake(this.collectionView.frame.size.width,Math.max(this.cachedLayout.sections[this.cachedLayout.sections.length-1].bottom+this._bottomPadding+this.sectionInsets.bottom,this.collectionView.frame.size.height)):this.collectionView.frame.size.copy():this.cachedLayout.sections.length?BMSizeMake(Math.max(this.cachedLayout.sections[this.cachedLayout.sections.length-1].right+this.sectionInsets.right,this.collectionView.frame.size.width),this.collectionView.frame.size.height):this.collectionView.frame.size.copy()},shouldInvalidateLayoutForFrameChange(t,{fromFrame:e}){return e&&e.size.width<t.size.width?this.collectionView.invalidateMeasuredSizeOfCells():this.collectionView.invalidateMeasuredSizeOfCellsWithBlock((t=>t.width>=this.cachedLayout.availableWidth)),YES},shouldInvalidateLayoutForBoundsChange:function(t){var e=this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge;return this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?this._expectedCellSize&&t.bottom>this.cachedLayout.resolvedHeight&&(this._layoutIterator.next({rect:t}),e=YES):this._expectedCellSize&&t.right>this.cachedLayout.resolvedWidth&&(this._layoutIterator.next({rect:t}),e=YES),e&&(this.isChangingBounds=YES),e},didInvalidateLayoutForBoundsChange:function(){this.isChangingBounds=NO},attributesForCellAtIndexPath:function(t){if(this._expectedCellSize&&(this.cachedLayout.resolvedIndexPath.section<t.section||this.cachedLayout.resolvedIndexPath.section==t.section&&this.cachedLayout.resolvedIndexPath.row<t.row)){const e=this.cachedLayout.resolvedHeight;this._layoutIterator.next({indexPath:t}),e!=this.cachedLayout.resolvedHeight&&this.invalidateContentSize()}return!this._cellSize||this._expectedCellSize?this.cachedAttributesForCellAtIndexPath(t):this.computedAttributesForCellAtIndexPath(t)},cachedAttributesForCellAtIndexPath:function(t,e){for(var i=(e&&e.usingCache||this.cachedLayout).sections[t.section].rows,o=t.row,n=i.length,s=0;s<n;s++){var a=i[s];if(o>=a.startIndex&&o<=a.endIndex)return a.attributes[o-a.startIndex]}throw"Unable to find the cached attributes for the cell at the given index path"},computedAttributesForCellAtIndexPath:function(t,e){var i,o=e&&e.usingCache||this.cachedLayout,n=t.section,s=o.sections[n],a=o.numberOfColumns,r=s.numberOfObjects,l=t.row,h=l/a|0,c=l%a;if(h==(r/a|0))var d=r%a||a,u=o.prototypeRows[d-1];else u=o.prototypeRows[a-1];if(o.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){let e=s.top;o.showsHeaders&&(e+=o.headerHeight+o.rowSpacing),e+=h*(o.rowHeight+o.rowSpacing),(i=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=u.attributes[c].frame.copy(),i.frame.origin.y=e}else{let e=s.left;o.showsHeaders&&(e+=o.headerHeight+o.rowSpacing),e+=h*(o.rowBreadth+o.rowSpacing),(i=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=u.attributes[c].frame.copy(),i.frame.origin.x=e}return i},attributesForSupplementaryViewWithIdentifier:function(t,e){if(t===BMCollectionViewTableLayoutSupplementaryView.Empty){var i=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return i.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),i}return this._expectedCellSize&&(this.cachedLayout.resolvedIndexPath.section<e.atIndexPath.section||this.cachedLayout.resolvedIndexPath.section==e.atIndexPath.section&&t==BMCollectionViewFlowLayoutSupplementaryView.Footer)&&(e.atIndexPath.section==this.collectionView.numberOfSections()-1?this._layoutIterator.next({indexPath:this.collectionView.indexPathForObjectAtRow(this.collectionView.numberOfObjectsInSectionAtIndex(e.atIndexPath.section)-1,{inSectionAtIndex:e.atIndexPath.section})}):this._layoutIterator.next({indexPath:this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e.atIndexPath.section+1})})),!this._cellSize||this._expectedCellSize?this.cachedAttributesForSupplementaryViewWithIdentifier(t,e):this.computedAttributesForSupplementaryViewWithIdentifier(t,e)},cachedAttributesForSupplementaryViewWithIdentifier:function(t,e){var i=e&&e.usingCache||this.cachedLayout,o=e.atIndexPath.section;if(!(o>=i.sections.length))return t===BMCollectionViewFlowLayoutSupplementaryView.Header?i.sections[o].headerAttributes:t===BMCollectionViewFlowLayoutSupplementaryView.Footer?i.sections[o].footerAttributes:void 0},computedAttributesForSupplementaryViewWithIdentifier:function(t,e){var i=e&&e.usingCache||this.cachedLayout,o=e.atIndexPath.section;if(!(o>=i.sections.length)){var n=i.sections[o],s=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath});return t===BMCollectionViewFlowLayoutSupplementaryView.Header?(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?s.frame=BMRectMake(i.sectionInsets.left,n.top,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):s.frame=BMRectMake(n.left,i.sectionInsets.top+i.topPadding,i.headderHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),s):t===BMCollectionViewFlowLayoutSupplementaryView.Footer?(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?s.frame=BMRectMake(i.sectionInsets.left,n.bottom-i.footerHeight,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):s.frame=BMRectMake(n.right-i.footerHeight,i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),s):void 0}},attributesForElementsInRect:function(t){if(this._expectedCellSize&&(this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?this.cachedLayout.resolvedHeight<t.bottom&&(this._layoutIterator.next({rect:t}),this.invalidateContentSize()):this.cachedLayout.resolvedWidth<t.right&&(this._layoutIterator.next({rect:t}),this.invalidateContentSize())),0==this.collectionView.numberOfSections()){var e=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return e.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),[e]}return!this._cellSize||this._expectedCellSize?this.cachedAttributesForElementsInRect(t):this.computedAttributesForElementsInRect(t)},cachedAttributesForElementsInRect:function(t,e){for(var i=e&&e.usingCache||this.cachedLayout,o=[],n=t.origin.y,s=t.bottom,a=t.origin.x,r=t.right,l=0,h=this._expectedCellSize?i.sectionCount:i.sections.length;l<h;l++)if(_=i.sections[l],i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(_.bottom>n)break}else if(_.right>a)break;if(l==h)return o;var c=-1;if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(!_.headerAttributes||_.headerAttributes.frame.bottom<n){c=0;for(var d=(f=_.rows).length,u=0;u<d;u++)if(f[u].bottom>n){c=u;break}c=u}}else if(!_.headerAttributes||_.headerAttributes.frame.right<a){c=0;for(d=(f=_.rows).length,u=0;u<d;u++)if(f[u].right>a){c=u;break}c=u}var p,g,w=_,y=_;if(i.pinsHeadersToContentEdge&&-1!=c){var m=_.headerAttributes.copy();i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?m.frame.origin.y=this.collectionView.scrollOffset.y:m.frame.origin.x=this.collectionView.scrollOffset.x,o.push(m)}try{for(;l<h;l++){var _;if(!(_=i.sections[l])&&this._expectedCellSize)return o;var f;for(d=(f=_.rows).length;c<=d;c++)if(-1==c){if(_.headerAttributes){m=_.headerAttributes;if(i.pinsHeadersToContentEdge&&_===w&&(m=m.copy(),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?m.frame.origin.y=Math.max(this.collectionView.scrollOffset.y,m.frame.origin.y):m.frame.origin.x=Math.max(this.collectionView.scrollOffset.x,m.frame.origin.x)),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(m.frame.origin.y>s)return o}else if(m.frame.origin.x>r)return o;if(o.push(m),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(m.frame.bottom>s)return o}else if(m.frame.right>r)return o}y=_}else if(c==d){if(_.footerAttributes){if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(_.footerAttributes.frame.origin.y>s)return o}else if(_.footerAttributes.frame.origin.x>r)return o;var v=_.footerAttributes;if(this.collectionView._pinsFootersToContentEdge&&(p=v=v.copy(),g=_),o.push(v),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(_.footerAttributes.frame.origin.y>s)return o}else if(_.footerAttributes.frame.origin.x>r)return o}}else{var M=f[c];if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(M.top>s)return o}else if(M.left>r)return o;for(u=0;u<M.attributes.length;u++)o.push(M.attributes[u]);if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(M.bottom>s)return o}else if(M.right>r)return o}c=-1}}finally{if(i.pinsFootersToContentEdge&&this._showsFooters)g===y?v=p:(v=y.footerAttributes.copy(),o.push(v)),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?v.frame.origin.y=Math.min(v.frame.origin.y,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-v.frame.size.height):v.frame.origin.x=Math.min(v.frame.origin.x,this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-v.frame.size.width)}return o},computedAttributesForElementsInRect:function(t,e){for(var i=e&&e.usingCache||this.cachedLayout,o=[],n=t.origin.y,s=t.bottom,a=t.origin.x,r=t.right,l=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?s:r,h=0,c=i.sections.length;h<c;h++)if(V=i.sections[h],i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(V.bottom>n)break}else if(V.right>a)break;if(h==c)return o;var d,u,p=-1,g=V.top,w=V.left,y=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?g:w,m=V,_=V;let f=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"top":"left",v=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"y":"x",M=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"height":"width",S=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?n:a;if(!i.showsHeaders||V[f]+i.headerHeight<S){p=0;var C=0|Math.ceil(V.numberOfObjects/i.numberOfColumns);y=i.showsHeaders?V[f]+i.headerHeight+i.rowSpacing:V[f];let t=NO;for(var b=0;b<C;b++){if(p=b,y+i.rowBreadth>S){t=YES;break}y+=i.rowBreadth+i.rowSpacing}t||(p=b)}if(i.pinsHeadersToContentEdge&&p>-1&&i.showsHeaders){var B=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([h])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?B.frame=BMRectMake(i.sectionInsets.left,this.collectionView.scrollOffset.y,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):B.frame=BMRectMake(this.collectionView.scrollOffset.x,i.sectionInsets.top+i.topPadding,i.headerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),B.style.zIndex=1,o.push(B)}var E=i.numberOfColumns;try{for(;h<c;h++){var V=i.sections[h];for(C=0|Math.ceil(V.numberOfObjects/E);p<=C;p++)if(-1==p){if(i.showsHeaders){if(y>l)return o;B=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([h])});if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?B.frame=BMRectMake(i.sectionInsets.left,y,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):B.frame=BMRectMake(y,i.sectionInsets.top+i.topPadding,i.headerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),V===m&&i.pinsHeadersToContentEdge){if(B.frame.origin[v]>this.collectionView.scrollOffset[v])if(i.sections[h-1]){var L=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([h-1])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?L.frame=BMRectMake(i.sectionInsets.left,Math.min(this.collectionView.scrollOffset.y,B.frame.origin.y-i.headerHeight),this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):L.frame=BMRectMake(Math.min(this.collectionView.scrollOffset[v],B.frame.origin[v]-i.headerHeight),i.sectionInsets.top+i.topPadding,i.headerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),o.push(L)}B.frame.origin[v]=Math.max(B.frame.origin[v],this.collectionView.scrollOffset[v]),B.style.zIndex=1}y+=i.headerHeight+i.rowSpacing,o.push(B)}_=V}else if(p==C){if(i.showsFooters){if(y>l)return o;var x=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([h])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?x.frame=BMRectMake(i.sectionInsets.left,y,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):x.frame=BMRectMake(y,i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),d=x,u=V,i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?y+=i.footerHeight+i.sectionInsets.top+i.sectionInsets.bottom:y+=i.footerHeight+i.sectionInsets.left+i.sectionInsets.right,o.push(x)}else if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?y+=i.sectionInsets.top+i.sectionInsets.bottom:y+=i.sectionInsets.left+i.sectionInsets.right,y>l)return o}else{if(y>l)return o;var A,I=p*E,P=E;p==C-1?(P=V.numberOfObjects%E||E,A=i.prototypeRows[P-1]):A=i.prototypeRows[E-1];for(b=0;b<P;b++){var W=I+b,T=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(this.collectionView.indexPathForObjectAtRow(W,{inSectionAtIndex:h}));T.frame=A.attributes[b].frame.copy(),T.frame.origin[v]=y,o.push(T)}y+=i.rowBreadth,(i.showsFooters||p<C-1)&&(y+=i.rowSpacing)}p=-1}}finally{if(i.pinsFootersToContentEdge&&i.showsFooters&&i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical)if(u===_){if((x=d).frame.origin[v]<this.collectionView.scrollOffset[v]+this.collectionView.frame.size[M]-i.footerHeight)if(i.sections[x.indexPath.section+1]){var z=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([x.indexPath.section+1])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?z.frame=BMRectMake(i.sectionInsets.left,Math.max(this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-i.footerHeight,x.frame.bottom),this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):z.frame=BMRectMake(Math.max(this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-i.footerHeight,x.frame.right),i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),o.push(z)}x.frame.origin[v]=Math.min(x.frame.origin[v],this.collectionView.scrollOffset[v]+this.collectionView.frame.size[M]-x.frame.size[M]),x.style.zIndex=1}else x=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([h])}),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?x.frame=BMRectMake(i.sectionInsets.left,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-i.footerHeight,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):x.frame=BMRectMake(this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-i.footerHeight,i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),x.style.zIndex=1,o.push(x)}return o},initialAttributesForPresentedCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.y+=this.collectionView.frame.size.height/2,e.style={rotateZ:"15deg",opacity:0,translateZ:0},e)},initialAttributesForPresentedSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x+=i.frame.size.width/2,i.style={opacity:0,translateZ:0},i)},initialAttributesForAppearingCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5},e)},initialAttributesForAppearingSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5},i)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i,o=this;return o._expectedCellSize&&(o.previousLayout.resolvedIndexPath.section<t.section||o.previousLayout.resolvedIndexPath.section==t.section&&o.previousLayout.resolvedIndexPath.row<t.row)&&o.collectionView.usingOldDataSet((function(){o.previousLayout.iterator.next({indexPath:t})})),this.collectionView.usingOldDataSet((function(){o._cellSize&&!o._expectedCellSize?i=o.computedAttributesForCellAtIndexPath(t,{usingCache:o.previousLayout}):(i=o.cachedAttributesForCellAtIndexPath(t,{usingCache:o.previousLayout}))||((i=e.withTargetAttributes.copy()).style=Object.assign(i.style,{opacity:0}))})),i},initialAttributesForMovingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return o._expectedCellSize&&(o.cachedLayout.resolvedIndexPath.section<e.atIndexPath.section||o.cachedLayout.resolvedIndexPath.section==e.atIndexPath.section&&t==BMCollectionViewFlowLayoutSupplementaryView.Footer)&&(e.atIndexPath.section==o.collectionView.numberOfSections()-1?o._layoutIterator.next({indexPath:o.collectionView.indexPathForObjectAtRow(o.collectionView.numberOfObjectsInSectionAtIndex(e.atIndexPath.section)-1,{inSectionAtIndex:e.atIndexPath.section})}):o._layoutIterator.next({indexPath:o.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e.atIndexPath.section+1})})),this.collectionView.usingOldDataSet((function(){t===BMCollectionViewTableLayoutSupplementaryView.Empty?i=o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}):o._cellSize&&!o._expectedCellSize?i=o.computedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}):(i=o.cachedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}))||((i=e.withTargetAttributes.copy()).style=Object.assign(i.style,{opacity:0}))})),i},supplementaryViewsToInsert:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=t;n<e;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return t>0&&0==e&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},supplementaryViewsToDelete:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=e;n<t;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return 0==t&&e>0&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},finalAttributesForDisappearingCellAtIndexPath:function(t){var e,i=this;return this.collectionView.usingOldDataSet((function(){e=i._cellSize&&!i._expectedCellSize?i.computedAttributesForCellAtIndexPath(t,{usingCache:i.previousLayout}):i.cachedAttributesForCellAtIndexPath(t,{usingCache:i.previousLayout}).copy(),i.collectionView.delegate&&i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath?e=i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath(i.collectionView,t,{withTargetAttributes:e}):e.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5}})),e},finalAttributesForDisappearingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=t===BMCollectionViewTableLayoutSupplementaryView.Empty?o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}):o._cellSize&&!o._expectedCellSize?o.computedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}):o.cachedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}),o.collectionView.delegate&&o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier?i=o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier(o.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):i.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5}})),i},indexPathToTheLeftOfIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?!this._cellSize||this._expectedCellSize?this._cachedIndexPathAboveIndexPath(t):this._computedIndexPathAboveIndexPath(t):BMCollectionViewLayout.prototype.indexPathToTheLeftOfIndexPath.apply(this,arguments)},indexPathAboveIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?BMCollectionViewLayout.prototype.indexPathToTheLeftOfIndexPath.apply(this,arguments):!this._cellSize||this._expectedCellSize?this._cachedIndexPathAboveIndexPath(t):this._computedIndexPathAboveIndexPath(t)},indexPathToTheRightOfIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?!this._cellSize||this._expectedCellSize?this._cachedIndexPathBelowIndexPath(t):this._computedIndexPathBelowIndexPath(t):BMCollectionViewLayout.prototype.indexPathToTheRightOfIndexPath.apply(this,arguments)},indexPathBelowIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?BMCollectionViewLayout.prototype.indexPathToTheRightOfIndexPath.apply(this,arguments):!this._cellSize||this._expectedCellSize?this._cachedIndexPathBelowIndexPath(t):this._computedIndexPathBelowIndexPath(t)},_cachedIndexPathAboveIndexPath(t){const e=t.section,i=t.row,o=this.cachedLayout.sections[e];if(!o)return t;const n=o.rows;let s=0;const a=n.length;for(;s<a;s++){const t=n[s];if(t.startIndex<=i&&t.endIndex>=i)break}const r=n[s].attributes.find((t=>t.indexPath.row==i)),l=this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"x":"y",h=r.frame.center[l];let c;if(s>0){c=n[s-1]}else{let t=e-1;for(;t>=0;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){c=this.cachedLayout.sections[t]?.rows[(this.cachedLayout.sections[t]?.rows.length||0)-1];break}t--}}if(c){let t=Number.MAX_SAFE_INTEGER,e=-1;for(let i=0;i<c.attributes.length;i++){const o=c.attributes[i],n=Math.abs(o.frame.center[l]-h);n<t&&(t=n,e=i)}return c.attributes[e].indexPath}return t},_computedIndexPathAboveIndexPath(t){const e=this.cachedLayout;var i=t.section;const o=e.numberOfColumns;var n=t.row;const s=n/o|0,a=n%o;let r;if(s>0)r=s-1;else{let t=i-1;for(;t>=0;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){r=e.sections[t].numberOfRows-1,i=t;break}t--}}if("number"!=typeof r)return t;const l=o*r,h=this.collectionView.numberOfObjectsInSectionAtIndex(i);if(r==(h/o|0)){var c=h%o||o;return this.collectionView.indexPathForObjectAtRow(l+Math.min(c,a),{inSectionAtIndex:i})}return this.collectionView.indexPathForObjectAtRow(l+a,{inSectionAtIndex:i})},_cachedIndexPathBelowIndexPath(t){const e=this.collectionView.numberOfSections(),i=t.section,o=t.row,n=this.cachedLayout.sections[i];if(!n)return t;const s=n.rows;let a=0;const r=s.length;for(;a<r;a++){const t=s[a];if(t.startIndex<=o&&t.endIndex>=o)break}const l=s[a].attributes.find((t=>t.indexPath.row==o)),h=this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"x":"y",c=l.frame.center[h];let d;if(a<r-1){d=s[a+1]}else{let t=i+1;for(;t<e;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){d=this.cachedLayout.sections[t]?.rows[0];break}t++}}if(d){let t=Number.MAX_SAFE_INTEGER,e=-1;for(let i=0;i<d.attributes.length;i++){const o=d.attributes[i],n=Math.abs(o.frame.center[h]-c);n<t&&(t=n,e=i)}return d.attributes[e].indexPath}return t},_computedIndexPathBelowIndexPath(t){const e=this.collectionView.numberOfSections(),i=this.cachedLayout;var o=t.section,n=i.sections[o];const s=i.numberOfColumns;var a=t.row;const r=a/s|0,l=a%s;let h;if(r<n.numberOfRows-1)h=r+1;else{let t=o+1;for(;t<e;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){h=0,o=t;break}t++}}if("number"!=typeof h)return t;const c=s*h,d=this.collectionView.numberOfObjectsInSectionAtIndex(o);if(h==(d/s|0)){var u=d%s||s;return this.collectionView.indexPathForObjectAtRow(c+Math.min(u,l),{inSectionAtIndex:o})}return this.collectionView.indexPathForObjectAtRow(c+l,{inSectionAtIndex:o})},copy:function(){var t=new BMCollectionViewFlowLayout;return t.cellSize=this.cellSize&&this.cellSize.copy(),t.expectedCellSize=this.expectedCellSize&&this.expectedCellSize.copy(),t.rowSpacing=this.rowSpacing,t.showsHeaders=this.showsHeaders,t.headerHeight=this.headerHeight,t.showsFooters=this.showsFooters,t.footerHeight=this.footerHeight,t.sectionInsets=this.sectionInsets,t.gravity=this.gravity,t.leftAlignFinalRow=this.leftAlignFinalRow,t.alignment=this.alignment,t.orientation=this.orientation,t.topPadding=this.topPadding,t.bottomPadding=this.bottomPadding,t.contentGravity=this.contentGravity,t.pinsHeadersToContentEdge=this.pinsHeadersToContentEdge,t.pinsFootersToContentEdge=this.pinsFootersToContentEdge,t}}),BMCollectionViewFlowLayout.flowLayout=function(){return new this},BMCollectionViewMasonryLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_minimumColumnWidth:128,get minimumColumnWidth(){return this._minimumColumnWidth},set minimumColumnWidth(t){this._minimumColumnWidth=t,this.invalidateLayout()},_numberOfColumns:void 0,get numberOfColumns(){return this._numberOfColumns},set numberOfColumns(t){this._numberOfColumns=t,this.invalidateLayout()},_columnSpacing:22,get columnSpacing(){return this._columnSpacing},set columnSpacing(t){this._columnSpacing=t,this.invalidateLayout()},_cellSpacing:22,get cellSpacing(){return this._cellSpacing},set cellSpacing(t){this._cellSpacing=t,this.invalidateLayout()},_columnSpeeds:[],get columnSpeeds(){return this._columnSpeeds},set columnSpeeds(t){this._columnSpeeds=t,this.invalidateLayout()},_topPadding:22,get topPadding(){return this._topPadding},set topPadding(t){this._topPadding=t,this.invalidateLayout()},_bottomPadding:22,get bottomPadding(){return this._bottomPadding},set bottomPadding(t){this._bottomPadding=t,this.invalidateLayout()},cachedLayout:void 0,prepareLayout:function(){if(!this.isChangingBounds){this.previousLayout=this.cachedLayout,this.cachedLayout={};var t,e=this.cachedLayout,i=this.collectionView.frame.size.width,o=this.columnSpacing,n=this.cellSpacing,s=this.numberOfColumns,a=this.columnSpeeds;if(s)t=(i-(s+1)*o)/s|0;else(s=i/(t=this.minimumColumnWidth)|0)*t+(s+1)*o>i&&(s-=1),t=(i-(s+1)*o)/s|0;e.columns=[];for(var r=0;r<s;r++)e.columns.push({height:this._topPadding,speedHeight:this._topPadding/(a[r]||1),speed:a[r]||1,attributes:[],x:o+r*(o+t)});var l=this.collectionView.numberOfSections();for(r=0;r<l;r++)for(var h=this.collectionView.numberOfObjectsInSectionAtIndex(r),c=0;c<h;c++){for(var d=this.collectionView.indexPathForObjectAtRow(c,{inSectionAtIndex:r}),u=this.collectionView.delegate.collectionViewHeightForCellAtIndexPath(this.collectionView,d,{forColumnWidth:t}),p=e.columns[0].speedHeight,g=0,w=1;w<s;w++){(y=e.columns[w]).speedHeight<p&&(p=y.speedHeight,g=w)}var y=e.columns[g],m=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(d);m.frame=BMRectMake(y.x,y.height,t,u),m.style={translateZ:0},y.attributes.push(m),y.height+=u+n,y.speedHeight+=(u+n)/y.speed}for(w=0;w<s;w++){(y=e.columns[w]).height+=this._bottomPadding,y.speedHeight+=this._bottomPadding/y.speed}}},contentSize:function(){for(var t=0,e=0;e<this.cachedLayout.columns.length;e++)t<this.cachedLayout.columns[e].speedHeight&&(t=this.cachedLayout.columns[e].speedHeight);return BMSizeMake(this.collectionView.frame.size.width,Math.max(t,this.collectionView.frame.size.height))},collectionViewWillStartUpdates:function(){this.prepareLayout()},collectionViewDidStartUpdates:function(){this.previousLayout=void 0},shouldInvalidateLayoutForBoundsChange:function(t){return this.isChangingBounds=YES,YES},didInvalidateLayoutForBoundsChange:function(){this.isChangingBounds=NO},attributesForElementsInRect:function(t){return this.cachedAttributesForElementsInRect(t)},cachedAttributesForElementsInRect:function(t,e){for(var i=e&&e.usingCache||this.cachedLayout,o=this.collectionView.scrollOffset,n=t.origin.y,s=t.bottom,a=[],r=i.columns,l=r.length,h=0;h<l;h++){for(var c=r[h],d=o.y*c.speed,u=(t.size.height,o.y-d),p=c.attributes.length,g=c.attributes,w=0;w<p;w++){if((y=g[w]).frame.bottom+u>n)break}for(;w!=p;){var y;if((y=g[w]).frame.top+u>s)break;(y=y.copy()).frame.origin.y=y.frame.origin.y+u|0,a.push(y),w++}}return a},attributesForCellAtIndexPath:function(t){return this.cachedAttributesForCellAtIndexPath(t)},cachedAttributesForCellAtIndexPath:function(t,e){return this._extendedCachedAttributesForCellAtIndexPath(t,e).attribute},_extendedCachedAttributesForCellAtIndexPath:function(t,e){for(var i=this.collectionView.scrollOffset,o=(e&&e.usingCache||this.cachedLayout).columns,n=o.length,s=0;s<n;s++)for(var a=o[s],r=i.y*a.speed,l=i.y-r,h=a.attributes.length,c=a.attributes,d=0;d<h;d++){var u=c[d];if(u.indexPath.section==t.section&&u.indexPath.row==t.row)return(u=u.copy()).frame.origin.y=u.frame.origin.y+l|0,u.speed=a.speed,{attribute:u,columnIndex:s,rowIndex:d}}},initialAttributesForPresentedCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t);return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e,layout:this}):(e.frame.origin.y+=this.collectionView.frame.size.height/3*e.speed,e.style={opacity:0,translateZ:0,rotateZ:"15deg"},e)},initialAttributesForAppearingCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t);return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e,layout:this}):(e.frame.origin.y+=this.collectionView.frame.size.height/3*e.speed,e.style={opacity:0,translateZ:0,rotateZ:"15deg"},e)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.cachedAttributesForCellAtIndexPath(t,{usingCache:o.previousLayout})})),i},finalAttributesForDisappearingCellAtIndexPath:function(t){var e,i=this;return this.collectionView.usingOldDataSet((function(){e=i.cachedAttributesForCellAtIndexPath(t,{usingCache:i.previousLayout}),i.collectionView.delegate&&i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath?e=i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath(i.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.y+=i.collectionView.frame.size.height/3*e.speed,e.style={opacity:0,translateZ:0,rotateZ:"15deg"})})),e},indexPathToTheLeftOfIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t);if(0==e.columnIndex)return t;const i=e.attribute.frame.center.y,o=this.collectionView.scrollOffset,n=this.cachedLayout.columns[e.columnIndex-1];var s=o.y*n.speed,a=o.y-s;let r=-1,l=Number.MAX_SAFE_INTEGER;for(let t=0;t<n.attributes.length;t++){const e=n.attributes[t].frame.center.y+a|0,o=Math.abs(e-i);o<l&&(r=t,l=o)}return-1!=r?n.attributes[r].indexPath:t},indexPathAboveIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t);return e.rowIndex>0?this.cachedLayout.columns[e.columnIndex].attributes[e.rowIndex-1].indexPath:t},indexPathToTheRightOfIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t),i=this.cachedLayout;if(e.columnIndex>=this.cachedLayout.columns.length-1)return t;const o=e.attribute.frame.center.y,n=this.collectionView.scrollOffset,s=i.columns[e.columnIndex+1];var a=n.y*s.speed,r=n.y-a;let l=-1,h=Number.MAX_SAFE_INTEGER;for(let t=0;t<s.attributes.length;t++){const e=s.attributes[t].frame.center.y+r|0,i=Math.abs(e-o);i<h&&(l=t,h=i)}return-1!=l?s.attributes[l].indexPath:t},indexPathBelowIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t);return e.rowIndex<this.cachedLayout.columns[e.columnIndex].attributes.length-1?this.cachedLayout.columns[e.columnIndex].attributes[e.rowIndex+1].indexPath:t},indexPathsFromIndexPath(t,{toIndexPath:e}){const i=this.attributesForCellAtIndexPath(t),o=this.attributesForCellAtIndexPath(e);return this.attributesForElementsInRect(i.frame.rectByUnionWithRect(o.frame)).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell)).map((t=>t.indexPath))},copy:function(){var t=new BMCollectionViewMasonryLayout;return t.minimumColumnWidth=this.minimumColumnWidth,t.numberOfColumns=this.numberOfColumns,t.columnSpacing=this.columnSpacing,t.cellSpacing=this.cellSpacing,t.columnSpeeds=this.columnSpeeds&&this.columnSpeeds.slice(),t.topPadding=this.topPadding,t.bottom=this.bottomPadding,t}}),BMCollectionViewMasonryLayout.masonryLayout=function(){return new this},BMCollectionViewStackLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_showsSingleCellFullScreen:NO,get showsSingleCellFullScreen(){return this._showsSingleCellFullScreen},set showsSingleCellFullScreen(t){this._showsSingleCellFullScreen=t,this.invalidateLayout()},_showsSingleCell:NO,get showsSingleCell(){return this._showsSingleCell},set showsSingleCell(t){this._showsSingleCell=t,this.invalidateLayout()},_insets:BMInsetMake(88,88,88,88),get insets(){return this._insets.copy()},set insets(t){this._insets=t.copy(),this.invalidateLayout()},_spread:22,get spread(){return this._spread},set spread(t){this._spread=t,this.invalidateLayout()},_numberOfBackgroundCells:3,get numberOfBackgroundCells(){return this._numberOfBackgroundCells},set numberOfBackgroundCells(t){this._numberOfBackgroundCells=t,this.invalidateLayout()},_minimumScale:.9,get minimumScale(){return this._minimumScale},set minimumScale(t){this._minimumScale=t,this.invalidateLayout()},_blursBackgroundCells:NO,get blursBackgroundCells(){return this._blursBackgroundCells},set blursBackgroundCells(t){this._blursBackgroundCells=t,this.invalidateLayout()},_maximumBlur:15,get maximumBlur(){return this._maximumBlur},set maximumBlur(t){this._maximumBlur=t,this.invalidateLayout()},_rotatesCells:NO,get rotatesCells(){return this._rotatesCells},set rotatesCells(t){this._rotatesCells=t,this.invalidateLayout()},_rotation:-90,get rotation(){return this._rotation},set rotation(t){this._rotation=t,this.invalidateLayout()},_numberOfObjects:0,shouldInvalidateLayoutForFrameChange:function(){return YES},shouldInvalidateLayoutForBoundsChange:function(){return YES},collectionViewWillStartUpdates:function(){this.prepareLayout()},prepareLayout:function(){for(var t=0,e=this.collectionView.numberOfSections(),i=0;i<e;i++)t+=this.collectionView.numberOfObjectsInSectionAtIndex(i);this._numberOfObjects=t},contentSize:function(){return this._showsSingleCell?this.collectionView.frame.size.copy():BMSizeMake(this.collectionView.frame.size.width,this.collectionView.frame.size.height*this._numberOfObjects)},previousIndexPathWithIndexPath:function(t){if(t.row)return this.collectionView.indexPathForObjectAtRow(t.row-1,{inSectionAtIndex:t.section});for(var e=t.section-1;e>=0;){var i=this.collectionView.numberOfObjectsInSectionAtIndex(e);if(i)return this.collectionView.indexPathForObjectAtRow(i-1,{inSectionAtIndex:e});e--}},nextIndexPathWithIndexPath:function(t){var e=this.collectionView.numberOfObjectsInSectionAtIndex(t.section);if(t.row<e-1)return this.collectionView.indexPathForObjectAtRow(t.row+1,{inSectionAtIndex:t.section});for(var i=this.collectionView.numberOfSections(),o=t.section+1;o<i;){if(e=this.collectionView.numberOfObjectsInSectionAtIndex(o))return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:o});o++}},attributesForElementsInRect:function(t){if(this._showsSingleCell){var e=[];if(this.collectionView.numberOfSections()&&this.collectionView.numberOfObjectsInSectionAtIndex(0)){var i=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:0}));i.frame=this.collectionView.frame.copy(),i.frame.origin=BMPointMake(),e.push(i)}return e}for(var o,n=this.collectionView.scrollOffset,s=this.collectionView.frame.size.height,a=this.collectionView.frame.size.width,r=n.y,l=n.y+s,h=a-this.insets.left-this.insets.right,c=s-this.insets.top-this.insets.bottom,d=(e=[],0),u=this.collectionView.numberOfSections(),p=0;p<u;p++){for(var g=this.collectionView.numberOfObjectsInSectionAtIndex(p),w=0;w<g;w++)if((d+=s)>=r&&d<=l){o=this.collectionView.indexPathForObjectAtRow(w,{inSectionAtIndex:p});break}if(o)break}if(!o)return e;this._spread;var y=(s-d+r)/s,m=this._spread*y|0,_=(1-this._minimumScale)/(this._numberOfBackgroundCells+1),f=1/(this._numberOfBackgroundCells+1),v=this._maximumBlur/(this._numberOfBackgroundCells+1),M=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(o);M.frame=BMRectMakeWithX(this.insets.left,{y:r+this.insets.top-m,width:h,height:c}),M.style.zIndex=2*this._numberOfBackgroundCells+4,M.style.scaleX=1-_*y,M.style.scaleY=1-_*y,M.style.opacity=1-f*y,this._blursBackgroundCells&&(M.style.blur=y*v+"px"),this._rotatesCells&&(M.style.rotateX=(this.numberOfBackgroundCells-1)/1e4+"deg",M.style.transformOriginX="50%",M.style.transformOriginY="100%",M.style.translateZ=2*this._numberOfBackgroundCells+4+"px"),e.push(M);var S=this.nextIndexPathWithIndexPath(o);if(S){let t=d-this.insets.bottom+this.insets.top/3,i=d+this.insets.top;(C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(S)).frame=BMRectMakeWithX(this.insets.left,{y:BMNumberByInterpolatingNumbersWithFraction(t,i,y),width:h,height:c}),C.style.zIndex=2*this._numberOfBackgroundCells+6,this._rotatesCells&&(C.style.rotateX=BMNumberByInterpolatingNumbersWithFraction(this._rotation,0,y)+"deg",C.style.transformOriginX="50%",C.style.transformOriginY="100%",C.style.translateZ=2*this._numberOfBackgroundCells+6+"px"),e.push(C);let o=this.nextIndexPathWithIndexPath(S);if(o){let t=d+this.collectionView.frame.size.height,i=t-this.insets.bottom+this.insets.top/3;this.insets.top;var C;(C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(o)).frame=BMRectMakeWithX(this.insets.left,{y:i,width:h,height:c}),C.style.zIndex=2*this._numberOfBackgroundCells+8,this._rotatesCells&&(C.style.rotateX=this._rotation+"deg",C.style.transformOriginX="50%",C.style.transformOriginY="100%",C.style.translateZ=2*this._numberOfBackgroundCells+8+"px"),e.push(C)}}for(p=0;p<this._numberOfBackgroundCells;p++){var b=this.previousIndexPathWithIndexPath(o);if(!b)return e;var B=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(b);B.frame=BMRectMakeWithX(this.insets.left,{y:r+this.insets.top-m-(p+1)*this._spread,width:h,height:c}),B.style.zIndex=2*(this._numberOfBackgroundCells+1-p),B.style.scaleX=1-_*y-_*(p+1),B.style.scaleY=1-_*y-_*(p+1),B.style.opacity=1-f*y-f*(p+1),this._blursBackgroundCells&&(B.style.blur=(y+p+1)*v+"px"),this._rotatesCells&&(B.style.rotateX=(this.numberOfBackgroundCells+p)/1e4+"deg",B.style.transformOriginX="50%",B.style.transformOriginY="100%",B.style.translateZ=2*(this._numberOfBackgroundCells+1-p)+"px"),e.push(B),o=b}return e},attributesForCellAtIndexPath:function(t){if(this._showsSingleCell){var e=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);return e.frame=this.collectionView.frame.copy(),e.frame.origin=BMPointMake(),0==t.row&&0==t.section||(e.isHidden=YES,e.style.opacity=0),e}for(var i,o=this.collectionView.scrollOffset,n=this.collectionView.frame.size.height,s=this.collectionView.frame.size.width,a=o.y,r=o.y+n,l=s-this.insets.left-this.insets.right,h=n-this.insets.top-this.insets.bottom,c=[],d=0,u=this.collectionView.numberOfSections(),p=0;p<u;p++){for(var g=this.collectionView.numberOfObjectsInSectionAtIndex(p),w=0;w<g;w++)if((d+=n)>=a&&d<=r){i=this.collectionView.indexPathForObjectAtRow(w,{inSectionAtIndex:p});break}if(i)break}this._spread;var y=(n-d+a)/n,m=this._spread*y|0,_=(1-this._minimumScale)/(this._numberOfBackgroundCells+1),f=1/(this._numberOfBackgroundCells+1),v=this._maximumBlur/(this._numberOfBackgroundCells+1);if(t.isEqualToIndexPath(i,{usingComparator:this.collectionView.identityComparator})){var M=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);return M.frame=BMRectMakeWithX(this.insets.left,{y:a+this.insets.top-m,width:l,height:h}),M.style.zIndex=this._numberOfBackgroundCells+2,M.style.scaleX=1-_*y,M.style.scaleY=1-_*y,M.style.opacity=1-f*y,this._blursBackgroundCells&&(M.style.blur=y*v+"px"),M}var S=this.nextIndexPathWithIndexPath(i);if(S&&t.isEqualToIndexPath(S,{usingComparator:this.collectionView.identityComparator})){var C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(S);return C.frame=BMRectMakeWithX(this.insets.left,{y:d+this.insets.top,width:l,height:h}),C.style.zIndex=this._numberOfBackgroundCells+3,C}if(t.section>S.section||t.section==S.section&&t.row>S.row){var b=0;for(p=0;p<t.section;p++){b+=n*(g=this.collectionView.numberOfObjectsInSectionAtIndex(p))}return b+=n*t.row,(c=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=BMRectMakeWithX(this.insets.left,{y:b,width:l,height:h}),c.isHidden=YES,c.opacity=0,c}for(p=0;p<this._numberOfBackgroundCells;p++){var B,E=this.previousIndexPathWithIndexPath(i);if(!E)break;if(t.isEqualToIndexPath(E,{usingComparator:this.collectionView.identityComparator}))return(B=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(E)).frame=BMRectMakeWithX(this.insets.left,{y:a+this.insets.top-m-(p+1)*this._spread,width:l,height:h}),B.style.zIndex=this._numberOfBackgroundCells+1-p,B.style.scaleX=1-_*y-_*(p+1),B.style.scaleY=1-_*y-_*(p+1),B.style.opacity=1-f*y-f*(p+1),this._blursBackgroundCells&&(B.style.blur=(y+p+1)*v+"px"),B;i=E}return(B=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=BMRectMakeWithX(this.insets.left,{y:a+this.insets.top-(this._numberOfBackgroundCells+1)*this._spread,width:l,height:h}),B.style.zIndex=0,B.style.scaleX=this._minimumScale,B.style.scaleY=this._minimumScale,B.style.opacity=0,this._blursBackgroundCells&&(B.style.blur=this._maximumBlur+"px"),B},rectWithScrollingPositionOfCellAtIndexPath:function(t){for(var e=this.collectionView.frame.size.height,i=0,o=0;o<t.section;o++){i+=e*this.collectionView.numberOfObjectsInSectionAtIndex(o)}return BMRectMakeWithX(0,{y:i+=e*t.row,width:this.collectionView.frame.size.width,height:this.collectionView.frame.size.height})},snapsScrollPosition:()=>YES,snappingScrollOffsetForScrollOffset(t,e){t=t.copy();var i=e.withVerticalDirection==BMScrollingDirectionVertical.Bottom?this.collectionView.frame.size.height:0;return t.y=(t.y/this.collectionView.frame.size.height|0)*this.collectionView.frame.size.height+i,t.y=Math.max(0,Math.min(this.collectionView.size.height-this.collectionView.frame.size.height,t.y)),t},copy(){var t=new BMCollectionViewStackLayout;return t._showsSingleCellFullScreen=this._showsSingleCellFullScreen,t._showsSingleCell=this._showsSingleCell,t._insets=this._insets.copy(),t._spread=this._spread,t._numberOfBackgroundCells=this._numberOfBackgroundCells,t._minimumScale=this._minimumScale,t._blursBackgroundCells=this._blursBackgroundCells,t._maximumBlur=this._maximumBlur,t}}),BMCollectionViewStackLayout.stackLayout=function(){return new this};var BMCollectionViewTileLayoutOrientation=Object.freeze({Horizontal:{},Vertical:{}});function BMCollectionViewTileLayout(){}BMCollectionViewTileLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_gridSize:0,get gridSize(){return this._gridSize},set gridSize(t){this._gridSize=t||0,this.invalidateLayout()},_spacing:0,get spacing(){return this._spacing},set spacing(t){this._spacing=t||0,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_topPadding:0,get topPadding(){return this._topPadding},set topPadding(t){this._topPadding=t,this.invalidateLayout()},_bottomPadding:0,get bottomPadding(){return this._bottomPadding},set bottomPadding(t){this._bottomPadding=t,this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},_orientation:BMCollectionViewTileLayoutOrientation.Vertical,get orientation(){return this._orientation},set orientation(t){this._orientation=t,this.invalidateLayout()},copy(){let t=new BMCollectionViewTileLayout;return t._gridSize=this._gridSize,t._spacing=this._spacing,t._showsHeaders=this._showsHeaders,t._headerHeight=this._headerHeight,t._showsFooters=this._showsFooters,t._footerHeight=this._footerHeight,t._sectionInsets=this._sectionInsets.copy(),t._topPadding=this._topPadding,t._bottomPadding=this._bottomPadding,t._pinsFootersToContentEdge=this._pinsFootersToContentEdge,t._pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,t._orientation=this._orientation,t},_isChangingBounds:NO,constrainedSizeWithSize:function(t){return BMSizeMake(Math.min(this.constrainedValueWithValue(t.width),this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right),this.constrainedValueWithValue(t.height))},constrainedValueWithValue:function(t){if(this._gridSize>1){var e=this._gridSize,i=this._spacing,o=t/(e+i)|0;0==o&&(o=1);var n=o*e+(o-1)*i;return t-n>n+e+i-t?n+e+i:n}return t},collectionViewWillStartUpdates:function(t){this.previousLayoutCache=this.layoutCache,this.prepareLayout()},collectionViewDidStartUpdates:function(t){this.previousLayoutCache=void 0},prepareLayout:function(){return this._prepareLayoutWithScrollbarOffset(NO)},_prepareLayoutWithScrollbarOffset:function(t){if(!this._isChangingBounds){var e=this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right,i={},o=this.collectionView.numberOfSections();this.layoutCache=i,i.sections=new Array(o),i.size=BMSizeMake(this.collectionView.frame.size.width,0);for(var n=this._topPadding,s=0;s<o;s++){var a={attributes:[]};if(i.sections[s]=a,n+=this._sectionInsets.top,a.outerFrame=BMRectMake(this._sectionInsets.left,n,e,0),this._showsHeaders){a.outerFrame.size.height+=this._headerHeight+this._spacing,n+=this._headerHeight+this._spacing;var r=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([s])});r.frame=a.outerFrame.copy(),r.frame.size.height=this._headerHeight,a.headerAttributes=r}if(a.frame=BMRectMake(this._sectionInsets.left,n,e,0),this._prepareLayoutForSection(s,{intoCache:a}),a.outerFrame.size.height+=a.frame.size.height,n=a.outerFrame.bottom,this._showsFooters){var l=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([s])});l.frame=a.outerFrame.copy(),l.frame.size.height=this._footerHeight,l.frame.origin.y=n+this._spacing,a.footerAttributes=l,a.outerFrame.size.height+=this._footerHeight+this._spacing,n+=this._footerHeight+this._spacing}a.outerFrame.size.height+=this._sectionInsets.bottom,n=a.outerFrame.bottom}i.size.height=n+this._bottomPadding}},_prepareLayoutForSection:function(t,e){for(var i=this.collectionView.numberOfObjectsInSectionAtIndex(t),o=e.intoCache,n=o.frame.origin.y,s=o.frame.origin.x,a=[BMRectMakeWithX(o.frame.origin.x,{y:o.frame.origin.y,width:o.frame.size.width,height:Number.MAX_SAFE_INTEGER})],r=0;r<i;r++){this.DEBUG;var l=this.collectionView.indexPathForObjectAtRow(r,{inSectionAtIndex:t}),h=this.collectionView.delegate.collectionViewSizeForCellAtIndexPath(this.collectionView,l);h=this.constrainedSizeWithSize(h);for(var c=void 0,d=0;d<a.length;d++){if(!((y=a[d]).size.width<h.width||y.size.height<h.height)&&!c){c=y;break}}var u=BMRectMakeWithOrigin(BMPointMakeWithX(c.origin.x,{y:c.origin.y}),{size:h}),p=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(l);if(p.frame=u,o.attributes.push(p),this.DEBUG){var g=document.createElement("div");BMCopyProperties(g.style,{position:"absolute",boxSizing:"border-box",top:u.origin.y+"px",left:u.origin.x+"px",width:u.size.width+"px",height:u.size.height+"px",boxShadow:"0px 0px 1px 1px blue"}),(this.collectionView._contentWrapper&&this.collectionView._contentWrapper[0]||this.collectionView._container[0]).appendChild(g)}n<u.bottom&&(n=u.bottom),s<u.right&&(s=u.right),this.DEBUG;var w=u.rectWithInset(BMInset.insetWithEqualInsets(-this._spacing));for(d=0;d<a.length;d++){var y;if((y=a[d]).isEqualToRect(w)||w.containsRect(y))a.splice(d,1),y.div&&y.div.remove(),d--;else if(w.intersectsContentOfRect(y)){var m=this.rectsWithDifferenceOfExtent(y,{fromRect:w,spacing:this._spacing});a.splice(d,1),y.div&&y.div.remove();var _=0,f=m[0];if(f)for(var v=d;v<a.length;v++){var M=a[v];if(M.isEqualToRect(f)&&(_++,f.isInvalid=YES,!(f=m[_])))break;if(M.origin.y>f.origin.y&&(a.splice(v,0,f),v++,!(f=m[++_])))break;if(M.origin.y==f.origin.y&&M.origin.x>f.origin.x&&(a.splice(v,0,f),v++,!(f=m[++_])))break}if(f)for(;_<m.length;_++)a.push(m[_]);if(d=-1,this.DEBUG)for(v=0;v<m.length;v++){var S=document.createElement("div"),C=m[v];C.isInvalid||(BMCopyProperties(S.style,{position:"absolute",boxSizing:"border-box",top:C.origin.y+"px",left:C.origin.x+"px",width:C.size.width+"px",height:C.size.height+"px",boxShadow:"0px 0px 1px 1px red"}),C.div=S,(this.collectionView._contentWrapper&&this.collectionView._contentWrapper[0]||this.collectionView._container[0]).appendChild(S))}}}}n+=this._spacing+this._sectionInsets.bottom;var b=(o.frame.right-s)/2|0;b&&(o.attributes=o.attributes.map((function(t){return t.frame.origin.x+=b,t}))),o.frame.size.width=s-o.frame.origin.x,o.frame.size.height=n-o.frame.origin.y},attributesForElementsInRect:function(t){if(0==this.collectionView.numberOfSections()){var e=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return e.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),[e]}for(var i,o,n,s=this.layoutCache.sections.length,a=[],r=NO,l=0;l<s;l++){var h=this.layoutCache.sections[l];if(t.intersectsRect(h.outerFrame)){var c,d=h;h.headerAttributes&&t.intersectsRect(h.headerAttributes.frame)&&(a.push(c=h.headerAttributes.copy()),o&&c.frame.intersectsRect(o.frame)&&(this.orientation==BMCollectionViewTileLayoutOrientation.Horizontal&&(o.frame.origin.x=c.frame.origin.x-o.frame.size.width),this.orientation==BMCollectionViewTileLayoutOrientation.Vertical&&(o.frame.origin.y=c.frame.origin.y-o.frame.size.height))),r||(r=YES,this.pinsHeadersToContentEdge&&h.headerAttributes&&(c||a.push(c=h.headerAttributes.copy()),(o=c).style.zIndex=1,c.frame.origin.y=Math.max(this.collectionView.scrollOffset.y,c.frame.origin.y),c.frame.origin.x=Math.max(this.collectionView.scrollOffset.x,c.frame.origin.x)));for(var u=h.attributes.length,p=0;p<u;p++)t.intersectsRect(h.attributes[p].frame)&&a.push(h.attributes[p]);h.footerAttributes&&t.intersectsRect(h.footerAttributes.frame)?(a.push(i=h.footerAttributes.copy()),n=i):i=void 0}else if(r)break}return d&&this.pinsFootersToContentEdge&&d.footerAttributes&&(i||a.push(i=d.footerAttributes.copy()),i.style.zIndex=1,i.frame.origin.y=Math.min(this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-i.frame.size.height,i.frame.origin.y),i.frame.origin.x=Math.min(this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-i.frame.size.width,i.frame.origin.x),n&&i.frame.intersectsRect(n.frame)&&(this.orientation==BMCollectionViewTileLayoutOrientation.Horizontal&&(i.frame.origin.x=n.frame.origin.x-i.frame.size.width),this.orientation==BMCollectionViewTileLayoutOrientation.Vertical&&(i.frame.origin.y=n.frame.origin.y-i.frame.size.height))),a},shouldInvalidateLayoutForBoundsChange:function(){var t=this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge;return t&&(this._isChangingBounds=YES),t},didInvalidateLayoutForBoundsChange:function(){this._isChangingBounds=NO},attributesForCellAtIndexPath:function(t){return this.cachedAttributesForCellAtIndexPath(t,{withCache:this.layoutCache})},cachedAttributesForCellAtIndexPath:function(t,e){return e.withCache.sections[t.section].attributes[t.row]},initialAttributesForMovingCellFromIndexPath:function(t){return this.cachedAttributesForCellAtIndexPath(t,{withCache:this.previousLayoutCache})},attributesForSupplementaryViewWithIdentifier:function(t,e){if(t===BMCollectionViewTableLayoutSupplementaryView.Empty){var i=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return i.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),i}var o=e.atIndexPath;return t==BMCollectionViewFlowLayoutSupplementaryView.Footer?this.layoutCache.sections[o.section].footerAttributes:t==BMCollectionViewFlowLayoutSupplementaryView.Header?this.layoutCache.sections[o.section].headerAttributes:void 0},contentSize:function(){let t=this.layoutCache.size;return t.height=Math.max(t.height,this.collectionView.frame.size.height),t},initialAttributesForPresentedCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy(),o=i.frame,n=this.collectionView.bounds.center.slopeAngleToPoint(o.center),s=this.collectionView.bounds.center.distanceToPoint(o.center);return o.offset(4*s*Math.cos(n),4*s*Math.sin(n)),i.style.scaleX=2,i.style.scaleY=2,i.style.opacity=0,i},supplementaryViewsToInsert:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=t;n<e;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return t>0&&0==e&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},supplementaryViewsToDelete:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=e;n<t;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return 0==t&&e>0&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},rightExtentByTrimmingLeftSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(i.right,{y:t.origin.y,width:t.right-i.right,height:t.height})},leftExtentByTrimmingRightSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:i.origin.x-t.origin.x,height:t.height})},topExtentByTrimmingBottomSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:i.origin.y-t.origin.y})},bottomExtentByTrimmingTopSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(t.origin.x,{y:i.bottom,width:t.size.width,height:t.bottom-i.bottom})},rectsWithDifferenceOfExtent:function(t,e){e.spacing;var i=this._gridSize,o=e.fromRect;if(o.bottom>=t.origin.y&&o.top<=t.origin.y){var n=[];return(r=this.leftExtentByTrimmingRightSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(r),(a=this.rightExtentByTrimmingLeftSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(a),(l=this.bottomExtentByTrimmingTopSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(l),n}if(o.right>=t.origin.x&&o.origin.x<=t.origin.x){n=[];return(s=this.topExtentByTrimmingBottomSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(s),(a=this.rightExtentByTrimmingLeftSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(a),(l=this.bottomExtentByTrimmingTopSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(l),n}if(o.origin.x<=t.right&&o.right>=t.right){n=[];return(s=this.topExtentByTrimmingBottomSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(s),(r=this.leftExtentByTrimmingRightSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(r),(l=this.bottomExtentByTrimmingTopSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(l),n}if(o.origin.y<=t.bottom&&o.bottom>=t.bottom){n=[];(r=this.leftExtentByTrimmingRightSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(r);var s=this.topExtentByTrimmingBottomSideOfExtent(t,{withIntersectingRect:o});return l.height>=i&&n.push(l),(a=this.rightExtentByTrimmingLeftSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(a),n}if(o.intersectsPoint(t.origin)){n=[];return(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.intersectsPoint({x:t.right,y:t.origin.y})){n=[];return(r=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:o.origin.x-t.origin.x,height:t.height})).width>=i&&n.push(r),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.intersectsPoint({x:t.left,y:t.bottom})){n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),n}if(o.intersectsPoint({x:t.right,y:t.bottom})){n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(r=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:o.origin.x-t.origin.x,height:t.height})).width>=i&&n.push(r),n}if(o.bottom>=t.origin.y&&o.top<=t.origin.y){n=[];return(r=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:o.origin.x-t.origin.x,height:t.height})).width>=i&&n.push(r),(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.right>=t.origin.x&&o.origin.x<=t.origin.x){var a;n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.origin.x<=t.right&&o.right>=t.right){var r,l;n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(r=BMRectMakeWithX(t.right,{y:t.origin.y,width:o.right-t.right,height:t.height})).width>=i&&n.push(r),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}},indexPathToTheLeftOfIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.origin.x-this.collectionView.bounds.size.width-1,e.frame.origin.y,this.collectionView.bounds.size.width,e.frame.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.left,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.x>n&&(n=o[t].frame.origin.x,s=t);return-1!=s?o[s].indexPath:t},indexPathAboveIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.origin.x,e.frame.origin.y-this.collectionView.bounds.size.height-1,e.frame.size.width,this.collectionView.bounds.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.origin.y,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.y>n&&(n=o[t].frame.origin.y,s=t);return-1!=s?o[s].indexPath:t},indexPathToTheRightOfIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.right+1,e.frame.origin.y,this.collectionView.bounds.size.width,e.frame.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.right,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.x<n&&(n=o[t].frame.origin.x,s=t);return-1!=s?o[s].indexPath:t},indexPathBelowIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.origin.x,e.frame.bottom+1,e.frame.size.width,this.collectionView.bounds.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.bottom,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.y<n&&(n=o[t].frame.origin.y,s=t);return-1!=s?o[s].indexPath:t},indexPathsFromIndexPath(t,{toIndexPath:e}){const i=this.attributesForCellAtIndexPath(t),o=this.attributesForCellAtIndexPath(e);return this.attributesForElementsInRect(i.frame.rectByUnionWithRect(o.frame)).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell)).map((t=>t.indexPath))}}),BMCollectionViewTileLayout.tileLayout=function(){return new this};const BM_COLLECTION_VIEW_USE_STATIC_CONTEXT=YES,BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS=YES,BM_COLLECTION_VIEW_DEBUG_MEASURE=NO,BM_COLLECTION_VIEW_DEBUG_MEASURE_CELL=NO,BM_COLLECTION_VIEW_DISABLE_ISCROLL=NO,BM_DEPRECATION_WARN=NO,BM_DEPRECATION_TRACE=YES,BM_SIMPLE_BENCH=NO;var BMCollectionViewTransferPolicy=Object.freeze({Move:"Move",Copy:"Copy"}),BMCollectionViewAcceptPolicy=Object.freeze({Move:"Move",Copy:"Copy"}),_BMCoreUIIsDragging=NO,_BMCollectionViewAnimationDurationDefault=500,_BMCollectionViewAnimationEasingDefault="easeInOutQuart",_BMCollectionViewAnimationStrideDefault=50,_BMCollectionViewDoubleClickDelay=250,_BMCollectionViewLongClickDelay=400,_BMCollectionViewClickSlopeThreshold=10,_BMCollectionViewSnappingScrollThreshold=200,_BMCollectionViewIdentityComparator=function(t,e){return t==e},BMCollectionViewScrollingDirection=Object.freeze({Vertical:{},Horizontal:{},Both:{}}),BMCollectionViewScrollingGravityHorizontal=Object.freeze({Left:{},Center:{},Right:{}}),BMCollectionViewScrollingGravityVertical=Object.freeze({Top:{},Center:{},Bottom:{}}),_BMCollectionViews=new Map;function BMCollectionView(){}function BMCollectionViewMakeWithContainer(t,e){return(new BMCollectionView).initWithDOMNode(t[0],e)}BMCollectionView.prototype=BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS?Object.create(BMView.prototype):{},{constructor:BMCollectionView,get supportsAutomaticIntrinsicSize(){return NO},_lastMeasuredIntrinsicSize:void 0,get intrinsicSize(){},delegate:void 0,_usesLegacyDataSet:NO,_dataSet:void 0,get dataSet(){return this._dataSet},set dataSet(t){var e=this._dataSet;this._usesLegacyDataSet=YES,this._dataSet=t,this._dataSource=BMCollectionViewDataSourceAdapter.adapterWithDataSet(t),this.dataSetDidChangeFromDataSet(e)},_dataSource:void 0,get dataSource(){return this._dataSource},set dataSource(t){const e=this._dataSet;this._usesLegacyDataSet=NO,this._dataSource=t,this._dataSet=BMCollectionViewDataSetAdapter.adapterWithDataSource(this,t),this.dataSetDidChangeFromDataSet(e)},_container:void 0,get container(){return this._container},identityComparator:_BMCollectionViewIdentityComparator,indexPathForObjectAtRow:function(t,e){return this._dataSet?this._dataSet.indexPathForObjectAtRow(t,{inSectionAtIndex:e.inSectionAtIndex}):void 0},indexPathForObject:function(t){return this._dataSet?this._dataSet.indexPathForObject(t):void 0},numberOfSections:function(){return this._dataSet?this._dataSet.numberOfSections():0},numberOfObjectsInSectionAtIndex:function(t){return this._dataSet?this._dataSet.numberOfObjectsInSectionAtIndex(t):0},_layout:void 0,get layout(){return this._transitionLayout&&this._layout==this._transitionLayout?this._layout.targetLayout:this._layout},set layout(t){if(this.isUpdatingData){var e=this;this.registerDataCompletionCallback((function(){e.layout=t}))}else if(BMAnimationContextGetCurrent()){if(!this.initialized)return this._layout=t||new BMCollectionViewFlowLayout,void(this._layout.collectionView=this);this.setLayout(t||new BMCollectionViewFlowLayout)}else{if(this._layout=t||new BMCollectionViewFlowLayout,this._layout.collectionView=this,!this.initialized)return;this.invalidateLayout()}},_transitionLayout:void 0,_frame:void 0,get frame(){return this._frame},set frame(t){if(this._layoutAnimator)return void Object.getOwnPropertyDescriptor(BMView.prototype,"frame").set.call(this,t);const e=this._frame&&this._frame.copy();let i=!1;if(this._frame&&!t.size.isEqualToSize(this._frame.size)&&this.initialized){let i=this._layout.shouldInvalidateLayoutForFrameChange(t,{fromFrame:e});if(BMAnimationContextGetCurrent()){let e=this._frame;this._pendingFrame=t,i&&(this.layout.supportsCopying?(this.layout.beginUpdates(),this.layout.applyUpdates()):(this._frame=t,this.invalidateLayout())),this._frame=e,this.iScroll&&BMAnimationContextAddCompletionHandler((()=>{this.iScroll.refresh()}))}else this._frame=t,this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize,this._constrainBounds(),i&&this.invalidateLayout()}else if(!this._frame&&(this._frame=t,this.initialized)){let i=this._layout.shouldInvalidateLayoutForFrameChange(t,{fromFrame:e});this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize,this._constrainBounds(),i&&this.invalidateLayout()}this.__awaitsInit&&this._frame.size.width>0&&this._frame.size.height>0&&(i=!0),Object.getOwnPropertyDescriptor(BMView.prototype,"frame").set.call(this,t),this._pendingFrame=void 0,BMAnimationContextGetCurrent()||this.iScroll&&this.iScroll.refresh(),this._frame=t,i&&this._init()},_size:void 0,get size(){return this._size},_contentNode:void 0,get contentNode(){return this._contentNode},__contentWrapper:void 0,get _contentWrapper(){return BM_DEPRECATION_WARN&&(console.warn("Attempting to acess the _contentWrapper property which was deprecated. Consider using _contentNode instead and wrapping it using jQuery"),BM_DEPRECATION_TRACE&&console.trace()),this.__contentWrapper},set _contentWrapper(t){BM_DEPRECATION_WARN&&(console.warn("Attempting to acess the _contentWrapper property which was deprecated. Consider using _contentNode instead and wrapping it using jQuery"),BM_DEPRECATION_TRACE&&console.trace()),this.__contentWrapper=t,this._contentNode=t[0]},get contentWrapper(){return this._contentWrapper},_bounds:void 0,get bounds(){return this._bounds},get visibleBounds(){return new BMRect(BMPointMake(this._bounds.origin.x+this._offscreenBufferSize,this._bounds.origin.y+this._offscreenBufferSize),this._frame.size.copy())},_offscreenBufferSize:100,offscreenBufferFactor:.5,allowsOffscreenLayout:YES,_scrollingDirection:BMCollectionViewScrollingDirection.Vertical,get scrollingDirection(){return this._scrollingDirection},cellCache:{},supplementaryViewCache:{},attributeCache:{},retainedCells:[],allCells:[],initialized:NO,_collectionEnabled:YES,get scrollOffset(){var t=this._bounds.origin.copy();return t.x+=this._offscreenBufferSize,t.y+=this._offscreenBufferSize,t},set scrollOffset(t){this._scrollToOffset(t)},get scrollBarSize(){return this._usesIScroll?0:BMScrollBarGetSize()},_autoResizeToken:void 0,get autoResizes(){return void 0!==this._autoResizeToken},set autoResizes(t){if(this.autoResizes!=t)if(t){var e=this;this._autoResizeToken=function(t){e.resized()},window.addEventListener("resize",this._autoResizeToken)}else window.removeEventListener("resize",this._autoResizeToken),this._autoResizeToken=void 0},_cellClass:BMCollectionViewCell,get cellClass(){return this._cellClass},set cellClass(t){this._cellClass=t||BMCollectionViewCell},_cellClasses:void 0,_cellLayoutQueue:void 0,get cellLayoutQueue(){return this._cellLayoutQueue},set cellLayoutQueue(t){t||(t=BMViewLayoutQueue.layoutQueue()),this._cellLayoutQueue=t,this.enumerateAllCellsWithBlock((e=>{e.layoutQueue=t}))},assignsReuseIdentifierAsClass:YES,_supportsKeyboardNavigation:NO,get supportsKeyboardNavigation(){return this._supportsKeyboardNavigation},set supportsKeyboardNavigation(t){t!=this._supportsKeyboardNavigation&&(this._supportsKeyboardNavigation=t,this.initialized&&(t?this.configureKeyboardShortcuts():this.disableKeyboardShortcuts()))},registerCellClass(t,e){this._cellClasses[e.forReuseIdentifier]=t},_supplementaryViewClasses:void 0,registerSupplementaryViewClass(t,e){this._supplementaryViewClasses[e.forReuseIdentifier]=t},initWithDOMNode(t,e){var i=e&&e.customScroll;return _BMCollectionViews.set(this,!0),this._container=BMJQueryShim.shimWithDOMNode(t),this.layout=new BMCollectionViewFlowLayout,this.cellCache={},this.retainedCells=[],this.allCells=[],this.supplementaryViewCache={},this.attributeCache={},this._selectedIndexPaths=[],this.customScrollRequired=i,this._cellClasses={},this._supplementaryViewClasses={},this._measures={},this._measuredIndexPaths=[],this._cellLayoutQueue=BMViewLayoutQueue.layoutQueue(),BMView.prototype.initWithDOMNode.apply(this,arguments)},viewDidBecomeVisible(){BMView.prototype.viewDidBecomeVisible.apply(this,arguments),this.__awaitsInit?this.superview?this.frame&&this.frame.size.width>0&&this.frame.size.height>0&&this._init():this._init():this.__awaitsLayout&&this.invalidateLayout(),this.enumerateRetainedCellsWithBlock((t=>{t._collectionViewDidBecomeVisible()}))},viewDidBecomeInvisible(){BMView.prototype.viewDidBecomeInvisible.apply(this,arguments),this.enumerateRetainedCellsWithBlock((t=>{t._collectionViewDidBecomeInvisible()}))},_init:function(){if(!this.isCurrentlyVisible)return void(this.__awaitsInit=YES);if(this.superview&&(!this.frame||0==this.frame.size.width||0==this.frame.size.height))return void(this.__awaitsInit=YES);this.__awaitsInit=NO;var t=window.navigator.standalone&&void 0===this.customScrollRequired||this.customScrollRequired;if(/android/i.test(window.navigator.userAgent)&&(t=YES),this._prepareFrame(),this._createBounds(),t&&!BM_COLLECTION_VIEW_DISABLE_ISCROLL&&(this._usesIScroll=YES),BM_SIMPLE_BENCH){const t=Date.now();this._reloadLayout(),alert(`[BMCollectionView] Initial layout took ${Date.now()-t}ms.`)}else this._reloadLayout();if(t&&!BM_COLLECTION_VIEW_DISABLE_ISCROLL){this._container.css({"overflow-x":"hidden","overflow-y":"hidden"}),this.customScroll=YES,this.offscreenBufferFactor=0,BMAddSmoothMousewheelInteractionToNode(this._container[0]),this.iScroll=new IScroll(this._container[0],{mouseWheel:YES,scrollbars:YES,probeType:3,click:NO,deceleration:.001,resizePolling:999999999999,scrollX:YES,freeScroll:YES,interactiveScrollbars:!BMIsTouchDevice,disableMouse:YES,disablePointer:YES,fadeScrollbars:BMIsTouchDevice,HWCompositing:YES,bindToWrapper:YES,stopPropagation:YES,disableTouch:NO});var e=this;this.iScroll.on("scroll",(function(){e._handleNewScrollFromEvent({x:-this.x,y:-this.y})}))}else{this._boundContainerDidScrollWithEvent=this.containerDidScrollWithEvent.bind(this);var i=this._highFrequencyScrollingEnabled;this.container[0].addEventListener("scroll",this._boundContainerDidScrollWithEvent,{capture:i,passive:YES})}let o,n,s=NO;this._container[0].addEventListener("wheel",(t=>{(this._size.width>this._frame.size.width||this._size.height>this._frame.size.height)&&t.stopPropagation()}));let a=NO;this._container[0].addEventListener("touchstart",(t=>{o||(s=this._size.width>this._frame.size.width||this._size.height>this._frame.size.height,s&&(o=t.changedTouches[0].identifier,n=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY)))})),this._container[0].addEventListener("touchmove",(t=>{if(!o)return;let e=t.changedTouches.length;for(let i=0;i<e;i++){let e=t.changedTouches[i];if(e.identifier==e){if(a)t.stopPropagation();else{let i=e;BMPointMake(i.clientX,i.clientY).distanceToPoint(n)>_BMCollectionViewClickSlopeThreshold&&(a=YES,t.stopPropagation())}return}}}));let r=t=>{if(!o)return;let e=t.changedTouches.length;for(let i=0;i<e;i++){let e=t.changedTouches[i];if(e.identifier==e)return e=void 0,a&&t.stopPropagation(),a=NO,void(n=void 0)}};this._container[0].addEventListener("touchcancel",r),this._container[0].addEventListener("touchend",r);var l=NO;if(this.delegate&&"function"==typeof this.delegate.collectionViewShouldRunIntroAnimation&&(l=this.delegate.collectionViewShouldRunIntroAnimation(this)),l){let t;this.isUpdatingData=YES,this._dataUpdatePromise=new Promise((e=>t=e));for(var h=this._bounds.rectWithInset(BMInset.insetWithEqualInsets(this._offscreenBufferSize)),c=this.retainedCells.slice(),d=(e=this,0);d<c.length;d++){var u,p=c[d];h.intersectsRect(p.attributes.frame)||(c.splice(d,1),d--),p.attributes.itemType==BMCollectionViewLayoutAttributesType.Cell?u=this.layout.initialAttributesForPresentedCellAtIndexPath(p.indexPath,{withTargetAttributes:p.attributes}):p.attributes.itemType==BMCollectionViewLayoutAttributesType.SupplementaryView&&(u=this.layout.initialAttributesForPresentedSupplementaryViewWithIdentifier(p.reuseIdentifier,{atIndexPath:p.indexPath,withTargetAttributes:p.attributes})),u.targetAttributes=p.attributes,p.attributes=u}var g={};this.delegate&&this.delegate.collectionViewAnimationOptionsForIntroAnimation&&(g=this.delegate.collectionViewAnimationOptionsForIntroAnimation(this)),BMAnimateWithBlock((function(){for(var i=0;i<c.length;i++){var o=c[i];o.attributes=o.attributes.targetAttributes}const n=()=>{e.isUpdatingData=NO,e._executeDataCompletionCallbacks(),t()};c.length?BMAnimationContextAddCompletionHandler(n):n()}),BMExtend({duration:_BMCollectionViewAnimationDurationDefault,easing:_BMCollectionViewAnimationEasingDefault,stride:_BMCollectionViewAnimationStrideDefault,delay:0},g))}this._supportsKeyboardNavigation&&this.configureKeyboardShortcuts(),this.initialized=YES},invalidateLayout:function(){if(!this.initialized)return;if(this._blocksLayoutInvalidation)return;if(!this.isCurrentlyVisible&&!this.allowsOffscreenLayout)return void(this.__awaitsLayout=YES);if(this.isUpdatingData){var t=this;return void this.registerDataCompletionCallback((function(){t.invalidateLayout()}))}let e;if(this._blocksLayoutInvalidation=YES,(e=BMAnimationContextGetCurrent())&&this.layout._copy){let t=this._layout;return this._layout=this._layout._copy,this._layout._collectionView=this,this._layout.prepareLayout(),this.setLayout(t,{animated:YES})}this.attributeCache={},this.retainedCells=[],this._reloadLayout(),this._blocksLayoutInvalidation=NO},invalidateLayoutWithContext:function(t,e){this.invalidateLayout()},resized:function(){if(!this.initialized)return;if(this._frame.size.height==this._container.height()&&this._frame.size.width==this._container.width())return;if(this.isUpdatingData){var t=this;return void this.registerDataCompletionCallback((function(){t.resized()}))}const e=this._frame&&this._frame.copy();this._prepareFrame(),this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize,this._constrainBounds(),this._layout.shouldInvalidateLayoutForFrameChange(this._frame,{fromFrame:e})&&this.invalidateLayout()},_prepareFrame:function(){var t=this._container.offset();this._frame=BMRectMake(t.left,t.top,this._container[0].offsetWidth,this._container[0].offsetHeight),this._offscreenBufferSize=this.customScroll?0:Math.max(this._frame.size.width*this.offscreenBufferFactor,this._frame.size.height*this.offscreenBufferFactor),this.scrollView&&(this.scrollView.frame=this._frame)},_createBounds:function(){this._bounds=this._frame.copy(),this._bounds.size.width+=2*this._offscreenBufferSize,this._bounds.size.height+=2*this._offscreenBufferSize,this._bounds.origin.x=-this._offscreenBufferSize,this._bounds.origin.y=-this._offscreenBufferSize},_constrainBounds:function(){var t=this._bounds;t.right>this._size.width+this._offscreenBufferSize&&(t.origin.x=this._size.width-this._frame.size.width-this._offscreenBufferSize,t.origin.x=Math.max(t.origin.x,-this._offscreenBufferSize)),t.origin.x<-this._offscreenBufferSize&&(t.origin.x=-this._offscreenBufferSize),t.bottom>this._size.height+this._offscreenBufferSize&&(t.origin.y=this._size.height-this._frame.size.height-this._offscreenBufferSize,t.origin.y=Math.max(t.origin.y,-this._offscreenBufferSize)),t.origin.y<-this._offscreenBufferSize&&(t.origin.y=-this._offscreenBufferSize)},invalidateContentSize(){if(this._collectionEnabled){var t=this._layout.contentSize();t.isEqualToSize(this._size)||(this._size=t.copy(),BMHook(this._contentWrapper[0],{width:this._size.width+"px",height:this._size.height+"px"}),this._constrainBounds(),this._applyOverflows())}else this.registerDataCompletionCallback((()=>{this.invalidateContentSize()}))},invalidateLayoutForBoundsChange:function(){if(this.initialized&&!this._blocksLayoutInvalidation)if(this.isCurrentlyVisible||this.allowsOffscreenLayout){this._blocksLayoutInvalidation=YES,this.attributeCache={},this._layout.prepareLayout(),this.invalidateContentSize();var t=this._requestAttributesInRect(this._bounds.copy());this._renderCellsWithAttributes(t,{exclusive:YES}),this._blocksLayoutInvalidation=NO}else this.__awaitsLayout=YES},_reloadLayout:function(){let t=!this._contentWrapper;if(t){const t=document.createElement("div");t.style.cssText="width: 900px; height: 900px; overflow: hidden; position: absolute; left: 0px; top: 0px;",this._contentWrapper=BMJQueryShim.shimWithDOMNode(t),this._container.append(this._contentWrapper)}this._layout.prepareLayout(),this._size=this._layout.contentSize().copy(),this.scrollView&&(this.scrollView.size=this._size),BMHook(this._contentWrapper[0],{width:this._size.width+"px",height:this._size.height+"px"}),this._constrainBounds(),this._applyOverflows();var e=this._requestAttributesInRect(this._bounds.copy());this._renderCellsWithAttributes(e,{exclusive:YES}),this._cellLayoutQueue.dequeue()},_applyOverflows:function(){if(this.customScroll){if(this.iScroll)return void this.iScroll.refresh();if(this.scrollView.canScrollHorizontally=this._size.width>this._frame.size.width,this.scrollView.canScrollVertically=this._size.height>this._frame.size.height,this.initialized)return;this._container.css({"overflow-x":"hidden","overflow-y":"hidden"})}else this._size.width<=this._frame.size.width?this._container.css("overflow-x","hidden"):this._container.css("overflow-x","scroll"),this._size.height<=this._frame.size.height?this._container.css("overflow-y","hidden"):this._container.css("overflow-y","scroll")},_alignedRequestRectWithRect:function(t){return this._alignedRequestRectWithPoint(t.origin)},_alignedRequestOriginWithPoint:function(t){return BMPointMake(((t.x+this._offscreenBufferSize)/this._bounds.size.width|0)*this._bounds.size.width-this._offscreenBufferSize,((t.y+this._offscreenBufferSize)/this._bounds.size.height|0)*this._bounds.size.height-this._offscreenBufferSize)},_alignedRequestRectWithPoint:function(t){if(!(t.x<-this._offscreenBufferSize||t.y<-this._offscreenBufferSize||t.x>this._size.width||t.y>this._size.height))return new BMRect(this._alignedRequestOriginWithPoint(t),this._bounds.size)},_requestAttributesInRect:function(t){var e=this._layout.attributesForElementsInRect(t);return this.attributeCache[t.origin.integerStringValue]={key:t,value:e},e},_highFrequencyScrollingEnabled:NO,get highFrequencyScrollingEnabled(){return this._highFrequencyScrollingEnabled},set highFrequencyScrollingEnabled(t){var e=this._highFrequencyScrollingEnabled;this._highFrequencyScrollingEnabled=t,this.initialized&&!this.iScroll&&(this.container[0].removeEventListener("scroll",this._boundContainerDidScrollWithEvent,{capture:e,passive:YES}),this.container[0].addEventListener("scroll",this._boundContainerDidScrollWithEvent,{capture:t,passive:YES}))},containerDidScrollWithEvent:function(t){if(this._collectionEnabled)return this._highFrequencyScrollingEnabled?this._handleNewScrollFromEvent(t):void(this.didRequestScrollAnimationFrame||(this.didRequestScrollAnimationFrame=YES,window.requestAnimationFrame(this._handleNewScrollFromEvent.bind(this,t))))},_handleNewScrollFromEvent:function(t){if(this.didRequestScrollAnimationFrame=NO,!this._collectionEnabled)return;var e,i=this._container[0],o=!this._isPerformingAnimatedScrolling&&this._layout.snapsScrollPosition;if(e=this._bounds.origin.copy(),this.customScroll?(this._bounds.origin.x=t.x-this._offscreenBufferSize,this._bounds.origin.y=t.y-this._offscreenBufferSize):(this._bounds.origin.x=Math.max(-this._offscreenBufferSize,i.scrollLeft-this._offscreenBufferSize),this._bounds.origin.y=Math.max(-this._offscreenBufferSize,i.scrollTop-this._offscreenBufferSize)),e.x==this._bounds.origin.x&&e.y==this._bounds.origin.y)return;const n=BMRectMakeWithOrigin(e,{size:this._bounds.size.copy()});if((async()=>{await 0,this._cellLayoutQueue.dequeue()})(),this._layout.shouldInvalidateLayoutForBoundsChange(this._bounds,{fromBounds:n}))return this.invalidateLayoutForBoundsChange(),this.delegate&&"function"==typeof this.delegate.collectionViewBoundsDidChange&&this.delegate.collectionViewBoundsDidChange(this,this._bounds,{fromBounds:n}),this._layout.didInvalidateLayoutForBoundsChange(),void(o&&this._prepareForSnappingScrollOffsetWithPreviousOffset(e));for(var s=0;s<this.retainedCells.length;s++){var a=this.retainedCells[s];a.attributes.frame.intersectsRect(this._bounds)||(a._unmanage(),s--)}var r=[],l=this._alignedRequestOriginWithPoint(this._bounds.origin),h=this.attributeCache[l.integerStringValue];if(h&&r.push(h),!l.isEqualToPoint(this._bounds.origin))if(l.x==this._bounds.origin.x){var c=l;c.y+=this._bounds.size.height;var d=this.attributeCache[c.integerStringValue];d&&r.push(d)}else if(l.y==this._bounds.origin.y){var u=l;u.x+=this._bounds.size.width;var p=this.attributeCache[u.integerStringValue];p&&r.push(p)}else{(c=l.copy()).y+=this._bounds.size.height,(d=this.attributeCache[c.integerStringValue])&&r.push(d),(u=l).x+=this._bounds.size.width,(p=this.attributeCache[u.integerStringValue])&&r.push(p);var g=c;g.x+=this._bounds.size.width;var w=this.attributeCache[g.integerStringValue];w&&r.push(w)}for(var y=r.length,m=[this._bounds],_=0;_<y;_++){var f=r[_].value,v=r[_].key;this._renderCellsWithAttributes(f);var M=[];for(s=0;s<m.length;s++){var S=m[s].rectsWithDifferenceFromRect(v);S&&(M=M.concat(S))}m=M}if(!y){m=[];var C=this._alignedRequestRectWithPoint(this._bounds.origin);if(C.isEqualToRect(this._bounds)){f=this._requestAttributesInRect(C);this._renderCellsWithAttributes(f)}else if(C.origin.x==this._bounds.origin.x){var b=this._alignedRequestRectWithPoint({x:C.origin.x,y:C.bottom+1});f=this._requestAttributesInRect(C);this._renderCellsWithAttributes(f),b&&(f=this._requestAttributesInRect(b),this._renderCellsWithAttributes(f))}else if(C.origin.y==this._bounds.origin.y){var B=this._alignedRequestRectWithPoint({x:C.right+1,y:C.origin.y});f=this._requestAttributesInRect(C);this._renderCellsWithAttributes(f),B&&(f=this._requestAttributesInRect(B),this._renderCellsWithAttributes(f))}else{m.push(C),(b=this._alignedRequestRectWithPoint({x:C.origin.x,y:C.bottom+1}))&&m.push(b),(B=this._alignedRequestRectWithPoint({x:C.right+1,y:C.origin.y}))&&m.push(B);var E=this._alignedRequestRectWithPoint({x:C.right+1,y:C.bottom+1});E&&m.push(E);for(s=0;s<m.length;s++){f=this._requestAttributesInRect(m[s]);this._renderCellsWithAttributes(f)}}return this.delegate&&"function"==typeof this.delegate.collectionViewBoundsDidChange&&this.delegate.collectionViewBoundsDidChange(this,this._bounds,{fromBounds:n}),void(o&&this._prepareForSnappingScrollOffsetWithPreviousOffset(e))}if(m)for(s=0;s<m.length;s++){var V=this._alignedRequestRectWithRect(m[s]);if(V){f=this._requestAttributesInRect(V);this._renderCellsWithAttributes(f)}}this.delegate&&"function"==typeof this.delegate.collectionViewBoundsDidChange&&this.delegate.collectionViewBoundsDidChange(this,this._bounds,{fromBounds:n}),this._isPerformingAnimatedScrolling||o&&this._prepareForSnappingScrollOffsetWithPreviousOffset(e)},_snappingScrollToken:void 0,_prepareForSnappingScrollOffsetWithPreviousOffset:function(t){this._snappingScrollToken&&window.clearTimeout(this._snappingScrollToken);var e=this;this._snappingScrollToken=window.setTimeout((function(){var i=Math.max(-1,Math.min(1,t.x-e._bounds.origin.x)),o=Math.max(-1,Math.min(1,t.y-e._bounds.origin.y)),n=e.layout.snappingScrollOffsetForScrollOffset(e.scrollOffset,{withVerticalDirection:o,horizontalDirection:i});BMAnimateWithBlock((t=>{e.scrollOffset=n}),{duration:200})}),_BMCollectionViewSnappingScrollThreshold)},_renderCellsWithAttributes:function(t,e){for(var i=t.length,o=(e=e||{}).exclusive||NO,n=0;n<i;n++){var s=t[n];if(s.frame.intersectsRect(this._bounds))if(l=this.cellAtIndexPath(s.indexPath,{ofType:s.itemType,withIdentifier:s.identifier}))l.isManaged?l.attributes!==s&&(s.isHidden?(l._unmanage(),l.isRetained&&(l.attributes=s)):l.attributes=s):(s.isHidden||l._manage(),l.attributes=s),o&&(l._exclusivelyRendered=YES);else if(!s.isHidden){if(s.itemType===BMCollectionViewLayoutAttributesType.Cell){var a=this.indexPathForObjectAtRow(s.indexPath.row,{inSectionAtIndex:s.indexPath.section});s.indexPath=a,l=this._dataSet.cellForItemAtIndexPath(a)}else s.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&(l=this._dataSet.cellForSupplementaryViewWithIdentifier(s.identifier,{atIndexPath:s.indexPath}));l.attributes=s,l._manage(),o&&(l._exclusivelyRendered=YES)}}if(o){var r=this.allCells.length;for(n=0;n<r;n++){var l;if((l=this.allCells[n])._reuseState!=BMCollectionViewCellReuseState.Deleting)if(l._exclusivelyRendered)l._exclusivelyRendered=void 0;else if(l.isManaged&&l._unmanage(),l.retainCount>0){if(l.itemType===BMCollectionViewLayoutAttributesType.Cell){let t=this._layout.attributesForCellAtIndexPath(l.indexPath);l.attributes=t}else if(l.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView){let t=this._layout.attributesForSupplementaryViewWithIdentifier(l.reuseIdentifier,{atIndexPath:l.indexPath});l.attributes=t}}else n--,r--}}},_measuringCells:void 0,_retainMeasuringCells(){this._measuringCells=[]},_releaseMeasuringCells(){this._measuringCells&&this._measuringCells.forEach((t=>t.release())),this._measuringCells=void 0},_measures:void 0,_measuredIndexPaths:void 0,_updateMeasuredCellsIndexPaths:function(){var t=this._measuredIndexPaths;this._measuredIndexPaths=[];for(var e=t.length,i=0;i<e;i++){var o=this.dataSet.indexPathForObject(t[i].indexPath.object);o&&(t[i].indexPath=o,this._measuredIndexPaths.push(t[i]))}},invalidateMeasuredSizeOfCells(){this._measures={},this._measuredIndexPaths=[]},invalidateMeasuredSizeOfCellsWithBlock(t){if(this._dataSet.identifierForIndexPath){let e=[];for(let i in this._measures)t(this._measures[i],void 0,i)&&e.push(i);for(let t of e)delete this._measures[t]}else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++)t(this._measuredIndexPaths[i].size,this._measuredIndexPaths[i].indexPath)&&(this._measuredIndexPaths.splice(i,1),e--,i--)}},invalidateMeasuredSizeOfCellAtIndexPath(t){let e;if(this._dataSet.identifierForIndexPath)e=this._dataSet.identifierForIndexPath(t),this._measures[e]&&delete this._measures[e];else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++){if(this._measuredIndexPaths[i].indexPath.isEqualToIndexPath(t,{usingComparator:this.identityComparator})){this._measuredIndexPaths.splice(i,1);break}}}},measureSizesOfCellsAtIndexPaths(t){const e=BMViewLayoutQueue.layoutQueue(),i=t.map((t=>this._measuredSizeOfCellAtIndexPathGenerator(t,{layoutQueue:e,dequeue:NO})));i.forEach((t=>t.next())),e.dequeue(),i.forEach((t=>t.next()))},measuredSizeOfCellAtIndexPath(t){const e=this._measuredSizeOfCellAtIndexPathGenerator(t,{layoutQueue:BMViewLayoutQueue.layoutQueue(),dequeue:YES});for(;YES;){const t=e.next();if(t.done)return t.value}let i;if(this._dataSet.identifierForIndexPath){if(i=this._dataSet.identifierForIndexPath(t),this._measures[i])return this._measures[i]}else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++){if(this._measuredIndexPaths[i].indexPath.isEqualToIndexPath(t,{usingComparator:this.identityComparator}))return this._measuredIndexPaths[i].size}}if(BM_COLLECTION_VIEW_DEBUG_MEASURE&&!this.__debug__measuring){this.__debug__measuring=YES;let t=document.createElement("div");t.style.cssText="position: fixed; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",document.body.appendChild(t),requestAnimationFrame((()=>(t.remove(),this.__debug__measuring=NO)))}let o,n=this.cellAtIndexPath(t),s=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);if(s.frame=BMRectMake(0,0,1e4,1e4),n?o=n.attributes:n=this._dataSet.cellForItemAtIndexPath(t),BM_COLLECTION_VIEW_DEBUG_MEASURE_CELL){let t=document.createElement("div");t.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",n.node.appendChild(t),requestAnimationFrame((()=>t.remove()))}n._isMeasuring=YES,n._invalidatedConstraints=YES;const a=n.layoutQueue;n.layoutQueue=BMViewLayoutQueue.layoutQueue(),n.attributes=s,n.retain();let r,l=[],h=n.left.equalTo(0);h.isActive=YES,l.push(h),h=n.top.equalTo(0),h.isActive=YES,l.push(h),h=n.width.equalTo(0,{priority:1}),h.isActive=YES,l.push(h),h=n.height.equalTo(0,{priority:1}),h.isActive=YES,l.push(h);for(let e of this.layout.constraintsForMeasuringCell(n,{atIndexPath:t}))e.isActive=YES,l.push(e);n.layoutIfNeeded(),n.layoutQueue=a,this._measuringCells&&this._measuringCells.push(n.retain()),r=n._subviews.length?n.subviews[0].frame.size:BMSizeMake(n._variables[BMLayoutAttribute.Width].value()|n.node.offsetWidth,n._variables[BMLayoutAttribute.Height].value()|n.node.offsetHeight),n.release();for(let t of l)t.remove();return n.retainCount>0&&o?n.attributes=o:(n._attributes=void 0,s._cell=void 0),n._invalidatedConstraints=YES,n._isMeasuring=NO,i?this._measures[i]=r.copy():this._measuredIndexPaths.push({indexPath:t,size:r}),r},*_measuredSizeOfCellAtIndexPathGenerator(t,{layoutQueue:e,dequeue:i}){let o;if(this._dataSet.identifierForIndexPath){if(o=this._dataSet.identifierForIndexPath(t),this._measures[o])return this._measures[o]}else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++){if(this._measuredIndexPaths[i].indexPath.isEqualToIndexPath(t,{usingComparator:this.identityComparator}))return this._measuredIndexPaths[i].size}}if(!this.isCurrentlyVisible)return this.__awaitsLayout=YES,BMSizeMake(0,0);if(BM_COLLECTION_VIEW_DEBUG_MEASURE&&!this.__debug__measuring){this.__debug__measuring=YES;let t=document.createElement("div");t.style.cssText="position: fixed; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",document.body.appendChild(t),requestAnimationFrame((()=>(t.remove(),this.__debug__measuring=NO)))}let n,s=this.cellAtIndexPath(t),a=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);if(a.frame=BMRectMake(0,0,1e4,1e4),s?n=s.attributes:s=this._dataSet.cellForItemAtIndexPath(t),BM_COLLECTION_VIEW_DEBUG_MEASURE_CELL){let t=document.createElement("div");t.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",s.node.appendChild(t),requestAnimationFrame((()=>t.remove()))}s._isMeasuring=YES,s._invalidatedConstraints=YES,s._subviews.length||(s._needsIntrinsicSizeMeasurement=YES);const r=s.layoutQueue;s._cancelLayout(),s.layoutQueue=e,s.attributes=a,s.retain();let l,h=[],c=s.left.equalTo(0);c.isActive=YES,h.push(c),c=s.top.equalTo(0),c.isActive=YES,h.push(c),c=s.width.equalTo(0,{priority:1}),c.isActive=YES,h.push(c),c=s.height.equalTo(0,{priority:1}),c.isActive=YES,h.push(c);for(let e of this.layout.constraintsForMeasuringCell(s,{atIndexPath:t}))e.isActive=YES,h.push(e);yield,i&&s.layoutIfNeeded(),s.layoutQueue=r,this._measuringCells&&this._measuringCells.push(s.retain()),l=s._subviews.length?s.subviews[0].frame.size:BMSizeMake(s._variables[BMLayoutAttribute.Width].value()||s.node.offsetWidth,s._variables[BMLayoutAttribute.Height].value()||s.node.offsetHeight),s.release();for(let t of h)t.remove();return s.retainCount>0&&n?s.attributes=n:(s._attributes=void 0,a._cell=void 0),s._invalidatedConstraints=YES,s._isMeasuring=NO,o?this._measures[o]=l.copy():this._measuredIndexPaths.push({indexPath:t,size:l}),l},refreshCellAtIndexPath:function(t,e){var i=e&&e.animated,o=this.cellAtIndexPath(t,{ofType:BMCollectionViewLayoutAttributesType.Cell});if(o){var n=o.attributes.copy();if(o._attributes=o.attributes.copy(),o._attributes.indexPath=BMIndexPathNone,o._attributes._cell=o,i){var s=this.dataSet.cellForItemAtIndexPath(t),a=n.style.opacity;void 0===a&&(a=1),n.style.opacity=0;var r=o.attributes.style.opacity;return void 0===r&&(r=1),s.attributes=n,n.isHidden||s._manage(),o.retain(),s.retain(),o._unmanage(),BMAnimateWithBlock((function(){s.attributes.style.opacity=a,o.attributes.style.opacity=0,s.attributes.style=s.attributes.style,o.attributes.style=o.attributes.style}),{duration:100,easing:"easeInOutQuad",queue:NO,complete:function(){s.release(),o.releaseRecycledCell(),o.attributes.style.opacity=r}}),s}return o.recycle(),n.isHidden?void 0:((s=this.dataSet.cellForItemAtIndexPath(t)).attributes=n,s._manage(),s)}},dequeueCellForReuseIdentifier:function(t){var e=this.cellCache[t];if(e&&e.length)return(i=e.pop()).node.style.opacity=i._backingOpacity,i;var i,o=this._cellClasses[t]||this._cellClass,n=document.createElement("div");n.style.cssText="position: absolute; left: 0px; top: 0px; visibility: hidden; overflow: visible;",(i=Object.create(o.prototype).initWithCollectionView(this,{reuseIdentifier:t,node:n,kind:BMCollectionViewLayoutAttributesType.Cell})).layoutQueue=this._cellLayoutQueue,o==BMCollectionViewCell&&this._usesLegacyDataSet&&i.element.append(this._dataSet.contentsForCellWithReuseIdentifier(t)),this._contentWrapper.append(i.element);var s,a,r,l=this,h=0,c=NO,d=BMPointMake(),u=NO,p=NO,g=NO,w=NO,y=NO;const m=()=>{u=NO,g=NO,r=void 0,window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES),h=0,s&&(window.clearTimeout(s),s=void 0),a&&(window.clearTimeout(a),a=void 0)};return i.mousedownHandler=function(t){if(_BMCoreUIIsDragging)return t.preventDefault(),void t.stopPropagation();t.originalEvent=t;const e=t.which||t.button;if(("touchstart"==t.originalEvent.type||1==e)&&!("BUTTON"==t.target.nodeName||"INPUT"==t.target.nodeName||"LABEL"==t.target.nodeName||"A"==t.target.nodeName||"BUTTON"==t.target.parentNode.nodeName||"INPUT"==t.target.parentNode.nodeName||"LABEL"==t.target.parentNode.nodeName||t.target.classList.contains("BMCollectionViewCellEventHandler")||t.target.parentNode.classList.contains("BMCollectionViewCellEventHandler")||t.target.classList.contains("widget-foldingpanel-header")||t.target.hasAttribute("contenteditable")||window.$&&window.$(t.target).parents(".widget-dhxdropdown").length)){if("touchstart"==t.originalEvent.type){if(void 0!==r)return;r=t.originalEvent.touches[0].identifier}else window.addEventListener("mousemove",i.mousemoveHandler,YES),window.addEventListener("mouseup",i.mouseupHandler,YES);y=NO,l.delegate&&l.delegate.collectionViewCanMoveCell&&(y=l.delegate.collectionViewCanMoveCell(l,i,{atIndexPath:i.indexPath})),y&&t.preventDefault(),d.x=t.pageX||t.originalEvent.touches&&t.originalEvent.touches[0].pageX||0,d.y=t.pageY||t.originalEvent.touches&&t.originalEvent.touches[0].pageY||0,c=NO,g=NO,s=window.setTimeout((function(){if(s=void 0,c=YES,l.cellWasLongClicked(i,{withEvent:t}))y&&(g=YES);else if(y){if(t.BM_Handled)return void m();t.BM_Handled=YES,window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES),u=NO,l.delegate&&l.delegate.collectionViewWillBeginInteractiveMovementForCell&&l.delegate.collectionViewWillBeginInteractiveMovementForCell(l,i,{atIndexPath:i.indexPath}),l.beginDragWithEvent(t,{forCell:i,touchIdentifier:r}),r=void 0}}),_BMCollectionViewLongClickDelay),p=NO,l.delegate&&l.delegate.collectionViewCanDoubleClickCell&&(p=l.delegate.collectionViewCanDoubleClickCell(l,i)),p&&(a=window.setTimeout((function(){a=void 0,h&&(l.cellWasClicked(i,{withEvent:t}),h=0)}),_BMCollectionViewDoubleClickDelay)),u=YES}},i.element[0].addEventListener("mousedown",i.mousedownHandler,w),i.element[0].addEventListener("touchstart",i.mousedownHandler,w),i.mousemoveHandler=function(t){if(t.BM_Handled)return void m();if(_BMCoreUIIsDragging)return t.preventDefault(),void t.stopPropagation();y&&t.preventDefault(),t.originalEvent=t;t.which||t.button;if(u){if("touchmove"==t.type){if(void 0===r)return;for(var e=0;e<t.originalEvent.changedTouches.length;e++)if(t.originalEvent.changedTouches[e].identifier==r){var o=t.originalEvent.changedTouches[e].pageX,n=t.originalEvent.changedTouches[e].pageY;break}if(e==t.originalEvent.changedTouches.length)return}else o=t.pageX,n=t.pageY;(Math.abs(o-d.x)>_BMCollectionViewClickSlopeThreshold||Math.abs(n-d.y)>_BMCollectionViewClickSlopeThreshold)&&(window.clearTimeout(s),window.clearTimeout(a),u=NO,h&&(l.cellWasClicked(i,{withEvent:t}),h=0),("mousemove"==t.type||g)&&y&&(t.BM_Handled=YES,l.delegate&&l.delegate.collectionViewWillBeginInteractiveMovementForCell&&l.delegate.collectionViewWillBeginInteractiveMovementForCell(l,i,{atIndexPath:i.indexPath}),window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES),l.beginDragWithEvent(t,{forCell:i,touchIdentifier:r}),r=void 0))}},i.element[0].addEventListener("touchmove",i.mousemoveHandler,w),i.touchcancelHandler=function(t){if(_BMCoreUIIsDragging)return;t.originalEvent=t;t.which||t.button;if(void 0!==r){for(var e=0;e<t.originalEvent.changedTouches.length;e++)if(t.originalEvent.changedTouches[e].identifier==r){r=void 0,t.preventDefault();break}e!=t.originalEvent.changedTouches.length&&window.clearTimeout(a)}},i.element[0].addEventListener("touchcancel",i.touchcancelHandler,w),i.mouseupHandler=function(t){if(_BMCoreUIIsDragging)return;t.originalEvent=t;const e=t.which||t.button;if("mouseup"!=t.originalEvent.type||1==e){if("touchend"==t.originalEvent.type){if(void 0===r)return;for(var o=0;o<t.originalEvent.changedTouches.length;o++)if(t.originalEvent.changedTouches[o].identifier==r){r=void 0,t.preventDefault();break}if(o==t.originalEvent.changedTouches.length)return}else window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES);u&&(u=NO,c||(window.clearTimeout(s),p?a&&++h>=2&&(h=0,l.cellWasDoubleClicked(i,{withEvent:t}),window.clearTimeout(a)):l.cellWasClicked(i,{withEvent:t})))}},i.element[0].addEventListener("touchend",i.mouseupHandler,w),i.contextMenuHandler=function(t){l.cellWasRightClicked(i,{withEvent:t})&&(t.preventDefault(),t.stopPropagation())},i.element[0].addEventListener("contextmenu",i.contextMenuHandler),i},isDragging:NO,interactiveMovement:void 0,_draggingIndexPaths:void 0,invalidateDraggingIndexPaths(){this._draggingIndexPaths&&(this._draggingIndexPaths=this._draggingIndexPaths.map((t=>this._dataSet.indexPathForObject(t.object))))},_canAcceptItems(t){return this.delegate&&this.delegate.collectionViewCanAcceptItems?this.delegate.collectionViewCanAcceptItems(this,t):NO},_insertItems:async function(t,e){this._droppedShadows=e.withDropShadows,this.dataSet.insertItems(t,e),await new Promise(((t,e)=>{this.registerDataCompletionCallback((()=>{t()}))}))},beginDragWithEvent(t,e){if(this.isDragging)return;let i,o=e.touchIdentifier;this.interactiveMovement=new Promise((function(t,e){i=t})),this.isDragging=YES,_BMCoreUIIsDragging=YES;let n=e.forCell,s=[];const a=n.node.classList.contains(BMMenuSourceNodeCSSClass);a&&n.node.classList.remove(BMMenuSourceNodeCSSClass);let r,l=n.node.cloneNode(YES);l.classList.add("BMDragShadow"),s.push(l),this.isCellAtIndexPathSelected(n.indexPath)?(r=[],this._selectedIndexPaths.sort(((t,e)=>e.section==t.section?t.row-e.row:t.section-e.section)).forEach((t=>{let e=this.retainCellForIndexPath(t);r.push(e),e.isDragging=YES,e.node.classList.add("BMCollectionViewCellDragging")}))):(r=[n],n.isDraggging=YES,n.retain(),n.node.classList.add("BMCollectionViewCellDragging"));let h,c,d=document.createElement("div");if(d.classList.add("BMDragIndicator"),d.innerText=r.length.toFixed(),d.style.zIndex="99999999",void 0!==o){for(var u=0;u<t.changedTouches.length;u++)if(t.changedTouches[u].identifier==o){h=t.changedTouches[u].clientX,c=t.changedTouches[u].clientY;break}}else h=t.clientX,c=t.clientY;let p=BMRectMakeWithNodeFrame(n.node),g=BMPointMake(h-p.origin.x,c-p.origin.y),w=BMPointMake(h-g.x,c-g.y),y=[],m=new Map,_=YES,f=null;r.forEach((t=>{if(t==n||y.length>=10)return;let e=t.node.cloneNode(YES);e.classList.add("BMDragShadow"),e.classList.remove("BMCollectionViewCellDragging"),s.splice(1,0,e),f=e;let i=BMRectMakeWithNodeFrame(t.node);m.set(e,t),e.style.pointerEvents="none",e.style.position="fixed",e.style.left=i.origin.x+"px",e.style.top=i.origin.y+"px",BMHook(e,{translateX:0,translateY:0}),e.style.zIndex=99999997,y.push(e);let o=y.length;(window.Velocity||$.Velocity).animate(e,{tween:1},{easing:"easeInOutQuad",duration:300,progress:(t,n,s,a,l)=>{BMHook(e,{rotateZ:l*(60*o/r.length)+"deg"}),e.style.left=BMNumberByInterpolatingNumbersWithFraction(i.origin.x,w.x,l)+"px",e.style.top=BMNumberByInterpolatingNumbersWithFraction(i.origin.y,w.y,l)+"px"},complete(){_=NO}})})),l.style.transform="",l.style.pointerEvents="none",l.style.position="fixed",l.style.left=h-g.x+"px",l.style.top=c-g.y+"px",l.style.zIndex=99999998,d.style.left=h-g.x-12+"px",d.style.top=c-g.y-12+"px",BMHook(d,{scaleX:0,scaleY:0}),s.forEach((t=>document.body.appendChild(t))),document.body.appendChild(d),__BMVelocityAnimate(d,{opacity:[1,0],scaleX:[1,0],scaleY:[1,0]},{duration:300,easing:"easeOutQuad"}),this.layout.prepareForDragOperation();let v=BMRectMakeWithNodeFrame(this.container[0]),M=0,S=0;var C=()=>{if(b=window.requestAnimationFrame(C),S||M){let t=this.scrollOffset;t.x=t.x+S,t.y=t.y+M,t.x=Math.max(0,Math.min(t.x,this.size.width-this.frame.size.width)),t.y=Math.max(0,Math.min(t.y,this.size.height-this.frame.size.height)),this.scrollOffset=t}},b=window.requestAnimationFrame(C);let B=NO,E=NO,V=NO;n.indexPath;this._draggingIndexPaths=r.map((t=>t.indexPath));let L,x,A,I,P=[],W=new Map;this.delegate&&this.delegate.collectionViewCanTransferItemsAtIndexPaths&&(V=this.delegate.collectionViewCanTransferItemsAtIndexPaths(this,this._draggingIndexPaths),V&&(_BMCollectionViews.forEach(((t,e)=>{if(e==this)return;if(!e._canAcceptItems(this._draggingIndexPaths.map((t=>t.object))))return;let i;P.push(e),o||(i={mouseover:t=>(x=e,L=BMRectMakeWithNodeFrame(e._container[0]),d.classList.add("BMDragIndicatorBlue"),t.preventDefault(),t.stopPropagation(),NO),mouseout:t=>(x=void 0,L=void 0,d.classList.remove("BMDragIndicatorBlue"),t.preventDefault(),t.stopPropagation(),NO)},e._container[0].addEventListener("mouseover",i.mouseover),e._container[0].addEventListener("mouseout",i.mouseout)),e._container[0].classList.add("BMDropTarget"),W.set(e,i)})),void 0!==o&&(I=t=>{let e,i;for(var n=0;n<t.changedTouches.length;n++)if(t.changedTouches[n].identifier==o){e=t.changedTouches[n].clientX,i=t.changedTouches[n].clientY;break}if(n==t.changedTouches.length)return NO;let s,a=document.elementFromPoint(e,i);if(a)for(let t of P)if(t._container[0].contains(a)){s=t;break}s!=x&&(x=s,s?(L=BMRectMakeWithNodeFrame(x._container[0]),d.classList.add("BMDragIndicatorBlue")):(L=void 0,d.classList.remove("BMDragIndicatorBlue")))}))),a&&n.node.classList.add(BMMenuSourceNodeCSSClass);let T=t=>{let e,i;if(t.preventDefault(),void 0!==o){t.preventDefault();for(var n=0;n<t.changedTouches.length;n++)if(t.changedTouches[n].identifier==o){e=t.changedTouches[n].clientX,i=t.changedTouches[n].clientY;break}if(n==t.changedTouches.length)return t.preventDefault()}else e=t.clientX,i=t.clientY;if(l.style.left=e-g.x+"px",l.style.top=i-g.y+"px",d.style.left=e-g.x-12+"px",d.style.top=i-g.y-12+"px",_?w=BMPointMake(e-g.x,i-g.y):y.forEach(((t,o)=>{t.style.left=e-g.x+"px",t.style.top=i-g.y+"px"})),this.isUpdatingData)return t.preventDefault(),t.stopPropagation();if(S=e-v.origin.x<32?(e-v.origin.x-32)/32*20:v.right-e<32?(32-v.right+e)/32*20:0,M=i-v.origin.y<32?(i-v.origin.y-32)/32*20:v.bottom-i<32?(32-v.bottom+i)/32*20:0,i<v.top||i>v.bottom||e<v.left||e>v.right?B||(B=YES,S=0,M=0,this.delegate&&this.delegate.collectionViewCanRemoveItemsAtIndexPaths&&(E=this.delegate.collectionViewCanRemoveItemsAtIndexPaths(this,this._draggingIndexPaths)),E&&d.classList.add("BMDragIndicatorRed")):B&&(B=NO,E=NO,d.classList.remove("BMDragIndicatorRed")),x){S=0,M=0;let o=BMPointMake(e-L.origin.x,i-L.origin.y);o.x+=x.scrollOffset.x,o.y+=x.scrollOffset.y;let n=BMRectMake(0,0,128,128);n.center=o;let s,a=x.layout.attributesForElementsInRect(n),r=Number.MAX_SAFE_INTEGER,l=0;return a.forEach(((t,e)=>{if(t.itemType!=BMCollectionViewLayoutAttributesType.Cell)return;t.frame.containsPoint(o)&&(s=t.indexPath.copy());let i=o.distanceToPoint(t.frame.center);i<r&&(r=i,l=e)})),s?A=s:a.length&&(A=a[l].indexPath.copy()),t.preventDefault(),t.stopPropagation()}if(S||M)return t.preventDefault(),t.stopPropagation();let s=BMPointMake(e-v.origin.x,i-v.origin.y);s.x+=this.scrollOffset.x,s.y+=this.scrollOffset.y;let a=BMRectMake(0,0,64,64);a.center=s;let h,c=this.layout.attributesForElementsInRect(a),u=NO;c.forEach((t=>{if(t.itemType!=BMCollectionViewLayoutAttributesType.Cell)return;if(u)return;t.frame.containsPoint(s)&&(h=t.indexPath.copy());let e=YES;h&&(this._draggingIndexPaths.forEach((t=>{h.row==t.row&&h.section==t.section&&(e=NO)})),e&&(u=YES,this.dataSet.moveItemsFromIndexPaths&&1!=r.length?this._draggingIndexPaths=this.dataSet.moveItemsFromIndexPaths(this._draggingIndexPaths,{toIndexPath:h}).sort(((t,e)=>t.section==e.section?t.row-e.row:t.section-e.section)):this._draggingIndexPaths.forEach(((t,e)=>{let i=h.copy();i.object=t.object,i.row+=e,this.dataSet.moveItemFromIndexPath(t,{toIndexPath:i})&&(this._draggingIndexPaths[e]=i)}))))})),t.preventDefault(),t.stopPropagation()};window.addEventListener(void 0!==o?"touchmove":"mousemove",T,{capture:YES,passive:NO}),void 0!==o&&window.addEventListener("touchmove",I,{capture:YES,passive:NO});let z=async t=>{if(void 0!==o){for(var e=0;e<t.changedTouches.length&&t.changedTouches[e].identifier!=o;e++);if(e==t.changedTouches.length)return}this.delegate&&this.delegate.collectionViewWillFinishInteractiveMovementForCell&&this.delegate.collectionViewWillFinishInteractiveMovementForCell(this,n,{atIndexPath:n.indexPath}),window.removeEventListener(void 0!==o?"touchmove":"mousemove",T,{capture:YES,passive:NO}),window.removeEventListener(void 0!==o?"touchend":"mouseup",z,{capture:YES,passive:NO}),void 0!==o&&window.removeEventListener("touchcancel",z,{capture:YES,passive:NO}),o?(P.forEach((t=>t._container[0].classList.remove("BMDropTarget"))),window.removeEventListener("touchmove",I,{capture:YES,passive:NO})):W.forEach(((t,e)=>{e._container[0].removeEventListener("mouseover",t.mouseover),e._container[0].removeEventListener("mouseout",t.mouseout),e._container[0].classList.remove("BMDropTarget")})),window.cancelAnimationFrame(b);let s=BMRectMakeWithNodeFrame(l),a=BMRectMakeWithNodeFrame(n.node);if(i(),__BMVelocityAnimate(d,{scaleX:0,scaleY:0,opacity:0},{duration:300,easing:"easeInOutQuad"}),x){let t=A;if(!t){let e=x.numberOfSections();t=x.indexPathForObjectAtRow(x.numberOfObjectsInSectionAtIndex(e-1)-1,{inSectionAtIndex:e-1})}let e=new Map,i=this._draggingIndexPaths.map((t=>{const e=JSON.parse(JSON.stringify(t.object));for(const i in t.object)void 0===t.object[i]&&(e[i]=void 0);return e})),o=0;(()=>{let t;for(let e=0;e<i.length;e++)this._draggingIndexPaths[e].row==n.indexPath.row&&this._draggingIndexPaths[e].section==n.indexPath.section&&(t=i[e]);e.set(t,{node:l,rotation:0})})(),m.forEach(((t,n)=>{let s;for(let e=0;e<i.length;e++)this._draggingIndexPaths[e].row==t.indexPath.row&&this._draggingIndexPaths[e].section==t.indexPath.section&&(s=i[e]);e.set(s,{node:n,rotation:60*(o+1)/r.length}),o++}));let s=BMCollectionViewTransferPolicy.Copy;this.delegate&&this.delegate.collectionViewTransferPolicyForItemsAtIndexPaths&&(s=this.delegate.collectionViewTransferPolicyForItemsAtIndexPaths(this,this._draggingIndexPaths));let a=BMCollectionViewTransferPolicy.Copy;x.delegate&&x.delegate.collectionViewAcceptPolicyForItems&&(a=x.delegate.collectionViewAcceptPolicyForItems(x,i)),E=s==BMCollectionViewTransferPolicy.Move&&a==BMCollectionViewAcceptPolicy.Move?YES:NO,this.isDragging=NO,E&&this.dataSet.removeItemsAtIndexPaths(this._draggingIndexPaths),r.forEach((t=>{t.node.classList.remove("BMCollectionViewCellDragging")})),await x._insertItems(i,{toIndexPath:t,withDropShadows:e}),this.isDragging=YES}else if(E){this.dataSet.removeItemsAtIndexPaths(this._draggingIndexPaths),r.forEach((t=>{t.node.classList.remove("BMCollectionViewCellDragging")}));const t=200/y.length;y.forEach(((e,i)=>{BMHook(e,{rotateZ:60*(i+1)/r.length+"deg"}),__BMVelocityAnimate(e,{rotateZ:60*(i+1)/r.length+"deg",blur:"20px",opacity:0},{easing:"easeInQuad",duration:200,delay:(y.length-i)*t})})),await __BMVelocityAnimate(l,{blur:"20px",opacity:0},{duration:200,easing:"easeInQuad",delay:y.length*t})}else y.forEach(((t,e)=>{let i=BMRectMakeWithNodeFrame(m.get(t).node);(window.Velocity||$.Velocity).animate(t,{tween:1,left:i.origin.x+"px",top:i.origin.y+"px"},{easing:"easeInOutQuad",duration:300,progress:(i,o,n,s,a)=>{t.style.transform="rotate("+(1-a)*(60*(e+1)/r.length)+"deg) translateZ(0)"},complete(){_=NO}})})),await __BMVelocityAnimate(l,{translateX:-s.origin.x+a.origin.x+"px",translateY:-s.origin.y+a.origin.y+"px"},{duration:300,easing:"easeInOutQuad"});l.remove(),d.remove(),y.forEach((t=>t.remove())),this.isDragging=NO,_BMCoreUIIsDragging=NO,r.forEach((t=>{t.node.classList.remove("BMCollectionViewCellDragging"),t.isDraggging=NO,t.release()})),this.delegate&&this.delegate.collectionViewDidFinishInteractiveMovementForCell&&this.delegate.collectionViewDidFinishInteractiveMovementForCell(this,n,{atIndexPath:n.indexPath}),this._draggingIndexPaths=void 0};window.addEventListener(void 0!==o?"touchend":"mouseup",z,{capture:YES,passive:NO}),void 0!==o&&window.addEventListener("touchcancel",z,{capture:YES,passive:NO})},dequeueCellForSupplementaryViewWithIdentifier:function(t){var e=this.supplementaryViewCache[t];if(e&&e.length)return(o=e.pop()).element[0].style.opacity=o._backingOpacity,o;var i=document.createElement("div");i.style="position: absolute; left: 0px; top: 0px; visibility: hidden; overflow: visible;";var o,n=this._supplementaryViewClasses[t]||this._cellClass;return(o=Object.create(n.prototype).initWithCollectionView(this,{reuseIdentifier:t,node:i,kind:BMCollectionViewLayoutAttributesType.SupplementaryView})).layoutQueue=this._cellLayoutQueue,n==BMCollectionViewCell&&this._usesLegacyDataSet&&o.element.append(this._dataSet.contentsForSupplementaryViewWithIdentifier(t)),this._contentWrapper.append(o.element),o},cellShouldRender:function(t){this.delegate&&"function"==typeof this.delegate.collectionViewWillRenderCell&&this.delegate.collectionViewWillRenderCell(this,t),t.element[0].style.visibility="inherit",this.allCells.push(t),t.rendered=YES,this.delegate&&"function"==typeof this.delegate.collectionViewDidRenderCell&&this.delegate.collectionViewDidRenderCell(this,t)},cellWasManaged:function(t){this.retainedCells.push(t)},cellWasReleased:function(t){this.delegate&&"function"==typeof this.delegate.collectionViewWillRecycleCell&&this.delegate.collectionViewWillRecycleCell(this,t),t.element[0].style.visibility="hidden",t._backingOpacity=t.attributes.style.opacity,void 0===t._backingOpacity&&(t._backingOpacity=BMCollectionViewLayoutAttributesStyleDefaults.opacity),t.element[0].style.opacity=0,t._previousFrame=void 0,BMHook(t.element[0],{translateX:"0px",translateY:"0px"});for(var e=this.allCells.length,i=0;i<e;i++)if(this.allCells[i]===t){this.allCells.splice(i,1);break}var o=t.itemType==BMCollectionViewLayoutAttributesType.Cell?this.cellCache:this.supplementaryViewCache;o[t.reuseIdentifier]||(o[t.reuseIdentifier]=[]),o[t.reuseIdentifier].push(t),t.rendered=NO,this.delegate&&"function"==typeof this.delegate.collectionViewDidRecycleCell&&this.delegate.collectionViewDidRecycleCell(this,t)},cellWasUnmanaged:function(t){for(var e=this.retainedCells.length,i=0;i<e;i++)if(this.retainedCells[i]===t){this.retainedCells.splice(i,1);break}},cellWasInvalidated:function(t){this.delegate&&"function"==typeof this.delegate.collectionViewWillDestroyCell&&this.delegate.collectionViewWillDestroyCell(this,t),t.element[0].removeEventListener("mousedown",t.mousedownHandler),t.element[0].removeEventListener("touchstart",t.mousedownHandler),t.element[0].removeEventListener("mousemove",t.mousemoveHandler),t.element[0].removeEventListener("touchmove",t.mousemoveHandler),t.element[0].removeEventListener("mouseup",t.mouseupHandler),t.element[0].removeEventListener("touchend",t.mouseupHandler),t.element[0].removeEventListener("touchcancel",t.touchcancelHandler),t.element[0].removeEventListener("contextmenu",t.contextMenuHandler),t.rendered=NO,t.element.remove();for(var e=this.retainedCells.length,i=0;i<e;i++)if(this.retainedCells[i]===t){this.retainedCells.splice(i,1);break}var o=this.allCells.length;for(i=0;i<o;i++)if(this.allCells[i]===t){this.allCells.splice(i,1);break}this.delegate&&"function"==typeof this.delegate.collectionViewDidDestroyCell&&this.delegate.collectionViewDidDestroyCell(this,t)},cellAtIndexPath:function(t,e){if(e||(e={ofType:BMCollectionViewLayoutAttributesType.Cell}),e.ofType=e.ofType||BMCollectionViewLayoutAttributesType.Cell,e.ofType==BMCollectionViewLayoutAttributesType.SupplementaryView)return this.supplementaryViewWithIdentifier(e.withIdentifier,{atIndexPath:t});for(var i=0;i<this.allCells.length;i++){var o=this.allCells[i];if(o.itemType==e.ofType&&(o._reuseState!=BMCollectionViewCellReuseState.Deleting&&o.indexPath.isLooselyEqualToIndexPath(t,{usingComparator:this.identityComparator})))return o}},supplementaryViewWithIdentifier:function(t,e){for(var i=0;i<this.allCells.length;i++){var o=this.allCells[i];if(o.itemType==BMCollectionViewLayoutAttributesType.SupplementaryView&&(o.reuseIdentifier==t&&o.indexPath.isEqualToIndexPath(e.atIndexPath,{usingComparator:this.identityComparator})))return o}},retainCellForIndexPath:function(t){if(!(t.section>this.numberOfSections()||t.row>this.numberOfObjectsInSectionAtIndex(t.section))){var e=this.cellAtIndexPath(t,{ofType:BMCollectionViewLayoutAttributesType.Cell});return e?(e.retain(),e):((e=this._dataSet.cellForItemAtIndexPath(t)).attributes=this.layout.attributesForCellAtIndexPath(t),e.retain(),e)}},retainSupplementaryViewWithIdentifier:function(t,e){var i=this.supplementaryViewWithIdentifier(t,{atIndexPath:e.forIndexPath});if(i)return i.retain(),i;var o=this.layout.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.forIndexPath});return o?((i=this._dataSet.cellForSupplementaryViewWithIdentifier(t,{atIndexPath:e.forIndexPath})).attributes=o,i.retain(),i):void 0},cellWasClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node),document.activeElement!=this.node&&this._supportsKeyboardNavigation&&this.node.focus();var i=NO;if(this.delegate&&this.delegate.collectionViewCellWasClicked&&(i=this.delegate.collectionViewCellWasClicked(this,t,{withEvent:e.withEvent})),i)return;if(this._highlightedIndexPath&&!this._highlightedIndexPath.isLooselyEqualToIndexPath(t.indexPath,{usingComparator:this.identityComparator})){let i=YES;this.delegate&&this.delegate.collectionViewCanHighlightCellAtIndexPath&&(i=this.delegate.collectionViewCanHighlightCellAtIndexPath(this,t.indexPath,{withEvent:e.withEvent})),i&&this._highlightIndexPath(t.indexPath,{withEvent:e.withEvent})}var o=YES;const n=this.isCellAtIndexPathSelected(t.indexPath);n?this.delegate&&"function"==typeof this.delegate.collectionViewCanDeselectCellAtIndexPath&&(o=this.delegate.collectionViewCanDeselectCellAtIndexPath(this,t.indexPath)):this.delegate&&"function"==typeof this.delegate.collectionViewCanSelectCellAtIndexPath&&(o=this.delegate.collectionViewCanSelectCellAtIndexPath(this,t.indexPath)),o&&(n?this.deselectCellAtIndexPath(t.indexPath):this.selectCellAtIndexPath(t.indexPath))},cellWasDoubleClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node),document.activeElement!=this.node&&this._supportsKeyboardNavigation&&this.node.focus();this.delegate&&this.delegate.collectionViewCellWasDoubleClicked&&this.delegate.collectionViewCellWasDoubleClicked(this,t,{withEvent:e.withEvent})},cellWasLongClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node),document.activeElement!=this.node&&this._supportsKeyboardNavigation&&this.node.focus();var i=NO;return this.delegate&&this.delegate.collectionViewCellWasLongClicked&&(i=this.delegate.collectionViewCellWasLongClicked(this,t,{withEvent:e.withEvent})),i},cellWasRightClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node);var i=NO;return this.delegate&&this.delegate.collectionViewCellWasRightClicked&&(i=this.delegate.collectionViewCellWasRightClicked(this,t,{withEvent:e.withEvent})),i},_keyboardNavigationShortcuts:void 0,configureKeyboardShortcuts(){this._keyboardNavigationShortcuts||(this._keyboardNavigationShortcuts=[],this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.forEach((t=>this.registerKeyboardShortcut(t))))},disableKeyboardShortcuts(){this._keyboardNavigationShortcuts&&(this._keyboardNavigationShortcuts.forEach((t=>this.unregisterKeyboardShortcut(t))),this._keyboardNavigationShortcuts=void 0)},_keyboardArrowPressedWithEvent(t){switch(t.code){case"ArrowLeft":case"ArrowUp":case"ArrowRight":case"ArrowDown":this.keyboardArrowPressed(t.code,{withEvent:t})}},_highlightedIndexPath:void 0,get highlightedIndexPath(){return this._highlightedIndexPath},set highlightedIndexPath(t){this._highlightIndexPath(t)},_highlightIndexPath(t,{withEvent:e}={withEvent:void 0}){const i=this._highlightedIndexPath;if(this._highlightedIndexPath=t,i&&this.delegate&&this.delegate.collectionViewDidDehighlightCellAtIndexPath&&this.delegate.collectionViewDidDehighlightCellAtIndexPath(this,i),t){const i=this.cellAtIndexPath(t);if(!i||!i._attributes.frame.intersectsRect(this.visibleBounds)){let e=YES;this.delegate&&this.delegate.collectionViewShouldScrollToHighlightedCellAtIndexPath&&(e=this.delegate.collectionViewShouldScrollToHighlightedCellAtIndexPath(this,t)),e&&this.scrollToCellAtIndexPath(t,{animated:YES})}e&&e instanceof KeyboardEvent&&e.preventDefault()}this.delegate&&this.delegate.collectionViewDidHighlightCellAtIndexPath&&this.delegate.collectionViewDidHighlightCellAtIndexPath(this,t,{withEvent:e})},isCellAtIndexPathHighlighted(t){return this._highlightedIndexPath?this._highlightedIndexPath.isLooselyEqualToIndexPath(t,{usingComparator:this.identityComparator}):NO},keyboardArrowPressed(t,e){let i=this._highlightedIndexPath;const o=e&&e.withEvent;if(o){let e=YES;if(this.delegate&&this.delegate.collectionViewShouldHighlightCellForArrowKey&&(e=this.delegate.collectionViewShouldHighlightCellForArrowKey(this,t,{withEvent:o})),!e)return}do{const e=i??BMIndexPathNone;if(i)switch(t){case"ArrowLeft":i=this.layout.indexPathToTheLeftOfIndexPath(i);break;case"ArrowUp":i=this.layout.indexPathAboveIndexPath(i);break;case"ArrowRight":i=this.layout.indexPathToTheRightOfIndexPath(i);break;case"ArrowDown":i=this.layout.indexPathBelowIndexPath(i)}else i=this.layout.firstIndexPath();if(!i)return;let n=YES;if(this.delegate&&this.delegate.collectionViewCanHighlightCellAtIndexPath&&(n=this.delegate.collectionViewCanHighlightCellAtIndexPath(this,i,{withEvent:o})),n)break;if(e.isEqualToIndexPath(i,{usingComparator:this.identityComparator}))return}while(i);i.isEqualToIndexPath(this._highlightedIndexPath,{usingComparator:this.identityComparator})||this._highlightIndexPath(i,{withEvent:o})},_selectedIndexPaths:void 0,get selectedIndexPaths(){return this._selectedIndexPaths},set selectedIndexPaths(t){var e=t.length,i=this._selectedIndexPaths;this._selectedIndexPaths=t;for(var o=0;o<e;o++){for(var n=t[o],s=NO,a=0;a<i.length;a++)if(i[a].isLooselyEqualToIndexPath(n,{usingComparator:this.identityComparator})){s=YES,i.splice(a,1);break}s||this.delegate&&"function"==typeof this.delegate.collectionViewDidSelectCellAtIndexPath&&this.delegate.collectionViewDidSelectCellAtIndexPath(this,n)}for(o=0;o<i.length;o++)this.delegate&&"function"==typeof this.delegate.collectionViewDidDeselectCellAtIndexPath&&this.delegate.collectionViewDidDeselectCellAtIndexPath(this,i[o])},_updateSelectionIndexPaths:function(){var t=this._selectedIndexPaths;this._selectedIndexPaths=[];for(var e=t.length,i=0;i<e;i++){var o=this.dataSet.indexPathForObject(t[i].object);o&&this._selectedIndexPaths.push(o)}this._highlightedIndexPath&&(this._highlightedIndexPath=this.dataSet.indexPathForObject(this._highlightedIndexPath.object))},isCellAtIndexPathSelected:function(t){for(var e=this._selectedIndexPaths.length,i=0;i<e;i++)if(t.isLooselyEqualToIndexPath(this._selectedIndexPaths[i],{usingComparator:this.identityComparator}))return YES;return NO},selectCellAtIndexPath:function(t){this._selectedIndexPaths.push(t),this.delegate&&"function"==typeof this.delegate.collectionViewDidSelectCellAtIndexPath&&this.delegate.collectionViewDidSelectCellAtIndexPath(this,t)},deselectCellAtIndexPath:function(t){for(var e=this._selectedIndexPaths.length,i=0;i<e;i++)if(this._selectedIndexPaths[i].isLooselyEqualToIndexPath(t,{usingComparator:this.identityComparator})){this._selectedIndexPaths.splice(i,1);break}this.delegate&&"function"==typeof this.delegate.collectionViewDidDeselectCellAtIndexPath&&this.delegate.collectionViewDidDeselectCellAtIndexPath(this,t)},setLayout:function(t,e){if(this.isUpdatingData){var i=this;return void this.registerDataCompletionCallback((function(){i.setLayout(t,e)}))}if(!(e&&e.animated)&&!BMAnimationContextGetCurrent()||!this.initialized)return this.layout=t,this._executeDataCompletionCallbacks(),e&&e.completionHandler&&e.completionHandler(),void(this._blocksLayoutInvalidation=NO);let o;BMAnimationContextBeginStatic();const n=new Promise((t=>o=t));this._dataUpdatePromise=n,this.attributeCache={},this.isUpdatingData=YES,this._collectionEnabled=NO;for(var s=[],a=this.allCells.length,r=[],l=0;l<a;l++){const t=this.allCells[l];t._reuseState!=BMCollectionViewCellReuseState.Deleting&&(s.push(t.attributes),r.push(t))}var h=this.scrollOffset,c=this._bounds.copy();let d=this._pendingFrame;this._frame;d&&(this._frame=d,this._offscreenBufferSize=this.customScroll?0:Math.max(this._frame.size.width*this.offscreenBufferFactor,this._frame.size.height*this.offscreenBufferFactor),this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize),t.collectionView=this,t.prepareLayout();var u=t.contentSize(),p=t.preferredScrollOffsetForTransitionFromLayout(this._layout,{withOffset:this.scrollOffset.copy()});p.x=Math.max(0,Math.min(p.x,u.width-this.frame.size.width)),p.y=Math.max(0,Math.min(p.y,u.height-this.frame.size.height));var g=BMRectMake(p.x-this._offscreenBufferSize,p.y-this._offscreenBufferSize,this._bounds.size.width,this._bounds.size.height);this._bounds=g;for(var w=t.attributesForElementsInRect(g.copy()),y=[],m=[];s.length;){var _=s[s.length-1],f=NO;if(_.itemType===BMCollectionViewLayoutAttributesType.Cell){for(var v=0;v<w.length;v++)if((S=w[v]).itemType===BMCollectionViewLayoutAttributesType.Cell&&S.indexPath.isEqualToIndexPath(_.indexPath,{usingComparator:this.identityComparator})){f=YES,w.splice(v,1);break}f||(S=t.attributesForCellAtIndexPath(_.indexPath));var M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(_,{targetAttributes:S});y.push(M)}else{var S;for(v=0;v<w.length;v++)if((S=w[v]).itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&S.identifier===_.identifier&&S.indexPath.isEqualToIndexPath(_.indexPath,{usingComparator:this.identityComparator})){f=YES,w.splice(v,1);break}if(f){M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(_,{targetAttributes:S});y.push(M)}else{m.push(_),(S=_.copy())._style||(w._style={}),S.style.opacity=0,isNaN(_.style.opacity)&&(_.style.opacity=1);var M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(_,{targetAttributes:S});y.push(M)}}s.splice(s.length-1,1)}for(this._bounds=c;w.length;){if((_=w[w.length-1]).itemType===BMCollectionViewLayoutAttributesType.Cell){M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(C=this._layout.attributesForCellAtIndexPath(_.indexPath),{targetAttributes:_});y.push(M)}else{var C;(C=_.copy()).style.opacity=0,isNaN(_.style.opacity)&&(_.style.opacity=1);M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(C,{targetAttributes:_});y.push(M)}w.splice(w.length-1,1)}this._bounds=g;var b=new _BMCollectionViewTransitionLayout(y,this._size,u,t);b.collectionView=this;var B=this._layout;this._layout.collectionView=void 0,this._layout=b,this._transitionLayout=b;let E=[];y.forEach((t=>{t._itemType==BMCollectionViewLayoutAttributesType.SupplementaryView?E.push(this.retainSupplementaryViewWithIdentifier(t.identifier,{forIndexPath:t.indexPath})):E.push(this.retainCellForIndexPath(t.indexPath))}));var V={};this.delegate&&this.delegate.collectionViewAnimationOptionsForLayoutChangeFromLayout&&(V=this.delegate.collectionViewAnimationOptionsForLayoutChangeFromLayout(this,B,{toLayout:t}));var L=BMExtend({duration:_BMCollectionViewAnimationDurationDefault,easing:_BMCollectionViewAnimationEasingDefault},V);r.forEach((t=>t.retain()));let x=t.contentSize();this._size=BMSizeMake(Math.max(this._size.width,x.width),Math.max(this._size.height,x.height)),L.complete=function(){var s=b.attributesForElementsInRect();if(i._renderCellsWithAttributes(s,{exclusive:YES}),i._size=x.copy(),i.iScroll&&(c.origin.x!=g.origin.x||c.origin.y!=g.origin.y)){var a=g.origin.copy();a.x+=i._offscreenBufferSize,a.y+=i._offscreenBufferSize,i.iScroll._translate(-a.x,-a.y)}r.forEach((t=>t.release())),E.forEach((t=>t.release())),b._applyFinalAttributes(),i.retainedCells.slice().forEach((function(t){t.attributes.isHidden&&t._unmanage()})),i._layout=t,i._transitionLayout=void 0,i.iScroll&&i.iScroll.refresh();for(var l=0;l<m.length;l++){var h=m[l],d=i.supplementaryViewWithIdentifier(h.identifier,{atIndexPath:h.indexPath});d&&d.isManaged&&d._unmanage()}i._applyOverflows(),i._dataUpdatePromise==n&&(i._collectionEnabled=YES,i.isUpdatingData=NO,i._executeDataCompletionCallbacks()),V.complete&&V.complete(),e&&e.completionHandler&&e.completionHandler(),o()},L.queue=NO,this._bounds=c;var A=b.attributesForElementsInRect();this._renderCellsWithAttributes(A,{exclusive:YES}),this._bounds=g,BMAnimationApply();i=this;let I=()=>{let t=BMAnimationContextGetCurrent().controllerForObject(i,{node:i._container[0]});b.fraction=1,t.registerCustomProperty("tween",{withHandler:t=>{this._bounds=BMRectByInterpolatingRect(c,{toRect:g,withFraction:t})}});let e=BMAnimationContextGetCurrent().controllerForObject(b,{node:i._contentWrapper[0]});if(e.registerBuiltInProperty("width",{withValue:x.width+"px"}),e.registerBuiltInProperty("height",{withValue:x.height+"px"}),b._layout(),c.origin.x!=i._bounds.origin.x||c.origin.y!=i._bounds.origin.y){var o=h,n=i._bounds.origin.copy();n.x+=i._offscreenBufferSize,n.y+=i._offscreenBufferSize;let t=BMAnimationContextGetCurrent().controllerForObject(i._contentWrapper[0],{node:i._contentWrapper[0]});i.iScroll?(BMHook(i._contentWrapper[0],{translateX:-o.x+"px",translateY:-o.y+"px"}),e.registerBuiltInProperty("translateX",{withValue:-n.x+"px"}),e.registerBuiltInProperty("translateY",{withValue:-n.y+"px"})):t.registerCustomProperty("scrollOffset",{withHandler:t=>{var e=o.x+t*(n.x-o.x),s=o.y+t*(n.y-o.y);i._container[0].scrollTo(e,s)}})}};BMAnimationContextGetCurrent()?(BMAnimationContextAddCompletionHandler(L.complete),I()):BMAnimateWithBlock(I,L),this._blocksLayoutInvalidation=NO},_updateLayoutWithBlock(t){throw new Error("This method is unavailable")},_dataUpdateCallbacks:void 0,registerDataCompletionCallback:function(t){this._dataUpdateCallbacks=this._dataUpdateCallbacks||[],this._dataUpdateCallbacks.push(t)},_executeDataCompletionCallbacks:function(){if(this._dataUpdateCallbacks){for(var t=this._dataUpdateCallbacks.length,e=0;e<t;e++)this._dataUpdateCallbacks[e]();this._dataUpdateCallbacks=[]}},dataSetDidChangeFromDataSet:function(t){this.initialized?this.invalidateLayout():this._init()},usingOldDataSet:function(t){var e=this.dataSet.isUsingOldData();this.dataSet.useOldData(YES),this._bounds=this.oldBounds,t(),this._bounds=this.newBounds,this.dataSet.useOldData(e)},usingNewDataSet:function(t){var e=this.dataSet.isUsingOldData();this.dataSet.useOldData(NO),t(),this.dataSet.useOldData(e)},_dataUpdatePromise:void 0,get dataUpdated(){return this._dataUpdatePromise},updateEntireDataAnimated:function(t,e){if(!this.initialized)return;BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationContextBeginStatic(),void 0===t&&(t=YES);var i=this;let o;const n=new Promise((function(t,e){o=t}));if(this._dataUpdatePromise=n,this._updateSelectionIndexPaths(),!t){if(this.layout.collectionViewWillStartUpdates(void 0),this.invalidateLayout(),i.layout.collectionViewDidStartUpdates(),this._usesLegacyDataSet)for(let t=0;t<this.allCells.length;t++){let e=this.allCells[t];e.itemType===BMCollectionViewLayoutAttributesType.Cell?this.dataSet.updateCell&&this.dataSet.updateCell(e,{atIndexPath:e.indexPath}):e.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(e,{withIdentifier:e.reuseIdentifier,atIndexPath:e.indexPath})}return e&&e.completionHandler&&e.completionHandler(),this._executeDataCompletionCallbacks(),o(),BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationApply(),this._dataUpdatePromise}if(e&&e.updateLayout===NO){for(var s=0;s<this.allCells.length;s++){(P=this.allCells[s]).itemType===BMCollectionViewLayoutAttributesType.Cell?(P.attributes.indexPath=this.dataSet.indexPathForObjectAtRow(P.indexPath.row,{inSectionAtIndex:P.indexPath.section}),this.dataSet.updateCell&&this.dataSet.updateCell(P,{atIndexPath:P.indexPath})):P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(P,{withIdentifier:P.reuseIdentifier,atIndexPath:P.indexPath})}return e&&e.completionHandler&&e.completionHandler(),this._executeDataCompletionCallbacks(),o(),BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationApply(),this._dataUpdatePromise}this._collectionEnabled=NO,this.isUpdatingData=YES,this.layout.collectionViewWillStartUpdates(void 0);var a=this._bounds.copy();this.oldBounds=a;var r=this.layout.contentSize().copy();let l=this._size;this._size=r;var h=BMPointMake(this._bounds.origin.x+this._offscreenBufferSize,this._bounds.origin.y+this._offscreenBufferSize),c=this.layout.preferredScrollOffsetWithOffset(h);this._bounds.origin.x+=c.x-h.x,this._bounds.origin.y+=c.y-h.y,this._constrainBounds(),this.newBounds=this._bounds,this._size=l,this._container[0].style.pointerEvents="none";var d=this.scrollOffset;this.iScroll||this._container[0].scrollTo(d.x,d.y),this.scrollView&&(this.scrollView.scrollingEnabled=NO);var u=this.layout.attributesForElementsInRect(this._bounds);this.attributeCache={};var p=[],g=[],w=this.layout.supplementaryViewsToInsert(),y=this.layout.supplementaryViewsToDelete(),m=this.allCells.slice(),_=new BMRect(BMPointMake(this._bounds.origin.x+this._offscreenBufferSize,this._bounds.origin.y+this._offscreenBufferSize),this._frame.size.copy()),f=new BMRect(BMPointMake(a.origin.x+this._offscreenBufferSize,a.origin.y+this._offscreenBufferSize),this._frame.size.copy());for(s=0;s<m.length;s++){if((P=m[s])._reuseState!=BMCollectionViewCellReuseState.Deleting){for(var v=NO,M=0;M<u.length;M++){var S=u[M];if(P.itemType===S.itemType&&P.indexPath.isLooselyEqualToIndexPath(S.indexPath,{usingComparator:this.identityComparator})){if(P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&P.reuseIdentifier!==S.identifier)continue;P.targetAttributes=S,S.initialAttributes=P.attributes,v=YES,u.splice(M,1),P.itemType===BMCollectionViewLayoutAttributesType.Cell?this.dataSet.updateCell&&this.dataSet.updateCell(P,{atIndexPath:S.indexPath}):P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(P,{withIdentifier:P.reuseIdentifier,atIndexPath:S.indexPath});break}}if(!v)if(P.itemType===BMCollectionViewLayoutAttributesType.Cell){var C=this.indexPathForObject(P.indexPath.object);if(C){S=this.layout.attributesForCellAtIndexPath(C);P.targetAttributes=S,g.push(P),this.dataSet.updateCell&&this.dataSet.updateCell(P,{atIndexPath:S.indexPath})}else{S=this.layout.finalAttributesForDisappearingCellAtIndexPath(P.indexPath,{withTargetAttributes:P.attributes});P.targetAttributes=S,p.push(P)}}else if(P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView){var b=NO;for(M=0;M<y.length;M++)if(P.indexPath.isLooselyEqualToIndexPath(y[M].indexPath,{usingComparator:this.identityComparator})&&P.reuseIdentifier==y[M].identifier){b=YES;break}if(b)P.targetAttributes=this.layout.finalAttributesForDisappearingSupplementaryViewWithIdentifier(P.reuseIdentifier,{atIndexPath:P.indexPath,withTargetAttributes:P.attributes}),p.push(P);else{S=this.layout.attributesForSupplementaryViewWithIdentifier(P.reuseIdentifier,{atIndexPath:P.indexPath});P.targetAttributes=S,g.push(P),this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(P,{withIdentifier:P.reuseIdentifier,atIndexPath:S.indexPath})}}}}this.dataSet.useOldData(YES);var B,E=[];this._droppedShadows&&(B=BMRectMakeWithNodeFrame(this._container[0]));for(s=0;s<u.length;s++){if(!(S=u[s]).initialAttributes)if(S.itemType===BMCollectionViewLayoutAttributesType.Cell){var V=this.indexPathForObject(S.indexPath.object);this.dataSet.useOldData(NO);var L=this.dataSet.cellForItemAtIndexPath(S.indexPath);if(V){var x=this.layout.initialAttributesForMovingCellFromIndexPath(V,{toIndexPath:S.indexPath,withTargetAttributes:S});S.initialAttributes=x}else{let t;if(this._droppedShadows&&(t=this._droppedShadows.get(S.indexPath.object))){var A=S.copy();let e=S.frame.copy();e.offset(-this.scrollOffset.x,-this.scrollOffset.y),e.offset(B.left,B.top),BMHook(t.node,{rotateZ:"0deg"});let i=BMRectMakeWithNodeFrame(t.node);BMHook(t.node,{rotateZ:t.rotation+"deg"});let o=e.rectWithTransformToRect(i),n=i.rectWithTransformToRect(e);t.transform=n,e.offset(this.scrollOffset.x,this.scrollOffset.y),e.offset(-B.left,-B.top),e.origin.x+=o.origin.x,e.origin.y+=o.origin.y,A.frame=e,A.style.rotateZ=t.rotation+"deg",A.style.scaleX=o.size.width,A.style.scaleY=o.size.height,A.style.opacity=0}else A=this.layout.initialAttributesForAppearingCellAtIndexPath(S.indexPath,{withTargetAttributes:S});S.initialAttributes=A}L.attributes=S.initialAttributes,L.targetAttributes=S,L._manage(),E.push(L),this.dataSet.useOldData(YES)}else if(S.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView){this.dataSet.useOldData(NO);var I=NO;for(M=0;M<w.length;M++)if(S.indexPath.isLooselyEqualToIndexPath(w[M].indexPath,{usingComparator:this.identityComparator})&&S.identifier==w[M].identifier){I=YES;break}if(I){A=this.layout.initialAttributesForAppearingSupplementaryViewWithIdentifier(S.identifier,{atIndexPath:S.indexPath,withTargetAttributes:S});S.initialAttributes=A}else{A=this.layout.initialAttributesForMovingSupplementaryViewWithIdentifier(S.identifier,{atIndexPath:S.indexPath,withTargetAttributes:S});S.initialAttributes=A}(L=this.dataSet.cellForSupplementaryViewWithIdentifier(S.identifier,{atIndexPath:S.indexPath})).attributes=S.initialAttributes,L.targetAttributes=S,L._manage(),E.push(L),this.dataSet.useOldData(YES)}}this.dataSet.useOldData(NO);for(s=0;s<m.length;s++){var P=m[s];_.intersectsRect(P.targetAttributes.frame)||_.intersectsRect(P.attributes.frame)||f.intersectsRect(P.targetAttributes.frame)||f.intersectsRect(P.attributes.frame)?(P.animatable=YES,P.targetAttributes.frame.intersectsRect(_)&&P._manage()):(P.animatable=NO,P.attributes=P.targetAttributes)}for(s=0;s<E.length;s++){P=E[s];_.intersectsRect(P.targetAttributes.frame)||_.intersectsRect(P.attributes.frame)||f.intersectsRect(P.targetAttributes.frame)||f.intersectsRect(P.attributes.frame)?P.animatable=YES:(P.animatable=NO,P.attributes=P.targetAttributes)}BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationApply();var W={};this.delegate&&this.delegate.collectionViewAnimationOptionsForUpdateAnimation&&(W=this.delegate.collectionViewAnimationOptionsForUpdateAnimation(this));var T=BMExtend({duration:this.isDragging?200:_BMCollectionViewAnimationDurationDefault,easing:_BMCollectionViewAnimationEasingDefault,queue:NO},W);T.complete=function(){if(!k){if(k=YES,i._dataUpdatePromise==n){const t=i.layout.contentSize();i._contentWrapper.css({width:t.width+"px"}),i._contentWrapper.css({height:t.height+"px"})}for(var t=0;t<g.length;t++)g[t].animatable=YES,g[t]._unmanage();for(t=0;t<z.length;t++)z[t].animatable=YES,z[t].release(),z[t].attributes.isHidden&&z[t]._unmanage();for(t=0;t<p.length;t++)p[t].animatable=YES,p[t].recycle();i._dataUpdatePromise==n&&(i._applyOverflows(),i._container[0].style.pointerEvents="inherit",i.scrollView&&(i.scrollView.scrollingEnabled=YES),i._collectionEnabled=YES,i.isUpdatingData=NO,i._executeDataCompletionCallbacks()),e&&e.completionHandler&&e.completionHandler(),W.complete&&W.complete.apply(this,arguments),o()}};var z=[],k=NO;let O=function(){for(const t of p)t._reuseState=BMCollectionViewCellReuseState.Deleting;if(i._droppedShadows&&i._droppedShadows.forEach((t=>{if(t.transform){BMHook(t.node,{rotateZ:t.rotation+"deg",translateX:"0px",translateY:"0px"});let e=BMAnimationContextGetCurrent().controllerForObject(t,{node:t.node});e.registerBuiltInProperty("translateX",{withValue:t.transform.origin.x+"px"}),e.registerBuiltInProperty("translateY",{withValue:t.transform.origin.y+"px"}),e.registerBuiltInProperty("scaleX",{withValue:t.transform.size.width}),e.registerBuiltInProperty("scaleY",{withValue:t.transform.size.height}),e.registerBuiltInProperty("rotateZ",{withValue:"0deg"}),e.registerBuiltInProperty("opacity",{withValue:0})}else{BMHook(t.node,{rotateZ:t.rotation+"deg"});let e=BMAnimationContextGetCurrent().controllerForObject(t,{node:t.node});e.registerBuiltInProperty("scaleX",{withValue:.33}),e.registerBuiltInProperty("scaleY",{withValue:.33}),e.registerBuiltInProperty("opacity",{withValue:0})}})),a.origin.x!=i._bounds.origin.x||a.origin.y!=i._bounds.origin.y){var t=h,e=i._bounds.origin.copy();e.x+=i._offscreenBufferSize,e.y+=i._offscreenBufferSize;let o=BMAnimationContextGetCurrent().controllerForObject(i._container[0],{node:i._container[0]});i.iScroll?o.registerCustomProperty("scrollOffset",{withHandler:o=>{var n=t.x+o*(e.x-t.x),s=t.y+o*(e.y-t.y);i.iScroll._translate(-n,-s)}}):o.registerCustomProperty("scrollOffset",{withHandler:o=>{var n=t.x+o*(e.x-t.x),s=t.y+o*(e.y-t.y);i._container[0].scrollTo({left:n,top:s,behavior:"auto"})}})}for(let t of m.concat(E))t.prepareForAnimatedUpdate();for(var o=0;o<m.length;o++){(n=m[o]).animatable&&(n.attributes=n.targetAttributes,n.animatable=NO,z.push(n.retain()))}for(o=0;o<E.length;o++){var n;(n=E[o]).animatable&&(n.attributes=n.targetAttributes,n.animatable=NO,z.push(n.retain()))}i._cellLayoutQueue.dequeue(),i._size.width<r.width&&(i._contentWrapper.css({width:r.width+"px"}),YES),i._size.height<r.height&&(i._contentWrapper.css({height:r.height+"px"}),YES),i._size=r,i.layout.collectionViewDidStartUpdates()};return this._cellLayoutQueue.dequeue(),BMAnimationContextGetCurrent()?(O(),BMAnimationContextAddCompletionHandler(T.complete)):BMAnimateWithBlock(O,T),this.newBounds=void 0,this.oldBounds=void 0,0==E.length&&0==m.length&&T.complete(),this._dataUpdatePromise},beginUpdatesWithBlock:function(t){throw new Error("This method is unavailable.")},scrollToCellAtIndexPath:function(t,e){var i=this._layout.rectWithScrollingPositionOfCellAtIndexPath(t);let o;if(i){var n=e&&e.withVerticalGravity,s=e&&e.horizontalGravity;n||(o=this.visibleBounds,n=i.origin.y>o.bottom?BMCollectionViewScrollingGravityVertical.Bottom:i.bottom<o.origin.y?BMCollectionViewScrollingGravityVertical.Top:BMCollectionViewScrollingGravityVertical.Center),s||(o=o||this.visibleBounds,s=i.origin.x>o.right?BMCollectionViewScrollingGravityHorizontal.Right:i.right<o.origin.x?BMCollectionViewScrollingGravityHorizontal.Left:BMCollectionViewScrollingGravityHorizontal.Center);var a=e&&e.animated;return this.scrollToRect(i,{withVerticalGravity:n,horizontalGravity:s,animated:a})}return Promise.resolve()},scrollToSupplementaryViewWithIdentifier:function(t,e){var i=this._layout.rectWithScrollingPositionOfSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath});let o;if(i){var n=e.verticalGravity,s=e.horizontalGravity;n||(o=this.visibleBounds,n=i.origin.y>o.bottom?BMCollectionViewScrollingGravityVertical.Bottom:i.bottom<o.origin.y?BMCollectionViewScrollingGravityVertical.Top:BMCollectionViewScrollingGravityVertical.Center),s||(o=o||this.visibleBounds,s=i.origin.x>o.right?BMCollectionViewScrollingGravityHorizontal.Right:i.right<o.origin.x?BMCollectionViewScrollingGravityHorizontal.Left:BMCollectionViewScrollingGravityHorizontal.Center);var a=e.animated;return this.scrollToRect(i,{withVerticalGravity:n,horizontalGravity:s,animated:a})}return Promise.resolve()},scrollToRect:function(t,e){var i=BMPointMake();if(e.withVerticalGravity==BMCollectionViewScrollingGravityVertical.Top?i.y=t.origin.y:e.withVerticalGravity==BMCollectionViewScrollingGravityVertical.Center?i.y=t.origin.y+t.size.height/2-this.frame.size.height/2:e.withVerticalGravity==BMCollectionViewScrollingGravityVertical.Bottom&&(i.y=t.origin.y+t.size.height-this.frame.size.height),e.horizontalGravity==BMCollectionViewScrollingGravityHorizontal.Left?i.x=t.origin.x:e.horizontalGravity==BMCollectionViewScrollingGravityHorizontal.Center?i.x=t.origin.x+t.size.width/2-this.frame.size.width/2:e.horizontalGravity==BMCollectionViewScrollingGravityHorizontal.Right&&(i.x=t.origin.x+t.size.width-this.frame.size.width),i.y=Math.min(Math.max(0,i.y),this._size.height-this.frame.size.height),i.x=Math.min(Math.max(0,i.x),this._size.width-this.frame.size.width),e.animated){var o=this;return BMAnimateWithBlock((t=>{o.scrollOffset=i}),{duration:300})}return this.iScroll?this.iScroll.scrollTo(-(0|i.x),-(0|i.y)):(this._container[0].scrollLeft=i.x,this._container[0].scrollTop=i.y),Promise.resolve()},__UUID:void 0,get _UUID(){return this.__UUID||(this.__UUID=BMUUIDMake())},_isPerformingAnimatedScrolling:NO,_scrollToOffset:function(t){if(BMAnimationContextGetCurrent()){var e=BMAnimationContextGetCurrent(),i=e.subscribers.get(this),o=this;if(i)i.targetOffset=t.copy(),i.startingOffset=o.scrollOffset.copy();else{let n;n=o.iScroll?(t,e,n,s,a)=>{let r=i.targetOffset,l=i.startingOffset;var h=BMPointMake((r.x-l.x)*a+l.x|0,(r.y-l.y)*a+l.y|0);o.iScroll._translate(-h.x,-h.y),o._handleNewScrollFromEvent({x:h.x,y:h.y})}:(t,e,n,s,a)=>{let r=i.targetOffset,l=i.startingOffset;o._container[0].scrollLeft=(r.x-l.x)*a+l.x|0,o._container[0].scrollTop=(r.y-l.y)*a+l.y|0,o._handleNewScrollFromEvent(null)},i={apply:function(t){o._isPerformingAnimatedScrolling&&o._stopAnimatedScrolling(),o._container[0].style.pointerEvents="none",o._isPerformingAnimatedScrolling=YES,t.targets.push({element:o._container[0],properties:{tween:1},complete:t=>{o._container[0].style.pointerEvents="inherit",o._isPerformingAnimatedScrolling=NO},options:{progress:n}})},targetOffset:t.copy(),startingOffset:o.scrollOffset.copy()},e.subscribers.set(this,i)}}else{(o=this)._isPerformingAnimatedScrolling&&o._stopAnimatedScrolling(),this.iScroll?(this.iScroll.scrollTo(-(0|t.x),-(0|t.y)),this._handleNewScrollFromEvent({x:t.x,y:t.y})):(this._container[0].scrollLeft=t.x,this._container[0].scrollTop=t.y)}},_stopAnimatedScrolling(){this._isPerformingAnimatedScrolling&&((window.Velocity||$.Velocity)(this._container[0],"stop",this.__UUID),this._container[0].style.pointerEvents="inherit",this._isPerformingAnimatedScrolling=NO)},enumerateAllCellsWithBlock:function(t){for(var e=this.allCells.length,i=0;i<e;i++){if(t(r=this.allCells[i],r.itemType,r.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView?r.reuseIdentifier:void 0,YES)===NO)break}for(var o in this.cellCache){if((s=this.cellCache[o])&&s.length){var n=s.length;for(i=0;i<n;i++){if(t(r=s[i],r.itemType,void 0,NO)===NO)break}}}for(var o in this.supplementaryViewCache){var s,a=o;if((s=this.cellCache[o])&&s.length)for(n=s.length,i=0;i<n;i++){var r;if(t(r=s[i],r.itemType,a,NO)===NO)break}}},enumerateRetainedCellsWithBlock:function(t){for(var e=this.allCells.length,i=0;i<e;i++){var o=this.allCells[i];if(t(o,o.itemType,o.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView?o.reuseIdentifier:void 0)===NO)break}},enumerateVisibleCellsWithBlock:function(t){for(var e=this.retainedCells.length,i=0;i<e;i++){var o=this.retainedCells[i];if(t(o,o.itemType,o.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView?o.reuseIdentifier:void 0)===NO)break}},flatten:function(){if(this.initialized){this.enumerateAllCellsWithBlock((function(t,e,i,o){o?t.attributes._flatten():t.element[0].style.display="none"})),this._collectionEnabled=NO,this._container[0].style.overflow="hidden",this._container[0].style.pointerEvents="none"}},release:function(){var t=this;_BMCollectionViews.delete(this),this.initialized&&!this.iScroll&&this.container[0].removeEventListener("scroll",this._boundContainerDidScrollWithEvent,this._highFrequencyScrollingEnabled),this.enumerateAllCellsWithBlock((function(e,i,o,n){t.delegate&&t.delegate.collectionViewWillDestroyCell&&t.delegate.collectionViewWillDestroyCell(t,e),e.invalidate(),t.delegate&&t.delegate.collectionViewDidDestroyCell&&t.delegate.collectionViewDidDestroyCell(t,e)})),this.iScroll&&this.iScroll.destroy(),this._container.empty(),this._layout._collectionView=void 0,BMView.prototype.release.call(this)}}),BMCollectionView.collectionViewForNode=function(t,e){return(new this).initWithDOMNode(t,e)},BMCollectionView.collectionView=function(){const t=document.createElement("div");return this.collectionViewForNode(t)};class BMCollectionViewDataSourceAdapter{constructor(t){this._dataSet=t}collectionViewNumberOfSections(t){return this._dataSet.numberOfSections()}collectionViewNumberOfObjectsInSectionAtIndex(t,e){return this._dataSet.numberOfObjectsInSectionAtIndex(e)}collectionViewIndexPathForObjectAtRow(t,e,i){return this._dataSet.indexPathForObjectAtRow(e,i)}collectionViewIndexPathForObject(t,e){return this._dataSet.indexPathForObject(e)}collectionViewCellForItemAtIndexPath(t,e){return this._dataSet.cellForItemAtIndexPath(e)}collectionViewCellForSupplementaryViewWithIdentifier(t,e,i){return this._dataSet.cellForSupplementaryViewWithIdentifier(e,i)}collectionViewUseOldData(t,e){return this._dataSet.useOldData(e)}collectionViewIsUsingOldData(t){return this._dataSet.isUsingOldData()}collectionViewMoveItemFromIndexPath(t,e,i){return this._dataSet.moveItemFromIndexPath(e,i)}collectionViewMoveItemsFromIndexPaths(t,e,i){return this._dataSet.moveItemsFromIndexPaths(e,i)}collectionViewRemoveItemsAtIndexPaths(t,e){return this._dataSet.removeItemsAtIndexPaths(e)}collectionViewInsertItems(t,e,i){return this._dataSet.insertItems(e,i)}static adapterWithDataSet(t){return new this(t)}}class BMCollectionViewDataSetAdapter{constructor(t,e){this._collectionView=t,this._dataSource=e}numberOfSections(){return this._dataSource.collectionViewNumberOfSections(this._collectionView)}numberOfObjectsInSectionAtIndex(t){return this._dataSource.collectionViewNumberOfObjectsInSectionAtIndex(this._collectionView,t)}indexPathForObjectAtRow(t,e){return this._dataSource.collectionViewNumberOfObjectsInSectionAtIndex(this._collectionView,t,e)}indexPathForObject(t){return this._dataSource.collectionViewIndexPathForObject(this._collectionView,t)}contentsForCellWithReuseIdentifier(t){throw new Error("contentsForCellWithReuseIdentifier is unsupported when using data source objects")}cellForItemAtIndexPath(t){return this._dataSource.collectionViewCellForItemAtIndexPath(this._collectionView,t)}contentsForSupplementaryViewWithIdentifier(t){throw new Error("contentsForSupplementaryViewWithIdentifier is unsupported when using data source objects")}cellForSupplementaryViewWithIdentifier(t,e){return this._dataSource.collectionViewCellForSupplementaryViewWithIdentifier(this._collectionView,t,e)}updateCell(t,{atIndexPath:e}){throw new Error("updateCell is unsupported when using data source objects")}updateSupplementaryView(t,{withIdentifier:e,atIndexPath:i}){throw new Error("updateSupplementaryView is unsupported when using data source objects")}useOldData(t){return this._dataSource.collectionViewUseOldData(this._collectionView,t)}isUsingOldData(){return this._dataSource.collectionViewIsUsingOldData(this._collectionView)}moveItemFromIndexPath(t,e){return this._dataSource.collectionViewMoveItemFromIndexPath(this._collectionView,t,e)}moveItemsFromIndexPaths(t,e){return this._dataSource.collectionViewMoveItemsFromIndexPaths(this._collectionView,t,e)}removeItemsAtIndexPaths(t){return this._dataSource.collectionViewRemoveItemsAtIndexPaths(this._collectionView,t)}insertItems(t,e){return this._dataSource.collectionViewInsertItems(this._collectionView,t,e)}static adapterWithDataSource(t,e){return new this(t,e)}}class BMWindowOverlay extends BMView{initWithWindow(t,e){this._window=t;let i=e&&"modal"in e?e.modal:YES,o=document.createElement("div");return o.className="BMWindowBlocker",BMCopyProperties(o.style,{opacity:0,display:"none",backdropFilter:i?"blur(15px)":"none",webkitBackdropFilter:i?"blur(15px)":"none"}),i||(o.style.pointerEvents="none",o.classList.add("BMWindowBlockerNonModal")),i&&o.addEventListener("click",(e=>{if(e.target==o){var i=YES;t.delegate&&t.delegate.windowShouldClose&&(i=t.delegate.windowShouldClose(t));var n=void 0,s=void 0;i&&(t._anchorPoint||t._anchorRect||t._anchorNode?t.dismissAnimated(YES):(t.delegate&&t.delegate.rectForDismissedWindow&&(n=t.delegate.rectForDismissedWindow(t)),t.delegate&&t.delegate.DOMNodeForDismissedWindow&&(s=t.delegate.DOMNodeForDismissedWindow(t)),t.dismissAnimated(YES,{toRect:n,toNode:s})))}})),super.initWithDOMNode(o)}frameForDescendant(t){return this._window.frameForDescendant(t)}_registerLayout(){this._window._visible?super._registerLayout():this._awaitsLayout=YES}_windowWillAppear(){this._awaitsLayout&&(this._awaitsLayout=NO,super._registerLayout(),this.layoutQueue.dequeue())}get _currentViewport(){if(this._requiredViewport)return this._requiredViewport;let t=new BMViewport;return t.init(),t._width=this._window._fullScreen?window.innerWidth:this._window.frame.size.width,t._height=this._window._fullScreen?window.innerHeight:this._window.frame.size.height,t._diagonal=Math.sqrt(Math.pow(t._width,2)+Math.pow(t._height,2)),t._orientation=t._width>=t._height?BMLayoutOrientation.Landscape:BMLayoutOrientation.Portrait,t._surfaceArea=t._width*t._height,t}}var _BMWindowAnimationDurationDefault=400,_BMWindowAnimationEasingDefault="easeInOutQuart";const _BMWindowAnimationEasingIncomingDefault="easeOutQuart",_BMWindowAnimationDurationIncomingDefault=200,_BMWindowAnimationEasingOutgoingDefault="easeInQuart",_BMWindowAnimationDurationOutgoingDefault=200,BM_WINDOW_SHOWCASE_MAX_ITERATIONS=5e3;var BM_WINDOW_Z_INDEX_MAX=2007;function BMWindow(){}function BMWindowMakeWithFrame(t,e){return(new BMWindow).initWithFrame(t,e)}function BMToolWindow(){}BMWindow._keyWindow=void 0,BMWindow._windows=[],BMWindow._minimizedWindows=[],BMWindow.zIndexMax=function(){return BM_WINDOW_Z_INDEX_MAX},BMWindow.minimizeAllAnimated=function(t){for(let e of this._windows.slice())e._minimizedWindow||e.minimizeAnimated(t)},BMWindow.restoreAllAnimated=function(t){for(let e of this._windows.slice())e._minimizedWindow&&e.restoreAnimated(t)},BMWindow.revealAll=function(){for(let t of this._windows.slice())t._hidden&&t.reveal()},BMWindow.hideAll=function(){for(let t of this._windows.slice())t._hidden||t.hide()},BMWindow._isShowcasing=NO,document.addEventListener("keydown",(t=>{69==t.which&&t.altKey&&(navigator.userAgent.includes("Macintosh")?t.metaKey:t.ctrlKey)&&(BMWindow._isShowcasing?BMWindow.exitShowcase():BMWindow.enterShowcase())}),YES),BMWindow._showcaseElements=[],BMWindow.registerShowcaseElement=function(t){BMWindow._showcaseElements.push(t)},BMWindow.unregisterShowcaseElement=function(t){BMWindow._showcaseElements.splice(BMWindow._showcaseElements.indexOf(t),1)},BMWindow.enterShowcase=async function(){if(BMWindow._isShowcasing)return;document.body.style.backgroundColor="rgb(60, 60, 60)",BMWindow._isShowcasing=YES,document.body.addEventListener("click",BMWindow.exitShowcase);let t=BMWindow._windows.filter((t=>!t._minimizedWindow));for(let e of BMWindow._showcaseElements)t.unshift(e);t.forEach((t=>{t.node.classList.add("BMWindowShowcaseWindow");let e=document.createElement("div");e.classList.add("BMWindowShowcaseWindowSelector"),e.addEventListener("click",(e=>{t.becomeKeyWindow?t.becomeKeyWindow():BMWindow.hideAll(),BMWindow.exitShowcase()})),t.node.appendChild(e)}));let e,i=BMRectMake(0,0,window.innerWidth,window.innerHeight),o=t.map((t=>t._fullScreen?i.copy():t.frame.copy())),n=o.map((t=>t.copy())),s=i.copy();for(let t=0;t<5e3;t++){for(let t=0;t<o.length;t++)for(let n=0;n<o.length;n++)if(t!=n&&o[t].intersectsRect(o[n])){e=YES;let a=o[t],r=o[n],l=r.center.pointBySubtractingPoint(a.center);l.x||l.y||(l.x=2*Math.random()-1,l.y=2*Math.random()-1),s.height/s.width>i.height/i.width?l.x=2*l.x:l.y=2*l.y;let h=Math.sqrt(l.x*l.x+l.y*l.y);l.x=20*l.x/h,l.y=20*l.y/h,a.offsetWithX(-l.x,{y:-l.y}),r.offsetWithX(l.x,{y:l.y}),s=s.rectByUnionWithRect(a).rectByUnionWithRect(r)}if(!e)break}let a=Math.min(1,i.width/s.width,i.height/s.height);for(let t of o)t.offset(-s.left,-s.top),t.origin.x=t.origin.x*a,t.origin.y=t.origin.y*a,t.size.width=t.size.width*a,t.size.height=t.size.height*a;BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();for(let e=0;e<o.length;e++){let i=n[e].rectWithTransformToRect(o[e]);BMAnimationContextGetCurrent().controllerForObject(t[e].node,{node:t[e].node}).registerBuiltInPropertiesWithDictionary({translateX:i.origin.x+"px",translateY:i.origin.y+"px",scaleX:i.size.width,scaleY:i.size.height,translateZ:0})}}),{duration:300,easing:"easeInOutQuad",complete:t=>BMWindow.revealAll()}),document.body.addEventListener("wheel",BMWindow._wheelHandler,YES)},BMWindow._wheelHandler=function(t){t.deltaY<0&&BMWindow.exitShowcase()},BMWindow.exitShowcase=function(t){if(t&&t.target!=document.body)return;BMWindow._isShowcasing=NO,document.body.removeEventListener("click",BMWindow.exitShowcase),document.body.removeEventListener("wheel",BMWindow._wheelHandler,YES);let e=BMWindow._windows.filter((t=>!t._minimizedWindow));for(let t of BMWindow._showcaseElements)e.unshift(t);e.forEach((t=>{t.node.classList.remove("BMWindowShowcaseWindow");let e=t.node.querySelector(".BMWindowShowcaseWindowSelector");e&&e.remove()})),BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();for(let t=0;t<e.length;t++){BMAnimationContextGetCurrent().controllerForObject(e[t].node,{node:e[t].node}).registerBuiltInPropertiesWithDictionary({translateX:"0px",translateY:"0px",scaleX:1,scaleY:1,translateZ:0})}}),{duration:300,easing:"easeInOutQuad",complete:t=>e[0].node.style.transform="none"})},BMWindow.prototype=BMExtend(Object.create(BMView.prototype),{delegate:void 0,_frame:void 0,get contentNode(){return this.content},get contentView(){return this},get frame(){return this._frame},set frame(t){if(!this._fullScreen){switch(t=t.integralRect,this._frame=t.copy(),BMCopyProperties(this._window.style,{left:t.origin.x+"px",top:t.origin.y+"px",width:t.size.width+"px",height:t.size.height+"px"}),this.frameHorizontalPositionLayoutAttribute){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:this.leftConstraint.constant=t.origin.x;break;case BMLayoutAttribute.CenterX:this.leftConstraint.constant=t.center.x-this.superview.frame.center.x;break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:this.leftConstraint.constant=t.right-this.superview.frame.right}switch(this.frameVerticalPositionLayoutAttribute){case BMLayoutAttribute.Top:this.topConstraint.constant=t.origin.y;break;case BMLayoutAttribute.CenterY:this.topConstraint.constant=t.center.y-this.superview.frame.center.y;break;case BMLayoutAttribute.Bottom:this.topConstraint.constant=t.bottom-this.superview.frame.bottom}this.widthConstraint.constant=t.size.width,this.heightConstraint.constant=t.size.height}},get framePositionPriority(){return 500},get frameSizePriority(){return 750},get frameHorizontalPositionLayoutAttribute(){return BMLayoutAttribute.Left},get _frameHorizontalAnchorName(){const t=this.frameHorizontalPositionLayoutAttribute;return t.substring(0,1).toLowerCase()+t.substring(1,t.length)},get frameVerticalPositionLayoutAttribute(){return BMLayoutAttribute.Top},get _frameVerticalAnchorName(){const t=this.frameVerticalPositionLayoutAttribute;return t.substring(0,1).toLowerCase()+t.substring(1,t.length)},_window:void 0,_toolbar:void 0,get toolbar(){return this._toolbar},_overlay:void 0,_blocker:void 0,_content:void 0,get content(){return this._content},_title:"New Window",get title(){return this._title},set title(t){this._title=t},_anchorPoint:void 0,get anchorPoint(){return this._anchorPoint},set anchorPoint(t){this._anchorPoint=t&&t.copy(),this.anchorNode=void 0,this._anchorRect=void 0},_anchorRect:void 0,get anchorRect(){return this._anchorRect},set anchorRect(t){this._anchorRect=t&&t.copy(),this.anchorNode=void 0,this._anchorPoint=void 0},_anchorNode:void 0,get anchorNode(){return this._anchorNode},set anchorNode(t){this._anchorNode=t,this._anchorPoint=void 0,this._anchorRect=void 0},_visible:NO,get isVisible(){return this._visible},_fullScreen:NO,get isFullScreen(){return this._fullScreen},_modal:NO,get isModal(){return this._modal},_toolWindow:NO,_toolWindows:void 0,initWithFrame:function(t,e){t=t.integralRect;let i=e&&"modal"in e?e.modal:YES;this._toolWindows=[],this._overlay=(new BMWindowOverlay).initWithWindow(this,{modal:i}),this._blocker=this._overlay.node;let o=document.createElement("div");this._window=o,o.className="BMDarkModeAuto BMWindow",BMCopyProperties(o.style,{opacity:0,display:"none"}),this._modal=i,i?o.classList.add("BMModalWindow"):(this._toolWindow||(o.addEventListener("mousedown",(t=>{this.isKeyWindow||this.becomeKeyWindow()}),YES),o.classList.add("BMWindowInactive"),BMWindow._windows.push(this)),o.classList.add("BMNonModalWindow")),this._content=document.createElement("div"),this._content.className="BMDarkModeAuto BMWindowContent",o.appendChild(this._content);var n=e&&void 0!==e.toolbar?e.toolbar:YES;if(n?(this._toolbar=document.createElement("div"),this._toolbar.className="BMDarkModeAuto BMWindowToolbar",o.appendChild(this._toolbar)):this._content.className="BMDarkModeAuto BMWindowContent BMWindowFullContent",document.body.appendChild(this._blocker),BMView.prototype.initWithDOMNode.call(this,o),this._overlay.addSubview(this),document.body.appendChild(o),this.leftConstraint=this[this._frameHorizontalAnchorName].equalTo(this._overlay[this._frameHorizontalAnchorName],{plus:t.origin.x,priority:this.framePositionPriority}),this.topConstraint=this[this._frameVerticalAnchorName].equalTo(this._overlay[this._frameVerticalAnchorName],{plus:t.origin.y,priority:this.framePositionPriority}),this.widthConstraint=this.width.equalTo(t.size.width,{priority:this.frameSizePriority}),this.heightConstraint=this.height.equalTo(t.size.height,{priority:this.frameSizePriority}),this.frame=t,this.leftConstraint.isActive=YES,this.topConstraint.isActive=YES,this.widthConstraint.isActive=YES,this.heightConstraint.isActive=YES,!i&&n){let t;this.maxLeftConstraint=this.left.greaterThanOrEqualTo(0),this.maxTopConstraint=this.top.greaterThanOrEqualTo(0),this.maxRightConstraint=this.right.lessThanOrEqualTo(window.innerWidth),this.maxBottomConstraint=this.bottom.lessThanOrEqualTo(window.innerHeight),this.maxLeftConstraint.isActive=YES,this.maxTopConstraint.isActive=YES,this.maxRightConstraint.isActive=YES,this.maxBottomConstraint.isActive=YES,window.addEventListener("resize",this._boundViewportDidResize=this._viewportDidResize.bind(this)),this._toolbar.addEventListener("mousedown",(t=>{if(t.target!=this._toolbar)return;if(this._fullScreen)return;this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let e=BMPointMake(t.clientX,t.clientY),i=t=>{let i=BMPointMake(t.clientX,t.clientY);const o=BMPointMake(this._position.x+i.x-e.x,this._position.y+i.y-e.y);let n=YES;this.delegate&&this.delegate.windowShouldMove&&(n=this.delegate.windowShouldMove(this,o)),n&&(this.leftConstraint.constant=this._position.x+i.x-e.x,this.topConstraint.constant=this._position.y+i.y-e.y,this._position=o,e=i,this.layout(),t.preventDefault())},o=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",o,YES)};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",o,YES),t.preventDefault()})),this._toolbar.addEventListener("touchstart",(e=>{if(void 0!==t)return;if(e.target!=this._toolbar)return;if(this._fullScreen)return;t=e.changedTouches[0].identifier,this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let i=BMPointMake(e.changedTouches[0].clientX,e.changedTouches[0].clientY),o=e=>{let o;for(let i of e.changedTouches)if(i.identifier==t){o=i;break}if(!o)return;let n=BMPointMake(o.clientX,o.clientY);const s=BMPointMake(this._position.x+n.x-i.x,this._position.y+n.y-i.y);let a=YES;this.delegate&&this.delegate.windowShouldMove&&(a=this.delegate.windowShouldMove(this,s)),a&&(this.leftConstraint.constant=this._position.x+n.x-i.x,this.topConstraint.constant=this._position.y+n.y-i.y,this._position=s,i=n,this.layout(),e.preventDefault())},n=e=>{t=void 0,window.removeEventListener("touchmove",o),window.removeEventListener("touchend",n),window.removeEventListener("touchcancel",n)};window.addEventListener("touchmove",o),window.addEventListener("touchend",n),window.removeEventListener("touchcancel",n),e.preventDefault()})),this._toolbar.addEventListener("dbclick",(t=>{this.minimizeAnimated(YES)})),this._toolbar.addEventListener("wheel",(t=>{if(t.deltaY>0){let t=YES;this.delegate&&this.delegate.windowShouldEnterShowcase&&(t=this.delegate.windowShouldEnterShowcase(this)),t&&BMWindow.enterShowcase()}}));let e,i=this._dragHandle=document.createElement("div");i.className="material-icons BMWindowDragHandle BMDarkModeAuto",i.innerText="dehaze",i.style.cursor="nwse-resize",o.appendChild(i),i.addEventListener("mousedown",(t=>{if(this._fullScreen)return;this._dragged=YES,this._position=BMPointMake(this.widthConstraint.constant,this.heightConstraint.constant);let e=BMPointMake(t.clientX,t.clientY),i=t=>{let i=BMPointMake(t.clientX,t.clientY);const o=this._position.x+i.x-e.x,n=this._position.y+i.y-e.y;this._position=BMPointMake(o,n),e=i;let s=YES;this.delegate&&this.delegate.windowShouldResize&&(s=this.delegate.windowShouldResize(this,BMSizeMake(o,n))),s&&(this.widthConstraint.constant=o,this.heightConstraint.constant=n,this.frame.size.width=this.widthConstraint.constant,this.frame.size.height=this.heightConstraint.constant,this.layout(),this.delegate&&this.delegate.windowDidResize&&this.delegate.windowDidResize(this,{toSize:this.frame.size}),t.preventDefault())},o=document.createElement("div");o.className="BMLayoutGuideMask",o.style.cursor="nwse-resize",document.body.appendChild(o);let n=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",n,YES),o.remove()};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",n,YES),t.preventDefault()})),i.addEventListener("touchstart",(i=>{if(this._fullScreen)return;if(void 0!==t)return;e=i.changedTouches[0].identifier,this._dragged=YES,this._position=BMPointMake(this.widthConstraint.constant,this.heightConstraint.constant);let o=BMPointMake(i.changedTouches[0].clientX,i.changedTouches[0].clientY),n=t=>{let i;for(let o of t.changedTouches)if(o.identifier==e){i=o;break}if(!i)return;let n=BMPointMake(i.clientX,i.clientY);const s=this._position.x+n.x-o.x,a=this._position.y+n.y-o.y;this._position=BMPointMake(s,a),o=n;let r=YES;this.delegate&&this.delegate.windowShouldResize&&(r=this.delegate.windowShouldResize(this,BMSizeMake(s,a))),r&&(this.widthConstraint.constant=s,this.heightConstraint.constant=a,this.frame.size.width=this.widthConstraint.constant,this.frame.size.height=this.heightConstraint.constant,this.layout(),this.delegate&&this.delegate.windowDidResize&&this.delegate.windowDidResize(this,{toSize:this.frame.size}),t.preventDefault())},s=t=>{e=void 0,window.removeEventListener("touchmove",n),window.removeEventListener("touchend",s),window.removeEventListener("touchcancel",s)};window.addEventListener("touchmove",n),window.addEventListener("touchend",s),window.removeEventListener("touchcancel",s),i.preventDefault()}))}return this},performDragWithEvent(t){"mousedown"==t.type?this.performDragWithMouseEvent(t):"touchstart"==t.type&&this.performDragWithTouchEvent(t)},performDragWithMouseEvent(t){if(this._fullScreen)return;this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let e=BMPointMake(t.clientX,t.clientY),i=t=>{let i=BMPointMake(t.clientX,t.clientY);const o=BMPointMake(this._position.x+i.x-e.x,this._position.y+i.y-e.y);let n=YES;this.delegate&&this.delegate.windowShouldMove&&(n=this.delegate.windowShouldMove(this,o)),n&&(this.leftConstraint.constant=this._position.x+i.x-e.x,this.topConstraint.constant=this._position.y+i.y-e.y,this._position=o,e=i,this.layout(),t.preventDefault())},o=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",o,YES)};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",o,YES),t.preventDefault()},_touchDragPoint:void 0,performDragWithTouchEvent(t){if(void 0!==this._touchDragPoint)return;if(this._fullScreen)return;this._touchDragPoint=t.changedTouches[0].identifier,this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let e=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY),i=t=>{let i;for(let e of t.changedTouches)if(e.identifier==this._touchDragPoint){i=e;break}if(!i)return;let o=BMPointMake(i.clientX,i.clientY);const n=BMPointMake(this._position.x+o.x-e.x,this._position.y+o.y-e.y);let s=YES;this.delegate&&this.delegate.windowShouldMove&&(s=this.delegate.windowShouldMove(this,n)),s&&(this.leftConstraint.constant=this._position.x+o.x-e.x,this.topConstraint.constant=this._position.y+o.y-e.y,this._position=n,e=o,this.layout(),t.preventDefault())},o=t=>{this._touchDragPoint=void 0,window.removeEventListener("touchmove",i),window.removeEventListener("touchend",o),window.removeEventListener("touchcancel",o)};window.addEventListener("touchmove",i),window.addEventListener("touchend",o),window.removeEventListener("touchcancel",o),t.preventDefault()},colorSchemeDidChange(t){switch(BMView.prototype.colorSchemeDidChange.apply(this,arguments),this.colorScheme){case BMViewColorScheme.Light:this.node.querySelectorAll(".BMDarkModeAuto").forEach((t=>t.classList.remove("BMDarkModeAuto"))),this.node.classList.remove("BMDarkModeAuto");break;case BMViewColorScheme.Auto:this.node.classList.add("BMDarkModeAuto"),this._dragHandle&&this._dragHandle.classList.add("BMDarkModeAuto");break;case BMViewColorScheme.Dark:default:throw new Error(`The color scheme ${t} is not supported on this view.`)}},_viewportDidResize(t){this.maxRightConstraint.constant=window.innerWidth,this.maxBottomConstraint.constant=window.innerHeight,this._fullScreen&&this.layout()},_enableKeyboardShortcuts(){BMView.prototype._enableKeyboardShortcuts.apply(this,arguments),(this.isModal||this.isKeyWindow)&&(document.activeElement&&!this.node.contains(document.activeElement)?this.node.focus():document.activeElement||this.node.focus())},toggleAnimated:function(t,e){this._visible?this.dismissAnimated(t,e):this.bringToFrontAnimated(t,e)},animateInWithCompletionHandler(t){const e=this;if(this._anchorRect){const t=this._anchorRect,i=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(t);__BMVelocityAnimate(this._window,{opacity:1,translateX:["0px",i.origin.x+"px"],translateY:["0px",i.origin.y+"px"],scaleX:[1,i.size.width],scaleY:[1,i.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"block"},YES)}else if(this._anchorNode){const i=this._anchorNode,o=BMRectMakeWithNodeFrame(i),n=i.cloneNode(YES),s=i.style.display;e._nodeDisplay=s,n.style.position="fixed",n.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,n.style.transform="",BMCopyProperties(n.style,{left:o.origin.x+"px",top:o.origin.y+"px",width:o.size.width+"px",height:o.size.height+"px",margin:0}),n.style.pointerEvents="none";const a=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(o);document.body.appendChild(n),i.style.display="none",__BMVelocityAnimate(this._window,{opacity:1,translateX:["0px",a.origin.x+"px"],translateY:["0px",a.origin.y+"px"],scaleX:[1,a.size.width],scaleY:[1,a.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"block",complete:t},YES),__BMVelocityAnimate(n,{opacity:[0,1],translateX:-a.origin.x+"px",translateY:-a.origin.y+"px",scaleX:1/a.size.width,scaleY:1/a.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){n.remove();var o=NO;e.delegate&&e.delegate.windowShouldKeepNodeHidden&&(o=e.delegate.windowShouldKeepNodeHidden(e,i)),o?e._nodeDisplay=s:(i.style.display=s,e._nodeDisplay=void 0),t()}},YES)}else __BMVelocityAnimate(this._window,{opacity:1,scaleX:[1,.9],scaleY:[1,.9],translateZ:0},{duration:200,easing:"easeOutQuart",display:"block",complete:t},YES)},bringToFrontAnimated:function(t,e={}){this._visible=YES,this.becomeKeyWindow();for(let e of this._toolWindows)e.opensAutomatically&&e.bringToFrontAnimated(t);t=void 0===t?YES:t;var i=this;if(i.delegate&&i.delegate.windowWillAppear&&i.delegate.windowWillAppear(i),t){let t;this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",__BMVelocityAnimate(this._blocker,{opacity:1,translateZ:0},{duration:500,easing:"easeInOutQuint",display:"block",complete:function(){i._blocker.style.pointerEvents="",i._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()}},YES),this._anchorNode||this._anchorRect||this._anchorPoint?t=()=>{}:(e.fromRect&&(this.anchorRect=e.fromRect),e.fromNode&&(this.anchorNode=e.fromNode),t=()=>{this.anchorRect=void 0,this.anchorNode=void 0,this._keyboardShortcutsEnabled&&this.node.focus()}),this.animateInWithCompletionHandler(t),this._blocker.style.display="block",this._window.style.display="block",this._keyboardShortcutsEnabled&&this.node.focus(),this._overlay._windowWillAppear()}else this._blocker.style.opacity=1,this._blocker.style.display="block",this._window.style.opacity=1,BMHook(this._window,{scaleX:1,scaleY:1}),this._window.style.display="block",this._overlay._windowWillAppear(),this._blocker.style.pointerEvents="",this._window.style.pointerEvents="",this._keyboardShortcutsEnabled&&this.node.focus(),i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()},animateOutWithCompletionHandler(t){const e=this;if(this._anchorRect){const i=this._anchorRect,o=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(i);__BMVelocityAnimate(this._window,{opacity:0,translateX:o.origin.x+"px",translateY:o.origin.y+"px",scaleX:o.size.width,scaleY:o.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:t},YES)}else if(this._anchorNode){const i=this._anchorNode;void 0!==e._nodeDisplay&&(i.style.display=e._nodeDisplay);const o=BMRectMakeWithNodeFrame(i),n=i.cloneNode(YES),s=void 0!==e._nodeDisplay?e._nodeDisplay:i.style.display;e._nodeDisplay=void 0,n.style.position="fixed",n.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,n.style.transform="",BMCopyProperties(n.style,{left:o.origin.x+"px",top:o.origin.y+"px",width:o.size.width+"px",height:o.size.height+"px",margin:0}),n.style.pointerEvents="none";const a=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(o);BMHook(n,{translateX:-a.origin.x+"px",translateY:-a.origin.y+"px",scaleX:1/a.size.width,scaleY:1/a.size.height,opacity:0}),document.body.appendChild(n),i.style.display="none",__BMVelocityAnimate(this._window,{opacity:0,translateX:a.origin.x+"px",translateY:a.origin.y+"px",scaleX:a.size.width,scaleY:a.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:t},YES),__BMVelocityAnimate(n,{opacity:[1,0],translateX:["0px",-a.origin.x+"px"],translateY:["0px",-a.origin.y+"px"],scaleX:[1,1/a.size.width],scaleY:[1,1/a.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){i.style.display=s,n.remove()}},YES)}else __BMVelocityAnimate(this._window,{opacity:0,scaleX:.9,scaleY:.9,translateZ:0},{duration:200,easing:"easeInQuart",display:"none",complete:t},YES)},dismissAnimated:function(t,e={}){t=void 0===t?YES:t;var i=this;this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",i.delegate&&i.delegate.windowWillClose&&i.delegate.windowWillClose(i),this._visible=NO;for(let e of this._toolWindows)e.dismissAnimated(t);if(t){let t;__BMVelocityAnimate(this._blocker,{opacity:0,translateZ:0},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:function(){i.windowDidClose(),i.delegate&&i.delegate.windowDidClose&&i.delegate.windowDidClose(i),e&&e.completionHandler&&e.completionHandler()}},YES),this._anchorNode||this._anchorRect||this._anchorPoint?t=()=>{this._window.style.display="none",this._window.style.opacity=0}:(e.fromRect&&(this.anchorRect=e.fromRect),e.fromNode&&(this.anchorNode=e.fromNode),t=()=>{this.anchorRect=void 0,this.anchorNode=void 0,this._window.style.display="none",this._window.style.opacity=0}),this.animateOutWithCompletionHandler(t)}else this._blocker.style.opacity=0,this._blocker.style.display="none",this._window.style.opacity=0,this._window.style.display="none",i.windowDidClose(),i.delegate&&i.delegate.windowDidClose&&i.delegate.windowDidClose(i),e&&e.completionHandler&&e.completionHandler()},windowDidClose(){},minimizeAnimated:function(t=YES,e={}){if(this._modal)throw new Error("A modal window cannot be minimized.");if(this._minimizedWindow)return;this.delegate&&this.delegate.windowWillMinimize&&this.delegate.windowWillMinimize(this);let i=document.createElement("div");i.className="BMWindowMinimized",i.innerText=this.title,i.style.left=2+258*BMWindow._minimizedWindows.length+"px",i.addEventListener("click",(t=>{t.altKey?BMWindow.restoreAllAnimated(YES):this.restoreAnimated(YES)})),BMWindow._minimizedWindows.push(i),document.body.appendChild(i),this._minimizedWindow=i;let o=this;if(t){var n=i,s=BMRectMakeWithNodeFrame(n),a=n.cloneNode(YES);a.style.position="fixed",a.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,a.style.transform="",BMCopyProperties(a.style,{left:s.origin.x+"px",top:s.origin.y+"px",width:s.size.width+"px",height:s.size.height+"px",margin:0}),a.style.pointerEvents="none";var r=(o._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):o.frame).rectWithTransformToRect(s);BMHook(a,{translateX:-r.origin.x+"px",translateY:-r.origin.y+"px",scaleX:1/r.size.width,scaleY:1/r.size.height,opacity:0}),document.body.appendChild(a),n.style.display="none",__BMVelocityAnimate(this._window,{opacity:0,translateX:r.origin.x+"px",translateY:r.origin.y+"px",scaleX:r.size.width,scaleY:r.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none"},YES),__BMVelocityAnimate(a,{opacity:[1,0],translateX:["0px",-r.origin.x+"px"],translateY:["0px",-r.origin.y+"px"],scaleX:[1,1/r.size.width],scaleY:[1,1/r.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){n.style.display="block",a.remove(),o.delegate&&o.delegate.windowDidMinimize&&o.delegate.windowDidMinimize(o),e&&e.completionHandler&&e.completionHandler()}},YES)}},restoreAnimated(t=YES,e={}){if(this._modal)throw new Error("A modal window cannot be restored.");if(!this._minimizedWindow)return;this.delegate&&this.delegate.windowWillRestore&&this.delegate.windowWillRestore(this);let i=this;if(t){var o=this._minimizedWindow,n=BMRectMakeWithNodeFrame(o),s=o.cloneNode(YES);this._minimizedWindow=void 0;let t=NO;for(let e=0,i=BMWindow._minimizedWindows.length,n=BMWindow._minimizedWindows;e<i;e++)n[e]!=o?t&&(n[e].style.left=2+258*e+"px"):(n.splice(e,1),e--,i--,t=YES);this.isKeyWindow||this.becomeKeyWindow(),s.style.position="fixed",s.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,s.style.transform="",BMCopyProperties(s.style,{left:n.origin.x+"px",top:n.origin.y+"px",width:n.size.width+"px",height:n.size.height+"px",margin:0}),s.style.pointerEvents="none";var a=(i._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):i.frame).rectWithTransformToRect(n);document.body.appendChild(s),o.style.display="none",__BMVelocityAnimate(this._window,{opacity:1,translateX:["0px",a.origin.x+"px"],translateY:["0px",a.origin.y+"px"],scaleX:[1,a.size.width],scaleY:[1,a.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"block"},YES),__BMVelocityAnimate(s,{opacity:[0,1],translateX:-a.origin.x+"px",translateY:-a.origin.y+"px",scaleX:1/a.size.width,scaleY:1/a.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){s.remove(),o.remove(),i.delegate&&i.delegate.windowDidRestore&&i.delegate.windowDidRestore(i),e&&e.completionHandler&&e.completionHandler()}},YES)}},enterFullScreenAnimated:function(t,e){this._fullScreen=YES,this.isKeyWindow||this.becomeKeyWindow(),t=void 0===t?YES:t;var i=this;this.widthConstraint.constant=window.innerWidth,this.heightConstraint.constant=window.innerHeight,this.leftConstraint.constant=0,this.topConstraint.constant=0,t?BMAnimateWithBlock((()=>{BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node}).registerBuiltInPropertiesWithDictionary({left:"0px",top:"0px",width:window.innerWidth+"px",height:window.innerHeight+"px"});const t=this.frame.copy();this.layout(),BMCopyProperties(this.node.style,{left:t.origin.x+"px",top:t.origin.y+"px",width:t.size.width+"px",height:t.size.height+"px"})}),{duration:300,easing:"easeInOutQuart",complete:function(){i.delegate&&i.delegate.windowDidEnterFullScreen&&i.delegate.windowDidEnterFullScreen(i),e&&e.completionHandler&&e.completionHandler(),i._window.classList.add("BMFullScreenWindow")}}):(i._window.classList.add("BMFullScreenWindow"),i.delegate&&i.delegate.windowDidEnterFullScreen&&i.delegate.windowDidEnterFullScreen(i),e&&e.completionHandler&&e.completionHandler()),this._resizeHandler=t=>{this.widthConstraint.constant=window.innerWidth,this.heightConstraint.constant=window.innerHeight},window.addEventListener("resize",this._resizeHandler)},exitFullScreenAnimated:function(t,e){if(this._fullScreen){t=void 0===t?YES:t;var i=this;if(this.widthConstraint.constant=this.frame.width,this.heightConstraint.constant=this.frame.height,this.leftConstraint.constant=this.frame.left,this.topConstraint.constant=this.frame.top,t){i._window.classList.remove("BMFullScreenWindow");var o=i.frame;BMCopyProperties(i._window.style,{left:"0px",top:"0px",width:window.innerWidth+"px",height:window.innerHeight+"px"}),BMAnimateWithBlock((()=>{let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("left",{withValue:o.origin.x+"px"}),t.registerBuiltInProperty("top",{withValue:o.origin.y+"px"}),t.registerBuiltInProperty("width",{withValue:o.size.width+"px"}),t.registerBuiltInProperty("height",{withValue:o.size.height+"px"}),this._fullScreen=NO,this.layout(),BMCopyProperties(i._window.style,{left:"0px",top:"0px",width:window.innerWidth+"px",height:window.innerHeight+"px"})}),{duration:300,easing:"easeInOutQuart",complete:function(){i.delegate&&i.delegate.windowDidExitFullScreen&&i.delegate.windowDidExitFullScreen(i),e&&e.completionHandler&&e.completionHandler(),i.frame=i.frame}})}else i._window.classList.remove("BMFullScreenWindow"),this._fullScreen=NO,i.frame=i.frame,i.delegate&&i.delegate.windowDidExitFullScreen&&i.delegate.windowDidExitFullScreen(i),e&&e.completionHandler&&e.completionHandler();window.removeEventListener("resize",this._resizeHandler)}},get isKeyWindow(){return BMWindow._keyWindow==this},resignKeyWindow(){if(BMWindow._keyWindow==this&&!this._modal){this.node.classList.remove("BMKeyWindow"),this.node.classList.add("BMWindowInactive"),BMWindow._keyWindow=void 0;for(let t of this._toolWindows)t.hide();this.delegate&&this.delegate.windowDidResignKeyWindow&&this.delegate.windowDidResignKeyWindow(this)}},becomeKeyWindow(){let t=!!this._minimizedWindow;if(this._minimizedWindow&&this.restoreAnimated(YES),this._hidden&&this.reveal(),BMWindow._keyWindow!=this){BMWindow._keyWindow&&BMWindow._keyWindow.resignKeyWindow(),this.node.classList.add("BMKeyWindow"),this.node.classList.remove("BMWindowInactive"),BMWindow._keyWindow=this,this._modal?(this._overlay.node.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,this.node.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1):(BMWindow._windows.splice(BMWindow._windows.indexOf(this),1),BMWindow._windows.push(this),BMWindow._windows.slice().reverse().forEach(((t,e)=>t.node.style.zIndex=BM_WINDOW_Z_INDEX_MAX-e))),this.delegate&&this.delegate.windowDidBecomeKeyWindow&&this.delegate.windowDidBecomeKeyWindow(this);for(let t of this._toolWindows)t.reveal()}else t||BMWindow._isShowcasing||BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("scaleX",{withValue:1.05}),t.registerBuiltInProperty("scaleY",{withValue:1.05})}),{duration:100,easing:"easeInQuad",complete:()=>{BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("scaleX",{withValue:1}),t.registerBuiltInProperty("scaleY",{withValue:1})}),{duration:100,easing:"easeOutQuad"})}})},release(){if(!this.__released){if(BMWindow._keyWindow==this&&(BMWindow._keyWindow=void 0),this._boundViewportDidResize&&window.removeEventListener("resize",this._boundViewportDidResize),!this._modal){for(let t=0,e=BMWindow._windows.length;t<e;t++)if(BMWindow._windows[t]==this){BMWindow._windows.splice(t,1);break}if(this._minimizedWindow){for(let t=0,e=BMWindow._minimizedWindows.length;t<e;t++)if(BMWindow._minimizedWindows[t]==this._minimizedWindow){BMWindow._minimizedWindows.splice(t,1);break}this._minimizedWindow.remove()}}BMView.prototype.release.call(this),this._cancelLayout(),this._overlay.release(),this._overlay.node.remove(),this.node.remove()}},hide(){this._hidden=YES,this.node.classList.add("BMWindowHidden")},reveal(){this._hidden=NO,this.node.classList.remove("BMWindowHidden")}}),BMToolWindow.prototype=BMExtend(Object.create(BMWindow.prototype),{opensAutomatically:YES,initWithFrame(t,{forWindow:e}){return this._toolWindow=YES,BMWindow.prototype.initWithFrame.call(this,t,{toolbar:YES,modal:NO}),this.node.classList.add("BMToolWindow"),e._toolWindows.push(this),BMWindow._keyWindow==e&&this.bringToFrontAnimated(YES),this},becomeKeyWindow(){},resignKeyWindow(){}}),BMToolWindow.toolWindowWithFrame=function(t,{forWindow:e}){return(new BMToolWindow).initWithFrame(t,{forWindow:e})};const _BMKeyboardShortcutCharacterMap={Backquote:"`",Minus:"-",Equal:"=",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Semicolon:";",Quote:"'",Comma:",",Period:".",Slash:"/",Enter:BMHTMLEntity.Return,Escape:BMHTMLEntity.Escape,Backspace:BMHTMLEntity.Delete},BMKeyboardShortcutModifier=Object.freeze({Command:{key:"metaKey",value:1},Option:{key:"altKey",value:2},Shift:{key:"shiftKey",value:4},Control:{key:"ctrlKey",value:8},System:{key:"systemKey",value:navigator.platform.startsWith("Mac")||/iPhone|iPad|iPod/.test(navigator.platform)?1:8}});function BMKeySequence(){}function BMKeyboardShortcut(){}BMKeySequence.prototype={_keyCode:void 0,get keyCode(){return this._key},_modifiers:void 0,get modifiers(){if(this._modifiers)return this._modifiers.slice()},initWithKeyCode(t,{modifiers:e}={modifiers:[]}){this._key=t,this._modifiers=e?.slice()??[];for(const t of this._modifiers)this._modifierBitmap=this._modifierBitmap|t.value;return this},initWithKeyboardEvent(t){const e=[];return t.shiftKey&&e.push(BMKeyboardShortcutModifier.Shift),t.altKey&&e.push(BMKeyboardShortcutModifier.Option),t.metaKey&&(BMKeyboardShortcutModifier.System.value==BMKeyboardShortcutModifier.Command.value?e.push(BMKeyboardShortcutModifier.System):e.push(BMKeyboardShortcutModifier.Command)),t.ctrlKey&&(BMKeyboardShortcutModifier.System.value==BMKeyboardShortcutModifier.Control.value?e.push(BMKeyboardShortcutModifier.System):e.push(BMKeyboardShortcutModifier.Control)),this.initWithKeyCode(t.code,{modifiers:e})},get HTMLDescription(){let t="";const e=this.keyCode||"";t=e.startsWith("Key")?e.substring(3):e.startsWith("Digit")?e.substring(5):_BMKeyboardShortcutCharacterMap[e]||e;const i=navigator.platform.startsWith("Mac")||/iPhone|iPad|iPod/.test(navigator.platform);return this.modifiers.includes(BMKeyboardShortcutModifier.System)&&(t=i?BMHTMLEntity.Command+t:"Ctrl + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Command)&&(t=i?BMHTMLEntity.Command+t:"Win + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Shift)&&(t=i?BMHTMLEntity.Shift+t:"Shift + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Option)&&(t=i?BMHTMLEntity.Option+t:"Alt + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Control)&&(t=i?BMHTMLEntity.Control+t:"Ctrl + "+t),t}},BMKeySequence.keySequenceWithKeyCode=function(t,e){return(new this).initWithKeyCode(t,e)},BMKeySequence.keySequenceWithKeyboardEvent=function(t){return(new this).initWithKeyboardEvent(t)},BMKeyboardShortcut.prototype={_keySequence:void 0,get keySequence(){return this._keySequence},get keyCode(){return this._keySequence._key},get modifiers(){return this._keySequence._modifiers?this._keySequence._modifiers.slice():[]},_modifierBitmap:0,_target:void 0,get target(){return this._target},set target(t){this._target=t},_action:void 0,get action(){return this._action},set action(t){this._action=t},preventsDefault:NO,initWithKeySequence(t,{target:e,action:i,preventsDefault:o}={}){this._keySequence=t,this._target=e,this._action=i,this.preventsDefault=o||NO;for(const t of this.modifiers)this._modifierBitmap=this._modifierBitmap|t.value;return this},initWithKeyCode(t,{modifiers:e,target:i,action:o,preventsDefault:n}={modifiers:[]}){const s=(new BMKeySequence).initWithKeyCode(t,{modifiers:e});return this._keySequence=s,this.initWithKeySequence(s,{target:i,action:o,preventsDefault:n})},initWithKeyboardEvent(t,{target:e,action:i,preventsDefault:o}={}){const n=(new BMKeySequence).initWithKeyboardEvent(t);return this.initWithKeySequence(n,{target:e,action:i,preventsDefault:o})},initWithSerializedKeyboardShortcut(t,{targetID:e}){if("BMKeyboardShortcut"!=t._class)throw new Error(`Unknown keyboard shortcut class - "${t._class}"`);const i=e(t._targetID),o=Object.values(BMKeyboardShortcutModifier),n=t._modifiers.map((t=>o.find((e=>e.key==t))));return this.initWithKeyCode(t._key,{modifiers:n,target:i,action:t._action,preventsDefault:t._preventsDefault})},serializedKeyboardShortcutWithTargetID(t){return{_class:"BMKeyboardShortcut",_key:this.keyCode,_modifiers:this.modifiers.map((t=>t.key)),_targetID:t,_action:this._action,_preventsDefault:this.preventsDefault}}},BMKeyboardShortcut.keyboardShortcutWithKeySequence=function(t,e){return(new BMKeyboardShortcut).initWithKeySequence(t,e)},BMKeyboardShortcut.keyboardShortcutWithKeyCode=function(t,e){return(new BMKeyboardShortcut).initWithKeyCode(t,e)},BMKeyboardShortcut.keyboardShortcutWithKeyboardEvent=function(t,e){return(new BMKeyboardShortcut).initWithKeyboardEvent(t,e)},BMKeyboardShortcut.keyboardShortcutWithSerializedKeyboardShortcut=function(t,e){return(new BMKeyboardShortcut).initWithSerializedKeyboardShortcut(t,e)};var BMPopoverIndicatorDirection=Object.freeze({Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"});function BMPopover(){}BMPopover.prototype=BMExtend(Object.create(BMWindow.prototype),{_anchorPoint:void 0,get anchorPoint(){return this._anchorPoint},set anchorPoint(t){this._anchorPoint=t},_anchorRect:void 0,get anchorRect(){return this._anchorRect},set anchorRect(t){this._anchorRect=t},_anchorNode:void 0,get anchorNode(){return this._anchorNode},set anchorNode(t){this._anchorNode=t},_size:void 0,get size(){return this._size},set size(t){this._size=t.copy()},_indicatorSize:16,get indicatorSize(){return this._indicatorSize},set indicatorSize(t){this._indicatorSize=t},_borderRadius:8,get borderRadius(){return this._borderRadius},set borderRadius(t){this._borderRadius=t},_edgeInsets:void 0,get edgeInsets(){return this._edgeInsets},set edgeInsets(t){this._edgeInsets=t||BMInsetMakeWithEqualInsets(8),this.isVisible&&this._updatePosition()},_dropShadowContainer:void 0,_dropShadowContent:void 0,_background:void 0,_darkModeFill:void 0,_contentView:void 0,get contentView(){return this._contentView},set contentView(t){this._contentView=t},_clipPathSVG:void 0,_clipPathBackgroundPath:void 0,_clipPathOutlinePath:void 0,_clipPathBoxShadowPath:void 0,_clipPathUUID:void 0,_contentViewTopConstraint:void 0,_contentViewBottomConstraint:void 0,_contentViewLeftConstraint:void 0,_contentViewRightConstraint:void 0,get _indicatorHeight(){return this.indicatorSize*Math.SQRT2/2|0},_permittedDirections:[BMPopoverIndicatorDirection.Bottom,BMPopoverIndicatorDirection.Top,BMPopoverIndicatorDirection.Right,BMPopoverIndicatorDirection.Left],get permittedDirections(){return this._permittedDirections.slice()},set permittedDirections(t){this._permittedDirections=t.slice()},initWithSize(t){const e=BMRectMakeWithOrigin(BMPointMake(),{size:t});BMWindow.prototype.initWithFrame.call(this,e,{modal:YES,toolbar:NO}),this._edgeInsets=BMInsetMakeWithEqualInsets(8),this._size=t.copy(),this.node.className="BMDarkModeAuto BMPopover",this.contentNode.className="BMDarkModeAuto BMPopoverContainer BMPopoverContainerView",this._overlay.node.className="BMPopoverOverlay";const i=document.createElement("div");i.className="BMDarkModeAuto BMPopoverContainerLayer BMPopoverDropShadowContainer";const o=document.createElement("div");o.className="BMDarkModeAuto BMPopoverDropShadowContent",i.appendChild(o);const n=document.createElement("div");n.className="BMDarkModeAuto BMPopoverBackground",n.innerHTML='<div class="BMDarkModeAuto BMPopoverBackgroundDarkModeContainer"><div class="BMDarkModeAuto BMPopoverBackgroundDarkModeOutline"></div><div class="BMDarkModeAuto BMPopoverBackgroundDarkModeFill"></div></div>',this.node.appendChild(n),this.node.appendChild(i),this.node.appendChild(this.contentNode),this._background=n,this._dropShadowContainer=i,this._dropShadowContent=o,this._popoverDarkModeFill=this._background.querySelector(".BMPopoverBackgroundDarkModeFill");const s=this._contentView=BMView.view();return this.addSubview(this._contentView),this._contentViewLeftConstraint=s.left.equalTo(this.left),this._contentViewLeftConstraint.isActive=YES,this._contentViewRightConstraint=s.right.equalTo(this.right),this._contentViewRightConstraint.isActive=YES,this._contentViewTopConstraint=s.top.equalTo(this.top),this._contentViewTopConstraint.isActive=YES,this._contentViewBottomConstraint=s.bottom.equalTo(this.bottom),this._contentViewBottomConstraint.isActive=YES,this},initWithFrame(t){return this.initWithSize(t.size)},colorSchemeDidChange(t){switch(BMWindow.prototype.colorSchemeDidChange.apply(this,arguments),this.colorScheme){case BMViewColorScheme.Light:break;case BMViewColorScheme.Auto:this._dropShadowContainer.classList.add("BMDarkModeAuto"),this._dropShadowContent.classList.add("BMDarkModeAuto"),this._background.classList.add("BMDarkModeAuto"),this._popoverDarkModeFill.classList.add("BMDarkModeAuto"),this._background.querySelector(".BMPopoverBackgroundDarkModeOutline").classList.add("BMDarkModeAuto"),this._background.querySelector(".BMPopoverBackgroundDarkModeContainer").classList.add("BMDarkModeAuto");break;case BMViewColorScheme.Dark:default:throw new Error(`The color scheme ${t} is not supported on this view.`)}},_updatePosition(){const t=BMRectMake();t.size.height=this._size.height+this._indicatorHeight,t.size.width=this._size.width;const e=this.anchorRect||this.anchorNode&&BMRectMakeWithNodeFrame(this.anchorNode),i=this.anchorPoint?this.anchorPoint.copy():e.center;let o,n;switch(o=this.anchorPoint?this._directionAroundPoint(i):this._directionAroundRect(e),o){case BMPopoverIndicatorDirection.Top:t.origin.y=this.anchorPoint?i.y:e.bottom-2,t.origin.x=i.x-t.size.width/2|0,t.origin.x<this._edgeInsets.left&&(t.origin.x=this._edgeInsets.left),t.right>window.innerWidth-this._edgeInsets.right&&(t.origin.x=window.innerWidth-t.size.width-this._edgeInsets.right),this._contentViewTopConstraint.constant=this._indicatorHeight,this._contentViewBottomConstraint.constant=0,this._contentViewLeftConstraint.constant=0,this._contentViewRightConstraint.constant=0;break;case BMPopoverIndicatorDirection.Bottom:t.origin.y=this.anchorPoint?i.y-t.size.height:e.origin.y+2-t.size.height,t.origin.x=i.x-t.size.width/2|0,t.origin.x<this._edgeInsets.left&&(t.origin.x=this._edgeInsets.left),t.right>window.innerWidth-this._edgeInsets.right&&(t.origin.x=window.innerWidth-t.size.width-this._edgeInsets.right),this._contentViewTopConstraint.constant=0,this._contentViewBottomConstraint.constant=-this._indicatorHeight,this._contentViewLeftConstraint.constant=0,this._contentViewRightConstraint.constant=0;break;case BMPopoverIndicatorDirection.Right:t.origin.x=this.anchorPoint?i.x-t.size.width:e.origin.x+2-t.size.width,t.origin.y=i.y-t.size.height/2|0,t.origin.y<this._edgeInsets.top&&(t.origin.y=this._edgeInsets.top),t.bottom>window.innerHeight-this._edgeInsets.bottom&&(t.origin.y=window.innerHeight-t.size.height-this._edgeInsets.bottom),this._contentViewTopConstraint.constant=0,this._contentViewBottomConstraint.constant=0,this._contentViewLeftConstraint.constant=0,this._contentViewRightConstraint.constant=-this._indicatorHeight;break;case BMPopoverIndicatorDirection.Left:t.origin.x=this.anchorPoint?i.x:e.right-2,t.origin.y=i.y-t.size.height/2|0,t.origin.y<this._edgeInsets.top&&(t.origin.y=this._edgeInsets.top),t.bottom>window.innerHeight-this._edgeInsets.bottom&&(t.origin.y=window.innerHeight-t.size.height-this._edgeInsets.bottom),this._contentViewTopConstraint.constant=0,this._contentViewBottomConstraint.constant=0,this._contentViewLeftConstraint.constant=this._indicatorHeight,this._contentViewRightConstraint.constant=0}switch(this.frame=t,o){case BMPopoverIndicatorDirection.Bottom:case BMPopoverIndicatorDirection.Top:n=BMNumberByConstrainingNumberToBounds(i.x-t.origin.x,12,t.size.width-12);break;case BMPopoverIndicatorDirection.Left:case BMPopoverIndicatorDirection.Right:n=BMNumberByConstrainingNumberToBounds(i.y-t.origin.y,12,t.size.height-12)}const s=t.copy();s.origin=BMPointMake();const a=`${this._pathForPopoverWithFrame(s,{indicatorSize:this._indicatorSize,position:n,direction:o,radius:this._borderRadius})}`,r=`${this._pathForPopoverWithFrame(s,{indicatorSize:this._indicatorSize,inset:1,position:n,direction:o,radius:this._borderRadius-1.5})}`,l=`${this._pathForPopoverWithFrame(s,{indicatorSize:this._indicatorSize,position:n,direction:o,radius:this._borderRadius+1.5})}`;if(!this._clipPathUUID&&!CSS.supports("clip-path",`path('${a}')`)){this._clipPathUUID=BMUUIDMake(),this._clipPathSVG=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._clipPathSVG.style.width="0",this._clipPathSVG.style.height="0";const t=document.createElementNS("http://www.w3.org/2000/svg","clipPath");t.setAttribute("id","popover-clip-path-"+this._clipPathUUID),t.setAttribute("clipPathUnits","userSpaceOnUse"),this._clipPathBackgroundPath=document.createElementNS("http://www.w3.org/2000/svg","path"),t.appendChild(this._clipPathBackgroundPath),this._clipPathSVG.appendChild(t);const e=document.createElementNS("http://www.w3.org/2000/svg","clipPath");e.setAttribute("id","popover-outline-clip-path-"+this._clipPathUUID),e.setAttribute("clipPathUnits","userSpaceOnUse"),this._clipPathOutlinePath=document.createElementNS("http://www.w3.org/2000/svg","path"),e.appendChild(this._clipPathOutlinePath),this._clipPathSVG.appendChild(e);const i=document.createElementNS("http://www.w3.org/2000/svg","clipPath");i.setAttribute("id","popover-box-shadow-clip-path-"+this._clipPathUUID),i.setAttribute("clipPathUnits","userSpaceOnUse"),this._clipPathBoxShadowPath=document.createElementNS("http://www.w3.org/2000/svg","path"),i.appendChild(this._clipPathBoxShadowPath),this._clipPathSVG.appendChild(i),document.body.appendChild(this._clipPathSVG)}this._clipPathUUID&&(this._clipPathBackgroundPath.setAttribute("d",a),this._clipPathOutlinePath.setAttribute("d",r),this._clipPathBoxShadowPath.setAttribute("d",l));const h=this._clipPathUUID?`url(#popover-clip-path-${this._clipPathUUID})`:`path('${a}')`,c=this._clipPathUUID?`url(#popover-outline-clip-path-${this._clipPathUUID})`:`path('${r}')`,d=this._clipPathUUID?`url(#popover-box-shadow-clip-path-${this._clipPathUUID})`:`path('${l}')`,u={left:s.origin.x+"px",top:s.origin.y+"px",width:s.size.width+"px",height:s.size.height+"px"};BMCopyProperties(this.contentNode.style,u),BMCopyProperties(this._background.style,u),this._background.style.clipPath=h,this._background.style.webkitClipPath=h;const p=this._background.querySelector(".BMPopoverBackgroundDarkModeFill");p.style.clipPath=c,p.style.webkitClipPath=c,BMCopyProperties(this._dropShadowContainer.style,u),this._dropShadowContent.style.clipPath=d,this._dropShadowContent.style.webkitClipPath=d;const g=[this.contentNode,this._background,this._dropShadowContainer];let w,y;switch(o){case BMPopoverIndicatorDirection.Bottom:w=n/this.frame.size.width*100+"%",y="100%";break;case BMPopoverIndicatorDirection.Top:w=n/this.frame.size.width*100+"%",y="0%";break;case BMPopoverIndicatorDirection.Left:w="0%",y=n/this.frame.size.height*100+"%";break;case BMPopoverIndicatorDirection.Right:w="100%",y=n/this.frame.size.height*100+"%"}for(const t of g)t.style.transformOrigin=`${w} ${y}`},_directionAroundPoint(t){for(const e of this._permittedDirections)switch(e){case BMPopoverIndicatorDirection.Top:if(t.y<window.innerHeight-this.size.height-this._indicatorHeight)return BMPopoverIndicatorDirection.Top;break;case BMPopoverIndicatorDirection.Bottom:if(t.y>this.size.height+this._indicatorHeight)return BMPopoverIndicatorDirection.Bottom;break;case BMPopoverIndicatorDirection.Right:if(t.x>this.size.width+this._indicatorHeight)return BMPopoverIndicatorDirection.Right;break;case BMPopoverIndicatorDirection.Left:if(t.x<window.innerWidth-this.size.width-this._indicatorHeight)return BMPopoverIndicatorDirection.Left}return this._permittedDirections[0]},_directionAroundRect(t){for(const e of this._permittedDirections)switch(e){case BMPopoverIndicatorDirection.Top:if(t.bottom<window.innerHeight-this.size.height-this._indicatorHeight)return BMPopoverIndicatorDirection.Top;break;case BMPopoverIndicatorDirection.Bottom:if(t.top>this.size.height+this._indicatorHeight)return BMPopoverIndicatorDirection.Bottom;break;case BMPopoverIndicatorDirection.Right:if(t.left>this.size.width+this._indicatorHeight)return BMPopoverIndicatorDirection.Right;break;case BMPopoverIndicatorDirection.Left:if(t.right<window.innerWidth-this.size.width-this._indicatorHeight)return BMPopoverIndicatorDirection.Left}return this._permittedDirections[0]},_pathForPopoverWithFrame(t,{indicatorSize:e=8,radius:i=8,inset:o=0,position:n,direction:s=BMPopoverIndicatorDirection.Top}={indicatorSize:8,radius:4,inset:0}){let a=s===BMPopoverIndicatorDirection.Top?e*Math.SQRT2/2|0:0,r=s==BMPopoverIndicatorDirection.Left?e*Math.SQRT2/2|0:0,l=s===BMPopoverIndicatorDirection.Bottom?t.size.height-e*Math.SQRT2/2|0:t.size.height,h=s==BMPopoverIndicatorDirection.Right?t.size.width-e*Math.SQRT2/2|0:t.size.width;o&&(e-=o,(t=t.copy()).insetWithInset(BMInsetMakeWithEqualInsets(o)),i+=o,a+=o,r+=o,l-=o,h-=o),n=void 0===n?t.size.width/2|0:n-o|0;const c=e*Math.SQRT2,d=c/2|0;let u=s===BMPopoverIndicatorDirection.Top?`M${r+i},${a} L${n-c/2+r},${a} l${c/2},${-d} l${c/2},${d} L${h-i},${a} `:`M${r+i},${a} L${h-i},${a} `;return u+=s==BMPopoverIndicatorDirection.Right?`Q${h},${a} ${h},${a+i} L${h},${n-c/2+a} l${d},${c/2} l${-d},${c/2} L${h},${l-i} `:`Q${h},${a} ${h},${a+i} L${h},${l-i} `,u+=s===BMPopoverIndicatorDirection.Bottom?`Q${h},${l} ${h-i},${l} L${n+c/2+r},${l} l${-c/2},${d} l${-c/2},${-d} L${r+i},${l} `:`Q${h},${l} ${h-i},${l} L${r+i},${l} `,u+=s===BMPopoverIndicatorDirection.Left?`Q${r},${l} ${r},${l-i} L${r},${n+c/2+a} l${-d},${-c/2} l${d},${-c/2} L${r},${a+i} Q${r},${a} ${r+i},${a} Z`:`Q${r},${l} ${r},${l-i} L${r},${a+i} Q${r},${a} ${r+i},${a} Z`,u},animateInWithCompletionHandler(t){const e=[this.contentNode,this._background,this._dropShadowContainer];this.node.style.opacity=1;let i=YES;for(const o of e)BMHook(o,{scaleX:.75,scaleY:.75,opacity:0}),__BMVelocityAnimate(o,{scaleX:1,scaleY:1,opacity:1},{duration:300,easing:[0,1.59,.49,1],complete:i?t:void 0},YES),i=NO},animateOutWithCompletionHandler(t){const e=[this.contentNode,this._background,this._dropShadowContainer],i=this;let o=YES;for(const n of e){n.style.pointerEvents="none";const e=o;__BMVelocityAnimate(n,{scaleX:.9,scaleY:.9,opacity:0},{duration:200,easing:"easeInOutQuart",complete(){e&&(i.node.style.opacity=0,t())}},YES),o=NO}},bringToFrontAnimated(t,e){if(!this.anchorNode&&!this.anchorPoint&&!this.anchorRect)throw new Error("The anchorPoint, anchorRect or anchorNode must be set prior to showing this popover.");this._updatePosition(),BMWindow.prototype.bringToFrontAnimated.apply(this,arguments)},release(){return this._clipPathUUID&&this._clipPathSVG.remove(),BMWindow.prototype.release.apply(this,arguments)}}),BMPopover.popoverWithSize=function(t){return(new BMPopover).initWithSize(t)};const BMConfirmationPopupResult=Object.freeze({Undecided:{},Cancelled:{},Declined:{},Confirmed:{}});function BMAlertPopup(){}function BMConfirmationPopup(){}BMAlertPopup.prototype=BMExtend(Object.create(BMWindow.prototype),{_result:BMConfirmationPopupResult.Undecided,get result(){return this._result},_resolution:void 0,get resolution(){return this._resolution},_resolve:void 0,_title:void 0,get title(){return this._title},set title(t){t!=this._title&&(this._title=t,this._titleView&&(this._titleView.node.innerText=t,this._titleView.invalidateIntrinsicSize()))},_text:void 0,get text(){return this._text},set text(t){t!=this._text&&(this._text=t,this._textView&&(this._textView.node.innerText=t,this._textView.invalidateIntrinsicSize()))},get HTML(){return this._text},set HTML(t){t!=this._text&&(this._text=t,this._textView&&(this._textView.node.innerHTML=t,this._textView.invalidateIntrinsicSize()))},_positiveActionText:void 0,get positiveActionText(){return this._positiveActionText},set positiveActionText(t){t!=this._positiveActionText&&(this._positiveActionText=t,this._positiveActionButton&&(this._positiveActionButton.node.innerText=t,this._positiveActionButton.invalidateIntrinsicSize()))},get frameSizePriority(){return 1},get frameHorizontalPositionLayoutAttribute(){return BMLayoutAttribute.CenterX},get frameVerticalPositionLayoutAttribute(){return BMLayoutAttribute.CenterY},_previouslyActiveNode:void 0,_centerHandler:void 0,initWithTitle(t,{text:e,actionText:i="OK"}){const o=BMRectMake(0,0,0,0);BMWindow.prototype.initWithFrame.call(this,o),this.contentView.contentNode.classList.add("BMWindowBackground"),this._resolution=new Promise((t=>{this._resolve=t})),this._title=t,this._text=e,this._positiveActionText=i,this._titleView=BMView.view(),this._titleView.supportsAutomaticIntrinsicSize=YES,this._titleView.node.classList.add("BMTitle"),this._titleView.node.innerText=t,this.contentView.addSubview(this._titleView),this._titleView.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,this._titleView.top.equalTo(this.contentView.top,{plus:32}).isActive=YES,this._titleView.trailing.lessThanOrEqualTo(this.contentView.trailing,{plus:-32}).isActive=YES,this._textView=BMView.view(),this._textView.supportsAutomaticIntrinsicSize=YES,this._textView.node.classList.add("BMLabel"),this._textView.node.innerText=e,this.contentView.addSubview(this._textView),this._textView.leading.equalTo(this._titleView.leading).isActive=YES,this._textView.top.equalTo(this._titleView.bottom,{plus:32}).isActive=YES,this._textView.trailing.lessThanOrEqualTo(this.contentView.trailing,{plus:-32}).isActive=YES,this._positiveActionButton=BMView.view(),this._positiveActionButton.supportsAutomaticIntrinsicSize=YES,this._positiveActionButton.node.classList.add("BMButton"),this._positiveActionButton.node.innerText=i,this.contentView.addSubview(this._positiveActionButton),this._positiveActionButton.trailing.equalTo(this.contentView.trailing,{plus:-32}).isActive=YES,this._positiveActionButton.bottom.equalTo(this.contentView.bottom,{plus:-32}).isActive=YES,this._positiveActionButton.top.equalTo(this._textView.bottom,{plus:64}).isActive=YES,this._positiveActionButton.node.addEventListener("click",(t=>this._confirm())),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Enter",{target:this,action:"_confirm"}));const n=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Escape",{target:this,action:"_escape"});return n.preventsDefault=YES,this.registerKeyboardShortcut(n),this._previouslyActiveNode=document.activeElement,this},_escape(){this._confirm()},_confirm(){this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Confirmed,this._resolve(BMConfirmationPopupResult.Confirmed),this.dismissAnimated(YES))},confirm(){return this.bringToFrontAnimated(YES),this._resolution},bringToFrontAnimated(){return this._resizeHandler=()=>this.needsLayout=YES,window.addEventListener("resize",this._resizeHandler),BMWindow.prototype.bringToFrontAnimated.apply(this,arguments)},dismissAnimated(){return this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Confirmed,this._resolve(BMConfirmationPopupResult.Confirmed)),this._previouslyActiveNode&&this._previouslyActiveNode.focus(),window.removeEventListener("resize",this._resizeHandler),BMWindow.prototype.dismissAnimated.apply(this,arguments)},windowDidClose(){this.release()}}),BMAlertPopup.alertPopupWithTitle=function(t,{text:e,actionText:i="OK"}){return(new BMAlertPopup).initWithTitle(t,{text:e,actionText:i})},BMConfirmationPopup.prototype=BMExtend(Object.create(BMAlertPopup.prototype),{_negativeActionText:void 0,get negativeActionText(){return this._negativeActionText},set negativeActionText(t){t!=this._negativeActionText&&(this._negativeActionText=t,this._negativeActionButton&&(this._negativeActionButton.node.innerText=t,this._negativeActionButton.invalidateIntrinsicSize()))},_showsCancelButton:NO,get showsCancelButton(){return this._showsCancelButton},set showsCancelButton(t){this._showsCancelButton=t,this._cancelButton&&(this._cancelButton.isVisible=t)},initWithTitle(t,{text:e,positiveActionText:i,negativeActionText:o}){return BMAlertPopup.prototype.initWithTitle.call(this,t,{text:e,actionText:i}),this._negativeActionText=o,this._negativeActionButton=BMView.view(),this._negativeActionButton.supportsAutomaticIntrinsicSize=YES,this._negativeActionButton.node.classList.add("BMButton","BMButtonWeak"),this._negativeActionButton.node.innerText=o,this.contentView.addSubview(this._negativeActionButton),this._negativeActionButton.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,this._negativeActionButton.bottom.equalTo(this.contentView.bottom,{plus:-32}).isActive=YES,this._negativeActionButton.top.equalTo(this._textView.bottom,{plus:64}).isActive=YES,this._negativeActionButton.node.addEventListener("click",(t=>this._decline())),this._cancelButton=BMView.view(),this._cancelButton.supportsAutomaticIntrinsicSize=YES,this._cancelButton.node.classList.add("BMButton","BMButtonWeak"),this._cancelButton.node.innerText="Cancel",this._cancelButton.isVisible=NO,this.contentView.addSubview(this._cancelButton),this._cancelButton.trailing.equalTo(this._positiveActionButton.leading,{plus:-32}).isActive=YES,this._cancelButton.bottom.equalTo(this.contentView.bottom,{plus:-32}).isActive=YES,this._cancelButton.top.equalTo(this._textView.bottom,{plus:64}).isActive=YES,this._cancelButton.leading.greaterThanOrEqualTo(this._negativeActionButton.trailing,{plus:64}).isActive=YES,this._cancelButton.node.addEventListener("click",(t=>this._cancel())),this},_escape(){this._showsCancelButton?this._cancel():this._decline()},_decline(){this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Declined,this._resolve(BMConfirmationPopupResult.Declined),this.dismissAnimated(YES))},_cancel(){this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Cancelled,this._resolve(BMConfirmationPopupResult.Cancelled),this.dismissAnimated(YES))},dismissAnimated(){return this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Cancelled,this._resolve(BMConfirmationPopupResult.Cancelled)),this._previouslyActiveNode&&this._previouslyActiveNode.focus(),BMWindow.prototype.dismissAnimated.apply(this,arguments)}}),BMConfirmationPopup.confirmationPopupWithTitle=function(t,{text:e,positiveActionText:i,negativeActionText:o}){return(new BMConfirmationPopup).initWithTitle(t,{text:e,positiveActionText:i,negativeActionText:o})};var BMCodeEditorLanguage=Object.freeze({Javascript:"javascript",CSS:"css",JSON:"json",Typescript:"typescript"});function BMCodeEditor(){}function BMCodeMirrorCodeEditor(){}function BMCodeMirrorCodeEditorMakeWithContainer(t,e){return(new BMCodeMirrorCodeEditor).initWithContainer(t,{code:e&&e.code,language:e&&e.language})}function BMMonacoCodeEditor(){}BMCodeEditor.prototype={_container:void 0,get container(){return this._container},delegate:void 0,initWithContainer:function(t){return this._container=t,this},get code(){},set code(t){},get requiresTranspilation(){return NO},async transpiledCode(){return this.code},get cursorPosition(){},set cursorPosition(t){},supportsExtensibleAutocomplete:NO,setBuiltinES6Library:function(t,e){},setImports(t){},addExternalLibraryNamed(t,e){},removeExternalLibraryNamed(t){},hasExternalLibraryNamed:t=>NO,get scope(){},set scope(t){},insertText:function(t){},acquireFocus:function(){},resignFocus:function(){},resized:function(){},release:function(){}},BMExtend(BMCodeMirrorCodeEditor.prototype,BMCodeEditor.prototype,{_codeMirror:void 0,initWithContainer:function(t,e){BMCodeEditor.prototype.initWithContainer.call(this,t),this._codeMirror=CodeMirror(this.container,{mode:e&&e.language||BMCodeEditorLanguage.Javascript,theme:"eclipse",lineNumbers:YES,firstLineNumber:0,matchBrackets:YES,extraKeys:{"Ctrl-Q":function(t){cm.foldCode(cm.getCursor())},"Ctrl-S":function(t){}},foldGutter:!0,gutters:["CodeMirror-lint-markers","CodeMirror-foldgutter"],indentUnit:4}),this.container.querySelectorAll(".CodeMirror")[0].style.height="100%";var i=this;this._codeMirror.on("change",(function(){i.delegate&&i.delegate.codeEditorContentsDidChange&&i.delegate.codeEditorContentsDidChange(i)}));var o=e&&e.code;return o?(this.code=o,this):this},get code(){return this._codeMirror.getValue()},set code(t){this._codeMirror.setValue(t)},get cursorPosition(){var t=this._codeMirror.getCursor();return BMPointMake(t.ch,t.line)},set cursorPosition(t){this._codeMirror.setCursor({ch:t.x,line:t.y}),this._codeMirror.scrollIntoView({ch:0,line:t.y})},insertText:function(t){var e=this._codeMirror.getDoc(),i=this._codeMirror.getCursor();e.replaceRange(t,i)},acquireFocus:function(){this._codeMirror.focus()},resignFocus:function(){},resized:function(){this._codeMirror.refresh()}});var _BMMonacoCodeEditorThemesCreated=NO;function BMMonacoCodeEditorMakeWithContainer(t,e){return(new BMMonacoCodeEditor).initWithContainer(t,{code:e&&e.code,language:e&&e.language})}BMMonacoCodeEditor.createThemes=function(){_BMMonacoCodeEditorThemesCreated||(_BMMonacoCodeEditorThemesCreated=YES,monaco.editor.defineTheme("BMMonacoCodeEditorTheme",{base:"vs",inherit:YES,colors:[],rules:[{token:"comment",foreground:"CCCCCC"},{token:"string",foreground:"BC670F",background:"FDFBF3"},{token:"keyword",foreground:"6700B9"},{token:"type",foreground:"6700B9"},{token:"identifier",foreground:"434343"},{token:"delimiter",foreground:"434343"},{token:"number",foreground:"7552c1",background:"E7E6FD"},{token:"tag",foreground:"434343"},{token:"attribute.name",foreground:"D4430D"},{token:"attribute.value",foreground:"43A202"},{token:"attribute.value.number",foreground:"5AA201",background:"F6FAEB"},{token:"attribute.value.unit",foreground:"5AA201",background:"F6FAEB"},{token:"attribute.value.hex",foreground:"43A202"},{token:"tag.css",foreground:"3A77BF"}]}),monaco.editor.defineTheme("BMMonacoCodeEditorThemeDark",{base:"vs-dark",inherit:YES,colors:[],rules:[{token:"comment",foreground:"555555"},{token:"string",foreground:"ee9452",background:"FDFBF3"},{token:"keyword",foreground:"a349f5"},{token:"type",foreground:"a349f5"},{token:"identifier",foreground:"bcbcbc"},{token:"delimiter",foreground:"bcbcbc"},{token:"number",foreground:"a37df1",background:"E7E6FD"},{token:"tag",foreground:"bcbcbc"},{token:"attribute.name",foreground:"ff7b41"},{token:"attribute.value",foreground:"80dc4c"},{token:"attribute.value.number",foreground:"92d94b",background:"F6FAEB"},{token:"attribute.value.unit",foreground:"92d94b",background:"F6FAEB"},{token:"attribute.value.hex",foreground:"80dc4c"},{token:"tag.css",foreground:"5fa1ec"}]}))},BMExtend(BMMonacoCodeEditor.prototype,BMCodeEditor.prototype,{_monaco:void 0,_autocompleteLibraries:void 0,_rootES6Library:void 0,_rootjQueryLibrary:void 0,_importsLibrary:void 0,_externalLibraries:void 0,_language:void 0,_darkModeQuery:void 0,_darkModeQueryCallback:void 0,initWithContainer:function(t,e){BMCodeEditor.prototype.initWithContainer.call(this,t),BMMonacoCodeEditor.createThemes();var i={folding:YES,fontLigatures:NO,formatOnPaste:YES,mouseWheelZoom:YES,scrollBeyondLastLine:YES,value:e&&e.code,language:e&&e.language||BMCodeEditorLanguage.Javascript,fontFamily:"Menlo, Meslo LG S, Fira Code, Monaco, monospace",theme:window.matchMedia("(prefers-color-scheme: dark)").matches?"BMMonacoCodeEditorThemeDark":"BMMonacoCodeEditorTheme",disableLayerHinting:YES};this._language=e.language||BMCodeEditorLanguage.Javascript,monaco.languages.typescript.javascriptDefaults.setCompilerOptions({target:monaco.languages.typescript.ScriptTarget.ESNext,allowNonTsExtensions:YES,experimentalDecorators:YES,strict:YES,inlineSourceMap:YES,module:monaco.languages.typescript.ModuleKind.ES2015,noImplicitUseStrict:YES}),monaco.languages.typescript.typescriptDefaults.setCompilerOptions({target:monaco.languages.typescript.ScriptTarget.ESNext,allowNonTsExtensions:YES,experimentalDecorators:YES,strict:YES,inlineSourceMap:YES,inlineSources:YES,noImplicitUseStrict:YES,alwaysStrict:NO,module:monaco.languages.typescript.ModuleKind.ES2015,useDefineForClassFields:NO}),this._monaco=monaco.editor.create(t,i);var o=this;return this._monaco.onDidChangeModelContent((function(t){o.delegate&&o.delegate.codeEditorContentsDidChange&&o.delegate.codeEditorContentsDidChange(o)})),this._externalLibraries={},this._darkModeQueryCallback=t=>{t.matches?monaco.editor.setTheme("BMMonacoCodeEditorThemeDark"):monaco.editor.setTheme("BMMonacoCodeEditorTheme")},this._darkModeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this._darkModeQuery.addListener(this._darkModeQueryCallback),this},setBuiltinES6Library:function(t,e){this._language===BMCodeEditorLanguage.Javascript?(this._rootES6Library=monaco.languages.typescript.javascriptDefaults.addExtraLib(t,"ES6.d.ts"),this._rootjQueryLibrary=monaco.languages.typescript.javascriptDefaults.addExtraLib(e.jQueryLibrary,"jQuery.d.ts"),e.additionalLibraries?this._autocompleteLibraries=monaco.languages.typescript.javascriptDefaults.addExtraLib(e.additionalLibraries.join("\n"),"additional.d.ts"):(this._autocompleteLibraries&&this._autocompleteLibraries.dispose(),this._autocompleteLibraries=void 0)):(this._rootES6Library=monaco.languages.typescript.typescriptDefaults.addExtraLib(t,"ES6.d.ts"),this._rootjQueryLibrary=monaco.languages.typescript.typescriptDefaults.addExtraLib(e.jQueryLibrary,"jQuery.d.ts"),e.additionalLibraries?this._autocompleteLibraries=monaco.languages.typescript.typescriptDefaults.addExtraLib(e.additionalLibraries.join("\n"),"additional.d.ts"):(this._autocompleteLibraries&&this._autocompleteLibraries.dispose(),this._autocompleteLibraries=void 0))},setImports(t){this._language===BMCodeEditorLanguage.Javascript?this._importsLibrary=monaco.languages.typescript.javascriptDefaults.addExtraLib(t,"node_modules/@types/imports/index.d.ts"):this._importsLibrary=monaco.languages.typescript.typescriptDefaults.addExtraLib(t,"node_modules/@types/imports/index.d.ts")},addExternalLibraryNamed(t,e){this._language===BMCodeEditorLanguage.Javascript?this._externalLibraries[t]=monaco.languages.typescript.javascriptDefaults.addExtraLib(e.code,"node_modules/@types/"+t):this._externalLibraries[t]=monaco.languages.typescript.typescriptDefaults.addExtraLib(e.code,"node_modules/@types/"+t)},removeExternalLibraryNamed(t){this._externalLibraries[t]&&(this._externalLibraries[t].dispose(),delete this._externalLibraries[t])},hasExternalLibraryNamed(t){return t in this._externalLibraries},get code(){return this._monaco.getValue()},set code(t){this._monaco.setValue(t)},get requiresTranspilation(){return this._language===BMCodeEditorLanguage.Typescript},transpiledCode(){return new Promise(((t,e)=>{let i;i=monaco.languages.typescript.getLanguageWorker?monaco.languages.typescript.getLanguageWorker("typescript"):monaco.languages.typescript.getTypeScriptWorker(),i.then((e=>{this._monaco.getModel()&&e(this._monaco.getModel().uri).then((e=>{this._monaco.getModel()&&e.getEmitOutput(this._monaco.getModel().uri.toString()).then((function(e){t(e.outputFiles[0].text)}))}))}))}))},get cursorPosition(){var t=this._monaco.getSelection();return BMPointMake(t.startColumn,t.startLineNumber)},set cursorPosition(t){var e=new monaco.Range(t.y,t.x,t.y,t.x);this._monaco.setSelection(e),this._monaco.revealPositionInCenter({lineNumber:t.y,column:t.x})},insertText:function(t){this._monaco.executeEdits("insertSnippet",[{range:this._monaco.getSelection(),text:t,forceMoveMarkers:!0}])},acquireFocus:function(){this._monaco.focus()},resignFocus:function(){},resized:function(){this._monaco.layout()},get supportsExtensibleAutocomplete(){return YES},get scope(){return this._scope},set scope(t){this._scope=t,this._language===BMCodeEditorLanguage.Javascript?this._autocompleteLibrary=monaco.languages.typescript.javascriptDefaults.addExtraLib(t,"BMMonacoCodeEditor.d.ts"):this._autocompleteLibrary=monaco.languages.typescript.typescriptDefaults.addExtraLib(t,"BMMonacoCodeEditor.d.ts")},release:function(){this._monaco.dispose(),this._autocompleteLibrary&&this._autocompleteLibrary.dispose(),this._autocompleteLibraries&&this._autocompleteLibraries.dispose(),this._rootES6Library&&this._rootES6Library.dispose(),this._rootjQueryLibrary&&this._rootjQueryLibrary.dispose(),this._importsLibrary&&this._importsLibrary.dispose(),this._darkModeQuery.removeListener(this._darkModeQueryCallback),Object.keys(this._externalLibraries).forEach((t=>this._externalLibraries[t].dispose()))}});_BMWindowAnimationDurationDefault=400,_BMWindowAnimationEasingDefault="easeInOutQuart";let BM_LAYOUT_EDITOR_USE_SETTINGS_VIEW=NO;const BM_LAYOUT_EDITOR_AUTO_CONSTRAINT_MARGIN=16,BM_LAYOUT_EDITOR_AUTO_CONSTRAINT_SPACING=64,_BMLayoutEditorToolbarHeight=32;function BMLayoutEditor(){}function BMViewLayoutEditor(){this._useSettingsView=YES}function _BMLayoutEditorTree(){}BMLayoutEditor.prototype=BMExtend(Object.create(BMWindow.prototype),{_view:void 0,get view(){return this._view},_settingsView:void 0,isCreatingTouchConstraints:NO,_dismissAnimated(t,e){var i;(e=e||{}).completionHandler&&(i=e.completionHandler);let o=this._view.node.cloneNode(YES),n=this._view.node.parentNode;return this._view.layoutEditor=void 0,this._rootNode.appendChild(this._view.node),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove())),this._view.allSubviews.forEach((t=>t.node.classList.remove("BMLayoutEditorManagedView"))),this._view.layout(),n.appendChild(o),e.completionHandler=()=>{i&&i()},window.removeEventListener("resize",this.resizeListener),BMWindow.prototype.dismissAnimated.call(this,t,e)},frameForDescendant(t){let e=BMView.prototype.frameForDescendant.apply(this,arguments);return t==this.workspaceWrapperView&&(this._staticWorkspaceSize?(this._staticWorkspaceWidth=this._staticWorkspaceSize.width,this._staticWorkspaceHeight=this._staticWorkspaceSize.height):(this._staticWorkspaceWidth=e.size.width,this._staticWorkspaceHeight=e.size.height),this._view.layout()),e},_panOffset:BMPointMake(),get panOffset(){return this._panOffset.copy()},set panOffset(t){if(t=t.copy(),this._panOffset=t,BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this.workspace,{node:this.workspace.node}).registerBuiltInPropertiesWithDictionary({translateX:t.x+"px",translateY:t.y+"px"})}else BMHook(this.workspace.node,{translateX:t.x+"px",translateY:t.y+"px"})},_useSettingsView:NO,initWithView(t,e){this._view=t,this._rootNode=t.node.parentNode,this._view.layoutEditor=this,this.layoutVariableProvider=e&&e.layoutVariableProvider||BMView,this.layoutVariableProvider.prepareLayoutVariables(),this._settingCellClasses={},this.resizeListener=e=>t.needsLayout=YES,window.addEventListener("resize",this.resizeListener),t.allSubviews.forEach((t=>{this._prepareView(t)}));let i=BMRectMake(0,0,document.documentElement.clientWidth,document.documentElement.clientHeight);BMWindow.prototype.initWithFrame.call(this,i,{toolbar:NO}),this._node.classList.add("BMLayoutEditor"),this._overlay._node.classList.add("BMLayoutEditorBlocker"),window.addEventListener("resize",(t=>{var e=document.documentElement.clientWidth,i=document.documentElement.clientHeight;this.frame=BMRectMake(0,0,e,i)})),this.content.style.backgroundColor="rgba(255, 255, 255, .8)";var o=document.createElement("div");if(o.classList.add("BMLayoutEditorTree"),this.treeNode=o,"backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(o.style.backgroundColor="#F8F8F8"),this.content.appendChild(o),this.tree=_BMLayoutEditorTree.editorTreeWithView(t,{node:o,editor:this}),this._useSettingsView){const t=BMRectMake(64,120,320,window.innerHeight-56-280),e=BMToolWindow.toolWindowWithFrame(t,{forWindow:this});e.addSubview(this.tree),this._treeWindow=e,e.opensAutomatically=NO,this.tree.left.equalTo(e.left).isActive=YES,this.tree.right.equalTo(e.right).isActive=YES,this.tree.top.equalTo(e.top).isActive=YES,this.tree.bottom.equalTo(e.bottom).isActive=YES;const i=document.createElement("div");i.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorCloseButton BMLayoutEditorFullscreen BMLayoutEditorDetailsCloseButton",i.innerHTML='<i class="material-icons">&#xE5CD;</i>',i.style.opacity="1",i.style.pointerEvents="all",i.addEventListener("click",(t=>e.dismissAnimated(YES))),e.node.appendChild(i),e.node.classList.add("BMLayoutEditorDetailsWindow"),e.toolbar.style.height="64px",e.width.greaterThanOrEqualTo(320).isActive=YES,e.height.greaterThanOrEqualTo(320).isActive=YES}else this.addSubview(this.tree);if(!this._useSettingsView){let t=document.createElement("div");t.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorCloseButton BMLayoutEditorFullscreen",t.innerHTML='<i class="material-icons">&#xE5CD;</i>',t.style.opacity=1,t.style.pointerEvents="all",t.addEventListener("click",(t=>this.dismissAnimated(YES,{toNode:this._returnNode}))),this.content.appendChild(t)}this._initKeyboardShortcuts();var n=document.createElement("div");n.className="BMLayoutEditorWorkspaceArea",this.content.appendChild(n),this.workspaceArea=n,this.workspaceView=BMView.viewForNode(n),this.addSubview(this.workspaceView);var s=document.createElement("div");s.className="BMLayoutEditorWorkspaceToolbar"+(this._useSettingsView?" BMWindowToolbarMini":""),n.appendChild(s),this._initToolbar(s),this.workspaceToolbar=s,this.workspaceToolbarView=BMView.viewForNode(s),this.workspaceView.addSubview(this.workspaceToolbarView);var a=document.createElement("div");a.className="BMLayoutEditorWorkspaceWrapper",n.appendChild(a),this.workspaceWrapperView=BMView.viewForNode(a),this.workspaceView.addSubview(this.workspaceWrapperView);var r=document.createElement("div");r.className="BMLayoutEditorWorkspace",a.appendChild(r),this.workspaceNode=r,this.workspace=BMView.viewForNode(r),this.workspaceWrapperView.addSubview(this.workspace),BMAddSmoothMousewheelInteractionToNode(a),this._initWorkspaceGestures(),this.panOffset=BMPointMake();let l=document.createElement("div");if(l.className="BMLayoutEditorDetails",this.detailsNode=l,this.detailsView=this._useSettingsView?_BMLayoutEditorSettingsView.settingsViewWithNode(l,{forEditor:this}):BMView.viewForNode(l),this._useSettingsView){l.classList.add("BMLayoutEditorDetailsView");const t=BMRectMake(window.innerWidth-64-384,120,360,Math.min(window.innerHeight-56-128,576)),e=BMToolWindow.toolWindowWithFrame(t,{forWindow:this});e.addSubview(this.detailsView),this.detailsView.left.equalTo(e.left).isActive=YES,this.detailsView.right.equalTo(e.right).isActive=YES,this.detailsView.top.equalTo(e.top).isActive=YES,this.detailsView.bottom.equalTo(e.bottom).isActive=YES,this.detailsView._window=e,e.delegate=this.detailsView,e.node.classList.add("BMLayoutEditorDetailsWindow");const i=document.createElement("div");i.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorCloseButton BMLayoutEditorFullscreen BMLayoutEditorDetailsCloseButton",i.innerHTML='<i class="material-icons">&#xE5CD;</i>',i.style.opacity="1",i.style.pointerEvents="all",i.addEventListener("click",(t=>{this.detailsView._dismissedByUser=YES,e.dismissAnimated(YES,{toRect:BMRectMakeWithNodeFrame(this._inspectorButton)})})),e.node.appendChild(i),e.toolbar.style.height="64px",e.opensAutomatically=NO,e.width.greaterThanOrEqualTo(320).isActive=YES,e.height.greaterThanOrEqualTo(320).isActive=YES,this._detailsToolWindow=e}else{this.content.appendChild(l),this.addSubview(this.detailsView);let t=document.createElement("div");t.className="BMWindowTitle",l.appendChild(t),this.detailsNodeTitle=t;let e=document.createElement("div");e.className="BMLayoutEditorDetailsContent",l.appendChild(e),this.detailsNodeContent=e}this._useSettingsView||(this.tree.top.equalTo(this.top).isActive=YES,this.tree.bottom.equalTo(this.bottom).isActive=YES);const h=this._useSettingsView?[this,this.workspaceView]:[this.tree,this.workspaceView,this.detailsView];if(BMEqualAttributeLayoutConstraint.constraintWithAttribute(BMLayoutAttribute.Top,{forViews:h}).isActive=YES,BMEqualAttributeLayoutConstraint.constraintWithAttribute(BMLayoutAttribute.Bottom,{forViews:h}).isActive=YES,this._useSettingsView?this.workspaceView.leading.equalTo(this.leading).isActive=YES:(this.tree.leading.equalTo(this.leading).isActive=YES,this.tree.trailing.equalTo(this.workspaceView.leading).isActive=YES),this.workspaceView.trailing.equalTo(this._useSettingsView?this.trailing:this.detailsView.leading).isActive=YES,this._useSettingsView||(this.detailsView.trailing.equalTo(this.trailing).isActive=YES),this.treeWidthConstraint=this.tree.width.equalTo(256),this._useSettingsView||(this.treeWidthConstraint.isActive=YES),this.detailsWidthConstraint=this.detailsView.width.equalTo(344,{priority:1e3}),this._useSettingsView||(this.detailsWidthConstraint.isActive=YES),this.workspaceToolbarView.top.equalTo(this.workspaceView.top).isActive=YES,this.workspaceToolbarView.bottom.equalTo(this.workspaceWrapperView.top).isActive=YES,this.workspaceWrapperView.bottom.equalTo(this.workspaceView.bottom).isActive=YES,this.workspaceToolbarView.leading.equalTo(this.workspaceView.leading).isActive=YES,this.workspaceToolbarView.trailing.equalTo(this.workspaceView.trailing).isActive=YES,this.workspaceWrapperView.leading.equalTo(this.workspaceView.leading).isActive=YES,this.workspaceWrapperView.trailing.equalTo(this.workspaceView.trailing).isActive=YES,this.workspaceToolbarHeightConstraint=this.workspaceToolbarView.height.equalTo(this._useSettingsView?32:64),this.workspaceToolbarHeightConstraint.isActive=YES,this.workspaceWidth=this.workspace.width.equalTo(this.workspaceWrapperView.width),this.workspaceWidth.isActive=YES,this.workspaceHeight=this.workspace.height.equalTo(this.workspaceWrapperView.height),this.workspaceHeight.isActive=YES,this.workspaceLeft=this.workspace.left.equalTo(this.workspaceWrapperView.left),this.workspaceLeft.isActive=YES,this.workspaceTop=this.workspace.top.equalTo(this.workspaceWrapperView.top),this.workspaceTop.isActive=YES,this.workspace.left.greaterThanOrEqualTo(this.workspaceWrapperView.left).isActive=YES,this.workspace.top.greaterThanOrEqualTo(this.workspaceWrapperView.top).isActive=YES,BMIsTouchDevice){let t=document.createElement("div");t.className="BMWindowButton BMLayoutEditorTouchHandler",t.innerText="Create Constraint",t.addEventListener("touchstart",(e=>{t.classList.add("BMLayoutEditorTouchHandlerActive"),this.isCreatingTouchConstraints=YES,e.preventDefault()})),t.addEventListener("touchend",(e=>{t.classList.remove("BMLayoutEditorTouchHandlerActive"),this.isCreatingTouchConstraints=NO,e.preventDefault()})),t.addEventListener("touchcancel",(e=>{t.classList.remove("BMLayoutEditorTouchHandlerActive"),this.isCreatingTouchConstraints=NO})),this.content.appendChild(t)}return this},_prepareView(t){let e=document.createElement("div");e.className="BMLayoutEditorViewSelector",t._selector=e,t.node.classList.add("BMLayoutEditorManagedView");const i=document.createElement("div");let o,n;i.className="material-icons BMWindowDragHandle BMLayoutEditorViewDragHandle",i.innerText="dehaze",i.style.cursor="nwse-resize",e.appendChild(i),i.addEventListener("mousedown",(e=>{let i=BMSizeMake(t.frame.size.width,t.frame.size.height),o=BMPointMake(e.clientX,e.clientY),n=NO,s=e=>{n||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),n=YES);let s=BMPointMake(e.clientX,e.clientY);const a=t.frame.copy();a.size.width=i.width+(s.x-o.x)/this.scale,a.size.height=i.height+(s.y-o.y)/this.scale,t.frame=a,i=BMSizeMake(i.width+(s.x-o.x)/this.scale,i.height+(s.y-o.y)/this.scale),o=s,e.preventDefault(),e.stopPropagation()},a=document.createElement("div");a.className="BMLayoutGuideMask",a.style.cursor="nwse-resize",document.body.appendChild(a);let r=e=>{window.removeEventListener("mousemove",s,YES),window.removeEventListener("mouseup",r,YES),a.remove(),e.preventDefault(),e.stopPropagation(),this.selectView(t)};window.addEventListener("mousemove",s,YES),window.addEventListener("mouseup",r,YES),e.preventDefault(),e.stopPropagation()})),i.addEventListener("touchstart",(e=>{o=e.changedTouches[0].identifier;let i=BMSizeMake(t.frame.size.width,t.frame.size.height),n=BMPointMake(e.changedTouches[0].clientX,e.changedTouches[0].clientY),s=NO,a=e=>{let a;for(let t of e.changedTouches)if(t.identifier==o){a=t;break}if(!a)return;s||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),s=YES);let r=BMPointMake(a.clientX,a.clientY);const l=t.frame.copy();l.size.width=i.width+(r.x-n.x)/this.scale,l.size.height=i.height+(r.y-n.y)/this.scale,t.frame=l,i=BMSizeMake(i.width+(r.x-n.x)/this.scale,i.height+(r.y-n.y)/this.scale),n=r,e.preventDefault(),e.stopPropagation()},r=e=>{o=void 0,window.removeEventListener("touchmove",a),window.removeEventListener("touchend",r),window.removeEventListener("touchcancel",r),e.preventDefault(),e.stopPropagation(),this.selectView(t)};window.addEventListener("touchmove",a),window.addEventListener("touchend",r),window.removeEventListener("touchcancel",r),e.preventDefault(),e.stopPropagation()})),e.addEventListener("click",(e=>{e.altKey||(this.selectView(t,{withEvent:e}),n?(n=void 0,this._detailsToolWindow._visible||this._detailsToolWindow.bringToFrontAnimated(YES,{fromRect:BMRectMakeWithNodeFrame(this._inspectorButton)})):n=setTimeout((()=>n=void 0),250),e.stopPropagation(),e.stopImmediatePropagation())})),this.initDragEventListenerForNode(e,{view:t}),e.addEventListener("mousedown",(t=>2!=t.button&&(t.stopPropagation(),t.stopImmediatePropagation()))),e.addEventListener("mousemove",(t=>2!=t.button&&(t.stopPropagation(),t.stopImmediatePropagation()))),e.addEventListener("mouseup",(t=>2!=t.button&&(t.stopPropagation(),t.stopImmediatePropagation()))),t.node.childNodes.length?t.node.insertBefore(e,t.node.childNodes[0]):t.node.appendChild(e)},_isFullScreen:NO,toggleFullscreenWithEvent(t){this._useSettingsView||(this._isFullScreen?(this.treeWidthConstraint.constant=256,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._fullScreenButton.style.marginLeft="0px",this._isFullScreen=!1):(this.treeWidthConstraint.constant=0,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._fullScreenButton.style.marginLeft="72px",this._isFullScreen=!0))},_isSettingsPaneHidden:NO,toggleSettingsPaneWithEvent(t){this._useSettingsView||(this._isSettingsPaneHidden?(this.detailsWidthConstraint.constant=344,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._isSettingsPaneHidden=!1):(this.detailsWidthConstraint.constant=0,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._isSettingsPaneHidden=!0))},_scale:1,get scale(){return this._scale},set scale(t){if(!isNaN(t)&&(t=BMNumberByConstrainingNumberToBounds(t,.25,2),this._scale!=t))if(this._scale=t,BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this.workspace,{node:this.workspace.node}).registerBuiltInPropertiesWithDictionary({scaleX:t,scaleY:t})}else BMHook(this.workspace.node,{scaleX:t,scaleY:t})},_activeSizeClass:void 0,get activeSizeClass(){return this._activeSizeClass},set activeSizeClass(t){let e=!!this._activeSizeClass;this._activeSizeClass=t,t?(e||this.workspaceToolbar.classList.add("BMLayoutEditorWorkspaceToolbarSizeClass"),e||this.workspaceToolbar.classList.add("BMWindowToolbarDark")):(e&&this.workspaceToolbar.classList.remove("BMLayoutEditorWorkspaceToolbarSizeClass"),e&&this.workspaceToolbar.classList.remove("BMWindowToolbarDark"));let i=t?BMViewport.currentViewport():void 0;t&&(t._maximumWidth&&(i._width=t._maximumWidth),t._maximumHeight&&(i._height=t._maximumHeight),t._maximumDiagonal&&(i._diagonal=t._maximumDiagonal),t._orientation!=BMLayoutOrientation.Any&&(i._orientation=t._orientation),t._maximumSurfaceArea&&(i._surfaceArea=t._maximumSurfaceArea)),this.view._requiredViewport=i,this.view._invalidatedSizeClasses=YES,this.view.needsLayout=YES,this.awaitLayout?this.layoutQueue._views.delete(this.view):BMAnimateWithBlock((()=>{this.view.layout()}),{duration:300,easing:"easeInOutQuart",complete:()=>{this.selectedView&&this.selectView(this.selectedView),this.selectedConstraint&&this.selectConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})}})},layoutVariableProvider:BMView,_settingCellClasses:void 0,registerCellClass(t,{forSettingOfKind:e}){this._settingCellClasses[e]=t},_showSizeClassMenuAtPoint(t,{action:e,kind:i}={}){let o=[];o.push(this._sizeClassMenuItemMakeWithName("All Size Classes",{ofType:"Desktop",preview:"Fill",action:e})),o.push(this.settingsDivider()),o.push(this._sizeClassMenuItemMakeWithName("Phone",{ofType:"Phone",sizeClass:BMLayoutSizeClass.phoneSizeClass(),preview:"Phone Portrait",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Phone Portrait",{ofType:"PhonePortrait",sizeClass:BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Portrait),preview:"Phone Portrait",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Phone Landscape",{ofType:"PhoneLandscape",sizeClass:BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Landscape),preview:"Phone Landscape",action:e})),o.push(this.settingsDivider()),o.push(this._sizeClassMenuItemMakeWithName("Tablet",{ofType:"Tablet",sizeClass:BMLayoutSizeClass.tabletSizeClass(),preview:"Tablet Landscape",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Tablet Portrait",{ofType:"TabletPortrait",sizeClass:BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Portrait),preview:"Tablet Portrait",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Tablet Landscape",{ofType:"TabletLandscape",sizeClass:BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Landscape),preview:"Tablet Landscape",action:e})),this.showMenuAtPoint(t,{withOptions:o,kind:i||BMMenuKind.PullDownMenu})},_sizeClassMenuItemMakeWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorConstraintPopupOption BMLayoutEditorSizeClassPopupOption";let o=document.createElement("div");o.className="BMLayoutEditorSizeClassImage BMLayoutEditorImage"+e.ofType+"Mini",i.appendChild(o);let n=document.createElement("span");return n.innerText=t,i.appendChild(n),i.addEventListener("click",(i=>{if(e.action)e.action(e.sizeClass);else{if(e.preview&&(this.awaitLayout=YES),this.activeSizeClass=e.sizeClass,this._sizeClassImage.className="BMLayoutEditorSizeClassImage BMLayoutEditorImage"+e.ofType+"Mini",this._sizeClassText.innerText=t,e.preview){this.deviceSelector.value=e.preview;i=new Event("change");this.deviceSelector.dispatchEvent(i)}this.awaitLayout=NO,this._useSettingsView&&this.detailsView.layoutEditorDidSelectSizeClass(e.sizeClass)}})),i},_inspectorButton:void 0,_initKeyboardShortcuts(){this._useSettingsView&&(this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectLeftConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectTopConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectRightConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectBottomConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("KeyI",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"toggleDetailsToolWindow",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("KeyI",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Shift],target:this,action:"toggleNavigationToolWindow",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Backspace",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"commandBackspacePressedWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Backspace",{modifiers:[],target:this,action:"backspacePressedWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Digit0",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Option],target:this,action:"setConstraintToEqualWithEvent",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Minus",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Option],target:this,action:"setConstraintToLessThanWithEvent",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Equal",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Option],target:this,action:"setConstraintToGreaterThanWithEvent",preventsDefault:YES})))},_initToolbar(t){if(this._useSettingsView){const e=document.createElement("div");e.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",e.innerHTML='<i class="material-icons">&#xE5CD;</i>',e.style.opacity="1",e.addEventListener("click",(t=>this.dismissAnimated(YES,{toNode:this._returnNode}))),t.appendChild(e)}const e=document.createElement("div");e.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",e.style.transition="margin-left .3s ease",e.innerHTML=`<i class="material-icons" style="pointer-events: none;">${this._useSettingsView?"layers":"&#xE5DC;"}</i>`,this._fullScreenButton=e,e.style.opacity="1",e.style.pointerEvents="all",e.addEventListener("click",this._useSettingsView?t=>this._treeWindow.toggleAnimated(YES):t=>this.toggleFullscreenWithEvent(t)),t.appendChild(e);let i=document.createElement("div");i.className="BMWindowToolbarLabel",i.innerText="View:",t.appendChild(i);let o=document.createElement("select");o.className="BMWindowInput BMWindowToolbarInput",this.deviceSelector=o,o.appendChild(this.optionNamed("Fill")),o.appendChild(this.optionNamed("Full HD")),o.appendChild(this.optionNamed('15" Laptop')),o.appendChild(this.optionNamed('13" Laptop')),o.appendChild(this.optionNamed("Tablet Landscape")),o.appendChild(this.optionNamed("Tablet Portrait")),o.appendChild(this.optionNamed("Phone Portrait")),o.appendChild(this.optionNamed("Phone Landscape")),o.appendChild(this.optionNamed("Custom")),t.appendChild(o);let n=document.createElement("input");n.type="number",n.style.cssText="width: 64px !important; margin-left: 32px !important; text-align: center;",n.className="BMWindowInput BMWindowToolbarInput",n.disabled=!0,t.appendChild(n);let s;n.addEventListener("input",(t=>{s&&window.clearTimeout(s),s=window.setTimeout((()=>{if(s=void 0,n.disabled)return;let t=parseInt(n.value,10);isNaN(t)||(this._staticWorkspaceSize.width=t,this._setStaticWorkspaceSize(this._staticWorkspaceSize))}),400)}));let a=document.createElement("div");a.className="BMWindowToolbarLabel",a.innerText="⨯",t.appendChild(a);let r,l=document.createElement("input");l.type="number",l.style.cssText="width: 64px !important; text-align: center;",l.className="BMWindowInput BMWindowToolbarInput",l.disabled=!0,t.appendChild(l),l.addEventListener("input",(t=>{r&&window.clearTimeout(r),r=window.setTimeout((()=>{if(r=void 0,l.disabled)return;let t=parseInt(l.value,10);isNaN(t)||(this._staticWorkspaceSize.height=t,this._setStaticWorkspaceSize(this._staticWorkspaceSize))}),400)})),o.addEventListener("change",(t=>{let e=o.value;"Fill"==e?(this._staticWorkspaceSize=void 0,this.workspaceLeft.remove(),this.workspaceTop.remove(),this.workspaceWidth.remove(),this.workspaceHeight.remove(),(this.workspaceLeft=this.workspace.left.equalTo(this.workspaceWrapperView.left)).isActive=YES,(this.workspaceTop=this.workspace.top.equalTo(this.workspaceWrapperView.top)).isActive=YES,(this.workspaceWidth=this.workspace.width.equalTo(this.workspaceWrapperView.width)).isActive=YES,(this.workspaceHeight=this.workspace.height.equalTo(this.workspaceWrapperView.height)).isActive=YES,BMAnimateWithBlock((()=>{this.layout()}),{duration:300,easing:"easeInOutQuart",complete:()=>{this.selectedView&&this.selectView(this.selectedView),this.selectedConstraint&&this.selectConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})}}),n.value="",l.value="",n.disabled=!0,l.disabled=!0):("Full HD"==e&&(this._setStaticWorkspaceSize(BMSizeMake(1920,1080),{animated:YES}),n.value=1920,l.value=1080),'15" Laptop'==e&&(this._setStaticWorkspaceSize(BMSizeMake(1680,1050),{animated:YES}),n.value=1680,l.value=1050),'13" Laptop'==e&&(this._setStaticWorkspaceSize(BMSizeMake(1400,900),{animated:YES}),n.value=1400,l.value=900),"Tablet Portrait"==e&&(this._setStaticWorkspaceSize(BMSizeMake(768,1024),{animated:YES}),n.value=768,l.value=1024),"Tablet Landscape"==e&&(this._setStaticWorkspaceSize(BMSizeMake(1024,768),{animated:YES}),n.value=1024,l.value=768),"Phone Portrait"==e&&(this._setStaticWorkspaceSize(BMSizeMake(375,667),{animated:YES}),n.value=375,l.value=667),"Phone Landscape"==e&&(this._setStaticWorkspaceSize(BMSizeMake(667,375),{animated:YES}),n.value=667,l.value=375),"Custom"==e?(this._setStaticWorkspaceSize(BMSizeMake(parseInt(n.value,10)||800,parseInt(l.value,10)||600)),n.value=n.value||800,l.value=l.value||600,n.disabled=!1,l.disabled=!1):(n.disabled=!0,l.disabled=!0))}));let h=document.createElement("div");h.className="BMWindowFlexibleSpace",t.appendChild(h);let c=document.createElement("div");c.className="BMWindowToolbarLabel",c.innerText="Zoom:",t.appendChild(c);const d=document.createElement("input");d.type="range",d.min="25",d.max="200",d.value="100",d.style.cssText="width: 100px; height: 24px",t.appendChild(d);const u=document.createElement("input");u.type="number",u.value="100",u.style.cssText="width: 64px !important; text-align: center;",u.className="BMWindowInput BMWindowToolbarInput",t.appendChild(u),d.addEventListener("input",(t=>{const e=parseFloat(d.value);if(isNaN(e))return;u.value=e;const i=e/100;this.scale=i})),u.addEventListener("input",(t=>{let e=parseFloat(u.value);if(isNaN(e))return;e=BMNumberByConstrainingNumberToBounds(e,25,200),d.value=e;const i=e/100;this.scale=i})),this.zoomBox=u,this.zoomSlider=d;const p=document.createElement("div");p.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",p.innerHTML='<i class="material-icons" style="pointer-events: none;">center_focus_strong</i>',p.style.opacity=1,p.style.pointerEvents="all",p.addEventListener("click",(t=>{BMAnimateWithBlock((()=>{this.zoomSlider.value=100,this.zoomBox.value=100,this.panOffset=BMPointMake(0,0),this.scale=1}),{duration:200,easing:"easeInOutQuad"})})),t.appendChild(p);let g=document.createElement("div");g.className="BMWindowFlexibleSpace",t.appendChild(g);let w=document.createElement("div");w.className="BMWindowInput BMWindowToolbarInput BMLayoutEditorSizeClassSelector";let y=document.createElement("div");y.className="BMLayoutEditorSizeClassImage BMLayoutEditorImageDesktop",w.appendChild(y),this._sizeClassImage=y;let m=document.createElement("span");m.innerText="All Size Classes",w.appendChild(m),this._sizeClassText=m,t.appendChild(w),w.addEventListener("click",(t=>{let e=BMRectMakeWithNodeFrame(w),i=BMPointMake(e.left,e.bottom);this._showSizeClassMenuAtPoint(i)}));const _=document.createElement("div");_.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",_.innerHTML='<i class="material-icons BMScriptFont" style="pointer-events: none;">+</i>',t.appendChild(_),this.addViewsButton=_,_.addEventListener("click",(t=>this.showViewsPopupWithEvent(t)));const f=document.createElement("div");f.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",f.innerHTML='<i class="material-icons BMScriptFont" style="pointer-events: none;">{X}</i>',t.appendChild(f),this.layoutVariablesButton=f,f.addEventListener("click",(t=>this.showLayoutVariablesPopupWithEvent(t)));const v=document.createElement("div");v.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",v.innerHTML=`<i class="material-icons" style="pointer-events: none;">${this._useSettingsView?"toggle_on":"&#xE5DD;"}</i>`,v.style.opacity=1,v.style.pointerEvents="all",this._inspectorButton=v,v.addEventListener("click",this._useSettingsView?t=>this.detailsView._window.toggleAnimated(YES,{fromRect:BMRectMakeWithNodeFrame(this._inspectorButton)}):t=>this.toggleSettingsPaneWithEvent(t)),t.appendChild(v)},toggleDetailsToolWindow(){this.detailsView._window.toggleAnimated(YES,{fromRect:BMRectMakeWithNodeFrame(this._inspectorButton)})},toggleNavigationToolWindow(){this._treeWindow.toggleAnimated(YES)},_initWorkspaceGestures(){const t=this.workspaceWrapperView.node;let e,i,o,n,s;t.addEventListener("touchstart",(t=>{this.isCreatingTouchConstraints||2==t.touches.length&&(e=BMPointMake(t.touches[0].pageX,t.touches[0].pageY),i=BMPointMake(t.touches[1].pageX,t.touches[1].pageY),o=BMPointMake((e.x+i.x)/2,(e.y+i.y)/2),n=e.distanceToPoint(i),t.stopPropagation(),t.preventDefault())}),YES),t.addEventListener("touchmove",(t=>{if(!this.isCreatingTouchConstraints&&2==t.touches.length){t.stopPropagation(),t.preventDefault();const s=BMPointMake(t.touches[0].pageX,t.touches[0].pageY),a=BMPointMake(t.touches[1].pageX,t.touches[1].pageY),r=BMPointMake((s.x+a.x)/2,(s.y+a.y)/2),l=BMPointMake(r.x-o.x,r.y-o.y),h=BMPointMake(this.panOffset.x+l.x,this.panOffset.y+l.y);this.panOffset=h;const c=s.distanceToPoint(a),d=c/n-1;this.scale+=d/1.25,e=s,i=a,o=r,n=c}}),YES),t.addEventListener("wheel",(t=>{if(t.preventDefault(),t.altKey){const e=((0==t.deltaMode?t.deltaY:10*t.deltaY)/25|0)/100;this.scale+=e,this.zoomBox.value=100*this.scale|0,this.zoomSlider.value=100*this.scale|0}else{let e,i;0==t.deltaMode?(e=0|t.deltaX,i=0|t.deltaY):(e=10*t.deltaX|0,i=10*t.deltaY|0);const o=this.panOffset;o.x-=e,o.y-=i,this.panOffset=o}}));t.addEventListener("mousedown",(t=>{if(0==t.button&&t.altKey){t.preventDefault(),t.stopPropagation(),s=BMPointMake(t.screenX,t.screenY);const e=t=>{const e=this.panOffset;e.x+=t.screenX-s.x,e.y+=t.screenY-s.y,s=BMPointMake(t.screenX,t.screenY),this.panOffset=e,t.stopPropagation(),t.preventDefault()},i=t=>{t.stopPropagation(),t.preventDefault(),window.removeEventListener("click",o,YES),window.removeEventListener("mousemove",e,YES),window.removeEventListener("mouseup",i,YES)},o=t=>{t.preventDefault(),t.stopPropagation()};window.addEventListener("click",o,YES),window.addEventListener("mousemove",e,YES),window.addEventListener("mouseup",i,YES)}}),YES)},_pathForPopoverWithFrame(t,{widthIndicatorSize:e=8,radius:i=8,inset:o=0,knobPosition:n,gravity:s="Top"}={widthIndicatorSize:8,radius:4,inset:0}){let a="Bottom"===s?0:e*Math.SQRT2/2|0,r="Bottom"===s?t.size.height-e*Math.SQRT2/2|0:t.size.height;const l=o;o&&(e-=o,(t=t.copy()).insetWithInset(BMInsetMakeWithEqualInsets(o)),i+=o,a+=o,r-=o),n=void 0===n?t.size.width/2|0:n-o|0;const h=e*Math.SQRT2,c=h/2|0,d="Bottom"===s?`M${l+i},${a} L${t.size.width+l-i},${a} `:`M${l+i},${a} L${n-h/2+l},${a} l${h/2},${-c} l${h/2},${c} L${t.size.width+l-i},${a} `,u="Bottom"===s?`Q${t.size.width+l},${r} ${t.size.width+l-i},${r} L${n+h/2+l},${r} l${-h/2},${c} l${-h/2},${-c} L${i},${r} `:`Q${t.size.width+l},${r} ${t.size.width+l-i},${r} L${i},${r} `;let p=d;return p+=`Q${t.size.width+l},${a} ${t.size.width+l},${a+i} L${t.size.width+l},${r-i} `,p+=u,p+=`Q${l},${r} ${l},${r-i} L${l},${a+i} Q${l},${a} ${i},${a} Z`,p},showLayoutVariablesPopupWithEvent(t){const e=document.body,i=document.createElement("div");i.className="BMPopoverContainer";const o=document.createElement("div");o.className="BMPopoverContainerLayer BMPopoverDropShadowContainer";const n=document.createElement("div");n.className="BMPopoverDropShadowContent",o.appendChild(n);const s=document.createElement("div");s.className="BMPopoverBackground",s.innerHTML='<div class="BMPopoverBackgroundDarkModeContainer"><div class="BMPopoverBackgroundDarkModeOutline"></div><div class="BMPopoverBackgroundDarkModeFill"></div></div>';const a=BMRectMakeWithNodeFrame(this.layoutVariablesButton).center,r=BMRectMake(window.innerWidth-320-16,a.y+16,320,388);r.origin.x=Math.min(r.origin.x,a.x-r.width/2);const l=a.x-r.origin.x,h=`path('${this._pathForPopoverWithFrame(r,{widthIndicatorSize:16,knobPosition:l})}')`,c=`path('${this._pathForPopoverWithFrame(r,{widthIndicatorSize:16,inset:1,knobPosition:l})}')`,d={left:r.origin.x+"px",top:r.origin.y+"px",width:r.size.width+"px",height:r.size.height+"px"};BMCopyProperties(i.style,d),BMCopyProperties(s.style,d),s.style.clipPath=h,s.style.webkitClipPath=h;const u=s.querySelector(".BMPopoverBackgroundDarkModeFill");u.style.clipPath=c,u.style.webkitClipPath=c,BMCopyProperties(o.style,d),n.style.clipPath=h,n.style.webkitClipPath=h;const p=document.createElement("div");p.className="BMPopoverOverlay",e.appendChild(p);const g=document.createElement("div");g.innerText="Layout Variables",g.className="BMWindowTitle",i.appendChild(g);const w=document.createElement("div");w.className="BMLayoutEditorVariablesContainer",i.appendChild(w);const y=document.createElement("button");y.className="BMWindowButton",y.innerText="Add Variable",y.style.boxSizing="border-box",this.layoutVariableProvider.canUseLayoutVariables()&&i.appendChild(y);const m=BMCollectionView.collectionViewForNode(w),_=(new BMLayoutEditorVariablesDataSet).initWithLayoutVariableProvider(this.layoutVariableProvider,{collectionView:m,editor:this});m.cellClass=BMLayoutEditorVariableCell,m.registerSupplementaryViewClass(BMLayoutEditorEmptyVariablesCell,{forReuseIdentifier:BMCollectionViewFlowLayoutSupplementaryView.Empty}),m.layout.maximumCellsPerRow=1,m.layout.gravity=BMCollectionViewFlowLayoutGravity.Expand,m.layout.rowSpacing=0,m.layout.topPadding=0,m.layout.bottomPadding=0,m.layout.contentGravity=BMCollectionViewFlowLayoutAlignment.Start,e.appendChild(s),e.appendChild(o),e.appendChild(i);let f=YES;m.delegate=_,(async()=>{await this.layoutVariableProvider.prepareLayoutVariables(),f&&(m.dataSet=_)})(),y.addEventListener("click",(t=>{_.addVariable()}));const v=[i,s,o];for(const t of v)t.style.transformOrigin=l/r.size.width*100+"% 0%",BMHook(t,{scaleX:.75,scaleY:.75,opacity:0}),__BMVelocityAnimate(t,{scaleX:1,scaleY:1,opacity:1},{duration:300,easing:[0,1.59,.49,1]});p.addEventListener("click",(t=>{f=NO,m.dataSet&&this.layoutVariableProvider.persistLayoutVariables(),m.release(),p.remove();for(const t of v)t.style.pointerEvents="none",__BMVelocityAnimate(t,{scaleX:.9,scaleY:.9,opacity:0},{duration:200,easing:"easeInOutQuart",complete(){t.remove()}});this.node.focus()}))},_showConstantPopupAtPoint(t,{forConstraint:e,withReferenceView:i}){const o=document.body,n=t.y<160,s=document.createElement("div");s.className="BMPopoverContainer BMPopoverContainerConstant"+(n?" BMPopoverContainerConstantBelow":"");const a=document.createElement("div");a.className="BMPopoverContainerLayer BMPopoverDropShadowContainer";const r=document.createElement("div");r.className="BMPopoverDropShadowContent",a.appendChild(r);const l=document.createElement("div");l.className="BMPopoverBackground",l.innerHTML='<div class="BMPopoverBackgroundDarkModeContainer"><div class="BMPopoverBackgroundDarkModeOutline"></div><div class="BMPopoverBackgroundDarkModeFill"></div></div>';const h=this.activeSizeClass?96:64,c=BMRectMake(t.x-120,n?t.y:t.y-h-8,240,h+8);c.origin.x<-4&&(c.origin.x=-4),c.right>window.innerWidth+4&&(c.origin.x=window.innerWidth-c.size.width+4);const d=BMNumberByConstrainingNumberToBounds(t.x-c.origin.x,12,c.size.width-12),u=`path('${this._pathForPopoverWithFrame(c,{widthIndicatorSize:16,knobPosition:d,gravity:n?"Top":"Bottom"})}')`,p=`path('${this._pathForPopoverWithFrame(c,{widthIndicatorSize:16,inset:1,knobPosition:d,gravity:n?"Top":"Bottom"})}')`,g={left:c.origin.x+"px",top:c.origin.y+"px",width:c.size.width+"px",height:c.size.height+"px"};BMCopyProperties(s.style,g),BMCopyProperties(l.style,g),l.style.clipPath=u,l.style.webkitClipPath=u;const w=l.querySelector(".BMPopoverBackgroundDarkModeFill");w.style.clipPath=p,w.style.webkitClipPath=p,BMCopyProperties(a.style,g),r.style.clipPath=u,r.style.webkitClipPath=u;const y=document.createElement("div");y.className="BMPopoverOverlay",o.appendChild(y),o.appendChild(l),o.appendChild(a),o.appendChild(s);const m=this;if(this.activeSizeClass){const t=document.createElement("div");t.className="BMLayoutEditorDetailsItemBadgeIcon",t.style.flexShrink="0",t.style.top="1px",s.appendChild(t);const o=document.createElement("div");o.className="BMLayoutEditorDetailsTitleCell",o.innerText="Constant:",o.style.paddingRight="8px",s.appendChild(o);const n=document.createElement("input");n.type="text",n.style.width="50px",n.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemTextValue",n.value=e.constant,s.appendChild(n);BMTextField.textFieldForInputNode(n).delegate={textFieldSuggestionsForText(){const t=[],e=Object.keys(m.layoutVariableProvider.layoutVariables),i=new Set;e.forEach((t=>i.add(t)));for(const e of i)t.unshift(e),t.push("-"+e);return t},textFieldShouldShowSuggestions:()=>NO,textFieldContentsDidChange(){const t=parseFloat(n.value),i=isNaN(t)?n.value:t;n.value?(e.constant=i,e._updateConfiguration(),e._constraint=void 0,e._constituentConstraints=void 0,e._sourceView?e._sourceView.needsLayout=YES:e._views[0].needsLayout=YES):e.constant=0},textFieldShouldReturn:()=>(y.dispatchEvent(new Event("click")),m.selectView(i),YES)};const a=document.createElement("div");a.style.flexBasis="100%",a.className="BMLayoutEditorDetailsDivider",a.style.marginTop="0px",a.style.marginBottom="0px",s.appendChild(a);const r=this.settingsBadgeForSizeClass(this.activeSizeClass);r.style.flexShrink="0",r.style.top="1px",s.appendChild(r)}const _=document.createElement("div");_.className="BMLayoutEditorDetailsTitleCell",_.innerText="Constant:",_.style.paddingRight="8px",s.appendChild(_);const f=document.createElement("input");f.type="text",f.style.width="50px",f.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemTextValue",this.activeSizeClass?e._variations[this.activeSizeClass]?f.value=e._variations[this.activeSizeClass].constant||"":f.value="":f.value=e.constant,s.appendChild(f);BMTextField.textFieldForInputNode(f).delegate={textFieldSuggestionsForText(){const t=[],e=Object.keys(m.layoutVariableProvider.layoutVariables),i=new Set;e.forEach((t=>i.add(t)));for(const e of i)t.unshift(e),t.push("-"+e);return t},textFieldShouldShowSuggestions:()=>NO,textFieldContentsDidChange(){const t=parseFloat(f.value),i=isNaN(t)?f.value:t;f.value?(m.activeSizeClass?e.setConstant(i,{forSizeClass:m.activeSizeClass}):e.constant=i,e._updateConfiguration(),e._constraint=void 0,e._constituentConstraints=void 0,e._sourceView?e._sourceView.needsLayout=YES:e._views[0].needsLayout=YES):m.activeSizeClass?(e.removeConstantVariationForSizeClass(m.activeSizeClass),e._updateConfiguration()):e.constant=0},textFieldShouldReturn:()=>(y.dispatchEvent(new Event("click")),m.selectView(i),YES)},f.focus(),f.select();let v=YES;const M=[s,l,a];for(const t of M)t.style.transformOrigin=d/c.size.width*100+"% "+(n?"100%":"0%"),BMHook(t,{scaleX:.75,scaleY:.75,opacity:0}),__BMVelocityAnimate(t,{scaleX:1,scaleY:1,opacity:1},{duration:300,easing:[0,1.59,.49,1]});y.addEventListener("click",(t=>{v=NO,y.remove();for(const t of M)t.style.pointerEvents="none",__BMVelocityAnimate(t,{scaleX:.9,scaleY:.9,opacity:0},{duration:200,easing:"easeInOutQuart",complete(){t.remove()}});this.node.focus()}))},_setStaticWorkspaceSize(t,e){this._staticWorkspaceSize=t,this.workspaceLeft.remove(),this.workspaceTop.remove(),this.workspaceWidth.remove(),this.workspaceHeight.remove(),(this.workspaceLeft=this.workspace.centerX.equalTo(this.workspaceWrapperView.centerX,{priority:750})).isActive=YES,(this.workspaceTop=this.workspace.centerY.equalTo(this.workspaceWrapperView.centerY,{priority:750})).isActive=YES,(this.workspaceWidth=this.workspace.width.equalTo(t.width)).isActive=YES,(this.workspaceHeight=this.workspace.height.equalTo(t.height)).isActive=YES,BMAnimateWithBlock((()=>{this.layout()}),{duration:300,easing:"easeInOutQuart",complete:()=>{this.selectedView&&this.selectView(this.selectedView),this.selectedConstraint&&this.selectConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})}})},_bringToFrontAnimated(t,e){var i;(e=e||{}).completionHandler&&(i=e.completionHandler),e.completionHandler=t=>{i&&i(),this._view.needsLayout=YES},BMWindow.prototype.bringToFrontAnimated.apply(this,arguments),this._view.node.style.display="block",this.workspaceNode.appendChild(this._view.node),requestAnimationFrame((t=>this._view.needsLayout=YES))},_drawConstraintsForView(t,e){e=e||{},this._clearOffsets(),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove()));let i=[];t.localConstraints.forEach((o=>{if(!o.affectsLayout&&!e.includesInactiveConstraints)return;o._isConstraintCollection;const n=this._drawConstraint(o,{withReferenceView:t});if(Array.isArray(n))for(const t of n)i.push(t);else i.push(n)})),i=i.filter((t=>t));let o=NO;for(let t=0;t<500;t++){for(const t of i)for(const e of i){if(e==t||e.kind!=t.kind)continue;let i="x",n="y";if(t.kind!==BMLayoutConstraintKind.Horizontal&&(i="y",n="x"),t.sourcePoint[i]==e.sourcePoint[i]&&Math.abs(t.sourcePoint[n]-e.sourcePoint[n])<5){const i=3*(Math.sign(t.sourcePoint[n]-e.sourcePoint[n])||-1),s=3*(Math.sign(e.sourcePoint[n]-t.sourcePoint[n])||1);t.sourcePoint[n]==t.targetPoint[n]&&(t.targetPoint[n]+=i),e.sourcePoint[n]==e.targetPoint[n]&&(e.targetPoint[n]+=s),t.sourcePoint[n]+=i,e.sourcePoint[n]+=s,t.displaced=YES,e.displaced=YES,o=YES}}if(!o)break}for(const t of i.filter((t=>t.displaced)))t.kind==BMLayoutConstraintKind.Horizontal?(BMCopyProperties(t.node.style,{left:Math.min(t.sourcePoint.x,t.targetPoint.x)+"px",top:t.sourcePoint.y+"px"}),BMCopyProperties(t.leadLine.style,{height:Math.abs(t.sourcePoint.y-t.targetPoint.y)+"px",left:(t.targetPoint.x<t.sourcePoint.x?t.targetPoint.x:t.targetPoint.x-1)+"px",top:Math.min(t.targetPoint.y,t.sourcePoint.y)+"px"})):(BMCopyProperties(t.node.style,{left:t.sourcePoint.x+"px",top:Math.min(t.sourcePoint.y,t.targetPoint.y)+"px"}),BMCopyProperties(t.leadLine.style,{width:Math.abs(t.sourcePoint.x-t.targetPoint.x)+"px",top:(t.targetPoint.y<t.sourcePoint.y?t.targetPoint.y:t.targetPoint.y-1)+"px",left:Math.min(t.targetPoint.x,t.sourcePoint.x)+"px"}))},selectView(t,e){let i=e&&e.withEvent;return i&&(i.metaKey||i.ctrlKey)?this.toggleSelectionForView(t):this._useSettingsView&&this.selectedView===t?(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this._clearOffsets(),void this._drawConstraintsForView(t)):(this.tree.selectView(t),t._checkConstraints(),t._hasDeterministicConstraints?this.workspaceNode.classList.remove("BMLayoutEditorWorkspaceInvalidLayout"):this.workspaceNode.classList.add("BMLayoutEditorWorkspaceInvalidLayout"),this._useSettingsView||(this.detailsNodeTitle.innerText=t.debuggingName||t.node.id),this._view.node.querySelectorAll(".BMLayoutEditorViewSelectorSelected, .BMLayoutEditorViewSelectorConstrained").forEach((t=>{t.classList.remove("BMLayoutEditorViewSelectorSelected"),t.classList.remove("BMLayoutEditorViewSelectorConstrained")})),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this.selectedView=t,this.selectedConstraint=void 0,this.selectedViews=void 0,void(t&&(t._selector.classList.add("BMLayoutEditorViewSelectorSelected"),this._clearOffsets(),t.localConstraints.forEach((e=>{e.isConstraintCollection?e._views.forEach((e=>e!=t&&e._selector.classList.add("BMLayoutEditorViewSelectorConstrained"))):(e._sourceView!=t&&e._sourceView._selector.classList.add("BMLayoutEditorViewSelectorConstrained"),e._targetView&&e._targetView!=t&&e._targetView._selector.classList.add("BMLayoutEditorViewSelectorConstrained"))})),this._drawConstraintsForView(t),this._useSettingsView?this.detailsView.layoutEditorDidSelectView(t):(this.detailsNodeContent.innerHTML="",this.createSettingsForView(t)))))},toggleSelectionForView(t){if(this.selectedViews=this.selectedViews||[],this.selectedView&&this.selectedViews.push(this.selectedView),this.selectedView=void 0,this.selectedConstraint=void 0,this.workspaceNode.classList.remove("BMLayoutEditorWorkspaceInvalidLayout"),this._view.node.querySelectorAll(".BMLayoutEditorViewSelectorConstrained").forEach((t=>{t.classList.remove("BMLayoutEditorViewSelectorConstrained")})),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),1==this.selectedViews.length&&this.selectedViews[0]==t)return;let e;return-1==(e=this.selectedViews.indexOf(t))?(this.selectedViews.push(t),t._selector.classList.add("BMLayoutEditorViewSelectorSelected"),this.tree.selectView(t,{continuous:YES})):(this.selectedViews.splice(e,1),t._selector.classList.remove("BMLayoutEditorViewSelectorSelected"),this.tree.deselectView(t)),1==this.selectedViews.length?this.selectView(this.selectedViews[0]):this._useSettingsView?this.detailsView.layoutEditorDidSelectViews(this.selectedViews):void this.createSettingsForMultipleViews()},viewDidLayoutSubviews(){this.selectedConstraint&&requestAnimationFrame((t=>{this._clearOffsets(),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this._drawConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})})),this.selectedView&&requestAnimationFrame((t=>{this._clearOffsets(),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this.selectedView.localConstraints.forEach((t=>this._drawConstraint(t,{withReferenceView:this.selectedView})))}))},initDragEventListenerForNode(t,e){let i,o=e.view;t.addEventListener("contextmenu",(t=>t.preventDefault()));let n=e=>{if(2!=e.button&&!this.isCreatingTouchConstraints)return;"touchstart"==e.type&&(i=e.changedTouches[0].identifier),this.isCreatingConstraint=YES,this.constraintSource=o,this.constraintTarget=o,t.classList.add("BMLayoutEditorDragSource");var n=t=>t.preventDefault();window.addEventListener("contextmenu",n);let s=t=>{if("touchend"==t.type||"touchstart"==t.type){var e=NO;for(let o of t.changedTouches)if(o.identifier==i){e=YES;break}if(!e)return}window.removeEventListener("mouseup",s),window.removeEventListener("touchchancel",s),window.removeEventListener("touchend",s),requestAnimationFrame((t=>window.removeEventListener("contextmenu",n))),this.isCreatingConstraint=NO,this.content.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this.content.querySelectorAll(".BMLayoutEditorDragSource").forEach((t=>t.classList.remove("BMLayoutEditorDragSource"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragSource").forEach((t=>t.classList.remove("BMLayoutEditorDragSource")));let o="mouseup"==t.type?BMPointMake(t.clientX,t.clientY):BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY);this.showConstraintOptionsFromView(this.constraintSource,{toView:this.constraintTarget,atPoint:o}),t.preventDefault()};if(window.addEventListener("mouseup",s),window.addEventListener("touchchancel",s),window.addEventListener("touchend",s),BMIsTouchDevice){let t=t=>{for(let e of t.changedTouches)if(e.identifier==i){this.content.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget")));let i=document.elementFromPoint(e.clientX,e.clientY),o=i.closest(".BMLayoutEditorViewSelector");o&&(i.classList.add("BMLayoutEditorDragTarget"),this.constraintTarget=BMView.viewForNode(o.parentNode)),t.preventDefault()}};window.addEventListener("touchmove",t)}e.preventDefault()};t.addEventListener("mousedown",n),t.addEventListener("touchstart",n),t.addEventListener("touchstart",(e=>{const i=e.changedTouches[0].identifier,n=e.changedTouches[0];let s=o.frame||BMRectMakeWithNodeFrame(o.node),a=!1,r=BMPointMake(n.pageX,n.pageY),l=NO,h=t=>{let e;for(let o=0;o<t.changedTouches.length;o++){const o=t.changedTouches;if(o.identifier==i){e=o;break}}if(!e)return;a=!0,l||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),l=YES);let n=BMPointMake(e.pageX-r.x,e.pageY-r.y);1!=this.scale&&n.multiplyWithScalar(1/this.scale);let h=s.copy();h.offsetWithX(n.x,{y:n.y}),o.frame=h,t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()},c=e=>{let n;for(let t=0;t<e.changedTouches.length;t++){const t=e.changedTouches;if(t.identifier==i){n=t;break}}n&&(t.removeEventListener("touchend",c,{capture:YES}),t.removeEventListener("touchcancel",c,{capture:YES}),t.removeEventListener("touchmove",h,{capture:YES}),a&&(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.selectView(o)))};t.addEventListener("touchend",c,{capture:YES}),t.addEventListener("touchcancel",c,{capture:YES}),t.addEventListener("touchmove",h,{capture:YES})})),t.addEventListener("mousedown",(t=>{if(0!=t.button)return;let e=o.frame||BMRectMakeWithNodeFrame(o.node),i=!1,n=BMPointMake(t.pageX,t.pageY),s=NO,a=t=>{i=!0,s||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),s=YES);let a=BMPointMake(t.pageX-n.x,t.pageY-n.y);1!=this.scale&&a.multiplyWithScalar(1/this.scale);let r=e.copy();r.offsetWithX(a.x,{y:a.y}),o.frame=r,t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()},r=t=>{window.removeEventListener("mouseup",r,{capture:YES}),window.removeEventListener("mousemove",a,{capture:YES}),i&&(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),this.selectView(o))};window.addEventListener("mouseup",r,{capture:YES}),window.addEventListener("mousemove",a,{capture:YES})})),t.addEventListener("mouseenter",(e=>{this.isCreatingConstraint&&(this.content.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),t.classList.add("BMLayoutEditorDragTarget"),this.constraintTarget=o,e.preventDefault())}))},constraintOptionWithLabel(t,e){let i=document.createElement("div");return i.className="BMLayoutEditorConstraintPopupOption",i.innerText=t,i.addEventListener("click",e.action),i},addConstraint(t){t.isActive=YES,this.tree.addConstraint(t),this._activeSizeClass&&(t.isActive=NO,t.setIsActive(YES,{forSizeClass:this._activeSizeClass}));const e=this.selectConstraint(t,{withReferenceView:t._sourceView});this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(e.node).center,{forConstraint:t,withReferenceView:t._sourceView})},_createMenuWithOptions(t){let e=document.createElement("div");e.className="BMLayoutEditorConstraintPopup";let i=document.createElement("div");return i.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(e.style.backgroundColor="white"),i.appendChild(e),t.forEach((t=>e.appendChild(t))),document.body.appendChild(i),i.style.opacity="0",i},showMenuAtPoint(t,e){let i,o;e.menu?(o=e.menu,i=e.menu.children[0],BMHook(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0}),o.style.opacity="1"):(i=document.createElement("div"),i.className="BMLayoutEditorConstraintPopup",o=document.createElement("div"),o.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(i.style.backgroundColor="white"),o.appendChild(i),e.withOptions.forEach((t=>i.appendChild(t))),BMHook(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0}),document.body.appendChild(o));const n=i.offsetHeight,s=i.offsetWidth;let a="0%",r=" 0%";e.kind==BMMenuKind.PullDownMenu?a="50%":s+t.x>document.documentElement.clientWidth&&(a="100%",t.x-=s),n+t.y>document.documentElement.clientHeight&&(r=" 100%",t.y-=n),i.style.transformOrigin=a+r,i.style.left=t.x+"px",i.style.top=t.y+"px",i.addEventListener("click",(t=>t.preventDefault())),(window.Velocity||$.Velocity).animate(i,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>(i.style.pointerEvents="all",o.style.pointerEvents="all")});let l=0;for(let t of i.childNodes)BMHook(t,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(t,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:l}),l+=16;return o.addEventListener("click",(t=>{i.style.pointerEvents="none",o.style.pointerEvents="none";let n=16*i.childNodes.length+100-200;n=n<0?0:n,(window.Velocity||$.Velocity).animate(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0,translateZ:0},{duration:200,easing:"easeInQuad",delay:n,complete:t=>o.remove()}),n=0;for(let t=i.childNodes.length-1;t>=0;t--){let e=i.childNodes[t];(window.Velocity||$.Velocity).animate(e,{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:n}),n+=16}this.node.focus()})),i},showConstraintOptionsFromView(t,e){let i=e.toView,o=document.createElement("div");o.className="BMLayoutEditorConstraintPopup",i&&i!==t?(this.horizontalConstraintOptionsFromView(t,{toView:i}).forEach((t=>o.appendChild(t))),o.appendChild(this.settingsDivider()),this.verticalConstraintOptionsFromView(t,{toView:i}).forEach((t=>o.appendChild(t))),o.appendChild(this.settingsDivider()),o.appendChild(this.constraintOptionWithLabel("Equal Width",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,toView:i,secondAttribute:BMLayoutAttribute.Width}))}})),o.appendChild(this.constraintOptionWithLabel("Equal Height",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Height,toView:i,secondAttribute:BMLayoutAttribute.Height}))}}))):(o.appendChild(this.constraintOptionWithLabel("Width",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,constant:t.node.offsetWidth}))}})),o.appendChild(this.constraintOptionWithLabel("Height",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Height,constant:t.node.offsetHeight}))}})));let n=document.createElement("div");n.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(o.style.backgroundColor="white"),n.appendChild(o),BMHook(o,{scaleX:.75,scaleY:.75,opacity:0}),document.body.appendChild(n);const s=o.offsetHeight,a=o.offsetWidth;let r="0%",l=" 0%";a+e.atPoint.x>document.documentElement.clientWidth&&(r="100%",e.atPoint.x-=a),s+e.atPoint.y>document.documentElement.clientHeight&&(l=" 100%",e.atPoint.y-=s),o.style.transformOrigin=r+l,o.style.left=e.atPoint.x+"px",o.style.top=e.atPoint.y+"px",o.addEventListener("click",(t=>t.preventDefault())),(window.Velocity||$.Velocity).animate(o,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>(o.style.pointerEvents="all",n.style.pointerEvents="all")});let h=0;for(let t of o.childNodes)BMHook(t,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(t,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:h}),h+=16;n.addEventListener("click",(t=>{o.style.pointerEvents="none",n.style.pointerEvents="none";let e=16*o.childNodes.length+100-200;e=e<0?0:e,(window.Velocity||$.Velocity).animate(o,{scaleX:.75,scaleY:.75,opacity:0,translateZ:0},{duration:200,easing:"easeInQuad",delay:e,complete:t=>n.remove()}),e=0;for(let t=o.childNodes.length-1;t>=0;t--){let i=o.childNodes[t];(window.Velocity||$.Velocity).animate(i,{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:e}),e+=16}}))},horizontalConstraintOptionsFromView(t,e){var i=e.toView;return[this.constraintOptionWithLabel("Align Leading",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Leading,constant:BMRectMakeWithNodeFrame(t.node).left-BMRectMakeWithNodeFrame(i.node).left}))}}),this.constraintOptionWithLabel("Align Horizontal Center",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.CenterX,toView:i,secondAttribute:BMLayoutAttribute.CenterX,constant:BMRectMakeWithNodeFrame(t.node).center.x-BMRectMakeWithNodeFrame(i.node).center.x}))}}),this.constraintOptionWithLabel("Align Trailing",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Trailing,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:BMRectMakeWithNodeFrame(t.node).right-BMRectMakeWithNodeFrame(i.node).right}))}}),this.constraintOptionWithLabel("Horizontal Spacing",{action:e=>{let o=BMRectMakeWithNodeFrame(t.node),n=BMRectMakeWithNodeFrame(i.node);o.origin.x>=n.right?this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:-BMRectMakeWithNodeFrame(t.node).right+BMRectMakeWithNodeFrame(i.node).origin.x})):this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Trailing,toView:i,secondAttribute:BMLayoutAttribute.Leading,constant:BMRectMakeWithNodeFrame(t.node).origin.x-BMRectMakeWithNodeFrame(i.node).right}))}})]},verticalConstraintOptionsFromView(t,e){var i=e.toView;return[this.constraintOptionWithLabel("Align Top",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Top,constant:BMRectMakeWithNodeFrame(t.node).top-BMRectMakeWithNodeFrame(i.node).top}))}}),this.constraintOptionWithLabel("Align Vertical Center",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.CenterY,toView:i,secondAttribute:BMLayoutAttribute.CenterY,constant:BMRectMakeWithNodeFrame(t.node).center.y-BMRectMakeWithNodeFrame(i.node).center.y}))}}),this.constraintOptionWithLabel("Align Bottom",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Bottom,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:BMRectMakeWithNodeFrame(t.node).bottom-BMRectMakeWithNodeFrame(i.node).bottom}))}}),this.constraintOptionWithLabel("Vertical Spacing",{action:e=>{let o=BMRectMakeWithNodeFrame(t.node),n=BMRectMakeWithNodeFrame(i.node);o.origin.y>=n.bottom?this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:-BMRectMakeWithNodeFrame(t.node).bottom+BMRectMakeWithNodeFrame(i.node).origin.y})):this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:BMRectMakeWithNodeFrame(t.node).origin.y-BMRectMakeWithNodeFrame(i.node).bottom}))}})]},selectConstraint(t,e){if((this.selectedConstraint!=t||this.selectedConstraintReferenceView!=e.withReferenceView)&&(this.selectedView=void 0,this.selectedViews=void 0,this.selectedConstraint=t,this.selectedConstraintReferenceView=e.withReferenceView,this.tree.selectConstraint(t),this.workspaceNode.classList.remove("BMLayoutEditorWorkspaceInvalidLayout"),this._useSettingsView||(this.detailsNodeTitle.innerText="Constraint"),this._view.node.querySelectorAll(".BMLayoutEditorViewSelectorSelected, .BMLayoutEditorViewSelectorConstrained").forEach((t=>{t.classList.remove("BMLayoutEditorViewSelectorSelected"),t.classList.remove("BMLayoutEditorViewSelectorConstrained")})),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),t)){this._clearOffsets();const i=this._drawConstraint(t,{withReferenceView:e.withReferenceView});return t.isConstraintCollection?t._views.forEach((t=>t._selector.classList.add("BMLayoutEditorViewSelectorConstrained"))):(t._sourceView&&t._sourceView._selector.classList.add("BMLayoutEditorViewSelectorConstrained"),t._targetView&&t._targetView._selector.classList.add("BMLayoutEditorViewSelectorConstrained")),this._useSettingsView?this.detailsView.layoutEditorDidSelectConstraint(t,{withReferenceView:e.withReferenceView}):(this.detailsNodeContent.innerHTML="",this.createSettingsForConstraint(t,{withReferenceView:e.withReferenceView})),i}},_constraintAffectingAttributeInList(t,{forView:e}){const i=e.localConstraints,o={};for(const e of t)o[e]=[];for(const n of i){if(!n._configuration.isActive)continue;let i=n.affectedAttributesForView(e).filter((e=>t.includes(e)));if(i.length)for(const t of i)o[t].push(n)}for(const t in o)if(o[t].length)return o[t][0]},backspacePressedWithEvent(t){if("INPUT"!=t.target.tagName&&(t.preventDefault(),this.selectedConstraint))if(this._activeSizeClass){const t=this.selectedConstraint._variations[this._activeSizeClass].isActive;void 0===t?this.selectedConstraint.setIsActive(NO,{forSizeClass:this._activeSizeClass}):t===NO?this.selectedConstraint.setIsActive(YES,{forSizeClass:this._activeSizeClass}):this.selectedConstraint.removeIsActiveVariationForSizeClass(this._activeSizeClass)}else this.selectedConstraint.isActive=!this.selectedConstraint.isActive},commandBackspacePressedWithEvent(t){"INPUT"!=t.target.tagName&&(t.preventDefault(),this.selectedConstraint&&(this.selectedConstraint.remove(),this.selectView(this.selectedConstraintReferenceView)))},setConstraintToEqualWithEvent(t){this.selectedConstraint&&(this.selectedConstraint._relation=BMLayoutConstraintRelation.Equals)},setConstraintToLessThanWithEvent(t){this.selectedConstraint&&(this.selectedConstraint._relation=BMLayoutConstraintRelation.LessThanOrEquals)},setConstraintToGreaterThanWithEvent(t){this.selectedConstraint&&(this.selectedConstraint._relation=BMLayoutConstraintRelation.GreaterThanOrEquals)},selectLeftConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if(e==this._view)return;if("INPUT"==t.target.tagName)return;t.preventDefault();let i,o,n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Leading,BMLayoutAttribute.Left,BMLayoutAttribute.CenterX],{forView:e});if(n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}if(this._constraintAffectingAttributeInList([BMLayoutAttribute.Trailing,BMLayoutAttribute.Right],{forView:e})&&(n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Width],{forView:e})),n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.top>e.frame.bottom||t.frame.bottom<e.frame.top)){const o=e.frame.origin.x-t.frame.right;o>=0&&(i?o<e.frame.origin.x-i.frame.right&&(i=t):i=t)}if(Math.abs(e.frame.origin.x-t.frame.origin.x)<16)if(o){Math.min(Math.abs(e.frame.origin.y-t.frame.bottom),Math.abs(e.frame.bottom-t.frame.origin.y))<Math.min(Math.abs(e.frame.origin.y-o.frame.bottom),Math.abs(e.frame.bottom-o.frame.origin.y))&&(o=t)}else o=t}if(i){const t=e.frame.origin.x-i.frame.right;if(t<=64&&i.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:t}))}const s=e.frame.origin.x-e.superview.frame.origin.x,a=i?e.frame.origin.x-i.frame.right:Number.MAX_SAFE_INTEGER,r=o?Math.min(Math.abs(e.frame.origin.y-o.frame.bottom),Math.abs(e.frame.bottom-o.frame.origin.y)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:o,secondAttribute:BMLayoutAttribute.Leading,constant:e.frame.origin.x-o.frame.origin.x})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:e.superview,secondAttribute:BMLayoutAttribute.Leading,constant:s}))},selectTopConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if("INPUT"==t.target.tagName)return;t.preventDefault();let i,o,n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Top,BMLayoutAttribute.CenterY],{forView:e});if(n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}if(this._constraintAffectingAttributeInList([BMLayoutAttribute.Bottom],{forView:e})&&(n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Height],{forView:e})),n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.left>e.frame.right||t.frame.right<e.frame.left)){const o=e.frame.origin.y-t.frame.bottom;o>=0&&(i?o<e.frame.origin.y-i.frame.bottom&&(i=t):i=t)}if(Math.abs(e.frame.origin.y-t.frame.origin.y)<16)if(o){Math.min(Math.abs(e.frame.origin.x-t.frame.right),Math.abs(e.frame.right-t.frame.origin.x))<Math.min(Math.abs(e.frame.origin.x-o.frame.right),Math.abs(e.frame.right-o.frame.origin.x))&&(o=t)}else o=t}if(i){const t=e.frame.origin.y-i.frame.bottom;if(t<=64&&i.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:t}))}const s=e.frame.origin.y-e.superview.frame.origin.y,a=i?e.frame.origin.y-i.frame.bottom:Number.MAX_SAFE_INTEGER,r=o?Math.min(Math.abs(e.frame.origin.x-o.frame.right),Math.abs(e.frame.right-o.frame.origin.x)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:o,secondAttribute:BMLayoutAttribute.Top,constant:e.frame.origin.y-o.frame.origin.y})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:e.superview,secondAttribute:BMLayoutAttribute.Top,constant:s}))},selectRightConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if("INPUT"==t.target.tagName)return;t.preventDefault();const i=this._constraintAffectingAttributeInList([BMLayoutAttribute.Trailing,BMLayoutAttribute.Right,BMLayoutAttribute.Width,BMLayoutAttribute.CenterX],{forView:e});if(i){const t=this.selectConstraint(i,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:i,withReferenceView:i._sourceView}))}let o,n;for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.top>e.frame.bottom||t.frame.bottom<e.frame.top)){const i=t.frame.origin.x-e.frame.right;i>=0&&(o?i<n.frame.origin.x-e.frame.right&&(o=t):o=t)}if(Math.abs(e.frame.right-t.frame.right)<16)if(n){Math.min(Math.abs(e.frame.origin.y-t.frame.bottom),Math.abs(e.frame.bottom-t.frame.origin.y))<Math.min(Math.abs(e.frame.origin.y-n.frame.bottom),Math.abs(e.frame.bottom-n.frame.origin.y))&&(n=t)}else n=t}if(o){const t=o.frame.origin.x-e.frame.right;if(t<=64&&o.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:o,secondAttribute:BMLayoutAttribute.Trailing,constant:-t}))}const s=e.superview.frame.right-e.frame.right,a=o?o.frame.origin.x-e.frame.right:Number.MAX_SAFE_INTEGER,r=n?Math.min(Math.abs(e.frame.origin.y-n.frame.bottom),Math.abs(e.frame.bottom-n.frame.origin.y)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:o,secondAttribute:BMLayoutAttribute.Leading,constant:-a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:n,secondAttribute:BMLayoutAttribute.Trailing,constant:e.frame.right-n.frame.right})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:e.superview,secondAttribute:BMLayoutAttribute.Trailing,constant:-s}))},selectBottomConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if("INPUT"==t.target.tagName)return;t.preventDefault();const i=this._constraintAffectingAttributeInList([BMLayoutAttribute.Bottom,BMLayoutAttribute.Height,BMLayoutAttribute.CenterY],{forView:e});if(i){const t=this.selectConstraint(i,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:i,withReferenceView:i._sourceView}))}let o,n;for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.left>e.frame.right||t.frame.right<e.frame.left)){const i=t.frame.origin.y-e.frame.bottom;i>=0&&(o?i<o.frame.origin.y-e.frame.bottom&&(o=t):o=t)}if(Math.abs(e.frame.bottom-t.frame.bottom)<16)if(n){Math.min(Math.abs(e.frame.origin.x-t.frame.right),Math.abs(e.frame.right-t.frame.origin.x))<Math.min(Math.abs(e.frame.origin.x-n.frame.right),Math.abs(e.frame.right-n.frame.origin.x))&&(n=t)}else n=t}if(o){const t=o.frame.origin.y-e.frame.bottom;if(t<=64&&o.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:o,secondAttribute:BMLayoutAttribute.Top,constant:-t}))}const s=e.superview.frame.bottom-e.frame.bottom,a=o?o.frame.origin.y-e.frame.bottom:Number.MAX_SAFE_INTEGER,r=n?Math.min(Math.abs(e.frame.origin.x-n.frame.right),Math.abs(e.frame.right-n.frame.origin.x)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:o,secondAttribute:BMLayoutAttribute.Top,constant:-a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:n,secondAttribute:BMLayoutAttribute.Bottom,constant:n.frame.bottom-e.frame.bottom})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:e.superview,secondAttribute:BMLayoutAttribute.Bottom,constant:-s}))},_clearOffsets(){this._leftOffset=-1,this._rightOffset=-1,this._centerXOffset=-1,this._widthOffset=-1,this._heightOffset=-1,this._topOffset=-1,this._bottomOffset=-1,this._centerYOffset=-1},_drawConstraint(t,e){let i=e.sourceConstraint;if(t.isConstraintCollection)return t.constituentConstraints.map((e=>this._drawConstraint(e,{withReferenceView:e._sourceView,sourceConstraint:t})));if(!t._targetView)return;if(!t._configuration.isActive)return;var o;let n=BMRectMakeWithNodeFrame(this._view.node);1!=this.scale&&(n=n.rectByMultiplyingWithScalar(1/this.scale));let s,a,r,l=e.withReferenceView;if(t._sourceView==l?(s=t._targetView,a="_sourceViewAttribute",r="_targetViewAttribute"):(s=t._sourceView,a="_targetViewAttribute",r="_sourceViewAttribute"),t._kind==BMLayoutConstraintKind.Horizontal){let e=BMRectMakeWithNodeFrame(l.node),h=BMRectMakeWithNodeFrame(s.node);1!=this.scale&&(e=e.rectByMultiplyingWithScalar(1/this.scale),h=h.rectByMultiplyingWithScalar(1/this.scale));let c=BMPointMake(0,0),d=BMPointMake(0,h.center.y-n.origin.y);switch(t[a]){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:c.x=e.origin.x-n.origin.x,o=++this._leftOffset;break;case BMLayoutAttribute.CenterX:c.x=e.center.x-n.origin.x,o=++this._centerXOffset;break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:c.x=e.right-n.origin.x,o=++this._rightOffset;break;case BMLayoutAttribute.Width:o=++this._widthOffset,c.y=e.bottom-12-8*o-n.origin.y,d.y=c.y,c.x=e.origin.x-n.origin.x,d.x=e.right-n.origin.x,this._drawHorizontalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}const u=Math.max(e.origin.y,h.origin.y);switch(c.y=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.bottom,h.bottom)-u)/2|0,e.origin.y+2,e.bottom-2)-n.origin.y,t[r]){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:d.x=h.origin.x-n.origin.x;break;case BMLayoutAttribute.CenterX:d.x=h.center.x-n.origin.x;break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:d.x=h.right-n.origin.x;break;case BMLayoutAttribute.Width:return c.y=h.bottom-12-8*o-n.origin.y,d.y=c.y,c.x=h.origin.x-n.origin.x,d.x=h.right-n.origin.x,void this._drawHorizontalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}return d.y=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.bottom,h.bottom)-u)/2|0,h.origin.y+2,h.bottom-2)-n.origin.y,this._drawHorizontalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}{let e=BMRectMakeWithNodeFrame(l.node),h=BMRectMakeWithNodeFrame(s.node);1!=this.scale&&(e=e.rectByMultiplyingWithScalar(1/this.scale),h=h.rectByMultiplyingWithScalar(1/this.scale));let c=BMPointMake(0,0),d=BMPointMake(h.center.x-n.origin.x,0);switch(t[a]){case BMLayoutAttribute.Top:c.y=e.origin.y-n.origin.y,o=++this._topOffset;break;case BMLayoutAttribute.CenterY:c.y=e.center.y-n.origin.y,o=++this._centerYOffset;break;case BMLayoutAttribute.Bottom:c.y=e.bottom-n.origin.y,o=++this._bottomOffset;break;case BMLayoutAttribute.Height:o=++this._heightOffset,c.x=e.right-12-8*o-n.origin.x,d.x=c.x,c.y=e.origin.y-n.origin.y,d.y=e.bottom-n.origin.y,this._drawVerticalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}const u=Math.max(e.origin.x,h.origin.x);switch(c.x=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.right,h.right)-u)/2|0,e.origin.x+2,e.right-2)-n.origin.x,t[r]){case BMLayoutAttribute.Top:d.y=h.origin.y-n.origin.y;break;case BMLayoutAttribute.CenterY:d.y=h.center.y-n.origin.y;break;case BMLayoutAttribute.Bottom:d.y=h.bottom-n.origin.y;break;case BMLayoutAttribute.Height:return c.x=h.right-12-8*o-n.origin.x,d.x=c.x,c.y=h.origin.y-n.origin.y,d.y=h.bottom-n.origin.y,void this._drawVerticalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}return d.x=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.right,h.right)-u)/2|0,h.origin.x+2,h.right-2)-n.origin.x,this._drawVerticalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}},_drawHorizontalConstraint(t,e){let i=e.sourceConstraint,o=e.fromSourcePoint,n=e.toPoint,s=Math.abs(o.x-n.x),a=Math.min(o.x,n.x),r=document.createElement("div");r.className="BMLayoutEditorConstraint BMLayoutEditorHorizontalConstraint",BMCopyProperties(r.style,{width:s+"px",height:"5px",left:a+"px",top:o.y+"px"}),t._relation==BMLayoutConstraintRelation.GreaterThanOrEquals?r.classList.add("BMLayoutEditorConstraintGreater"):t._relation==BMLayoutConstraintRelation.LessThanOrEquals&&r.classList.add("BMLayoutEditorConstraintLess");let l=document.createElement("div");l.className="BMLayoutEditorHorizontalConstraintLine",r.appendChild(l),t._priority<BMLayoutConstraintPriorityRequired&&l.classList.add("BMLayoutEditorConstraintLineOptional");let h=document.createElement("div");return h.className="BMLayoutEditorLeadLine BMLayoutEditorVerticalLeadLine",BMCopyProperties(h.style,{width:"1px",height:Math.abs(o.y-n.y)+"px",left:(n.x<o.x?n.x:n.x-1)+"px",top:Math.min(n.y,o.y)+"px"}),this._view.node.appendChild(h),this._view.node.appendChild(r),r.addEventListener("click",(o=>{this.selectConstraint(i||t,{withReferenceView:e.withReferenceView}),this._useSettingsView&&!this._detailsToolWindow._visible&&this._showConstantPopupAtPoint(BMPointMake(o.clientX,o.clientY),{forConstraint:i||t,withReferenceView:e.withReferenceView}),o.stopPropagation()})),{sourcePoint:o,targetPoint:n,kind:BMLayoutConstraintKind.Horizontal,node:r,leadLine:h,displaced:NO}},_drawVerticalConstraint(t,e){let i=e.sourceConstraint,o=e.fromSourcePoint,n=e.toPoint,s=Math.abs(o.y-n.y),a=Math.min(o.y,n.y),r=document.createElement("div");r.className="BMLayoutEditorConstraint BMLayoutEditorVerticalConstraint",BMCopyProperties(r.style,{width:"5px",height:s+"px",left:o.x+"px",top:a+"px"}),t._relation==BMLayoutConstraintRelation.GreaterThanOrEquals?r.classList.add("BMLayoutEditorConstraintGreater"):t._relation==BMLayoutConstraintRelation.LessThanOrEquals&&r.classList.add("BMLayoutEditorConstraintLess");let l=document.createElement("div");l.className="BMLayoutEditorVerticalConstraintLine",r.appendChild(l),t._priority<BMLayoutConstraintPriorityRequired&&l.classList.add("BMLayoutEditorConstraintLineOptional");let h=document.createElement("div");return h.className="BMLayoutEditorLeadLine BMLayoutEditorHorizontalLeadLine",BMCopyProperties(h.style,{width:Math.abs(o.x-n.x)+"px",height:"1px",top:(n.y<o.y?n.y:n.y-1)+"px",left:Math.min(n.x,o.x)+"px"}),this._view.node.appendChild(h),this._view.node.appendChild(r),r.addEventListener("click",(o=>{this.selectConstraint(i||t,{withReferenceView:e.withReferenceView}),this._useSettingsView&&!this._detailsToolWindow._visible&&this._showConstantPopupAtPoint(BMPointMake(o.clientX,o.clientY),{forConstraint:i||t,withReferenceView:e.withReferenceView}),o.stopPropagation()})),{sourcePoint:o,targetPoint:n,kind:BMLayoutConstraintKind.Vertical,node:r,leadLine:h,displaced:NO}},setValue(t,{forSetting:e}){const i=void 0===t;e.sizeClass?t?e.target[`set${BMStringByCapitalizingString(e.property)}`](t,{forSizeClass:e.sizeClass}):e.target[`remove${BMStringByCapitalizingString(e.property)}VariationForSizeClass`](e.sizeClass):e.target[e.property]=i?e.defaultValue:t},settingsBadgeForSizeClass(t){let e=document.createElement("div");switch(t){case BMLayoutSizeClass.phoneSizeClass():e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Portrait):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhonePortraitMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Landscape):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneLandscapeMini";break;case BMLayoutSizeClass.tabletSizeClass():e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Portrait):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletPortraitMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Landscape):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletLandscapeMini";break;default:e.className="BMLayoutEditorDetailsItemBadge",e.innerText=t._hashString}return e},readonlySettingWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorDetailsItem";let o,n=document.createElement("div");return n.className="BMLayoutEditorDetailsItemTitle",n.innerText=t,i.appendChild(n),e.value?(o=document.createElement("div"),o.className="BMLayoutEditorDetailsItemReadonlyValue",o.innerText=e.value,i.appendChild(o)):n.style.width="240px",e.action&&(o.classList.add("BMLayoutEditorDetailsItemReadonlyValueClickable"),o.addEventListener("click",e.action)),i},createVariableBooleanSettingWithName(t,{forConstraint:e,withReferenceView:i,propertyName:o,container:n}){let s=n||this.detailsNodeContent,a=o[0].toUpperCase()+o.substring(1);if(e){this.booleanSettingWithName(t,{value:e[o],indeterminate:NO,container:s,changeHandler:t=>e[o]=t});for(let i in e._variations)this._activeSizeClass&&i==this._activeSizeClass._hashString||o in e._variations[i]&&this.booleanSettingWithName(t,{value:e._variations[i][o],indeterminate:YES,container:s,sizeClass:e._variations[i].sizeClass,changeHandler:(t,i)=>{void 0!==t?e["set"+a](t,{forSizeClass:i}):e["remove"+a+"VariationForSizeClass"](i)}});if(this._activeSizeClass){let i;e._variations[this._activeSizeClass._hashString]&&o in e._variations[this._activeSizeClass._hashString]&&(i=e._variations[this._activeSizeClass._hashString][o]),this.booleanSettingWithName(t,{value:i,indeterminate:YES,container:s,sizeClass:this._activeSizeClass,changeHandler:(t,i)=>{void 0!==t?e["set"+a](t,{forSizeClass:i}):e["remove"+a+"VariationForSizeClass"](i)}})}}else{this.booleanSettingWithName(t,{value:i[o],indeterminate:NO,container:s,changeHandler:t=>i[o]=t});for(let e in i._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||o in i._variations[e]&&this.booleanSettingWithName(t,{value:i._variations[e][o],indeterminate:YES,container:s,sizeClass:i._variations[e].sizeClass,changeHandler:(t,e)=>{void 0!==t?i["set"+a](t,{forSizeClass:e}):i["remove"+a+"VariationForSizeClass"](e)}});if(this._activeSizeClass){let e;i._variations[this._activeSizeClass._hashString]&&o in i._variations[this._activeSizeClass._hashString]&&(e=i._variations[this._activeSizeClass._hashString][o]),this.booleanSettingWithName(t,{value:e,indeterminate:YES,container:s,sizeClass:this._activeSizeClass,changeHandler:(t,e)=>{void 0!==t?i["set"+a](t,{forSizeClass:e}):i["remove"+a+"VariationForSizeClass"](e)}})}}},booleanSettingWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorDetailsItem";let o=document.createElement("div");if(o.className="BMLayoutEditorDetailsItemTitle",o.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);o.insertBefore(t,o.lastChild)}i.appendChild(o);let n=document.createElement("label");n.className="BMWindowSwitch",n.innerHTML='<input type="checkbox" data-toggle="YES"> OFF\n <div class="BMWindowSwitchGutter">\n <div class="BMWindowSwitchKnob"></div>\n </div>\n ON',i.appendChild(n);let s=n.getElementsByTagName("input")[0];return s.checked=e.value,e.indeterminate&&(n.addEventListener("click",(t=>{t.target!==s&&s.checked&&(t.preventDefault(),t.stopPropagation(),s.indeterminate?(s.indeterminate=!1,s.checked=!1,e.changeHandler(!1,e.sizeClass)):(s.indeterminate=!0,e.changeHandler(void 0,e.sizeClass)))})),void 0===e.value&&(s.indeterminate=!0,s.checked=!0)),s.addEventListener("change",(t=>{let i=Boolean(t.target.checked);e.indeterminate&&s.indeterminate&&(i=void 0),e.changeHandler(i,e.sizeClass)})),e.container&&e.container.appendChild(i),i},textSettingWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorDetailsItem";let o=document.createElement("div");if(o.className="BMLayoutEditorDetailsItemTitle",o.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);o.insertBefore(t,o.lastChild)}i.appendChild(o);let n=document.createElement("input");n.type="text",n.className="BMWindowInput BMLayoutEditorDetailsItemTextValue",n.value=e.value,i.appendChild(n);let s=!0;return n.addEventListener("input",(t=>{let i=n.value,o=e.changeHandler(i);o!=s&&(s=o,o?n.classList.remove("BMWindowInputInvalid"):n.classList.add("BMWindowInputInvalid"))})),i},stringSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=e.withReferenceView,s=o[0].toUpperCase()+o.substring(1),a=document.createElement("div");a.className="BMLayoutEditorDetailsItem";let r=document.createElement("div");if(r.className="BMLayoutEditorDetailsItemTitle",r.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);r.insertBefore(t,r.lastChild)}a.appendChild(r);let l=document.createElement("input");return l.type="text",l.className="BMWindowInput BMLayoutEditorDetailsItemTextValue",l.value=e.value,a.appendChild(l),l.addEventListener("input",(t=>{let a=l.value;a?i?(e.sizeClass?i[`set${s}`](a,{forSizeClass:e.sizeClass}):i[o]=a,i._updateConfiguration(),i._constraint=void 0,i._constituentConstraints=void 0,i._sourceView?i._sourceView.needsLayout=YES:i._views[0].needsLayout=YES):(e.sizeClass?n[`set${s}`](a,{forSizeClass:e.sizeClass}):n[o]=a,n.needsLayout=YES):e.sizeClass&&(i?(i[`remove${s}VariationForSizeClass`](e.sizeClass),i._updateConfiguration()):(n[`remove${s}VariationForSizeClass`](e.sizeClass),n._updateConfiguration()))})),a},createVariableStringSettingWithName(t,{forConstraint:e,withReferenceView:i,propertyName:o,container:n}){let s=n||this.detailsNodeContent;if(e){s.appendChild(this.stringSettingWithName(t,{value:e[o],forConstraint:e,propertyName:o,withReferenceView:i}));for(let n in e._variations)this._activeSizeClass&&n==this._activeSizeClass._hashString||o in e._variations[n]&&s.appendChild(this.stringSettingWithName(t,{value:e._variations[n][o],forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:e._variations[n].sizeClass}));if(this._activeSizeClass){let n="";e._variations[this._activeSizeClass._hashString]&&o in e._variations[this._activeSizeClass._hashString]&&(n=e._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.stringSettingWithName(t,{value:n,forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}else{s.appendChild(this.stringSettingWithName(t,{value:i[o],propertyName:o,withReferenceView:i}));for(let e in i._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||o in i._variations[e]&&s.appendChild(this.stringSettingWithName(t,{value:i._variations[e][o],propertyName:o,withReferenceView:i,sizeClass:i._variations[e].sizeClass}));if(this._activeSizeClass){let e="";i._variations[this._activeSizeClass._hashString]&&o in i._variations[this._activeSizeClass._hashString]&&(e=i._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.stringSettingWithName(t,{value:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}},createVariableNumericSettingWithName(t,{forConstraint:e,withReferenceView:i,propertyName:o,container:n}){let s=n||this.detailsNodeContent;if(e){s.appendChild(this.numericSettingWithName(t,{value:e[o],forConstraint:e,propertyName:o,withReferenceView:i}));for(let n in e._variations)this._activeSizeClass&&n==this._activeSizeClass._hashString||o in e._variations[n]&&s.appendChild(this.numericSettingWithName(t,{value:e._variations[n][o],forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:e._variations[n].sizeClass}));if(this._activeSizeClass){let n="";e._variations[this._activeSizeClass._hashString]&&o in e._variations[this._activeSizeClass._hashString]&&(n=e._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.numericSettingWithName(t,{value:n,forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}else{s.appendChild(this.numericSettingWithName(t,{value:i[o],propertyName:o,withReferenceView:i}));for(let e in i._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||o in i._variations[e]&&s.appendChild(this.numericSettingWithName(t,{value:i._variations[e][o],propertyName:o,withReferenceView:i,sizeClass:i._variations[e].sizeClass}));if(this._activeSizeClass){let e="";i._variations[this._activeSizeClass._hashString]&&o in i._variations[this._activeSizeClass._hashString]&&(e=i._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.numericSettingWithName(t,{value:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}},constantSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=e.withReferenceView,s=o[0].toUpperCase()+o.substring(1),a=document.createElement("div");a.className="BMLayoutEditorDetailsItem";let r=document.createElement("div");if(r.className="BMLayoutEditorDetailsItemTitle",r.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);r.insertBefore(t,r.lastChild)}a.appendChild(r);let l=document.createElement("input");l.type="text",l.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",l.value=e.value,a.appendChild(l);let h,c,d=[],u=[];return l.addEventListener("focus",(async t=>{l.select(),d=[];const e=Object.keys(this.layoutVariableProvider.layoutVariables),i=new Set;e.forEach((t=>i.add(t)));let o=[];for(const t of i)d.unshift(t),d.push("-"+t);u=d,c=-1;for(const t of d)o.push(this.constraintOptionWithLabel(t,{action:()=>{h=void 0,l.value=t,l.dispatchEvent(new Event("input")),l.blur()}}));if(d.length){let t=BMRectMakeWithNodeFrame(l),e=BMPointMake(t.origin.x,t.bottom);h=this.showMenuAtPoint(e,{withOptions:o,kind:BMMenuKind.PullDownMenu}),h.classList.add("BMLayoutEditorConstantSuggestions"),h.parentNode.classList.add("BMLayoutEditorConstantSuggestionsOverlay"),h.addEventListener("mousedown",(t=>t.preventDefault()),YES)}const n=t=>t.preventDefault();l.addEventListener("mouseup",n),await new Promise((t=>setTimeout(t,200))),l.removeEventListener("mouseup",n)})),l.addEventListener("keydown",(t=>{if("ArrowDown"==t.code||"ArrowUp"==t.code){if(t.preventDefault(),0==u.length)return;c="ArrowUp"==t.code?Math.max((c||0)-1,0):Math.min((isNaN(c)?-1:c)+1,u.length-1);for(const t of h.querySelectorAll(".BMLayoutEditorConstraintPopupOptionHighlighted"))t.classList.remove("BMLayoutEditorConstraintPopupOptionHighlighted");h.childNodes[c].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted")}"Enter"==t.code&&(!isNaN(c)&&u.length&&(l.value=u[c],l.dispatchEvent(new Event("input"))),l.blur())})),l.addEventListener("input",(t=>{const a=parseFloat(l.value),r=isNaN(a)?l.value:a;if(h){u=d.filter((t=>t.toLowerCase().startsWith(l.value.toLowerCase()))),h.innerHTML="",c=0;for(const t of u)h.appendChild(this.constraintOptionWithLabel(t,{action:()=>{h=void 0,l.value=t,l.dispatchEvent(new Event("input"))}}));u.length?(h.childNodes[0].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted"),h.style.display="block"):h.style.display="none"}l.value?i?(e.sizeClass?i[`set${s}`](r,{forSizeClass:e.sizeClass}):i[o]=r,i._updateConfiguration(),i._constraint=void 0,i._constituentConstraints=void 0,i._sourceView?i._sourceView.needsLayout=YES:i._views[0].needsLayout=YES):(e.sizeClass?n[`set${s}`](a,{forSizeClass:e.sizeClass}):n[o]=a,n.needsLayout=YES):e.sizeClass&&(i?(i[`remove${s}VariationForSizeClass`](e.sizeClass),i._updateConfiguration()):(n[`remove${s}VariationForSizeClass`](e.sizeClass),n._updateConfiguration()))})),l.addEventListener("blur",(t=>{h&&h.parentNode.dispatchEvent(new Event("click"))})),a},numericSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=e.withReferenceView,s=o[0].toUpperCase()+o.substring(1),a=document.createElement("div");a.className="BMLayoutEditorDetailsItem";let r=document.createElement("div");if(r.className="BMLayoutEditorDetailsItemTitle",r.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);r.insertBefore(t,r.lastChild)}a.appendChild(r);let l=document.createElement("input");return l.type="number",l.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",l.value=e.value,a.appendChild(l),l.addEventListener("input",(t=>{let a=parseFloat(l.value);isNaN(a)?e.sizeClass&&(i?(i[`remove${s}VariationForSizeClass`](e.sizeClass),i._updateConfiguration()):(n[`remove${s}VariationForSizeClass`](e.sizeClass),n._updateConfiguration())):i?(e.sizeClass?i[`set${s}`](a,{forSizeClass:e.sizeClass}):i[o]=a,i._updateConfiguration(),i._constraint=void 0,i._constituentConstraints=void 0,i._sourceView?i._sourceView.needsLayout=YES:i._views[0].needsLayout=YES):(e.sizeClass?n[`set${s}`](a,{forSizeClass:e.sizeClass}):n[o]=a,n.needsLayout=YES)})),a},optionNamed(t,e){let i=document.createElement("option");return i.value=e?e.value:t,i.innerText=t,e&&e.selected&&(i.selected=YES),i},dropdownSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=document.createElement("div");n.className="BMLayoutEditorDetailsItem";let s=document.createElement("div");s.className="BMLayoutEditorDetailsItemTitle",s.innerText=t,n.appendChild(s);let a=document.createElement("select");return a.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",i._kind==BMLayoutConstraintKind.Horizontal?i._sourceViewAttribute===BMLayoutAttribute.Width?a.appendChild(this.optionNamed(i._sourceViewAttribute)):(a.appendChild(this.optionNamed(BMLayoutAttribute.Leading)),a.appendChild(this.optionNamed(BMLayoutAttribute.CenterX)),a.appendChild(this.optionNamed(BMLayoutAttribute.Trailing)),a.appendChild(this.optionNamed(BMLayoutAttribute.Left)),a.appendChild(this.optionNamed(BMLayoutAttribute.Right))):i._sourceViewAttribute===BMLayoutAttribute.Height?a.appendChild(this.optionNamed(i._sourceViewAttribute)):(a.appendChild(this.optionNamed(BMLayoutAttribute.Top)),a.appendChild(this.optionNamed(BMLayoutAttribute.CenterY)),a.appendChild(this.optionNamed(BMLayoutAttribute.Bottom))),a.value=e.value,n.appendChild(a),a.addEventListener("change",(t=>{i[o]=a.value,i._cassowaryConstraint=void 0,i._constituentConstraints=void 0,i._sourceView.needsLayout=YES})),n},equalitySettingWithName(t,e){let i=e.forConstraint,o=document.createElement("div");o.className="BMLayoutEditorDetailsItem";let n=document.createElement("div");n.className="BMLayoutEditorDetailsItemTitle",n.innerText=t,o.appendChild(n);let s=document.createElement("select");return s.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",s.appendChild(this.optionNamed("=",{value:BMLayoutConstraintRelation.Equals,selected:i._relation==BMLayoutConstraintRelation.Equals})),s.appendChild(this.optionNamed("≥",{value:BMLayoutConstraintRelation.GreaterThanOrEquals,selected:i._relation==BMLayoutConstraintRelation.GreaterThanOrEquals})),s.appendChild(this.optionNamed("≤",{value:BMLayoutConstraintRelation.LessThanOrEquals,selected:i._relation==BMLayoutConstraintRelation.LessThanOrEquals})),s.value=""+e.value,o.appendChild(s),s.addEventListener("change",(t=>{i._relation=parseInt(s.value,10),i._sourceView.needsLayout=YES})),o},buttonSettingWithName(t,e){var i;e.class?(i=document.createElement("div")).className="BMLayoutEditorImageButton "+e.class:((i=document.createElement("button")).className="BMWindowButton",i.innerText=t);return i.addEventListener("click",e.action),i},settingsDivider(){let t=document.createElement("div");return t.className="BMLayoutEditorDetailsDivider",t},viewSettingWithView(t){let e=document.createElement("div");return e.classList.add("BMLayoutEditorDetailsConstraintItem"),e.innerText=t.debuggingName||t.node.id,e.addEventListener("click",(e=>this.selectView(t))),e},createAdditionalSettingsForConstraint(t,e){},_createConstantSettingsForConstraint(t,e){let i,o=this.detailsNodeContent;o.appendChild(i=this.constantSettingWithName("Constant:",{value:t._constant,forConstraint:t,propertyName:"_constant",withReferenceView:e.withReferenceView}));for(let i in t._variations)this._activeSizeClass&&i==this._activeSizeClass._hashString||"constant"in t._variations[i]&&o.appendChild(this.constantSettingWithName("Constant:",{value:t._variations[i].constant,forConstraint:t,propertyName:"constant",withReferenceView:e.withReferenceView,sizeClass:t._variations[i].sizeClass}));if(this._activeSizeClass){let n="";t._variations[this._activeSizeClass._hashString]&&"constant"in t._variations[this._activeSizeClass._hashString]&&(n=t._variations[this._activeSizeClass._hashString].constant),o.appendChild(i=this.constantSettingWithName("Constant:",{value:n,forConstraint:t,propertyName:"constant",withReferenceView:e.withReferenceView,sizeClass:this._activeSizeClass}))}requestAnimationFrame((t=>i.querySelectorAll("input")[0].focus()),i.querySelectorAll("input")[0].select())},_createPrioritySettingsForConstraint(t,e){let i=this.detailsNodeContent;i.appendChild(this.numericSettingWithName("Priority:",{value:t._priority,forConstraint:t,propertyName:"_priority",withReferenceView:e.withReferenceView}));for(let o in t._variations)this._activeSizeClass&&o==this._activeSizeClass._hashString||"priority"in t._variations[o]&&i.appendChild(this.numericSettingWithName("Priority:",{value:t._variations[o].priority,forConstraint:t,propertyName:"priority",withReferenceView:e.withReferenceView,sizeClass:t._variations[o].sizeClass}));if(this._activeSizeClass){let o="";t._variations[this._activeSizeClass._hashString]&&"priority"in t._variations[this._activeSizeClass._hashString]&&(o=t._variations[this._activeSizeClass._hashString].priority),i.appendChild(this.numericSettingWithName("Priority:",{value:o,forConstraint:t,propertyName:"priority",withReferenceView:e.withReferenceView,sizeClass:this._activeSizeClass}))}},_createIsActiveSettingsForConstraint(t,e){let i=this.detailsNodeContent;this.booleanSettingWithName("Active:",{value:t._isActive,container:i,changeHandler:e=>{t.isActive=e,t._updateConfiguration()}});for(let e in t._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||"isActive"in t._variations[e]&&this.booleanSettingWithName("Active:",{value:t._variations[e].isActive,indeterminate:YES,container:i,sizeClass:t._variations[e].sizeClass,changeHandler:(e,i)=>{void 0===e?t.removeIsActiveVariationForSizeClass(i):t.setIsActive(e,{forSizeClass:i}),t._updateConfiguration()}});if(this._activeSizeClass){let e;t._variations[this._activeSizeClass._hashString]&&"isActive"in t._variations[this._activeSizeClass._hashString]&&(e=t._variations[this._activeSizeClass._hashString].isActive),this.booleanSettingWithName("Active:",{value:e,indeterminate:YES,container:i,sizeClass:this._activeSizeClass,changeHandler:(e,i)=>{void 0===e?t.removeIsActiveVariationForSizeClass(i):t.setIsActive(e,{forSizeClass:i}),t._updateConfiguration()}})}},createSettingsForConstraint(t,e){if(this._disableSettingsKeyboardShortcuts(),t.isConstraintCollection)return this.createSettingsForConstraintCollection(t,e);var i=this.detailsNodeContent;i.classList.remove("BMLayoutEditorViewDetails");BMLayoutConstraintRelation.Equals,BMLayoutConstraintRelation.GreaterThanOrEquals,BMLayoutConstraintRelation.LessThanOrEquals;i.appendChild(this.readonlySettingWithName("First View:",{value:t._sourceView.debuggingName||t._sourceView.node.id,action:e=>this.selectView(t._sourceView)})),i.appendChild(this.dropdownSettingWithName("Attribute:",{value:t._sourceViewAttribute,forConstraint:t,propertyName:"_sourceViewAttribute",withReferenceView:e.withReferenceView})),i.appendChild(this.settingsDivider()),i.appendChild(this.equalitySettingWithName("Relation:",{value:t._relation,forConstraint:t,withReferenceView:e.withReferenceView})),i.appendChild(this.settingsDivider()),t._targetView&&(i.appendChild(this.numericSettingWithName("Multiplier:",{value:t._multiplier,forConstraint:t,propertyName:"_multiplier",withReferenceView:e.withReferenceView})),i.appendChild(this.readonlySettingWithName("Second View:",{value:t._targetView.debuggingName||t._targetView.node.id,action:e=>this.selectView(t._targetView)})),i.appendChild(this.dropdownSettingWithName("Attribute:",{value:t._targetViewAttribute,forConstraint:t,propertyName:"_targetViewAttribute",withReferenceView:e.withReferenceView}))),this._createConstantSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()),this._createPrioritySettingsForConstraint(t,e),this._createIsActiveSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()),this.createAdditionalSettingsForConstraint(t,{withReferenceView:e.withReferenceView,inContainer:i}),i.appendChild(this.buttonSettingWithName("Remove Constraint",{action:i=>{this.tree.removeConstraint(t),t.remove(),this.selectView(e.withReferenceView)}}))},createSettingsForConstraintCollection(t,e){var i=this.detailsNodeContent;i.classList.remove("BMLayoutEditorViewDetails"),t._hasEditableConstant&&(this._createConstantSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()));let o=this.readonlySettingWithName("Affected Views",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px",i.appendChild(o),t._views.forEach((t=>i.appendChild(this.viewSettingWithView(t)))),i.appendChild(this.settingsDivider()),this._createPrioritySettingsForConstraint(t,e),this._createIsActiveSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()),this.createAdditionalSettingsForConstraint(t,{withReferenceView:e.withReferenceView,inContainer:i}),i.appendChild(this.buttonSettingWithName("Remove Constraint",{action:e=>{this.tree.removeConstraint(t);let i=t._views[0];t.remove(),this.selectView(i)}}))},constraintSettingWithConstraint(t,e){let i=document.createElement("div");return i.classList.add("BMLayoutEditorDetailsConstraintItem"),i.innerText=t.toString(),t._priority>500&&t._priority<1e3?i.classList.add("BMLayoutEditorDetailsConstraintItemStrong"):t._priority<=500&&i.classList.add("BMLayoutEditorDetailsConstraintItemWeak"),e.internal?i.classList.add("BMLayoutEditorDetailsConstraintItemReadonly"):i.addEventListener("click",(i=>this.selectConstraint(t,{withReferenceView:e.referenceView}))),i},_settingsKeyboardShortcuts:void 0,_disableSettingsKeyboardShortcuts(){this._settingsKeyboardShortcuts&&this._settingsKeyboardShortcuts.forEach((t=>{window.removeEventListener("keydown",t,YES),window.removeEventListener("keyup",t,YES),window.removeEventListener("keypress",t,YES)})),this._settingsKeyboardShortcuts=[]},createSettingsForView(t){this._disableSettingsKeyboardShortcuts();var e=this.detailsNodeContent;e.classList.add("BMLayoutEditorViewDetails");let i=document.createElement("div");i.className="BMLayoutEditorViewTabDetails",e.appendChild(i),e=i,this.createVariableNumericSettingWithName("Opacity:",{withReferenceView:t,propertyName:"opacity",container:e}),this.createVariableBooleanSettingWithName("Visible:",{withReferenceView:t,propertyName:"isVisible",container:e}),this.createVariableStringSettingWithName("CSS Class:",{withReferenceView:t,propertyName:"CSSClass",container:e}),e.appendChild(this.settingsDivider()),e.appendChild(this.numericSettingWithName("Compression Resistance:",{value:t.compressionResistance,propertyName:"compressionResistance",withReferenceView:t})),e.appendChild(this.numericSettingWithName("Expansion Resistance:",{value:t.expansionResistance,propertyName:"expansionResistance",withReferenceView:t})),e.appendChild(this.settingsDivider()),e.appendChild(this.readonlySettingWithName("Intrinsic Size:",{value:t.supportsIntrinsicSize?"Supported":"Unsupported"}));let o={},n={},s={},a=NO,r=NO;t.localConstraints.forEach((e=>{let i=e.categoryKind;if(!e._configuration.isActive)return r=YES,s[i]=s[i]||[],void s[i].push(e);if(!e._isConstraintCollection){if(e._sourceView==t&&e._targetView&&e._targetView.isDescendantOfView(t))return n[i]=n[i]||[],n[i].push(e),void(a=YES);if(e._targetView==t&&e._sourceView.isDescendantOfView(t))return n[i]=n[i]||[],n[i].push(e),void(a=YES)}o[i]=o[i]||[],o[i].push(e)})),Object.keys(o).sort().forEach((i=>{e.appendChild(this.settingsDivider());let n=this.readonlySettingWithName(i+" Constraints",{value:""});n.childNodes[0].style.textAlign="left",n.childNodes[0].style.paddingLeft="16px",e.appendChild(n),o[i].forEach((i=>e.appendChild(this.constraintSettingWithConstraint(i,{referenceView:t}))))}));let l=NO,h=NO;if(a){let i=document.createElement("div");i.classList.add("BMLayoutEditorViewDetails"),i.classList.add("BMLayoutEditorSubviewDetails"),i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),i.style.height="0px",e.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Subview Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px";let s=document.createElement("div");s.classList.add("BMDisclosureTriangle"),o.insertBefore(s,o.childNodes[0]),s.addEventListener("click",(e=>{i.classList.contains("BMLayoutEditorSubviewDetailsCollapsed")?(l=YES,s.classList.add("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:i.scrollHeight+"px"},{duration:200,easing:"easeInOutQuad",complete:()=>i.classList.remove("BMLayoutEditorSubviewDetailsCollapsed")})):(l=NO,i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),s.classList.remove("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:"0px"},{duration:200,easing:"easeInOutQuad"})),this._drawConstraintsForView(t,{includesInactiveConstraints:h,includesSubviewConstraints:l}),e.stopPropagation()})),e.appendChild(o),Object.keys(n).sort().forEach((e=>{i.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Subview "+e+" Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px",i.appendChild(o),n[e].forEach((e=>i.appendChild(this.constraintSettingWithConstraint(e,{referenceView:t}))))})),e.appendChild(i)}if(r){let i=document.createElement("div");i.classList.add("BMLayoutEditorViewDetails"),i.classList.add("BMLayoutEditorSubviewDetails"),i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),i.style.height="0px",e.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Inactive Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px";let n=document.createElement("div");n.classList.add("BMDisclosureTriangle"),o.insertBefore(n,o.childNodes[0]),n.addEventListener("click",(e=>{i.classList.contains("BMLayoutEditorSubviewDetailsCollapsed")?(h=YES,n.classList.add("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:i.scrollHeight+"px"},{duration:200,easing:"easeInOutQuad",complete:()=>i.classList.remove("BMLayoutEditorSubviewDetailsCollapsed")})):(h=NO,i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),n.classList.remove("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:"0px"},{duration:200,easing:"easeInOutQuad"})),this._drawConstraintsForView(t,{includesInactiveConstraints:h,includesSubviewConstraints:l}),e.stopPropagation()})),e.appendChild(o),Object.keys(s).sort().forEach((e=>{i.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Inactive "+e+" Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px",i.appendChild(o),s[e].forEach((e=>i.appendChild(this.constraintSettingWithConstraint(e,{referenceView:t}))))})),e.appendChild(i)}let c=t.internalConstraints();if(c.length){e.appendChild(this.settingsDivider());let i=this.readonlySettingWithName("Internal Constraints",{value:""});i.childNodes[0].style.textAlign="left",i.childNodes[0].style.paddingLeft="16px",e.appendChild(i),c.forEach((i=>e.appendChild(this.constraintSettingWithConstraint(i,{referenceView:t,internal:YES}))))}let d=NO,u=NO,p=NO;e.appendChild(this.settingsDivider());let g=this.buttonSettingWithName("Deactivate Constraints",{action:e=>{if(d&&u&&p)new Set(t.rootView.allConstraints).forEach((t=>t.remove()));else if(d)for(let e of t.localConstraints)u?e.remove():this._activeSizeClass?e.setIsActive(NO,{forSizeClass:this._activeSizeClass}):e.isActive=NO;else Object.keys(o).forEach((t=>{for(let e of o[t])u?e.remove():this._activeSizeClass?e.setIsActive(NO,{forSizeClass:this._activeSizeClass}):e.isActive=NO}));this.selectView(t)}});e.appendChild(g),g.addEventListener("contextmenu",(t=>t.preventDefault()));let w=t=>{switch(t.key){case"Alt":d="keydown"==t.type;break;case"Shift":u="keydown"==t.type;break;case"Control":p="keydown"==t.type}g.innerText=d?u?p?"Reset Layout":"Remove All Constraints":"Deactivate All Constraints":u?"Remove Constraints":"Deactivate Constraints"};window.addEventListener("keydown",w,YES),window.addEventListener("keyup",w,YES),this._settingsKeyboardShortcuts.push(w)},equalConstraintSettingWithName(t,e){return this.buttonSettingWithName(t,{class:e.class,action:t=>{let i=BMEqualAttributeLayoutConstraint.constraintWithAttribute(e.attribute,{forViews:this.selectedViews,_internal:t.shiftKey});t.shiftKey?i.constituentConstraints.forEach((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(i)}})},createSettingsForMultipleViews(){this._disableSettingsKeyboardShortcuts(),this.detailsNodeTitle.innerText=this.selectedViews.length+" selected",this.detailsNodeContent.innerHTML="";let t=this.detailsNodeContent,e=this.readonlySettingWithName("Align Horizontal",{value:""});e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(e);let i=document.createElement("div");i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Top",{class:"BMLayoutEditorImageButtonAlignAlignTop",attribute:BMLayoutAttribute.Top})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterY",attribute:BMLayoutAttribute.CenterY})),i.appendChild(this.equalConstraintSettingWithName("Align Bottom",{class:"BMLayoutEditorImageButtonAlignBottom",attribute:BMLayoutAttribute.Bottom})),t.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Distribute Horizontal",{value:""});e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(o),i=document.createElement("div"),i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Width",{class:"BMLayoutEditorImageButtonEqualWidth",attribute:BMLayoutAttribute.Width})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Align Vertical",{value:""}),e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(o),i=document.createElement("div"),i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Leading",{class:"BMLayoutEditorImageButtonAlignLeading",attribute:BMLayoutAttribute.Leading})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterX",attribute:BMLayoutAttribute.CenterX})),i.appendChild(this.equalConstraintSettingWithName("Align Trailing",{class:"BMLayoutEditorImageButtonAlignTrailing",attribute:BMLayoutAttribute.Trailing})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Distribute Vertical",{value:""}),e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(o),i=document.createElement("div"),i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualVerticalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualVerticalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Height",{class:"BMLayoutEditorImageButtonEqualHeight",attribute:BMLayoutAttribute.Height}))},bringToFrontAnimated:function(t,e){this._visible=YES,t=void 0===t?YES:t,(window.Velocity||$.Velocity)(this._blocker,"stop"),(window.Velocity||$.Velocity)(this._window,"stop");var i=this;if(i.delegate&&i.delegate.windowWillAppear&&i.delegate.windowWillAppear(i),t){this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",BM_USE_VELOCITY2?this._blocker.velocity({opacity:1,translateZ:0,display:"block"},{duration:500,easing:"easeInOutQuint",complete:function(){i._blocker.style.pointerEvents="",i._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()}}):(window.Velocity||$.Velocity)(this._blocker,{opacity:1,translateZ:0},{duration:500,easing:"easeInOutQuint",display:"block",complete:function(){i._blocker.style.pointerEvents="",i._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()}});let o=this.frame.copy(),n=BMRectMakeWithNodeFrame(this._rootNode);this.frame=n,this.treeWidthConstraint.constant=0,this.detailsWidthConstraint.constant=0,this.workspaceToolbarHeightConstraint.constant=0,this.node.style.opacity=1,this.node.style.display="block",this._view.node.style.display="block",this.workspaceNode.appendChild(this._view.node),this.layout(),BMAnimateWithBlock((()=>{this.leftConstraint.constant=o.origin.x,this.topConstraint.constant=o.origin.y,this.widthConstraint.constant=o.size.width,this.heightConstraint.constant=o.size.height,this.treeWidthConstraint.constant=256,this.detailsWidthConstraint.constant=344,this.workspaceToolbarHeightConstraint.constant=this._useSettingsView?32:64,this.layout(),BMCopyProperties(this.node.style,{left:n.origin.x+"px",top:n.origin.y+"px",width:n.size.width+"px",height:n.size.height+"px"});let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("left",{withValue:o.origin.x+"px"}),t.registerBuiltInProperty("top",{withValue:o.origin.y+"px"}),t.registerBuiltInProperty("width",{withValue:o.size.width+"px"}),t.registerBuiltInProperty("height",{withValue:o.size.height+"px"}),this._frame=o}),{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:()=>{for(const e of i._toolWindows)e.opensAutomatically&&e.bringToFrontAnimated(t)}})}else{this._blocker.style.opacity=1,this._blocker.style.display="block",this._blocker.style.webkitBackdropFilter="blur(15px)",this._blocker.style.backdropFilter="blur(15px)",this._window.style.opacity=1,BMHook(this._window,{scaleX:1,scaleY:1}),this._window.style.display="block",this._blocker.style.pointerEvents="",this._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i);for(const e of this._toolWindows)e.bringToFrontAnimated(t);e&&e.completionHandler&&e.completionHandler()}},dismissAnimated:async function(t,e){var i;e=e||{},this._disableSettingsKeyboardShortcuts(),e.completionHandler&&(i=e.completionHandler),e.completionHandler=()=>{i&&i()},window.removeEventListener("resize",this.resizeListener),t=void 0===t?YES:t,(window.Velocity||$.Velocity)(this._blocker,"stop"),(window.Velocity||$.Velocity)(this._window,"stop");var o=this;this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",o.delegate&&o.delegate.windowWillClose&&o.delegate.windowWillClose(o);for(const e of this._toolWindows)e.dismissAnimated(t);if(t){(window.Velocity||$.Velocity)(this._blocker,{opacity:0,translateZ:0},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:function(){o.delegate&&o.delegate.windowDidClose&&o.delegate.windowDidClose(o),e&&e.completionHandler&&e.completionHandler()}});let t=this.frame.copy(),i=BMRectMakeWithNodeFrame(this._rootNode).integralRect;this.node.classList.add("BMLayoutEditorNoShadow"),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove())),await 0,BMAnimateWithBlock((()=>{this.leftConstraint.constant=i.origin.x,this.topConstraint.constant=i.origin.y,this.widthConstraint.constant=i.size.width,this.heightConstraint.constant=i.size.height,this.treeWidthConstraint.constant=0,this.detailsWidthConstraint.constant=0,this.workspaceToolbarHeightConstraint.constant=0,this._staticWorkspaceSize=void 0,this.view._requiredViewport=void 0,this.workspaceLeft.remove(),this.workspaceTop.remove(),this.workspaceWidth.remove(),this.workspaceHeight.remove(),(this.workspaceLeft=this.workspace.left.equalTo(this.workspaceWrapperView.left)).isActive=YES,(this.workspaceTop=this.workspace.top.equalTo(this.workspaceWrapperView.top)).isActive=YES,(this.workspaceWidth=this.workspace.width.equalTo(this.workspaceWrapperView.width)).isActive=YES,(this.workspaceHeight=this.workspace.height.equalTo(this.workspaceWrapperView.height)).isActive=YES,this.layout(),this.panOffset=BMPointMake(0,0),this.scale=1,BMCopyProperties(this.node.style,{left:t.origin.x+"px",top:t.origin.y+"px",width:t.size.width+"px",height:t.size.height+"px"});let e=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});e.registerBuiltInProperty("left",{withValue:i.origin.x+"px"}),e.registerBuiltInProperty("top",{withValue:i.origin.y+"px"}),e.registerBuiltInProperty("width",{withValue:i.size.width+"px"}),e.registerBuiltInProperty("height",{withValue:i.size.height+"px"}),this._frame=t}),{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:()=>{this._view.layoutEditor=void 0,this._rootNode.appendChild(this._view.node),this._view.allSubviews.forEach((t=>t.node.classList.remove("BMLayoutEditorManagedView"))),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove()))}}),this._visible=NO}else this._blocker.style.opacity=0,this._blocker.style.display="none",this._window.style.opacity=0,this._window.style.display="none",this._visible=NO,this._view.layoutEditor=void 0,this._rootNode.appendChild(this._view.node),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove())),this._view.allSubviews.forEach((t=>t.node.classList.remove("BMLayoutEditorManagedView"))),o.delegate&&o.delegate.windowDidClose&&o.delegate.windowDidClose(o),e&&e.completionHandler&&e.completionHandler()}}),BMLayoutEditor.editorForView=function(t){return(new BMLayoutEditor).initWithView(t)},BMViewLayoutEditor.editorForView=function(t){return(new BMViewLayoutEditor).initWithView(t)},BMViewLayoutEditor.prototype=Object.create(BMLayoutEditor.prototype),_BMLayoutEditorTree.prototype=BMExtend(Object.create(BMView.prototype),{constructor:_BMLayoutEditorTree,_node:void 0,_view:void 0,_editor:void 0,_viewNodeMap:void 0,_constraintNodeMap:void 0,initWithView(t,e){return BMView.prototype.initWithDOMNode.call(this,e.node),this._view=t,this._editor=e.editor,this._viewNodeMap=new Map,this._constraintNodeMap=new Map,this._buildTree(),this},_buildTree(){this._node.innerHTML="",this._node.appendChild(this.treeNodeForView(this._view))},treeNodeForView(t){let e=document.createElement("div");e.classList.add("BMLayoutTreeView");let i=document.createElement("div");i.classList.add("BMLayoutTreeViewTitle"),i.classList.add("BMLayoutTreeViewEntity"),e.appendChild(i),this._editor.initDragEventListenerForNode(i,{view:t}),this._viewNodeMap.set(t,i);let o=document.createElement("div");o.classList.add("BMDisclosureTriangle"),o.classList.add("BMDisclosureTriangleExpanded"),i.appendChild(o),i.appendChild(document.createTextNode(t.debuggingName||t.node.id));let n=document.createElement("div");n.classList.add("BMLayoutTreeViewContainer"),n.classList.add("BMLayoutTreeViewContainerExpanded"),e.appendChild(n),t.subviews.forEach((t=>n.appendChild(this.treeNodeForView(t)))),t.subviews.length||(o.style.visibility="hidden");let s=document.createElement("div");s.classList.add("BMLayoutTreeViewConstraintsTitle"),s.classList.add("BMLayoutTreeViewEntity"),s.style.display="none";let a=document.createElement("div");a.classList.add("BMDisclosureTriangle"),s.appendChild(a),s.appendChild(document.createTextNode("Constraints")),n.appendChild(s);let r=document.createElement("div");return r.classList.add("BMLayoutTreeViewConstraintsContainer"),r.classList.add("BMLayoutTreeViewContainer"),r.style.display="none",n.appendChild(r),a.addEventListener("click",(t=>{r.classList.contains("BMLayoutTreeViewContainerExpanded")?(r.classList.remove("BMLayoutTreeViewContainerExpanded"),a.classList.remove("BMDisclosureTriangleExpanded")):(r.classList.add("BMLayoutTreeViewContainerExpanded"),a.classList.add("BMDisclosureTriangleExpanded")),t.stopPropagation()})),i.addEventListener("click",(e=>this._editor.selectView(t,{withEvent:e}))),o.addEventListener("click",(t=>{n.classList.contains("BMLayoutTreeViewContainerExpanded")?(n.classList.remove("BMLayoutTreeViewContainerExpanded"),o.classList.remove("BMDisclosureTriangleExpanded")):(n.classList.add("BMLayoutTreeViewContainerExpanded"),o.classList.add("BMDisclosureTriangleExpanded")),t.stopPropagation()})),t.localConstraints.forEach((e=>r.appendChild(this.treeNodeForConstraint(e,{withReferenceView:t})))),e},treeNodeForConstraint(t,e){let i=document.createElement("div");i.classList.add("BMLayoutTreeViewConstraintsTitle"),i.classList.add("BMLayoutTreeViewEntity"),i.innerText=t.toCompactString(),i.addEventListener("click",(i=>this._editor.selectConstraint(t,{withReferenceView:e.withReferenceView})));let o=this._constraintNodeMap.get(t);return o||(o=[],this._constraintNodeMap.set(t,o)),o.push(i),i},selectView(t,e){(!e||!e.continuous)&&this._node.querySelectorAll(".BMLayoutTreeViewEntitySelected").forEach((t=>t.classList.remove("BMLayoutTreeViewEntitySelected")));var i=this._viewNodeMap.get(t);i&&i.classList.add("BMLayoutTreeViewEntitySelected")},deselectView(t,e){var i=this._viewNodeMap.get(t);i&&i.classList.remove("BMLayoutTreeViewEntitySelected")},selectConstraint(t){this._node.querySelectorAll(".BMLayoutTreeViewEntitySelected").forEach((t=>t.classList.remove("BMLayoutTreeViewEntitySelected")));var e=this._constraintNodeMap.get(t);e&&e.forEach((t=>t.classList.add("BMLayoutTreeViewEntitySelected")))},removeConstraint(t){var e=this._constraintNodeMap.get(t);e&&e.forEach((t=>t.remove())),this._constraintNodeMap.delete(t)},addConstraint(t){var e=[],i=this._viewNodeMap.get(t._firstView);if(i){let n=this.treeNodeForConstraint(t);(o=(o=i.parentNode.childNodes)[o.length-1]).appendChild(n),e.push(n)}if(this._viewNodeMap.get(t._secondView)){let n=this.treeNodeForConstraint(t);var o;(o=(o=i.parentNode.childNodes)[o.length-1]).appendChild(n),e.push(n)}this._constraintNodeMap.set(t,e)}}),_BMLayoutEditorTree.editorTreeWithView=function(t,e){return(new _BMLayoutEditorTree).initWithView(t,e)};const BMLayoutEditorAvailable=YES;class BMLayoutEditorVariableCell extends BMCollectionViewCell{initWithCollectionView(t,e){super.initWithCollectionView(t,e);const i=e.node;i.classList.add("BMLayoutEditorVariable");const o=document.createElement("div");o.className="BMLayoutEditorDetailsItemBadgeIcon",this.sizeClassBadge=o,i.appendChild(o);const n=document.createElement("input");n.type="text",n.className="BMWindowInput BMLayoutEditorVariableName",this.variableName=n,i.appendChild(n),this._initNameEditor();const s=document.createElement("input");s.type="number",s.className="BMWindowInput BMLayoutEditorVariableValue",this.variableValue=s,i.appendChild(s),this._initValueEditor();const a=document.createElement("div");a.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorVariableButton BMLayoutEditorAddVariationButton",a.innerHTML='<i class="material-icons">add_circle</i>',i.appendChild(a),this.addVariationButton=a,this._initAddVariationButton();const r=document.createElement("div");return r.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorVariableButton BMLayoutEditorRemoveVariationButton",r.innerHTML='<i class="material-icons">remove_circle</i>',i.appendChild(r),this.removeVariationButton=r,this._initRemoveVariationButton(),this}_initAddVariationButton(){this.addVariationButton.addEventListener("click",(t=>{this.editor._showSizeClassMenuAtPoint(BMRectMakeWithNodeFrame(this.addVariationButton).center,{kind:BMMenuKind.Menu,action:t=>{if(this.collectionView.dataSet.variables.find((e=>e.name==this.indexPath.object.name&&t.isEqualToSizeClass(e.sizeClass))))return;this.collectionView.dataSet.beginUpdates(),this.collectionView.dataSet.variables.splice(this.indexPath.row+1,0,{name:this.indexPath.object.name,sizeClass:t,value:this.indexPath.object.value});const e=this.indexPath.row+1;this.collectionView.dataSet.commitUpdatesWithCompletionHandler((()=>{var t=this.collectionView.indexPathForObjectAtRow(e,{inSectionAtIndex:0}),i=this.collectionView.cellAtIndexPath(t);i?(i.node.querySelector(".BMLayoutEditorVariableValue").focus(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES})):((i=propertiesCollection.retainCellForIndexPath(t)).node.querySelector(".BMLayoutEditorVariableValue").focus(),i.release(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES}))})),this.editor.layoutVariableProvider.setLayoutVariableValue(this.indexPath.object.value,{named:this.indexPath.object.name,inSizeClass:t})}})}))}_initRemoveVariationButton(){this.removeVariationButton.addEventListener("click",(t=>{const e=this.collectionView.dataSet.variables;if(this.indexPath.object.sizeClass)this.collectionView.dataSet.beginUpdates(),e.splice(this.indexPath.row,1),this.collectionView.dataSet.commitUpdates(),this.editor.layoutVariableProvider.removeVariationForLayoutVariableNamed(this.indexPath.object.name,{inSizeClass:this.indexPath.object.sizeClass});else{this.collectionView.dataSet.beginUpdates();for(let t=0;t<e.length;t++){const i=e[t];i.name==this.indexPath.object.name&&(i.sizeClass?this.editor.layoutVariableProvider.removeVariationForLayoutVariableNamed(i.name,{inSizeClass:i.sizeClass}):this.editor.layoutVariableProvider.unregisterLayoutVariableNamed(i.name),e.splice(t,1),t--)}this.collectionView.dataSet.commitUpdates()}}))}_initNameEditor(){let t;this.variableName.addEventListener("focus",(async e=>{t=this._variable.name,this.variableName.select(),this.retain();const i=t=>t.preventDefault();this.variableName.addEventListener("mouseup",i),await new Promise((t=>setTimeout(t,200))),this.variableName.removeEventListener("mouseup",i)})),this.variableName.addEventListener("blur",(async e=>{let i=this.variableName.value.trim();if(i!=t){let e=NO;for(const t of this.collectionView.dataSet.variables)if(t.name==i){e=YES;break}if(e)this.variableName.value=t,await __BMVelocityAnimate(this.variableName,{translateX:"20px"},{duration:50,ease:"easeOutQuad"}),await __BMVelocityAnimate(this.variableName,{translateX:"-20px"},{duration:100,ease:"easeInOutQuad"}),__BMVelocityAnimate(this.variableName,{translateX:"0px"},{duration:50,ease:"easeInQuad"});else{this.editor.layoutVariableProvider.renameLayoutVariableNamed(t,{toName:i});for(const e of this.collectionView.dataSet.variables)e.name==t&&(e.name=i)}}this.release()}))}_initValueEditor(){this.variableValue.addEventListener("focus",(async t=>{this.variableValue.select(),this.retain();const e=t=>t.preventDefault();this.variableValue.addEventListener("mouseup",e),await new Promise((t=>setTimeout(t,200))),this.variableValue.removeEventListener("mouseup",e)})),this.variableValue.addEventListener("input",(t=>{let e=parseFloat(this.variableValue.value.trim());isNaN(e)||(this._variable.value=e,this._variable.sizeClass?this.editor.layoutVariableProvider.setLayoutVariableValue(e,{named:this._variable.name,inSizeClass:this._variable.sizeClass}):this.editor.layoutVariableProvider.registerLayoutVariableNamed(this._variable.name,{withValue:e}))})),this.variableValue.addEventListener("blur",(async t=>this.release()))}get variable(){return this._variable}set variable(t){if(this._variable=t,t.sizeClass){this.addVariationButton.style.visibility="hidden",this.sizeClassBadge.style.display="block",this.variableName.style.display="none";const e=this.editor.settingsBadgeForSizeClass(t.sizeClass);this.sizeClassBadge.className=e.className,this.sizeClassBadge.innerText=e.innerText,this.node.classList.remove("BMLayoutEditorVariableMain")}else this.addVariationButton.style.visibility="visible",this.sizeClassBadge.style.display="none",this.variableName.style.display="block",this.node.classList.add("BMLayoutEditorVariableMain");this.variableValue.value=t.value,this.variableName.value=t.name}}class BMLayoutEditorEmptyVariablesCell extends BMCollectionViewCell{initWithCollectionView(t,e){super.initWithCollectionView(t,e);const i=t.dataSet.provider.canUseLayoutVariables(),o=document.createElement("div");o.innerText=i?"No Layout Variables Defined":"Layout Variables Unavailable",o.className="BMWindowLabel BMLayoutEditorMessageTitle",this.node.appendChild(o);const n=document.createElement("div");return n.innerText=i?'Use the "Add Variable" button below to add a layout variable.':t.dataSet.provider.unavailableLayoutVariablesUserLabel(),n.className="BMWindowLabel BMLayoutEditorMessageDescription",this.node.appendChild(n),this.node.classList.add("BMLayoutEditorEmptyVariableMessage"),this}}class BMLayoutEditorVariablesDataSet{initWithLayoutVariableProvider(t,{collectionView:e,editor:i}){this.provider=t,this.variables=[];const o=t.layoutVariables;for(const e in o){this.variables.push({name:e,value:o[e]});const i=t.variationsForLayoutVariableNamed(e);for(const t of i)this.variables.push(t)}return this.collectionView=e,this.editor=i,this}numberOfSections(){return Math.min(this.variables.length,1)}numberOfObjectsInSectionAtIndex(t){return this.variables.length}indexPathForObjectAtRow(t){return BMIndexPathMakeWithRow(t,{section:0,forObject:this.variables[t]})}indexPathForObject(t){for(let e=0;e<this.variables.length;e++){const i=this.variables[e];if(i.name==t.name&&i.sizeClass==t.sizeClass)return BMIndexPathMakeWithRow(e,{section:0,object:i})}}cellForItemAtIndexPath(t){const e=this.collectionView.dequeueCellForReuseIdentifier("Variable");return e.editor=this.editor,e.variable=t.object,e}cellForSupplementaryViewWithIdentifier(t,e){return this.collectionView.dequeueCellForSupplementaryViewWithIdentifier(t)}beginUpdates(){this._oldData=this.variables.slice(),this._newData=this.variables}useOldData(t){this.variables=t?this._oldData:this._newData}isUsingOldData(){return this.variables===this._newData}commitUpdates(){return this.commitUpdatesWithCompletionHandler()}commitUpdatesWithCompletionHandler(t){this.collectionView.updateEntireDataAnimated(YES,{completionHandler:t}),this.variables=this._newData,this._oldData=void 0}addVariable(){this.beginUpdates();let t="new variable",e=0;for(;YES;){let o=NO;for(var i=0;i<this.variables.length;i++)if(this.variables[i].name==t){o=YES;break}if(!o)break;e++,t="new variable "+e}this.variables.push({name:t,value:0}),this.provider.registerLayoutVariableNamed(t,{withValue:0}),this.commitUpdatesWithCompletionHandler((()=>{var t=this.indexPathForObjectAtRow(this.variables.length-1,{inSectionAtIndex:0}),e=this.collectionView.cellAtIndexPath(t);e?(e.node.querySelector(".BMLayoutEditorVariableName").focus(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES})):((e=this.collectionView.retainCellForIndexPath(t)).node.querySelector(".BMLayoutEditorVariableName").focus(),e.release(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES}))}))}collectionViewCanSelectCellAtIndexPath(){return NO}collectionViewSizeForCellAtIndexPath(t,e){return e.object.sizeClass?BMSizeMake(1,32):BMSizeMake(1,48)}}function _BMURLOfImageAtPath(t){return("TW"in window?"/Thingworx/Common/extensions/BMCoreUI/ui/BMCoreUI/":"")+t}function _BMLayoutEditorSettingsView(){}function _BMLayoutEditorSettingsPanel(){}function _BMLayoutEditorCollectionSettingsPanel(){}function BMLayoutEditorSettingsTab(){}function BMLayoutEditorSettingsSection(){}_BMLayoutEditorSettingsView.prototype=BMExtend(Object.create(BMView.prototype),{constructor:_BMLayoutEditorSettingsView,_editor:void 0,_panels:void 0,_window:void 0,_dismissedByUser:NO,get window(){return this._window},get currentPanel(){return this._panels[this._panels.length-1]},initWithDOMNode(t,{forEditor:e}){return BMView.prototype.initWithDOMNode.call(this,t),this.node.style.overflow="hidden",this._editor=e,this._panels=[],this},async windowWillAppear(t){if(this._panels.length&&this._panels[this._panels.length-1]._awaitsLayout){await 0;const t=this._panels[this._panels.length-1];t.view.needsLayout=YES,t.view.layoutIfNeeded(),t.settingsPanelDidLayoutView(),t._awaitsLayout=NO}},_provisionPanel(t,{withBackButton:e}={withBackButton:NO}){t._settingsView=this;const i=BMView.view();this.addSubview(i),i.leading.equalTo(this.leading).isActive=YES,i.trailing.equalTo(this.trailing).isActive=YES,i.top.equalTo(this.top).isActive=YES,i.bottom.equalTo(this.bottom).isActive=YES,t._container=i,i.node.classList.add("BMLayoutEditorDetails"),i.node.style.cssText="border: none !important;",i.node.style.overflow="hidden";const o=BMView.view();i.addSubview(o),o.leading.equalTo(i.leading).isActive=YES,o.trailing.equalTo(i.trailing).isActive=YES,o.bottom.equalTo(i.bottom).isActive=YES,t._view=o;const n=BMView.view();n.node.innerText=(e?"‹ ":"")+t.title||"",n.node.className="BMWindowTitle BMLayoutEditorDetailsTitle";let s=64;e&&(n.node.classList.add("BMLayoutEditorDetailsItemReadonlyValueClickable"),n.node.classList.add("BMLayoutEditorDetailsBackButton"),s-=8),n.node.style.zIndex=1,n.supportsAutomaticIntrinsicSize=YES,i.addSubview(n),n.leading.equalTo(i.leading,{plus:s}).isActive=YES,n.trailing.lessThanOrEqualTo(i.trailing,{plus:-16}).isActive=YES,n.height.greaterThanOrEqualTo(32).isActive=YES,n.top.equalTo(i.top,{plus:12}).isActive=YES,t._titleView=n,o.top.equalTo(n.bottom,{plus:12}).isActive=YES,e&&n.node.addEventListener("click",(t=>this.popPanel())),t.settingsPanelDidLoad(),this._window&&!this._window._visible?t._awaitsLayout=YES:(this.layoutIfNeeded(),t.settingsPanelDidLayoutView())},selectView(t){this._ignoresSelection=YES,this._editor.selectView(t);const e=(new _BMLayoutEditorViewSettingsPanel).initWithSettingsView(this,{forView:t});this._provisionPanel(e,{withBackButton:YES}),this.pushPanel(e),this._ignoresSelection=NO},layoutEditorDidSelectView(t){if(this._ignoresSelection)return;let e=YES;this._window&&!this._window._visible&&(e=NO);const i=(new _BMLayoutEditorViewSettingsPanel).initWithSettingsView(this,{forView:t});this._provisionPanel(i),this.resetToPanel(i,{animated:e})},layoutEditorDidSelectViews(t){if(this._panels[0]instanceof _BMLayoutEditorViewGroupSettingsPanel)return void(this._panels[0].views=t);if(this._ignoresSelection)return;let e=YES;this._window&&!this._window._visible&&(e=NO);const i=(new _BMLayoutEditorViewGroupSettingsPanel).initWithSettingsView(this,{forViews:t});this._provisionPanel(i),this.resetToPanel(i,{animated:e})},selectConstraint(t,{withReferenceView:e}){this._ignoresSelection=YES,this._editor.selectConstraint(t,{withReferenceView:e});const i=(new _BMLayoutEditorConstraintSettingsPanel).initWithSettingsView(this,{forConstraint:t,withReferenceView:e});this._provisionPanel(i,{withBackButton:YES}),this.pushPanel(i),this._ignoresSelection=NO},layoutEditorDidSelectConstraint(t,{withReferenceView:e}){if(this._ignoresSelection)return;let i=YES;this._window&&!this._window._visible&&(i=NO);const o=(new _BMLayoutEditorConstraintSettingsPanel).initWithSettingsView(this,{forConstraint:t,withReferenceView:e});this._provisionPanel(o,{withBackButton:YES}),this.pushPanel(o,{animated:i})},layoutEditorDidSelectSizeClass(t){for(const e of this._panels)e.layoutEditorDidSelectSizeClass(t)},async resetToPanel(t,{animated:e=YES}={animated:YES}){const i=this.currentPanel;for(const t of this._panels)t!=i&&(t.settingsPanelWillUnload(),t._container.release());if(i){if(this._panels=t?[t]:[],i)if(i.settingsPanelWillDisappear(YES),e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"}),i._container.opacity=0,e){BMAnimationContextGetCurrent().controllerForObject(i._container,{node:i._container.node}).registerBuiltInPropertiesWithDictionary({scaleX:.85,scaleY:.85})}else BMHook(i._container.node,{scaleX:.85,scaleY:.85});else t&&e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"});if(t){if(BMAnimationContextBeginStatic(),this._ignoresSelection=YES,t.settingsPanelWillAppear(YES),this._ignoresSelection=NO,t._container.opacity=0,BMHook(t._container.node,{scaleX:1.23,scaleY:1.23}),e&&BMAnimationApply(),e){BMAnimationContextGetCurrent().controllerForObject(t._container,{node:t._container.node}).registerBuiltInPropertiesWithDictionary({scaleX:1,scaleY:1})}else BMHook(t._container.node,{scaleX:1,scaleY:1});t._container.opacity=1}(t||i)&&e&&await BMAnimationApply(),i&&(i.settingsPanelDidDisappear(YES),i.settingsPanelWillUnload(),i._container.release()),t&&t.settingsPanelDidAppear(YES)}else t&&(this._panels.push(t),this._ignoresSelection=YES,t.settingsPanelWillAppear(NO),this._ignoresSelection=NO,t.settingsPanelDidAppear(NO))},async pushPanel(t,{animated:e=YES}={animated:YES}){const i=this.currentPanel;if(this._panels.push(t),i){e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"}),i.settingsPanelWillDisappear(YES);const t=i._container.frame.copy();t.offsetWithX(-t.width/2|0,{y:0}),i._container.frame=t,i._container.opacity=0}else e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"});BMAnimationContextBeginStatic();const o=t._container.frame.copy(),n=o.copy();n.offsetWithX(o.width,{y:0}),t._container.frame=n,BMAnimationApply(),this._ignoresSelection=YES,t.settingsPanelWillAppear(YES),this._ignoresSelection=NO,t._container.frame=o,e&&await BMAnimationApply(),i.settingsPanelDidDisappear(YES),i._container.isVisible=NO,t.settingsPanelDidAppear(YES)},async popPanel(){const t=this.currentPanel;t._container.node.style.pointerEvents="none",this._panels.pop(),BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"}),t.settingsPanelWillDisappear(YES);const e=this.frame.copy();e.origin=BMPointMake(),e.offsetWithX(e.width,{y:0}),t._container.frame=e;const i=this.currentPanel;if(i){BMAnimationContextBeginStatic();const t=this.frame.copy();t.origin=BMPointMake();const o=t.copy();o.offsetWithX(-e.width/2|0,{y:0}),i._container.frame=o,i._container.opacity=0,i._container.isVisible=YES,BMAnimationApply(),this._ignoresSelection=YES,i.settingsPanelWillAppear(YES),this._ignoresSelection=NO,i._container.frame=t,i._container.opacity=1,i._awaitsLayout&&(BMAnimationContextBeginStatic(),i._titleView.invalidateIntrinsicSize(),i.view.needsLayout=YES,i.view.layoutIfNeeded(),i.settingsPanelDidLayoutView(),i._awaitsLayout=NO,BMAnimationApply())}await BMAnimationApply(),t.settingsPanelDidDisappear(YES),t.settingsPanelWillUnload(),t._container.release(),i&&i.settingsPanelDidAppear(YES)}}),_BMLayoutEditorSettingsView.settingsViewWithNode=function(t,{forEditor:e}){return(new _BMLayoutEditorSettingsView).initWithDOMNode(t,{forEditor:e})},_BMLayoutEditorSettingsPanel.prototype={constructor:_BMLayoutEditorSettingsPanel,_settingsView:void 0,_title:void 0,get title(){return this._title},set title(t){this._title=t,this._titleView&&(this._titleView.node.innerText=t,this._titleView.invalidateIntrinsicSize())},_container:void 0,_titleView:void 0,_view:void 0,get view(){return this._view},get layoutEditor(){return this._settingsView._editor},initWithSettingsView(t){return this._settingsView=t,this},settingsPanelDidLoad(){},settingsPanelDidLayoutView(){},settingsPanelWillAppear(t){},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){},settingsPanelWillUnload(){}},_BMLayoutEditorCollectionSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorSettingsPanel.prototype),{_tabs:void 0,_currentTab:void 0,_configureCollectionViewLayout(t,{forTab:e}){t.node.style.position="absolute",t.layout.expectedCellSize=BMSizeMake(384,e instanceof _BMLayoutEditorViewLayoutSettingsTab?48:32),t.layout.maximumCellsPerRow=1,t.layout.gravity=BMCollectionViewFlowLayoutGravity.Expand,t.layout.rowSpacing=0,t.layout.contentGravity=BMCollectionViewFlowLayoutAlignment.Start,t.layout.showsFooters=YES,t.layout.footerHeight=17,t.layout.topPadding=8,t.identityComparator=(t,e)=>t||e?t&&e?t.isEqualToSetting(e):NO:YES;for(const e in BMLayoutEditorSettingKind)t.registerCellClass(BMLayoutEditorSettingsCell,{forReuseIdentifier:BMLayoutEditorSettingKind[e]});t.registerCellClass(BMLayoutEditorSettingsConstraintCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Constraint}),t.registerCellClass(BMLayoutEditorSettingsTitleCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Title}),t.registerCellClass(BMLayoutEditorSettingsIntegerCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Integer}),t.registerCellClass(BMLayoutEditorSettingsNumberCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Number}),t.registerCellClass(BMLayoutEditorSettingsConstantCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Constant}),t.registerCellClass(BMLayoutEditorSettingsStringCell,{forReuseIdentifier:BMLayoutEditorSettingKind.String}),t.registerCellClass(BMLayoutEditorSettingsBooleanCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Boolean}),t.registerCellClass(BMLayoutEditorSettingsReadonlyCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Info}),t.registerCellClass(BMLayoutEditorSettingsDeleteConstraintCell,{forReuseIdentifier:BMLayoutEditorSettingKind.DeleteConstraintButton}),t.registerCellClass(BMLayoutEditorSettingsDeactivateConstraintsCell,{forReuseIdentifier:BMLayoutEditorSettingKind.DeactivateConstraintsButton}),t.registerCellClass(BMLayoutEditorSettingsSegmentCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Segment}),t.registerCellClass(BMLayoutEditorSettingsViewCell,{forReuseIdentifier:BMLayoutEditorSettingKind.View}),t.registerCellClass(BMLayoutEditorSettingsDropdownCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Enum}),t.registerCellClass(BMLayoutEditorSettingsInsetCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Insets}),t.registerCellClass(BMLayoutEditorSettingsSizeCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Size}),t.registerSupplementaryViewClass(BMLayoutEditorSettingsFooter,{forReuseIdentifier:BMCollectionViewFlowLayoutSupplementaryView.Footer}),t.registerSupplementaryViewClass(BMLayoutEditorSettingsFooter,{forReuseIdentifier:BMCollectionViewFlowLayoutSupplementaryView.Empty});for(const e in this.layoutEditor._settingCellClasses)t.registerCellClass(this.layoutEditor._settingCellClasses[e],{forReuseIdentifier:e})},settingsPanelDidLoad(){const t=BMView.view();t.CSSClass="BMLayoutEditorDetailsTabView",this.view.addSubview(t),t.height.equalTo(48).isActive=YES,t.leading.equalTo(this.view.leading).isActive=YES,t.trailing.equalTo(this.view.trailing).isActive=YES,t.top.equalTo(this.view.top).isActive=YES;const e=BMView.view();this.view.addSubview(e),e.top.equalTo(t.bottom).isActive=YES,e.leading.equalTo(this.view.leading).isActive=YES,e.trailing.equalTo(this.view.trailing).isActive=YES,e.bottom.equalTo(this.view.bottom).isActive=YES;for(const i of this._tabs){const o=BMCollectionView.collectionView();o.allowsOffscreenLayout=NO,e.addSubview(o),this._configureCollectionViewLayout(o,{forTab:i}),o.leading.equalTo(e.leading).isActive=!0,o.trailing.equalTo(e.trailing).isActive=!0,o.top.equalTo(e.top).isActive=!0,o.bottom.equalTo(e.bottom).isActive=!0,i._collectionView=o,o._settingsTab=i,i!=this._currentTab&&(o.isVisible=NO);const n=document.createElement("img");n.className="BMLayoutEditorDetailsTab",n.src=i.icon,t.contentNode.appendChild(n),i==this._currentTab&&n.classList.add("BMLayoutEditorDetailsTabSelected"),i._tabNode=n,n.addEventListener("click",(t=>{n!=this._currentTab&&(this._currentTab._collectionView.isVisible=NO,this._currentTab._tabNode.classList.remove("BMLayoutEditorDetailsTabSelected"),this._currentTab=i,o.isVisible=YES,n.classList.add("BMLayoutEditorDetailsTabSelected"))}))}},settingsPanelDidLayoutView(){for(const t of this._tabs)t.collectionView=t._collectionView},settingsPanelWillUnload(){for(const t of this._tabs)t._collectionView.release(),t._collectionView=void 0},layoutEditorDidSelectSizeClass(t){for(const e of this._tabs)e.layoutEditorDidSelectSizeClass(t)}}),BMLayoutEditorSettingsTab.prototype={name:void 0,icon:void 0,_constraint:void 0,get constraint(){return this._constraint},_view:void 0,get view(){return this._view},_settingSections:void 0,_compiledSettingSections:void 0,_collectionView:void 0,get collectionView(){return this._collectionView},set collectionView(t){this._compiledSettingSections.length=0;for(const t of this._settingSections)this._compiledSettingSections.push(t._compiledSectionForSizeClass(this.layoutEditor.activeSizeClass));this._collectionView=t,t.dataSet=this,t.delegate=this},_settingsPanel:void 0,get layoutEditor(){if(this._settingsPanel)return this._settingsPanel.layoutEditor},initWithName(t,{icon:e}){return this.name=t,this.icon=e,this._settingSections=[],this._compiledSettingSections=[],this},_updateSettingsID:0,async updateSettings(){this._updateSettingsID=this._updateSettingsID+1;const t=this._updateSettingsID;for(;this._collectionView&&this._collectionView.isUpdatingData;)await this._collectionView._dataUpdatePromise;this._updateSettingsID==t&&(this.beginUpdates(),this._settingsPanel._updateSettingsForTab(this),this.commitUpdates())},numberOfSections(){return this._compiledSettingSections.length},numberOfObjectsInSectionAtIndex(t){return this._compiledSettingSections[t]._settings.length+(this._compiledSettingSections[t].name?1:0)},indexPathForObjectAtRow(t,{inSectionAtIndex:e}){return this._compiledSettingSections[e].name?BMIndexPathMakeWithRow(t,0==t?{section:e,forObject:this._compiledSettingSections[e]._nameSetting}:{section:e,forObject:this._compiledSettingSections[e]._settings[t-1]}):BMIndexPathMakeWithRow(t,{section:e,forObject:this._compiledSettingSections[e]._settings[t]})},indexPathForObject(t){for(const[e,i]of this._compiledSettingSections.entries())for(const[o,n]of i._settings.entries()){if(n==i._nameSetting)return BMIndexPathMakeWithRow(0,{section:e,forObject:t});if(n.isEqualToSetting(t))return i.name?BMIndexPathMakeWithRow(o+1,{section:e,forObject:t}):BMIndexPathMakeWithRow(o,{section:e,forObject:t})}},cellForItemAtIndexPath(t){const e=this._collectionView.dequeueCellForReuseIdentifier(t.object.kind);return e.node.classList.add("BMLayoutEditorDetailsCell"),e._tab=this,e.setting=t.object,e},cellForSupplementaryViewWithIdentifier(t,{atIndexPath:e}){const i=this._collectionView.dequeueCellForSupplementaryViewWithIdentifier(t);return i._tab=this,i.section=this._compiledSettingSections[e.section],i},useOldData(t){if(!this._oldData)throw new Error("[BMLayoutEditorSettingsTab] Illegal state - Data update performed outside of a transaction.");this._compiledSettingSections=t?this._oldData:this._newData},isUsingOldData(){if(!this._oldData)throw new Error("[BMLayoutEditorSettingsTab] Illegal state - Data update performed outside of a transaction.");return this._compiledSettingSections===this._oldData},beginUpdates(){this._collectionView&&(this._oldData=this._compiledSettingSections.map((t=>BMLayoutEditorSettingsSection.sectionWithSection(t))),this._compiledSettingSections=[],this._newData=this._compiledSettingSections)},async commitUpdates(){if(!this.layoutEditor)return;if(!this._collectionView)return;for(const t of this._settingSections)this._compiledSettingSections.push(t._compiledSectionForSizeClass(this.layoutEditor.activeSizeClass));for(;this._collectionView.isUpdatingData;)await this._collectionView._dataUpdatePromise;const t=this._collectionView.updateEntireDataAnimated(YES);this._oldData=void 0,this._compiledSettingSections=this._newData,this._newData=void 0,await t},layoutEditorDidSelectSizeClass(t){for(const t of this._settingSections)for(const e of t._settings)if(e.variations&&e.automaticallyExpandsVariations)return this.beginUpdates(),void this.commitUpdates()}},BMLayoutEditorSettingsTab.tabWithName=function(t,{icon:e}){return(new BMLayoutEditorSettingsTab).initWithName(t,{icon:e})},BMLayoutEditorSettingsSection.prototype={_name:void 0,get name(){return this._name},set name(t){this._name=t,t&&(this._nameSetting=BMLayoutEditorSetting.settingWithName(t,{kind:BMLayoutEditorSettingKind.Title,target:this}),this._nameSetting._section=this)},collapsible:NO,_collapsed:NO,get isCollapsed(){return this._collapsed},set isCollapsed(t){this._tab&&(t?this.collapse():this.expand()),this._collapsed=t},_settings:void 0,get settings(){return this._settings.slice()},set settings(t){this._settings=t.slice()},_compiledSectionForSizeClass(t){const e=BMLayoutEditorSettingsSection.section();e._name=this._name,e._nameSetting=this._nameSetting,e.collapsible=e.collapsible,e._settings=[];for(const i of this._settings)if(e._settings.push(i),i.variations){for(const o in i.target._variations){const n=i.target._variations[o];if((n.sizeClass!=t||!i.automaticallyExpandsVariations)&&i.property in n){const t=BMLayoutEditorSetting.settingWithName(i.name,{kind:i.kind,target:i.target,variations:NO,nullable:i.nullable,property:i.property});t._sizeClass=n.sizeClass,t._associatedSetting=i,e._settings.push(t)}}if(i.automaticallyExpandsVariations&&t){const o=BMLayoutEditorSetting.settingWithName(i.name,{kind:i.kind,target:i.target,variations:NO,nullable:YES,property:i.property});o._sizeClass=t,o._associatedSetting=i,e._settings.push(o)}}return e}},BMLayoutEditorSettingsSection.section=function(){const t=new BMLayoutEditorSettingsSection;return t._settings=[],t},BMLayoutEditorSettingsSection.sectionWithSection=function(t){const e=new BMLayoutEditorSettingsSection;return e.name=t.name,e.collapsible=t.collapsible,e._settings=t._settings.slice(),e};var BMLayoutEditorSettingKind=Object.freeze({String:"_String",Integer:"_Integer",Number:"_Number",Boolean:"_Boolean",Size:"_BMSize",Constant:"_Constant",Constraint:"_Constraint",View:"_View",Enum:"_Enum",Segment:"_Segment",Info:"_Info",Title:"_Title",Insets:"_Insets",DeactivateConstraintsButton:"_DeactivateConstraintsButton",DeleteConstraintButton:"_DeleteConstraintButton"});function BMLayoutEditorSetting(){}function BMLayoutEditorEnumSetting(){}BMLayoutEditorSetting.prototype={name:void 0,kind:BMLayoutEditorSettingKind.String,nullable:NO,variations:NO,automaticallyExpandsVariations:NO,_sizeClass:void 0,get sizeClass(){return this._sizeClass},_associatedProperty:void 0,get associatedProperty(){return this._associatedProperty},target:void 0,property:void 0,initWithName(t,{kind:e,target:i,variations:o=NO,nullable:n=NO,property:s}){return this.name=t,this.kind=e,this.target=i,this.variations=o,this.nullable=n,void 0!==s&&(this.property=s),this},isEqualToSetting(t){return t.name==this.name&&t.target==this.target&&t._sizeClass==this._sizeClass&&t.property==this.property}},BMLayoutEditorSetting.settingWithName=function(t,{kind:e,target:i,variations:o=NO,nullable:n=NO,property:s}){return(new this).initWithName(t,{kind:e,target:i,variations:o,nullable:n,property:s})},BMLayoutEditorEnumSetting.prototype=BMExtend(Object.create(BMLayoutEditorSetting.prototype),{options:void 0,initWithName(t,e){return BMLayoutEditorSetting.prototype.initWithName.apply(this,arguments),this.options=[],this}}),BMLayoutEditorEnumSetting.settingWithName=BMLayoutEditorSetting.settingWithName;const BMLayoutEdittorSettingCellRowSpacing=2;function BMLayoutEditorSettingsTitleView(){}function BMLayoutEditorSettingsFooter(){}function BMLayoutEditorSettingsCell(){}function BMLayoutEditorSettingsConstraintCell(){}function BMLayoutEditorSettingsDeactivateConstraintsCell(){}function BMLayoutEditorSettingsDeleteConstraintCell(){}function BMLayoutEditorSettingsTitleCell(){}function BMLayoutEditorSettingsReadonlyCell(){}function BMLayoutEditorSettingsViewCell(){}function BMLayoutEditorSettingsSegmentCell(){}function BMLayoutEditorSettingsBooleanCell(){}function BMLayoutEditorSettingsDropdownCell(){}function BMLayoutEditorSettingsInputCell(){}function BMLayoutEditorSettingsIntegerCell(){}function BMLayoutEditorSettingsNumberCell(){}function BMLayoutEditorSettingsStringCell(){}function BMLayoutEditorSettingsConstantCell(){}function BMLayoutEditorSettingsSizeCell(){}function BMLayoutEditorSettingsInsetCell(){}function _BMLayoutEditorViewSettingsPanel(){}function _BMLayoutEditorViewLayoutSettingsTab(){}function _BMLayoutEditorViewGroupSettingsPanel(){}function _BMLayoutEditorConstraintSettingsPanel(){}function _BMLayoutEditorConstraintSettingsTab(){}BMLayoutEditorSettingsTitleView.prototype=BMExtend(Object.create(BMView.prototype),{constructor:BMLayoutEditorSettingsTitleView,_titleLabel:void 0,_badge:void 0,_button:void 0,_title:void 0,get title(){return this._title},set title(t){this._title=t,this._titleLabel.node.innerText=t,this._titleLabel.invalidateIntrinsicSize()},_setting:void 0,get setting(){return this._setting},set setting(t){if(this._setting=t,t.sizeClass){switch(t.sizeClass){case BMLayoutSizeClass.phoneSizeClass():this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Portrait):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhonePortraitMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Landscape):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneLandscapeMini";break;case BMLayoutSizeClass.tabletSizeClass():this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Portrait):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletPortraitMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Landscape):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletLandscapeMini";break;default:this._badge.node.className="BMLayoutEditorDetailsItemBadge",this._badge.node.innerText=t.sizeClass._hashString}this._button.node.innerHTML='<i class="material-icons">remove_circle</i>',this._button.isVisible=YES,this._badgeWidthConstraint.constant=16,this._buttonWidthConstraint.constant=24}else this._badge.node.className="",t.variations?(this._button.node.innerHTML='<i class="material-icons">add_circle</i>',this._button.isVisible=YES,this._buttonWidthConstraint.constant=24):(this._button.node.innerHTML="",this._button.isVisible=NO,this._buttonWidthConstraint.constant=0),this._badgeWidthConstraint.constant=0;this._badge.invalidateIntrinsicSize(),this.title=t.name+":"},initWithDOMNode(){BMView.prototype.initWithDOMNode.apply(this,arguments),this.debuggingName="TitleView";const t=this._titleLabel=BMView.view();t.debuggingName="TitleViewLabel",t.supportsAutomaticIntrinsicSize=YES,t.node.className="BMLayoutEditorDetailsTitleCell",this.addSubview(t),t.trailing.equalTo(this.trailing).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.compressionResistance=700;const e=this._badge=BMView.view();e.debuggingName="TitleViewBadge",e.supportsAutomaticIntrinsicSize=YES,this.addSubview(e),t.leading.equalTo(e.trailing,{plus:4}).isActive=YES,e.centerY.equalTo(t.centerY).isActive=YES,this._badgeWidthConstraint=e.width.greaterThanOrEqualTo(16),this._badgeWidthConstraint.isActive=YES,e.height.greaterThanOrEqualTo(16).isActive=YES;const i=this._button=BMView.view();return i.debuggingName="TitleViewButton",i.node.className="BMLayoutEditorDetailsItemVariationsButton",this.addSubview(i),i.leading.equalTo(this.leading).isActive=YES,e.leading.greaterThanOrEqualTo(i.trailing,{plus:4}).isActive=YES,i.centerY.equalTo(t.centerY).isActive=YES,this._buttonWidthConstraint=i.width.equalTo(24),this._buttonWidthConstraint.isActive=YES,i.height.equalTo(24).isActive=YES,i.node.addEventListener("click",(t=>this.variationsButtonClickedWithEvent(t))),this},variationsButtonClickedWithEvent(t){this.setting.sizeClass?(this.setting.target[`remove${BMStringByCapitalizingString(this.setting.property)}VariationForSizeClass`](this.setting.sizeClass),this.rootView.setting=this.rootView.setting,this.rootView.tab.updateSettings()):this.rootView.layoutEditor._showSizeClassMenuAtPoint(BMPointMake(t.clientX,t.clientY),{kind:BMMenuKind.Menu,action:t=>{this.setting.target._variations&&this.setting.target._variations[t]&&this.setting.property in this.setting.target._variations[t]||(this.setting.target[`set${BMStringByCapitalizingString(this.setting.property)}`](this.setting.target[this.setting.property],{forSizeClass:t}),this.rootView.tab.updateSettings())}})}}),BMLayoutEditorSettingsTitleView.titleView=function(){return(new BMLayoutEditorSettingsTitleView).initWithDOMNode(document.createElement("div"))},BMLayoutEditorSettingsFooter.prototype=BMExtend(Object.create(BMCollectionViewCell.prototype),{constructor:BMLayoutEditorSettingsFooter,initWithCollectionView(){BMCollectionViewCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();this.addSubview(t),t.leading.equalTo(this.leading).isActive=YES,t.trailing.equalTo(this.trailing).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES;const e=BMView.view();return t.addSubview(e),e.node.className="BMLayoutEditorDetailsDividerCell",e.leading.equalTo(t.leading).isActive=YES,e.trailing.equalTo(t.trailing).isActive=YES,e.height.equalTo(1).isActive=YES,e.centerY.equalTo(t.centerY).isActive=YES,this}}),BMLayoutEditorSettingsCell.prototype=BMExtend(Object.create(BMCollectionViewCell.prototype),{constructor:BMLayoutEditorSettingsCell,_contentView:void 0,get contentView(){return this._contentView},initWithCollectionView(){BMCollectionViewCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return t.debuggingName="ContentView",this._contentView=t,this.addSubview(t),this.constructor===BMLayoutEditorSettingsCell&&(t.node.innerText="This is a test!",t.node.style.color="white"),t.leading.equalTo(this.leading).isActive=YES,t.trailing.equalTo(this.trailing).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.height.greaterThanOrEqualTo(32,{priority:750}).isActive=YES,this},_setting:void 0,get setting(){return this._setting},set setting(t){this._setting=t,this.cellDidBindToSetting(t)},_tab:void 0,get tab(){return this._tab},get settingsView(){const t=this.tab;if(t)return t._settingsPanel._settingsView},get layoutEditor(){const t=this.tab;if(t)return t.layoutEditor},cellDidBindToSetting(t){}}),BMLayoutEditorSettingsConstraintCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsConstraintCell,_constraintView:void 0,_constraintViewLeading:void 0,initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return t.debuggingName="ConstraintView",this._constraintView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,this._constraintViewLeading=t.leading.equalTo(this.leading,{plus:8}),this._constraintViewLeading.isActive=YES,t.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,t.top.equalTo(this.top,{plus:8}).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.node.className="BMLayoutEditorDetailsConstraintItem BMLayoutEditorDetailsConstraintItemCell BMCollectionViewCellEventHandler",t.node.addEventListener("click",(t=>{const e=this.setting.target;e._internal||this.settingsView.selectConstraint(e,{withReferenceView:this.tab._displayedView})})),this},cellDidBindToSetting(t){const e=this._constraintView.node,i=t.target;e.innerText=i.descriptionRelativeToView(this.tab._displayedView);const o=document.createElement("img");if(o.className="BMLayoutEditorDetailsConstraintIcon",i.isConstraintCollection)o.src=_BMURLOfImageAtPath("images/OwnConstraints.png");else{switch(i[i._sourceView==this.tab._displayedView?"_sourceViewAttribute":"_targetViewAttribute"]){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:o.src=_BMURLOfImageAtPath("images/LeftConstraint.png");break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:o.src=_BMURLOfImageAtPath("images/RightConstraint.png");break;case BMLayoutAttribute.CenterX:o.src=_BMURLOfImageAtPath("images/CenterXConstraint.png");break;case BMLayoutAttribute.CenterY:o.src=_BMURLOfImageAtPath("images/CenterYConstraint.png");break;case BMLayoutAttribute.Top:o.src=_BMURLOfImageAtPath("images/TopConstraint.png");break;case BMLayoutAttribute.Bottom:o.src=_BMURLOfImageAtPath("images/BottomConstraint.png");break;case BMLayoutAttribute.Width:o.src=_BMURLOfImageAtPath("images/WidthConstraint.png");break;case BMLayoutAttribute.Height:o.src=_BMURLOfImageAtPath("images/HeightConstraint.png")}}return e.insertBefore(o,e.firstChild),i._priority>500&&i._priority<1e3?(e.classList.add("BMLayoutEditorDetailsConstraintItemStrong"),e.classList.remove("BMLayoutEditorDetailsConstraintItemWeak")):i._priority<=500?(e.classList.remove("BMLayoutEditorDetailsConstraintItemStrong"),e.classList.add("BMLayoutEditorDetailsConstraintItemWeak")):(e.classList.remove("BMLayoutEditorDetailsConstraintItemStrong"),e.classList.remove("BMLayoutEditorDetailsConstraintItemWeak")),i._internal?e.classList.add("BMLayoutEditorDetailsConstraintItemReadonly"):e.classList.remove("BMLayoutEditorDetailsConstraintItemReadonly"),i._configuration.isActive?e.classList.remove("BMLayoutEditorDetailsConstraintItemInactive"):e.classList.add("BMLayoutEditorDetailsConstraintItemInactive"),this._constraintView.invalidateIntrinsicSize(),e}}),BMLayoutEditorSettingsDeactivateConstraintsCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsDeactivateConstraintsCell,_buttonView:void 0,prepareForDisplay(){window.addEventListener("keydown",this._keyboardModifier,YES),window.addEventListener("keyup",this._keyboardModifier,YES)},prepareForReuse(){window.removeEventListener("keydown",this._keyboardModifier,YES),window.removeEventListener("keyup",this._keyboardModifier,YES)},invalidate(){window.removeEventListener("keydown",this._keyboardModifier,YES),window.removeEventListener("keyup",this._keyboardModifier,YES)},initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();t.debuggingName="DeactivateButton",this._buttonView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,t.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,t.trailing.equalTo(this.contentView.trailing,{plus:-32}).isActive=YES,t.top.equalTo(this.contentView.top,{plus:8}).isActive=YES,t.bottom.equalTo(this.contentView.bottom,{plus:-8}).isActive=YES,t.node.className="BMWindowButton BMCollectionViewCellEventHandler",t.node.style.boxSizing="border-box",t.node.style.textAlign="center",t.node.style.pointer="default",t.node.style.margin=0,t.node.innerText="Deactivate Constraints";let e=NO,i=NO,o=NO;return t.node.addEventListener("click",(t=>{if(e&&i&&o)new Set(this.setting.target._view.rootView.allConstraints).forEach((t=>t.remove()));else if(e)for(let t of this.setting.target._view.localConstraints)i?t.remove():this._activeSizeClass?t.setIsActive(NO,{forSizeClass:this._activeSizeClass}):t.isActive=NO;else{const t=this.tab._constraintCategories;Object.keys(t).forEach((e=>{for(let o of t[e])i?o.remove():this.layoutEditor._activeSizeClass?o.setIsActive(NO,{forSizeClass:this.layoutEditor._activeSizeClass}):o.isActive=NO}))}this.tab._updateSettings()})),t.node.addEventListener("contextmenu",(t=>t.preventDefault())),this._keyboardModifier=n=>{switch(n.key){case"Alt":e="keydown"==n.type;break;case"Shift":i="keydown"==n.type;break;case"Control":o="keydown"==n.type}t.node.innerText=e?i?o?"Reset Layout":"Remove All Constraints":"Deactivate All Constraints":i?"Remove Constraints":"Deactivate Constraints"},this},cellDidBindToSetting(t){}}),BMLayoutEditorSettingsDeleteConstraintCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsDeleteConstraintCell,_buttonView:void 0,initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return this._buttonView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,t.debuggingName="DeleteConstraintsButton",t.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,t.trailing.equalTo(this.contentView.trailing,{plus:-32}).isActive=YES,t.top.equalTo(this.contentView.top,{plus:8}).isActive=YES,t.bottom.equalTo(this.contentView.bottom,{plus:-8}).isActive=YES,t.node.className="BMWindowButton BMCollectionViewCellEventHandler",t.node.style.boxSizing="border-box",t.node.style.textAlign="center",t.node.style.pointer="default",t.node.style.margin=0,t.node.innerText="Delete Constraint",t.node.addEventListener("click",(t=>{this.setting.target.remove(),this.layoutEditor.selectView(this.tab._settingsPanel._referenceView)})),t.node.addEventListener("contextmenu",(t=>t.preventDefault())),this},cellDidBindToSetting(t){}}),BMLayoutEditorSettingsTitleCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsTitleCell,_titleView:void 0,initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return this._titleView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,t.debuggingName="TitleView",t.leading.equalTo(this.leading,{plus:8}).isActive=YES,t.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.node.className="BMLayoutEditorDetailsTitleCell",this},cellDidBindToSetting(t){this._titleView.node.innerText=t.name,this._titleView.invalidateIntrinsicSize()}}),BMLayoutEditorSettingsReadonlyCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsReadonlyCell,_titleView:void 0,get titleView(){return this._titleView},_inputView:void 0,get inputView(){return this._inputView},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMView.view();this._titleView=i,this.contentView.addSubview(i),i.supportsAutomaticIntrinsicSize=YES,i.debuggingName="TitleView",i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.top.equalTo(this.top,{plus:2}).isActive=YES,i.node.className="BMLayoutEditorDetailsTitleCell",i.node.style.textAlign="right",i.height.greaterThanOrEqualTo(24).isActive=YES,i.node.style.cssText="vertical-align: middle; line-height: 24px; text-align: right;";const o=document.createElement("div");o.className="BMLayoutEditorDetailsItemReadonlyValue BMLayoutEditorDetailsItemReadonlyValueCell",o.style.cssText="padding-left: 8px !important";const n=BMView.viewForNode(o);return this._inputView=n,n.supportsAutomaticIntrinsicSize=YES,n.debuggingName="LabelView",this.contentView.addSubview(n),n.leading.equalTo(i.trailing,{plus:8}).isActive=YES,n.width.greaterThanOrEqualTo(200).isActive=YES,n.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES,n.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,n.top.equalTo(this.top,{plus:2}).isActive=YES,n.height.greaterThanOrEqualTo(24).isActive=YES,n.bottom.equalTo(this.bottom,{plus:-2}).isActive=YES,this},cellDidBindToSetting(t){this._titleView.node.innerText=t.name+":",this._titleView.invalidateIntrinsicSize(),this._inputView.node.innerText=t.target[t.property],this._inputView.invalidateIntrinsicSize()}}),BMLayoutEditorSettingsViewCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsReadonlyCell.prototype),{constructor:BMLayoutEditorSettingsViewCell,initWithCollectionView(t,e){return BMLayoutEditorSettingsReadonlyCell.prototype.initWithCollectionView.apply(this,arguments),this._inputView.node.classList.add("BMLayoutEditorDetailsItemReadonlyValueClickable"),this._inputView.node.addEventListener("click",(t=>{this.settingsView.selectView(this.setting.target[this.setting.property])})),this._inputView.node.style.cssText+="margin: 0px !important;",this},cellDidBindToSetting(t){this._titleView.node.innerText=t.name+":",this._titleView.invalidateIntrinsicSize();const e=t.target[t.property],i=document.createElement("span");i.innerText="›",i.className="BMLayoutEditorDetailsItemViewLink BMCollectionViewCellEventHandler";const o=document.createElement("span");o.innerText=" "+(e.debuggingName||e.node.id),this._inputView.node.innerHTML="",this._inputView.node.appendChild(i),this._inputView.node.appendChild(o)}}),BMLayoutEditorSettingsSegmentCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsSegmentCell,_currentMenuItem:void 0,initWithCollectionView(t,e){return BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments),this.contentView.CSSClass="BMLayoutEditorDetailsTabView BMLayoutEditorDetailsSegmentControl",this.contentView.height.equalTo(48).isActive=YES,this.contentView.width.equalTo(1024,{priority:750}).isActive=YES,this},cellDidBindToSetting(t){this.contentView.contentNode.innerHTML="";for(const e of t.options){const i=document.createElement("img");i.className="BMLayoutEditorDetailsTab BMCollectionViewCellEventHandler",i.src=e.icon,this.contentView.contentNode.appendChild(i),i.title=e.name,e.userInfo==t.target[t.property]&&(this._currentMenuItem=e,i.classList.add("BMLayoutEditorDetailsTabSelected")),e._tabNode=i,i.addEventListener("click",(o=>{e!=this._currentMenuItem&&(this._currentMenuItem._tabNode.classList.remove("BMLayoutEditorDetailsTabSelected"),this._currentMenuItem=e,i.classList.add("BMLayoutEditorDetailsTabSelected"),t.target[t.property]=e.userInfo)}))}}}),BMLayoutEditorSettingsBooleanCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsBooleanCell,_titleView:void 0,get titleView(){return this._titleView},_labelView:void 0,get labelView(){return this._labelView},_inputNode:void 0,initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMLayoutEditorSettingsTitleView.titleView();this._titleView=i,this.contentView.addSubview(i),i.debuggingName="TitleView",i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.centerY.equalTo(this.centerY).isActive=YES;const o=BMView.view();o.debuggingName="BooleanContainer",this.contentView.addSubview(o),o.leading.equalTo(i.trailing,{plus:8}).isActive=YES,o.trailing.equalTo(this.contentView.trailing,{plus:-8}).isActive=YES,o.top.equalTo(this.contentView.top,{plus:2}).isActive=YES,o.bottom.equalTo(this.contentView.bottom,{plus:-2}).isActive=YES,o.width.greaterThanOrEqualTo(200).isActive=YES,o.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES;let n=document.createElement("label");n.className="BMWindowSwitch",n.style.margin="0",n.innerHTML='<input type="checkbox" data-toggle="YES"> OFF\n <div class="BMWindowSwitchGutter">\n <div class="BMWindowSwitchKnob"></div>\n </div>\n ON',this._labelView=BMView.viewForNode(n),o.addSubview(this._labelView),this._labelView.supportsAutomaticIntrinsicSize=YES,this._labelView.debuggingName="BooleanSwitch",this._labelView.centerY.equalTo(o.centerY).isActive=YES,this._labelView.leading.equalTo(o.leading).isActive=YES,this._labelView.width.equalTo(104).isActive=YES,this._labelView.height.equalTo(20).isActive=YES;let s=n.getElementsByTagName("input")[0];return this._inputNode=s,n.addEventListener("click",(t=>{this.setting.nullable&&t.target!==s&&s.checked&&(t.preventDefault(),t.stopPropagation(),s.indeterminate?(s.indeterminate=NO,s.checked=NO,this.inputValueDidChangeWithEvent(t,{toValue:NO})):(s.indeterminate=YES,this.inputValueDidChangeWithEvent(t,{toValue:void 0})))})),s.addEventListener("change",(t=>{let e=Boolean(t.target.checked);this.setting.nullable&&s.indeterminate&&(e=void 0),this.inputValueDidChangeWithEvent(t,{toValue:e})})),this},inputValueDidChangeWithEvent(t,{toValue:e}){const i=this.setting;i.sizeClass?void 0===e?i.target[`remove${BMStringByCapitalizingString(i.property)}VariationForSizeClass`](i.sizeClass):i.target[`set${BMStringByCapitalizingString(i.property)}`](e,{forSizeClass:i.sizeClass}):i.target[i.property]=e},cellDidBindToSetting(t){let e;e=t.sizeClass?t.target._variations[t.sizeClass]?t.target._variations[t.sizeClass][t.property]:void 0:t.target[t.property],void 0===e&&t.nullable?(this._inputNode.indeterminate=YES,this._inputNode.checked=YES):(this._inputNode.indeterminate=NO,this._inputNode.checked=e),this._titleView.setting=t}}),BMLayoutEditorSettingsDropdownCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsDropdownCell,_titleView:void 0,get titleView(){return this._titleView},_select:void 0,get inputView(){return this._select},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMLayoutEditorSettingsTitleView.titleView();this._titleView=i,i.debuggingName="TitleView",this.contentView.addSubview(i),i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.centerY.equalTo(this.centerY).isActive=YES;const o=document.createElement("select");o.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue BMLayoutEditorDetailsDropdown";const n=BMView.viewForNode(o);return n.debuggingName="DropdownView",this._inputView=n,this.contentView.addSubview(n),n.leading.equalTo(i.trailing,{plus:8}).isActive=YES,n.width.greaterThanOrEqualTo(200).isActive=YES,n.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,n.height.equalTo(24).isActive=YES,n.centerY.equalTo(this.centerY).isActive=YES,n.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES,o.addEventListener("change",(t=>{this._bound&&this.inputValueDidChangeWithEvent(t)})),o.addEventListener("focus",(t=>this.retain())),o.addEventListener("blur",(t=>this.release())),this},inputValueDidChangeWithEvent(t){const e=this.setting,i=JSON.parse(this._inputView.node.value);e.sizeClass?e.target[`set${BMStringByCapitalizingString(e.property)}`](i,{forSizeClass:e.sizeClass}):e.target[e.property]=i},cellDidBindToSetting(t){this._inputView.node.innerHTML="";for(const e of t.options){const t=document.createElement("option");t.value=JSON.stringify(e.userInfo),t.innerText=e.name,this._inputView.node.appendChild(t)}this._inputView.node.value=t.sizeClass?JSON.stringify(t.target._variations[t.sizeClass][t.property]):JSON.stringify(t.target[t.property]),this._titleView.setting=t}}),BMLayoutEditorSettingsInputCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsInputCell,_titleView:void 0,get titleView(){return this._titleView},_inputView:void 0,get inputView(){return this._inputView},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},get nullValue(){return""},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMLayoutEditorSettingsTitleView.titleView();this._titleView=i,this.contentView.addSubview(i),i.debuggingName="TitleView",i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.centerY.equalTo(this.centerY).isActive=YES;const o=document.createElement("input");o.className="BMWindowInput BMLayoutEditorDetailsCellInput "+e.inputClasses,o.type=e.inputKind;const n=BMView.viewForNode(o);return this._inputView=n,n.debuggingName="InputView",this.contentView.addSubview(n),n.leading.equalTo(i.trailing,{plus:8}).isActive=YES,n.width.greaterThanOrEqualTo(200).isActive=YES,n.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,n.centerY.equalTo(this.centerY).isActive=YES,n.height.equalTo(24).isActive=YES,n.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES,o.addEventListener("input",(t=>{this._bound&&this.inputValueDidChangeWithEvent(t)})),o.addEventListener("paste",(t=>{this._bound&&this.inputValueDidChangeWithEvent(t)})),o.addEventListener("focus",(t=>this.retain())),o.addEventListener("blur",(t=>this.release())),this},get value(){return this._inputView.node.value},inputValueDidChangeWithEvent(t){const e=this.setting;if(e.sizeClass){const t=this.value;void 0===t||""===t||t===this.nullValue?e.target[`remove${BMStringByCapitalizingString(e.property)}VariationForSizeClass`](e.sizeClass):e.target[`set${BMStringByCapitalizingString(e.property)}`](t,{forSizeClass:e.sizeClass})}else e.target[e.property]=this.value},cellDidBindToSetting(t){if(t.sizeClass)t.target._variations[t.sizeClass]&&t.property in t.target._variations[t.sizeClass]?this._inputView.node.value=t.target._variations[t.sizeClass][t.property]:this._inputView.node.value=this.nullValue;else{const e=t.target[t.property];this._inputView.node.value=void 0===e?this.nullValue:t.target[t.property]}this._titleView.setting=t}}),BMLayoutEditorSettingsIntegerCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsIntegerCell,initWithCollectionView(t,e){return e.inputKind="number",e.inputClasses="BMLayoutEditorDetailsItemNumericValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments),this._inputView.node.step=1,this},get value(){const t=parseInt(this._inputView.node.value,10);return isNaN(t)?0:t},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)}}),BMLayoutEditorSettingsNumberCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsNumberCell,initWithCollectionView(t,e){return e.inputKind="number",e.inputClasses="BMLayoutEditorDetailsItemNumericValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments)},get value(){const t=parseFloat(this._inputView.node.value);return isNaN(t)?0:t},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)}}),BMLayoutEditorSettingsStringCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsStringCell,initWithCollectionView(t,e){return e.inputKind="text",e.inputClasses="BMLayoutEditorDetailsItemTextValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments)},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)}}),BMLayoutEditorSettingsConstantCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsConstantCell,get nullValue(){return""},initWithCollectionView(t,e){e.inputKind="text",e.inputClasses="BMLayoutEditorDetailsItemTextValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments);const i=this._inputView.node;let o,n,s=[],a=[];return i.addEventListener("focus",(async t=>{i.select(),s=[];const e=Object.keys(this.layoutEditor.layoutVariableProvider.layoutVariables),r=new Set;e.forEach((t=>r.add(t)));let l=[];for(const t of r)s.unshift(t),s.push("-"+t);a=s,n=-1;for(const t of s)l.push(this.layoutEditor.constraintOptionWithLabel(t,{action:()=>{o=void 0,i.value=t,i.dispatchEvent(new Event("input")),i.blur()}}));if(s.length){if(this._delaysSuggestionsDropdown){const t=this.layoutEditor._createMenuWithOptions(l);o=t.children[0],setTimeout((()=>{if(document.activeElement==i){let e=BMRectMakeWithNodeFrame(i),o=BMPointMake(e.origin.x,e.bottom);this.layoutEditor.showMenuAtPoint(o,{menu:t,kind:BMMenuKind.PullDownMenu})}}),200)}else{let t=BMRectMakeWithNodeFrame(i),e=BMPointMake(t.origin.x,t.bottom);o=this.layoutEditor.showMenuAtPoint(e,{withOptions:l,kind:BMMenuKind.PullDownMenu})}o.classList.add("BMLayoutEditorConstantSuggestions"),o.parentNode.classList.add("BMLayoutEditorConstantSuggestionsOverlay"),o.addEventListener("mousedown",(t=>t.preventDefault()),YES)}const h=t=>t.preventDefault();i.addEventListener("mouseup",h),await new Promise((t=>setTimeout(t,200))),i.removeEventListener("mouseup",h)})),i.addEventListener("keydown",(t=>{if("ArrowDown"==t.code||"ArrowUp"==t.code){if(t.preventDefault(),0==a.length)return;n="ArrowUp"==t.code?Math.max((n||0)-1,0):Math.min((isNaN(n)?-1:n)+1,a.length-1);for(const t of o.querySelectorAll(".BMLayoutEditorConstraintPopupOptionHighlighted"))t.classList.remove("BMLayoutEditorConstraintPopupOptionHighlighted");o.childNodes[n].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted")}"Enter"==t.code&&(!isNaN(n)&&a.length&&(i.value=a[n],i.dispatchEvent(new Event("input"))),i.blur())})),i.addEventListener("input",(t=>{const r=this.tab._settingsPanel._referenceView,l=this._setting.target,h="constant",c="Constant";if(!r||!l)return;const d=parseFloat(i.value),u=isNaN(d)?i.value:d;if(o){a=s.filter((t=>t.toLowerCase().startsWith(i.value.toLowerCase()))),o.innerHTML="",n=0;for(const t of a)o.appendChild(this.layoutEditor.constraintOptionWithLabel(t,{action:()=>{o=void 0,i.value=t,i.dispatchEvent(new Event("input"))}}));a.length?(o.childNodes[0].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted"),o.style.display="block"):o.style.display="none"}i.value?l?(this.setting.sizeClass?l[`set${c}`](u,{forSizeClass:this.setting.sizeClass}):l[h]=u,l._updateConfiguration(),l._constraint=void 0,l._constituentConstraints=void 0,l._sourceView?l._sourceView.needsLayout=YES:l._views[0].needsLayout=YES):(this.setting.sizeClass?r[`set${c}`](d,{forSizeClass:this.setting.sizeClass}):r[h]=d,r.needsLayout=YES):e.sizeClass&&(l?(l[`remove${c}VariationForSizeClass`](e.sizeClass),l._updateConfiguration()):(r[`remove${c}VariationForSizeClass`](e.sizeClass),r._updateConfiguration()))})),i.addEventListener("blur",(t=>{o&&o.parentNode.dispatchEvent(new Event("click"))})),this},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)},inputValueDidChangeWithEvent(t){}}),BMLayoutEditorSettingsSizeCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsSizeCell,_titleView:void 0,get titleView(){return this._titleView},_widthInputView:void 0,get widthInputView(){return this._widthInputView},_heightInputView:void 0,get heightInputView(){return this._heightInputView},_indicator:void 0,get indicator(){return this._indicator},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},_createInputView(){const t=document.createElement("input");t.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue",t.type="number";const e=BMView.viewForNode(t);return e.debuggingName="InputView",e.supportsAutomaticIntrinsicSize=YES,e},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments),this._titleView=BMLayoutEditorSettingsTitleView.titleView(),this.contentView.addSubview(this._titleView),this._titleView.leading.equalTo(this.contentView.leading,{plus:8}).isActive=YES,this._titleView.top.equalTo(this.contentView.top,{plus:4}).isActive=YES,this._indicator=BMView.view(),this._indicator.node.className="BMLayoutEditorDetailsBoxIndicator";const i=document.createElement("div");i.className="BMLayoutEditorDetailsWidthIndicator",this._indicator.node.appendChild(i);const o=document.createElement("div");return o.className="BMLayoutEditorDetailsHeightIndicator",this._indicator.node.appendChild(o),this.contentView.addSubview(this._indicator),this._indicator.height.equalTo(40).isActive=YES,this._indicator.width.equalTo(40).isActive=YES,this._widthInputView=this._createInputView(),this.contentView.addSubview(this._widthInputView),this._widthInputView.width.equalTo(64).isActive=YES,this._widthInputView.node.style.textAlign="center",this._heightInputView=this._createInputView(),this.contentView.addSubview(this._heightInputView),this._heightInputView.width.equalTo(64).isActive=YES,this._heightInputView.node.style.textAlign="right",this._widthInputView.top.equalTo(this._titleView.bottom,{plus:-4}).isActive=YES,this._indicator.top.equalTo(this._widthInputView.bottom,{plus:12}).isActive=YES,this._indicator.bottom.lessThanOrEqualTo(this.contentView.bottom,{plus:-4}).isActive=YES,this._heightInputView.centerY.equalTo(this._indicator.centerY).isActive=YES,this._indicator.centerX.equalTo(this.contentView.centerX,{priority:750}).isActive=YES,this._indicator.leading.equalTo(this._heightInputView.trailing,{plus:12}).isActive=YES,this._widthInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this.contentView.trailing.greaterThanOrEqualTo(this._indicator.trailing,{plus:8}).isActive=YES,[this._widthInputView,this._heightInputView].forEach((t=>{const e=t.node;e.addEventListener("input",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("paste",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("focus",(t=>this.retain())),e.addEventListener("blur",(t=>this.release()))})),this},cellDidBindToSetting(t){let e;this._titleView.setting=t,t.sizeClass?t.target._variations[t.sizeClass]&&t.property in t.target._variations[t.sizeClass]&&t.target._variations[t.sizeClass][t.property]:e=t.target[t.property],e?(this._widthInputView.node.value=e.width,this._heightInputView.node.value=e.height):(this._widthInputView.node.value="",this._heightInputView.node.value="")},_inputValueDidChangeWithEvent(t){const e=this.setting,i=parseInt(this._widthInputView.node.value,10),o=parseInt(this._heightInputView.node.value,10);let n=isNaN(i)||isNaN(o)?void 0:BMSizeMake(i,o);e.nullable||n||(n=BMSizeMake()),this.layoutEditor.setValue(n,{forSetting:e})}}),BMLayoutEditorSettingsInsetCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsInsetCell,_titleView:void 0,get titleView(){return this._titleView},_leftInputView:void 0,get leftInputView(){return this._leftInputView},_topInputView:void 0,get heightInputView(){return this._topInputView},_rightInputView:void 0,get rightInputView(){return this._rightInputView},_bottomInputView:void 0,get bottomInputView(){return this._bottomInputView},_indicator:void 0,get indicator(){return this._indicator},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},_createInputView(){const t=document.createElement("input");t.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue",t.type="number";const e=BMView.viewForNode(t);return e.debuggingName="InputView",e.supportsAutomaticIntrinsicSize=YES,e},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments),this._titleView=BMLayoutEditorSettingsTitleView.titleView(),this.contentView.addSubview(this._titleView),this._titleView.leading.equalTo(this.contentView.leading,{plus:8}).isActive=YES,this._titleView.top.equalTo(this.contentView.top,{plus:4}).isActive=YES,this._indicator=BMView.view(),this._indicator.node.className="BMLayoutEditorDetailsBoxIndicator";const i=document.createElement("div");i.className="BMLayoutEditorDetailsInsetTopLeftIndicator",this._indicator.node.appendChild(i);const o=document.createElement("div");return o.className="BMLayoutEditorDetailsInsetBottomRightIndicator",this._indicator.node.appendChild(o),this.contentView.addSubview(this._indicator),this._indicator.height.equalTo(48).isActive=YES,this._indicator.width.equalTo(48).isActive=YES,this._leftInputView=this._createInputView(),this.contentView.addSubview(this._leftInputView),this._leftInputView.width.equalTo(64).isActive=YES,this._leftInputView.node.style.textAlign="right",this._topInputView=this._createInputView(),this.contentView.addSubview(this._topInputView),this._topInputView.width.equalTo(64).isActive=YES,this._topInputView.node.style.textAlign="center",this._rightInputView=this._createInputView(),this.contentView.addSubview(this._rightInputView),this._rightInputView.width.equalTo(64).isActive=YES,this._bottomInputView=this._createInputView(),this.contentView.addSubview(this._bottomInputView),this._bottomInputView.width.equalTo(64).isActive=YES,this._bottomInputView.node.style.textAlign="center",this._topInputView.top.equalTo(this._titleView.bottom,{plus:-4}).isActive=YES,this._indicator.top.equalTo(this._topInputView.bottom,{plus:4}).isActive=YES,this._bottomInputView.top.equalTo(this._indicator.bottom,{plus:4}).isActive=YES,this._bottomInputView.bottom.lessThanOrEqualTo(this.contentView.bottom,{plus:-4}).isActive=YES,this._leftInputView.centerY.equalTo(this._indicator.centerY).isActive=YES,this._rightInputView.centerY.equalTo(this._indicator.centerY).isActive=YES,this._indicator.centerX.equalTo(this.contentView.centerX,{priority:750}).isActive=YES,this._indicator.leading.equalTo(this._leftInputView.trailing,{plus:4}).isActive=YES,this._rightInputView.leading.equalTo(this._indicator.trailing,{plus:4}).isActive=YES,this._topInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this._bottomInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this._topInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this.contentView.trailing.greaterThanOrEqualTo(this._rightInputView.trailing,{plus:8}).isActive=YES,[this._leftInputView,this._topInputView,this._rightInputView,this._bottomInputView].forEach((t=>{const e=t.node;e.addEventListener("input",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("paste",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("focus",(t=>this.retain())),e.addEventListener("blur",(t=>this.release()))})),this},cellDidBindToSetting(t){let e;this._titleView.setting=t,t.sizeClass?t.target._variations[t.sizeClass]&&t.property in t.target._variations[t.sizeClass]&&t.target._variations[t.sizeClass][t.property]:e=t.target[t.property],e?(this._leftInputView.node.value=e.left,this._topInputView.node.value=e.top,this._rightInputView.node.value=e.right,this._bottomInputView.node.value=e.bottom):(this._leftInputView.node.value="",this._topInputView.node.value="",this._rightInputView.node.value="",this._bottomInputView.node.value="")},_inputValueDidChangeWithEvent(t){const e=this.setting,i=parseInt(this._leftInputView.node.value,10),o=parseInt(this._topInputView.node.value,10),n=parseInt(this._rightInputView.node.value,10),s=parseInt(this._bottomInputView.node.value,10);let a=isNaN(i)||isNaN(o)||isNaN(n)||isNaN(s)?void 0:BMInsetMake(i,o,n,s);e.nullable||a||(a=BMInsetMake()),this.layoutEditor.setValue(a,{forSetting:e})}}),_BMLayoutEditorViewSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorCollectionSettingsPanel.prototype),{constructor:_BMLayoutEditorViewSettingsPanel,_displayedView:void 0,_attributesTab:void 0,_layoutTab:void 0,initWithSettingsView(t,{forView:e}){if(_BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this,t),this._displayedView=e,this._attributesTab=BMLayoutEditorSettingsTab.tabWithName("Attributes",{icon:_BMURLOfImageAtPath("images/Properties.png")}),this._layoutTab=_BMLayoutEditorViewLayoutSettingsTab.viewLayoutTabForView(e),this._currentTab=this._layoutTab,this._tabs=[this._attributesTab,this._layoutTab,...e.additionalSettingTabsForLayoutEditor(this.layoutEditor)],this.title=e.debuggingName,this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForView){const t=this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForView(this.layoutEditor,e);this._tabs=this._tabs.concat(t)}for(const t of this._tabs)t._settingsPanel=this,t._view=e,t.updateSettings();return this},_updateSettingsForTab(t){if(t._settingSections=[],t==this._attributesTab){const t=this._displayedView,e=BMLayoutEditorSettingsSection.section();e._settings[0]=BMLayoutEditorSetting.settingWithName("Opacity",{kind:BMLayoutEditorSettingKind.Number,target:t,variations:YES,property:"opacity"}),e._settings[1]=BMLayoutEditorSetting.settingWithName("Visible",{kind:BMLayoutEditorSettingKind.Boolean,target:t,variations:YES,property:"isVisible"}),e._settings[2]=BMLayoutEditorSetting.settingWithName("CSS Class",{kind:BMLayoutEditorSettingKind.String,target:t,variations:YES,property:"CSSClass"}),this._attributesTab._settingSections.push(e);const i=BMLayoutEditorSettingsSection.section();i._settings[0]=BMLayoutEditorSetting.settingWithName("Content Insets",{kind:BMLayoutEditorSettingKind.Insets,target:t,variations:YES,nullable:YES,property:"contentInsets"}),this._attributesTab._settingSections.push(i)}for(const e of this._displayedView.additionalSettingSectionsForTab(t,{layoutEditor:this.layoutEditor}))t._settingSections.push(e);if(this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab)for(const e of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor,t))t._settingSections.push(e)},settingsPanelWillAppear(t){this.layoutEditor.selectView(this._displayedView)},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){}}),_BMLayoutEditorViewLayoutSettingsTab.prototype=BMExtend(Object.create(BMLayoutEditorSettingsTab.prototype),{constructor:_BMLayoutEditorViewLayoutSettingsTab,_displayedView:void 0,_showsSubviewConstraints:YES,_constraintCategories:void 0,get showsSubviewConstraints(){return this._showsSubviewConstraints},set showsSubviewConstraints(t){this._showsSubviewConstraints=t,this._updateSettings()},_showsInactiveConstraints:NO,get showsInactiveConstraints(){return this._showsInactiveConstraints},set showsInactiveConstraints(t){this._showsInactiveConstraints=t,this._updateSettings()},get _displayMode(){return this._showsInactiveConstraints&&this._showsSubviewConstraints?"all":this._showsInactiveConstraints?"inactive":this._showsSubviewConstraints?"subview":"own"},set _displayMode(t){"all"==t?(this._showsSubviewConstraints=YES,this.showsInactiveConstraints=YES):"subview"==t?(this._showsInactiveConstraints=NO,this.showsSubviewConstraints=YES):"inactive"==t?(this._showsInactiveConstraints=YES,this.showsSubviewConstraints=YES):(this._showsSubviewConstraints=YES,this.showsInactiveConstraints=NO)},initWithView(t){return BMLayoutEditorSettingsTab.prototype.initWithName.call(this,"Layout",{icon:_BMURLOfImageAtPath("images/Layout.png")}),this._displayedView=t,this},updateSettings(){this._updateSettings()},_updateSettings(){const t=this._displayedView;if(this.beginUpdates(),this._settingSections.length=0,this._intrinsicResistanceSection)t.supportsIntrinsicSize&&this._settingSections.push(this._intrinsicResistanceSection);else{const e=BMLayoutEditorSettingsSection.section();this._intrinsicResistanceSection=e,e.name="Intrinsic Size Resistance",e._settings[0]=BMLayoutEditorSetting.settingWithName("Compression",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"compressionResistance"}),e._settings[1]=BMLayoutEditorSetting.settingWithName("Expansion",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"expansionResistance"}),t.supportsIntrinsicSize&&this._settingSections.push(e)}this._settingsPanel._updateSettingsForTab(this);const e=this._constraintViewPickerSection||BMLayoutEditorSettingsSection.section();this._constraintViewPickerSection=e,e.name="Show",e._settings[0]=BMLayoutEditorEnumSetting.settingWithName("Show",{kind:BMLayoutEditorSettingKind.Segment,target:this,property:"_displayMode"}),e._settings[0].options=[BMMenuItem.menuItemWithName("This Size Class",{icon:_BMURLOfImageAtPath("images/OwnConstraints.png"),userInfo:"subview"}),BMMenuItem.menuItemWithName("All Size Classes",{icon:_BMURLOfImageAtPath("images/InactiveConstraints.png"),userInfo:"inactive"})],this._settingSections.push(e);let i={},o={},n={},s=NO,a=NO;t.localConstraints.forEach((t=>{let e=t.categoryKind;if(!t._configuration.isActive)return a=YES,n[e]=n[e]||[],void n[e].push(t);i[e]=i[e]||[],i[e].push(t)}));for(const t of Object.keys(i).sort()){const e=this[`_${t}`]||BMLayoutEditorSettingsSection.section();this[`_${t}`]=e,e.length=0,e.name=t+" Constraints",e._settings=i[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}if(this._constraintCategories=i,s&&this._showsSubviewConstraints)for(const t of Object.keys(o).sort()){const e="_subview"+t,i=this[e]||BMLayoutEditorSettingsSection.section();this[e]=i,i.length=0,i.name="Subview "+t+" Constraints",i._settings=o[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(i)}if(a&&this._showsInactiveConstraints)for(const t of Object.keys(n).sort()){const e=this[t]||BMLayoutEditorSettingsSection.section();this[t]=e,e.length=0,e.name="Inactive "+t+" Constraints",e._settings=n[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}let r=t.internalConstraints();if(r.length){const t=this._internalConstraintsSection||BMLayoutEditorSettingsSection.section();this._internalConstraintsSection=t,t.length=0,t.name="Internal Constraints",t._settings=r.map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(t)}this.layoutEditor&&this.layoutEditor._drawConstraintsForView(this._displayedView,{includesInactiveConstraints:this._showsInactiveConstraints,includesSubviewConstraints:this._showsSubviewConstraints});const l=BMLayoutEditorSettingsSection.section();l._settings[0]=BMLayoutEditorSetting.settingWithName("Deactivate Constraints",{kind:BMLayoutEditorSettingKind.DeactivateConstraintsButton,target:this}),this._settingSections.push(l),this.commitUpdates()}}),_BMLayoutEditorViewLayoutSettingsTab.viewLayoutTabForView=function(t){return(new _BMLayoutEditorViewLayoutSettingsTab).initWithView(t)},_BMLayoutEditorViewGroupSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorSettingsPanel.prototype),{constructor:_BMLayoutEditorViewGroupSettingsPanel,_views:void 0,get views(){return this._views},set views(t){this._views=t,this.title=t.length+" Selected"},initWithSettingsView(t,{forViews:e}){return _BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this,t),this._views=e,this.title=e.length+" Selected",this},readonlySettingWithName(t,e){let i=document.createElement("div");return i.className="BMLayoutEditorDetailsItemTitle",i.innerText=t,i.style.textAlign="left",i.style.paddingLeft="8px",i},buttonSettingWithName(t,e){let i;return e.class?(i=document.createElement("div"),i.className="BMLayoutEditorImageButton "+e.class):(i=document.createElement("button"),i.className="BMWindowButton",i.innerText=t),i.addEventListener("click",e.action),i},settingsDivider(){let t=document.createElement("div");return t.className="BMLayoutEditorDetailsDivider",t},equalConstraintSettingWithName(t,e){return this.buttonSettingWithName(t,{class:e.class,action:t=>{let i=BMEqualAttributeLayoutConstraint.constraintWithAttribute(e.attribute,{forViews:this.views,_internal:t.shiftKey});t.shiftKey?i.constituentConstraints.forEach((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(i)}})},settingsPanelDidLoad(){const t=this.view.node;let e=this.readonlySettingWithName("Align Horizontal",{value:""});t.appendChild(e);let i=document.createElement("div");i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Top",{class:"BMLayoutEditorImageButtonAlignAlignTop",attribute:BMLayoutAttribute.Top})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterY",attribute:BMLayoutAttribute.CenterY})),i.appendChild(this.equalConstraintSettingWithName("Align Bottom",{class:"BMLayoutEditorImageButtonAlignBottom",attribute:BMLayoutAttribute.Bottom})),t.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Distribute Horizontal",{value:""});t.appendChild(o),i=document.createElement("div"),i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Width",{class:"BMLayoutEditorImageButtonEqualWidth",attribute:BMLayoutAttribute.Width})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Align Vertical",{value:""}),t.appendChild(o),i=document.createElement("div"),i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Leading",{class:"BMLayoutEditorImageButtonAlignLeading",attribute:BMLayoutAttribute.Leading})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterX",attribute:BMLayoutAttribute.CenterX})),i.appendChild(this.equalConstraintSettingWithName("Align Trailing",{class:"BMLayoutEditorImageButtonAlignTrailing",attribute:BMLayoutAttribute.Trailing})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Distribute Vertical",{value:""}),t.appendChild(o),i=document.createElement("div"),i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualVerticalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualVerticalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Height",{class:"BMLayoutEditorImageButtonEqualHeight",attribute:BMLayoutAttribute.Height}))},settingsPanelWillAppear(t){},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){}}),_BMLayoutEditorConstraintSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorCollectionSettingsPanel.prototype),{constructor:_BMLayoutEditorConstraintSettingsPanel,_displayedConstraint:void 0,_referenceView:void 0,_attributesTab:void 0,initWithSettingsView(t,{forConstraint:e,withReferenceView:i}){if(_BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this,t),this._displayedConstraint=e,this._referenceView=i,this._attributesTab=BMLayoutEditorSettingsTab.tabWithName("Attributes",{icon:_BMURLOfImageAtPath("images/Properties.png")}),this._attributesTab._settingsPanel=this,this._currentTab=this._attributesTab,this._tabs=[this._attributesTab],this.title="Constraint",this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForConstraint){const t=this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForConstraint(this.layoutEditor,e);this._tabs=this._tabs.concat(t)}for(const t of this._tabs)t._settingsPanel=this,t._constraint=e,t.updateSettings();return this},_updateSettingsForTab(t){if(t==this._attributesTab){t._settingSections.length=0;const e=this._displayedConstraint,i=[];if(e.isConstraintCollection||(e._kind==BMLayoutConstraintKind.Horizontal?e._sourceViewAttribute===BMLayoutAttribute.Width?i.push(BMMenuItem.menuItemWithName(e._sourceViewAttribute,{userInfo:e._sourceViewAttribute})):(i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Leading,{userInfo:BMLayoutAttribute.Leading})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.CenterX,{userInfo:BMLayoutAttribute.CenterX})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Trailing,{userInfo:BMLayoutAttribute.Trailing})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Left,{userInfo:BMLayoutAttribute.Left})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Right,{userInfo:BMLayoutAttribute.Right}))):e._sourceViewAttribute===BMLayoutAttribute.Height?i.push(BMMenuItem.menuItemWithName(e._sourceViewAttribute,{userInfo:e._sourceViewAttribute})):(i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Top,{userInfo:BMLayoutAttribute.Top})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.CenterY,{userInfo:BMLayoutAttribute.CenterY})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Bottom,{userInfo:BMLayoutAttribute.Bottom})))),e.isConstraintCollection){if(e._hasEditableConstant){const t=BMLayoutEditorSettingsSection.section();t._settings[0]=BMLayoutEditorSetting.settingWithName("Constant",{kind:BMLayoutEditorSettingKind.Constant,target:e,variations:YES,property:"constant"}),t._settings[0].automaticallyExpandsVariations=YES,this._attributesTab._settingSections.push(t)}const t=BMLayoutEditorSettingsSection.section();t.title="Affected Views";let i=1;for(const o of e._views)t._settings.push(BMLayoutEditorSetting.settingWithName("View "+i,{kind:BMLayoutEditorSettingKind.View,target:e._views,property:i-1})),i++;this._attributesTab._settingSections.push(t)}else{const t=BMLayoutEditorSettingsSection.section();t._settings[0]=BMLayoutEditorSetting.settingWithName("First View",{kind:BMLayoutEditorSettingKind.View,target:e,property:"_sourceView"}),t._settings[1]=BMLayoutEditorEnumSetting.settingWithName("Attribute",{kind:BMLayoutEditorSettingKind.Enum,target:e,property:"_sourceViewAttribute"}),t._settings[1].options=i,this._attributesTab._settingSections.push(t);const o=BMLayoutEditorSettingsSection.section();o._settings[0]=BMLayoutEditorEnumSetting.settingWithName("Relation",{kind:BMLayoutEditorSettingKind.Enum,target:e,property:"_relation"}),o._settings[0].options=[BMMenuItem.menuItemWithName("=",{userInfo:BMLayoutConstraintRelation.Equals}),BMMenuItem.menuItemWithName("≥",{userInfo:BMLayoutConstraintRelation.GreaterThanOrEquals}),BMMenuItem.menuItemWithName("≤",{userInfo:BMLayoutConstraintRelation.LessThanOrEquals})],this._attributesTab._settingSections.push(o);const n=BMLayoutEditorSettingsSection.section();let s;e._targetView&&(n._settings[0]=BMLayoutEditorSetting.settingWithName("Multiplier",{kind:BMLayoutEditorSettingKind.Number,target:e,property:"_multiplier"}),n._settings[1]=BMLayoutEditorSetting.settingWithName("Second View",{kind:BMLayoutEditorSettingKind.View,target:e,property:"_targetView"}),n._settings[2]=BMLayoutEditorEnumSetting.settingWithName("Attribute",{kind:BMLayoutEditorSettingKind.Enum,target:e,property:"_targetViewAttribute"}),n._settings[2].options=i),n._settings[n._settings.length]=s=BMLayoutEditorSetting.settingWithName("Constant",{kind:BMLayoutEditorSettingKind.Constant,target:e,variations:YES,property:"constant"}),s.automaticallyExpandsVariations=YES,this._attributesTab._settingSections.push(n)}const o=BMLayoutEditorSettingsSection.section();if(o._settings[0]=BMLayoutEditorSetting.settingWithName("Priority",{kind:BMLayoutEditorSettingKind.Number,target:e,variations:YES,property:"priority"}),o._settings[1]=BMLayoutEditorSetting.settingWithName("Active",{kind:BMLayoutEditorSettingKind.Boolean,target:e,variations:YES,property:"isActive"}),o._settings[1].automaticallyExpandsVariations=YES,this._attributesTab._settingSections.push(o),this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab)for(const e of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor,t))t._settingSections.push(e);const n=BMLayoutEditorSettingsSection.section();n._settings[0]=BMLayoutEditorSetting.settingWithName("Delete",{kind:BMLayoutEditorSettingKind.DeleteConstraintButton,target:e,variations:NO}),this._attributesTab._settingSections.push(n)}else if(t._settingSections.length=0,this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab)for(const e of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor,t))t._settingSections.push(e)},async settingsPanelWillAppear(t){this.layoutEditor.selectConstraint(this._displayedConstraint,{withReferenceView:this._referenceView}),await 0;const e=BMLayoutEditorSetting.settingWithName("Constant",{kind:BMLayoutEditorSettingKind.Constant,target:this._displayedConstraint,variations:YES,property:"constant"});e._sizeClass=this.layoutEditor.activeSizeClass;const i=this._attributesTab.indexPathForObject(e),o=i&&this._attributesTab._collectionView.cellAtIndexPath(i);o&&(o._delaysSuggestionsDropdown=YES,o._inputView.node.focus())},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){}}),_BMLayoutEditorConstraintSettingsTab.prototype=BMExtend(Object.create(BMLayoutEditorSettingsTab.prototype),{constructor:_BMLayoutEditorConstraintSettingsTab,_displayedView:void 0,_showsSubviewConstraints:NO,_constraintCategories:void 0,initWithView(t){return BMLayoutEditorSettingsTab.prototype.initWithName.call(this,"Layout",{icon:_BMURLOfImageAtPath("images/Layout.png")}),this},updateSettings(){this._updateSettings()},_updateSettings(){const t=this._displayedView;if(this.beginUpdates(),this._settingSections.length=0,this._intrinsicResistanceSection)this._settingSections.push(this._intrinsicResistanceSection);else{const e=BMLayoutEditorSettingsSection.section();this._intrinsicResistanceSection=e,e._settings[0]=BMLayoutEditorSetting.settingWithName("Compression Resistance",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"compressionResistance"}),e._settings[1]=BMLayoutEditorSetting.settingWithName("Expansion Resistance",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"expansionResistance"}),this._settingSections.push(e)}if(this._intrinsicSizeSection)this._settingSections.push(this._intrinsicSizeSection);else{const e=BMLayoutEditorSettingsSection.section();this._intrinsicSizeSection=e,e._settings[0]=BMLayoutEditorSetting.settingWithName("Intrinsic Size",{kind:BMLayoutEditorSettingKind.Info,target:t,property:"supportsIntrinsicSize"}),this._settingSections.push(e)}const e=this._constraintViewPickerSection||BMLayoutEditorSettingsSection.section();this._constraintViewPickerSection=e,e.name="Show",e._settings[0]=BMLayoutEditorEnumSetting.settingWithName("Show",{kind:BMLayoutEditorSettingKind.Segment,target:this,property:"_displayMode"}),e._settings[0].options=[BMMenuItem.menuItemWithName("Own Constraints",{icon:_BMURLOfImageAtPath("images/OwnConstraints.png"),userInfo:"own"}),BMMenuItem.menuItemWithName("Subview Constraints",{icon:_BMURLOfImageAtPath("images/SubviewConstraints.png"),userInfo:"subview"}),BMMenuItem.menuItemWithName("Inactive Constraints",{icon:_BMURLOfImageAtPath("images/InactiveConstraints.png"),userInfo:"inactive"}),BMMenuItem.menuItemWithName("All Constraints",{icon:_BMURLOfImageAtPath("images/AllConstraints.png"),userInfo:"all"})],this._settingSections.push(e);let i={},o={},n={},s=NO,a=NO;t.localConstraints.forEach((e=>{let r=e.categoryKind;if(!e._configuration.isActive)return a=YES,n[r]=n[r]||[],void n[r].push(e);if(!e.isConstraintCollection){if(e._sourceView==t&&e._targetView&&e._targetView.isDescendantOfView(t))return o[r]=o[r]||[],o[r].push(e),void(s=YES);if(e._targetView==t&&e._sourceView.isDescendantOfView(t))return o[r]=o[r]||[],o[r].push(e),void(s=YES)}i[r]=i[r]||[],i[r].push(e)}));for(const t of Object.keys(i).sort()){const e=this[`_${t}`]||BMLayoutEditorSettingsSection.section();this[`_${t}`]=e,e.length=0,e.name=t+" Constraints",e._settings=i[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}if(this._constraintCategories=i,s&&this._showsSubviewConstraints)for(const t of Object.keys(o).sort()){const e="_subview"+t,i=this[e]||BMLayoutEditorSettingsSection.section();this[e]=i,i.length=0,i.name="Subview "+t+" Constraints",i._settings=o[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(i)}if(a&&this._showsInactiveConstraints)for(const t of Object.keys(n).sort()){const e=this[t]||BMLayoutEditorSettingsSection.section();this[t]=e,e.length=0,e.name="Inactive "+t+" Constraints",e._settings=n[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}let r=t.internalConstraints();if(r.length){const t=this._internalConstraintsSection||BMLayoutEditorSettingsSection.section();this._internalConstraintsSection=t,t.length=0,t.name="Internal Constraints",t._settings=r.map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(t)}this.layoutEditor&&this.layoutEditor._drawConstraintsForView(this._displayedView,{includesInactiveConstraints:this._showsInactiveConstraints,includesSubviewConstraints:this._showsSubviewConstraints});const l=BMLayoutEditorSettingsSection.section();l._settings[0]=BMLayoutEditorSetting.settingWithName("Deactivate Constraints",{kind:BMLayoutEditorSettingKind.DeactivateConstraintsButton,target:this}),this._settingSections.push(l),this.commitUpdates()}}),_BMLayoutEditorConstraintSettingsTab.viewLayoutTabForView=function(t){return(new _BMLayoutEditorConstraintSettingsTab).initWithView(t)};const BMMENU_USE_WEB_ANIMATIONS=NO,_BMMenuSpacingToNode=8,_BMMenuSubmenuTimeout=300,BMMenuSourceNodeCSSClass="BMMenuSourceNode";var BMMenuKind=Object.freeze({Menu:{},PullDownMenu:{}});function BMMenuItem(){}function BMMenu(){}BMMenuItem.prototype={_name:void 0,get name(){return this._name},_icon:void 0,get icon(){return this._icon},_action:void 0,get action(){return this._action},_submenu:void 0,get submenu(){return this._submenu},_isSeparator:NO,get isSeparator(){return this._isSeparator},userInfo:void 0,_CSSClass:"",get CSSClass(){return this._CSSClass},set CSSClass(t){let e=this._node;e&&(this._CSSClass&&this._CSSClass.split(" ").forEach((t=>e.classList.remove(t))),t&&t.split(" ").forEach((t=>e.classList.add(t)))),this._CSSClass=t||""},_keySequence:void 0,get keySequence(){return this._keySequence},set keySequence(t){this._keySequence=t},_hintHTML:void 0,get hintHTML(){return this._hintHTML},set hintHTML(t){if(this._hintHTML=t,this._node){const e=this._node.querySelector(".BMMenuItemHint");e&&(e.innerHTML=t)}},_node:void 0,_enabled:YES,get enabled(){return this._enabled},set enabled(t){if(this._enabled!=t&&!this._isSeparator&&(this._enabled=t,this._node)){const e=this._node;t?e.classList.remove("BMMenuItemDisabled"):e.classList.add("BMMenuItemDisabled")}},initWithName(t,{icon:e,action:i,submenu:o,enabled:n=!0,userInfo:s}={}){return this._name=t,this._icon=e,this._action=i,this._submenu=o,this.userInfo=s,t.startsWith("---")&&(this._isSeparator=YES,this._enabled=NO),this._enabled=n,this}},BMMenuItem.menuItemWithName=function(t,e){return(new BMMenuItem).initWithName(t,e)},BMMenuItem.menuSeparator=function(){return(new BMMenuItem).initWithName("---")},BMMenu.prototype={_items:void 0,get items(){return this._items.slice()},_delegate:void 0,get delegate(){return this._delegate},set delegate(t){this._delegate=t},_iconSize:24,get iconSize(){return this._iconSize},set iconSize(t){if(this._iconSize=t,this._node)for(const e of this._node.querySelectorAll(".BMMenuIcon"))BMCopyProperties(e.style,{width:t+"px",height:t+"px"})},_CSSClass:"",get CSSClass(){return this._CSSClass},set CSSClass(t){let e=this._node;e&&(this._CSSClass&&this._CSSClass.split(" ").forEach((t=>e.classList.remove(t))),t&&t.split(" ").forEach((t=>e.classList.add(t)))),this._CSSClass=t||""},_point:new BMPoint,_node:void 0,_containerNode:void 0,_sourceNode:void 0,_sourceNodeShadow:void 0,_sourceNodeDisplacement:0,_sourceNodeHorizontalDisplacement:0,_previouslyActiveNode:void 0,_submenu:void 0,_supermenu:void 0,_frame:void 0,get frame(){return this._frame&&this._frame.copy()},_highlightedIndex:-1,get highlightedIndex(){return this._highlightedIndex},set highlightedIndex(t){if(t!=this._highlightedIndex){if(this._highlightedIndex=t,this._node){const e=this._node.querySelector(".BMMenuItemHighlighted");e&&e.classList.remove("BMMenuItemHighlighted");const i=this._node.children[t];i&&i.classList.add("BMMenuItemHighlighted")}-1!=t&&this._submenu&&this._submenu.closeAnimated(YES)}},_delaysEvents:NO,__delaysClosing:NO,get _delaysClosing(){return this.__delaysClosing},set _delaysClosing(t){this._supermenu&&(this._supermenu._delaysClosing=t),this.__delaysClosing=t},initWithItems(t){return this._items=[...t],this},_renderMenu(){return this._supermenu?this._renderMenuWithContainer(this._supermenu._containerNode):this._renderMenuWithContainer()},_renderMenuWithContainer(t){const e=document.createElement("div");e.className=this._CSSClass?`BMMenu ${this._CSSClass}`:"BMMenu",this._node=e,this._highlightedIndex=-1,e.tabIndex=-1;const i=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{modifiers:[],target:this,action:"arrowUpPressedWithEvent"});i.preventsDefault=YES,BMView.registerKeyboardShortcut(i,{forNode:e});const o=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{modifiers:[],target:this,action:"arrowDownPressedWithEvent"});o.preventsDefault=YES,BMView.registerKeyboardShortcut(o,{forNode:e});const n=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{modifiers:[],target:this,action:"arrowRightPressedWithEvent"});n.preventsDefault=YES,BMView.registerKeyboardShortcut(n,{forNode:e});const s=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{modifiers:[],target:this,action:"arrowLeftPressedWithEvent"});s.preventsDefault=YES,BMView.registerKeyboardShortcut(s,{forNode:e});const a=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Enter",{modifiers:[],target:this,action:"returnPressedWithEvent"});a.preventsDefault=YES,BMView.registerKeyboardShortcut(a,{forNode:e});const r=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Space",{modifiers:[],target:this,action:"returnPressedWithEvent"});r.preventsDefault=YES,BMView.registerKeyboardShortcut(r,{forNode:e});const l=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Tab",{modifiers:[],target:this,action:"tabPressedWithEvent"});l.preventsDefault=YES,BMView.registerKeyboardShortcut(l,{forNode:e});const h=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Escape",{modifiers:[],target:this,action:"escapePressedWithEvent"});h.preventsDefault=YES,BMView.registerKeyboardShortcut(h,{forNode:e});for(const t of this._items)if(t.keySequence){const i=BMKeyboardShortcut.keyboardShortcutWithKeySequence(t.keySequence,{target:this,action:"_selectMenuItemWithEvent"});i._menuItem=t,BMView.registerKeyboardShortcut(i,{forNode:e})}const c=t||document.createElement("div");t||(c.className="BMMenuContainer"),"backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(e.style.backgroundColor="white"),c.appendChild(e),this._containerNode=c,this._renderMenuItems(),e.addEventListener("click",(t=>{t.target==e&&(this._submenu&&this._submenu.closeAnimated(YES),t.stopPropagation()),t.preventDefault()})),e.addEventListener("mouseleave",(t=>{this._delaysEvents||document.activeElement==e&&(this.highlightedIndex=-1)})),c.addEventListener("click",(t=>{this._delaysEvents&&this._frame&&this._frame.intersectsPoint(BMPointMake(t.clientX,t.clientY))||(this.closeAnimated(YES),t.preventDefault())})),c.addEventListener("contextmenu",(t=>{this.closeAnimated(YES),t.preventDefault()}))},_renderMenuItems(){const t=this._iconSize;this._items.forEach(((e,i)=>{if(e.name.startsWith("---")){const t=document.createElement("div");return t.className="BMMenuDivider",void this._node.appendChild(t)}let o=document.createElement("div");if(o.className="BMMenuItem",e._node=o,e.icon){const i=document.createElement("img");i.className="BMMenuIcon",i.src=e.icon,BMCopyProperties(i.style,{width:t+"px",height:t+"px"}),o.appendChild(i)}const n=document.createElement("span");n.innerText=e.name,o.appendChild(n);const s=document.createElement("div");s.classList.add("BMMenuItemHint"),s.innerHTML=e._hintHTML||"",o.appendChild(s);const a=document.createElement("div");a.classList.add("BMMenuItemDisclosure"),e.submenu&&a.classList.add("BMMenuItemDisclosureSubmenu"),o.appendChild(a),e._enabled||o.classList.add("BMMenuItemDisabled"),o.addEventListener("click",(t=>{if(!e._enabled)return;if(e.submenu&&this._sourceNodeShadow)return this._openSubmenuForMenuItem(e,{animated:YES,delayEvents:NO,acquireFocus:YES}),void t.stopPropagation();let i=YES;this.delegate&&this.delegate.menuShouldSelectItem&&(i=this.delegate.menuShouldSelectItem(this,e)),i?(this._delaysClosing=YES,e.action&&e.action(e),o.classList.add("BMMenuItemActive"),this.delegate&&this.delegate.menuDidSelectItem&&this.delegate.menuDidSelectItem(this,e)):t.stopPropagation()})),o.addEventListener("mouseover",(t=>{e._enabled?this._highlightedIndex!=i&&(this._delaysEvents||(this.highlightedIndex=i,e.submenu&&setTimeout((()=>{this._sourceNodeShadow||this._highlightedIndex==i&&this._openSubmenuForMenuItem(e,{animated:YES,delayEvents:YES})}),100))):this.highlightedIndex=-1})),this._node.appendChild(o)}))},_kind:BMMenuKind.Menu,async openFromNode(t,{animated:e=NO,kind:i=BMMenuKind.Menu}={}){this.delegate&&this.delegate.menuWillOpen&&this.delegate.menuWillOpen(this),this._sourceNode=t;const o=BMRectMakeWithNodeFrame(t);o.size.height=t.offsetHeight;const n=window.innerHeight;this._sourceNodeShadow=t.cloneNode(YES),this._renderMenu();const s=this._node,a=this._containerNode;this._supermenu||document.body.appendChild(a),document.body.appendChild(this._sourceNodeShadow);const r=o.copy();r.scaleWithFactor(1.1),a.classList.add("BMMenuContainerFullScreen"),this._sourceNodeShadow.classList.add("BMMenuSourceNodeShadow"),s.classList.add("BMMenuTouch"),this._supermenu&&(s.style.minWidth=`${this._supermenu.frame.size.width+8}px`,this._supermenu._node.classList.add("BMMenuTouchSubmenu")),this._sourceNode.classList.add(BMMenuSourceNodeCSSClass),"vibrate"in window.navigator&&window.navigator.vibrate(10);const l=s.offsetHeight,h=s.offsetWidth,c=window.innerWidth;let d=1.1;if(r.width>c-16){const t=(c-16)/r.width;r.scaleWithFactor(t),d*=t}if(r.height>n-l-16){const t=(n-l-16)/r.height;r.scaleWithFactor(t),d*=t}const u=n-r.bottom;let p=0,g=0;const w=400,y=[.17,1.46,.84,.93];r.origin.y<0&&(p=16-r.origin.y),l+16>u&&(p=u-(l+16)),h+r.origin.x+8>c&&(g=c-(h+r.origin.x+8)),this._sourceNodeDisplacement=p,this._sourceNodeHorizontalDisplacement=g,BMCopyProperties(this._sourceNodeShadow.style,{left:o.origin.x+"px",top:o.origin.y+"px",width:o.size.width+"px",height:o.size.height+"px",transform:"none"}),s.style.transformOrigin="0% 0%",i==BMMenuKind.PullDownMenu&&(s.style.transformOrigin="50% 0%");const m=BMPointMake(Math.max(r.origin.x+g,8),r.bottom+8+p);BMCopyProperties(s.style,{left:m.x+"px",top:m.y+"px"}),this._frame=BMRectMakeWithOrigin(m,{size:BMSizeMake(h,l)}),this._supermenu?BMHook(s,{opacity:0}):BMHook(a,{opacity:0}),BMHook(s,{scaleX:i==BMMenuKind.PullDownMenu?.5:.33,scaleY:i==BMMenuKind.PullDownMenu?.5:.33,translateY:-p+"px",translateX:-g+"px"}),this._supermenu?(this._supermenu._node.classList.add("BMMenuInactive"),__BMVelocityAnimate(this._supermenu._node,{scaleX:.95,scaleY:.95},{duration:w,easing:"easeOutQuad"},BMMENU_USE_WEB_ANIMATIONS)):__BMVelocityAnimate(a,{opacity:1},{duration:w,easing:y},BMMENU_USE_WEB_ANIMATIONS),s.style.overflow="hidden",__BMVelocityAnimate(s,{opacity:1},{duration:w,easing:y},BMMENU_USE_WEB_ANIMATIONS),__BMVelocityAnimate(s,{scaleX:1,scaleY:1,translateZ:0,translateY:0,translateX:0},{duration:w,easing:y,complete:t=>{s.style.pointerEvents="all",a.style.pointerEvents="all"}},BMMENU_USE_WEB_ANIMATIONS);let _=50,f=Math.min(16,150/s.childNodes.length);for(let t=0;t<s.childNodes.length;t++){const e=s.childNodes[t];BMHook(e,{translateY:"16px",translateZ:0,opacity:0}),__BMVelocityAnimate(e,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:_,complete:t==s.childNodes.length-1?()=>{s.style.overflow=""}:void 0},BMMENU_USE_WEB_ANIMATIONS),_+=f}this._previouslyActiveNode=document.activeElement,s.focus(),await __BMVelocityAnimate(this._sourceNodeShadow,{translateY:p+"px",translateX:g+"px",scaleX:d,scaleY:d},{duration:w,easing:y},BMMENU_USE_WEB_ANIMATIONS)},openAtPoint(t,{animated:e=NO,kind:i=BMMenuKind.Menu}={}){const o=BMRectMakeWithOrigin(t,{size:BMSizeMake()});return this._openAroundRect(o,arguments[1])},_openAroundRect(t,{animated:e=NO,kind:i=BMMenuKind.Menu}={}){if(this._node)return;this.delegate&&this.delegate.menuWillOpen&&this.delegate.menuWillOpen(this),this._renderMenu();const o=this._node,n=this._containerNode;BMHook(o,{scaleX:i==BMMenuKind.PullDownMenu?.5:.75,scaleY:i==BMMenuKind.PullDownMenu?.5:.75,opacity:0}),this._supermenu||document.body.appendChild(n);const s=o.offsetHeight,a=o.offsetWidth,r=window.getComputedStyle(o),l=parseInt(r.paddingTop,10)||0,h=parseInt(r.paddingBottom,10)||0;let c="0%",d=" 0%";const u=BMPointMake(t.right,t.origin.y-l),p=window.innerWidth,g=window.innerHeight;i==BMMenuKind.PullDownMenu?c="50%":a+u.x>p&&(u.x>p/2?(c="100%",o.style.maxWidth=t.origin.x+"px",u.x=t.origin.x-a):o.style.maxWidth=window.innerWidth-u.x+"px"),s+u.y>g&&(u.y>g/2?(d=" 100%",o.style.maxHeight=t.bottom+"px",u.y=Math.max(t.bottom+h-s,0)):o.style.maxHeight=g-u.y+"px"),o.style.transformOrigin=c+d,this._frame=BMRectMakeWithOrigin(u,{size:BMSizeMake(a,s)}),o.style.left=u.x+"px",o.style.top=u.y+"px",o.style.overflow="hidden",(window.Velocity||$.Velocity).animate(o,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>{o.style.pointerEvents="all",n.style.pointerEvents="all"}});let w=0,y=Math.min(16,150/o.childNodes.length);for(let t=0;t<o.childNodes.length;t++){const e=o.childNodes[t];BMHook(e,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(e,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:w,complete:t==o.childNodes.length-1?()=>{o.style.overflow=""}:void 0}),w+=y}this._previouslyActiveNode=document.activeElement,this._supermenu||o.focus()},_openSubmenuForMenuItem(t,{animated:e=YES,delayEvents:i,acquireFocus:o}={animated:YES}){const n=t._submenu;if(!n)return;const s=BMRectMakeWithNodeFrame(t._node);i&&this._delayEventsForSubmenu(n,{item:t}),n._supermenu=this,this._submenu=n,this._sourceNodeShadow?n.openFromNode(t._node,{animated:e,kind:BMMenuKind.PullDownMenu}):n._openAroundRect(s,{animated:e}),o&&n._node.focus()},_delayEventsForSubmenu(t,{item:e}){let i=t.frame;const o=BMRectMakeWithNodeFrame(e._node);let n,s,a,r=!1;const l=this._containerNode;this._delaysEvents=YES,l.classList.add("BMMenuContainerSubmenuActive");const h="mousemove";let c,d=NO;const u=()=>{this._delaysEvents=NO,l.removeEventListener(h,p,{capture:YES}),l.classList.remove("BMMenuContainerSubmenuActive"),c&&(window.clearTimeout(c),c=void 0)},p=e=>{const l=BMPointMake(e.clientX,e.clientY);if(!i)return void(i=t.frame);if(!n)return n=l,s=i.origin.x>n.x?i.origin:BMPointMake(i.right,i.origin.y),a=i.origin.x>n.x?BMPointMake(i.origin.x,i.bottom):BMPointMake(i.right,i.bottom),void(i.origin.x<n.x&&(r=!0));if(!this._delaysEvents)return void u();if(!d){if(o.intersectsPoint(l))return;d=YES,c=window.setTimeout(u,300)}if(i.intersectsPoint(l))return t._node.focus(),void u();if(e.preventDefault(),e.stopPropagation(),l.isEqualToPoint(n))return;const h=l.slopeAngleToPoint(s),p=l.slopeAngleToPoint(a),g=n.slopeAngleToPoint(l),w=Math.min(h,p),y=Math.max(h,p);(r?g>w&&g<y:g<w||g>y)?u():n=l};l.addEventListener(h,p,{capture:YES})},closeAnimated(t=YES,{withSupermenu:e=NO}={}){if(!this._node)return;this._submenu&&(this._submenu._isSupermenuClosing=YES,this._submenu.closeAnimated(t)),this.delegate&&this.delegate.menuWillClose&&this.delegate.menuWillClose(this),e&&this._supermenu&&this._supermenu.closeAnimated(t,{withSupermenu:e}),this._delaysEvents=NO,this._previouslyActiveNode&&this._previouslyActiveNode.focus();const i=this._supermenu;i&&(i._submenu=void 0,this._supermenu=void 0,i._node&&!this._isSupermenuClosing&&(__BMVelocityAnimate(i._node,{scaleX:1,scaleY:1},{duration:200,easing:"easeInOutQuad"},BMMENU_USE_WEB_ANIMATIONS),i._node.classList.remove("BMMenuTouchSubmenu"),i._node.classList.remove("BMMenuInactive"))),this._node.style.pointerEvents="none",i||(this._containerNode.style.pointerEvents="none"),this._frame=void 0;let o=16*this._node.childNodes.length;o=o<0?0:o;const n=this._delaysClosing;this._delaysClosing=NO,n&&!this._sourceNodeShadow&&(o+=200);const s=this._sourceNodeShadow,a=this._containerNode,r=this._node,l=this._sourceNode;this._sourceNode=void 0,this._sourceNodeShadow=void 0,this._items.forEach((t=>t._node=void 0));const h=s?.33:.75,c=s?200:400,d=s?"easeInOutQuad":"easeInQuad";if(s){const t={translateY:0,translateX:0,scaleX:1,scaleY:1};this._isSupermenuClosing&&(t.opacity=0),__BMVelocityAnimate(s,t,{duration:c,easing:d,delay:o},BMMENU_USE_WEB_ANIMATIONS),i||__BMVelocityAnimate(a,{opacity:0},{duration:c,easing:d,delay:o},BMMENU_USE_WEB_ANIMATIONS)}this._isSupermenuClosing=NO,this._node.style.overflow="hidden",__BMVelocityAnimate(this._node,{scaleX:this._kind==BMMenuKind.PullDownMenu?1:h,scaleY:h,opacity:s&&!i?1:0,translateY:s?-this._sourceNodeDisplacement+"px":"0px",translateX:s?-this._sourceNodeHorizontalDisplacement+"px":"0px",translateZ:0},{duration:200,easing:d,delay:o,complete:t=>{i?r.remove():a.remove(),s&&(s.remove(),l.classList.remove(BMMenuSourceNodeCSSClass)),this.delegate&&this.delegate.menuDidClose&&this.delegate.menuDidClose(this)}},BMMENU_USE_WEB_ANIMATIONS),o=0,n&&!s&&(o=200);for(let t=this._node.childNodes.length-1;t>=0;t--){__BMVelocityAnimate(this._node.childNodes[t],{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:o},BMMENU_USE_WEB_ANIMATIONS),o+=16}this._node=void 0,this._containerNode=void 0},arrowUpPressedWithEvent(t){if(0!=this._highlightedIndex){let t=this._highlightedIndex;for(;YES&&(t=BMNumberByConstrainingNumberToBounds(t-1,0,this._items.length-1),this._items[t]._isSeparator||!this._items[t]._enabled);)if(0==t)return;this.highlightedIndex=t}},arrowDownPressedWithEvent(t){if(this._highlightedIndex!=this._items.length-1){let t=this._highlightedIndex;for(;YES&&(t=BMNumberByConstrainingNumberToBounds(t+1,0,this._items.length-1),this._items[t]._isSeparator||!this._items[t]._enabled);)if(t==this._items.length-1)return;this.highlightedIndex=t}},arrowRightPressedWithEvent(t){const e=this._items[this._highlightedIndex];e&&e._submenu&&this._openSubmenuForMenuItem(e,{delayEvents:NO,acquireFocus:YES})},arrowLeftPressedWithEvent(t){this._supermenu&&this.closeAnimated(YES)},_selectMenuItemWithEvent(t,{forKeyboardShortcut:e}){t.preventDefault();const i=e._menuItem;if(i._isSeparator||!i._enabled)return;if(!this._node)return;this._node.inert=!0,this._node.style.pointerEvents="none";const o=this._items.indexOf(i);this.highlightedIndex=o,setTimeout((()=>{this.returnPressedWithEvent(t)}),50)},returnPressedWithEvent(t){if(this._highlightedIndex>=0&&this._highlightedIndex<this._items.length){const t=this._items[this._highlightedIndex];let e=YES;if(this.delegate&&this.delegate.menuShouldSelectItem&&(e=this.delegate.menuShouldSelectItem(this,t)),!e)return;this._delaysClosing=YES,t.action&&t.action(t),this.delegate&&this.delegate.menuDidSelectItem&&this.delegate.menuDidSelectItem(this,t);const i=t._node;i&&i.classList.add("BMMenuItemActive"),this.closeAnimated(YES,{withSupermenu:YES})}},tabPressedWithEvent(t){},escapePressedWithEvent(t){this._node&&this.closeAnimated(YES)}},BMMenu.menuWithItems=function(t){return(new BMMenu).initWithItems(t)};
1
+ var BMCoreUI="2.5.0",YES=!0,NO=!1;if(!("remove"in Element.prototype)){Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}}var _BMScrollBarSize,BMIsTouchDevice=!(!("ontouchstart"in window)&&!navigator.maxTouchPoints);function BMScrollBarGetSize(){if(void 0!==_BMScrollBarSize)return _BMScrollBarSize;var t=document.createElement("div");return t.style.cssText="width: 100px; height: 100px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(t),_BMScrollBarSize=t.offsetWidth-t.clientWidth,t.remove(),_BMScrollBarSize}function BMCSSRuleWithSelector(t,e){let i=e.properties,o=t+" {\n";return Object.keys(i).forEach((t=>{o+=t+": "+i[t]+(e.important?" !important":"")+";\n"})),o+="\n}\n",o}function BMAddSmoothMousewheelInteractionToNode(t,e){let i,o,n=NO,s=0,a=0,r=(e=e||{}).withDeceleration||3,l=0,h=0,c=e.baseAcceleration||6,d=e.speedIncrement||20;function u(){let e=Math.sign(s),i=Math.sign(a);if(s&&(s-=e*r),a&&(a-=i*r),s&&(s+=e*l),a&&(a+=i*h),l&&(l-=.5),h&&(h-=.5),Math.sign(s)!=e&&(s=0),Math.sign(a)!=i&&(a=0),(a||s)&&requestAnimationFrame(u),!s&&!a)return;let n=new WheelEvent("wheel",{deltaX:s,deltaY:a,deltaZ:0,deltaMode:0,clientX:o.clientX,cientY:o.clientY,offsetX:o.offsetX,offsetY:o.offsetY,layerX:o.layerX,layerY:o.layerY,target:o.target,altKey:o.altKey,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey});n._BMIsCustomScrollEvent=YES,t.dispatchEvent(n)}t.addEventListener("mousedown",(function(){s=0,a=0})),t.addEventListener("wheel",(function(t){i&&window.clearTimeout(i),i=window.setTimeout((t=>{i=void 0,n=NO}),200),t._BMIsCustomScrollEvent||n||(0==t.deltaMode&&Math.abs(t.deltaX)<50&&Math.abs(t.deltaY)<50&&Math.floor(t.deltaY)-t.deltaY==0?n=YES:(o=t,t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),0==s&&0==a&&(r=0,requestAnimationFrame(u)),Math.sign(t.deltaX)!=Math.sign(s)||0==s?(s=c*Math.sign(t.deltaX),l=c):s+=t.deltaX?Math.sign(t.deltaX)*d:0,Math.sign(t.deltaY)!=Math.sign(a)||0==a?(a=c*Math.sign(t.deltaY),h=c):a+=t.deltaY?Math.sign(t.deltaY)*d:0,r+=r?(e.withDeceleration||3)/3:e.withDeceleration||3))}))}function BMExtend(t){void 0===t&&(t={});var e=arguments.length;if("function"==typeof Object.getOwnPropertyDescriptors)for(var i=1;i<e;i++){var o=Object.getOwnPropertyDescriptors(arguments[i]);Object.defineProperties(t,o)}else for(i=1;i<e;i++)for(var n=Object.getOwnPropertyNames(arguments[i]),s=0;s<n.length;s++){var a=Object.getOwnPropertyDescriptor(arguments[i],n[s]);a&&Object.defineProperty(t,n[s],a)}return t}function BMCopyProperties(t){var e=arguments.length,i=arguments;void 0===t&&(t={});for(var o=1;o<e;o++)Object.getOwnPropertyNames(arguments[o]).forEach((function(e){t[e]=i[o][e]}));return t}function BMShadowForElevation(t,e){var i=void 0===(e=e||{}).opacity?.1:e.opacity;return"0px "+4*t+"px "+6*t+"px"+" rgba(0, 0, 0, "+i+"), "+("0px "+8*t+"px "+12*t+"px")+" rgba(0, 0, 0, "+i+")"+(e.drawOutline||NO?", 0px 0px 1px 1px rgba(0, 0, 0, "+i+")":"")}function BMNumberByInterpolatingNumbersWithFraction(t,e,i){return(e-t)*i+t}function BMNumberByConstrainingNumberToBounds(t,e,i){return Math.max(e,Math.min(t,i))}function BMStringByCapitalizingString(t){return t.charAt(0).toUpperCase()+t.slice(1)}function BMKeysForValue(t,e){var i=[];return Object.getOwnPropertyNames(e.inObject).forEach((function(o){e.inObject[o]==t&&i.push(o)})),i}function BMUUIDMake(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))}var BMHTMLEntity=Object.freeze({Control:"&#8963;",Command:"&#8984;",Option:"&#8997;",Shift:"&#8679;",CapsLock:"&#8682;",Delete:"&#9003;",Return:"&#9166;",Escape:"&#9099;",Tab:"&#8677;"}),BMScrollingDirectionVertical=Object.freeze({Stationary:0,Top:1,Bottom:-1}),BMScrollingDirectionHorizontal=Object.freeze({Stationary:0,Left:1,Right:-1});function BMInset(t,e,i,o){this.left=t||0,this.top=e||0,this.right=i||0,this.bottom=o||0}function BMInsetMakeWithEqualInsets(t){return BMInsetMake(t=t||0,t,t,t)}function BMInsetMake(t,e,i,o){return new BMInset(t,e,i,o)}function BMInsetMakeWithLeft(t,e){return new BMInset(t||0,(e=e||{}).top||0,e.right||0,e.bottom||0)}function BMPoint(t,e){t=t||0,e=e||0,this.x=t,this.y=e}function BMPointMake(t,e){return new BMPoint(t,e)}function BMPointMakeWithX(t,e){return new BMPoint(t||0,e&&e.y||0)}function BMPointMakeWithRadius(t=0,{angle:e=0}={angle:0}){return BMPointMake(t*Math.cos(e),t*Math.sin(e))}function BMDistanceBetweenPoints(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function BMSlopeAngleBetweenPoints(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}BMInset.prototype={left:0,top:0,right:0,bottom:0,initWithInset(t){return this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom,this},isEqualToInset(t){return this.left===t.left&&this.top===t.top&&this.right===t.right&&this.bottom===t.bottom},copy:function(){return new BMInset(this.left,this.top,this.right,this.bottom)}},BMInset.insetWithEqualInsets=BMInsetMakeWithEqualInsets,BMInset.insetWithLeft=BMInsetMakeWithLeft,BMPoint.prototype={x:0,y:0,get r(){return BMDistanceBetweenPoints(this,BMOriginPoint)},set r(t){const e=this.t;this.x=t*Math.cos(e),this.y=t*Math.sin(e)},get t(){return BMSlopeAngleBetweenPoints(BMOriginPoint,this)},set t(t){const e=this.r;this.x=e*Math.cos(t),this.y=e*Math.sin(t)},initWithPoint(t){return this.x=t.x,this.y=t.y,this},get stringValue(){return this.x+","+this.y},get integerStringValue(){return(0|this.x)+","+(0|this.y)},get integerPointValue(){return BMPointMake(0|this.x,0|this.y)},get integralPoint(){return this.integerPointValue},isEqualToPoint:function(t){return this.x==t.x&&this.y==t.y},copy:function(){return BMPointMake(this.x,this.y)},multiplyWithScalar(t){this.x*=t,this.y*=t},pointByMultiplyingWithScalar(t){const e=this.copy();return e.multiplyWithScalar(t),e},pointByAddingPoint(t){return BMPointMake(this.x+t.x,this.y+t.y)},pointBySubtractingPoint(t){return BMPointMake(this.x-t.x,this.y-t.y)},distanceToPoint:function(t){return BMDistanceBetweenPoints(this,t)},slopeAngleToPoint:function(t){return BMSlopeAngleBetweenPoints(this,t)},interpolatedValueWithFraction(t,e){var i=e.toValue;return BMPointMake(BMNumberByInterpolatingNumbersWithFraction(this.x,i.x,t),BMNumberByInterpolatingNumbersWithFraction(this.y,i.y,t))},toString(){return`(${this.x}:${this.y})`}},BMPoint.pointWithX=BMPointMakeWithX,BMPoint.pointWithRadius=BMPointMakeWithRadius;const BMOriginPoint=BMPointMake(0,0);function BMSize(t,e){t=t||0,e=e||0,this.width=t,this.height=e}function BMSizeMake(t,e){return new BMSize(t,e)}function BMRect(t,e){t=t||new BMPoint,e=e||new BMSize,this.origin=t,this.size=e}function BMRectByInterpolatingRect(t,e){var i=e.toRect,o=e.withFraction;return BMRectMake(BMNumberByInterpolatingNumbersWithFraction(t.origin.x,i.origin.x,o),BMNumberByInterpolatingNumbersWithFraction(t.origin.y,i.origin.y,o),BMNumberByInterpolatingNumbersWithFraction(t.size.width,i.size.width,o),BMNumberByInterpolatingNumbersWithFraction(t.size.height,i.size.height,o))}function BMRectMake(t,e,i,o){return new BMRect(new BMPoint(t,e),new BMSize(i,o))}function BMRectMakeWithX(t,e){return new BMRect(new BMPoint(t,e&&e.y),new BMSize(e&&e.width,e&&e.height))}function BMRectMakeWithOrigin(t,e){return new BMRect(t||new BMPoint,e&&e.size||new BMSize)}function BMRectMakeWithNodeFrame(t){var e=t.getBoundingClientRect();return new BMRect(new BMPoint(e.left,e.top),new BMSize(e.width,e.height))}function BMFunctionCollectionMake(){var t=[],e=function(){var e,i=this;return t.forEach((t=>e=t.apply(i,arguments))),e};return Object.getOwnPropertyNames(Array.prototype).forEach((function(i){i in e||(e[i]=function(){return t[i].apply(t,arguments)})})),BMExtend(e,{get length(){return t.length},set length(e){t.length=e},functionAtIndex:e=>t[e],setfunction:(e,i)=>t[i.atIndex]=e,_isFunctionCollection:YES}),e}BMSize.prototype={width:0,height:0,initWithSize(t){return this.width=t.width,this.height=t.height,this},newRectWithSize:function(){return new BMRect(new BMPoint,this)},copy:function(){return new BMSize(this.width,this.height)},isEqualToSize:function(t){return t.width===this.width&&t.height===this.height},isGreaterThanSize:function(t){return this.width>=t.width&&this.height>=t.height},isLessThanSize:function(t){return this.width<=t.width&&this.height<=t.height},interpolatedValueWithFraction(t,e){var i=e.toValue;return BMSizeMake(BMNumberByInterpolatingNumbersWithFraction(this.width,i.width,t),BMNumberByInterpolatingNumbersWithFraction(this.height,i.height,t))},toString(){return`[${this.width}:${this.height}]`}},BMRect.prototype={origin:void 0,size:void 0,get right(){return this.origin.x+this.size.width},get bottom(){return this.origin.y+this.size.height},get left(){return this.origin.x},get top(){return this.origin.y},get width(){return this.size.width},get height(){return this.size.height},get center(){return new BMPoint(this.origin.x+this.size.width/2,this.origin.y+this.size.height/2)},set center(t){var e=this.center;this.offset(t.x-e.x,t.y-e.y)},get integralRect(){return BMRectMake(0|this.origin.x,0|this.origin.y,0|this.size.width,0|this.size.height)},initWithRect(t){return this.origin=t.origin.copy(),this.size=t.size.copy(),this},isEqualToRect:function(t){return t.origin.x==this.origin.x&&t.origin.y==this.origin.y&&this.size.width==t.size.width&&this.size.height==t.size.height},intersectsRect:function(t){return this.isEqualToRect(t)?YES:!(t.left>this.right||t.right<this.left||t.top>this.bottom||t.bottom<this.top)},intersectsContentOfRect:function(t){return this.isEqualToRect(t)?YES:!(t.left>=this.right||t.right<=this.left||t.top>=this.bottom||t.bottom<=this.top)},rectByIntersectingWithRect:function(t){var e=new BMPoint(Math.max(this.left,t.left),Math.max(this.top,t.top)),i=new BMSize(Math.min(this.right,t.right)-e.x,Math.min(this.bottom,t.bottom)-e.y);if(!(i.width<=0||i.height<=0))return new BMRect(e,i)},rectByUnionWithRect(t){let e=Math.min(this.origin.x,t.origin.x),i=Math.min(this.origin.y,t.origin.y);return BMRectMake(e,i,Math.max(this.right,t.right)-e,Math.max(this.bottom,t.bottom)-i)},rectsByExclusiveOrWithRect:function(t){throw new Error("This method is not available.")},rectsWithDifferenceFromRect:function(t){if(!this.isEqualToRect(t)){var e=this.rectByIntersectingWithRect(t);if(!e)return[this];if(!e.isEqualToRect(this)){if(e.size.height==this.size.height)return[BMRectMake(e.origin.x==this.origin.x?e.right:this.origin.x,this.origin.y,this.size.width-e.size.width,this.size.height)];if(e.size.width==this.size.width)return[BMRectMake(this.origin.x,e.origin.y==this.origin.y?e.bottom:this.origin.y,this.size.width,this.size.height-e.size.height)];var i=BMRectMake(e.origin.x==this.origin.x?e.right:this.origin.x,this.origin.y,this.size.width-e.size.width,this.size.height);return[i,BMRectMake(i.origin.x==this.origin.x?i.right:this.origin.x,e.origin.y==this.origin.y?e.bottom:this.origin.y,this.size.width-i.size.width,this.size.height-e.size.height)]}}},containsRect:function(t){return t.left>=this.left&&t.top>=this.top&&t.right<=this.right&&t.bottom<=this.bottom},containsPoint:function(t){return t.x>this.left&&t.x<this.right&&t.y>this.top&&t.y<this.bottom},intersectsPoint:function(t){return t.x>=this.left&&t.x<=this.right&&t.y>=this.top&&t.y<=this.bottom},offset:function(t,e){this.origin.x+=t,this.origin.y+=e},offsetWithX:function(t,e){this.origin.x+=t||0,this.origin.y+=e&&e.y||0},multiplyWithScalar(t){this.origin.x*=t,this.origin.y*=t,this.size.width*=t,this.size.height*=t},rectByMultiplyingWithScalar(t){const e=this.copy();return e.multiplyWithScalar(t),e},scaleWithFactor(t,e){const i=e&&e.aroundPoint||this.center,o=BMPointMake((i.x-this.origin.x)/this.size.width,(i.y-this.origin.y)/this.size.height);this.size.width*=t,this.size.height*=t,this.origin.x=i.x-o.x*this.size.width,this.origin.y=i.y-o.y*this.size.height},rectByScalingWithFactor(t,e){const i=this.copy();return i.scaleWithFactor(t,e),i},inset:function(t,e){void 0===e?(this.origin.x+=t.left,this.origin.y+=t.top,this.size.width-=t.left+t.right,this.size.height-=t.top+t.bottom):(this.origin.x+=t,this.origin.y+=e,this.size.width-=2*t,this.size.height-=2*e)},insetWithWidth:function(t,e){var i=e.height;this.origin.x+=t,this.origin.y+=i,this.size.width-=2*t,this.size.height-=2*i},insetWithInset:function(t){this.origin.x+=t.left,this.origin.y+=t.top,this.size.width-=t.left+t.right,this.size.height-=t.top+t.bottom},rectWithInset:function(t){var e=this.copy();return e.insetWithInset(t),e},rectWithTransformToRect:function(t){var e=BMRectMake();e.size.width=t.size.width/this.size.width,e.size.height=t.size.height/this.size.height;var i=t.center.x-this.center.x,o=t.center.y-this.center.y;return e.origin.x=i,e.origin.y=o,e},copy:function(){var t=new BMRect;return t.origin.x=this.origin.x,t.origin.y=this.origin.y,t.size.width=this.size.width,t.size.height=this.size.height,t},interpolatedValueWithFraction(t,e){return BMRectByInterpolatingRect(this,{toRect:e.toValue,withFraction:t})},toString(){return`(${this.origin.x}:${this.origin.y})=>[${this.size.width}:${this.size.height}]`}};const BM_USE_VELOCITY2=NO;var BM_USE_WEB_ANIMATIONS=NO;function BMAnimatable(t,e,i){if(!i.set)throw new Error("[BMCoreUI] Incorrectly applied BMAnimatable to property "+e+" that doesn't have a setter");if(i.get){o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerAnimatableProperty(e,{targetValue:t.copy(),startingValue:this[e].copy()})}else o.call(this,t)}}else{i.get=function(){return this["_"+e]};var o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerAnimatableProperty(e,{targetValue:t.copy(),startingValue:this[e].copy()})}else o.call(this,t),this["_"+e]=t.copy()}}}function BMAnimatableNumber(t,e,i){if(!i.set)throw new Error("[BMCoreUI] Incorrectly applied BMAnimatable to property "+e+" that doesn't have a setter");if(i.get){o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerOwnProperty(e,{targetValue:t,startingValue:this[e]||0})}else o.call(this,t)}}else{i.get=function(){return this["_"+e]};var o=i.set;i.set=function(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node||document.body}).registerOwnProperty(e,{targetValue:t,startingValue:this[e]||0})}else o.call(this,t),this["_"+e]=t}}}function BMAnimationController(){}BMAnimationController.prototype={_animation:void 0,_owner:void 0,_node:void 0,_promise:void 0,get promise(){return this._promise},_resolve:void 0,_properties:void 0,initWithAnimation(t,e){return this._animation=t,this._owner=e.owner,this._node=e.node,this._properties={},this._promise=new Promise((t=>this._resolve=t)),this},registerBuiltInProperty(t,e){this._properties[t]=e.withValue},registerBuiltInPropertiesWithDictionary(t){for(let e in t)this.registerBuiltInProperty(e,{withValue:t[e]})},registerCustomProperty(t,e){this._properties.tween||(this._properties.tween={}),BM_USE_WEB_ANIMATIONS&&console.warn(`[BMAnimationController] Registering custom property ${t} with handler ${e.withHandler} which will run in legacy mode.`),this._properties.tween[t]={handler:e.withHandler,startingValue:e.startingValue,targetValue:e.targetValue,BMAnimatable:NO}},registerOwnProperty(t,e){this._properties.tween||(this._properties.tween={}),BM_USE_WEB_ANIMATIONS&&console.warn(`[BMAnimationController] Registering own property ${t} which will run in legacy mode.`);var i=this;this._properties.tween[t]={handler:(e,o)=>{i._owner[t]=o},startingValue:e.startingValue,targetValue:e.targetValue,name:t,BMAnimatable:NO}},registerAnimatableProperty(t,e){this._properties.tween||(this._properties.tween={}),BM_USE_WEB_ANIMATIONS&&console.warn(`[BMAnimationController] Registering animatable property ${t} which will run in legacy mode.`);var i=this;this._properties.tween[t]={handler:(e,o)=>{i._owner[t]=o},startingValue:e.startingValue,targetValue:e.targetValue,name:t,BMAnimatable:YES}},apply(t){if(this._options={complete:()=>{this._resolve()}},"tween"in this._properties){var e=this._properties.tween;this._properties.tween=[1,0];var i=this,o=BMFunctionCollectionMake();Object.getOwnPropertyNames(e).forEach((t=>{var n=e[t];if(n.name)if(n.BMAnimatable){(s=n.startingValue)||(s=i._owner[n.name].copy()),o.push(((t,e,i,o,a)=>{n.handler(a,s.interpolatedValueWithFraction(a,{toValue:n.targetValue}))}))}else{var s;void 0===(s=n.startingValue)&&(s=i._owner[n.name]),o.push(((t,e,i,o,a)=>{n.handler(a,BMNumberByInterpolatingNumbersWithFraction(s,n.targetValue,a))}))}else"number"==typeof n.startingValue&&"number"==typeof n.targetValue?o.push(((t,e,i,o,s)=>{n.handler(s,BMNumberByInterpolatingNumbersWithFraction(n.startingValue,n.targetValue,s))})):o.push(((t,e,i,o,s)=>{n.handler(s)}))})),this._options.progress=o}t.targets.push({element:this._node,properties:this._properties,options:this._options})}};const BMAnimationEasing=Object.freeze({ease:"cubic-bezier(0.25, 0.1, 0.25, 1)",easeIn:"cubic-bezier(0.42, 0, 1, 1)",easeOut:"cubic-bezier(0, 0, 0.58, 1)",easeInOut:"cubic-bezier(0.42, 0, 0.58, 1)",easeInSine:"cubic-bezier(0.47, 0, 0.745, 0.715)",easeOutSine:"cubic-bezier(0.39, 0.575, 0.565, 1)",easeInOutSine:"cubic-bezier(0.445, 0.05, 0.55, 0.95)",easeInQuad:"cubic-bezier(0.55, 0.085, 0.68, 0.53)",easeOutQuad:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",easeInOutQuad:"cubic-bezier(0.455, 0.03, 0.515, 0.955)",easeInCubic:"cubic-bezier(0.55, 0.055, 0.675, 0.19)",easeOutCubic:"cubic-bezier(0.215, 0.61, 0.355, 1)",easeInOutCubic:"cubic-bezier(0.645, 0.045, 0.355, 1)",easeInQuart:"cubic-bezier(0.895, 0.03, 0.685, 0.22)",easeOutQuart:"cubic-bezier(0.165, 0.84, 0.44, 1)",easeInOutQuart:"cubic-bezier(0.77, 0, 0.175, 1)",easeInQuint:"cubic-bezier(0.755, 0.05, 0.855, 0.06)",easeOutQuint:"cubic-bezier(0.23, 1, 0.32, 1)",easeInOutQuint:"cubic-bezier(0.86, 0, 0.07, 1)",easeInExpo:"cubic-bezier(0.95, 0.05, 0.795, 0.035)",easeOutExpo:"cubic-bezier(0.19, 1, 0.22, 1)",easeInOutExpo:"cubic-bezier(1, 0, 0, 1)",easeInCirc:"cubic-bezier(0.6, 0.04, 0.98, 0.335)",easeOutCirc:"cubic-bezier(0.075, 0.82, 0.165, 1)",easeInOutCirc:"cubic-bezier(0.785, 0.135, 0.15, 0.86)"}),BMAnimationTransformPropertyDefaults=Object.freeze({scaleX:1,scaleY:1,scaleZ:1,rotate:0,rotateX:0,rotateY:0,rotateZ:0,skewX:0,skewY:0,skewZ:0,translateZ:0,translateX:0,translateY:0}),BMAnimationFilterPropertyDefaults=Object.freeze({blur:1,brightness:1,contrast:1,"drop-shadow":0,grayscale:0,"hue-rotate":0,invert:0,saturate:0,sepia:0});function __BMVelocityAnimate(t,e,i,o){return BMAnimateWithBlock((()=>{BMAnimationContextGetCurrent().controllerForObject(t,{node:t}).registerBuiltInPropertiesWithDictionary(e),o&&BMAnimationContextEnableWebAnimations()}),i)}function BMHook(t,e){if(BM_USE_VELOCITY2){let i=t;window.$&&t instanceof window.$&&(i=t[0]);let o={},n="";for(let t in e)t in BMAnimationTransformPropertyDefaults?n+=`${t}(${e[t]}) `:o[t]=e[t];n&&(o.transform=n);let s="";for(let t in e)t in BMAnimationFilterPropertyDefaults&&(s+=`${t}(${e[t]}) `);s&&(o.filter=s),BMCopyProperties(i.style,o)}else for(var i in e)(window.Velocity||$.Velocity).hook(t,i,e[i])}function BMAnimationContext(){throw new Error("Animation contexts may not be created manually. To create an animation context, invoke the BMAnimationBeginWithDuration() function.")}BMAnimationContext.prototype={options:{},subscribers:void 0,controllerForObject(t,e){let i=this.subscribers.get(t);return i||(i=Object.create(BMAnimationController.prototype).initWithAnimation(this,{owner:t,node:e.node}),this.subscribers.set(t,i)),i},targets:void 0,registerAnimationForTarget:function(t,e){this.targets.push({element:t,properties:e.properties,options:e.options})},registerSubscriber:function(t,e){}},BMAnimationContext._pendingAnimations=new Map;var _BMAnimationStack=[];function BMAnimationContextGetCurrent(){let t=_BMAnimationStack[_BMAnimationStack.length-1];return t&&t._isDisabled?void 0:t}function BMAnimationContextEnableWebAnimations(){let t=BMAnimationContextGetCurrent();t&&(t._useWebAnimations=YES)}function BMAnimationContextBeginStatic(){var t=Object.create(BMAnimationContext.prototype);return t.options={duration:0,easing:"linear"},t.targets=[],t._isDisabled=YES,t.subscribers=new Map,_BMAnimationStack.push(t),t}function BMAnimationBeginWithDuration(t,e){(e=e||{}).duration=t;var i=Object.create(BMAnimationContext.prototype);return i.options=e,i.targets=[],i.subscribers=new Map,_BMAnimationStack.push(i),i}function BMAnimationContextAddCompletionHandler(t){let e;if(e=BMAnimationContextGetCurrent())if(e.options.complete)if(e.options.complete._isFunctionCollection)e.options.complete.push(t);else{let i=BMFunctionCollectionMake();i.push(e.options.complete),i.push(t),e.options.complete=i}else e.options.complete=BMFunctionCollectionMake(),e.options.complete.push(t);else t()}function BMAnimationApply(){return BMAnimationApplyBlocking(NO)}var BM_WEB_ANIMATIONS_DISABLED=NO;function BMAnimationApplyBlocking(t){let e=_BMAnimationStack[_BMAnimationStack.length-1];if(!e)return console.error("Attempted to apply an animation while there was no animation context active. This method call will be ignored."),Promise.resolve(void 0);if(e._isDisabled)return _BMAnimationStack.pop(),Promise.resolve(void 0);void 0===t&&(t=YES),new Map(BMAnimationContextGetCurrent().subscribers).forEach((function(t,e,i){t.prepare&&t.prepare(o)}));var i,o=_BMAnimationStack.pop(),n=o.targets;o.subscribers.forEach((function(t,e,i){t.apply(o)}));var s=NO;if(o.options.complete){var a=o.options.complete;i=async function(t){if(!s){s=YES,await 0,a(t);for(var e=0;e<u;e++)n[e].options&&n[e].options.complete?n[e].options.complete(t):n[e].complete&&n[e].complete(t)}}}else i=async function(t){if(!s){s=YES,await 0;for(var e=0;e<u;e++)n[e].options&&n[e].options.complete?n[e].options.complete(t):n[e].complete&&n[e].complete(t)}};o.options.complete=i;var r=o.options.stride,l=o.options.delay||0,h=window.Velocity||$.Velocity,c=[];let d=[];for(var u=o.targets.length,p=0;p<u;p++){var g=n[p].element;const t=(e._useWebAnimations||BM_USE_WEB_ANIMATIONS)&&document.body.animate&&!BM_WEB_ANIMATIONS_DISABLED;var w=n[p].options?BMCopyProperties({},o.options,n[p].options):BMCopyProperties({},o.options);if(r&&(w=BMCopyProperties({},w),p<u-1&&delete w.complete,w.delay=l,l+=r),!h||t||l||BMAnimationContext._prepareAnimationForNode(g,{withProperties:n[p].properties,options:w}),delete w.complete,t){w.queue&&console.warn("[BMCoreUI] Using the queue animation option with web animations which is not supported. This argument will be ignored.");let t={},e="",i="";for(let t in n[p].properties)t in BMAnimationTransformPropertyDefaults&&(Array.isArray(n[p].properties[t])?(i+=`${t}(${n[p].properties[t][0]}) `,e+=`${t}(${n[p].properties[t][1]}) `):i+=`${t}(${n[p].properties[t]}) `);i&&(t.transform=e?[i,e]:i);let o="";for(let t in n[p].properties)t in BMAnimationFilterPropertyDefaults&&(o+=`${t}(${n[p].properties[t]}) `);o&&(t.filter=o);for(let e in n[p].properties)e in BMAnimationTransformPropertyDefaults||e in BMAnimationFilterPropertyDefaults||"tween"!=e&&(t[e]=n[p].properties[e]);let s=g;window.$&&g instanceof window.$&&(s=g[0]),"block"==w.display&&(s.style.display="block");let a={};for(let e in t)Array.isArray(t[e])?(a[e]=t[e][1],t[e]=t[e][0],w.delay&&(s.style[e]=t[e][1])):a[e]=s.style[e];const r=Array.isArray(w.easing)?`cubic-bezier(${w.easing.join(",")})`:BMAnimationEasing[w.easing];let l;try{l=s.animate([a,t],{duration:w.duration*(window.BMAnimationMultiplier||1),easing:r||"linear",delay:w.delay&&w.delay*(window.BMAnimationMultiplier||1),composite:"replace",iterationComposite:"replace"})}catch(t){console.error("[BMCoreUI] This environment does not fully support web animations and use of this API will be disabled."),BM_WEB_ANIMATIONS_DISABLED=YES,p--;continue}let u=NO;l.finished&&(u=YES,l.finished.then((async()=>{for(let e in t)s.style[e]=t[e]}))),d.push(l);let y=new Promise(((e,i)=>{let o=NO;l.onfinish=function(){if(!o){if(o=YES,!u)for(let e in t)s.style[e]=t[e];"none"==w.display&&(s.style.display="none"),e()}},l.oncancel=function(){e()}}));c.push(y),w.progress&&c.push(h.animate(g,{tween:1},w))}else if(BM_USE_VELOCITY2)window.$&&g instanceof window.$?c.push(g[0].velocity(n[p].properties,w)):c.push(g.velocity(n[p].properties,w));else if(w.queue&&console.warn('Ignoring deprecated property "queue" for animation context.'),w.queue=!1,w.delay){const t=g,i=n[p].properties,o=w;Object.keys(i).length||(i.tween=[1,0]),c.push(new Promise((async n=>{const s=w.delay;w.delay=void 0;const a={node:t,properties:i,options:o,animationContext:e},r=(setTimeout((async()=>{const e=BMAnimationContext._pendingAnimations.get(g)||[],s=e?.indexOf(a)??-1;-1!=s&&e.splice(s,1),a?.length||BMAnimationContext._pendingAnimations.delete(g),BMAnimationContext._prepareAnimationForNode(t,{withProperties:i,options:o});const r=await h.animate(t,i,o);n(r)}),s),BMAnimationContext._pendingAnimations.get(g)||[]);r.push(a),BMAnimationContext._pendingAnimations.set(g,r)})))}else Object.keys(n[p].properties).length||(n[p].properties.tween=[1,0]),c.push(h.animate(g,n[p].properties,w))}if(window.Promise){let t=Promise.all(c);return t.then((function(){o.options.complete&&o.options.complete()})),t}}function BMAnimateWithBlock(t,e){BMAnimationBeginWithDuration(e.duration,e);return t(),e.blocking?BMAnimationApplyBlocking(YES):BMAnimationApply()}function BMRippleMakeWithElement(t,e){var i=e.forTarget;t[0].classList.add("BMRipple");var o=BMIsTouchDevice?"touchstart.ripple":"mousedown.ripple",n=BMIsTouchDevice?"touchend.ripple":"mouseup.ripple";i.on(o,(function(e){var o=i.outerWidth(),s=i.outerHeight(),a=(Math.max(o,s),Math.sqrt(Math.pow(o,2)+Math.pow(s,2))),r=i[0].getBoundingClientRect(),l=r.left,h=r.top;e.pageX=BMIsTouchDevice?e.originalEvent.touches[0].screenX:e.originalEvent.clientX,e.pageY=BMIsTouchDevice?e.originalEvent.touches[0].screenY:e.originalEvent.clientY,t.velocity("stop",!0).css({width:"0px",height:"0px",opacity:0}),BMHook(t,{translateX:e.pageX-l+"px",translateY:e.pageY-h+"px"}),t.velocity({translateX:(o-a)/2+"px",translateY:(s-a)/2+"px",width:a+"px",height:a+"px",opacity:1},{duration:400,easing:"ease-out",display:"block",queue:NO});let c=BMUUIDMake();$(window).on(n+c,(function(e){$(window).off(n+c),t.velocity({opacity:0},{duration:300,easing:"ease-in-out",display:"none",queue:NO})}))}))}function BMRippleMakeForTarget(t,e){var i=e&&e.withColor||"rgba(0, 0, 0, .1)";i=i.RGBAString||i;var o=$('<div style="position: absolute; display: block; top: 0px; left: 0px; border-radius: 50%;"></div>');return o.css({backgroundColor:i}),BMRippleMakeWithElement(o,{forTarget:t}),o}function BMIndexPath(){}BMAnimationContext._prepareAnimationForNode=function(t,{withProperties:e,options:i}){const o=window.Velocity||window.$?.Velocity;if(!o)return;const n=o.State.calls.filter((e=>e[1]?.[0]==t));for(const t of n)for(const i in e)"element"!=i&&"tween"!=i&&delete t[0]?.[0]?.[i]},BMIndexPath.prototype={object:void 0,indexes:void 0,initWithIndexPath(t){return this.object=t.object,this.indexes=t.indexes.slice(),this},get row(){return this.indexes[1]},set row(t){this.indexes[1]=t},get section(){return this.indexes[0]},set section(t){this.indexes[0]=t},copy:function(){var t=new BMIndexPath;return t.object=this.object,t.indexes=this.indexes.slice(),t},isEqualToIndexPath:function(t,e){if(!t||t==BMIndexPathNone)return NO;if(t.indexes.length!=this.indexes.length)return NO;for(var i=0;i<this.indexes.length;i++)if(this.indexes[i]!=t.indexes[i])return NO;return e.usingComparator(this.object,t.object)},isLooselyEqualToIndexPath:function(t,e){if(!t||t==BMIndexPathNone)return NO;if(void 0===t.object&&void 0===this.object){if(t.indexes.length!=this.indexes.length)return NO;for(var i=0;i<this.indexes.length;i++)if(this.indexes[i]!=t.indexes[i])return NO;return YES}return e.usingComparator(this.object,t.object)}};var BMIndexPathNone=BMIndexPathMakeWithRow(NaN,{section:NaN,forObject:NaN});function BMIndexPathMakeWithRow(t,e){var i=new BMIndexPath;return i.indexes=[e&&e.section||0,t],i.object=e&&e.forObject,i}function BMIndexPathMakeWithIndexes(t,e){var i=new BMIndexPath;return i.indexes=t,i.object=e?e.forObject:void 0,i}function BMKeyPath(){}function BMKeyPathMakeWithString(t){return(new BMKeyPath).initWithString(t)}function BMKeyPathMakeWithComponents(t){return(new BMKeyPath).initWithComponents(t)}function BMColor(){}function BMColorMake(){return BMColorMakeWithRed(0,{green:0,blue:0,alpha:0})}function BMColorMakeWithString(t){return t?_BMColorKeywords[t]?BMColorMakeWithHexString(_BMColorKeywords[t]):0==t.indexOf("#")?BMColorMakeWithHexString(t):0==t.indexOf("rgba")?BMColorMakeWithRGBAString(t):0==t.indexOf("rgb")?BMColorMakeWithRGBString(t):0==t.indexOf("hsla")?BMColorMakeWithHSLAString(t):0==t.indexOf("hsl")?BMColorMakeWithHSLString(t):void 0:BMColorMakeWithRed(0,{green:0,blue:0,alpha:0})}function BMColorMakeWithRed(t,e){var i=new BMColor;return i._storage=new _BMRGBAColor,i._storage._color=i,i._storage._red=BMNumberByConstrainingNumberToBounds(0|t,0,255),i._storage._green=BMNumberByConstrainingNumberToBounds(0|e.green,0,255),i._storage._blue=BMNumberByConstrainingNumberToBounds(0|e.blue,0,255),i._storage._alpha=BMNumberByConstrainingNumberToBounds("alpha"in e?e.alpha:1,0,1),i}function BMColorMakeWithHue(t,e){var i=new BMColor;return i._storage=new _BMHSLAColor,i._storage._color=i,i._storage._hue=BMNumberByConstrainingNumberToBounds(0|t,0,360),i._storage._saturation=BMNumberByConstrainingNumberToBounds(0|e.saturation,0,100),i._storage._lightness=BMNumberByConstrainingNumberToBounds(0|e.lightness,0,100),i._storage._alpha=BMNumberByConstrainingNumberToBounds("alpha"in e?e.alpha:1,0,1),i}function BMColorMakeWithHexString(t){var e=new BMColor;return e._storage=new _BMRGBAColor,e._storage._color=e,"#"==t.charAt(0)?(e._storage._red=parseInt(t.substring(1,3),16),e._storage._green=parseInt(t.substring(3,5),16),e._storage._blue=parseInt(t.substring(5,7),16)):(e._storage._red=parseInt(t.substring(0,2),16),e._storage._green=parseInt(t.substring(2,4),16),e._storage._blue=parseInt(t.substring(4,6),16)),e}function BMColorMakeWithRGBAString(t){var e=new BMColor;e._storage=new _BMRGBAColor,e._storage._color=e;var i=t.split(",");return e._storage.red=parseInt(i[0].substring(5),10),e._storage.green=parseInt(i[1],10),e._storage.blue=parseInt(i[2],10),e._storage.alpha=parseFloat(i[3]),e}function BMColorMakeWithRGBString(t){var e=new BMColor;e._storage=new _BMRGBAColor,e._storage._color=e;var i=t.split(",");return e._storage.red=parseInt(i[0].substring(4),10),e._storage.green=parseInt(i[1],10),e._storage.blue=parseInt(i[2],10),e}function BMColorMakeWithHSLAString(t){var e=new BMColor;e._storage=new _BMHSLAColor,e._storage._color=e;var i=t.split(",");return e._storage.hue=parseInt(i[0].substring(5),10),e._storage.saturation=parseInt(i[1],10),e._storage.luminosity=parseInt(i[2],10),e._storage.alpha=parseFloat(i[3]),e}function BMColorMakeWithHSLString(t){var e=new BMColor;e._storage=new _BMHSLAColor,e._storage._color=e;var i=t.split(",");return e._storage.hue=parseInt(i[0].substring(4),10),e._storage.saturation=parseInt(i[1],10),e._storage.luminosity=parseInt(i[2],10),e}function BMColorByInterpolatingRGBAColor(t,e){var i=e.toColor,o=e.withFraction;return BMColorMakeWithRed(BMNumberByInterpolatingNumbersWithFraction(t.red,i.red,o),{green:BMNumberByInterpolatingNumbersWithFraction(t.green,i.green,o),blue:BMNumberByInterpolatingNumbersWithFraction(t.blue,i.blue,o),alpha:BMNumberByInterpolatingNumbersWithFraction(t.alpha,i.alpha,o)})}function BMColorByInterpolatingHSLAColor(t,e){var i=e.toColor,o=e.withFraction;return BMColorMakeWithHue(BMNumberByInterpolatingNumbersWithFraction(t.hue,i.hue,o),{saturation:BMNumberByInterpolatingNumbersWithFraction(t.saturation,i.saturation,o),luminosity:BMNumberByInterpolatingNumbersWithFraction(t.luminosity,i.luminosity,o),alpha:BMNumberByInterpolatingNumbersWithFraction(t.alpha,i.alpha,o)})}function BMHexStringWithNumber(t,e){for(var i=t.toString(16),o=e&&e.minDigits||0;i.length<o;)i="0"+i;return i}function _BMRGBAColor(){}function _BMHSLAColor(){}function _BMHueToRGB(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}BMIndexPathNone.section=NaN,BMIndexPathNone.isEqualToIndexPath=function(){return NO},BMIndexPathNone.isLooselyEqualToIndexPath=function(){return NO},BMKeyPath.prototype={_components:void 0,get components(){return this._components.slice()},initWithString:function(t){this._components=t.split(".")},initWithComponents:function(t){this._components=t.slice()},valueForObject:function(t,e){for(var i=t,o=Math.min(this._components.length,e&&e.withLimit||this._components.length),n=0;n<o;n++)if(void 0===(i=i[this._components[n]]))return;return i}},BMColor.prototype={_storage:void 0,get red(){return this._storage.red},set red(t){this._storage.red=t},get green(){return this._storage.green},set green(t){this._storage.green=t},get blue(){return this._storage.blue},set blue(t){this._storage.blue=t},get alpha(){return this._storage.alpha},set alpha(t){this._storage.alpha=t},get hue(){return this._storage.hue},set hue(t){this._storage.hue=t},get saturation(){return this._storage.saturation},set saturation(t){this._storage.saturation=t},get luminosity(){return this._storage.luminosity},set luminosity(t){this._storage.luminosity=t},get RGBAString(){return this._storage.RGBAString},get RGBString(){return this._storage.RGBString},get hexString(){return this._storage.hexString},get HSLAString(){return this._storage.HSLAString},get HSLString(){return this._storage.HSLString},copy:function(){var t=new BMColor;return t._storage=this._storage.copy(),t},interpolatedValueWithFraction(t,e){return BMColorByInterpolatingRGBAColor(this,{toColor:e.toValue,withFraction:t})}},_BMRGBAColor.prototype={_color:void 0,_red:0,get red(){return this._red},set red(t){this._red=BMNumberByConstrainingNumberToBounds(0|t,0,255)},_green:0,get green(){return this._green},set green(t){this._green=BMNumberByConstrainingNumberToBounds(0|t,0,255)},_blue:0,get blue(){return this._blue},set blue(t){this._blue=BMNumberByConstrainingNumberToBounds(0|t,0,255)},_alpha:1,get alpha(){return this._alpha},set alpha(t){this._alpha=BMNumberByConstrainingNumberToBounds(t,0,1)},get hue(){return this.BMHSLAColor.hue},set hue(t){var e=this.BMHSLAColor;this._color._storage=e,e.hue=t},get saturation(){return this.BMHSLAColor.saturation},set saturation(t){var e=this.BMHSLAColor;this._color._storage=e,e.saturation=t},get luminosity(){return this.BMHSLAColor.luminosity},set luminosity(t){var e=this.BMHSLAColor;this._color._storage=e,e.luminosity=t},get BMHSLAColor(){var t=new _BMHSLAColor,e=this._red/255,i=this._green/255,o=this._blue/255,n=Math.max(e,i,o),s=Math.min(e,i,o),a=(n+s)/2;if(t._luminosity=100*a|0,n==s)t._saturation=0,t._hue=0;else{var r,l=n-s,h=a>.5?l/(2-n-s):l/(n+s);switch(n){case e:r=(i-o)/l+(i<o?6:0);break;case i:r=(o-e)/l+2;break;case o:r=(e-i)/l+4}r/=6,t._saturation=100*h|0,t._hue=360*r|0}return t._alpha=this._alpha,t},get RGBAString(){return"rgba("+this._red+","+this._green+","+this._blue+","+this._alpha+")"},get RGBString(){return"rgb("+this._red+","+this._green+","+this._blue+")"},get hexString(){return"#"+BMHexStringWithNumber(this._red,{minDigits:2})+BMHexStringWithNumber(this._green,{minDigits:2})+BMHexStringWithNumber(this._blue,{minDigits:2})},get HSLAString(){return this.BMHSLAColor.HSLAString},get HSLString(){return this.BMHSLAColor.HSLString},copy:function(){var t=new _BMRGBAColor;return t._red=this._red,t._green=this._green,t._blue=this._blue,t._alpha=this._alpha,t}},_BMHSLAColor.prototype={_color:void 0,get red(){return this.BMRGBAColor.red},set red(t){var e=this.BMRGBAColor;this._color._storage=e,e.red=t},get green(){return this.BMRGBAColor.green},set green(t){var e=this.BMRGBAColor;this._color._storage=e,e.green=t},get blue(){return this.BMRGBAColor.blue},set blue(t){var e=this.BMRGBAColor;this._color._storage=e,e.blue=t},_alpha:1,get alpha(){return this._alpha},set alpha(t){this._alpha=BMNumberByConstrainingNumberToBounds(t,0,1)},_hue:0,get hue(){return this._hue},set hue(t){this._hue=BMNumberByConstrainingNumberToBounds(0|t,0,360)},_saturation:0,get saturation(){return this._saturation},set saturation(t){this._saturation=BMNumberByConstrainingNumberToBounds(0|t,0,100)},_luminosity:0,get luminosity(){return this._luminosity},set luminosity(t){this._luminosity=BMNumberByConstrainingNumberToBounds(0|t,0,100)},get BMRGBAColor(){var t=new _BMRGBAColor;if(0==this._saturation)t._red=t._green=t._blue=this._luminosity/100*255|0;else{var e=this._hue/360,i=this._luminosity/100,o=this._saturation/100,n=i<.5?i*(1+o):i+o-i*o,s=2*i-n;t._red=255*_BMHueToRGB(s,n,e+1/3)|0,t._green=255*_BMHueToRGB(s,n,e)|0,t._blue=255*_BMHueToRGB(s,n,e-1/3)|0}return t._alpha=this._alpha,t},get RGBAString(){return this.BMRGBAColor.RGBAString},get RGBString(){return this.BMRGBAColor.RGBString},get hexString(){return this.BMRGBAColor.hexString},get HSLAString(){return"hsl("+this._hue+","+this._saturation+"%,"+this._luminosity+"%,"+this._alpha+")"},get HSLString(){return"hsl("+this._hue+","+this._saturation+"%,"+this._luminosity+"%)"},copy:function(){var t=new _BMRGBAColor;return t._hue=this._hue,t._saturation=this._saturation,t._luminosity=this._luminosity,t._alpha=this._alpha,t}};var _BMColorKeywords={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},BMLayoutDimensionClass=Object.freeze({Compact:"C",Regular:"R",Extended:"E",Any:"_"});function BMLayoutDimensionClassForSize(t){return t?t<600?BMLayoutDimensionClass.Compact:t<=1024?BMLayoutDimensionClass.Regular:BMLayoutDimensionClass.Extended:BMLayoutDimensionClass.Extended}function BMSizeForLayoutDimensionClass(t){return t==BMLayoutDimensionClass.Compact?600:t==BMLayoutDimensionClass.Regular?1024:0}var BMLayoutSizeClassDeviceKind=Object.freeze({Phone:"S",Tablet:"T",Extended:"_"}),BMLayoutOrientation=Object.freeze({Portrait:"P",Landscape:"L",Any:"_"});function BMLayoutSizeClass(){}BMLayoutSizeClass.prototype={_widthSizeClass:BMLayoutSizeClass.Extended,get widthSizeClass(){return this._widthSizeClass},_maximumWidth:0,get maximumWidth(){return this._maximumWidth},_heightSizeClass:BMLayoutSizeClass.Extended,get heightSizeClass(){return this._heightSizeClass},_maximumHeight:0,get maximumHeight(){return this._maximumHeight},_orientation:BMLayoutOrientation.Any,get orientation(){return this._orientation},_deviceKind:BMLayoutSizeClassDeviceKind.Extended,get deviceType(){return this._deviceKind},_maximumDiagonal:0,get maximumDiagonal(){return this._maximumDiagonal},_priority:0,get priority(){return this._priority},_hashString:void 0,_createHashString(){let t=[];this._maximumWidth&&t.push("w"+this._maximumWidth.toFixed()),this._maximumHeight&&t.push("h"+this._maximumWidth.toFixed()),this._maximumDiagonal&&t.push("d"+this._maximumDiagonal.toFixed()),this._orientation!=BMLayoutOrientation.Any&&t.push(this._orientation),this._hashString=t.join(" ")},isEqualToSizeClass(t){return t?this._hashString==t._hashString:NO},toString(){return this._hashString}};var _BMActiveLayoutSizeClasses=new Map;function BMViewport(){}BMLayoutSizeClass.layoutSizeClassWithMaximumWidth=function(t,e){let i=new BMLayoutSizeClass;i._widthSizeClass=BMLayoutDimensionClassForSize(t),i._maximumWidth=t,i._heightSizeClass=BMLayoutDimensionClassForSize(e.maximumHeight),i._maximumHeight=e.maximumHeight,i._orientation=e.orientation||BMLayoutOrientation.Any,i._maximumDiagonal=e.maximumDiagonal||0;let o=0;return i._maximumWidth&&(o+=10),i._maximumHeight&&(o+=10),e.orientation!==BMLayoutOrientation.Any&&(o+=1),i._priority=o,i._createHashString(),_BMActiveLayoutSizeClasses[i._hashString]?_BMActiveLayoutSizeClasses[i._hashString]:(_BMActiveLayoutSizeClasses[i._hashString]=i,i)},BMLayoutSizeClass.layoutSizeClassWithWidthClass=function(t,e){let i=new BMLayoutSizeClass;i._widthSizeClass=t,i._maximumWidth=BMSizeForLayoutDimensionClass(t),i._heightSizeClass=e.heightSizeClass,i._maximumHeight=BMSizeForLayoutDimensionClass(e.heightSizeClass),i._orientation=e.orientation||BMLayoutOrientation.Any,i._maximumDiagonal=0;let o=0;return i._maximumWidth&&(o+=10),i._maximumHeight&&(o+=10),e.orientation!==BMLayoutOrientation.Any&&(o+=1),i._priority=o,i._createHashString(),_BMActiveLayoutSizeClasses[i._hashString]?_BMActiveLayoutSizeClasses[i._hashString]:(_BMActiveLayoutSizeClasses[i._hashString]=i,i)},BMLayoutSizeClass.phoneSizeClass=function(){return this.phoneSizeClassWithOrientation(BMLayoutOrientation.Any)},BMLayoutSizeClass.phoneSizeClassWithOrientation=function(t){let e=new BMLayoutSizeClass;return e._maximumDiagonal=1e3,e._orientation=t||BMLayoutOrientation.Any,e._createHashString(),_BMActiveLayoutSizeClasses[e._hashString]?_BMActiveLayoutSizeClasses[e._hashString]:(_BMActiveLayoutSizeClasses[e._hashString]=e,e)},BMLayoutSizeClass.tabletSizeClass=function(){return this.tabletSizeClassWithOrientation(BMLayoutOrientation.Any)},BMLayoutSizeClass.tabletSizeClassWithOrientation=function(t){let e=new BMLayoutSizeClass;return e._maximumDiagonal=1450,e._orientation=t||BMLayoutOrientation.Any,e._createHashString(),_BMActiveLayoutSizeClasses[e._hashString]?_BMActiveLayoutSizeClasses[e._hashString]:(_BMActiveLayoutSizeClasses[e._hashString]=e,e)},BMLayoutSizeClass._layoutSizeClassForHashString=function(t){if(_BMActiveLayoutSizeClasses[t])return _BMActiveLayoutSizeClasses[t];let e=t.split(" "),i=new BMLayoutSizeClass;i._hashString=t;for(let t of e){switch(t.charAt(0)){case"w":i._maximumWidth=parseInt(t.substring(1,t.length)),i._widthSizeClass=BMLayoutDimensionClassForSize(i._maximumWidth);break;case"h":i._maximumHeight=parseInt(t.substring(1,t.length)),i._heightSizeClass=BMLayoutDimensionClassForSize(i._maximumHeight);break;case"d":i._maximumDiagonal=parseInt(t.substring(1,t.length));break;case"P":i._orientation=BMLayoutOrientation.Portrait;break;case"L":i._orientation=BMLayoutOrientation.Landscape;break;case"p":i._priority=parseInt(t.substring(1,t.length))}}return _BMActiveLayoutSizeClasses[i._hashString]=i,i},BMViewport.prototype={_width:void 0,get width(){return this._width},_height:void 0,get height(){return this._height},_orientation:void 0,get orientation(){return this._orientation},_diagonal:void 0,get diagonal(){return this._diagonal},_smallestDimension:void 0,get smallestDimension(){return this._smallestDimension},_surfaceArea:void 0,get surfaceArea(){return this._surfaceArea},_measurements:void 0,init(){this._measurements={}},_measureCompatibilityWithSizeClass(t){let e={},i=YES;if(t._maximumWidth&&this._width>t._maximumWidth&&(i=NO),t._maximumHeight&&this._height>t._maximumHeight&&(i=NO),t._maximumDiagonal&&this._diagonal>t._maximumDiagonal&&(i=NO),t._maximumSurfaceArea&&this._surfaceArea>t._maximumSurfaceArea&&(i=NO),t._orientation!=BMLayoutOrientation.Any&&this._orientation!=t._orientation&&(i=NO),e.matches=i,i){let i=[];t._maximumWidth&&i.push(t._maximumWidth/this._width),t._maximumHeight&&i.push(t._maximumHeight/this._height),t._maximumDiagonal&&i.push(t._maximumDiagonal/this._diagonal),t._maximumSurfaceArea&&i.push(t._maximumSurfaceArea/this._surfaceArea),i.length?e.matchPriority=i.reduce(((t,e)=>t+e))/i.length:e.matchPriority=2}else e.matchPriority=0;this._measurements[t._hashString]=e},matchesSizeClass(t){return this._measurements[t._hashString]||this._measureCompatibilityWithSizeClass(t),this._measurements[t._hashString].matches},matchPriorityForSizeClass(t){return this._measurements[t._hashString]||this._measureCompatibilityWithSizeClass(t),this._measurements[t._hashString].matchPriority},isEqualToViewport(t){return this._width==t._width&&this._height==t._height}},BMViewport.currentViewport=function(){let t=new BMViewport;return t.init(),t._width=window.innerWidth,t._height=window.innerHeight,t._diagonal=Math.sqrt(Math.pow(window.innerWidth,2)+Math.pow(window.innerHeight,2)),t._orientation=t._width>=t._height?BMLayoutOrientation.Landscape:BMLayoutOrientation.Portrait,t._surfaceArea=window.innerWidth*window.innerHeight,t};var BMLayoutAttribute=Object.freeze({Leading:"Leading",Trailing:"Trailing",Left:"Left",Right:"Right",Top:"Top",Bottom:"Bottom",CenterX:"CenterX",CenterY:"CenterY",Width:"Width",Height:"Height",AspectRatio:"AspectRatio"}),BMLayoutConstraintRelation=Object.freeze({Equals:kiwi.Operator.Eq,LessThanOrEquals:kiwi.Operator.Le,GreaterThanOrEquals:kiwi.Operator.Ge}),BMLayoutConstraintKind=Object.freeze({Horizontal:"BMLayoutConstraintKindHorizontal",Vertical:"BMLayoutConstraintKindVertical",AspectRatio:"BMLayoutConstraintKindAspectRatio"});const _BMLayoutConstraintClasses={BMLayoutConstraint:BMLayoutConstraint,BMEqualAttributeLayoutConstraint:BMEqualAttributeLayoutConstraint,BMEqualSpacingLayoutConstraint:BMEqualSpacingLayoutConstraint};function BMLayoutConstraint(){}var BMLayoutConstraintPriorityRequired=1e3;function BMEqualAttributeLayoutConstraint(){}function BMEqualSpacingLayoutConstraint(){}BMLayoutConstraint.internalConstraintWithView=function(t,e){return e._internal=YES,BMLayoutConstraint.constraintWithView(t,e)},BMLayoutConstraint.constraintWithView=function(t,e){var i=new BMLayoutConstraint;return i._identifier=BMUUIDMake(),i._sourceView=t,i._sourceViewAttribute=e.attribute,i._relation=void 0===e.relatedBy?BMLayoutConstraintRelation.Equals:e.relatedBy,i._targetView=e.toView,i._targetViewAttribute=e.secondAttribute,i._multiplier=isNaN(e.multiplier)?1:e.multiplier,i._constant=e.constant||0,e.priority?i._priority=e.priority:i._priority=BMLayoutConstraintPriorityRequired,e.attribute===BMLayoutAttribute.AspectRatio?i._kind=BMLayoutConstraintKind.AspectRatio:e.attribute===BMLayoutAttribute.Top||e.attribute==BMLayoutAttribute.Bottom||e.attribute===BMLayoutAttribute.Height||e.attribute===BMLayoutAttribute.CenterY?i._kind=BMLayoutConstraintKind.Vertical:i._kind=BMLayoutConstraintKind.Horizontal,i._variations={},i._configuration={constant:i._constant,priority:i._priority,isActive:i._isActive},"string"==typeof i._constant?i._configuration.constantValue=t.rootView.valueForLayoutVariable(i._constant):i._configuration.constantValue=i._constant,e._internal?i._internal=YES:i._install(),i},BMLayoutConstraint.constraintWithSerializedConstraint=function(t,e){return Object.create(_BMLayoutConstraintClasses[t._class||"BMLayoutConstraint"].prototype).initWithSerializedConstraint(t,e)},BMLayoutConstraint.prototype={_identifier:void 0,get identifier(){return this._identifier},set identifier(t){this._identifier=t},_solver:void 0,_constraint:void 0,initWithSerializedConstraint(t,e){if(this._sourceViewAttribute=t._sourceViewAttribute,this._relation=t._relation,this._targetViewAttribute=t._targetViewAttribute,this._multiplier=t._multiplier,this._constant=t._constant,this._kind=t._kind,this._priority=t._priority,this._sourceView=e.viewIDs(t._sourceView),this._identifier=t._identifier||BMUUIDMake(),this._isActive=void 0===t._isActive?YES:t._isActive,this._sourceView&&(!t._targetView||(this._targetView=e.viewIDs(t._targetView),this._targetView))){this._variations=t._variations||{};for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t);return this._configuration={constant:t._constant,priority:t._priority,isActive:t._isActive},this._updateConfiguration(),this._install(),this}},affectedAttributesForView(t){return t==this._sourceView?[this._sourceViewAttribute]:t==this._targetView?[this._targetViewAttribute]:[]},get isConstraintCollection(){return NO},get constituentConstraints(){return[this]},get _hasEditableConstant(){return YES},_sourceView:void 0,_sourceViewAttribute:void 0,_targetView:void 0,_targetViewAttribute:void 0,_multiplier:1,_configuration:void 0,activeSizeClassesDidChange(t){this._updateConfiguration()},layoutVariablesDidChange(){"string"==typeof this._configuration.constant&&this._updateConfiguration()},_updateConfiguration(){return this._updateConfigurationSilently(NO)},_updateConfigurationSilently(t){let e={constant:this._constant,priority:this._priority,isActive:this._isActive},i=(this._sourceView||this._views[0]).viewport;for(let t in this._variations)this._variations[t]._matchPriority=i.matchPriorityForSizeClass(this._variations[t].sizeClass);Object.keys(this._variations).map((t=>this._variations[t])).sort(((t,e)=>e._matchPriority-t._matchPriority)).forEach((t=>{t._matchPriority&&("constant"in t&&(e.constant=t.constant),"priority"in t&&(e.priority=t.priority),"isActive"in t&&(e.isActive=t.isActive))}));let o=NO;"string"==typeof e.constant?e.constantValue=this._sourceView.valueForLayoutVariable(e.constant):e.constantValue=e.constant;let n=this._configuration||e;if(this._configuration=e,this._reversesConstant&&(e.constantValue=-e.constantValue),this.isConstraintCollection)for(let t of this.constituentConstraints)t._updateConfiguration();else if(!t&&(n.isActive!=e.isActive&&(this._sourceView.needsLayout=YES,this._sourceView.rootView._invalidatedConstraints=YES,this._sourceView._checkConstraints(),this._targetView&&this._targetView._checkConstraints(),o=YES),n.priority!=e.priority&&(this._sourceView.needsLayout=YES,this._sourceView.rootView._invalidatedConstraints=YES,o=YES),n.constantValue!=e.constantValue&&!o)){if(o=YES,this._solver){if(this._constraint){try{this._solver.hasConstraint(this._constraint)&&this._solver.removeConstraint(this._constraint)}catch(t){this._cassowaryConstraint=void 0,this._sourceView.rootView._invalidatedConstraints=YES,this._sourceView.needsLayout=YES}this._constraint=void 0}try{this._solver.addConstraint(this._cassowaryConstraint)}catch(t){this._cassowaryConstraint=void 0,this._sourceView.rootView._invalidatedConstraints=YES,this._sourceView.needsLayout=YES}}e.isActive&&(this._sourceView.needsLayout=YES)}},get _activeConfiguration(){let t={constant:this._constant,priority:this._priority,isActive:this._isActive},e=this._sourceView.sizeClass,i=[];for(let t in this._variations){this._variations[t].sizeClass.matchesSizeClass(e)&&i.push(this._variations[t])}return i.sort(((t,e)=>e.sizeClass._priority-t.sizeClass._priority)).forEach((e=>{BMCopyProperties(t,e)})),t},_constant:0,get constant(){return this._constant},set constant(t){if(t!=this._constant)return this._constant=t,this._updateConfiguration()},setConstant(t,e){this._variations[e.forSizeClass._hashString]||(this._variations[e.forSizeClass._hashString]={sizeClass:e.forSizeClass},this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),this._variations[e.forSizeClass._hashString].constant=t,(this._sourceView||this._views[0]).viewport.matchesSizeClass(e.forSizeClass)&&this._updateConfiguration()},removeConstantVariationForSizeClass(t){this._variations[t._hashString]&&(delete this._variations[t._hashString].constant,1==Object.keys(this._variations[t._hashString]).length&&(delete this._variations[t._hashString],this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),(this._sourceView||this._views[0]).viewport.matchesSizeClass(t)&&this._updateConfiguration())},hasConstantVariationForSizeClass(t){return this._variations[t._hashString]?"constant"in this._variations[t._hashString]:NO},get activeConstant(){return this._configuration.constant},_priority:BMLayoutConstraintPriorityRequired,get priority(){return this._priority},set priority(t){if(this._priority!=t)return this._priority=t,this._updateConfiguration()},setPriority(t,e){this._variations[e.forSizeClass._hashString]||(this._variations[e.forSizeClass._hashString]={sizeClass:e.forSizeClass},this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),this._variations[e.forSizeClass._hashString].priority=t,(this._sourceView||this._views[0]).viewport.matchesSizeClass(e.forSizeClass)&&this._updateConfiguration()},removePriorityVariationForSizeClass(t){this._variations[t._hashString]&&(delete this._variations[t._hashString].priority,1==Object.keys(this._variations[t._hashString]).length&&(delete this._variations[t._hashString],this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),(this._sourceView||this._views[0]).viewport.matchesSizeClass(t)&&this._updateConfiguration())},hasPriorityVariationForSizeClass(t){return this._variations[t._hashString]?"priority"in this._variations[t._hashString]:NO},get activePriority(){return this._configuration.priority},_relation:BMLayoutConstraintRelation.Equals,_kind:void 0,get categoryKind(){return this._kind==BMLayoutConstraintKind.Vertical?this._sourceViewAttribute==BMLayoutAttribute.Height?"Height":"Vertical Position":this._sourceViewAttribute==BMLayoutAttribute.Width?"Width":"Horizontal Position"},_isActive:NO,get isActive(){return this._isActive},set isActive(t){if(t!=this._isActive)return this._isActive=t,this._updateConfiguration()},setIsActive(t,e){this._variations[e.forSizeClass._hashString]||(this._variations[e.forSizeClass._hashString]={sizeClass:e.forSizeClass},this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),this._variations[e.forSizeClass._hashString].isActive=t,(this._sourceView||this._views[0]).viewport.matchesSizeClass(e.forSizeClass)&&this._updateConfiguration()},removeIsActiveVariationForSizeClass(t){this._variations[t._hashString]&&(delete this._variations[t._hashString].isActive,1==Object.keys(this._variations[t._hashString]).length&&(delete this._variations[t._hashString],this.isConstraintCollection?this._views[0].rootView._invalidatedSizeClasses=YES:this._sourceView.rootView._invalidatedSizeClasses=YES),(this._sourceView||this._views[0]).viewport.matchesSizeClass(t)&&this._updateConfiguration())},hasIsActiveVariationForSizeClass(t){return this._variations[t._hashString]?"isActive"in this._variations[t._hashString]:NO},get affectsLayout(){return this._configuration.isActive},_install(){this._sourceView._addConstraint(this),this._targetView&&this._targetView._addConstraint(this),this._sourceView.rootView._invalidatedConstraints=YES},remove(){this._isActive&&(this._sourceView.needsLayout=YES),this._isActive=NO,this._sourceView._removeConstraint(this),this._sourceView.rootView._invalidatedConstraints=YES,this._targetView&&(this._targetView.needsLayout=YES,this._targetView._removeConstraint(this),this._sourceView.rootView._invalidatedConstraints=YES),this._sourceView=void 0,this._targetView=void 0},get _cassowaryExpression(){let t=this._configuration.constantValue||0;if(this._targetView){if(this._sourceViewAttribute==BMLayoutAttribute.AspectRatio){if(this._targetViewAttribute!=BMLayoutAttribute.AspectRatio)throw new Error("[BMCoreUI] Aspect ratio constraints must affect both views' aspect ratio.");throw new Error("[BMCoreUI] Non-constant aspect ratio constraint are currently not supported.")}var e=new kiwi.Expression(this._sourceView._cassowaryExpressionForLayoutAttribute(this._sourceViewAttribute)).minus(this._targetView._cassowaryExpressionForLayoutAttribute(this._targetViewAttribute,{withMultiplier:this._multiplier}));return t&&(e=this._sourceView.LTRLayout||this._kind!=BMLayoutConstraintKind.Horizontal||this._sourceViewAttribute==BMLayoutAttribute.Width?e.minus(t):e.plus(t)),e}return this._sourceViewAttribute==BMLayoutAttribute.AspectRatio?new kiwi.Expression([t,this._sourceView._variables[BMLayoutAttribute.Height]],[-1,this._sourceView._variables[BMLayoutAttribute.Width]]):t?this._sourceView._cassowaryExpressionForLayoutAttribute(this._sourceViewAttribute).plus(-t):this._sourceView._cassowaryExpressionForLayoutAttribute(this._sourceViewAttribute)},get _cassowaryConstraint(){if(this._constraint)return this._constraint;var t=this._cassowaryExpression,e=this._configuration.priority==BMLayoutConstraintPriorityRequired?kiwi.Strength.required:this._configuration.priority/1e3*kiwi.Strength.required;let i=this._relation;return this._sourceView.LTRLayout||this._kind!=BMLayoutConstraintKind.Horizontal||this._sourceViewAttribute==BMLayoutAttribute.Width||(this._relation==BMLayoutConstraintRelation.GreaterThanOrEquals?i=BMLayoutConstraintRelation.LessThanOrEquals:this._relation==BMLayoutConstraintRelation.LessThanOrEquals&&(i=BMLayoutConstraintRelation.GreaterThanOrEquals)),this._constraint=new kiwi.Constraint(t,i,void 0,e),this._constraint},_variations:void 0,get _serializedVariations(){let t={};return this._variations&&Object.keys(this._variations).forEach((e=>{t[e]={},Object.keys(this._variations[e]).forEach((i=>{"sizeClass"!=i&&(t[e][i]=this._variations[e][i])}))})),t},toString(){let t={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≥",[BMLayoutConstraintRelation.LessThanOrEquals]:"≤"};if(this._targetView){let e=this._configuration.constant?`${this._configuration.constant<0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"";return`${this._sourceView.debuggingName||this._sourceView.node.id}.${this._sourceViewAttribute} ${t[this._relation]} \t\t\t${1!=this._multiplier?this._multiplier+"* ":""}${this._targetView.debuggingName||this._targetView.node.id}.${this._targetViewAttribute} \t\t\t${e}`}return`${this._sourceView.debuggingName||this._sourceView.node.id}.${this._sourceViewAttribute} ${t[this._relation]} ${this._configuration.constant} (${this._configuration.priority})`},toCompactString(){let t={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≥",[BMLayoutConstraintRelation.LessThanOrEquals]:"≤"},e=this._sourceViewAttribute.charAt(0);if(this._sourceViewAttribute==BMLayoutAttribute.Left&&(e="Lf"),this._targetView){let i=this._targetViewAttribute.charAt(0);this._targetViewAttribute==BMLayoutAttribute.Left&&(i="Lf");let o=this._configuration.constant?`${this._configuration.constant<0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"";return`${this._sourceView.debuggingName||this._sourceView.node.id}.${e} ${t[this._relation]} \t\t\t${1!=this._multiplier?this._multiplier+"* ":""}${this._targetView.debuggingName||this._targetView.node.id}.${i} \t\t\t${o}`}return`${this._sourceView.debuggingName||this._sourceView.node.id}.${e} ${t[this._relation]} ${this._configuration.constant}`},descriptionRelativeToView(t){let e={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≥",[BMLayoutConstraintRelation.LessThanOrEquals]:"≤"};if(this._sourceView!==t&&this._targetView!==t)return this.toString();if(this._targetView){this._configuration.constant&&(this._configuration.constant,this._configuration.constant<0?this._configuration.constant:this._configuration.constant);if(this._sourceView===t){const t=this._configuration.constant?`${this._configuration.constant<0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"";return`${this._sourceViewAttribute} ${e[this._relation]} \t\t\t\t\t\t${1!=this._multiplier?this._multiplier+"* ":""}${this._targetView.debuggingName||this._targetView.node.id}.${this._targetViewAttribute} \t\t\t\t\t\t${t}`}{const t=this._configuration.constant?`${this._configuration.constant>0?"-":"+"} ${this._configuration.constant<0?-this._configuration.constant:this._configuration.constant}`:"",e={[BMLayoutConstraintRelation.Equals]:"=",[BMLayoutConstraintRelation.GreaterThanOrEquals]:"≤",[BMLayoutConstraintRelation.LessThanOrEquals]:"≥"};return`${this._targetViewAttribute} ${e[this._relation]} \t\t\t\t\t\t${1!=this._multiplier?"(":""}${this._sourceView.debuggingName||this._sourceView.node.id}.${this._sourceViewAttribute} \t\t\t\t\t\t${t}${1!=this._multiplier?") / "+this._multiplier:""}`}}return`${this._sourceViewAttribute} ${e[this._relation]} ${this._configuration.constant}`},serializedConstraintWithViewIDs(t){return{_class:"BMLayoutConstraint",_sourceViewAttribute:this._sourceViewAttribute,_relation:this._relation,_targetViewAttribute:this._targetViewAttribute,_constant:this._constant,_multiplier:this._multiplier,_priority:this._priority,_sourceView:t(this._sourceView),_targetView:this._targetView?t(this._targetView):void 0,_kind:this._kind,_identifier:this._identifier,_variations:this._serializedVariations,_isActive:this._isActive}}},BMEqualAttributeLayoutConstraint.constraintWithAttribute=function(t,e){let i=new BMEqualAttributeLayoutConstraint;return i._identifier=BMUUIDMake(),i._views=e.forViews.slice(),i._attribute=t,i._priority=e.priority||BMLayoutConstraintPriorityRequired,t===BMLayoutAttribute.Top||t==BMLayoutAttribute.Bottom||t===BMLayoutAttribute.Height||t===BMLayoutAttribute.CenterY?i._kind=BMLayoutConstraintKind.Vertical:i._kind=BMLayoutConstraintKind.Horizontal,i._variations={},i._configuration={constant:i._constant,priority:i._priority,isActive:i._isActive},e._internal?i._internal=YES:i._install(),i},BMEqualAttributeLayoutConstraint.prototype=BMExtend({},BMLayoutConstraint.prototype,{initWithSerializedConstraint(t,e){this._views=t._views.map((t=>e.viewIDs(t)));for(var i=0;i<this._views.length;i++)if(!this._views[i])return;this._attribute=t._attribute,this._kind=t._kind,this._priority=t._priority,this._identifier=t._identifier||BMUUIDMake(),this._isActive=void 0===t._isActive?YES:t._isActive,this._variations=t._variations||{};for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t);return this._updateConfiguration(),this._install(),this},_views:void 0,_attribute:void 0,affectedAttributesForView(t){return-1!=this._views.indexOf(t)?[this._attribute]:[]},get isConstraintCollection(){return YES},_constituentConstraints:void 0,get constituentConstraints(){if(this._constituentConstraints)return this._constituentConstraints;let t,e=[];for(let i=1;i<this._views.length;i++)e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[i-1],{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._views[i],secondAttribute:this._attribute,constant:0,multiplier:1,priority:this._priority})),t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES);return this._constituentConstraints=e,e},get constant(){return this._constant},set constant(t){if(t!=this._constant)return this._constant=t,this._updateConfiguration()},get _hasEditableConstant(){return NO},get categoryKind(){return this._kind==BMLayoutConstraintKind.Vertical?this._attribute==BMLayoutAttribute.Height?"Height":"Vertical Position":this._attribute==BMLayoutAttribute.Width?"Width":"Horizontal Position"},_isActive:NO,get isActive(){return this._isActive},set isActive(t){if(t!=this._isActive)return this._isActive=t,this._updateConfiguration()},_install(){this._views.forEach((t=>t._addConstraint(this))),this._views[0].rootView._invalidatedConstraints=YES},remove(){this._isActive&&(this._isActive=NO),this._views.forEach((t=>{t._removeConstraint(this),t._checkConstraints(),t.needsLayout=YES})),this._views[0].rootView._invalidatedConstraints=YES,this._views=void 0},toString(){return"Equal "+this._attribute},toCompactString(){return"Equal "+this._attribute},serializedConstraintWithViewIDs(t){return{_class:"BMEqualAttributeLayoutConstraint",_attribute:this._attribute,_priority:this._priority,_views:this._views.map((e=>t(e))),_kind:this._kind,_identifier:this._identifier,_variations:this._serializedVariations,_isActive:this._isActive}}}),BMEqualSpacingLayoutConstraint.constraintOfKind=function(t,e){let i=new BMEqualSpacingLayoutConstraint;if(i._views=e.forViews.slice(),i._kind=t,i._priority=e.priority||BMLayoutConstraintPriorityRequired,i._constant=e.constant||0,i._identifier=BMUUIDMake(),e.withSuperview){i._withSuperview=e.withSuperview;let t=e.forViews[0].superview;e.forViews.forEach((e=>{if(e.superview!=t)throw new Error("The views must have the same superview.")})),i._superview=t}return t==BMLayoutConstraintKind.Horizontal?(i._firstAttribute=BMLayoutAttribute.Leading,i._secondAttribute=BMLayoutAttribute.Trailing):(i._firstAttribute=BMLayoutAttribute.Top,i._secondAttribute=BMLayoutAttribute.Bottom),i._variations={},i._configuration={constant:i._constant,priority:i._priority,isActive:i._isActive},"string"==typeof i._constant?i._configuration.constantValue=e.forViews[0].rootView.valueForLayoutVariable(i._constant):i._configuration.constantValue=i._constant,e._internal?i._internal=YES:i._install(),i},BMEqualSpacingLayoutConstraint.prototype=BMExtend({},BMLayoutConstraint.prototype,{initWithSerializedConstraint(t,e){this._views=t._views.map((t=>e.viewIDs(t)));for(var i=0;i<this._views.length;i++)if(!this._views[i])return;if(!t._superview||(this._superview=e.viewIDs(t._superview),this._superview)){this._firstAttribute=t._firstAttribute,this._secondAttribute=t._secondAttribute,this._constant=t._constant,this._kind=t._kind,this._priority=t._priority,this._identifier=t._identifier||BMUUIDMake(),this._isActive=void 0===t._isActive?YES:t._isActive,this._variations=t._variations||{};for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t);return this._updateConfiguration(),this._install(),this}},_views:void 0,_superview:void 0,_firstAttribute:void 0,_secondAttribute:void 0,_kind:void 0,affectedAttributesForView(t){let e=0;return t==this._superview?[this._firstAttribute,this._secondAttribute]:-1!=(e=this._views.indexOf(t))?this._superview?0==e?[this._secondAttribute]:e==this._views.length-1?[this._firstAttribute]:[this._firstAttribute,this._secondAttribute]:[this._firstAttribute,this._secondAttribute]:[]},get isConstraintCollection(){return YES},_constituentConstraints:void 0,get constituentConstraints(){if(this._constituentConstraints)return this._constituentConstraints;let t,e=[];for(let i=1;i<this._views.length;i++)e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[i-1],{attribute:this._secondAttribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._views[i],secondAttribute:this._firstAttribute,constant:this._constant,multiplier:1,priority:this._priority})),t._reversesConstant=YES,t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES);return this._superview&&(e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[0],{attribute:this._firstAttribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._superview,secondAttribute:this._firstAttribute,constant:this._constant,multiplier:1,priority:this._priority})),t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES),e.push(t=BMLayoutConstraint.internalConstraintWithView(this._views[this._views.length-1],{attribute:this._secondAttribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:this._superview,secondAttribute:this._secondAttribute,constant:this._constant,multiplier:1,priority:this._priority})),t._reversesConstant=YES,t._variations=this._variations,t._isActive=this._isActive,t._updateConfigurationSilently(YES)),this._constituentConstraints=e,e},get constant(){return this._constant},set constant(t){if(t!=this._constant)return this._constant=t,this._updateConfiguration()},get _hasEditableConstant(){return YES},get categoryKind(){return this._kind==BMLayoutConstraintKind.Vertical?"Vertical Position":"Horizontal Position"},_isActive:NO,get isActive(){return this._isActive},set isActive(t){if(t!=this._isActive)return this._isActive=t,this._updateConfiguration()},_install(){this._views.forEach((t=>t._addConstraint(this))),this._views[0].rootView._invalidatedConstraints=YES,this._superview&&this._superview._addConstraint(this)},remove(){this._isActive&&(this._isActive=NO),this._views.forEach((t=>{t._removeConstraint(this),t._checkConstraints(),t.needsLayout=YES})),this._views[0].rootView._invalidatedConstraints=YES,this._superview&&(this._superview._removeConstraint(this),this._superview._checkConstraints(),this._superview.needsLayout=YES),this._views=void 0},toString:()=>"Equal Spacing",toCompactString:()=>"Equal Spacing",serializedConstraintWithViewIDs(t){return{_class:"BMEqualSpacingLayoutConstraint",_priority:this._priority,_views:this._views.map((e=>t(e))),_superview:this._superview?t(this._superview):void 0,_constant:this._constant,_firstAttribute:this._firstAttribute,_secondAttribute:this._secondAttribute,_kind:this._kind,_identifier:this._identifier,_variations:this._serializedVariations,_isActive:this._isActive}}});const BM_VIEW_USE_TRANSFORM=NO,BM_VIEW_DEBUG_AUTOMATIC_INTRINSIC_SIZE=NO,BM_VIEW_DEBUG_LAYOUT_QUEUE=NO;function BMViewConstraintAttribute(){}function BMViewLayoutQueue(){}BMViewConstraintAttribute.prototype={_attribute:void 0,_view:void 0,equalTo(t,{times:e=1,plus:i=0,priority:o=BMLayoutConstraintPriorityRequired}={}){return"number"==typeof t?BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.Equals,constant:t,priority:o}):BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.Equals,toView:t._view,secondAttribute:t._attribute,constant:i,multiplier:e,priority:o})},lessThanOrEqualTo(t,{times:e=1,plus:i=0,priority:o=BMLayoutConstraintPriorityRequired}={}){return"number"==typeof t?BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:t,priority:o}):BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,toView:t._view,secondAttribute:t._attribute,constant:i,multiplier:e,priority:o})},greaterThanOrEqualTo(t,{times:e=1,plus:i=0,priority:o=BMLayoutConstraintPriorityRequired}={}){return"number"==typeof t?BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,constant:t,priority:o}):BMLayoutConstraint.constraintWithView(this._view,{attribute:this._attribute,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,toView:t._view,secondAttribute:t._attribute,constant:i,multiplier:e,priority:o})}},BMViewLayoutQueue.prototype={_views:void 0,_enqueueView(t){if(BM_VIEW_DEBUG_LAYOUT_QUEUE&&this._views.has(t)){console.error("[BMViewLayoutQueue] Enqueueing view "+t.debuggingName+" into queue "+this._identifier+".");let e=document.createElement("div");e.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: yellow; pointer-events: none;",t.node.appendChild(e),requestAnimationFrame((()=>e.remove()))}this._views.add(t)},_removeView(t){this._views.delete(t)},dequeue(){if(BM_VIEW_DEBUG_LAYOUT_QUEUE&&this._views.size){console.error("[BMViewLayoutQueue] Dequeueing queue "+this._identifier+" with "+this._views.size+" view hierarchies.");for(let t of this._views){let e=document.createElement("div");e.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: blue; pointer-events: none;",t.node.appendChild(e),requestAnimationFrame((()=>e.remove()))}}_BMViewDequeueLayoutQueue(this)}},BMViewLayoutQueue.layoutQueue=function(){let t=new BMViewLayoutQueue;return t._views=new Set,t._identifier=BMUUIDMake(),t};var BMViewColorScheme=Object.freeze({Auto:"auto",Dark:"dark",Light:"light"});const BMViewDebug=NO,_BMViewLayoutQueue=BMViewLayoutQueue.layoutQueue(),_BMViewDequeueLayoutQueue=function(t){let e;t?(e=[...t._views],t._views=new Set):(e=[..._BMViewLayoutQueue._views],_BMViewLayoutQueue._views=new Set),e=e.map((t=>t._layoutSubviewsGenerator()));let i=YES;for(;i;)i=!e.reduce(((t,e)=>e.next().done&&t),YES)};function BMView(){}function BMScrollView(){}function BMScrollContentView(){}function BMLayoutGuide(){}!function(){var t=new WeakMap;BMView.viewForNode=function(e){let i=t.get(e);return i||(i=Object.create(this.prototype),i.initWithDOMNode(e))},BMView.view=function(){const t=document.createElement("div");return Object.create(this.prototype).initWithDOMNode(t)};const e=new Set;BMView._markAsRootView=function(t){e.add(t)},BMView._markAsNonRootView=function(t){e.delete(t)};const i={},o={};Object.defineProperty(BMView,"layoutVariables",{get:()=>BMCopyProperties({},i)}),BMView.prepareLayoutVariables=function(){},BMView.canUseLayoutVariables=function(){return YES},BMView.variationsForLayoutVariableNamed=function(t){const e=[];let i;for(let n in o)t in o[n]&&(i=o[n][t],e.push({name:t,sizeClass:o[n].sizeClass,value:i}));return e},BMView.registerLayoutVariableNamed=function(t,{withValue:o}){i[t]=o;for(const t of e)t._layoutVariablesDidUpdate()},BMView.renameLayoutVariableNamed=function(t,{toName:n}){if(t in i){if(n in i)throw new Error("A layout variable with the given name already exists.");i[n]=i[t],delete i[t];for(let e in o)t in o[e]&&(o[e][n]=o[e][t],delete o[e][t]);for(const t of e)t._layoutVariablesDidUpdate()}},BMView.unregisterLayoutVariableNamed=function(t){delete i[t];for(const t of e)t._layoutVariablesDidUpdate()},BMView.setLayoutVariableValue=function(t,{named:i,inSizeClass:n}){o[n._hashString]=o[n._hashString]||{sizeClass:n},o[n._hashString][i]=t;for(const t of e)t._layoutVariablesDidUpdate()},BMView.removeVariationForLayoutVariableNamed=function(t,{inSizeClass:i}){if(o[i._hashString]){delete o[i._hashString][t],1==Object.keys(o[i._hashString]).length&&delete o[i._hashString];for(const t of e)t._layoutVariablesDidUpdate()}},BMView.removeVariationsForLayoutVariableNamed=function(t){for(let e in o)delete o[e][t],1==Object.keys(o[e]).length&&delete o[e];for(const t of e)t._layoutVariablesDidUpdate()},BMView.persistLayoutVariables=function(){},BMView.prototype._layoutVariableValuesForViewport=function(t){let e={};for(let t of Object.keys(i))e[t]=i[t];for(let e in o)o[e]._matchPriority=t.matchPriorityForSizeClass(o[e].sizeClass);return Object.keys(o).map((t=>o[t])).sort(((t,e)=>e._matchPriority-t._matchPriority)).forEach((t=>{if(t._matchPriority)for(let o in i)o in t&&(e[o]=t[o])})),this._layoutVariables=e,e};const n=new WeakMap,s=function(t){this.node=t,this._keyboardShortcuts={}};s.prototype={node:void 0,_keyboardShortcuts:void 0,registerKeyboardShortcut(t){return BMView.prototype.registerKeyboardShortcut.apply(this,arguments)},unregisterKeyboardShortcut(t){return BMView.prototype.unregisterKeyboardShortcut.apply(this,arguments)},keyPressedWithEvent(t){return BMView.prototype.keyPressedWithEvent.apply(this,arguments)},_keyboardShortcutsEnabled:NO,_enableKeyboardShortcuts(){return BMView.prototype._enableKeyboardShortcuts.apply(this,arguments)},_disableKeyboardShortcuts(){return BMView.prototype._disableKeyboardShortcuts.apply(this,arguments)}},BMView.registerKeyboardShortcut=function(t,{forNode:e}){let i=n.get(e);i||(i=new s(e),n.set(e,i)),i.registerKeyboardShortcut(t)},BMView.unregisterKeyboardShortcut=function(t,{forNode:e}){const i=n.get(e);i&&i.unregisterKeyboardShortcut(t)},BMView.prototype._releaseRecursive=function(){if(!this.__released){this.__released=YES;for(const t of this._subviews)t._releaseRecursive();t.delete(this._node),e.delete(this)}},BMView.prototype.release=function(){if(!this.__released){this.__released=YES,this.layoutQueue._removeView(this);for(const t of this._subviews.slice())t._releaseRecursive();t.delete(this._node),this._superview&&this.removeFromSuperview(),e.delete(this)}},BMView.prototype.initWithDOMNode=function(e){var i;if(this._node=e,this._constraints=[],this._subviews=[],i=t.get(e)){if(i!=this)throw new Error("There is already a view associated with the given node.")}else t.set(e,this);this._variables={[BMLayoutAttribute.Left]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Left),[BMLayoutAttribute.Width]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Width),[BMLayoutAttribute.Top]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Top),[BMLayoutAttribute.Height]:new kiwi.Variable(this.node.id+"."+BMLayoutAttribute.Height)};for(let t in BMLayoutAttribute){let e=t.substring(0,1).toLowerCase()+t.substring(1,t.length),i=Object.create(BMViewConstraintAttribute.prototype);i._view=this,i._attribute=BMLayoutAttribute[t],this[e]=i}return this._sizeClasses=new Set,this._variations={},this._configuration={opacity:this._opacity,isVisible:this._isVisible,contentInsets:this.__activeInsets},this._variableProperties={},this._keyboardShortcuts={},this}}(),BMView.prototype=BMExtend(BMView.prototype,{_node:void 0,get node(){return this._node},get contentNode(){return this._node},debuggingName:"",leading:void 0,trailing:void 0,left:void 0,right:void 0,top:void 0,bottom:void 0,centerX:void 0,centerY:void 0,width:void 0,height:void 0,_layoutEditor:void 0,get layoutEditor(){return this._layoutEditor},set layoutEditor(t){this._layoutEditor=t},_layoutQueue:_BMViewLayoutQueue,get layoutQueue(){return this._layoutQueue},set layoutQueue(t){const e=this._layoutQueue._views.has(this);this._layoutQueue._removeView(this),this._layoutQueue=t||_BMViewLayoutQueue,e&&this._layoutQueue._enqueueView(this)},_layoutAnimator:void 0,_frame:void 0,get frame(){return this._frame||BMRectMakeWithNodeFrame(this._node)},set frame(t){this._frame||(this._node.style.position="absolute",this._node.style.contain="layout",this._node.style.right="auto",this._node.style.bottom="auto",this._node.style.left="0px",this._node.style.top="0px");let e,i=NO;if(this._frame&&this._frame.size.isEqualToSize(t.size)||(e=t.copy(),e.origin=BMPointMake(),this.boundsWillChangeToBounds(e),i=YES),this.isRootView)this._frame?(this._node.style.width="100%",this._node.style.height="100%"):(BM_VIEW_USE_TRANSFORM?BMHook(this._node,{translateX:"0px",translateY:"0px"}):(this._node.style.top="0px",this._node.style.left="0px"),this._node.style.width="100%",this._node.style.height="100%"),this._frame=t.copy(),this._layoutEditor&&this._layoutEditor.viewDidLayoutSubviews(this);else if(BMAnimationContextGetCurrent()){this._frame||(this._frame=BMRectMakeWithNodeFrame(this.node)),BMHook(this._node,BM_VIEW_USE_TRANSFORM?{translateX:this._frame.origin.x+"px",translateY:this._frame.origin.y+"px"}:{left:this._frame.origin.x+"px",top:this._frame.origin.y+"px"}),this._node.style.width=this._frame.size.width+"px",this._node.style.height=this._frame.size.height+"px";let o=BMAnimationContextGetCurrent().controllerForObject(this,{node:this._node});BM_VIEW_USE_TRANSFORM?(o.registerBuiltInProperty("translateX",{withValue:t.origin.x+"px"}),o.registerBuiltInProperty("translateY",{withValue:t.origin.y+"px"})):(o.registerBuiltInProperty("left",{withValue:t.origin.x+"px"}),o.registerBuiltInProperty("top",{withValue:t.origin.y+"px"})),o.registerBuiltInProperty("width",{withValue:t.size.width+"px"}),o.registerBuiltInProperty("height",{withValue:t.size.height+"px"}),this._layoutAnimator=o.promise,o.promise.then((o=>{this._layoutAnimator=void 0,this.didSetFrame(t),i&&this.boundsDidChangeToBounds(e)})),this._frame=t.copy()}else this._frame=t.copy(),BMHook(this._node,BM_VIEW_USE_TRANSFORM?{translateX:t.origin.x+"px",translateY:t.origin.y+"px"}:{left:t.origin.x+"px",top:t.origin.y+"px"}),this._node.style.width=t.size.width+"px",this._node.style.height=t.size.height+"px",i&&this.boundsDidChangeToBounds(e);this.didSetFrame(t)},get frameRelativeToRootView(){let t=BMPointMake(),e=this.superview;for(;e&&e.superview;)t.x+=e.frame.origin.x,t.y+=e.frame.origin.y,e=e.superview;let i=this.frame.copy();return i.origin.x+=t.x,i.origin.y+=t.y,i},set frameRelativeToRootView(t){let e=BMPointMake(),i=this.superview;for(;i&&i.superview;)e.x+=i.frame.origin.x,e.y+=i.frame.origin.y,i=i.superview;let o=t.copy();o.origin.x-=e.x,o.origin.y-=e.y,this.frame=o},didSetFrame(t){},get bounds(){let t=this._frame.copy();return t.origin=BMPointMake(),t},set bounds(t){let e=this.bounds;if(e.size.width!=t.size.width||e.size.height!=t.size.height){let e=this.frame.copy();e.size=t.size.copy(),this.frame=e}},boundsWillChangeToBounds(t){},boundsDidChangeToBounds(t){},LTRLayout:YES,get _serializedVariations(){let t={};return this._variations&&Object.keys(this._variations).forEach((e=>{t[e]={},Object.keys(this._variations[e]).forEach((i=>{"sizeClass"!=i&&(t[e][i]=this._variations[e][i])}))})),t},set _serializedVariations(t){if(t){this._variations=t;for(let t in this._variations)this._variations[t].sizeClass=BMLayoutSizeClass._layoutSizeClassForHashString(t)}},_variableProperties:void 0,_configuration:void 0,registerVariablePropertyNamed(t,e){if(this[t])throw new Error("Unable to register the property "+t+" as a variable property. This property duplicates an existing property of this view.");let i=t[0].toUpperCase()+t.substring(1),o=e.forTarget;this._variableProperties[t]=o,this[t]=o[t],this[`set${i}`]=(e,i)=>this._setVariation(e,{forProperty:t,inSizeClass:i.forSizeClass}),this[`remove${i}VariationForSizeClass`]=e=>this._removeVariationForProperty(t,{inSizeClass:e}),this[`has${i}VariationForSizeClass`]=e=>this._hasVariationForProperty(t,{inSizeClass:e})},unregisterVariablePropertyNamed(t){this._variableProperties[t]&&delete this._variableProperties[t]},activeSizeClassesDidChange(t){this._updateConfiguration()},_updateConfiguration(){let t={opacity:this._opacity,isVisible:this._isVisible,contentInsets:this._contentInsets,CSSClass:this._CSSClass},e=this.viewport;for(let t in this._variations)this._variations[t]._matchPriority=e.matchPriorityForSizeClass(this._variations[t].sizeClass);Object.keys(this._variations).map((t=>this._variations[t])).sort(((t,e)=>e._matchPriority-t._matchPriority)).forEach((e=>{if(e._matchPriority){"opacity"in e&&(t.opacity=e.opacity),"isVisible"in e&&(t.isVisible=e.isVisible),"contentInsets"in e&&(t.contentInsets=e.contentInsets),"CSSClass"in e&&(t.CSSClass=e.CSSClass);for(let i in this._variableProperties)i in e&&(t[i]=e[i])}}));let i=this._configuration||t;this._configuration=t,i.opacity!=t.opacity&&(this._activeOpacity=t.opacity),i.isVisible!=t.isVisible&&(this._activeVisibility=t.isVisible),i.CSSClass!=t.CSSClass&&(this._activeCSSClass=t.CSSClass),i.contentInsets.isEqualToInset(t.contentInsets)||(this._activeInsets=t.contentInsets)},_setVariation(t,e){this._variations[e.inSizeClass._hashString]||(this._variations[e.inSizeClass._hashString]={sizeClass:e.inSizeClass},this.rootView._invalidatedSizeClasses=YES),this._variations[e.inSizeClass._hashString][e.forProperty]=t,this.viewport.matchesSizeClass(e.inSizeClass)&&this._updateConfiguration()},_removeVariationForProperty(t,e){this._variations[e.inSizeClass._hashString]&&(delete this._variations[e.inSizeClass._hashString][t],1==Object.keys(this._variations[e.inSizeClass._hashString]).length&&(delete this._variations[e.inSizeClass._hashString],this.rootView._invalidatedSizeClasses=YES),this.viewport.matchesSizeClass(e.inSizeClass)&&this._updateConfiguration())},_hasVariationForProperty(t,e){return this._variations[e.inSizeClass._hashString]?t in this._variations[e.inSizeClass._hashString]:NO},__activeInsets:BMInsetMake(),set _activeInsets(t){this.__activeInsets=t?t.copy():BMInsetMake(),t=this.__activeInsets;const e=this.contentNode;e.style.paddingLeft=t.left+"px",e.style.paddingTop=t.top+"px",e.style.paddingRight=t.right+"px",e.style.paddingBottom=t.bottom+"px",this.supportsIntrinsicSize&&this.invalidateIntrinsicSize()},_contentInsets:BMInsetMake(),get contentInsets(){return this._contentInsets.copy()},set contentInsets(t){this._contentInsets=t?t.copy():BMInsetMake(),this._updateConfiguration()},setContentInsets(t,e){return this._setVariation(t||BMInsetMake(),{forProperty:"contentInsets",inSizeClass:e.forSizeClass})},removeContentInsetsVariationForSizeClass(t){return this._removeVariationForProperty("contentInsets",{inSizeClass:t})},hasContentInsetsVariationForSizeClass(t){return this._hasVariationForProperty("contentInsets",{inSizeClass:t})},__activeCSSClass:"",set _activeCSSClass(t){t=t||"";const e=this.__activeCSSClass.split(" "),i=t.split(" ");for(const t of e)t&&(i.includes(t)||this.node.classList.remove(t));for(const t of i)t&&(e.includes(t)||this.node.classList.add(t));this.__activeCSSClass=t,this.supportsIntrinsicSize&&this.invalidateIntrinsicSize()},_CSSClass:"",get CSSClass(){return this._CSSClass},set CSSClass(t){this._CSSClass=t,this._updateConfiguration()},setCSSClass(t,e){return this._setVariation(t,{forProperty:"CSSClass",inSizeClass:e.forSizeClass})},removeCSSClassVariationForSizeClass(t){return this._removeVariationForProperty("CSSClass",{inSizeClass:t})},hasCSSClassVariationForSizeClass(t){return this._hasVariationForProperty("CSSClass",{inSizeClass:t})},__activeOpacity:1,set _activeOpacity(t){if(BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this,{node:this._node}).registerBuiltInProperty("opacity",{withValue:this._opacity})}else this.__activeOpacity=t,this.node.style.opacity=t},get currentOpacity(){return this.__activeOpacity},_opacity:1,get opacity(){return this._opacity},set opacity(t){this._opacity=t,this._updateConfiguration()},setOpacity(t,e){return this._setVariation(t,{forProperty:"opacity",inSizeClass:e.forSizeClass})},removeOpacityVariationForSizeClass(t){return this._removeVariationForProperty("opacity",{inSizeClass:t})},hasOpacityVariationForSizeClass(t){return this._hasVariationForProperty("opacity",{inSizeClass:t})},__activeVisibility:YES,set _activeVisibility(t){if(t!=this.__activeVisibility){const e=this.isCurrentlyVisible;this.__activeVisibility=t,t?(this.rootView._layoutEditor?this.node.classList.remove("BMLayoutEditorInvisibleView"):this.node.style.display="block",e||this.viewDidBecomeVisible()):(this.rootView._layoutEditor?this.node.classList.add("BMLayoutEditorInvisibleView"):this.node.style.display="none",e||this.viewDidBecomeInvisible());for(const e of this._subviews)e._parentVisible=t;this.invalidateIntrinsicSize()}},get _activeVisibility(){return this.__activeVisibility},__parentVisible:YES,get _parentVisible(){return this.__parentVisible},set _parentVisible(t){const e=t&&this.__activeVisibility,i=this.isCurrentlyVisible;if(e!=this.__parentVisible)for(const e of this._subviews)e._parentVisible=t;this.__parentVisible=e,this.isCurrentlyVisible!=i&&(this.isCurrentlyVisible?this.viewDidBecomeVisible():this.viewDidBecomeInvisible())},get isCurrentlyVisible(){return this.__activeVisibility&&this.__parentVisible},viewDidBecomeVisible(){this.supportsIntrinsicSize&&this.invalidateIntrinsicSize()},viewDidBecomeInvisible(){},_isVisible:YES,get isVisible(){return this._isVisible},set isVisible(t){this._isVisible=t,this._updateConfiguration()},setIsVisible(t,e){return this._setVariation(t,{forProperty:"isVisible",inSizeClass:e.forSizeClass})},removeIsVisibleVariationForSizeClass(t){return this._removeVariationForProperty("isVisible",{inSizeClass:t})},hasIsVisibleVariationForSizeClass(t){return this._hasVariationForProperty("isVisible",{inSizeClass:t})},_colorScheme:BMViewColorScheme.Auto,get colorScheme(){return this._colorScheme},set colorScheme(t){const e=this._colorScheme;this._colorScheme=t,this.colorSchemeDidChange(e)},colorSchemeDidChange(t){},_supportsAutomaticIntrinsicSize:NO,get supportsAutomaticIntrinsicSize(){return this._supportsAutomaticIntrinsicSize},set supportsAutomaticIntrinsicSize(t){this._supportsAutomaticIntrinsicSize=t},get supportsIntrinsicSize(){return this.supportsAutomaticIntrinsicSize},_requiredWidth:void 0,get requiredWidth(){return this._requiredWidth},_needsIntrinsicSizeMeasurement:YES,get needsIntrinsicSizeMeasurement(){if(this._needsIntrinsicSizeMeasurement&&this.supportsAutomaticIntrinsicSize)return YES;if(!this._hasDeterministicSize&&this._preferredIntrinsicSize&&this._intrinsicSize&&!this._preferredIntrinsicSize.isEqualToSize(this._instrinsicSize))return YES;let t=this._subviews.length;for(let e=0;e<t;e++)if(this._subviews[e].needsIntrinsicSizeMeasurement)return YES;return NO},invalidateIntrinsicSize(){this._preferredIntrinsicSize=void 0,this._needsIntrinsicSizeMeasurement=YES;const t=this.rootView;t._needsLayout=YES,t._scheduleImmediateLayout()},_intrinsicSize:void 0,_preferredIntrinsicSize:void 0,_getIntrinsicSize(){let t;return this._needsIntrinsicSizeMeasurement?t=this.requiredWidth?this._instrinsicSize=this.intrinsicSize:this._instrinsicSize=this._preferredIntrinsicSize=this.intrinsicSize:this.requiredWidth&&this._intrinsicSize&&!this._intrinsicSize.isEqualToSize(this._preferredIntrinsicSize)&&(t=this._instrinsicSize=this.intrinsicSize),t||(t=this._instrinsicSize),t},get intrinsicSize(){if(this.supportsAutomaticIntrinsicSize){if(this._needsIntrinsicSizeMeasurement){let t=this._node;if(this._intrinsicSize=BMSizeMake(t.offsetWidth-t.clientWidth+t.scrollWidth+1,t.offsetHeight-t.clientHeight+t.offsetHeight),BM_VIEW_DEBUG_AUTOMATIC_INTRINSIC_SIZE){let e=document.createElement("div");e.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",t.appendChild(e),requestAnimationFrame((()=>e.remove()))}}return this._intrinsicSize}},_compressionResistance:750,get compressionResistance(){return this._compressionResistance},set compressionResistance(t){this._compressionResistance=t,this._widthCompressionConstraint=void 0,this._heightCompressionConstraint=void 0,this.needsLayout=YES,this.rootView._invalidatedConstraints=YES},_expansionResistance:250,get expansionResistance(){return this._expansionResistance},set expansionResistance(t){this._expansionResistance=t,this._widthExpansionConstraint=void 0,this._heightExpansionConstraint=void 0,this.needsLayout=YES,this.rootView._invalidatedConstraints=YES},_invalidatedSizeClasses:NO,_sizeClasses:void 0,_matchingSizeClasses:void 0,_updateSizeClasses(){this._sizeClasses=new Set,this.allSubviews.forEach((t=>{for(let e in t._variations){let i=t._variations[e].sizeClass;this._sizeClasses.has(i)||this._sizeClasses.add(i)}})),this.allConstraints.forEach((t=>{for(let e in t._variations){let i=t._variations[e].sizeClass;this._sizeClasses.has(i)||this._sizeClasses.add(i)}}))},_viewport:void 0,get viewport(){return this.isRootView?(!this._viewport&&this._updateViewport(),this._requiredViewport||this._viewport):this.rootView.viewport},_requiredViewport:void 0,get _currentViewport(){if(this._requiredViewport)return this._requiredViewport;let t=new BMViewport;return t.init(),t._width=window.innerWidth,t._height=window.innerHeight,t._diagonal=Math.sqrt(Math.pow(window.innerWidth,2)+Math.pow(window.innerHeight,2)),t._orientation=t._width>=t._height?BMLayoutOrientation.Landscape:BMLayoutOrientation.Portrait,t._surfaceArea=t._width*t._height,t},_layoutVariablesDidUpdate(){if(!this._viewport)return;const t=this._layoutVariables||{};this._layoutVariableValuesForViewport(this._viewport);let e=NO;for(let i in this._layoutVariables)if(t[i]!=this._layoutVariables[i]){e=YES;break}e&&this.allConstraints.forEach((t=>t.layoutVariablesDidChange()))},_updateViewport(){let t=this._currentViewport;this._viewport=t;let e=this._layoutVariables||{};this._layoutVariableValuesForViewport(t);let i=NO;for(let t in this._layoutVariables)if(e[t]!=this._layoutVariables[t]){i=YES;break}let o=new Set;for(let e of this._sizeClasses.keys())t.matchesSizeClass(e)&&o.add(e);if(this._matchingSizeClasses){let t=NO;if(this._matchingSizeClasses.size!=o.size)t=YES;else for(let e of this._matchingSizeClasses)o.has(e)||(t=YES);if(t){this._matchingSizeClasses=o;let t=Array.from(o);this.allConstraints.forEach((e=>e.activeSizeClassesDidChange(t))),this.allSubviews.forEach((e=>e.activeSizeClassesDidChange(t)))}else i&&this.allConstraints.forEach((t=>t.layoutVariablesDidChange()))}else{this._matchingSizeClasses=o;let t=Array.from(o);this.allConstraints.forEach((e=>e.activeSizeClassesDidChange(t))),this.allSubviews.forEach((e=>e.activeSizeClassesDidChange(t)))}},valueForLayoutVariable(t){const e=this.rootView;return e!=this?e.valueForLayoutVariable(t):"-"==t.charAt(0)?-(this._layoutVariables[t.substring(1)]||0):this._layoutVariables[t]||0},_keyboardShortcuts:void 0,registerKeyboardShortcut(t){Object.keys(this._keyboardShortcuts).length||this._enableKeyboardShortcuts(),this._keyboardShortcuts[t.keyCode]||(this._keyboardShortcuts[t.keyCode]=[]),this._keyboardShortcuts[t.keyCode].push(t)},unregisterKeyboardShortcut(t){const e=this._keyboardShortcuts[t.keyCode];if(e){for(let i=0;i<e.length;i++)if(e[i]==t){e.splice(i,1);break}e.length||delete this._keyboardShortcuts[t.keyCode]}Object.keys(this._keyboardShortcuts).length||this._disableKeyboardShortcuts()},keyPressedWithEvent(t){if(this._keyboardShortcuts[t.code])for(const e of this._keyboardShortcuts[t.code]){let i=0;for(const e in BMKeyboardShortcutModifier)t[BMKeyboardShortcutModifier[e].key]&&(i|=BMKeyboardShortcutModifier[e].value);i==e._modifierBitmap&&(e.preventsDefault&&t.preventDefault(),e.target[e.action](t,{forKeyboardShortcut:e}))}},_keyboardShortcutsEnabled:NO,_enableKeyboardShortcuts(){this.node.hasAttribute("tabIndex")||(this.node.tabIndex=-1),this._keypressHandler=t=>{this.keyPressedWithEvent(t)},this.node.addEventListener("keydown",this._keypressHandler),this._keyboardShortcutsEnabled=YES},_disableKeyboardShortcuts(){this.node.removeEventListener("keydown",this._keypressHandler),this._keyboardShortcutsEnabled=NO},_constraints:void 0,_variables:void 0,constraintWithIdentifier(t){for(let e of this._constraints)if(e.identifier==t)return e;for(let e of this._subviews){let i=e.constraintWithIdentifier(t);if(i)return i}},get allConstraints(){let t=this._constraints.slice();return this._subviews.forEach((e=>{t=t.concat(e.allConstraints)})),t},get activeConstraints(){let t=[];return this._hasDeterministicConstraints&&(t=this._constraints.filter((t=>t.affectsLayout))),this._subviews.forEach((e=>{t=t.concat(e.activeConstraints)})),t},get localConstraints(){return this._constraints.slice()},_invalidatedConstraints:NO,_addConstraint(t){this._constraints.push(t),this.rootView._invalidatedConstraints=YES,this._checkConstraints()},_removeConstraint(t){var e=this._constraints.indexOf(t);this.rootView._invalidatedConstraints=YES,-1!=e&&this._constraints.splice(e,1),this._checkConstraints()},_hasDeterministicConstraints:NO,_checkConstraints(){let t=NO,e=NO,i=new Set,o=new Set,n=NO,s=NO,a=NO;this.supportsIntrinsicSize&&(i.add(BMLayoutAttribute.Width),o.add(BMLayoutAttribute.Height));let r=this._constraints;for(var l=0;l<r.length;l++){let h=r[l];if(h.affectsLayout){switch(h._kind){case BMLayoutConstraintKind.Horizontal:h.affectedAttributesForView(this).forEach((t=>i.add(t))),i.size>1&&(t=YES),h._sourceViewAttribute==BMLayoutAttribute.Width&&!h._targetView&&!h.isConstraintCollection&&h._relation==BMLayoutConstraintRelation.Equals&&h.activePriority>this._compressionResistance&&h.activePriority>this._expansionResistance&&(s=YES);break;case BMLayoutConstraintKind.Vertical:h.affectedAttributesForView(this).forEach((t=>o.add(t))),o.size>1&&(e=YES),h._sourceViewAttribute==BMLayoutAttribute.Height&&!h._targetView&&!h.isConstraintCollection&&h._relation==BMLayoutConstraintRelation.Equals&&h.activePriority>this._compressionResistance&&h.activePriority>this._expansionResistance&&(a=YES)}if(a&&s&&(n=YES),t&&e&&n)break}}if(n&&(this._hasDeterministicSize=YES),t&&e)return this._hasDeterministicConstraints=YES;r=this.internalConstraints();for(l=0;l<r.length;l++){let n=r[l];switch(n._kind){case BMLayoutConstraintKind.Horizontal:n.affectedAttributesForView(this).forEach((t=>i.add(t))),i.size>1&&(t=YES);break;case BMLayoutConstraintKind.Vertical:n.affectedAttributesForView(this).forEach((t=>o.add(t))),o.size>1&&(e=YES)}if(t&&e)break}this._hasDeterministicConstraints=t&&e},_clearConstraints(){this.localConstraints.forEach((t=>t.remove())),this._subviews.forEach((t=>t._clearConstraints()))},_leftExpressionWithMultiplier(t){return t=t||1,this.isRootView?new kiwi.Expression([t,this._variables[BMLayoutAttribute.Left]]):new kiwi.Expression(this.superview._leftExpressionWithMultiplier(),[t,this._variables[BMLayoutAttribute.Left]])},_topExpressionWithMultiplier(t){return t=t||1,this.isRootView?new kiwi.Expression([t,this._variables[BMLayoutAttribute.Top]]):new kiwi.Expression(this.superview._topExpressionWithMultiplier(),[t,this._variables[BMLayoutAttribute.Top]])},_cassowaryExpressionForLayoutAttribute(t,e){var i=e&&e.withMultiplier||1;if(t in this._variables)return t==BMLayoutAttribute.Left?this._leftExpressionWithMultiplier(i):t==BMLayoutAttribute.Top?this._topExpressionWithMultiplier(i):new kiwi.Expression(1!=i?[i,this._variables[t]]:this._variables[t]);switch(t){case BMLayoutAttribute.Leading:return this.LTRLayout?this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Left,e):this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Right,e);case BMLayoutAttribute.Trailing:return this.LTRLayout?this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Right,e):this._cassowaryExpressionForLayoutAttribute(BMLayoutAttribute.Left,e);case BMLayoutAttribute.Right:return 1!=i?new kiwi.Expression([i,this._variables[BMLayoutAttribute.Width]],this._leftExpressionWithMultiplier(i)):new kiwi.Expression(this._variables[BMLayoutAttribute.Width],this._leftExpressionWithMultiplier(i));case BMLayoutAttribute.CenterX:return 1!=i?new kiwi.Expression([i/2,this._variables[BMLayoutAttribute.Width]],this._leftExpressionWithMultiplier(i)):new kiwi.Expression([.5,this._variables[BMLayoutAttribute.Width]],this._leftExpressionWithMultiplier(i));case BMLayoutAttribute.Bottom:return 1!=i?new kiwi.Expression([i,this._variables[BMLayoutAttribute.Height]],this._topExpressionWithMultiplier(i)):new kiwi.Expression(this._variables[BMLayoutAttribute.Height],this._topExpressionWithMultiplier(i));case BMLayoutAttribute.CenterY:return 1!=i?new kiwi.Expression([i/2,this._variables[BMLayoutAttribute.Height]],this._topExpressionWithMultiplier(i)):new kiwi.Expression([.5,this._variables[BMLayoutAttribute.Height]],this._topExpressionWithMultiplier(i));case BMLayoutAttribute.AspectRatio:throw new Error("Aspect ratio constraints are currently unsupported!")}},get builtInConstraints(){var t=this._getIntrinsicSize(),e=[];return(t||this.supportsAutomaticIntrinsicSize)&&(this._widthCompressionConstraint?(this._widthCompressionConstraint.constant=t.width,this._heightCompressionConstraint.constant=t.height,e.push(this._widthCompressionConstraint,this._heightCompressionConstraint)):e.push(this._widthCompressionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,constant:t.width,priority:this.compressionResistance}),this._heightCompressionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,constant:t.height,priority:this.compressionResistance})),this._widthExpansionConstraint?(this._widthExpansionConstraint.constant=t.width,this._heightExpansionConstraint.constant=t.height,e.push(this._widthExpansionConstraint,this._heightExpansionConstraint)):e.push(this._widthExpansionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:t.width,priority:this.expansionResistance}),this._heightExpansionConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:t.height,priority:this.expansionResistance}))),e=e.concat(this.internalConstraints()),this._internalConstraints=e,this._subviews.forEach((t=>{e=e.concat(t.builtInConstraints)})),e},internalConstraints(){var t=[];if(this.isRootView){if(!this.node.parentNode)return t;this._rootViewLeftConstraint?(this._layoutEditor?(this._rootViewHeightConstraint.constant=this._layoutEditor._staticWorkspaceHeight,this._rootViewWidthConstraint.constant=this._layoutEditor._staticWorkspaceWidth):(this._rootViewHeightConstraint.constant=this._node.parentNode.offsetHeight,this._rootViewWidthConstraint.constant=this._node.parentNode.offsetWidth),t.push(this._rootViewLeftConstraint,this._rootViewTopConstraint,this._rootViewWidthConstraint,this._rootViewHeightConstraint)):t.push(this._rootViewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Left,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Top,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewWidthConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.Equals,constant:this._node.parentNode.offsetWidth}),this._rootViewHeightConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.Equals,constant:this._node.parentNode.offsetHeight}))}return t},_assignWidth(){this._requiredWidth=this._variables[BMLayoutAttribute.Width].value(),!this._hasDeterministicSize&&this._intrinsicSize&&this._preferredIntrinsicSize&&!this._instrinsicSize.isEqualToSize(this._preferredIntrinsicSize)&&this._intrinsicSize.width!=this._requiredWidth&&(this._needsIntrinsicSizeMeasurement=YES),this._subviews.forEach((t=>t._assignWidth()))},_acquireReferenceFrames(){if(this._frame)this._referenceFrame=this._frame.copy();else{let t=BMRectMake(this.node.offsetLeft,this.node.offsetTop,this.node.offsetWidth,this.node.offsetHeight);(t.width&&t.height||!this._referenceFrame)&&(this._referenceFrame=t)}!this._hasDeterministicSize&&this._intrinsicSize&&this._preferredIntrinsicSize&&!this._instrinsicSize.isGreaterThanSize(this._preferredIntrinsicSize)&&(this._needsIntrinsicSizeMeasurement=YES),this._subviews.forEach((t=>t._acquireReferenceFrames()))},_resizeForAutomaticInstricSize(){this.supportsAutomaticIntrinsicSize&&this.needsIntrinsicSizeMeasurement?this._requiredWidth?this._node.style.width=this._requiredWidth+"px":BMCopyProperties(this._node.style,{width:"auto",height:"auto",left:"0px",top:"0px",position:"absolute"}):this.needsIntrinsicSizeMeasurement&&BMCopyProperties(this._node.style,{width:"100%",height:"100%"}),this._subviews.forEach((t=>t._resizeForAutomaticInstricSize()))},_prepareForAutomaticIntrinsicSize(){void 0===this._requiredWidth&&this._acquireReferenceFrames(),this._resizeForAutomaticInstricSize()},_updateInternalHeightConstraints(){var t=this._getIntrinsicSize();t&&this._heightCompressionConstraint&&(this._heightCompressionConstraint.constant=t.height,this._heightExpansionConstraint.constant=t.height),this._subviews.forEach((t=>t._updateInternalHeightConstraints()))},get _horizontalLayoutVariables(){var t=[this._variables[BMLayoutAttribute.Left],this._variables[BMLayoutAttribute.Width]];return this._subviews.forEach((e=>t=t.concat(e._horizontalLayoutVariables))),t},get _verticalLayoutVariables(){var t=[this._variables[BMLayoutAttribute.Top],this._variables[BMLayoutAttribute.Height]];return this._subviews.forEach((e=>t=t.concat(e._verticalLayoutVariables))),t},_isPerformingLayoutPass:NO,_layoutAnimationFrameIdentifier:void 0,_cancelLayout(){this._layoutQueue._removeView(this),this._layoutAnimationFrameIdentifier&&window.cancelAnimationFrame(this._layoutAnimationFrameIdentifier),this._layoutAnimationFrameIdentifier=void 0,this._layoutIntrisicSizeInvalidationIdentifier=void 0},_registerLayout(){this._layoutQueue._enqueueView(this)},async _scheduleLayout(){if(this!=this.rootView)return this.rootView._scheduleLayout();this._layoutAnimator&&await this._layoutAnimator,this._layoutAnimationFrameIdentifier||this._layoutIntrisicSizeInvalidationIdentifier||(this._registerLayout(),this._layoutAnimationFrameIdentifier=window.requestAnimationFrame((t=>{this._layoutAnimationFrameIdentifier=void 0,this._layoutQueue.dequeue()})))},_layoutIntrisicSizeInvalidationIdentifier:void 0,async _scheduleImmediateLayout(){if(this!=this.rootView)return this.rootView._scheduleImmediateLayout();if(this._layoutAnimator&&await this._layoutAnimator,this._layoutAnimationFrameIdentifier&&(window.cancelAnimationFrame(this._layoutAnimationFrameIdentifier),this._layoutAnimationFrameIdentifier=void 0),!this._layoutIntrisicSizeInvalidationIdentifier){this._layoutIntrisicSizeInvalidationIdentifier=BMUUIDMake();var t=this._layoutIntrisicSizeInvalidationIdentifier;this._registerLayout(),await 0,this._layoutIntrisicSizeInvalidationIdentifier&&t==this._layoutIntrisicSizeInvalidationIdentifier&&(this._layoutIntrisicSizeInvalidationIdentifier=void 0,this._layoutQueue.dequeue())}},layout:function(){return this.layoutIfNeeded()},layoutIfNeeded:async function(){if(this!=this.rootView)return this.rootView.layout();this._needsLayout&&(this._layoutAnimator&&await this._layoutAnimator,this._registerLayout(),this._layoutQueue.dequeue())},layoutSubviews(){let t=this._layoutSubviewsGenerator(),e=NO;for(;!e;)e=t.next().done},*_layoutSubviewsGenerator(){if(this._layoutAnimationFrameIdentifier&&(window.cancelAnimationFrame(this._layoutAnimationFrameIdentifier),this._layoutAnimationFrameIdentifier=void 0),this._layoutIntrisicSizeInvalidationIdentifier&&(window.removeEventListener("message",this._layoutIntrisicSizeInvalidationHandler),this._layoutIntrisicSizeInvalidationHandler=void 0,this._layoutIntrisicSizeInvalidationIdentifier=void 0),!this._node||!this._node.parentNode)return;if(this.superview)return;BMViewDebug&&console.log("\n ***********************************************************************************************************\n [BMCoreUI] Layout pass began\n ***********************************************************************************************************\n ");var t,e=new Set;this._invalidatedSizeClasses&&this._updateSizeClasses(),this._updateViewport();let i=NO;if(!this._solver||this._layoutEditor||this._invalidatedConstraints?(t=new kiwi.Solver,this._solver=t,i=YES,this._layoutEditor&&this.allSubviews.forEach((t=>t._needsIntrinsicSizeMeasurement=YES)),this._invalidatedConstraints=NO):(t=this._solver,i=NO),this._prepareForAutomaticIntrinsicSize(),yield,i){let i;for(this.activeConstraints.forEach((t=>{e.add(t)})),this.builtInConstraints.forEach((t=>{e.add(t)})),this._horizontalLayoutVariables.forEach((e=>t.addEditVariable(e,kiwi.Strength.strong)));YES;){let o,n=[],s=[];try{e.forEach((e=>{i&&i.includes(e)||e._kind===BMLayoutConstraintKind.Horizontal&&(o=e,n.push(e),BMViewDebug&&console.log(`[BMCoreUI] Horizontal constraint: ${e}`),e.constituentConstraints.forEach((e=>{e._constraint=void 0;let i=e._cassowaryConstraint;s.push(i),t.addConstraint(i),e._solver=t})))}));break}catch(e){if(console.error(`[BMCoreUI] Unsatisfiable constraints. The following constraints are not satisfiable and the\n layout operation cannot be completed. Will attempt to solve the layout by breaking constraint \n ${o}. Please check the following constraints at design-time to resolve the problem:\n`),n.forEach((t=>{console.error(`${t}`)})),this._layoutEditor)return;i=i||[],i.push(o),s.forEach((e=>{t.hasConstraint(e)&&t.removeConstraint(e)}))}}}else this.builtInConstraints||console.log();try{t.suggestValue(this._variables[BMLayoutAttribute.Left],0)}catch(t){console.log(t)}let o=this.allSubviews;if(o.forEach((e=>{if(e._widthCompressionConstraint)try{t.suggestValue(e._variables[BMLayoutAttribute.Width],e._widthCompressionConstraint._constant)}catch(t){console.log(t)}})),t.updateVariables(),yield,this.supportsAutomaticIntrinsicSize&&!this._subviews.length?(this._assignWidth(),this._prepareForAutomaticIntrinsicSize(),this._updateInternalHeightConstraints()):this._subviews.forEach((t=>{t._assignWidth(),t._prepareForAutomaticIntrinsicSize(),t._updateInternalHeightConstraints()})),yield,i){let i;for(this._verticalLayoutVariables.forEach((e=>t.addEditVariable(e,kiwi.Strength.strong)));YES;){let o,n=[],s=[];try{e.forEach((e=>{i&&i.includes(e)||(o=e,s.push(e),e._kind===BMLayoutConstraintKind.Vertical&&e.constituentConstraints.forEach((e=>{e._constraint=void 0;let i=e._cassowaryConstraint;n.push(i),t.addConstraint(i),e._solver=t})))}));break}catch(e){if(console.error(`[BMCoreUI] Unsatisfiable constraints. The following constraints are not satisfiable and the\n layout operation cannot be completed. Will attempt to solve the layout by breaking constraint \n ${o}. Please check the following constraints at design-time to resolve the problem:\n`),s.forEach((t=>{console.error(`${t}`)})),this._layoutEditor)return;i=i||[],i.push(o),n.forEach((e=>{t.hasConstraint(e)&&t.removeConstraint(e)}))}}}try{t.suggestValue(this._variables[BMLayoutAttribute.Top],0)}catch(t){console.log(t)}o.forEach((e=>{if(e._heightCompressionConstraint)try{t.suggestValue(e._variables[BMLayoutAttribute.Height],e._heightCompressionConstraint._constant)}catch(t){console.log(t)}})),t.updateVariables(),this.frame=BMRectMake(0,0,0|this._variables[BMLayoutAttribute.Width].value(),0|this._variables[BMLayoutAttribute.Height].value()),this._needsIntrinsicSizeMeasurement=NO,this.supportsAutomaticIntrinsicSize&&!this._subviews.length?(this._requiredWidth=void 0,this._needsLayout=NO,this._needsIntrinsicSizeMeasurement=NO):this._subviews.forEach((t=>t._updateFrames())),BMViewDebug&&console.log("\n ***********************************************************************************************************\n [BMCoreUI] Layout pass finished\n ***********************************************************************************************************\n ")},frameForDescendant:t=>(t._constraints.length||t._internalConstraints.length)&&t._hasDeterministicConstraints?BMRectMake(0|t._variables[BMLayoutAttribute.Left].value(),0|t._variables[BMLayoutAttribute.Top].value(),0|t._variables[BMLayoutAttribute.Width].value(),0|t._variables[BMLayoutAttribute.Height].value()):t._referenceFrame,_updateFrames(){this._requiredWidth=void 0,this._needsLayout=NO,this._needsIntrinsicSizeMeasurement=NO,this.frame=this.rootView.frameForDescendant(this),this._subviews.forEach((t=>t._updateFrames()))},_needsLayout:NO,get needsLayout(){return this._needsLayout},set needsLayout(t){this._needsLayout=t,t&&(this.rootView._needsLayout=YES,this.rootView._scheduleLayout())},_rootView:void 0,get rootView(){for(var t=this;t;){if(!t.superview)return t;t=t.superview}},get isRootView(){return void 0===this.superview},_superview:void 0,get superview(){return this._superview},_subviews:void 0,get subviews(){return this._subviews.slice()},addToSuperview(t,e){return t.addSubview(this,e)},addSubview(t,e){if(t.superview==this)return;this.superview||BMView._markAsRootView(this),BMView._markAsNonRootView(t);var i=e&&e.toPosition;void 0===i&&(i=this._subviews.length);var o=this._subviews[i];if(this._subviews.splice(i,0,t),t.superview&&t.superview._detachSubview(t),t._superview=this,o)if(o.node.parentNode!=this.contentNode){let e=this.contentNode.children[i];e?this.contentNode.insertBefore(t.node,e):this.contentNode.appendChild(t.node)}else this.contentNode.insertBefore(t.node,o.node);else t.node.parentNode!=this.contentNode&&this.contentNode.appendChild(t.node);const n=this.rootView;n._invalidatedConstraints=YES,n._invalidatedSizeClasses=YES,n.needsLayout=YES},removeSubview(t){var e=this._subviews.indexOf(t);if(-1!=e){this._subviews.splice(e,1),t._node.parentNode==this.contentNode&&t._node.remove(),t._superview=void 0,this._removeInvalidConstraints(),this._subviews.length||BMView._markAsNonRootView(this),t._subviews.length&&BMView._markAsRootView(t);const i=this.rootView;i._invalidatedConstraints=YES,i._invalidatedSizeClasses=YES,i.needsLayout=YES}},removeFromSuperview(){this._superview&&this._superview.removeSubview(this)},isDescendantOfView(t){let e=this.superview;for(;e;){if(e==t)return YES;e=e.superview}return NO},_removeInvalidConstraints(){let t=new Set;this.activeConstraints.forEach((e=>{t.add(e)})),t.forEach((t=>{if(t.isConstraintCollection){for(let e of t.constituentConstraints)if(e._targetView&&e._sourceView.rootView!=e._targetView.rootView){t.remove();break}}else t._targetView&&t._sourceView.rootView!=t._targetView.rootView&&t.remove()}))},_detachSubview(t){var e=this._subviews.indexOf(t);-1!=e&&this._subviews.splice(e,1)},get allSubviews(){let t=[this];return this._subviews.forEach((e=>t=t.concat(e.allSubviews))),t},_prepareForCloning(){this._BMTempID=BMUUIDMake(),this._BMOriginalID=this.node.id,this.node.id=this._BMTempID,this._subviews.each((t=>t._prepareForCloning()))},_clone(){this._prepareForCloning();let t=this.node.cloneNode(YES);this._cloneForNode(t)},_cloneForNode(t,e){BMView.viewForNode.call(this.constructor,t)._BMOriginalView=this,this.node.id=this._BMOriginalID},additionalSettingTabsForLayoutEditor:t=>[],additionalSettingSectionsForTab:(t,{layoutEditor:e})=>[]}),BMScrollView.scrollView=function(){return BMView.view.call(this)},BMScrollView.scrollViewForNode=function(t,e){return Object.create(BMScrollView.prototype).initWithWrapperDOMNode(t,e)},BMScrollView.prototype=BMExtend({},BMView.prototype,{get contentNode(){return this._node},set contentNode(t){},_contentView:void 0,get contentView(){return this._contentView},_iScroll:void 0,_scrollOffset:void 0,get supportsAutomaticIntrinsicSize(){return NO},initWithDOMNode(t){let e=document.createElement("div");return this.initWithWrapperDOMNode(t,{contentNode:e})},initWithWrapperDOMNode(t,e){return BMView.prototype.initWithDOMNode.call(this,t),this._contentView=BMView.viewForNode.call(BMScrollContentView,e.contentNode),BMView.prototype.addSubview.call(this,this._contentView),t.style.overflow="hidden",t.className="BMScrollView",BMAddSmoothMousewheelInteractionToNode(t),this._iScroll=new IScroll(t,{mouseWheel:YES,scrollbars:YES,probeType:3,click:NO,deceleration:.001,resizePolling:999999999999,scrollX:YES,freeScroll:YES,interactiveScrollbars:!BMIsTouchDevice,disableMouse:YES,disablePointer:YES,fadeScrollbars:BMIsTouchDevice}),this._iScroll.on("scroll",(()=>this._iScrollDidScroll())),this._scrollOffset=BMPointMake(),this},_iScrollDidScroll(){this._scrollOffset=BMPointMake(this._iScroll.x,this._iScroll.y),this.layout()},get bounds(){let t=this._frame.copy();return t.origin=this._scrollOffset,t},addSubview(t,e){this._contentView.addSubview(t,e)},release(){this._contentView.release(),this._iScroll&&this._iScroll.destroy(),BMView.prototype.release.call(this)}}),BMScrollContentView.prototype=BMExtend({},BMView.prototype,{get contentNode(){return this._node},set contentNode(t){},_hasDeterministicConstraints:YES,debuggingName:"Scroll View Content",get supportsAutomaticIntrinsicSize(){return NO},_frame:void 0,get frame(){return this._frame||BMRectMakeWithNodeFrame(this._node)},set frame(t){t.origin=BMPointMake(),Object.getOwnPropertyDescriptor(BMView.prototype,"frame").set.call(this,t),BMAnimationContextGetCurrent()?BMAnimationContextAddCompletionHandler((()=>{this.superview._iScroll.refresh()})):this.superview._iScroll&&this.superview._iScroll.refresh()},internalConstraints(){let t=BMView.prototype.internalConstraints.call(this);return this._superviewLeftConstraint?(this._superviewLeftConstraint.constant=this.superview._scrollOffset.x,this._superviewTopConstraint.constant=this.superview._scrollOffset.y,t.push(this._superviewWidthConstraint,this._superviewHeightConstraint,this._superviewLeftConstraint,this._superviewTopConstraint)):(t.push(this._superviewWidthConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,toView:this.superview,secondAttribute:BMLayoutAttribute.Width})),t.push(this._superviewHeightConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.GreaterThanOrEquals,toView:this.superview,secondAttribute:BMLayoutAttribute.Height})),t.push(this._superviewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Leading,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:BMLayoutAttribute.Leading,constant:this.superview._scrollOffset.x})),t.push(this._superviewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Top,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:BMLayoutAttribute.Top,constant:this.superview._scrollOffset.y}))),t}}),BMLayoutGuide.prototype=BMExtend({},BMView.prototype,{get supportsAutomaticIntrinsicSize(){return NO},_position:BMPointMake(),_dragged:NO,_horizontalConstraintAnchor:BMLayoutAttribute.Leading,_verticalConstraintAnchor:BMLayoutAttribute.Top,initWithDOMNode(t){let e;return BMView.prototype.initWithDOMNode.call(this,t),t.addEventListener("mousedown",(t=>{let e;this._dragged=YES,this._horizontalConstraintAnchor==BMLayoutAttribute.Trailing?(this._position=BMPointMake(this.node.offsetLeft+this.node.offsetWidth-this.node.parentNode.offsetWidth,this.node.offsetTop+this.node.offsetHeight-this.node.parentNode.offsetHeight),e=BMPointMake(t.clientX,t.clientY)):(this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop),e=BMPointMake(t.clientX,t.clientY));let i=t=>{let i=BMPointMake(t.clientX,t.clientY);this._position=BMPointMake(this._position.x+i.x-e.x,this._position.y+i.y-e.y),e=i,this.superview&&this.layout(),t.preventDefault()},o=window.getComputedStyle(this.node).cursor,n=document.createElement("div");n.className="BMLayoutGuideMask",n.style.cursor=o,document.body.appendChild(n);let s=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",s,YES),n.remove()};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",s,YES),t.preventDefault()})),t.addEventListener("touchstart",(t=>{if(void 0!==e)return;let i;e=t.changedTouches[0].identifier,this._dragged=YES,this._horizontalConstraintAnchor==BMLayoutAttribute.Trailing?(this._position=BMPointMake(this.node.offsetLeft+this.node.offsetWidth-this.node.parentNode.offsetWidth,this.node.offsetTop+this.node.offsetHeight-this.node.parentNode.offsetHeight),i=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY)):(this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop),i=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY));let o=t=>{let o;for(let i of t.changedTouches)if(i.identifier==e){o=i;break}if(!o)return;let n=BMPointMake(o.clientX,o.clientY);this._position=BMPointMake(this._position.x+n.x-i.x,this._position.y+n.y-i.y),i=n,this.superview&&this.layout(),t.preventDefault()},n=t=>{e=void 0,window.removeEventListener("touchmove",o),window.removeEventListener("touchend",n),window.removeEventListener("touchcancel",n)};window.addEventListener("touchmove",o),window.addEventListener("touchend",n),window.removeEventListener("touchcancel",n),t.preventDefault()})),this},set initialPosition(t){this._dragged||(this._position=t.copy(),this.superview&&this.layout())},internalConstraints(){let t=BMView.prototype.internalConstraints.call(this);return this._superviewLeftConstraint?(this._superviewLeftConstraint.constant=this._position.x,this._superviewTopConstraint.constant=this._position.y,t.push(this._superviewLeftConstraint,this._superviewTopConstraint)):(t.push(this._superviewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:this._horizontalConstraintAnchor,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:this._horizontalConstraintAnchor,constant:this._position.x,priority:500})),t.push(this._superviewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:this._verticalConstraintAnchor,relatedBy:BMLayoutConstraintRelation.Equals,toView:this.superview,secondAttribute:this._verticalConstraintAnchor,constant:this._position.y,priority:500}))),t}});const BM_LABEL_VIEW_DEBUG_INTRINSIC_SIZE=NO;function BMAttributedLabelView(){}const _BMAttributedLabelViewRegex=/\${([a-zA-Z0-9]+)}/g;function BMAttributedLabelViewArgument(){}BMAttributedLabelView.prototype=BMExtend(Object.create(BMView.prototype),{_supportsAutomaticIntrinsicSize:YES,get intrinsicSize(){let t=Object.getOwnPropertyDescriptor(BMView.prototype,"intrinsicSize").get.call(this);return BM_LABEL_VIEW_DEBUG_INTRINSIC_SIZE&&console.log("[BMAttributedLabelView] Intrinsic size is "+t),BM_LABEL_VIEW_DEBUG_INTRINSIC_SIZE&&t&&t.width,t},initWithDOMNode(){return BMView.prototype.initWithDOMNode.apply(this,arguments),this.arguments={},this},_contentNode:void 0,get contentNode(){return this._contentNode||this.node},_classPrefix:void 0,get classPrefix(){return this._classPrefix},set classPrefix(t){t=t||"";for(let e in this.arguments){this.arguments[e]._node.className=t+e}},_template:void 0,get template(){return this._template},set template(t){this._template=t,_BMAttributedLabelViewRegex.lastIndex=0;let e,i={},o=0;for(;e=_BMAttributedLabelViewRegex.exec(t);){let t,n=e[1];this.arguments[n]?(t=this.arguments[n],t._index=o,i[n]=t):(t=Object.create(BMAttributedLabelViewArgument.prototype),t._name=n,t._index=o,t._view=this,i[n]=t),o++}t=t.replace(_BMAttributedLabelViewRegex,`<span class=${this._classPrefix}$1></span>`),this.contentNode.innerHTML=t,this.arguments=i;for(let t in i){i[t]._setNode(this._node.querySelectorAll(`.${this._classPrefix+t}`)[0])}this.invalidateIntrinsicSize()},arguments:void 0}),BMAttributedLabelView.labelViewWithTemplate=function(t,e){let i=BMView.view.call(BMAttributedLabelView);i._classPrefix="",i.template=t;for(let t in e)i.arguments[t]&&(i.arguments[t].value=e[t]);return i},BMAttributedLabelView.labelViewForNode=function(t,e){let i=BMView.viewForNode.call(BMAttributedLabelView,t);i._contentNode=e.contentNode,i._classPrefix="",i.template=e.template;for(let t in e.arguments)i.arguments[t]&&(i.arguments[t].value=e.arguments[t]);return i},BMAttributedLabelViewArgument.prototype={_view:void 0,_name:void 0,_index:void 0,_value:"",get value(){return this._value},set value(t){(t=void 0===t?"":t)!=this._value&&(this._value=t,this._node&&(this._node.innerText=t,this._view.invalidateIntrinsicSize()))},_style:void 0,get style(){return this._style},set style(t){if(this._node){if(t=t||{},this._style)for(let e in this._style)e in t||this._node.style.removeProperty(e);this._style=t;for(let t in this._style)this._node.style[t]=this._style[t];this._view.invalidateIntrinsicSize()}else this._style=t||{}},_node:void 0,get node(){return this._node},_setNode:function(t){this._node=t,t.innerText=this._value,BMCopyProperties(t.style,this._style||{})}};const BM_TEXT_FIELD_MAX_SUGGESTIONS=10;function BMTextField(){}BMTextField.prototype=BMExtend(Object.create(BMView.prototype),{constructor:BMTextField,supportsAutomaticIntrinsicSize:NO,supportsIntrinsicSize:NO,_autoCompletes:YES,get autoCompletes(){return this._autoCompletes},set autoCompletes(t){this._autoCompletes=t},_usesSuggestions:YES,get usesSuggestions(){return this._usesSuggestions},set usesSuggestions(t){t!=this._usesSuggestions&&(this._usesSuggestions=t,t?this._setUpEventHandlers():this._clearEventHandlers())},maxSuggestions:10,delegate:void 0,initWithDOMNode(t){return BMView.prototype.initWithDOMNode.apply(this,arguments),this._usesSuggestions&&this._setUpEventHandlers(),this},_focusHandler:void 0,_blurHandler:void 0,_keydownHandler:void 0,_inputHandler:void 0,_pasteHandler:void 0,_setUpEventHandlers(){const t=this.node;let e,i,o=[],n=[];t.addEventListener("focus",this._focusHandler=async s=>{if(!this._usesSuggestions)return;let a=[];if(!this.delegate||!this.delegate.textFieldSuggestionsForText)return;o=this.delegate.textFieldSuggestionsForText(this,this.value),n=o,i=-1;let r=this.maxSuggestions;for(const i of o)if(a.push(this._menuItemWithLabel(i,{action:()=>{e=void 0,t.value=i,this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this),t.blur()}})),r--,!r)break;let l=YES;if(this.delegate.textFieldShouldShowSuggestions&&(l=this.delegate.textFieldShouldShowSuggestions(this)),l&&o.length){let i=BMRectMakeWithNodeFrame(t),o=BMPointMake(i.origin.x,i.bottom);e=this._showMenuAtPoint(o,{withOptions:a,kind:BMMenuKind.PullDownMenu}),e.classList.add("BMLayoutEditorConstantSuggestions"),e.parentNode.classList.add("BMLayoutEditorConstantSuggestionsOverlay"),e.addEventListener("mousedown",(t=>t.preventDefault()),YES)}const h=t=>t.preventDefault();t.addEventListener("mouseup",h),await new Promise((t=>setTimeout(t,200))),t.removeEventListener("mouseup",h)});let s=NO;t.addEventListener("keydown",this._keydownHandler=o=>{if(this._usesSuggestions){if("ArrowDown"==o.code||"ArrowUp"==o.code){if(o.preventDefault(),0==n.length)return;if(i="ArrowUp"==o.code?Math.max((i||0)-1,0):Math.min((isNaN(i)?-1:i)+1,n.length-1,this.maxSuggestions-1),e){for(const t of e.querySelectorAll(".BMLayoutEditorConstraintPopupOptionHighlighted"))t.classList.remove("BMLayoutEditorConstraintPopupOptionHighlighted");e.childNodes[i].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted")}}if("Enter"==o.code){let e=YES;if(this.delegate&&this.delegate.textFieldShouldReturn&&(e=this.delegate.textFieldShouldReturn(this)),void 0===e&&(e=YES),!e)return;let o=NO;!isNaN(i)&&n.length&&n[i]&&(this.delegate&&this.delegate.textFieldShouldAutocompleteText&&(o=this.delegate.textFieldShouldAutocompleteText(this,t.value,{withSuggestion:n[i]})),o&&(t.value=n[i],this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this))),t.blur()}"Backspace"!=o.code&&"Delete"!=o.code||(s=YES)}}),t.addEventListener("input",this._inputHandler=a=>{let r=NO;this._usesSuggestions||r||this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this),this.delegate&&this.delegate.textFieldSuggestionsForText&&(o=this.delegate.textFieldSuggestionsForText(this,this.value)),n=o.filter((e=>e.toLowerCase().startsWith(t.value.toLowerCase()))),n.length=Math.min(n.length,this.maxSuggestions),e&&(e.innerHTML=""),i=0;let l=this.maxSuggestions;if(e)for(const i of n)if(e.appendChild(this._menuItemWithLabel(i,{action:()=>{e=void 0,t.value=i,this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this)}})),l--,!l)break;if(n.length){if(e){e.childNodes[0].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted"),e.style.display="block";let i=BMRectMakeWithNodeFrame(t),o=BMPointMake(i.origin.x,i.bottom);this._repositionMenu(e,{atPoint:o})}if(this._autoCompletes&&!s){const e=t.selectionStart;e==t.value.length&&(r=YES,t.value=n[0],t.setSelectionRange(e,t.value.length,"backward"),this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this))}s&&(s=NO)}else e&&(e.style.display="none");r||this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this)}),t.addEventListener("blur",this._blurHandler=t=>{e&&e.parentNode.dispatchEvent(new Event("click"))}),t.addEventListener("paste",this._pasteHandler=t=>{this.delegate&&this.delegate.textFieldContentsDidChange&&this.delegate.textFieldContentsDidChange(this)})},_clearEventHandlers(){this.node.removeEventListener("focus",this._focusHandler),this.node.removeEventListener("blur",this._blurHandler),this.node.removeEventListener("keydown",this._keydownHandler),this.node.removeEventListener("input",this._inputHandler),this.node.removeEventListener("input",this._pasteHandler)},_menuItemWithLabel(t,e){let i=document.createElement("div");return i.className="BMLayoutEditorConstraintPopupOption",i.innerText=t,i.addEventListener("click",e.action),i},_showMenuAtPoint(t,e){let i=document.createElement("div");i.className="BMLayoutEditorConstraintPopup BMTextFieldSuggestions";let o=i,n=document.createElement("div");n.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(i.style.backgroundColor="white"),n.appendChild(i),e.withOptions.forEach((t=>i.appendChild(t))),BMHook(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0}),document.body.appendChild(n),this._repositionMenu(o,{atPoint:t}),i.addEventListener("click",(t=>t.preventDefault())),(window.Velocity||$.Velocity).animate(i,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>(i.style.pointerEvents="all",n.style.pointerEvents="all")});let s=0;for(let t of i.childNodes)BMHook(t,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(t,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:s}),s+=16;return n.addEventListener("click",(t=>{i.style.pointerEvents="none",n.style.pointerEvents="none";let o=16*i.childNodes.length+100-200;o=o<0?0:o,(window.Velocity||$.Velocity).animate(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0,translateZ:0},{duration:200,easing:"easeInQuad",delay:o,complete:t=>n.remove()}),o=0;for(let t=i.childNodes.length-1;t>=0;t--){let e=i.childNodes[t];(window.Velocity||$.Velocity).animate(e,{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:o}),o+=16}})),i},_repositionMenu(t,{atPoint:e}){let i=t.offsetHeight;t.style.transformOrigin="50% 0%",i+e.y>document.documentElement.clientHeight&&(t.style.transformOrigin="50% 100%",e.y-=i+this.frame.size.height),t.style.left=e.x+"px",t.style.top=e.y+"px"}}),BMTextField.textField=function(){const t=document.createElement("input");t.type="text";return Object.create(BMTextField.prototype).initWithDOMNode(t)},BMTextField.textFieldForInputNode=function(t){return Object.create(BMTextField.prototype).initWithDOMNode(t)};var BMCollectionViewLayoutAttributesType=Object.freeze({Cell:{},SupplementaryView:{},DecorationView:{}}),BMCellAttributesType=BMCollectionViewLayoutAttributesType,BMCollectionViewLayoutAttributesStyleDefaults=Object.freeze({opacity:1,scaleX:1,scaleY:1,rotate:0,rotateX:0,rotateY:0,rotateZ:0,skewX:0,skewY:0,skewZ:0,transformOriginX:"50%",transformOriginY:"50%",translateZ:0,blur:"0px"}),BMCellAttributesStyleDefaults=BMCollectionViewLayoutAttributesStyleDefaults;function BMCollectionViewLayoutAttributes(){}var BMCellAttributes=BMCollectionViewLayoutAttributes;function BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t){var e=new BMCollectionViewLayoutAttributes;return e.indexPath=t,e._itemType=BMCollectionViewLayoutAttributesType.Cell,e._style={},e}BMCollectionViewLayoutAttributes.prototype={_cell:void 0,get cell(){return this._cell},set cell(t){this._cell=t,t&&t.element&&(t._previousFrame&&t._previousFrame.isEqualToRect(this.frame)&&t.retainCount||this._hookFrame(),this._style&&Object.keys(this._style).length&&(this._style.translateX=this.frame.origin.x+"px",this._style.translateY=this.frame.origin.y+"px",this.hook(this._style)))},_itemType:BMCollectionViewLayoutAttributesType.Cell,get itemType(){return this._itemType},identifier:void 0,_frame:void 0,get frame(){return this._frame},set frame(t){this._frame=t.copy(),this._hookFrame()},_hookFrame:function(){var t=this.frame;if(this._cell&&this._cell.element){var e={translateX:t.origin.x+"px",translateY:t.origin.y+"px"};this._cell._lastAssignedWidth!=t.size.width&&(e.width=t.size.width+"px"),this._cell._lastAssignedHeight!=t.size.height&&(e.height=t.size.height+"px"),(e.width||e.height)&&this._cell.collectionView.delegate&&this._cell.collectionView.delegate.collectionViewWillResizeCell&&this._cell.collectionView.delegate.collectionViewWillResizeCell(this._cell.collectionView,this._cell,{toSize:t.size.copy()}),this.hook(e)}},_flatten:function(){this._cell&&(this.style={},this._cell.element[0].style.transform="",BMCopyProperties(this._cell.element[0].style,{left:this._frame.origin.x+"px",top:this._frame.origin.y+"px"}))},_style:void 0,get style(){return this._style||(this._style={}),this._style},set style(t){delete(t=t||{}).width,delete t.height,delete t.left,delete t.right,delete t.translateX,delete t.translateY;var e=this._style;for(i in this._style={translateX:this.frame.origin.x+"px",translateY:this.frame.origin.y+"px"},t)this._style[i]=t[i];if(e)for(var i in e)void 0===t[i]&&(t[i]=BMCollectionViewLayoutAttributesStyleDefaults[i]);this.hook(t)},addStyle:function(t){for(var e in delete t.width,delete t.height,delete t.left,delete t.right,delete t.translateX,delete t.translateY,t)this._style[e]=t[e];this.hook(t)},_isHidden:NO,get isHidden(){return this._isHidden},set isHidden(t){this._isHidden=t},hook:function(t){if(this._cell&&this._cell.element){var e=this;if(BMAnimationContextGetCurrent()){var i=BMAnimationContextGetCurrent(),o=i.subscribers.get(this);this._cell._isHidden==this._isHidden||this._isHidden||(this._cell.isHidden=NO),o||(o={prepare(){if(e._cell){for(var i={},o=0;o<this.properties.length;o++){var n=this.properties[o];for(var s in n)i[s]=n[s]}if(this._propertyMap=i,t.width||t.height){var a=BMRectMakeWithOrigin(BMPointMake(),{size:e.frame.size.copy()});e._cell.boundsWillChangeToBounds(a)}}},apply:function(i){if(!e._cell)return;var o=this._propertyMap,n=e._cell;let s;n._layoutAnimator=new Promise((t=>s=t));e._cell._bounds;if(t.width||t.height){var a=BMRectMakeWithOrigin(BMPointMake(),{size:e.frame.size.copy()});YES,a.copy()}var r=NO,l=e.frame.size.width,h=e.frame.size.height;i.targets.push({element:e._cell.element[0],properties:o,complete:function(){if(!r&&(r=YES,o.width&&(n._lastAssignedWidth=l),o.height&&(n._lastAssignedHeight=h),n._isHidden!=e._isHidden&&e._isHidden&&(n.isHidden=YES),s(),n._layoutAnimator=void 0,t.width||t.height)){var i=BMRectMakeWithOrigin(BMPointMake(),{size:e.frame.size.copy()}),a=n._bounds;n._bounds=i,n.boundsDidChangeFromBounds(a),n.collectionView.delegate&&n.collectionView.delegate.collectionViewDidResizeCell&&n.collectionView.delegate.collectionViewDidResizeCell(n.collectionView,n,{toSize:e.frame.size.copy()})}}})},properties:[]},i.subscribers.set(this,o)),o.properties.push(t),(t.width||t.height)&&(e._cell.needsLayout=YES)}else{if(BMHook(this._cell.element[0],t),t.width&&(this._cell._lastAssignedWidth=this.frame.size.width),t.height&&(this._cell._lastAssignedHeight=this.frame.size.height),t.width||t.height){this._fraction||(e._cell.needsLayout=YES);var n=BMRectMakeWithOrigin(BMPointMake(),{size:this.frame.size.copy()});this._cell.boundsWillChangeToBounds(n);var s=this._cell._bounds;this._cell._bounds=n,this._cell.boundsDidChangeFromBounds(s),this._cell.collectionView.delegate&&this._cell.collectionView.delegate.collectionViewDidResizeCell&&this._cell.collectionView.delegate.collectionViewDidResizeCell(this._cell.collectionView,this._cell,{toSize:this.frame.size.copy()})}this._isHidden!=this._cell._isHidden&&(this._cell.isHidden=this._isHidden)}}},indexPath:void 0,copy:function(){var t=new BMCollectionViewLayoutAttributes;return t._frame=this._frame.copy(),t.indexPath=this.indexPath.copy(),t._style=BMCopyProperties({},this._style),t._itemType=this._itemType,t.identifier=this.identifier,t}};var BMCellAttributesMakeForCellAtIndexPath=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath;function BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(t,e){var i=new BMCollectionViewLayoutAttributes;return i.indexPath=e.atIndexPath,i._itemType=BMCollectionViewLayoutAttributesType.SupplementaryView,i.identifier=t,i._style={},i}var BMCellAttributesMakeForSupplementaryViewWithIdentifier=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier,_BMCollectionViewTransitionLayoutAttributesUnitRegex=/\-?\+?\d*\.?\d*(\D*)/,_BMCollectionViewTransitionCellAttributesUnitRegex=_BMCollectionViewTransitionLayoutAttributesUnitRegex;function _BMCollectionViewTransitionLayoutAttributes(){}function _BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(t,e){var i=new _BMCollectionViewTransitionLayoutAttributes;return i.indexPath=t.indexPath.copy(),i._itemType=t._itemType,i.identifier=t.identifier,i._sourceAttributes=t,i._targetAttributes=e.targetAttributes,i.fraction=0,i._frame=t._frame,i}_BMCollectionViewTransitionLayoutAttributes.prototype=BMExtend({},BMCollectionViewLayoutAttributes.prototype,{_sourceAttributes:void 0,get sourceAttributes(){return this._sourceAttributes},_targetAttributes:void 0,get targetAttributes(){return this._targetAttributes},_fraction:0,get fraction(){return this._fraction},set fraction(t){this._sourceAttributes.isHidden&&this._targetAttributes.isHidden?this.isHidden=YES:this.isHidden=NO,this._fraction=t,this._frame=BMRectByInterpolatingRect(this._sourceAttributes._frame,{toRect:this._targetAttributes._frame,withFraction:t}),this._hookFrame();var e=BMCopyProperties(this._sourceAttributes.style,{translateX:this._sourceAttributes._frame.origin.x+"px",translateY:this._sourceAttributes._frame.origin.y+"px"}),i=BMCopyProperties(this._targetAttributes.style,{translateX:this._targetAttributes._frame.origin.x+"px",translateY:this._targetAttributes._frame.origin.y+"px"});if(this._style||(this._style={}),!this._intermediateTransitionStyle){for(var o in this._intermediateTransitionStyle={},e){this._intermediateTransitionStyle[o]={source:parseFloat(e[o])};var n=parseFloat(i[o]);isNaN(n)&&(n=parseFloat(BMCollectionViewLayoutAttributesStyleDefaults[o])),this._intermediateTransitionStyle[o].target=n;var s=_BMCollectionViewTransitionLayoutAttributesUnitRegex.exec(e[o])[1]||"";this._intermediateTransitionStyle[o].unit=s}for(var o in i)if(!this._intermediateTransitionStyle[o]){this._intermediateTransitionStyle[o]={target:parseFloat(i[o])};var a=parseFloat(e[o]);isNaN(a)&&(a=parseFloat(BMCollectionViewLayoutAttributesStyleDefaults[o])),this._intermediateTransitionStyle[o].source=a;s=_BMCollectionViewTransitionCellAttributesUnitRegex.exec(i[o])[1]||"";this._intermediateTransitionStyle[o].unit=s}}var r=this._intermediateTransitionStyle;for(var o in r){var l=r[o];this._style[o]=BMNumberByInterpolatingNumbersWithFraction(l.source,l.target,t)+l.unit}this.hook(this._style)},_applyFinalAttributes:function(){this._cell&&(this._cell.attributes=this._targetAttributes)},_layout(){this._cell&&(this._frame=this._targetAttributes.frame,this._cell.needsLayout=YES)}});var _BMCollectionViewTransitionCellAttributesMakeWithSourceAttributes=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes;function BMJQueryShim(){}BMJQueryShim.prototype={0:document.body,css(t,e){if("string"==typeof t)this[0].style[t]=e;else for(const e in t)this[0].style[e]=t[e]},width(){return this[0].offsetWidth},height(){return this[0].offsetHeight},offset(){return{left:this[0].offsetLeft,top:this[0].offsetTop}},append(t){"string"!=typeof t?this[0].append(t[0]):this[0].insertAdjacentHTML("beforeend",t)},empty(){this[0].innerHTML=""},remove(){this[0].remove()}},BMJQueryShim.shimWithDOMNode=function(t){if("$"in window)return $(t);const e=new BMJQueryShim;return e[0]=t,e};const BM_USE_BMVIEW_SUBCLASS=YES,BMCollectionViewCellReuseState=Object.freeze({InUse:"InUse",InQueue:"InQueue",Deleting:"Deleting",Discarded:"Discarded"});function BMCollectionViewCell(){}var BMCell=BMCollectionViewCell;function BMCollectionViewCellMakeForCollectionView(t,e){return(new BMCollectionViewCell).initWithCollectionView(t,e)}BMCollectionViewCell.prototype=BMExtend(BM_USE_BMVIEW_SUBCLASS?Object.create(BMView.prototype):{},{get retainCount(){return this._retainCount+this._manageCount},get isManaged(){return this._manageCount>0},get isRetained(){return this.retainCount>0},get _frame(){return this._attributes&&this._attributes.frame},get frame(){return this._attributes&&this._attributes.frame},set frame(t){},get supportsAutomaticIntrinsicSize(){return this._isMeasuring&&!this._subviews.length?YES:NO},collectionView:void 0,_element:void 0,get element(){return this._element||(this._element=BMJQueryShim.shimWithDOMNode(this.node))},itemType:BMCollectionViewLayoutAttributesType.Cell,_reuseIdentifier:void 0,get reuseIdentifier(){return this._reuseIdentifier},set reuseIdentifier(t){t!=this._reuseIdentifier&&this.collectionView.assignsReuseIdentifierAsClass&&(this._reuseIdentifier&&this.node.classList.remove(`BMCollectionViewCell-${this._reuseIdentifier}`),t&&this.node.classList.add(`BMCollectionViewCell-${t}`),this._reuseIdentifier=t)},_bounds:BMRectMake(),get bounds(){return this._bounds},boundsWillChangeToBounds(t){},boundsDidTransitionToBounds(t){},boundsDidChangeFromBounds(t){},_attributes:void 0,get attributes(){return this._attributes},set attributes(t){var e=this._attributes;if(this._attributes?(this._attributes.cell=void 0,this._previousFrame=e.frame.copy()):this._previousFrame=void 0,this._attributes=t,t){if(t.cell=void 0,e&&e.style)for(var i in t.style=t.style||{},e.style)void 0===t.style[i]&&(t.style[i]=BMCollectionViewLayoutAttributesStyleDefaults[i]);t&&(t.cell=this)}},get indexPath(){return this._attributes?this._attributes.indexPath:void 0},_manage:function(){return this._manageCount||(this._manageCount++,this.collectionView.cellWasManaged(this),1===this.retainCount&&(this.prepareForDisplay(),this.collectionView.cellShouldRender(this))),this},_unmanage:function(){this._manageCount&&(this._manageCount--,this.collectionView.cellWasUnmanaged(this),0===this.retainCount&&(this.prepareForReuse(),this.collectionView.cellWasReleased(this)))},retain:function(){return this._retainCount++,1==this.retainCount&&(this.prepareForDisplay(),this.collectionView.cellShouldRender(this)),this},release:function(){this._retainCount--,0==this.retainCount&&(this.prepareForReuse(),this.collectionView.cellWasReleased(this))},recycle:function(){this._unmanage(),this.retainCount>0&&(this.invalidate(),this.collectionView.cellWasInvalidated(this),this.destroy(),this._manage=function(){},this._unmanage=this._manage,this.retain=this._manage,this.release=this.retain,this.recycle=this.retain,this.releaseRecycledCell=this.retain)},releaseRecycledCell:function(){this.release(),this.retainCount>0&&(this.invalidate(),this.collectionView.cellWasInvalidated(this),this.destroy(),this._manage=function(){},this._unmanage=this._manage,this.retain=this._manage,this.release=this.retain,this.recycle=this.retain,this.releaseRecycledCell=this.retain)},_reuseState:BMCollectionViewCellReuseState.InQueue,get reuseState(){return this._reuseState},_isHidden:NO,get isHidden(){return this._isHidden},set isHidden(t){this._isHidden!=t&&(t?this._hide():this._show())},_hide:function(){this._isHidden=YES,this.node.classList.add("BMCollectionViewCellHidden")},_show:function(){this._isHidden=NO,this.node.classList.remove("BMCollectionViewCellHidden")},_prepareForAutomaticIntrinsicSize(){for(let t of this._subviews)t._prepareForAutomaticIntrinsicSize();this._isMeasuring&&(this._subviews.length?BMCopyProperties(this._node.style,{width:"100%",height:"100%"}):this._requiredWidth?BMCopyProperties(this._node.style,{width:this._requiredWidth+"px",height:"auto"}):BMCopyProperties(this._node.style,{width:"auto",height:"auto"}))},_supportsAutomaticIntrinsicSize:NO,_isMeasuring:NO,internalConstraints(){var t=[];return this._isMeasuring||(this._rootViewLeftConstraint?(this.attributes&&(this._rootViewWidthConstraint.constant=this.attributes.frame.size.width,this._rootViewHeightConstraint.constant=this.attributes.frame.size.height),t.push(this._rootViewLeftConstraint,this._rootViewTopConstraint,this._rootViewWidthConstraint,this._rootViewHeightConstraint)):t.push(this._rootViewLeftConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Left,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewTopConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Top,relatedBy:BMLayoutConstraintRelation.Equals,constant:0}),this._rootViewWidthConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.Equals,constant:this.attributes?this.attributes.frame.size.width:0}),this._rootViewHeightConstraint=BMLayoutConstraint.internalConstraintWithView(this,{attribute:BMLayoutAttribute.Height,relatedBy:BMLayoutConstraintRelation.Equals,constant:this.attributes?this.attributes.frame.size.height:0}))),t},prepareForAnimatedUpdate(){},prepareForReuse(){this._reuseState=BMCollectionViewCellReuseState.InQueue},prepareForDisplay(){this._reuseState=BMCollectionViewCellReuseState.InUse},invalidate(){},destroy(){BMView.prototype.release.call(this)},get initializesAtomically(){return YES},initWithCollectionView(t,e){return this._retainCount=0,this._manageCount=0,this.collectionView=t,BM_USE_BMVIEW_SUBCLASS?BMView.prototype.initWithDOMNode.call(this,e.node):this.node=e.node,this.reuseIdentifier=e.reuseIdentifier,e.kind&&(this.itemType=e.kind),this},_collectionViewDidBecomeVisible(){for(const t of this.allSubviews)t.viewDidBecomeVisible()},_collectionViewDidBecomeInvisible(){for(const t of this.allSubviews)t.viewDidBecomeInvisible()},initNonatomic:async function(){}});var BMCellMakeForCollectionView=BMCollectionViewCellMakeForCollectionView;function BMCollectionViewLayout(){}function BMCollectionViewLayoutInvalidationContext(){}BMCollectionViewLayout.prototype={_collectionView:void 0,get collectionView(){return this._collectionView},set collectionView(t){this._collectionView=t},attributesForCellAtIndexPath:function(t){throw new Error("attributesForCellAtIndexPath() must be implemented by layout objects.")},attributesForElementsInRect:function(t){throw new Error("attributesForCellsInRect() must be implemented by layout objects.")},contentSize:function(){throw new Error("contentSize() must be implemented by layout objects.")},attributesForSupplementaryViewWithIdentifier:function(t,e){throw new Error("attributesForSupplementaryViewWithIdentifier(_, {atIndexPath}) must be implemented by layout objects that define supplementary views.")},prepareLayout:function(){},get invalidationContextType(){return BMCollectionViewLayoutInvalidationContext},get supportsCopying(){return NO},beginUpdates(){this._copy=this.copy()},applyUpdates(){this._collectionView&&this._collectionView.invalidateLayout(),this._copy=void 0},firstIndexPath(){const t=this.collectionView.numberOfSections();for(let e=0;e<t;e++){if(this.collectionView.numberOfObjectsInSectionAtIndex(e))return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e})}},indexPathToTheLeftOfIndexPath(t){if(t.row>0)return this.collectionView.indexPathForObjectAtRow(t.row-1,{inSectionAtIndex:t.section});if(t.section>0){let e=t.section-1;do{const t=this.collectionView.numberOfObjectsInSectionAtIndex(e);if(t)return this.collectionView.indexPathForObjectAtRow(t-1,{inSectionAtIndex:e});e-=1}while(e>=0)}return t},indexPathAboveIndexPath(t){return this.indexPathToTheLeftOfIndexPath(t)},indexPathToTheRightOfIndexPath(t){const e=this.collectionView.numberOfObjectsInSectionAtIndex(t.section);if(t.row<e-1)return this.collectionView.indexPathForObjectAtRow(t.row+1,{inSectionAtIndex:t.section});const i=this.collectionView.numberOfSections();if(t.section<i-1){let e=t.section+1;do{if(this.collectionView.numberOfObjectsInSectionAtIndex(e))return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e});e+=1}while(e<i)}return t},indexPathBelowIndexPath(t){return this.indexPathToTheRightOfIndexPath(t)},indexPathsFromIndexPath(t,{toIndexPath:e}){const i=[];if(e.section<t.section){const i=e;e=t,t=i}else if(t.section==e.section&&e.row<t.row){const i=e;e=t,t=i}let o=t.row;const n=e.section;for(let s=t.section;s<n+1;s++){let t=this.collectionView.numberOfObjectsInSectionAtIndex(s);for(s==n&&(t=e.row+1);o<t;o++)i.push(this.collectionView.indexPathForObjectAtRow(o,{inSectionAtIndex:s}));o=0}return i},collectionViewWillStartUpdates:function(t){},collectionViewDidStartUpdates:function(){},preferredScrollOffsetWithOffset:function(t){return t},preferredScrollOffsetForTransitionFromLayout:function(t,e){return this.preferredScrollOffsetWithOffset(e.withOffset)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={opacity:0},i},initialAttributesForMovingSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={opacity:0},i},initialAttributesForAppearingCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},initialAttributesForAppearingSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},initialAttributesForRevealingCellAtIndexPath:function(t,e){return this.initialAttributesForAppearingCellAtIndexPath(t,e)},initialAttributesForRevealingSupplementaryViewWithIdentifier:function(t,e){return this.initialAttributesForAppearingSupplementaryViewWithIdentifier(t,e)},initialAttributesForPresentedCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},initialAttributesForPresentedSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},supplementaryViewsToInsert:function(){return[]},finalAttributesForDisappearingCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},finalAttributesForDisappearingSupplementaryViewWithIdentifier:function(t,e){var i=e.withTargetAttributes.copy();return i.style={scaleX:0,scaleY:0,opacity:0},i},finalAttributesForHidingCellAtIndexPath:function(t,e){return this.finalAttributesForDisappearingCellAtIndexPath(t,e)},finalAttributesForHidingSupplementaryViewWithIdentifier:function(t,e){return this.finalAttributesForDisappearingSupplementaryViewWithIdentifier(t,e)},supplementaryViewsToDelete:function(){return[]},invalidateLayout:function(){this._copy||this._collectionView&&this._collectionView.invalidateLayout()},invalidateContentSize:function(){this._copy||this._collectionView&&this._collectionView.invalidateContentSize()},invalidateLayoutWithContext:function(t,e){this._collectionView&&this._collectionView.invalidateLayoutWithContext(t,e)},shouldInvalidateLayoutForFrameChange:function(t,e){return YES},shouldInvalidateLayoutForBoundsChange:function(t,{fromBounds:e}){return NO},didInvalidateLayoutForBoundsChange:function(){},rectWithScrollingPositionOfCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t);return e?e.frame:BMRectMake()},rectWithScrollingPositionOfSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,e);return i?i.frame:BMRectMake()},get snapsScrollPosition(){return NO},snappingScrollOffsetForScrollOffset:function(t,e){return t},prepareForDragOperation(){},dragOperationWillRollback(){},dragOperationDidFinish(){},constraintsForMeasuringCell:(t,{atIndexPath:e})=>[],copy:function(){throw new Error("Layout objects that support copying should implement the copy() method.")},get supportsStatefulCopying(){return NO},statefulCopy(){return this.copy()}},BMCollectionViewLayoutInvalidationContext.prototype={invalidateEverything:NO,invalidateDataSetCounts:NO,contentSizeAdjustment:void 0,invalidatedCellIndexPaths:void 0,invalidatedSupplementaryViewIndexPaths:void 0};var _BMCollectionViewTransitionLayout=function(t,e,i,o){this.transitionAttributes=t,this.initialSize=e,this.targetSize=i,this.targetLayout=o};_BMCollectionViewTransitionLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{_fraction:0,get fraction(){return this._fraction},set fraction(t){if(this.collectionView){this._fraction=t;for(var e=this.transitionAttributes.length,i=0;i<e;i++)this.transitionAttributes[i].fraction=t}},attributesForElementsInRect:function(t){return this.transitionAttributes},contentSize:function(){return BMSizeMake(BMNumberByInterpolatingNumbersWithFraction(this.initialSize.width,this.targetSize.width,this._fraction),BMNumberByInterpolatingNumbersWithFraction(this.initialSize.height,this.targetSize.height,this._fraction))},attributesForCellAtIndexPath:function(t,e){for(let e of this.transitionAttributes)if(e.indexPath.isEqualToIndexPath(t,{usingComparator:this.collectionView.identityComparator}))return e;return this.targetLayout.attributesForCellAtIndexPath(t,e)},attributesForSupplementaryViewWithIdentifier:function(t,e){return this.targetLayout.attributesForSupplementaryViewWithIdentifier(t,e)},_applyFinalAttributes:function(){for(var t=this.transitionAttributes.length,e=0;e<t;e++)this.transitionAttributes[e]._applyFinalAttributes()},_layout(){for(var t=this.transitionAttributes.length,e=0;e<t;e++)this.transitionAttributes[e]._layout();this.collectionView._cellLayoutQueue.dequeue()}});const BM_AUTOMATIC_CELL_SIZE_MESSAGES=NO;var BMCollectionViewTableLayoutSupplementaryView=Object.freeze({Footer:"Footer",Header:"Header",Empty:"Empty"});function BMCollectionViewTableLayout(){}var BMCollectionViewTableLayoutRowHeightVariable=-1;function BMCollectionViewTreeLayout(){}BMCollectionViewTableLayout.prototype=BMExtend(Object.create(BMCollectionViewLayout.prototype),{constructor:BMCollectionViewTableLayout,get supportsCopying(){return YES},_rowHeight:44,get rowHeight(){return this._rowHeight},set rowHeight(t){this._rowHeight=t,this.invalidateLayout()},_minimumWidth:0,get minimumWidth(){return this._minimumWidth},set minimumWidth(t){this._minimumWidth=t,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},_cachedContentSize:void 0,constraintsForMeasuringCell(t,{atIndexPath:e}){return[BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,constant:this.collectionView.frame.size.width})]},prepareLayout(){return this.contentSize()},contentSize:function(){var t=this._sectionInsets.top,e=this._sectionInsets.bottom,i=this.headerHeight,o=this.footerHeight,n=0,s=this.collectionView.numberOfSections();if(n+=s*(i+o+t+e),this._rowHeight>=0)for(var a=0;a<s;a++)n+=this._rowHeight*this.collectionView.numberOfObjectsInSectionAtIndex(a);else for(a=0;a<s;a++)for(var r=this.collectionView.numberOfObjectsInSectionAtIndex(a),l=0;l<r;l++)n+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(l,{inSectionAtIndex:a}));return this._cachedContentSize=BMSizeMake(Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize),Math.max(this.collectionView.frame.size.height,n)),this._cachedContentSize},shouldInvalidateLayoutForBoundsChange:function(t){return this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge},shouldInvalidateLayoutForFrameChange(){return this.collectionView.invalidateMeasuredSizeOfCells(),YES},attributesForCellAtIndexPath:function(t){var e=t.row,i=t.section,o=(i+1)*(this._sectionInsets.top+this.headerHeight)+i*(this._sectionInsets.bottom+this.footerHeight),n=this._cachedContentSize.height>this.collectionView.frame.size.height;if(this._rowHeight>=0)for(var s=0;s<=i;s++){var a=s==i?e:this.collectionView.numberOfObjectsInSectionAtIndex(s);o+=this._rowHeight*a}else for(s=0;s<=i;s++){a=s==i?e:this.collectionView.numberOfObjectsInSectionAtIndex(s);for(var r=0;r<a;r++)o+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(r,{inSectionAtIndex:s}))}var l=BMRectMake(this._sectionInsets.left,o,Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize)-this._sectionInsets.left-this._sectionInsets.right-(n?this.collectionView.scrollBarSize:0),this._rowHeight>=0?this._rowHeight:this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,t)),h=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);return h.frame=l,h},attributesForSupplementaryViewWithIdentifier:function(t,e){var i=this._cachedContentSize.height>this.collectionView.frame.size.height;if(t===BMCollectionViewTableLayoutSupplementaryView.Empty){var o=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return o.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),o}var n=e.atIndexPath.section;if(!(n>=this.collectionView.numberOfSections())){for(var s,a=this.sectionInsets.top,r=this._rowHeight<0,l=this.sectionInsets.top+this.sectionInsets.bottom,h=this.sectionInsets.left,c=Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize)-this.sectionInsets.left-this.sectionInsets.right-(i?this.collectionView.scrollBarSize:0),d=NO,u=NO,p=this.collectionView.scrollOffset,g=this.collectionView.frame,w=0;w<n;w++){s=a+l,a+=this.headerHeight+this.footerHeight+l;var y=this.collectionView.numberOfObjectsInSectionAtIndex(w);if(r)for(var m=0;m<y;m++)a+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(m,{inSectionAtIndex:w}));else a+=y*this._rowHeight}if(d=s<p.y&&a>p.y?YES:NO,u=s>p.y&&a>p.y+g.size.height?YES:NO,t===BMCollectionViewTableLayoutSupplementaryView.Header)return(_=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:e.atIndexPath})).frame=BMRectMake(h,a,c,this.headerHeight),this._pinsHeadersToContentEdge&&d&&(_.frame.origin.y=Math.max(_.frame.origin.y,p.y),_.style.zIndex=1),_;if(t===BMCollectionViewTableLayoutSupplementaryView.Footer){var _;y=this.collectionView.numberOfObjectsInSectionAtIndex(w);if(r)for(m=0;m<y;m++)a+=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(m,{inSectionAtIndex:w}));else a+=y*this._rowHeight;return a+=this.headerHeight,(_=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:e.atIndexPath})).frame=BMRectMake(h,a,c,this.footerHeight),this._pinsHeadersToContentEdge&&u&&(_.frame.origin.y=Math.min(_.frame.origin.y,p.y+this.collectionView.frame.size.height-_.frame.size.height),_.style.zIndex=1),_}}},indexPathAtPoint:function(t,e){var i=(e=e||{}).directionNext,o=t.y,n=0,s=this._sectionInsets.top+this.headerHeight,a=this._sectionInsets.bottom+this.footerHeight;if(o<=s)return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:0});n=s;var r=this.collectionView.numberOfSections();if(this._rowHeight>=0){for(var l=0;l<r;l++){if(o<=n+(d=this.collectionView.numberOfObjectsInSectionAtIndex(l))*this._rowHeight){var h=o-n,c=0|Math.floor(h/this._rowHeight);return this.collectionView.indexPathForObjectAtRow(c,{inSectionAtIndex:l})}if(o<=(n+=d*this._rowHeight)+a+s)return i&&l<r-1?this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:l+1}):this.collectionView.indexPathForObjectAtRow(d-1,{inSectionAtIndex:l});n+=a+s}return this.collectionView.indexPathForObjectAtRow(this.collectionView.numberOfObjectsInSectionAtIndex(r-1),{inSectionAtIndex:r-1})}for(l=0;l<r;l++){for(var d=this.collectionView.numberOfObjectsInSectionAtIndex(l),u=0;u<d;u++){var p=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,this.collectionView.indexPathForObjectAtRow(u,{inSectionAtIndex:l}));if(o<=n+p)return this.collectionView.indexPathForObjectAtRow(u,{inSectionAtIndex:l});n+=p}if(o<=n+a+s)return i&&l<r-1?this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:l+1}):this.collectionView.indexPathForObjectAtRow(d-1,{inSectionAtIndex:l});n+=a+s}return this.collectionView.indexPathForObjectAtRow(this.collectionView.numberOfObjectsInSectionAtIndex(r-1),{inSectionAtIndex:r-1})},attributesForElementsInRect:function(t){var e=this._cachedContentSize.height>this.collectionView.frame.size.height;if(0==this.collectionView.numberOfSections())return(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})).frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),[C];for(var i=this._sectionInsets.top,o=this._rowHeight<0,n=(this._sectionInsets.top,this.headerHeight,this._sectionInsets.bottom,this.footerHeight,this.sectionInsets.left),s=Math.max(this.collectionView.frame.size.width,this.minimumWidth+this.collectionView.scrollBarSize)-this.sectionInsets.left-this.sectionInsets.right-(e?this.collectionView.scrollBarSize:0),a=t.origin.y,r=t.bottom,l=0,h=-1;!(i+this.headerHeight>a);){if(i+=this.headerHeight,h=0,o){for(var c=this.collectionView.numberOfObjectsInSectionAtIndex(l),d=0;d<c;d++){var u=this.collectionView.indexPathForObjectAtRow(d,{inSectionAtIndex:l}),p=this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,u);if(i+p>a){h=d;break}i+=p}h=d}else{var g=this.collectionView.numberOfObjectsInSectionAtIndex(l)*this._rowHeight;if(i+g>a){var w=Math.floor((a-i)/this._rowHeight);h=w,i+=w*this._rowHeight;break}h=this.collectionView.numberOfObjectsInSectionAtIndex(l),i+=g}if(i+this.footerHeight>a)break;if(i+=this.footerHeight+this.sectionInsets.top+this.sectionInsets.bottom,h=-1,++l>=this.collectionView.numberOfSections())return[]}var y=[],m=l;this._pinsHeadersToContentEdge&&h>-1&&((C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([l])})).frame=BMRectMake(n,this.collectionView.scrollOffset.y,s,this.headerHeight),C.style.zIndex=1,y.push(C));for(var _,f,v=l;i<r&&!(l>=this.collectionView.numberOfSections());)if(v=l,-1!=h)if(h!=this.collectionView.numberOfObjectsInSectionAtIndex(l)){if(l>=this.collectionView.numberOfSections())return y;(C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(u=this.collectionView.indexPathForObjectAtRow(h,{inSectionAtIndex:l}))).frame=BMRectMake(n,i,s,o?this.collectionView.delegate.collectionViewRowHeightForCellAtIndexPath(this.collectionView,u):this._rowHeight),y.push(C),i+=C.frame.size.height,h++}else{if(!this.showsFooters){h=-1,l++,i+=this.footerHeight+this.sectionInsets.top+this.sectionInsets.bottom;continue}(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([l])})).frame=BMRectMake(n,i,s,this.footerHeight),y.push(C),_=C,f=l,i+=this.footerHeight+this.sectionInsets.top+this.sectionInsets.bottom,h=-1,l++}else{if(!this.showsHeaders){h=0;continue}if((C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([l])})).frame=BMRectMake(n,i,s,this.headerHeight),this._pinsHeadersToContentEdge&&l===m){if(C.frame.origin.y>this.collectionView.scrollOffset.y)if(l-1>-1){var M=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([l-1])});M.frame=BMRectMake(n,Math.min(this.collectionView.scrollOffset.y,C.frame.origin.y-this.headerHeight),s,this.headerHeight),M.style.zIndex=1,y.push(M)}C.frame.origin.y=Math.max(this.collectionView.scrollOffset.y,C.frame.origin.y),C.style.zIndex=1}y.push(C),i+=this.headerHeight,h=0}if(this._pinsFootersToContentEdge)if(v===f){if(_.frame.origin.y<this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-this.footerHeight)if(f+1<this.collectionView.numberOfSections()){var S=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([f+1])});S.frame=BMRectMake(n,Math.max(this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-this.footerHeight,_.frame.bottom),s,this.footerHeight),y.push(S)}_.frame.origin.y=Math.min(_.frame.origin.y,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-_.frame.size.height),_.style.zIndex=1}else{var C;(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([v])})).frame=BMRectMake(n,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-this.footerHeight,s,this.footerHeight),C.style.zIndex=1,y.push(C)}return y},initialAttributesForPresentedCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.x+=e.frame.size.width/2,e.style={opacity:0,translateZ:0},e)},initialAttributesForPresentedSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x+=i.frame.size.width/2,i.style={opacity:0,translateZ:0},i)},initialAttributesForAppearingCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.x+=e.frame.size.width/2,e.style={opacity:0,translateZ:0},e)},initialAttributesForAppearingSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x+=i.frame.size.width/2,i.style={opacity:0,translateZ:0},i)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.attributesForCellAtIndexPath(t)})),i},initialAttributesForMovingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath})})),i},supplementaryViewsToInsert:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=t;n<e;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return t>0&&0==e&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},supplementaryViewsToDelete:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=e;n<t;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return 0==t&&e>0&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},finalAttributesForDisappearingCellAtIndexPath:function(t){var e,i=this;return this.collectionView.usingOldDataSet((function(){e=i.attributesForCellAtIndexPath(t).copy(),i.collectionView.delegate&&i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath?e=i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath(i.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.x-=e.frame.size.width/2,e.style={opacity:0,translateZ:0})})),e},finalAttributesForDisappearingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy(),o.collectionView.delegate&&o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier?i=o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier(o.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x-=i.frame.size.width/2,i.style={opacity:0,translateZ:0})})),i},copy:function(){var t=new BMCollectionViewTableLayout;return t.rowHeight=this.rowHeight,t.showsHeaders=this.showsHeaders,t.headerHeight=this.headerHeight,t.showsFooters=this.showsFooters,t.footerHeight=this.footerHeight,t.sectionInsets=this.sectionInsets,t.pinsHeadersToContentEdge=this.pinsHeadersToContentEdge,t.pinsFootersToContentEdge=this.pinsFootersToContentEdge,t}}),BMExtend(BMCollectionViewTreeLayout.prototype,BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_rowHeight:44,get rowHeight(){return this._rowHeight},set rowHeight(t){this._rowHeight=t,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_indentWidth:22,get indentWidth(){return this._indentWidth},set indentWidth(t){this._indentWidth=t,this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},_layoutCache:void 0,prepareLayout:function(){if(!this.collectionView.invalidationContext)return this.rebuildLayout()},contentSize:function(){return this._layoutCache.contentSize},shouldInvalidateLayoutForBoundsChange:function(t){return this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge},copy(){let t=new BMCollectionViewTreeLayout;return t._rowHeight=this._rowHeight,t._showsHeaders=this._showsHeaders,t._headerHeight=this._headerHeight,t._pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,t._showsFooters=this._showsFooters,t._footerHeight=this._footerHeight,t._pinsFootersToContentEdge=this._pinsFootersToContentEdge,t._indentWidth=this._indentWidth,t._sectionInsets=this.sectionInsets.copy(),t}});var BMCollectionViewFlowLayoutGravity=Object.freeze({Center:{},Start:{},End:{},Edge:{},Spaced:{},Expand:{}}),BMCollectionViewFlowLayoutAlignment=function(){const t={},e={};return Object.freeze({Top:t,Start:t,Center:{},Bottom:e,End:e,Expand:{}})}(),BMCollectionViewFlowLayoutOrientation=Object.freeze({Horizontal:{},Vertical:{}}),BMCollectionViewFlowLayoutSupplementaryView=BMCollectionViewTableLayoutSupplementaryView;function BMCollectionViewFlowLayout(){}function BMCollectionViewMasonryLayout(){}function BMCollectionViewStackLayout(){}BMCollectionViewFlowLayout.prototype=BMExtend(Object.create(BMCollectionViewLayout.prototype),{get supportsCopying(){return YES},_cellSize:void 0,get cellSize(){return this._cellSize},set cellSize(t){this._cellSize=t,this.invalidateLayout()},_expectedCellSize:void 0,get expectedCellSize(){return this._expectedCellSize},set expectedCellSize(t){this._expectedCellSize=t,this.invalidateLayout()},_rowSpacing:44,get rowSpacing(){return this._rowSpacing},set rowSpacing(t){this._rowSpacing=t,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_gravity:BMCollectionViewFlowLayoutGravity.Spaced,get gravity(){return this._gravity},set gravity(t){this._gravity=t,this.invalidateLayout()},_minimumSpacing:0,get minimumSpacing(){return this._minimumSpacing},set minimumSpacing(t){this._minimumSpacing=t,this.invalidateLayout()},_maximumCellsPerRow:0,get maximumCellsPerRow(){return this._maximumCellsPerRow},set maximumCellsPerRow(t){t<0&&(t=0),this._maximumCellsPerRow=t,this.invalidateLayout()},_leftAlignFinalRow:NO,get leftAlignFinalRow(){return this._leftAlignFinalRow},set leftAlignFinalRow(t){this._leftAlignFinalRow=t,this.invalidateLayout()},_alignment:BMCollectionViewFlowLayoutAlignment.Center,get alignment(){return this._alignment},set alignment(t){this._alignment=t,this.invalidateLayout()},_orientation:BMCollectionViewFlowLayoutOrientation.Vertical,get orientation(){return this._orientation},set orientation(t){this._orientation=t,this.invalidateLayout()},_topPadding:0,get topPadding(){return this._topPadding},set topPadding(t){this._topPadding=t,this.invalidateLayout()},_bottomPadding:0,get bottomPadding(){return this._bottomPadding},set bottomPadding(t){this._bottomPadding=t,this.invalidateLayout()},_contentGravity:BMCollectionViewFlowLayoutAlignment.Center,get contentGravity(){return this._contentGravity},set contentGravity(t){this._contentGravity=t,this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},cachedLayout:void 0,collectionViewWillStartUpdates:function(t){this.prepareLayout(),this._expectedCellSize&&this.cachedLayout.iterator.next({rect:this.collectionView.bounds})},collectionViewDidStartUpdates:function(){this.previousLayout=void 0},prepareLayout:function(){return this._prepareLayoutWithScrollbarOffset(NO)},_prepareLayoutWithScrollbarOffset:function(t){if(this.isChangingBounds)return;if(this._expectedCellSize&&this._collectionView.scrollBarSize)if(this.orientation===BMCollectionViewFlowLayoutOrientation.Horizontal){const t=this._sectionInsets.top+this._sectionInsets.bottom,e=this._topPadding+this._bottomPadding,i=this._collectionView.frame.size.height-t-e-this._collectionView.scrollBarSize;this._collectionView.invalidateMeasuredSizeOfCellsWithBlock((t=>t.height>i))}else{const t=this._sectionInsets.left+this._sectionInsets.right,e=this._collectionView.frame.size.width-t-this.collectionView.scrollBarSize;this._collectionView.invalidateMeasuredSizeOfCellsWithBlock((t=>t.width>e))}let e=this._prepareLayoutWithScrollbarOffsetGenerator(t);const i=this.collectionView.numberOfSections(),o=i?this.collectionView.numberOfObjectsInSectionAtIndex(i-1):0;let n=!this._expectedCellSize||!i||this.cachedLayout?.sections?.length==i&&this.cachedLayout?.sections[i-1].rows?.length==o;if(e.next().done){if(!this.cachedLayout.iterator){if(n){this.cachedLayout.resolvedIndexPath=BMIndexPathMakeWithRow(o-1,{inSectionAtIndex:i-1});const t=this.contentSize();this.cachedLayout.resolvedWidth=t.width,this.cachedLayout.resolvedHeight=t.height}this._layoutIterator||(this._layoutIterator={next(){}}),this.cachedLayout.iterator={next(){}}}}else this._layoutIterator=e,this.cachedLayout.iterator=e},*_prepareLayoutWithScrollbarOffsetGenerator(t,e){if(this.isChangingBounds)return;this.previousLayout=t?this.previousLayout:this.cachedLayout;var i=this.collectionView.frame.size.height,o=this.collectionView.frame.size.width;let n=this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?i:o;if(!this._cellSize||this._expectedCellSize){this.cachedLayout={sections:[]},this._expectedCellSize&&this._copy&&((e=e||{}).targetRect?e.targetRect=e.targetRect.rectByUnionWithRect(this.collectionView.bounds):e.targetRect=this.collectionView.bounds),(T=this.cachedLayout).pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,T.pinsFootersToContentEdge=this._pinsFootersToContentEdge;let G=this._orientation;T.orientation=G;var s=this._sectionInsets.top,a=this._sectionInsets.bottom,r=this._sectionInsets.left,l=this._sectionInsets.right,h=this._topPadding,c=this._bottomPadding,d=this.headerHeight,u=this.footerHeight,p=this._sectionInsets.left;this._sectionInsets.right;var g=G==BMCollectionViewFlowLayoutOrientation.Vertical?h:this.collectionView.frame.size.height-this._sectionInsets.top-this._sectionInsets.bottom-(t?this.collectionView.scrollBarSize:0)-h-c;T.availableHeight=g;var w=G==BMCollectionViewFlowLayoutOrientation.Vertical?this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right-(t?this.collectionView.scrollBarSize:0):p;T.availableWidth=w;var y=this.showsHeaders,m=this.showsFooters,_=(d=this.headerHeight,u=this.footerHeight,this.collectionView.numberOfSections()),f=this._rowSpacing,v=this._minimumSpacing;const Q=[],Z=this;function M(t){if(T.resolvedIndexPath){let t,e=T.resolvedIndexPath.section;-1==T.resolvedIndexPath.row&&e--;for(let i=0;i<=e;i++){let o=Q[i],n=T.sections[i];if(i<e||n.resolved)o.start=G==BMCollectionViewFlowLayoutOrientation.Vertical?n.top:n.left,o.preliminaryEnd=o.end,o.end=G==BMCollectionViewFlowLayoutOrientation.Vertical?n.bottom:n.right,o.preliminaryRows=o.rows,o.rows=n.rows.map((t=>G==BMCollectionViewFlowLayoutOrientation.Vertical?{start:t.top,end:t.bottom,indexStart:t.startIndex,indexEnd:t.endIndex}:{start:t.left,end:t.right,indexStart:t.startIndex,indexEnd:t.endIndex}));else{o.preliminaryRows=o.rows,o.rows=[],o.start=G==BMCollectionViewFlowLayoutOrientation.Vertical?n.top:n.left;let e=o.start,i=0;for(const t of n.rows){let n=G==BMCollectionViewFlowLayoutOrientation.Vertical?{start:t.top,end:t.bottom,indexStart:t.startIndex,indexEnd:t.endIndex}:{start:t.left,end:t.right,indexStart:t.startIndex,indexEnd:t.endIndex};o.rows.push(n),e=n.end,i=n.indexEnd}e+=f;for(const n of o.preliminaryRows)if(n.indexEnd>i){t=e-n.start;break}for(const e of o.preliminaryRows)e.indexEnd>i&&(e.start+=t,e.end+=t)}}for(let i=e+1;i<c;i++){void 0===t&&(t=(G==BMCollectionViewFlowLayoutOrientation.Vertical?T.sections[e].bottom:T.sections[e].right)-Q[e].end);const o=Q[i];o.start+=t,o.end+=t;for(const e of o.row)e.start+=t,e.end+=t}}let e=[];var i=t.origin.y,o=t.bottom,n=t.origin.x,s=t.right,a=G==BMCollectionViewFlowLayoutOrientation.Vertical?o:s;const r=G==BMCollectionViewFlowLayoutOrientation.Vertical?i:n;for(var l,h=0,c=Q.length;h<c&&!((l=Q[h]).end>r);h++);if(h!=c){var d=0;for(const t of l.rows){if(t.end>r)break;d++}for(;YES;){if(!(l=Q[h]))return Z.collectionView.measureSizesOfCellsAtIndexPaths(e);const t=l.rows.length;for(let i=d;i<t;i++){const t=l.rows[i];if(t.start>a)return Z.collectionView.measureSizesOfCellsAtIndexPaths(e);const o=Math.min(t.indexEnd+1,Z.collectionView.numberOfObjectsInSectionAtIndex(h));for(let i=t.indexStart;i<o;i++)e.push(Z.collectionView.indexPathForObjectAtRow(i,{inSectionAtIndex:h}))}h++,d=0}}}if(this._expectedCellSize){T.resolvedHeight=0,T.resolvedWidth=0,T.resolvedIndexPath=BMIndexPathMakeWithRow(-1,{inSectionAtIndex:-1}),T.sectionCount=this.collectionView.numberOfSections();let J=this._maximumCellsPerRow,tt=this._expectedCellSize.width,et=this._expectedCellSize.height,it=G==BMCollectionViewFlowLayoutOrientation.Vertical?tt:et,ot=G==BMCollectionViewFlowLayoutOrientation.Vertical?et:tt,nt=G==BMCollectionViewFlowLayoutOrientation.Vertical?w:g;if(!J){if(T.minimumSpacing){J=0;let st=0;this._gravity===BMCollectionViewFlowLayoutGravity.Spaced&&(st=2*v);do{if(st&&st+it+v>nt)break;J&&(st+=v),st+=it,J++}while(st<nt&&it)}else J=nt/it|0;J=Math.max(J,1)}for(let at=0;at<_;at++){let rt=this.collectionView.numberOfObjectsInSectionAtIndex(at),lt=0|Math.ceil(rt/J),ht=(lt-1)*f;if(d&&(ht+=f),u&&(ht+=f),G==BMCollectionViewFlowLayoutOrientation.Vertical){let ct={top:g,start:g,bottom:g+u+d+ot*lt+ht,end:g+u+d+ot*lt+ht,numberOfObjects:rt,numberOfRows:lt,rows:[]},dt=d?g+d+f:g,ut=0;for(let pt=0;pt<lt;pt++)ct.rows.push({start:dt,end:dt+ot,indexStart:ut,indexEnd:ut+J-1}),dt+=ot+f,ut+=J;if((g=ct.bottom+s+a)>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);Q.push(ct)}else{let gt={left:w,start:w,right:w+ot*lt+ht,end:w+ot*lt+ht,numberOfObjects:rt,numberOfRows:lt,rows:[]},wt=w,yt=0;for(let mt=0;mt<lt;mt++)gt.rows.push({start:wt,end:wt+ot,indexStart:yt,indexEnd:yt+J-1}),wt+=ot+f,yt+=J;if((w=gt.right+r+l)>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);Q.push(gt)}}if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if((g+=this._bottomPadding)>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);T.size=BMSizeMake(this.collectionView.frame.size.width,g),e||(e=yield),e.rect&&M(e.rect),g=h}else{if(w>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);T.size=BMSizeMake(w,this.collectionView.frame.size.height),e||(e=yield),e.rect&&M(e.rect),w=0}}for(var S=0;S<_;S++){var C,b={rows:[]};if(T.sections.push(b),G==BMCollectionViewFlowLayoutOrientation.Vertical?(g+=s,b.top=g):(w+=r,b.left=w),y)if(G==BMCollectionViewFlowLayoutOrientation.Vertical)(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(p,g,w,d),this.pinsHeadersToContentEdge&&(C.style={zIndex:1}),b.headerAttributes=C,g+=d+f;else(C=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(w,h+s,d,g),this.pinsHeadersToContentEdge&&(C.style={zIndex:1}),b.headerAttributes=C,w+=d+f;var B=this.collectionView.numberOfObjectsInSectionAtIndex(S),E=0;let _t=G==BMCollectionViewFlowLayoutOrientation.Vertical?w:g,ft=G==BMCollectionViewFlowLayoutOrientation.Vertical?"width":"height",vt=G==BMCollectionViewFlowLayoutOrientation.Vertical?"height":"width",Mt=G==BMCollectionViewFlowLayoutOrientation.Vertical?"top":"left";for(;E<B;){var V={top:g,left:w,attributes:[],startIndex:E},L=0,x=0;for(this._gravity===BMCollectionViewFlowLayoutGravity.Spaced&&(L=2*v);L<_t||_t<=0;){var A=this.collectionView.indexPathForObjectAtRow(E,{inSectionAtIndex:S}),I=this._expectedCellSize&&this.collectionView.measuredSizeOfCellAtIndexPath(A)||this.collectionView.delegate.collectionViewSizeForCellAtIndexPath(this.collectionView,A);if(I[ft]+L+v>_t&&V.attributes.length)break;var P=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(A);if(P._requireMeasurement=YES,G==BMCollectionViewFlowLayoutOrientation.Vertical?P.frame=BMRectMake(L,g,I.width,I.height):P.frame=BMRectMake(w,L,I.width,I.height),x<I[vt]&&(x=I[vt]),V.attributes.push(P),L+=I[ft],V.attributes.length>1&&(L+=v),E++,V[Mt]+x>n&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if(E>=B||0==w)break}else if(E>=B||0==g)break;if(this._maximumCellsPerRow&&V.attributes.length==this._maximumCellsPerRow)break}if(V.attributes.length&&(G==BMCollectionViewFlowLayoutOrientation.Vertical?(this._reflowRow(V,{forLength:w,breadth:x,withOccupiedLength:L,spacing:v}),g+=x,V.bottom=g,V.endIndex=E-1,b.rows.push(V),g+=f):(this._reflowRow(V,{forLength:g,breadth:x,withOccupiedLength:L,spacing:v}),w+=x,V.right=w,V.endIndex=E-1,b.rows.push(V),w+=f)),e){if(m&&this.pinsFootersToContentEdge)if(G==BMCollectionViewFlowLayoutOrientation.Vertical){let St=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])});St.frame=BMRectMake(p,g,w,u),St.style={zIndex:1},b.footerAttributes=St}else{let Ct=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])});Ct.frame=BMRectMake(w,h+s,u,g),this.pinsFootersToContentEdge&&(Ct.style={zIndex:1}),b.footerAttributes=Ct}if(e.indexPath){let bt=e.indexPath;(bt.section<S||bt.section==S&&bt.row<V.endIndex)&&(T.resolvedHeight=g,T.resolvedWidth=w,T.resolvedIndexPath=V.attributes[V.attributes.length-1].indexPath,G==BMCollectionViewFlowLayoutOrientation.Vertical?g>T.size.height&&(T.size.height=g+f+a+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout height has changed to "+g)):w>T.size.width&&(T.size.width=w+f+l+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout width has changed to "+w)),b.bottom=g,b.right=w,(e=yield).rect&&M(e.rect))}if(e.rect){g>e.rect.bottom&&(T.resolvedHeight=g,T.resolvedWidth=w,T.resolvedIndexPath=V.attributes[V.attributes.length-1].indexPath,G==BMCollectionViewFlowLayoutOrientation.Vertical?g>T.size.height&&(T.size.height=g+f+a+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout height has changed to "+g)):w>T.size.width&&(T.size.width=w+f+l+1,BM_AUTOMATIC_CELL_SIZE_MESSAGES&&console.log("Layout width has changed to "+w)),b.bottom=g,b.right=w,(e=yield).rect&&M(e.rect))}}}var W;if(b.resolved,G==BMCollectionViewFlowLayoutOrientation.Vertical?g-=f:w-=f,m)if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if(g+=f,(W=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(p,g,w,u),this.pinsFootersToContentEdge&&(W.style={zIndex:1}),b.footerAttributes=W,(g+=u)>i&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES)}else if(w+=f,(W=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([S])})).frame=BMRectMake(w,h+s,u,g),this.pinsFootersToContentEdge&&(W.style={zIndex:1}),b.footerAttributes=W,(w+=u)>o&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if(b.bottom=g,(g+=a)>i&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES)}else if(b.right=w,(w+=l)>o&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES)}if(G==BMCollectionViewFlowLayoutOrientation.Vertical){if((g+=c)>i&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(g<this.collectionView.frame.size.height){let Bt=0;this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?Bt=(this.collectionView.frame.size.height-g)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&(Bt=this.collectionView.frame.size.height-g);let Et=0;if(0!=Bt||this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let Vt=T.sections.length;for(let Lt=0;Lt<Vt;Lt++){let xt=T.sections[Lt];xt.top+=Bt,xt.bottom+=Bt;let At=xt.rows.length;for(let It=0;It<At;It++){let Pt=xt.rows[It];Pt.top+=Bt,Pt.bottom+=Bt,Et+=Pt.bottom-Pt.top;for(let Wt=0;Wt<Pt.attributes.length;Wt++)Pt.attributes[Wt].frame.origin.y+=Bt}xt.headerAttributes&&(xt.headerAttributes.frame.origin.y+=Bt),xt.footerAttributes&&(xt.footerAttributes.frame.origin.y+=Bt)}}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){const Tt=g-Et,zt=(this.collectionView.frame.size.height-Tt)/Et;let kt=0;for(const Nt of this.cachedLayout.sections){Nt.top+=kt,Nt.headerAttributes&&(Nt.headerAttributes.frame.origin.y+=kt);for(const Ot of Nt.rows){const Ft=Ot.bottom-Ot.top;Ot.top+=kt;const Dt=Ft*zt|0;for(const Yt of Ot.attributes)Yt.frame.origin.y+=kt,Yt.frame.size.height=Yt.frame.size.height*zt|0;kt+=Dt-Ft,Ot.bottom+=kt}Nt.bottom+=kt,Nt.footerAttributes&&(Nt.footerAttributes.frame.origin.y+=kt)}}}T.size=BMSizeMake(this.collectionView.frame.size.width,Math.max(g,this.collectionView.frame.size.height))}else{if(w>o&&this.collectionView.scrollBarSize&&!t)return e?yield*this._prepareLayoutWithScrollbarOffsetGenerator(YES,e):this._prepareLayoutWithScrollbarOffset(YES);if(w<this.collectionView.frame.size.width){let Rt=0;this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?Rt=(this.collectionView.frame.size.width-w)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&(Rt=this.collectionView.frame.size.width-w);let Ht=0;if(0!=Rt||this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let qt=T.sections.length;for(let Kt=0;Kt<qt;Kt++){let Xt=T.sections[Kt];Xt.left+=Rt,Xt.right+=Rt;let jt=Xt.rows.length;for(let Ut=0;Ut<jt;Ut++){let $t=Xt.rows[Ut];$t.left+=Rt,$t.right+=Rt,Ht+=$t.right-$t.left;for(let Gt=0;Gt<$t.attributes.length;Gt++)$t.attributes[Gt].frame.origin.x+=Rt}Xt.headerAttributes&&(Xt.headerAttributes.frame.origin.x+=Rt),Xt.footerAttributes&&(Xt.footerAttributes.frame.origin.x+=Rt)}}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){const Qt=w-Ht,Zt=(this.collectionView.frame.size.width-Qt)/Ht;let Jt=0;for(const te of this.cachedLayout.sections){te.left+=Jt,te.headerAttributes&&(te.headerAttributes.frame.origin.x+=Jt);for(const ee of te.rows){const ie=ee.right-ee.left;ee.left+=Jt;const oe=ie*Zt|0;for(const ne of ee.attributes)ne.frame.origin.x+=Jt,ne.frame.size.width=ne.frame.size.width*Zt|0;Jt+=oe-ie,ee.right+=Jt}te.right+=Jt,te.footerAttributes&&(te.footerAttributes.frame.origin.x+=Jt)}}}T.size=BMSizeMake(Math.max(w,this.collectionView.frame.size.width),this.collectionView.frame.size.height)}this._expectedCellSize&&e&&this.invalidateContentSize()}else{this.cachedLayout={sections:[],prototypeRows:[]};var T=this.cachedLayout;let se=this._orientation;T.orientation=se,T.sectionInsets=this.sectionInsets,T.rowSpacing=this.rowSpacing,T.showsHeaders=this.showsHeaders,T.showsFooters=this.showsFooters,T.headerHeight=this.headerHeight,T.footerHeight=this.footerHeight,T.minimumSpacing=this.minimumSpacing,T.topPadding=this.topPadding,T.bottomPadding=this.bottomPadding;let ae=this.topPadding,re=this.bottomPadding;T.pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,T.pinsFootersToContentEdge=this._pinsFootersToContentEdge;let le=this.cellSize.width,he=this.cellSize.height,ce=se==BMCollectionViewFlowLayoutOrientation.Vertical?le:he,de=se==BMCollectionViewFlowLayoutOrientation.Vertical?he:le,ue=de;T.cellWidth=le,T.rowHeight=he,T.rowBreadth=de;f=this.rowSpacing,v=this.minimumSpacing,g=se==BMCollectionViewFlowLayoutOrientation.Vertical?ae:this.collectionView.frame.size.height-this._sectionInsets.top-this._sectionInsets.bottom-(t?this.collectionView.scrollBarSize:0)-ae-re;T.availableHeight=g;w=se==BMCollectionViewFlowLayoutOrientation.Vertical?this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right-(t?this.collectionView.scrollBarSize:0):p;T.availableWidth=w;var z=se==BMCollectionViewFlowLayoutOrientation.Vertical?w:g,k=this._maximumCellsPerRow;if(!k){if(T.minimumSpacing){k=0;var N=0;this._gravity===BMCollectionViewFlowLayoutGravity.Spaced&&(N=2*v);do{if(N&&N+ce+v>z)break;k&&(N+=v),N+=ce,k++}while(N<z&&ce)}else k=z/ce|0;k=Math.max(k,1)}T.numberOfColumns=k;for(S=0;S<k;S++){for(var O={attributes:[]},F=this.leftAlignFinalRow?k-1:S,D=ce*(F+1)+v*F,Y=0;Y<=F;Y++)O.attributes.push({frame:BMRectMake(0,0,le,he)});this._reflowRow(O,{forLength:z,breadth:de,withOccupiedLength:D,spacing:v}),T.prototypeRows.push(O)}var R=this.collectionView.numberOfSections();s=this._sectionInsets.top,a=this._sectionInsets.bottom;let pe=this._sectionInsets.left,ge=this._sectionInsets.right;d=this.headerHeight,u=this.footerHeight;if(se==BMCollectionViewFlowLayoutOrientation.Vertical){let we=s+this._topPadding;for(S=0;S<R;S++){var H=this.collectionView.numberOfObjectsInSectionAtIndex(S),q=((j=0|Math.ceil(H/k))-1)*f;d&&(q+=f),u&&(q+=f);let ye={top:we,bottom:we+u+d+ue*j+q,numberOfObjects:H,numberOfRows:j};if(T.sections.push(ye),we=ye.bottom+s+a,we>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES)}if(we+=this._bottomPadding,we>i&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);if(we<this.collectionView.frame.size.height){var K=0;if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?K=(this.collectionView.frame.size.height-we)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&(K=this.collectionView.frame.size.height-we),0!=K){var X=T.sections.length;for(S=0;S<X;S++){(b=T.sections[S]).top+=K,b.bottom+=K}}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let me=0;for(const Me of T.sections)me+=Me.numberOfRows*ue;const _e=we-me,fe=(this.collectionView.frame.size.height-_e)/me;for(const Se of T.prototypeRows)for(const Ce of Se.attributes)Ce.frame.size.height=Ce.frame.size.height*fe|0;let ve=0;for(const be of T.sections){be.top+=ve;const Be=be.numberOfRows*ue;ve+=(Be*fe|0)-Be,be.bottom+=ve}T.rowHeight=T.rowHeight*fe|0,T.rowBreadth=T.rowBreadth*fe|0}}}else{let Ee=pe;for(S=0;S<R;S++){H=this.collectionView.numberOfObjectsInSectionAtIndex(S);var j,U=((j=0|Math.ceil(H/k))-1)*f;d&&(U+=f),u&&(U+=f);let Ve={left:Ee,right:Ee+de*j+U,numberOfObjects:H,numberOfRows:j};if(T.sections.push(Ve),Ee=Ve.right+pe+ge,Ee>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES)}if(Ee>o&&this.collectionView.scrollBarSize&&!t)return this._prepareLayoutWithScrollbarOffset(YES);if(Ee<this.collectionView.frame.size.width){var $=0;if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Center?$=(this.collectionView.frame.size.width-Ee)/2|0:this._contentGravity===BMCollectionViewFlowLayoutAlignment.Bottom&&($=this.collectionView.frame.size.width-Ee),0!=$)for(X=T.sections.length,S=0;S<X;S++){(b=T.sections[S]).left+=$,b.right+=$}if(this._contentGravity===BMCollectionViewFlowLayoutAlignment.Expand){let Le=0;for(const Pe of T.sections)Le+=Pe.numberOfRows*ue;const xe=Ee-Le,Ae=(this.collectionView.frame.size.width-xe)/Le;for(const We of T.prototypeRows)for(const Te of We.attributes)Te.frame.size.width=Te.frame.size.width*Ae|0;let Ie=0;for(const ze of T.sections){ze.left+=Ie;const ke=ze.numberOfRows*ue;Ie+=(ke*Ae|0)-ke,ze.right+=Ie}T.cellWidth=T.cellWidth*Ae|0,T.rowBreadth=T.rowBreadth*Ae|0}}}}},constraintsForMeasuringCell(t,{atIndexPath:e}){return[BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,relatedBy:BMLayoutConstraintRelation.LessThanOrEquals,constant:this.collectionView.frame.size.width-this.sectionInsets.left-this.sectionInsets.right})]},reflowRow:function(t,e){var i=e.forWidth,o=e.withOccupiedWidth,n=e.height,s=e.spacing,a=s*(t.attributes.length-1),r=o-a,l=this._gravity,h=this._alignment,c=t.attributes.length,d=l==BMCollectionViewFlowLayoutGravity.Expand?(i-a)/r:1,u=0;if(l==BMCollectionViewFlowLayoutGravity.Expand){for(var p=0,g=0;g<c;g++)p+=t.attributes[g].frame.size.width*d|0;u=(i-a|0)%(0|p)}var w=0,y=this._sectionInsets.left;l===BMCollectionViewFlowLayoutGravity.Center?y=y+(i-o)/2|0:l===BMCollectionViewFlowLayoutGravity.End?y=y+i-o|0:l===BMCollectionViewFlowLayoutGravity.Edge?w=i-((s=(i-r)/(c-1)|0)*(c-1)+r):l===BMCollectionViewFlowLayoutGravity.Spaced&&(w=i-((s=(i-r)/(c+1)|0)*(c+1)+r),y+=s);for(g=0;g<c;g++){var m=t.attributes[g];m.frame.origin.x=y,m.frame.size.width*=d,m.frame.size.width=0|m.frame.size.width,u&&(m.frame.size.width+=1,u--),y+=s+m.frame.size.width,w&&(y+=1,w--),h===BMCollectionViewFlowLayoutAlignment.Center?m.frame.origin.y+=(n-m.frame.size.height)/2|0:h===BMCollectionViewFlowLayoutAlignment.Bottom?m.frame.origin.y+=n-m.frame.size.height:h===BMCollectionViewFlowLayoutAlignment.Expand&&(m.frame.size.height=n)}},_reflowRow:function(t,{forLength:e,breadth:i,withOccupiedLength:o,spacing:n}){var s=n*(t.attributes.length-1),a=o-s,r=this._gravity,l=this._alignment;let h=this._orientation,c=h==BMCollectionViewFlowLayoutOrientation.Vertical?"width":"height",d=h==BMCollectionViewFlowLayoutOrientation.Vertical?"height":"width",u=h==BMCollectionViewFlowLayoutOrientation.Vertical?"x":"y",p=h==BMCollectionViewFlowLayoutOrientation.Vertical?"y":"x";var g=t.attributes.length,w=r==BMCollectionViewFlowLayoutGravity.Expand?(e-s)/a:1,y=0;if(r==BMCollectionViewFlowLayoutGravity.Expand){for(var m=0,_=0;_<g;_++)m+=t.attributes[_].frame.size[c]*w|0;y=(e-s|0)%(0|m)}var f=0,v=h==BMCollectionViewFlowLayoutOrientation.Vertical?this._sectionInsets.left:this._sectionInsets.top+this.topPadding;r===BMCollectionViewFlowLayoutGravity.Center?v=v+(e-o)/2|0:r===BMCollectionViewFlowLayoutGravity.End?v=v+e-o|0:r===BMCollectionViewFlowLayoutGravity.Edge?f=e-((n=(e-a)/(g-1)|0)*(g-1)+a):r===BMCollectionViewFlowLayoutGravity.Spaced&&(f=e-((n=(e-a)/(g+1)|0)*(g+1)+a),v+=n);for(_=0;_<g;_++){var M=t.attributes[_];M.frame.origin[u]=v,M.frame.size[c]*=w,M.frame.size[c]=0|M.frame.size[c],y&&(M.frame.size[c]+=1,y--),v+=n+M.frame.size[c],f&&(v+=1,f--),l===BMCollectionViewFlowLayoutAlignment.Center?M.frame.origin[p]+=(i-M.frame.size[d])/2|0:l===BMCollectionViewFlowLayoutAlignment.Bottom?M.frame.origin[p]+=i-M.frame.size[d]:l===BMCollectionViewFlowLayoutAlignment.Expand&&(M.frame.size[d]=i)}},contentSize:function(){return!this._cellSize||this._expectedCellSize?this.cachedLayout.size:this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?this.cachedLayout.sections.length?BMSizeMake(this.collectionView.frame.size.width,Math.max(this.cachedLayout.sections[this.cachedLayout.sections.length-1].bottom+this._bottomPadding+this.sectionInsets.bottom,this.collectionView.frame.size.height)):this.collectionView.frame.size.copy():this.cachedLayout.sections.length?BMSizeMake(Math.max(this.cachedLayout.sections[this.cachedLayout.sections.length-1].right+this.sectionInsets.right,this.collectionView.frame.size.width),this.collectionView.frame.size.height):this.collectionView.frame.size.copy()},shouldInvalidateLayoutForFrameChange(t,{fromFrame:e}){return e&&e.size.width<t.size.width?this.collectionView.invalidateMeasuredSizeOfCells():this.collectionView.invalidateMeasuredSizeOfCellsWithBlock((t=>t.width>=this.cachedLayout.availableWidth)),YES},shouldInvalidateLayoutForBoundsChange:function(t){var e=this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge;return this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?this._expectedCellSize&&t.bottom>this.cachedLayout.resolvedHeight&&(this._layoutIterator.next({rect:t}),e=YES):this._expectedCellSize&&t.right>this.cachedLayout.resolvedWidth&&(this._layoutIterator.next({rect:t}),e=YES),e&&(this.isChangingBounds=YES),e},didInvalidateLayoutForBoundsChange:function(){this.isChangingBounds=NO},attributesForCellAtIndexPath:function(t){if(this._expectedCellSize&&(this.cachedLayout.resolvedIndexPath.section<t.section||this.cachedLayout.resolvedIndexPath.section==t.section&&this.cachedLayout.resolvedIndexPath.row<t.row)){const e=this.cachedLayout.resolvedHeight;this._layoutIterator.next({indexPath:t}),e!=this.cachedLayout.resolvedHeight&&this.invalidateContentSize()}return!this._cellSize||this._expectedCellSize?this.cachedAttributesForCellAtIndexPath(t):this.computedAttributesForCellAtIndexPath(t)},cachedAttributesForCellAtIndexPath:function(t,e){for(var i=(e&&e.usingCache||this.cachedLayout).sections[t.section].rows,o=t.row,n=i.length,s=0;s<n;s++){var a=i[s];if(o>=a.startIndex&&o<=a.endIndex)return a.attributes[o-a.startIndex]}throw"Unable to find the cached attributes for the cell at the given index path"},computedAttributesForCellAtIndexPath:function(t,e){var i,o=e&&e.usingCache||this.cachedLayout,n=t.section,s=o.sections[n],a=o.numberOfColumns,r=s.numberOfObjects,l=t.row,h=l/a|0,c=l%a;if(h==(r/a|0))var d=r%a||a,u=o.prototypeRows[d-1];else u=o.prototypeRows[a-1];if(o.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){let e=s.top;o.showsHeaders&&(e+=o.headerHeight+o.rowSpacing),e+=h*(o.rowHeight+o.rowSpacing),(i=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=u.attributes[c].frame.copy(),i.frame.origin.y=e}else{let e=s.left;o.showsHeaders&&(e+=o.headerHeight+o.rowSpacing),e+=h*(o.rowBreadth+o.rowSpacing),(i=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=u.attributes[c].frame.copy(),i.frame.origin.x=e}return i},attributesForSupplementaryViewWithIdentifier:function(t,e){if(t===BMCollectionViewTableLayoutSupplementaryView.Empty){var i=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return i.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),i}return this._expectedCellSize&&(this.cachedLayout.resolvedIndexPath.section<e.atIndexPath.section||this.cachedLayout.resolvedIndexPath.section==e.atIndexPath.section&&t==BMCollectionViewFlowLayoutSupplementaryView.Footer)&&(e.atIndexPath.section==this.collectionView.numberOfSections()-1?this._layoutIterator.next({indexPath:this.collectionView.indexPathForObjectAtRow(this.collectionView.numberOfObjectsInSectionAtIndex(e.atIndexPath.section)-1,{inSectionAtIndex:e.atIndexPath.section})}):this._layoutIterator.next({indexPath:this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e.atIndexPath.section+1})})),!this._cellSize||this._expectedCellSize?this.cachedAttributesForSupplementaryViewWithIdentifier(t,e):this.computedAttributesForSupplementaryViewWithIdentifier(t,e)},cachedAttributesForSupplementaryViewWithIdentifier:function(t,e){var i=e&&e.usingCache||this.cachedLayout,o=e.atIndexPath.section;if(!(o>=i.sections.length))return t===BMCollectionViewFlowLayoutSupplementaryView.Header?i.sections[o].headerAttributes:t===BMCollectionViewFlowLayoutSupplementaryView.Footer?i.sections[o].footerAttributes:void 0},computedAttributesForSupplementaryViewWithIdentifier:function(t,e){var i=e&&e.usingCache||this.cachedLayout,o=e.atIndexPath.section;if(!(o>=i.sections.length)){var n=i.sections[o],s=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath});return t===BMCollectionViewFlowLayoutSupplementaryView.Header?(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?s.frame=BMRectMake(i.sectionInsets.left,n.top,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):s.frame=BMRectMake(n.left,i.sectionInsets.top+i.topPadding,i.headderHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),s):t===BMCollectionViewFlowLayoutSupplementaryView.Footer?(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?s.frame=BMRectMake(i.sectionInsets.left,n.bottom-i.footerHeight,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):s.frame=BMRectMake(n.right-i.footerHeight,i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),s):void 0}},attributesForElementsInRect:function(t){if(this._expectedCellSize&&(this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?this.cachedLayout.resolvedHeight<t.bottom&&(this._layoutIterator.next({rect:t}),this.invalidateContentSize()):this.cachedLayout.resolvedWidth<t.right&&(this._layoutIterator.next({rect:t}),this.invalidateContentSize())),0==this.collectionView.numberOfSections()){var e=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return e.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),[e]}return!this._cellSize||this._expectedCellSize?this.cachedAttributesForElementsInRect(t):this.computedAttributesForElementsInRect(t)},cachedAttributesForElementsInRect:function(t,e){for(var i=e&&e.usingCache||this.cachedLayout,o=[],n=t.origin.y,s=t.bottom,a=t.origin.x,r=t.right,l=0,h=this._expectedCellSize?i.sectionCount:i.sections.length;l<h;l++)if(_=i.sections[l],i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(_.bottom>n)break}else if(_.right>a)break;if(l==h)return o;var c=-1;if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(!_.headerAttributes||_.headerAttributes.frame.bottom<n){c=0;for(var d=(f=_.rows).length,u=0;u<d;u++)if(f[u].bottom>n){c=u;break}c=u}}else if(!_.headerAttributes||_.headerAttributes.frame.right<a){c=0;for(d=(f=_.rows).length,u=0;u<d;u++)if(f[u].right>a){c=u;break}c=u}var p,g,w=_,y=_;if(i.pinsHeadersToContentEdge&&-1!=c){var m=_.headerAttributes.copy();i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?m.frame.origin.y=this.collectionView.scrollOffset.y:m.frame.origin.x=this.collectionView.scrollOffset.x,o.push(m)}try{for(;l<h;l++){var _;if(!(_=i.sections[l])&&this._expectedCellSize)return o;var f;for(d=(f=_.rows).length;c<=d;c++)if(-1==c){if(_.headerAttributes){m=_.headerAttributes;if(i.pinsHeadersToContentEdge&&_===w&&(m=m.copy(),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?m.frame.origin.y=Math.max(this.collectionView.scrollOffset.y,m.frame.origin.y):m.frame.origin.x=Math.max(this.collectionView.scrollOffset.x,m.frame.origin.x)),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(m.frame.origin.y>s)return o}else if(m.frame.origin.x>r)return o;if(o.push(m),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(m.frame.bottom>s)return o}else if(m.frame.right>r)return o}y=_}else if(c==d){if(_.footerAttributes){if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(_.footerAttributes.frame.origin.y>s)return o}else if(_.footerAttributes.frame.origin.x>r)return o;var v=_.footerAttributes;if(this.collectionView._pinsFootersToContentEdge&&(p=v=v.copy(),g=_),o.push(v),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(_.footerAttributes.frame.origin.y>s)return o}else if(_.footerAttributes.frame.origin.x>r)return o}}else{var M=f[c];if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(M.top>s)return o}else if(M.left>r)return o;for(u=0;u<M.attributes.length;u++)o.push(M.attributes[u]);if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(M.bottom>s)return o}else if(M.right>r)return o}c=-1}}finally{if(i.pinsFootersToContentEdge&&this._showsFooters)g===y?v=p:(v=y.footerAttributes.copy(),o.push(v)),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?v.frame.origin.y=Math.min(v.frame.origin.y,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-v.frame.size.height):v.frame.origin.x=Math.min(v.frame.origin.x,this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-v.frame.size.width)}return o},computedAttributesForElementsInRect:function(t,e){for(var i=e&&e.usingCache||this.cachedLayout,o=[],n=t.origin.y,s=t.bottom,a=t.origin.x,r=t.right,l=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?s:r,h=0,c=i.sections.length;h<c;h++)if(V=i.sections[h],i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical){if(V.bottom>n)break}else if(V.right>a)break;if(h==c)return o;var d,u,p=-1,g=V.top,w=V.left,y=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?g:w,m=V,_=V;let f=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"top":"left",v=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"y":"x",M=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"height":"width",S=i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?n:a;if(!i.showsHeaders||V[f]+i.headerHeight<S){p=0;var C=0|Math.ceil(V.numberOfObjects/i.numberOfColumns);y=i.showsHeaders?V[f]+i.headerHeight+i.rowSpacing:V[f];let t=NO;for(var b=0;b<C;b++){if(p=b,y+i.rowBreadth>S){t=YES;break}y+=i.rowBreadth+i.rowSpacing}t||(p=b)}if(i.pinsHeadersToContentEdge&&p>-1&&i.showsHeaders){var B=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([h])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?B.frame=BMRectMake(i.sectionInsets.left,this.collectionView.scrollOffset.y,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):B.frame=BMRectMake(this.collectionView.scrollOffset.x,i.sectionInsets.top+i.topPadding,i.headerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),B.style.zIndex=1,o.push(B)}var E=i.numberOfColumns;try{for(;h<c;h++){var V=i.sections[h];for(C=0|Math.ceil(V.numberOfObjects/E);p<=C;p++)if(-1==p){if(i.showsHeaders){if(y>l)return o;B=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([h])});if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?B.frame=BMRectMake(i.sectionInsets.left,y,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):B.frame=BMRectMake(y,i.sectionInsets.top+i.topPadding,i.headerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),V===m&&i.pinsHeadersToContentEdge){if(B.frame.origin[v]>this.collectionView.scrollOffset[v])if(i.sections[h-1]){var L=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([h-1])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?L.frame=BMRectMake(i.sectionInsets.left,Math.min(this.collectionView.scrollOffset.y,B.frame.origin.y-i.headerHeight),this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.headerHeight):L.frame=BMRectMake(Math.min(this.collectionView.scrollOffset[v],B.frame.origin[v]-i.headerHeight),i.sectionInsets.top+i.topPadding,i.headerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),o.push(L)}B.frame.origin[v]=Math.max(B.frame.origin[v],this.collectionView.scrollOffset[v]),B.style.zIndex=1}y+=i.headerHeight+i.rowSpacing,o.push(B)}_=V}else if(p==C){if(i.showsFooters){if(y>l)return o;var x=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([h])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?x.frame=BMRectMake(i.sectionInsets.left,y,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):x.frame=BMRectMake(y,i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),d=x,u=V,i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?y+=i.footerHeight+i.sectionInsets.top+i.sectionInsets.bottom:y+=i.footerHeight+i.sectionInsets.left+i.sectionInsets.right,o.push(x)}else if(i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?y+=i.sectionInsets.top+i.sectionInsets.bottom:y+=i.sectionInsets.left+i.sectionInsets.right,y>l)return o}else{if(y>l)return o;var A,I=p*E,P=E;p==C-1?(P=V.numberOfObjects%E||E,A=i.prototypeRows[P-1]):A=i.prototypeRows[E-1];for(b=0;b<P;b++){var W=I+b,T=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(this.collectionView.indexPathForObjectAtRow(W,{inSectionAtIndex:h}));T.frame=A.attributes[b].frame.copy(),T.frame.origin[v]=y,o.push(T)}y+=i.rowBreadth,(i.showsFooters||p<C-1)&&(y+=i.rowSpacing)}p=-1}}finally{if(i.pinsFootersToContentEdge&&i.showsFooters&&i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical)if(u===_){if((x=d).frame.origin[v]<this.collectionView.scrollOffset[v]+this.collectionView.frame.size[M]-i.footerHeight)if(i.sections[x.indexPath.section+1]){var z=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([x.indexPath.section+1])});i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?z.frame=BMRectMake(i.sectionInsets.left,Math.max(this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-i.footerHeight,x.frame.bottom),this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):z.frame=BMRectMake(Math.max(this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-i.footerHeight,x.frame.right),i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),o.push(z)}x.frame.origin[v]=Math.min(x.frame.origin[v],this.collectionView.scrollOffset[v]+this.collectionView.frame.size[M]-x.frame.size[M]),x.style.zIndex=1}else x=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([h])}),i.orientation==BMCollectionViewFlowLayoutOrientation.Vertical?x.frame=BMRectMake(i.sectionInsets.left,this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-i.footerHeight,this.collectionView.frame.size.width-i.sectionInsets.left-i.sectionInsets.right,i.footerHeight):x.frame=BMRectMake(this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-i.footerHeight,i.sectionInsets.top+i.topPadding,i.footerHeight,this.collectionView.frame.size.height-i.sectionInsets.top-i.sectionInsets.bottom-i.topPadding-i.bottomPadding),x.style.zIndex=1,o.push(x)}return o},initialAttributesForPresentedCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.y+=this.collectionView.frame.size.height/2,e.style={rotateZ:"15deg",opacity:0,translateZ:0},e)},initialAttributesForPresentedSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForPresentedSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.frame.origin.x+=i.frame.size.width/2,i.style={opacity:0,translateZ:0},i)},initialAttributesForAppearingCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e}):(e.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5},e)},initialAttributesForAppearingSupplementaryViewWithIdentifier:function(t,e){var i=this.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}).copy();return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier?this.collectionView.delegate.collectionViewInitialAttributesForAppearingSupplementaryViewWithIdentifier(this.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):(i.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5},i)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i,o=this;return o._expectedCellSize&&(o.previousLayout.resolvedIndexPath.section<t.section||o.previousLayout.resolvedIndexPath.section==t.section&&o.previousLayout.resolvedIndexPath.row<t.row)&&o.collectionView.usingOldDataSet((function(){o.previousLayout.iterator.next({indexPath:t})})),this.collectionView.usingOldDataSet((function(){o._cellSize&&!o._expectedCellSize?i=o.computedAttributesForCellAtIndexPath(t,{usingCache:o.previousLayout}):(i=o.cachedAttributesForCellAtIndexPath(t,{usingCache:o.previousLayout}))||((i=e.withTargetAttributes.copy()).style=Object.assign(i.style,{opacity:0}))})),i},initialAttributesForMovingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return o._expectedCellSize&&(o.cachedLayout.resolvedIndexPath.section<e.atIndexPath.section||o.cachedLayout.resolvedIndexPath.section==e.atIndexPath.section&&t==BMCollectionViewFlowLayoutSupplementaryView.Footer)&&(e.atIndexPath.section==o.collectionView.numberOfSections()-1?o._layoutIterator.next({indexPath:o.collectionView.indexPathForObjectAtRow(o.collectionView.numberOfObjectsInSectionAtIndex(e.atIndexPath.section)-1,{inSectionAtIndex:e.atIndexPath.section})}):o._layoutIterator.next({indexPath:o.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:e.atIndexPath.section+1})})),this.collectionView.usingOldDataSet((function(){t===BMCollectionViewTableLayoutSupplementaryView.Empty?i=o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}):o._cellSize&&!o._expectedCellSize?i=o.computedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}):(i=o.cachedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}))||((i=e.withTargetAttributes.copy()).style=Object.assign(i.style,{opacity:0}))})),i},supplementaryViewsToInsert:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=t;n<e;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return t>0&&0==e&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},supplementaryViewsToDelete:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=e;n<t;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return 0==t&&e>0&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},finalAttributesForDisappearingCellAtIndexPath:function(t){var e,i=this;return this.collectionView.usingOldDataSet((function(){e=i._cellSize&&!i._expectedCellSize?i.computedAttributesForCellAtIndexPath(t,{usingCache:i.previousLayout}):i.cachedAttributesForCellAtIndexPath(t,{usingCache:i.previousLayout}).copy(),i.collectionView.delegate&&i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath?e=i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath(i.collectionView,t,{withTargetAttributes:e}):e.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5}})),e},finalAttributesForDisappearingSupplementaryViewWithIdentifier:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=t===BMCollectionViewTableLayoutSupplementaryView.Empty?o.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath}):o._cellSize&&!o._expectedCellSize?o.computedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}):o.cachedAttributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath,usingCache:o.previousLayout}),o.collectionView.delegate&&o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier?i=o.collectionView.delegate.collectionViewFinalAttributesForDisappearingSupplementaryViewWithIdentifier(o.collectionView,t,{atIndexPath:e.atIndexPath,withTargetAttributes:i}):i.style={opacity:0,translateZ:0,scaleX:.5,scaleY:.5}})),i},indexPathToTheLeftOfIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?!this._cellSize||this._expectedCellSize?this._cachedIndexPathAboveIndexPath(t):this._computedIndexPathAboveIndexPath(t):BMCollectionViewLayout.prototype.indexPathToTheLeftOfIndexPath.apply(this,arguments)},indexPathAboveIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?BMCollectionViewLayout.prototype.indexPathToTheLeftOfIndexPath.apply(this,arguments):!this._cellSize||this._expectedCellSize?this._cachedIndexPathAboveIndexPath(t):this._computedIndexPathAboveIndexPath(t)},indexPathToTheRightOfIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?!this._cellSize||this._expectedCellSize?this._cachedIndexPathBelowIndexPath(t):this._computedIndexPathBelowIndexPath(t):BMCollectionViewLayout.prototype.indexPathToTheRightOfIndexPath.apply(this,arguments)},indexPathBelowIndexPath(t){return this._orientation==BMCollectionViewFlowLayoutOrientation.Horizontal?BMCollectionViewLayout.prototype.indexPathToTheRightOfIndexPath.apply(this,arguments):!this._cellSize||this._expectedCellSize?this._cachedIndexPathBelowIndexPath(t):this._computedIndexPathBelowIndexPath(t)},_cachedIndexPathAboveIndexPath(t){const e=t.section,i=t.row,o=this.cachedLayout.sections[e];if(!o)return t;const n=o.rows;let s=0;const a=n.length;for(;s<a;s++){const t=n[s];if(t.startIndex<=i&&t.endIndex>=i)break}const r=n[s].attributes.find((t=>t.indexPath.row==i)),l=this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"x":"y",h=r.frame.center[l];let c;if(s>0){c=n[s-1]}else{let t=e-1;for(;t>=0;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){c=this.cachedLayout.sections[t]?.rows[(this.cachedLayout.sections[t]?.rows.length||0)-1];break}t--}}if(c){let t=Number.MAX_SAFE_INTEGER,e=-1;for(let i=0;i<c.attributes.length;i++){const o=c.attributes[i],n=Math.abs(o.frame.center[l]-h);n<t&&(t=n,e=i)}return c.attributes[e].indexPath}return t},_computedIndexPathAboveIndexPath(t){const e=this.cachedLayout;var i=t.section;const o=e.numberOfColumns;var n=t.row;const s=n/o|0,a=n%o;let r;if(s>0)r=s-1;else{let t=i-1;for(;t>=0;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){r=e.sections[t].numberOfRows-1,i=t;break}t--}}if("number"!=typeof r)return t;const l=o*r,h=this.collectionView.numberOfObjectsInSectionAtIndex(i);if(r==(h/o|0)){var c=h%o||o;return this.collectionView.indexPathForObjectAtRow(l+Math.min(c,a),{inSectionAtIndex:i})}return this.collectionView.indexPathForObjectAtRow(l+a,{inSectionAtIndex:i})},_cachedIndexPathBelowIndexPath(t){const e=this.collectionView.numberOfSections(),i=t.section,o=t.row,n=this.cachedLayout.sections[i];if(!n)return t;const s=n.rows;let a=0;const r=s.length;for(;a<r;a++){const t=s[a];if(t.startIndex<=o&&t.endIndex>=o)break}const l=s[a].attributes.find((t=>t.indexPath.row==o)),h=this._orientation==BMCollectionViewFlowLayoutOrientation.Vertical?"x":"y",c=l.frame.center[h];let d;if(a<r-1){d=s[a+1]}else{let t=i+1;for(;t<e;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){d=this.cachedLayout.sections[t]?.rows[0];break}t++}}if(d){let t=Number.MAX_SAFE_INTEGER,e=-1;for(let i=0;i<d.attributes.length;i++){const o=d.attributes[i],n=Math.abs(o.frame.center[h]-c);n<t&&(t=n,e=i)}return d.attributes[e].indexPath}return t},_computedIndexPathBelowIndexPath(t){const e=this.collectionView.numberOfSections(),i=this.cachedLayout;var o=t.section,n=i.sections[o];const s=i.numberOfColumns;var a=t.row;const r=a/s|0,l=a%s;let h;if(r<n.numberOfRows-1)h=r+1;else{let t=o+1;for(;t<e;){if(this.collectionView.numberOfObjectsInSectionAtIndex(t)){h=0,o=t;break}t++}}if("number"!=typeof h)return t;const c=s*h,d=this.collectionView.numberOfObjectsInSectionAtIndex(o);if(h==(d/s|0)){var u=d%s||s;return this.collectionView.indexPathForObjectAtRow(c+Math.min(u,l),{inSectionAtIndex:o})}return this.collectionView.indexPathForObjectAtRow(c+l,{inSectionAtIndex:o})},copy:function(){var t=new BMCollectionViewFlowLayout;return t.cellSize=this.cellSize&&this.cellSize.copy(),t.expectedCellSize=this.expectedCellSize&&this.expectedCellSize.copy(),t.rowSpacing=this.rowSpacing,t.showsHeaders=this.showsHeaders,t.headerHeight=this.headerHeight,t.showsFooters=this.showsFooters,t.footerHeight=this.footerHeight,t.sectionInsets=this.sectionInsets,t.gravity=this.gravity,t.leftAlignFinalRow=this.leftAlignFinalRow,t.alignment=this.alignment,t.orientation=this.orientation,t.topPadding=this.topPadding,t.bottomPadding=this.bottomPadding,t.contentGravity=this.contentGravity,t.pinsHeadersToContentEdge=this.pinsHeadersToContentEdge,t.pinsFootersToContentEdge=this.pinsFootersToContentEdge,t}}),BMCollectionViewFlowLayout.flowLayout=function(){return new this},BMCollectionViewMasonryLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_minimumColumnWidth:128,get minimumColumnWidth(){return this._minimumColumnWidth},set minimumColumnWidth(t){this._minimumColumnWidth=t,this.invalidateLayout()},_numberOfColumns:void 0,get numberOfColumns(){return this._numberOfColumns},set numberOfColumns(t){this._numberOfColumns=t,this.invalidateLayout()},_columnSpacing:22,get columnSpacing(){return this._columnSpacing},set columnSpacing(t){this._columnSpacing=t,this.invalidateLayout()},_cellSpacing:22,get cellSpacing(){return this._cellSpacing},set cellSpacing(t){this._cellSpacing=t,this.invalidateLayout()},_columnSpeeds:[],get columnSpeeds(){return this._columnSpeeds},set columnSpeeds(t){this._columnSpeeds=t,this.invalidateLayout()},_topPadding:22,get topPadding(){return this._topPadding},set topPadding(t){this._topPadding=t,this.invalidateLayout()},_bottomPadding:22,get bottomPadding(){return this._bottomPadding},set bottomPadding(t){this._bottomPadding=t,this.invalidateLayout()},cachedLayout:void 0,prepareLayout:function(){if(!this.isChangingBounds){this.previousLayout=this.cachedLayout,this.cachedLayout={};var t,e=this.cachedLayout,i=this.collectionView.frame.size.width,o=this.columnSpacing,n=this.cellSpacing,s=this.numberOfColumns,a=this.columnSpeeds;if(s)t=(i-(s+1)*o)/s|0;else(s=i/(t=this.minimumColumnWidth)|0)*t+(s+1)*o>i&&(s-=1),t=(i-(s+1)*o)/s|0;e.columns=[];for(var r=0;r<s;r++)e.columns.push({height:this._topPadding,speedHeight:this._topPadding/(a[r]||1),speed:a[r]||1,attributes:[],x:o+r*(o+t)});var l=this.collectionView.numberOfSections();for(r=0;r<l;r++)for(var h=this.collectionView.numberOfObjectsInSectionAtIndex(r),c=0;c<h;c++){for(var d=this.collectionView.indexPathForObjectAtRow(c,{inSectionAtIndex:r}),u=this.collectionView.delegate.collectionViewHeightForCellAtIndexPath(this.collectionView,d,{forColumnWidth:t}),p=e.columns[0].speedHeight,g=0,w=1;w<s;w++){(y=e.columns[w]).speedHeight<p&&(p=y.speedHeight,g=w)}var y=e.columns[g],m=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(d);m.frame=BMRectMake(y.x,y.height,t,u),m.style={translateZ:0},y.attributes.push(m),y.height+=u+n,y.speedHeight+=(u+n)/y.speed}for(w=0;w<s;w++){(y=e.columns[w]).height+=this._bottomPadding,y.speedHeight+=this._bottomPadding/y.speed}}},contentSize:function(){for(var t=0,e=0;e<this.cachedLayout.columns.length;e++)t<this.cachedLayout.columns[e].speedHeight&&(t=this.cachedLayout.columns[e].speedHeight);return BMSizeMake(this.collectionView.frame.size.width,Math.max(t,this.collectionView.frame.size.height))},collectionViewWillStartUpdates:function(){this.prepareLayout()},collectionViewDidStartUpdates:function(){this.previousLayout=void 0},shouldInvalidateLayoutForBoundsChange:function(t){return this.isChangingBounds=YES,YES},didInvalidateLayoutForBoundsChange:function(){this.isChangingBounds=NO},attributesForElementsInRect:function(t){return this.cachedAttributesForElementsInRect(t)},cachedAttributesForElementsInRect:function(t,e){for(var i=e&&e.usingCache||this.cachedLayout,o=this.collectionView.scrollOffset,n=t.origin.y,s=t.bottom,a=[],r=i.columns,l=r.length,h=0;h<l;h++){for(var c=r[h],d=o.y*c.speed,u=(t.size.height,o.y-d),p=c.attributes.length,g=c.attributes,w=0;w<p;w++){if((y=g[w]).frame.bottom+u>n)break}for(;w!=p;){var y;if((y=g[w]).frame.top+u>s)break;(y=y.copy()).frame.origin.y=y.frame.origin.y+u|0,a.push(y),w++}}return a},attributesForCellAtIndexPath:function(t){return this.cachedAttributesForCellAtIndexPath(t)},cachedAttributesForCellAtIndexPath:function(t,e){return this._extendedCachedAttributesForCellAtIndexPath(t,e).attribute},_extendedCachedAttributesForCellAtIndexPath:function(t,e){for(var i=this.collectionView.scrollOffset,o=(e&&e.usingCache||this.cachedLayout).columns,n=o.length,s=0;s<n;s++)for(var a=o[s],r=i.y*a.speed,l=i.y-r,h=a.attributes.length,c=a.attributes,d=0;d<h;d++){var u=c[d];if(u.indexPath.section==t.section&&u.indexPath.row==t.row)return(u=u.copy()).frame.origin.y=u.frame.origin.y+l|0,u.speed=a.speed,{attribute:u,columnIndex:s,rowIndex:d}}},initialAttributesForPresentedCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t);return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForPresentedCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e,layout:this}):(e.frame.origin.y+=this.collectionView.frame.size.height/3*e.speed,e.style={opacity:0,translateZ:0,rotateZ:"15deg"},e)},initialAttributesForAppearingCellAtIndexPath:function(t){var e=this.attributesForCellAtIndexPath(t);return this.collectionView.delegate&&this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath?this.collectionView.delegate.collectionViewInitialAttributesForAppearingCellAtIndexPath(this.collectionView,t,{withTargetAttributes:e,layout:this}):(e.frame.origin.y+=this.collectionView.frame.size.height/3*e.speed,e.style={opacity:0,translateZ:0,rotateZ:"15deg"},e)},initialAttributesForMovingCellFromIndexPath:function(t,e){var i,o=this;return this.collectionView.usingOldDataSet((function(){i=o.cachedAttributesForCellAtIndexPath(t,{usingCache:o.previousLayout})})),i},finalAttributesForDisappearingCellAtIndexPath:function(t){var e,i=this;return this.collectionView.usingOldDataSet((function(){e=i.cachedAttributesForCellAtIndexPath(t,{usingCache:i.previousLayout}),i.collectionView.delegate&&i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath?e=i.collectionView.delegate.collectionViewFinalAttributesForDisappearingCellAtIndexPath(i.collectionView,t,{withTargetAttributes:e}):(e.frame.origin.y+=i.collectionView.frame.size.height/3*e.speed,e.style={opacity:0,translateZ:0,rotateZ:"15deg"})})),e},indexPathToTheLeftOfIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t);if(0==e.columnIndex)return t;const i=e.attribute.frame.center.y,o=this.collectionView.scrollOffset,n=this.cachedLayout.columns[e.columnIndex-1];var s=o.y*n.speed,a=o.y-s;let r=-1,l=Number.MAX_SAFE_INTEGER;for(let t=0;t<n.attributes.length;t++){const e=n.attributes[t].frame.center.y+a|0,o=Math.abs(e-i);o<l&&(r=t,l=o)}return-1!=r?n.attributes[r].indexPath:t},indexPathAboveIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t);return e.rowIndex>0?this.cachedLayout.columns[e.columnIndex].attributes[e.rowIndex-1].indexPath:t},indexPathToTheRightOfIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t),i=this.cachedLayout;if(e.columnIndex>=this.cachedLayout.columns.length-1)return t;const o=e.attribute.frame.center.y,n=this.collectionView.scrollOffset,s=i.columns[e.columnIndex+1];var a=n.y*s.speed,r=n.y-a;let l=-1,h=Number.MAX_SAFE_INTEGER;for(let t=0;t<s.attributes.length;t++){const e=s.attributes[t].frame.center.y+r|0,i=Math.abs(e-o);i<h&&(l=t,h=i)}return-1!=l?s.attributes[l].indexPath:t},indexPathBelowIndexPath(t){const e=this._extendedCachedAttributesForCellAtIndexPath(t);return e.rowIndex<this.cachedLayout.columns[e.columnIndex].attributes.length-1?this.cachedLayout.columns[e.columnIndex].attributes[e.rowIndex+1].indexPath:t},indexPathsFromIndexPath(t,{toIndexPath:e}){const i=this.attributesForCellAtIndexPath(t),o=this.attributesForCellAtIndexPath(e);return this.attributesForElementsInRect(i.frame.rectByUnionWithRect(o.frame)).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell)).map((t=>t.indexPath))},copy:function(){var t=new BMCollectionViewMasonryLayout;return t.minimumColumnWidth=this.minimumColumnWidth,t.numberOfColumns=this.numberOfColumns,t.columnSpacing=this.columnSpacing,t.cellSpacing=this.cellSpacing,t.columnSpeeds=this.columnSpeeds&&this.columnSpeeds.slice(),t.topPadding=this.topPadding,t.bottom=this.bottomPadding,t}}),BMCollectionViewMasonryLayout.masonryLayout=function(){return new this},BMCollectionViewStackLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_showsSingleCellFullScreen:NO,get showsSingleCellFullScreen(){return this._showsSingleCellFullScreen},set showsSingleCellFullScreen(t){this._showsSingleCellFullScreen=t,this.invalidateLayout()},_showsSingleCell:NO,get showsSingleCell(){return this._showsSingleCell},set showsSingleCell(t){this._showsSingleCell=t,this.invalidateLayout()},_insets:BMInsetMake(88,88,88,88),get insets(){return this._insets.copy()},set insets(t){this._insets=t.copy(),this.invalidateLayout()},_spread:22,get spread(){return this._spread},set spread(t){this._spread=t,this.invalidateLayout()},_numberOfBackgroundCells:3,get numberOfBackgroundCells(){return this._numberOfBackgroundCells},set numberOfBackgroundCells(t){this._numberOfBackgroundCells=t,this.invalidateLayout()},_minimumScale:.9,get minimumScale(){return this._minimumScale},set minimumScale(t){this._minimumScale=t,this.invalidateLayout()},_blursBackgroundCells:NO,get blursBackgroundCells(){return this._blursBackgroundCells},set blursBackgroundCells(t){this._blursBackgroundCells=t,this.invalidateLayout()},_maximumBlur:15,get maximumBlur(){return this._maximumBlur},set maximumBlur(t){this._maximumBlur=t,this.invalidateLayout()},_rotatesCells:NO,get rotatesCells(){return this._rotatesCells},set rotatesCells(t){this._rotatesCells=t,this.invalidateLayout()},_rotation:-90,get rotation(){return this._rotation},set rotation(t){this._rotation=t,this.invalidateLayout()},_numberOfObjects:0,shouldInvalidateLayoutForFrameChange:function(){return YES},shouldInvalidateLayoutForBoundsChange:function(){return YES},collectionViewWillStartUpdates:function(){this.prepareLayout()},prepareLayout:function(){for(var t=0,e=this.collectionView.numberOfSections(),i=0;i<e;i++)t+=this.collectionView.numberOfObjectsInSectionAtIndex(i);this._numberOfObjects=t},contentSize:function(){return this._showsSingleCell?this.collectionView.frame.size.copy():BMSizeMake(this.collectionView.frame.size.width,this.collectionView.frame.size.height*this._numberOfObjects)},previousIndexPathWithIndexPath:function(t){if(t.row)return this.collectionView.indexPathForObjectAtRow(t.row-1,{inSectionAtIndex:t.section});for(var e=t.section-1;e>=0;){var i=this.collectionView.numberOfObjectsInSectionAtIndex(e);if(i)return this.collectionView.indexPathForObjectAtRow(i-1,{inSectionAtIndex:e});e--}},nextIndexPathWithIndexPath:function(t){var e=this.collectionView.numberOfObjectsInSectionAtIndex(t.section);if(t.row<e-1)return this.collectionView.indexPathForObjectAtRow(t.row+1,{inSectionAtIndex:t.section});for(var i=this.collectionView.numberOfSections(),o=t.section+1;o<i;){if(e=this.collectionView.numberOfObjectsInSectionAtIndex(o))return this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:o});o++}},attributesForElementsInRect:function(t){if(this._showsSingleCell){var e=[];if(this.collectionView.numberOfSections()&&this.collectionView.numberOfObjectsInSectionAtIndex(0)){var i=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(this.collectionView.indexPathForObjectAtRow(0,{inSectionAtIndex:0}));i.frame=this.collectionView.frame.copy(),i.frame.origin=BMPointMake(),e.push(i)}return e}for(var o,n=this.collectionView.scrollOffset,s=this.collectionView.frame.size.height,a=this.collectionView.frame.size.width,r=n.y,l=n.y+s,h=a-this.insets.left-this.insets.right,c=s-this.insets.top-this.insets.bottom,d=(e=[],0),u=this.collectionView.numberOfSections(),p=0;p<u;p++){for(var g=this.collectionView.numberOfObjectsInSectionAtIndex(p),w=0;w<g;w++)if((d+=s)>=r&&d<=l){o=this.collectionView.indexPathForObjectAtRow(w,{inSectionAtIndex:p});break}if(o)break}if(!o)return e;this._spread;var y=(s-d+r)/s,m=this._spread*y|0,_=(1-this._minimumScale)/(this._numberOfBackgroundCells+1),f=1/(this._numberOfBackgroundCells+1),v=this._maximumBlur/(this._numberOfBackgroundCells+1),M=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(o);M.frame=BMRectMakeWithX(this.insets.left,{y:r+this.insets.top-m,width:h,height:c}),M.style.zIndex=2*this._numberOfBackgroundCells+4,M.style.scaleX=1-_*y,M.style.scaleY=1-_*y,M.style.opacity=1-f*y,this._blursBackgroundCells&&(M.style.blur=y*v+"px"),this._rotatesCells&&(M.style.rotateX=(this.numberOfBackgroundCells-1)/1e4+"deg",M.style.transformOriginX="50%",M.style.transformOriginY="100%",M.style.translateZ=2*this._numberOfBackgroundCells+4+"px"),e.push(M);var S=this.nextIndexPathWithIndexPath(o);if(S){let t=d-this.insets.bottom+this.insets.top/3,i=d+this.insets.top;(C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(S)).frame=BMRectMakeWithX(this.insets.left,{y:BMNumberByInterpolatingNumbersWithFraction(t,i,y),width:h,height:c}),C.style.zIndex=2*this._numberOfBackgroundCells+6,this._rotatesCells&&(C.style.rotateX=BMNumberByInterpolatingNumbersWithFraction(this._rotation,0,y)+"deg",C.style.transformOriginX="50%",C.style.transformOriginY="100%",C.style.translateZ=2*this._numberOfBackgroundCells+6+"px"),e.push(C);let o=this.nextIndexPathWithIndexPath(S);if(o){let t=d+this.collectionView.frame.size.height,i=t-this.insets.bottom+this.insets.top/3;this.insets.top;var C;(C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(o)).frame=BMRectMakeWithX(this.insets.left,{y:i,width:h,height:c}),C.style.zIndex=2*this._numberOfBackgroundCells+8,this._rotatesCells&&(C.style.rotateX=this._rotation+"deg",C.style.transformOriginX="50%",C.style.transformOriginY="100%",C.style.translateZ=2*this._numberOfBackgroundCells+8+"px"),e.push(C)}}for(p=0;p<this._numberOfBackgroundCells;p++){var b=this.previousIndexPathWithIndexPath(o);if(!b)return e;var B=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(b);B.frame=BMRectMakeWithX(this.insets.left,{y:r+this.insets.top-m-(p+1)*this._spread,width:h,height:c}),B.style.zIndex=2*(this._numberOfBackgroundCells+1-p),B.style.scaleX=1-_*y-_*(p+1),B.style.scaleY=1-_*y-_*(p+1),B.style.opacity=1-f*y-f*(p+1),this._blursBackgroundCells&&(B.style.blur=(y+p+1)*v+"px"),this._rotatesCells&&(B.style.rotateX=(this.numberOfBackgroundCells+p)/1e4+"deg",B.style.transformOriginX="50%",B.style.transformOriginY="100%",B.style.translateZ=2*(this._numberOfBackgroundCells+1-p)+"px"),e.push(B),o=b}return e},attributesForCellAtIndexPath:function(t){if(this._showsSingleCell){var e=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);return e.frame=this.collectionView.frame.copy(),e.frame.origin=BMPointMake(),0==t.row&&0==t.section||(e.isHidden=YES,e.style.opacity=0),e}for(var i,o=this.collectionView.scrollOffset,n=this.collectionView.frame.size.height,s=this.collectionView.frame.size.width,a=o.y,r=o.y+n,l=s-this.insets.left-this.insets.right,h=n-this.insets.top-this.insets.bottom,c=[],d=0,u=this.collectionView.numberOfSections(),p=0;p<u;p++){for(var g=this.collectionView.numberOfObjectsInSectionAtIndex(p),w=0;w<g;w++)if((d+=n)>=a&&d<=r){i=this.collectionView.indexPathForObjectAtRow(w,{inSectionAtIndex:p});break}if(i)break}this._spread;var y=(n-d+a)/n,m=this._spread*y|0,_=(1-this._minimumScale)/(this._numberOfBackgroundCells+1),f=1/(this._numberOfBackgroundCells+1),v=this._maximumBlur/(this._numberOfBackgroundCells+1);if(t.isEqualToIndexPath(i,{usingComparator:this.collectionView.identityComparator})){var M=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);return M.frame=BMRectMakeWithX(this.insets.left,{y:a+this.insets.top-m,width:l,height:h}),M.style.zIndex=this._numberOfBackgroundCells+2,M.style.scaleX=1-_*y,M.style.scaleY=1-_*y,M.style.opacity=1-f*y,this._blursBackgroundCells&&(M.style.blur=y*v+"px"),M}var S=this.nextIndexPathWithIndexPath(i);if(S&&t.isEqualToIndexPath(S,{usingComparator:this.collectionView.identityComparator})){var C=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(S);return C.frame=BMRectMakeWithX(this.insets.left,{y:d+this.insets.top,width:l,height:h}),C.style.zIndex=this._numberOfBackgroundCells+3,C}if(t.section>S.section||t.section==S.section&&t.row>S.row){var b=0;for(p=0;p<t.section;p++){b+=n*(g=this.collectionView.numberOfObjectsInSectionAtIndex(p))}return b+=n*t.row,(c=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=BMRectMakeWithX(this.insets.left,{y:b,width:l,height:h}),c.isHidden=YES,c.opacity=0,c}for(p=0;p<this._numberOfBackgroundCells;p++){var B,E=this.previousIndexPathWithIndexPath(i);if(!E)break;if(t.isEqualToIndexPath(E,{usingComparator:this.collectionView.identityComparator}))return(B=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(E)).frame=BMRectMakeWithX(this.insets.left,{y:a+this.insets.top-m-(p+1)*this._spread,width:l,height:h}),B.style.zIndex=this._numberOfBackgroundCells+1-p,B.style.scaleX=1-_*y-_*(p+1),B.style.scaleY=1-_*y-_*(p+1),B.style.opacity=1-f*y-f*(p+1),this._blursBackgroundCells&&(B.style.blur=(y+p+1)*v+"px"),B;i=E}return(B=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t)).frame=BMRectMakeWithX(this.insets.left,{y:a+this.insets.top-(this._numberOfBackgroundCells+1)*this._spread,width:l,height:h}),B.style.zIndex=0,B.style.scaleX=this._minimumScale,B.style.scaleY=this._minimumScale,B.style.opacity=0,this._blursBackgroundCells&&(B.style.blur=this._maximumBlur+"px"),B},rectWithScrollingPositionOfCellAtIndexPath:function(t){for(var e=this.collectionView.frame.size.height,i=0,o=0;o<t.section;o++){i+=e*this.collectionView.numberOfObjectsInSectionAtIndex(o)}return BMRectMakeWithX(0,{y:i+=e*t.row,width:this.collectionView.frame.size.width,height:this.collectionView.frame.size.height})},snapsScrollPosition:()=>YES,snappingScrollOffsetForScrollOffset(t,e){t=t.copy();var i=e.withVerticalDirection==BMScrollingDirectionVertical.Bottom?this.collectionView.frame.size.height:0;return t.y=(t.y/this.collectionView.frame.size.height|0)*this.collectionView.frame.size.height+i,t.y=Math.max(0,Math.min(this.collectionView.size.height-this.collectionView.frame.size.height,t.y)),t},copy(){var t=new BMCollectionViewStackLayout;return t._showsSingleCellFullScreen=this._showsSingleCellFullScreen,t._showsSingleCell=this._showsSingleCell,t._insets=this._insets.copy(),t._spread=this._spread,t._numberOfBackgroundCells=this._numberOfBackgroundCells,t._minimumScale=this._minimumScale,t._blursBackgroundCells=this._blursBackgroundCells,t._maximumBlur=this._maximumBlur,t}}),BMCollectionViewStackLayout.stackLayout=function(){return new this};var BMCollectionViewTileLayoutOrientation=Object.freeze({Horizontal:{},Vertical:{}});function BMCollectionViewTileLayout(){}BMCollectionViewTileLayout.prototype=BMExtend({},BMCollectionViewLayout.prototype,{get supportsCopying(){return YES},_gridSize:0,get gridSize(){return this._gridSize},set gridSize(t){this._gridSize=t||0,this.invalidateLayout()},_spacing:0,get spacing(){return this._spacing},set spacing(t){this._spacing=t||0,this.invalidateLayout()},_showsHeaders:NO,get showsHeaders(){return this._showsHeaders},set showsHeaders(t){this._showsHeaders=t,this.invalidateLayout()},_headerHeight:22,get headerHeight(){return this._showsHeaders?this._headerHeight:0},set headerHeight(t){this._headerHeight=t,this._showsHeader&&this.invalidateLayout()},_showsFooters:NO,get showsFooters(){return this._showsFooters},set showsFooters(t){this._showsFooters=t,this.invalidateLayout()},_footerHeight:22,get footerHeight(){return this._showsFooters?this._footerHeight:0},set footerHeight(t){this._footerHeight=t,this._showsFooters&&this.invalidateLayout()},_sectionInsets:BMInsetMake(),get sectionInsets(){return this._sectionInsets},set sectionInsets(t){this._sectionInsets=t||BMInsetMake(),this.invalidateLayout()},_topPadding:0,get topPadding(){return this._topPadding},set topPadding(t){this._topPadding=t,this.invalidateLayout()},_bottomPadding:0,get bottomPadding(){return this._bottomPadding},set bottomPadding(t){this._bottomPadding=t,this.invalidateLayout()},_pinsHeadersToContentEdge:NO,get pinsHeadersToContentEdge(){return this._pinsHeadersToContentEdge},set pinsHeadersToContentEdge(t){this._pinsHeadersToContentEdge=t,this.invalidateLayout()},_pinsFootersToContentEdge:NO,get pinsFootersToContentEdge(){return this._pinsFootersToContentEdge},set pinsFootersToContentEdge(t){this._pinsFootersToContentEdge=t,this.invalidateLayout()},_orientation:BMCollectionViewTileLayoutOrientation.Vertical,get orientation(){return this._orientation},set orientation(t){this._orientation=t,this.invalidateLayout()},copy(){let t=new BMCollectionViewTileLayout;return t._gridSize=this._gridSize,t._spacing=this._spacing,t._showsHeaders=this._showsHeaders,t._headerHeight=this._headerHeight,t._showsFooters=this._showsFooters,t._footerHeight=this._footerHeight,t._sectionInsets=this._sectionInsets.copy(),t._topPadding=this._topPadding,t._bottomPadding=this._bottomPadding,t._pinsFootersToContentEdge=this._pinsFootersToContentEdge,t._pinsHeadersToContentEdge=this._pinsHeadersToContentEdge,t._orientation=this._orientation,t},_isChangingBounds:NO,constrainedSizeWithSize:function(t){return BMSizeMake(Math.min(this.constrainedValueWithValue(t.width),this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right),this.constrainedValueWithValue(t.height))},constrainedValueWithValue:function(t){if(this._gridSize>1){var e=this._gridSize,i=this._spacing,o=t/(e+i)|0;0==o&&(o=1);var n=o*e+(o-1)*i;return t-n>n+e+i-t?n+e+i:n}return t},collectionViewWillStartUpdates:function(t){this.previousLayoutCache=this.layoutCache,this.prepareLayout()},collectionViewDidStartUpdates:function(t){this.previousLayoutCache=void 0},prepareLayout:function(){return this._prepareLayoutWithScrollbarOffset(NO)},_prepareLayoutWithScrollbarOffset:function(t){if(!this._isChangingBounds){var e=this.collectionView.frame.size.width-this._sectionInsets.left-this._sectionInsets.right,i={},o=this.collectionView.numberOfSections();this.layoutCache=i,i.sections=new Array(o),i.size=BMSizeMake(this.collectionView.frame.size.width,0);for(var n=this._topPadding,s=0;s<o;s++){var a={attributes:[]};if(i.sections[s]=a,n+=this._sectionInsets.top,a.outerFrame=BMRectMake(this._sectionInsets.left,n,e,0),this._showsHeaders){a.outerFrame.size.height+=this._headerHeight+this._spacing,n+=this._headerHeight+this._spacing;var r=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([s])});r.frame=a.outerFrame.copy(),r.frame.size.height=this._headerHeight,a.headerAttributes=r}if(a.frame=BMRectMake(this._sectionInsets.left,n,e,0),this._prepareLayoutForSection(s,{intoCache:a}),a.outerFrame.size.height+=a.frame.size.height,n=a.outerFrame.bottom,this._showsFooters){var l=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([s])});l.frame=a.outerFrame.copy(),l.frame.size.height=this._footerHeight,l.frame.origin.y=n+this._spacing,a.footerAttributes=l,a.outerFrame.size.height+=this._footerHeight+this._spacing,n+=this._footerHeight+this._spacing}a.outerFrame.size.height+=this._sectionInsets.bottom,n=a.outerFrame.bottom}i.size.height=n+this._bottomPadding}},_prepareLayoutForSection:function(t,e){for(var i=this.collectionView.numberOfObjectsInSectionAtIndex(t),o=e.intoCache,n=o.frame.origin.y,s=o.frame.origin.x,a=[BMRectMakeWithX(o.frame.origin.x,{y:o.frame.origin.y,width:o.frame.size.width,height:Number.MAX_SAFE_INTEGER})],r=0;r<i;r++){this.DEBUG;var l=this.collectionView.indexPathForObjectAtRow(r,{inSectionAtIndex:t}),h=this.collectionView.delegate.collectionViewSizeForCellAtIndexPath(this.collectionView,l);h=this.constrainedSizeWithSize(h);for(var c=void 0,d=0;d<a.length;d++){if(!((y=a[d]).size.width<h.width||y.size.height<h.height)&&!c){c=y;break}}var u=BMRectMakeWithOrigin(BMPointMakeWithX(c.origin.x,{y:c.origin.y}),{size:h}),p=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(l);if(p.frame=u,o.attributes.push(p),this.DEBUG){var g=document.createElement("div");BMCopyProperties(g.style,{position:"absolute",boxSizing:"border-box",top:u.origin.y+"px",left:u.origin.x+"px",width:u.size.width+"px",height:u.size.height+"px",boxShadow:"0px 0px 1px 1px blue"}),(this.collectionView._contentWrapper&&this.collectionView._contentWrapper[0]||this.collectionView._container[0]).appendChild(g)}n<u.bottom&&(n=u.bottom),s<u.right&&(s=u.right),this.DEBUG;var w=u.rectWithInset(BMInset.insetWithEqualInsets(-this._spacing));for(d=0;d<a.length;d++){var y;if((y=a[d]).isEqualToRect(w)||w.containsRect(y))a.splice(d,1),y.div&&y.div.remove(),d--;else if(w.intersectsContentOfRect(y)){var m=this.rectsWithDifferenceOfExtent(y,{fromRect:w,spacing:this._spacing});a.splice(d,1),y.div&&y.div.remove();var _=0,f=m[0];if(f)for(var v=d;v<a.length;v++){var M=a[v];if(M.isEqualToRect(f)&&(_++,f.isInvalid=YES,!(f=m[_])))break;if(M.origin.y>f.origin.y&&(a.splice(v,0,f),v++,!(f=m[++_])))break;if(M.origin.y==f.origin.y&&M.origin.x>f.origin.x&&(a.splice(v,0,f),v++,!(f=m[++_])))break}if(f)for(;_<m.length;_++)a.push(m[_]);if(d=-1,this.DEBUG)for(v=0;v<m.length;v++){var S=document.createElement("div"),C=m[v];C.isInvalid||(BMCopyProperties(S.style,{position:"absolute",boxSizing:"border-box",top:C.origin.y+"px",left:C.origin.x+"px",width:C.size.width+"px",height:C.size.height+"px",boxShadow:"0px 0px 1px 1px red"}),C.div=S,(this.collectionView._contentWrapper&&this.collectionView._contentWrapper[0]||this.collectionView._container[0]).appendChild(S))}}}}n+=this._spacing+this._sectionInsets.bottom;var b=(o.frame.right-s)/2|0;b&&(o.attributes=o.attributes.map((function(t){return t.frame.origin.x+=b,t}))),o.frame.size.width=s-o.frame.origin.x,o.frame.size.height=n-o.frame.origin.y},attributesForElementsInRect:function(t){if(0==this.collectionView.numberOfSections()){var e=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return e.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),[e]}for(var i,o,n,s=this.layoutCache.sections.length,a=[],r=NO,l=0;l<s;l++){var h=this.layoutCache.sections[l];if(t.intersectsRect(h.outerFrame)){var c,d=h;h.headerAttributes&&t.intersectsRect(h.headerAttributes.frame)&&(a.push(c=h.headerAttributes.copy()),o&&c.frame.intersectsRect(o.frame)&&(this.orientation==BMCollectionViewTileLayoutOrientation.Horizontal&&(o.frame.origin.x=c.frame.origin.x-o.frame.size.width),this.orientation==BMCollectionViewTileLayoutOrientation.Vertical&&(o.frame.origin.y=c.frame.origin.y-o.frame.size.height))),r||(r=YES,this.pinsHeadersToContentEdge&&h.headerAttributes&&(c||a.push(c=h.headerAttributes.copy()),(o=c).style.zIndex=1,c.frame.origin.y=Math.max(this.collectionView.scrollOffset.y,c.frame.origin.y),c.frame.origin.x=Math.max(this.collectionView.scrollOffset.x,c.frame.origin.x)));for(var u=h.attributes.length,p=0;p<u;p++)t.intersectsRect(h.attributes[p].frame)&&a.push(h.attributes[p]);h.footerAttributes&&t.intersectsRect(h.footerAttributes.frame)?(a.push(i=h.footerAttributes.copy()),n=i):i=void 0}else if(r)break}return d&&this.pinsFootersToContentEdge&&d.footerAttributes&&(i||a.push(i=d.footerAttributes.copy()),i.style.zIndex=1,i.frame.origin.y=Math.min(this.collectionView.scrollOffset.y+this.collectionView.frame.size.height-i.frame.size.height,i.frame.origin.y),i.frame.origin.x=Math.min(this.collectionView.scrollOffset.x+this.collectionView.frame.size.width-i.frame.size.width,i.frame.origin.x),n&&i.frame.intersectsRect(n.frame)&&(this.orientation==BMCollectionViewTileLayoutOrientation.Horizontal&&(i.frame.origin.x=n.frame.origin.x-i.frame.size.width),this.orientation==BMCollectionViewTileLayoutOrientation.Vertical&&(i.frame.origin.y=n.frame.origin.y-i.frame.size.height))),a},shouldInvalidateLayoutForBoundsChange:function(){var t=this._pinsHeadersToContentEdge||this._pinsFootersToContentEdge;return t&&(this._isChangingBounds=YES),t},didInvalidateLayoutForBoundsChange:function(){this._isChangingBounds=NO},attributesForCellAtIndexPath:function(t){return this.cachedAttributesForCellAtIndexPath(t,{withCache:this.layoutCache})},cachedAttributesForCellAtIndexPath:function(t,e){return e.withCache.sections[t.section].attributes[t.row]},initialAttributesForMovingCellFromIndexPath:function(t){return this.cachedAttributesForCellAtIndexPath(t,{withCache:this.previousLayoutCache})},attributesForSupplementaryViewWithIdentifier:function(t,e){if(t===BMCollectionViewTableLayoutSupplementaryView.Empty){var i=BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])});return i.frame=BMRectMake(0,0,this.collectionView.frame.size.width,this.collectionView.frame.size.height),i}var o=e.atIndexPath;return t==BMCollectionViewFlowLayoutSupplementaryView.Footer?this.layoutCache.sections[o.section].footerAttributes:t==BMCollectionViewFlowLayoutSupplementaryView.Header?this.layoutCache.sections[o.section].headerAttributes:void 0},contentSize:function(){let t=this.layoutCache.size;return t.height=Math.max(t.height,this.collectionView.frame.size.height),t},initialAttributesForPresentedCellAtIndexPath:function(t,e){var i=e.withTargetAttributes.copy(),o=i.frame,n=this.collectionView.bounds.center.slopeAngleToPoint(o.center),s=this.collectionView.bounds.center.distanceToPoint(o.center);return o.offset(4*s*Math.cos(n),4*s*Math.sin(n)),i.style.scaleX=2,i.style.scaleY=2,i.style.opacity=0,i},supplementaryViewsToInsert:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=t;n<e;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return t>0&&0==e&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},supplementaryViewsToDelete:function(){var t,e=this.collectionView.numberOfSections(),i=this;this.collectionView.usingOldDataSet((function(){t=i.collectionView.numberOfSections()}));for(var o=[],n=e;n<t;n++)this.showsHeaders&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Header,{atIndexPath:BMIndexPathMakeWithIndexes([n])})),this.showsFooters&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewFlowLayoutSupplementaryView.Footer,{atIndexPath:BMIndexPathMakeWithIndexes([n])}));return 0==t&&e>0&&o.push(BMCollectionViewLayoutAttributesMakeForSupplementaryViewWithIdentifier(BMCollectionViewTableLayoutSupplementaryView.Empty,{atIndexPath:BMIndexPathMakeWithIndexes([0])})),o},rightExtentByTrimmingLeftSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(i.right,{y:t.origin.y,width:t.right-i.right,height:t.height})},leftExtentByTrimmingRightSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:i.origin.x-t.origin.x,height:t.height})},topExtentByTrimmingBottomSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:i.origin.y-t.origin.y})},bottomExtentByTrimmingTopSideOfExtent:function(t,e){var i=e.withIntersectingRect;return BMRectMakeWithX(t.origin.x,{y:i.bottom,width:t.size.width,height:t.bottom-i.bottom})},rectsWithDifferenceOfExtent:function(t,e){e.spacing;var i=this._gridSize,o=e.fromRect;if(o.bottom>=t.origin.y&&o.top<=t.origin.y){var n=[];return(r=this.leftExtentByTrimmingRightSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(r),(a=this.rightExtentByTrimmingLeftSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(a),(l=this.bottomExtentByTrimmingTopSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(l),n}if(o.right>=t.origin.x&&o.origin.x<=t.origin.x){n=[];return(s=this.topExtentByTrimmingBottomSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(s),(a=this.rightExtentByTrimmingLeftSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(a),(l=this.bottomExtentByTrimmingTopSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(l),n}if(o.origin.x<=t.right&&o.right>=t.right){n=[];return(s=this.topExtentByTrimmingBottomSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(s),(r=this.leftExtentByTrimmingRightSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(r),(l=this.bottomExtentByTrimmingTopSideOfExtent(t,{withIntersectingRect:o})).height>=i&&n.push(l),n}if(o.origin.y<=t.bottom&&o.bottom>=t.bottom){n=[];(r=this.leftExtentByTrimmingRightSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(r);var s=this.topExtentByTrimmingBottomSideOfExtent(t,{withIntersectingRect:o});return l.height>=i&&n.push(l),(a=this.rightExtentByTrimmingLeftSideOfExtent(t,{withIntersectingRect:o})).width>=i&&n.push(a),n}if(o.intersectsPoint(t.origin)){n=[];return(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.intersectsPoint({x:t.right,y:t.origin.y})){n=[];return(r=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:o.origin.x-t.origin.x,height:t.height})).width>=i&&n.push(r),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.intersectsPoint({x:t.left,y:t.bottom})){n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),n}if(o.intersectsPoint({x:t.right,y:t.bottom})){n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(r=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:o.origin.x-t.origin.x,height:t.height})).width>=i&&n.push(r),n}if(o.bottom>=t.origin.y&&o.top<=t.origin.y){n=[];return(r=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:o.origin.x-t.origin.x,height:t.height})).width>=i&&n.push(r),(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.right>=t.origin.x&&o.origin.x<=t.origin.x){var a;n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(a=BMRectMakeWithX(o.right,{y:t.origin.y,width:t.right-o.right,height:t.height})).width>=i&&n.push(a),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}if(o.origin.x<=t.right&&o.right>=t.right){var r,l;n=[];return(s=BMRectMakeWithX(t.origin.x,{y:t.origin.y,width:t.size.width,height:o.origin.y-t.origin.y})).height>=i&&n.push(s),(r=BMRectMakeWithX(t.right,{y:t.origin.y,width:o.right-t.right,height:t.height})).width>=i&&n.push(r),(l=BMRectMakeWithX(t.origin.x,{y:o.bottom,width:t.width,height:t.bottom-o.bottom})).height>=i&&n.push(l),n}},indexPathToTheLeftOfIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.origin.x-this.collectionView.bounds.size.width-1,e.frame.origin.y,this.collectionView.bounds.size.width,e.frame.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.left,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.x>n&&(n=o[t].frame.origin.x,s=t);return-1!=s?o[s].indexPath:t},indexPathAboveIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.origin.x,e.frame.origin.y-this.collectionView.bounds.size.height-1,e.frame.size.width,this.collectionView.bounds.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.origin.y,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.y>n&&(n=o[t].frame.origin.y,s=t);return-1!=s?o[s].indexPath:t},indexPathToTheRightOfIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.right+1,e.frame.origin.y,this.collectionView.bounds.size.width,e.frame.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.right,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.x<n&&(n=o[t].frame.origin.x,s=t);return-1!=s?o[s].indexPath:t},indexPathBelowIndexPath(t){const e=this.attributesForCellAtIndexPath(t),i=BMRectMake(e.frame.origin.x,e.frame.bottom+1,e.frame.size.width,this.collectionView.bounds.size.height),o=this.attributesForElementsInRect(i).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell));let n=i.bottom,s=-1;for(let t=0;t<o.length;t++)o[t].frame.origin.y<n&&(n=o[t].frame.origin.y,s=t);return-1!=s?o[s].indexPath:t},indexPathsFromIndexPath(t,{toIndexPath:e}){const i=this.attributesForCellAtIndexPath(t),o=this.attributesForCellAtIndexPath(e);return this.attributesForElementsInRect(i.frame.rectByUnionWithRect(o.frame)).filter((t=>t.itemType==BMCollectionViewLayoutAttributesType.Cell)).map((t=>t.indexPath))}}),BMCollectionViewTileLayout.tileLayout=function(){return new this};const BM_COLLECTION_VIEW_USE_STATIC_CONTEXT=YES,BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS=YES,BM_COLLECTION_VIEW_DEBUG_MEASURE=NO,BM_COLLECTION_VIEW_DEBUG_MEASURE_CELL=NO,BM_COLLECTION_VIEW_DISABLE_ISCROLL=NO,BM_DEPRECATION_WARN=NO,BM_DEPRECATION_TRACE=YES,BM_SIMPLE_BENCH=NO;var BMCollectionViewTransferPolicy=Object.freeze({Move:"Move",Copy:"Copy"}),BMCollectionViewAcceptPolicy=Object.freeze({Move:"Move",Copy:"Copy"}),_BMCoreUIIsDragging=NO,_BMCollectionViewAnimationDurationDefault=500,_BMCollectionViewAnimationEasingDefault="easeInOutQuart",_BMCollectionViewAnimationStrideDefault=50,_BMCollectionViewDoubleClickDelay=250,_BMCollectionViewLongClickDelay=400,_BMCollectionViewClickSlopeThreshold=10,_BMCollectionViewSnappingScrollThreshold=200,_BMCollectionViewIdentityComparator=function(t,e){return t==e},BMCollectionViewScrollingDirection=Object.freeze({Vertical:{},Horizontal:{},Both:{}}),BMCollectionViewScrollingGravityHorizontal=Object.freeze({Left:{},Center:{},Right:{}}),BMCollectionViewScrollingGravityVertical=Object.freeze({Top:{},Center:{},Bottom:{}}),_BMCollectionViews=new Map;function BMCollectionView(){}function BMCollectionViewMakeWithContainer(t,e){return(new BMCollectionView).initWithDOMNode(t[0],e)}BMCollectionView.prototype=BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS?Object.create(BMView.prototype):{},{constructor:BMCollectionView,get supportsAutomaticIntrinsicSize(){return NO},_lastMeasuredIntrinsicSize:void 0,get intrinsicSize(){},delegate:void 0,_usesLegacyDataSet:NO,_dataSet:void 0,get dataSet(){return this._dataSet},set dataSet(t){var e=this._dataSet;this._usesLegacyDataSet=YES,this._dataSet=t,this._dataSource=BMCollectionViewDataSourceAdapter.adapterWithDataSet(t),this.dataSetDidChangeFromDataSet(e)},_dataSource:void 0,get dataSource(){return this._dataSource},set dataSource(t){const e=this._dataSet;this._usesLegacyDataSet=NO,this._dataSource=t,this._dataSet=BMCollectionViewDataSetAdapter.adapterWithDataSource(this,t),this.dataSetDidChangeFromDataSet(e)},_container:void 0,get container(){return this._container},identityComparator:_BMCollectionViewIdentityComparator,indexPathForObjectAtRow:function(t,e){return this._dataSet?this._dataSet.indexPathForObjectAtRow(t,{inSectionAtIndex:e.inSectionAtIndex}):void 0},indexPathForObject:function(t){return this._dataSet?this._dataSet.indexPathForObject(t):void 0},numberOfSections:function(){return this._dataSet?this._dataSet.numberOfSections():0},numberOfObjectsInSectionAtIndex:function(t){return this._dataSet?this._dataSet.numberOfObjectsInSectionAtIndex(t):0},_layout:void 0,get layout(){return this._transitionLayout&&this._layout==this._transitionLayout?this._layout.targetLayout:this._layout},set layout(t){if(this.isUpdatingData){var e=this;this.registerDataCompletionCallback((function(){e.layout=t}))}else if(BMAnimationContextGetCurrent()){if(!this.initialized)return this._layout=t||new BMCollectionViewFlowLayout,void(this._layout.collectionView=this);this.setLayout(t||new BMCollectionViewFlowLayout)}else{if(this._layout=t||new BMCollectionViewFlowLayout,this._layout.collectionView=this,!this.initialized)return;this.invalidateLayout()}},_transitionLayout:void 0,_frame:void 0,get frame(){return this._frame},set frame(t){if(this._layoutAnimator)return void Object.getOwnPropertyDescriptor(BMView.prototype,"frame").set.call(this,t);const e=this._frame&&this._frame.copy();let i=!1;if(this._frame&&!t.size.isEqualToSize(this._frame.size)&&this.initialized){let i=this._layout.shouldInvalidateLayoutForFrameChange(t,{fromFrame:e});if(BMAnimationContextGetCurrent()){let e=this._frame;this._pendingFrame=t,i&&(this.layout.supportsCopying?(this.layout.beginUpdates(),this.layout.applyUpdates()):(this._frame=t,this.invalidateLayout())),this._frame=e,this.iScroll&&BMAnimationContextAddCompletionHandler((()=>{this.iScroll.refresh()}))}else this._frame=t,this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize,this._constrainBounds(),i&&this.invalidateLayout()}else if(!this._frame&&(this._frame=t,this.initialized)){let i=this._layout.shouldInvalidateLayoutForFrameChange(t,{fromFrame:e});this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize,this._constrainBounds(),i&&this.invalidateLayout()}this.__awaitsInit&&this._frame.size.width>0&&this._frame.size.height>0&&(i=!0),Object.getOwnPropertyDescriptor(BMView.prototype,"frame").set.call(this,t),this._pendingFrame=void 0,BMAnimationContextGetCurrent()||this.iScroll&&this.iScroll.refresh(),this._frame=t,i&&this._init()},_size:void 0,get size(){return this._size},_contentNode:void 0,get contentNode(){return this._contentNode},__contentWrapper:void 0,get _contentWrapper(){return BM_DEPRECATION_WARN&&(console.warn("Attempting to acess the _contentWrapper property which was deprecated. Consider using _contentNode instead and wrapping it using jQuery"),BM_DEPRECATION_TRACE&&console.trace()),this.__contentWrapper},set _contentWrapper(t){BM_DEPRECATION_WARN&&(console.warn("Attempting to acess the _contentWrapper property which was deprecated. Consider using _contentNode instead and wrapping it using jQuery"),BM_DEPRECATION_TRACE&&console.trace()),this.__contentWrapper=t,this._contentNode=t[0]},get contentWrapper(){return this._contentWrapper},_bounds:void 0,get bounds(){return this._bounds},get visibleBounds(){return new BMRect(BMPointMake(this._bounds.origin.x+this._offscreenBufferSize,this._bounds.origin.y+this._offscreenBufferSize),this._frame.size.copy())},_offscreenBufferSize:100,offscreenBufferFactor:.5,allowsOffscreenLayout:YES,_scrollingDirection:BMCollectionViewScrollingDirection.Vertical,get scrollingDirection(){return this._scrollingDirection},cellCache:{},supplementaryViewCache:{},attributeCache:{},retainedCells:[],allCells:[],initialized:NO,_collectionEnabled:YES,get scrollOffset(){var t=this._bounds.origin.copy();return t.x+=this._offscreenBufferSize,t.y+=this._offscreenBufferSize,t},set scrollOffset(t){this._scrollToOffset(t)},get scrollBarSize(){return this._usesIScroll?0:BMScrollBarGetSize()},_autoResizeToken:void 0,get autoResizes(){return void 0!==this._autoResizeToken},set autoResizes(t){if(this.autoResizes!=t)if(t){var e=this;this._autoResizeToken=function(t){e.resized()},window.addEventListener("resize",this._autoResizeToken)}else window.removeEventListener("resize",this._autoResizeToken),this._autoResizeToken=void 0},_cellClass:BMCollectionViewCell,get cellClass(){return this._cellClass},set cellClass(t){this._cellClass=t||BMCollectionViewCell},_cellClasses:void 0,_cellLayoutQueue:void 0,get cellLayoutQueue(){return this._cellLayoutQueue},set cellLayoutQueue(t){t||(t=BMViewLayoutQueue.layoutQueue()),this._cellLayoutQueue=t,this.enumerateAllCellsWithBlock((e=>{e.layoutQueue=t}))},assignsReuseIdentifierAsClass:YES,_supportsKeyboardNavigation:NO,get supportsKeyboardNavigation(){return this._supportsKeyboardNavigation},set supportsKeyboardNavigation(t){t!=this._supportsKeyboardNavigation&&(this._supportsKeyboardNavigation=t,this.initialized&&(t?this.configureKeyboardShortcuts():this.disableKeyboardShortcuts()))},registerCellClass(t,e){this._cellClasses[e.forReuseIdentifier]=t},_supplementaryViewClasses:void 0,registerSupplementaryViewClass(t,e){this._supplementaryViewClasses[e.forReuseIdentifier]=t},initWithDOMNode(t,e){var i=e&&e.customScroll;return _BMCollectionViews.set(this,!0),this._container=BMJQueryShim.shimWithDOMNode(t),this.layout=new BMCollectionViewFlowLayout,this.cellCache={},this.retainedCells=[],this.allCells=[],this.supplementaryViewCache={},this.attributeCache={},this._selectedIndexPaths=[],this.customScrollRequired=i,this._cellClasses={},this._supplementaryViewClasses={},this._measures={},this._measuredIndexPaths=[],this._cellLayoutQueue=BMViewLayoutQueue.layoutQueue(),BMView.prototype.initWithDOMNode.apply(this,arguments)},viewDidBecomeVisible(){BMView.prototype.viewDidBecomeVisible.apply(this,arguments),this.__awaitsInit?this.superview?this.frame&&this.frame.size.width>0&&this.frame.size.height>0&&this._init():this._init():this.__awaitsLayout&&this.invalidateLayout(),this.enumerateRetainedCellsWithBlock((t=>{t._collectionViewDidBecomeVisible()}))},viewDidBecomeInvisible(){BMView.prototype.viewDidBecomeInvisible.apply(this,arguments),this.enumerateRetainedCellsWithBlock((t=>{t._collectionViewDidBecomeInvisible()}))},_init:function(){if(!this.isCurrentlyVisible)return void(this.__awaitsInit=YES);if(this.superview&&(!this.frame||0==this.frame.size.width||0==this.frame.size.height))return void(this.__awaitsInit=YES);this.__awaitsInit=NO;var t=window.navigator.standalone&&void 0===this.customScrollRequired||this.customScrollRequired;if(/android/i.test(window.navigator.userAgent)&&(t=YES),this._prepareFrame(),this._createBounds(),t&&!BM_COLLECTION_VIEW_DISABLE_ISCROLL&&(this._usesIScroll=YES),BM_SIMPLE_BENCH){const t=Date.now();this._reloadLayout(),alert(`[BMCollectionView] Initial layout took ${Date.now()-t}ms.`)}else this._reloadLayout();if(t&&!BM_COLLECTION_VIEW_DISABLE_ISCROLL){this._container.css({"overflow-x":"hidden","overflow-y":"hidden"}),this.customScroll=YES,this.offscreenBufferFactor=0,BMAddSmoothMousewheelInteractionToNode(this._container[0]),this.iScroll=new IScroll(this._container[0],{mouseWheel:YES,scrollbars:YES,probeType:3,click:NO,deceleration:.001,resizePolling:999999999999,scrollX:YES,freeScroll:YES,interactiveScrollbars:!BMIsTouchDevice,disableMouse:YES,disablePointer:YES,fadeScrollbars:BMIsTouchDevice,HWCompositing:YES,bindToWrapper:YES,stopPropagation:YES,disableTouch:NO});var e=this;this.iScroll.on("scroll",(function(){e._handleNewScrollFromEvent({x:-this.x,y:-this.y})}))}else{this._boundContainerDidScrollWithEvent=this.containerDidScrollWithEvent.bind(this);var i=this._highFrequencyScrollingEnabled;this.container[0].addEventListener("scroll",this._boundContainerDidScrollWithEvent,{capture:i,passive:YES})}let o,n,s=NO;this._container[0].addEventListener("wheel",(t=>{(this._size.width>this._frame.size.width||this._size.height>this._frame.size.height)&&t.stopPropagation()}));let a=NO;this._container[0].addEventListener("touchstart",(t=>{o||(s=this._size.width>this._frame.size.width||this._size.height>this._frame.size.height,s&&(o=t.changedTouches[0].identifier,n=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY)))})),this._container[0].addEventListener("touchmove",(t=>{if(!o)return;let e=t.changedTouches.length;for(let i=0;i<e;i++){let e=t.changedTouches[i];if(e.identifier==e){if(a)t.stopPropagation();else{let i=e;BMPointMake(i.clientX,i.clientY).distanceToPoint(n)>_BMCollectionViewClickSlopeThreshold&&(a=YES,t.stopPropagation())}return}}}));let r=t=>{if(!o)return;let e=t.changedTouches.length;for(let i=0;i<e;i++){let e=t.changedTouches[i];if(e.identifier==e)return e=void 0,a&&t.stopPropagation(),a=NO,void(n=void 0)}};this._container[0].addEventListener("touchcancel",r),this._container[0].addEventListener("touchend",r);var l=NO;if(this.delegate&&"function"==typeof this.delegate.collectionViewShouldRunIntroAnimation&&(l=this.delegate.collectionViewShouldRunIntroAnimation(this)),l){let t;this.isUpdatingData=YES,this._dataUpdatePromise=new Promise((e=>t=e));for(var h=this._bounds.rectWithInset(BMInset.insetWithEqualInsets(this._offscreenBufferSize)),c=this.retainedCells.slice(),d=(e=this,0);d<c.length;d++){var u,p=c[d];h.intersectsRect(p.attributes.frame)||(c.splice(d,1),d--),p.attributes.itemType==BMCollectionViewLayoutAttributesType.Cell?u=this.layout.initialAttributesForPresentedCellAtIndexPath(p.indexPath,{withTargetAttributes:p.attributes}):p.attributes.itemType==BMCollectionViewLayoutAttributesType.SupplementaryView&&(u=this.layout.initialAttributesForPresentedSupplementaryViewWithIdentifier(p.reuseIdentifier,{atIndexPath:p.indexPath,withTargetAttributes:p.attributes})),u.targetAttributes=p.attributes,p.attributes=u}var g={};this.delegate&&this.delegate.collectionViewAnimationOptionsForIntroAnimation&&(g=this.delegate.collectionViewAnimationOptionsForIntroAnimation(this)),BMAnimateWithBlock((function(){for(var i=0;i<c.length;i++){var o=c[i];o.attributes=o.attributes.targetAttributes}const n=()=>{e.isUpdatingData=NO,e._executeDataCompletionCallbacks(),t()};c.length?BMAnimationContextAddCompletionHandler(n):n()}),BMExtend({duration:_BMCollectionViewAnimationDurationDefault,easing:_BMCollectionViewAnimationEasingDefault,stride:_BMCollectionViewAnimationStrideDefault,delay:0},g))}this._supportsKeyboardNavigation&&this.configureKeyboardShortcuts(),this.initialized=YES},invalidateLayout:function(){if(!this.initialized)return;if(this._blocksLayoutInvalidation)return;if(!this.isCurrentlyVisible&&!this.allowsOffscreenLayout)return void(this.__awaitsLayout=YES);if(this.isUpdatingData){var t=this;return void this.registerDataCompletionCallback((function(){t.invalidateLayout()}))}let e;if(this._blocksLayoutInvalidation=YES,(e=BMAnimationContextGetCurrent())&&this.layout._copy){let t=this._layout;return this._layout=this._layout._copy,this._layout._collectionView=this,this._layout.prepareLayout(),this.setLayout(t,{animated:YES})}this.attributeCache={},this.retainedCells=[],this._reloadLayout(),this._blocksLayoutInvalidation=NO},invalidateLayoutWithContext:function(t,e){this.invalidateLayout()},resized:function(){if(!this.initialized)return;if(this._frame.size.height==this._container.height()&&this._frame.size.width==this._container.width())return;if(this.isUpdatingData){var t=this;return void this.registerDataCompletionCallback((function(){t.resized()}))}const e=this._frame&&this._frame.copy();this._prepareFrame(),this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize,this._constrainBounds(),this._layout.shouldInvalidateLayoutForFrameChange(this._frame,{fromFrame:e})&&this.invalidateLayout()},_prepareFrame:function(){var t=this._container.offset();this._frame=BMRectMake(t.left,t.top,this._container[0].offsetWidth,this._container[0].offsetHeight),this._offscreenBufferSize=this.customScroll?0:Math.max(this._frame.size.width*this.offscreenBufferFactor,this._frame.size.height*this.offscreenBufferFactor),this.scrollView&&(this.scrollView.frame=this._frame)},_createBounds:function(){this._bounds=this._frame.copy(),this._bounds.size.width+=2*this._offscreenBufferSize,this._bounds.size.height+=2*this._offscreenBufferSize,this._bounds.origin.x=-this._offscreenBufferSize,this._bounds.origin.y=-this._offscreenBufferSize},_constrainBounds:function(){var t=this._bounds;t.right>this._size.width+this._offscreenBufferSize&&(t.origin.x=this._size.width-this._frame.size.width-this._offscreenBufferSize,t.origin.x=Math.max(t.origin.x,-this._offscreenBufferSize)),t.origin.x<-this._offscreenBufferSize&&(t.origin.x=-this._offscreenBufferSize),t.bottom>this._size.height+this._offscreenBufferSize&&(t.origin.y=this._size.height-this._frame.size.height-this._offscreenBufferSize,t.origin.y=Math.max(t.origin.y,-this._offscreenBufferSize)),t.origin.y<-this._offscreenBufferSize&&(t.origin.y=-this._offscreenBufferSize)},invalidateContentSize(){if(this._collectionEnabled){var t=this._layout.contentSize();t.isEqualToSize(this._size)||(this._size=t.copy(),BMHook(this._contentWrapper[0],{width:this._size.width+"px",height:this._size.height+"px"}),this._constrainBounds(),this._applyOverflows())}else this.registerDataCompletionCallback((()=>{this.invalidateContentSize()}))},invalidateLayoutForBoundsChange:function(){if(this.initialized&&!this._blocksLayoutInvalidation)if(this.isCurrentlyVisible||this.allowsOffscreenLayout){this._blocksLayoutInvalidation=YES,this.attributeCache={},this._layout.prepareLayout(),this.invalidateContentSize();var t=this._requestAttributesInRect(this._bounds.copy());this._renderCellsWithAttributes(t,{exclusive:YES}),this._blocksLayoutInvalidation=NO}else this.__awaitsLayout=YES},_reloadLayout:function(){let t=!this._contentWrapper;if(t){const t=document.createElement("div");t.style.cssText="width: 900px; height: 900px; overflow: hidden; position: absolute; left: 0px; top: 0px;",this._contentWrapper=BMJQueryShim.shimWithDOMNode(t),this._container.append(this._contentWrapper)}this._layout.prepareLayout(),this._size=this._layout.contentSize().copy(),this.scrollView&&(this.scrollView.size=this._size),BMHook(this._contentWrapper[0],{width:this._size.width+"px",height:this._size.height+"px"}),this._constrainBounds(),this._applyOverflows();var e=this._requestAttributesInRect(this._bounds.copy());this._renderCellsWithAttributes(e,{exclusive:YES}),this._cellLayoutQueue.dequeue()},_applyOverflows:function(){if(this.customScroll){if(this.iScroll)return void this.iScroll.refresh();if(this.scrollView.canScrollHorizontally=this._size.width>this._frame.size.width,this.scrollView.canScrollVertically=this._size.height>this._frame.size.height,this.initialized)return;this._container.css({"overflow-x":"hidden","overflow-y":"hidden"})}else this._size.width<=this._frame.size.width?this._container.css("overflow-x","hidden"):this._container.css("overflow-x","scroll"),this._size.height<=this._frame.size.height?this._container.css("overflow-y","hidden"):this._container.css("overflow-y","scroll")},_alignedRequestRectWithRect:function(t){return this._alignedRequestRectWithPoint(t.origin)},_alignedRequestOriginWithPoint:function(t){return BMPointMake(((t.x+this._offscreenBufferSize)/this._bounds.size.width|0)*this._bounds.size.width-this._offscreenBufferSize,((t.y+this._offscreenBufferSize)/this._bounds.size.height|0)*this._bounds.size.height-this._offscreenBufferSize)},_alignedRequestRectWithPoint:function(t){if(!(t.x<-this._offscreenBufferSize||t.y<-this._offscreenBufferSize||t.x>this._size.width||t.y>this._size.height))return new BMRect(this._alignedRequestOriginWithPoint(t),this._bounds.size)},_requestAttributesInRect:function(t){var e=this._layout.attributesForElementsInRect(t);return this.attributeCache[t.origin.integerStringValue]={key:t,value:e},e},_highFrequencyScrollingEnabled:NO,get highFrequencyScrollingEnabled(){return this._highFrequencyScrollingEnabled},set highFrequencyScrollingEnabled(t){var e=this._highFrequencyScrollingEnabled;this._highFrequencyScrollingEnabled=t,this.initialized&&!this.iScroll&&(this.container[0].removeEventListener("scroll",this._boundContainerDidScrollWithEvent,{capture:e,passive:YES}),this.container[0].addEventListener("scroll",this._boundContainerDidScrollWithEvent,{capture:t,passive:YES}))},containerDidScrollWithEvent:function(t){if(this._collectionEnabled)return this._highFrequencyScrollingEnabled?this._handleNewScrollFromEvent(t):void(this.didRequestScrollAnimationFrame||(this.didRequestScrollAnimationFrame=YES,window.requestAnimationFrame(this._handleNewScrollFromEvent.bind(this,t))))},_handleNewScrollFromEvent:function(t){if(this.didRequestScrollAnimationFrame=NO,!this._collectionEnabled)return;var e,i=this._container[0],o=!this._isPerformingAnimatedScrolling&&this._layout.snapsScrollPosition;if(e=this._bounds.origin.copy(),this.customScroll?(this._bounds.origin.x=t.x-this._offscreenBufferSize,this._bounds.origin.y=t.y-this._offscreenBufferSize):(this._bounds.origin.x=Math.max(-this._offscreenBufferSize,i.scrollLeft-this._offscreenBufferSize),this._bounds.origin.y=Math.max(-this._offscreenBufferSize,i.scrollTop-this._offscreenBufferSize)),e.x==this._bounds.origin.x&&e.y==this._bounds.origin.y)return;const n=BMRectMakeWithOrigin(e,{size:this._bounds.size.copy()});if((async()=>{await 0,this._cellLayoutQueue.dequeue()})(),this._layout.shouldInvalidateLayoutForBoundsChange(this._bounds,{fromBounds:n}))return this.invalidateLayoutForBoundsChange(),this.delegate&&"function"==typeof this.delegate.collectionViewBoundsDidChange&&this.delegate.collectionViewBoundsDidChange(this,this._bounds,{fromBounds:n}),this._layout.didInvalidateLayoutForBoundsChange(),void(o&&this._prepareForSnappingScrollOffsetWithPreviousOffset(e));for(var s=0;s<this.retainedCells.length;s++){var a=this.retainedCells[s];a.attributes.frame.intersectsRect(this._bounds)||(a._unmanage(),s--)}var r=[],l=this._alignedRequestOriginWithPoint(this._bounds.origin),h=this.attributeCache[l.integerStringValue];if(h&&r.push(h),!l.isEqualToPoint(this._bounds.origin))if(l.x==this._bounds.origin.x){var c=l;c.y+=this._bounds.size.height;var d=this.attributeCache[c.integerStringValue];d&&r.push(d)}else if(l.y==this._bounds.origin.y){var u=l;u.x+=this._bounds.size.width;var p=this.attributeCache[u.integerStringValue];p&&r.push(p)}else{(c=l.copy()).y+=this._bounds.size.height,(d=this.attributeCache[c.integerStringValue])&&r.push(d),(u=l).x+=this._bounds.size.width,(p=this.attributeCache[u.integerStringValue])&&r.push(p);var g=c;g.x+=this._bounds.size.width;var w=this.attributeCache[g.integerStringValue];w&&r.push(w)}for(var y=r.length,m=[this._bounds],_=0;_<y;_++){var f=r[_].value,v=r[_].key;this._renderCellsWithAttributes(f);var M=[];for(s=0;s<m.length;s++){var S=m[s].rectsWithDifferenceFromRect(v);S&&(M=M.concat(S))}m=M}if(!y){m=[];var C=this._alignedRequestRectWithPoint(this._bounds.origin);if(C.isEqualToRect(this._bounds)){f=this._requestAttributesInRect(C);this._renderCellsWithAttributes(f)}else if(C.origin.x==this._bounds.origin.x){var b=this._alignedRequestRectWithPoint({x:C.origin.x,y:C.bottom+1});f=this._requestAttributesInRect(C);this._renderCellsWithAttributes(f),b&&(f=this._requestAttributesInRect(b),this._renderCellsWithAttributes(f))}else if(C.origin.y==this._bounds.origin.y){var B=this._alignedRequestRectWithPoint({x:C.right+1,y:C.origin.y});f=this._requestAttributesInRect(C);this._renderCellsWithAttributes(f),B&&(f=this._requestAttributesInRect(B),this._renderCellsWithAttributes(f))}else{m.push(C),(b=this._alignedRequestRectWithPoint({x:C.origin.x,y:C.bottom+1}))&&m.push(b),(B=this._alignedRequestRectWithPoint({x:C.right+1,y:C.origin.y}))&&m.push(B);var E=this._alignedRequestRectWithPoint({x:C.right+1,y:C.bottom+1});E&&m.push(E);for(s=0;s<m.length;s++){f=this._requestAttributesInRect(m[s]);this._renderCellsWithAttributes(f)}}return this.delegate&&"function"==typeof this.delegate.collectionViewBoundsDidChange&&this.delegate.collectionViewBoundsDidChange(this,this._bounds,{fromBounds:n}),void(o&&this._prepareForSnappingScrollOffsetWithPreviousOffset(e))}if(m)for(s=0;s<m.length;s++){var V=this._alignedRequestRectWithRect(m[s]);if(V){f=this._requestAttributesInRect(V);this._renderCellsWithAttributes(f)}}this.delegate&&"function"==typeof this.delegate.collectionViewBoundsDidChange&&this.delegate.collectionViewBoundsDidChange(this,this._bounds,{fromBounds:n}),this._isPerformingAnimatedScrolling||o&&this._prepareForSnappingScrollOffsetWithPreviousOffset(e)},_snappingScrollToken:void 0,_prepareForSnappingScrollOffsetWithPreviousOffset:function(t){this._snappingScrollToken&&window.clearTimeout(this._snappingScrollToken);var e=this;this._snappingScrollToken=window.setTimeout((function(){var i=Math.max(-1,Math.min(1,t.x-e._bounds.origin.x)),o=Math.max(-1,Math.min(1,t.y-e._bounds.origin.y)),n=e.layout.snappingScrollOffsetForScrollOffset(e.scrollOffset,{withVerticalDirection:o,horizontalDirection:i});BMAnimateWithBlock((t=>{e.scrollOffset=n}),{duration:200})}),_BMCollectionViewSnappingScrollThreshold)},_renderCellsWithAttributes:function(t,e){for(var i=t.length,o=(e=e||{}).exclusive||NO,n=0;n<i;n++){var s=t[n];if(s.frame.intersectsRect(this._bounds))if(l=this.cellAtIndexPath(s.indexPath,{ofType:s.itemType,withIdentifier:s.identifier}))l.isManaged?l.attributes!==s&&(s.isHidden?(l._unmanage(),l.isRetained&&(l.attributes=s)):l.attributes=s):(s.isHidden||l._manage(),l.attributes=s),o&&(l._exclusivelyRendered=YES);else if(!s.isHidden){if(s.itemType===BMCollectionViewLayoutAttributesType.Cell){var a=this.indexPathForObjectAtRow(s.indexPath.row,{inSectionAtIndex:s.indexPath.section});s.indexPath=a,l=this._dataSet.cellForItemAtIndexPath(a)}else s.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&(l=this._dataSet.cellForSupplementaryViewWithIdentifier(s.identifier,{atIndexPath:s.indexPath}));l.attributes=s,l._manage(),o&&(l._exclusivelyRendered=YES)}}if(o){var r=this.allCells.length;for(n=0;n<r;n++){var l;if((l=this.allCells[n])._reuseState!=BMCollectionViewCellReuseState.Deleting)if(l._exclusivelyRendered)l._exclusivelyRendered=void 0;else if(l.isManaged&&l._unmanage(),l.retainCount>0){if(l.itemType===BMCollectionViewLayoutAttributesType.Cell){let t=this._layout.attributesForCellAtIndexPath(l.indexPath);l.attributes=t}else if(l.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView){let t=this._layout.attributesForSupplementaryViewWithIdentifier(l.reuseIdentifier,{atIndexPath:l.indexPath});l.attributes=t}}else n--,r--}}},_measuringCells:void 0,_retainMeasuringCells(){this._measuringCells=[]},_releaseMeasuringCells(){this._measuringCells&&this._measuringCells.forEach((t=>t.release())),this._measuringCells=void 0},_measures:void 0,_measuredIndexPaths:void 0,_updateMeasuredCellsIndexPaths:function(){var t=this._measuredIndexPaths;this._measuredIndexPaths=[];for(var e=t.length,i=0;i<e;i++){var o=this.dataSet.indexPathForObject(t[i].indexPath.object);o&&(t[i].indexPath=o,this._measuredIndexPaths.push(t[i]))}},invalidateMeasuredSizeOfCells(){this._measures={},this._measuredIndexPaths=[]},invalidateMeasuredSizeOfCellsWithBlock(t){if(this._dataSet.identifierForIndexPath){let e=[];for(let i in this._measures)t(this._measures[i],void 0,i)&&e.push(i);for(let t of e)delete this._measures[t]}else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++)t(this._measuredIndexPaths[i].size,this._measuredIndexPaths[i].indexPath)&&(this._measuredIndexPaths.splice(i,1),e--,i--)}},invalidateMeasuredSizeOfCellAtIndexPath(t){let e;if(this._dataSet.identifierForIndexPath)e=this._dataSet.identifierForIndexPath(t),this._measures[e]&&delete this._measures[e];else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++){if(this._measuredIndexPaths[i].indexPath.isEqualToIndexPath(t,{usingComparator:this.identityComparator})){this._measuredIndexPaths.splice(i,1);break}}}},measureSizesOfCellsAtIndexPaths(t){const e=BMViewLayoutQueue.layoutQueue(),i=t.map((t=>this._measuredSizeOfCellAtIndexPathGenerator(t,{layoutQueue:e,dequeue:NO})));i.forEach((t=>t.next())),e.dequeue(),i.forEach((t=>t.next()))},measuredSizeOfCellAtIndexPath(t){const e=this._measuredSizeOfCellAtIndexPathGenerator(t,{layoutQueue:BMViewLayoutQueue.layoutQueue(),dequeue:YES});for(;YES;){const t=e.next();if(t.done)return t.value}let i;if(this._dataSet.identifierForIndexPath){if(i=this._dataSet.identifierForIndexPath(t),this._measures[i])return this._measures[i]}else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++){if(this._measuredIndexPaths[i].indexPath.isEqualToIndexPath(t,{usingComparator:this.identityComparator}))return this._measuredIndexPaths[i].size}}if(BM_COLLECTION_VIEW_DEBUG_MEASURE&&!this.__debug__measuring){this.__debug__measuring=YES;let t=document.createElement("div");t.style.cssText="position: fixed; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",document.body.appendChild(t),requestAnimationFrame((()=>(t.remove(),this.__debug__measuring=NO)))}let o,n=this.cellAtIndexPath(t),s=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);if(s.frame=BMRectMake(0,0,1e4,1e4),n?o=n.attributes:n=this._dataSet.cellForItemAtIndexPath(t),BM_COLLECTION_VIEW_DEBUG_MEASURE_CELL){let t=document.createElement("div");t.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",n.node.appendChild(t),requestAnimationFrame((()=>t.remove()))}n._isMeasuring=YES,n._invalidatedConstraints=YES;const a=n.layoutQueue;n.layoutQueue=BMViewLayoutQueue.layoutQueue(),n.attributes=s,n.retain();let r,l=[],h=n.left.equalTo(0);h.isActive=YES,l.push(h),h=n.top.equalTo(0),h.isActive=YES,l.push(h),h=n.width.equalTo(0,{priority:1}),h.isActive=YES,l.push(h),h=n.height.equalTo(0,{priority:1}),h.isActive=YES,l.push(h);for(let e of this.layout.constraintsForMeasuringCell(n,{atIndexPath:t}))e.isActive=YES,l.push(e);n.layoutIfNeeded(),n.layoutQueue=a,this._measuringCells&&this._measuringCells.push(n.retain()),r=n._subviews.length?n.subviews[0].frame.size:BMSizeMake(n._variables[BMLayoutAttribute.Width].value()|n.node.offsetWidth,n._variables[BMLayoutAttribute.Height].value()|n.node.offsetHeight),n.release();for(let t of l)t.remove();return n.retainCount>0&&o?n.attributes=o:(n._attributes=void 0,s._cell=void 0),n._invalidatedConstraints=YES,n._isMeasuring=NO,i?this._measures[i]=r.copy():this._measuredIndexPaths.push({indexPath:t,size:r}),r},*_measuredSizeOfCellAtIndexPathGenerator(t,{layoutQueue:e,dequeue:i}){let o;if(this._dataSet.identifierForIndexPath){if(o=this._dataSet.identifierForIndexPath(t),this._measures[o])return this._measures[o]}else{let e=this._measuredIndexPaths.length;for(let i=0;i<e;i++){if(this._measuredIndexPaths[i].indexPath.isEqualToIndexPath(t,{usingComparator:this.identityComparator}))return this._measuredIndexPaths[i].size}}if(!this.isCurrentlyVisible)return this.__awaitsLayout=YES,BMSizeMake(0,0);if(BM_COLLECTION_VIEW_DEBUG_MEASURE&&!this.__debug__measuring){this.__debug__measuring=YES;let t=document.createElement("div");t.style.cssText="position: fixed; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",document.body.appendChild(t),requestAnimationFrame((()=>(t.remove(),this.__debug__measuring=NO)))}let n,s=this.cellAtIndexPath(t),a=BMCollectionViewLayoutAttributesMakeForCellAtIndexPath(t);if(a.frame=BMRectMake(0,0,1e4,1e4),s?n=s.attributes:s=this._dataSet.cellForItemAtIndexPath(t),BM_COLLECTION_VIEW_DEBUG_MEASURE_CELL){let t=document.createElement("div");t.style.cssText="position: absolute; z-index: 999999999; top: 0px; left: 0px; width: 100%; height: 100%; background-color: red; pointer-events: none;",s.node.appendChild(t),requestAnimationFrame((()=>t.remove()))}s._isMeasuring=YES,s._invalidatedConstraints=YES,s._subviews.length||(s._needsIntrinsicSizeMeasurement=YES);const r=s.layoutQueue;s._cancelLayout(),s.layoutQueue=e,s.attributes=a,s.retain();let l,h=[],c=s.left.equalTo(0);c.isActive=YES,h.push(c),c=s.top.equalTo(0),c.isActive=YES,h.push(c),c=s.width.equalTo(0,{priority:1}),c.isActive=YES,h.push(c),c=s.height.equalTo(0,{priority:1}),c.isActive=YES,h.push(c);for(let e of this.layout.constraintsForMeasuringCell(s,{atIndexPath:t}))e.isActive=YES,h.push(e);yield,i&&s.layoutIfNeeded(),s.layoutQueue=r,this._measuringCells&&this._measuringCells.push(s.retain()),l=s._subviews.length?s.subviews[0].frame.size:BMSizeMake(s._variables[BMLayoutAttribute.Width].value()||s.node.offsetWidth,s._variables[BMLayoutAttribute.Height].value()||s.node.offsetHeight),s.release();for(let t of h)t.remove();return s.retainCount>0&&n?s.attributes=n:(s._attributes=void 0,a._cell=void 0),s._invalidatedConstraints=YES,s._isMeasuring=NO,o?this._measures[o]=l.copy():this._measuredIndexPaths.push({indexPath:t,size:l}),l},refreshCellAtIndexPath:function(t,e){var i=e&&e.animated,o=this.cellAtIndexPath(t,{ofType:BMCollectionViewLayoutAttributesType.Cell});if(o){var n=o.attributes.copy();if(o._attributes=o.attributes.copy(),o._attributes.indexPath=BMIndexPathNone,o._attributes._cell=o,i){var s=this.dataSet.cellForItemAtIndexPath(t),a=n.style.opacity;void 0===a&&(a=1),n.style.opacity=0;var r=o.attributes.style.opacity;return void 0===r&&(r=1),s.attributes=n,n.isHidden||s._manage(),o.retain(),s.retain(),o._unmanage(),BMAnimateWithBlock((function(){s.attributes.style.opacity=a,o.attributes.style.opacity=0,s.attributes.style=s.attributes.style,o.attributes.style=o.attributes.style}),{duration:100,easing:"easeInOutQuad",queue:NO,complete:function(){s.release(),o.releaseRecycledCell(),o.attributes.style.opacity=r}}),s}return o.recycle(),n.isHidden?void 0:((s=this.dataSet.cellForItemAtIndexPath(t)).attributes=n,s._manage(),s)}},dequeueCellForReuseIdentifier:function(t){var e=this.cellCache[t];if(e&&e.length)return(i=e.pop()).node.style.opacity=i._backingOpacity,i;var i,o=this._cellClasses[t]||this._cellClass,n=document.createElement("div");n.style.cssText="position: absolute; left: 0px; top: 0px; visibility: hidden; overflow: visible;",(i=Object.create(o.prototype).initWithCollectionView(this,{reuseIdentifier:t,node:n,kind:BMCollectionViewLayoutAttributesType.Cell})).layoutQueue=this._cellLayoutQueue,o==BMCollectionViewCell&&this._usesLegacyDataSet&&i.element.append(this._dataSet.contentsForCellWithReuseIdentifier(t)),this._contentWrapper.append(i.element);var s,a,r,l=this,h=0,c=NO,d=BMPointMake(),u=NO,p=NO,g=NO,w=NO,y=NO;const m=()=>{u=NO,g=NO,r=void 0,window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES),h=0,s&&(window.clearTimeout(s),s=void 0),a&&(window.clearTimeout(a),a=void 0)};return i.mousedownHandler=function(t){if(_BMCoreUIIsDragging)return t.preventDefault(),void t.stopPropagation();t.originalEvent=t;const e=t.which||t.button;if(("touchstart"==t.originalEvent.type||1==e)&&!("BUTTON"==t.target.nodeName||"INPUT"==t.target.nodeName||"LABEL"==t.target.nodeName||"A"==t.target.nodeName||"BUTTON"==t.target.parentNode.nodeName||"INPUT"==t.target.parentNode.nodeName||"LABEL"==t.target.parentNode.nodeName||t.target.classList.contains("BMCollectionViewCellEventHandler")||t.target.parentNode.classList.contains("BMCollectionViewCellEventHandler")||t.target.classList.contains("widget-foldingpanel-header")||t.target.hasAttribute("contenteditable")||window.$&&window.$(t.target).parents(".widget-dhxdropdown").length)){if("touchstart"==t.originalEvent.type){if(void 0!==r)return;r=t.originalEvent.touches[0].identifier}else window.addEventListener("mousemove",i.mousemoveHandler,YES),window.addEventListener("mouseup",i.mouseupHandler,YES);y=NO,l.delegate&&l.delegate.collectionViewCanMoveCell&&(y=l.delegate.collectionViewCanMoveCell(l,i,{atIndexPath:i.indexPath})),y&&t.preventDefault(),d.x=t.pageX||t.originalEvent.touches&&t.originalEvent.touches[0].pageX||0,d.y=t.pageY||t.originalEvent.touches&&t.originalEvent.touches[0].pageY||0,c=NO,g=NO,s=window.setTimeout((function(){if(s=void 0,c=YES,l.cellWasLongClicked(i,{withEvent:t}))y&&(g=YES);else if(y){if(t.BM_Handled)return void m();t.BM_Handled=YES,window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES),u=NO,l.delegate&&l.delegate.collectionViewWillBeginInteractiveMovementForCell&&l.delegate.collectionViewWillBeginInteractiveMovementForCell(l,i,{atIndexPath:i.indexPath}),l.beginDragWithEvent(t,{forCell:i,touchIdentifier:r}),r=void 0}}),_BMCollectionViewLongClickDelay),p=NO,l.delegate&&l.delegate.collectionViewCanDoubleClickCell&&(p=l.delegate.collectionViewCanDoubleClickCell(l,i)),p&&(a=window.setTimeout((function(){a=void 0,h&&(l.cellWasClicked(i,{withEvent:t}),h=0)}),_BMCollectionViewDoubleClickDelay)),u=YES}},i.element[0].addEventListener("mousedown",i.mousedownHandler,w),i.element[0].addEventListener("touchstart",i.mousedownHandler,w),i.mousemoveHandler=function(t){if(t.BM_Handled)return void m();if(_BMCoreUIIsDragging)return t.preventDefault(),void t.stopPropagation();y&&t.preventDefault(),t.originalEvent=t;t.which||t.button;if(u){if("touchmove"==t.type){if(void 0===r)return;for(var e=0;e<t.originalEvent.changedTouches.length;e++)if(t.originalEvent.changedTouches[e].identifier==r){var o=t.originalEvent.changedTouches[e].pageX,n=t.originalEvent.changedTouches[e].pageY;break}if(e==t.originalEvent.changedTouches.length)return}else o=t.pageX,n=t.pageY;(Math.abs(o-d.x)>_BMCollectionViewClickSlopeThreshold||Math.abs(n-d.y)>_BMCollectionViewClickSlopeThreshold)&&(window.clearTimeout(s),window.clearTimeout(a),u=NO,h&&(l.cellWasClicked(i,{withEvent:t}),h=0),("mousemove"==t.type||g)&&y&&(t.BM_Handled=YES,l.delegate&&l.delegate.collectionViewWillBeginInteractiveMovementForCell&&l.delegate.collectionViewWillBeginInteractiveMovementForCell(l,i,{atIndexPath:i.indexPath}),window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES),l.beginDragWithEvent(t,{forCell:i,touchIdentifier:r}),r=void 0))}},i.element[0].addEventListener("touchmove",i.mousemoveHandler,w),i.touchcancelHandler=function(t){if(_BMCoreUIIsDragging)return;t.originalEvent=t;t.which||t.button;if(void 0!==r){for(var e=0;e<t.originalEvent.changedTouches.length;e++)if(t.originalEvent.changedTouches[e].identifier==r){r=void 0,t.preventDefault();break}e!=t.originalEvent.changedTouches.length&&window.clearTimeout(a)}},i.element[0].addEventListener("touchcancel",i.touchcancelHandler,w),i.mouseupHandler=function(t){if(_BMCoreUIIsDragging)return;t.originalEvent=t;const e=t.which||t.button;if("mouseup"!=t.originalEvent.type||1==e){if("touchend"==t.originalEvent.type){if(void 0===r)return;for(var o=0;o<t.originalEvent.changedTouches.length;o++)if(t.originalEvent.changedTouches[o].identifier==r){r=void 0,t.preventDefault();break}if(o==t.originalEvent.changedTouches.length)return}else window.removeEventListener("mousemove",i.mousemoveHandler,YES),window.removeEventListener("mouseup",i.mouseupHandler,YES);u&&(u=NO,c||(window.clearTimeout(s),p?a&&++h>=2&&(h=0,l.cellWasDoubleClicked(i,{withEvent:t}),window.clearTimeout(a)):l.cellWasClicked(i,{withEvent:t})))}},i.element[0].addEventListener("touchend",i.mouseupHandler,w),i.contextMenuHandler=function(t){l.cellWasRightClicked(i,{withEvent:t})&&(t.preventDefault(),t.stopPropagation())},i.element[0].addEventListener("contextmenu",i.contextMenuHandler),i},isDragging:NO,interactiveMovement:void 0,_draggingIndexPaths:void 0,invalidateDraggingIndexPaths(){this._draggingIndexPaths&&(this._draggingIndexPaths=this._draggingIndexPaths.map((t=>this._dataSet.indexPathForObject(t.object))))},_canAcceptItems(t){return this.delegate&&this.delegate.collectionViewCanAcceptItems?this.delegate.collectionViewCanAcceptItems(this,t):NO},_insertItems:async function(t,e){this._droppedShadows=e.withDropShadows,this.dataSet.insertItems(t,e),await new Promise(((t,e)=>{this.registerDataCompletionCallback((()=>{t()}))}))},beginDragWithEvent(t,e){if(this.isDragging)return;let i,o=e.touchIdentifier;this.interactiveMovement=new Promise((function(t,e){i=t})),this.isDragging=YES,_BMCoreUIIsDragging=YES;let n=e.forCell,s=[];const a=n.node.classList.contains(BMMenuSourceNodeCSSClass);a&&n.node.classList.remove(BMMenuSourceNodeCSSClass);let r,l=n.node.cloneNode(YES);l.classList.add("BMDragShadow"),s.push(l),this.isCellAtIndexPathSelected(n.indexPath)?(r=[],this._selectedIndexPaths.sort(((t,e)=>e.section==t.section?t.row-e.row:t.section-e.section)).forEach((t=>{let e=this.retainCellForIndexPath(t);r.push(e),e.isDragging=YES,e.node.classList.add("BMCollectionViewCellDragging")}))):(r=[n],n.isDraggging=YES,n.retain(),n.node.classList.add("BMCollectionViewCellDragging"));let h,c,d=document.createElement("div");if(d.classList.add("BMDragIndicator"),d.innerText=r.length.toFixed(),d.style.zIndex="99999999",void 0!==o){for(var u=0;u<t.changedTouches.length;u++)if(t.changedTouches[u].identifier==o){h=t.changedTouches[u].clientX,c=t.changedTouches[u].clientY;break}}else h=t.clientX,c=t.clientY;let p=BMRectMakeWithNodeFrame(n.node),g=BMPointMake(h-p.origin.x,c-p.origin.y),w=BMPointMake(h-g.x,c-g.y),y=[],m=new Map,_=YES,f=null;r.forEach((t=>{if(t==n||y.length>=10)return;let e=t.node.cloneNode(YES);e.classList.add("BMDragShadow"),e.classList.remove("BMCollectionViewCellDragging"),s.splice(1,0,e),f=e;let i=BMRectMakeWithNodeFrame(t.node);m.set(e,t),e.style.pointerEvents="none",e.style.position="fixed",e.style.left=i.origin.x+"px",e.style.top=i.origin.y+"px",BMHook(e,{translateX:0,translateY:0}),e.style.zIndex=99999997,y.push(e);let o=y.length;(window.Velocity||$.Velocity).animate(e,{tween:1},{easing:"easeInOutQuad",duration:300,progress:(t,n,s,a,l)=>{BMHook(e,{rotateZ:l*(60*o/r.length)+"deg"}),e.style.left=BMNumberByInterpolatingNumbersWithFraction(i.origin.x,w.x,l)+"px",e.style.top=BMNumberByInterpolatingNumbersWithFraction(i.origin.y,w.y,l)+"px"},complete(){_=NO}})})),l.style.transform="",l.style.pointerEvents="none",l.style.position="fixed",l.style.left=h-g.x+"px",l.style.top=c-g.y+"px",l.style.zIndex=99999998,d.style.left=h-g.x-12+"px",d.style.top=c-g.y-12+"px",BMHook(d,{scaleX:0,scaleY:0}),s.forEach((t=>document.body.appendChild(t))),document.body.appendChild(d),__BMVelocityAnimate(d,{opacity:[1,0],scaleX:[1,0],scaleY:[1,0]},{duration:300,easing:"easeOutQuad"}),this.layout.prepareForDragOperation();let v=BMRectMakeWithNodeFrame(this.container[0]),M=0,S=0;var C=()=>{if(b=window.requestAnimationFrame(C),S||M){let t=this.scrollOffset;t.x=t.x+S,t.y=t.y+M,t.x=Math.max(0,Math.min(t.x,this.size.width-this.frame.size.width)),t.y=Math.max(0,Math.min(t.y,this.size.height-this.frame.size.height)),this.scrollOffset=t}},b=window.requestAnimationFrame(C);let B=NO,E=NO,V=NO;n.indexPath;this._draggingIndexPaths=r.map((t=>t.indexPath));let L,x,A,I,P=[],W=new Map;this.delegate&&this.delegate.collectionViewCanTransferItemsAtIndexPaths&&(V=this.delegate.collectionViewCanTransferItemsAtIndexPaths(this,this._draggingIndexPaths),V&&(_BMCollectionViews.forEach(((t,e)=>{if(e==this)return;if(!e._canAcceptItems(this._draggingIndexPaths.map((t=>t.object))))return;let i;P.push(e),o||(i={mouseover:t=>(x=e,L=BMRectMakeWithNodeFrame(e._container[0]),d.classList.add("BMDragIndicatorBlue"),t.preventDefault(),t.stopPropagation(),NO),mouseout:t=>(x=void 0,L=void 0,d.classList.remove("BMDragIndicatorBlue"),t.preventDefault(),t.stopPropagation(),NO)},e._container[0].addEventListener("mouseover",i.mouseover),e._container[0].addEventListener("mouseout",i.mouseout)),e._container[0].classList.add("BMDropTarget"),W.set(e,i)})),void 0!==o&&(I=t=>{let e,i;for(var n=0;n<t.changedTouches.length;n++)if(t.changedTouches[n].identifier==o){e=t.changedTouches[n].clientX,i=t.changedTouches[n].clientY;break}if(n==t.changedTouches.length)return NO;let s,a=document.elementFromPoint(e,i);if(a)for(let t of P)if(t._container[0].contains(a)){s=t;break}s!=x&&(x=s,s?(L=BMRectMakeWithNodeFrame(x._container[0]),d.classList.add("BMDragIndicatorBlue")):(L=void 0,d.classList.remove("BMDragIndicatorBlue")))}))),a&&n.node.classList.add(BMMenuSourceNodeCSSClass);let T=t=>{let e,i;if(t.preventDefault(),void 0!==o){t.preventDefault();for(var n=0;n<t.changedTouches.length;n++)if(t.changedTouches[n].identifier==o){e=t.changedTouches[n].clientX,i=t.changedTouches[n].clientY;break}if(n==t.changedTouches.length)return t.preventDefault()}else e=t.clientX,i=t.clientY;if(l.style.left=e-g.x+"px",l.style.top=i-g.y+"px",d.style.left=e-g.x-12+"px",d.style.top=i-g.y-12+"px",_?w=BMPointMake(e-g.x,i-g.y):y.forEach(((t,o)=>{t.style.left=e-g.x+"px",t.style.top=i-g.y+"px"})),this.isUpdatingData)return t.preventDefault(),t.stopPropagation();if(S=e-v.origin.x<32?(e-v.origin.x-32)/32*20:v.right-e<32?(32-v.right+e)/32*20:0,M=i-v.origin.y<32?(i-v.origin.y-32)/32*20:v.bottom-i<32?(32-v.bottom+i)/32*20:0,i<v.top||i>v.bottom||e<v.left||e>v.right?B||(B=YES,S=0,M=0,this.delegate&&this.delegate.collectionViewCanRemoveItemsAtIndexPaths&&(E=this.delegate.collectionViewCanRemoveItemsAtIndexPaths(this,this._draggingIndexPaths)),E&&d.classList.add("BMDragIndicatorRed")):B&&(B=NO,E=NO,d.classList.remove("BMDragIndicatorRed")),x){S=0,M=0;let o=BMPointMake(e-L.origin.x,i-L.origin.y);o.x+=x.scrollOffset.x,o.y+=x.scrollOffset.y;let n=BMRectMake(0,0,128,128);n.center=o;let s,a=x.layout.attributesForElementsInRect(n),r=Number.MAX_SAFE_INTEGER,l=0;return a.forEach(((t,e)=>{if(t.itemType!=BMCollectionViewLayoutAttributesType.Cell)return;t.frame.containsPoint(o)&&(s=t.indexPath.copy());let i=o.distanceToPoint(t.frame.center);i<r&&(r=i,l=e)})),s?A=s:a.length&&(A=a[l].indexPath.copy()),t.preventDefault(),t.stopPropagation()}if(S||M)return t.preventDefault(),t.stopPropagation();let s=BMPointMake(e-v.origin.x,i-v.origin.y);s.x+=this.scrollOffset.x,s.y+=this.scrollOffset.y;let a=BMRectMake(0,0,64,64);a.center=s;let h,c=this.layout.attributesForElementsInRect(a),u=NO;c.forEach((t=>{if(t.itemType!=BMCollectionViewLayoutAttributesType.Cell)return;if(u)return;t.frame.containsPoint(s)&&(h=t.indexPath.copy());let e=YES;h&&(this._draggingIndexPaths.forEach((t=>{h.row==t.row&&h.section==t.section&&(e=NO)})),e&&(u=YES,this.dataSet.moveItemsFromIndexPaths&&1!=r.length?this._draggingIndexPaths=this.dataSet.moveItemsFromIndexPaths(this._draggingIndexPaths,{toIndexPath:h}).sort(((t,e)=>t.section==e.section?t.row-e.row:t.section-e.section)):this._draggingIndexPaths.forEach(((t,e)=>{let i=h.copy();i.object=t.object,i.row+=e,this.dataSet.moveItemFromIndexPath(t,{toIndexPath:i})&&(this._draggingIndexPaths[e]=i)}))))})),t.preventDefault(),t.stopPropagation()};window.addEventListener(void 0!==o?"touchmove":"mousemove",T,{capture:YES,passive:NO}),void 0!==o&&window.addEventListener("touchmove",I,{capture:YES,passive:NO});let z=async t=>{if(void 0!==o){for(var e=0;e<t.changedTouches.length&&t.changedTouches[e].identifier!=o;e++);if(e==t.changedTouches.length)return}this.delegate&&this.delegate.collectionViewWillFinishInteractiveMovementForCell&&this.delegate.collectionViewWillFinishInteractiveMovementForCell(this,n,{atIndexPath:n.indexPath}),window.removeEventListener(void 0!==o?"touchmove":"mousemove",T,{capture:YES,passive:NO}),window.removeEventListener(void 0!==o?"touchend":"mouseup",z,{capture:YES,passive:NO}),void 0!==o&&window.removeEventListener("touchcancel",z,{capture:YES,passive:NO}),o?(P.forEach((t=>t._container[0].classList.remove("BMDropTarget"))),window.removeEventListener("touchmove",I,{capture:YES,passive:NO})):W.forEach(((t,e)=>{e._container[0].removeEventListener("mouseover",t.mouseover),e._container[0].removeEventListener("mouseout",t.mouseout),e._container[0].classList.remove("BMDropTarget")})),window.cancelAnimationFrame(b);let s=BMRectMakeWithNodeFrame(l),a=BMRectMakeWithNodeFrame(n.node);if(i(),__BMVelocityAnimate(d,{scaleX:0,scaleY:0,opacity:0},{duration:300,easing:"easeInOutQuad"}),x){let t=A;if(!t){let e=x.numberOfSections();t=x.indexPathForObjectAtRow(x.numberOfObjectsInSectionAtIndex(e-1)-1,{inSectionAtIndex:e-1})}let e=new Map,i=this._draggingIndexPaths.map((t=>{if(this._dataSet.copyOfItem)return this._dataSet.copyOfItem(t.object);{const e=JSON.parse(JSON.stringify(t.object));for(const i in t.object)void 0===t.object[i]&&(e[i]=void 0);return e}})),o=0;(()=>{let t;for(let e=0;e<i.length;e++)this._draggingIndexPaths[e].row==n.indexPath.row&&this._draggingIndexPaths[e].section==n.indexPath.section&&(t=i[e]);e.set(t,{node:l,rotation:0})})(),m.forEach(((t,n)=>{let s;for(let e=0;e<i.length;e++)this._draggingIndexPaths[e].row==t.indexPath.row&&this._draggingIndexPaths[e].section==t.indexPath.section&&(s=i[e]);e.set(s,{node:n,rotation:60*(o+1)/r.length}),o++}));let s=BMCollectionViewTransferPolicy.Copy;this.delegate&&this.delegate.collectionViewTransferPolicyForItemsAtIndexPaths&&(s=this.delegate.collectionViewTransferPolicyForItemsAtIndexPaths(this,this._draggingIndexPaths));let a=BMCollectionViewTransferPolicy.Copy;x.delegate&&x.delegate.collectionViewAcceptPolicyForItems&&(a=x.delegate.collectionViewAcceptPolicyForItems(x,i)),E=s==BMCollectionViewTransferPolicy.Move&&a==BMCollectionViewAcceptPolicy.Move?YES:NO,this.isDragging=NO,E&&this.dataSet.removeItemsAtIndexPaths(this._draggingIndexPaths),r.forEach((t=>{t.node.classList.remove("BMCollectionViewCellDragging")})),await x._insertItems(i,{toIndexPath:t,withDropShadows:e}),this.isDragging=YES}else if(E){this.dataSet.removeItemsAtIndexPaths(this._draggingIndexPaths),r.forEach((t=>{t.node.classList.remove("BMCollectionViewCellDragging")}));const t=200/y.length;y.forEach(((e,i)=>{BMHook(e,{rotateZ:60*(i+1)/r.length+"deg"}),__BMVelocityAnimate(e,{rotateZ:60*(i+1)/r.length+"deg",blur:"20px",opacity:0},{easing:"easeInQuad",duration:200,delay:(y.length-i)*t})})),await __BMVelocityAnimate(l,{blur:"20px",opacity:0},{duration:200,easing:"easeInQuad",delay:y.length*t})}else y.forEach(((t,e)=>{let i=BMRectMakeWithNodeFrame(m.get(t).node);(window.Velocity||$.Velocity).animate(t,{tween:1,left:i.origin.x+"px",top:i.origin.y+"px"},{easing:"easeInOutQuad",duration:300,progress:(i,o,n,s,a)=>{t.style.transform="rotate("+(1-a)*(60*(e+1)/r.length)+"deg) translateZ(0)"},complete(){_=NO}})})),await __BMVelocityAnimate(l,{translateX:-s.origin.x+a.origin.x+"px",translateY:-s.origin.y+a.origin.y+"px"},{duration:300,easing:"easeInOutQuad"});l.remove(),d.remove(),y.forEach((t=>t.remove())),this.isDragging=NO,_BMCoreUIIsDragging=NO,r.forEach((t=>{t.node.classList.remove("BMCollectionViewCellDragging"),t.isDraggging=NO,t.release()})),this.delegate&&this.delegate.collectionViewDidFinishInteractiveMovementForCell&&this.delegate.collectionViewDidFinishInteractiveMovementForCell(this,n,{atIndexPath:n.indexPath}),this._draggingIndexPaths=void 0};window.addEventListener(void 0!==o?"touchend":"mouseup",z,{capture:YES,passive:NO}),void 0!==o&&window.addEventListener("touchcancel",z,{capture:YES,passive:NO})},dequeueCellForSupplementaryViewWithIdentifier:function(t){var e=this.supplementaryViewCache[t];if(e&&e.length)return(o=e.pop()).element[0].style.opacity=o._backingOpacity,o;var i=document.createElement("div");i.style="position: absolute; left: 0px; top: 0px; visibility: hidden; overflow: visible;";var o,n=this._supplementaryViewClasses[t]||this._cellClass;return(o=Object.create(n.prototype).initWithCollectionView(this,{reuseIdentifier:t,node:i,kind:BMCollectionViewLayoutAttributesType.SupplementaryView})).layoutQueue=this._cellLayoutQueue,n==BMCollectionViewCell&&this._usesLegacyDataSet&&o.element.append(this._dataSet.contentsForSupplementaryViewWithIdentifier(t)),this._contentWrapper.append(o.element),o},cellShouldRender:function(t){this.delegate&&"function"==typeof this.delegate.collectionViewWillRenderCell&&this.delegate.collectionViewWillRenderCell(this,t),t.element[0].style.visibility="inherit",this.allCells.push(t),t.rendered=YES,this.delegate&&"function"==typeof this.delegate.collectionViewDidRenderCell&&this.delegate.collectionViewDidRenderCell(this,t)},cellWasManaged:function(t){this.retainedCells.push(t)},cellWasReleased:function(t){this.delegate&&"function"==typeof this.delegate.collectionViewWillRecycleCell&&this.delegate.collectionViewWillRecycleCell(this,t),t.element[0].style.visibility="hidden",t._backingOpacity=t.attributes.style.opacity,void 0===t._backingOpacity&&(t._backingOpacity=BMCollectionViewLayoutAttributesStyleDefaults.opacity),t.element[0].style.opacity=0,t._previousFrame=void 0,BMHook(t.element[0],{translateX:"0px",translateY:"0px"});for(var e=this.allCells.length,i=0;i<e;i++)if(this.allCells[i]===t){this.allCells.splice(i,1);break}var o=t.itemType==BMCollectionViewLayoutAttributesType.Cell?this.cellCache:this.supplementaryViewCache;o[t.reuseIdentifier]||(o[t.reuseIdentifier]=[]),o[t.reuseIdentifier].push(t),t.rendered=NO,this.delegate&&"function"==typeof this.delegate.collectionViewDidRecycleCell&&this.delegate.collectionViewDidRecycleCell(this,t)},cellWasUnmanaged:function(t){for(var e=this.retainedCells.length,i=0;i<e;i++)if(this.retainedCells[i]===t){this.retainedCells.splice(i,1);break}},cellWasInvalidated:function(t){this.delegate&&"function"==typeof this.delegate.collectionViewWillDestroyCell&&this.delegate.collectionViewWillDestroyCell(this,t),t.element[0].removeEventListener("mousedown",t.mousedownHandler),t.element[0].removeEventListener("touchstart",t.mousedownHandler),t.element[0].removeEventListener("mousemove",t.mousemoveHandler),t.element[0].removeEventListener("touchmove",t.mousemoveHandler),t.element[0].removeEventListener("mouseup",t.mouseupHandler),t.element[0].removeEventListener("touchend",t.mouseupHandler),t.element[0].removeEventListener("touchcancel",t.touchcancelHandler),t.element[0].removeEventListener("contextmenu",t.contextMenuHandler),t.rendered=NO,t.element.remove();for(var e=this.retainedCells.length,i=0;i<e;i++)if(this.retainedCells[i]===t){this.retainedCells.splice(i,1);break}var o=this.allCells.length;for(i=0;i<o;i++)if(this.allCells[i]===t){this.allCells.splice(i,1);break}this.delegate&&"function"==typeof this.delegate.collectionViewDidDestroyCell&&this.delegate.collectionViewDidDestroyCell(this,t)},cellAtIndexPath:function(t,e){if(e||(e={ofType:BMCollectionViewLayoutAttributesType.Cell}),e.ofType=e.ofType||BMCollectionViewLayoutAttributesType.Cell,e.ofType==BMCollectionViewLayoutAttributesType.SupplementaryView)return this.supplementaryViewWithIdentifier(e.withIdentifier,{atIndexPath:t});for(var i=0;i<this.allCells.length;i++){var o=this.allCells[i];if(o.itemType==e.ofType&&(o._reuseState!=BMCollectionViewCellReuseState.Deleting&&o.indexPath.isLooselyEqualToIndexPath(t,{usingComparator:this.identityComparator})))return o}},supplementaryViewWithIdentifier:function(t,e){for(var i=0;i<this.allCells.length;i++){var o=this.allCells[i];if(o.itemType==BMCollectionViewLayoutAttributesType.SupplementaryView&&(o.reuseIdentifier==t&&o.indexPath.isEqualToIndexPath(e.atIndexPath,{usingComparator:this.identityComparator})))return o}},retainCellForIndexPath:function(t){if(!(t.section>this.numberOfSections()||t.row>this.numberOfObjectsInSectionAtIndex(t.section))){var e=this.cellAtIndexPath(t,{ofType:BMCollectionViewLayoutAttributesType.Cell});return e?(e.retain(),e):((e=this._dataSet.cellForItemAtIndexPath(t)).attributes=this.layout.attributesForCellAtIndexPath(t),e.retain(),e)}},retainSupplementaryViewWithIdentifier:function(t,e){var i=this.supplementaryViewWithIdentifier(t,{atIndexPath:e.forIndexPath});if(i)return i.retain(),i;var o=this.layout.attributesForSupplementaryViewWithIdentifier(t,{atIndexPath:e.forIndexPath});return o?((i=this._dataSet.cellForSupplementaryViewWithIdentifier(t,{atIndexPath:e.forIndexPath})).attributes=o,i.retain(),i):void 0},cellWasClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node),document.activeElement!=this.node&&this._supportsKeyboardNavigation&&this.node.focus();var i=NO;if(this.delegate&&this.delegate.collectionViewCellWasClicked&&(i=this.delegate.collectionViewCellWasClicked(this,t,{withEvent:e.withEvent})),i)return;if(this._highlightedIndexPath&&!this._highlightedIndexPath.isLooselyEqualToIndexPath(t.indexPath,{usingComparator:this.identityComparator})){let i=YES;this.delegate&&this.delegate.collectionViewCanHighlightCellAtIndexPath&&(i=this.delegate.collectionViewCanHighlightCellAtIndexPath(this,t.indexPath,{withEvent:e.withEvent})),i&&this._highlightIndexPath(t.indexPath,{withEvent:e.withEvent})}var o=YES;const n=this.isCellAtIndexPathSelected(t.indexPath);n?this.delegate&&"function"==typeof this.delegate.collectionViewCanDeselectCellAtIndexPath&&(o=this.delegate.collectionViewCanDeselectCellAtIndexPath(this,t.indexPath)):this.delegate&&"function"==typeof this.delegate.collectionViewCanSelectCellAtIndexPath&&(o=this.delegate.collectionViewCanSelectCellAtIndexPath(this,t.indexPath)),o&&(n?this.deselectCellAtIndexPath(t.indexPath):this.selectCellAtIndexPath(t.indexPath))},cellWasDoubleClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node),document.activeElement!=this.node&&this._supportsKeyboardNavigation&&this.node.focus();this.delegate&&this.delegate.collectionViewCellWasDoubleClicked&&this.delegate.collectionViewCellWasDoubleClicked(this,t,{withEvent:e.withEvent})},cellWasLongClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node),document.activeElement!=this.node&&this._supportsKeyboardNavigation&&this.node.focus();var i=NO;return this.delegate&&this.delegate.collectionViewCellWasLongClicked&&(i=this.delegate.collectionViewCellWasLongClicked(this,t,{withEvent:e.withEvent})),i},cellWasRightClicked:function(t,e){e&&e.withEvent&&(e.withEvent._BMOriginalTarget=t.node);var i=NO;return this.delegate&&this.delegate.collectionViewCellWasRightClicked&&(i=this.delegate.collectionViewCellWasRightClicked(this,t,{withEvent:e.withEvent})),i},_keyboardNavigationShortcuts:void 0,configureKeyboardShortcuts(){this._keyboardNavigationShortcuts||(this._keyboardNavigationShortcuts=[],this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{target:this,action:"_keyboardArrowPressedWithEvent"})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.push(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{target:this,action:"_keyboardArrowPressedWithEvent",modifiers:[BMKeyboardShortcutModifier.Shift]})),this._keyboardNavigationShortcuts.forEach((t=>this.registerKeyboardShortcut(t))))},disableKeyboardShortcuts(){this._keyboardNavigationShortcuts&&(this._keyboardNavigationShortcuts.forEach((t=>this.unregisterKeyboardShortcut(t))),this._keyboardNavigationShortcuts=void 0)},_keyboardArrowPressedWithEvent(t){switch(t.code){case"ArrowLeft":case"ArrowUp":case"ArrowRight":case"ArrowDown":this.keyboardArrowPressed(t.code,{withEvent:t})}},_highlightedIndexPath:void 0,get highlightedIndexPath(){return this._highlightedIndexPath},set highlightedIndexPath(t){this._highlightIndexPath(t)},_highlightIndexPath(t,{withEvent:e}={withEvent:void 0}){const i=this._highlightedIndexPath;if(this._highlightedIndexPath=t,i&&this.delegate&&this.delegate.collectionViewDidDehighlightCellAtIndexPath&&this.delegate.collectionViewDidDehighlightCellAtIndexPath(this,i),t){const i=this.cellAtIndexPath(t);if(!i||!i._attributes.frame.intersectsRect(this.visibleBounds)){let e=YES;this.delegate&&this.delegate.collectionViewShouldScrollToHighlightedCellAtIndexPath&&(e=this.delegate.collectionViewShouldScrollToHighlightedCellAtIndexPath(this,t)),e&&this.scrollToCellAtIndexPath(t,{animated:YES})}e&&e instanceof KeyboardEvent&&e.preventDefault()}this.delegate&&this.delegate.collectionViewDidHighlightCellAtIndexPath&&this.delegate.collectionViewDidHighlightCellAtIndexPath(this,t,{withEvent:e})},isCellAtIndexPathHighlighted(t){return this._highlightedIndexPath?this._highlightedIndexPath.isLooselyEqualToIndexPath(t,{usingComparator:this.identityComparator}):NO},keyboardArrowPressed(t,e){let i=this._highlightedIndexPath;const o=e&&e.withEvent;if(o){let e=YES;if(this.delegate&&this.delegate.collectionViewShouldHighlightCellForArrowKey&&(e=this.delegate.collectionViewShouldHighlightCellForArrowKey(this,t,{withEvent:o})),!e)return}do{const e=i??BMIndexPathNone;if(i)switch(t){case"ArrowLeft":i=this.layout.indexPathToTheLeftOfIndexPath(i);break;case"ArrowUp":i=this.layout.indexPathAboveIndexPath(i);break;case"ArrowRight":i=this.layout.indexPathToTheRightOfIndexPath(i);break;case"ArrowDown":i=this.layout.indexPathBelowIndexPath(i)}else i=this.layout.firstIndexPath();if(!i)return;let n=YES;if(this.delegate&&this.delegate.collectionViewCanHighlightCellAtIndexPath&&(n=this.delegate.collectionViewCanHighlightCellAtIndexPath(this,i,{withEvent:o})),n)break;if(e.isEqualToIndexPath(i,{usingComparator:this.identityComparator}))return}while(i);i.isEqualToIndexPath(this._highlightedIndexPath,{usingComparator:this.identityComparator})||this._highlightIndexPath(i,{withEvent:o})},_selectedIndexPaths:void 0,get selectedIndexPaths(){return this._selectedIndexPaths},set selectedIndexPaths(t){var e=t.length,i=this._selectedIndexPaths;this._selectedIndexPaths=t;for(var o=0;o<e;o++){for(var n=t[o],s=NO,a=0;a<i.length;a++)if(i[a].isLooselyEqualToIndexPath(n,{usingComparator:this.identityComparator})){s=YES,i.splice(a,1);break}s||this.delegate&&"function"==typeof this.delegate.collectionViewDidSelectCellAtIndexPath&&this.delegate.collectionViewDidSelectCellAtIndexPath(this,n)}for(o=0;o<i.length;o++)this.delegate&&"function"==typeof this.delegate.collectionViewDidDeselectCellAtIndexPath&&this.delegate.collectionViewDidDeselectCellAtIndexPath(this,i[o])},_updateSelectionIndexPaths:function(){var t=this._selectedIndexPaths;this._selectedIndexPaths=[];for(var e=t.length,i=0;i<e;i++){var o=this.dataSet.indexPathForObject(t[i].object);o&&this._selectedIndexPaths.push(o)}this._highlightedIndexPath&&(this._highlightedIndexPath=this.dataSet.indexPathForObject(this._highlightedIndexPath.object))},isCellAtIndexPathSelected:function(t){for(var e=this._selectedIndexPaths.length,i=0;i<e;i++)if(t.isLooselyEqualToIndexPath(this._selectedIndexPaths[i],{usingComparator:this.identityComparator}))return YES;return NO},selectCellAtIndexPath:function(t){this._selectedIndexPaths.push(t),this.delegate&&"function"==typeof this.delegate.collectionViewDidSelectCellAtIndexPath&&this.delegate.collectionViewDidSelectCellAtIndexPath(this,t)},deselectCellAtIndexPath:function(t){for(var e=this._selectedIndexPaths.length,i=0;i<e;i++)if(this._selectedIndexPaths[i].isLooselyEqualToIndexPath(t,{usingComparator:this.identityComparator})){this._selectedIndexPaths.splice(i,1);break}this.delegate&&"function"==typeof this.delegate.collectionViewDidDeselectCellAtIndexPath&&this.delegate.collectionViewDidDeselectCellAtIndexPath(this,t)},setLayout:function(t,e){if(this.isUpdatingData){var i=this;return void this.registerDataCompletionCallback((function(){i.setLayout(t,e)}))}if(!(e&&e.animated)&&!BMAnimationContextGetCurrent()||!this.initialized)return this.layout=t,this._executeDataCompletionCallbacks(),e&&e.completionHandler&&e.completionHandler(),void(this._blocksLayoutInvalidation=NO);let o;BMAnimationContextBeginStatic();const n=new Promise((t=>o=t));this._dataUpdatePromise=n,this.attributeCache={},this.isUpdatingData=YES,this._collectionEnabled=NO;for(var s=[],a=this.allCells.length,r=[],l=0;l<a;l++){const t=this.allCells[l];t._reuseState!=BMCollectionViewCellReuseState.Deleting&&(s.push(t.attributes),r.push(t))}var h=this.scrollOffset,c=this._bounds.copy();let d=this._pendingFrame;this._frame;d&&(this._frame=d,this._offscreenBufferSize=this.customScroll?0:Math.max(this._frame.size.width*this.offscreenBufferFactor,this._frame.size.height*this.offscreenBufferFactor),this._bounds.size.width=this._frame.size.width+2*this._offscreenBufferSize,this._bounds.size.height=this._frame.size.height+2*this._offscreenBufferSize),t.collectionView=this,t.prepareLayout();var u=t.contentSize(),p=t.preferredScrollOffsetForTransitionFromLayout(this._layout,{withOffset:this.scrollOffset.copy()});p.x=Math.max(0,Math.min(p.x,u.width-this.frame.size.width)),p.y=Math.max(0,Math.min(p.y,u.height-this.frame.size.height));var g=BMRectMake(p.x-this._offscreenBufferSize,p.y-this._offscreenBufferSize,this._bounds.size.width,this._bounds.size.height);this._bounds=g;for(var w=t.attributesForElementsInRect(g.copy()),y=[],m=[];s.length;){var _=s[s.length-1],f=NO;if(_.itemType===BMCollectionViewLayoutAttributesType.Cell){for(var v=0;v<w.length;v++)if((S=w[v]).itemType===BMCollectionViewLayoutAttributesType.Cell&&S.indexPath.isEqualToIndexPath(_.indexPath,{usingComparator:this.identityComparator})){f=YES,w.splice(v,1);break}f||(S=t.attributesForCellAtIndexPath(_.indexPath));var M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(_,{targetAttributes:S});y.push(M)}else{var S;for(v=0;v<w.length;v++)if((S=w[v]).itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&S.identifier===_.identifier&&S.indexPath.isEqualToIndexPath(_.indexPath,{usingComparator:this.identityComparator})){f=YES,w.splice(v,1);break}if(f){M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(_,{targetAttributes:S});y.push(M)}else{m.push(_),(S=_.copy())._style||(w._style={}),S.style.opacity=0,isNaN(_.style.opacity)&&(_.style.opacity=1);var M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(_,{targetAttributes:S});y.push(M)}}s.splice(s.length-1,1)}for(this._bounds=c;w.length;){if((_=w[w.length-1]).itemType===BMCollectionViewLayoutAttributesType.Cell){M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(C=this._layout.attributesForCellAtIndexPath(_.indexPath),{targetAttributes:_});y.push(M)}else{var C;(C=_.copy()).style.opacity=0,isNaN(_.style.opacity)&&(_.style.opacity=1);M=_BMCollectionViewTransitionLayoutAttributesMakeWithSourceAttributes(C,{targetAttributes:_});y.push(M)}w.splice(w.length-1,1)}this._bounds=g;var b=new _BMCollectionViewTransitionLayout(y,this._size,u,t);b.collectionView=this;var B=this._layout;this._layout.collectionView=void 0,this._layout=b,this._transitionLayout=b;let E=[];y.forEach((t=>{t._itemType==BMCollectionViewLayoutAttributesType.SupplementaryView?E.push(this.retainSupplementaryViewWithIdentifier(t.identifier,{forIndexPath:t.indexPath})):E.push(this.retainCellForIndexPath(t.indexPath))}));var V={};this.delegate&&this.delegate.collectionViewAnimationOptionsForLayoutChangeFromLayout&&(V=this.delegate.collectionViewAnimationOptionsForLayoutChangeFromLayout(this,B,{toLayout:t}));var L=BMExtend({duration:_BMCollectionViewAnimationDurationDefault,easing:_BMCollectionViewAnimationEasingDefault},V);r.forEach((t=>t.retain()));let x=t.contentSize();this._size=BMSizeMake(Math.max(this._size.width,x.width),Math.max(this._size.height,x.height)),L.complete=function(){var s=b.attributesForElementsInRect();if(i._renderCellsWithAttributes(s,{exclusive:YES}),i._size=x.copy(),i.iScroll&&(c.origin.x!=g.origin.x||c.origin.y!=g.origin.y)){var a=g.origin.copy();a.x+=i._offscreenBufferSize,a.y+=i._offscreenBufferSize,i.iScroll._translate(-a.x,-a.y)}r.forEach((t=>t.release())),E.forEach((t=>t.release())),b._applyFinalAttributes(),i.retainedCells.slice().forEach((function(t){t.attributes.isHidden&&t._unmanage()})),i._layout=t,i._transitionLayout=void 0,i.iScroll&&i.iScroll.refresh();for(var l=0;l<m.length;l++){var h=m[l],d=i.supplementaryViewWithIdentifier(h.identifier,{atIndexPath:h.indexPath});d&&d.isManaged&&d._unmanage()}i._applyOverflows(),i._dataUpdatePromise==n&&(i._collectionEnabled=YES,i.isUpdatingData=NO,i._executeDataCompletionCallbacks()),V.complete&&V.complete(),e&&e.completionHandler&&e.completionHandler(),o()},L.queue=NO,this._bounds=c;var A=b.attributesForElementsInRect();this._renderCellsWithAttributes(A,{exclusive:YES}),this._bounds=g,BMAnimationApply();i=this;let I=()=>{let t=BMAnimationContextGetCurrent().controllerForObject(i,{node:i._container[0]});b.fraction=1,t.registerCustomProperty("tween",{withHandler:t=>{this._bounds=BMRectByInterpolatingRect(c,{toRect:g,withFraction:t})}});let e=BMAnimationContextGetCurrent().controllerForObject(b,{node:i._contentWrapper[0]});if(e.registerBuiltInProperty("width",{withValue:x.width+"px"}),e.registerBuiltInProperty("height",{withValue:x.height+"px"}),b._layout(),c.origin.x!=i._bounds.origin.x||c.origin.y!=i._bounds.origin.y){var o=h,n=i._bounds.origin.copy();n.x+=i._offscreenBufferSize,n.y+=i._offscreenBufferSize;let t=BMAnimationContextGetCurrent().controllerForObject(i._contentWrapper[0],{node:i._contentWrapper[0]});i.iScroll?(BMHook(i._contentWrapper[0],{translateX:-o.x+"px",translateY:-o.y+"px"}),e.registerBuiltInProperty("translateX",{withValue:-n.x+"px"}),e.registerBuiltInProperty("translateY",{withValue:-n.y+"px"})):t.registerCustomProperty("scrollOffset",{withHandler:t=>{var e=o.x+t*(n.x-o.x),s=o.y+t*(n.y-o.y);i._container[0].scrollTo(e,s)}})}};BMAnimationContextGetCurrent()?(BMAnimationContextAddCompletionHandler(L.complete),I()):BMAnimateWithBlock(I,L),this._blocksLayoutInvalidation=NO},_updateLayoutWithBlock(t){throw new Error("This method is unavailable")},_dataUpdateCallbacks:void 0,registerDataCompletionCallback:function(t){this._dataUpdateCallbacks=this._dataUpdateCallbacks||[],this._dataUpdateCallbacks.push(t)},_executeDataCompletionCallbacks:function(){if(this._dataUpdateCallbacks){for(var t=this._dataUpdateCallbacks.length,e=0;e<t;e++)this._dataUpdateCallbacks[e]();this._dataUpdateCallbacks=[]}},dataSetDidChangeFromDataSet:function(t){this.initialized?this.invalidateLayout():this._init()},usingOldDataSet:function(t){var e=this.dataSet.isUsingOldData();this.dataSet.useOldData(YES),this._bounds=this.oldBounds,t(),this._bounds=this.newBounds,this.dataSet.useOldData(e)},usingNewDataSet:function(t){var e=this.dataSet.isUsingOldData();this.dataSet.useOldData(NO),t(),this.dataSet.useOldData(e)},_dataUpdatePromise:void 0,get dataUpdated(){return this._dataUpdatePromise},updateEntireDataAnimated:function(t,e){if(!this.initialized)return;BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationContextBeginStatic(),void 0===t&&(t=YES);var i=this;let o;const n=new Promise((function(t,e){o=t}));if(this._dataUpdatePromise=n,this._updateSelectionIndexPaths(),!t){if(this.layout.collectionViewWillStartUpdates(void 0),this.invalidateLayout(),i.layout.collectionViewDidStartUpdates(),this._usesLegacyDataSet)for(let t=0;t<this.allCells.length;t++){let e=this.allCells[t];e.itemType===BMCollectionViewLayoutAttributesType.Cell?this.dataSet.updateCell&&this.dataSet.updateCell(e,{atIndexPath:e.indexPath}):e.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(e,{withIdentifier:e.reuseIdentifier,atIndexPath:e.indexPath})}return e&&e.completionHandler&&e.completionHandler(),this._executeDataCompletionCallbacks(),o(),BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationApply(),this._dataUpdatePromise}if(e&&e.updateLayout===NO){for(var s=0;s<this.allCells.length;s++){(P=this.allCells[s]).itemType===BMCollectionViewLayoutAttributesType.Cell?(P.attributes.indexPath=this.dataSet.indexPathForObjectAtRow(P.indexPath.row,{inSectionAtIndex:P.indexPath.section}),this.dataSet.updateCell&&this.dataSet.updateCell(P,{atIndexPath:P.indexPath})):P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(P,{withIdentifier:P.reuseIdentifier,atIndexPath:P.indexPath})}return e&&e.completionHandler&&e.completionHandler(),this._executeDataCompletionCallbacks(),o(),BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationApply(),this._dataUpdatePromise}this._collectionEnabled=NO,this.isUpdatingData=YES,this.layout.collectionViewWillStartUpdates(void 0);var a=this._bounds.copy();this.oldBounds=a;var r=this.layout.contentSize().copy();let l=this._size;this._size=r;var h=BMPointMake(this._bounds.origin.x+this._offscreenBufferSize,this._bounds.origin.y+this._offscreenBufferSize),c=this.layout.preferredScrollOffsetWithOffset(h);this._bounds.origin.x+=c.x-h.x,this._bounds.origin.y+=c.y-h.y,this._constrainBounds(),this.newBounds=this._bounds,this._size=l,this._container[0].style.pointerEvents="none";var d=this.scrollOffset;this.iScroll||this._container[0].scrollTo(d.x,d.y),this.scrollView&&(this.scrollView.scrollingEnabled=NO);var u=this.layout.attributesForElementsInRect(this._bounds);this.attributeCache={};var p=[],g=[],w=this.layout.supplementaryViewsToInsert(),y=this.layout.supplementaryViewsToDelete(),m=this.allCells.slice(),_=new BMRect(BMPointMake(this._bounds.origin.x+this._offscreenBufferSize,this._bounds.origin.y+this._offscreenBufferSize),this._frame.size.copy()),f=new BMRect(BMPointMake(a.origin.x+this._offscreenBufferSize,a.origin.y+this._offscreenBufferSize),this._frame.size.copy());for(s=0;s<m.length;s++){if((P=m[s])._reuseState!=BMCollectionViewCellReuseState.Deleting){for(var v=NO,M=0;M<u.length;M++){var S=u[M];if(P.itemType===S.itemType&&P.indexPath.isLooselyEqualToIndexPath(S.indexPath,{usingComparator:this.identityComparator})){if(P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&P.reuseIdentifier!==S.identifier)continue;P.targetAttributes=S,S.initialAttributes=P.attributes,v=YES,u.splice(M,1),P.itemType===BMCollectionViewLayoutAttributesType.Cell?this.dataSet.updateCell&&this.dataSet.updateCell(P,{atIndexPath:S.indexPath}):P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView&&this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(P,{withIdentifier:P.reuseIdentifier,atIndexPath:S.indexPath});break}}if(!v)if(P.itemType===BMCollectionViewLayoutAttributesType.Cell){var C=this.indexPathForObject(P.indexPath.object);if(C){S=this.layout.attributesForCellAtIndexPath(C);P.targetAttributes=S,g.push(P),this.dataSet.updateCell&&this.dataSet.updateCell(P,{atIndexPath:S.indexPath})}else{S=this.layout.finalAttributesForDisappearingCellAtIndexPath(P.indexPath,{withTargetAttributes:P.attributes});P.targetAttributes=S,p.push(P)}}else if(P.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView){var b=NO;for(M=0;M<y.length;M++)if(P.indexPath.isLooselyEqualToIndexPath(y[M].indexPath,{usingComparator:this.identityComparator})&&P.reuseIdentifier==y[M].identifier){b=YES;break}if(b)P.targetAttributes=this.layout.finalAttributesForDisappearingSupplementaryViewWithIdentifier(P.reuseIdentifier,{atIndexPath:P.indexPath,withTargetAttributes:P.attributes}),p.push(P);else{S=this.layout.attributesForSupplementaryViewWithIdentifier(P.reuseIdentifier,{atIndexPath:P.indexPath});P.targetAttributes=S,g.push(P),this.dataSet.updateSupplementaryView&&this.dataSet.updateSupplementaryView(P,{withIdentifier:P.reuseIdentifier,atIndexPath:S.indexPath})}}}}this.dataSet.useOldData(YES);var B,E=[];this._droppedShadows&&(B=BMRectMakeWithNodeFrame(this._container[0]));for(s=0;s<u.length;s++){if(!(S=u[s]).initialAttributes)if(S.itemType===BMCollectionViewLayoutAttributesType.Cell){var V=this.indexPathForObject(S.indexPath.object);this.dataSet.useOldData(NO);var L=this.dataSet.cellForItemAtIndexPath(S.indexPath);if(V){var x=this.layout.initialAttributesForMovingCellFromIndexPath(V,{toIndexPath:S.indexPath,withTargetAttributes:S});S.initialAttributes=x}else{let t;if(this._droppedShadows&&(t=this._droppedShadows.get(S.indexPath.object))){var A=S.copy();let e=S.frame.copy();e.offset(-this.scrollOffset.x,-this.scrollOffset.y),e.offset(B.left,B.top),BMHook(t.node,{rotateZ:"0deg"});let i=BMRectMakeWithNodeFrame(t.node);BMHook(t.node,{rotateZ:t.rotation+"deg"});let o=e.rectWithTransformToRect(i),n=i.rectWithTransformToRect(e);t.transform=n,e.offset(this.scrollOffset.x,this.scrollOffset.y),e.offset(-B.left,-B.top),e.origin.x+=o.origin.x,e.origin.y+=o.origin.y,A.frame=e,A.style.rotateZ=t.rotation+"deg",A.style.scaleX=o.size.width,A.style.scaleY=o.size.height,A.style.opacity=0}else A=this.layout.initialAttributesForAppearingCellAtIndexPath(S.indexPath,{withTargetAttributes:S});S.initialAttributes=A}L.attributes=S.initialAttributes,L.targetAttributes=S,L._manage(),E.push(L),this.dataSet.useOldData(YES)}else if(S.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView){this.dataSet.useOldData(NO);var I=NO;for(M=0;M<w.length;M++)if(S.indexPath.isLooselyEqualToIndexPath(w[M].indexPath,{usingComparator:this.identityComparator})&&S.identifier==w[M].identifier){I=YES;break}if(I){A=this.layout.initialAttributesForAppearingSupplementaryViewWithIdentifier(S.identifier,{atIndexPath:S.indexPath,withTargetAttributes:S});S.initialAttributes=A}else{A=this.layout.initialAttributesForMovingSupplementaryViewWithIdentifier(S.identifier,{atIndexPath:S.indexPath,withTargetAttributes:S});S.initialAttributes=A}(L=this.dataSet.cellForSupplementaryViewWithIdentifier(S.identifier,{atIndexPath:S.indexPath})).attributes=S.initialAttributes,L.targetAttributes=S,L._manage(),E.push(L),this.dataSet.useOldData(YES)}}this.dataSet.useOldData(NO);for(s=0;s<m.length;s++){var P=m[s];_.intersectsRect(P.targetAttributes.frame)||_.intersectsRect(P.attributes.frame)||f.intersectsRect(P.targetAttributes.frame)||f.intersectsRect(P.attributes.frame)?(P.animatable=YES,P.targetAttributes.frame.intersectsRect(_)&&P._manage()):(P.animatable=NO,P.attributes=P.targetAttributes)}for(s=0;s<E.length;s++){P=E[s];_.intersectsRect(P.targetAttributes.frame)||_.intersectsRect(P.attributes.frame)||f.intersectsRect(P.targetAttributes.frame)||f.intersectsRect(P.attributes.frame)?P.animatable=YES:(P.animatable=NO,P.attributes=P.targetAttributes)}BM_COLLECTION_VIEW_USE_STATIC_CONTEXT&&BMAnimationApply();var W={};this.delegate&&this.delegate.collectionViewAnimationOptionsForUpdateAnimation&&(W=this.delegate.collectionViewAnimationOptionsForUpdateAnimation(this));var T=BMExtend({duration:this.isDragging?200:_BMCollectionViewAnimationDurationDefault,easing:_BMCollectionViewAnimationEasingDefault,queue:NO},W);T.complete=function(){if(!k){if(k=YES,i._dataUpdatePromise==n){const t=i.layout.contentSize();i._contentWrapper.css({width:t.width+"px"}),i._contentWrapper.css({height:t.height+"px"})}for(var t=0;t<g.length;t++)g[t].animatable=YES,g[t]._unmanage();for(t=0;t<z.length;t++)z[t].animatable=YES,z[t].release(),z[t].attributes.isHidden&&z[t]._unmanage();for(t=0;t<p.length;t++)p[t].animatable=YES,p[t].recycle();i._dataUpdatePromise==n&&(i._applyOverflows(),i._container[0].style.pointerEvents="inherit",i.scrollView&&(i.scrollView.scrollingEnabled=YES),i._collectionEnabled=YES,i.isUpdatingData=NO,i._executeDataCompletionCallbacks()),e&&e.completionHandler&&e.completionHandler(),W.complete&&W.complete.apply(this,arguments),o()}};var z=[],k=NO;let N=function(){for(const t of p)t._reuseState=BMCollectionViewCellReuseState.Deleting;if(i._droppedShadows&&i._droppedShadows.forEach((t=>{if(t.transform){BMHook(t.node,{rotateZ:t.rotation+"deg",translateX:"0px",translateY:"0px"});let e=BMAnimationContextGetCurrent().controllerForObject(t,{node:t.node});e.registerBuiltInProperty("translateX",{withValue:t.transform.origin.x+"px"}),e.registerBuiltInProperty("translateY",{withValue:t.transform.origin.y+"px"}),e.registerBuiltInProperty("scaleX",{withValue:t.transform.size.width}),e.registerBuiltInProperty("scaleY",{withValue:t.transform.size.height}),e.registerBuiltInProperty("rotateZ",{withValue:"0deg"}),e.registerBuiltInProperty("opacity",{withValue:0})}else{BMHook(t.node,{rotateZ:t.rotation+"deg"});let e=BMAnimationContextGetCurrent().controllerForObject(t,{node:t.node});e.registerBuiltInProperty("scaleX",{withValue:.33}),e.registerBuiltInProperty("scaleY",{withValue:.33}),e.registerBuiltInProperty("opacity",{withValue:0})}})),a.origin.x!=i._bounds.origin.x||a.origin.y!=i._bounds.origin.y){var t=h,e=i._bounds.origin.copy();e.x+=i._offscreenBufferSize,e.y+=i._offscreenBufferSize;let o=BMAnimationContextGetCurrent().controllerForObject(i._container[0],{node:i._container[0]});i.iScroll?o.registerCustomProperty("scrollOffset",{withHandler:o=>{var n=t.x+o*(e.x-t.x),s=t.y+o*(e.y-t.y);i.iScroll._translate(-n,-s)}}):o.registerCustomProperty("scrollOffset",{withHandler:o=>{var n=t.x+o*(e.x-t.x),s=t.y+o*(e.y-t.y);i._container[0].scrollTo({left:n,top:s,behavior:"auto"})}})}for(let t of m.concat(E))t.prepareForAnimatedUpdate();for(var o=0;o<m.length;o++){(n=m[o]).animatable&&(n.attributes=n.targetAttributes,n.animatable=NO,z.push(n.retain()))}for(o=0;o<E.length;o++){var n;(n=E[o]).animatable&&(n.attributes=n.targetAttributes,n.animatable=NO,z.push(n.retain()))}i._cellLayoutQueue.dequeue(),i._size.width<r.width&&(i._contentWrapper.css({width:r.width+"px"}),YES),i._size.height<r.height&&(i._contentWrapper.css({height:r.height+"px"}),YES),i._size=r,i.layout.collectionViewDidStartUpdates()};return this._cellLayoutQueue.dequeue(),BMAnimationContextGetCurrent()?(N(),BMAnimationContextAddCompletionHandler(T.complete)):BMAnimateWithBlock(N,T),this.newBounds=void 0,this.oldBounds=void 0,0==E.length&&0==m.length&&T.complete(),this._dataUpdatePromise},beginUpdatesWithBlock:function(t){throw new Error("This method is unavailable.")},scrollToCellAtIndexPath:function(t,e){var i=this._layout.rectWithScrollingPositionOfCellAtIndexPath(t);let o;if(i){var n=e&&e.withVerticalGravity,s=e&&e.horizontalGravity;n||(o=this.visibleBounds,n=i.origin.y>o.bottom?BMCollectionViewScrollingGravityVertical.Bottom:i.bottom<o.origin.y?BMCollectionViewScrollingGravityVertical.Top:BMCollectionViewScrollingGravityVertical.Center),s||(o=o||this.visibleBounds,s=i.origin.x>o.right?BMCollectionViewScrollingGravityHorizontal.Right:i.right<o.origin.x?BMCollectionViewScrollingGravityHorizontal.Left:BMCollectionViewScrollingGravityHorizontal.Center);var a=e&&e.animated;return this.scrollToRect(i,{withVerticalGravity:n,horizontalGravity:s,animated:a})}return Promise.resolve()},scrollToSupplementaryViewWithIdentifier:function(t,e){var i=this._layout.rectWithScrollingPositionOfSupplementaryViewWithIdentifier(t,{atIndexPath:e.atIndexPath});let o;if(i){var n=e.verticalGravity,s=e.horizontalGravity;n||(o=this.visibleBounds,n=i.origin.y>o.bottom?BMCollectionViewScrollingGravityVertical.Bottom:i.bottom<o.origin.y?BMCollectionViewScrollingGravityVertical.Top:BMCollectionViewScrollingGravityVertical.Center),s||(o=o||this.visibleBounds,s=i.origin.x>o.right?BMCollectionViewScrollingGravityHorizontal.Right:i.right<o.origin.x?BMCollectionViewScrollingGravityHorizontal.Left:BMCollectionViewScrollingGravityHorizontal.Center);var a=e.animated;return this.scrollToRect(i,{withVerticalGravity:n,horizontalGravity:s,animated:a})}return Promise.resolve()},scrollToRect:function(t,e){var i=BMPointMake();if(e.withVerticalGravity==BMCollectionViewScrollingGravityVertical.Top?i.y=t.origin.y:e.withVerticalGravity==BMCollectionViewScrollingGravityVertical.Center?i.y=t.origin.y+t.size.height/2-this.frame.size.height/2:e.withVerticalGravity==BMCollectionViewScrollingGravityVertical.Bottom&&(i.y=t.origin.y+t.size.height-this.frame.size.height),e.horizontalGravity==BMCollectionViewScrollingGravityHorizontal.Left?i.x=t.origin.x:e.horizontalGravity==BMCollectionViewScrollingGravityHorizontal.Center?i.x=t.origin.x+t.size.width/2-this.frame.size.width/2:e.horizontalGravity==BMCollectionViewScrollingGravityHorizontal.Right&&(i.x=t.origin.x+t.size.width-this.frame.size.width),i.y=Math.min(Math.max(0,i.y),this._size.height-this.frame.size.height),i.x=Math.min(Math.max(0,i.x),this._size.width-this.frame.size.width),e.animated){var o=this;return BMAnimateWithBlock((t=>{o.scrollOffset=i}),{duration:300})}return this.iScroll?this.iScroll.scrollTo(-(0|i.x),-(0|i.y)):(this._container[0].scrollLeft=i.x,this._container[0].scrollTop=i.y),Promise.resolve()},__UUID:void 0,get _UUID(){return this.__UUID||(this.__UUID=BMUUIDMake())},_isPerformingAnimatedScrolling:NO,_scrollToOffset:function(t){if(BMAnimationContextGetCurrent()){var e=BMAnimationContextGetCurrent(),i=e.subscribers.get(this),o=this;if(i)i.targetOffset=t.copy(),i.startingOffset=o.scrollOffset.copy();else{let n;n=o.iScroll?(t,e,n,s,a)=>{let r=i.targetOffset,l=i.startingOffset;var h=BMPointMake((r.x-l.x)*a+l.x|0,(r.y-l.y)*a+l.y|0);o.iScroll._translate(-h.x,-h.y),o._handleNewScrollFromEvent({x:h.x,y:h.y})}:(t,e,n,s,a)=>{let r=i.targetOffset,l=i.startingOffset;o._container[0].scrollLeft=(r.x-l.x)*a+l.x|0,o._container[0].scrollTop=(r.y-l.y)*a+l.y|0,o._handleNewScrollFromEvent(null)},i={apply:function(t){o._isPerformingAnimatedScrolling&&o._stopAnimatedScrolling(),o._container[0].style.pointerEvents="none",o._isPerformingAnimatedScrolling=YES,t.targets.push({element:o._container[0],properties:{tween:1},complete:t=>{o._container[0].style.pointerEvents="inherit",o._isPerformingAnimatedScrolling=NO},options:{progress:n}})},targetOffset:t.copy(),startingOffset:o.scrollOffset.copy()},e.subscribers.set(this,i)}}else{(o=this)._isPerformingAnimatedScrolling&&o._stopAnimatedScrolling(),this.iScroll?(this.iScroll.scrollTo(-(0|t.x),-(0|t.y)),this._handleNewScrollFromEvent({x:t.x,y:t.y})):(this._container[0].scrollLeft=t.x,this._container[0].scrollTop=t.y)}},_stopAnimatedScrolling(){this._isPerformingAnimatedScrolling&&((window.Velocity||$.Velocity)(this._container[0],"stop",this.__UUID),this._container[0].style.pointerEvents="inherit",this._isPerformingAnimatedScrolling=NO)},enumerateAllCellsWithBlock:function(t){for(var e=this.allCells.length,i=0;i<e;i++){if(t(r=this.allCells[i],r.itemType,r.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView?r.reuseIdentifier:void 0,YES)===NO)break}for(var o in this.cellCache){if((s=this.cellCache[o])&&s.length){var n=s.length;for(i=0;i<n;i++){if(t(r=s[i],r.itemType,void 0,NO)===NO)break}}}for(var o in this.supplementaryViewCache){var s,a=o;if((s=this.cellCache[o])&&s.length)for(n=s.length,i=0;i<n;i++){var r;if(t(r=s[i],r.itemType,a,NO)===NO)break}}},enumerateRetainedCellsWithBlock:function(t){for(var e=this.allCells.length,i=0;i<e;i++){var o=this.allCells[i];if(t(o,o.itemType,o.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView?o.reuseIdentifier:void 0)===NO)break}},enumerateVisibleCellsWithBlock:function(t){for(var e=this.retainedCells.length,i=0;i<e;i++){var o=this.retainedCells[i];if(t(o,o.itemType,o.itemType===BMCollectionViewLayoutAttributesType.SupplementaryView?o.reuseIdentifier:void 0)===NO)break}},flatten:function(){if(this.initialized){this.enumerateAllCellsWithBlock((function(t,e,i,o){o?t.attributes._flatten():t.element[0].style.display="none"})),this._collectionEnabled=NO,this._container[0].style.overflow="hidden",this._container[0].style.pointerEvents="none"}},release:function(){var t=this;_BMCollectionViews.delete(this),this.initialized&&!this.iScroll&&this.container[0].removeEventListener("scroll",this._boundContainerDidScrollWithEvent,this._highFrequencyScrollingEnabled),this.enumerateAllCellsWithBlock((function(e,i,o,n){t.delegate&&t.delegate.collectionViewWillDestroyCell&&t.delegate.collectionViewWillDestroyCell(t,e),e.invalidate(),t.delegate&&t.delegate.collectionViewDidDestroyCell&&t.delegate.collectionViewDidDestroyCell(t,e)})),this.iScroll&&this.iScroll.destroy(),this._container.empty(),this._layout._collectionView=void 0,BMView.prototype.release.call(this)}}),BMCollectionView.collectionViewForNode=function(t,e){return(new this).initWithDOMNode(t,e)},BMCollectionView.collectionView=function(){const t=document.createElement("div");return this.collectionViewForNode(t)};class BMCollectionViewDataSourceAdapter{constructor(t){this._dataSet=t}collectionViewNumberOfSections(t){return this._dataSet.numberOfSections()}collectionViewNumberOfObjectsInSectionAtIndex(t,e){return this._dataSet.numberOfObjectsInSectionAtIndex(e)}collectionViewIndexPathForObjectAtRow(t,e,i){return this._dataSet.indexPathForObjectAtRow(e,i)}collectionViewIndexPathForObject(t,e){return this._dataSet.indexPathForObject(e)}collectionViewCellForItemAtIndexPath(t,e){return this._dataSet.cellForItemAtIndexPath(e)}collectionViewCellForSupplementaryViewWithIdentifier(t,e,i){return this._dataSet.cellForSupplementaryViewWithIdentifier(e,i)}collectionViewUseOldData(t,e){return this._dataSet.useOldData(e)}collectionViewIsUsingOldData(t){return this._dataSet.isUsingOldData()}collectionViewMoveItemFromIndexPath(t,e,i){return this._dataSet.moveItemFromIndexPath(e,i)}collectionViewMoveItemsFromIndexPaths(t,e,i){return this._dataSet.moveItemsFromIndexPaths(e,i)}collectionViewRemoveItemsAtIndexPaths(t,e){return this._dataSet.removeItemsAtIndexPaths(e)}collectionViewInsertItems(t,e,i){return this._dataSet.insertItems(e,i)}static adapterWithDataSet(t){const e=new this(t);return t.copyOfItem&&(e.collectionViewCopyOfItem=function(e,i){return t.copyOfItem(i)}),e}}class BMCollectionViewDataSetAdapter{constructor(t,e){this._collectionView=t,this._dataSource=e}numberOfSections(){return this._dataSource.collectionViewNumberOfSections(this._collectionView)}numberOfObjectsInSectionAtIndex(t){return this._dataSource.collectionViewNumberOfObjectsInSectionAtIndex(this._collectionView,t)}indexPathForObjectAtRow(t,e){return this._dataSource.collectionViewIndexPathForObjectAtRow(this._collectionView,t,e)}indexPathForObject(t){return this._dataSource.collectionViewIndexPathForObject(this._collectionView,t)}contentsForCellWithReuseIdentifier(t){throw new Error("contentsForCellWithReuseIdentifier is unsupported when using data source objects")}cellForItemAtIndexPath(t){return this._dataSource.collectionViewCellForItemAtIndexPath(this._collectionView,t)}contentsForSupplementaryViewWithIdentifier(t){throw new Error("contentsForSupplementaryViewWithIdentifier is unsupported when using data source objects")}cellForSupplementaryViewWithIdentifier(t,e){return this._dataSource.collectionViewCellForSupplementaryViewWithIdentifier(this._collectionView,t,e)}updateCell(t,{atIndexPath:e}){throw new Error("updateCell is unsupported when using data source objects")}updateSupplementaryView(t,{withIdentifier:e,atIndexPath:i}){throw new Error("updateSupplementaryView is unsupported when using data source objects")}useOldData(t){return this._dataSource.collectionViewUseOldData(this._collectionView,t)}isUsingOldData(){return this._dataSource.collectionViewIsUsingOldData(this._collectionView)}moveItemFromIndexPath(t,e){return this._dataSource.collectionViewMoveItemFromIndexPath(this._collectionView,t,e)}moveItemsFromIndexPaths(t,e){return this._dataSource.collectionViewMoveItemsFromIndexPaths(this._collectionView,t,e)}removeItemsAtIndexPaths(t){return this._dataSource.collectionViewRemoveItemsAtIndexPaths(this._collectionView,t)}insertItems(t,e){return this._dataSource.collectionViewInsertItems(this._collectionView,t,e)}static adapterWithDataSource(t,e){const i=new this(t,e);return e.collectionViewCopyOfItem&&(i.copyOfItem=function(t){return e.collectionViewCopyOfItem(i._collectionView,t)}),i}}class BMWindowOverlay extends BMView{initWithWindow(t,e){this._window=t;let i=e&&"modal"in e?e.modal:YES,o=document.createElement("div");return o.className="BMWindowBlocker",BMCopyProperties(o.style,{opacity:0,display:"none",backdropFilter:i?"blur(15px)":"none",webkitBackdropFilter:i?"blur(15px)":"none"}),i||(o.style.pointerEvents="none",o.classList.add("BMWindowBlockerNonModal")),i&&o.addEventListener("click",(e=>{if(e.target==o){var i=YES;t.delegate&&t.delegate.windowShouldClose&&(i=t.delegate.windowShouldClose(t));var n=void 0,s=void 0;i&&(t._anchorPoint||t._anchorRect||t._anchorNode?t.dismissAnimated(YES):(t.delegate&&t.delegate.rectForDismissedWindow&&(n=t.delegate.rectForDismissedWindow(t)),t.delegate&&t.delegate.DOMNodeForDismissedWindow&&(s=t.delegate.DOMNodeForDismissedWindow(t)),t.dismissAnimated(YES,{toRect:n,toNode:s})))}})),super.initWithDOMNode(o)}frameForDescendant(t){return this._window.frameForDescendant(t)}_registerLayout(){this._window._visible?super._registerLayout():this._awaitsLayout=YES}_windowWillAppear(){this._awaitsLayout&&(this._awaitsLayout=NO,super._registerLayout(),this.layoutQueue.dequeue())}get _currentViewport(){if(this._requiredViewport)return this._requiredViewport;let t=new BMViewport;return t.init(),t._width=this._window._fullScreen?window.innerWidth:this._window.frame.size.width,t._height=this._window._fullScreen?window.innerHeight:this._window.frame.size.height,t._diagonal=Math.sqrt(Math.pow(t._width,2)+Math.pow(t._height,2)),t._orientation=t._width>=t._height?BMLayoutOrientation.Landscape:BMLayoutOrientation.Portrait,t._surfaceArea=t._width*t._height,t}}var _BMWindowAnimationDurationDefault=400,_BMWindowAnimationEasingDefault="easeInOutQuart";const _BMWindowAnimationEasingIncomingDefault="easeOutQuart",_BMWindowAnimationDurationIncomingDefault=200,_BMWindowAnimationEasingOutgoingDefault="easeInQuart",_BMWindowAnimationDurationOutgoingDefault=200,BM_WINDOW_SHOWCASE_MAX_ITERATIONS=5e3;var BM_WINDOW_Z_INDEX_MAX=2007;function BMWindow(){}function BMWindowMakeWithFrame(t,e){return(new BMWindow).initWithFrame(t,e)}function BMToolWindow(){}BMWindow._keyWindow=void 0,BMWindow._windows=[],BMWindow._minimizedWindows=[],BMWindow.zIndexMax=function(){return BM_WINDOW_Z_INDEX_MAX},BMWindow.minimizeAllAnimated=function(t){for(let e of this._windows.slice())e._minimizedWindow||e.minimizeAnimated(t)},BMWindow.restoreAllAnimated=function(t){for(let e of this._windows.slice())e._minimizedWindow&&e.restoreAnimated(t)},BMWindow.revealAll=function(){for(let t of this._windows.slice())t._hidden&&t.reveal()},BMWindow.hideAll=function(){for(let t of this._windows.slice())t._hidden||t.hide()},BMWindow._isShowcasing=NO,document.addEventListener("keydown",(t=>{69==t.which&&t.altKey&&(navigator.userAgent.includes("Macintosh")?t.metaKey:t.ctrlKey)&&(BMWindow._isShowcasing?BMWindow.exitShowcase():BMWindow.enterShowcase())}),YES),BMWindow._showcaseElements=[],BMWindow.registerShowcaseElement=function(t){BMWindow._showcaseElements.push(t)},BMWindow.unregisterShowcaseElement=function(t){BMWindow._showcaseElements.splice(BMWindow._showcaseElements.indexOf(t),1)},BMWindow.enterShowcase=async function(){if(BMWindow._isShowcasing)return;document.body.style.backgroundColor="rgb(60, 60, 60)",BMWindow._isShowcasing=YES,document.body.addEventListener("click",BMWindow.exitShowcase);let t=BMWindow._windows.filter((t=>!t._minimizedWindow));for(let e of BMWindow._showcaseElements)t.unshift(e);t.forEach((t=>{t.node.classList.add("BMWindowShowcaseWindow");let e=document.createElement("div");e.classList.add("BMWindowShowcaseWindowSelector"),e.addEventListener("click",(e=>{t.becomeKeyWindow?t.becomeKeyWindow():BMWindow.hideAll(),BMWindow.exitShowcase()})),t.node.appendChild(e)}));let e,i=BMRectMake(0,0,window.innerWidth,window.innerHeight),o=t.map((t=>t._fullScreen?i.copy():t.frame.copy())),n=o.map((t=>t.copy())),s=i.copy();for(let t=0;t<5e3;t++){for(let t=0;t<o.length;t++)for(let n=0;n<o.length;n++)if(t!=n&&o[t].intersectsRect(o[n])){e=YES;let a=o[t],r=o[n],l=r.center.pointBySubtractingPoint(a.center);l.x||l.y||(l.x=2*Math.random()-1,l.y=2*Math.random()-1),s.height/s.width>i.height/i.width?l.x=2*l.x:l.y=2*l.y;let h=Math.sqrt(l.x*l.x+l.y*l.y);l.x=20*l.x/h,l.y=20*l.y/h,a.offsetWithX(-l.x,{y:-l.y}),r.offsetWithX(l.x,{y:l.y}),s=s.rectByUnionWithRect(a).rectByUnionWithRect(r)}if(!e)break}let a=Math.min(1,i.width/s.width,i.height/s.height);for(let t of o)t.offset(-s.left,-s.top),t.origin.x=t.origin.x*a,t.origin.y=t.origin.y*a,t.size.width=t.size.width*a,t.size.height=t.size.height*a;BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();for(let e=0;e<o.length;e++){let i=n[e].rectWithTransformToRect(o[e]);BMAnimationContextGetCurrent().controllerForObject(t[e].node,{node:t[e].node}).registerBuiltInPropertiesWithDictionary({translateX:i.origin.x+"px",translateY:i.origin.y+"px",scaleX:i.size.width,scaleY:i.size.height,translateZ:0})}}),{duration:300,easing:"easeInOutQuad",complete:t=>BMWindow.revealAll()}),document.body.addEventListener("wheel",BMWindow._wheelHandler,YES)},BMWindow._wheelHandler=function(t){t.deltaY<0&&BMWindow.exitShowcase()},BMWindow.exitShowcase=function(t){if(t&&t.target!=document.body)return;BMWindow._isShowcasing=NO,document.body.removeEventListener("click",BMWindow.exitShowcase),document.body.removeEventListener("wheel",BMWindow._wheelHandler,YES);let e=BMWindow._windows.filter((t=>!t._minimizedWindow));for(let t of BMWindow._showcaseElements)e.unshift(t);e.forEach((t=>{t.node.classList.remove("BMWindowShowcaseWindow");let e=t.node.querySelector(".BMWindowShowcaseWindowSelector");e&&e.remove()})),BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();for(let t=0;t<e.length;t++){BMAnimationContextGetCurrent().controllerForObject(e[t].node,{node:e[t].node}).registerBuiltInPropertiesWithDictionary({translateX:"0px",translateY:"0px",scaleX:1,scaleY:1,translateZ:0})}}),{duration:300,easing:"easeInOutQuad",complete:t=>e[0].node.style.transform="none"})},BMWindow.prototype=BMExtend(Object.create(BMView.prototype),{delegate:void 0,_frame:void 0,get contentNode(){return this.content},get contentView(){return this},get frame(){return this._frame},set frame(t){if(!this._fullScreen){switch(t=t.integralRect,this._frame=t.copy(),BMCopyProperties(this._window.style,{left:t.origin.x+"px",top:t.origin.y+"px",width:t.size.width+"px",height:t.size.height+"px"}),this.frameHorizontalPositionLayoutAttribute){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:this.leftConstraint.constant=t.origin.x;break;case BMLayoutAttribute.CenterX:this.leftConstraint.constant=t.center.x-this.superview.frame.center.x;break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:this.leftConstraint.constant=t.right-this.superview.frame.right}switch(this.frameVerticalPositionLayoutAttribute){case BMLayoutAttribute.Top:this.topConstraint.constant=t.origin.y;break;case BMLayoutAttribute.CenterY:this.topConstraint.constant=t.center.y-this.superview.frame.center.y;break;case BMLayoutAttribute.Bottom:this.topConstraint.constant=t.bottom-this.superview.frame.bottom}this.widthConstraint.constant=t.size.width,this.heightConstraint.constant=t.size.height}},get framePositionPriority(){return 500},get frameSizePriority(){return 750},get frameHorizontalPositionLayoutAttribute(){return BMLayoutAttribute.Left},get _frameHorizontalAnchorName(){const t=this.frameHorizontalPositionLayoutAttribute;return t.substring(0,1).toLowerCase()+t.substring(1,t.length)},get frameVerticalPositionLayoutAttribute(){return BMLayoutAttribute.Top},get _frameVerticalAnchorName(){const t=this.frameVerticalPositionLayoutAttribute;return t.substring(0,1).toLowerCase()+t.substring(1,t.length)},_window:void 0,_toolbar:void 0,get toolbar(){return this._toolbar},_overlay:void 0,_blocker:void 0,_content:void 0,get content(){return this._content},_title:"New Window",get title(){return this._title},set title(t){this._title=t},_anchorPoint:void 0,get anchorPoint(){return this._anchorPoint},set anchorPoint(t){this.anchorNode=void 0,this._anchorRect=void 0,this._anchorPoint=t&&t.copy()},_anchorRect:void 0,get anchorRect(){return this._anchorRect},set anchorRect(t){this.anchorNode=void 0,this._anchorPoint=void 0,this._anchorRect=t&&t.copy()},_anchorNode:void 0,get anchorNode(){return this._anchorNode},set anchorNode(t){this._keepsNodeHidden&&this._visible&&this._anchorNode&&this._anchorNode.classList.remove("BMWindowAnchorNodeHidden"),this._anchorNode=t,this._anchorPoint=void 0,this._anchorRect=void 0,this._keepsNodeHidden&&this._visible&&this._anchorNode&&this._anchorNode.classList.add("BMWindowAnchorNodeHidden")},_visible:NO,get isVisible(){return this._visible},_fullScreen:NO,get isFullScreen(){return this._fullScreen},_modal:NO,get isModal(){return this._modal},_toolWindow:NO,_toolWindows:void 0,initWithFrame:function(t,e){t=t.integralRect;let i=e&&"modal"in e?e.modal:YES;this._toolWindows=[],this._overlay=(new BMWindowOverlay).initWithWindow(this,{modal:i}),this._blocker=this._overlay.node;let o=document.createElement("div");this._window=o,o.className="BMDarkModeAuto BMWindow",BMCopyProperties(o.style,{opacity:0,display:"none"}),this._modal=i,i?o.classList.add("BMModalWindow"):(this._toolWindow||(o.addEventListener("mousedown",(t=>{this.isKeyWindow||this.becomeKeyWindow()}),YES),o.classList.add("BMWindowInactive"),BMWindow._windows.push(this)),o.classList.add("BMNonModalWindow")),this._content=document.createElement("div"),this._content.className="BMDarkModeAuto BMWindowContent",o.appendChild(this._content);var n=e&&void 0!==e.toolbar?e.toolbar:YES;if(n?(this._toolbar=document.createElement("div"),this._toolbar.className="BMDarkModeAuto BMWindowToolbar",o.appendChild(this._toolbar)):this._content.className="BMDarkModeAuto BMWindowContent BMWindowFullContent",document.body.appendChild(this._blocker),BMView.prototype.initWithDOMNode.call(this,o),this._overlay.addSubview(this),document.body.appendChild(o),this.leftConstraint=this[this._frameHorizontalAnchorName].equalTo(this._overlay[this._frameHorizontalAnchorName],{plus:t.origin.x,priority:this.framePositionPriority}),this.topConstraint=this[this._frameVerticalAnchorName].equalTo(this._overlay[this._frameVerticalAnchorName],{plus:t.origin.y,priority:this.framePositionPriority}),this.widthConstraint=this.width.equalTo(t.size.width,{priority:this.frameSizePriority}),this.heightConstraint=this.height.equalTo(t.size.height,{priority:this.frameSizePriority}),this.frame=t,this.leftConstraint.isActive=YES,this.topConstraint.isActive=YES,this.widthConstraint.isActive=YES,this.heightConstraint.isActive=YES,!i&&n){let t;this.maxLeftConstraint=this.left.greaterThanOrEqualTo(0),this.maxTopConstraint=this.top.greaterThanOrEqualTo(0),this.maxRightConstraint=this.right.lessThanOrEqualTo(window.innerWidth),this.maxBottomConstraint=this.bottom.lessThanOrEqualTo(window.innerHeight),this.maxLeftConstraint.isActive=YES,this.maxTopConstraint.isActive=YES,this.maxRightConstraint.isActive=YES,this.maxBottomConstraint.isActive=YES,window.addEventListener("resize",this._boundViewportDidResize=this._viewportDidResize.bind(this)),this._toolbar.addEventListener("mousedown",(t=>{if(t.target!=this._toolbar)return;if(this._fullScreen)return;this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let e=BMPointMake(t.clientX,t.clientY),i=t=>{let i=BMPointMake(t.clientX,t.clientY);const o=BMPointMake(this._position.x+i.x-e.x,this._position.y+i.y-e.y);let n=YES;this.delegate&&this.delegate.windowShouldMove&&(n=this.delegate.windowShouldMove(this,o)),n&&(this.leftConstraint.constant=this._position.x+i.x-e.x,this.topConstraint.constant=this._position.y+i.y-e.y,this._position=o,e=i,this.layout(),t.preventDefault())},o=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",o,YES)};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",o,YES),t.preventDefault()})),this._toolbar.addEventListener("touchstart",(e=>{if(void 0!==t)return;if(e.target!=this._toolbar)return;if(this._fullScreen)return;t=e.changedTouches[0].identifier,this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let i=BMPointMake(e.changedTouches[0].clientX,e.changedTouches[0].clientY),o=e=>{let o;for(let i of e.changedTouches)if(i.identifier==t){o=i;break}if(!o)return;let n=BMPointMake(o.clientX,o.clientY);const s=BMPointMake(this._position.x+n.x-i.x,this._position.y+n.y-i.y);let a=YES;this.delegate&&this.delegate.windowShouldMove&&(a=this.delegate.windowShouldMove(this,s)),a&&(this.leftConstraint.constant=this._position.x+n.x-i.x,this.topConstraint.constant=this._position.y+n.y-i.y,this._position=s,i=n,this.layout(),e.preventDefault())},n=e=>{t=void 0,window.removeEventListener("touchmove",o),window.removeEventListener("touchend",n),window.removeEventListener("touchcancel",n)};window.addEventListener("touchmove",o),window.addEventListener("touchend",n),window.removeEventListener("touchcancel",n),e.preventDefault()})),this._toolbar.addEventListener("dbclick",(t=>{this.minimizeAnimated(YES)})),this._toolbar.addEventListener("wheel",(t=>{if(t.deltaY>0){let t=YES;this.delegate&&this.delegate.windowShouldEnterShowcase&&(t=this.delegate.windowShouldEnterShowcase(this)),t&&BMWindow.enterShowcase()}}));let e,i=this._dragHandle=document.createElement("div");i.className="material-icons BMWindowDragHandle BMDarkModeAuto",i.innerText="dehaze",i.style.cursor="nwse-resize",o.appendChild(i),i.addEventListener("mousedown",(t=>{if(this._fullScreen)return;this._dragged=YES,this._position=BMPointMake(this.widthConstraint.constant,this.heightConstraint.constant);let e=BMPointMake(t.clientX,t.clientY),i=t=>{let i=BMPointMake(t.clientX,t.clientY);const o=this._position.x+i.x-e.x,n=this._position.y+i.y-e.y;this._position=BMPointMake(o,n),e=i;let s=YES;this.delegate&&this.delegate.windowShouldResize&&(s=this.delegate.windowShouldResize(this,BMSizeMake(o,n))),s&&(this.widthConstraint.constant=o,this.heightConstraint.constant=n,this.frame.size.width=this.widthConstraint.constant,this.frame.size.height=this.heightConstraint.constant,this.layout(),this.delegate&&this.delegate.windowDidResize&&this.delegate.windowDidResize(this,{toSize:this.frame.size}),t.preventDefault())},o=document.createElement("div");o.className="BMLayoutGuideMask",o.style.cursor="nwse-resize",document.body.appendChild(o);let n=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",n,YES),o.remove()};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",n,YES),t.preventDefault()})),i.addEventListener("touchstart",(i=>{if(this._fullScreen)return;if(void 0!==t)return;e=i.changedTouches[0].identifier,this._dragged=YES,this._position=BMPointMake(this.widthConstraint.constant,this.heightConstraint.constant);let o=BMPointMake(i.changedTouches[0].clientX,i.changedTouches[0].clientY),n=t=>{let i;for(let o of t.changedTouches)if(o.identifier==e){i=o;break}if(!i)return;let n=BMPointMake(i.clientX,i.clientY);const s=this._position.x+n.x-o.x,a=this._position.y+n.y-o.y;this._position=BMPointMake(s,a),o=n;let r=YES;this.delegate&&this.delegate.windowShouldResize&&(r=this.delegate.windowShouldResize(this,BMSizeMake(s,a))),r&&(this.widthConstraint.constant=s,this.heightConstraint.constant=a,this.frame.size.width=this.widthConstraint.constant,this.frame.size.height=this.heightConstraint.constant,this.layout(),this.delegate&&this.delegate.windowDidResize&&this.delegate.windowDidResize(this,{toSize:this.frame.size}),t.preventDefault())},s=t=>{e=void 0,window.removeEventListener("touchmove",n),window.removeEventListener("touchend",s),window.removeEventListener("touchcancel",s)};window.addEventListener("touchmove",n),window.addEventListener("touchend",s),window.removeEventListener("touchcancel",s),i.preventDefault()}))}return this},performDragWithEvent(t){"mousedown"==t.type?this.performDragWithMouseEvent(t):"touchstart"==t.type&&this.performDragWithTouchEvent(t)},performDragWithMouseEvent(t){if(this._fullScreen)return;this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let e=BMPointMake(t.clientX,t.clientY),i=t=>{let i=BMPointMake(t.clientX,t.clientY);const o=BMPointMake(this._position.x+i.x-e.x,this._position.y+i.y-e.y);let n=YES;this.delegate&&this.delegate.windowShouldMove&&(n=this.delegate.windowShouldMove(this,o)),n&&(this.leftConstraint.constant=this._position.x+i.x-e.x,this.topConstraint.constant=this._position.y+i.y-e.y,this._position=o,e=i,this.layout(),t.preventDefault())},o=t=>{window.removeEventListener("mousemove",i,YES),window.removeEventListener("mouseup",o,YES)};window.addEventListener("mousemove",i,YES),window.addEventListener("mouseup",o,YES),t.preventDefault()},_touchDragPoint:void 0,performDragWithTouchEvent(t){if(void 0!==this._touchDragPoint)return;if(this._fullScreen)return;this._touchDragPoint=t.changedTouches[0].identifier,this._dragged=YES,this._position=BMPointMake(this.node.offsetLeft,this.node.offsetTop);let e=BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY),i=t=>{let i;for(let e of t.changedTouches)if(e.identifier==this._touchDragPoint){i=e;break}if(!i)return;let o=BMPointMake(i.clientX,i.clientY);const n=BMPointMake(this._position.x+o.x-e.x,this._position.y+o.y-e.y);let s=YES;this.delegate&&this.delegate.windowShouldMove&&(s=this.delegate.windowShouldMove(this,n)),s&&(this.leftConstraint.constant=this._position.x+o.x-e.x,this.topConstraint.constant=this._position.y+o.y-e.y,this._position=n,e=o,this.layout(),t.preventDefault())},o=t=>{this._touchDragPoint=void 0,window.removeEventListener("touchmove",i),window.removeEventListener("touchend",o),window.removeEventListener("touchcancel",o)};window.addEventListener("touchmove",i),window.addEventListener("touchend",o),window.removeEventListener("touchcancel",o),t.preventDefault()},colorSchemeDidChange(t){switch(BMView.prototype.colorSchemeDidChange.apply(this,arguments),this.colorScheme){case BMViewColorScheme.Light:this.node.querySelectorAll(".BMDarkModeAuto").forEach((t=>t.classList.remove("BMDarkModeAuto"))),this.node.classList.remove("BMDarkModeAuto");break;case BMViewColorScheme.Auto:this.node.classList.add("BMDarkModeAuto"),this._dragHandle&&this._dragHandle.classList.add("BMDarkModeAuto");break;case BMViewColorScheme.Dark:default:throw new Error(`The color scheme ${t} is not supported on this view.`)}},_viewportDidResize(t){this.maxRightConstraint.constant=window.innerWidth,this.maxBottomConstraint.constant=window.innerHeight,this._fullScreen&&this.layout()},_enableKeyboardShortcuts(){BMView.prototype._enableKeyboardShortcuts.apply(this,arguments),(this.isModal||this.isKeyWindow)&&(document.activeElement&&!this.node.contains(document.activeElement)?this.node.focus():document.activeElement||this.node.focus())},toggleAnimated:function(t,e){this._visible?this.dismissAnimated(t,e):this.bringToFrontAnimated(t,e)},_keepsNodeHidden:NO,animateInWithCompletionHandler(t){const e=this;if(this._anchorRect){const t=this._anchorRect,i=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(t);__BMVelocityAnimate(this._window,{opacity:1,translateX:["0px",i.origin.x+"px"],translateY:["0px",i.origin.y+"px"],scaleX:[1,i.size.width],scaleY:[1,i.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"block"},YES)}else if(this._anchorNode){const i=this._anchorNode,o=BMRectMakeWithNodeFrame(i),n=i.cloneNode(YES),s=i.style.display;e._nodeDisplay=s,n.style.position="fixed",n.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,n.style.transform="",BMCopyProperties(n.style,{left:o.origin.x+"px",top:o.origin.y+"px",width:o.size.width+"px",height:o.size.height+"px",margin:0}),n.style.pointerEvents="none";const a=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(o);let r=NO;e.delegate&&e.delegate.windowShouldKeepNodeHidden&&(r=e.delegate.windowShouldKeepNodeHidden(e,i)),document.body.appendChild(n),r?(i.classList.add("BMWindowAnchorNodeHidden"),this._keepsNodeHidden=YES):(i.animate([{opacity:0,easing:"cubic-bezier(0.77, 0, 0.175, 1)"},{opacity:0,easing:"cubic-bezier(0.77, 0, 0.175, 1)",offset:.5},{opacity:1}],_BMWindowAnimationDurationDefault),this._keepsNodeHidden=NO),__BMVelocityAnimate(this._window,{opacity:1,translateX:["0px",a.origin.x+"px"],translateY:["0px",a.origin.y+"px"],scaleX:[1,a.size.width],scaleY:[1,a.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"block",complete:t},YES),__BMVelocityAnimate(n,{opacity:[0,1],translateX:-a.origin.x+"px",translateY:-a.origin.y+"px",scaleX:1/a.size.width,scaleY:1/a.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){n.remove(),t()}},YES)}else __BMVelocityAnimate(this._window,{opacity:1,scaleX:[1,.9],scaleY:[1,.9],translateZ:0},{duration:200,easing:"easeOutQuart",display:"block",complete:t},YES)},bringToFrontAnimated:function(t,e={}){this._visible=YES,this.isKeyWindow||this.becomeKeyWindow();for(let e of this._toolWindows)e.opensAutomatically&&e.bringToFrontAnimated(t);t=void 0===t?YES:t;var i=this;if(i.delegate&&i.delegate.windowWillAppear&&i.delegate.windowWillAppear(i),t){let t;this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",__BMVelocityAnimate(this._blocker,{opacity:1,translateZ:0},{duration:500,easing:"easeInOutQuint",display:"block",complete:function(){i._blocker.style.pointerEvents="",i._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()}},YES),this._anchorNode||this._anchorRect||this._anchorPoint?t=()=>{}:(e.fromRect&&(this.anchorRect=e.fromRect),e.fromNode&&(this.anchorNode=e.fromNode),t=()=>{this.anchorRect=void 0,this.anchorNode=void 0,this._keyboardShortcutsEnabled&&this.isKeyWindow&&this.node.focus()}),this.animateInWithCompletionHandler(t),this._blocker.style.display="block",this._window.style.display="block",this._keyboardShortcutsEnabled&&this.node.focus(),this._overlay._windowWillAppear()}else this._blocker.style.opacity=1,this._blocker.style.display="block",this._window.style.opacity=1,BMHook(this._window,{scaleX:1,scaleY:1}),this._window.style.display="block",this._overlay._windowWillAppear(),this._blocker.style.pointerEvents="",this._window.style.pointerEvents="",this._keyboardShortcutsEnabled&&this.node.focus(),i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()},animateOutWithCompletionHandler(t){const e=this;if(this._anchorRect){const i=this._anchorRect,o=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(i);__BMVelocityAnimate(this._window,{opacity:0,translateX:o.origin.x+"px",translateY:o.origin.y+"px",scaleX:o.size.width,scaleY:o.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:t},YES)}else if(this._anchorNode){const i=this._anchorNode;this._keepsNodeHidden&&i.classList.remove("BMWindowAnchorNodeHidden");const o=BMRectMakeWithNodeFrame(i),n=i.cloneNode(YES);n.style.position="fixed",n.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,n.style.transform="",BMCopyProperties(n.style,{left:o.origin.x+"px",top:o.origin.y+"px",width:o.size.width+"px",height:o.size.height+"px",margin:0}),n.style.pointerEvents="none";const s=(e._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):e.frame).rectWithTransformToRect(o);BMHook(n,{translateX:-s.origin.x+"px",translateY:-s.origin.y+"px",scaleX:1/s.size.width,scaleY:1/s.size.height,opacity:0}),document.body.appendChild(n),this._keepsNodeHidden?i.classList.add("BMWindowAnchorNodeHidden"):i.animate([{opacity:1,easing:"cubic-bezier(0.77, 0, 0.175, 1)"},{opacity:0,easing:"cubic-bezier(0.77, 0, 0.175, 1)",offset:.5},{opacity:0}],_BMWindowAnimationDurationDefault),__BMVelocityAnimate(this._window,{opacity:0,translateX:s.origin.x+"px",translateY:s.origin.y+"px",scaleX:s.size.width,scaleY:s.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:t},YES),__BMVelocityAnimate(n,{opacity:[1,0],translateX:["0px",-s.origin.x+"px"],translateY:["0px",-s.origin.y+"px"],scaleX:[1,1/s.size.width],scaleY:[1,1/s.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){i.classList.remove("BMWindowAnchorNodeHidden"),n.remove()}},YES)}else __BMVelocityAnimate(this._window,{opacity:0,scaleX:.9,scaleY:.9,translateZ:0},{duration:200,easing:"easeInQuart",display:"none",complete:t},YES)},dismissAnimated:function(t,e={}){t=void 0===t?YES:t;var i=this;this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",i.delegate&&i.delegate.windowWillClose&&i.delegate.windowWillClose(i),this._visible=NO;for(let e of this._toolWindows)e.dismissAnimated(t);if(t){let t;__BMVelocityAnimate(this._blocker,{opacity:0,translateZ:0},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:function(){i.windowDidClose(),i.delegate&&i.delegate.windowDidClose&&i.delegate.windowDidClose(i),e&&e.completionHandler&&e.completionHandler()}},YES),this._anchorNode||this._anchorRect||this._anchorPoint?t=()=>{this._window.style.display="none",this._window.style.opacity=0}:(e.fromRect&&(this.anchorRect=e.fromRect),e.fromNode&&(this.anchorNode=e.fromNode),t=()=>{this.anchorRect=void 0,this.anchorNode=void 0,this._window.style.display="none",this._window.style.opacity=0}),this.animateOutWithCompletionHandler(t)}else this._blocker.style.opacity=0,this._blocker.style.display="none",this._window.style.opacity=0,this._window.style.display="none",i.windowDidClose(),i.delegate&&i.delegate.windowDidClose&&i.delegate.windowDidClose(i),e&&e.completionHandler&&e.completionHandler()},windowDidClose(){},minimizeAnimated:function(t=YES,e={}){if(this._modal)throw new Error("A modal window cannot be minimized.");if(this._minimizedWindow)return;this.delegate&&this.delegate.windowWillMinimize&&this.delegate.windowWillMinimize(this);let i=document.createElement("div");i.className="BMWindowMinimized",i.innerText=this.title,i.style.left=2+258*BMWindow._minimizedWindows.length+"px",i.addEventListener("click",(t=>{t.altKey?BMWindow.restoreAllAnimated(YES):this.restoreAnimated(YES)})),BMWindow._minimizedWindows.push(i),document.body.appendChild(i),this._minimizedWindow=i;let o=this;if(t){var n=i,s=BMRectMakeWithNodeFrame(n),a=n.cloneNode(YES);a.style.position="fixed",a.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,a.style.transform="",BMCopyProperties(a.style,{left:s.origin.x+"px",top:s.origin.y+"px",width:s.size.width+"px",height:s.size.height+"px",margin:0}),a.style.pointerEvents="none";var r=(o._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):o.frame).rectWithTransformToRect(s);BMHook(a,{translateX:-r.origin.x+"px",translateY:-r.origin.y+"px",scaleX:1/r.size.width,scaleY:1/r.size.height,opacity:0}),document.body.appendChild(a),n.style.display="none",__BMVelocityAnimate(this._window,{opacity:0,translateX:r.origin.x+"px",translateY:r.origin.y+"px",scaleX:r.size.width,scaleY:r.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none"},YES),__BMVelocityAnimate(a,{opacity:[1,0],translateX:["0px",-r.origin.x+"px"],translateY:["0px",-r.origin.y+"px"],scaleX:[1,1/r.size.width],scaleY:[1,1/r.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){n.style.display="block",a.remove(),o.delegate&&o.delegate.windowDidMinimize&&o.delegate.windowDidMinimize(o),e&&e.completionHandler&&e.completionHandler()}},YES)}},restoreAnimated(t=YES,e={}){if(this._modal)throw new Error("A modal window cannot be restored.");if(!this._minimizedWindow)return;this.delegate&&this.delegate.windowWillRestore&&this.delegate.windowWillRestore(this);let i=this;if(t){var o=this._minimizedWindow,n=BMRectMakeWithNodeFrame(o),s=o.cloneNode(YES);this._minimizedWindow=void 0;let t=NO;for(let e=0,i=BMWindow._minimizedWindows.length,n=BMWindow._minimizedWindows;e<i;e++)n[e]!=o?t&&(n[e].style.left=2+258*e+"px"):(n.splice(e,1),e--,i--,t=YES);this.isKeyWindow||this.becomeKeyWindow(),s.style.position="fixed",s.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,s.style.transform="",BMCopyProperties(s.style,{left:n.origin.x+"px",top:n.origin.y+"px",width:n.size.width+"px",height:n.size.height+"px",margin:0}),s.style.pointerEvents="none";var a=(i._fullScreen?BMRectMake(0,0,window.innerWidth,window.innerHeight):i.frame).rectWithTransformToRect(n);document.body.appendChild(s),o.style.display="none",__BMVelocityAnimate(this._window,{opacity:1,translateX:["0px",a.origin.x+"px"],translateY:["0px",a.origin.y+"px"],scaleX:[1,a.size.width],scaleY:[1,a.size.height]},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"block"},YES),__BMVelocityAnimate(s,{opacity:[0,1],translateX:-a.origin.x+"px",translateY:-a.origin.y+"px",scaleX:1/a.size.width,scaleY:1/a.size.height},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:function(){s.remove(),o.remove(),i.delegate&&i.delegate.windowDidRestore&&i.delegate.windowDidRestore(i),e&&e.completionHandler&&e.completionHandler()}},YES)}},enterFullScreenAnimated:function(t,e){this._fullScreen=YES,this.isKeyWindow||this.becomeKeyWindow(),t=void 0===t?YES:t;var i=this;this.widthConstraint.constant=window.innerWidth,this.heightConstraint.constant=window.innerHeight,this.leftConstraint.constant=0,this.topConstraint.constant=0,t?BMAnimateWithBlock((()=>{BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node}).registerBuiltInPropertiesWithDictionary({left:"0px",top:"0px",width:window.innerWidth+"px",height:window.innerHeight+"px"});const t=this.frame.copy();this.layout(),BMCopyProperties(this.node.style,{left:t.origin.x+"px",top:t.origin.y+"px",width:t.size.width+"px",height:t.size.height+"px"})}),{duration:300,easing:"easeInOutQuart",complete:function(){i.delegate&&i.delegate.windowDidEnterFullScreen&&i.delegate.windowDidEnterFullScreen(i),e&&e.completionHandler&&e.completionHandler(),i._window.classList.add("BMFullScreenWindow")}}):(i._window.classList.add("BMFullScreenWindow"),i.delegate&&i.delegate.windowDidEnterFullScreen&&i.delegate.windowDidEnterFullScreen(i),e&&e.completionHandler&&e.completionHandler()),this._resizeHandler=t=>{this.widthConstraint.constant=window.innerWidth,this.heightConstraint.constant=window.innerHeight},window.addEventListener("resize",this._resizeHandler)},exitFullScreenAnimated:function(t,e){if(this._fullScreen){t=void 0===t?YES:t;var i=this;if(this.widthConstraint.constant=this.frame.width,this.heightConstraint.constant=this.frame.height,this.leftConstraint.constant=this.frame.left,this.topConstraint.constant=this.frame.top,t){i._window.classList.remove("BMFullScreenWindow");var o=i.frame;BMCopyProperties(i._window.style,{left:"0px",top:"0px",width:window.innerWidth+"px",height:window.innerHeight+"px"}),BMAnimateWithBlock((()=>{let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("left",{withValue:o.origin.x+"px"}),t.registerBuiltInProperty("top",{withValue:o.origin.y+"px"}),t.registerBuiltInProperty("width",{withValue:o.size.width+"px"}),t.registerBuiltInProperty("height",{withValue:o.size.height+"px"}),this._fullScreen=NO,this.layout(),BMCopyProperties(i._window.style,{left:"0px",top:"0px",width:window.innerWidth+"px",height:window.innerHeight+"px"})}),{duration:300,easing:"easeInOutQuart",complete:function(){i.delegate&&i.delegate.windowDidExitFullScreen&&i.delegate.windowDidExitFullScreen(i),e&&e.completionHandler&&e.completionHandler(),i.frame=i.frame}})}else i._window.classList.remove("BMFullScreenWindow"),this._fullScreen=NO,i.frame=i.frame,i.delegate&&i.delegate.windowDidExitFullScreen&&i.delegate.windowDidExitFullScreen(i),e&&e.completionHandler&&e.completionHandler();window.removeEventListener("resize",this._resizeHandler)}},get isKeyWindow(){return BMWindow._keyWindow==this},resignKeyWindow(){if(BMWindow._keyWindow==this&&!this._modal){this.node.classList.remove("BMKeyWindow"),this.node.classList.add("BMWindowInactive"),BMWindow._keyWindow=void 0;for(let t of this._toolWindows)t.hide();this.delegate&&this.delegate.windowDidResignKeyWindow&&this.delegate.windowDidResignKeyWindow(this)}},becomeKeyWindow(){let t=!!this._minimizedWindow;if(this._minimizedWindow&&this.restoreAnimated(YES),this._hidden&&this.reveal(),BMWindow._keyWindow!=this){BMWindow._keyWindow&&BMWindow._keyWindow.resignKeyWindow(),this.node.classList.add("BMKeyWindow"),this.node.classList.remove("BMWindowInactive"),BMWindow._keyWindow=this,this._modal?(this._overlay.node.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1,this.node.style.zIndex=BM_WINDOW_Z_INDEX_MAX+1):(BMWindow._windows.splice(BMWindow._windows.indexOf(this),1),BMWindow._windows.push(this),BMWindow._windows.slice().reverse().forEach(((t,e)=>t.node.style.zIndex=BM_WINDOW_Z_INDEX_MAX-e))),this.delegate&&this.delegate.windowDidBecomeKeyWindow&&this.delegate.windowDidBecomeKeyWindow(this);for(let t of this._toolWindows)t.reveal()}else t||BMWindow._isShowcasing||BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("scaleX",{withValue:1.05}),t.registerBuiltInProperty("scaleY",{withValue:1.05})}),{duration:100,easing:"easeInQuad",complete:()=>{BMAnimateWithBlock((()=>{BMAnimationContextEnableWebAnimations();let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("scaleX",{withValue:1}),t.registerBuiltInProperty("scaleY",{withValue:1})}),{duration:100,easing:"easeOutQuad"})}})},release(){if(!this.__released){if(BMWindow._keyWindow==this&&(BMWindow._keyWindow=void 0),this._boundViewportDidResize&&window.removeEventListener("resize",this._boundViewportDidResize),!this._modal){for(let t=0,e=BMWindow._windows.length;t<e;t++)if(BMWindow._windows[t]==this){BMWindow._windows.splice(t,1);break}if(this._minimizedWindow){for(let t=0,e=BMWindow._minimizedWindows.length;t<e;t++)if(BMWindow._minimizedWindows[t]==this._minimizedWindow){BMWindow._minimizedWindows.splice(t,1);break}this._minimizedWindow.remove()}}BMView.prototype.release.call(this),this._cancelLayout(),this._overlay.release(),this._overlay.node.remove(),this.node.remove()}},hide(){this._hidden=YES,this.node.classList.add("BMWindowHidden")},reveal(){this._hidden=NO,this.node.classList.remove("BMWindowHidden")}}),BMToolWindow.prototype=BMExtend(Object.create(BMWindow.prototype),{opensAutomatically:YES,initWithFrame(t,{forWindow:e}){return this._toolWindow=YES,BMWindow.prototype.initWithFrame.call(this,t,{toolbar:YES,modal:NO}),this.node.classList.add("BMToolWindow"),e._toolWindows.push(this),BMWindow._keyWindow==e&&this.bringToFrontAnimated(YES),this},becomeKeyWindow(){},resignKeyWindow(){}}),BMToolWindow.toolWindowWithFrame=function(t,{forWindow:e}){return(new BMToolWindow).initWithFrame(t,{forWindow:e})};const _BMKeyboardShortcutCharacterMap={Backquote:"`",Minus:"-",Equal:"=",BracketLeft:"[",BracketRight:"]",Backslash:"\\",Semicolon:";",Quote:"'",Comma:",",Period:".",Slash:"/",Enter:BMHTMLEntity.Return,Escape:BMHTMLEntity.Escape,Backspace:BMHTMLEntity.Delete},BMKeyboardShortcutModifier=Object.freeze({Command:{key:"metaKey",value:1},Option:{key:"altKey",value:2},Shift:{key:"shiftKey",value:4},Control:{key:"ctrlKey",value:8},System:{key:"systemKey",value:navigator.platform.startsWith("Mac")||/iPhone|iPad|iPod/.test(navigator.platform)?1:8}});function BMKeySequence(){}function BMKeyboardShortcut(){}BMKeySequence.prototype={_keyCode:void 0,get keyCode(){return this._key},_modifiers:void 0,get modifiers(){if(this._modifiers)return this._modifiers.slice()},initWithKeyCode(t,{modifiers:e}={modifiers:[]}){this._key=t,this._modifiers=e?.slice()??[];for(const t of this._modifiers)this._modifierBitmap=this._modifierBitmap|t.value;return this},initWithKeyboardEvent(t){const e=[];return t.shiftKey&&e.push(BMKeyboardShortcutModifier.Shift),t.altKey&&e.push(BMKeyboardShortcutModifier.Option),t.metaKey&&(BMKeyboardShortcutModifier.System.value==BMKeyboardShortcutModifier.Command.value?e.push(BMKeyboardShortcutModifier.System):e.push(BMKeyboardShortcutModifier.Command)),t.ctrlKey&&(BMKeyboardShortcutModifier.System.value==BMKeyboardShortcutModifier.Control.value?e.push(BMKeyboardShortcutModifier.System):e.push(BMKeyboardShortcutModifier.Control)),this.initWithKeyCode(t.code,{modifiers:e})},get HTMLDescription(){let t="";const e=this.keyCode||"";t=e.startsWith("Key")?e.substring(3):e.startsWith("Digit")?e.substring(5):_BMKeyboardShortcutCharacterMap[e]||e;const i=navigator.platform.startsWith("Mac")||/iPhone|iPad|iPod/.test(navigator.platform);return this.modifiers.includes(BMKeyboardShortcutModifier.System)&&(t=i?BMHTMLEntity.Command+t:"Ctrl + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Command)&&(t=i?BMHTMLEntity.Command+t:"Win + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Shift)&&(t=i?BMHTMLEntity.Shift+t:"Shift + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Option)&&(t=i?BMHTMLEntity.Option+t:"Alt + "+t),this.modifiers.includes(BMKeyboardShortcutModifier.Control)&&(t=i?BMHTMLEntity.Control+t:"Ctrl + "+t),t}},BMKeySequence.keySequenceWithKeyCode=function(t,e){return(new this).initWithKeyCode(t,e)},BMKeySequence.keySequenceWithKeyboardEvent=function(t){return(new this).initWithKeyboardEvent(t)},BMKeyboardShortcut.prototype={_keySequence:void 0,get keySequence(){return this._keySequence},get keyCode(){return this._keySequence._key},get modifiers(){return this._keySequence._modifiers?this._keySequence._modifiers.slice():[]},_modifierBitmap:0,_target:void 0,get target(){return this._target},set target(t){this._target=t},_action:void 0,get action(){return this._action},set action(t){this._action=t},preventsDefault:NO,initWithKeySequence(t,{target:e,action:i,preventsDefault:o}={}){this._keySequence=t,this._target=e,this._action=i,this.preventsDefault=o||NO;for(const t of this.modifiers)this._modifierBitmap=this._modifierBitmap|t.value;return this},initWithKeyCode(t,{modifiers:e,target:i,action:o,preventsDefault:n}={modifiers:[]}){const s=(new BMKeySequence).initWithKeyCode(t,{modifiers:e});return this._keySequence=s,this.initWithKeySequence(s,{target:i,action:o,preventsDefault:n})},initWithKeyboardEvent(t,{target:e,action:i,preventsDefault:o}={}){const n=(new BMKeySequence).initWithKeyboardEvent(t);return this.initWithKeySequence(n,{target:e,action:i,preventsDefault:o})},initWithSerializedKeyboardShortcut(t,{targetID:e}){if("BMKeyboardShortcut"!=t._class)throw new Error(`Unknown keyboard shortcut class - "${t._class}"`);const i=e(t._targetID),o=Object.values(BMKeyboardShortcutModifier),n=t._modifiers.map((t=>o.find((e=>e.key==t))));return this.initWithKeyCode(t._key,{modifiers:n,target:i,action:t._action,preventsDefault:t._preventsDefault})},serializedKeyboardShortcutWithTargetID(t){return{_class:"BMKeyboardShortcut",_key:this.keyCode,_modifiers:this.modifiers.map((t=>t.key)),_targetID:t,_action:this._action,_preventsDefault:this.preventsDefault}}},BMKeyboardShortcut.keyboardShortcutWithKeySequence=function(t,e){return(new BMKeyboardShortcut).initWithKeySequence(t,e)},BMKeyboardShortcut.keyboardShortcutWithKeyCode=function(t,e){return(new BMKeyboardShortcut).initWithKeyCode(t,e)},BMKeyboardShortcut.keyboardShortcutWithKeyboardEvent=function(t,e){return(new BMKeyboardShortcut).initWithKeyboardEvent(t,e)},BMKeyboardShortcut.keyboardShortcutWithSerializedKeyboardShortcut=function(t,e){return(new BMKeyboardShortcut).initWithSerializedKeyboardShortcut(t,e)};var BMPopoverIndicatorDirection=Object.freeze({Top:"Top",Bottom:"Bottom",Left:"Left",Right:"Right"});function BMPopover(){}BMPopover.prototype=BMExtend(Object.create(BMWindow.prototype),{_anchorPoint:void 0,get anchorPoint(){return this._anchorPoint},set anchorPoint(t){this._anchorPoint=t},_anchorRect:void 0,get anchorRect(){return this._anchorRect},set anchorRect(t){this._anchorRect=t},_anchorNode:void 0,get anchorNode(){return this._anchorNode},set anchorNode(t){this._anchorNode=t},_size:void 0,get size(){return this._size},set size(t){this._size=t.copy()},_indicatorSize:16,get indicatorSize(){return this._indicatorSize},set indicatorSize(t){this._indicatorSize=t},_borderRadius:8,get borderRadius(){return this._borderRadius},set borderRadius(t){this._borderRadius=t},_edgeInsets:void 0,get edgeInsets(){return this._edgeInsets},set edgeInsets(t){this._edgeInsets=t||BMInsetMakeWithEqualInsets(8),this.isVisible&&this._updatePosition()},_dropShadowContainer:void 0,_dropShadowContent:void 0,_background:void 0,_darkModeFill:void 0,_contentView:void 0,get contentView(){return this._contentView},set contentView(t){this._contentView=t},_clipPathSVG:void 0,_clipPathBackgroundPath:void 0,_clipPathOutlinePath:void 0,_clipPathBoxShadowPath:void 0,_clipPathUUID:void 0,_contentViewTopConstraint:void 0,_contentViewBottomConstraint:void 0,_contentViewLeftConstraint:void 0,_contentViewRightConstraint:void 0,get _indicatorHeight(){return this.indicatorSize*Math.SQRT2/2|0},_permittedDirections:[BMPopoverIndicatorDirection.Bottom,BMPopoverIndicatorDirection.Top,BMPopoverIndicatorDirection.Right,BMPopoverIndicatorDirection.Left],get permittedDirections(){return this._permittedDirections.slice()},set permittedDirections(t){this._permittedDirections=t.slice()},initWithSize(t){const e=BMRectMakeWithOrigin(BMPointMake(),{size:t});BMWindow.prototype.initWithFrame.call(this,e,{modal:YES,toolbar:NO}),this._edgeInsets=BMInsetMakeWithEqualInsets(8),this._size=t.copy(),this.node.className="BMDarkModeAuto BMPopover",this.contentNode.className="BMDarkModeAuto BMPopoverContainer BMPopoverContainerView",this._overlay.node.className="BMPopoverOverlay";const i=document.createElement("div");i.className="BMDarkModeAuto BMPopoverContainerLayer BMPopoverDropShadowContainer";const o=document.createElement("div");o.className="BMDarkModeAuto BMPopoverDropShadowContent",i.appendChild(o);const n=document.createElement("div");n.className="BMDarkModeAuto BMPopoverBackground",n.innerHTML='<div class="BMDarkModeAuto BMPopoverBackgroundDarkModeContainer"><div class="BMDarkModeAuto BMPopoverBackgroundDarkModeOutline"></div><div class="BMDarkModeAuto BMPopoverBackgroundDarkModeFill"></div></div>',this.node.appendChild(n),this.node.appendChild(i),this.node.appendChild(this.contentNode),this._background=n,this._dropShadowContainer=i,this._dropShadowContent=o,this._popoverDarkModeFill=this._background.querySelector(".BMPopoverBackgroundDarkModeFill");const s=this._contentView=BMView.view();return this.addSubview(this._contentView),this._contentViewLeftConstraint=s.left.equalTo(this.left),this._contentViewLeftConstraint.isActive=YES,this._contentViewRightConstraint=s.right.equalTo(this.right),this._contentViewRightConstraint.isActive=YES,this._contentViewTopConstraint=s.top.equalTo(this.top),this._contentViewTopConstraint.isActive=YES,this._contentViewBottomConstraint=s.bottom.equalTo(this.bottom),this._contentViewBottomConstraint.isActive=YES,this},initWithFrame(t){return this.initWithSize(t.size)},colorSchemeDidChange(t){switch(BMWindow.prototype.colorSchemeDidChange.apply(this,arguments),this.colorScheme){case BMViewColorScheme.Light:break;case BMViewColorScheme.Auto:this._dropShadowContainer.classList.add("BMDarkModeAuto"),this._dropShadowContent.classList.add("BMDarkModeAuto"),this._background.classList.add("BMDarkModeAuto"),this._popoverDarkModeFill.classList.add("BMDarkModeAuto"),this._background.querySelector(".BMPopoverBackgroundDarkModeOutline").classList.add("BMDarkModeAuto"),this._background.querySelector(".BMPopoverBackgroundDarkModeContainer").classList.add("BMDarkModeAuto");break;case BMViewColorScheme.Dark:default:throw new Error(`The color scheme ${t} is not supported on this view.`)}},_updatePosition(){const t=BMRectMake();t.size.height=this._size.height+this._indicatorHeight,t.size.width=this._size.width;const e=this.anchorRect||this.anchorNode&&BMRectMakeWithNodeFrame(this.anchorNode),i=this.anchorPoint?this.anchorPoint.copy():e.center;let o,n;switch(o=this.anchorPoint?this._directionAroundPoint(i):this._directionAroundRect(e),o){case BMPopoverIndicatorDirection.Top:t.origin.y=this.anchorPoint?i.y:e.bottom-2,t.origin.x=i.x-t.size.width/2|0,t.origin.x<this._edgeInsets.left&&(t.origin.x=this._edgeInsets.left),t.right>window.innerWidth-this._edgeInsets.right&&(t.origin.x=window.innerWidth-t.size.width-this._edgeInsets.right),this._contentViewTopConstraint.constant=this._indicatorHeight,this._contentViewBottomConstraint.constant=0,this._contentViewLeftConstraint.constant=0,this._contentViewRightConstraint.constant=0;break;case BMPopoverIndicatorDirection.Bottom:t.origin.y=this.anchorPoint?i.y-t.size.height:e.origin.y+2-t.size.height,t.origin.x=i.x-t.size.width/2|0,t.origin.x<this._edgeInsets.left&&(t.origin.x=this._edgeInsets.left),t.right>window.innerWidth-this._edgeInsets.right&&(t.origin.x=window.innerWidth-t.size.width-this._edgeInsets.right),this._contentViewTopConstraint.constant=0,this._contentViewBottomConstraint.constant=-this._indicatorHeight,this._contentViewLeftConstraint.constant=0,this._contentViewRightConstraint.constant=0;break;case BMPopoverIndicatorDirection.Right:t.origin.x=this.anchorPoint?i.x-t.size.width:e.origin.x+2-t.size.width,t.origin.y=i.y-t.size.height/2|0,t.origin.y<this._edgeInsets.top&&(t.origin.y=this._edgeInsets.top),t.bottom>window.innerHeight-this._edgeInsets.bottom&&(t.origin.y=window.innerHeight-t.size.height-this._edgeInsets.bottom),this._contentViewTopConstraint.constant=0,this._contentViewBottomConstraint.constant=0,this._contentViewLeftConstraint.constant=0,this._contentViewRightConstraint.constant=-this._indicatorHeight;break;case BMPopoverIndicatorDirection.Left:t.origin.x=this.anchorPoint?i.x:e.right-2,t.origin.y=i.y-t.size.height/2|0,t.origin.y<this._edgeInsets.top&&(t.origin.y=this._edgeInsets.top),t.bottom>window.innerHeight-this._edgeInsets.bottom&&(t.origin.y=window.innerHeight-t.size.height-this._edgeInsets.bottom),this._contentViewTopConstraint.constant=0,this._contentViewBottomConstraint.constant=0,this._contentViewLeftConstraint.constant=this._indicatorHeight,this._contentViewRightConstraint.constant=0}switch(this.frame=t,o){case BMPopoverIndicatorDirection.Bottom:case BMPopoverIndicatorDirection.Top:n=BMNumberByConstrainingNumberToBounds(i.x-t.origin.x,12,t.size.width-12);break;case BMPopoverIndicatorDirection.Left:case BMPopoverIndicatorDirection.Right:n=BMNumberByConstrainingNumberToBounds(i.y-t.origin.y,12,t.size.height-12)}const s=t.copy();s.origin=BMPointMake();const a=`${this._pathForPopoverWithFrame(s,{indicatorSize:this._indicatorSize,position:n,direction:o,radius:this._borderRadius})}`,r=`${this._pathForPopoverWithFrame(s,{indicatorSize:this._indicatorSize,inset:1,position:n,direction:o,radius:this._borderRadius-1.5})}`,l=`${this._pathForPopoverWithFrame(s,{indicatorSize:this._indicatorSize,position:n,direction:o,radius:this._borderRadius+1.5})}`;if(!this._clipPathUUID&&!CSS.supports("clip-path",`path('${a}')`)){this._clipPathUUID=BMUUIDMake(),this._clipPathSVG=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._clipPathSVG.style.width="0",this._clipPathSVG.style.height="0";const t=document.createElementNS("http://www.w3.org/2000/svg","clipPath");t.setAttribute("id","popover-clip-path-"+this._clipPathUUID),t.setAttribute("clipPathUnits","userSpaceOnUse"),this._clipPathBackgroundPath=document.createElementNS("http://www.w3.org/2000/svg","path"),t.appendChild(this._clipPathBackgroundPath),this._clipPathSVG.appendChild(t);const e=document.createElementNS("http://www.w3.org/2000/svg","clipPath");e.setAttribute("id","popover-outline-clip-path-"+this._clipPathUUID),e.setAttribute("clipPathUnits","userSpaceOnUse"),this._clipPathOutlinePath=document.createElementNS("http://www.w3.org/2000/svg","path"),e.appendChild(this._clipPathOutlinePath),this._clipPathSVG.appendChild(e);const i=document.createElementNS("http://www.w3.org/2000/svg","clipPath");i.setAttribute("id","popover-box-shadow-clip-path-"+this._clipPathUUID),i.setAttribute("clipPathUnits","userSpaceOnUse"),this._clipPathBoxShadowPath=document.createElementNS("http://www.w3.org/2000/svg","path"),i.appendChild(this._clipPathBoxShadowPath),this._clipPathSVG.appendChild(i),document.body.appendChild(this._clipPathSVG)}this._clipPathUUID&&(this._clipPathBackgroundPath.setAttribute("d",a),this._clipPathOutlinePath.setAttribute("d",r),this._clipPathBoxShadowPath.setAttribute("d",l));const h=this._clipPathUUID?`url(#popover-clip-path-${this._clipPathUUID})`:`path('${a}')`,c=this._clipPathUUID?`url(#popover-outline-clip-path-${this._clipPathUUID})`:`path('${r}')`,d=this._clipPathUUID?`url(#popover-box-shadow-clip-path-${this._clipPathUUID})`:`path('${l}')`,u={left:s.origin.x+"px",top:s.origin.y+"px",width:s.size.width+"px",height:s.size.height+"px"};BMCopyProperties(this.contentNode.style,u),BMCopyProperties(this._background.style,u),this._background.style.clipPath=h,this._background.style.webkitClipPath=h;const p=this._background.querySelector(".BMPopoverBackgroundDarkModeFill");p.style.clipPath=c,p.style.webkitClipPath=c,BMCopyProperties(this._dropShadowContainer.style,u),this._dropShadowContent.style.clipPath=d,this._dropShadowContent.style.webkitClipPath=d;const g=[this.contentNode,this._background,this._dropShadowContainer];let w,y;switch(o){case BMPopoverIndicatorDirection.Bottom:w=n/this.frame.size.width*100+"%",y="100%";break;case BMPopoverIndicatorDirection.Top:w=n/this.frame.size.width*100+"%",y="0%";break;case BMPopoverIndicatorDirection.Left:w="0%",y=n/this.frame.size.height*100+"%";break;case BMPopoverIndicatorDirection.Right:w="100%",y=n/this.frame.size.height*100+"%"}for(const t of g)t.style.transformOrigin=`${w} ${y}`},_directionAroundPoint(t){for(const e of this._permittedDirections)switch(e){case BMPopoverIndicatorDirection.Top:if(t.y<window.innerHeight-this.size.height-this._indicatorHeight)return BMPopoverIndicatorDirection.Top;break;case BMPopoverIndicatorDirection.Bottom:if(t.y>this.size.height+this._indicatorHeight)return BMPopoverIndicatorDirection.Bottom;break;case BMPopoverIndicatorDirection.Right:if(t.x>this.size.width+this._indicatorHeight)return BMPopoverIndicatorDirection.Right;break;case BMPopoverIndicatorDirection.Left:if(t.x<window.innerWidth-this.size.width-this._indicatorHeight)return BMPopoverIndicatorDirection.Left}return this._permittedDirections[0]},_directionAroundRect(t){for(const e of this._permittedDirections)switch(e){case BMPopoverIndicatorDirection.Top:if(t.bottom<window.innerHeight-this.size.height-this._indicatorHeight)return BMPopoverIndicatorDirection.Top;break;case BMPopoverIndicatorDirection.Bottom:if(t.top>this.size.height+this._indicatorHeight)return BMPopoverIndicatorDirection.Bottom;break;case BMPopoverIndicatorDirection.Right:if(t.left>this.size.width+this._indicatorHeight)return BMPopoverIndicatorDirection.Right;break;case BMPopoverIndicatorDirection.Left:if(t.right<window.innerWidth-this.size.width-this._indicatorHeight)return BMPopoverIndicatorDirection.Left}return this._permittedDirections[0]},_pathForPopoverWithFrame(t,{indicatorSize:e=8,radius:i=8,inset:o=0,position:n,direction:s=BMPopoverIndicatorDirection.Top}={indicatorSize:8,radius:4,inset:0}){let a=s===BMPopoverIndicatorDirection.Top?e*Math.SQRT2/2|0:0,r=s==BMPopoverIndicatorDirection.Left?e*Math.SQRT2/2|0:0,l=s===BMPopoverIndicatorDirection.Bottom?t.size.height-e*Math.SQRT2/2|0:t.size.height,h=s==BMPopoverIndicatorDirection.Right?t.size.width-e*Math.SQRT2/2|0:t.size.width;o&&(e-=o,(t=t.copy()).insetWithInset(BMInsetMakeWithEqualInsets(o)),i+=o,a+=o,r+=o,l-=o,h-=o),n=void 0===n?t.size.width/2|0:n-o|0;const c=e*Math.SQRT2,d=c/2|0;let u=s===BMPopoverIndicatorDirection.Top?`M${r+i},${a} L${n-c/2+r},${a} l${c/2},${-d} l${c/2},${d} L${h-i},${a} `:`M${r+i},${a} L${h-i},${a} `;return u+=s==BMPopoverIndicatorDirection.Right?`Q${h},${a} ${h},${a+i} L${h},${n-c/2+a} l${d},${c/2} l${-d},${c/2} L${h},${l-i} `:`Q${h},${a} ${h},${a+i} L${h},${l-i} `,u+=s===BMPopoverIndicatorDirection.Bottom?`Q${h},${l} ${h-i},${l} L${n+c/2+r},${l} l${-c/2},${d} l${-c/2},${-d} L${r+i},${l} `:`Q${h},${l} ${h-i},${l} L${r+i},${l} `,u+=s===BMPopoverIndicatorDirection.Left?`Q${r},${l} ${r},${l-i} L${r},${n+c/2+a} l${-d},${-c/2} l${d},${-c/2} L${r},${a+i} Q${r},${a} ${r+i},${a} Z`:`Q${r},${l} ${r},${l-i} L${r},${a+i} Q${r},${a} ${r+i},${a} Z`,u},animateInWithCompletionHandler(t){const e=[this.contentNode,this._background,this._dropShadowContainer];this.node.style.opacity=1;let i=YES;for(const o of e)BMHook(o,{scaleX:.75,scaleY:.75,opacity:0}),__BMVelocityAnimate(o,{scaleX:1,scaleY:1,opacity:1},{duration:300,easing:[0,1.59,.49,1],complete:i?t:void 0},YES),i=NO},animateOutWithCompletionHandler(t){const e=[this.contentNode,this._background,this._dropShadowContainer],i=this;let o=YES;for(const n of e){n.style.pointerEvents="none";const e=o;__BMVelocityAnimate(n,{scaleX:.9,scaleY:.9,opacity:0},{duration:200,easing:"easeInOutQuart",complete(){e&&(i.node.style.opacity=0,t())}},YES),o=NO}},bringToFrontAnimated(t,e){if(!this.anchorNode&&!this.anchorPoint&&!this.anchorRect)throw new Error("The anchorPoint, anchorRect or anchorNode must be set prior to showing this popover.");this._updatePosition(),BMWindow.prototype.bringToFrontAnimated.apply(this,arguments)},release(){return this._clipPathUUID&&this._clipPathSVG.remove(),BMWindow.prototype.release.apply(this,arguments)}}),BMPopover.popoverWithSize=function(t){return(new BMPopover).initWithSize(t)};const BMConfirmationPopupResult=Object.freeze({Undecided:{},Cancelled:{},Declined:{},Confirmed:{}});function BMAlertPopup(){}function BMConfirmationPopup(){}BMAlertPopup.prototype=BMExtend(Object.create(BMWindow.prototype),{_result:BMConfirmationPopupResult.Undecided,get result(){return this._result},_resolution:void 0,get resolution(){return this._resolution},_resolve:void 0,_title:void 0,get title(){return this._title},set title(t){t!=this._title&&(this._title=t,this._titleView&&(this._titleView.node.innerText=t,this._titleView.invalidateIntrinsicSize()))},_text:void 0,get text(){return this._text},set text(t){t!=this._text&&(this._text=t,this._textView&&(this._textView.node.innerText=t,this._textView.invalidateIntrinsicSize()))},get HTML(){return this._text},set HTML(t){t!=this._text&&(this._text=t,this._textView&&(this._textView.node.innerHTML=t,this._textView.invalidateIntrinsicSize()))},_positiveActionText:void 0,get positiveActionText(){return this._positiveActionText},set positiveActionText(t){t!=this._positiveActionText&&(this._positiveActionText=t,this._positiveActionButton&&(this._positiveActionButton.node.innerText=t,this._positiveActionButton.invalidateIntrinsicSize()))},get frameSizePriority(){return 1},get frameHorizontalPositionLayoutAttribute(){return BMLayoutAttribute.CenterX},get frameVerticalPositionLayoutAttribute(){return BMLayoutAttribute.CenterY},_previouslyActiveNode:void 0,_centerHandler:void 0,initWithTitle(t,{text:e,actionText:i="OK"}){const o=BMRectMake(0,0,0,0);BMWindow.prototype.initWithFrame.call(this,o),this.contentView.contentNode.classList.add("BMWindowBackground"),this._resolution=new Promise((t=>{this._resolve=t})),this._title=t,this._text=e,this._positiveActionText=i,this._titleView=BMView.view(),this._titleView.supportsAutomaticIntrinsicSize=YES,this._titleView.node.classList.add("BMTitle"),this._titleView.node.innerText=t,this.contentView.addSubview(this._titleView),this._titleView.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,this._titleView.top.equalTo(this.contentView.top,{plus:32}).isActive=YES,this._titleView.trailing.lessThanOrEqualTo(this.contentView.trailing,{plus:-32}).isActive=YES,this._textView=BMView.view(),this._textView.supportsAutomaticIntrinsicSize=YES,this._textView.node.classList.add("BMLabel"),this._textView.node.innerText=e,this.contentView.addSubview(this._textView),this._textView.leading.equalTo(this._titleView.leading).isActive=YES,this._textView.top.equalTo(this._titleView.bottom,{plus:32}).isActive=YES,this._textView.trailing.lessThanOrEqualTo(this.contentView.trailing,{plus:-32}).isActive=YES,this._positiveActionButton=BMView.view(),this._positiveActionButton.supportsAutomaticIntrinsicSize=YES,this._positiveActionButton.node.classList.add("BMButton"),this._positiveActionButton.node.innerText=i,this.contentView.addSubview(this._positiveActionButton),this._positiveActionButton.trailing.equalTo(this.contentView.trailing,{plus:-32}).isActive=YES,this._positiveActionButton.bottom.equalTo(this.contentView.bottom,{plus:-32}).isActive=YES,this._positiveActionButton.top.equalTo(this._textView.bottom,{plus:64}).isActive=YES,this._positiveActionButton.node.addEventListener("click",(t=>this._confirm())),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Enter",{target:this,action:"_confirm"}));const n=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Escape",{target:this,action:"_escape"});return n.preventsDefault=YES,this.registerKeyboardShortcut(n),this._previouslyActiveNode=document.activeElement,this},_escape(){this._confirm()},_confirm(){this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Confirmed,this._resolve(BMConfirmationPopupResult.Confirmed),this.dismissAnimated(YES))},confirm(){return this.bringToFrontAnimated(YES),this._resolution},bringToFrontAnimated(){return this._resizeHandler=()=>this.needsLayout=YES,window.addEventListener("resize",this._resizeHandler),BMWindow.prototype.bringToFrontAnimated.apply(this,arguments)},dismissAnimated(){return this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Confirmed,this._resolve(BMConfirmationPopupResult.Confirmed)),this._previouslyActiveNode&&this._previouslyActiveNode.focus(),window.removeEventListener("resize",this._resizeHandler),BMWindow.prototype.dismissAnimated.apply(this,arguments)},windowDidClose(){this.release()}}),BMAlertPopup.alertPopupWithTitle=function(t,{text:e,actionText:i="OK"}){return(new BMAlertPopup).initWithTitle(t,{text:e,actionText:i})},BMConfirmationPopup.prototype=BMExtend(Object.create(BMAlertPopup.prototype),{_negativeActionText:void 0,get negativeActionText(){return this._negativeActionText},set negativeActionText(t){t!=this._negativeActionText&&(this._negativeActionText=t,this._negativeActionButton&&(this._negativeActionButton.node.innerText=t,this._negativeActionButton.invalidateIntrinsicSize()))},_showsCancelButton:NO,get showsCancelButton(){return this._showsCancelButton},set showsCancelButton(t){this._showsCancelButton=t,this._cancelButton&&(this._cancelButton.isVisible=t)},initWithTitle(t,{text:e,positiveActionText:i,negativeActionText:o}){return BMAlertPopup.prototype.initWithTitle.call(this,t,{text:e,actionText:i}),this._negativeActionText=o,this._negativeActionButton=BMView.view(),this._negativeActionButton.supportsAutomaticIntrinsicSize=YES,this._negativeActionButton.node.classList.add("BMButton","BMButtonWeak"),this._negativeActionButton.node.innerText=o,this.contentView.addSubview(this._negativeActionButton),this._negativeActionButton.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,this._negativeActionButton.bottom.equalTo(this.contentView.bottom,{plus:-32}).isActive=YES,this._negativeActionButton.top.equalTo(this._textView.bottom,{plus:64}).isActive=YES,this._negativeActionButton.node.addEventListener("click",(t=>this._decline())),this._cancelButton=BMView.view(),this._cancelButton.supportsAutomaticIntrinsicSize=YES,this._cancelButton.node.classList.add("BMButton","BMButtonWeak"),this._cancelButton.node.innerText="Cancel",this._cancelButton.isVisible=NO,this.contentView.addSubview(this._cancelButton),this._cancelButton.trailing.equalTo(this._positiveActionButton.leading,{plus:-32}).isActive=YES,this._cancelButton.bottom.equalTo(this.contentView.bottom,{plus:-32}).isActive=YES,this._cancelButton.top.equalTo(this._textView.bottom,{plus:64}).isActive=YES,this._cancelButton.leading.greaterThanOrEqualTo(this._negativeActionButton.trailing,{plus:64}).isActive=YES,this._cancelButton.node.addEventListener("click",(t=>this._cancel())),this},_escape(){this._showsCancelButton?this._cancel():this._decline()},_decline(){this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Declined,this._resolve(BMConfirmationPopupResult.Declined),this.dismissAnimated(YES))},_cancel(){this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Cancelled,this._resolve(BMConfirmationPopupResult.Cancelled),this.dismissAnimated(YES))},dismissAnimated(){return this._result==BMConfirmationPopupResult.Undecided&&(this._result=BMConfirmationPopupResult.Cancelled,this._resolve(BMConfirmationPopupResult.Cancelled)),this._previouslyActiveNode&&this._previouslyActiveNode.focus(),BMWindow.prototype.dismissAnimated.apply(this,arguments)}}),BMConfirmationPopup.confirmationPopupWithTitle=function(t,{text:e,positiveActionText:i,negativeActionText:o}){return(new BMConfirmationPopup).initWithTitle(t,{text:e,positiveActionText:i,negativeActionText:o})};var BMCodeEditorLanguage=Object.freeze({Javascript:"javascript",CSS:"css",JSON:"json",Typescript:"typescript"});function BMCodeEditor(){}function BMCodeMirrorCodeEditor(){}function BMCodeMirrorCodeEditorMakeWithContainer(t,e){return(new BMCodeMirrorCodeEditor).initWithContainer(t,{code:e&&e.code,language:e&&e.language})}function BMMonacoCodeEditor(){}BMCodeEditor.prototype={_container:void 0,get container(){return this._container},delegate:void 0,initWithContainer:function(t){return this._container=t,this},get code(){},set code(t){},get requiresTranspilation(){return NO},async transpiledCode(){return this.code},get cursorPosition(){},set cursorPosition(t){},supportsExtensibleAutocomplete:NO,setBuiltinES6Library:function(t,e){},setImports(t){},addExternalLibraryNamed(t,e){},removeExternalLibraryNamed(t){},hasExternalLibraryNamed:t=>NO,get scope(){},set scope(t){},insertText:function(t){},acquireFocus:function(){},resignFocus:function(){},resized:function(){},release:function(){}},BMExtend(BMCodeMirrorCodeEditor.prototype,BMCodeEditor.prototype,{_codeMirror:void 0,initWithContainer:function(t,e){BMCodeEditor.prototype.initWithContainer.call(this,t),this._codeMirror=CodeMirror(this.container,{mode:e&&e.language||BMCodeEditorLanguage.Javascript,theme:"eclipse",lineNumbers:YES,firstLineNumber:0,matchBrackets:YES,extraKeys:{"Ctrl-Q":function(t){cm.foldCode(cm.getCursor())},"Ctrl-S":function(t){}},foldGutter:!0,gutters:["CodeMirror-lint-markers","CodeMirror-foldgutter"],indentUnit:4}),this.container.querySelectorAll(".CodeMirror")[0].style.height="100%";var i=this;this._codeMirror.on("change",(function(){i.delegate&&i.delegate.codeEditorContentsDidChange&&i.delegate.codeEditorContentsDidChange(i)}));var o=e&&e.code;return o?(this.code=o,this):this},get code(){return this._codeMirror.getValue()},set code(t){this._codeMirror.setValue(t)},get cursorPosition(){var t=this._codeMirror.getCursor();return BMPointMake(t.ch,t.line)},set cursorPosition(t){this._codeMirror.setCursor({ch:t.x,line:t.y}),this._codeMirror.scrollIntoView({ch:0,line:t.y})},insertText:function(t){var e=this._codeMirror.getDoc(),i=this._codeMirror.getCursor();e.replaceRange(t,i)},acquireFocus:function(){this._codeMirror.focus()},resignFocus:function(){},resized:function(){this._codeMirror.refresh()}});var _BMMonacoCodeEditorThemesCreated=NO;function BMMonacoCodeEditorMakeWithContainer(t,e){return(new BMMonacoCodeEditor).initWithContainer(t,{code:e&&e.code,language:e&&e.language})}BMMonacoCodeEditor.createThemes=function(){_BMMonacoCodeEditorThemesCreated||(_BMMonacoCodeEditorThemesCreated=YES,monaco.editor.defineTheme("BMMonacoCodeEditorTheme",{base:"vs",inherit:YES,colors:[],rules:[{token:"comment",foreground:"CCCCCC"},{token:"string",foreground:"BC670F",background:"FDFBF3"},{token:"keyword",foreground:"6700B9"},{token:"type",foreground:"6700B9"},{token:"identifier",foreground:"434343"},{token:"delimiter",foreground:"434343"},{token:"number",foreground:"7552c1",background:"E7E6FD"},{token:"tag",foreground:"434343"},{token:"attribute.name",foreground:"D4430D"},{token:"attribute.value",foreground:"43A202"},{token:"attribute.value.number",foreground:"5AA201",background:"F6FAEB"},{token:"attribute.value.unit",foreground:"5AA201",background:"F6FAEB"},{token:"attribute.value.hex",foreground:"43A202"},{token:"tag.css",foreground:"3A77BF"}]}),monaco.editor.defineTheme("BMMonacoCodeEditorThemeDark",{base:"vs-dark",inherit:YES,colors:[],rules:[{token:"comment",foreground:"555555"},{token:"string",foreground:"ee9452",background:"FDFBF3"},{token:"keyword",foreground:"a349f5"},{token:"type",foreground:"a349f5"},{token:"identifier",foreground:"bcbcbc"},{token:"delimiter",foreground:"bcbcbc"},{token:"number",foreground:"a37df1",background:"E7E6FD"},{token:"tag",foreground:"bcbcbc"},{token:"attribute.name",foreground:"ff7b41"},{token:"attribute.value",foreground:"80dc4c"},{token:"attribute.value.number",foreground:"92d94b",background:"F6FAEB"},{token:"attribute.value.unit",foreground:"92d94b",background:"F6FAEB"},{token:"attribute.value.hex",foreground:"80dc4c"},{token:"tag.css",foreground:"5fa1ec"}]}))},BMExtend(BMMonacoCodeEditor.prototype,BMCodeEditor.prototype,{_monaco:void 0,_autocompleteLibraries:void 0,_rootES6Library:void 0,_rootjQueryLibrary:void 0,_importsLibrary:void 0,_externalLibraries:void 0,_language:void 0,_darkModeQuery:void 0,_darkModeQueryCallback:void 0,initWithContainer:function(t,e){BMCodeEditor.prototype.initWithContainer.call(this,t),BMMonacoCodeEditor.createThemes();var i={folding:YES,fontLigatures:NO,formatOnPaste:YES,mouseWheelZoom:YES,scrollBeyondLastLine:YES,value:e&&e.code,language:e&&e.language||BMCodeEditorLanguage.Javascript,fontFamily:"Menlo, Meslo LG S, Fira Code, Monaco, monospace",theme:window.matchMedia("(prefers-color-scheme: dark)").matches?"BMMonacoCodeEditorThemeDark":"BMMonacoCodeEditorTheme",disableLayerHinting:YES};this._language=e.language||BMCodeEditorLanguage.Javascript,monaco.languages.typescript.javascriptDefaults.setCompilerOptions({target:monaco.languages.typescript.ScriptTarget.ESNext,allowNonTsExtensions:YES,experimentalDecorators:YES,strict:YES,inlineSourceMap:YES,module:monaco.languages.typescript.ModuleKind.ES2015,noImplicitUseStrict:YES}),monaco.languages.typescript.typescriptDefaults.setCompilerOptions({target:monaco.languages.typescript.ScriptTarget.ESNext,allowNonTsExtensions:YES,experimentalDecorators:YES,strict:YES,inlineSourceMap:YES,inlineSources:YES,noImplicitUseStrict:YES,alwaysStrict:NO,module:monaco.languages.typescript.ModuleKind.ES2015,useDefineForClassFields:NO}),this._monaco=monaco.editor.create(t,i);var o=this;return this._monaco.onDidChangeModelContent((function(t){o.delegate&&o.delegate.codeEditorContentsDidChange&&o.delegate.codeEditorContentsDidChange(o)})),this._externalLibraries={},this._darkModeQueryCallback=t=>{t.matches?monaco.editor.setTheme("BMMonacoCodeEditorThemeDark"):monaco.editor.setTheme("BMMonacoCodeEditorTheme")},this._darkModeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this._darkModeQuery.addListener(this._darkModeQueryCallback),this},setBuiltinES6Library:function(t,e){this._language===BMCodeEditorLanguage.Javascript?(this._rootES6Library=monaco.languages.typescript.javascriptDefaults.addExtraLib(t,"ES6.d.ts"),this._rootjQueryLibrary=monaco.languages.typescript.javascriptDefaults.addExtraLib(e.jQueryLibrary,"jQuery.d.ts"),e.additionalLibraries?this._autocompleteLibraries=monaco.languages.typescript.javascriptDefaults.addExtraLib(e.additionalLibraries.join("\n"),"additional.d.ts"):(this._autocompleteLibraries&&this._autocompleteLibraries.dispose(),this._autocompleteLibraries=void 0)):(this._rootES6Library=monaco.languages.typescript.typescriptDefaults.addExtraLib(t,"ES6.d.ts"),this._rootjQueryLibrary=monaco.languages.typescript.typescriptDefaults.addExtraLib(e.jQueryLibrary,"jQuery.d.ts"),e.additionalLibraries?this._autocompleteLibraries=monaco.languages.typescript.typescriptDefaults.addExtraLib(e.additionalLibraries.join("\n"),"additional.d.ts"):(this._autocompleteLibraries&&this._autocompleteLibraries.dispose(),this._autocompleteLibraries=void 0))},setImports(t){this._language===BMCodeEditorLanguage.Javascript?this._importsLibrary=monaco.languages.typescript.javascriptDefaults.addExtraLib(t,"node_modules/@types/imports/index.d.ts"):this._importsLibrary=monaco.languages.typescript.typescriptDefaults.addExtraLib(t,"node_modules/@types/imports/index.d.ts")},addExternalLibraryNamed(t,e){this._language===BMCodeEditorLanguage.Javascript?this._externalLibraries[t]=monaco.languages.typescript.javascriptDefaults.addExtraLib(e.code,"node_modules/@types/"+t):this._externalLibraries[t]=monaco.languages.typescript.typescriptDefaults.addExtraLib(e.code,"node_modules/@types/"+t)},removeExternalLibraryNamed(t){this._externalLibraries[t]&&(this._externalLibraries[t].dispose(),delete this._externalLibraries[t])},hasExternalLibraryNamed(t){return t in this._externalLibraries},get code(){return this._monaco.getValue()},set code(t){this._monaco.setValue(t)},get requiresTranspilation(){return this._language===BMCodeEditorLanguage.Typescript},transpiledCode(){return new Promise(((t,e)=>{let i;i=monaco.languages.typescript.getLanguageWorker?monaco.languages.typescript.getLanguageWorker("typescript"):monaco.languages.typescript.getTypeScriptWorker(),i.then((e=>{this._monaco.getModel()&&e(this._monaco.getModel().uri).then((e=>{this._monaco.getModel()&&e.getEmitOutput(this._monaco.getModel().uri.toString()).then((function(e){t(e.outputFiles[0].text)}))}))}))}))},get cursorPosition(){var t=this._monaco.getSelection();return BMPointMake(t.startColumn,t.startLineNumber)},set cursorPosition(t){var e=new monaco.Range(t.y,t.x,t.y,t.x);this._monaco.setSelection(e),this._monaco.revealPositionInCenter({lineNumber:t.y,column:t.x})},insertText:function(t){this._monaco.executeEdits("insertSnippet",[{range:this._monaco.getSelection(),text:t,forceMoveMarkers:!0}])},acquireFocus:function(){this._monaco.focus()},resignFocus:function(){},resized:function(){this._monaco.layout()},get supportsExtensibleAutocomplete(){return YES},get scope(){return this._scope},set scope(t){this._scope=t,this._language===BMCodeEditorLanguage.Javascript?this._autocompleteLibrary=monaco.languages.typescript.javascriptDefaults.addExtraLib(t,"BMMonacoCodeEditor.d.ts"):this._autocompleteLibrary=monaco.languages.typescript.typescriptDefaults.addExtraLib(t,"BMMonacoCodeEditor.d.ts")},release:function(){this._monaco.dispose(),this._autocompleteLibrary&&this._autocompleteLibrary.dispose(),this._autocompleteLibraries&&this._autocompleteLibraries.dispose(),this._rootES6Library&&this._rootES6Library.dispose(),this._rootjQueryLibrary&&this._rootjQueryLibrary.dispose(),this._importsLibrary&&this._importsLibrary.dispose(),this._darkModeQuery.removeListener(this._darkModeQueryCallback),Object.keys(this._externalLibraries).forEach((t=>this._externalLibraries[t].dispose()))}});_BMWindowAnimationDurationDefault=400,_BMWindowAnimationEasingDefault="easeInOutQuart";let BM_LAYOUT_EDITOR_USE_SETTINGS_VIEW=NO;const BM_LAYOUT_EDITOR_AUTO_CONSTRAINT_MARGIN=16,BM_LAYOUT_EDITOR_AUTO_CONSTRAINT_SPACING=64,_BMLayoutEditorToolbarHeight=32;function BMLayoutEditor(){}function BMViewLayoutEditor(){this._useSettingsView=YES}function _BMLayoutEditorTree(){}BMLayoutEditor.prototype=BMExtend(Object.create(BMWindow.prototype),{_view:void 0,get view(){return this._view},_settingsView:void 0,isCreatingTouchConstraints:NO,_dismissAnimated(t,e){var i;(e=e||{}).completionHandler&&(i=e.completionHandler);let o=this._view.node.cloneNode(YES),n=this._view.node.parentNode;return this._view.layoutEditor=void 0,this._rootNode.appendChild(this._view.node),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove())),this._view.allSubviews.forEach((t=>t.node.classList.remove("BMLayoutEditorManagedView"))),this._view.layout(),n.appendChild(o),e.completionHandler=()=>{i&&i()},window.removeEventListener("resize",this.resizeListener),BMWindow.prototype.dismissAnimated.call(this,t,e)},frameForDescendant(t){let e=BMView.prototype.frameForDescendant.apply(this,arguments);return t==this.workspaceWrapperView&&(this._staticWorkspaceSize?(this._staticWorkspaceWidth=this._staticWorkspaceSize.width,this._staticWorkspaceHeight=this._staticWorkspaceSize.height):(this._staticWorkspaceWidth=e.size.width,this._staticWorkspaceHeight=e.size.height),this._view.layout()),e},_panOffset:BMPointMake(),get panOffset(){return this._panOffset.copy()},set panOffset(t){if(t=t.copy(),this._panOffset=t,BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this.workspace,{node:this.workspace.node}).registerBuiltInPropertiesWithDictionary({translateX:t.x+"px",translateY:t.y+"px"})}else BMHook(this.workspace.node,{translateX:t.x+"px",translateY:t.y+"px"})},_useSettingsView:NO,initWithView(t,e){this._view=t,this._rootNode=t.node.parentNode,this._view.layoutEditor=this,this.layoutVariableProvider=e&&e.layoutVariableProvider||BMView,this.layoutVariableProvider.prepareLayoutVariables(),this._settingCellClasses={},this.resizeListener=e=>t.needsLayout=YES,window.addEventListener("resize",this.resizeListener),t.allSubviews.forEach((t=>{this._prepareView(t)}));let i=BMRectMake(0,0,document.documentElement.clientWidth,document.documentElement.clientHeight);BMWindow.prototype.initWithFrame.call(this,i,{toolbar:NO}),this._node.classList.add("BMLayoutEditor"),this._overlay._node.classList.add("BMLayoutEditorBlocker"),window.addEventListener("resize",(t=>{var e=document.documentElement.clientWidth,i=document.documentElement.clientHeight;this.frame=BMRectMake(0,0,e,i)})),this.content.style.backgroundColor="rgba(255, 255, 255, .8)";var o=document.createElement("div");if(o.classList.add("BMLayoutEditorTree"),this.treeNode=o,"backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(o.style.backgroundColor="#F8F8F8"),this.content.appendChild(o),this.tree=_BMLayoutEditorTree.editorTreeWithView(t,{node:o,editor:this}),this._useSettingsView){const t=BMRectMake(64,120,320,window.innerHeight-56-280),e=BMToolWindow.toolWindowWithFrame(t,{forWindow:this});e.addSubview(this.tree),this._treeWindow=e,e.opensAutomatically=NO,this.tree.left.equalTo(e.left).isActive=YES,this.tree.right.equalTo(e.right).isActive=YES,this.tree.top.equalTo(e.top).isActive=YES,this.tree.bottom.equalTo(e.bottom).isActive=YES;const i=document.createElement("div");i.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorCloseButton BMLayoutEditorFullscreen BMLayoutEditorDetailsCloseButton",i.innerHTML='<i class="material-icons">&#xE5CD;</i>',i.style.opacity="1",i.style.pointerEvents="all",i.addEventListener("click",(t=>e.dismissAnimated(YES))),e.node.appendChild(i),e.node.classList.add("BMLayoutEditorDetailsWindow"),e.toolbar.style.height="64px",e.width.greaterThanOrEqualTo(320).isActive=YES,e.height.greaterThanOrEqualTo(320).isActive=YES}else this.addSubview(this.tree);if(!this._useSettingsView){let t=document.createElement("div");t.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorCloseButton BMLayoutEditorFullscreen",t.innerHTML='<i class="material-icons">&#xE5CD;</i>',t.style.opacity=1,t.style.pointerEvents="all",t.addEventListener("click",(t=>this.dismissAnimated(YES,{toNode:this._returnNode}))),this.content.appendChild(t)}this._initKeyboardShortcuts();var n=document.createElement("div");n.className="BMLayoutEditorWorkspaceArea",this.content.appendChild(n),this.workspaceArea=n,this.workspaceView=BMView.viewForNode(n),this.addSubview(this.workspaceView);var s=document.createElement("div");s.className="BMLayoutEditorWorkspaceToolbar"+(this._useSettingsView?" BMWindowToolbarMini":""),n.appendChild(s),this._initToolbar(s),this.workspaceToolbar=s,this.workspaceToolbarView=BMView.viewForNode(s),this.workspaceView.addSubview(this.workspaceToolbarView);var a=document.createElement("div");a.className="BMLayoutEditorWorkspaceWrapper",n.appendChild(a),this.workspaceWrapperView=BMView.viewForNode(a),this.workspaceView.addSubview(this.workspaceWrapperView);var r=document.createElement("div");r.className="BMLayoutEditorWorkspace",a.appendChild(r),this.workspaceNode=r,this.workspace=BMView.viewForNode(r),this.workspaceWrapperView.addSubview(this.workspace),BMAddSmoothMousewheelInteractionToNode(a),this._initWorkspaceGestures(),this.panOffset=BMPointMake();let l=document.createElement("div");if(l.className="BMLayoutEditorDetails",this.detailsNode=l,this.detailsView=this._useSettingsView?_BMLayoutEditorSettingsView.settingsViewWithNode(l,{forEditor:this}):BMView.viewForNode(l),this._useSettingsView){l.classList.add("BMLayoutEditorDetailsView");const t=BMRectMake(window.innerWidth-64-384,120,360,Math.min(window.innerHeight-56-128,576)),e=BMToolWindow.toolWindowWithFrame(t,{forWindow:this});e.addSubview(this.detailsView),this.detailsView.left.equalTo(e.left).isActive=YES,this.detailsView.right.equalTo(e.right).isActive=YES,this.detailsView.top.equalTo(e.top).isActive=YES,this.detailsView.bottom.equalTo(e.bottom).isActive=YES,this.detailsView._window=e,e.delegate=this.detailsView,e.node.classList.add("BMLayoutEditorDetailsWindow");const i=document.createElement("div");i.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorCloseButton BMLayoutEditorFullscreen BMLayoutEditorDetailsCloseButton",i.innerHTML='<i class="material-icons">&#xE5CD;</i>',i.style.opacity="1",i.style.pointerEvents="all",i.addEventListener("click",(t=>{this.detailsView._dismissedByUser=YES,e.dismissAnimated(YES,{toRect:BMRectMakeWithNodeFrame(this._inspectorButton)})})),e.node.appendChild(i),e.toolbar.style.height="64px",e.opensAutomatically=NO,e.width.greaterThanOrEqualTo(320).isActive=YES,e.height.greaterThanOrEqualTo(320).isActive=YES,this._detailsToolWindow=e}else{this.content.appendChild(l),this.addSubview(this.detailsView);let t=document.createElement("div");t.className="BMWindowTitle",l.appendChild(t),this.detailsNodeTitle=t;let e=document.createElement("div");e.className="BMLayoutEditorDetailsContent",l.appendChild(e),this.detailsNodeContent=e}this._useSettingsView||(this.tree.top.equalTo(this.top).isActive=YES,this.tree.bottom.equalTo(this.bottom).isActive=YES);const h=this._useSettingsView?[this,this.workspaceView]:[this.tree,this.workspaceView,this.detailsView];if(BMEqualAttributeLayoutConstraint.constraintWithAttribute(BMLayoutAttribute.Top,{forViews:h}).isActive=YES,BMEqualAttributeLayoutConstraint.constraintWithAttribute(BMLayoutAttribute.Bottom,{forViews:h}).isActive=YES,this._useSettingsView?this.workspaceView.leading.equalTo(this.leading).isActive=YES:(this.tree.leading.equalTo(this.leading).isActive=YES,this.tree.trailing.equalTo(this.workspaceView.leading).isActive=YES),this.workspaceView.trailing.equalTo(this._useSettingsView?this.trailing:this.detailsView.leading).isActive=YES,this._useSettingsView||(this.detailsView.trailing.equalTo(this.trailing).isActive=YES),this.treeWidthConstraint=this.tree.width.equalTo(256),this._useSettingsView||(this.treeWidthConstraint.isActive=YES),this.detailsWidthConstraint=this.detailsView.width.equalTo(344,{priority:1e3}),this._useSettingsView||(this.detailsWidthConstraint.isActive=YES),this.workspaceToolbarView.top.equalTo(this.workspaceView.top).isActive=YES,this.workspaceToolbarView.bottom.equalTo(this.workspaceWrapperView.top).isActive=YES,this.workspaceWrapperView.bottom.equalTo(this.workspaceView.bottom).isActive=YES,this.workspaceToolbarView.leading.equalTo(this.workspaceView.leading).isActive=YES,this.workspaceToolbarView.trailing.equalTo(this.workspaceView.trailing).isActive=YES,this.workspaceWrapperView.leading.equalTo(this.workspaceView.leading).isActive=YES,this.workspaceWrapperView.trailing.equalTo(this.workspaceView.trailing).isActive=YES,this.workspaceToolbarHeightConstraint=this.workspaceToolbarView.height.equalTo(this._useSettingsView?32:64),this.workspaceToolbarHeightConstraint.isActive=YES,this.workspaceWidth=this.workspace.width.equalTo(this.workspaceWrapperView.width),this.workspaceWidth.isActive=YES,this.workspaceHeight=this.workspace.height.equalTo(this.workspaceWrapperView.height),this.workspaceHeight.isActive=YES,this.workspaceLeft=this.workspace.left.equalTo(this.workspaceWrapperView.left),this.workspaceLeft.isActive=YES,this.workspaceTop=this.workspace.top.equalTo(this.workspaceWrapperView.top),this.workspaceTop.isActive=YES,this.workspace.left.greaterThanOrEqualTo(this.workspaceWrapperView.left).isActive=YES,this.workspace.top.greaterThanOrEqualTo(this.workspaceWrapperView.top).isActive=YES,BMIsTouchDevice){let t=document.createElement("div");t.className="BMWindowButton BMLayoutEditorTouchHandler",t.innerText="Create Constraint",t.addEventListener("touchstart",(e=>{t.classList.add("BMLayoutEditorTouchHandlerActive"),this.isCreatingTouchConstraints=YES,e.preventDefault()})),t.addEventListener("touchend",(e=>{t.classList.remove("BMLayoutEditorTouchHandlerActive"),this.isCreatingTouchConstraints=NO,e.preventDefault()})),t.addEventListener("touchcancel",(e=>{t.classList.remove("BMLayoutEditorTouchHandlerActive"),this.isCreatingTouchConstraints=NO})),this.content.appendChild(t)}return this},_prepareView(t){let e=document.createElement("div");e.className="BMLayoutEditorViewSelector",t._selector=e,t.node.classList.add("BMLayoutEditorManagedView");const i=document.createElement("div");let o,n;i.className="material-icons BMWindowDragHandle BMLayoutEditorViewDragHandle",i.innerText="dehaze",i.style.cursor="nwse-resize",e.appendChild(i),i.addEventListener("mousedown",(e=>{let i=BMSizeMake(t.frame.size.width,t.frame.size.height),o=BMPointMake(e.clientX,e.clientY),n=NO,s=e=>{n||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),n=YES);let s=BMPointMake(e.clientX,e.clientY);const a=t.frame.copy();a.size.width=i.width+(s.x-o.x)/this.scale,a.size.height=i.height+(s.y-o.y)/this.scale,t.frame=a,i=BMSizeMake(i.width+(s.x-o.x)/this.scale,i.height+(s.y-o.y)/this.scale),o=s,e.preventDefault(),e.stopPropagation()},a=document.createElement("div");a.className="BMLayoutGuideMask",a.style.cursor="nwse-resize",document.body.appendChild(a);let r=e=>{window.removeEventListener("mousemove",s,YES),window.removeEventListener("mouseup",r,YES),a.remove(),e.preventDefault(),e.stopPropagation(),this.selectView(t)};window.addEventListener("mousemove",s,YES),window.addEventListener("mouseup",r,YES),e.preventDefault(),e.stopPropagation()})),i.addEventListener("touchstart",(e=>{o=e.changedTouches[0].identifier;let i=BMSizeMake(t.frame.size.width,t.frame.size.height),n=BMPointMake(e.changedTouches[0].clientX,e.changedTouches[0].clientY),s=NO,a=e=>{let a;for(let t of e.changedTouches)if(t.identifier==o){a=t;break}if(!a)return;s||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),s=YES);let r=BMPointMake(a.clientX,a.clientY);const l=t.frame.copy();l.size.width=i.width+(r.x-n.x)/this.scale,l.size.height=i.height+(r.y-n.y)/this.scale,t.frame=l,i=BMSizeMake(i.width+(r.x-n.x)/this.scale,i.height+(r.y-n.y)/this.scale),n=r,e.preventDefault(),e.stopPropagation()},r=e=>{o=void 0,window.removeEventListener("touchmove",a),window.removeEventListener("touchend",r),window.removeEventListener("touchcancel",r),e.preventDefault(),e.stopPropagation(),this.selectView(t)};window.addEventListener("touchmove",a),window.addEventListener("touchend",r),window.removeEventListener("touchcancel",r),e.preventDefault(),e.stopPropagation()})),e.addEventListener("click",(e=>{e.altKey||(this.selectView(t,{withEvent:e}),n?(n=void 0,this._detailsToolWindow._visible||this._detailsToolWindow.bringToFrontAnimated(YES,{fromRect:BMRectMakeWithNodeFrame(this._inspectorButton)})):n=setTimeout((()=>n=void 0),250),e.stopPropagation(),e.stopImmediatePropagation())})),this.initDragEventListenerForNode(e,{view:t}),e.addEventListener("mousedown",(t=>2!=t.button&&(t.stopPropagation(),t.stopImmediatePropagation()))),e.addEventListener("mousemove",(t=>2!=t.button&&(t.stopPropagation(),t.stopImmediatePropagation()))),e.addEventListener("mouseup",(t=>2!=t.button&&(t.stopPropagation(),t.stopImmediatePropagation()))),t.node.childNodes.length?t.node.insertBefore(e,t.node.childNodes[0]):t.node.appendChild(e)},_isFullScreen:NO,toggleFullscreenWithEvent(t){this._useSettingsView||(this._isFullScreen?(this.treeWidthConstraint.constant=256,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._fullScreenButton.style.marginLeft="0px",this._isFullScreen=!1):(this.treeWidthConstraint.constant=0,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._fullScreenButton.style.marginLeft="72px",this._isFullScreen=!0))},_isSettingsPaneHidden:NO,toggleSettingsPaneWithEvent(t){this._useSettingsView||(this._isSettingsPaneHidden?(this.detailsWidthConstraint.constant=344,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._isSettingsPaneHidden=!1):(this.detailsWidthConstraint.constant=0,BMAnimateWithBlock((()=>this.layout()),{duration:300,easing:"easeInOutQuad"}),this._isSettingsPaneHidden=!0))},_scale:1,get scale(){return this._scale},set scale(t){if(!isNaN(t)&&(t=BMNumberByConstrainingNumberToBounds(t,.25,2),this._scale!=t))if(this._scale=t,BMAnimationContextGetCurrent()){BMAnimationContextGetCurrent().controllerForObject(this.workspace,{node:this.workspace.node}).registerBuiltInPropertiesWithDictionary({scaleX:t,scaleY:t})}else BMHook(this.workspace.node,{scaleX:t,scaleY:t})},_activeSizeClass:void 0,get activeSizeClass(){return this._activeSizeClass},set activeSizeClass(t){let e=!!this._activeSizeClass;this._activeSizeClass=t,t?(e||this.workspaceToolbar.classList.add("BMLayoutEditorWorkspaceToolbarSizeClass"),e||this.workspaceToolbar.classList.add("BMWindowToolbarDark")):(e&&this.workspaceToolbar.classList.remove("BMLayoutEditorWorkspaceToolbarSizeClass"),e&&this.workspaceToolbar.classList.remove("BMWindowToolbarDark"));let i=t?BMViewport.currentViewport():void 0;t&&(t._maximumWidth&&(i._width=t._maximumWidth),t._maximumHeight&&(i._height=t._maximumHeight),t._maximumDiagonal&&(i._diagonal=t._maximumDiagonal),t._orientation!=BMLayoutOrientation.Any&&(i._orientation=t._orientation),t._maximumSurfaceArea&&(i._surfaceArea=t._maximumSurfaceArea)),this.view._requiredViewport=i,this.view._invalidatedSizeClasses=YES,this.view.needsLayout=YES,this.awaitLayout?this.layoutQueue._views.delete(this.view):BMAnimateWithBlock((()=>{this.view.layout()}),{duration:300,easing:"easeInOutQuart",complete:()=>{this.selectedView&&this.selectView(this.selectedView),this.selectedConstraint&&this.selectConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})}})},layoutVariableProvider:BMView,_settingCellClasses:void 0,registerCellClass(t,{forSettingOfKind:e}){this._settingCellClasses[e]=t},_showSizeClassMenuAtPoint(t,{action:e,kind:i}={}){let o=[];o.push(this._sizeClassMenuItemMakeWithName("All Size Classes",{ofType:"Desktop",preview:"Fill",action:e})),o.push(this.settingsDivider()),o.push(this._sizeClassMenuItemMakeWithName("Phone",{ofType:"Phone",sizeClass:BMLayoutSizeClass.phoneSizeClass(),preview:"Phone Portrait",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Phone Portrait",{ofType:"PhonePortrait",sizeClass:BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Portrait),preview:"Phone Portrait",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Phone Landscape",{ofType:"PhoneLandscape",sizeClass:BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Landscape),preview:"Phone Landscape",action:e})),o.push(this.settingsDivider()),o.push(this._sizeClassMenuItemMakeWithName("Tablet",{ofType:"Tablet",sizeClass:BMLayoutSizeClass.tabletSizeClass(),preview:"Tablet Landscape",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Tablet Portrait",{ofType:"TabletPortrait",sizeClass:BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Portrait),preview:"Tablet Portrait",action:e})),o.push(this._sizeClassMenuItemMakeWithName("Tablet Landscape",{ofType:"TabletLandscape",sizeClass:BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Landscape),preview:"Tablet Landscape",action:e})),this.showMenuAtPoint(t,{withOptions:o,kind:i||BMMenuKind.PullDownMenu})},_sizeClassMenuItemMakeWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorConstraintPopupOption BMLayoutEditorSizeClassPopupOption";let o=document.createElement("div");o.className="BMLayoutEditorSizeClassImage BMLayoutEditorImage"+e.ofType+"Mini",i.appendChild(o);let n=document.createElement("span");return n.innerText=t,i.appendChild(n),i.addEventListener("click",(i=>{if(e.action)e.action(e.sizeClass);else{if(e.preview&&(this.awaitLayout=YES),this.activeSizeClass=e.sizeClass,this._sizeClassImage.className="BMLayoutEditorSizeClassImage BMLayoutEditorImage"+e.ofType+"Mini",this._sizeClassText.innerText=t,e.preview){this.deviceSelector.value=e.preview;i=new Event("change");this.deviceSelector.dispatchEvent(i)}this.awaitLayout=NO,this._useSettingsView&&this.detailsView.layoutEditorDidSelectSizeClass(e.sizeClass)}})),i},_inspectorButton:void 0,_initKeyboardShortcuts(){this._useSettingsView&&(this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectLeftConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectTopConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectRightConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"selectBottomConstraintWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("KeyI",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"toggleDetailsToolWindow",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("KeyI",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Shift],target:this,action:"toggleNavigationToolWindow",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Backspace",{modifiers:[BMKeyboardShortcutModifier.System],target:this,action:"commandBackspacePressedWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Backspace",{modifiers:[],target:this,action:"backspacePressedWithEvent"})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Digit0",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Option],target:this,action:"setConstraintToEqualWithEvent",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Minus",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Option],target:this,action:"setConstraintToLessThanWithEvent",preventsDefault:YES})),this.registerKeyboardShortcut(BMKeyboardShortcut.keyboardShortcutWithKeyCode("Equal",{modifiers:[BMKeyboardShortcutModifier.System,BMKeyboardShortcutModifier.Option],target:this,action:"setConstraintToGreaterThanWithEvent",preventsDefault:YES})))},_initToolbar(t){if(this._useSettingsView){const e=document.createElement("div");e.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",e.innerHTML='<i class="material-icons">&#xE5CD;</i>',e.style.opacity="1",e.addEventListener("click",(t=>this.dismissAnimated(YES,{toNode:this._returnNode}))),t.appendChild(e)}const e=document.createElement("div");e.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",e.style.transition="margin-left .3s ease",e.innerHTML=`<i class="material-icons" style="pointer-events: none;">${this._useSettingsView?"layers":"&#xE5DC;"}</i>`,this._fullScreenButton=e,e.style.opacity="1",e.style.pointerEvents="all",e.addEventListener("click",this._useSettingsView?t=>this._treeWindow.toggleAnimated(YES):t=>this.toggleFullscreenWithEvent(t)),t.appendChild(e);let i=document.createElement("div");i.className="BMWindowToolbarLabel",i.innerText="View:",t.appendChild(i);let o=document.createElement("select");o.className="BMWindowInput BMWindowToolbarInput",this.deviceSelector=o,o.appendChild(this.optionNamed("Fill")),o.appendChild(this.optionNamed("Full HD")),o.appendChild(this.optionNamed('15" Laptop')),o.appendChild(this.optionNamed('13" Laptop')),o.appendChild(this.optionNamed("Tablet Landscape")),o.appendChild(this.optionNamed("Tablet Portrait")),o.appendChild(this.optionNamed("Phone Portrait")),o.appendChild(this.optionNamed("Phone Landscape")),o.appendChild(this.optionNamed("Custom")),t.appendChild(o);let n=document.createElement("input");n.type="number",n.style.cssText="width: 64px !important; margin-left: 32px !important; text-align: center;",n.className="BMWindowInput BMWindowToolbarInput",n.disabled=!0,t.appendChild(n);let s;n.addEventListener("input",(t=>{s&&window.clearTimeout(s),s=window.setTimeout((()=>{if(s=void 0,n.disabled)return;let t=parseInt(n.value,10);isNaN(t)||(this._staticWorkspaceSize.width=t,this._setStaticWorkspaceSize(this._staticWorkspaceSize))}),400)}));let a=document.createElement("div");a.className="BMWindowToolbarLabel",a.innerText="⨯",t.appendChild(a);let r,l=document.createElement("input");l.type="number",l.style.cssText="width: 64px !important; text-align: center;",l.className="BMWindowInput BMWindowToolbarInput",l.disabled=!0,t.appendChild(l),l.addEventListener("input",(t=>{r&&window.clearTimeout(r),r=window.setTimeout((()=>{if(r=void 0,l.disabled)return;let t=parseInt(l.value,10);isNaN(t)||(this._staticWorkspaceSize.height=t,this._setStaticWorkspaceSize(this._staticWorkspaceSize))}),400)})),o.addEventListener("change",(t=>{let e=o.value;"Fill"==e?(this._staticWorkspaceSize=void 0,this.workspaceLeft.remove(),this.workspaceTop.remove(),this.workspaceWidth.remove(),this.workspaceHeight.remove(),(this.workspaceLeft=this.workspace.left.equalTo(this.workspaceWrapperView.left)).isActive=YES,(this.workspaceTop=this.workspace.top.equalTo(this.workspaceWrapperView.top)).isActive=YES,(this.workspaceWidth=this.workspace.width.equalTo(this.workspaceWrapperView.width)).isActive=YES,(this.workspaceHeight=this.workspace.height.equalTo(this.workspaceWrapperView.height)).isActive=YES,BMAnimateWithBlock((()=>{this.layout()}),{duration:300,easing:"easeInOutQuart",complete:()=>{this.selectedView&&this.selectView(this.selectedView),this.selectedConstraint&&this.selectConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})}}),n.value="",l.value="",n.disabled=!0,l.disabled=!0):("Full HD"==e&&(this._setStaticWorkspaceSize(BMSizeMake(1920,1080),{animated:YES}),n.value=1920,l.value=1080),'15" Laptop'==e&&(this._setStaticWorkspaceSize(BMSizeMake(1680,1050),{animated:YES}),n.value=1680,l.value=1050),'13" Laptop'==e&&(this._setStaticWorkspaceSize(BMSizeMake(1400,900),{animated:YES}),n.value=1400,l.value=900),"Tablet Portrait"==e&&(this._setStaticWorkspaceSize(BMSizeMake(768,1024),{animated:YES}),n.value=768,l.value=1024),"Tablet Landscape"==e&&(this._setStaticWorkspaceSize(BMSizeMake(1024,768),{animated:YES}),n.value=1024,l.value=768),"Phone Portrait"==e&&(this._setStaticWorkspaceSize(BMSizeMake(375,667),{animated:YES}),n.value=375,l.value=667),"Phone Landscape"==e&&(this._setStaticWorkspaceSize(BMSizeMake(667,375),{animated:YES}),n.value=667,l.value=375),"Custom"==e?(this._setStaticWorkspaceSize(BMSizeMake(parseInt(n.value,10)||800,parseInt(l.value,10)||600)),n.value=n.value||800,l.value=l.value||600,n.disabled=!1,l.disabled=!1):(n.disabled=!0,l.disabled=!0))}));let h=document.createElement("div");h.className="BMWindowFlexibleSpace",t.appendChild(h);let c=document.createElement("div");c.className="BMWindowToolbarLabel",c.innerText="Zoom:",t.appendChild(c);const d=document.createElement("input");d.type="range",d.min="25",d.max="200",d.value="100",d.style.cssText="width: 100px; height: 24px",t.appendChild(d);const u=document.createElement("input");u.type="number",u.value="100",u.style.cssText="width: 64px !important; text-align: center;",u.className="BMWindowInput BMWindowToolbarInput",t.appendChild(u),d.addEventListener("input",(t=>{const e=parseFloat(d.value);if(isNaN(e))return;u.value=e;const i=e/100;this.scale=i})),u.addEventListener("input",(t=>{let e=parseFloat(u.value);if(isNaN(e))return;e=BMNumberByConstrainingNumberToBounds(e,25,200),d.value=e;const i=e/100;this.scale=i})),this.zoomBox=u,this.zoomSlider=d;const p=document.createElement("div");p.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",p.innerHTML='<i class="material-icons" style="pointer-events: none;">center_focus_strong</i>',p.style.opacity=1,p.style.pointerEvents="all",p.addEventListener("click",(t=>{BMAnimateWithBlock((()=>{this.zoomSlider.value=100,this.zoomBox.value=100,this.panOffset=BMPointMake(0,0),this.scale=1}),{duration:200,easing:"easeInOutQuad"})})),t.appendChild(p);let g=document.createElement("div");g.className="BMWindowFlexibleSpace",t.appendChild(g);let w=document.createElement("div");w.className="BMWindowInput BMWindowToolbarInput BMLayoutEditorSizeClassSelector";let y=document.createElement("div");y.className="BMLayoutEditorSizeClassImage BMLayoutEditorImageDesktop",w.appendChild(y),this._sizeClassImage=y;let m=document.createElement("span");m.innerText="All Size Classes",w.appendChild(m),this._sizeClassText=m,t.appendChild(w),w.addEventListener("click",(t=>{let e=BMRectMakeWithNodeFrame(w),i=BMPointMake(e.left,e.bottom);this._showSizeClassMenuAtPoint(i)}));const _=document.createElement("div");_.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",_.innerHTML='<i class="material-icons BMScriptFont" style="pointer-events: none;">+</i>',t.appendChild(_),this.addViewsButton=_,_.addEventListener("click",(t=>this.showViewsPopupWithEvent(t)));const f=document.createElement("div");f.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",f.innerHTML='<i class="material-icons BMScriptFont" style="pointer-events: none;">{X}</i>',t.appendChild(f),this.layoutVariablesButton=f,f.addEventListener("click",(t=>this.showLayoutVariablesPopupWithEvent(t)));const v=document.createElement("div");v.className="BMWindowToolbarButton BMLayoutEditorToolbarButton",v.innerHTML=`<i class="material-icons" style="pointer-events: none;">${this._useSettingsView?"toggle_on":"&#xE5DD;"}</i>`,v.style.opacity=1,v.style.pointerEvents="all",this._inspectorButton=v,v.addEventListener("click",this._useSettingsView?t=>this.detailsView._window.toggleAnimated(YES,{fromRect:BMRectMakeWithNodeFrame(this._inspectorButton)}):t=>this.toggleSettingsPaneWithEvent(t)),t.appendChild(v)},toggleDetailsToolWindow(){this.detailsView._window.toggleAnimated(YES,{fromRect:BMRectMakeWithNodeFrame(this._inspectorButton)})},toggleNavigationToolWindow(){this._treeWindow.toggleAnimated(YES)},_initWorkspaceGestures(){const t=this.workspaceWrapperView.node;let e,i,o,n,s;t.addEventListener("touchstart",(t=>{this.isCreatingTouchConstraints||2==t.touches.length&&(e=BMPointMake(t.touches[0].pageX,t.touches[0].pageY),i=BMPointMake(t.touches[1].pageX,t.touches[1].pageY),o=BMPointMake((e.x+i.x)/2,(e.y+i.y)/2),n=e.distanceToPoint(i),t.stopPropagation(),t.preventDefault())}),YES),t.addEventListener("touchmove",(t=>{if(!this.isCreatingTouchConstraints&&2==t.touches.length){t.stopPropagation(),t.preventDefault();const s=BMPointMake(t.touches[0].pageX,t.touches[0].pageY),a=BMPointMake(t.touches[1].pageX,t.touches[1].pageY),r=BMPointMake((s.x+a.x)/2,(s.y+a.y)/2),l=BMPointMake(r.x-o.x,r.y-o.y),h=BMPointMake(this.panOffset.x+l.x,this.panOffset.y+l.y);this.panOffset=h;const c=s.distanceToPoint(a),d=c/n-1;this.scale+=d/1.25,e=s,i=a,o=r,n=c}}),YES),t.addEventListener("wheel",(t=>{if(t.preventDefault(),t.altKey){const e=((0==t.deltaMode?t.deltaY:10*t.deltaY)/25|0)/100;this.scale+=e,this.zoomBox.value=100*this.scale|0,this.zoomSlider.value=100*this.scale|0}else{let e,i;0==t.deltaMode?(e=0|t.deltaX,i=0|t.deltaY):(e=10*t.deltaX|0,i=10*t.deltaY|0);const o=this.panOffset;o.x-=e,o.y-=i,this.panOffset=o}}));t.addEventListener("mousedown",(t=>{if(0==t.button&&t.altKey){t.preventDefault(),t.stopPropagation(),s=BMPointMake(t.screenX,t.screenY);const e=t=>{const e=this.panOffset;e.x+=t.screenX-s.x,e.y+=t.screenY-s.y,s=BMPointMake(t.screenX,t.screenY),this.panOffset=e,t.stopPropagation(),t.preventDefault()},i=t=>{t.stopPropagation(),t.preventDefault(),window.removeEventListener("click",o,YES),window.removeEventListener("mousemove",e,YES),window.removeEventListener("mouseup",i,YES)},o=t=>{t.preventDefault(),t.stopPropagation()};window.addEventListener("click",o,YES),window.addEventListener("mousemove",e,YES),window.addEventListener("mouseup",i,YES)}}),YES)},_pathForPopoverWithFrame(t,{widthIndicatorSize:e=8,radius:i=8,inset:o=0,knobPosition:n,gravity:s="Top"}={widthIndicatorSize:8,radius:4,inset:0}){let a="Bottom"===s?0:e*Math.SQRT2/2|0,r="Bottom"===s?t.size.height-e*Math.SQRT2/2|0:t.size.height;const l=o;o&&(e-=o,(t=t.copy()).insetWithInset(BMInsetMakeWithEqualInsets(o)),i+=o,a+=o,r-=o),n=void 0===n?t.size.width/2|0:n-o|0;const h=e*Math.SQRT2,c=h/2|0,d="Bottom"===s?`M${l+i},${a} L${t.size.width+l-i},${a} `:`M${l+i},${a} L${n-h/2+l},${a} l${h/2},${-c} l${h/2},${c} L${t.size.width+l-i},${a} `,u="Bottom"===s?`Q${t.size.width+l},${r} ${t.size.width+l-i},${r} L${n+h/2+l},${r} l${-h/2},${c} l${-h/2},${-c} L${i},${r} `:`Q${t.size.width+l},${r} ${t.size.width+l-i},${r} L${i},${r} `;let p=d;return p+=`Q${t.size.width+l},${a} ${t.size.width+l},${a+i} L${t.size.width+l},${r-i} `,p+=u,p+=`Q${l},${r} ${l},${r-i} L${l},${a+i} Q${l},${a} ${i},${a} Z`,p},showLayoutVariablesPopupWithEvent(t){const e=document.body,i=document.createElement("div");i.className="BMPopoverContainer";const o=document.createElement("div");o.className="BMPopoverContainerLayer BMPopoverDropShadowContainer";const n=document.createElement("div");n.className="BMPopoverDropShadowContent",o.appendChild(n);const s=document.createElement("div");s.className="BMPopoverBackground",s.innerHTML='<div class="BMPopoverBackgroundDarkModeContainer"><div class="BMPopoverBackgroundDarkModeOutline"></div><div class="BMPopoverBackgroundDarkModeFill"></div></div>';const a=BMRectMakeWithNodeFrame(this.layoutVariablesButton).center,r=BMRectMake(window.innerWidth-320-16,a.y+16,320,388);r.origin.x=Math.min(r.origin.x,a.x-r.width/2);const l=a.x-r.origin.x,h=`path('${this._pathForPopoverWithFrame(r,{widthIndicatorSize:16,knobPosition:l})}')`,c=`path('${this._pathForPopoverWithFrame(r,{widthIndicatorSize:16,inset:1,knobPosition:l})}')`,d={left:r.origin.x+"px",top:r.origin.y+"px",width:r.size.width+"px",height:r.size.height+"px"};BMCopyProperties(i.style,d),BMCopyProperties(s.style,d),s.style.clipPath=h,s.style.webkitClipPath=h;const u=s.querySelector(".BMPopoverBackgroundDarkModeFill");u.style.clipPath=c,u.style.webkitClipPath=c,BMCopyProperties(o.style,d),n.style.clipPath=h,n.style.webkitClipPath=h;const p=document.createElement("div");p.className="BMPopoverOverlay",e.appendChild(p);const g=document.createElement("div");g.innerText="Layout Variables",g.className="BMWindowTitle",i.appendChild(g);const w=document.createElement("div");w.className="BMLayoutEditorVariablesContainer",i.appendChild(w);const y=document.createElement("button");y.className="BMWindowButton",y.innerText="Add Variable",y.style.boxSizing="border-box",this.layoutVariableProvider.canUseLayoutVariables()&&i.appendChild(y);const m=BMCollectionView.collectionViewForNode(w),_=(new BMLayoutEditorVariablesDataSet).initWithLayoutVariableProvider(this.layoutVariableProvider,{collectionView:m,editor:this});m.cellClass=BMLayoutEditorVariableCell,m.registerSupplementaryViewClass(BMLayoutEditorEmptyVariablesCell,{forReuseIdentifier:BMCollectionViewFlowLayoutSupplementaryView.Empty}),m.layout.maximumCellsPerRow=1,m.layout.gravity=BMCollectionViewFlowLayoutGravity.Expand,m.layout.rowSpacing=0,m.layout.topPadding=0,m.layout.bottomPadding=0,m.layout.contentGravity=BMCollectionViewFlowLayoutAlignment.Start,e.appendChild(s),e.appendChild(o),e.appendChild(i);let f=YES;m.delegate=_,(async()=>{await this.layoutVariableProvider.prepareLayoutVariables(),f&&(m.dataSet=_)})(),y.addEventListener("click",(t=>{_.addVariable()}));const v=[i,s,o];for(const t of v)t.style.transformOrigin=l/r.size.width*100+"% 0%",BMHook(t,{scaleX:.75,scaleY:.75,opacity:0}),__BMVelocityAnimate(t,{scaleX:1,scaleY:1,opacity:1},{duration:300,easing:[0,1.59,.49,1]});p.addEventListener("click",(t=>{f=NO,m.dataSet&&this.layoutVariableProvider.persistLayoutVariables(),m.release(),p.remove();for(const t of v)t.style.pointerEvents="none",__BMVelocityAnimate(t,{scaleX:.9,scaleY:.9,opacity:0},{duration:200,easing:"easeInOutQuart",complete(){t.remove()}});this.node.focus()}))},_showConstantPopupAtPoint(t,{forConstraint:e,withReferenceView:i}){const o=document.body,n=t.y<160,s=document.createElement("div");s.className="BMPopoverContainer BMPopoverContainerConstant"+(n?" BMPopoverContainerConstantBelow":"");const a=document.createElement("div");a.className="BMPopoverContainerLayer BMPopoverDropShadowContainer";const r=document.createElement("div");r.className="BMPopoverDropShadowContent",a.appendChild(r);const l=document.createElement("div");l.className="BMPopoverBackground",l.innerHTML='<div class="BMPopoverBackgroundDarkModeContainer"><div class="BMPopoverBackgroundDarkModeOutline"></div><div class="BMPopoverBackgroundDarkModeFill"></div></div>';const h=this.activeSizeClass?96:64,c=BMRectMake(t.x-120,n?t.y:t.y-h-8,240,h+8);c.origin.x<-4&&(c.origin.x=-4),c.right>window.innerWidth+4&&(c.origin.x=window.innerWidth-c.size.width+4);const d=BMNumberByConstrainingNumberToBounds(t.x-c.origin.x,12,c.size.width-12),u=`path('${this._pathForPopoverWithFrame(c,{widthIndicatorSize:16,knobPosition:d,gravity:n?"Top":"Bottom"})}')`,p=`path('${this._pathForPopoverWithFrame(c,{widthIndicatorSize:16,inset:1,knobPosition:d,gravity:n?"Top":"Bottom"})}')`,g={left:c.origin.x+"px",top:c.origin.y+"px",width:c.size.width+"px",height:c.size.height+"px"};BMCopyProperties(s.style,g),BMCopyProperties(l.style,g),l.style.clipPath=u,l.style.webkitClipPath=u;const w=l.querySelector(".BMPopoverBackgroundDarkModeFill");w.style.clipPath=p,w.style.webkitClipPath=p,BMCopyProperties(a.style,g),r.style.clipPath=u,r.style.webkitClipPath=u;const y=document.createElement("div");y.className="BMPopoverOverlay",o.appendChild(y),o.appendChild(l),o.appendChild(a),o.appendChild(s);const m=this;if(this.activeSizeClass){const t=document.createElement("div");t.className="BMLayoutEditorDetailsItemBadgeIcon",t.style.flexShrink="0",t.style.top="1px",s.appendChild(t);const o=document.createElement("div");o.className="BMLayoutEditorDetailsTitleCell",o.innerText="Constant:",o.style.paddingRight="8px",s.appendChild(o);const n=document.createElement("input");n.type="text",n.style.width="50px",n.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemTextValue",n.value=e.constant,s.appendChild(n);BMTextField.textFieldForInputNode(n).delegate={textFieldSuggestionsForText(){const t=[],e=Object.keys(m.layoutVariableProvider.layoutVariables),i=new Set;e.forEach((t=>i.add(t)));for(const e of i)t.unshift(e),t.push("-"+e);return t},textFieldShouldShowSuggestions:()=>NO,textFieldContentsDidChange(){const t=parseFloat(n.value),i=isNaN(t)?n.value:t;n.value?(e.constant=i,e._updateConfiguration(),e._constraint=void 0,e._constituentConstraints=void 0,e._sourceView?e._sourceView.needsLayout=YES:e._views[0].needsLayout=YES):e.constant=0},textFieldShouldReturn:()=>(y.dispatchEvent(new Event("click")),m.selectView(i),YES)};const a=document.createElement("div");a.style.flexBasis="100%",a.className="BMLayoutEditorDetailsDivider",a.style.marginTop="0px",a.style.marginBottom="0px",s.appendChild(a);const r=this.settingsBadgeForSizeClass(this.activeSizeClass);r.style.flexShrink="0",r.style.top="1px",s.appendChild(r)}const _=document.createElement("div");_.className="BMLayoutEditorDetailsTitleCell",_.innerText="Constant:",_.style.paddingRight="8px",s.appendChild(_);const f=document.createElement("input");f.type="text",f.style.width="50px",f.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemTextValue",this.activeSizeClass?e._variations[this.activeSizeClass]?f.value=e._variations[this.activeSizeClass].constant||"":f.value="":f.value=e.constant,s.appendChild(f);BMTextField.textFieldForInputNode(f).delegate={textFieldSuggestionsForText(){const t=[],e=Object.keys(m.layoutVariableProvider.layoutVariables),i=new Set;e.forEach((t=>i.add(t)));for(const e of i)t.unshift(e),t.push("-"+e);return t},textFieldShouldShowSuggestions:()=>NO,textFieldContentsDidChange(){const t=parseFloat(f.value),i=isNaN(t)?f.value:t;f.value?(m.activeSizeClass?e.setConstant(i,{forSizeClass:m.activeSizeClass}):e.constant=i,e._updateConfiguration(),e._constraint=void 0,e._constituentConstraints=void 0,e._sourceView?e._sourceView.needsLayout=YES:e._views[0].needsLayout=YES):m.activeSizeClass?(e.removeConstantVariationForSizeClass(m.activeSizeClass),e._updateConfiguration()):e.constant=0},textFieldShouldReturn:()=>(y.dispatchEvent(new Event("click")),m.selectView(i),YES)},f.focus(),f.select();let v=YES;const M=[s,l,a];for(const t of M)t.style.transformOrigin=d/c.size.width*100+"% "+(n?"100%":"0%"),BMHook(t,{scaleX:.75,scaleY:.75,opacity:0}),__BMVelocityAnimate(t,{scaleX:1,scaleY:1,opacity:1},{duration:300,easing:[0,1.59,.49,1]});y.addEventListener("click",(t=>{v=NO,y.remove();for(const t of M)t.style.pointerEvents="none",__BMVelocityAnimate(t,{scaleX:.9,scaleY:.9,opacity:0},{duration:200,easing:"easeInOutQuart",complete(){t.remove()}});this.node.focus()}))},_setStaticWorkspaceSize(t,e){this._staticWorkspaceSize=t,this.workspaceLeft.remove(),this.workspaceTop.remove(),this.workspaceWidth.remove(),this.workspaceHeight.remove(),(this.workspaceLeft=this.workspace.centerX.equalTo(this.workspaceWrapperView.centerX,{priority:750})).isActive=YES,(this.workspaceTop=this.workspace.centerY.equalTo(this.workspaceWrapperView.centerY,{priority:750})).isActive=YES,(this.workspaceWidth=this.workspace.width.equalTo(t.width)).isActive=YES,(this.workspaceHeight=this.workspace.height.equalTo(t.height)).isActive=YES,BMAnimateWithBlock((()=>{this.layout()}),{duration:300,easing:"easeInOutQuart",complete:()=>{this.selectedView&&this.selectView(this.selectedView),this.selectedConstraint&&this.selectConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})}})},_bringToFrontAnimated(t,e){var i;(e=e||{}).completionHandler&&(i=e.completionHandler),e.completionHandler=t=>{i&&i(),this._view.needsLayout=YES},BMWindow.prototype.bringToFrontAnimated.apply(this,arguments),this._view.node.style.display="block",this.workspaceNode.appendChild(this._view.node),requestAnimationFrame((t=>this._view.needsLayout=YES))},_drawConstraintsForView(t,e){e=e||{},this._clearOffsets(),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove()));let i=[];t.localConstraints.forEach((o=>{if(!o.affectsLayout&&!e.includesInactiveConstraints)return;o._isConstraintCollection;const n=this._drawConstraint(o,{withReferenceView:t});if(Array.isArray(n))for(const t of n)i.push(t);else i.push(n)})),i=i.filter((t=>t));let o=NO;for(let t=0;t<500;t++){for(const t of i)for(const e of i){if(e==t||e.kind!=t.kind)continue;let i="x",n="y";if(t.kind!==BMLayoutConstraintKind.Horizontal&&(i="y",n="x"),t.sourcePoint[i]==e.sourcePoint[i]&&Math.abs(t.sourcePoint[n]-e.sourcePoint[n])<5){const i=3*(Math.sign(t.sourcePoint[n]-e.sourcePoint[n])||-1),s=3*(Math.sign(e.sourcePoint[n]-t.sourcePoint[n])||1);t.sourcePoint[n]==t.targetPoint[n]&&(t.targetPoint[n]+=i),e.sourcePoint[n]==e.targetPoint[n]&&(e.targetPoint[n]+=s),t.sourcePoint[n]+=i,e.sourcePoint[n]+=s,t.displaced=YES,e.displaced=YES,o=YES}}if(!o)break}for(const t of i.filter((t=>t.displaced)))t.kind==BMLayoutConstraintKind.Horizontal?(BMCopyProperties(t.node.style,{left:Math.min(t.sourcePoint.x,t.targetPoint.x)+"px",top:t.sourcePoint.y+"px"}),BMCopyProperties(t.leadLine.style,{height:Math.abs(t.sourcePoint.y-t.targetPoint.y)+"px",left:(t.targetPoint.x<t.sourcePoint.x?t.targetPoint.x:t.targetPoint.x-1)+"px",top:Math.min(t.targetPoint.y,t.sourcePoint.y)+"px"})):(BMCopyProperties(t.node.style,{left:t.sourcePoint.x+"px",top:Math.min(t.sourcePoint.y,t.targetPoint.y)+"px"}),BMCopyProperties(t.leadLine.style,{width:Math.abs(t.sourcePoint.x-t.targetPoint.x)+"px",top:(t.targetPoint.y<t.sourcePoint.y?t.targetPoint.y:t.targetPoint.y-1)+"px",left:Math.min(t.targetPoint.x,t.sourcePoint.x)+"px"}))},selectView(t,e){let i=e&&e.withEvent;return i&&(i.metaKey||i.ctrlKey)?this.toggleSelectionForView(t):this._useSettingsView&&this.selectedView===t?(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this._clearOffsets(),void this._drawConstraintsForView(t)):(this.tree.selectView(t),t._checkConstraints(),t._hasDeterministicConstraints?this.workspaceNode.classList.remove("BMLayoutEditorWorkspaceInvalidLayout"):this.workspaceNode.classList.add("BMLayoutEditorWorkspaceInvalidLayout"),this._useSettingsView||(this.detailsNodeTitle.innerText=t.debuggingName||t.node.id),this._view.node.querySelectorAll(".BMLayoutEditorViewSelectorSelected, .BMLayoutEditorViewSelectorConstrained").forEach((t=>{t.classList.remove("BMLayoutEditorViewSelectorSelected"),t.classList.remove("BMLayoutEditorViewSelectorConstrained")})),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this.selectedView=t,this.selectedConstraint=void 0,this.selectedViews=void 0,void(t&&(t._selector.classList.add("BMLayoutEditorViewSelectorSelected"),this._clearOffsets(),t.localConstraints.forEach((e=>{e.isConstraintCollection?e._views.forEach((e=>e!=t&&e._selector.classList.add("BMLayoutEditorViewSelectorConstrained"))):(e._sourceView!=t&&e._sourceView._selector.classList.add("BMLayoutEditorViewSelectorConstrained"),e._targetView&&e._targetView!=t&&e._targetView._selector.classList.add("BMLayoutEditorViewSelectorConstrained"))})),this._drawConstraintsForView(t),this._useSettingsView?this.detailsView.layoutEditorDidSelectView(t):(this.detailsNodeContent.innerHTML="",this.createSettingsForView(t)))))},toggleSelectionForView(t){if(this.selectedViews=this.selectedViews||[],this.selectedView&&this.selectedViews.push(this.selectedView),this.selectedView=void 0,this.selectedConstraint=void 0,this.workspaceNode.classList.remove("BMLayoutEditorWorkspaceInvalidLayout"),this._view.node.querySelectorAll(".BMLayoutEditorViewSelectorConstrained").forEach((t=>{t.classList.remove("BMLayoutEditorViewSelectorConstrained")})),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),1==this.selectedViews.length&&this.selectedViews[0]==t)return;let e;return-1==(e=this.selectedViews.indexOf(t))?(this.selectedViews.push(t),t._selector.classList.add("BMLayoutEditorViewSelectorSelected"),this.tree.selectView(t,{continuous:YES})):(this.selectedViews.splice(e,1),t._selector.classList.remove("BMLayoutEditorViewSelectorSelected"),this.tree.deselectView(t)),1==this.selectedViews.length?this.selectView(this.selectedViews[0]):this._useSettingsView?this.detailsView.layoutEditorDidSelectViews(this.selectedViews):void this.createSettingsForMultipleViews()},viewDidLayoutSubviews(){this.selectedConstraint&&requestAnimationFrame((t=>{this._clearOffsets(),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this._drawConstraint(this.selectedConstraint,{withReferenceView:this.selectedConstraintReferenceView})})),this.selectedView&&requestAnimationFrame((t=>{this._clearOffsets(),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),this.selectedView.localConstraints.forEach((t=>this._drawConstraint(t,{withReferenceView:this.selectedView})))}))},initDragEventListenerForNode(t,e){let i,o=e.view;t.addEventListener("contextmenu",(t=>t.preventDefault()));let n=e=>{if(2!=e.button&&!this.isCreatingTouchConstraints)return;"touchstart"==e.type&&(i=e.changedTouches[0].identifier),this.isCreatingConstraint=YES,this.constraintSource=o,this.constraintTarget=o,t.classList.add("BMLayoutEditorDragSource");var n=t=>t.preventDefault();window.addEventListener("contextmenu",n);let s=t=>{if("touchend"==t.type||"touchstart"==t.type){var e=NO;for(let o of t.changedTouches)if(o.identifier==i){e=YES;break}if(!e)return}window.removeEventListener("mouseup",s),window.removeEventListener("touchchancel",s),window.removeEventListener("touchend",s),requestAnimationFrame((t=>window.removeEventListener("contextmenu",n))),this.isCreatingConstraint=NO,this.content.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this.content.querySelectorAll(".BMLayoutEditorDragSource").forEach((t=>t.classList.remove("BMLayoutEditorDragSource"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragSource").forEach((t=>t.classList.remove("BMLayoutEditorDragSource")));let o="mouseup"==t.type?BMPointMake(t.clientX,t.clientY):BMPointMake(t.changedTouches[0].clientX,t.changedTouches[0].clientY);this.showConstraintOptionsFromView(this.constraintSource,{toView:this.constraintTarget,atPoint:o}),t.preventDefault()};if(window.addEventListener("mouseup",s),window.addEventListener("touchchancel",s),window.addEventListener("touchend",s),BMIsTouchDevice){let t=t=>{for(let e of t.changedTouches)if(e.identifier==i){this.content.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget")));let i=document.elementFromPoint(e.clientX,e.clientY),o=i.closest(".BMLayoutEditorViewSelector");o&&(i.classList.add("BMLayoutEditorDragTarget"),this.constraintTarget=BMView.viewForNode(o.parentNode)),t.preventDefault()}};window.addEventListener("touchmove",t)}e.preventDefault()};t.addEventListener("mousedown",n),t.addEventListener("touchstart",n),t.addEventListener("touchstart",(e=>{const i=e.changedTouches[0].identifier,n=e.changedTouches[0];let s=o.frame||BMRectMakeWithNodeFrame(o.node),a=!1,r=BMPointMake(n.pageX,n.pageY),l=NO,h=t=>{let e;for(let o=0;o<t.changedTouches.length;o++){const o=t.changedTouches;if(o.identifier==i){e=o;break}}if(!e)return;a=!0,l||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),l=YES);let n=BMPointMake(e.pageX-r.x,e.pageY-r.y);1!=this.scale&&n.multiplyWithScalar(1/this.scale);let h=s.copy();h.offsetWithX(n.x,{y:n.y}),o.frame=h,t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()},c=e=>{let n;for(let t=0;t<e.changedTouches.length;t++){const t=e.changedTouches;if(t.identifier==i){n=t;break}}n&&(t.removeEventListener("touchend",c,{capture:YES}),t.removeEventListener("touchcancel",c,{capture:YES}),t.removeEventListener("touchmove",h,{capture:YES}),a&&(e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.selectView(o)))};t.addEventListener("touchend",c,{capture:YES}),t.addEventListener("touchcancel",c,{capture:YES}),t.addEventListener("touchmove",h,{capture:YES})})),t.addEventListener("mousedown",(t=>{if(0!=t.button)return;let e=o.frame||BMRectMakeWithNodeFrame(o.node),i=!1,n=BMPointMake(t.pageX,t.pageY),s=NO,a=t=>{i=!0,s||(this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),s=YES);let a=BMPointMake(t.pageX-n.x,t.pageY-n.y);1!=this.scale&&a.multiplyWithScalar(1/this.scale);let r=e.copy();r.offsetWithX(a.x,{y:a.y}),o.frame=r,t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()},r=t=>{window.removeEventListener("mouseup",r,{capture:YES}),window.removeEventListener("mousemove",a,{capture:YES}),i&&(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),this.selectView(o))};window.addEventListener("mouseup",r,{capture:YES}),window.addEventListener("mousemove",a,{capture:YES})})),t.addEventListener("mouseenter",(e=>{this.isCreatingConstraint&&(this.content.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),this._treeWindow.node.querySelectorAll(".BMLayoutEditorDragTarget").forEach((t=>t.classList.remove("BMLayoutEditorDragTarget"))),t.classList.add("BMLayoutEditorDragTarget"),this.constraintTarget=o,e.preventDefault())}))},constraintOptionWithLabel(t,e){let i=document.createElement("div");return i.className="BMLayoutEditorConstraintPopupOption",i.innerText=t,i.addEventListener("click",e.action),i},addConstraint(t){t.isActive=YES,this.tree.addConstraint(t),this._activeSizeClass&&(t.isActive=NO,t.setIsActive(YES,{forSizeClass:this._activeSizeClass}));const e=this.selectConstraint(t,{withReferenceView:t._sourceView});this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(e.node).center,{forConstraint:t,withReferenceView:t._sourceView})},_createMenuWithOptions(t){let e=document.createElement("div");e.className="BMLayoutEditorConstraintPopup";let i=document.createElement("div");return i.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(e.style.backgroundColor="white"),i.appendChild(e),t.forEach((t=>e.appendChild(t))),document.body.appendChild(i),i.style.opacity="0",i},showMenuAtPoint(t,e){let i,o;e.menu?(o=e.menu,i=e.menu.children[0],BMHook(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0}),o.style.opacity="1"):(i=document.createElement("div"),i.className="BMLayoutEditorConstraintPopup",o=document.createElement("div"),o.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(i.style.backgroundColor="white"),o.appendChild(i),e.withOptions.forEach((t=>i.appendChild(t))),BMHook(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0}),document.body.appendChild(o));const n=i.offsetHeight,s=i.offsetWidth;let a="0%",r=" 0%";e.kind==BMMenuKind.PullDownMenu?a="50%":s+t.x>document.documentElement.clientWidth&&(a="100%",t.x-=s),n+t.y>document.documentElement.clientHeight&&(r=" 100%",t.y-=n),i.style.transformOrigin=a+r,i.style.left=t.x+"px",i.style.top=t.y+"px",i.addEventListener("click",(t=>t.preventDefault())),(window.Velocity||$.Velocity).animate(i,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>(i.style.pointerEvents="all",o.style.pointerEvents="all")});let l=0;for(let t of i.childNodes)BMHook(t,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(t,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:l}),l+=16;return o.addEventListener("click",(t=>{i.style.pointerEvents="none",o.style.pointerEvents="none";let n=16*i.childNodes.length+100-200;n=n<0?0:n,(window.Velocity||$.Velocity).animate(i,{scaleX:e.kind==BMMenuKind.PullDownMenu?1:.75,scaleY:.75,opacity:0,translateZ:0},{duration:200,easing:"easeInQuad",delay:n,complete:t=>o.remove()}),n=0;for(let t=i.childNodes.length-1;t>=0;t--){let e=i.childNodes[t];(window.Velocity||$.Velocity).animate(e,{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:n}),n+=16}this.node.focus()})),i},showConstraintOptionsFromView(t,e){let i=e.toView,o=document.createElement("div");o.className="BMLayoutEditorConstraintPopup",i&&i!==t?(this.horizontalConstraintOptionsFromView(t,{toView:i}).forEach((t=>o.appendChild(t))),o.appendChild(this.settingsDivider()),this.verticalConstraintOptionsFromView(t,{toView:i}).forEach((t=>o.appendChild(t))),o.appendChild(this.settingsDivider()),o.appendChild(this.constraintOptionWithLabel("Equal Width",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,toView:i,secondAttribute:BMLayoutAttribute.Width}))}})),o.appendChild(this.constraintOptionWithLabel("Equal Height",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Height,toView:i,secondAttribute:BMLayoutAttribute.Height}))}}))):(o.appendChild(this.constraintOptionWithLabel("Width",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Width,constant:t.node.offsetWidth}))}})),o.appendChild(this.constraintOptionWithLabel("Height",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Height,constant:t.node.offsetHeight}))}})));let n=document.createElement("div");n.className="BMLayoutEditorConstraintPopupContainer","backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(o.style.backgroundColor="white"),n.appendChild(o),BMHook(o,{scaleX:.75,scaleY:.75,opacity:0}),document.body.appendChild(n);const s=o.offsetHeight,a=o.offsetWidth;let r="0%",l=" 0%";a+e.atPoint.x>document.documentElement.clientWidth&&(r="100%",e.atPoint.x-=a),s+e.atPoint.y>document.documentElement.clientHeight&&(l=" 100%",e.atPoint.y-=s),o.style.transformOrigin=r+l,o.style.left=e.atPoint.x+"px",o.style.top=e.atPoint.y+"px",o.addEventListener("click",(t=>t.preventDefault())),(window.Velocity||$.Velocity).animate(o,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>(o.style.pointerEvents="all",n.style.pointerEvents="all")});let h=0;for(let t of o.childNodes)BMHook(t,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(t,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:h}),h+=16;n.addEventListener("click",(t=>{o.style.pointerEvents="none",n.style.pointerEvents="none";let e=16*o.childNodes.length+100-200;e=e<0?0:e,(window.Velocity||$.Velocity).animate(o,{scaleX:.75,scaleY:.75,opacity:0,translateZ:0},{duration:200,easing:"easeInQuad",delay:e,complete:t=>n.remove()}),e=0;for(let t=o.childNodes.length-1;t>=0;t--){let i=o.childNodes[t];(window.Velocity||$.Velocity).animate(i,{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:e}),e+=16}}))},horizontalConstraintOptionsFromView(t,e){var i=e.toView;return[this.constraintOptionWithLabel("Align Leading",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Leading,constant:BMRectMakeWithNodeFrame(t.node).left-BMRectMakeWithNodeFrame(i.node).left}))}}),this.constraintOptionWithLabel("Align Horizontal Center",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.CenterX,toView:i,secondAttribute:BMLayoutAttribute.CenterX,constant:BMRectMakeWithNodeFrame(t.node).center.x-BMRectMakeWithNodeFrame(i.node).center.x}))}}),this.constraintOptionWithLabel("Align Trailing",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Trailing,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:BMRectMakeWithNodeFrame(t.node).right-BMRectMakeWithNodeFrame(i.node).right}))}}),this.constraintOptionWithLabel("Horizontal Spacing",{action:e=>{let o=BMRectMakeWithNodeFrame(t.node),n=BMRectMakeWithNodeFrame(i.node);o.origin.x>=n.right?this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:-BMRectMakeWithNodeFrame(t.node).right+BMRectMakeWithNodeFrame(i.node).origin.x})):this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Trailing,toView:i,secondAttribute:BMLayoutAttribute.Leading,constant:BMRectMakeWithNodeFrame(t.node).origin.x-BMRectMakeWithNodeFrame(i.node).right}))}})]},verticalConstraintOptionsFromView(t,e){var i=e.toView;return[this.constraintOptionWithLabel("Align Top",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Top,constant:BMRectMakeWithNodeFrame(t.node).top-BMRectMakeWithNodeFrame(i.node).top}))}}),this.constraintOptionWithLabel("Align Vertical Center",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.CenterY,toView:i,secondAttribute:BMLayoutAttribute.CenterY,constant:BMRectMakeWithNodeFrame(t.node).center.y-BMRectMakeWithNodeFrame(i.node).center.y}))}}),this.constraintOptionWithLabel("Align Bottom",{action:e=>{this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Bottom,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:BMRectMakeWithNodeFrame(t.node).bottom-BMRectMakeWithNodeFrame(i.node).bottom}))}}),this.constraintOptionWithLabel("Vertical Spacing",{action:e=>{let o=BMRectMakeWithNodeFrame(t.node),n=BMRectMakeWithNodeFrame(i.node);o.origin.y>=n.bottom?this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:-BMRectMakeWithNodeFrame(t.node).bottom+BMRectMakeWithNodeFrame(i.node).origin.y})):this.addConstraint(BMLayoutConstraint.constraintWithView(t,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:BMRectMakeWithNodeFrame(t.node).origin.y-BMRectMakeWithNodeFrame(i.node).bottom}))}})]},selectConstraint(t,e){if((this.selectedConstraint!=t||this.selectedConstraintReferenceView!=e.withReferenceView)&&(this.selectedView=void 0,this.selectedViews=void 0,this.selectedConstraint=t,this.selectedConstraintReferenceView=e.withReferenceView,this.tree.selectConstraint(t),this.workspaceNode.classList.remove("BMLayoutEditorWorkspaceInvalidLayout"),this._useSettingsView||(this.detailsNodeTitle.innerText="Constraint"),this._view.node.querySelectorAll(".BMLayoutEditorViewSelectorSelected, .BMLayoutEditorViewSelectorConstrained").forEach((t=>{t.classList.remove("BMLayoutEditorViewSelectorSelected"),t.classList.remove("BMLayoutEditorViewSelectorConstrained")})),this._view.node.querySelectorAll(".BMLayoutEditorConstraint, .BMLayoutEditorLeadLine").forEach((t=>t.remove())),t)){this._clearOffsets();const i=this._drawConstraint(t,{withReferenceView:e.withReferenceView});return t.isConstraintCollection?t._views.forEach((t=>t._selector.classList.add("BMLayoutEditorViewSelectorConstrained"))):(t._sourceView&&t._sourceView._selector.classList.add("BMLayoutEditorViewSelectorConstrained"),t._targetView&&t._targetView._selector.classList.add("BMLayoutEditorViewSelectorConstrained")),this._useSettingsView?this.detailsView.layoutEditorDidSelectConstraint(t,{withReferenceView:e.withReferenceView}):(this.detailsNodeContent.innerHTML="",this.createSettingsForConstraint(t,{withReferenceView:e.withReferenceView})),i}},_constraintAffectingAttributeInList(t,{forView:e}){const i=e.localConstraints,o={};for(const e of t)o[e]=[];for(const n of i){if(!n._configuration.isActive)continue;let i=n.affectedAttributesForView(e).filter((e=>t.includes(e)));if(i.length)for(const t of i)o[t].push(n)}for(const t in o)if(o[t].length)return o[t][0]},backspacePressedWithEvent(t){if("INPUT"!=t.target.tagName&&(t.preventDefault(),this.selectedConstraint))if(this._activeSizeClass){const t=this.selectedConstraint._variations[this._activeSizeClass].isActive;void 0===t?this.selectedConstraint.setIsActive(NO,{forSizeClass:this._activeSizeClass}):t===NO?this.selectedConstraint.setIsActive(YES,{forSizeClass:this._activeSizeClass}):this.selectedConstraint.removeIsActiveVariationForSizeClass(this._activeSizeClass)}else this.selectedConstraint.isActive=!this.selectedConstraint.isActive},commandBackspacePressedWithEvent(t){"INPUT"!=t.target.tagName&&(t.preventDefault(),this.selectedConstraint&&(this.selectedConstraint.remove(),this.selectView(this.selectedConstraintReferenceView)))},setConstraintToEqualWithEvent(t){this.selectedConstraint&&(this.selectedConstraint._relation=BMLayoutConstraintRelation.Equals)},setConstraintToLessThanWithEvent(t){this.selectedConstraint&&(this.selectedConstraint._relation=BMLayoutConstraintRelation.LessThanOrEquals)},setConstraintToGreaterThanWithEvent(t){this.selectedConstraint&&(this.selectedConstraint._relation=BMLayoutConstraintRelation.GreaterThanOrEquals)},selectLeftConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if(e==this._view)return;if("INPUT"==t.target.tagName)return;t.preventDefault();let i,o,n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Leading,BMLayoutAttribute.Left,BMLayoutAttribute.CenterX],{forView:e});if(n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}if(this._constraintAffectingAttributeInList([BMLayoutAttribute.Trailing,BMLayoutAttribute.Right],{forView:e})&&(n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Width],{forView:e})),n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.top>e.frame.bottom||t.frame.bottom<e.frame.top)){const o=e.frame.origin.x-t.frame.right;o>=0&&(i?o<e.frame.origin.x-i.frame.right&&(i=t):i=t)}if(Math.abs(e.frame.origin.x-t.frame.origin.x)<16)if(o){Math.min(Math.abs(e.frame.origin.y-t.frame.bottom),Math.abs(e.frame.bottom-t.frame.origin.y))<Math.min(Math.abs(e.frame.origin.y-o.frame.bottom),Math.abs(e.frame.bottom-o.frame.origin.y))&&(o=t)}else o=t}if(i){const t=e.frame.origin.x-i.frame.right;if(t<=64&&i.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:t}))}const s=e.frame.origin.x-e.superview.frame.origin.x,a=i?e.frame.origin.x-i.frame.right:Number.MAX_SAFE_INTEGER,r=o?Math.min(Math.abs(e.frame.origin.y-o.frame.bottom),Math.abs(e.frame.bottom-o.frame.origin.y)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:i,secondAttribute:BMLayoutAttribute.Trailing,constant:a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:o,secondAttribute:BMLayoutAttribute.Leading,constant:e.frame.origin.x-o.frame.origin.x})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Leading,toView:e.superview,secondAttribute:BMLayoutAttribute.Leading,constant:s}))},selectTopConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if("INPUT"==t.target.tagName)return;t.preventDefault();let i,o,n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Top,BMLayoutAttribute.CenterY],{forView:e});if(n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}if(this._constraintAffectingAttributeInList([BMLayoutAttribute.Bottom],{forView:e})&&(n=this._constraintAffectingAttributeInList([BMLayoutAttribute.Height],{forView:e})),n){const t=this.selectConstraint(n,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:n,withReferenceView:n._sourceView}))}for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.left>e.frame.right||t.frame.right<e.frame.left)){const o=e.frame.origin.y-t.frame.bottom;o>=0&&(i?o<e.frame.origin.y-i.frame.bottom&&(i=t):i=t)}if(Math.abs(e.frame.origin.y-t.frame.origin.y)<16)if(o){Math.min(Math.abs(e.frame.origin.x-t.frame.right),Math.abs(e.frame.right-t.frame.origin.x))<Math.min(Math.abs(e.frame.origin.x-o.frame.right),Math.abs(e.frame.right-o.frame.origin.x))&&(o=t)}else o=t}if(i){const t=e.frame.origin.y-i.frame.bottom;if(t<=64&&i.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:t}))}const s=e.frame.origin.y-e.superview.frame.origin.y,a=i?e.frame.origin.y-i.frame.bottom:Number.MAX_SAFE_INTEGER,r=o?Math.min(Math.abs(e.frame.origin.x-o.frame.right),Math.abs(e.frame.right-o.frame.origin.x)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:i,secondAttribute:BMLayoutAttribute.Bottom,constant:a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:o,secondAttribute:BMLayoutAttribute.Top,constant:e.frame.origin.y-o.frame.origin.y})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Top,toView:e.superview,secondAttribute:BMLayoutAttribute.Top,constant:s}))},selectRightConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if("INPUT"==t.target.tagName)return;t.preventDefault();const i=this._constraintAffectingAttributeInList([BMLayoutAttribute.Trailing,BMLayoutAttribute.Right,BMLayoutAttribute.Width,BMLayoutAttribute.CenterX],{forView:e});if(i){const t=this.selectConstraint(i,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:i,withReferenceView:i._sourceView}))}let o,n;for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.top>e.frame.bottom||t.frame.bottom<e.frame.top)){const i=t.frame.origin.x-e.frame.right;i>=0&&(o?i<n.frame.origin.x-e.frame.right&&(o=t):o=t)}if(Math.abs(e.frame.right-t.frame.right)<16)if(n){Math.min(Math.abs(e.frame.origin.y-t.frame.bottom),Math.abs(e.frame.bottom-t.frame.origin.y))<Math.min(Math.abs(e.frame.origin.y-n.frame.bottom),Math.abs(e.frame.bottom-n.frame.origin.y))&&(n=t)}else n=t}if(o){const t=o.frame.origin.x-e.frame.right;if(t<=64&&o.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:o,secondAttribute:BMLayoutAttribute.Trailing,constant:-t}))}const s=e.superview.frame.right-e.frame.right,a=o?o.frame.origin.x-e.frame.right:Number.MAX_SAFE_INTEGER,r=n?Math.min(Math.abs(e.frame.origin.y-n.frame.bottom),Math.abs(e.frame.bottom-n.frame.origin.y)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:o,secondAttribute:BMLayoutAttribute.Leading,constant:-a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:n,secondAttribute:BMLayoutAttribute.Trailing,constant:e.frame.right-n.frame.right})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Trailing,toView:e.superview,secondAttribute:BMLayoutAttribute.Trailing,constant:-s}))},selectBottomConstraintWithEvent(t){const e=this.selectedView||this.selectedConstraintReferenceView;if(!e)return;if("INPUT"==t.target.tagName)return;t.preventDefault();const i=this._constraintAffectingAttributeInList([BMLayoutAttribute.Bottom,BMLayoutAttribute.Height,BMLayoutAttribute.CenterY],{forView:e});if(i){const t=this.selectConstraint(i,{withReferenceView:e});return void(this._detailsToolWindow._visible||this._showConstantPopupAtPoint(BMRectMakeWithNodeFrame(t&&t.node||e.node).center,{forConstraint:i,withReferenceView:i._sourceView}))}let o,n;for(const t of this._view.allSubviews)if(t!=e&&!e.isDescendantOfView(t)){if(!(t.frame.left>e.frame.right||t.frame.right<e.frame.left)){const i=t.frame.origin.y-e.frame.bottom;i>=0&&(o?i<o.frame.origin.y-e.frame.bottom&&(o=t):o=t)}if(Math.abs(e.frame.bottom-t.frame.bottom)<16)if(n){Math.min(Math.abs(e.frame.origin.x-t.frame.right),Math.abs(e.frame.right-t.frame.origin.x))<Math.min(Math.abs(e.frame.origin.x-n.frame.right),Math.abs(e.frame.right-n.frame.origin.x))&&(n=t)}else n=t}if(o){const t=o.frame.origin.y-e.frame.bottom;if(t<=64&&o.superview==e.superview)return this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:o,secondAttribute:BMLayoutAttribute.Top,constant:-t}))}const s=e.superview.frame.bottom-e.frame.bottom,a=o?o.frame.origin.y-e.frame.bottom:Number.MAX_SAFE_INTEGER,r=n?Math.min(Math.abs(e.frame.origin.x-n.frame.right),Math.abs(e.frame.right-n.frame.origin.x)):Number.MAX_SAFE_INTEGER;return a<s&&a<r?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:o,secondAttribute:BMLayoutAttribute.Top,constant:-a})):r<a&&r<s?this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:n,secondAttribute:BMLayoutAttribute.Bottom,constant:n.frame.bottom-e.frame.bottom})):this.addConstraint(BMLayoutConstraint.constraintWithView(e,{attribute:BMLayoutAttribute.Bottom,toView:e.superview,secondAttribute:BMLayoutAttribute.Bottom,constant:-s}))},_clearOffsets(){this._leftOffset=-1,this._rightOffset=-1,this._centerXOffset=-1,this._widthOffset=-1,this._heightOffset=-1,this._topOffset=-1,this._bottomOffset=-1,this._centerYOffset=-1},_drawConstraint(t,e){let i=e.sourceConstraint;if(t.isConstraintCollection)return t.constituentConstraints.map((e=>this._drawConstraint(e,{withReferenceView:e._sourceView,sourceConstraint:t})));if(!t._targetView)return;if(!t._configuration.isActive)return;var o;let n=BMRectMakeWithNodeFrame(this._view.node);1!=this.scale&&(n=n.rectByMultiplyingWithScalar(1/this.scale));let s,a,r,l=e.withReferenceView;if(t._sourceView==l?(s=t._targetView,a="_sourceViewAttribute",r="_targetViewAttribute"):(s=t._sourceView,a="_targetViewAttribute",r="_sourceViewAttribute"),t._kind==BMLayoutConstraintKind.Horizontal){let e=BMRectMakeWithNodeFrame(l.node),h=BMRectMakeWithNodeFrame(s.node);1!=this.scale&&(e=e.rectByMultiplyingWithScalar(1/this.scale),h=h.rectByMultiplyingWithScalar(1/this.scale));let c=BMPointMake(0,0),d=BMPointMake(0,h.center.y-n.origin.y);switch(t[a]){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:c.x=e.origin.x-n.origin.x,o=++this._leftOffset;break;case BMLayoutAttribute.CenterX:c.x=e.center.x-n.origin.x,o=++this._centerXOffset;break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:c.x=e.right-n.origin.x,o=++this._rightOffset;break;case BMLayoutAttribute.Width:o=++this._widthOffset,c.y=e.bottom-12-8*o-n.origin.y,d.y=c.y,c.x=e.origin.x-n.origin.x,d.x=e.right-n.origin.x,this._drawHorizontalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}const u=Math.max(e.origin.y,h.origin.y);switch(c.y=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.bottom,h.bottom)-u)/2|0,e.origin.y+2,e.bottom-2)-n.origin.y,t[r]){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:d.x=h.origin.x-n.origin.x;break;case BMLayoutAttribute.CenterX:d.x=h.center.x-n.origin.x;break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:d.x=h.right-n.origin.x;break;case BMLayoutAttribute.Width:return c.y=h.bottom-12-8*o-n.origin.y,d.y=c.y,c.x=h.origin.x-n.origin.x,d.x=h.right-n.origin.x,void this._drawHorizontalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}return d.y=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.bottom,h.bottom)-u)/2|0,h.origin.y+2,h.bottom-2)-n.origin.y,this._drawHorizontalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}{let e=BMRectMakeWithNodeFrame(l.node),h=BMRectMakeWithNodeFrame(s.node);1!=this.scale&&(e=e.rectByMultiplyingWithScalar(1/this.scale),h=h.rectByMultiplyingWithScalar(1/this.scale));let c=BMPointMake(0,0),d=BMPointMake(h.center.x-n.origin.x,0);switch(t[a]){case BMLayoutAttribute.Top:c.y=e.origin.y-n.origin.y,o=++this._topOffset;break;case BMLayoutAttribute.CenterY:c.y=e.center.y-n.origin.y,o=++this._centerYOffset;break;case BMLayoutAttribute.Bottom:c.y=e.bottom-n.origin.y,o=++this._bottomOffset;break;case BMLayoutAttribute.Height:o=++this._heightOffset,c.x=e.right-12-8*o-n.origin.x,d.x=c.x,c.y=e.origin.y-n.origin.y,d.y=e.bottom-n.origin.y,this._drawVerticalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}const u=Math.max(e.origin.x,h.origin.x);switch(c.x=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.right,h.right)-u)/2|0,e.origin.x+2,e.right-2)-n.origin.x,t[r]){case BMLayoutAttribute.Top:d.y=h.origin.y-n.origin.y;break;case BMLayoutAttribute.CenterY:d.y=h.center.y-n.origin.y;break;case BMLayoutAttribute.Bottom:d.y=h.bottom-n.origin.y;break;case BMLayoutAttribute.Height:return c.x=h.right-12-8*o-n.origin.x,d.x=c.x,c.y=h.origin.y-n.origin.y,d.y=h.bottom-n.origin.y,void this._drawVerticalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}return d.x=BMNumberByConstrainingNumberToBounds(u+(Math.min(e.right,h.right)-u)/2|0,h.origin.x+2,h.right-2)-n.origin.x,this._drawVerticalConstraint(t,{fromSourcePoint:c,toPoint:d,withReferenceView:l,sourceConstraint:i})}},_drawHorizontalConstraint(t,e){let i=e.sourceConstraint,o=e.fromSourcePoint,n=e.toPoint,s=Math.abs(o.x-n.x),a=Math.min(o.x,n.x),r=document.createElement("div");r.className="BMLayoutEditorConstraint BMLayoutEditorHorizontalConstraint",BMCopyProperties(r.style,{width:s+"px",height:"5px",left:a+"px",top:o.y+"px"}),t._relation==BMLayoutConstraintRelation.GreaterThanOrEquals?r.classList.add("BMLayoutEditorConstraintGreater"):t._relation==BMLayoutConstraintRelation.LessThanOrEquals&&r.classList.add("BMLayoutEditorConstraintLess");let l=document.createElement("div");l.className="BMLayoutEditorHorizontalConstraintLine",r.appendChild(l),t._priority<BMLayoutConstraintPriorityRequired&&l.classList.add("BMLayoutEditorConstraintLineOptional");let h=document.createElement("div");return h.className="BMLayoutEditorLeadLine BMLayoutEditorVerticalLeadLine",BMCopyProperties(h.style,{width:"1px",height:Math.abs(o.y-n.y)+"px",left:(n.x<o.x?n.x:n.x-1)+"px",top:Math.min(n.y,o.y)+"px"}),this._view.node.appendChild(h),this._view.node.appendChild(r),r.addEventListener("click",(o=>{this.selectConstraint(i||t,{withReferenceView:e.withReferenceView}),this._useSettingsView&&!this._detailsToolWindow._visible&&this._showConstantPopupAtPoint(BMPointMake(o.clientX,o.clientY),{forConstraint:i||t,withReferenceView:e.withReferenceView}),o.stopPropagation()})),{sourcePoint:o,targetPoint:n,kind:BMLayoutConstraintKind.Horizontal,node:r,leadLine:h,displaced:NO}},_drawVerticalConstraint(t,e){let i=e.sourceConstraint,o=e.fromSourcePoint,n=e.toPoint,s=Math.abs(o.y-n.y),a=Math.min(o.y,n.y),r=document.createElement("div");r.className="BMLayoutEditorConstraint BMLayoutEditorVerticalConstraint",BMCopyProperties(r.style,{width:"5px",height:s+"px",left:o.x+"px",top:a+"px"}),t._relation==BMLayoutConstraintRelation.GreaterThanOrEquals?r.classList.add("BMLayoutEditorConstraintGreater"):t._relation==BMLayoutConstraintRelation.LessThanOrEquals&&r.classList.add("BMLayoutEditorConstraintLess");let l=document.createElement("div");l.className="BMLayoutEditorVerticalConstraintLine",r.appendChild(l),t._priority<BMLayoutConstraintPriorityRequired&&l.classList.add("BMLayoutEditorConstraintLineOptional");let h=document.createElement("div");return h.className="BMLayoutEditorLeadLine BMLayoutEditorHorizontalLeadLine",BMCopyProperties(h.style,{width:Math.abs(o.x-n.x)+"px",height:"1px",top:(n.y<o.y?n.y:n.y-1)+"px",left:Math.min(n.x,o.x)+"px"}),this._view.node.appendChild(h),this._view.node.appendChild(r),r.addEventListener("click",(o=>{this.selectConstraint(i||t,{withReferenceView:e.withReferenceView}),this._useSettingsView&&!this._detailsToolWindow._visible&&this._showConstantPopupAtPoint(BMPointMake(o.clientX,o.clientY),{forConstraint:i||t,withReferenceView:e.withReferenceView}),o.stopPropagation()})),{sourcePoint:o,targetPoint:n,kind:BMLayoutConstraintKind.Vertical,node:r,leadLine:h,displaced:NO}},setValue(t,{forSetting:e}){const i=void 0===t;e.sizeClass?t?e.target[`set${BMStringByCapitalizingString(e.property)}`](t,{forSizeClass:e.sizeClass}):e.target[`remove${BMStringByCapitalizingString(e.property)}VariationForSizeClass`](e.sizeClass):e.target[e.property]=i?e.defaultValue:t},settingsBadgeForSizeClass(t){let e=document.createElement("div");switch(t){case BMLayoutSizeClass.phoneSizeClass():e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Portrait):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhonePortraitMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Landscape):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneLandscapeMini";break;case BMLayoutSizeClass.tabletSizeClass():e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Portrait):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletPortraitMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Landscape):e.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletLandscapeMini";break;default:e.className="BMLayoutEditorDetailsItemBadge",e.innerText=t._hashString}return e},readonlySettingWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorDetailsItem";let o,n=document.createElement("div");return n.className="BMLayoutEditorDetailsItemTitle",n.innerText=t,i.appendChild(n),e.value?(o=document.createElement("div"),o.className="BMLayoutEditorDetailsItemReadonlyValue",o.innerText=e.value,i.appendChild(o)):n.style.width="240px",e.action&&(o.classList.add("BMLayoutEditorDetailsItemReadonlyValueClickable"),o.addEventListener("click",e.action)),i},createVariableBooleanSettingWithName(t,{forConstraint:e,withReferenceView:i,propertyName:o,container:n}){let s=n||this.detailsNodeContent,a=o[0].toUpperCase()+o.substring(1);if(e){this.booleanSettingWithName(t,{value:e[o],indeterminate:NO,container:s,changeHandler:t=>e[o]=t});for(let i in e._variations)this._activeSizeClass&&i==this._activeSizeClass._hashString||o in e._variations[i]&&this.booleanSettingWithName(t,{value:e._variations[i][o],indeterminate:YES,container:s,sizeClass:e._variations[i].sizeClass,changeHandler:(t,i)=>{void 0!==t?e["set"+a](t,{forSizeClass:i}):e["remove"+a+"VariationForSizeClass"](i)}});if(this._activeSizeClass){let i;e._variations[this._activeSizeClass._hashString]&&o in e._variations[this._activeSizeClass._hashString]&&(i=e._variations[this._activeSizeClass._hashString][o]),this.booleanSettingWithName(t,{value:i,indeterminate:YES,container:s,sizeClass:this._activeSizeClass,changeHandler:(t,i)=>{void 0!==t?e["set"+a](t,{forSizeClass:i}):e["remove"+a+"VariationForSizeClass"](i)}})}}else{this.booleanSettingWithName(t,{value:i[o],indeterminate:NO,container:s,changeHandler:t=>i[o]=t});for(let e in i._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||o in i._variations[e]&&this.booleanSettingWithName(t,{value:i._variations[e][o],indeterminate:YES,container:s,sizeClass:i._variations[e].sizeClass,changeHandler:(t,e)=>{void 0!==t?i["set"+a](t,{forSizeClass:e}):i["remove"+a+"VariationForSizeClass"](e)}});if(this._activeSizeClass){let e;i._variations[this._activeSizeClass._hashString]&&o in i._variations[this._activeSizeClass._hashString]&&(e=i._variations[this._activeSizeClass._hashString][o]),this.booleanSettingWithName(t,{value:e,indeterminate:YES,container:s,sizeClass:this._activeSizeClass,changeHandler:(t,e)=>{void 0!==t?i["set"+a](t,{forSizeClass:e}):i["remove"+a+"VariationForSizeClass"](e)}})}}},booleanSettingWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorDetailsItem";let o=document.createElement("div");if(o.className="BMLayoutEditorDetailsItemTitle",o.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);o.insertBefore(t,o.lastChild)}i.appendChild(o);let n=document.createElement("label");n.className="BMWindowSwitch",n.innerHTML='<input type="checkbox" data-toggle="YES"> OFF\n <div class="BMWindowSwitchGutter">\n <div class="BMWindowSwitchKnob"></div>\n </div>\n ON',i.appendChild(n);let s=n.getElementsByTagName("input")[0];return s.checked=e.value,e.indeterminate&&(n.addEventListener("click",(t=>{t.target!==s&&s.checked&&(t.preventDefault(),t.stopPropagation(),s.indeterminate?(s.indeterminate=!1,s.checked=!1,e.changeHandler(!1,e.sizeClass)):(s.indeterminate=!0,e.changeHandler(void 0,e.sizeClass)))})),void 0===e.value&&(s.indeterminate=!0,s.checked=!0)),s.addEventListener("change",(t=>{let i=Boolean(t.target.checked);e.indeterminate&&s.indeterminate&&(i=void 0),e.changeHandler(i,e.sizeClass)})),e.container&&e.container.appendChild(i),i},textSettingWithName(t,e){let i=document.createElement("div");i.className="BMLayoutEditorDetailsItem";let o=document.createElement("div");if(o.className="BMLayoutEditorDetailsItemTitle",o.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);o.insertBefore(t,o.lastChild)}i.appendChild(o);let n=document.createElement("input");n.type="text",n.className="BMWindowInput BMLayoutEditorDetailsItemTextValue",n.value=e.value,i.appendChild(n);let s=!0;return n.addEventListener("input",(t=>{let i=n.value,o=e.changeHandler(i);o!=s&&(s=o,o?n.classList.remove("BMWindowInputInvalid"):n.classList.add("BMWindowInputInvalid"))})),i},stringSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=e.withReferenceView,s=o[0].toUpperCase()+o.substring(1),a=document.createElement("div");a.className="BMLayoutEditorDetailsItem";let r=document.createElement("div");if(r.className="BMLayoutEditorDetailsItemTitle",r.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);r.insertBefore(t,r.lastChild)}a.appendChild(r);let l=document.createElement("input");return l.type="text",l.className="BMWindowInput BMLayoutEditorDetailsItemTextValue",l.value=e.value,a.appendChild(l),l.addEventListener("input",(t=>{let a=l.value;a?i?(e.sizeClass?i[`set${s}`](a,{forSizeClass:e.sizeClass}):i[o]=a,i._updateConfiguration(),i._constraint=void 0,i._constituentConstraints=void 0,i._sourceView?i._sourceView.needsLayout=YES:i._views[0].needsLayout=YES):(e.sizeClass?n[`set${s}`](a,{forSizeClass:e.sizeClass}):n[o]=a,n.needsLayout=YES):e.sizeClass&&(i?(i[`remove${s}VariationForSizeClass`](e.sizeClass),i._updateConfiguration()):(n[`remove${s}VariationForSizeClass`](e.sizeClass),n._updateConfiguration()))})),a},createVariableStringSettingWithName(t,{forConstraint:e,withReferenceView:i,propertyName:o,container:n}){let s=n||this.detailsNodeContent;if(e){s.appendChild(this.stringSettingWithName(t,{value:e[o],forConstraint:e,propertyName:o,withReferenceView:i}));for(let n in e._variations)this._activeSizeClass&&n==this._activeSizeClass._hashString||o in e._variations[n]&&s.appendChild(this.stringSettingWithName(t,{value:e._variations[n][o],forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:e._variations[n].sizeClass}));if(this._activeSizeClass){let n="";e._variations[this._activeSizeClass._hashString]&&o in e._variations[this._activeSizeClass._hashString]&&(n=e._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.stringSettingWithName(t,{value:n,forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}else{s.appendChild(this.stringSettingWithName(t,{value:i[o],propertyName:o,withReferenceView:i}));for(let e in i._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||o in i._variations[e]&&s.appendChild(this.stringSettingWithName(t,{value:i._variations[e][o],propertyName:o,withReferenceView:i,sizeClass:i._variations[e].sizeClass}));if(this._activeSizeClass){let e="";i._variations[this._activeSizeClass._hashString]&&o in i._variations[this._activeSizeClass._hashString]&&(e=i._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.stringSettingWithName(t,{value:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}},createVariableNumericSettingWithName(t,{forConstraint:e,withReferenceView:i,propertyName:o,container:n}){let s=n||this.detailsNodeContent;if(e){s.appendChild(this.numericSettingWithName(t,{value:e[o],forConstraint:e,propertyName:o,withReferenceView:i}));for(let n in e._variations)this._activeSizeClass&&n==this._activeSizeClass._hashString||o in e._variations[n]&&s.appendChild(this.numericSettingWithName(t,{value:e._variations[n][o],forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:e._variations[n].sizeClass}));if(this._activeSizeClass){let n="";e._variations[this._activeSizeClass._hashString]&&o in e._variations[this._activeSizeClass._hashString]&&(n=e._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.numericSettingWithName(t,{value:n,forConstraint:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}else{s.appendChild(this.numericSettingWithName(t,{value:i[o],propertyName:o,withReferenceView:i}));for(let e in i._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||o in i._variations[e]&&s.appendChild(this.numericSettingWithName(t,{value:i._variations[e][o],propertyName:o,withReferenceView:i,sizeClass:i._variations[e].sizeClass}));if(this._activeSizeClass){let e="";i._variations[this._activeSizeClass._hashString]&&o in i._variations[this._activeSizeClass._hashString]&&(e=i._variations[this._activeSizeClass._hashString][o]),s.appendChild(this.numericSettingWithName(t,{value:e,propertyName:o,withReferenceView:i,sizeClass:this._activeSizeClass}))}}},constantSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=e.withReferenceView,s=o[0].toUpperCase()+o.substring(1),a=document.createElement("div");a.className="BMLayoutEditorDetailsItem";let r=document.createElement("div");if(r.className="BMLayoutEditorDetailsItemTitle",r.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);r.insertBefore(t,r.lastChild)}a.appendChild(r);let l=document.createElement("input");l.type="text",l.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",l.value=e.value,a.appendChild(l);let h,c,d=[],u=[];return l.addEventListener("focus",(async t=>{l.select(),d=[];const e=Object.keys(this.layoutVariableProvider.layoutVariables),i=new Set;e.forEach((t=>i.add(t)));let o=[];for(const t of i)d.unshift(t),d.push("-"+t);u=d,c=-1;for(const t of d)o.push(this.constraintOptionWithLabel(t,{action:()=>{h=void 0,l.value=t,l.dispatchEvent(new Event("input")),l.blur()}}));if(d.length){let t=BMRectMakeWithNodeFrame(l),e=BMPointMake(t.origin.x,t.bottom);h=this.showMenuAtPoint(e,{withOptions:o,kind:BMMenuKind.PullDownMenu}),h.classList.add("BMLayoutEditorConstantSuggestions"),h.parentNode.classList.add("BMLayoutEditorConstantSuggestionsOverlay"),h.addEventListener("mousedown",(t=>t.preventDefault()),YES)}const n=t=>t.preventDefault();l.addEventListener("mouseup",n),await new Promise((t=>setTimeout(t,200))),l.removeEventListener("mouseup",n)})),l.addEventListener("keydown",(t=>{if("ArrowDown"==t.code||"ArrowUp"==t.code){if(t.preventDefault(),0==u.length)return;c="ArrowUp"==t.code?Math.max((c||0)-1,0):Math.min((isNaN(c)?-1:c)+1,u.length-1);for(const t of h.querySelectorAll(".BMLayoutEditorConstraintPopupOptionHighlighted"))t.classList.remove("BMLayoutEditorConstraintPopupOptionHighlighted");h.childNodes[c].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted")}"Enter"==t.code&&(!isNaN(c)&&u.length&&(l.value=u[c],l.dispatchEvent(new Event("input"))),l.blur())})),l.addEventListener("input",(t=>{const a=parseFloat(l.value),r=isNaN(a)?l.value:a;if(h){u=d.filter((t=>t.toLowerCase().startsWith(l.value.toLowerCase()))),h.innerHTML="",c=0;for(const t of u)h.appendChild(this.constraintOptionWithLabel(t,{action:()=>{h=void 0,l.value=t,l.dispatchEvent(new Event("input"))}}));u.length?(h.childNodes[0].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted"),h.style.display="block"):h.style.display="none"}l.value?i?(e.sizeClass?i[`set${s}`](r,{forSizeClass:e.sizeClass}):i[o]=r,i._updateConfiguration(),i._constraint=void 0,i._constituentConstraints=void 0,i._sourceView?i._sourceView.needsLayout=YES:i._views[0].needsLayout=YES):(e.sizeClass?n[`set${s}`](a,{forSizeClass:e.sizeClass}):n[o]=a,n.needsLayout=YES):e.sizeClass&&(i?(i[`remove${s}VariationForSizeClass`](e.sizeClass),i._updateConfiguration()):(n[`remove${s}VariationForSizeClass`](e.sizeClass),n._updateConfiguration()))})),l.addEventListener("blur",(t=>{h&&h.parentNode.dispatchEvent(new Event("click"))})),a},numericSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=e.withReferenceView,s=o[0].toUpperCase()+o.substring(1),a=document.createElement("div");a.className="BMLayoutEditorDetailsItem";let r=document.createElement("div");if(r.className="BMLayoutEditorDetailsItemTitle",r.innerText=t,e.sizeClass){let t=this.settingsBadgeForSizeClass(e.sizeClass);r.insertBefore(t,r.lastChild)}a.appendChild(r);let l=document.createElement("input");return l.type="number",l.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",l.value=e.value,a.appendChild(l),l.addEventListener("input",(t=>{let a=parseFloat(l.value);isNaN(a)?e.sizeClass&&(i?(i[`remove${s}VariationForSizeClass`](e.sizeClass),i._updateConfiguration()):(n[`remove${s}VariationForSizeClass`](e.sizeClass),n._updateConfiguration())):i?(e.sizeClass?i[`set${s}`](a,{forSizeClass:e.sizeClass}):i[o]=a,i._updateConfiguration(),i._constraint=void 0,i._constituentConstraints=void 0,i._sourceView?i._sourceView.needsLayout=YES:i._views[0].needsLayout=YES):(e.sizeClass?n[`set${s}`](a,{forSizeClass:e.sizeClass}):n[o]=a,n.needsLayout=YES)})),a},optionNamed(t,e){let i=document.createElement("option");return i.value=e?e.value:t,i.innerText=t,e&&e.selected&&(i.selected=YES),i},dropdownSettingWithName(t,e){let i=e.forConstraint,o=e.propertyName,n=document.createElement("div");n.className="BMLayoutEditorDetailsItem";let s=document.createElement("div");s.className="BMLayoutEditorDetailsItemTitle",s.innerText=t,n.appendChild(s);let a=document.createElement("select");return a.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",i._kind==BMLayoutConstraintKind.Horizontal?i._sourceViewAttribute===BMLayoutAttribute.Width?a.appendChild(this.optionNamed(i._sourceViewAttribute)):(a.appendChild(this.optionNamed(BMLayoutAttribute.Leading)),a.appendChild(this.optionNamed(BMLayoutAttribute.CenterX)),a.appendChild(this.optionNamed(BMLayoutAttribute.Trailing)),a.appendChild(this.optionNamed(BMLayoutAttribute.Left)),a.appendChild(this.optionNamed(BMLayoutAttribute.Right))):i._sourceViewAttribute===BMLayoutAttribute.Height?a.appendChild(this.optionNamed(i._sourceViewAttribute)):(a.appendChild(this.optionNamed(BMLayoutAttribute.Top)),a.appendChild(this.optionNamed(BMLayoutAttribute.CenterY)),a.appendChild(this.optionNamed(BMLayoutAttribute.Bottom))),a.value=e.value,n.appendChild(a),a.addEventListener("change",(t=>{i[o]=a.value,i._cassowaryConstraint=void 0,i._constituentConstraints=void 0,i._sourceView.needsLayout=YES})),n},equalitySettingWithName(t,e){let i=e.forConstraint,o=document.createElement("div");o.className="BMLayoutEditorDetailsItem";let n=document.createElement("div");n.className="BMLayoutEditorDetailsItemTitle",n.innerText=t,o.appendChild(n);let s=document.createElement("select");return s.className="BMWindowInput BMLayoutEditorDetailsItemNumericValue",s.appendChild(this.optionNamed("=",{value:BMLayoutConstraintRelation.Equals,selected:i._relation==BMLayoutConstraintRelation.Equals})),s.appendChild(this.optionNamed("≥",{value:BMLayoutConstraintRelation.GreaterThanOrEquals,selected:i._relation==BMLayoutConstraintRelation.GreaterThanOrEquals})),s.appendChild(this.optionNamed("≤",{value:BMLayoutConstraintRelation.LessThanOrEquals,selected:i._relation==BMLayoutConstraintRelation.LessThanOrEquals})),s.value=""+e.value,o.appendChild(s),s.addEventListener("change",(t=>{i._relation=parseInt(s.value,10),i._sourceView.needsLayout=YES})),o},buttonSettingWithName(t,e){var i;e.class?(i=document.createElement("div")).className="BMLayoutEditorImageButton "+e.class:((i=document.createElement("button")).className="BMWindowButton",i.innerText=t);return i.addEventListener("click",e.action),i},settingsDivider(){let t=document.createElement("div");return t.className="BMLayoutEditorDetailsDivider",t},viewSettingWithView(t){let e=document.createElement("div");return e.classList.add("BMLayoutEditorDetailsConstraintItem"),e.innerText=t.debuggingName||t.node.id,e.addEventListener("click",(e=>this.selectView(t))),e},createAdditionalSettingsForConstraint(t,e){},_createConstantSettingsForConstraint(t,e){let i,o=this.detailsNodeContent;o.appendChild(i=this.constantSettingWithName("Constant:",{value:t._constant,forConstraint:t,propertyName:"_constant",withReferenceView:e.withReferenceView}));for(let i in t._variations)this._activeSizeClass&&i==this._activeSizeClass._hashString||"constant"in t._variations[i]&&o.appendChild(this.constantSettingWithName("Constant:",{value:t._variations[i].constant,forConstraint:t,propertyName:"constant",withReferenceView:e.withReferenceView,sizeClass:t._variations[i].sizeClass}));if(this._activeSizeClass){let n="";t._variations[this._activeSizeClass._hashString]&&"constant"in t._variations[this._activeSizeClass._hashString]&&(n=t._variations[this._activeSizeClass._hashString].constant),o.appendChild(i=this.constantSettingWithName("Constant:",{value:n,forConstraint:t,propertyName:"constant",withReferenceView:e.withReferenceView,sizeClass:this._activeSizeClass}))}requestAnimationFrame((t=>i.querySelectorAll("input")[0].focus()),i.querySelectorAll("input")[0].select())},_createPrioritySettingsForConstraint(t,e){let i=this.detailsNodeContent;i.appendChild(this.numericSettingWithName("Priority:",{value:t._priority,forConstraint:t,propertyName:"_priority",withReferenceView:e.withReferenceView}));for(let o in t._variations)this._activeSizeClass&&o==this._activeSizeClass._hashString||"priority"in t._variations[o]&&i.appendChild(this.numericSettingWithName("Priority:",{value:t._variations[o].priority,forConstraint:t,propertyName:"priority",withReferenceView:e.withReferenceView,sizeClass:t._variations[o].sizeClass}));if(this._activeSizeClass){let o="";t._variations[this._activeSizeClass._hashString]&&"priority"in t._variations[this._activeSizeClass._hashString]&&(o=t._variations[this._activeSizeClass._hashString].priority),i.appendChild(this.numericSettingWithName("Priority:",{value:o,forConstraint:t,propertyName:"priority",withReferenceView:e.withReferenceView,sizeClass:this._activeSizeClass}))}},_createIsActiveSettingsForConstraint(t,e){let i=this.detailsNodeContent;this.booleanSettingWithName("Active:",{value:t._isActive,container:i,changeHandler:e=>{t.isActive=e,t._updateConfiguration()}});for(let e in t._variations)this._activeSizeClass&&e==this._activeSizeClass._hashString||"isActive"in t._variations[e]&&this.booleanSettingWithName("Active:",{value:t._variations[e].isActive,indeterminate:YES,container:i,sizeClass:t._variations[e].sizeClass,changeHandler:(e,i)=>{void 0===e?t.removeIsActiveVariationForSizeClass(i):t.setIsActive(e,{forSizeClass:i}),t._updateConfiguration()}});if(this._activeSizeClass){let e;t._variations[this._activeSizeClass._hashString]&&"isActive"in t._variations[this._activeSizeClass._hashString]&&(e=t._variations[this._activeSizeClass._hashString].isActive),this.booleanSettingWithName("Active:",{value:e,indeterminate:YES,container:i,sizeClass:this._activeSizeClass,changeHandler:(e,i)=>{void 0===e?t.removeIsActiveVariationForSizeClass(i):t.setIsActive(e,{forSizeClass:i}),t._updateConfiguration()}})}},createSettingsForConstraint(t,e){if(this._disableSettingsKeyboardShortcuts(),t.isConstraintCollection)return this.createSettingsForConstraintCollection(t,e);var i=this.detailsNodeContent;i.classList.remove("BMLayoutEditorViewDetails");BMLayoutConstraintRelation.Equals,BMLayoutConstraintRelation.GreaterThanOrEquals,BMLayoutConstraintRelation.LessThanOrEquals;i.appendChild(this.readonlySettingWithName("First View:",{value:t._sourceView.debuggingName||t._sourceView.node.id,action:e=>this.selectView(t._sourceView)})),i.appendChild(this.dropdownSettingWithName("Attribute:",{value:t._sourceViewAttribute,forConstraint:t,propertyName:"_sourceViewAttribute",withReferenceView:e.withReferenceView})),i.appendChild(this.settingsDivider()),i.appendChild(this.equalitySettingWithName("Relation:",{value:t._relation,forConstraint:t,withReferenceView:e.withReferenceView})),i.appendChild(this.settingsDivider()),t._targetView&&(i.appendChild(this.numericSettingWithName("Multiplier:",{value:t._multiplier,forConstraint:t,propertyName:"_multiplier",withReferenceView:e.withReferenceView})),i.appendChild(this.readonlySettingWithName("Second View:",{value:t._targetView.debuggingName||t._targetView.node.id,action:e=>this.selectView(t._targetView)})),i.appendChild(this.dropdownSettingWithName("Attribute:",{value:t._targetViewAttribute,forConstraint:t,propertyName:"_targetViewAttribute",withReferenceView:e.withReferenceView}))),this._createConstantSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()),this._createPrioritySettingsForConstraint(t,e),this._createIsActiveSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()),this.createAdditionalSettingsForConstraint(t,{withReferenceView:e.withReferenceView,inContainer:i}),i.appendChild(this.buttonSettingWithName("Remove Constraint",{action:i=>{this.tree.removeConstraint(t),t.remove(),this.selectView(e.withReferenceView)}}))},createSettingsForConstraintCollection(t,e){var i=this.detailsNodeContent;i.classList.remove("BMLayoutEditorViewDetails"),t._hasEditableConstant&&(this._createConstantSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()));let o=this.readonlySettingWithName("Affected Views",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px",i.appendChild(o),t._views.forEach((t=>i.appendChild(this.viewSettingWithView(t)))),i.appendChild(this.settingsDivider()),this._createPrioritySettingsForConstraint(t,e),this._createIsActiveSettingsForConstraint(t,e),i.appendChild(this.settingsDivider()),this.createAdditionalSettingsForConstraint(t,{withReferenceView:e.withReferenceView,inContainer:i}),i.appendChild(this.buttonSettingWithName("Remove Constraint",{action:e=>{this.tree.removeConstraint(t);let i=t._views[0];t.remove(),this.selectView(i)}}))},constraintSettingWithConstraint(t,e){let i=document.createElement("div");return i.classList.add("BMLayoutEditorDetailsConstraintItem"),i.innerText=t.toString(),t._priority>500&&t._priority<1e3?i.classList.add("BMLayoutEditorDetailsConstraintItemStrong"):t._priority<=500&&i.classList.add("BMLayoutEditorDetailsConstraintItemWeak"),e.internal?i.classList.add("BMLayoutEditorDetailsConstraintItemReadonly"):i.addEventListener("click",(i=>this.selectConstraint(t,{withReferenceView:e.referenceView}))),i},_settingsKeyboardShortcuts:void 0,_disableSettingsKeyboardShortcuts(){this._settingsKeyboardShortcuts&&this._settingsKeyboardShortcuts.forEach((t=>{window.removeEventListener("keydown",t,YES),window.removeEventListener("keyup",t,YES),window.removeEventListener("keypress",t,YES)})),this._settingsKeyboardShortcuts=[]},createSettingsForView(t){this._disableSettingsKeyboardShortcuts();var e=this.detailsNodeContent;e.classList.add("BMLayoutEditorViewDetails");let i=document.createElement("div");i.className="BMLayoutEditorViewTabDetails",e.appendChild(i),e=i,this.createVariableNumericSettingWithName("Opacity:",{withReferenceView:t,propertyName:"opacity",container:e}),this.createVariableBooleanSettingWithName("Visible:",{withReferenceView:t,propertyName:"isVisible",container:e}),this.createVariableStringSettingWithName("CSS Class:",{withReferenceView:t,propertyName:"CSSClass",container:e}),e.appendChild(this.settingsDivider()),e.appendChild(this.numericSettingWithName("Compression Resistance:",{value:t.compressionResistance,propertyName:"compressionResistance",withReferenceView:t})),e.appendChild(this.numericSettingWithName("Expansion Resistance:",{value:t.expansionResistance,propertyName:"expansionResistance",withReferenceView:t})),e.appendChild(this.settingsDivider()),e.appendChild(this.readonlySettingWithName("Intrinsic Size:",{value:t.supportsIntrinsicSize?"Supported":"Unsupported"}));let o={},n={},s={},a=NO,r=NO;t.localConstraints.forEach((e=>{let i=e.categoryKind;if(!e._configuration.isActive)return r=YES,s[i]=s[i]||[],void s[i].push(e);if(!e._isConstraintCollection){if(e._sourceView==t&&e._targetView&&e._targetView.isDescendantOfView(t))return n[i]=n[i]||[],n[i].push(e),void(a=YES);if(e._targetView==t&&e._sourceView.isDescendantOfView(t))return n[i]=n[i]||[],n[i].push(e),void(a=YES)}o[i]=o[i]||[],o[i].push(e)})),Object.keys(o).sort().forEach((i=>{e.appendChild(this.settingsDivider());let n=this.readonlySettingWithName(i+" Constraints",{value:""});n.childNodes[0].style.textAlign="left",n.childNodes[0].style.paddingLeft="16px",e.appendChild(n),o[i].forEach((i=>e.appendChild(this.constraintSettingWithConstraint(i,{referenceView:t}))))}));let l=NO,h=NO;if(a){let i=document.createElement("div");i.classList.add("BMLayoutEditorViewDetails"),i.classList.add("BMLayoutEditorSubviewDetails"),i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),i.style.height="0px",e.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Subview Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px";let s=document.createElement("div");s.classList.add("BMDisclosureTriangle"),o.insertBefore(s,o.childNodes[0]),s.addEventListener("click",(e=>{i.classList.contains("BMLayoutEditorSubviewDetailsCollapsed")?(l=YES,s.classList.add("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:i.scrollHeight+"px"},{duration:200,easing:"easeInOutQuad",complete:()=>i.classList.remove("BMLayoutEditorSubviewDetailsCollapsed")})):(l=NO,i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),s.classList.remove("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:"0px"},{duration:200,easing:"easeInOutQuad"})),this._drawConstraintsForView(t,{includesInactiveConstraints:h,includesSubviewConstraints:l}),e.stopPropagation()})),e.appendChild(o),Object.keys(n).sort().forEach((e=>{i.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Subview "+e+" Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px",i.appendChild(o),n[e].forEach((e=>i.appendChild(this.constraintSettingWithConstraint(e,{referenceView:t}))))})),e.appendChild(i)}if(r){let i=document.createElement("div");i.classList.add("BMLayoutEditorViewDetails"),i.classList.add("BMLayoutEditorSubviewDetails"),i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),i.style.height="0px",e.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Inactive Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px";let n=document.createElement("div");n.classList.add("BMDisclosureTriangle"),o.insertBefore(n,o.childNodes[0]),n.addEventListener("click",(e=>{i.classList.contains("BMLayoutEditorSubviewDetailsCollapsed")?(h=YES,n.classList.add("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:i.scrollHeight+"px"},{duration:200,easing:"easeInOutQuad",complete:()=>i.classList.remove("BMLayoutEditorSubviewDetailsCollapsed")})):(h=NO,i.classList.add("BMLayoutEditorSubviewDetailsCollapsed"),n.classList.remove("BMDisclosureTriangleExpanded"),(window.Velocity||$.Velocity).animate(i,{height:"0px"},{duration:200,easing:"easeInOutQuad"})),this._drawConstraintsForView(t,{includesInactiveConstraints:h,includesSubviewConstraints:l}),e.stopPropagation()})),e.appendChild(o),Object.keys(s).sort().forEach((e=>{i.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Inactive "+e+" Constraints",{value:""});o.childNodes[0].style.textAlign="left",o.childNodes[0].style.paddingLeft="16px",i.appendChild(o),s[e].forEach((e=>i.appendChild(this.constraintSettingWithConstraint(e,{referenceView:t}))))})),e.appendChild(i)}let c=t.internalConstraints();if(c.length){e.appendChild(this.settingsDivider());let i=this.readonlySettingWithName("Internal Constraints",{value:""});i.childNodes[0].style.textAlign="left",i.childNodes[0].style.paddingLeft="16px",e.appendChild(i),c.forEach((i=>e.appendChild(this.constraintSettingWithConstraint(i,{referenceView:t,internal:YES}))))}let d=NO,u=NO,p=NO;e.appendChild(this.settingsDivider());let g=this.buttonSettingWithName("Deactivate Constraints",{action:e=>{if(d&&u&&p)new Set(t.rootView.allConstraints).forEach((t=>t.remove()));else if(d)for(let e of t.localConstraints)u?e.remove():this._activeSizeClass?e.setIsActive(NO,{forSizeClass:this._activeSizeClass}):e.isActive=NO;else Object.keys(o).forEach((t=>{for(let e of o[t])u?e.remove():this._activeSizeClass?e.setIsActive(NO,{forSizeClass:this._activeSizeClass}):e.isActive=NO}));this.selectView(t)}});e.appendChild(g),g.addEventListener("contextmenu",(t=>t.preventDefault()));let w=t=>{switch(t.key){case"Alt":d="keydown"==t.type;break;case"Shift":u="keydown"==t.type;break;case"Control":p="keydown"==t.type}g.innerText=d?u?p?"Reset Layout":"Remove All Constraints":"Deactivate All Constraints":u?"Remove Constraints":"Deactivate Constraints"};window.addEventListener("keydown",w,YES),window.addEventListener("keyup",w,YES),this._settingsKeyboardShortcuts.push(w)},equalConstraintSettingWithName(t,e){return this.buttonSettingWithName(t,{class:e.class,action:t=>{let i=BMEqualAttributeLayoutConstraint.constraintWithAttribute(e.attribute,{forViews:this.selectedViews,_internal:t.shiftKey});t.shiftKey?i.constituentConstraints.forEach((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(i)}})},createSettingsForMultipleViews(){this._disableSettingsKeyboardShortcuts(),this.detailsNodeTitle.innerText=this.selectedViews.length+" selected",this.detailsNodeContent.innerHTML="";let t=this.detailsNodeContent,e=this.readonlySettingWithName("Align Horizontal",{value:""});e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(e);let i=document.createElement("div");i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Top",{class:"BMLayoutEditorImageButtonAlignAlignTop",attribute:BMLayoutAttribute.Top})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterY",attribute:BMLayoutAttribute.CenterY})),i.appendChild(this.equalConstraintSettingWithName("Align Bottom",{class:"BMLayoutEditorImageButtonAlignBottom",attribute:BMLayoutAttribute.Bottom})),t.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Distribute Horizontal",{value:""});e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(o),i=document.createElement("div"),i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Width",{class:"BMLayoutEditorImageButtonEqualWidth",attribute:BMLayoutAttribute.Width})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Align Vertical",{value:""}),e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(o),i=document.createElement("div"),i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Leading",{class:"BMLayoutEditorImageButtonAlignLeading",attribute:BMLayoutAttribute.Leading})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterX",attribute:BMLayoutAttribute.CenterX})),i.appendChild(this.equalConstraintSettingWithName("Align Trailing",{class:"BMLayoutEditorImageButtonAlignTrailing",attribute:BMLayoutAttribute.Trailing})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Distribute Vertical",{value:""}),e.childNodes[0].style.textAlign="center",e.childNodes[0].style.width="100%",t.appendChild(o),i=document.createElement("div"),i.style="display: flex; flex-direction: row; align-self: center; padding-top: 8px; padding-bottom: 8px",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualVerticalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualVerticalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.selectedViews.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.addConstraint(t)})):this.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Height",{class:"BMLayoutEditorImageButtonEqualHeight",attribute:BMLayoutAttribute.Height}))},bringToFrontAnimated:function(t,e){this._visible=YES,t=void 0===t?YES:t,(window.Velocity||$.Velocity)(this._blocker,"stop"),(window.Velocity||$.Velocity)(this._window,"stop");var i=this;if(i.delegate&&i.delegate.windowWillAppear&&i.delegate.windowWillAppear(i),t){this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",BM_USE_VELOCITY2?this._blocker.velocity({opacity:1,translateZ:0,display:"block"},{duration:500,easing:"easeInOutQuint",complete:function(){i._blocker.style.pointerEvents="",i._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()}}):(window.Velocity||$.Velocity)(this._blocker,{opacity:1,translateZ:0},{duration:500,easing:"easeInOutQuint",display:"block",complete:function(){i._blocker.style.pointerEvents="",i._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i),e&&e.completionHandler&&e.completionHandler()}});let o=this.frame.copy(),n=BMRectMakeWithNodeFrame(this._rootNode);this.frame=n,this.treeWidthConstraint.constant=0,this.detailsWidthConstraint.constant=0,this.workspaceToolbarHeightConstraint.constant=0,this.node.style.opacity=1,this.node.style.display="block",this._view.node.style.display="block",this.workspaceNode.appendChild(this._view.node),this.layout(),BMAnimateWithBlock((()=>{this.leftConstraint.constant=o.origin.x,this.topConstraint.constant=o.origin.y,this.widthConstraint.constant=o.size.width,this.heightConstraint.constant=o.size.height,this.treeWidthConstraint.constant=256,this.detailsWidthConstraint.constant=344,this.workspaceToolbarHeightConstraint.constant=this._useSettingsView?32:64,this.layout(),BMCopyProperties(this.node.style,{left:n.origin.x+"px",top:n.origin.y+"px",width:n.size.width+"px",height:n.size.height+"px"});let t=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});t.registerBuiltInProperty("left",{withValue:o.origin.x+"px"}),t.registerBuiltInProperty("top",{withValue:o.origin.y+"px"}),t.registerBuiltInProperty("width",{withValue:o.size.width+"px"}),t.registerBuiltInProperty("height",{withValue:o.size.height+"px"}),this._frame=o}),{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:()=>{for(const e of i._toolWindows)e.opensAutomatically&&e.bringToFrontAnimated(t)}})}else{this._blocker.style.opacity=1,this._blocker.style.display="block",this._blocker.style.webkitBackdropFilter="blur(15px)",this._blocker.style.backdropFilter="blur(15px)",this._window.style.opacity=1,BMHook(this._window,{scaleX:1,scaleY:1}),this._window.style.display="block",this._blocker.style.pointerEvents="",this._window.style.pointerEvents="",i.delegate&&i.delegate.windowDidAppear&&i.delegate.windowDidAppear(i);for(const e of this._toolWindows)e.bringToFrontAnimated(t);e&&e.completionHandler&&e.completionHandler()}},dismissAnimated:async function(t,e){var i;e=e||{},this._disableSettingsKeyboardShortcuts(),e.completionHandler&&(i=e.completionHandler),e.completionHandler=()=>{i&&i()},window.removeEventListener("resize",this.resizeListener),t=void 0===t?YES:t,(window.Velocity||$.Velocity)(this._blocker,"stop"),(window.Velocity||$.Velocity)(this._window,"stop");var o=this;this._blocker.style.pointerEvents="none",this._window.style.pointerEvents="none",o.delegate&&o.delegate.windowWillClose&&o.delegate.windowWillClose(o);for(const e of this._toolWindows)e.dismissAnimated(t);if(t){(window.Velocity||$.Velocity)(this._blocker,{opacity:0,translateZ:0},{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,display:"none",complete:function(){o.delegate&&o.delegate.windowDidClose&&o.delegate.windowDidClose(o),e&&e.completionHandler&&e.completionHandler()}});let t=this.frame.copy(),i=BMRectMakeWithNodeFrame(this._rootNode).integralRect;this.node.classList.add("BMLayoutEditorNoShadow"),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove())),await 0,BMAnimateWithBlock((()=>{this.leftConstraint.constant=i.origin.x,this.topConstraint.constant=i.origin.y,this.widthConstraint.constant=i.size.width,this.heightConstraint.constant=i.size.height,this.treeWidthConstraint.constant=0,this.detailsWidthConstraint.constant=0,this.workspaceToolbarHeightConstraint.constant=0,this._staticWorkspaceSize=void 0,this.view._requiredViewport=void 0,this.workspaceLeft.remove(),this.workspaceTop.remove(),this.workspaceWidth.remove(),this.workspaceHeight.remove(),(this.workspaceLeft=this.workspace.left.equalTo(this.workspaceWrapperView.left)).isActive=YES,(this.workspaceTop=this.workspace.top.equalTo(this.workspaceWrapperView.top)).isActive=YES,(this.workspaceWidth=this.workspace.width.equalTo(this.workspaceWrapperView.width)).isActive=YES,(this.workspaceHeight=this.workspace.height.equalTo(this.workspaceWrapperView.height)).isActive=YES,this.layout(),this.panOffset=BMPointMake(0,0),this.scale=1,BMCopyProperties(this.node.style,{left:t.origin.x+"px",top:t.origin.y+"px",width:t.size.width+"px",height:t.size.height+"px"});let e=BMAnimationContextGetCurrent().controllerForObject(this,{node:this.node});e.registerBuiltInProperty("left",{withValue:i.origin.x+"px"}),e.registerBuiltInProperty("top",{withValue:i.origin.y+"px"}),e.registerBuiltInProperty("width",{withValue:i.size.width+"px"}),e.registerBuiltInProperty("height",{withValue:i.size.height+"px"}),this._frame=t}),{duration:_BMWindowAnimationDurationDefault,easing:_BMWindowAnimationEasingDefault,complete:()=>{this._view.layoutEditor=void 0,this._rootNode.appendChild(this._view.node),this._view.allSubviews.forEach((t=>t.node.classList.remove("BMLayoutEditorManagedView"))),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove()))}}),this._visible=NO}else this._blocker.style.opacity=0,this._blocker.style.display="none",this._window.style.opacity=0,this._window.style.display="none",this._visible=NO,this._view.layoutEditor=void 0,this._rootNode.appendChild(this._view.node),this._view.node.querySelectorAll(".BMLayoutEditorViewSelector, .BMLayoutEditorConstraint, .BMLayoutEditorVerticalLeadLine, .BMLayoutEditorHorizontalLeadLine").forEach((t=>t.remove())),this._view.allSubviews.forEach((t=>t.node.classList.remove("BMLayoutEditorManagedView"))),o.delegate&&o.delegate.windowDidClose&&o.delegate.windowDidClose(o),e&&e.completionHandler&&e.completionHandler()}}),BMLayoutEditor.editorForView=function(t){return(new BMLayoutEditor).initWithView(t)},BMViewLayoutEditor.editorForView=function(t){return(new BMViewLayoutEditor).initWithView(t)},BMViewLayoutEditor.prototype=Object.create(BMLayoutEditor.prototype),_BMLayoutEditorTree.prototype=BMExtend(Object.create(BMView.prototype),{constructor:_BMLayoutEditorTree,_node:void 0,_view:void 0,_editor:void 0,_viewNodeMap:void 0,_constraintNodeMap:void 0,initWithView(t,e){return BMView.prototype.initWithDOMNode.call(this,e.node),this._view=t,this._editor=e.editor,this._viewNodeMap=new Map,this._constraintNodeMap=new Map,this._buildTree(),this},_buildTree(){this._node.innerHTML="",this._node.appendChild(this.treeNodeForView(this._view))},treeNodeForView(t){let e=document.createElement("div");e.classList.add("BMLayoutTreeView");let i=document.createElement("div");i.classList.add("BMLayoutTreeViewTitle"),i.classList.add("BMLayoutTreeViewEntity"),e.appendChild(i),this._editor.initDragEventListenerForNode(i,{view:t}),this._viewNodeMap.set(t,i);let o=document.createElement("div");o.classList.add("BMDisclosureTriangle"),o.classList.add("BMDisclosureTriangleExpanded"),i.appendChild(o),i.appendChild(document.createTextNode(t.debuggingName||t.node.id));let n=document.createElement("div");n.classList.add("BMLayoutTreeViewContainer"),n.classList.add("BMLayoutTreeViewContainerExpanded"),e.appendChild(n),t.subviews.forEach((t=>n.appendChild(this.treeNodeForView(t)))),t.subviews.length||(o.style.visibility="hidden");let s=document.createElement("div");s.classList.add("BMLayoutTreeViewConstraintsTitle"),s.classList.add("BMLayoutTreeViewEntity"),s.style.display="none";let a=document.createElement("div");a.classList.add("BMDisclosureTriangle"),s.appendChild(a),s.appendChild(document.createTextNode("Constraints")),n.appendChild(s);let r=document.createElement("div");return r.classList.add("BMLayoutTreeViewConstraintsContainer"),r.classList.add("BMLayoutTreeViewContainer"),r.style.display="none",n.appendChild(r),a.addEventListener("click",(t=>{r.classList.contains("BMLayoutTreeViewContainerExpanded")?(r.classList.remove("BMLayoutTreeViewContainerExpanded"),a.classList.remove("BMDisclosureTriangleExpanded")):(r.classList.add("BMLayoutTreeViewContainerExpanded"),a.classList.add("BMDisclosureTriangleExpanded")),t.stopPropagation()})),i.addEventListener("click",(e=>this._editor.selectView(t,{withEvent:e}))),o.addEventListener("click",(t=>{n.classList.contains("BMLayoutTreeViewContainerExpanded")?(n.classList.remove("BMLayoutTreeViewContainerExpanded"),o.classList.remove("BMDisclosureTriangleExpanded")):(n.classList.add("BMLayoutTreeViewContainerExpanded"),o.classList.add("BMDisclosureTriangleExpanded")),t.stopPropagation()})),t.localConstraints.forEach((e=>r.appendChild(this.treeNodeForConstraint(e,{withReferenceView:t})))),e},treeNodeForConstraint(t,e){let i=document.createElement("div");i.classList.add("BMLayoutTreeViewConstraintsTitle"),i.classList.add("BMLayoutTreeViewEntity"),i.innerText=t.toCompactString(),i.addEventListener("click",(i=>this._editor.selectConstraint(t,{withReferenceView:e.withReferenceView})));let o=this._constraintNodeMap.get(t);return o||(o=[],this._constraintNodeMap.set(t,o)),o.push(i),i},selectView(t,e){(!e||!e.continuous)&&this._node.querySelectorAll(".BMLayoutTreeViewEntitySelected").forEach((t=>t.classList.remove("BMLayoutTreeViewEntitySelected")));var i=this._viewNodeMap.get(t);i&&i.classList.add("BMLayoutTreeViewEntitySelected")},deselectView(t,e){var i=this._viewNodeMap.get(t);i&&i.classList.remove("BMLayoutTreeViewEntitySelected")},selectConstraint(t){this._node.querySelectorAll(".BMLayoutTreeViewEntitySelected").forEach((t=>t.classList.remove("BMLayoutTreeViewEntitySelected")));var e=this._constraintNodeMap.get(t);e&&e.forEach((t=>t.classList.add("BMLayoutTreeViewEntitySelected")))},removeConstraint(t){var e=this._constraintNodeMap.get(t);e&&e.forEach((t=>t.remove())),this._constraintNodeMap.delete(t)},addConstraint(t){var e=[],i=this._viewNodeMap.get(t._firstView);if(i){let n=this.treeNodeForConstraint(t);(o=(o=i.parentNode.childNodes)[o.length-1]).appendChild(n),e.push(n)}if(this._viewNodeMap.get(t._secondView)){let n=this.treeNodeForConstraint(t);var o;(o=(o=i.parentNode.childNodes)[o.length-1]).appendChild(n),e.push(n)}this._constraintNodeMap.set(t,e)}}),_BMLayoutEditorTree.editorTreeWithView=function(t,e){return(new _BMLayoutEditorTree).initWithView(t,e)};const BMLayoutEditorAvailable=YES;class BMLayoutEditorVariableCell extends BMCollectionViewCell{initWithCollectionView(t,e){super.initWithCollectionView(t,e);const i=e.node;i.classList.add("BMLayoutEditorVariable");const o=document.createElement("div");o.className="BMLayoutEditorDetailsItemBadgeIcon",this.sizeClassBadge=o,i.appendChild(o);const n=document.createElement("input");n.type="text",n.className="BMWindowInput BMLayoutEditorVariableName",this.variableName=n,i.appendChild(n),this._initNameEditor();const s=document.createElement("input");s.type="number",s.className="BMWindowInput BMLayoutEditorVariableValue",this.variableValue=s,i.appendChild(s),this._initValueEditor();const a=document.createElement("div");a.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorVariableButton BMLayoutEditorAddVariationButton",a.innerHTML='<i class="material-icons">add_circle</i>',i.appendChild(a),this.addVariationButton=a,this._initAddVariationButton();const r=document.createElement("div");return r.className="BMWindowToolbarButton BMLayoutEditorToolbarButton BMLayoutEditorVariableButton BMLayoutEditorRemoveVariationButton",r.innerHTML='<i class="material-icons">remove_circle</i>',i.appendChild(r),this.removeVariationButton=r,this._initRemoveVariationButton(),this}_initAddVariationButton(){this.addVariationButton.addEventListener("click",(t=>{this.editor._showSizeClassMenuAtPoint(BMRectMakeWithNodeFrame(this.addVariationButton).center,{kind:BMMenuKind.Menu,action:t=>{if(this.collectionView.dataSet.variables.find((e=>e.name==this.indexPath.object.name&&t.isEqualToSizeClass(e.sizeClass))))return;this.collectionView.dataSet.beginUpdates(),this.collectionView.dataSet.variables.splice(this.indexPath.row+1,0,{name:this.indexPath.object.name,sizeClass:t,value:this.indexPath.object.value});const e=this.indexPath.row+1;this.collectionView.dataSet.commitUpdatesWithCompletionHandler((()=>{var t=this.collectionView.indexPathForObjectAtRow(e,{inSectionAtIndex:0}),i=this.collectionView.cellAtIndexPath(t);i?(i.node.querySelector(".BMLayoutEditorVariableValue").focus(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES})):((i=propertiesCollection.retainCellForIndexPath(t)).node.querySelector(".BMLayoutEditorVariableValue").focus(),i.release(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES}))})),this.editor.layoutVariableProvider.setLayoutVariableValue(this.indexPath.object.value,{named:this.indexPath.object.name,inSizeClass:t})}})}))}_initRemoveVariationButton(){this.removeVariationButton.addEventListener("click",(t=>{const e=this.collectionView.dataSet.variables;if(this.indexPath.object.sizeClass)this.collectionView.dataSet.beginUpdates(),e.splice(this.indexPath.row,1),this.collectionView.dataSet.commitUpdates(),this.editor.layoutVariableProvider.removeVariationForLayoutVariableNamed(this.indexPath.object.name,{inSizeClass:this.indexPath.object.sizeClass});else{this.collectionView.dataSet.beginUpdates();for(let t=0;t<e.length;t++){const i=e[t];i.name==this.indexPath.object.name&&(i.sizeClass?this.editor.layoutVariableProvider.removeVariationForLayoutVariableNamed(i.name,{inSizeClass:i.sizeClass}):this.editor.layoutVariableProvider.unregisterLayoutVariableNamed(i.name),e.splice(t,1),t--)}this.collectionView.dataSet.commitUpdates()}}))}_initNameEditor(){let t;this.variableName.addEventListener("focus",(async e=>{t=this._variable.name,this.variableName.select(),this.retain();const i=t=>t.preventDefault();this.variableName.addEventListener("mouseup",i),await new Promise((t=>setTimeout(t,200))),this.variableName.removeEventListener("mouseup",i)})),this.variableName.addEventListener("blur",(async e=>{let i=this.variableName.value.trim();if(i!=t){let e=NO;for(const t of this.collectionView.dataSet.variables)if(t.name==i){e=YES;break}if(e)this.variableName.value=t,await __BMVelocityAnimate(this.variableName,{translateX:"20px"},{duration:50,ease:"easeOutQuad"}),await __BMVelocityAnimate(this.variableName,{translateX:"-20px"},{duration:100,ease:"easeInOutQuad"}),__BMVelocityAnimate(this.variableName,{translateX:"0px"},{duration:50,ease:"easeInQuad"});else{this.editor.layoutVariableProvider.renameLayoutVariableNamed(t,{toName:i});for(const e of this.collectionView.dataSet.variables)e.name==t&&(e.name=i)}}this.release()}))}_initValueEditor(){this.variableValue.addEventListener("focus",(async t=>{this.variableValue.select(),this.retain();const e=t=>t.preventDefault();this.variableValue.addEventListener("mouseup",e),await new Promise((t=>setTimeout(t,200))),this.variableValue.removeEventListener("mouseup",e)})),this.variableValue.addEventListener("input",(t=>{let e=parseFloat(this.variableValue.value.trim());isNaN(e)||(this._variable.value=e,this._variable.sizeClass?this.editor.layoutVariableProvider.setLayoutVariableValue(e,{named:this._variable.name,inSizeClass:this._variable.sizeClass}):this.editor.layoutVariableProvider.registerLayoutVariableNamed(this._variable.name,{withValue:e}))})),this.variableValue.addEventListener("blur",(async t=>this.release()))}get variable(){return this._variable}set variable(t){if(this._variable=t,t.sizeClass){this.addVariationButton.style.visibility="hidden",this.sizeClassBadge.style.display="block",this.variableName.style.display="none";const e=this.editor.settingsBadgeForSizeClass(t.sizeClass);this.sizeClassBadge.className=e.className,this.sizeClassBadge.innerText=e.innerText,this.node.classList.remove("BMLayoutEditorVariableMain")}else this.addVariationButton.style.visibility="visible",this.sizeClassBadge.style.display="none",this.variableName.style.display="block",this.node.classList.add("BMLayoutEditorVariableMain");this.variableValue.value=t.value,this.variableName.value=t.name}}class BMLayoutEditorEmptyVariablesCell extends BMCollectionViewCell{initWithCollectionView(t,e){super.initWithCollectionView(t,e);const i=t.dataSet.provider.canUseLayoutVariables(),o=document.createElement("div");o.innerText=i?"No Layout Variables Defined":"Layout Variables Unavailable",o.className="BMWindowLabel BMLayoutEditorMessageTitle",this.node.appendChild(o);const n=document.createElement("div");return n.innerText=i?'Use the "Add Variable" button below to add a layout variable.':t.dataSet.provider.unavailableLayoutVariablesUserLabel(),n.className="BMWindowLabel BMLayoutEditorMessageDescription",this.node.appendChild(n),this.node.classList.add("BMLayoutEditorEmptyVariableMessage"),this}}class BMLayoutEditorVariablesDataSet{initWithLayoutVariableProvider(t,{collectionView:e,editor:i}){this.provider=t,this.variables=[];const o=t.layoutVariables;for(const e in o){this.variables.push({name:e,value:o[e]});const i=t.variationsForLayoutVariableNamed(e);for(const t of i)this.variables.push(t)}return this.collectionView=e,this.editor=i,this}numberOfSections(){return Math.min(this.variables.length,1)}numberOfObjectsInSectionAtIndex(t){return this.variables.length}indexPathForObjectAtRow(t){return BMIndexPathMakeWithRow(t,{section:0,forObject:this.variables[t]})}indexPathForObject(t){for(let e=0;e<this.variables.length;e++){const i=this.variables[e];if(i.name==t.name&&i.sizeClass==t.sizeClass)return BMIndexPathMakeWithRow(e,{section:0,object:i})}}cellForItemAtIndexPath(t){const e=this.collectionView.dequeueCellForReuseIdentifier("Variable");return e.editor=this.editor,e.variable=t.object,e}cellForSupplementaryViewWithIdentifier(t,e){return this.collectionView.dequeueCellForSupplementaryViewWithIdentifier(t)}beginUpdates(){this._oldData=this.variables.slice(),this._newData=this.variables}useOldData(t){this.variables=t?this._oldData:this._newData}isUsingOldData(){return this.variables===this._newData}commitUpdates(){return this.commitUpdatesWithCompletionHandler()}commitUpdatesWithCompletionHandler(t){this.collectionView.updateEntireDataAnimated(YES,{completionHandler:t}),this.variables=this._newData,this._oldData=void 0}addVariable(){this.beginUpdates();let t="new variable",e=0;for(;YES;){let o=NO;for(var i=0;i<this.variables.length;i++)if(this.variables[i].name==t){o=YES;break}if(!o)break;e++,t="new variable "+e}this.variables.push({name:t,value:0}),this.provider.registerLayoutVariableNamed(t,{withValue:0}),this.commitUpdatesWithCompletionHandler((()=>{var t=this.indexPathForObjectAtRow(this.variables.length-1,{inSectionAtIndex:0}),e=this.collectionView.cellAtIndexPath(t);e?(e.node.querySelector(".BMLayoutEditorVariableName").focus(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES})):((e=this.collectionView.retainCellForIndexPath(t)).node.querySelector(".BMLayoutEditorVariableName").focus(),e.release(),this.collectionView.scrollToCellAtIndexPath(t,{animated:YES}))}))}collectionViewCanSelectCellAtIndexPath(){return NO}collectionViewSizeForCellAtIndexPath(t,e){return e.object.sizeClass?BMSizeMake(1,32):BMSizeMake(1,48)}}function _BMURLOfImageAtPath(t){return("TW"in window?"/Thingworx/Common/extensions/BMCoreUI/ui/BMCoreUI/":"")+t}function _BMLayoutEditorSettingsView(){}function _BMLayoutEditorSettingsPanel(){}function _BMLayoutEditorCollectionSettingsPanel(){}function BMLayoutEditorSettingsTab(){}function BMLayoutEditorSettingsSection(){}_BMLayoutEditorSettingsView.prototype=BMExtend(Object.create(BMView.prototype),{constructor:_BMLayoutEditorSettingsView,_editor:void 0,_panels:void 0,_window:void 0,_dismissedByUser:NO,get window(){return this._window},get currentPanel(){return this._panels[this._panels.length-1]},initWithDOMNode(t,{forEditor:e}){return BMView.prototype.initWithDOMNode.call(this,t),this.node.style.overflow="hidden",this._editor=e,this._panels=[],this},async windowWillAppear(t){if(this._panels.length&&this._panels[this._panels.length-1]._awaitsLayout){await 0;const t=this._panels[this._panels.length-1];t.view.needsLayout=YES,t.view.layoutIfNeeded(),t.settingsPanelDidLayoutView(),t._awaitsLayout=NO}},_provisionPanel(t,{withBackButton:e}={withBackButton:NO}){t._settingsView=this;const i=BMView.view();this.addSubview(i),i.leading.equalTo(this.leading).isActive=YES,i.trailing.equalTo(this.trailing).isActive=YES,i.top.equalTo(this.top).isActive=YES,i.bottom.equalTo(this.bottom).isActive=YES,t._container=i,i.node.classList.add("BMLayoutEditorDetails"),i.node.style.cssText="border: none !important;",i.node.style.overflow="hidden";const o=BMView.view();i.addSubview(o),o.leading.equalTo(i.leading).isActive=YES,o.trailing.equalTo(i.trailing).isActive=YES,o.bottom.equalTo(i.bottom).isActive=YES,t._view=o;const n=BMView.view();n.node.innerText=(e?"‹ ":"")+t.title||"",n.node.className="BMWindowTitle BMLayoutEditorDetailsTitle";let s=64;e&&(n.node.classList.add("BMLayoutEditorDetailsItemReadonlyValueClickable"),n.node.classList.add("BMLayoutEditorDetailsBackButton"),s-=8),n.node.style.zIndex=1,n.supportsAutomaticIntrinsicSize=YES,i.addSubview(n),n.leading.equalTo(i.leading,{plus:s}).isActive=YES,n.trailing.lessThanOrEqualTo(i.trailing,{plus:-16}).isActive=YES,n.height.greaterThanOrEqualTo(32).isActive=YES,n.top.equalTo(i.top,{plus:12}).isActive=YES,t._titleView=n,o.top.equalTo(n.bottom,{plus:12}).isActive=YES,e&&n.node.addEventListener("click",(t=>this.popPanel())),t.settingsPanelDidLoad(),this._window&&!this._window._visible?t._awaitsLayout=YES:(this.layoutIfNeeded(),t.settingsPanelDidLayoutView())},selectView(t){this._ignoresSelection=YES,this._editor.selectView(t);const e=(new _BMLayoutEditorViewSettingsPanel).initWithSettingsView(this,{forView:t});this._provisionPanel(e,{withBackButton:YES}),this.pushPanel(e),this._ignoresSelection=NO},layoutEditorDidSelectView(t){if(this._ignoresSelection)return;let e=YES;this._window&&!this._window._visible&&(e=NO);const i=(new _BMLayoutEditorViewSettingsPanel).initWithSettingsView(this,{forView:t});this._provisionPanel(i),this.resetToPanel(i,{animated:e})},layoutEditorDidSelectViews(t){if(this._panels[0]instanceof _BMLayoutEditorViewGroupSettingsPanel)return void(this._panels[0].views=t);if(this._ignoresSelection)return;let e=YES;this._window&&!this._window._visible&&(e=NO);const i=(new _BMLayoutEditorViewGroupSettingsPanel).initWithSettingsView(this,{forViews:t});this._provisionPanel(i),this.resetToPanel(i,{animated:e})},selectConstraint(t,{withReferenceView:e}){this._ignoresSelection=YES,this._editor.selectConstraint(t,{withReferenceView:e});const i=(new _BMLayoutEditorConstraintSettingsPanel).initWithSettingsView(this,{forConstraint:t,withReferenceView:e});this._provisionPanel(i,{withBackButton:YES}),this.pushPanel(i),this._ignoresSelection=NO},layoutEditorDidSelectConstraint(t,{withReferenceView:e}){if(this._ignoresSelection)return;let i=YES;this._window&&!this._window._visible&&(i=NO);const o=(new _BMLayoutEditorConstraintSettingsPanel).initWithSettingsView(this,{forConstraint:t,withReferenceView:e});this._provisionPanel(o,{withBackButton:YES}),this.pushPanel(o,{animated:i})},layoutEditorDidSelectSizeClass(t){for(const e of this._panels)e.layoutEditorDidSelectSizeClass(t)},async resetToPanel(t,{animated:e=YES}={animated:YES}){const i=this.currentPanel;for(const t of this._panels)t!=i&&(t.settingsPanelWillUnload(),t._container.release());if(i){if(this._panels=t?[t]:[],i)if(i.settingsPanelWillDisappear(YES),e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"}),i._container.opacity=0,e){BMAnimationContextGetCurrent().controllerForObject(i._container,{node:i._container.node}).registerBuiltInPropertiesWithDictionary({scaleX:.85,scaleY:.85})}else BMHook(i._container.node,{scaleX:.85,scaleY:.85});else t&&e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"});if(t){if(BMAnimationContextBeginStatic(),this._ignoresSelection=YES,t.settingsPanelWillAppear(YES),this._ignoresSelection=NO,t._container.opacity=0,BMHook(t._container.node,{scaleX:1.23,scaleY:1.23}),e&&BMAnimationApply(),e){BMAnimationContextGetCurrent().controllerForObject(t._container,{node:t._container.node}).registerBuiltInPropertiesWithDictionary({scaleX:1,scaleY:1})}else BMHook(t._container.node,{scaleX:1,scaleY:1});t._container.opacity=1}(t||i)&&e&&await BMAnimationApply(),i&&(i.settingsPanelDidDisappear(YES),i.settingsPanelWillUnload(),i._container.release()),t&&t.settingsPanelDidAppear(YES)}else t&&(this._panels.push(t),this._ignoresSelection=YES,t.settingsPanelWillAppear(NO),this._ignoresSelection=NO,t.settingsPanelDidAppear(NO))},async pushPanel(t,{animated:e=YES}={animated:YES}){const i=this.currentPanel;if(this._panels.push(t),i){e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"}),i.settingsPanelWillDisappear(YES);const t=i._container.frame.copy();t.offsetWithX(-t.width/2|0,{y:0}),i._container.frame=t,i._container.opacity=0}else e&&BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"});BMAnimationContextBeginStatic();const o=t._container.frame.copy(),n=o.copy();n.offsetWithX(o.width,{y:0}),t._container.frame=n,BMAnimationApply(),this._ignoresSelection=YES,t.settingsPanelWillAppear(YES),this._ignoresSelection=NO,t._container.frame=o,e&&await BMAnimationApply(),i.settingsPanelDidDisappear(YES),i._container.isVisible=NO,t.settingsPanelDidAppear(YES)},async popPanel(){const t=this.currentPanel;t._container.node.style.pointerEvents="none",this._panels.pop(),BMAnimationBeginWithDuration(200,{easing:"easeInOutQuad"}),t.settingsPanelWillDisappear(YES);const e=this.frame.copy();e.origin=BMPointMake(),e.offsetWithX(e.width,{y:0}),t._container.frame=e;const i=this.currentPanel;if(i){BMAnimationContextBeginStatic();const t=this.frame.copy();t.origin=BMPointMake();const o=t.copy();o.offsetWithX(-e.width/2|0,{y:0}),i._container.frame=o,i._container.opacity=0,i._container.isVisible=YES,BMAnimationApply(),this._ignoresSelection=YES,i.settingsPanelWillAppear(YES),this._ignoresSelection=NO,i._container.frame=t,i._container.opacity=1,i._awaitsLayout&&(BMAnimationContextBeginStatic(),i._titleView.invalidateIntrinsicSize(),i.view.needsLayout=YES,i.view.layoutIfNeeded(),i.settingsPanelDidLayoutView(),i._awaitsLayout=NO,BMAnimationApply())}await BMAnimationApply(),t.settingsPanelDidDisappear(YES),t.settingsPanelWillUnload(),t._container.release(),i&&i.settingsPanelDidAppear(YES)}}),_BMLayoutEditorSettingsView.settingsViewWithNode=function(t,{forEditor:e}){return(new _BMLayoutEditorSettingsView).initWithDOMNode(t,{forEditor:e})},_BMLayoutEditorSettingsPanel.prototype={constructor:_BMLayoutEditorSettingsPanel,_settingsView:void 0,_title:void 0,get title(){return this._title},set title(t){this._title=t,this._titleView&&(this._titleView.node.innerText=t,this._titleView.invalidateIntrinsicSize())},_container:void 0,_titleView:void 0,_view:void 0,get view(){return this._view},get layoutEditor(){return this._settingsView._editor},initWithSettingsView(t){return this._settingsView=t,this},settingsPanelDidLoad(){},settingsPanelDidLayoutView(){},settingsPanelWillAppear(t){},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){},settingsPanelWillUnload(){}},_BMLayoutEditorCollectionSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorSettingsPanel.prototype),{_tabs:void 0,_currentTab:void 0,_configureCollectionViewLayout(t,{forTab:e}){t.node.style.position="absolute",t.layout.expectedCellSize=BMSizeMake(384,e instanceof _BMLayoutEditorViewLayoutSettingsTab?48:32),t.layout.maximumCellsPerRow=1,t.layout.gravity=BMCollectionViewFlowLayoutGravity.Expand,t.layout.rowSpacing=0,t.layout.contentGravity=BMCollectionViewFlowLayoutAlignment.Start,t.layout.showsFooters=YES,t.layout.footerHeight=17,t.layout.topPadding=8,t.identityComparator=(t,e)=>t||e?t&&e?t.isEqualToSetting(e):NO:YES;for(const e in BMLayoutEditorSettingKind)t.registerCellClass(BMLayoutEditorSettingsCell,{forReuseIdentifier:BMLayoutEditorSettingKind[e]});t.registerCellClass(BMLayoutEditorSettingsConstraintCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Constraint}),t.registerCellClass(BMLayoutEditorSettingsTitleCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Title}),t.registerCellClass(BMLayoutEditorSettingsIntegerCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Integer}),t.registerCellClass(BMLayoutEditorSettingsNumberCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Number}),t.registerCellClass(BMLayoutEditorSettingsConstantCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Constant}),t.registerCellClass(BMLayoutEditorSettingsStringCell,{forReuseIdentifier:BMLayoutEditorSettingKind.String}),t.registerCellClass(BMLayoutEditorSettingsBooleanCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Boolean}),t.registerCellClass(BMLayoutEditorSettingsReadonlyCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Info}),t.registerCellClass(BMLayoutEditorSettingsDeleteConstraintCell,{forReuseIdentifier:BMLayoutEditorSettingKind.DeleteConstraintButton}),t.registerCellClass(BMLayoutEditorSettingsDeactivateConstraintsCell,{forReuseIdentifier:BMLayoutEditorSettingKind.DeactivateConstraintsButton}),t.registerCellClass(BMLayoutEditorSettingsSegmentCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Segment}),t.registerCellClass(BMLayoutEditorSettingsViewCell,{forReuseIdentifier:BMLayoutEditorSettingKind.View}),t.registerCellClass(BMLayoutEditorSettingsDropdownCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Enum}),t.registerCellClass(BMLayoutEditorSettingsInsetCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Insets}),t.registerCellClass(BMLayoutEditorSettingsSizeCell,{forReuseIdentifier:BMLayoutEditorSettingKind.Size}),t.registerSupplementaryViewClass(BMLayoutEditorSettingsFooter,{forReuseIdentifier:BMCollectionViewFlowLayoutSupplementaryView.Footer}),t.registerSupplementaryViewClass(BMLayoutEditorSettingsFooter,{forReuseIdentifier:BMCollectionViewFlowLayoutSupplementaryView.Empty});for(const e in this.layoutEditor._settingCellClasses)t.registerCellClass(this.layoutEditor._settingCellClasses[e],{forReuseIdentifier:e})},settingsPanelDidLoad(){const t=BMView.view();t.CSSClass="BMLayoutEditorDetailsTabView",this.view.addSubview(t),t.height.equalTo(48).isActive=YES,t.leading.equalTo(this.view.leading).isActive=YES,t.trailing.equalTo(this.view.trailing).isActive=YES,t.top.equalTo(this.view.top).isActive=YES;const e=BMView.view();this.view.addSubview(e),e.top.equalTo(t.bottom).isActive=YES,e.leading.equalTo(this.view.leading).isActive=YES,e.trailing.equalTo(this.view.trailing).isActive=YES,e.bottom.equalTo(this.view.bottom).isActive=YES;for(const i of this._tabs){const o=BMCollectionView.collectionView();o.allowsOffscreenLayout=NO,e.addSubview(o),this._configureCollectionViewLayout(o,{forTab:i}),o.leading.equalTo(e.leading).isActive=!0,o.trailing.equalTo(e.trailing).isActive=!0,o.top.equalTo(e.top).isActive=!0,o.bottom.equalTo(e.bottom).isActive=!0,i._collectionView=o,o._settingsTab=i,i!=this._currentTab&&(o.isVisible=NO);const n=document.createElement("img");n.className="BMLayoutEditorDetailsTab",n.src=i.icon,t.contentNode.appendChild(n),i==this._currentTab&&n.classList.add("BMLayoutEditorDetailsTabSelected"),i._tabNode=n,n.addEventListener("click",(t=>{n!=this._currentTab&&(this._currentTab._collectionView.isVisible=NO,this._currentTab._tabNode.classList.remove("BMLayoutEditorDetailsTabSelected"),this._currentTab=i,o.isVisible=YES,n.classList.add("BMLayoutEditorDetailsTabSelected"))}))}},settingsPanelDidLayoutView(){for(const t of this._tabs)t.collectionView=t._collectionView},settingsPanelWillUnload(){for(const t of this._tabs)t._collectionView.release(),t._collectionView=void 0},layoutEditorDidSelectSizeClass(t){for(const e of this._tabs)e.layoutEditorDidSelectSizeClass(t)}}),BMLayoutEditorSettingsTab.prototype={name:void 0,icon:void 0,_constraint:void 0,get constraint(){return this._constraint},_view:void 0,get view(){return this._view},_settingSections:void 0,_compiledSettingSections:void 0,_collectionView:void 0,get collectionView(){return this._collectionView},set collectionView(t){this._compiledSettingSections.length=0;for(const t of this._settingSections)this._compiledSettingSections.push(t._compiledSectionForSizeClass(this.layoutEditor.activeSizeClass));this._collectionView=t,t.dataSet=this,t.delegate=this},_settingsPanel:void 0,get layoutEditor(){if(this._settingsPanel)return this._settingsPanel.layoutEditor},initWithName(t,{icon:e}){return this.name=t,this.icon=e,this._settingSections=[],this._compiledSettingSections=[],this},_updateSettingsID:0,async updateSettings(){this._updateSettingsID=this._updateSettingsID+1;const t=this._updateSettingsID;for(;this._collectionView&&this._collectionView.isUpdatingData;)await this._collectionView._dataUpdatePromise;this._updateSettingsID==t&&(this.beginUpdates(),this._settingsPanel._updateSettingsForTab(this),this.commitUpdates())},numberOfSections(){return this._compiledSettingSections.length},numberOfObjectsInSectionAtIndex(t){return this._compiledSettingSections[t]._settings.length+(this._compiledSettingSections[t].name?1:0)},indexPathForObjectAtRow(t,{inSectionAtIndex:e}){return this._compiledSettingSections[e].name?BMIndexPathMakeWithRow(t,0==t?{section:e,forObject:this._compiledSettingSections[e]._nameSetting}:{section:e,forObject:this._compiledSettingSections[e]._settings[t-1]}):BMIndexPathMakeWithRow(t,{section:e,forObject:this._compiledSettingSections[e]._settings[t]})},indexPathForObject(t){for(const[e,i]of this._compiledSettingSections.entries())for(const[o,n]of i._settings.entries()){if(n==i._nameSetting)return BMIndexPathMakeWithRow(0,{section:e,forObject:t});if(n.isEqualToSetting(t))return i.name?BMIndexPathMakeWithRow(o+1,{section:e,forObject:t}):BMIndexPathMakeWithRow(o,{section:e,forObject:t})}},cellForItemAtIndexPath(t){const e=this._collectionView.dequeueCellForReuseIdentifier(t.object.kind);return e.node.classList.add("BMLayoutEditorDetailsCell"),e._tab=this,e.setting=t.object,e},cellForSupplementaryViewWithIdentifier(t,{atIndexPath:e}){const i=this._collectionView.dequeueCellForSupplementaryViewWithIdentifier(t);return i._tab=this,i.section=this._compiledSettingSections[e.section],i},useOldData(t){if(!this._oldData)throw new Error("[BMLayoutEditorSettingsTab] Illegal state - Data update performed outside of a transaction.");this._compiledSettingSections=t?this._oldData:this._newData},isUsingOldData(){if(!this._oldData)throw new Error("[BMLayoutEditorSettingsTab] Illegal state - Data update performed outside of a transaction.");return this._compiledSettingSections===this._oldData},beginUpdates(){this._collectionView&&(this._oldData=this._compiledSettingSections.map((t=>BMLayoutEditorSettingsSection.sectionWithSection(t))),this._compiledSettingSections=[],this._newData=this._compiledSettingSections)},async commitUpdates(){if(!this.layoutEditor)return;if(!this._collectionView)return;for(const t of this._settingSections)this._compiledSettingSections.push(t._compiledSectionForSizeClass(this.layoutEditor.activeSizeClass));for(;this._collectionView.isUpdatingData;)await this._collectionView._dataUpdatePromise;const t=this._collectionView.updateEntireDataAnimated(YES);this._oldData=void 0,this._compiledSettingSections=this._newData,this._newData=void 0,await t},layoutEditorDidSelectSizeClass(t){for(const t of this._settingSections)for(const e of t._settings)if(e.variations&&e.automaticallyExpandsVariations)return this.beginUpdates(),void this.commitUpdates()}},BMLayoutEditorSettingsTab.tabWithName=function(t,{icon:e}){return(new BMLayoutEditorSettingsTab).initWithName(t,{icon:e})},BMLayoutEditorSettingsSection.prototype={_name:void 0,get name(){return this._name},set name(t){this._name=t,t&&(this._nameSetting=BMLayoutEditorSetting.settingWithName(t,{kind:BMLayoutEditorSettingKind.Title,target:this}),this._nameSetting._section=this)},collapsible:NO,_collapsed:NO,get isCollapsed(){return this._collapsed},set isCollapsed(t){this._tab&&(t?this.collapse():this.expand()),this._collapsed=t},_settings:void 0,get settings(){return this._settings.slice()},set settings(t){this._settings=t.slice()},_compiledSectionForSizeClass(t){const e=BMLayoutEditorSettingsSection.section();e._name=this._name,e._nameSetting=this._nameSetting,e.collapsible=e.collapsible,e._settings=[];for(const i of this._settings)if(e._settings.push(i),i.variations){for(const o in i.target._variations){const n=i.target._variations[o];if((n.sizeClass!=t||!i.automaticallyExpandsVariations)&&i.property in n){const t=BMLayoutEditorSetting.settingWithName(i.name,{kind:i.kind,target:i.target,variations:NO,nullable:i.nullable,property:i.property});t._sizeClass=n.sizeClass,t._associatedSetting=i,e._settings.push(t)}}if(i.automaticallyExpandsVariations&&t){const o=BMLayoutEditorSetting.settingWithName(i.name,{kind:i.kind,target:i.target,variations:NO,nullable:YES,property:i.property});o._sizeClass=t,o._associatedSetting=i,e._settings.push(o)}}return e}},BMLayoutEditorSettingsSection.section=function(){const t=new BMLayoutEditorSettingsSection;return t._settings=[],t},BMLayoutEditorSettingsSection.sectionWithSection=function(t){const e=new BMLayoutEditorSettingsSection;return e.name=t.name,e.collapsible=t.collapsible,e._settings=t._settings.slice(),e};var BMLayoutEditorSettingKind=Object.freeze({String:"_String",Integer:"_Integer",Number:"_Number",Boolean:"_Boolean",Size:"_BMSize",Constant:"_Constant",Constraint:"_Constraint",View:"_View",Enum:"_Enum",Segment:"_Segment",Info:"_Info",Title:"_Title",Insets:"_Insets",DeactivateConstraintsButton:"_DeactivateConstraintsButton",DeleteConstraintButton:"_DeleteConstraintButton"});function BMLayoutEditorSetting(){}function BMLayoutEditorEnumSetting(){}BMLayoutEditorSetting.prototype={name:void 0,kind:BMLayoutEditorSettingKind.String,nullable:NO,variations:NO,automaticallyExpandsVariations:NO,_sizeClass:void 0,get sizeClass(){return this._sizeClass},_associatedProperty:void 0,get associatedProperty(){return this._associatedProperty},target:void 0,property:void 0,initWithName(t,{kind:e,target:i,variations:o=NO,nullable:n=NO,property:s}){return this.name=t,this.kind=e,this.target=i,this.variations=o,this.nullable=n,void 0!==s&&(this.property=s),this},isEqualToSetting(t){return t.name==this.name&&t.target==this.target&&t._sizeClass==this._sizeClass&&t.property==this.property}},BMLayoutEditorSetting.settingWithName=function(t,{kind:e,target:i,variations:o=NO,nullable:n=NO,property:s}){return(new this).initWithName(t,{kind:e,target:i,variations:o,nullable:n,property:s})},BMLayoutEditorEnumSetting.prototype=BMExtend(Object.create(BMLayoutEditorSetting.prototype),{options:void 0,initWithName(t,e){return BMLayoutEditorSetting.prototype.initWithName.apply(this,arguments),this.options=[],this}}),BMLayoutEditorEnumSetting.settingWithName=BMLayoutEditorSetting.settingWithName;const BMLayoutEdittorSettingCellRowSpacing=2;function BMLayoutEditorSettingsTitleView(){}function BMLayoutEditorSettingsFooter(){}function BMLayoutEditorSettingsCell(){}function BMLayoutEditorSettingsConstraintCell(){}function BMLayoutEditorSettingsDeactivateConstraintsCell(){}function BMLayoutEditorSettingsDeleteConstraintCell(){}function BMLayoutEditorSettingsTitleCell(){}function BMLayoutEditorSettingsReadonlyCell(){}function BMLayoutEditorSettingsViewCell(){}function BMLayoutEditorSettingsSegmentCell(){}function BMLayoutEditorSettingsBooleanCell(){}function BMLayoutEditorSettingsDropdownCell(){}function BMLayoutEditorSettingsInputCell(){}function BMLayoutEditorSettingsIntegerCell(){}function BMLayoutEditorSettingsNumberCell(){}function BMLayoutEditorSettingsStringCell(){}function BMLayoutEditorSettingsConstantCell(){}function BMLayoutEditorSettingsSizeCell(){}function BMLayoutEditorSettingsInsetCell(){}function _BMLayoutEditorViewSettingsPanel(){}function _BMLayoutEditorViewLayoutSettingsTab(){}function _BMLayoutEditorViewGroupSettingsPanel(){}function _BMLayoutEditorConstraintSettingsPanel(){}function _BMLayoutEditorConstraintSettingsTab(){}BMLayoutEditorSettingsTitleView.prototype=BMExtend(Object.create(BMView.prototype),{constructor:BMLayoutEditorSettingsTitleView,_titleLabel:void 0,_badge:void 0,_button:void 0,_title:void 0,get title(){return this._title},set title(t){this._title=t,this._titleLabel.node.innerText=t,this._titleLabel.invalidateIntrinsicSize()},_setting:void 0,get setting(){return this._setting},set setting(t){if(this._setting=t,t.sizeClass){switch(t.sizeClass){case BMLayoutSizeClass.phoneSizeClass():this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Portrait):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhonePortraitMini";break;case BMLayoutSizeClass.phoneSizeClassWithOrientation(BMLayoutOrientation.Landscape):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImagePhoneLandscapeMini";break;case BMLayoutSizeClass.tabletSizeClass():this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Portrait):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletPortraitMini";break;case BMLayoutSizeClass.tabletSizeClassWithOrientation(BMLayoutOrientation.Landscape):this._badge.node.className="BMLayoutEditorDetailsItemBadgeIcon BMLayoutEditorImageTabletLandscapeMini";break;default:this._badge.node.className="BMLayoutEditorDetailsItemBadge",this._badge.node.innerText=t.sizeClass._hashString}this._button.node.innerHTML='<i class="material-icons">remove_circle</i>',this._button.isVisible=YES,this._badgeWidthConstraint.constant=16,this._buttonWidthConstraint.constant=24}else this._badge.node.className="",t.variations?(this._button.node.innerHTML='<i class="material-icons">add_circle</i>',this._button.isVisible=YES,this._buttonWidthConstraint.constant=24):(this._button.node.innerHTML="",this._button.isVisible=NO,this._buttonWidthConstraint.constant=0),this._badgeWidthConstraint.constant=0;this._badge.invalidateIntrinsicSize(),this.title=t.name+":"},initWithDOMNode(){BMView.prototype.initWithDOMNode.apply(this,arguments),this.debuggingName="TitleView";const t=this._titleLabel=BMView.view();t.debuggingName="TitleViewLabel",t.supportsAutomaticIntrinsicSize=YES,t.node.className="BMLayoutEditorDetailsTitleCell",this.addSubview(t),t.trailing.equalTo(this.trailing).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.compressionResistance=700;const e=this._badge=BMView.view();e.debuggingName="TitleViewBadge",e.supportsAutomaticIntrinsicSize=YES,this.addSubview(e),t.leading.equalTo(e.trailing,{plus:4}).isActive=YES,e.centerY.equalTo(t.centerY).isActive=YES,this._badgeWidthConstraint=e.width.greaterThanOrEqualTo(16),this._badgeWidthConstraint.isActive=YES,e.height.greaterThanOrEqualTo(16).isActive=YES;const i=this._button=BMView.view();return i.debuggingName="TitleViewButton",i.node.className="BMLayoutEditorDetailsItemVariationsButton",this.addSubview(i),i.leading.equalTo(this.leading).isActive=YES,e.leading.greaterThanOrEqualTo(i.trailing,{plus:4}).isActive=YES,i.centerY.equalTo(t.centerY).isActive=YES,this._buttonWidthConstraint=i.width.equalTo(24),this._buttonWidthConstraint.isActive=YES,i.height.equalTo(24).isActive=YES,i.node.addEventListener("click",(t=>this.variationsButtonClickedWithEvent(t))),this},variationsButtonClickedWithEvent(t){this.setting.sizeClass?(this.setting.target[`remove${BMStringByCapitalizingString(this.setting.property)}VariationForSizeClass`](this.setting.sizeClass),this.rootView.setting=this.rootView.setting,this.rootView.tab.updateSettings()):this.rootView.layoutEditor._showSizeClassMenuAtPoint(BMPointMake(t.clientX,t.clientY),{kind:BMMenuKind.Menu,action:t=>{this.setting.target._variations&&this.setting.target._variations[t]&&this.setting.property in this.setting.target._variations[t]||(this.setting.target[`set${BMStringByCapitalizingString(this.setting.property)}`](this.setting.target[this.setting.property],{forSizeClass:t}),this.rootView.tab.updateSettings())}})}}),BMLayoutEditorSettingsTitleView.titleView=function(){return(new BMLayoutEditorSettingsTitleView).initWithDOMNode(document.createElement("div"))},BMLayoutEditorSettingsFooter.prototype=BMExtend(Object.create(BMCollectionViewCell.prototype),{constructor:BMLayoutEditorSettingsFooter,initWithCollectionView(){BMCollectionViewCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();this.addSubview(t),t.leading.equalTo(this.leading).isActive=YES,t.trailing.equalTo(this.trailing).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES;const e=BMView.view();return t.addSubview(e),e.node.className="BMLayoutEditorDetailsDividerCell",e.leading.equalTo(t.leading).isActive=YES,e.trailing.equalTo(t.trailing).isActive=YES,e.height.equalTo(1).isActive=YES,e.centerY.equalTo(t.centerY).isActive=YES,this}}),BMLayoutEditorSettingsCell.prototype=BMExtend(Object.create(BMCollectionViewCell.prototype),{constructor:BMLayoutEditorSettingsCell,_contentView:void 0,get contentView(){return this._contentView},initWithCollectionView(){BMCollectionViewCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return t.debuggingName="ContentView",this._contentView=t,this.addSubview(t),this.constructor===BMLayoutEditorSettingsCell&&(t.node.innerText="This is a test!",t.node.style.color="white"),t.leading.equalTo(this.leading).isActive=YES,t.trailing.equalTo(this.trailing).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.height.greaterThanOrEqualTo(32,{priority:750}).isActive=YES,this},_setting:void 0,get setting(){return this._setting},set setting(t){this._setting=t,this.cellDidBindToSetting(t)},_tab:void 0,get tab(){return this._tab},get settingsView(){const t=this.tab;if(t)return t._settingsPanel._settingsView},get layoutEditor(){const t=this.tab;if(t)return t.layoutEditor},cellDidBindToSetting(t){}}),BMLayoutEditorSettingsConstraintCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsConstraintCell,_constraintView:void 0,_constraintViewLeading:void 0,initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return t.debuggingName="ConstraintView",this._constraintView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,this._constraintViewLeading=t.leading.equalTo(this.leading,{plus:8}),this._constraintViewLeading.isActive=YES,t.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,t.top.equalTo(this.top,{plus:8}).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.node.className="BMLayoutEditorDetailsConstraintItem BMLayoutEditorDetailsConstraintItemCell BMCollectionViewCellEventHandler",t.node.addEventListener("click",(t=>{const e=this.setting.target;e._internal||this.settingsView.selectConstraint(e,{withReferenceView:this.tab._displayedView})})),this},cellDidBindToSetting(t){const e=this._constraintView.node,i=t.target;e.innerText=i.descriptionRelativeToView(this.tab._displayedView);const o=document.createElement("img");if(o.className="BMLayoutEditorDetailsConstraintIcon",i.isConstraintCollection)o.src=_BMURLOfImageAtPath("images/OwnConstraints.png");else{switch(i[i._sourceView==this.tab._displayedView?"_sourceViewAttribute":"_targetViewAttribute"]){case BMLayoutAttribute.Left:case BMLayoutAttribute.Leading:o.src=_BMURLOfImageAtPath("images/LeftConstraint.png");break;case BMLayoutAttribute.Right:case BMLayoutAttribute.Trailing:o.src=_BMURLOfImageAtPath("images/RightConstraint.png");break;case BMLayoutAttribute.CenterX:o.src=_BMURLOfImageAtPath("images/CenterXConstraint.png");break;case BMLayoutAttribute.CenterY:o.src=_BMURLOfImageAtPath("images/CenterYConstraint.png");break;case BMLayoutAttribute.Top:o.src=_BMURLOfImageAtPath("images/TopConstraint.png");break;case BMLayoutAttribute.Bottom:o.src=_BMURLOfImageAtPath("images/BottomConstraint.png");break;case BMLayoutAttribute.Width:o.src=_BMURLOfImageAtPath("images/WidthConstraint.png");break;case BMLayoutAttribute.Height:o.src=_BMURLOfImageAtPath("images/HeightConstraint.png")}}return e.insertBefore(o,e.firstChild),i._priority>500&&i._priority<1e3?(e.classList.add("BMLayoutEditorDetailsConstraintItemStrong"),e.classList.remove("BMLayoutEditorDetailsConstraintItemWeak")):i._priority<=500?(e.classList.remove("BMLayoutEditorDetailsConstraintItemStrong"),e.classList.add("BMLayoutEditorDetailsConstraintItemWeak")):(e.classList.remove("BMLayoutEditorDetailsConstraintItemStrong"),e.classList.remove("BMLayoutEditorDetailsConstraintItemWeak")),i._internal?e.classList.add("BMLayoutEditorDetailsConstraintItemReadonly"):e.classList.remove("BMLayoutEditorDetailsConstraintItemReadonly"),i._configuration.isActive?e.classList.remove("BMLayoutEditorDetailsConstraintItemInactive"):e.classList.add("BMLayoutEditorDetailsConstraintItemInactive"),this._constraintView.invalidateIntrinsicSize(),e}}),BMLayoutEditorSettingsDeactivateConstraintsCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsDeactivateConstraintsCell,_buttonView:void 0,prepareForDisplay(){window.addEventListener("keydown",this._keyboardModifier,YES),window.addEventListener("keyup",this._keyboardModifier,YES)},prepareForReuse(){window.removeEventListener("keydown",this._keyboardModifier,YES),window.removeEventListener("keyup",this._keyboardModifier,YES)},invalidate(){window.removeEventListener("keydown",this._keyboardModifier,YES),window.removeEventListener("keyup",this._keyboardModifier,YES)},initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();t.debuggingName="DeactivateButton",this._buttonView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,t.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,t.trailing.equalTo(this.contentView.trailing,{plus:-32}).isActive=YES,t.top.equalTo(this.contentView.top,{plus:8}).isActive=YES,t.bottom.equalTo(this.contentView.bottom,{plus:-8}).isActive=YES,t.node.className="BMWindowButton BMCollectionViewCellEventHandler",t.node.style.boxSizing="border-box",t.node.style.textAlign="center",t.node.style.pointer="default",t.node.style.margin=0,t.node.innerText="Deactivate Constraints";let e=NO,i=NO,o=NO;return t.node.addEventListener("click",(t=>{if(e&&i&&o)new Set(this.setting.target._view.rootView.allConstraints).forEach((t=>t.remove()));else if(e)for(let t of this.setting.target._view.localConstraints)i?t.remove():this._activeSizeClass?t.setIsActive(NO,{forSizeClass:this._activeSizeClass}):t.isActive=NO;else{const t=this.tab._constraintCategories;Object.keys(t).forEach((e=>{for(let o of t[e])i?o.remove():this.layoutEditor._activeSizeClass?o.setIsActive(NO,{forSizeClass:this.layoutEditor._activeSizeClass}):o.isActive=NO}))}this.tab._updateSettings()})),t.node.addEventListener("contextmenu",(t=>t.preventDefault())),this._keyboardModifier=n=>{switch(n.key){case"Alt":e="keydown"==n.type;break;case"Shift":i="keydown"==n.type;break;case"Control":o="keydown"==n.type}t.node.innerText=e?i?o?"Reset Layout":"Remove All Constraints":"Deactivate All Constraints":i?"Remove Constraints":"Deactivate Constraints"},this},cellDidBindToSetting(t){}}),BMLayoutEditorSettingsDeleteConstraintCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsDeleteConstraintCell,_buttonView:void 0,initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return this._buttonView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,t.debuggingName="DeleteConstraintsButton",t.leading.equalTo(this.contentView.leading,{plus:32}).isActive=YES,t.trailing.equalTo(this.contentView.trailing,{plus:-32}).isActive=YES,t.top.equalTo(this.contentView.top,{plus:8}).isActive=YES,t.bottom.equalTo(this.contentView.bottom,{plus:-8}).isActive=YES,t.node.className="BMWindowButton BMCollectionViewCellEventHandler",t.node.style.boxSizing="border-box",t.node.style.textAlign="center",t.node.style.pointer="default",t.node.style.margin=0,t.node.innerText="Delete Constraint",t.node.addEventListener("click",(t=>{this.setting.target.remove(),this.layoutEditor.selectView(this.tab._settingsPanel._referenceView)})),t.node.addEventListener("contextmenu",(t=>t.preventDefault())),this},cellDidBindToSetting(t){}}),BMLayoutEditorSettingsTitleCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsTitleCell,_titleView:void 0,initWithCollectionView(){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const t=BMView.view();return this._titleView=t,this.contentView.addSubview(t),t.supportsAutomaticIntrinsicSize=YES,t.debuggingName="TitleView",t.leading.equalTo(this.leading,{plus:8}).isActive=YES,t.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,t.top.equalTo(this.top).isActive=YES,t.bottom.equalTo(this.bottom).isActive=YES,t.node.className="BMLayoutEditorDetailsTitleCell",this},cellDidBindToSetting(t){this._titleView.node.innerText=t.name,this._titleView.invalidateIntrinsicSize()}}),BMLayoutEditorSettingsReadonlyCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsReadonlyCell,_titleView:void 0,get titleView(){return this._titleView},_inputView:void 0,get inputView(){return this._inputView},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMView.view();this._titleView=i,this.contentView.addSubview(i),i.supportsAutomaticIntrinsicSize=YES,i.debuggingName="TitleView",i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.top.equalTo(this.top,{plus:2}).isActive=YES,i.node.className="BMLayoutEditorDetailsTitleCell",i.node.style.textAlign="right",i.height.greaterThanOrEqualTo(24).isActive=YES,i.node.style.cssText="vertical-align: middle; line-height: 24px; text-align: right;";const o=document.createElement("div");o.className="BMLayoutEditorDetailsItemReadonlyValue BMLayoutEditorDetailsItemReadonlyValueCell",o.style.cssText="padding-left: 8px !important";const n=BMView.viewForNode(o);return this._inputView=n,n.supportsAutomaticIntrinsicSize=YES,n.debuggingName="LabelView",this.contentView.addSubview(n),n.leading.equalTo(i.trailing,{plus:8}).isActive=YES,n.width.greaterThanOrEqualTo(200).isActive=YES,n.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES,n.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,n.top.equalTo(this.top,{plus:2}).isActive=YES,n.height.greaterThanOrEqualTo(24).isActive=YES,n.bottom.equalTo(this.bottom,{plus:-2}).isActive=YES,this},cellDidBindToSetting(t){this._titleView.node.innerText=t.name+":",this._titleView.invalidateIntrinsicSize(),this._inputView.node.innerText=t.target[t.property],this._inputView.invalidateIntrinsicSize()}}),BMLayoutEditorSettingsViewCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsReadonlyCell.prototype),{constructor:BMLayoutEditorSettingsViewCell,initWithCollectionView(t,e){return BMLayoutEditorSettingsReadonlyCell.prototype.initWithCollectionView.apply(this,arguments),this._inputView.node.classList.add("BMLayoutEditorDetailsItemReadonlyValueClickable"),this._inputView.node.addEventListener("click",(t=>{this.settingsView.selectView(this.setting.target[this.setting.property])})),this._inputView.node.style.cssText+="margin: 0px !important;",this},cellDidBindToSetting(t){this._titleView.node.innerText=t.name+":",this._titleView.invalidateIntrinsicSize();const e=t.target[t.property],i=document.createElement("span");i.innerText="›",i.className="BMLayoutEditorDetailsItemViewLink BMCollectionViewCellEventHandler";const o=document.createElement("span");o.innerText=" "+(e.debuggingName||e.node.id),this._inputView.node.innerHTML="",this._inputView.node.appendChild(i),this._inputView.node.appendChild(o)}}),BMLayoutEditorSettingsSegmentCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsSegmentCell,_currentMenuItem:void 0,initWithCollectionView(t,e){return BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments),this.contentView.CSSClass="BMLayoutEditorDetailsTabView BMLayoutEditorDetailsSegmentControl",this.contentView.height.equalTo(48).isActive=YES,this.contentView.width.equalTo(1024,{priority:750}).isActive=YES,this},cellDidBindToSetting(t){this.contentView.contentNode.innerHTML="";for(const e of t.options){const i=document.createElement("img");i.className="BMLayoutEditorDetailsTab BMCollectionViewCellEventHandler",i.src=e.icon,this.contentView.contentNode.appendChild(i),i.title=e.name,e.userInfo==t.target[t.property]&&(this._currentMenuItem=e,i.classList.add("BMLayoutEditorDetailsTabSelected")),e._tabNode=i,i.addEventListener("click",(o=>{e!=this._currentMenuItem&&(this._currentMenuItem._tabNode.classList.remove("BMLayoutEditorDetailsTabSelected"),this._currentMenuItem=e,i.classList.add("BMLayoutEditorDetailsTabSelected"),t.target[t.property]=e.userInfo)}))}}}),BMLayoutEditorSettingsBooleanCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsBooleanCell,_titleView:void 0,get titleView(){return this._titleView},_labelView:void 0,get labelView(){return this._labelView},_inputNode:void 0,initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMLayoutEditorSettingsTitleView.titleView();this._titleView=i,this.contentView.addSubview(i),i.debuggingName="TitleView",i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.centerY.equalTo(this.centerY).isActive=YES;const o=BMView.view();o.debuggingName="BooleanContainer",this.contentView.addSubview(o),o.leading.equalTo(i.trailing,{plus:8}).isActive=YES,o.trailing.equalTo(this.contentView.trailing,{plus:-8}).isActive=YES,o.top.equalTo(this.contentView.top,{plus:2}).isActive=YES,o.bottom.equalTo(this.contentView.bottom,{plus:-2}).isActive=YES,o.width.greaterThanOrEqualTo(200).isActive=YES,o.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES;let n=document.createElement("label");n.className="BMWindowSwitch",n.style.margin="0",n.innerHTML='<input type="checkbox" data-toggle="YES"> OFF\n <div class="BMWindowSwitchGutter">\n <div class="BMWindowSwitchKnob"></div>\n </div>\n ON',this._labelView=BMView.viewForNode(n),o.addSubview(this._labelView),this._labelView.supportsAutomaticIntrinsicSize=YES,this._labelView.debuggingName="BooleanSwitch",this._labelView.centerY.equalTo(o.centerY).isActive=YES,this._labelView.leading.equalTo(o.leading).isActive=YES,this._labelView.width.equalTo(104).isActive=YES,this._labelView.height.equalTo(20).isActive=YES;let s=n.getElementsByTagName("input")[0];return this._inputNode=s,n.addEventListener("click",(t=>{this.setting.nullable&&t.target!==s&&s.checked&&(t.preventDefault(),t.stopPropagation(),s.indeterminate?(s.indeterminate=NO,s.checked=NO,this.inputValueDidChangeWithEvent(t,{toValue:NO})):(s.indeterminate=YES,this.inputValueDidChangeWithEvent(t,{toValue:void 0})))})),s.addEventListener("change",(t=>{let e=Boolean(t.target.checked);this.setting.nullable&&s.indeterminate&&(e=void 0),this.inputValueDidChangeWithEvent(t,{toValue:e})})),this},inputValueDidChangeWithEvent(t,{toValue:e}){const i=this.setting;i.sizeClass?void 0===e?i.target[`remove${BMStringByCapitalizingString(i.property)}VariationForSizeClass`](i.sizeClass):i.target[`set${BMStringByCapitalizingString(i.property)}`](e,{forSizeClass:i.sizeClass}):i.target[i.property]=e},cellDidBindToSetting(t){let e;e=t.sizeClass?t.target._variations[t.sizeClass]?t.target._variations[t.sizeClass][t.property]:void 0:t.target[t.property],void 0===e&&t.nullable?(this._inputNode.indeterminate=YES,this._inputNode.checked=YES):(this._inputNode.indeterminate=NO,this._inputNode.checked=e),this._titleView.setting=t}}),BMLayoutEditorSettingsDropdownCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsDropdownCell,_titleView:void 0,get titleView(){return this._titleView},_select:void 0,get inputView(){return this._select},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMLayoutEditorSettingsTitleView.titleView();this._titleView=i,i.debuggingName="TitleView",this.contentView.addSubview(i),i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.centerY.equalTo(this.centerY).isActive=YES;const o=document.createElement("select");o.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue BMLayoutEditorDetailsDropdown";const n=BMView.viewForNode(o);return n.debuggingName="DropdownView",this._inputView=n,this.contentView.addSubview(n),n.leading.equalTo(i.trailing,{plus:8}).isActive=YES,n.width.greaterThanOrEqualTo(200).isActive=YES,n.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,n.height.equalTo(24).isActive=YES,n.centerY.equalTo(this.centerY).isActive=YES,n.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES,o.addEventListener("change",(t=>{this._bound&&this.inputValueDidChangeWithEvent(t)})),o.addEventListener("focus",(t=>this.retain())),o.addEventListener("blur",(t=>this.release())),this},inputValueDidChangeWithEvent(t){const e=this.setting,i=JSON.parse(this._inputView.node.value);e.sizeClass?e.target[`set${BMStringByCapitalizingString(e.property)}`](i,{forSizeClass:e.sizeClass}):e.target[e.property]=i},cellDidBindToSetting(t){this._inputView.node.innerHTML="";for(const e of t.options){const t=document.createElement("option");t.value=JSON.stringify(e.userInfo),t.innerText=e.name,this._inputView.node.appendChild(t)}this._inputView.node.value=t.sizeClass?JSON.stringify(t.target._variations[t.sizeClass][t.property]):JSON.stringify(t.target[t.property]),this._titleView.setting=t}}),BMLayoutEditorSettingsInputCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsInputCell,_titleView:void 0,get titleView(){return this._titleView},_inputView:void 0,get inputView(){return this._inputView},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},get nullValue(){return""},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments);const i=BMLayoutEditorSettingsTitleView.titleView();this._titleView=i,this.contentView.addSubview(i),i.debuggingName="TitleView",i.leading.equalTo(this.leading,{plus:8}).isActive=YES,i.centerY.equalTo(this.centerY).isActive=YES;const o=document.createElement("input");o.className="BMWindowInput BMLayoutEditorDetailsCellInput "+e.inputClasses,o.type=e.inputKind;const n=BMView.viewForNode(o);return this._inputView=n,n.debuggingName="InputView",this.contentView.addSubview(n),n.leading.equalTo(i.trailing,{plus:8}).isActive=YES,n.width.greaterThanOrEqualTo(200).isActive=YES,n.trailing.equalTo(this.trailing,{plus:-8}).isActive=YES,n.centerY.equalTo(this.centerY).isActive=YES,n.height.equalTo(24).isActive=YES,n.width.equalTo(i.width,{times:1.5,priority:600}).isActive=YES,o.addEventListener("input",(t=>{this._bound&&this.inputValueDidChangeWithEvent(t)})),o.addEventListener("paste",(t=>{this._bound&&this.inputValueDidChangeWithEvent(t)})),o.addEventListener("focus",(t=>this.retain())),o.addEventListener("blur",(t=>this.release())),this},get value(){return this._inputView.node.value},inputValueDidChangeWithEvent(t){const e=this.setting;if(e.sizeClass){const t=this.value;void 0===t||""===t||t===this.nullValue?e.target[`remove${BMStringByCapitalizingString(e.property)}VariationForSizeClass`](e.sizeClass):e.target[`set${BMStringByCapitalizingString(e.property)}`](t,{forSizeClass:e.sizeClass})}else e.target[e.property]=this.value},cellDidBindToSetting(t){if(t.sizeClass)t.target._variations[t.sizeClass]&&t.property in t.target._variations[t.sizeClass]?this._inputView.node.value=t.target._variations[t.sizeClass][t.property]:this._inputView.node.value=this.nullValue;else{const e=t.target[t.property];this._inputView.node.value=void 0===e?this.nullValue:t.target[t.property]}this._titleView.setting=t}}),BMLayoutEditorSettingsIntegerCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsIntegerCell,initWithCollectionView(t,e){return e.inputKind="number",e.inputClasses="BMLayoutEditorDetailsItemNumericValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments),this._inputView.node.step=1,this},get value(){const t=parseInt(this._inputView.node.value,10);return isNaN(t)?0:t},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)}}),BMLayoutEditorSettingsNumberCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsNumberCell,initWithCollectionView(t,e){return e.inputKind="number",e.inputClasses="BMLayoutEditorDetailsItemNumericValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments)},get value(){const t=parseFloat(this._inputView.node.value);return isNaN(t)?0:t},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)}}),BMLayoutEditorSettingsStringCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsStringCell,initWithCollectionView(t,e){return e.inputKind="text",e.inputClasses="BMLayoutEditorDetailsItemTextValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments)},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)}}),BMLayoutEditorSettingsConstantCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsInputCell.prototype),{constructor:BMLayoutEditorSettingsConstantCell,get nullValue(){return""},initWithCollectionView(t,e){e.inputKind="text",e.inputClasses="BMLayoutEditorDetailsItemTextValue",BMLayoutEditorSettingsInputCell.prototype.initWithCollectionView.apply(this,arguments);const i=this._inputView.node;let o,n,s=[],a=[];return i.addEventListener("focus",(async t=>{i.select(),s=[];const e=Object.keys(this.layoutEditor.layoutVariableProvider.layoutVariables),r=new Set;e.forEach((t=>r.add(t)));let l=[];for(const t of r)s.unshift(t),s.push("-"+t);a=s,n=-1;for(const t of s)l.push(this.layoutEditor.constraintOptionWithLabel(t,{action:()=>{o=void 0,i.value=t,i.dispatchEvent(new Event("input")),i.blur()}}));if(s.length){if(this._delaysSuggestionsDropdown){const t=this.layoutEditor._createMenuWithOptions(l);o=t.children[0],setTimeout((()=>{if(document.activeElement==i){let e=BMRectMakeWithNodeFrame(i),o=BMPointMake(e.origin.x,e.bottom);this.layoutEditor.showMenuAtPoint(o,{menu:t,kind:BMMenuKind.PullDownMenu})}}),200)}else{let t=BMRectMakeWithNodeFrame(i),e=BMPointMake(t.origin.x,t.bottom);o=this.layoutEditor.showMenuAtPoint(e,{withOptions:l,kind:BMMenuKind.PullDownMenu})}o.classList.add("BMLayoutEditorConstantSuggestions"),o.parentNode.classList.add("BMLayoutEditorConstantSuggestionsOverlay"),o.addEventListener("mousedown",(t=>t.preventDefault()),YES)}const h=t=>t.preventDefault();i.addEventListener("mouseup",h),await new Promise((t=>setTimeout(t,200))),i.removeEventListener("mouseup",h)})),i.addEventListener("keydown",(t=>{if("ArrowDown"==t.code||"ArrowUp"==t.code){if(t.preventDefault(),0==a.length)return;n="ArrowUp"==t.code?Math.max((n||0)-1,0):Math.min((isNaN(n)?-1:n)+1,a.length-1);for(const t of o.querySelectorAll(".BMLayoutEditorConstraintPopupOptionHighlighted"))t.classList.remove("BMLayoutEditorConstraintPopupOptionHighlighted");o.childNodes[n].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted")}"Enter"==t.code&&(!isNaN(n)&&a.length&&(i.value=a[n],i.dispatchEvent(new Event("input"))),i.blur())})),i.addEventListener("input",(t=>{const r=this.tab._settingsPanel._referenceView,l=this._setting.target,h="constant",c="Constant";if(!r||!l)return;const d=parseFloat(i.value),u=isNaN(d)?i.value:d;if(o){a=s.filter((t=>t.toLowerCase().startsWith(i.value.toLowerCase()))),o.innerHTML="",n=0;for(const t of a)o.appendChild(this.layoutEditor.constraintOptionWithLabel(t,{action:()=>{o=void 0,i.value=t,i.dispatchEvent(new Event("input"))}}));a.length?(o.childNodes[0].classList.add("BMLayoutEditorConstraintPopupOptionHighlighted"),o.style.display="block"):o.style.display="none"}i.value?l?(this.setting.sizeClass?l[`set${c}`](u,{forSizeClass:this.setting.sizeClass}):l[h]=u,l._updateConfiguration(),l._constraint=void 0,l._constituentConstraints=void 0,l._sourceView?l._sourceView.needsLayout=YES:l._views[0].needsLayout=YES):(this.setting.sizeClass?r[`set${c}`](d,{forSizeClass:this.setting.sizeClass}):r[h]=d,r.needsLayout=YES):e.sizeClass&&(l?(l[`remove${c}VariationForSizeClass`](e.sizeClass),l._updateConfiguration()):(r[`remove${c}VariationForSizeClass`](e.sizeClass),r._updateConfiguration()))})),i.addEventListener("blur",(t=>{o&&o.parentNode.dispatchEvent(new Event("click"))})),this},cellDidBindToSetting(t){BMLayoutEditorSettingsInputCell.prototype.cellDidBindToSetting.apply(this,arguments)},inputValueDidChangeWithEvent(t){}}),BMLayoutEditorSettingsSizeCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsSizeCell,_titleView:void 0,get titleView(){return this._titleView},_widthInputView:void 0,get widthInputView(){return this._widthInputView},_heightInputView:void 0,get heightInputView(){return this._heightInputView},_indicator:void 0,get indicator(){return this._indicator},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},_createInputView(){const t=document.createElement("input");t.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue",t.type="number";const e=BMView.viewForNode(t);return e.debuggingName="InputView",e.supportsAutomaticIntrinsicSize=YES,e},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments),this._titleView=BMLayoutEditorSettingsTitleView.titleView(),this.contentView.addSubview(this._titleView),this._titleView.leading.equalTo(this.contentView.leading,{plus:8}).isActive=YES,this._titleView.top.equalTo(this.contentView.top,{plus:4}).isActive=YES,this._indicator=BMView.view(),this._indicator.node.className="BMLayoutEditorDetailsBoxIndicator";const i=document.createElement("div");i.className="BMLayoutEditorDetailsWidthIndicator",this._indicator.node.appendChild(i);const o=document.createElement("div");return o.className="BMLayoutEditorDetailsHeightIndicator",this._indicator.node.appendChild(o),this.contentView.addSubview(this._indicator),this._indicator.height.equalTo(40).isActive=YES,this._indicator.width.equalTo(40).isActive=YES,this._widthInputView=this._createInputView(),this.contentView.addSubview(this._widthInputView),this._widthInputView.width.equalTo(64).isActive=YES,this._widthInputView.node.style.textAlign="center",this._heightInputView=this._createInputView(),this.contentView.addSubview(this._heightInputView),this._heightInputView.width.equalTo(64).isActive=YES,this._heightInputView.node.style.textAlign="right",this._widthInputView.top.equalTo(this._titleView.bottom,{plus:-4}).isActive=YES,this._indicator.top.equalTo(this._widthInputView.bottom,{plus:12}).isActive=YES,this._indicator.bottom.lessThanOrEqualTo(this.contentView.bottom,{plus:-4}).isActive=YES,this._heightInputView.centerY.equalTo(this._indicator.centerY).isActive=YES,this._indicator.centerX.equalTo(this.contentView.centerX,{priority:750}).isActive=YES,this._indicator.leading.equalTo(this._heightInputView.trailing,{plus:12}).isActive=YES,this._widthInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this.contentView.trailing.greaterThanOrEqualTo(this._indicator.trailing,{plus:8}).isActive=YES,[this._widthInputView,this._heightInputView].forEach((t=>{const e=t.node;e.addEventListener("input",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("paste",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("focus",(t=>this.retain())),e.addEventListener("blur",(t=>this.release()))})),this},cellDidBindToSetting(t){let e;this._titleView.setting=t,t.sizeClass?t.target._variations[t.sizeClass]&&t.property in t.target._variations[t.sizeClass]&&t.target._variations[t.sizeClass][t.property]:e=t.target[t.property],e?(this._widthInputView.node.value=e.width,this._heightInputView.node.value=e.height):(this._widthInputView.node.value="",this._heightInputView.node.value="")},_inputValueDidChangeWithEvent(t){const e=this.setting,i=parseInt(this._widthInputView.node.value,10),o=parseInt(this._heightInputView.node.value,10);let n=isNaN(i)||isNaN(o)?void 0:BMSizeMake(i,o);e.nullable||n||(n=BMSizeMake()),this.layoutEditor.setValue(n,{forSetting:e})}}),BMLayoutEditorSettingsInsetCell.prototype=BMExtend(Object.create(BMLayoutEditorSettingsCell.prototype),{constructor:BMLayoutEditorSettingsInsetCell,_titleView:void 0,get titleView(){return this._titleView},_leftInputView:void 0,get leftInputView(){return this._leftInputView},_topInputView:void 0,get heightInputView(){return this._topInputView},_rightInputView:void 0,get rightInputView(){return this._rightInputView},_bottomInputView:void 0,get bottomInputView(){return this._bottomInputView},_indicator:void 0,get indicator(){return this._indicator},_bound:NO,prepareForReuse(){this._bound=NO},prepareForDisplay(){this._bound=YES},_createInputView(){const t=document.createElement("input");t.className="BMWindowInput BMLayoutEditorDetailsCellInput BMLayoutEditorDetailsItemNumericValue",t.type="number";const e=BMView.viewForNode(t);return e.debuggingName="InputView",e.supportsAutomaticIntrinsicSize=YES,e},initWithCollectionView(t,e){BMLayoutEditorSettingsCell.prototype.initWithCollectionView.apply(this,arguments),this._titleView=BMLayoutEditorSettingsTitleView.titleView(),this.contentView.addSubview(this._titleView),this._titleView.leading.equalTo(this.contentView.leading,{plus:8}).isActive=YES,this._titleView.top.equalTo(this.contentView.top,{plus:4}).isActive=YES,this._indicator=BMView.view(),this._indicator.node.className="BMLayoutEditorDetailsBoxIndicator";const i=document.createElement("div");i.className="BMLayoutEditorDetailsInsetTopLeftIndicator",this._indicator.node.appendChild(i);const o=document.createElement("div");return o.className="BMLayoutEditorDetailsInsetBottomRightIndicator",this._indicator.node.appendChild(o),this.contentView.addSubview(this._indicator),this._indicator.height.equalTo(48).isActive=YES,this._indicator.width.equalTo(48).isActive=YES,this._leftInputView=this._createInputView(),this.contentView.addSubview(this._leftInputView),this._leftInputView.width.equalTo(64).isActive=YES,this._leftInputView.node.style.textAlign="right",this._topInputView=this._createInputView(),this.contentView.addSubview(this._topInputView),this._topInputView.width.equalTo(64).isActive=YES,this._topInputView.node.style.textAlign="center",this._rightInputView=this._createInputView(),this.contentView.addSubview(this._rightInputView),this._rightInputView.width.equalTo(64).isActive=YES,this._bottomInputView=this._createInputView(),this.contentView.addSubview(this._bottomInputView),this._bottomInputView.width.equalTo(64).isActive=YES,this._bottomInputView.node.style.textAlign="center",this._topInputView.top.equalTo(this._titleView.bottom,{plus:-4}).isActive=YES,this._indicator.top.equalTo(this._topInputView.bottom,{plus:4}).isActive=YES,this._bottomInputView.top.equalTo(this._indicator.bottom,{plus:4}).isActive=YES,this._bottomInputView.bottom.lessThanOrEqualTo(this.contentView.bottom,{plus:-4}).isActive=YES,this._leftInputView.centerY.equalTo(this._indicator.centerY).isActive=YES,this._rightInputView.centerY.equalTo(this._indicator.centerY).isActive=YES,this._indicator.centerX.equalTo(this.contentView.centerX,{priority:750}).isActive=YES,this._indicator.leading.equalTo(this._leftInputView.trailing,{plus:4}).isActive=YES,this._rightInputView.leading.equalTo(this._indicator.trailing,{plus:4}).isActive=YES,this._topInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this._bottomInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this._topInputView.centerX.equalTo(this._indicator.centerX).isActive=YES,this.contentView.trailing.greaterThanOrEqualTo(this._rightInputView.trailing,{plus:8}).isActive=YES,[this._leftInputView,this._topInputView,this._rightInputView,this._bottomInputView].forEach((t=>{const e=t.node;e.addEventListener("input",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("paste",(t=>{this._bound&&this._inputValueDidChangeWithEvent(t)})),e.addEventListener("focus",(t=>this.retain())),e.addEventListener("blur",(t=>this.release()))})),this},cellDidBindToSetting(t){let e;this._titleView.setting=t,t.sizeClass?t.target._variations[t.sizeClass]&&t.property in t.target._variations[t.sizeClass]&&t.target._variations[t.sizeClass][t.property]:e=t.target[t.property],e?(this._leftInputView.node.value=e.left,this._topInputView.node.value=e.top,this._rightInputView.node.value=e.right,this._bottomInputView.node.value=e.bottom):(this._leftInputView.node.value="",this._topInputView.node.value="",this._rightInputView.node.value="",this._bottomInputView.node.value="")},_inputValueDidChangeWithEvent(t){const e=this.setting,i=parseInt(this._leftInputView.node.value,10),o=parseInt(this._topInputView.node.value,10),n=parseInt(this._rightInputView.node.value,10),s=parseInt(this._bottomInputView.node.value,10);let a=isNaN(i)||isNaN(o)||isNaN(n)||isNaN(s)?void 0:BMInsetMake(i,o,n,s);e.nullable||a||(a=BMInsetMake()),this.layoutEditor.setValue(a,{forSetting:e})}}),_BMLayoutEditorViewSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorCollectionSettingsPanel.prototype),{constructor:_BMLayoutEditorViewSettingsPanel,_displayedView:void 0,_attributesTab:void 0,_layoutTab:void 0,initWithSettingsView(t,{forView:e}){if(_BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this,t),this._displayedView=e,this._attributesTab=BMLayoutEditorSettingsTab.tabWithName("Attributes",{icon:_BMURLOfImageAtPath("images/Properties.png")}),this._layoutTab=_BMLayoutEditorViewLayoutSettingsTab.viewLayoutTabForView(e),this._currentTab=this._layoutTab,this._tabs=[this._attributesTab,this._layoutTab,...e.additionalSettingTabsForLayoutEditor(this.layoutEditor)],this.title=e.debuggingName,this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForView){const t=this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForView(this.layoutEditor,e);this._tabs=this._tabs.concat(t)}for(const t of this._tabs)t._settingsPanel=this,t._view=e,t.updateSettings();return this},_updateSettingsForTab(t){if(t._settingSections=[],t==this._attributesTab){const t=this._displayedView,e=BMLayoutEditorSettingsSection.section();e._settings[0]=BMLayoutEditorSetting.settingWithName("Opacity",{kind:BMLayoutEditorSettingKind.Number,target:t,variations:YES,property:"opacity"}),e._settings[1]=BMLayoutEditorSetting.settingWithName("Visible",{kind:BMLayoutEditorSettingKind.Boolean,target:t,variations:YES,property:"isVisible"}),e._settings[2]=BMLayoutEditorSetting.settingWithName("CSS Class",{kind:BMLayoutEditorSettingKind.String,target:t,variations:YES,property:"CSSClass"}),this._attributesTab._settingSections.push(e);const i=BMLayoutEditorSettingsSection.section();i._settings[0]=BMLayoutEditorSetting.settingWithName("Content Insets",{kind:BMLayoutEditorSettingKind.Insets,target:t,variations:YES,nullable:YES,property:"contentInsets"}),this._attributesTab._settingSections.push(i)}for(const e of this._displayedView.additionalSettingSectionsForTab(t,{layoutEditor:this.layoutEditor}))t._settingSections.push(e);if(this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab)for(const e of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor,t))t._settingSections.push(e)},settingsPanelWillAppear(t){this.layoutEditor.selectView(this._displayedView)},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){}}),_BMLayoutEditorViewLayoutSettingsTab.prototype=BMExtend(Object.create(BMLayoutEditorSettingsTab.prototype),{constructor:_BMLayoutEditorViewLayoutSettingsTab,_displayedView:void 0,_showsSubviewConstraints:YES,_constraintCategories:void 0,get showsSubviewConstraints(){return this._showsSubviewConstraints},set showsSubviewConstraints(t){this._showsSubviewConstraints=t,this._updateSettings()},_showsInactiveConstraints:NO,get showsInactiveConstraints(){return this._showsInactiveConstraints},set showsInactiveConstraints(t){this._showsInactiveConstraints=t,this._updateSettings()},get _displayMode(){return this._showsInactiveConstraints&&this._showsSubviewConstraints?"all":this._showsInactiveConstraints?"inactive":this._showsSubviewConstraints?"subview":"own"},set _displayMode(t){"all"==t?(this._showsSubviewConstraints=YES,this.showsInactiveConstraints=YES):"subview"==t?(this._showsInactiveConstraints=NO,this.showsSubviewConstraints=YES):"inactive"==t?(this._showsInactiveConstraints=YES,this.showsSubviewConstraints=YES):(this._showsSubviewConstraints=YES,this.showsInactiveConstraints=NO)},initWithView(t){return BMLayoutEditorSettingsTab.prototype.initWithName.call(this,"Layout",{icon:_BMURLOfImageAtPath("images/Layout.png")}),this._displayedView=t,this},updateSettings(){this._updateSettings()},_updateSettings(){const t=this._displayedView;if(this.beginUpdates(),this._settingSections.length=0,this._intrinsicResistanceSection)t.supportsIntrinsicSize&&this._settingSections.push(this._intrinsicResistanceSection);else{const e=BMLayoutEditorSettingsSection.section();this._intrinsicResistanceSection=e,e.name="Intrinsic Size Resistance",e._settings[0]=BMLayoutEditorSetting.settingWithName("Compression",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"compressionResistance"}),e._settings[1]=BMLayoutEditorSetting.settingWithName("Expansion",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"expansionResistance"}),t.supportsIntrinsicSize&&this._settingSections.push(e)}this._settingsPanel._updateSettingsForTab(this);const e=this._constraintViewPickerSection||BMLayoutEditorSettingsSection.section();this._constraintViewPickerSection=e,e.name="Show",e._settings[0]=BMLayoutEditorEnumSetting.settingWithName("Show",{kind:BMLayoutEditorSettingKind.Segment,target:this,property:"_displayMode"}),e._settings[0].options=[BMMenuItem.menuItemWithName("This Size Class",{icon:_BMURLOfImageAtPath("images/OwnConstraints.png"),userInfo:"subview"}),BMMenuItem.menuItemWithName("All Size Classes",{icon:_BMURLOfImageAtPath("images/InactiveConstraints.png"),userInfo:"inactive"})],this._settingSections.push(e);let i={},o={},n={},s=NO,a=NO;t.localConstraints.forEach((t=>{let e=t.categoryKind;if(!t._configuration.isActive)return a=YES,n[e]=n[e]||[],void n[e].push(t);i[e]=i[e]||[],i[e].push(t)}));for(const t of Object.keys(i).sort()){const e=this[`_${t}`]||BMLayoutEditorSettingsSection.section();this[`_${t}`]=e,e.length=0,e.name=t+" Constraints",e._settings=i[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}if(this._constraintCategories=i,s&&this._showsSubviewConstraints)for(const t of Object.keys(o).sort()){const e="_subview"+t,i=this[e]||BMLayoutEditorSettingsSection.section();this[e]=i,i.length=0,i.name="Subview "+t+" Constraints",i._settings=o[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(i)}if(a&&this._showsInactiveConstraints)for(const t of Object.keys(n).sort()){const e=this[t]||BMLayoutEditorSettingsSection.section();this[t]=e,e.length=0,e.name="Inactive "+t+" Constraints",e._settings=n[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}let r=t.internalConstraints();if(r.length){const t=this._internalConstraintsSection||BMLayoutEditorSettingsSection.section();this._internalConstraintsSection=t,t.length=0,t.name="Internal Constraints",t._settings=r.map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(t)}this.layoutEditor&&this.layoutEditor._drawConstraintsForView(this._displayedView,{includesInactiveConstraints:this._showsInactiveConstraints,includesSubviewConstraints:this._showsSubviewConstraints});const l=BMLayoutEditorSettingsSection.section();l._settings[0]=BMLayoutEditorSetting.settingWithName("Deactivate Constraints",{kind:BMLayoutEditorSettingKind.DeactivateConstraintsButton,target:this}),this._settingSections.push(l),this.commitUpdates()}}),_BMLayoutEditorViewLayoutSettingsTab.viewLayoutTabForView=function(t){return(new _BMLayoutEditorViewLayoutSettingsTab).initWithView(t)},_BMLayoutEditorViewGroupSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorSettingsPanel.prototype),{constructor:_BMLayoutEditorViewGroupSettingsPanel,_views:void 0,get views(){return this._views},set views(t){this._views=t,this.title=t.length+" Selected"},initWithSettingsView(t,{forViews:e}){return _BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this,t),this._views=e,this.title=e.length+" Selected",this},readonlySettingWithName(t,e){let i=document.createElement("div");return i.className="BMLayoutEditorDetailsItemTitle",i.innerText=t,i.style.textAlign="left",i.style.paddingLeft="8px",i},buttonSettingWithName(t,e){let i;return e.class?(i=document.createElement("div"),i.className="BMLayoutEditorImageButton "+e.class):(i=document.createElement("button"),i.className="BMWindowButton",i.innerText=t),i.addEventListener("click",e.action),i},settingsDivider(){let t=document.createElement("div");return t.className="BMLayoutEditorDetailsDivider",t},equalConstraintSettingWithName(t,e){return this.buttonSettingWithName(t,{class:e.class,action:t=>{let i=BMEqualAttributeLayoutConstraint.constraintWithAttribute(e.attribute,{forViews:this.views,_internal:t.shiftKey});t.shiftKey?i.constituentConstraints.forEach((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(i)}})},settingsPanelDidLoad(){const t=this.view.node;let e=this.readonlySettingWithName("Align Horizontal",{value:""});t.appendChild(e);let i=document.createElement("div");i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Top",{class:"BMLayoutEditorImageButtonAlignAlignTop",attribute:BMLayoutAttribute.Top})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterY",attribute:BMLayoutAttribute.CenterY})),i.appendChild(this.equalConstraintSettingWithName("Align Bottom",{class:"BMLayoutEditorImageButtonAlignBottom",attribute:BMLayoutAttribute.Bottom})),t.appendChild(this.settingsDivider());let o=this.readonlySettingWithName("Distribute Horizontal",{value:""});t.appendChild(o),i=document.createElement("div"),i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualHorizontalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Horizontal,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().left-e.node.getBoundingClientRect().left)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints.forEach((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Width",{class:"BMLayoutEditorImageButtonEqualWidth",attribute:BMLayoutAttribute.Width})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Align Vertical",{value:""}),t.appendChild(o),i=document.createElement("div"),i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.equalConstraintSettingWithName("Align Leading",{class:"BMLayoutEditorImageButtonAlignLeading",attribute:BMLayoutAttribute.Leading})),i.appendChild(this.equalConstraintSettingWithName("Align Center",{class:"BMLayoutEditorImageButtonAlignCenterX",attribute:BMLayoutAttribute.CenterX})),i.appendChild(this.equalConstraintSettingWithName("Align Trailing",{class:"BMLayoutEditorImageButtonAlignTrailing",attribute:BMLayoutAttribute.Trailing})),t.appendChild(this.settingsDivider()),o=this.readonlySettingWithName("Distribute Vertical",{value:""}),t.appendChild(o),i=document.createElement("div"),i.style.cssText="display: flex; flex-direction: row; align-self: center; justify-content: center;",t.appendChild(i),i.appendChild(this.buttonSettingWithName("Equal Spacing",{class:"BMLayoutEditorImageButtonEqualVerticalSpacing",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:NO,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.buttonSettingWithName("Equal Spacing In Superview",{class:"BMLayoutEditorImageButtonEqualVerticalSpacingInSuperview",action:t=>{let e=BMEqualSpacingLayoutConstraint.constraintOfKind(BMLayoutConstraintKind.Vertical,{forViews:this.views.slice().sort(((t,e)=>t.node.getBoundingClientRect().top-e.node.getBoundingClientRect().top)),withSuperview:YES,_internal:t.shiftKey});t.shiftKey?e.constituentConstraints((t=>{t._install(),this.layoutEditor.addConstraint(t)})):this.layoutEditor.addConstraint(e)}})),i.appendChild(this.equalConstraintSettingWithName("Equal Height",{class:"BMLayoutEditorImageButtonEqualHeight",attribute:BMLayoutAttribute.Height}))},settingsPanelWillAppear(t){},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){}}),_BMLayoutEditorConstraintSettingsPanel.prototype=BMExtend(Object.create(_BMLayoutEditorCollectionSettingsPanel.prototype),{constructor:_BMLayoutEditorConstraintSettingsPanel,_displayedConstraint:void 0,_referenceView:void 0,_attributesTab:void 0,initWithSettingsView(t,{forConstraint:e,withReferenceView:i}){if(_BMLayoutEditorSettingsPanel.prototype.initWithSettingsView.call(this,t),this._displayedConstraint=e,this._referenceView=i,this._attributesTab=BMLayoutEditorSettingsTab.tabWithName("Attributes",{icon:_BMURLOfImageAtPath("images/Properties.png")}),this._attributesTab._settingsPanel=this,this._currentTab=this._attributesTab,this._tabs=[this._attributesTab],this.title="Constraint",this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForConstraint){const t=this.layoutEditor.delegate.layoutEditorAdditionalSettingTabsForConstraint(this.layoutEditor,e);this._tabs=this._tabs.concat(t)}for(const t of this._tabs)t._settingsPanel=this,t._constraint=e,t.updateSettings();return this},_updateSettingsForTab(t){if(t==this._attributesTab){t._settingSections.length=0;const e=this._displayedConstraint,i=[];if(e.isConstraintCollection||(e._kind==BMLayoutConstraintKind.Horizontal?e._sourceViewAttribute===BMLayoutAttribute.Width?i.push(BMMenuItem.menuItemWithName(e._sourceViewAttribute,{userInfo:e._sourceViewAttribute})):(i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Leading,{userInfo:BMLayoutAttribute.Leading})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.CenterX,{userInfo:BMLayoutAttribute.CenterX})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Trailing,{userInfo:BMLayoutAttribute.Trailing})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Left,{userInfo:BMLayoutAttribute.Left})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Right,{userInfo:BMLayoutAttribute.Right}))):e._sourceViewAttribute===BMLayoutAttribute.Height?i.push(BMMenuItem.menuItemWithName(e._sourceViewAttribute,{userInfo:e._sourceViewAttribute})):(i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Top,{userInfo:BMLayoutAttribute.Top})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.CenterY,{userInfo:BMLayoutAttribute.CenterY})),i.push(BMMenuItem.menuItemWithName(BMLayoutAttribute.Bottom,{userInfo:BMLayoutAttribute.Bottom})))),e.isConstraintCollection){if(e._hasEditableConstant){const t=BMLayoutEditorSettingsSection.section();t._settings[0]=BMLayoutEditorSetting.settingWithName("Constant",{kind:BMLayoutEditorSettingKind.Constant,target:e,variations:YES,property:"constant"}),t._settings[0].automaticallyExpandsVariations=YES,this._attributesTab._settingSections.push(t)}const t=BMLayoutEditorSettingsSection.section();t.title="Affected Views";let i=1;for(const o of e._views)t._settings.push(BMLayoutEditorSetting.settingWithName("View "+i,{kind:BMLayoutEditorSettingKind.View,target:e._views,property:i-1})),i++;this._attributesTab._settingSections.push(t)}else{const t=BMLayoutEditorSettingsSection.section();t._settings[0]=BMLayoutEditorSetting.settingWithName("First View",{kind:BMLayoutEditorSettingKind.View,target:e,property:"_sourceView"}),t._settings[1]=BMLayoutEditorEnumSetting.settingWithName("Attribute",{kind:BMLayoutEditorSettingKind.Enum,target:e,property:"_sourceViewAttribute"}),t._settings[1].options=i,this._attributesTab._settingSections.push(t);const o=BMLayoutEditorSettingsSection.section();o._settings[0]=BMLayoutEditorEnumSetting.settingWithName("Relation",{kind:BMLayoutEditorSettingKind.Enum,target:e,property:"_relation"}),o._settings[0].options=[BMMenuItem.menuItemWithName("=",{userInfo:BMLayoutConstraintRelation.Equals}),BMMenuItem.menuItemWithName("≥",{userInfo:BMLayoutConstraintRelation.GreaterThanOrEquals}),BMMenuItem.menuItemWithName("≤",{userInfo:BMLayoutConstraintRelation.LessThanOrEquals})],this._attributesTab._settingSections.push(o);const n=BMLayoutEditorSettingsSection.section();let s;e._targetView&&(n._settings[0]=BMLayoutEditorSetting.settingWithName("Multiplier",{kind:BMLayoutEditorSettingKind.Number,target:e,property:"_multiplier"}),n._settings[1]=BMLayoutEditorSetting.settingWithName("Second View",{kind:BMLayoutEditorSettingKind.View,target:e,property:"_targetView"}),n._settings[2]=BMLayoutEditorEnumSetting.settingWithName("Attribute",{kind:BMLayoutEditorSettingKind.Enum,target:e,property:"_targetViewAttribute"}),n._settings[2].options=i),n._settings[n._settings.length]=s=BMLayoutEditorSetting.settingWithName("Constant",{kind:BMLayoutEditorSettingKind.Constant,target:e,variations:YES,property:"constant"}),s.automaticallyExpandsVariations=YES,this._attributesTab._settingSections.push(n)}const o=BMLayoutEditorSettingsSection.section();if(o._settings[0]=BMLayoutEditorSetting.settingWithName("Priority",{kind:BMLayoutEditorSettingKind.Number,target:e,variations:YES,property:"priority"}),o._settings[1]=BMLayoutEditorSetting.settingWithName("Active",{kind:BMLayoutEditorSettingKind.Boolean,target:e,variations:YES,property:"isActive"}),o._settings[1].automaticallyExpandsVariations=YES,this._attributesTab._settingSections.push(o),this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab)for(const e of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor,t))t._settingSections.push(e);const n=BMLayoutEditorSettingsSection.section();n._settings[0]=BMLayoutEditorSetting.settingWithName("Delete",{kind:BMLayoutEditorSettingKind.DeleteConstraintButton,target:e,variations:NO}),this._attributesTab._settingSections.push(n)}else if(t._settingSections.length=0,this.layoutEditor.delegate&&this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab)for(const e of this.layoutEditor.delegate.layoutEditorAdditionalSettingSectionsForTab(this.layoutEditor,t))t._settingSections.push(e)},async settingsPanelWillAppear(t){this.layoutEditor.selectConstraint(this._displayedConstraint,{withReferenceView:this._referenceView}),await 0;const e=BMLayoutEditorSetting.settingWithName("Constant",{kind:BMLayoutEditorSettingKind.Constant,target:this._displayedConstraint,variations:YES,property:"constant"});e._sizeClass=this.layoutEditor.activeSizeClass;const i=this._attributesTab.indexPathForObject(e),o=i&&this._attributesTab._collectionView.cellAtIndexPath(i);o&&(o._delaysSuggestionsDropdown=YES,o._inputView.node.focus())},settingsPanelDidAppear(t){},settingsPanelWillDisappear(t){},settingsPanelDidDisappear(t){}}),_BMLayoutEditorConstraintSettingsTab.prototype=BMExtend(Object.create(BMLayoutEditorSettingsTab.prototype),{constructor:_BMLayoutEditorConstraintSettingsTab,_displayedView:void 0,_showsSubviewConstraints:NO,_constraintCategories:void 0,initWithView(t){return BMLayoutEditorSettingsTab.prototype.initWithName.call(this,"Layout",{icon:_BMURLOfImageAtPath("images/Layout.png")}),this},updateSettings(){this._updateSettings()},_updateSettings(){const t=this._displayedView;if(this.beginUpdates(),this._settingSections.length=0,this._intrinsicResistanceSection)this._settingSections.push(this._intrinsicResistanceSection);else{const e=BMLayoutEditorSettingsSection.section();this._intrinsicResistanceSection=e,e._settings[0]=BMLayoutEditorSetting.settingWithName("Compression Resistance",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"compressionResistance"}),e._settings[1]=BMLayoutEditorSetting.settingWithName("Expansion Resistance",{kind:BMLayoutEditorSettingKind.Integer,target:t,property:"expansionResistance"}),this._settingSections.push(e)}if(this._intrinsicSizeSection)this._settingSections.push(this._intrinsicSizeSection);else{const e=BMLayoutEditorSettingsSection.section();this._intrinsicSizeSection=e,e._settings[0]=BMLayoutEditorSetting.settingWithName("Intrinsic Size",{kind:BMLayoutEditorSettingKind.Info,target:t,property:"supportsIntrinsicSize"}),this._settingSections.push(e)}const e=this._constraintViewPickerSection||BMLayoutEditorSettingsSection.section();this._constraintViewPickerSection=e,e.name="Show",e._settings[0]=BMLayoutEditorEnumSetting.settingWithName("Show",{kind:BMLayoutEditorSettingKind.Segment,target:this,property:"_displayMode"}),e._settings[0].options=[BMMenuItem.menuItemWithName("Own Constraints",{icon:_BMURLOfImageAtPath("images/OwnConstraints.png"),userInfo:"own"}),BMMenuItem.menuItemWithName("Subview Constraints",{icon:_BMURLOfImageAtPath("images/SubviewConstraints.png"),userInfo:"subview"}),BMMenuItem.menuItemWithName("Inactive Constraints",{icon:_BMURLOfImageAtPath("images/InactiveConstraints.png"),userInfo:"inactive"}),BMMenuItem.menuItemWithName("All Constraints",{icon:_BMURLOfImageAtPath("images/AllConstraints.png"),userInfo:"all"})],this._settingSections.push(e);let i={},o={},n={},s=NO,a=NO;t.localConstraints.forEach((e=>{let r=e.categoryKind;if(!e._configuration.isActive)return a=YES,n[r]=n[r]||[],void n[r].push(e);if(!e.isConstraintCollection){if(e._sourceView==t&&e._targetView&&e._targetView.isDescendantOfView(t))return o[r]=o[r]||[],o[r].push(e),void(s=YES);if(e._targetView==t&&e._sourceView.isDescendantOfView(t))return o[r]=o[r]||[],o[r].push(e),void(s=YES)}i[r]=i[r]||[],i[r].push(e)}));for(const t of Object.keys(i).sort()){const e=this[`_${t}`]||BMLayoutEditorSettingsSection.section();this[`_${t}`]=e,e.length=0,e.name=t+" Constraints",e._settings=i[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}if(this._constraintCategories=i,s&&this._showsSubviewConstraints)for(const t of Object.keys(o).sort()){const e="_subview"+t,i=this[e]||BMLayoutEditorSettingsSection.section();this[e]=i,i.length=0,i.name="Subview "+t+" Constraints",i._settings=o[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(i)}if(a&&this._showsInactiveConstraints)for(const t of Object.keys(n).sort()){const e=this[t]||BMLayoutEditorSettingsSection.section();this[t]=e,e.length=0,e.name="Inactive "+t+" Constraints",e._settings=n[t].map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(e)}let r=t.internalConstraints();if(r.length){const t=this._internalConstraintsSection||BMLayoutEditorSettingsSection.section();this._internalConstraintsSection=t,t.length=0,t.name="Internal Constraints",t._settings=r.map((t=>BMLayoutEditorSetting.settingWithName(t.toString(),{kind:BMLayoutEditorSettingKind.Constraint,target:t}))),this._settingSections.push(t)}this.layoutEditor&&this.layoutEditor._drawConstraintsForView(this._displayedView,{includesInactiveConstraints:this._showsInactiveConstraints,includesSubviewConstraints:this._showsSubviewConstraints});const l=BMLayoutEditorSettingsSection.section();l._settings[0]=BMLayoutEditorSetting.settingWithName("Deactivate Constraints",{kind:BMLayoutEditorSettingKind.DeactivateConstraintsButton,target:this}),this._settingSections.push(l),this.commitUpdates()}}),_BMLayoutEditorConstraintSettingsTab.viewLayoutTabForView=function(t){return(new _BMLayoutEditorConstraintSettingsTab).initWithView(t)};const BMMENU_USE_WEB_ANIMATIONS=NO,_BMMenuSpacingToNode=8,_BMMenuSubmenuTimeout=300,BMMenuSourceNodeCSSClass="BMMenuSourceNode";var BMMenuKind=Object.freeze({Menu:{},PullDownMenu:{}});function BMMenuItem(){}function BMMenu(){}BMMenuItem.prototype={_name:void 0,get name(){return this._name},_icon:void 0,get icon(){return this._icon},_action:void 0,get action(){return this._action},_submenu:void 0,get submenu(){return this._submenu},_isSeparator:NO,get isSeparator(){return this._isSeparator},userInfo:void 0,_CSSClass:"",get CSSClass(){return this._CSSClass},set CSSClass(t){let e=this._node;e&&(this._CSSClass&&this._CSSClass.split(" ").forEach((t=>e.classList.remove(t))),t&&t.split(" ").forEach((t=>e.classList.add(t)))),this._CSSClass=t||""},_keySequence:void 0,get keySequence(){return this._keySequence},set keySequence(t){this._keySequence=t},_hintHTML:void 0,get hintHTML(){return this._hintHTML},set hintHTML(t){if(this._hintHTML=t,this._node){const e=this._node.querySelector(".BMMenuItemHint");e&&(e.innerHTML=t)}},_node:void 0,_enabled:YES,get enabled(){return this._enabled},set enabled(t){if(this._enabled!=t&&!this._isSeparator&&(this._enabled=t,this._node)){const e=this._node;t?e.classList.remove("BMMenuItemDisabled"):e.classList.add("BMMenuItemDisabled")}},initWithName(t,{icon:e,action:i,submenu:o,enabled:n=!0,userInfo:s}={}){return this._name=t,this._icon=e,this._action=i,this._submenu=o,this.userInfo=s,t.startsWith("---")&&(this._isSeparator=YES,this._enabled=NO),this._enabled=n,this}},BMMenuItem.menuItemWithName=function(t,e){return(new BMMenuItem).initWithName(t,e)},BMMenuItem.menuSeparator=function(){return(new BMMenuItem).initWithName("---")},BMMenu.prototype={_items:void 0,get items(){return this._items.slice()},_delegate:void 0,get delegate(){return this._delegate},set delegate(t){this._delegate=t},_iconSize:24,get iconSize(){return this._iconSize},set iconSize(t){if(this._iconSize=t,this._node)for(const e of this._node.querySelectorAll(".BMMenuIcon"))BMCopyProperties(e.style,{width:t+"px",height:t+"px"})},_CSSClass:"",get CSSClass(){return this._CSSClass},set CSSClass(t){let e=this._node;e&&(this._CSSClass&&this._CSSClass.split(" ").forEach((t=>e.classList.remove(t))),t&&t.split(" ").forEach((t=>e.classList.add(t)))),this._CSSClass=t||""},_point:new BMPoint,_node:void 0,_itemsContainerNode:void 0,_containerNode:void 0,_sourceNode:void 0,_sourceNodeShadow:void 0,_sourceNodeDisplacement:0,_sourceNodeHorizontalDisplacement:0,_previouslyActiveNode:void 0,_submenu:void 0,_supermenu:void 0,_frame:void 0,get frame(){return this._frame&&this._frame.copy()},_highlightedIndex:-1,get highlightedIndex(){return this._highlightedIndex},set highlightedIndex(t){if(t!=this._highlightedIndex){if(this._highlightedIndex=t,this._node){const e=this._node.querySelector(".BMMenuItemHighlighted");e&&e.classList.remove("BMMenuItemHighlighted");const i=this._itemsContainerNode.children[t];i&&(i.classList.add("BMMenuItemHighlighted"),i.scrollIntoViewIfNeeded?i.scrollIntoViewIfNeeded():i.scrollIntoView())}-1!=t&&this._submenu&&this._submenu.closeAnimated(YES)}},_delaysEvents:NO,__delaysClosing:NO,get _delaysClosing(){return this.__delaysClosing},set _delaysClosing(t){this._supermenu&&(this._supermenu._delaysClosing=t),this.__delaysClosing=t},initWithItems(t){return this._items=[...t],this},_renderMenu(){return this._supermenu?this._renderMenuWithContainer(this._supermenu._containerNode):this._renderMenuWithContainer()},_renderMenuWithContainer(t){const e=document.createElement("div");e.className=this._CSSClass?`BMMenu ${this._CSSClass}`:"BMMenu",this._node=e;const i=document.createElement("div");i.className="BMMenuItemsContainer",this._itemsContainerNode=i,e.appendChild(i),this._highlightedIndex=-1,e.tabIndex=-1;const o=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowUp",{modifiers:[],target:this,action:"arrowUpPressedWithEvent"});o.preventsDefault=YES,BMView.registerKeyboardShortcut(o,{forNode:e});const n=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowDown",{modifiers:[],target:this,action:"arrowDownPressedWithEvent"});n.preventsDefault=YES,BMView.registerKeyboardShortcut(n,{forNode:e});const s=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowRight",{modifiers:[],target:this,action:"arrowRightPressedWithEvent"});s.preventsDefault=YES,BMView.registerKeyboardShortcut(s,{forNode:e});const a=BMKeyboardShortcut.keyboardShortcutWithKeyCode("ArrowLeft",{modifiers:[],target:this,action:"arrowLeftPressedWithEvent"});a.preventsDefault=YES,BMView.registerKeyboardShortcut(a,{forNode:e});const r=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Enter",{modifiers:[],target:this,action:"returnPressedWithEvent"});r.preventsDefault=YES,BMView.registerKeyboardShortcut(r,{forNode:e});const l=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Space",{modifiers:[],target:this,action:"returnPressedWithEvent"});l.preventsDefault=YES,BMView.registerKeyboardShortcut(l,{forNode:e});const h=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Tab",{modifiers:[],target:this,action:"tabPressedWithEvent"});h.preventsDefault=YES,BMView.registerKeyboardShortcut(h,{forNode:e});const c=BMKeyboardShortcut.keyboardShortcutWithKeyCode("Escape",{modifiers:[],target:this,action:"escapePressedWithEvent"});c.preventsDefault=YES,BMView.registerKeyboardShortcut(c,{forNode:e});for(const t of this._items)if(t.keySequence){const i=BMKeyboardShortcut.keyboardShortcutWithKeySequence(t.keySequence,{target:this,action:"_selectMenuItemWithEvent"});i._menuItem=t,BMView.registerKeyboardShortcut(i,{forNode:e})}const d=t||document.createElement("div");t||(d.className="BMMenuContainer"),"backdropFilter"in document.body.style||"webkitBackdropFilter"in document.body.style||(e.style.backgroundColor="white"),d.appendChild(e),this._containerNode=d,this._renderMenuItems(),e.addEventListener("click",(t=>{t.target==e&&(this._submenu&&this._submenu.closeAnimated(YES),t.stopPropagation()),t.preventDefault()})),e.addEventListener("mouseleave",(t=>{this._delaysEvents||document.activeElement==e&&(this.highlightedIndex=-1)})),d.addEventListener("click",(t=>{this._delaysEvents&&this._frame&&this._frame.intersectsPoint(BMPointMake(t.clientX,t.clientY))||(this.closeAnimated(YES),t.preventDefault())})),d.addEventListener("contextmenu",(t=>{this.closeAnimated(YES),t.preventDefault()}))},_renderMenuItems(){const t=this._iconSize;this._items.forEach(((e,i)=>{if(e.name.startsWith("---")){const t=document.createElement("div");return t.className="BMMenuDivider",void this._itemsContainerNode.appendChild(t)}let o=document.createElement("div");if(o.className="BMMenuItem",e._node=o,e.icon){const i=document.createElement("img");i.className="BMMenuIcon",i.src=e.icon,BMCopyProperties(i.style,{width:t+"px",height:t+"px"}),o.appendChild(i)}const n=document.createElement("span");n.innerText=e.name,o.appendChild(n);const s=document.createElement("div");s.classList.add("BMMenuItemHint"),s.innerHTML=e._hintHTML||"",o.appendChild(s);const a=document.createElement("div");a.classList.add("BMMenuItemDisclosure"),e.submenu&&a.classList.add("BMMenuItemDisclosureSubmenu"),o.appendChild(a),e._enabled||o.classList.add("BMMenuItemDisabled"),o.addEventListener("click",(t=>{if(!e._enabled)return;if(e.submenu&&this._sourceNodeShadow)return this._openSubmenuForMenuItem(e,{animated:YES,delayEvents:NO,acquireFocus:YES}),void t.stopPropagation();let i=YES;this.delegate&&this.delegate.menuShouldSelectItem&&(i=this.delegate.menuShouldSelectItem(this,e)),i?(this._delaysClosing=YES,e.action&&e.action(e),o.classList.add("BMMenuItemActive"),this.delegate&&this.delegate.menuDidSelectItem&&this.delegate.menuDidSelectItem(this,e)):t.stopPropagation()})),o.addEventListener("mouseover",(t=>{e._enabled?this._highlightedIndex!=i&&(this._delaysEvents||(this.highlightedIndex=i,e.submenu&&setTimeout((()=>{this._sourceNodeShadow||this._highlightedIndex==i&&this._openSubmenuForMenuItem(e,{animated:YES,delayEvents:YES})}),100))):this.highlightedIndex=-1})),this._itemsContainerNode.appendChild(o)}))},_kind:BMMenuKind.Menu,async openFromNode(t,{animated:e=NO,kind:i=BMMenuKind.Menu}={}){this.delegate&&this.delegate.menuWillOpen&&this.delegate.menuWillOpen(this),this._sourceNode=t;const o=BMRectMakeWithNodeFrame(t);o.size.height=t.offsetHeight;const n=window.innerHeight;this._sourceNodeShadow=t.cloneNode(YES),this._renderMenu();const s=this._node,a=this._itemsContainerNode,r=this._containerNode;this._supermenu||document.body.appendChild(r),document.body.appendChild(this._sourceNodeShadow);const l=o.copy();l.scaleWithFactor(1.1),r.classList.add("BMMenuContainerFullScreen"),this._sourceNodeShadow.classList.add("BMMenuSourceNodeShadow"),s.classList.add("BMMenuTouch"),this._supermenu&&(s.style.minWidth=`${this._supermenu.frame.size.width+8}px`,this._supermenu._node.classList.add("BMMenuTouchSubmenu")),this._sourceNode.classList.add(BMMenuSourceNodeCSSClass),"vibrate"in window.navigator&&window.navigator.vibrate(10);const h=s.offsetHeight,c=s.offsetWidth,d=window.innerWidth;let u=1.1;if(l.width>d-16){const t=(d-16)/l.width;l.scaleWithFactor(t),u*=t}if(l.height>n-h-16){const t=(n-h-16)/l.height;l.scaleWithFactor(t),u*=t}const p=n-l.bottom;let g=0,w=0;const y=400,m=[.17,1.46,.84,.93];l.origin.y<0&&(g=16-l.origin.y),h+16>p&&(g=p-(h+16)),c+l.origin.x+8>d&&(w=d-(c+l.origin.x+8)),this._sourceNodeDisplacement=g,this._sourceNodeHorizontalDisplacement=w,BMCopyProperties(this._sourceNodeShadow.style,{left:o.origin.x+"px",top:o.origin.y+"px",width:o.size.width+"px",height:o.size.height+"px",transform:"none"}),s.style.transformOrigin="0% 0%",i==BMMenuKind.PullDownMenu&&(s.style.transformOrigin="50% 0%"),this._kind=i;const _=BMPointMake(Math.max(l.origin.x+w,8),l.bottom+8+g);BMCopyProperties(s.style,{left:_.x+"px",top:_.y+"px"}),this._frame=BMRectMakeWithOrigin(_,{size:BMSizeMake(c,h)}),this._supermenu?BMHook(s,{opacity:0}):BMHook(r,{opacity:0}),BMHook(s,{scaleX:i==BMMenuKind.PullDownMenu?.5:.33,scaleY:i==BMMenuKind.PullDownMenu?.5:.33,translateY:-g+"px",translateX:-w+"px"}),this._supermenu?(this._supermenu._node.classList.add("BMMenuInactive"),__BMVelocityAnimate(this._supermenu._node,{scaleX:.95,scaleY:.95},{duration:y,easing:"easeOutQuad"},BMMENU_USE_WEB_ANIMATIONS)):__BMVelocityAnimate(r,{opacity:1},{duration:y,easing:m},BMMENU_USE_WEB_ANIMATIONS),a.style.overflow="hidden",__BMVelocityAnimate(s,{opacity:1},{duration:y,easing:m},BMMENU_USE_WEB_ANIMATIONS),__BMVelocityAnimate(s,{scaleX:1,scaleY:1,translateZ:0,translateY:0,translateX:0},{duration:y,easing:m,complete:t=>{s.style.pointerEvents="all",r.style.pointerEvents="all"}},BMMENU_USE_WEB_ANIMATIONS);let f=50,v=Math.min(16,150/a.childNodes.length);for(let t=0;t<a.childNodes.length;t++){const e=a.childNodes[t];BMHook(e,{translateY:"16px",translateZ:0,opacity:0}),__BMVelocityAnimate(e,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:f,complete:t==a.childNodes.length-1?()=>{this._node==s&&(a.style.overflow="")}:void 0},BMMENU_USE_WEB_ANIMATIONS),f+=v}this._previouslyActiveNode=document.activeElement,s.focus(),await __BMVelocityAnimate(this._sourceNodeShadow,{translateY:g+"px",translateX:w+"px",scaleX:u,scaleY:u},{duration:y,easing:m},BMMENU_USE_WEB_ANIMATIONS)},openAtPoint(t,{animated:e=NO,kind:i=BMMenuKind.Menu}={}){const o=BMRectMakeWithOrigin(t,{size:BMSizeMake()});return this._openAroundRect(o,arguments[1])},_openAroundRect(t,{animated:e=NO,kind:i=BMMenuKind.Menu}={}){if(this._node)return;this.delegate&&this.delegate.menuWillOpen&&this.delegate.menuWillOpen(this),this._renderMenu();const o=this._node,n=this._itemsContainerNode,s=this._containerNode;this._kind=i,BMHook(o,{scaleX:i==BMMenuKind.PullDownMenu?1:.75,scaleY:i==BMMenuKind.PullDownMenu?.5:.75,opacity:0}),this._supermenu||document.body.appendChild(s);const a=o.offsetHeight,r=o.offsetWidth,l=window.getComputedStyle(o),h=window.getComputedStyle(n),c=(parseInt(l.paddingTop,10)||0)+(parseInt(h.paddingTop,10)||0),d=(parseInt(l.paddingBottom,10)||0)+(parseInt(h.paddingBottom,10)||0);let u="0%",p=" 0%";const g=BMPointMake(t.right,t.origin.y-c),w=window.innerWidth,y=window.innerHeight;i==BMMenuKind.PullDownMenu?u="50%":r+g.x>w&&(g.x>w/2?(u="100%",o.style.maxWidth=t.origin.x+"px",g.x=Math.max(t.origin.x-r,0)):o.style.maxWidth=window.innerWidth-g.x+"px"),a+g.y>y&&(g.y>y/2?(p=" 100%",o.style.maxHeight=t.bottom+"px",g.y=Math.max(t.bottom+d-a,0)):o.style.maxHeight=y-g.y+"px"),o.style.transformOrigin=u+p,this._frame=BMRectMakeWithOrigin(g,{size:BMSizeMake(r,a)}),o.style.left=g.x+"px",o.style.top=g.y+"px",n.style.overflow="hidden",(window.Velocity||$.Velocity).animate(o,{scaleX:1,scaleY:1,opacity:1,translateZ:0},{duration:200,easing:"easeOutQuad",complete:t=>{o.style.pointerEvents="all",s.style.pointerEvents="all"}});let m=0,_=Math.min(16,150/n.childNodes.length);for(let t=0;t<n.childNodes.length;t++){const e=n.childNodes[t];BMHook(e,{translateY:"16px",translateZ:0,opacity:0}),(window.Velocity||$.Velocity).animate(e,{translateY:"0px",translateZ:0,opacity:1},{duration:100,easing:"easeOutQuad",delay:m,complete:t==n.childNodes.length-1?()=>{this._node==o&&(n.style.overflow="")}:void 0}),m+=_}this._previouslyActiveNode=document.activeElement,this._supermenu||o.focus()},_openSubmenuForMenuItem(t,{animated:e=YES,delayEvents:i,acquireFocus:o}={animated:YES}){const n=t._submenu;if(!n)return;const s=BMRectMakeWithNodeFrame(t._node);i&&this._delayEventsForSubmenu(n,{item:t}),n._supermenu=this,this._submenu=n,this._sourceNodeShadow?n.openFromNode(t._node,{animated:e,kind:BMMenuKind.PullDownMenu}):n._openAroundRect(s,{animated:e}),o&&n._node.focus()},_delayEventsForSubmenu(t,{item:e}){let i=t.frame;const o=BMRectMakeWithNodeFrame(e._node);let n,s,a,r=!1;const l=this._containerNode;this._delaysEvents=YES,l.classList.add("BMMenuContainerSubmenuActive");const h="mousemove";let c,d=NO;const u=()=>{this._delaysEvents=NO,l.removeEventListener(h,p,{capture:YES}),l.classList.remove("BMMenuContainerSubmenuActive"),c&&(window.clearTimeout(c),c=void 0)},p=e=>{const l=BMPointMake(e.clientX,e.clientY);if(!i)return void(i=t.frame);if(!n)return n=l,s=i.origin.x>n.x?i.origin:BMPointMake(i.right,i.origin.y),a=i.origin.x>n.x?BMPointMake(i.origin.x,i.bottom):BMPointMake(i.right,i.bottom),void(i.origin.x<n.x&&(r=!0));if(!this._delaysEvents)return void u();if(!d){if(o.intersectsPoint(l))return;d=YES,c=window.setTimeout(u,300)}if(i.intersectsPoint(l))return t._node.focus(),void u();if(e.preventDefault(),e.stopPropagation(),l.isEqualToPoint(n))return;const h=l.slopeAngleToPoint(s),p=l.slopeAngleToPoint(a),g=n.slopeAngleToPoint(l),w=Math.min(h,p),y=Math.max(h,p);(r?g>w&&g<y:g<w||g>y)?u():n=l};l.addEventListener(h,p,{capture:YES})},closeAnimated(t=YES,{withSupermenu:e=NO}={}){if(!this._node)return;this._submenu&&(this._submenu._isSupermenuClosing=YES,this._submenu.closeAnimated(t)),this.delegate&&this.delegate.menuWillClose&&this.delegate.menuWillClose(this),e&&this._supermenu&&this._supermenu.closeAnimated(t,{withSupermenu:e}),this._delaysEvents=NO,this._previouslyActiveNode&&this._previouslyActiveNode.focus();const i=this._supermenu;i&&(i._submenu=void 0,this._supermenu=void 0,i._node&&!this._isSupermenuClosing&&(__BMVelocityAnimate(i._node,{scaleX:1,scaleY:1},{duration:200,easing:"easeInOutQuad"},BMMENU_USE_WEB_ANIMATIONS),i._node.classList.remove("BMMenuTouchSubmenu"),i._node.classList.remove("BMMenuInactive"))),this._node.style.pointerEvents="none",i||(this._containerNode.style.pointerEvents="none"),this._frame=void 0;let o=Math.min(16*this._itemsContainerNode.childNodes.length,150);o=o<0?0:o;const n=this._delaysClosing;this._delaysClosing=NO,n&&!this._sourceNodeShadow&&(o+=200);const s=this._sourceNodeShadow,a=this._containerNode,r=this._node,l=this._itemsContainerNode,h=this._sourceNode;this._sourceNode=void 0,this._sourceNodeShadow=void 0,this._items.forEach((t=>t._node=void 0));const c=s?.33:.75,d=s?200:400,u=s?"easeInOutQuad":"easeInQuad";if(s){const t={translateY:0,translateX:0,scaleX:1,scaleY:1};this._isSupermenuClosing&&(t.opacity=0),__BMVelocityAnimate(s,t,{duration:d,easing:u,delay:o},BMMENU_USE_WEB_ANIMATIONS),i||__BMVelocityAnimate(a,{opacity:0},{duration:d,easing:u,delay:o},BMMENU_USE_WEB_ANIMATIONS)}this._isSupermenuClosing=NO,l.style.overflow="hidden",__BMVelocityAnimate(this._node,{scaleX:this._kind==BMMenuKind.PullDownMenu?1:c,scaleY:c,opacity:s&&!i?1:0,translateY:s?-this._sourceNodeDisplacement+"px":"0px",translateX:s?-this._sourceNodeHorizontalDisplacement+"px":"0px",translateZ:0},{duration:200,easing:u,delay:o,complete:t=>{i?r.remove():a.remove(),s&&(s.remove(),h.classList.remove(BMMenuSourceNodeCSSClass)),this.delegate&&this.delegate.menuDidClose&&this.delegate.menuDidClose(this)}},BMMENU_USE_WEB_ANIMATIONS),o=0,n&&!s&&(o=200);const p=Math.min(16,150/l.childNodes.length);for(let t=l.childNodes.length-1;t>=0;t--){__BMVelocityAnimate(l.childNodes[t],{translateY:"16px",translateZ:0,opacity:0},{duration:100,easing:"easeInQuad",delay:o},BMMENU_USE_WEB_ANIMATIONS),o+=p}this._node=void 0,this._containerNode=void 0,this._itemsContainerNode=void 0},arrowUpPressedWithEvent(t){if(0!=this._highlightedIndex){let t=this._highlightedIndex;for(;YES&&(t=BMNumberByConstrainingNumberToBounds(t-1,0,this._items.length-1),this._items[t]._isSeparator||!this._items[t]._enabled);)if(0==t)return;this.highlightedIndex=t}},arrowDownPressedWithEvent(t){if(this._highlightedIndex!=this._items.length-1){let t=this._highlightedIndex;for(;YES&&(t=BMNumberByConstrainingNumberToBounds(t+1,0,this._items.length-1),this._items[t]._isSeparator||!this._items[t]._enabled);)if(t==this._items.length-1)return;this.highlightedIndex=t}},arrowRightPressedWithEvent(t){const e=this._items[this._highlightedIndex];e&&e._submenu&&this._openSubmenuForMenuItem(e,{delayEvents:NO,acquireFocus:YES})},arrowLeftPressedWithEvent(t){this._supermenu&&this.closeAnimated(YES)},_selectMenuItemWithEvent(t,{forKeyboardShortcut:e}){t.preventDefault();const i=e._menuItem;if(i._isSeparator||!i._enabled)return;if(!this._node)return;this._node.inert=!0,this._node.style.pointerEvents="none";const o=this._items.indexOf(i);this.highlightedIndex=o,setTimeout((()=>{this.returnPressedWithEvent(t)}),50)},returnPressedWithEvent(t){if(this._highlightedIndex>=0&&this._highlightedIndex<this._items.length){const t=this._items[this._highlightedIndex];let e=YES;if(this.delegate&&this.delegate.menuShouldSelectItem&&(e=this.delegate.menuShouldSelectItem(this,t)),!e)return;this._delaysClosing=YES,t.action&&t.action(t),this.delegate&&this.delegate.menuDidSelectItem&&this.delegate.menuDidSelectItem(this,t);const i=t._node;i&&i.classList.add("BMMenuItemActive"),this.closeAnimated(YES,{withSupermenu:YES})}},tabPressedWithEvent(t){},escapePressedWithEvent(t){this._node&&this.closeAnimated(YES)}},BMMenu.menuWithItems=function(t){return(new BMMenu).initWithItems(t)};
2
2
  /*! iScroll v5.2.0 ~ (c) 2008-2016 Matteo Spinelli ~ @license: http://cubiq.org/license */
3
3
  var IScroll=function(t,e,i){var o=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e){t.setTimeout(e,1e3/60)},n=function(){var o={},n=e.createElement("div").style,s=function(){for(var t=["t","webkitT","MozT","msT","OT"],e=0,i=t.length;e<i;e++)if(t[e]+"ransform"in n)return t[e].substr(0,t[e].length-1);return!1}();function a(t){return!1!==s&&(""===s?t:s+t.charAt(0).toUpperCase()+t.substr(1))}o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,e){for(var i in e)t[i]=e[i]},o.addEvent=function(t,e,i,o){t.addEventListener(e,i,!!o)},o.removeEvent=function(t,e,i,o){t.removeEventListener(e,i,!!o)},o.prefixPointerEvent=function(e){return t.MSPointerEvent?"MSPointer"+e.charAt(7).toUpperCase()+e.substr(8):e},o.momentum=function(t,e,o,n,s,a){var r,l,h=t-e,c=i.abs(h)/o;return l=c/(a=void 0===a?6e-4:a),(r=t+c*c/(2*a)*(h<0?-1:1))<n?(r=s?n-s/2.5*(c/8):n,l=(h=i.abs(r-t))/c):r>0&&(r=s?s/2.5*(c/8):0,l=(h=i.abs(t)+r)/c),{destination:i.round(r),duration:l}};var r=a("transform");return o.extend(o,{hasTransform:!1!==r,hasPerspective:a("perspective")in n,hasTouch:"ontouchstart"in t,hasPointer:!(!t.PointerEvent&&!t.MSPointerEvent),hasTransition:a("transition")in n}),o.isBadAndroid=function(){var e=t.navigator.appVersion;if(/Android/.test(e)&&!/Chrome\/\d/.test(e)){var i=e.match(/Safari\/(\d+.\d)/);return!(i&&"object"==typeof i&&i.length>=2)||parseFloat(i[1])<535.19}return!1}(),o.extend(o.style={},{transform:r,transitionTimingFunction:a("transitionTimingFunction"),transitionDuration:a("transitionDuration"),transitionDelay:a("transitionDelay"),transformOrigin:a("transformOrigin")}),o.hasClass=function(t,e){return new RegExp("(^|\\s)"+e+"(\\s|$)").test(t.className)},o.addClass=function(t,e){if(!o.hasClass(t,e)){var i=t.className.split(" ");i.push(e),t.className=i.join(" ")}},o.removeClass=function(t,e){if(o.hasClass(t,e)){var i=new RegExp("(^|\\s)"+e+"(\\s|$)","g");t.className=t.className.replace(i," ")}},o.offset=function(t){for(var e=-t.offsetLeft,i=-t.offsetTop;t=t.offsetParent;)e-=t.offsetLeft,i-=t.offsetTop;return{left:e,top:i}},o.preventDefaultException=function(t,e){for(var i in e)if(e[i].test(t[i]))return!0;return!1},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,pointerdown:3,pointermove:3,pointerup:3,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return i.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){return(t-=1)*t*(5*t+4)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return 0===t?0:1==t?1:.4*i.pow(2,-10*t)*i.sin((t-.055)*(2*i.PI)/.22)+1}}}),o.tap=function(t,i){var o=e.createEvent("Event");o.initEvent(i,!0,!0),o.pageX=t.pageX,o.pageY=t.pageY,t.target.dispatchEvent(o)},o.click=function(i){var o,n=i.target;/(SELECT|INPUT|TEXTAREA)/i.test(n.tagName)||((o=e.createEvent(t.MouseEvent?"MouseEvents":"Event")).initEvent("click",!0,!0),o.view=i.view||t,o.detail=1,o.screenX=n.screenX||0,o.screenY=n.screenY||0,o.clientX=n.clientX||0,o.clientY=n.clientY||0,o.ctrlKey=!!i.ctrlKey,o.altKey=!!i.altKey,o.shiftKey=!!i.shiftKey,o.metaKey=!!i.metaKey,o.button=0,o.relatedTarget=null,o._constructed=!0,n.dispatchEvent(o))},o}();function s(i,o){for(var s in this.wrapper="string"==typeof i?e.querySelector(i):i,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeScrollbars:!0,mouseWheelSpeed:20,snapThreshold:.334,disablePointer:!n.hasPointer,disableTouch:n.hasPointer||!n.hasTouch,disableMouse:n.hasPointer||n.hasTouch,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,preventDefaultException:{tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT)$/},HWCompositing:!0,useTransition:!0,useTransform:!0,bindToWrapper:void 0===t.onmousedown},o)this.options[s]=o[s];this.translateZ=this.options.HWCompositing&&n.hasPerspective?" translateZ(0)":"",this.options.useTransition=n.hasTransition&&this.options.useTransition,this.options.useTransform=n.hasTransform&&this.options.useTransform,this.options.eventPassthrough=!0===this.options.eventPassthrough?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"!=this.options.eventPassthrough&&this.options.scrollY,this.options.scrollX="horizontal"!=this.options.eventPassthrough&&this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?n.ease[this.options.bounceEasing]||n.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,!0===this.options.tap&&(this.options.tap="tap"),this.options.useTransition||this.options.useTransform||/relative|absolute/i.test(this.scrollerStyle.position)||(this.scrollerStyle.position="relative"),"scale"==this.options.shrinkScrollbars&&(this.options.useTransition=!1),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,3==this.options.probeType&&(this.options.useTransition=!1),this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function a(t,i,o){var n=e.createElement("div"),s=e.createElement("div");return!0===o&&(n.style.cssText="position:absolute;z-index:9999",s.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),s.className="iScrollIndicator","h"==t?(!0===o&&(n.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",s.style.height="100%"),n.className="iScrollHorizontalScrollbar"):(!0===o&&(n.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",s.style.width="100%"),n.className="iScrollVerticalScrollbar"),n.style.cssText+=";overflow:hidden",i||(n.style.pointerEvents="none"),n.appendChild(s),n}function r(i,s){for(var a in this.wrapper="string"==typeof s.el?e.querySelector(s.el):s.el,this.wrapperStyle=this.wrapper.style,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=i,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,shrink:!1,fade:!1,speedRatioX:0,speedRatioY:0},s)this.options[a]=s[a];if(this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(this.options.disableTouch||(n.addEvent(this.indicator,"touchstart",this),n.addEvent(t,"touchend",this)),this.options.disablePointer||(n.addEvent(this.indicator,n.prefixPointerEvent("pointerdown"),this),n.addEvent(t,n.prefixPointerEvent("pointerup"),this)),this.options.disableMouse||(n.addEvent(this.indicator,"mousedown",this),n.addEvent(t,"mouseup",this))),this.options.fade){this.wrapperStyle[n.style.transform]=this.scroller.translateZ;var r=n.style.transitionDuration;if(!r)return;this.wrapperStyle[r]=n.isBadAndroid?"0.0001ms":"0ms";var l=this;n.isBadAndroid&&o((function(){"0.0001ms"===l.wrapperStyle[r]&&(l.wrapperStyle[r]="0s")})),this.wrapperStyle.opacity="0"}}return s.prototype={version:"5.2.0",_init:function(){this._initEvents(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),clearTimeout(this.resizeTimeout),this.resizeTimeout=null,this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&this.isInTransition&&(this._transitionTime(),this.resetPosition(this.options.bounceTime)||(this.isInTransition=!1,this._execEvent("scrollEnd")))},_start:function(t){if(1!=n.eventType[t.type]&&0!==(t.which?t.button:t.button<2?0:4==t.button?1:2))return;if(this.enabled&&(!this.initiated||n.eventType[t.type]===this.initiated)){!this.options.preventDefault||n.isBadAndroid||n.preventDefaultException(t.target,this.options.preventDefaultException)||t.target.classList.contains("BMCollectionViewCellEventHandler")||t.target.parentNode.classList.contains("BMCollectionViewCellEventHandler")||t.preventDefault();var e,o=t.touches?t.touches[0]:t;this.initiated=n.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this.startTime=n.getTime(),this.options.useTransition&&this.isInTransition?(this._transitionTime(),this.isInTransition=!1,e=this.getComputedPosition(),this._translate(i.round(e.x),i.round(e.y)),this._execEvent("scrollEnd")):!this.options.useTransition&&this.isAnimating&&(this.isAnimating=!1,this._execEvent("scrollEnd")),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=o.pageX,this.pointY=o.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&n.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var e,o,s,a,r=t.touches?t.touches[0]:t,l=r.pageX-this.pointX,h=r.pageY-this.pointY,c=n.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=l,this.distY+=h,s=i.abs(this.distX),a=i.abs(this.distY),!(c-this.endTime>300&&s<10&&a<10)){if(this.directionLocked||this.options.freeScroll||(s>a+this.options.directionLockThreshold?this.directionLocked="h":a>=s+this.options.directionLockThreshold?this.directionLocked="v":this.directionLocked="n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return void(this.initiated=!1);h=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return void(this.initiated=!1);l=0}l=this.hasHorizontalScroll?l:0,h=this.hasVerticalScroll?h:0,e=this.x+l,o=this.y+h,(e>0||e<this.maxScrollX)&&(e=this.options.bounce?this.x+l/3:e>0?0:this.maxScrollX),(o>0||o<this.maxScrollY)&&(o=this.options.bounce?this.y+h/3:o>0?0:this.maxScrollY),this.directionX=l>0?-1:l<0?1:0,this.directionY=h>0?-1:h<0?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(e,o),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y,1==this.options.probeType&&this._execEvent("scroll")),this.options.probeType>1&&this._execEvent("scroll"),this.options.stopPropagation&&t.stopPropagation()}}},_end:function(t){if(this.enabled&&n.eventType[t.type]===this.initiated){!this.options.preventDefault||n.preventDefaultException(t.target,this.options.preventDefaultException)||t.target.classList.contains("BMCollectionViewCellEventHandler")||t.target.parentNode.classList.contains("BMCollectionViewCellEventHandler")||t.preventDefault();t.changedTouches&&t.changedTouches[0];var e,o,s=n.getTime()-this.startTime,a=i.round(this.x),r=i.round(this.y),l=i.abs(a-this.startX),h=i.abs(r-this.startY),c=0,d="";if(this.isInTransition=0,this.initiated=0,this.endTime=n.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(a,r),!this.moved)return this.options.tap&&n.tap(t,this.options.tap),this.options.click&&n.click(t),void this._execEvent("scrollCancel");if(this._events.flick&&s<200&&l<100&&h<100)this._execEvent("flick");else{if(this.options.momentum&&s<300&&(e=this.hasHorizontalScroll?n.momentum(this.x,this.startX,s,this.maxScrollX,this.options.bounce?this.wrapperWidth:0,this.options.deceleration):{destination:a,duration:0},o=this.hasVerticalScroll?n.momentum(this.y,this.startY,s,this.maxScrollY,this.options.bounce?this.wrapperHeight:0,this.options.deceleration):{destination:r,duration:0},a=e.destination,r=o.destination,c=i.max(e.duration,o.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(a,r);this.currentPage=u,c=this.options.snapSpeed||i.max(i.max(i.min(i.abs(a-u.x),1e3),i.min(i.abs(r-u.y),1e3)),300),a=u.x,r=u.y,this.directionX=0,this.directionY=0,d=this.options.bounceEasing}if(a!=this.x||r!=this.y)return(a>0||a<this.maxScrollX||r>0||r<this.maxScrollY)&&(d=n.ease.quadratic),void this.scrollTo(a,r,c,d);this._execEvent("scrollEnd")}}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout((function(){t.refresh()}),this.options.resizePolling)},resetPosition:function(t){var e=this.x,i=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?e=0:this.x<this.maxScrollX&&(e=this.maxScrollX),!this.hasVerticalScroll||this.y>0?i=0:this.y<this.maxScrollY&&(i=this.maxScrollY),(e!=this.x||i!=this.y)&&(this.scrollTo(e,i,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,this.wrapperOffset=n.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,e){this._events[t]||(this._events[t]=[]),this._events[t].push(e)},off:function(t,e){if(this._events[t]){var i=this._events[t].indexOf(e);i>-1&&this._events[t].splice(i,1)}},_execEvent:function(t){if(this._events[t]){var e=0,i=this._events[t].length;if(i)for(;e<i;e++)this._events[t][e].apply(this,[].slice.call(arguments,1))}},scrollBy:function(t,e,i,o){t=this.x+t,e=this.y+e,i=i||0,this.scrollTo(t,e,i,o)},scrollTo:function(t,e,i,o){o=o||n.ease.circular,this.isInTransition=this.options.useTransition&&i>0;var s=this.options.useTransition&&o.style;!i||s?(s&&(this._transitionTimingFunction(o.style),this._transitionTime(i)),this._translate(t,e)):this._animate(t,e,i,o.fn)},scrollToElement:function(t,e,o,s,a){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=n.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,!0===o&&(o=i.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),!0===s&&(s=i.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=o||0,r.top-=s||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,e=null==e||"auto"===e?i.max(i.abs(this.x-r.left),i.abs(this.y-r.top)):e,this.scrollTo(r.left,r.top,e,a)}},_transitionTime:function(t){if(this.options.useTransition){t=t||0;var e=n.style.transitionDuration;if(e){if(this.scrollerStyle[e]=t+"ms",!t&&n.isBadAndroid){this.scrollerStyle[e]="0.0001ms";var i=this;o((function(){"0.0001ms"===i.scrollerStyle[e]&&(i.scrollerStyle[e]="0s")}))}if(this.indicators)for(var s=this.indicators.length;s--;)this.indicators[s].transitionTime(t)}}},_transitionTimingFunction:function(t){if(this.scrollerStyle[n.style.transitionTimingFunction]=t,this.indicators)for(var e=this.indicators.length;e--;)this.indicators[e].transitionTimingFunction(t)},_translate:function(t,e){if(this.options.useTransform?this.scrollerStyle[n.style.transform]="translate("+t+"px,"+e+"px)"+this.translateZ:(t=i.round(t),e=i.round(e),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=e+"px"),this.x=t,this.y=e,this.indicators)for(var o=this.indicators.length;o--;)this.indicators[o].updatePosition()},_initEvents:function(e){var i=e?n.removeEvent:n.addEvent,o=this.options.bindToWrapper?this.wrapper:t;i(t,"orientationchange",this),i(t,"resize",this),this.options.click&&i(this.wrapper,"click",this,!0),this.options.disableMouse||(i(this.wrapper,"mousedown",this),i(o,"mousemove",this),i(o,"mousecancel",this),i(o,"mouseup",this)),n.hasPointer&&!this.options.disablePointer&&(i(this.wrapper,n.prefixPointerEvent("pointerdown"),this),i(o,n.prefixPointerEvent("pointermove"),this),i(o,n.prefixPointerEvent("pointercancel"),this),i(o,n.prefixPointerEvent("pointerup"),this)),n.hasTouch&&!this.options.disableTouch&&(i(this.wrapper,"touchstart",this),i(o,"touchmove",this),i(o,"touchcancel",this),i(o,"touchend",this)),i(this.scroller,"transitionend",this),i(this.scroller,"webkitTransitionEnd",this),i(this.scroller,"oTransitionEnd",this),i(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var e,i,o=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=+((o=o[n.style.transform].split(")")[0].split(", "))[12]||o[4]),i=+(o[13]||o[5])):(e=+o.left.replace(/[^-\d.]/g,""),i=+o.top.replace(/[^-\d.]/g,"")),{x:e,y:i}},_initIndicators:function(){var t,e=this.options.interactiveScrollbars,i="string"!=typeof this.options.scrollbars,o=[],n=this;this.indicators=[],this.options.scrollbars&&(this.options.scrollY&&(t={el:a("v",e,this.options.scrollbars),interactive:e,defaultScrollbars:!0,customStyle:i,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:!1},this.wrapper.appendChild(t.el),o.push(t)),this.options.scrollX&&(t={el:a("h",e,this.options.scrollbars),interactive:e,defaultScrollbars:!0,customStyle:i,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:!1},this.wrapper.appendChild(t.el),o.push(t))),this.options.indicators&&(o=o.concat(this.options.indicators));for(var s=o.length;s--;)this.indicators.push(new r(this,o[s]));function l(t){if(n.indicators)for(var e=n.indicators.length;e--;)t.call(n.indicators[e])}this.options.fadeScrollbars&&(this.on("scrollEnd",(function(){l((function(){this.fade()}))})),this.on("scrollCancel",(function(){l((function(){this.fade()}))})),this.on("scrollStart",(function(){l((function(){this.fade(1)}))})),this.on("beforeScrollStart",(function(){l((function(){this.fade(1,!0)}))}))),this.on("refresh",(function(){l((function(){this.refresh()}))})),this.on("destroy",(function(){l((function(){this.destroy()})),delete this.indicators}))},_initWheel:function(){n.addEvent(this.wrapper,"wheel",this),n.addEvent(this.wrapper,"mousewheel",this),n.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",(function(){clearTimeout(this.wheelTimeout),this.wheelTimeout=null,n.removeEvent(this.wrapper,"wheel",this),n.removeEvent(this.wrapper,"mousewheel",this),n.removeEvent(this.wrapper,"DOMMouseScroll",this)}))},_wheel:function(t){if(this.enabled){t.preventDefault();var e,o,n,s,a=this;if(void 0===this.wheelTimeout&&a._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout((function(){a.options.snap||a._execEvent("scrollEnd"),a.wheelTimeout=void 0}),400),"deltaX"in t)1===t.deltaMode?(e=-t.deltaX*this.options.mouseWheelSpeed,o=-t.deltaY*this.options.mouseWheelSpeed):(e=-t.deltaX,o=-t.deltaY);else if("wheelDeltaX"in t)e=t.wheelDeltaX/120*this.options.mouseWheelSpeed,o=t.wheelDeltaY/120*this.options.mouseWheelSpeed;else if("wheelDelta"in t)e=o=t.wheelDelta/120*this.options.mouseWheelSpeed;else{if(!("detail"in t))return;e=o=-t.detail/3*this.options.mouseWheelSpeed}if(e*=this.options.invertWheelDirection,o*=this.options.invertWheelDirection,this.hasVerticalScroll||(e=o,o=0),this.options.snap)return n=this.currentPage.pageX,s=this.currentPage.pageY,e>0?n--:e<0&&n++,o>0?s--:o<0&&s++,void this.goToPage(n,s);n=this.x+i.round(this.hasHorizontalScroll?e:0),s=this.y+i.round(this.hasVerticalScroll?o:0),this.directionX=e>0?-1:e<0?1:0,this.directionY=o>0?-1:o<0?1:0,n>0?n=0:n<this.maxScrollX&&(n=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),this.scrollTo(n,s,0),this.options.probeType>1&&this._execEvent("scroll")}},_initSnap:function(){this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",(function(){var t,e,o,n,s,a,r=0,l=0,h=0,c=this.options.snapStepX||this.wrapperWidth,d=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(!0===this.options.snap)for(o=i.round(c/2),n=i.round(d/2);h>-this.scrollerWidth;){for(this.pages[r]=[],t=0,s=0;s>-this.scrollerHeight;)this.pages[r][t]={x:i.max(h,this.maxScrollX),y:i.max(s,this.maxScrollY),width:c,height:d,cx:h-o,cy:s-n},s-=d,t++;h-=c,r++}else for(t=(a=this.options.snap).length,e=-1;r<t;r++)(0===r||a[r].offsetLeft<=a[r-1].offsetLeft)&&(l=0,e++),this.pages[l]||(this.pages[l]=[]),h=i.max(-a[r].offsetLeft,this.maxScrollX),s=i.max(-a[r].offsetTop,this.maxScrollY),o=h-i.round(a[r].offsetWidth/2),n=s-i.round(a[r].offsetHeight/2),this.pages[l][e]={x:h,y:s,width:a[r].offsetWidth,height:a[r].offsetHeight,cx:o,cy:n},h>this.maxScrollX&&l++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),this.options.snapThreshold%1==0?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=i.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=i.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}})),this.on("flick",(function(){var t=this.options.snapSpeed||i.max(i.max(i.min(i.abs(this.x-this.startX),1e3),i.min(i.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)}))},_nearestSnap:function(t,e){if(!this.pages.length)return{x:0,y:0,pageX:0,pageY:0};var o=0,n=this.pages.length,s=0;if(i.abs(t-this.absStartX)<this.snapThresholdX&&i.abs(e-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),e>0?e=0:e<this.maxScrollY&&(e=this.maxScrollY);o<n;o++)if(t>=this.pages[o][0].cx){t=this.pages[o][0].x;break}for(n=this.pages[o].length;s<n;s++)if(e>=this.pages[0][s].cy){e=this.pages[0][s].y;break}return o==this.currentPage.pageX&&((o+=this.directionX)<0?o=0:o>=this.pages.length&&(o=this.pages.length-1),t=this.pages[o][0].x),s==this.currentPage.pageY&&((s+=this.directionY)<0?s=0:s>=this.pages[0].length&&(s=this.pages[0].length-1),e=this.pages[0][s].y),{x:t,y:e,pageX:o,pageY:s}},goToPage:function(t,e,o,n){n=n||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:t<0&&(t=0),e>=this.pages[t].length?e=this.pages[t].length-1:e<0&&(e=0);var s=this.pages[t][e].x,a=this.pages[t][e].y;o=void 0===o?this.options.snapSpeed||i.max(i.max(i.min(i.abs(s-this.x),1e3),i.min(i.abs(a-this.y),1e3)),300):o,this.currentPage={x:s,y:a,pageX:t,pageY:e},this.scrollTo(s,a,o,n)},next:function(t,e){var i=this.currentPage.pageX,o=this.currentPage.pageY;++i>=this.pages.length&&this.hasVerticalScroll&&(i=0,o++),this.goToPage(i,o,t,e)},prev:function(t,e){var i=this.currentPage.pageX,o=this.currentPage.pageY;--i<0&&this.hasVerticalScroll&&(i=0,o--),this.goToPage(i,o,t,e)},_initKeys:function(e){var i,o={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in o)this.options.keyBindings[i]=this.options.keyBindings[i]||o[i];n.addEvent(t,"keydown",this),this.on("destroy",(function(){n.removeEvent(t,"keydown",this)}))},_key:function(t){if(this.enabled){var e,o=this.options.snap,s=o?this.currentPage.pageX:this.x,a=o?this.currentPage.pageY:this.y,r=n.getTime(),l=this.keyTime||0;switch(this.options.useTransition&&this.isInTransition&&(e=this.getComputedPosition(),this._translate(i.round(e.x),i.round(e.y)),this.isInTransition=!1),this.keyAcceleration=r-l<200?i.min(this.keyAcceleration+.25,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?s+=o?1:this.wrapperWidth:a+=o?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?s-=o?1:this.wrapperWidth:a-=o?1:this.wrapperHeight;break;case this.options.keyBindings.end:s=o?this.pages.length-1:this.maxScrollX,a=o?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:s=0,a=0;break;case this.options.keyBindings.left:s+=o?-1:5+this.keyAcceleration|0;break;case this.options.keyBindings.up:a+=o?1:5+this.keyAcceleration|0;break;case this.options.keyBindings.right:s-=o?-1:5+this.keyAcceleration|0;break;case this.options.keyBindings.down:a-=o?1:5+this.keyAcceleration|0;break;default:return}o?this.goToPage(s,a):(s>0?(s=0,this.keyAcceleration=0):s<this.maxScrollX&&(s=this.maxScrollX,this.keyAcceleration=0),a>0?(a=0,this.keyAcceleration=0):a<this.maxScrollY&&(a=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(s,a,0),this.keyTime=r)}},_animate:function(t,e,i,s){var a=this,r=this.x,l=this.y,h=n.getTime(),c=h+i;this.isAnimating=!0,function d(){var u,p,g,w=n.getTime();if(w>=c)return a.isAnimating=!1,a._translate(t,e),void(a.resetPosition(a.options.bounceTime)||a._execEvent("scrollEnd"));g=s(w=(w-h)/i),u=(t-r)*g+r,p=(e-l)*g+l,a._translate(u,p),a.isAnimating&&o(d),3==a.options.probeType&&a._execEvent("scroll")}()},handleEvent:function(t){switch(t.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"wheel":case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t);break;case"click":this.enabled&&!t._constructed&&(t.preventDefault(),t.stopPropagation())}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.fadeScrollbars&&(clearTimeout(this.fadeTimeout),this.fadeTimeout=null),this.options.interactive&&(n.removeEvent(this.indicator,"touchstart",this),n.removeEvent(this.indicator,n.prefixPointerEvent("pointerdown"),this),n.removeEvent(this.indicator,"mousedown",this),n.removeEvent(t,"touchmove",this),n.removeEvent(t,n.prefixPointerEvent("pointermove"),this),n.removeEvent(t,"mousemove",this),n.removeEvent(t,"touchend",this),n.removeEvent(t,n.prefixPointerEvent("pointerup"),this),n.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(e){var i=e.touches?e.touches[0]:e;e.preventDefault(),e.stopPropagation(),this.transitionTime(),this.initiated=!0,this.moved=!1,this.lastPointX=i.pageX,this.lastPointY=i.pageY,this.startTime=n.getTime(),this.options.disableTouch||n.addEvent(t,"touchmove",this),this.options.disablePointer||n.addEvent(t,n.prefixPointerEvent("pointermove"),this),this.options.disableMouse||n.addEvent(t,"mousemove",this),this.scroller._execEvent("beforeScrollStart")},_move:function(t){var e,i,o,s,a=t.touches?t.touches[0]:t,r=n.getTime();this.moved||this.scroller._execEvent("scrollStart"),this.moved=!0,e=a.pageX-this.lastPointX,this.lastPointX=a.pageX,i=a.pageY-this.lastPointY,this.lastPointY=a.pageY,o=this.x+e,s=this.y+i,this._pos(o,s),1==this.scroller.options.probeType&&r-this.startTime>300?(this.startTime=r,this.scroller._execEvent("scroll")):this.scroller.options.probeType>1&&this.scroller._execEvent("scroll"),t.preventDefault(),t.stopPropagation()},_end:function(e){if(this.initiated){if(this.initiated=!1,e.preventDefault(),e.stopPropagation(),n.removeEvent(t,"touchmove",this),n.removeEvent(t,n.prefixPointerEvent("pointermove"),this),n.removeEvent(t,"mousemove",this),this.scroller.options.snap){var o=this.scroller._nearestSnap(this.scroller.x,this.scroller.y),s=this.options.snapSpeed||i.max(i.max(i.min(i.abs(this.scroller.x-o.x),1e3),i.min(i.abs(this.scroller.y-o.y),1e3)),300);this.scroller.x==o.x&&this.scroller.y==o.y||(this.scroller.directionX=0,this.scroller.directionY=0,this.scroller.currentPage=o,this.scroller.scrollTo(o.x,o.y,s,this.scroller.options.bounceEasing))}this.moved&&this.scroller._execEvent("scrollEnd")}},transitionTime:function(t){t=t||0;var e=n.style.transitionDuration;if(e&&(this.indicatorStyle[e]=t+"ms",!t&&n.isBadAndroid)){this.indicatorStyle[e]="0.0001ms";var i=this;o((function(){"0.0001ms"===i.indicatorStyle[e]&&(i.indicatorStyle[e]="0s")}))}},transitionTimingFunction:function(t){this.indicatorStyle[n.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(),this.options.listenX&&!this.options.listenY?this.indicatorStyle.display=this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.indicatorStyle.display=this.scroller.hasVerticalScroll?"block":"none":this.indicatorStyle.display=this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(n.addClass(this.wrapper,"iScrollBothScrollbars"),n.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(n.removeClass(this.wrapper,"iScrollBothScrollbars"),n.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px"));this.wrapper.offsetHeight;this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=i.max(i.round(this.wrapperWidth*this.wrapperWidth/(this.scroller.scrollerWidth||this.wrapperWidth||1)),32),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,"clip"==this.options.shrink?(this.minBoundaryX=8-this.indicatorWidth,this.maxBoundaryX=this.wrapperWidth-8):(this.minBoundaryX=0,this.maxBoundaryX=this.maxPosX),this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=i.max(i.round(this.wrapperHeight*this.wrapperHeight/(this.scroller.scrollerHeight||this.wrapperHeight||1)),32),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,"clip"==this.options.shrink?(this.minBoundaryY=8-this.indicatorHeight,this.maxBoundaryY=this.wrapperHeight-8):(this.minBoundaryY=0,this.maxBoundaryY=this.maxPosY),this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=this.options.listenX&&i.round(this.sizeRatioX*this.scroller.x)||0,e=this.options.listenY&&i.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(t<this.minBoundaryX?("scale"==this.options.shrink&&(this.width=i.max(this.indicatorWidth+t,8),this.indicatorStyle.width=this.width+"px"),t=this.minBoundaryX):t>this.maxBoundaryX?"scale"==this.options.shrink?(this.width=i.max(this.indicatorWidth-(t-this.maxPosX),8),this.indicatorStyle.width=this.width+"px",t=this.maxPosX+this.indicatorWidth-this.width):t=this.maxBoundaryX:"scale"==this.options.shrink&&this.width!=this.indicatorWidth&&(this.width=this.indicatorWidth,this.indicatorStyle.width=this.width+"px"),e<this.minBoundaryY?("scale"==this.options.shrink&&(this.height=i.max(this.indicatorHeight+3*e,8),this.indicatorStyle.height=this.height+"px"),e=this.minBoundaryY):e>this.maxBoundaryY?"scale"==this.options.shrink?(this.height=i.max(this.indicatorHeight-3*(e-this.maxPosY),8),this.indicatorStyle.height=this.height+"px",e=this.maxPosY+this.indicatorHeight-this.height):e=this.maxBoundaryY:"scale"==this.options.shrink&&this.height!=this.indicatorHeight&&(this.height=this.indicatorHeight,this.indicatorStyle.height=this.height+"px")),this.x=t,this.y=e,this.scroller.options.useTransform?this.indicatorStyle[n.style.transform]="translate("+t+"px,"+e+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=e+"px")},_pos:function(t,e){t<0?t=0:t>this.maxPosX&&(t=this.maxPosX),e<0?e=0:e>this.maxPosY&&(e=this.maxPosY),t=this.options.listenX?i.round(t/this.sizeRatioX):this.scroller.x,e=this.options.listenY?i.round(e/this.sizeRatioY):this.scroller.y,this.scroller.scrollTo(t,e)},fade:function(t,e){if(!e||this.visible){clearTimeout(this.fadeTimeout),this.fadeTimeout=null;var i=t?250:500,o=t?0:300;t=t?"1":"0",this.wrapperStyle[n.style.transitionDuration]=i+"ms",this.fadeTimeout=setTimeout(function(t){this.wrapperStyle.opacity=t,this.visible=+t}.bind(this,t),o)}}},s.utils=n,s}(window,document,Math);