').appendTo(e);if(n.append(t),this.settings.sortable&&(n.append('
'),this.structureDrag.addItems(e)),this.settings.newChildUrl){var r=$('
').appendTo(n);this.initNewChildMenus(r)}n.css("margin-bottom",-30),n.velocity({"margin-bottom":0},"fast")},removeElement:function(t){var e,n=this,r=t.parent().parent();this.settings.sortable&&this.structureDrag.removeItems(r),r.siblings().length||(e=r.parent()),r.css("visibility","hidden").velocity({marginBottom:-r.height()},"fast",(function(){r.remove(),void 0!==e&&n._removeUl(e)}))},_removeUl:function(t){t.siblings(".row").children(".toggle").remove(),t.remove()},destroy:function(){this.$container.removeData("structure"),this.base()}},{baseIndent:8,nestedIndent:35,defaults:{storageKey:null,sortable:!1,newChildUrl:null,maxLevels:null}})},258:function(){Craft.AssetImageEditor=Garnish.Modal.extend({$body:null,$footer:null,$imageTools:null,$buttons:null,$cancelBtn:null,$replaceBtn:null,$saveBtn:null,$focalPointBtn:null,$editorContainer:null,$straighten:null,$croppingCanvas:null,$spinner:null,$constraintContainer:null,$constraintRadioInputs:null,$customConstraints:null,canvas:null,image:null,viewport:null,focalPoint:null,focalPointInnerCircle:null,focalPointOuterCircle:null,focalPointPickedIndicator:null,grid:null,croppingCanvas:null,clipper:null,croppingRectangle:null,cropperHandles:null,cropperGrid:null,croppingShade:null,imageStraightenAngle:0,viewportRotation:0,originalWidth:0,originalHeight:0,imageVerticeCoords:null,zoomRatio:1,animationInProgress:!1,currentView:"",assetId:null,cacheBust:null,draggingCropper:!1,scalingCropper:!1,handleClicked:!1,draggingFocal:!1,focalPickedUp:!1,focalClicked:!1,cropperClicked:!1,previousMouseX:0,previousMouseY:0,shiftKeyHeld:!1,editorHeight:0,editorWidth:0,cropperState:!1,scaleFactor:1,flipData:{},focalPointState:!1,maxImageSize:null,lastLoadedDimensions:null,imageIsLoading:!1,mouseMoveEvent:null,croppingConstraint:!1,constraintOrientation:"landscape",showingCustomConstraint:!1,saving:!1,renderImage:null,renderCropper:null,_queue:null,init:function(t,e){var n=this;this._queue=new Craft.Queue,this.cacheBust=Date.now(),this.setSettings(e,Craft.AssetImageEditor.defaults),null===this.settings.allowDegreeFractions&&(this.settings.allowDegreeFractions=Craft.isImagick),Garnish.prefersReducedMotion()&&(this.settings.animationDuration=1),this.assetId=t,this.flipData={x:0,y:0},this.$container=$('
').appendTo(Garnish.$bod),this.$body=$('
').appendTo(this.$container),this.$footer=$('').appendTo(this.$container),this.base(this.$container,this.settings),this.$buttons=$('
').appendTo(this.$footer),this.$cancelBtn=$("
",{type:"button",class:"btn cancel",text:Craft.t("app","Cancel")}).appendTo(this.$buttons),this.settings.allowSavingAsNew&&(this.$saveBtn=Craft.ui.createButton({class:"save copy",label:Craft.t("app","Save as a new {type}",{type:Craft.elementTypeNames["craft\\elements\\Asset"][2]}),spinner:!0}).appendTo(this.$buttons),this.addListener(this.$saveBtn,"activate",this.saveImage)),this.$replaceBtn=Craft.ui.createSubmitButton({class:"save replace",label:Craft.t("app","Save"),spinner:!0}).appendTo(this.$buttons),this.addListener(this.$replaceBtn,"activate",this.saveImage),this.addListener(this.$cancelBtn,"activate",this.hide),this.removeListener(this.$shade,"click"),this.maxImageSize=this.getMaxImageSize(),Craft.sendActionRequest("POST","assets/image-editor",{data:{assetId:t}}).then((function(t){return n.loadEditor(t.data)}))},getMaxImageSize:function(){var t=Garnish.$doc.get(0).documentElement.clientWidth,e=Garnish.$doc.get(0).documentElement.clientHeight;return Math.max(e,t)*(window.devicePixelRatio>1?2:1)},loadEditor:function(t){var e=this;t.html||Craft.cp.displayError(Craft.t("app","Could not load the image editor.")),this.$body.html(t.html),this.$tabs=$(".tabs li",this.$body),this.$viewsContainer=$(".views",this.$body),this.$views=$("> div",this.$viewsContainer),this.$imageTools=$(".image-container .image-tools",this.$body),this.$editorContainer=$(".image-container .image",this.$body),this.$constraintContainer=$(".constraint-group",this.$body),this.$constraintRadioInputs=$('[name="constraint"]',this.$constraintContainer),this.$focalPointBtn=$(".focal-point",this.$body),this.editorHeight=this.$editorContainer.innerHeight(),this.editorWidth=this.$editorContainer.innerWidth(),this._showSpinner(),this.updateSizeAndPosition(),$customConstraintWrapper=this.$constraintRadioInputs.filter('[value="custom"]').parent(),$customConstraintGroupLabel=$customConstraintWrapper.find("label"),this.$customConstraints=$("
",{class:"constraint custom hidden","data-constraint":"custom",role:"group","aria-labelledby":$customConstraintGroupLabel.attr("id")}).append($("
",{type:"text",class:"custom-constraint-w",size:3,value:1,"aria-label":Craft.t("app","Width unit")})).append($("
",{class:"custom-constraint-spacer",text:"x","aria-hidden":"true"})).append($("
",{type:"text",class:"custom-constraint-h",size:3,value:1,"aria-label":Craft.t("app","Height unit")})).appendTo($customConstraintWrapper),this.$constraintRadioInputs.filter((function(){var t=$(this).val();return/^\d*\.\d+$/.test(t)})).addClass("flip"),this.canvas=new fabric.StaticCanvas("image-canvas"),this.$croppingCanvas=$("#cropping-canvas",this.$editorContainer),this.$croppingCanvas.width(this.editorWidth),this.$croppingCanvas.height(this.editorHeight),this.canvas.enableRetinaScaling=!0,this.renderImage=function(){Garnish.requestAnimationFrame(e.canvas.renderAll.bind(e.canvas))};var n=Craft.getActionUrl("assets/edit-image",{assetId:this.assetId,size:this.maxImageSize,cacheBust:this.cacheBust});fabric.Image.fromURL(n,(function(n){e.image=n,e.image.set({originX:"center",originY:"center",left:e.editorWidth/2,top:e.editorHeight/2}),e.canvas.add(e.image),e.originalHeight=e.image.getHeight(),e.originalWidth=e.image.getWidth(),e.zoomRatio=1,e.lastLoadedDimensions=e.getScaledImageDimensions(),e._setFittedImageVerticeCoordinates(),e._repositionEditorElements();var r={imageDimensions:e.getScaledImageDimensions(),offsetX:0,offsetY:0},i=!1;if(t.focalPoint){var a=t.focalPoint,s=r.imageDimensions.width*a.x,o=r.imageDimensions.height*a.y;r.offsetX=s-r.imageDimensions.width/2,r.offsetY=o-r.imageDimensions.height/2,i=!0}e.storeFocalPointState(r),i&&e._createFocalPoint(),e._createViewport(),e.storeCropperState(),e._addControlListeners(),e.addListener(e.$croppingCanvas,"mousemove,touchmove",e._handleMouseMove),e.addListener(e.$croppingCanvas,"mousedown,touchstart",e._handleMouseDown),e.addListener(e.$croppingCanvas,"mouseup,touchend",e._handleMouseUp),e.addListener(e.$croppingCanvas,"mouseout,touchcancel",e._handleMouseOut),e._hideSpinner(),e.renderImage(),e.$tabs.first().trigger("click")}))},_reloadImage:function(){var t=this;if(!this.imageIsLoading){this.imageIsLoading=!0,this.maxImageSize=this.getMaxImageSize();var e=Craft.getActionUrl("assets/edit-image",{assetId:this.assetId,size:this.maxImageSize,cacheBust:this.cacheBust});this.image.setSrc(e,(function(e){t.originalHeight=e.getHeight(),t.originalWidth=e.getWidth(),t.lastLoadedDimensions={width:t.originalHeight,height:t.originalWidth},t.updateSizeAndPosition(),t.renderImage(),t.imageIsLoading=!1}))}},updateSizeAndPosition:function(){if(this.$container){var t=window.innerWidth,e=window.innerHeight;this.$container.css({width:t,"min-width":t,left:0,height:e,"min-height":e,top:0}),this.$body.css({height:e-(this.$footer.outerHeight()-1)}),t
1.5||e.height/this.lastLoadedDimensions.height>1.5)&&this._reloadImage()},_repositionImage:function(t){this.image.set({left:this.image.left-(t.width-this.editorWidth)/2,top:this.image.top-(t.height-this.editorHeight)/2})},_createViewport:function(){this.viewport=new fabric.Rect({width:this.image.width,height:this.image.height,fill:"rgba(127,0,0,1)",originX:"center",originY:"center",globalCompositeOperation:"destination-in",left:this.image.left,top:this.image.top}),this.canvas.add(this.viewport),this.renderImage()},_createFocalPoint:function(){var t=this.focalPointState,e=this.getScaledImageDimensions().width/t.imageDimensions.width,n=t.offsetX*e*this.zoomRatio*this.scaleFactor,r=t.offsetY*e*this.zoomRatio*this.scaleFactor;n+=this.image.left,r+=this.image.top;var i=0,a=0;this.viewport&&0===t.offsetX&&0===t.offsetY&&("crop"!==this.currentView?(i=this.viewport.left-this.image.left,a=this.viewport.top-this.image.top):(i=this.clipper.left-this.image.left,a=this.clipper.top-this.image.top),n+=i,r+=a,t.offsetX+=i/(e*this.zoomRatio*this.scaleFactor),t.offsetY+=a/(e*this.zoomRatio*this.scaleFactor)),this.focalPointOuterCircle=new fabric.Circle({radius:8,fill:"rgba(0,0,0,0.5)",strokeWidth:2,stroke:"rgba(255,255,255,0.8)",left:0,top:0,originX:"center",originY:"center"}),this.focalPointInnerCircle=new fabric.Circle({radius:1,fill:"rgba(255,255,255,0)",strokeWidth:2,stroke:"rgba(255,255,255,0.8)",left:0,top:0,originX:"center",originY:"center"}),this.focalPointPickedIndicator=new fabric.Circle({radius:12,strokeWidth:0,stroke:"rgba(255,255,255,0.8)",left:0,top:0,originX:"center",originY:"center"}),this.focalPoint=new fabric.Group([this.focalPointPickedIndicator,this.focalPointOuterCircle,this.focalPointInnerCircle],{originX:"center",originY:"center",left:n,top:r}),this.storeFocalPointState(t),this.canvas.add(this.focalPoint)},toggleFocalPoint:function(){this.focalPoint?(this.canvas.remove(this.focalPoint),this.focalPoint=null,this.$focalPointBtn.attr("aria-pressed","false")):(this._createFocalPoint(),this.$focalPointBtn.attr("aria-pressed","true")),this.renderImage()},_repositionViewport:function(){if(this.viewport){var t={left:this.editorWidth/2,top:this.editorHeight/2};if("crop"===this.currentView)t.width=this.editorWidth,t.height=this.editorHeight;else if(this.cropperState){var e=this.cropperState,n=this.getScaledImageDimensions().width/e.imageDimensions.width;t.width=e.width*n*this.zoomRatio,t.height=e.height*n*this.zoomRatio,this.image.set({left:this.editorWidth/2-e.offsetX*n,top:this.editorHeight/2-e.offsetY*n})}else $.extend(t,this.getScaledImageDimensions());this.viewport.set(t)}},_repositionFocalPoint:function(t){if(this.focalPoint){var e=this.focalPoint.left-this.editorWidth/2,n=this.focalPoint.top-this.editorHeight/2,r=this.image.width,i=this.getScaledImageDimensions().width*this.zoomRatio/r/this.scaleFactor;e-=(t.width-this.editorWidth)/2,n-=(t.height-this.editorHeight)/2,e*=i,n*=i,this.focalPoint.set({left:this.editorWidth/2+e,top:this.editorHeight/2+n})}},hasOrientationChanged:function(){return this.viewportRotation%180!=0},getScaledImageDimensions:function(){return void 0===this.getScaledImageDimensions._&&(this.getScaledImageDimensions._={}),this.getScaledImageDimensions._.imageRatio=this.originalHeight/this.originalWidth,this.getScaledImageDimensions._.editorRatio=this.editorHeight/this.editorWidth,this.getScaledImageDimensions._.dimensions={},this.getScaledImageDimensions._.imageRatio>this.getScaledImageDimensions._.editorRatio?(this.getScaledImageDimensions._.dimensions.height=Math.min(this.editorHeight,this.originalHeight),this.getScaledImageDimensions._.dimensions.width=Math.round(this.originalWidth/(this.originalHeight/this.getScaledImageDimensions._.dimensions.height))):(this.getScaledImageDimensions._.dimensions.width=Math.min(this.editorWidth,this.originalWidth),this.getScaledImageDimensions._.dimensions.height=Math.round(this.originalHeight*(this.getScaledImageDimensions._.dimensions.width/this.originalWidth))),this.getScaledImageDimensions._.dimensions},_zoomImage:function(){void 0===this._zoomImage._&&(this._zoomImage._={}),this._zoomImage._.imageDimensions=this.getScaledImageDimensions(),this.image.set({width:this._zoomImage._.imageDimensions.width*this.zoomRatio,height:this._zoomImage._.imageDimensions.height*this.zoomRatio})},_getPrevTab:function(){var t,e=this._getActiveTabIndex();if(!(e<0))return t=e>0?e-1:this.$tabs.length-1,this.$tabs.eq(t)},_getNextTab:function(){var t,e=this._getActiveTabIndex();if(!(e<0))return t=e0&&t.h>0&&(this.setCroppingConstraint(t.w/t.h),this.enforceCroppingConstraint())},_getCustomConstraint:function(){var t=parseFloat($(".custom-constraint-w").val()),e=parseFloat($(".custom-constraint-h").val());return{w:isNaN(t)?0:t,h:isNaN(e)?0:e}},_setCustomConstraint:function(t,e){$(".custom-constraint-w").val(parseFloat(t)),$(".custom-constraint-h").val(parseFloat(e))},_hideCustomConstraint:function(){this.showingCustomConstraint=!1,this.$customConstraints.addClass("hidden"),$(".orientation",this.$container).removeClass("hidden")},_showCustomConstraint:function(){this.showingCustomConstraint||(this.showingCustomConstraint=!0,this.$customConstraints.removeClass("hidden"),$(".orientation",this.$container).addClass("hidden"))},_handleTabClick:function(t){if(!this.animationInProgress){var e=$(t.currentTarget);this.activateTab(e)}},activateTab:function(t){var e=$(t).data("view");this.$tabs.removeClass("selected").attr({"aria-selected":"false",tabindex:"-1"}),$(t).addClass("selected").attr({"aria-selected":"true",tabindex:"0"}).focus(),this.showView(e)},showView:function(t){var e=this;this.currentView!==t&&(this.$views.addClass("hidden"),this.$views.filter('[data-view="'+t+'"]').removeClass("hidden"),"rotate"===t?this.enableSlider():this.disableSlider(),this.updateSizeAndPosition(),"crop"===this.currentView&&"crop"!==t?this._queue.push((function(){return new Promise((function(t,n){e.disableCropMode(),t()}))})):"crop"!==this.currentView&&"crop"===t&&this._queue.push((function(){return new Promise((function(t,n){e.enableCropMode(),t()}))})),this.currentView=t)},storeCropperState:function(t){void 0===this.storeCropperState._&&(this.storeCropperState._={}),t?this.cropperState=t:this.clipper?(this.storeCropperState._.zoomFactor=1/this.zoomRatio,this.cropperState={offsetX:(this.clipper.left-this.image.left)*this.storeCropperState._.zoomFactor,offsetY:(this.clipper.top-this.image.top)*this.storeCropperState._.zoomFactor,height:this.clipper.height*this.storeCropperState._.zoomFactor,width:this.clipper.width*this.storeCropperState._.zoomFactor,imageDimensions:this.getScaledImageDimensions()}):(this.storeCropperState._.dimensions=this.getScaledImageDimensions(),this.cropperState={offsetX:0,offsetY:0,height:this.storeCropperState._.dimensions.height,width:this.storeCropperState._.dimensions.width,imageDimensions:this.storeCropperState._.dimensions})},storeFocalPointState:function(t){void 0===this.storeFocalPointState._&&(this.storeFocalPointState._={}),t?this.focalPointState=t:this.focalPoint&&(this.storeFocalPointState._.zoomFactor=1/this.zoomRatio,this.focalPointState={offsetX:(this.focalPoint.left-this.image.left)*this.storeFocalPointState._.zoomFactor/this.scaleFactor,offsetY:(this.focalPoint.top-this.image.top)*this.storeFocalPointState._.zoomFactor/this.scaleFactor,imageDimensions:this.getScaledImageDimensions()})},rotateImage:function(t){var e=this;if(!this.animationInProgress){if(90!==t&&-90!==t)return!1;this.animationInProgress=!0,this.viewportRotation+=t,this.viewportRotation=parseInt((this.viewportRotation+360)%360,10);var n,r=this.image.angle+t,i=this.getScaledImageDimensions();n=this.hasOrientationChanged()?this.getZoomToCoverRatio({height:i.width,width:i.height}):this.getZoomToCoverRatio(i),this.zoomRatio>n&&(n=this.zoomRatio);var a={angle:90===t?"+=90":"-=90"},s={angle:r,width:i.width*n,height:i.height*n},o=1;this.scaleFactor<1?(o=1/this.scaleFactor,this.scaleFactor=1):(this.viewport.width>this.editorHeight?o=this.editorHeight/this.viewport.width:this.viewport.height>this.editorWidth&&(o=this.editorWidth/this.viewport.height),this.scaleFactor=o),o<1&&(s.width*=o,s.height*=o);var l=this.cropperState,c=l.offsetX,u=l.offsetY,h=t*(Math.PI/180),d=c*Math.cos(h)-u*Math.sin(h),f=c*Math.sin(h)+u*Math.cos(h),p=i.width/l.imageDimensions.width,g=d*p*this.zoomRatio*this.scaleFactor,m=f*p*this.zoomRatio*this.scaleFactor;s.left=this.editorWidth/2-g,s.top=this.editorHeight/2-m,l.offsetX=d,l.offsetY=f;var v=l.width;l.width=l.height,l.height=v,this.storeCropperState(l),this.focalPoint&&this.canvas.remove(this.focalPoint),this.viewport.animate(a,{duration:this.settings.animationDuration,onComplete:function(){var t=e.viewport.height*o;e.viewport.height=e.viewport.width*o,e.viewport.width=t,e.viewport.set({angle:0})}}),this.image.animate(s,{onChange:this.canvas.renderAll.bind(this.canvas),duration:this.settings.animationDuration,onComplete:function(){var n=parseFloat((e.image.angle+360)%360);e.image.set({angle:n}),e.animationInProgress=!1,e.focalPoint?(e._adjustFocalPointByAngle(t),e.straighten(e.straighteningInput),e.canvas.add(e.focalPoint)):e._resetFocalPointPosition()}})}},flipImage:function(t){var e=this;if(!this.animationInProgress){this.animationInProgress=!0,this.hasOrientationChanged()&&(t="y"===t?"x":"y"),this.focalPoint?this.canvas.remove(this.focalPoint):this._resetFocalPointPosition();var n={x:this.editorWidth/2,y:this.editorHeight/2};this.straighteningInput.setValue(-this.imageStraightenAngle),this.imageStraightenAngle=-this.imageStraightenAngle;var r,i,a={angle:this.viewportRotation+this.imageStraightenAngle},s=this.cropperState,o=this.focalPointState;"y"===t&&this.hasOrientationChanged()||"y"!==t&&!this.hasOrientationChanged()?(s.offsetX=-s.offsetX,o.offsetX=-o.offsetX,i=this.image.left-n.x,a.left=n.x-i):(s.offsetY=-s.offsetY,o.offsetY=-o.offsetY,r=this.image.top-n.y,a.top=n.y-r),"y"===t?(a.scaleY=-1*this.image.scaleY,this.flipData.y=1-this.flipData.y):(a.scaleX=-1*this.image.scaleX,this.flipData.x=1-this.flipData.x),this.storeCropperState(s),this.storeFocalPointState(o),this.image.animate(a,{onChange:this.canvas.renderAll.bind(this.canvas),duration:this.settings.animationDuration,onComplete:function(){e.animationInProgress=!1,e.focalPoint&&(e._adjustFocalPointByAngle(0),e.canvas.add(e.focalPoint))}})}},straighten:function(t){if(!this.animationInProgress){this.animationInProgress=!0;var e=this.image.angle;this.imageStraightenAngle=(this.settings.allowDegreeFractions?parseFloat(t.value):Math.round(parseFloat(t.value)))%360,this.image.set({angle:this.viewportRotation+this.imageStraightenAngle}),this.zoomRatio=this.getZoomToCoverRatio(this.getScaledImageDimensions())*this.scaleFactor,this._zoomImage(),this.cropperState&&this._adjustEditorElementsOnStraighten(e),this.renderImage(),this.animationInProgress=!1}},_adjustEditorElementsOnStraighten:function(t){var e,n,r,i,a,s=this.getScaledImageDimensions(),o=this.image.angle-t,l=this.cropperState,c=this.zoomRatio,u=1;do{var h=l.offsetX,d=l.offsetY,f=o*(Math.PI/180);r=h*Math.cos(f)-d*Math.sin(f),i=h*Math.sin(f)+d*Math.cos(f),e=r*c*(a=s.width/l.imageDimensions.width),n=i*c*a;var p=this.getImageVerticeCoords(c),g={width:this.viewport.width,height:this.viewport.height,left:this.editorWidth/2-this.viewport.width/2+e,top:this.editorHeight/2-this.viewport.height/2+n};c*=u=this._getZoomRatioToFitRectangle(g,p)}while(1!==u);this.image.set({left:this.editorWidth/2-e,top:this.editorHeight/2-n}),l.offsetX=r,l.offsetY=i,l.width=this.viewport.width/c/a,l.height=this.viewport.height/c/a,this.storeCropperState(l),this.zoomRatio=c,this.focalPoint?(this._adjustFocalPointByAngle(o),this._isCenterInside(this.focalPoint,this.viewport)?this.focalPoint.set({opacity:1}):this.focalPoint.set({opacity:0})):0!==o&&this._resetFocalPointPosition(),this._zoomImage()},_cleanupFocalPointAfterStraighten:function(){if(this.focalPoint&&!this._isCenterInside(this.focalPoint,this.viewport)){this.focalPoint.set({opacity:1});var t=this.focalPointState;t.offsetX=0,t.offsetY=0,this.storeFocalPointState(t),this.toggleFocalPoint()}},_resetFocalPointPosition:function(){var t=this.focalPointState;t.offsetX=0,t.offsetY=0,this.storeFocalPointState(t)},_isCenterInside:function(t,e){return t.left>e.left-e.width/2&&t.top>e.top-e.height/2&&t.leftthis.editorHeight||e.width>this.editorWidth){var r=this.editorHeight/e.height,i=this.editorWidth/e.width;n=Math.min(i,r)}return n},getCombinedZoomRatio:function(t){return this.getZoomToCoverRatio(t)/this.getZoomToFitRatio(t)},_showGrid:function(){if(!this.grid){var t,e={strokeWidth:1,stroke:"rgba(255,255,255,0.5)"},n=this.viewport.width,r=this.viewport.height,i=n/9,a=r/9,s=[new fabric.Rect({strokeWidth:2,stroke:"rgba(255,255,255,1)",originX:"center",originY:"center",width:n,height:r,left:n/2,top:r/2,fill:"rgba(255,255,255,0)"})];for(t=1;t<=8;t++)s.push(new fabric.Line([t*i,0,t*i,r],e));for(t=1;t<=8;t++)s.push(new fabric.Line([0,t*a,n,t*a],e));this.grid=new fabric.Group(s,{left:this.editorWidth/2,top:this.editorHeight/2,originX:"center",originY:"center",angle:this.viewport.angle}),this.canvas.add(this.grid),this.renderImage()}},_hideGrid:function(){this.canvas.remove(this.grid),this.grid=null,this.renderImage()},onFadeOut:function(){this.destroy()},show:function(){this.base(),Garnish.$bod.addClass("no-scroll")},hide:function(){this.removeAllListeners(),this.straighteningInput.removeAllListeners(),Garnish.$bod.removeClass("no-scroll"),this.base()},onSave:function(t){this.settings.onSave(t),this.trigger("save")},enableSlider:function(){this.$imageTools.removeClass("hidden")},disableSlider:function(){this.$imageTools.addClass("hidden")},enableCropMode:function(){var t=this,e=this.getScaledImageDimensions();this.zoomRatio=this.getZoomToFitRatio(e);var n={width:this.editorWidth,height:this.editorHeight},r={width:e.width*this.zoomRatio,height:e.height*this.zoomRatio,left:this.editorWidth/2,top:this.editorHeight/2};this._editorModeTransition((function(){t._setFittedImageVerticeCoordinates();var e=t.cropperState,n=t.getScaledImageDimensions(),r=n.width/e.imageDimensions.width,i={left:t.image.left+e.offsetX*r*t.zoomRatio,top:t.image.top+e.offsetY*r*t.zoomRatio,width:e.width*r*t.zoomRatio,height:e.height*r*t.zoomRatio};t._showCropper(i),t.focalPoint&&(r=n.width/t.focalPointState.imageDimensions.width,t.focalPoint.left=t.image.left+t.focalPointState.offsetX*r*t.zoomRatio,t.focalPoint.top=t.image.top+t.focalPointState.offsetY*r*t.zoomRatio,t.canvas.add(t.focalPoint))}),r,n)},disableCropMode:function(){var t=this,e={};this._hideCropper();var n=this.getScaledImageDimensions(),r=this.getZoomToCoverRatio(n)*this.scaleFactor,i=r/this.zoomRatio;this.zoomRatio=r;var a={width:n.width*this.zoomRatio,height:n.height*this.zoomRatio,left:this.editorWidth/2,top:this.editorHeight/2},s=(this.clipper.left-this.image.left)*i,o=(this.clipper.top-this.image.top)*i;a.left=this.editorWidth/2-s,a.top=this.editorHeight/2-o,e.height=this.clipper.height*i,e.width=this.clipper.width*i,(!this.focalPoint||this.focalPoint&&!this._isCenterInside(this.focalPoint,this.clipper))&&(this.focalPoint&&this.toggleFocalPoint(),this._resetFocalPointPosition()),this._editorModeTransition((function(){if(t.focalPoint){var e=t.getScaledImageDimensions().width/t.focalPointState.imageDimensions.width;t.focalPoint.left=t.image.left+t.focalPointState.offsetX*e*t.zoomRatio,t.focalPoint.top=t.image.top+t.focalPointState.offsetY*e*t.zoomRatio,t.canvas.add(t.focalPoint)}}),a,e)},_editorModeTransition:function(t,e,n){var r=this;this._queue.pause(),this.animationInProgress||(this.animationInProgress=!0,this.focalPoint&&(this.canvas.remove(this.focalPoint),this.renderImage()),this.image.animate(e,{onChange:this.canvas.renderAll.bind(this.canvas),duration:this.settings.animationDuration,onComplete:function(){t(),r.animationInProgress=!1,r.renderImage(),r._queue.resume()}}),this.viewport.animate(n,{duration:this.settings.animationDuration}))},_showSpinner:function(){this.$spinner||(this.$spinner=$('
')),this.$spinner.appendTo(this.$container.find(".image"))},_hideSpinner:function(){this.$spinner.remove()},_showCropper:function(t){this._setupCropperLayer(t),this._redrawCropperElements(),this.renderCropper()},_hideCropper:function(){this.clipper&&(this.croppingCanvas.remove(this.clipper),this.croppingCanvas.remove(this.croppingShade),this.croppingCanvas.remove(this.cropperHandles),this.croppingCanvas.remove(this.cropperGrid),this.croppingCanvas.remove(this.croppingRectangle),this.croppingCanvas=null,this.renderCropper=null)},_setupCropperLayer:function(t){var e=this;this.croppingCanvas=new fabric.StaticCanvas("cropping-canvas",{backgroundColor:"rgba(0,0,0,0)",hoverCursor:"default",selection:!1}),this.croppingCanvas.setDimensions({width:this.editorWidth,height:this.editorHeight}),this.renderCropper=function(){return Garnish.requestAnimationFrame(e.croppingCanvas.renderAll.bind(e.croppingCanvas))},$("#cropping-canvas",this.$editorContainer).css({position:"absolute",top:0,left:0}),this.croppingShade=new fabric.Rect({left:this.editorWidth/2,top:this.editorHeight/2,originX:"center",originY:"center",width:this.editorWidth,height:this.editorHeight,fill:"rgba(0,0,0,0.7)"});var n=this.getScaledImageDimensions(),r=0===this.imageStraightenAngle?1:1.2*this.getCombinedZoomRatio(n),i=n.width/r,a=n.height/r;if(this.hasOrientationChanged()){var s=a;a=i,i=s}this.clipper=new fabric.Rect({left:this.editorWidth/2,top:this.editorHeight/2,originX:"center",originY:"center",width:i,height:a,stroke:"black",fill:"rgba(128,0,0,1)",strokeWidth:0}),t&&this.clipper.set(t),this.clipper.globalCompositeOperation="destination-out",this.croppingCanvas.add(this.croppingShade),this.croppingCanvas.add(this.clipper)},_redrawCropperElements:function(){void 0===this._redrawCropperElements._&&(this._redrawCropperElements._={}),this.cropperHandles&&(this.croppingCanvas.remove(this.cropperHandles),this.croppingCanvas.remove(this.cropperGrid),this.croppingCanvas.remove(this.croppingRectangle)),this._redrawCropperElements._.lineOptions={strokeWidth:4,stroke:"rgb(255,255,255)",fill:!1},this._redrawCropperElements._.gridOptions={strokeWidth:2,stroke:"rgba(255,255,255,0.5)"},this._redrawCropperElements._.pathGroup=[new fabric.Path("M 0,10 L 0,0 L 10,0",this._redrawCropperElements._.lineOptions),new fabric.Path("M "+(this.clipper.width-8)+",0 L "+(this.clipper.width+4)+",0 L "+(this.clipper.width+4)+",10",this._redrawCropperElements._.lineOptions),new fabric.Path("M "+(this.clipper.width+4)+","+(this.clipper.height-8)+" L"+(this.clipper.width+4)+","+(this.clipper.height+4)+" L "+(this.clipper.width-8)+","+(this.clipper.height+4),this._redrawCropperElements._.lineOptions),new fabric.Path("M 10,"+(this.clipper.height+4)+" L 0,"+(this.clipper.height+4)+" L 0,"+(this.clipper.height-8),this._redrawCropperElements._.lineOptions)],this.cropperHandles=new fabric.Group(this._redrawCropperElements._.pathGroup,{left:this.clipper.left,top:this.clipper.top,originX:"center",originY:"center"}),this.croppingRectangle=new fabric.Rect({left:this.clipper.left,top:this.clipper.top,width:this.clipper.width,height:this.clipper.height,fill:"rgba(0,0,0,0)",stroke:"rgba(255,255,255,0.8)",strokeWidth:2,originX:"center",originY:"center"}),this.cropperGrid=new fabric.Group([new fabric.Line([.33*this.clipper.width,0,.33*this.clipper.width,this.clipper.height],this._redrawCropperElements._.gridOptions),new fabric.Line([.66*this.clipper.width,0,.66*this.clipper.width,this.clipper.height],this._redrawCropperElements._.gridOptions),new fabric.Line([0,.33*this.clipper.height,this.clipper.width,.33*this.clipper.height],this._redrawCropperElements._.gridOptions),new fabric.Line([0,.66*this.clipper.height,this.clipper.width,.66*this.clipper.height],this._redrawCropperElements._.gridOptions)],{left:this.clipper.left,top:this.clipper.top,originX:"center",originY:"center"}),this._redrawCropperElements._.cropTextTop=this.croppingRectangle.top+this.clipper.height/2+12,this._redrawCropperElements._.cropTextBackgroundColor="rgba(0,0,0,0)",this._redrawCropperElements._.cropTextTop+12>this.editorHeight-2&&(this._redrawCropperElements._.cropTextTop-=24,this._redrawCropperElements._.cropTextBackgroundColor="rgba(0,0,0,0.5)"),this.croppingCanvas.add(this.cropperHandles),this.croppingCanvas.add(this.cropperGrid),this.croppingCanvas.add(this.croppingRectangle)},_repositionCropper:function(t){if(this.croppingCanvas){var e=this.clipper.left-this.croppingCanvas.width/2,n=this.clipper.top-this.croppingCanvas.height/2;this.croppingCanvas.setDimensions({width:this.editorWidth,height:this.editorHeight});var r=this._getBoundingRectangle(this.imageVerticeCoords).width/t.width;this.clipper.width=Math.round(this.clipper.width*r),this.clipper.height=Math.round(this.clipper.height*r),this.clipper.left=this.editorWidth/2+e*r,this.clipper.top=this.editorHeight/2+n*r,this.croppingShade.set({width:this.editorWidth,height:this.editorHeight,left:this.editorWidth/2,top:this.editorHeight/2}),this._redrawCropperElements(),this.renderCropper()}},_getBoundingRectangle:function(t){return{width:Math.max(t.a.x,t.b.x,t.c.x,t.d.x)-Math.min(t.a.x,t.b.x,t.c.x,t.d.x),height:Math.max(t.a.y,t.b.y,t.c.y,t.d.y)-Math.min(t.a.y,t.b.y,t.c.y,t.d.y)}},_handleMouseDown:function(t){var e=this.focalPoint&&this._isMouseOver(t,this.focalPoint),n=this.croppingCanvas&&this._isMouseOver(t,this.clipper),r=this.croppingCanvas&&this._cropperHandleHitTest(t);(r||n||e)&&(this.previousMouseX=t.pageX,this.previousMouseY=t.pageY,e?this.focalClicked=!0:r?this.handleClicked=r:n&&(this.cropperClicked=!0))},_toggleFocalModeStyles:function(){var t,e;this.focalPickedUp?(t=2,e="rgba(0,0,0,0.5)",$(".body").css("cursor","grabbing")):(t=0,e="rgba(0,0,0,0)",$(".body").css("cursor","pointer")),this.focalPointPickedIndicator.set({strokeWidth:t,fill:e}),this.canvas.renderAll()},_handleMouseMove:function(t){null!==this.mouseMoveEvent&&Garnish.requestAnimationFrame(this._handleMouseMoveInternal.bind(this)),this.mouseMoveEvent=t},_handleMouseMoveInternal:function(){null!==this.mouseMoveEvent&&(this.focalPoint&&this.focalClicked?(this.draggingFocal=!0,this._handleFocalDrag(this.mouseMoveEvent),this.storeFocalPointState(),this.renderImage()):this.cropperClicked||this.handleClicked?(this.cropperClicked?(this.draggingCropper=!0,this._handleCropperDrag(this.mouseMoveEvent)):(this.scalingCropper=!0,this._handleCropperResize(this.mouseMoveEvent)),this._redrawCropperElements(),this.storeCropperState(),this.renderCropper()):this._setMouseCursor(this.mouseMoveEvent),this.previousMouseX=this.mouseMoveEvent.pageX,this.previousMouseY=this.mouseMoveEvent.pageY,this.mouseMoveEvent=null)},_handleMouseUp:function(t){this.focalClicked?this.draggingFocal||(this.focalPickedUp=!this.focalPickedUp,this._toggleFocalModeStyles()):!this.focalPickedUp||this.draggingFocal||this.draggingCropper||this.scalingCropper||this._handleFocalClickToMove(t),this.draggingCropper=!1,this.cropperClicked=!1,this.scalingCropper=!1,this.handleClicked=!1,this.draggingFocal=!1,this.focalClicked=!1},_handleMouseOut:function(t){this._handleMouseUp(t),this.mouseMoveEvent=t,this._handleMouseMoveInternal()},_handleFocalClickToMove:function(t){if(void 0===this._handleFocalClickToMove._&&(this._handleFocalClickToMove._={}),this.focalPoint){this.focalPoint.get("left"),this.focalPoint.get("top");var e=this.$croppingCanvas.offset(),n=e.left,r=e.top;if(this._handleFocalClickToMove._.newX=t.pageX-n,this._handleFocalClickToMove._.newY=t.pageY-r,"crop"===this.currentView){if(!this.arePointsInsideRectangle([{x:this._handleFocalClickToMove._.newX,y:this._handleFocalClickToMove._.newY}],this.imageVerticeCoords))return}else if(!this.isPointInsideViewport({x:this._handleFocalClickToMove._.newX,y:this._handleFocalClickToMove._.newY}))return;this.focalPoint.set({left:this._handleFocalClickToMove._.newX,top:this._handleFocalClickToMove._.newY}),this.storeFocalPointState(),this.renderImage()}},_handleCropperDrag:function(t){if(void 0===this._handleCropperDrag._&&(this._handleCropperDrag._={}),this._handleCropperDrag._.deltaX=t.pageX-this.previousMouseX,this._handleCropperDrag._.deltaY=t.pageY-this.previousMouseY,0===this._handleCropperDrag._.deltaX&&0===this._handleCropperDrag._.deltaY)return!1;if(this._handleCropperDrag._.rectangle={left:this.clipper.left-this.clipper.width/2,top:this.clipper.top-this.clipper.height/2,width:this.clipper.width,height:this.clipper.height},this._handleCropperDrag._.vertices=this._getRectangleVertices(this._handleCropperDrag._.rectangle,this._handleCropperDrag._.deltaX,this._handleCropperDrag._.deltaY),!this.arePointsInsideRectangle(this._handleCropperDrag._.vertices,this.imageVerticeCoords)){for(this._handleCropperDrag._.dxi=0,this._handleCropperDrag._.dyi=0,this._handleCropperDrag._.xStep=this._handleCropperDrag._.deltaX>0?-1:1,this._handleCropperDrag._.yStep=this._handleCropperDrag._.deltaY>0?-1:1,this._handleCropperDrag._.furthest=0,this._handleCropperDrag._.furthestDeltas={},this._handleCropperDrag._.dxi=Math.min(Math.abs(this._handleCropperDrag._.deltaX),10);this._handleCropperDrag._.dxi>=0;this._handleCropperDrag._.dxi--)for(this._handleCropperDrag._.dyi=Math.min(Math.abs(this._handleCropperDrag._.deltaY),10);this._handleCropperDrag._.dyi>=0;this._handleCropperDrag._.dyi--)this._handleCropperDrag._.vertices=this._getRectangleVertices(this._handleCropperDrag._.rectangle,this._handleCropperDrag._.dxi*(this._handleCropperDrag._.deltaX>0?1:-1),this._handleCropperDrag._.dyi*(this._handleCropperDrag._.deltaY>0?1:-1)),this.arePointsInsideRectangle(this._handleCropperDrag._.vertices,this.imageVerticeCoords)&&this._handleCropperDrag._.dxi+this._handleCropperDrag._.dyi>this._handleCropperDrag._.furthest&&(this._handleCropperDrag._.furthest=this._handleCropperDrag._.dxi+this._handleCropperDrag._.dyi,this._handleCropperDrag._.furthestDeltas={x:this._handleCropperDrag._.dxi*(this._handleCropperDrag._.deltaX>0?1:-1),y:this._handleCropperDrag._.dyi*(this._handleCropperDrag._.deltaY>0?1:-1)});if(0==this._handleCropperDrag._.furthest)return;this._handleCropperDrag._.deltaX=this._handleCropperDrag._.furthestDeltas.x,this._handleCropperDrag._.deltaY=this._handleCropperDrag._.furthestDeltas.y}this.clipper.set({left:this.clipper.left+this._handleCropperDrag._.deltaX,top:this.clipper.top+this._handleCropperDrag._.deltaY})},_handleFocalDrag:function(t){if(void 0===this._handleFocalDrag._&&(this._handleFocalDrag._={}),this.focalPoint){if(this._handleFocalDrag._.deltaX=t.pageX-this.previousMouseX,this._handleFocalDrag._.deltaY=t.pageY-this.previousMouseY,0===this._handleFocalDrag._.deltaX&&0===this._handleFocalDrag._.deltaY)return;if(this._handleFocalDrag._.newX=this.focalPoint.left+this._handleFocalDrag._.deltaX,this._handleFocalDrag._.newY=this.focalPoint.top+this._handleFocalDrag._.deltaY,"crop"===this.currentView){if(!this.arePointsInsideRectangle([{x:this._handleFocalDrag._.newX,y:this._handleFocalDrag._.newY}],this.imageVerticeCoords))return}else if(!this.isPointInsideViewport({x:this._handleFocalDrag._.newX,y:this._handleFocalDrag._.newY}))return;this.focalPoint.set({left:this.focalPoint.left+this._handleFocalDrag._.deltaX,top:this.focalPoint.top+this._handleFocalDrag._.deltaY})}},isPointInsideViewport:function(t){return this.viewport.left-this.viewport.width/2-t.x<0&&this.viewport.left+this.viewport.width/2-t.x>0&&this.viewport.top-this.viewport.height/2-t.y<0&&this.viewport.top+this.viewport.height/2-t.y>0},setCroppingConstraint:function(t){switch(this.updateSizeAndPosition(),t){case"none":this.croppingConstraint=!1;break;case"original":this.croppingConstraint=this.originalWidth/this.originalHeight;break;case"current":this.croppingConstraint=this.clipper.width/this.clipper.height;break;case"custom":break;default:this.croppingConstraint=parseFloat(t)}},enforceCroppingConstraint:function(){var t=this;void 0===this.enforceCroppingConstraint._&&(this.enforceCroppingConstraint._={}),!this.animationInProgress&&this.croppingConstraint&&(this.animationInProgress=!0,this.enforceCroppingConstraint._.rectangle={left:this.clipper.left-this.clipper.width/2,top:this.clipper.top-this.clipper.height/2,width:this.clipper.width,height:this.clipper.height},this.clipper.width>this.clipper.height*this.croppingConstraint?(this.enforceCroppingConstraint._.previousHeight=this.enforceCroppingConstraint._.rectangle.height,this.enforceCroppingConstraint._.rectangle.height=this.clipper.width/this.croppingConstraint,this.enforceCroppingConstraint._.rectangle.top-=(this.enforceCroppingConstraint._.rectangle.height-this.enforceCroppingConstraint._.previousHeight)/2,this.arePointsInsideRectangle(this._getRectangleVertices(this.enforceCroppingConstraint._.rectangle),this.imageVerticeCoords)||(this.enforceCroppingConstraint._.rectangle.width=this.clipper.height*this.croppingConstraint,this.enforceCroppingConstraint._.rectangle.height=this.enforceCroppingConstraint._.rectangle.width/this.croppingConstraint)):(this.enforceCroppingConstraint._.previousWidth=this.enforceCroppingConstraint._.rectangle.width,this.enforceCroppingConstraint._.rectangle.width=this.clipper.height*this.croppingConstraint,this.enforceCroppingConstraint._.rectangle.left-=(this.enforceCroppingConstraint._.rectangle.width-this.enforceCroppingConstraint._.previousWidth)/2,this.arePointsInsideRectangle(this._getRectangleVertices(this.enforceCroppingConstraint._.rectangle),this.imageVerticeCoords)||(this.enforceCroppingConstraint._.rectangle.height=this.clipper.width/this.croppingConstraint,this.enforceCroppingConstraint._.rectangle.width=this.enforceCroppingConstraint._.rectangle.height*this.croppingConstraint)),this.enforceCroppingConstraint._.properties={height:this.enforceCroppingConstraint._.rectangle.height,width:this.enforceCroppingConstraint._.rectangle.width},this.clipper.animate(this.enforceCroppingConstraint._.properties,{onChange:function(){t._redrawCropperElements(),t.croppingCanvas.renderAll()},duration:this.settings.animationDuration,onComplete:function(){t._redrawCropperElements(),t.animationInProgress=!1,t.renderCropper(),t.storeCropperState()}}))},_handleCropperResize:function(t){void 0===this._handleCropperResize._&&(this._handleCropperResize._={}),this._handleCropperResize._.deltaX=t.pageX-this.previousMouseX,this._handleCropperResize._.deltaY=t.pageY-this.previousMouseY,"b"!==this.handleClicked&&"t"!==this.handleClicked||(this._handleCropperResize._.deltaX=0),"l"!==this.handleClicked&&"r"!==this.handleClicked||(this._handleCropperResize._.deltaY=0),0===this._handleCropperResize._.deltaX&&0===this._handleCropperResize._.deltaY||(this._handleCropperResize._.startingRectangle={left:this.clipper.left-this.clipper.width/2,top:this.clipper.top-this.clipper.height/2,width:this.clipper.width,height:this.clipper.height},this._handleCropperResize._.rectangle=this._calculateNewCropperSizeByDeltas(this._handleCropperResize._.startingRectangle,this._handleCropperResize._.deltaX,this._handleCropperResize._.deltaY,this.handleClicked),this._handleCropperResize._.rectangle.height<30||this._handleCropperResize._.rectangle.width<30||this.arePointsInsideRectangle(this._getRectangleVertices(this._handleCropperResize._.rectangle),this.imageVerticeCoords)&&(this.clipper.set({top:this._handleCropperResize._.rectangle.top+this._handleCropperResize._.rectangle.height/2,left:this._handleCropperResize._.rectangle.left+this._handleCropperResize._.rectangle.width/2,width:this._handleCropperResize._.rectangle.width,height:this._handleCropperResize._.rectangle.height}),this._redrawCropperElements()))},_calculateNewCropperSizeByDeltas:function(t,e,n,r){if(void 0===this._calculateNewCropperSizeByDeltas._&&(this._calculateNewCropperSizeByDeltas._={}),this._calculateNewCropperSizeByDeltas._.topDelta=0,this._calculateNewCropperSizeByDeltas._.leftDelta=0,this._calculateNewCropperSizeByDeltas._.rectangle=t,this._calculateNewCropperSizeByDeltas._.deltaX=e,this._calculateNewCropperSizeByDeltas._.deltaY=n,this.croppingConstraint){switch(this._calculateNewCropperSizeByDeltas._.change=0,r){case"t":this._calculateNewCropperSizeByDeltas._.change=-this._calculateNewCropperSizeByDeltas._.deltaY;break;case"b":this._calculateNewCropperSizeByDeltas._.change=this._calculateNewCropperSizeByDeltas._.deltaY;break;case"r":this._calculateNewCropperSizeByDeltas._.change=this._calculateNewCropperSizeByDeltas._.deltaX;break;case"l":this._calculateNewCropperSizeByDeltas._.change=-this._calculateNewCropperSizeByDeltas._.deltaX;break;case"tr":this._calculateNewCropperSizeByDeltas._.change=Math.abs(this._calculateNewCropperSizeByDeltas._.deltaY)>Math.abs(this._calculateNewCropperSizeByDeltas._.deltaX)?-this._calculateNewCropperSizeByDeltas._.deltaY:this._calculateNewCropperSizeByDeltas._.deltaX;break;case"tl":this._calculateNewCropperSizeByDeltas._.change=Math.abs(this._calculateNewCropperSizeByDeltas._.deltaY)>Math.abs(this._calculateNewCropperSizeByDeltas._.deltaX)?-this._calculateNewCropperSizeByDeltas._.deltaY:-this._calculateNewCropperSizeByDeltas._.deltaX;break;case"br":this._calculateNewCropperSizeByDeltas._.change=Math.abs(this._calculateNewCropperSizeByDeltas._.deltaY)>Math.abs(this._calculateNewCropperSizeByDeltas._.deltaX)?this._calculateNewCropperSizeByDeltas._.deltaY:this._calculateNewCropperSizeByDeltas._.deltaX;break;case"bl":this._calculateNewCropperSizeByDeltas._.change=Math.abs(this._calculateNewCropperSizeByDeltas._.deltaY)>Math.abs(this._calculateNewCropperSizeByDeltas._.deltaX)?this._calculateNewCropperSizeByDeltas._.deltaY:-this._calculateNewCropperSizeByDeltas._.deltaX}switch(this.croppingConstraint>1?(this._calculateNewCropperSizeByDeltas._.deltaX=this._calculateNewCropperSizeByDeltas._.change,this._calculateNewCropperSizeByDeltas._.deltaY=this._calculateNewCropperSizeByDeltas._.deltaX/this.croppingConstraint):(this._calculateNewCropperSizeByDeltas._.deltaY=this._calculateNewCropperSizeByDeltas._.change,this._calculateNewCropperSizeByDeltas._.deltaX=this._calculateNewCropperSizeByDeltas._.deltaY*this.croppingConstraint),this._calculateNewCropperSizeByDeltas._.rectangle.height+=this._calculateNewCropperSizeByDeltas._.deltaY,this._calculateNewCropperSizeByDeltas._.rectangle.width+=this._calculateNewCropperSizeByDeltas._.deltaX,r){case"t":this._calculateNewCropperSizeByDeltas._.rectangle.top-=this._calculateNewCropperSizeByDeltas._.deltaY,this._calculateNewCropperSizeByDeltas._.rectangle.left-=this._calculateNewCropperSizeByDeltas._.deltaX/2;break;case"b":this._calculateNewCropperSizeByDeltas._.rectangle.left+=-this._calculateNewCropperSizeByDeltas._.deltaX/2;break;case"r":this._calculateNewCropperSizeByDeltas._.rectangle.top+=-this._calculateNewCropperSizeByDeltas._.deltaY/2;break;case"l":this._calculateNewCropperSizeByDeltas._.rectangle.top-=this._calculateNewCropperSizeByDeltas._.deltaY/2,this._calculateNewCropperSizeByDeltas._.rectangle.left-=this._calculateNewCropperSizeByDeltas._.deltaX;break;case"tr":this._calculateNewCropperSizeByDeltas._.rectangle.top-=this._calculateNewCropperSizeByDeltas._.deltaY;break;case"tl":this._calculateNewCropperSizeByDeltas._.rectangle.top-=this._calculateNewCropperSizeByDeltas._.deltaY,this._calculateNewCropperSizeByDeltas._.rectangle.left-=this._calculateNewCropperSizeByDeltas._.deltaX;break;case"bl":this._calculateNewCropperSizeByDeltas._.rectangle.left-=this._calculateNewCropperSizeByDeltas._.deltaX}}else!this.shiftKeyHeld||"tl"!==r&&"tr"!==r&&"bl"!==r&&"br"!==r||(this._calculateNewCropperSizeByDeltas._.ratio,Math.abs(e)>Math.abs(n)?(this._calculateNewCropperSizeByDeltas._.ratio=t.width/t.height,this._calculateNewCropperSizeByDeltas._.deltaY=this._calculateNewCropperSizeByDeltas._.deltaX/this._calculateNewCropperSizeByDeltas._.ratio,this._calculateNewCropperSizeByDeltas._.deltaY*="tr"===r||"bl"===r?-1:1):(this._calculateNewCropperSizeByDeltas._.ratio=t.width/t.height,this._calculateNewCropperSizeByDeltas._.deltaX=this._calculateNewCropperSizeByDeltas._.deltaY*this._calculateNewCropperSizeByDeltas._.ratio,this._calculateNewCropperSizeByDeltas._.deltaX*="tr"===r||"bl"===r?-1:1)),r.match(/t/)&&(this._calculateNewCropperSizeByDeltas._.rectangle.top+=this._calculateNewCropperSizeByDeltas._.deltaY,this._calculateNewCropperSizeByDeltas._.rectangle.height-=this._calculateNewCropperSizeByDeltas._.deltaY),r.match(/b/)&&(this._calculateNewCropperSizeByDeltas._.rectangle.height+=this._calculateNewCropperSizeByDeltas._.deltaY),r.match(/r/)&&(this._calculateNewCropperSizeByDeltas._.rectangle.width+=this._calculateNewCropperSizeByDeltas._.deltaX),r.match(/l/)&&(this._calculateNewCropperSizeByDeltas._.rectangle.left+=this._calculateNewCropperSizeByDeltas._.deltaX,this._calculateNewCropperSizeByDeltas._.rectangle.width-=this._calculateNewCropperSizeByDeltas._.deltaX);return this._calculateNewCropperSizeByDeltas._.rectangle.top=this._calculateNewCropperSizeByDeltas._.rectangle.top,this._calculateNewCropperSizeByDeltas._.rectangle.left=this._calculateNewCropperSizeByDeltas._.rectangle.left,this._calculateNewCropperSizeByDeltas._.rectangle.width=this._calculateNewCropperSizeByDeltas._.rectangle.width,this._calculateNewCropperSizeByDeltas._.rectangle.height=this._calculateNewCropperSizeByDeltas._.rectangle.height,this._calculateNewCropperSizeByDeltas._.rectangle},_setMouseCursor:function(t){void 0===this._setMouseCursor._&&(this._setMouseCursor._={}),Garnish.isMobileBrowser(!0)||(this._setMouseCursor._.cursor="default",this._setMouseCursor._.handle=this.croppingCanvas&&this._cropperHandleHitTest(t),this.focalPoint&&this._isMouseOver(t,this.focalPoint)?this._setMouseCursor._.cursor="pointer":this._setMouseCursor._.handle?"t"===this._setMouseCursor._.handle||"b"===this._setMouseCursor._.handle?this._setMouseCursor._.cursor="ns-resize":"l"===this._setMouseCursor._.handle||"r"===this._setMouseCursor._.handle?this._setMouseCursor._.cursor="ew-resize":"tl"===this._setMouseCursor._.handle||"br"===this._setMouseCursor._.handle?this._setMouseCursor._.cursor="nwse-resize":"bl"!==this._setMouseCursor._.handle&&"tr"!==this._setMouseCursor._.handle||(this._setMouseCursor._.cursor="nesw-resize"):this.croppingCanvas&&this._isMouseOver(t,this.clipper)?this._setMouseCursor._.cursor="move":this.focalPickedUp&&(this._setMouseCursor._.cursor="grabbing"),$(".body").css("cursor",this._setMouseCursor._.cursor))},_cropperHandleHitTest:function(t){if(void 0===this._cropperHandleHitTest._&&(this._cropperHandleHitTest._={}),this._cropperHandleHitTest._.parentOffset=this.$croppingCanvas.offset(),this._cropperHandleHitTest._.mouseX=t.pageX-this._cropperHandleHitTest._.parentOffset.left,this._cropperHandleHitTest._.mouseY=t.pageY-this._cropperHandleHitTest._.parentOffset.top,this._cropperHandleHitTest._.lb=this.clipper.left-this.clipper.width/2,this._cropperHandleHitTest._.rb=this._cropperHandleHitTest._.lb+this.clipper.width,this._cropperHandleHitTest._.tb=this.clipper.top-this.clipper.height/2,this._cropperHandleHitTest._.bb=this._cropperHandleHitTest._.tb+this.clipper.height,this._cropperHandleHitTest._.mouseXthis._cropperHandleHitTest._.lb-3){if(this._cropperHandleHitTest._.mouseYthis._cropperHandleHitTest._.tb-3)return"tl";if(this._cropperHandleHitTest._.mouseYthis._cropperHandleHitTest._.bb-10)return"bl"}if(this._cropperHandleHitTest._.mouseX>this._cropperHandleHitTest._.rb-13&&this._cropperHandleHitTest._.mouseXthis._cropperHandleHitTest._.tb-3)return"tr";if(this._cropperHandleHitTest._.mouseYthis._cropperHandleHitTest._.bb-10)return"br"}return this._cropperHandleHitTest._.mouseXthis._cropperHandleHitTest._.lb-3&&this._cropperHandleHitTest._.mouseYthis._cropperHandleHitTest._.tb+10?"l":this._cropperHandleHitTest._.mouseXthis._cropperHandleHitTest._.rb-5&&this._cropperHandleHitTest._.mouseYthis._cropperHandleHitTest._.tb+10?"r":this._cropperHandleHitTest._.mouseYthis._cropperHandleHitTest._.tb-2&&this._cropperHandleHitTest._.mouseX>this._cropperHandleHitTest._.lb+10&&this._cropperHandleHitTest._.mouseXthis._cropperHandleHitTest._.bb-4&&this._cropperHandleHitTest._.mouseX>this._cropperHandleHitTest._.lb+10&&this._cropperHandleHitTest._.mouseX=this._isMouseOver._.lb&&this._isMouseOver._.mouseX<=this._isMouseOver._.rb&&this._isMouseOver._.mouseY>=this._isMouseOver._.tb&&this._isMouseOver._.mouseY<=this._isMouseOver._.bb},_getRectangleVertices:function(t,e,n){return void 0===this._getRectangleVertices._&&(this._getRectangleVertices._={}),void 0===e&&(e=0),void 0===n&&(n=0),this._getRectangleVertices._.topLeft={x:t.left+e,y:t.top+n},this._getRectangleVertices._.topRight={x:this._getRectangleVertices._.topLeft.x+t.width,y:this._getRectangleVertices._.topLeft.y},this._getRectangleVertices._.bottomRight={x:this._getRectangleVertices._.topRight.x,y:this._getRectangleVertices._.topRight.y+t.height},this._getRectangleVertices._.bottomLeft={x:this._getRectangleVertices._.topLeft.x,y:this._getRectangleVertices._.bottomRight.y},[this._getRectangleVertices._.topLeft,this._getRectangleVertices._.topRight,this._getRectangleVertices._.bottomRight,this._getRectangleVertices._.bottomLeft]},_setFittedImageVerticeCoordinates:function(){this.imageVerticeCoords=this.getImageVerticeCoords("fit")},getImageVerticeCoords:function(t){var e,n=-1*((this.hasOrientationChanged()?90:0)+this.imageStraightenAngle)*(Math.PI/180),r=this.getScaledImageDimensions();e="number"==typeof t?t:"cover"===t?this.getZoomToCoverRatio(r):this.getZoomToFitRatio(r);var i=r.height*e,a=r.width*e,s=Math.cos(n)*i,o=Math.sin(n)*a,l=Math.cos(n)*a,c=Math.sin(n)*i,u=(this.editorHeight-(s+o))/2,h=(this.editorWidth-(c+l))/2;return{a:{x:h+l,y:u},b:{x:this.editorWidth-h,y:u+s},c:{x:h+c,y:this.editorHeight-u},d:{x:h,y:u+o}}},_debug:function(t){this.canvas.remove(this.debugger),this.debugger=t,this.canvas.add(this.debugger)},arePointsInsideRectangle:function(t,e){for(void 0===this.arePointsInsideRectangle._&&(this.arePointsInsideRectangle._={}),this.arePointsInsideRectangle._.ab=this._getVector(e.a,e.b),this.arePointsInsideRectangle._.bc=this._getVector(e.b,e.c),this.arePointsInsideRectangle._.scalarAbAb=this._getScalarProduct(this.arePointsInsideRectangle._.ab,this.arePointsInsideRectangle._.ab),this.arePointsInsideRectangle._.scalarBcBc=this._getScalarProduct(this.arePointsInsideRectangle._.bc,this.arePointsInsideRectangle._.bc),this.arePointsInsideRectangle._.i=0;this.arePointsInsideRectangle._.it.length)&&(e=t.length);for(var n=0,r=Array(e);n",{class:"cpmodal-body"}),this.$content=$("
",{class:"cpmodal-content"}).appendTo(this.$body),this.$footer=$("
",{class:"cpmodal-footer hidden"}),$("
",{class:"flex-grow"}).appendTo(this.$footer);var r=$("
",{class:"flex flex-nowrap"}).appendTo(this.$footer);this.$loadSpinner=$("
",{class:"spinner",title:Craft.t("app","Loading"),"aria-label":Craft.t("app","Loading")}).prependTo(r),this.$cancelBtn=$(" ",{type:"button",class:"btn",text:Craft.t("app","Cancel")}).appendTo(r),this.settings.showSubmitButton&&(this.$saveBtn=Craft.ui.createSubmitButton({label:Craft.t("app","Save"),spinner:!0}).appendTo(r)),this.$container=$("<".concat(this.settings.containerElement,"/>"),this.settings.containerAttributes);var i=this.$body.add(this.$footer);this.$container.append(i),this.base(this.$container,{autoShow:!1}),this.$container.data("cpModal",this),Garnish.uiLayerManager.registerShortcut({keyCode:Garnish.S_KEY,ctrl:!0},(function(t){n.handleSubmit(t)})),Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY,(function(){n.closeMeMaybe()})),this.addListener(this.$cancelBtn,"click",(function(){n.closeMeMaybe()})),this.addListener(this.$shade,"click",(function(){n.closeMeMaybe()})),this.addListener(this.$container,"click",(function(t){var e=$(event.target);!n.showingSidebar||e.closest(n.$sidebarBtn).length||e.closest(n.$sidebar).length||n.hideSidebar()})),this.addListener(this.$container,"submit","handleSubmit"),this.load()},load:function(t,e){var n=this;return new Promise((function(t,r){n.trigger("beforeLoad"),n.showLoadSpinner(),n.cancelToken&&(n.ignoreFailedRequest=!0,n.cancelToken.cancel()),n.cancelToken=axios.CancelToken.source(),Craft.sendActionRequest("GET",n.action,$.extend({params:Object.assign({},n.getParams(),n.settings.params),cancelToken:n.cancelToken.token,headers:{"X-Craft-Container-Id":n.$container.attr("id")}},n.settings.requestOptions)).then((function(i){n.update(i.data).then((function(){!1!==e&&(n.$container.data("delta-names",i.data.deltaNames),n.$container.data("initial-delta-values",i.data.initialDeltaValues),n.$container.data("initialSerializedValue",n.$container.serialize())),t()})).catch((function(t){r(t)}))})).catch((function(t){n.ignoreFailedRequest||(Craft.cp.displayError(),r(t)),n.ignoreFailedRequest=!1})).finally((function(){n.hideLoadSpinner(),n.show(),n.cancelToken=null}))}))},getParams:function(){return{}},showLoadSpinner:function(){this.$loadSpinner.removeClass("hidden"),this.showingLoadSpinner=!0},hideLoadSpinner:function(){this.$loadSpinner.addClass("hidden"),this.showingLoadSpinner=!1},update:function(t){var e=this;return new Promise((function(n){e.namespace=t.namespace,t.bodyClass&&e.$body.addClass(t.bodyClass),e.$content.html(t.content),t.submitButtonLabel&&e.$saveBtn.text(t.submitButtonLabel),t.formAttributes&&Craft.setElementAttributes(e.$container,t.formAttributes),e.$footer.removeClass("hidden"),Garnish.requestAnimationFrame((function(){Craft.appendHeadHtml(t.headHtml),Craft.appendBodyHtml(t.bodyHtml),Craft.initUiElements(e.$content),Craft.cp.elementThumbLoader.load($(e.$content)),Garnish.isMobileBrowser()||Craft.setFocusWithin(e.$content),n(),e.trigger("load")}))}))},showSubmitSpinner:function(){this.$saveBtn.addClass("loading")},hideSubmitSpinner:function(){this.$saveBtn.removeClass("loading")},handleSubmit:function(t){t.preventDefault(),this.submit()},submit:function(){var t=this;this.showSubmitSpinner();var e=Craft.findDeltaData(this.$container.data("initialSerializedValue"),this.$container.serialize(),null,this.$container.data("initial-delta-values"));Craft.sendActionRequest("POST",null,{data:e,headers:{"X-Craft-Namespace":this.namespace}}).then((function(e){t.handleSubmitResponse(e)})).catch((function(e){t.handleSubmitError(e)})).finally((function(){t.hideSubmitSpinner()}))},handleSubmitResponse:function(t){this.clearErrors();var e=t.data||{};e.message&&Craft.cp.displaySuccess(e.message,e.notificationSettings),e.modelClass&&e.modelId&&Craft.refreshComponentInstances(e.modelClass,e.modelId),this.trigger("submit",{response:t,data:e.modelName&&e[e.modelName]||{}}),this.settings.closeOnSubmit&&this.close()},handleSubmitError:function(t){if(!t.isAxiosError||!t.response||400===!t.response.status)throw Craft.cp.displayError(),t;var e=t.response.data||{};Craft.cp.displayError(e.message),e.errors&&this.showErrors(e.errors)},showErrors:function(e){var n=this;this.clearErrors(),Object.entries(e).forEach((function(e){var r=function(e,n){return function(t){if(Array.isArray(t))return t}(e)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(t){c=!0,i=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,n)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),i=r[0],a=r[1],s=n.$container.find('[data-attribute="'.concat(i,'"]'));s&&(Craft.ui.addErrorsToField(s,a),n.fieldsWithErrors.push(s))})),this.updateSizeAndPosition()},clearErrors:function(){this.fieldsWithErrors.forEach((function(t){Craft.ui.clearErrorsFromField(t)}))},isDirty:function(){var t=this,e=this.$container.data("initialSerializedValue");return void 0!==e&&e!==(this.$container.data("serializer")||function(){return t.$container.serialize()})()},closeMeMaybe:function(){this.visible&&(this.isDirty()&&!confirm(Craft.t("app","Are you sure you want to close this screen? Any changes will be lost."))||this.close())},close:function(){this.cancelToken&&(this.ignoreFailedRequest=!0,this.cancelToken.cancel()),this.trigger("close"),this.destroy()}},{defaults:{params:{},containerElement:"form",containerAttributes:{id:"cp-modal-".concat(Math.floor(1e8*Math.random())),action:"",method:"post",novalidate:"",class:"cpmodal modal fitted"},requestOptions:{},closeOnSubmit:!0,showSubmitButton:!0}})},337:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";e=function(){return r};var n,r={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function h(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(n){h=function(t,e,n){return t[e]=n}}function d(t,e,n,r){var i=e&&e.prototype instanceof y?e:y,a=Object.create(i.prototype),o=new A(r||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}r.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function w(){}function C(){}var $={};h($,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==i&&a.call(S,l)&&($=S);var x=C.prototype=y.prototype=Object.create($);function I(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function r(i,s,o,l){var c=f(e[i],e,s);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==t(h)&&a.call(h,"__await")?n.resolve(h.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):n.resolve(h).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,l)}))}l(c.arg)}var i;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,i){r(t,e,n,i)}))}return i=i?i.then(a,a):a()}})}function E(t,e,r){var i=p;return function(a,s){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===a)throw s;return{value:n,done:!0}}for(r.method=a,r.arg=s;;){var o=r.delegate;if(o){var l=k(o,r);if(l){if(l===b)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===p)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=f(t,e,r);if("normal"===c.type){if(i=r.done?v:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=v,r.method="throw",r.arg=c.arg)}}}function k(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=f(i,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,b;var s=a.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function t(){for(;++i=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:M(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},r}function n(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(i,a){var s=t.apply(e,r);function o(t){n(s,i,a,o,l,"next",t)}function l(t){n(s,i,a,o,l,"throw",t)}o(void 0)}))}}var i;Craft.AuthManager=Garnish.Base.extend({checkRemainingSessionTimer:null,decrementLogoutWarningInterval:null,showingLogoutWarningModal:!1,showingLoginModal:!1,renewingSession:!1,logoutWarningModal:null,loginModal:null,$logoutWarningPara:null,$passwordInput:null,$loginBtn:null,loginBtn:null,get remainingSessionTime(){return Craft.remainingSessionTime},init:function(){Craft.username&&this.updateRemainingSessionTime(Craft.remainingSessionTime,!1)},setCheckRemainingSessionTimer:function(t){var e=this;this.checkRemainingSessionTimer&&clearTimeout(this.checkRemainingSessionTimer),this.checkRemainingSessionTimer=setTimeout((function(){e.checkRemainingSessionTime()}),1e3*t)},checkRemainingSessionTime:function(t){var n=this;return r(e().mark((function r(){var i,a,s;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=Craft.getActionUrl("users/session-info",t?null:"dontExtendSession=1"),e.prev=1,e.next=4,Craft.sendActionRequest("GET",i);case 4:a=e.sent,s=a.data,void 0!==Craft.csrfTokenValue&&(Craft.csrfTokenValue=s.csrfTokenValue),n.updateRemainingSessionTime(s.timeout,s.isGuest),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),n.updateRemainingSessionTime(-1,!1);case 13:case"end":return e.stop()}}),r,null,[[1,10]])})))()},updateRemainingSessionTime:function(t,e){this.checkRemainingSessionTimer&&clearTimeout(this.checkRemainingSessionTimer);var n=!Craft.remainingSessionTime&&t;if(Craft.remainingSessionTime=parseInt(t),-1!==Craft.remainingSessionTime&&Craft.remainingSessionTime '),r=$('
').appendTo(n),i=$('
').appendTo(r),a=$(" ",{type:"button",class:"btn",text:Craft.t("app","Sign out now")}).appendTo(i),s=$(" ",{type:"submit",class:"btn submit",text:Craft.t("app","Keep me signed in")}).appendTo(i);this.$logoutWarningPara=$("
").prependTo(r),this.logoutWarningModal=new Garnish.Modal(n,{autoShow:!1,closeOtherModals:!1,hideOnEsc:!1,hideOnShadeClick:!1,shadeClass:"modal-shade dark logoutwarningmodalshade",onFadeIn:function(){Garnish.isMobileBrowser(!0)||setTimeout((function(){s.focus()}),100)}}),this.addListener(a,"activate","logout"),this.addListener(n,"submit",(function(t){t.preventDefault(),e.renewSession()}))}t?this.logoutWarningModal.quickShow():this.logoutWarningModal.show(),this.updateLogoutWarningMessage(),this.decrementLogoutWarningInterval=setInterval(this.decrementLogoutWarning.bind(this),1e3)},updateLogoutWarningMessage:function(){this.$logoutWarningPara.text(Craft.t("app","Your session will expire in {time}.",{time:Craft.secondsToHumanTimeDuration(Craft.remainingSessionTime)})),this.logoutWarningModal.updateSizeAndPosition()},decrementLogoutWarning:function(){Craft.remainingSessionTime>0&&(Craft.remainingSessionTime--,this.updateLogoutWarningMessage()),0===Craft.remainingSessionTime&&clearInterval(this.decrementLogoutWarningInterval)},hideLogoutWarningModal:function(t){this.showingLogoutWarningModal=!1,this.logoutWarningModal&&(t?this.logoutWarningModal.quickHide():this.logoutWarningModal.hide(),this.decrementLogoutWarningInterval&&clearInterval(this.decrementLogoutWarningInterval))},showLoginModal:function(){var t=this;return r(e().mark((function n(){var i,a,s,o,l;return e().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t.showingLoginModal){n.next=2;break}return n.abrupt("return");case 2:return t.showingLoginModal=!0,t.loginModal&&t.loginModal.destroy(),n.next=6,Craft.sendActionRequest("POST","users/login-modal",{data:{email:Craft.userEmail}});case 6:i=n.sent,a=i.data,s=$(a.html),o=document.documentElement.lang,(l=s.attr("lang"))===o&&l&&s.removeAttr("lang"),t.loginModal=new Garnish.Modal(s,{closeOtherModals:!1,hideOnEsc:!1,hideOnShadeClick:!1,shadeClass:"modal-shade dark blurred login-modal-shade",onFadeIn:function(){var n=r(e().mark((function n(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Craft.initUiElements(s),new Craft.LoginForm(s.find(".login-container"),{showPasskeyBtn:Craft.userHasPasskeys,onLogin:function(){t.loginModal.hide(),t.checkRemainingSessionTime()}}),e.next=4,Craft.appendHeadHtml(a.headHtml);case 4:return e.next=6,Craft.appendBodyHtml(a.bodyHtml);case 6:case"end":return e.stop()}}),n)})));return function(){return n.apply(this,arguments)}}(),onFadeOut:function(){var e;null===(e=t.loginModal)||void 0===e||e.destroy(),t.loginModal=null},onHide:function(){t.showingLoginModal=!1}});case 13:case"end":return n.stop()}}),n)})))()},hideLoginModal:function(t){this.loginModal&&(t?this.loginModal.quickHide():this.loginModal.hide(),this.loginModal.destroy(),this.loginModal=null)},logout:function(){$.get({url:Craft.getActionUrl("users/logout"),dataType:"json",success:function(){Craft.redirectTo("")}})},renewSession:(i=r(e().mark((function t(){var n=this;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.hideLogoutWarningModal(),this.renewingSession=!0,this.checkRemainingSessionTime(!0,(function(){n.renewingSession=!1}));case 3:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)}),closeModal:function(){this.loginBtn.successEvent(),this.hideLoginModal(),this.checkRemainingSessionTime()}},{checkInterval:60,minSafeSessionTime:120})},341:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";e=function(){return r};var n,r={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function h(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(n){h=function(t,e,n){return t[e]=n}}function d(t,e,n,r){var i=e&&e.prototype instanceof y?e:y,a=Object.create(i.prototype),o=new A(r||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}r.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function w(){}function C(){}var $={};h($,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==i&&a.call(S,l)&&($=S);var x=C.prototype=y.prototype=Object.create($);function I(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function r(i,s,o,l){var c=f(e[i],e,s);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==t(h)&&a.call(h,"__await")?n.resolve(h.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):n.resolve(h).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,l)}))}l(c.arg)}var i;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,i){r(t,e,n,i)}))}return i=i?i.then(a,a):a()}})}function E(t,e,r){var i=p;return function(a,s){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===a)throw s;return{value:n,done:!0}}for(r.method=a,r.arg=s;;){var o=r.delegate;if(o){var l=k(o,r);if(l){if(l===b)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===p)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=f(t,e,r);if("normal"===c.type){if(i=r.done?v:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=v,r.method="throw",r.arg=c.arg)}}}function k(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=f(i,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,b;var s=a.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function t(){for(;++i=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:M(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},r}function n(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(i,a){var s=t.apply(e,r);function o(t){n(s,i,a,o,l,"next",t)}function l(t){n(s,i,a,o,l,"throw",t)}o(void 0)}))}}Craft.IconPicker=Craft.BaseInputGenerator.extend({$container:null,$preview:null,$chooseBtn:null,$removeBtn:null,$input:null,modal:null,cancelToken:null,$searchInput:null,$iconListContainer:null,$iconList:null,defaultListHtml:null,get listLength(){return this.$iconList.find("li").length},init:function(t,e){var n=this;this.$container=$(t),this.setSettings(e,Craft.IconPicker.defaults),this.$preview=this.$container.children(".icon-picker--icon"),this.$chooseBtn=this.$container.children(".icon-picker--choose-btn"),this.$removeBtn=this.$container.children(".icon-picker--remove-btn"),this.$input=this.$container.children("input"),this.addListener(this.$chooseBtn,"activate",(function(){n.showModal()})),this.addListener(this.$removeBtn,"activate",(function(){n.removeIcon()}))},showModal:function(){this.modal?this.modal.show():this.createModal()},createModal:function(){var t=this,e=$('
'),n=$('
').appendTo(e),r=$('
').appendTo(n);$(' ').appendTo(r),this.$searchInput=Craft.ui.createTextInput({name:"search",class:"clearable",placeholder:Craft.t("app","Search")}).attr("aria-label",Craft.t("app","Search")).appendTo(r);var i=$(" ",{class:"clear-btn hidden",title:Craft.t("app","Clear search"),"aria-label":Craft.t("app","Clear search")}).appendTo(r);this.$iconListContainer=$('
').appendTo(n),this.$iconList=$('').appendTo(this.$iconListContainer),this.updateLangAttribute(this.$iconList),$('
').appendTo(this.$iconListContainer),Craft.cp.announce(Craft.t("app","Loading"));var a=new Craft.FormObserver(r,(function(){t.updateIcons()}));this.addListener(this.$searchInput,"input,change",(function(){t.$searchInput.val()?i.removeClass("hidden"):i.addClass("hidden")})),this.addListener(i,"activate",(function(){t.$searchInput.val("").trigger("change"),a.checkForm()})),this.addListener(this.$iconList,"click",(function(e){var n;if("BUTTON"===e.target.nodeName)n=$(e.target);else if(!(n=$(e.target).closest("button")).length)return;t.selectIcon(n)})),this.modal=new Garnish.Modal(e),this.updateIcons()},updateIcons:function(){var t=this;return r(e().mark((function n(){var r,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.loadIcons();case 2:r=e.sent,t.$iconList.html(r),i="".concat(Craft.t("app","Loading complete")," - ").concat(Craft.t("app","{num, number} {num, plural, =1{result} other{results}}",{num:t.listLength})),Craft.cp.announce(i);case 6:case"end":return e.stop()}}),n)})))()},loadIcons:function(){var t=this;return r(e().mark((function n(){var r,i,a;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.cancelToken&&t.cancelToken.cancel(),""!==(r=t.$searchInput.val())||null===t.defaultListHtml){e.next=4;break}return e.abrupt("return",t.defaultListHtml);case 4:return t.$iconListContainer.addClass("loading"),Craft.cp.announce(Craft.t("app","Loading")),t.cancelToken=axios.CancelToken.source(),e.prev=7,e.next=10,Craft.sendActionRequest("POST","app/icon-picker-options",{data:{search:r,freeOnly:t.settings.freeOnly},cancelToken:t.cancelToken.token});case 10:return i=e.sent,a=i.data.listHtml,""===r&&(t.defaultListHtml=a),e.abrupt("return",a);case 14:return e.prev=14,t.$iconListContainer.removeClass("loading"),t.cancelToken=null,e.finish(14);case 18:case"end":return e.stop()}}),n,null,[[7,,14,18]])})))()},updateLangAttribute:function(t){document.documentElement.lang.startsWith("en")||t.attr("lang","en")},selectIcon:function(t){this.modal.hide();var e=t.attr("title");this.$preview.html(t.html()).attr("title",e).attr("aria-label",e).attr("role","img"),this.updateLangAttribute(this.$preview),this.$input.val(e),this.$chooseBtn.children(".label").text(Craft.t("app","Change")),this.$chooseBtn.focus(),this.$removeBtn.removeClass("hidden"),this.$container.hasClass("small")&&this.$chooseBtn.addClass("hidden")},removeIcon:function(){this.$preview.html("").removeAttr("title").removeAttr("aria-label"),this.$input.val(""),this.$chooseBtn.children(".label").text(Craft.t("app","Choose")),this.$removeBtn.addClass("hidden"),this.$container.hasClass("small")?(this.$chooseBtn.removeClass("hidden"),this.$chooseBtn.focus()):this.$chooseBtn.focus()}},{defaults:{freeOnly:!1}})},555:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var n=0;n=0;--a){var s=this.tryEntries[a],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var l=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;k(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:P(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function asyncGeneratorStep(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function _asyncToGenerator(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var a=t.apply(e,n);function s(t){asyncGeneratorStep(a,r,i,s,o,"next",t)}function o(t){asyncGeneratorStep(a,r,i,s,o,"throw",t)}s(void 0)}))}}function _createForOfIteratorHelper(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n ",{id:a,class:"menu menu--disclosure"}).insertAfter(this.$createBtn),o=$("").appendTo(s),l=_createForOfIteratorHelper(this.settings.createAttributes);try{var c=function(){var t=i.value,e=$(" ").appendTo(o),n="";if(t.icon){var a=$(''.concat(t.icon," "));t.color&&a.addClass(t.color),n+=a.prop("outerHTML")}n+=''.concat(t.label," ");var s=$(" ",{type:"button",class:"menu-item",html:n}).appendTo(e);r.addListener(s,"activate",(function(e){e.preventDefault(),r.$createBtn.data("disclosureMenu").hide(),r.createElement(t.attributes)}))};for(l.s();!(i=l.n()).done;)c()}catch(t){l.e(t)}finally{l.f()}this.$createBtn.attr("aria-controls",a).attr("data-disclosure-trigger","true").addClass("menubtn").disclosureMenu()}else this.addListener(this.$createBtn,"activate",(function(t){t.preventDefault(),r.createElement(r.settings.createAttributes)}));setTimeout((function(){r.elementEditor=r.$container.closest("form").data("elementEditor"),r.elementEditor&&r.elementEditor.on("update",(function(){r.settings.ownerId=r.elementEditor.getDraftElementId(r.settings.ownerId),r.elementIndex&&(r.elementIndex.settings.criteria[r.settings.ownerIdParam]=r.settings.ownerId)})),r.trigger("afterInit")}),100),Craft.cp.onCopyElements((function(t,e){r.updatePasteButton(t),r.$pasteBtn&&e&&r.$pasteBtn.find(".label").text(e)}))},addButton:function(t){"cards"===this.settings.mode?(this.$btnContainer||(this.$btnContainer=$btnContainer=$("
",{class:"flex flex-inline"}).appendTo(this.$container)),t.appendTo(this.$btnContainer),this.updateCreateBtn()):t.appendTo(this.elementIndex.$toolbar)},initCards:function(){var t=this;this.$elements=this.$container.children(".elements"),this.$elements.length||(this.$elements=$("",{class:"elements ".concat(this.settings.showInGrid?"card-grid":"cards")}).prependTo(this.$container),this.$container.children(".zilch").addClass("hidden")),this.settings.sortable&&(this.elementSort=new Garnish.DragSort({container:this.$elements,handle:"> .element > .card-titlebar > .card-actions-container > .card-actions > .move-btn",ignoreHandleSelector:null,collapseDraggees:!0,magnetStrength:4,helperLagBase:1.5,onSortChange:function(){t.onSortChange(t.elementSort.$draggee)}}));var e,n=_createForOfIteratorHelper(this.$elements.children().toArray());try{for(n.s();!(e=n.n()).done;){var r=e.value;this.initElement($(r).children(".element"))}}catch(t){n.e(t)}finally{n.f()}},deinitCards:function(){this.$elements&&(this.$elements.remove(),this.$elements=null,this.elementSort.destroy(),this.elementSort=null,this.$container.children(".zilch").removeClass("hidden"))},initElementIndex:function(){var t,e,n,r,i,a,s,o,l,c=this;this.elementIndex=Craft.createElementIndex(this.elementType,this.$container,Object.assign({context:"embedded-index",sortable:this.settings.sortable,prevalidate:this.settings.prevalidate},this.settings.indexSettings,{canDuplicateElements:function(t){return c.canCreate(t.length)},canDeleteElements:function(t){return c.canDelete(t.length)},onBeforeMoveElementsToPage:(l=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return l.apply(this,arguments)}),onMoveElementsToPage:(o=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return o.apply(this,arguments)}),onBeforeReorderElements:(s=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return s.apply(this,arguments)}),onReorderElements:(a=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return a.apply(this,arguments)}),onBeforeDuplicateElements:(i=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return i.apply(this,arguments)}),onDuplicateElements:(r=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)}),onBeforeDeleteElements:(n=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)}),onDeleteElements:(e=_asyncToGenerator(_regeneratorRuntime().mark((function t(){var e;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.markAsDirty();case 2:if(t.sent){t.next=4;break}null===(e=c.elementEditor)||void 0===e||e.checkForm(!0);case 4:case"end":return t.stop()}}),t)}))),function(){return e.apply(this,arguments)}),onBeforeUpdateElements:function(){c.$createBtn&&c.$createBtn.addClass("disabled")},onCountResults:function(){c.updateCreateBtn()},onSortChange:(t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.onSortChange(e);case 2:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}))},markAsDirty:function(){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.elementEditor&&t.settings.baseInputName){e.next=2;break}return e.abrupt("return",!1);case 2:return e.next=4,t.elementEditor.setFormValue(t.settings.baseInputName,"*");case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))()},getBaseActionData:function(){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.markAsDirty();case 2:return e.abrupt("return",{ownerElementType:t.settings.ownerElementType,ownerId:t.settings.ownerId,ownerSiteId:t.settings.ownerSiteId,attribute:t.settings.attribute});case 3:case"end":return e.stop()}}),e)})))()},onSortChange:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark((function n(){var r,i,a;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=parseInt(t.find(".element").data("id")),n.prev=1,n.next=4,e.updateSortOrder(r);case 4:i=n.sent,Craft.cp.displayNotice(i.data.message),n.next=11;break;case 8:n.prev=8,n.t0=n.catch(1),Craft.cp.displayError(null===n.t0||void 0===n.t0||null===(a=n.t0.response)||void 0===a||null===(a=a.data)||void 0===a?void 0:a.message);case 11:return n.next=13,e.markAsDirty();case 13:if(n.sent){n.next=15;break}Craft.Preview.refresh();case 15:case"end":return n.stop()}}),n,null,[[1,8]])})))()},updateSortOrder:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark((function n(){var r,i;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=parseInt(t),r=e.getElementIds(),n.t0=Object,n.next=5,e.getBaseActionData();case 5:return n.t1=n.sent,n.t2={elementIds:[t],offset:e.getBaseElementOffset()+r.indexOf(t)},i=n.t0.assign.call(n.t0,n.t1,n.t2),n.next=10,Craft.sendActionRequest("POST","nested-elements/reorder",{data:i});case 10:return n.abrupt("return",n.sent);case 11:case"end":return n.stop()}}),n)})))()},updateCreateBtn:function(){this.$createBtn&&(this.canCreate()?this.$createBtn.removeClass("disabled"):this.$createBtn.addClass("disabled"),this.updatePasteButton())},updatePasteButton:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e=e||Craft.cp.getCopiedElements(),this.canPaste(e)?this.$pasteBtn?this.$pasteBtn.removeClass("hidden"):(this.$pasteBtn=Craft.ui.createPasteButton(),this.addButton(this.$pasteBtn),this.addListener(this.$pasteBtn,"activate","pasteElements")):null===(t=this.$pasteBtn)||void 0===t||t.addClass("hidden")},canCreate:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(!this.settings.canCreate||0===t)return!1;if(!this.settings.maxElements)return!0;var e=this.getTotalElements();return null!==e&&e+t<=this.settings.maxElements},canDelete:function(){return!this.settings.minElements||null!==this.getTotalElements()},canPaste:function canPaste(elementInfo){if(!this.settings.canPaste||!this.canCreate(elementInfo.length))return!1;var _iterator3=_createForOfIteratorHelper(elementInfo),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var e=_step3.value;if(e.type!==this.elementType)return!1}}catch(t){_iterator3.e(t)}finally{_iterator3.f()}return"function"==typeof this.settings.canPaste?this.settings.canPaste(elementInfo):"string"!=typeof this.settings.canPaste||eval(this.settings.canPaste)(elementInfo)},getElementIds:function(){return("cards"===this.settings.mode?this.$elements.find("> li > .element").toArray():this.elementIndex.view.getAllElements().toArray().map((function(t){return t.querySelector(".element")}))).map((function(t){return t.getAttribute("data-id")})).filter((function(t){return t})).map((function(t){return parseInt(t)}))},getTotalElements:function(){return"cards"===this.settings.mode?this.$elements?this.$elements.children().length:0:this.elementIndex.isIndexBusy?null:this.elementIndex.totalUnfilteredResults},getBaseElementOffset:function(){return"cards"===this.settings.mode?0:this.elementIndex.settings.batchSize*(this.elementIndex.page-1)},createElement:(_createElement=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var n,r,i,a,s,o,l=this;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.$createBtn){t.next=5;break}if(!this.$createBtn.hasClass("loading")){t.next=3;break}return t.abrupt("return");case 3:this.$createBtn.addClass("loading"),Craft.cp.announce(Craft.t("app","Loading"));case 5:return t.prev=5,t.next=8,this.markAsDirty();case 8:return e=Object.assign({elementType:this.elementType,ownerId:this.settings.ownerId,fieldId:this.settings.fieldId,siteId:this.settings.ownerSiteId},e),t.next=11,Craft.sendActionRequest("POST","elements/create",{data:e});case 11:n=t.sent,r=n.data,i=Craft.createElementEditor(this.elementType,{siteId:r.element.siteId,elementId:r.element.id,draftId:r.element.draftId,params:{fresh:1}}),a=!1,s=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a){t.next=12;break}if(a=!0,"cards"!==l.settings.mode){t.next=8;break}return t.next=5,l.addElementCard(e);case 5:t.sent,t.next=10;break;case 8:l.elementIndex.clearSearch(),l.elementIndex.updateElements();case 10:return t.next=12,l.markAsDirty();case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),i.on("load",(function(){i.elementEditor.once("afterSaveDraft",(function(t){s(r.element)}))})),i.on("submit",_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s(r.element);case 2:case"end":return t.stop()}}),t)})))),i.on("close",(function(){var t;l.$createBtn&&l.$createBtn.focus(),null===(t=l.elementEditor)||void 0===t||t.checkForm(!0)})),t.next=24;break;case 21:t.prev=21,t.t0=t.catch(5),Craft.cp.displayError(null===t.t0||void 0===t.t0||null===(o=t.t0.response)||void 0===o||null===(o=o.data)||void 0===o?void 0:o.message);case 24:return t.prev=24,this.$createBtn&&this.$createBtn.removeClass("loading"),t.finish(24);case 27:case"end":return t.stop()}}),t,this,[[5,21,24,27]])}))),function(t){return _createElement.apply(this,arguments)}),duplicateElement:(_duplicateElement=_asyncToGenerator(_regeneratorRuntime().mark((function t(e){var n,r,i,a,s,o;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Craft.cp.announce(Craft.t("app","Loading")),t.next=3,this.markAsDirty();case 3:return t.prev=3,a=e.data("id"),t.next=7,Craft.sendActionRequest("POST","elements/duplicate",{data:{elementType:this.elementType,ownerId:this.settings.ownerId,siteId:this.settings.ownerSiteId,elementId:(null===(i=this.elementEditor)||void 0===i?void 0:i.getDraftElementId(a))||a}});case 7:s=t.sent,r=s.data,t.next=14;break;case 11:t.prev=11,t.t0=t.catch(3),Craft.cp.displayError(null===t.t0||void 0===t.t0||null===(o=t.t0.response)||void 0===o||null===(o=o.data)||void 0===o?void 0:o.message);case 14:return t.next=16,this.addElementCard(r.element);case 16:return t.sent.parent().insertAfter(e.parent()),t.next=20,this.updateSortOrder(r.element.id);case 20:null===(n=this.elementEditor)||void 0===n||n.checkForm(!0);case 21:case"end":return t.stop()}}),t,this,[[3,11]])}))),function(t){return _duplicateElement.apply(this,arguments)}),pasteElements:function(){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark((function e(){var n,r,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Craft.cp.announce(Craft.t("app","Loading")),t.$pasteBtn.addClass("loading"),e.prev=2,e.next=5,t.markAsDirty();case 5:return e.next=7,Craft.cp.pasteElements(Object.assign({primaryOwnerId:t.settings.ownerId,ownerId:t.settings.ownerId,fieldId:t.settings.fieldId,siteId:t.settings.ownerSiteId},t.settings.pasteAttributes||{}));case 7:if((r=e.sent).length){e.next=10;break}return e.abrupt("return");case 10:if("cards"!==t.settings.mode){e.next=19;break}return e.next=13,t.addElementCards(r,!1);case 13:return i=e.sent,e.next=16,t.updateSortOrder(r[0].id);case 16:Garnish.firstFocusableElement(i).focus(),e.next=22;break;case 19:return t.elementIndex.clearSearch(),e.next=22,t.elementIndex.updateElements();case 22:return e.prev=22,t.$pasteBtn.removeClass("loading"),e.finish(22);case 25:null===(n=t.elementEditor)||void 0===n||n.checkForm(!0);case 26:case"end":return e.stop()}}),e,null,[[2,,22,25]])})))()},initElement:function(t){var e=this;setTimeout((function(){if(Garnish.hasAttr(t,"data-editable")){var n=t.find(".edit-btn");n.length&&(n.off("activate"),e.addListener(n,"activate",(function(r){n.focus();var i=t.data("cpUrl");i&&Garnish.isCtrlKeyPressed(r.originalEvent)?window.open(i):e.createElementEditor(t)}))),e.addListener(t,"dblclick,taphold",(function(n){$(n.target).closest("a[href],button,[role=button]").length||e.createElementEditor(t)}))}var r,i,a,s,o,l=t.find(".action-btn").removeClass("hidden").disclosureMenu().data("disclosureMenu");if(l){var c,u,h,d=l.$container,f=l.getFirstDestructiveGroup(),p=t.parent(),g=function(){return p.prev("li")},m=function(){return p.next("li")};if(e.settings.sortable){e.elementSort.addItems(p);var v=l.addGroup(null,!0,f);c=l.addItem({icon:(o=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon(e.settings.showInGrid?"ltr"===Craft.orientation?"arrow-left":"arrow-right":"arrow-up");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return o.apply(this,arguments)}),label:e.settings.showInGrid?Craft.t("app","Move forward"):Craft.t("app","Move up"),onActivate:function(){var t=g();t.length&&(p.insertBefore(t),e.onSortChange(p))}},v),u=l.addItem({icon:(s=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon(e.settings.showInGrid?"ltr"===Craft.orientation?"arrow-right":"arrow-left":"arrow-down");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return s.apply(this,arguments)}),label:e.settings.showInGrid?Craft.t("app","Move backward"):Craft.t("app","Move down"),onActivate:function(){var t=m();t.length&&(p.insertAfter(t),e.onSortChange(p))}},v)}var b=Garnish.hasAttr(t,"data-duplicatable"),y=Garnish.hasAttr(t,"data-copyable");if(b||y){var w=l.addGroup(null,!0,f);if(b&&(h=l.addItem({icon:(a=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon("clone");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return a.apply(this,arguments)}),label:Craft.t("app","Duplicate"),onActivate:function(){e.duplicateElement(t)}},w)),y){var C=d.find("[data-copy-action]");C.length&&l.removeItem(C[0]),l.addItem({icon:(i=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon("clone-dashed");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return i.apply(this,arguments)}),iconColor:"fuchsia",label:Craft.t("app","Copy"),onActivate:function(){Craft.cp.copyElements(t)}},w)}}if(Garnish.hasAttr(t,"data-deletable")){var _=l.addGroup();l.addItem({icon:(r=_asyncToGenerator(_regeneratorRuntime().mark((function t(){return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon("trash");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)}),label:e.settings.deleteLabel||Craft.t("app","Delete"),destructive:!0,onActivate:function(){confirm(e.settings.deleteConfirmationMessage)&&e.deleteElement(t)}},_)}l.on("show",(function(){c&&l.toggleItem(c,g().length),u&&l.toggleItem(u,m().length),h&&l.toggleItem(h,e.canCreate())}))}}),1)},createElementEditor:function(t){var e,n,r=this,i=Craft.createElementEditor(this.elementType,t,{ownerId:null===(e=this.elementEditor)||void 0===e?void 0:e.getDraftElementId(t.data("ownerId")),onLoad:function(){i.elementEditor.on("update",(function(){Craft.Preview.refresh()}))},onBeforeSubmit:(n=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r.elementEditor||!Garnish.hasAttr(t,"data-owner-is-canonical")||Garnish.hasAttr(t,"data-is-unpublished-draft")||r.elementEditor.settings.isUnpublishedDraft){e.next=6;break}return e.next=3,i.elementEditor.checkForm(!0,!0);case 3:return e.next=5,r.markAsDirty();case 5:r.elementEditor.settings.draftId&&i.elementEditor.settings.draftId&&(i.elementEditor.settings.saveParams||(i.elementEditor.settings.saveParams={}),i.elementEditor.settings.saveParams.action="elements/save-nested-element-for-derivative",i.elementEditor.settings.saveParams.newOwnerId=r.settings.ownerId);case 6:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)}),onSubmit:function(e){e.data.id!=t.data("id")&&(t.attr("data-id",e.data.id).data("id",e.data.id).data("owner-id",e.data.ownerId),Craft.refreshElementInstances(e.data.id))}})},deleteElement:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark((function n(){var r,i,a,s;return _regeneratorRuntime().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.t0=Object,n.next=3,e.getBaseActionData();case 3:return n.t1=n.sent,n.t2={elementId:t.data("id")},r=n.t0.assign.call(n.t0,n.t1,n.t2),n.prev=6,n.next=9,Craft.sendActionRequest("POST","nested-elements/delete",{data:r});case 9:i=n.sent,Craft.cp.displayNotice(i.data.message),n.next=17;break;case 13:throw n.prev=13,n.t3=n.catch(6),Craft.cp.displayError(null===n.t3||void 0===n.t3||null===(a=n.t3.response)||void 0===a||null===(a=a.data)||void 0===a?void 0:a.message),n.t3;case 17:return e.settings.sortable&&e.elementSort.removeItems(t),t.parent().remove(),0===e.$elements.children().length&&e.deinitCards(),e.$createBtn&&(e.updateCreateBtn(),e.canCreate()&&e.$createBtn.focus()),n.next=23,e.markAsDirty();case 23:if(n.sent){n.next=25;break}null===(s=e.elementEditor)||void 0===s||s.checkForm(!0);case 25:case"end":return n.stop()}}),n,null,[[6,13]])})))()},addElementCard:function(t){var e=arguments,n=this;return _asyncToGenerator(_regeneratorRuntime().mark((function r(){var i;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=!(e.length>1&&void 0!==e[1])||e[1],r.next=3,n.addElementCards([t],i);case 3:return r.abrupt("return",r.sent);case 4:case"end":return r.stop()}}),r)})))()},addElementCards:function(t){var e=arguments,n=this;return _asyncToGenerator(_regeneratorRuntime().mark((function r(){var i,a,s,o,l,c,u,h,d,f,p,g,m,v,b,y;return _regeneratorRuntime().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(a=!(e.length>1&&void 0!==e[1])||e[1],null===(i=n.$createBtn)||void 0===i||!i.hasClass("loading")){r.next=3;break}return r.abrupt("return",null);case 3:return a&&n.$createBtn&&(n.$createBtn.addClass("loading"),Craft.cp.announce(Craft.t("app","Loading"))),r.prev=4,r.next=7,Craft.sendActionRequest("POST","app/render-elements",{data:{elements:t.map((function(t){return{type:n.elementType,id:t.id,siteId:t.siteId,instances:[{context:"field",ui:"card",sortable:n.settings.sortable,showActionMenu:!0,hyperlink:!1}]}}))}});case 7:o=r.sent,s=o.data,r.next=15;break;case 11:throw r.prev=11,r.t0=r.catch(4),Craft.cp.displayError(null===r.t0||void 0===r.t0||null===(l=r.t0.response)||void 0===l||null===(l=l.data)||void 0===l?void 0:l.message),null!==(c=null===r.t0||void 0===r.t0||null===(u=r.t0.response)||void 0===u||null===(u=u.data)||void 0===u?void 0:u.message)&&void 0!==c?c:r.t0;case 15:return r.prev=15,a&&n.$createBtn&&n.$createBtn.removeClass("loading"),r.finish(15);case 18:n.$elements||n.initCards(),h=$(),d=_createForOfIteratorHelper(t);try{for(d.s();!(f=d.n()).done;){p=f.value,g=_createForOfIteratorHelper(s.elements[p.id]||[]);try{for(g.s();!(m=g.n()).done;)v=m.value,b=$(" ").appendTo(n.$elements),y=$(v).appendTo(b),h=h.add(y),n.initElement(y),Craft.cp.elementThumbLoader.load(y)}catch(t){g.e(t)}finally{g.f()}}}catch(t){d.e(t)}finally{d.f()}return r.next=24,Craft.appendHeadHtml(s.headHtml);case 24:return r.next=26,Craft.appendBodyHtml(s.bodyHtml);case 26:return n.updateCreateBtn(),r.abrupt("return",h);case 28:case"end":return r.stop()}}),r,null,[[4,11,15,18]])})))()},destroy:function(){this.$container.removeData("nestedElementManager"),this.base()}},{ownerId:null,defaults:{mode:"cards",showInGrid:!1,ownerElementType:null,ownerId:null,ownerSiteId:null,attribute:null,sortable:!1,indexSettings:{},canCreate:!1,canPaste:!1,minElements:null,maxElements:null,createButtonLabel:Craft.t("app","Create"),ownerIdParam:null,createAttributes:null,pasteAttributes:null,fieldId:null,fieldHandle:null,baseInputName:null,deleteLabel:null,deleteConfirmationMessage:null,prevalidate:!1}})},743:function(){Craft.HandleGenerator=Craft.BaseInputGenerator.extend({generateTargetValue:function(t){var e=t.replace(/<(.*?)>/g,"");e=(e=e.replace(/['"‘’“”ʻ\[\]\(\)\{\}:]/g,"")).toLowerCase(),e=Craft.asciiString(e),this.settings.allowNonAlphaStart||(e=e.replace(/^[^a-z]+/,""));var n=Craft.filterArray(e.split(/[^a-z0-9]+/));if(e="","snake"===Craft.handleCasing)return n.join("_");for(var r=0;r(null===(e=this.scroller)||void 0===e?void 0:e.clientWidth)}},{key:"connectedCallback",value:function(){this.ignoreScrollEvent=!1,this.animation=!1,this.scroller=document.querySelector(this.getAttribute("scroller")),this.content=document.querySelector(this.getAttribute("content")),this.scroller&&this.content&&(this.proxy=document.createElement("div"),this.proxy.style.height="1px",this.proxy.style.width=this.content.getBoundingClientRect().width+"px",this.appendChild(this.proxy),this.addEventListener("scroll",this.syncScroll(this.scroller,this)),this.scroller.addEventListener("scroll",this.syncScroll(this,this.scroller)),window.addEventListener("resize",this.handleResize.bind(this)),Object.assign(this.style,{display:this.hasOverflow?"block":"none",overflowX:"scroll"}))}},{key:"attributeChangedCallback",value:function(t,e,n){"hidden"===t&&(this.style.display=n?"none":"block")}},{key:"disconnectedCallback",value:function(){this.proxy.remove(),this.scroller.removeEventListener("scroll",this.syncScroll(this.scroller,this)),this.scroller.removeEventListener("scroll",this.syncScroll(this,this.scroller)),window.removeEventListener("resize",this.handleResize.bind(this))}},{key:"handleResize",value:function(){this.proxy.style.width=this.content.getBoundingClientRect().width+"px",this.hasOverflow?this.removeAttribute("hidden"):this.setAttribute("hidden","true")}},{key:"syncScroll",value:function(t,e){var n=this;return function(){if(n.ignoreScrollEvent)return!1;n.animation&&cancelAnimationFrame(n.animation),n.animation=requestAnimationFrame((function(){n.ignoreScrollEvent=!0,t.scrollLeft=e.scrollLeft,n.ignoreScrollEvent=!1}))}}}])}(n(HTMLElement));!function(t,e,n){(e=s(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n}(o,"observedAttributes",["hidden"]),customElements.define("craft-proxy-scrollbar",o)},991:function(){Craft.AdminTable=Garnish.Base.extend({settings:null,totalItems:null,sorter:null,$noItems:null,$table:null,$tbody:null,$deleteBtns:null,init:function(t){var e=this;this.setSettings(t,Craft.AdminTable.defaults),this.settings.allowDeleteAll||(this.settings.minItems=1),this.$noItems=$(this.settings.noItemsSelector),this.$table=$(this.settings.tableSelector),this.$tbody=this.$table.children("tbody"),this.totalItems=this.$tbody.children().length,this.settings.sortable&&(this.sorter=new Craft.DataTableSorter(this.$table,{onSortChange:this.reorderItems.bind(this)})),this.$deleteBtns=this.$table.find(".delete:not(.disabled)"),this.addListener(this.$deleteBtns,"click","handleDeleteBtnClick"),this.addListener(this.$deleteBtns,"keydown",(function(t){t.keyCode!==Garnish.SPACE_KEY&&t.keyCode!==Garnish.RETURN_KEY||(t.preventDefault(),e.handleDeleteBtnClick(t))})),this.updateUI()},addRow:function(t){if(!(this.settings.maxItems&&this.totalItems>=this.settings.maxItems)){var e=$(t).appendTo(this.$tbody),n=e.find(".delete");this.settings.sortable&&this.sorter.addItems(e),this.$deleteBtns=this.$deleteBtns.add(n),this.addListener(n,"click","handleDeleteBtnClick"),this.totalItems++,this.updateUI()}},reorderItems:function(){var t=this;if(this.settings.sortable){for(var e=[],n=0;n=this.settings.maxItems?$(this.settings.newItemBtnSelector).addClass("hidden"):$(this.settings.newItemBtnSelector).removeClass("hidden"))}},{defaults:{tableSelector:null,noItemsSelector:null,newItemBtnSelector:null,idAttribute:"data-id",nameAttribute:"data-name",sortable:!1,allowDeleteAll:!0,minItems:0,maxItems:null,reorderAction:null,deleteAction:null,reorderSuccessMessage:Craft.t("app","New order saved."),reorderFailMessage:Craft.t("app","Couldn’t save new order."),confirmDeleteMessage:Craft.t("app","Are you sure you want to delete “{name}”?"),deleteSuccessMessage:Craft.t("app","“{name}” deleted."),deleteFailMessage:Craft.t("app","Couldn’t delete “{name}”."),onReorderItems:$.noop,onDeleteItem:$.noop}})},1255:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,a=function(){};return{s:a,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}function n(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:M(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),b}},n}function a(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function s(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var s=t.apply(e,n);function o(t){a(s,r,i,o,l,"next",t)}function l(t){a(s,r,i,o,l,"throw",t)}o(void 0)}))}}var o;Craft.AssetMover=Garnish.Base.extend({undoMovedAssets:null,undoMovedFolders:null,conflictCount:0,init:function(){this.undoMovedAssets={assetIds:[],targetFolderId:null},this.undoMovedFolders={folderIds:[],targetFolderId:null}},getMoveParams:(o=s(i().mark((function t(e,n){var r,a,s,o;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=!0,a=!1,t.prev=2,t.next=5,Craft.sendActionRequest("POST","assets/move-info",{data:{folderIds:e,assetIds:n}});case 5:s=t.sent,t.next=12;break;case 8:return t.prev=8,t.t0=t.catch(2),Craft.cp.displayError(null===t.t0||void 0===t.t0||null===(o=t.t0.response)||void 0===o||null===(o=o.data)||void 0===o?void 0:o.message),t.abrupt("return");case 12:return(s.data.count>Craft.AssetMover.countLimit||s.data.totalSize>Craft.AssetMover.sizeLimit)&&(r=confirm(Craft.t("app","Are you sure you want to move the selected items?")),a=!0),t.abrupt("return",{proceed:r,confirmed:a});case 14:case"end":return t.stop()}}),t,null,[[2,8]])}))),function(t,e){return o.apply(this,arguments)}),successNotice:function(t,e){var n=this,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=null,o=null;r&&0===this.conflictCount&&(o=Craft.ui.createButton({label:Craft.t("app","Undo"),spinner:!0})),!t.confirmed&&r&&(a={details:o});var l,c=Craft.cp.displayNotice(e,a);r&&(null===(l=o)||void 0===l||l.on("activate",s(i().mark((function e(){var r,a;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!confirm(Craft.t("app","Are you sure you want to undo the move?"))){e.next=9;break}return e.next=3,n.moveFolders(n.undoMovedFolders.folderIds,n.undoMovedFolders.targetFolderId);case 3:return r=e.sent,e.next=6,n.moveAssets(n.undoMovedAssets.assetIds,n.undoMovedAssets.targetFolderId);case 6:a=e.sent,r+a&&(n.successNotice(t,Craft.t("app","Move reverted."),!1),Craft.elementIndex.updateElements(!0));case 9:c.$closeBtn.trigger("click");case 10:case"end":return e.stop()}}),e)})))))},moveAssets:function(t,e,n){var r=t.map((function(t){return{for:"asset",action:"assets/move-asset",params:{assetId:t,folderId:e,initialFolderId:n}}}));return this._batchMoveRequests(r,{conflictChoices:[{value:"keepBoth",title:Craft.t("app","Keep both")},{value:"replace",title:Craft.t("app","Replace it")}],handleConflictChoice:function(t){var e={folderId:t.request.params.folderId,assetId:t.assetId,initialFolderId:t.request.params.initialFolderId};switch(t.choice){case"replace":e.force=!0;break;case"keepBoth":e.filename=t.suggestedFilename}return{action:"assets/move-asset",params:e}}})},moveFolders:function(t,e,i){var a=this;return new Promise((function(s,o){var l=[],c=[],u=[],h=t.map((function(t){return{for:"folder",action:"assets/move-folder",params:{folderId:t,parentId:e,initialParentId:i},onSuccess:function(e){var i;e.transferList.length&&(e.transferList.forEach((function(e){return e.oldFolderId=t})),l.push.apply(l,function(t){if(Array.isArray(t))return r(t)}(i=e.transferList)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||n(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),c.push(t)}}}));a._batchMoveRequests(h,{conflictChoices:[{value:"replace",title:Craft.t("app","Replace the folder (all existing files will be deleted)")},{value:"merge",title:Craft.t("app","Merge the folder (any conflicting files will be replaced)")}],handleConflictChoice:function(t){var e={folderId:t.folderId,parentId:t.parentId,initialParentId:t.request.params.initialParentId};switch(t.choice){case"replace":e.force=!0;break;case"merge":e.merge=!0}return{action:"assets/move-folder",params:e}}}).then((function(t){a._processTransferList(l).then((function(e){e.forEach((function(t){var e;if(null!==(e=t.error)&&void 0!==e&&e.length){var n=t.request.params.oldFolderId;u.includes(n)||u.push(n),c.includes(n)&&(c=c.filter((function(t){return t!==n})))}})),t-=u.length,a._deleteFolders(c).then((function(){s(t)}))}))})).catch(o)}))},_processTransferList:function(t){return this._batchRequests(t.map((function(t){return{action:"assets/move-asset",params:t}})))},_deleteFolders:function(t){return this._batchRequests(t.map((function(t){return{action:"assets/delete-folder",params:{folderId:t}}})))},_batchMoveRequests:function(t,n){var r=this;return new Promise((function(i){var a=0;r._batchRequests(t).then((function(t){Craft.elementIndex.promptHandler.resetPrompts();var s,o=e(t);try{for(o.s();!(s=o.n()).done;){var l=s.value;l.success&&(l.newFolderId?(r.undoMovedFolders.folderIds.push(l.newFolderId),null===r.undoMovedFolders.targetFolderId&&(r.undoMovedFolders.targetFolderId=l.request.params.initialParentId)):(r.undoMovedAssets.assetIds.push(l.request.params.assetId),null===r.undoMovedAssets.targetFolderId&&(r.undoMovedAssets.targetFolderId=l.request.params.initialFolderId)),a++),l.conflict&&(r.conflictCount++,Craft.elementIndex.promptHandler.addPrompt(Object.assign({},l,{prompt:{message:l.conflict,choices:n.conflictChoices}}))),l.error&&Craft.cp.displayError(l.error)}}catch(t){o.e(t)}finally{o.f()}Craft.elementIndex.promptHandler.getPromptCount()?Craft.elementIndex.promptHandler.showBatchPrompts((function(t){Craft.elementIndex.promptHandler.resetPrompts();var s,o=[],l=e(t);try{for(l.s();!(s=l.n()).done;){var c=s.value;if("cancel"!==c.choice&&n.handleConflictChoice){var u=n.handleConflictChoice(c);c.request&&c.request.onSuccess&&(u.onSuccess=c.request.onSuccess),o.push(u)}}}catch(t){l.e(t)}finally{l.f()}r._batchMoveRequests(o,n).then((function(t){i(a+t)}))})):i(a)}))}))},_batchRequests:function(t){return new Promise((function(n){if(t.length){Craft.elementIndex.setIndexBusy(!1),Craft.elementIndex._positionProgressBar(),Craft.elementIndex.progressBar.resetProgressBar(),Craft.elementIndex.progressBar.setItemCount(t.length),Craft.elementIndex.progressBar.showProgressBar();var r,i=[],a=t.length,s=e(t);try{var o=function(){var t=r.value;Craft.sendActionRequest("POST",t.action,{data:t.params}).then((function(e){i.push(Object.assign({success:!0},e.data,{request:t})),t.onSuccess&&t.onSuccess(e.data)})).catch((function(e){e.response&&e.response.data&&i.push(Object.assign({success:!1},e.response.data,{request:t}))})).finally((function(){0==--a?(Craft.elementIndex.setIndexAvailable(),Craft.elementIndex.progressBar.hideProgressBar(),Craft.cp.runQueue(),n(i)):(Craft.elementIndex.progressBar.incrementProcessedItemCount(1),Craft.elementIndex.progressBar.updateProgressBar())}))};for(s.s();!(r=s.n()).done;)o()}catch(t){s.e(t)}finally{s.f()}}else n([])}))}},{countLimit:50,sizeLimit:5e7})},1448:function(){Craft.AssetSelectorModal=Craft.BaseElementSelectorModal.extend({$selectTransformBtn:null,_selectedTransform:null,init:function(t,e){e=$.extend({},Craft.AssetSelectorModal.defaults,e),this.base(t,e),e.transforms.length&&this.createSelectTransformButton(e.transforms)},createSelectTransformButton:function(t){if(t&&t.length){var e=$('
').appendTo(this.$primaryButtons);this.$selectBtn.appendTo(e),this.$selectTransformBtn=$(" ",{type:"button",class:"btn menubtn disabled",text:Craft.t("app","Select transform")}).appendTo(e);for(var n=$('').insertAfter(this.$selectTransformBtn),r=$("").appendTo(n),i=0;i'+t[i].name+" ").appendTo(r);var a=new Garnish.MenuBtn(this.$selectTransformBtn,{onOptionSelect:this.onSelectTransform.bind(this)});a.disable(),this.$selectTransformBtn.data("menuButton",a)}},onSelectionChange:function(t){var e=!1;this.elementIndex.getSelectedElements().length&&this.settings.transforms.length&&(e=!0);var n=null;this.$selectTransformBtn&&(n=this.$selectTransformBtn.data("menuButton")),e?(n&&n.enable(),this.$selectTransformBtn.removeClass("disabled")):this.$selectTransformBtn&&(n&&n.disable(),this.$selectTransformBtn.addClass("disabled")),this.base()},onSelectTransform:function(t){var e=$(t).data("transform");this.selectImagesWithTransform(e)},selectImagesWithTransform:function(t){var e=this;void 0===Craft.AssetSelectorModal.transformUrls[t]&&(Craft.AssetSelectorModal.transformUrls[t]={});for(var n=this.elementIndex.getSelectedElements(),r=[],i=0;i=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:M(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),b}},r}function r(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n ').appendTo(Garnish.$bod);this.$sidebar=$('').appendTo(r).attr({role:"navigation","aria-label":Craft.t("app","Source")}),this.$sourcesContainer=$('').appendTo(this.$sidebar),this.$sourceSettingsContainer=$('
').appendTo(r),this.$footer=$('').appendTo(r),this.$footerBtnContainer=$('
').appendTo(this.$footer),this.$cancelBtn=$("
",{type:"button",class:"btn",text:Craft.t("app","Cancel")}).appendTo(this.$footerBtnContainer),this.$saveBtn=Craft.ui.createSubmitButton({class:"disabled",label:Craft.t("app","Save"),spinner:!0}).appendTo(this.$footerBtnContainer),this.$loadingSpinner=$('
').appendTo(this.$sourceSettingsContainer),this.setContainer(r),this.show(),Craft.sendActionRequest("POST","element-index-settings/get-customize-sources-modal-data",{data:{elementType:this.elementIndex.elementType}}).then((function(t){n.$saveBtn.removeClass("disabled"),n.buildModal(t.data)})).finally((function(){n.$loadingSpinner.remove(),Garnish.setFocusWithin(n.$sidebar)})),this.addListener(this.$cancelBtn,"click","hide"),this.addListener(this.$saveBtn,"click","save"),this.addListener(this.$container,"submit","save")},buildModal:(l=o(n().mark((function t(e){var i,a,s,o,l,c,u,h=this;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.baseSortOptions=e.baseSortOptions,this.defaultSortOptions=e.defaultSortOptions,this.availableTableAttributes=e.availableTableAttributes,this.customFieldAttributes=e.customFieldAttributes,this.elementTypeName=e.elementTypeName,this.conditionBuilderHtml=e.conditionBuilderHtml,this.conditionBuilderJs=e.conditionBuilderJs,this.sites=e.sites,this.userGroups=e.userGroups,this.viewModes=e.viewModes,!e.headHtml){t.next=13;break}return t.next=13,Craft.appendHeadHtml(e.headHtml);case 13:if(!e.bodyHtml){t.next=16;break}return t.next=16,Craft.appendBodyHtml(e.bodyHtml);case 16:for(this.sourceSort=new Garnish.DragSort({handle:".move",axis:"y",filter:function(){return h.sourceSort.$targetItem.hasClass("heading")?h.sourceSort.$targetItem.add(h.sourceSort.$targetItem.nextUntil(".heading")):h.sourceSort.$targetItem}}),this.sources=[],i=0;i
').appendTo(this.$footer),s=$("
",{type:"button",class:"btn menubtn add icon","aria-label":Craft.t("app","Add…"),"aria-controls":"add-source-menu",title:Craft.t("app","Add…"),"data-disclosure-trigger":""}).appendTo(a),this.$addSourceMenu=$("
",{id:"add-source-menu",class:"menu menu--disclosure"}).appendTo(a),o=function(t){var e=h.addSource(t,!0);Garnish.scrollContainerToElement(h.$sidebar,e.$item),e.select(),h.addSourceMenu.hide()},l=$("
",{type:"button",class:"menu-item",text:Craft.t("app","New heading")}).on("click",(function(){o({type:"heading"}),h.focusLabelInput()})),c=$("
",{type:"button",class:"menu-item",text:Craft.t("app","New custom source"),"data-type":"custom"}).on("click",(function(){var t=h.baseSortOptions.slice(0);t.push.apply(t,r(h.defaultSortOptions)),o({type:"custom",key:"custom:".concat(Craft.uuid()),sortOptions:t,defaultSort:[t[0].attr,t[1].defaultDir],tableAttributes:[],availableTableAttributes:[]}),h.focusLabelInput()})),u=$("
").append($("
").append(l)).appendTo(this.$addSourceMenu),e.conditionBuilderHtml&&$("
").append(c).appendTo(u),Craft.useMobileStyles()&&this.buildSidebarToggleView(),this.addListener(Garnish.$win,"resize",this.updateSidebarView),this.addSourceMenu=new Garnish.DisclosureMenu(s);case 31:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)}),focusLabelInput:function(){this.selectedSource.$labelInput.focus()},getSourceName:function(){return this.selectedSource?this.selectedSource.sourceData.label:this.sources[0].sourceData.label},updateSidebarView:function(){Craft.useMobileStyles()?this.$sidebarToggleBtn||this.buildSidebarToggleView():this.$sidebarToggleBtn&&this.resetView()},resetView:function(){this.$sourceSettingsHeader&&this.$sourceSettingsHeader.remove(),this.$sourcesHeader&&this.$sourcesHeader.remove(),this.$sidebarToggleBtn=null,this.$container.removeClass("sidebar-hidden")},updateHeading:function(){this.$sourcesHeading&&this.$sourcesHeading.text(this.getSourceName())},buildSidebarToggleView:function(){var t=this;this.$sourcesHeader=$('').addClass("sidebar-header").prependTo(this.$sourcesContainer),this.$sidebarCloseBtn=Craft.ui.createButton({class:"nav-close close-btn"}).attr("aria-label",Craft.t("app","Close")).removeClass("btn").appendTo(this.$sourcesHeader),this.$sourcesHeading=$('
').text(this.getSourceName()),this.$sourceSettingsHeader=$('').addClass("main-header").append(this.$sourcesHeading).prependTo(this.$sourceSettingsContainer),this.$sidebarToggleBtn=Craft.ui.createButton({toggle:!0,controls:"modal-sidebar",class:"nav-toggle"}).removeClass("btn").attr("aria-label",Craft.t("app","Show sidebar")).appendTo(this.$sourceSettingsHeader),this.closeSidebar(),this.addListener(this.$sidebarToggleBtn,"click",(function(){t.toggleSidebar()})),this.addListener(this.$sidebarCloseBtn,"click",(function(){t.toggleSidebar(),t.$sidebarToggleBtn.focus()}))},toggleSidebar:function(){this.sidebarIsOpen()?this.closeSidebar():this.openSidebar()},openSidebar:function(){var t=this;this.$container.removeClass("sidebar-hidden"),this.$sidebarToggleBtn.attr("aria-expanded","true"),this.$sidebar.find(":focusable").first().focus(),Garnish.uiLayerManager.addLayer(this.$sidebar),Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY,(function(){t.closeSidebar(),Garnish.focusIsInside(t.$sidebar)&&t.$sidebarToggleBtn.focus()}))},closeSidebar:function(){this.$container.addClass("sidebar-hidden"),this.$sidebarToggleBtn&&this.$sidebarToggleBtn.attr("aria-expanded","false"),Garnish.uiLayerManager.currentLayer.$container.hasClass("cs-sidebar")&&Garnish.uiLayerManager.removeLayer()},sidebarIsOpen:function(){return"true"===this.$sidebarToggleBtn.attr("aria-expanded")},addSource:function(t,e){var n,r,i=$('
').appendTo(this.$sourcesContainer),a=$('
').attr({tabindex:"0",role:"button"}).append($('
')).append($('
')).appendTo(i),s=$('
').appendTo(i);return $('
')).appendTo(i),"heading"===t.type?(i.addClass("heading"),s.attr("name","sourceOrder[][heading]"),(n=new Craft.CustomizeSourcesModal.Heading(this,i,a,s,t,e)).updateItemLabel(t.heading)):(s.attr("name","sourceOrder[][key]").val(t.key),(n="native"===t.type?new Craft.CustomizeSourcesModal.Source(this,i,a,s,t,e):new Craft.CustomizeSourcesModal.CustomSource(this,i,a,s,t,e)).updateItemLabel(t.label),null!==(r=t.data)&&void 0!==r&&r.handle&&n.updateItemHandle(t.data.handle),t.key===this.elementIndex.rootSourceKey&&n.select()),this.sourceSort.addItems(i),n},save:function(t){var e=this;t&&t.preventDefault(),this.$saveBtn.hasClass("disabled")||this.$saveBtn.hasClass("loading")||(this.$saveBtn.addClass("loading"),Craft.sendActionRequest("POST","element-index-settings/save-customize-sources-modal-settings",{data:this.$container.serialize()+"&elementType=".concat(this.elementIndex.elementType)}).then((function(t){var n=t.data,r=null;e.selectedSource&&e.selectedSource.sourceData.key&&!n.disabledSourceKeys.includes(e.selectedSource.sourceData.key)?r=e.selectedSource.sourceData.key:e.elementIndex.sourceKey||(r=e.elementIndex.$visibleSources.first().data("key")),r&&e.elementIndex.selectSourceByKey(r),window.location.reload()})).catch((function(t){var e;Craft.cp.displayError(null==t||null===(e=t.response)||void 0===e||null===(e=e.data)||void 0===e?void 0:e.message)})).finally((function(){e.$saveBtn.removeClass("loading")})))},appendIndexSourceItem:function(t,e){if(e){var n=t.hasClass("heading");if(e.hasClass("heading")&&!n)t.appendTo(e.children("ul"));else{if(n){var r=e.parentsUntil(this.$elementIndexSourcesContainer,"li").last();r.length&&(e=r)}t.insertAfter(e)}}else t.prependTo(this.$elementIndexSourcesContainer)},destroy:function(){for(var t=0;t
").appendTo(this.modal.$sourceSettingsContainer),this.createSettings(this.$settingsContainer)),this.modal.$sourceSettingsContainer.scrollTop(0))},createSettings:(c=o(n().mark((function t(){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return c.apply(this,arguments)}),getIndexSourceItem:function(){},deselect:function(){this.$item.removeClass("sel"),this.$itemButton.attr({"aria-current":"false"}),this.modal.selectedSource=null,this.$settingsContainer.addClass("hidden")},updateItemLabel:function(t){t?this.$itemButton.find(".label").text(t):this.$itemButton.find(".label").html(" ")},updateItemHandle:function(t){t?this.$itemButton.find(".handle").text(t):this.$itemButton.find(".handle").empty()},destroy:function(){this.modal.sourceSort.removeItems(this.$item),this.modal.sources.splice($.inArray(this,this.modal.sources),1),this.isSelected()&&(this.deselect(),this.modal.sources.length&&this.modal.sources[0].select(),Garnish.setFocusWithin(this.modal.$sourceSettingsContainer)),this.$item.data("source",null),this.$item.remove(),this.$settingsContainer&&this.$settingsContainer.remove(),this.base()}}),Craft.CustomizeSourcesModal.Source=Craft.CustomizeSourcesModal.BaseSource.extend({$viewModeInput:null,viewModeListbox:null,$sortAttributeSelect:null,$sortDirectionPicker:null,$sortDirectionInput:null,sortDirectionListbox:null,isNative:function(){return!0},createSettings:(u=o(n().mark((function t(e){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Craft.ui.createLightswitchField({label:Craft.t("app","Enabled"),name:"sources[".concat(this.sourceData.key,"][enabled]"),on:!this.sourceData.disabled}).appendTo(e),this.createViewModeField(e),this.createSortField(e),this.createTableAttributesField(e);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)}),createViewModeField:function(t){var e,n=this,r=$("",{class:"btngroup btngroup--exclusive","aria-label":Craft.t("app","View mode options")}),a=this.modal.viewModes.filter((function(t){return!t.structuresOnly||n.sourceData.structureId})),s=this.sourceData.defaultViewMode;s&&a.some((function(t){return t.mode===s}))||(s=null===(e=a[0])||void 0===e?void 0:e.mode);var o,l=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=i(t))){e&&(t=e);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return s=t.done,t},e:function(t){o=!0,a=t},f:function(){try{s||null==e.return||e.return()}finally{if(o)throw a}}}}(a);try{for(l.s();!(o=l.n()).done;){var c=o.value,u=$(" ",{type:"button",class:"btn",title:c.title,"aria-label":c.title,"data-mode":c.mode}).appendTo(r);$("
",{class:"cp-icon small"}).append(c.iconSvg).appendTo(u),c.mode===s?u.addClass("active").attr("aria-pressed","true"):u.attr("aria-pressed","false")}}catch(t){l.e(t)}finally{l.f()}r.children("button:last").addClass("btngroup-btn-last"),this.$viewModeInput=$(" ",{type:"hidden",name:"sources[".concat(this.sourceData.key,"][defaultViewMode]"),value:this.sourceData.defaultViewMode}).appendTo(r),this.viewModeListbox=new Craft.Listbox(r,{onChange:function(t){n.$viewModeInput.val(t.data("mode"))}}),Craft.ui.createField(r,{label:Craft.t("app","Default View Mode"),fieldset:!0}).appendTo(t).addClass("view-mode-field")},createSortField:function(t){var e=this,n=$('
'),i=this.sourceData.sortOptions.sort((function(t,e){return t.label===e.label?0:t.label ").appendTo(n));this.$sortAttributeSelect=a.children("select").attr("aria-label",Craft.t("app","Sort attribute")),this.$sortDirectionPicker=$("",{class:"btngroup btngroup--exclusive","aria-label":Craft.t("app","Sort direction")}).append($(" ",{type:"button",class:"btn",title:Craft.t("app","Sort ascending"),"aria-label":Craft.t("app","Sort ascending"),"aria-pressed":"false","data-icon":"asc","data-dir":"asc"})).append($(" ",{type:"button",class:"btn",title:Craft.t("app","Sort descending"),"aria-label":Craft.t("app","Sort descending"),"aria-pressed":"false","data-icon":"desc","data-dir":"desc"})).appendTo(n),this.$sortDirectionInput=$(" ",{type:"hidden",name:"sources[".concat(this.sourceData.key,"][defaultSort][1]")}).appendTo(n),this.sortDirectionListbox=new Craft.Listbox(this.$sortDirectionPicker,{onChange:function(t){e.$sortDirectionInput.val(t.data("dir"))}}),this.$sortAttributeSelect.on("change",(function(){e.handleSortAttributeChange()})),this.handleSortAttributeChange(!0),Craft.ui.createField(n,{label:Craft.t("app","Default Sort"),fieldset:!0}).appendTo(t).addClass("sort-field")},handleSortAttributeChange:function(t){var e=this.$sortAttributeSelect.val();if("structure"===e)this.sortDirectionListbox.select(0),this.sortDirectionListbox.disable(),this.$sortDirectionPicker.addClass("disabled");else{this.sortDirectionListbox.enable(),this.$sortDirectionPicker.removeClass("disabled");var n=t?this.sourceData.defaultSort[1]:this.sourceData.sortOptions.find((function(t){return t.attr===e})).defaultDir;this.sortDirectionListbox.select("asc"===n?0:1)}},createTableAttributesField:function(t){var n=this.availableTableAttributes().sort((function(t,e){return t[1]===e[1]?0:t[1] ",{type:"hidden",name:r,value:""}).appendTo(t),Craft.ui.createCheckboxSelectField({label:Craft.t("app","Default Table Columns"),instructions:Craft.t("app","Choose which table columns should be visible for this source by default."),name:r,options:n.map((function(t){var n=e(t,2),r=n[0];return{label:n[1],value:r}})),values:this.sourceData.tableAttributes.map((function(t){return e(t,1)[0]})),sortable:!0}).appendTo(t)}},availableTableAttributes:function(){var t=this.modal.availableTableAttributes.slice(0);return t.push.apply(t,r(this.sourceData.availableTableAttributes)),t},getIndexSourceItem:function(){var t=this.modal.elementIndex.getSourceByKey(this.sourceData.key);if(t)return t.closest("li")}}),Craft.CustomizeSourcesModal.CustomSource=Craft.CustomizeSourcesModal.Source.extend({$labelInput:null,createSettings:(h=o(n().mark((function t(e){var r,i,a,s,o,l=this;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Craft.ui.createTextField({label:Craft.t("app","Label"),name:"sources[".concat(this.sourceData.key,"][label]"),value:this.sourceData.label}).appendTo(e),this.$labelInput=r.find(".text"),i="condition".concat(Math.floor(1e6*Math.random())),a=function(t){return t.replace(/__ID__/g,i).replace(/__SOURCE_KEY__(?=-)/g,Craft.formatInputId(l.sourceData.key)).replace(/__SOURCE_KEY__/g,l.sourceData.key)},s=this.sourceData.conditionBuilderHtml||a(this.modal.conditionBuilderHtml),o=this.sourceData.conditionBuilderJs||a(this.modal.conditionBuilderJs),Craft.ui.createField($("
").append(s),{id:"criteria",label:Craft.t("app","{type} Criteria",{type:this.modal.elementTypeName})}).appendTo(e),!o){t.next=10;break}return t.next=10,Craft.appendBodyHtml(o);case 10:this.createSortField(e),this.createTableAttributesField(e),this.createViewModeField(e),Craft.sites.length>1&&Craft.ui.createCheckboxSelectField({label:Craft.t("app","Sites"),instructions:Craft.t("app","Choose which sites this source should be visible for."),name:"sources[".concat(this.sourceData.key,"][sites]"),options:Craft.sites.map((function(t){return{label:t.name,value:t.uid}})),values:this.sourceData.sites||"*",showAllOption:!0}).appendTo(e),this.modal.userGroups.length&&Craft.ui.createCheckboxSelectField({label:Craft.t("app","User Groups"),instructions:Craft.t("app","Choose which user groups should have access to this source."),name:"sources[".concat(this.sourceData.key,"][userGroups]"),options:this.modal.userGroups,values:this.sourceData.userGroups||"*",showAllOption:!0}).appendTo(e),e.append(" "),this.$deleteBtn=$(' ').attr({role:"button",tabindex:"0"}).text(Craft.t("app","Delete custom source")).appendTo(e),this.addListener(this.$labelInput,"input","handleLabelInputChange"),this.addListener(this.$deleteBtn,"activate","destroy");case 19:case"end":return t.stop()}}),t,this)}))),function(t){return h.apply(this,arguments)}),availableTableAttributes:function(){var t=this.base();if(this.isNew){var e=[],n=[];this.modal.customFieldAttributes.forEach((function(t){-1==e.indexOf(t[0])&&(e.push(t[0]),n.push(t))})),t.push.apply(t,n)}return t},handleLabelInputChange:function(){this.updateItemLabel(this.$labelInput.val())},getIndexSourceItem:function(){var t,e=this.base();if(e?t=e.find(".label"):(t=$(" ",{class:"label"}),e=$(" ").append($(" ",{"data-key":this.sourceData.key}).append(t))),this.$labelInput){var n=this.$labelInput.val().trim();""===n&&(n=Craft.t("app","(blank)")),t.text(n)}return e}}),Craft.CustomizeSourcesModal.Heading=Craft.CustomizeSourcesModal.BaseSource.extend({$labelInput:null,$deleteBtn:null,isHeading:function(){return!0},createSettings:(d=o(n().mark((function t(e){var r;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=Craft.ui.createTextField({label:Craft.t("app","Heading"),instructions:Craft.t("app","This can be left blank if you just want an unlabeled separator."),value:this.sourceData.heading||""}).appendTo(e),this.$labelInput=r.find(".text"),e.append(" "),this.$deleteBtn=$(' ').text(Craft.t("app","Delete heading")).attr({role:"button",tabindex:"0"}).appendTo(e),this.addListener(this.$labelInput,"input","handleLabelInputChange"),this.addListener(this.$deleteBtn,"activate","destroy");case 6:case"end":return t.stop()}}),t,this)}))),function(t){return d.apply(this,arguments)}),handleLabelInputChange:function(){this.updateItemLabel(this.$labelInput.val())},updateItemLabel:function(t){this.$itemButton.find(".label").html((t?Craft.escapeHtml(t):"".concat(Craft.t("app","(blank)")," "))+" "),this.$itemInput.val(t)},getIndexSourceItem:function(){var t=(this.$labelInput?this.$labelInput.val():null)||this.sourceData.heading||"";return $(' ').append($(" ").text(t)).append("")}})},1833:function(){Craft.BaseElementSelectorModal=Garnish.Modal.extend({elementType:null,elementIndex:null,supportSidebarToggleView:!1,$body:null,$content:null,$footer:null,$selectBtn:null,$sidebar:null,$sources:null,$sourceToggles:null,$sidebarToggleBtn:null,$sidebarCloseBtn:null,$mainHeading:null,$main:null,$search:null,$elements:null,$tbody:null,$primaryButtons:null,$secondaryButtons:null,$cancelBtn:null,init:function(t,e){this.elementType=t,this.setSettings(e,Craft.BaseElementSelectorModal.defaults);var n="elementSelectorModalHeading-"+Math.floor(1e6*Math.random()),r=$("
",{class:"modal elementselectormodal","aria-labelledby":n}).appendTo(Garnish.$bod),i=$("
",{class:this.settings.showTitle?"header":"visually-hidden"}).appendTo(r);$(" ",{id:n,text:this.settings.modalTitle}).appendTo(i);var a=$("
",{class:"body"}).append($("
",{class:"spinner big"})).appendTo(r);this.$footer=$("
",{class:"footer"}).appendTo(r),this.settings.fullscreen&&(r.addClass("fullscreen"),this.settings.minGutter=0),this.base(r,this.settings),this.$secondaryButtons=$('
').appendTo(this.$footer),this.$primaryButtons=$('
').appendTo(this.$footer),this.$cancelBtn=$(" ",{type:"button",class:"btn",text:Craft.t("app","Cancel")}).appendTo(this.$primaryButtons),this.$selectBtn=Craft.ui.createSubmitButton({class:"disabled",label:this.settings.selectBtnLabel,spinner:!0}).attr("aria-disabled","true").appendTo(this.$primaryButtons),this.$body=a,this.addListener(this.$cancelBtn,"activate","cancel"),this.addListener(this.$selectBtn,"activate","selectElements")},updateModalBottomPadding:function(){var t=this.$footer.outerHeight();t!==parseInt(this.$container.css("padding-bottom"))&&this.$container.css("padding-bottom",t)},updateSidebarView:function(){this.supportSidebarToggleView&&(this.sidebarShouldBeHidden()?this.$sidebarToggleBtn||this.buildSidebarToggleView():this.$sidebarToggleBtn&&this.resetView())},sidebarShouldBeHidden:function(){return this.$container.outerWidth()<550},resetView:function(){this.$mainHeader&&this.$mainHeader.remove(),this.$sidebarHeader&&this.$sidebarHeader.remove(),this.$sidebarToggleBtn=null,this.$body.addClass("has-sidebar"),this.$content.addClass("has-sidebar"),this.$sidebar.removeClass("hidden")},buildSidebarToggleView:function(){var t=this;!this.$sidebarToggleBtn&&this.sidebarShouldBeHidden()&&(this.$sidebarHeader=$('').prependTo(this.$sidebar),this.$sidebarCloseBtn=Craft.ui.createButton({class:"nav-close close-btn"}).attr("aria-label",Craft.t("app","Close")).removeClass("btn").appendTo(this.$sidebarHeader),this.$mainHeader=$('
').prependTo(this.$main),this.$mainHeading=$(''.concat(this.getActiveSourceName()," ")).appendTo(this.$mainHeader),this.$sidebarToggleBtn=Craft.ui.createButton({toggle:!0,controls:"modal-sidebar",class:"nav-toggle"}).removeClass("btn").attr("aria-label",Craft.t("app","Show sidebar")).appendTo(this.$mainHeader),this.$sidebar.attr("id","modal-sidebar"),this.closeSidebar(),this.addListener(this.$sidebarToggleBtn,"click",(function(){t.toggleSidebar()})),this.addListener(this.$sidebarCloseBtn,"click",(function(){t.toggleSidebar()})))},sidebarIsOpen:function(){return"true"===this.$sidebarToggleBtn.attr("aria-expanded")},toggleSidebar:function(){this.sidebarIsOpen()?this.closeSidebar():this.openSidebar()},openSidebar:function(){var t=this;this.$body.addClass("has-sidebar"),this.$content.addClass("has-sidebar"),this.$sidebar.removeClass("hidden"),this.$sidebarToggleBtn.attr("aria-expanded","true"),this.$sidebar.find(":focusable").first().focus(),Garnish.uiLayerManager.addLayer(this.$sidebar),Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY,(function(){t.closeSidebar()}))},closeSidebar:function(){if(this.$sidebarToggleBtn){this.sidebarIsOpen()&&Garnish.uiLayerManager.removeLayer(),this.$sidebar.addClass("hidden"),this.$sidebarToggleBtn.attr("aria-expanded","false");var t=Garnish.getFocusedElement();$.contains(this.$sidebar.get(0),t.get(0))&&this.$sidebarToggleBtn.focus(),this.$body.removeClass("has-sidebar"),this.$content.removeClass("has-sidebar")}},getActiveSourceName:function(){return this.$sidebar.find(".sel").text()},onFadeIn:function(){this.elementIndex?(this.updateModalBottomPadding(),Garnish.isMobileBrowser(!0)||this.elementIndex.$search.focus()):this._createElementIndex(),this.base()},onSelectionChange:function(){this.updateSelectBtnState()},onSelectSource:function(){this.updateHeading(),this.updateModalBottomPadding()},updateHeading:function(){this.$mainHeading&&this.$mainHeading.text(this.getActiveSourceName())},updateSelectBtnState:function(){this.$selectBtn&&(this.shouldEnableSelectBtn()?this.enableSelectBtn():this.disableSelectBtn())},shouldEnableSelectBtn:function(){return this.hasSelection()},hasSelection:function(){return this.elementIndex&&this.elementIndex.getSelectedElements().length},enableSelectBtn:function(){this.$selectBtn.removeClass("disabled").attr("aria-disabled","false")},disableSelectBtn:function(){this.$selectBtn.addClass("disabled").attr("aria-disabled","true")},enableCancelBtn:function(){this.$cancelBtn.removeClass("disabled")},disableCancelBtn:function(){this.$cancelBtn.addClass("disabled")},showFooterSpinner:function(){this.$selectBtn.addClass("loading")},hideFooterSpinner:function(){this.$selectBtn.removeClass("loading")},cancel:function(){this.$cancelBtn.hasClass("disabled")||this.hide()},selectElements:function(){if(this.hasSelection()){this.elementIndex.view&&this.elementIndex.view.elementSelect&&this.elementIndex.view.elementSelect.clearMouseUpTimeout();var t=this.elementIndex.getSelectedElements(),e=this.getElementInfo(t);this.onSelect(e),this.settings.disableElementsOnSelect&&this.elementIndex.disableElements(this.elementIndex.getSelectedElements()),this.settings.hideOnSelect&&this.hide()}},getElementInfo:function(t){for(var e=[],n=0;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:M(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),b}},n}function i(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var s=t.apply(e,n);function o(t){i(s,r,a,o,l,"next",t)}function l(t){i(s,r,a,o,l,"throw",t)}o(void 0)}))}}var s;Craft.TableElementIndexView=Craft.BaseElementIndexView.extend({$table:null,$tableCaption:null,$selectedSortHeader:null,$statusMessage:null,$editBtn:null,$saveBtn:null,$cancelBtn:null,tableSort:null,_totalVisiblePostStructureTableDraggee:null,_morePendingPostStructureTableDraggee:!1,_broadcastListener:null,initialSerializedValue:null,stickyScrollbar:null,stickyScrollbarObserver:null,getElementContainer:function(){return this.$table=this.$container.find("table:first"),this.$table.children("tbody:first")},afterInit:function(){var t=this;this.$tableCaption=this.$table.find("caption"),this.initTableHeaders(),this.createScrollbar(),(this.settings.sortable||this.elementIndex.isAdministrative&&"structure"===this.elementIndex.viewMode&&Garnish.hasAttr(this.$table,"data-structure-id"))&&!this.elementIndex.inlineEditing&&(this.tableSort=new Craft.ElementTableSorter(this,this.getAllElements(),{structureId:this.$table.data("structure-id"),maxLevels:this.$table.attr("data-max-levels"),onSortChange:function(){t.settings.onSortChange(t.tableSort.$draggee)}})),"structure"!==this.elementIndex.viewMode||this.elementIndex.inlineEditing||this.addListener(this.$elementContainer,"click",(function(t){var e=$(t.target);e.hasClass("toggle")&&!1===this._collapseElement(e)&&this._expandElement(e)})),this.elementIndex.isAdministrative&&!this.elementIndex.settings.static&&!1!==this.elementIndex.settings.inlineEditable&&this.$elementContainer.has("> tr[data-id] > th .element[data-editable]")&&this.initForInlineEditing(),Craft.messageReceiver&&(this._broadcastListener=function(e){if("saveElement"===e.data.event||"replaceFile"===e.data.event){var n=t.$table.find('> tbody > tr[data-id="'.concat(e.data.id,'"]'));if(n.length){var r=Object.assign(t.elementIndex.getViewParams(),{id:e.data.id});Craft.sendActionRequest("POST","element-indexes/element-table-html",{data:r}).then((function(t){for(var e=t.data,r=0;r td[data-attr="'.concat(a,'"]')).html(e.attributeHtml[a])}Craft.cp.elementThumbLoader.load(n)}))}}},Craft.messageReceiver.addEventListener("message",this._broadcastListener))},initForInlineEditing:function(){var t=this;this.elementIndex.inlineEditing?(Craft.initUiElements(this.$elementContainer),this.initialSerializedValue=this.serializeInputs(),this.$saveBtn=Craft.ui.createSubmitButton({label:Craft.t("app","Save"),spinner:!0}).insertBefore(this.elementIndex.$exportBtn),this.$cancelBtn=Craft.ui.createButton({label:Craft.t("app","Cancel"),spinner:!0}).insertBefore(this.elementIndex.$exportBtn),this.addListener(this.$saveBtn,"activate",(function(){t.$saveBtn.addClass("loading"),t.closeDateTimeFields(),t.saveChanges().then((function(e){if(e.errors){for(var n in e.errors)if(e.errors.hasOwnProperty(n)){var r=t.$elementContainer.children('[data-id="'.concat(n,'"]'));for(var i in e.errors[n])r.find('[name*="'.concat(i,'"]')).closest("td").addClass("errors")}return t.elementIndex.setIndexAvailable(),void Craft.cp.displayError(Craft.t("app","Could not save due to validation errors."))}Craft.cp.displaySuccess(Craft.t("app","Changes saved.")),t.elementIndex.inlineEditing=!1,t.elementIndex.updateElements(!0,!1).then((function(){t.elementIndex.$elements.removeClass("inline-editing")}))})).catch((function(){t.elementIndex.setIndexAvailable(),Craft.cp.displayError()})).finally((function(){t.$saveBtn.removeClass("loading")}))})),this.addListener(this.$cancelBtn,"activate",(function(){t.getDeltaInputChanges()&&!confirm(Craft.t("app","Are you sure you want to discard your changes?"))||(t.$cancelBtn.addClass("loading"),t.elementIndex.inlineEditing=!1,t.closeDateTimeFields(),t.elementIndex.updateElements(!0,!1).then((function(){t.elementIndex.$elements.removeClass("inline-editing")})))})),this.addListener(this.$elementContainer,"keydown",(function(e){e.keyCode===Garnish.RETURN_KEY?t.$saveBtn.trigger("click"):e.keyCode===Garnish.S_KEY&&Garnish.isCtrlKeyPressed(e)&&(e.stopPropagation(),e.preventDefault(),t.$saveBtn.trigger("click"))}))):(this.$editBtn=Craft.ui.createButton({label:Craft.t("app","Edit"),spinner:!0}).insertBefore(this.elementIndex.$exportBtn),this.addListener(this.$editBtn,"activate",(function(){t.$editBtn.addClass("loading"),t.elementIndex.inlineEditing=!0,t.elementIndex.updateElements(!0,!1).then((function(){t.elementIndex.$elements.addClass("inline-editing")}))})))},closeDateTimeFields:function(){this.elementIndex.$elements.find(".datewrapper input").datepicker("destroy"),$().timepicker&&this.elementIndex.$elements.find(".timewrapper input").timepicker("remove")},serializeInputs:function(){var t=Garnish.getPostData(this.$elementContainer),e=[];for(var n in t)e.push(encodeURIComponent("".concat(n,"=").concat(t[n])));return e.join("&")},getDeltaInputChanges:function(){var t=this,e=this.$elementContainer.children().toArray().map((function(e){return"".concat(t.elementIndex.nestedInputNamespace,"[element-").concat($(e).data("id"),"]")}));return Craft.findDeltaData(this.initialSerializedValue,this.serializeInputs(),e)},haveInputsChanged:function(){return this.serializeInputs()!==this.initialSerializedValue},saveChanges:(s=a(r().mark((function t(){var e,n;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.getDeltaInputChanges()){t.next=3;break}return t.abrupt("return",{});case 3:return e+="&"+$.param({elementType:this.elementIndex.elementType,siteId:this.elementIndex.siteId,namespace:this.elementIndex.nestedInputNamespace}),t.next=6,Craft.sendActionRequest("POST","element-indexes/save-elements",{data:e});case 6:return n=t.sent,t.abrupt("return",n.data);case 8:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)}),initTableHeaders:function(){if(!this.elementIndex.inlineEditing){var t,n;if("structure"===this.elementIndex.viewMode)t="structure",n="asc";else{var r=e(this.elementIndex.getSortAttributeAndDirection(),2);t=r[0],n=r[1]}for(var i=this.$table.children("thead").children().children("[data-attribute]"),a=0;a1&&void 0!==arguments[1]&&arguments[1];t.addClass("orderable");var n=t.html(),r=this.$tableCaption.find("[data-sort-instructions]"),i=$(" ",{id:"".concat(this.elementIndex.idPrefix,"-").concat(t.attr("data-attribute")),type:"button","aria-pressed":"false"}).html(n);r.length&&i.attr("aria-describedby",r.attr("id")),e?(i.attr("aria-pressed","true"),i.on("click",this._handleSelectedSortHeaderClick.bind(this))):i.on("click",this._handleUnselectedSortHeaderClick.bind(this)),t.empty().append(i)},isVerticalList:function(){return!0},getTotalVisible:function(){return this._isStructureTableDraggingLastElements()?this._totalVisiblePostStructureTableDraggee:this._totalVisible},setTotalVisible:function(t){this._isStructureTableDraggingLastElements()?this._totalVisiblePostStructureTableDraggee=t:this._totalVisible=t},getMorePending:function(){return this._isStructureTableDraggingLastElements()?this._morePendingPostStructureTableDraggee:this._morePending},setMorePending:function(t){this._isStructureTableDraggingLastElements()?this._morePendingPostStructureTableDraggee=t:this._morePending=this._morePendingPostStructureTableDraggee=t},getLoadMoreParams:function(){var t=this.base();return this._isStructureTableDraggingLastElements()&&(t.criteria.positionedAfter=this.tableSort.$targetItem.data("id")),t},appendElements:function(t){this.base(t),this.tableSort&&this.tableSort.addItems(t),Craft.cp.updateResponsiveTables()},_collapseElement:function(t,e){if(!e&&!t.hasClass("expanded"))return!1;t.removeClass("expanded"),t.attr("aria-expanded","false");for(var n=t.closest("tr"),r=n.data("id"),i=n.data("level"),a=n.next();a.length;){if(!Garnish.hasAttr(a,"data-spinnerrow")){if(a.data("level")<=i)break;this.elementSelect&&this.elementSelect.removeItems(a),this.tableSort&&this.tableSort.removeItems(a),this._totalVisible--}var s=a.next();a.remove(),a=s}this.elementIndex.instanceState.collapsedElementIds||(this.elementIndex.instanceState.collapsedElementIds=[]),this.elementIndex.instanceState.collapsedElementIds.push(r),this.elementIndex.setInstanceState("collapsedElementIds",this.elementIndex.instanceState.collapsedElementIds),this.maybeLoadMore()},_expandElement:function(t,e){var n=this;if(!e&&t.hasClass("expanded"))return!1;if(t.addClass("expanded"),t.attr("aria-expanded","true"),this.elementIndex.instanceState.collapsedElementIds){var i=t.closest("tr"),s=i.data("id"),o=$.inArray(s,this.elementIndex.instanceState.collapsedElementIds);if(-1!==o){this.elementIndex.instanceState.collapsedElementIds.splice(o,1),this.elementIndex.setInstanceState("collapsedElementIds",this.elementIndex.instanceState.collapsedElementIds);var l=this._createSpinnerRowAfter(i),c=$.extend(!0,{},this.settings.params);c.criteria.descendantOf=s,Craft.sendActionRequest("POST",this.settings.loadMoreElementsAction,{data:c}).then(function(){var t=a(r().mark((function t(e){var i,a,s,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l.parent().length){t.next=2;break}return t.abrupt("return");case 2:return i=$(e.data.html),a=n._totalVisible+i.length,(s=n.settings.batchSize&&i.length===n.settings.batchSize)?(o=l.nextAll(),n.elementSelect&&n.elementSelect.removeItems(o),n.tableSort&&n.tableSort.removeItems(o),o.remove(),a-=o.length):s=n._morePending,l.replaceWith(i),n.thumbLoader.load(i),(n.elementIndex.actions||n.settings.selectable)&&(n.elementSelect.addItems(i.filter(":not(.disabled)")),n.elementIndex.updateActionTriggers()),n.tableSort&&n.tableSort.addItems(i),t.next=12,Craft.appendHeadHtml(e.data.headHtml);case 12:return t.next=14,Craft.appendBodyHtml(e.data.bodyHtml);case 14:Craft.cp.updateResponsiveTables(),n.setTotalVisible(a),n.setMorePending(s),n.maybeLoadMore();case 18:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).catch((function(t){Craft.cp.displayError(),l.parent().length}))}}},_createSpinnerRowAfter:function(t){return $('
').insertAfter(t)},_isStructureTableDraggingLastElements:function(){return this.tableSort&&this.tableSort.dragging&&this.tableSort.draggingLastElements},_handleSelectedSortHeaderClick:function(t){var e=$(t.currentTarget).closest("th");if(!e.hasClass("loading")){var n="asc"===this.elementIndex.getSelectedSortDirection()?"desc":"asc";this.elementIndex.selectViewMode("table"),this.elementIndex.setSelectedSortDirection(n),this._handleSortHeaderClick(t,e)}},_handleUnselectedSortHeaderClick:function(t){var e=$(t.currentTarget).closest("th");if(!e.hasClass("loading")){var n=e.attr("data-attribute");this.elementIndex.selectViewMode("table"),this.elementIndex.setSelectedSortAttribute(n),this._handleSortHeaderClick(t,e)}},_handleSortHeaderClick:function(t,e){this.$selectedSortHeader&&this.$selectedSortHeader.removeClass("ordered asc desc"),e.addClass("ordered loading"),this.elementIndex.updateElements(),this.elementIndex.setIndexAvailable()},_updateTableAttributes:function(t,e){var n=t.closest("tr");for(var r in e)e.hasOwnProperty(r)&&n.children('[data-attr="'+r+'"]:first').html(e[r])},destroy:function(){this.$editBtn?this.$editBtn.remove():this.$cancelBtn&&(this.$saveBtn.remove(),this.$cancelBtn.remove()),this.stickyScrollbar&&this.stickyScrollbar.remove(),this.stickyScrollbarObserver&&this.stickyScrollbarObserver.disconnect(),this._broadcastListener&&(Craft.messageReceiver.removeEventListener("message",this._broadcastListener),delete this._broadcastListener),this.base()},createScrollbar:function(){var t=this;if("index"===this.elementIndex.settings.context){var n=document.querySelector("#content > #footer");if(n){this.stickyScrollbar=document.createElement("craft-proxy-scrollbar"),this.stickyScrollbar.setAttribute("scroller",".tablepane"),this.stickyScrollbar.setAttribute("content",".tablepane > table"),this.stickyScrollbar.style.bottom="".concat(n.getBoundingClientRect().height+2,"px");var r=$(this.stickyScrollbar);this.stickyScrollbarObserver=new IntersectionObserver((function(n){e(n,1)[0].intersectionRatio<1?r.insertAfter(t.$container):r.remove()}),{rootMargin:"0px 0px -1px 0px",threshold:[1]}),this.stickyScrollbarObserver.observe(n)}}}})},1980:function(){Craft.IntervalManager=Garnish.Base.extend({_intervalId:null,init:function(t){this.setSettings(t,Craft.IntervalManager.defaults)},start:function(){var t=this;this._intervalId=setInterval((function(){t.settings.onInterval()}),this.settings.interval)},stop:function(){clearInterval(this._intervalId),this._intervalId=null}},{defaults:{interval:5e3,onInterval:$.noop}})},2059:function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n ",{id:i}).insertAfter(this.$colorInput),o=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}(this.settings.presets);try{for(o.s();!(a=o.n()).done;){var l=a.value;$(" ").text(l).appendTo(s)}}catch(t){o.e(t)}finally{o.f()}}this.addListener(this.$colorInput,"click",(function(t){t.stopPropagation()})),this.addListener(this.$colorContainer,"click",(function(){this.$colorInput.trigger("click")})),this.addListener(this.$colorInput,"input","updateColor")}},updateColor:function(){this.$input.val(this.$colorInput.val()),this.handleTextChange()},handleTextChange:function(){var t=this.$input.val();t!==(t=t.trim())&&this.$input.val(t),t.length&&"#"===t[0]&&(t=t.substring(1),this.$input.val(t)),t.length?(3===t.length&&(t=t[0].repeat(2)+t[1].repeat(2)+t[2].repeat(2)),t.match(/^[0-9a-f]{6}$/i)?(this.$colorPreview.css("background-color","#".concat(t)),this.$colorInput&&this.$colorInput.val("#".concat(t))):this.$colorPreview.css("background-color","")):this.$colorPreview.css("background-color","")}},{defaults:{presets:[]},_browserSupportsColorInputs:null,doesBrowserSupportColorInputs:function(){return Craft.ColorInput._browserSupportsColorInputs,Craft.ColorInput._browserSupportsColorInputs}})},2107:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){"use strict";e=function(){return r};var n,r={},i=Object.prototype,a=i.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function h(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(n){h=function(t,e,n){return t[e]=n}}function d(t,e,n,r){var i=e&&e.prototype instanceof y?e:y,a=Object.create(i.prototype),o=new A(r||[]);return s(a,"_invoke",{value:E(t,n,o)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}r.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function w(){}function C(){}var $={};h($,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==i&&a.call(S,l)&&($=S);var x=C.prototype=y.prototype=Object.create($);function I(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function r(i,s,o,l){var c=f(e[i],e,s);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==t(h)&&a.call(h,"__await")?n.resolve(h.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):n.resolve(h).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,l)}))}l(c.arg)}var i;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,i){r(t,e,n,i)}))}return i=i?i.then(a,a):a()}})}function E(t,e,r){var i=p;return function(a,s){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===a)throw s;return{value:n,done:!0}}for(r.method=a,r.arg=s;;){var o=r.delegate;if(o){var l=k(o,r);if(l){if(l===b)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===p)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=f(t,e,r);if("normal"===c.type){if(i=r.done?v:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=v,r.method="throw",r.arg=c.arg)}}}function k(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var a=f(i,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,b;var s=a.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=function t(){for(;++i=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:M(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},r}function n(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(i,a){var s=t.apply(e,r);function o(t){n(s,i,a,o,l,"next",t)}function l(t){n(s,i,a,o,l,"throw",t)}o(void 0)}))}}Craft.SortableCheckboxSelect=Garnish.Base.extend({$container:null,dragSort:null,init:function(t){var e=this;this.$container=$(t),this.$container.data("sortableCheckboxSelect",this);var n=this.$container.children(".checkbox-select-item:not(.all)");this.initDrag(n),n.length&&n.each((function(t,n){e.initItem(n)}))},initDrag:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];0===t.length&&(t=this.$container.children(".checkbox-select-item:not(.all)")),t.length&&(this.dragSort=new Garnish.DragSort(t,{axis:Garnish.Y_AXIS,handle:".draggable-handle"}))},initItem:function(t){return new Craft.SortableCheckboxSelect.Item(this,t)}}),Craft.SortableCheckboxSelect.Item=Garnish.Base.extend({select:null,$item:null,$moveHandle:null,$checkbox:null,$actionMenuBtn:null,$actionMenu:null,actionDisclosure:null,moveUpBtn:null,moveDownBtn:null,init:function(t,e){var n=this;this.select=t,this.$item=$(e),this.$moveHandle=this.$item.children(".move"),this.$checkbox=this.$item.children("input[type=checkbox]"),this.addListener(this.$checkbox,"change",(function(){n.handleCheckboxChange()})),this.handleCheckboxChange()},handleCheckboxChange:function(){this.$checkbox.prop("checked")?this.onCheck():this.onUncheck()},onCheck:function(){var t=this;this.$actionMenuBtn&&this.onUncheck(),this.$moveHandle.removeClass("disabled");var n,i,a="menu-"+Math.floor(1e9*Math.random());this.$actionMenuBtn=$(" ",{class:"btn action-btn","aria-controls":a,"aria-label":Craft.t("app","Actions"),"data-disclosure-trigger":"","data-icon":"ellipsis"}).appendTo(this.$item),this.$actionMenu=$("
",{id:a,class:"menu menu--disclosure"}).appendTo(this.$item),this.actionDisclosure=new Garnish.DisclosureMenu(this.$actionMenuBtn),this.moveUpBtn=this.actionDisclosure.addItem({icon:(n=r(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon("arrow-up");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)}),label:Craft.t("app","Move up"),onActivate:function(){t.moveUp()}}),this.moveDownBtn=this.actionDisclosure.addItem({icon:(i=r(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Craft.ui.icon("arrow-down");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(){return i.apply(this,arguments)}),label:Craft.t("app","Move down"),onActivate:function(){t.moveDown()}}),this.actionDisclosure.on("show",(function(){t.getPrevCheckedItem()?t.actionDisclosure.showItem(t.moveUpBtn):t.actionDisclosure.hideItem(t.moveUpBtn),t.getNextCheckedItem()?t.actionDisclosure.showItem(t.moveDownBtn):t.actionDisclosure.hideItem(t.moveDownBtn)}));var s=this.getAllCheckedSiblings();0==s.length?this.$actionMenuBtn.hide():1==s.length&&$(s[0]).find(".btn.action-btn").show(),this.$item.trigger("checked")},onUncheck:function(){var t,e,n,r,i=this.getAllCheckedSiblings();1==i.length&&$(i[0]).find(".btn.action-btn").hide(),null===(t=this.$moveHandle)||void 0===t||t.addClass("disabled"),null===(e=this.$actionMenuBtn)||void 0===e||e.remove(),null===(n=this.$actionMenu)||void 0===n||n.remove(),null===(r=this.actionDisclosure)||void 0===r||r.destroy(),this.$actionMenuBtn=this.actionDisclosure=null,this.$item.trigger("unchecked")},getPrevCheckedItem:function(){var t=this.$item.prevAll(".checkbox-select-item:not(.all):has(input[type=checkbox]:checked):first");return t.length?t:null},getNextCheckedItem:function(){var t=this.$item.nextAll(".checkbox-select-item:not(.all):has(input[type=checkbox]:checked):first");return t.length?t:null},getAllCheckedSiblings:function(){return this.$item.siblings(".checkbox-select-item:not(.all):has(input[type=checkbox]:checked)")},moveUp:function(){var t=this.getPrevCheckedItem();t&&(this.$item.insertBefore(t),this.$item.trigger("movedUp"))},moveDown:function(){var t=this.getNextCheckedItem();t&&(this.$item.insertAfter(t),this.$item.trigger("movedDown"))}})},2200:function(){Craft.LinkField=Garnish.Base.extend({$container:null,$typeSelect:null,$labelInput:null,$filenameInput:null,init:function(t,e){var n=this;this.$container=$(t),this.$container.data("linkField",this),this.$typeSelect=this.$container.find("select:first"),this.$labelInput=this.$container.children("[data-label-field]:first").find(".text:first"),this.$filenameInput=this.$container.find("[data-filename-field]:first .text:first"),this.$typeSelect.length&&this.$typeSelect.fieldtoggle().data("fieldtoggle").on("toggleChange",(function(){n.updateLabel(),n.updateFilename()}))},getActiveLinkTypeContainer:function(){return this.$container.find("[data-link-type]:not(.hidden):first")},updateLabel:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.getActiveLinkTypeContainer();null===t?t=e.data("linkLabel")||"":e.data("linkLabel",t),this.$labelInput.prop("placeholder",t)},updateFilename:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.getActiveLinkTypeContainer();null===t?t=e.data("filename")||"":e.data("filename",t),this.$filenameInput.prop("placeholder",t)}})},2211:function(){Craft.ElementFieldSettings=Garnish.Base.extend({allowMultipleSources:null,$maintainHierarchyField:null,$maintainHierarchyButton:null,$sourcesField:null,$sourceSelect:null,$branchLimitField:null,$maxRelationsField:null,$minRelationsField:null,$defaultPlacementField:null,$viewModeField:null,init:function(t,e,n,r,i,a,s,o){this.allowMultipleSources=t,this.$maintainHierarchyField=$("#".concat(e)),this.$maintainHierarchyButton=this.$maintainHierarchyField.find("button"),this.$sourcesField=$("#".concat(n)),this.allowMultipleSources||(this.$sourceSelect=this.$sourcesField.find("select")),this.$branchLimitField=$("#".concat(r)),this.$minRelationsField=$("#".concat(i)),this.$maxRelationsField=$("#".concat(a)),this.$defaultPlacementField=$("#".concat(s)),this.$viewModeField=$("#".concat(o)),this.updateLimitFields(),this.addListener(this.$maintainHierarchyButton,"change","updateLimitFields"),this.allowMultipleSources?this.$sourcesField.find("[type=checkbox]").each(function(t,e){this.addListener($(e),"change","updateMaintainHierarchyField")}.bind(this)):this.addListener(this.$sourceSelect,"change","updateMaintainHierarchyField"),this.updateMaintainHierarchyField()},updateLimitFields:function(){!this.$maintainHierarchyField.hasClass("hidden")&&this.$maintainHierarchyButton.hasClass("on")?(this.$minRelationsField.addClass("hidden"),this.$maxRelationsField.addClass("hidden"),this.$branchLimitField.removeClass("hidden"),this.$defaultPlacementField.addClass("hidden"),this.$viewModeField.find("select").val("list").trigger("change"),this.$viewModeField.addClass("hidden")):(this.$branchLimitField.addClass("hidden"),this.$minRelationsField.removeClass("hidden"),this.$maxRelationsField.removeClass("hidden"),this.$defaultPlacementField.removeClass("hidden"),this.$viewModeField.removeClass("hidden"))},updateMaintainHierarchyField:function(){var t;if(this.allowMultipleSources){var e=this.$sourcesField.find('[type="checkbox"]:checked');t=1===e.length&&e.data("structure-id")}else t=this.$sourceSelect.children("option:selected").data("structure-id");t?this.$maintainHierarchyField.removeClass("hidden"):this.$maintainHierarchyField.addClass("hidden"),this.updateLimitFields()}})},2290:function(){Craft.BaseInputGenerator=Garnish.Base.extend({$source:null,$target:null,$form:null,settings:null,listening:null,sourceVal:null,init:function(t,e,n){this.$source=$(t),this.$target=$(e),this.$form=this.$source.closest("form"),this.setSettings(n,Craft.BaseInputGenerator.defaults),this.setSettings(n),this.startListening()},setNewSource:function(t){var e=this.listening;this.stopListening(),this.$source=$(t),e&&this.startListening()},startListening:function(){this.listening||(this.listening=!0,this.sourceVal=this.$source.val(),this.addListener(this.$source,"input","onSourceTextChange"),this.addListener(this.$target,"input","onTargetTextChange"),this.addListener(this.$form,"submit","updateTarget"))},stopListening:function(){this.listening&&(this.listening=!1,this.removeAllListeners(this.$source),this.removeAllListeners(this.$target),this.removeAllListeners(this.$form))},onSourceTextChange:function(){var t=this.$source.val();this.sourceVal!==(this.sourceVal=t)&&this.updateTarget()},onTargetTextChange:function(){this.$target.get(0)===document.activeElement&&this.stopListening()},updateTarget:function(){if(this.$target.is(":visible")||0!=this.settings.updateWhenHidden){var t=this.$source.val();if(void 0!==t){var e=this.generateTargetValue(t);e&&(e="".concat(this.settings.prefix).concat(e).concat(this.settings.suffix)),this.$target.val(e);for(var n=0;n'+Craft.getCsrfInput()+' '+(Array.isArray(this.userId)?"":' ')+(e.redirect?' ':"")+"").appendTo(Garnish.$bod),a=$('").appendTo(i),s=$('
').appendTo(a),o=$(" ",{type:"button",class:"btn",text:Craft.t("app","Cancel")}).appendTo(s),l=a.find(".content-summary");if(e.contentSummary.length)for(var c=0;c ",{text:e.contentSummary[c]}));else l.find("ul").remove();if(this.$deleteActionRadios=a.find("input[type=radio]"),this.$deleteSubmitBtn=Craft.ui.createSubmitButton({class:"disabled",label:this._submitBtnLabel(!1),spinner:!0}).appendTo(s),Array.isArray(this.userId)){r=["and"];for(var u=0;u=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n ');var s="new-entry-menu-"+Craft.randomString(10),o=this.publishableSections.filter((function(t){return t.sites.includes(e.siteId)}));if(a){var l="index"===this.settings.context?Craft.uppercaseFirst(Craft.t("app","New {type}",{type:Craft.elementTypeNames["craft\\elements\\Entry"][2]})):Craft.t("app","New {section} entry",{section:a.name}),c="index"===this.settings.context?Craft.t("app","New entry in the {section} section",{section:a.name}):l,u="index"===this.settings.context?"link":null;this.$newEntryBtn=Craft.ui.createButton({label:l,ariaLabel:c,spinner:!0,role:u}).addClass("submit add icon").appendTo(this.$newEntryBtnGroup),this.addListener(this.$newEntryBtn,"click mousedown",(function(t){if("index"===e.settings.context&&("click"===t.type&&Garnish.isCtrlKeyPressed(t)||"mousedown"===t.type&&1===t.originalEvent.button)){var n={};r&&(n.type=r),window.open(Craft.getUrl("entries/".concat(a.handle,"/new"),n))}else"click"===t.type&&e._createEntry(a.id,r)})),o.length>1&&(i=$(" ",{type:"button",class:"btn submit menubtn btngroup-btn-last","aria-controls":s,"data-disclosure-trigger":"","aria-label":Craft.t("app","New entry, choose a section")}).appendTo(this.$newEntryBtnGroup))}else o.length>0&&(this.$newEntryBtn=i=Craft.ui.createButton({label:Craft.uppercaseFirst(Craft.t("app","New {type}",{type:Craft.elementTypeNames["craft\\elements\\Entry"][2]})),ariaLabel:Craft.t("app","New entry, choose a section"),spinner:!0}).addClass("submit add icon menubtn btngroup-btn-last").attr("aria-controls",s).attr("data-disclosure-trigger","").appendTo(this.$newEntryBtnGroup));if(this.addButton(this.$newEntryBtnGroup),i){var h,d=$("
",{id:s,class:"menu menu--disclosure"}).appendTo(this.$newEntryBtnGroup),f=$("").appendTo(d),p=t(this.publishableSections);try{var g=function(){var t=h.value,n="index"===e.settings.context?"link":"button";if("index"===e.settings.context&&t.sites.includes(e.siteId)||"index"!==e.settings.context&&t!==a&&t.sites.includes(e.siteId)){var r=$(" ").appendTo(f),s=$(" ",{role:"button"===n?"button":null,href:Craft.getUrl("entries/".concat(t.handle,"/new")),type:"button"===n?"button":null,text:Craft.t("app","New {section} entry",{section:t.name})}).appendTo(r);e.addListener(s,"activate",(function(n){n.originalEvent.preventDefault(),i.data("trigger").hide(),e._createEntry(t.id)})),"button"===n&&e.addListener(s,"keydown",(function(n){n.keyCode===Garnish.SPACE_KEY&&(n.preventDefault(),i.data("trigger").hide(),e._createEntry(t.id))}))}};for(p.s();!(h=p.n()).done;)g()}catch(t){p.e(t)}finally{p.f()}new Garnish.DisclosureMenu(i)}}if("index"===this.settings.context){var m="entries";n&&(m+="/"+n),Craft.setPath(m)}}else this.$newEntryBtnGroup&&this.$newEntryBtnGroup.remove()},_createEntry:function(t,e){var n=this;if(this.$newEntryBtn.hasClass("loading"))console.warn("New entry creation already in progress.");else{var r=this.publishableSections.find((function(e){return e.id===t}));if(!r)throw"Invalid section ID: ".concat(t);this.$newEntryBtn.addClass("loading"),Craft.sendActionRequest("POST","entries/create",{data:{siteId:this.siteId,section:r.handle,type:e}}).then((function(t){var e=t.data;"index"===n.settings.context?document.location.href=Craft.getUrl(e.cpEditUrl,{fresh:1}):Craft.createElementEditor(n.elementType,{siteId:n.siteId,elementId:e.entry.id,draftId:e.entry.draftId,params:{fresh:1}}).on("submit",(function(){n.clearSearch(),n.setSelectedSortAttribute("dateCreated","desc"),n.selectElementAfterUpdate(e.entry.id),n.updateElements()}))})).finally((function(){n.$newEntryBtn.removeClass("loading")}))}},canPaste:function(e){if(!this.$source.data("sectionId"))return!1;var n,r=this.$source.data("entryTypeIds")||[],i=t(e);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(!r.includes(a.data.entryTypeId))return!1}}catch(t){i.e(t)}finally{i.f()}return!0},pasteAttributes:function(){return{sectionId:this.$source.data("sectionId"),placeInStructure:!0}}}),Craft.registerElementIndexClass("craft\\elements\\Entry",Craft.EntryIndex)},2410:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:M(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),b}},n}function i(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}function a(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var s=t.apply(e,n);function o(t){i(s,r,a,o,l,"next",t)}function l(t){i(s,r,a,o,l,"throw",t)}o(void 0)}))}}Craft.CpScreenSlideout=Craft.Slideout.extend({action:null,namespace:null,showingLoadSpinner:!1,hasTabs:!1,hasCpLink:!1,hasSidebar:!1,$header:null,$toolbar:null,$tabContainer:null,$extraToolbarItems:null,$loadSpinner:null,$actionBtn:null,$editLink:null,$sidebarBtn:null,$body:null,$content:null,$sidebar:null,$footer:null,$noticeContainer:null,$cancelBtn:null,$saveBtn:null,tabManager:null,showingSidebar:!1,cancelToken:null,ignoreFailedRequest:!1,fieldsWithErrors:null,get showExpandedView(){return this.$container.width()>700},get sidebarIsOverlapping(){return this.showingSidebar&&"absolute"===this.$sidebar.css("position")},init:function(t,e){var n=this;this.action=t,this.setSettings(e,Craft.CpScreenSlideout.defaults),this.fieldsWithErrors=[],this.$header=$("",{class:"pane-header"}),this.$toolbar=$("
",{class:"so-toolbar"}).appendTo(this.$header),this.$tabContainer=$("
",{class:"pane-tabs"}).appendTo(this.$toolbar),this.$loadSpinner=$("
",{class:"spinner",title:Craft.t("app","Loading"),"aria-label":Craft.t("app","Loading")}).appendTo(this.$toolbar),this.$editLink=$(" ",{target:"_blank",class:"btn header-btn hidden",title:Craft.t("app","Open in a new tab"),"aria-label":Craft.t("app","Open in a new tab"),"data-icon":"external"}).appendTo(this.$toolbar),this.$sidebarBtn=$(" ",{type:"button",class:"btn header-btn hidden sidebar-btn",title:Craft.t("app","Show sidebar"),"aria-label":Craft.t("app","Show sidebar"),"data-icon":"sidebar-".concat(Garnish.ltr?"right":"left"),"aria-expanded":"false"}).appendTo(this.$toolbar),this.addListener(this.$sidebarBtn,"click",(function(t){t.preventDefault(),n.showingSidebar?(n.hideSidebar(),n.showExpandedView&&Craft.setCookie("sidebar-slideout","collapsed")):(n.showSidebar(),n.showExpandedView&&Craft.setCookie("sidebar-slideout","expanded"))})),this.$body=$("
",{class:"so-body"}),this.$content=$("
",{class:"so-content"}).appendTo(this.$body),this.$sidebar=$("
",{class:"so-sidebar details hidden"}).appendTo(this.$body),this.$footer=$("
",{class:"so-footer hidden"}),this.$noticeContainer=$("
",{class:"so-notice"}).appendTo(this.$footer),$("
",{class:"flex-grow"}).appendTo(this.$footer);var r=$("
",{class:"flex flex-nowrap"}).appendTo(this.$footer);this.$cancelBtn=$(" ",{type:"button",class:"btn",text:Craft.t("app","Cancel")}).appendTo(r),this.$saveBtn=Craft.ui.createSubmitButton({label:Craft.t("app","Save"),spinner:!0}).appendTo(r);var i=this.$header.add(this.$body).add(this.$footer);this.base(i,{containerElement:"form",containerAttributes:{id:"cp-screen-".concat(Math.floor(1e8*Math.random())),action:"",method:"post",novalidate:"",class:"cp-screen"},closeOnEsc:!1,closeOnShadeClick:!1}),this.$container.data("cpScreen",this),this.on("beforeClose",(function(){n.hideSidebarIfOverlapping()})),Garnish.uiLayerManager.registerShortcut({keyCode:Garnish.S_KEY,ctrl:!0},(function(t){n.handleSubmit(t)})),Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY,(function(){n.closeMeMaybe()})),this.addListener(this.$cancelBtn,"click",(function(){n.closeMeMaybe()})),this.addListener(this.$shade,"click",(function(){n.closeMeMaybe()})),this.addListener(this.$container,"click",(function(t){var e=$(event.target);!n.showingSidebar||e.closest(n.$sidebarBtn).length||e.closest(n.$sidebar).length||n.hideSidebarIfOverlapping()})),this.addListener(this.$container,"submit","handleSubmit"),this.load()},load:function(t,e){var n=this;return new Promise((function(t,r){n.trigger("beforeLoad"),n.showLoadSpinner(),n.cancelToken&&(n.ignoreFailedRequest=!0,n.cancelToken.cancel()),n.cancelToken=axios.CancelToken.source(),Craft.sendActionRequest("GET",n.action,$.extend({params:Object.assign({},n.getParams(),n.settings.params),cancelToken:n.cancelToken.token,headers:{"X-Craft-Container-Id":n.$container.attr("id")}},n.settings.requestOptions)).then((function(i){n.update(i.data).then((function(){!1!==e&&(n.$container.data("delta-names",i.data.deltaNames),n.$container.data("initial-delta-values",i.data.initialDeltaValues),n.$container.data("initialSerializedValue",n.$container.serialize())),t()})).catch((function(t){r(t)}))})).catch((function(t){n.ignoreFailedRequest||(Craft.cp.displayError(),r(t)),n.ignoreFailedRequest=!1})).finally((function(){n.hideLoadSpinner(),n.cancelToken=null}))}))},getParams:function(){return{}},updateHeaderVisibility:function(){var t=this.settings.showHeader||this.hasTabs||this.hasCpLink||this.showingLoadSpinner;t||this.hasSidebar?this.$header.removeClass("hidden"):this.$header.addClass("hidden"),t?this.$header.addClass("so-visible"):this.$header.removeClass("so-visible")},showLoadSpinner:function(){this.$loadSpinner.removeClass("hidden"),this.showingLoadSpinner=!0,this.updateHeaderVisibility()},hideLoadSpinner:function(){this.$loadSpinner.addClass("hidden"),this.showingLoadSpinner=!1,this.updateHeaderVisibility()},update:function(t){var e=this;return new Promise((function(n){if(e.namespace=t.namespace,t.bodyClass&&e.$body.addClass(t.bodyClass),e.$content.html(t.content),t.submitButtonLabel&&e.$saveBtn.text(t.submitButtonLabel),e.updateTabs(t.tabs),e.updateExtraToolbarItems(t.extraToolbarItems),t.formAttributes&&Craft.setElementAttributes(e.$container,t.formAttributes),t.editUrl?(e.$editLink.removeClass("hidden").attr("href",t.editUrl),e.hasCpLink=!0):(e.$editLink.addClass("hidden"),e.hasCpLink=!1),t.actionMenu){var i=Craft.namespaceId("action-menu-label",e.namespace),s=Craft.namespaceId("action-menu",e.namespace);$(" ",{id:i,class:"visually-hidden",text:Craft.t("app","Actions")}).insertBefore(e.$editLink),e.$actionBtn=$(" ",{class:"btn action-btn header-btn",type:"button",title:Craft.t("app","Actions"),"aria-controls":s,"aria-describedby":i,"data-disclosure-trigger":"true"}).insertBefore(e.$editLink),$(t.actionMenu).insertBefore(e.$editLink),e.$actionBtn.disclosureMenu()}else e.$actionBtn=null;t.sidebar?(e.$sidebarBtn.removeClass("hidden"),e.$sidebar.html(t.sidebar),e.$sidebar.find("a").each((function(){this.hostname.length&&void 0===$(this).attr("target")&&$(this).attr("target","_blank")})),e.hasSidebar=!0,e.showExpandedView&&"expanded"===(Craft.getCookie("sidebar-slideout")||"expanded")?e.showSidebar(!1):e.hideSidebar()):(e.hideSidebar(),e.$sidebarBtn.addClass("hidden"),e.$sidebar.addClass("hidden").html(""),e.hasSidebar=!1),t.notice?e.$noticeContainer.html(t.notice):e.$noticeContainer.empty(),e.updateHeaderVisibility(),e.$footer.removeClass("hidden"),Garnish.requestAnimationFrame(a(r().mark((function i(){return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Craft.appendHeadHtml(t.headHtml);case 2:return r.next=4,Craft.appendBodyHtml(t.bodyHtml);case 4:Craft.initUiElements(e.$content),Craft.cp.elementThumbLoader.load($(e.$content)),t.sidebar&&(Craft.initUiElements(e.$sidebar),Craft.cp.elementThumbLoader.load(e.$sidebar)),Garnish.isMobileBrowser()||Craft.setFocusWithin(e.$content),n(),e.trigger("load"),e.settings.onLoad();case 11:case"end":return r.stop()}}),i)}))))}))},updateTabs:function(t){var e=this;if(this.tabManager&&(this.tabManager.destroy(),this.tabManager=null,this.$tabContainer.html("")),this.hasTabs=!!t,this.hasTabs){var n=$(t);this.$tabContainer.replaceWith(n),this.$tabContainer=n,this.tabManager=new Craft.Tabs(this.$tabContainer),this.tabManager.on("deselectTab",(function(t){$(t.$tab.attr("href")).addClass("hidden")})),this.tabManager.on("selectTab",(function(t){$(t.$tab.attr("href")).removeClass("hidden"),Garnish.$win.trigger("resize"),e.$body.trigger("scroll")}))}},updateExtraToolbarItems:function(t){this.$extraToolbarItems&&(this.$extraToolbarItems.remove(),this.$extraToolbarItems=null),t&&(this.$extraToolbarItems=$(t).insertAfter(this.$tabContainer))},showSidebar:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.showingSidebar||(this.$container.addClass("showing-sidebar"),this.$body.scrollTop(0).addClass("no-scroll"),this.$sidebar.off("transitionend.so").css(this._closedSidebarStyles()).removeClass("hidden"),this.$sidebar[0].offsetWidth,this.$sidebar.css(this._openedSidebarStyles()),e&&!Garnish.isMobileBrowser()&&this.$sidebar.one("transitionend.so",(function(){Craft.setFocusWithin(t.$sidebar)})),this.showExpandedView||Craft.trapFocusWithin(this.$sidebar),this.$sidebarBtn.addClass("active").attr({"aria-expanded":"true"}),Garnish.$win.trigger("resize"),this.$sidebar.trigger("scroll"),Garnish.uiLayerManager.addLayer({bubble:!0}),Garnish.uiLayerManager.registerShortcut(Garnish.ESC_KEY,(function(e){t.hideSidebarIfOverlapping()||e.bubbleShortcut()})),this.showingSidebar=!0)},hideSidebar:function(){var t=this;this.showingSidebar&&(this.$container.removeClass("showing-sidebar"),this.$body.removeClass("no-scroll"),this.sidebarIsOverlapping||(this.$sidebar.addClass("hidden"),this.$sidebarBtn.focus()),this.$sidebar.off("transitionend.so").css(this._closedSidebarStyles()).one("transitionend.so",(function(){t.$sidebar.addClass("hidden"),t.$sidebarBtn.focus()})),Craft.releaseFocusWithin(this.$sidebar),this.$sidebarBtn.removeClass("active").attr({"aria-expanded":"false"}),Garnish.uiLayerManager.removeLayer(),this.showingSidebar=!1)},hideSidebarIfOverlapping:function(){return!!this.sidebarIsOverlapping&&(this.hideSidebar(),!0)},_openedSidebarStyles:function(){return n({},Garnish.ltr?"right":"left","0")},_closedSidebarStyles:function(){return n({},Garnish.ltr?"right":"left","-350px")},showSubmitSpinner:function(){this.$saveBtn.addClass("loading")},hideSubmitSpinner:function(){this.$saveBtn.removeClass("loading")},handleSubmit:function(t){var e=this;t.preventDefault(),setTimeout((function(){e.submit()}),1)},submit:function(){var t=this;this.showSubmitSpinner();var e=Craft.findDeltaData(this.$container.data("initialSerializedValue"),this.$container.serialize(),this.$container.data("delta-names"),null,this.$container.data("initial-delta-values"));Craft.sendActionRequest("POST",null,{data:e,headers:{"X-Craft-Namespace":this.namespace}}).then((function(e){t.handleSubmitResponse(e)})).catch((function(e){t.handleSubmitError(e)})).finally((function(){t.hideSubmitSpinner()}))},handleSubmitResponse:function(t){this.clearErrors();var e=t.data||{};e.message&&Craft.cp.displaySuccess(e.message,e.notificationSettings),e.modelClass&&e.modelId&&Craft.refreshComponentInstances(e.modelClass,e.modelId);var n={response:t,data:e.modelName&&e[e.modelName]||{}};this.trigger("submit",n),this.settings.onSubmit(n),this.settings.closeOnSubmit&&this.close()},handleSubmitError:function(t){if(!t.isAxiosError||!t.response||400===!t.response.status)throw Craft.cp.displayError(),t;var e=t.response.data||{};Craft.cp.displayError(e.message),e.errors&&this.showErrors(e.errors),e.errorSummary&&this.showErrorSummary(e.errorSummary,Object.keys(e.errors||{}).length)},showErrorSummary:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(Craft.ui.clearErrorSummary(this.$body),null!==this.tabManager){var n=this.tabManager.$tabs,r=n.filter(".error"),i=this.$content;n.each((function(n,a){var s=$(a).data("id"),o=i.find("#"+s);if(o.length>0){var l=o.data("layout-tab"),c=$(t),u=c.find("ul.errors li").length,h="";c.find("ul.errors li").each((function(t,e){var n=$(e).find("a").data("layout-tab");void 0!==n&&n!==l&&($(e).remove(),u--)})),u>0?(h=Craft.t("app","Found {num, number} {num, plural, =1{error} other{errors}} in this tab.",{num:u}),r.length-1>0&&(h+=''+Craft.t("app","{total, number} {total, plural, =1{error} other{errors}} found in {num, number} {num, plural, =1{tab} other{tabs}}.",{total:e,num:r.length})+" ")):h=Craft.t("app","Found errors in other tabs."),c.find("h2").html(h),c.prependTo(o),Craft.ui.setFocusOnErrorSummary(o)}}))}else $(t).prependTo(this.$content),Craft.ui.setFocusOnErrorSummary(this.$content)},showErrors:function(t){var n,r=this;this.clearErrors();var i=(null===(n=this.tabManager)||void 0===n?void 0:n.menu)||[],a=''+Craft.t("app","This tab contains errors")+" \n ";Object.entries(t).forEach((function(t){var n=function(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(t){c=!0,i=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),s=n[0],o=n[1],l=r.$container.find('[data-error-key="'.concat(s,'"]'));if(l){Craft.ui.addErrorsToField(l,o),r.fieldsWithErrors.push(l);var c=Craft.ui.findTabAnchorForField(l,r.$container);if(c.length>0){0==r.tabManager.$menuBtn.hasClass("error")&&(r.tabManager.$menuBtn.addClass("error"),r.tabManager.$menuBtn.append(' '));for(var u=0;u0&&0==d.hasClass("error")&&(d.addClass("error"),d.append(a))}}}}}))},clearErrors:function(){this.fieldsWithErrors.forEach((function(t){Craft.ui.clearErrorsFromField(t)}))},isDirty:function(){var t=this,e=this.$container.data("initialSerializedValue");return void 0!==e&&e!==(this.$container.data("serializer")||function(){return t.$container.serialize()})()},closeMeMaybe:function(){this.isOpen&&(this.isDirty()&&!confirm(Craft.t("app","Are you sure you want to close this screen? Any changes will be lost."))||this.close())},close:function(){this.showingSidebar&&this.hideSidebar(),this.base(),this.cancelToken&&(this.ignoreFailedRequest=!0,this.cancelToken.cancel())}},{defaults:{params:{},requestOptions:{},showHeader:null,closeOnSubmit:!0,onLoad:function(){},onSubmit:function(){}}})},2756:function(){Craft.ImageUpload=Garnish.Base.extend({$container:null,progressBar:null,uploader:null,init:function(t){this.setSettings(t,Craft.ImageUpload.defaults),this.$container=$(this.settings.containerSelector),this.initImageUpload()},initImageUpload:function(){this.progressBar=new Craft.ProgressBar($('
').appendTo(this.$container));var t={url:Craft.getActionUrl(this.settings.uploadAction),formData:this.settings.postParameters,fileInput:this.$container.find(this.settings.fileInputSelector),paramName:this.settings.uploadParamName};void 0!==Craft.csrfTokenName&&void 0!==Craft.csrfTokenValue&&(t.formData[Craft.csrfTokenName]=Craft.csrfTokenValue),t.events={},t.events.fileuploadstart=this._onUploadStart.bind(this),t.events.fileuploadprogressall=this._onUploadProgress.bind(this),t.events.fileuploaddone=this._onUploadComplete.bind(this),t.events.fileuploadfail=this._onUploadFailure.bind(this),this.uploader=Craft.createUploader(null,this.$container,t),this.initButtons()},initButtons:function(){var t=this;this.$container.find(this.settings.uploadButtonSelector).on("click",(function(e){t.$container.find(t.settings.fileInputSelector).trigger("click")})),this.$container.find(this.settings.deleteButtonSelector).on("click",(function(e){confirm(Craft.t("app","Are you sure you want to delete this image?"))&&($(e.currentTarget).parent().append('
'),Craft.sendActionRequest("POST",t.settings.deleteAction,{data:t.settings.postParameters}).then((function(e){var n=e.data;t.refreshImage(n)})))}))},refreshImage:function(t){this.$container.replaceWith(this.$container=$(t.html)),this.settings.onAfterRefreshImage(t),Craft.cp.elementThumbLoader.load(this.$container),this.initImageUpload()},_onUploadStart:function(t){this.progressBar.$progressBar.css({top:Math.round(this.$container.outerHeight()/2)-6}),this.$container.addClass("uploading"),this.progressBar.resetProgressBar(),this.progressBar.showProgressBar()},_onUploadProgress:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=parseInt(e.loaded/e.total*100,10);this.progressBar.setProgressPercentage(n)},_onUploadComplete:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.refreshImage(e.result),this.uploader.isLastUpload()&&(this.progressBar.hideProgressBar(),this.$container.removeClass("uploading"))},_onUploadFailure:function(t){var e,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=r.response(),a=(null==i||null===(e=i.jqXHR)||void 0===e?void 0:e.responseJSON)||{},s=a.message,o=a.filename,l=a.errors,c=void 0===l?{}:l;o=o||(null==r||null===(n=r.files)||void 0===n?void 0:n[0].name);var u=c?Object.values(c).flat():[];s||(s=u.length?u.join("\n"):o?Craft.t("app","Upload failed for “{filename}”.",{filename:o}):Craft.t("app","Upload failed.")),Craft.cp.displayError(s),this.progressBar.hideProgressBar(),this.$container.removeClass("uploading")}},{defaults:{postParameters:{},uploadAction:"",deleteAction:"",fileInputSelector:"",onAfterRefreshImage:$.noop,containerSelector:null,uploadButtonSelector:null,deleteButtonSelector:null,uploadParamName:"files"}})},2760:function(){Craft.VolumeFolderSelectorModal=Craft.BaseElementSelectorModal.extend({init:function(t){(t=Object.assign({},Craft.VolumeFolderSelectorModal.defaults,t,{showSiteMenu:!1})).indexSettings.disabledFolderIds=t.disabledFolderIds,this.base("craft\\elements\\Asset",t)},getElementIndexParams:function(){return Object.assign({},this.base(),{foldersOnly:!0})},shouldEnableSelectBtn:function(){var t;return!!this.base()||(null===(t=this.elementIndex)||void 0===t?void 0:t.sourcePath.length)&&void 0!==this.elementIndex.sourcePath[this.elementIndex.sourcePath.length-1].folderId&&!this.settings.disabledFolderIds.includes(this.elementIndex.sourcePath[this.elementIndex.sourcePath.length-1].folderId)},selectElements:function(t){if(this.hasSelection())this.base();else if(this.$selectBtn&&(null==t?void 0:t.currentTarget)===this.$selectBtn[0]&&this.shouldEnableSelectBtn()){var e=this.elementIndex.sourcePath[this.elementIndex.sourcePath.length-1].folderId;this.onSelect([{folderId:e}]),this.settings.hideOnSelect&&this.hide()}},getElementInfo:function(t){for(var e=[],n=0;n ').appendTo(this.$container),this.$cursor=$('
').appendTo(this.$container),this.$graduations=$('
').appendTo(this.$container),this.$graduationsUl=$("
").attr({"aria-hidden":"true"}).appendTo(this.$graduations),this.$container.attr({role:"slider",tabindex:"0","aria-valuemin":this.slideMin,"aria-valuemax":this.slideMax,"aria-valuenow":"0","aria-valuetext":Craft.t("app","{num, number} {num, plural, =1{degree} other{degrees}}",{num:0})});for(var r=this.graduationsMin;r<=this.graduationsMax;r++){var i=$('
'+r+"
").appendTo(this.$graduationsUl);r%5==0&&i.addClass("main-graduation"),0===r&&i.addClass("selected")}this.$options=this.$container.find(".graduation"),this.addListener(this.$container,"resize",this._handleResize.bind(this)),this.addListener(this.$container,"tapstart",this._handleTapStart.bind(this)),this.addListener(Garnish.$bod,"tapmove",this._handleTapMove.bind(this)),this.addListener(Garnish.$bod,"tapend",this._handleTapEnd.bind(this)),this.addListener(this.$container,"keydown",this._handleKeypress.bind(this)),setTimeout((function(){n.graduationsCalculatedWidth=10*(n.$options.length-1),n.$graduationsUl.css("left",-n.graduationsCalculatedWidth/2+n.$container.width()/2)}),50)},_handleResize:function(){var t=this.valueToPosition(this.value);this.$graduationsUl.css("left",t)},_handleKeypress:function(t){var e=parseInt(this.$container.attr("aria-valuenow"),10);switch(t.keyCode){case Garnish.UP_KEY:case Garnish.RIGHT_KEY:this.setValue(e+1);break;case Garnish.DOWN_KEY:case Garnish.LEFT_KEY:this.setValue(e-1);break;case Garnish.PAGE_UP_KEY:this.setValue(e+10);break;case Garnish.PAGE_DOWN_KEY:this.setValue(e-10);break;case Garnish.HOME_KEY:this.setValue(this.slideMin);break;case Garnish.END_KEY:this.setValue(this.slideMax)}this.onChange()},_handleTapStart:function(t,e){t.preventDefault(),this.rotateIntent=$(t.target).is(".graduations *"),this.rotateIntent&&(this.startPositionX=e.position.x,this.startLeft=this.$graduationsUl.position().left,this.onStart())},_handleTapMove:function(t,e){this.rotateIntent&&Math.abs(e.position.x-this.startPositionX)>this.sensitivity&&(this.dragging=!0,this.$container.addClass("dragging"),t.preventDefault(),this._setValueFromTouch(e),this.onChange())},_setValueFromTouch:function(t){var e,n=this.dragging?this.startPositionX:this.$cursor.offset().left+this.$cursor.outerWidth()/2;e=this.dragging?n-t.position.x:t.position.x-n;var r=this.startLeft-e,i=this.positionToValue(r);this.setValue(i)},setValue:function(t){var e=this.valueToPosition(t);t
this.slideMax&&(t=this.slideMax,e=this.valueToPosition(t)),this.$graduationsUl.css("left",e),t>=this.slideMin&&t<=this.slideMax&&(this.$options.removeClass("selected"),$.each(this.$options,(function(e,n){$(n).data("graduation")>0&&$(n).data("graduation")<=t&&$(n).addClass("selected"),$(n).data("graduation")<0&&$(n).data("graduation")>=t&&$(n).addClass("selected"),0==$(n).data("graduation")&&$(n).addClass("selected")}))),this.$container.attr({"aria-valuenow":t,"aria-valuetext":Craft.t("app","{num, number} {num, plural, =1{degree} other{degrees}}",{num:parseInt(t,10)})}),this.value=t},_handleTapEnd:function(t,e){this.rotateIntent&&(this.dragging?(t.preventDefault(),this.dragging=!1,this.$container.removeClass("dragging")):(this._setValueFromTouch(e),this.onChange()),this.onEnd(),this.startPositionX=null,this.rotateIntent=!1)},positionToValue:function(t){var e=-1*this.graduationsMin,n=-1*(this.graduationsMin-this.graduationsMax);return(this.$graduations.width()/2+-1*t)/this.graduationsCalculatedWidth*n-e},valueToPosition:function(t){var e=-1*this.graduationsMin,n=-1*(this.graduationsMin-this.graduationsMax);return-((t+e)*this.graduationsCalculatedWidth/n-this.$graduations.width()/2)},onStart:function(){"function"==typeof this.settings.onChange&&this.settings.onStart(this)},onChange:function(){"function"==typeof this.settings.onChange&&this.settings.onChange(this)},onEnd:function(){"function"==typeof this.settings.onChange&&this.settings.onEnd(this)},defaultSettings:{onStart:$.noop,onChange:$.noop,onEnd:$.noop}})},3254:function(){},3517:function(){Craft.BaseUploader=Garnish.Base.extend({allowedKinds:null,$element:null,$fileInput:null,settings:null,fsType:null,formData:{},events:{},_rejectedFiles:{},_extensionList:null,_inProgressCounter:0,init:function(t,e){this._rejectedFiles={size:[],type:[],limit:[]},this.$element=t,this.settings=$.extend({},Craft.BaseUploader.defaults,e),this.formData=this.settings.formData,this.$fileInput=this.settings.fileInput||t,this.events=this.settings.events,this.settings.url||(this.settings.url=this.settings.replace?Craft.getActionUrl(this.settings.replaceAction):Craft.getActionUrl(this.settings.createAction)),this.settings.allowedKinds&&this.settings.allowedKinds.length&&("string"==typeof this.settings.allowedKinds&&(this.settings.allowedKinds=[this.settings.allowedKinds]),this.allowedKinds=this.settings.allowedKinds,delete this.settings.allowedKinds)},setParams:function(t){void 0!==Craft.csrfTokenName&&void 0!==Craft.csrfTokenValue&&(t[Craft.csrfTokenName]=Craft.csrfTokenValue),this.formData=t},getInProgress:function(){return this._inProgressCounter},isLastUpload:function(){return this.getInProgress()<2},processErrorMessages:function(){var t;this._rejectedFiles.type.length&&(t=1===this._rejectedFiles.type.length?"The file {files} could not be uploaded. The allowed file kinds are: {kinds}.":"The files {files} could not be uploaded. The allowed file kinds are: {kinds}.",t=Craft.t("app",t,{files:this._rejectedFiles.type.join(", "),kinds:this.allowedKinds.join(", ")}),this._rejectedFiles.type=[],Craft.cp.displayError(t)),this._rejectedFiles.size.length&&(t=1===this._rejectedFiles.size.length?"The file {files} could not be uploaded, because it exceeds the maximum upload size of {size}.":"The files {files} could not be uploaded, because they exceeded the maximum upload size of {size}.",t=Craft.t("app",t,{files:this._rejectedFiles.size.join(", "),size:this.humanFileSize(this.settings.maxFileSize)}),this._rejectedFiles.size=[],Craft.cp.displayError(t)),this._rejectedFiles.limit.length&&(t=1===this._rejectedFiles.limit.length?"The file {files} could not be uploaded, because the field limit has been reached.":"The files {files} could not be uploaded, because the field limit has been reached.",t=Craft.t("app",t,{files:this._rejectedFiles.limit.join(", ")}),this._rejectedFiles.limit=[],Craft.cp.displayError(t))},humanFileSize:function(t){var e=1024;if(t=e);return t.toFixed(1)+" "+["kB","MB","GB","TB","PB","EB","ZB","YB"][n]},_createExtensionList:function(){this._extensionList=[];for(var t=0;t=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&a.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:M(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},r}function n(t,e,n,r,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(r,i)}Craft.AssetSelectInput=Craft.BaseElementSelectInput.extend({$uploadBtn:null,uploader:null,progressBar:null,openPreviewTimeout:null,init:function(){this.base.apply(this,arguments),this.settings.canUpload&&this._attachUploader(),this.updateAddElementsBtn(),this.addListener(this.$elementsContainer,"keydown",this._onKeyDown.bind(this))},elementSelectSettings:function(){return Object.assign(this.base(),{makeFocusable:!0})},_onKeyDown:function(t){if(t.keyCode===Garnish.SPACE_KEY&&t.shiftKey)return this.openPreview(),t.stopPropagation(),!1},clearOpenPreviewTimeout:function(){this.openPreviewTimeout&&(clearTimeout(this.openPreviewTimeout),this.openPreviewTimeout=null)},openPreview:function(t){Craft.PreviewFileModal.openInstance?Craft.PreviewFileModal.openInstance.hide():(t||(t=this.$elements.filter(":focus").add(this.$elements.has(":focus"))),t.length&&Craft.PreviewFileModal.showForAsset(t,this.elementSelect))},_attachUploader:function(){var t=this;this.progressBar=new Craft.ProgressBar($('
').appendTo(this.$container)),this.$addElementBtn&&(this.$uploadBtn=$(" ",{type:"button",class:"btn dashed","data-icon":"upload","aria-label":1==this.settings.limit?Craft.t("app","Upload a file"):Craft.t("app","Upload files"),"aria-describedby":this.settings.describedBy,text:1==this.settings.limit?Craft.t("app","Upload a file"):Craft.t("app","Upload files")}).insertAfter(this.$addElementBtn),this.$fileInput=$(" ",{type:"file",class:"hidden",multiple:1!=this.settings.limit}).insertAfter(this.$uploadBtn),Garnish.$win.trigger("resize"));var e={dropZone:this.$container,fileInput:this.$fileInput};void 0!==this.settings.criteria.kind&&(e.allowedKinds=this.settings.criteria.kind),e.canAddMoreFiles=this.canAddMoreFiles.bind(this),e.events={},e.events.fileuploadstart=this._onUploadStart.bind(this),e.events.fileuploadprogressall=this._onUploadProgress.bind(this),e.events.fileuploaddone=this._onUploadComplete.bind(this),e.events.fileuploadfail=this._onUploadFailure.bind(this),this.uploader=Craft.createUploader(this.settings.fsType,this.$container,e);var n={fieldId:this.settings.fieldId};this.settings.sourceElementId&&(n.elementId=this.settings.sourceElementId),this.settings.criteria.siteId&&(n.siteId=this.settings.criteria.siteId),this.uploader.setParams(n),this.$uploadBtn&&this.$uploadBtn.on("click",(function(e){t.$uploadBtn.next("input[type=file]").trigger("click")}))},enableAddElementsBtn:function(){this.$uploadBtn&&this.$uploadBtn.removeClass("hidden"),this.base()},disableAddElementsBtn:function(){this.$uploadBtn&&this.$uploadBtn.addClass("hidden"),this.base()},selectUploadedFile:function(t){if(this.canAddMoreElements()){var e=t.$element;e.appendTo(this.$elementsContainer);var n=-(e.outerWidth()+10);this.$addElementBtn.css("margin-"+Craft.left,n+"px");var r={};r["margin-"+Craft.left]=0,this.$addElementBtn.velocity(r,"fast"),this.addElements(e),delete this.modal}},_onUploadStart:function(){this.progressBar.$progressBar.css({top:Math.round(this.$container.outerHeight()/2)-6}),this.$container.addClass("uploading"),this.progressBar.resetProgressBar(),this.progressBar.showProgressBar()},_onUploadProgress:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=t instanceof CustomEvent?t.detail:e;var n=parseInt(100*Math.min(e.loaded/e.total,1),10);this.progressBar.setProgressPercentage(n)},_onUploadComplete:function(t){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=t instanceof CustomEvent?t.detail:i.result;Craft.sendActionRequest("POST","app/render-elements",{data:{elements:[{type:"craft\\elements\\Asset",id:a.assetId,siteId:this.settings.criteria.siteId,instances:[{context:"field",ui:["list","large"].includes(this.settings.viewMode)?"chip":"card",size:"large"===this.settings.viewMode?"large":"small"}]}]}}).then(function(){var t,i=(t=e().mark((function t(n){var i,s;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=n.data,s=Craft.getElementInfo(i.elements[a.assetId][0]),r.selectElements([s]),t.next=5,Craft.appendHeadHtml(i.headHtml);case 5:return t.next=7,Craft.appendBodyHtml(i.bodyHtml);case 7:r.uploader.isLastUpload()&&(r.progressBar.hideProgressBar(),r.$container.removeClass("uploading"),r.$container.trigger("change"));case 8:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(i,a){var s=t.apply(e,r);function o(t){n(s,i,a,o,l,"next",t)}function l(t){n(s,i,a,o,l,"throw",t)}o(void 0)}))});return function(t){return i.apply(this,arguments)}}()).catch((function(t){if(!t||!t.response)throw Craft.cp.displayError(),t;Craft.cp.displayError(response.data.message)})),Craft.cp.runQueue()},_onUploadFailure:function(t){var e,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=(t instanceof CustomEvent?t.detail:null==r||null===(e=r.jqXHR)||void 0===e?void 0:e.responseJSON)||{},a=i.message,s=i.filename,o=i.errors;s=s||(null==r||null===(n=r.files)||void 0===n?void 0:n[0].name);var l=o?Object.values(o).flat():[];a||(a=l.length?l.join("\n"):s?Craft.t("app","Upload failed for “{filename}”.",{filename:s}):Craft.t("app","Upload failed.")),Craft.cp.displayError(a),this.progressBar.hideProgressBar(),this.$container.removeClass("uploading")},canAddMoreFiles:function(t){return!this.settings.limit||this.$elements.length+t ').addClass().appendTo(Garnish.$bod)),this.$prompt=$('
').appendTo(this.$modalContainerDiv.empty()),this.$promptMessage=$('
').appendTo(this.$prompt),this.$promptChoices=$('
').appendTo(this.$prompt),this.$promptApplyToRemainingContainer=$(' ').appendTo(this.$prompt).hide(),this.$promptApplyToRemainingCheckbox=$(' ').appendTo(this.$promptApplyToRemainingContainer),this.$promptApplyToRemainingLabel=$(" ").appendTo(this.$promptApplyToRemainingContainer),this.$promptButtons=$('
').appendTo(this.$prompt),this.modal.setContainer(this.$modalContainerDiv),this.$promptMessage.html(t);for(var a=$(" ",{type:"button",class:"btn",text:Craft.t("app","Cancel")}).appendTo(this.$promptButtons),s=$(" ",{type:"submit",class:"btn submit disabled",text:Craft.t("app","OK")}).appendTo(this.$promptButtons),o=0;o '+e[o].title+" ").appendTo(this.$promptChoices).find("input");this.addListener(l,"click",(function(){s.removeClass("disabled")}))}this.addListener(s,"activate",(function(t){var e=$(t.currentTarget).parents(".modal").find("input[name=promptAction]:checked").val(),n=this.$promptApplyToRemainingCheckbox.prop("checked");this._selectPromptChoice(e,n)})),this.addListener(a,"activate",(function(){var t=this.$promptApplyToRemainingCheckbox.prop("checked");this._selectPromptChoice("cancel",t)})),r&&(this.$promptApplyToRemainingContainer.show(),this.$promptApplyToRemainingLabel.html(" "+Craft.t("app","Apply this to the {number} remaining conflicts?",{number:r}))),this.modal.show(),this.modal.removeListener(Garnish.Modal.$shade,"click"),this.addListener(Garnish.Modal.$shade,"click","_cancelPrompt")},_selectPromptChoice:function(t,e){var n=this;this.$prompt.fadeOut("fast",(function(){n.modal.hide(),n._promptCallback(t,e)}))},_cancelPrompt:function(){this._selectPromptChoice("cancel",!0)}})},3914:function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,a,s,o=[],l=!0,c=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=a.call(n)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(t){c=!0,i=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(t,e)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n