diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md
index 15f787288b9..60cdee39031 100644
--- a/CHANGELOG-WIP.md
+++ b/CHANGELOG-WIP.md
@@ -12,6 +12,7 @@
- Improved the accessibility of control panel icons. ([#16128](https://github.com/craftcms/cms/pull/16128))
- Improved the accessibility of Selectize inputs. ([#16110](https://github.com/craftcms/cms/pull/16110))
- Improved the accessibility of the image rotation control within the Image Editor. ([#16218](https://github.com/craftcms/cms/pull/16218))
+- Improved the accessibility of action menus on the Plugins index page.
### Administration
- Added the “Show the ‘URL Suffix’ field” setting to Link fields. ([#15813](https://github.com/craftcms/cms/discussions/15813))
@@ -21,6 +22,8 @@
- Added the “GraphQL Mode” Link field setting. ([#16237](https://github.com/craftcms/cms/pull/16237))
- Added the “Field” entry condition rule, which replaces “Matrix field”, includes a “has a value” operator. ([#16270](https://github.com/craftcms/cms/discussions/16270))
- Section condition rules now have a “has a value” operator. ([#16270](https://github.com/craftcms/cms/discussions/16270))
+- Added “Copy plugin handle” and “Copy package name” options to plugins’ action menus on the Plugins index page. ([#16281](https://github.com/craftcms/cms/discussions/16281))
+- The Updates utility now shows an action menu for each plugin, with “Copy plugin handle” and “Copy package name” options. ([#16281](https://github.com/craftcms/cms/discussions/16281))
- The Queue Manager utility now shows jobs’ class names. ([#16228](https://github.com/craftcms/cms/pull/16228))
- Improved the wording of field instance action labels. ([#16261](https://github.com/craftcms/cms/discussions/16261))
- Improved the error output for nested elements when they can’t be resaved via `resave` commands.
diff --git a/src/templates/_includes/disclosuremenu.twig b/src/templates/_includes/disclosuremenu.twig
index 3d436fa1ad6..2ba8d4e851c 100644
--- a/src/templates/_includes/disclosuremenu.twig
+++ b/src/templates/_includes/disclosuremenu.twig
@@ -38,6 +38,7 @@
sel: selected,
error: item.destructive ?? false,
formsubmit: item.action ?? false,
+ disabled: item.disabled ?? false,
}|filter|keys,
href: type == 'button' ? null : url(item.url),
data: {
diff --git a/src/templates/settings/plugins/index.twig b/src/templates/settings/plugins/index.twig
index 6e52ebd1501..f1cc1219e4c 100644
--- a/src/templates/settings/plugins/index.twig
+++ b/src/templates/settings/plugins/index.twig
@@ -26,7 +26,84 @@
{% for handle, config in info %}
{% set pluginStoreUrl = url('plugin-store/' ~ handle) %}
{% set forceDisabled = disabledPlugins == '*' or handle in disabledPlugins %}
-
")).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;n=e);return t.toFixed(1)+" "+["kB","MB","GB","TB","PB","EB","ZB","YB"][n]},_createExtensionList:function(){this._extensionList=[];for(var t=0;t=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return i("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 i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(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 i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:M(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},n}function e(t,e,n,i,r,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(i,r)}function n(t){return function(){var n=this,i=arguments;return new Promise((function(r,a){var s=t.apply(n,i);function o(t){e(s,r,a,o,l,"next",t)}function l(t){e(s,r,a,o,l,"throw",t)}o(void 0)}))}}function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},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 s,o=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw s}}}}function r(t){return r="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},r(t)}function a(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.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)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n .field > .instructions").add($(".field.info-icon-instructions > .instructions")),i=0;i",{class:"info",html:r.children().html()}).appendTo(s),r.remove()}if(!this.isMobile&&this.$header.length&&(this.addListener(Garnish.$win,"scroll","updateFixedHeader"),this.updateFixedHeader()),Garnish.$doc.ready((function(){t.addListener(Garnish.$win,"resize",(function(e){if(e.target===window){t.handleWindowResize(),clearTimeout(t.resizeTimeout);var n=t;t.resizeTimeout=setTimeout((function(){n.setSidebarNavAttributes()}),100)}})),t.handleWindowResize(),t.setSidebarNavAttributes(),Garnish.requestAnimationFrame(t.initSpecialForms.bind(t))})),this.$alerts.length&&this.initAlerts(),this.addListener(this.$navToggle,"click","toggleNav"),this.addListener(this.$sidebarToggle,"click","toggleSidebar"),Garnish.uiLayerManager.on("addLayer",(function(){t.handleLayerUpdates()})),Garnish.uiLayerManager.on("removeLayer",(function(){t.handleLayerUpdates()})),this.$primaryForm.length||(this.$primaryForm=$("form[data-saveshortcut]:first")),this.$primaryForm.length&&Garnish.hasAttr(this.$primaryForm,"data-saveshortcut")){var o=[],l=this.$primaryForm.data("actions");if(void 0===l)o.push([{keyCode:Garnish.S_KEY,ctrl:!0},{redirect:this.$primaryForm.data("saveshortcut-redirect"),retainScroll:Garnish.hasAttr(this.$primaryForm,"saveshortcut-scroll")}]);else for(var c=0;c",{class:"visually-hidden",html:Craft.t("app","Unread messages")}),b.addClass("unread").append(m)),this.addListener(b,"click",(function(){if(v)v.show();else{var t="";Craft.announcements.forEach((function(e){t+='
')+'
'+'
'.concat(e.heading,"
")+'
'+'
'.concat(e.icon,"
")+'
'.concat(e.label,"
")+"
"+"
".concat(e.body,"
")+"
"})),v=new Garnish.HUD(b,'
'.concat(Craft.t("app","Announcements"),'
').concat(t,"
"),{onShow:function(){b.addClass("active")},onHide:function(){b.removeClass("active")}}),$("a",v.$main).each((function(){this.hostname.length&&this.hostname!==p.hostname&&void 0===$(this).attr("target")&&$(this).attr("rel","noopener").attr("target","_blank")})),y&&(b.removeClass("unread"),m.remove(),Craft.sendActionRequest("POST","users/mark-announcements-as-read",{data:{ids:Craft.announcements.map((function(t){return t.id}))}}))}}))}var C=document.getElementById("footer");C&&new IntersectionObserver((function(t){var e=function(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 i,r,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=(i=a.call(n)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return o}}(t,e)||a(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.")}()}(t,1)[0];e.target.classList.toggle("stuck",e.intersectionRatio<1)}),{rootMargin:"0px 0px -1px 0px",threshold:[1]}).observe(C),this.elementThumbLoader.load(this.$pageContainer),this.on("notificationClose",(function(){t.updateNotificationHeadingDisplay()}))},get $contentHeader(){var t=$("#content-header");return t.length?t:$("",{id:"content-header",class:"pane-header"}).prependTo($("#content"))},get $noticeContainer(){var t=$("#content-notice");return t.length?t:$('').attr("role","status").prependTo(this.$contentHeader)},get notificationCount(){return this.$notificationContainer.find(".notification").length},initSpecialForms:function(){var t=this;if(this.$confirmUnloadForms=$("form[data-confirm-unload]"),this.$deltaForms=$("form[data-delta]"),this.$confirmUnloadForms.length){for(var e=this.$confirmUnloadForms.add(this.$deltaForms),n=function(){var n=e.eq(i);if(!n.data("initialSerializedValue")){var r=n.data("serializer")||function(){return n.serialize()};n.data("initialSerializedValue",r())}t.addListener(n,"submit",(function(t){if(Garnish.hasAttr(n,"data-confirm-unload")&&this.removeListener(Garnish.$win,"beforeunload"),Garnish.hasAttr(n,"data-delta")){t.preventDefault();var e=n.data("serializer")||function(){return n.serialize()},i=Craft.findDeltaData(n.data("initialSerializedValue"),e(),n.data("delta-names"),null,n.data("initial-delta-values"),n.data("modified-delta-names"));Craft.createForm(i).appendTo(Garnish.$bod).submit()}}))},i=0;i a"):void 0},get $selectedTab(){return this.tabManager?this.tabManager.$selectedTab:void 0},get selectedTabIndex(){return this.tabManager?this.tabManager.$tabs.index(this.tabManager.$selectedTab):void 0},get $focusableTab(){return this.tabManager?this.tabManager.$focusableTab:void 0},selectTab:function(t){this.tabManager&&this.tabManager.selectTab(t)},deselectTab:function(){this.tabManager&&this.tabManager.deselectTab()},handleBreadcrumbVisibility:function(){if(this.$crumbItems.length){this.$crumbMenuItems&&(this.$crumbItems.css("max-width",""),this.$crumbMenuItems.insertAfter(this.$crumbMenuTriggerItem),this.$crumbMenuTriggerItem.detach(),this.$crumbMenuItems=null);for(var t=Math.ceil(this.$crumbs[0].getBoundingClientRect().width-this.$navToggle[0].getBoundingClientRect().width),e=[],n=0;nt){if(this.$crumbMenuTriggerItem)this.$crumbMenuTriggerItem.prependTo(this.$crumbList);else{this.$crumbMenuTriggerItem=$("",{class:"crumb"}).prependTo(this.$crumbList);var r=$("",{class:"crumb-label"}).appendTo(this.$crumbMenuTriggerItem),a=$("",{id:"crumb-menu-trigger","data-icon":"ellipsis","data-disclosure-trigger":"true","aria-controls":"crumb-menu","aria-haspopup":"true","aria-label":Craft.t("app","More…"),title:Craft.t("app","More…")}).appendTo(r);this.$crumbMenu=$("",{id:"crumb-menu",class:"menu menu--disclosure","data-disclosure-menu":"true"}).appendTo(r),this.$crumbMenuList=$("
").appendTo(this.$crumbMenu),a.disclosureMenu()}for(var s=this.$crumbMenuTriggerItem[0].getBoundingClientRect().width,o=this.$crumbItems.length-1;o>=0;o--){if(s+e[o]>t){this.$crumbMenuItems=this.$crumbItems.slice(0,o+1),this.$crumbMenuItems.appendTo(this.$crumbMenuList);break}s+=e[o]}}}},handleWindowResize:function(){this.updateResponsiveTables(),this.handleBreadcrumbVisibility()},handleLayerUpdates:function(){var t;if(Garnish.uiLayerManager.modalLayers.length!==this.modalLayers.length){if(this.modalLayers=Garnish.uiLayerManager.modalLayers,this.announcerTimeout&&clearTimeout(this.announcerTimeout),0===Garnish.uiLayerManager.modalLayers.length)this.$activeLiveRegion=this.$globalLiveRegion;else{var e,n,i=Garnish.uiLayerManager.highestModalLayer.$container;i.hasClass("modal")?n=i.data("modal"):i.hasClass("slideout-container")&&(n=i.find(".slideout").data("slideout")),n||console.warn("There is no modal object"),null!==(e=n)&&void 0!==e&&e.$liveRegion?this.$activeLiveRegion=n.$liveRegion:(console.warn("There is no live region in the active modal layer."),this.$activeLiveRegion=null)}null===(t=this.$activeLiveRegion)||void 0===t||t.empty()}},updateResponsiveTables:function(){for(this.updateResponsiveTables._i=0;this.updateResponsiveTables._i0&&(void 0===this.updateResponsiveTables._$table.data("lastContainerWidth")?this.updateResponsiveTables._check=!0:(this.updateResponsiveTables._isCollapsed=this.updateResponsiveTables._$table.hasClass("collapsed"),this.updateResponsiveTables._containerWidth>this.updateResponsiveTables._$table.data("lastContainerWidth")?this.updateResponsiveTables._isCollapsed&&(this.updateResponsiveTables._$table.removeClass("collapsed"),this.updateResponsiveTables._check=!0):this.updateResponsiveTables._isCollapsed||(this.updateResponsiveTables._check=!0)),this.updateResponsiveTables._check&&this.updateResponsiveTables._$table.width()-30>this.updateResponsiveTables._containerWidth&&this.updateResponsiveTables._$table.addClass("collapsed"),this.updateResponsiveTables._$table.data("lastContainerWidth",this.updateResponsiveTables._containerWidth))},updateFixedHeader:function(){var t;if(!(this.isMobile||null!==(t=this.$sidebarToggle)&&void 0!==t&&t.length&&null!==this.$sidebarToggle[0].offsetParent))if(this.$main.length&&this.$headerContainer[0].getBoundingClientRect().top<0){var e=this.$headerContainer.height(),n=this.$header.width();this.fixedHeader||(this.$contentContainer.css("min-height","calc(100vh - "+(e+14+48-1)+"px)"),this.$headerContainer.height(e),this.$header.width(n),Garnish.$bod.addClass("fixed-header"),this.fixedHeader=!0),this._setFixedTopPos(this.$sidebar,e),this.$detailsContainer.css("top",e+14)}else this.fixedHeader&&(this.$headerContainer.height("auto"),this.$header.width("auto"),Garnish.$bod.removeClass("fixed-header"),this.$contentContainer.css("min-height",""),this.$sidebar.removeClass("fixed").css("top",""),this.$detailsContainer.css("top",""),this.fixedHeader=!1)},updateNotificationHeadingDisplay:function(){this.notificationCount>0?this.$notificationHeading.removeClass("hidden"):this.$notificationHeading.addClass("hidden")},_setFixedTopPos:function(t,e){t.length&&this.$contentContainer.length&&(t.outerHeight()>=this.$contentContainer.outerHeight()?t.removeClass("fixed").css("top",""):t.addClass("fixed").css("top",Math.min(e+14,Math.max(this.$mainContent[0].getBoundingClientRect().top,document.documentElement.clientHeight-t.outerHeight()))+"px"))},announce:function(t){var e,n=this;t&&this.$activeLiveRegion&&document.contains(this.$activeLiveRegion[0])?(this.announcerTimeout&&clearTimeout(this.announcerTimeout),null===(e=this.$activeLiveRegion)||void 0===e||e.empty().text(t),this.announcerTimeout=setTimeout((function(){var t;null===(t=n.$activeLiveRegion)||void 0===t||t.empty()}),5e3)):console.warn("There was an error announcing this message.")},displayNotification:function(t,e,n){var i=new Craft.CP.Notification(t,e,n);return this.trigger("displayNotification",{notificationType:t,message:e,notification:i}),this.updateNotificationHeadingDisplay(),i},displayNotice:function(t,e){return this.displayNotification("notice",t,Object.assign({icon:"info",iconLabel:Craft.t("app","Notice")},e))},displaySuccess:function(t,e){return this.displayNotification("success",t,Object.assign({icon:"check",iconLabel:Craft.t("app","Success")},e))},displayError:function(t,e){return t&&"object"!==r(t)||(e=t,t=Craft.t("app","A server error occurred.")),this.displayNotification("error",t,Object.assign({icon:"alert",iconLabel:Craft.t("app","Error")},e))},fetchAlerts:function(){return Craft.queue.push((function(){return new Promise((function(t,e){var n={path:Craft.path};Craft.sendActionRequest("POST","app/get-cp-alerts",{data:n}).then((function(e){var n=e.data;t(n.alerts)})).catch(e)}))}))},displayAlerts:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.$alerts.remove(),Array.isArray(t)&&t.length){this.$alerts=$('
",{class:"thin action"}).append($("",{class:"delete icon",title:Craft.t("app","Delete"),type:"button"})).appendTo(o),o}}),Craft.EditableTable.Row=Garnish.Base.extend({table:null,id:null,niceTexts:null,$tr:null,$tds:null,tds:null,$textareas:null,$deleteBtn:null,get prevRow(){return this.$tr.prev("tr")},get nextRow(){return this.$tr.next("tr")},init:function(t,e){var n=this;this.table=t,this.$tr=$(e),this.$tds=this.$tr.children(),this.tds=[],this.id=this.$tr.attr("data-id"),this.$tr.data("editable-table-row",this);var i=parseInt(this.id.substring(this.table.settings.rowIdPrefix.length));i>this.table.biggestId&&(this.table.biggestId=i),this.$textareas=$(),this.niceTexts=[];var r,a,s,o,l={},c=0;for(r in this.table.columns)if(this.table.columns.hasOwnProperty(r)){if(a=this.table.columns[r],s=this.tds[r]=this.$tds[c],Craft.inArray(a.type,Craft.EditableTable.textualColTypes)){$(".editable-table-preview",s).remove();var h=void 0;"color"===a.type?h=$("input.color-input",s):(h=$("textarea",s),this.$textareas=this.$textareas.add(h),this.niceTexts.push(new Garnish.NiceText(h,{onHeightChange:this.onTextareaHeightChange.bind(this)}))),this.addListener(h,"focus","onTextareaFocus"),this.addListener(h,"mousedown","ignoreNextTextareaFocus"),this.addListener(h,"keypress",{tdIndex:c,type:a.type},"handleKeypress"),this.addListener(h,"input",{type:a.type},"validateValue"),h.trigger("input"),"multiline"!==a.type&&this.addListener(h,"paste",{tdIndex:c,type:a.type},"handlePaste"),l[r]=h}else"checkbox"===a.type&&(o=$('input[type="checkbox"]',s),a.radioMode&&(void 0===this.table.radioCheckboxes[r]&&(this.table.radioCheckboxes[r]=[]),this.table.radioCheckboxes[r].push(o[0]),this.addListener(o,"change",{colId:r},"onRadioCheckboxChange")),a.toggle&&this.addListener(o,"change",{colId:r},(function(t){this.applyToggleCheckbox(t.data.colId)})));$(s).hasClass("disabled")||this.addListener(s,"click",{td:s},(function(t){t.target===t.data.td&&$(t.data.td).find("textarea,input,select,.lightswitch").focus()})),c++}for(r in this.onTextareaHeightChange(),this.table.columns)this.table.columns.hasOwnProperty(r)&&"checkbox"===(a=this.table.columns[r]).type&&a.toggle&&this.applyToggleCheckbox(r);for(r in this.table.columns)this.table.columns.hasOwnProperty(r)&&(!(a=this.table.columns[r]).autopopulate||void 0===l[a.autopopulate]||l[r].val()||l[a.autopopulate].val()||new Craft.HandleGenerator(l[r],l[a.autopopulate],{allowNonAlphaStart:!0}));var u=this.$tr.children().last().find(".delete");this.addListener(u,"click","deleteRow");var d=this.$tr.find("input,textarea,select,.lightswitch");this.addListener(d,"focus",(function(t){$(t.currentTarget).closest("td:not(.disabled)").addClass("focus")})),this.addListener(d,"blur",(function(t){$(t.currentTarget).closest("td").removeClass("focus")}));var f=this.$tr.find("> .action .action-btn");f.length&&(this.actionDisclosure=f.data("trigger")||new Garnish.DisclosureMenu(f),this.$actionMenu=this.actionDisclosure.$container,this.actionDisclosure.on("show",(function(){n.updateDisclosureMenu(),Garnish.firstFocusableElement(n.$actionMenu).focus()})),this.$actionMenuOptions=this.$actionMenu.find("button[data-action]"),this.addListener(this.$actionMenuOptions,"activate",this.handleActionClick))},updateDisclosureMenu:function(){this.prevRow.length?this.$actionMenu.find("button[data-action=moveUp]:first").parent().removeClass("hidden"):this.$actionMenu.find("button[data-action=moveUp]:first").parent().addClass("hidden"),this.nextRow.length?this.$actionMenu.find("button[data-action=moveDown]:first").parent().removeClass("hidden"):this.$actionMenu.find("button[data-action=moveDown]:first").parent().addClass("hidden")},handleActionClick:function(t){t.preventDefault(),this.onActionSelect(t.target)},onActionSelect:function(t){switch($option=$(t),$option.data("action")){case"moveUp":this.moveUp();break;case"moveDown":this.moveDown()}this.actionDisclosure.hide()},moveUp:function(){var t=this.prevRow;t.length&&(this.$tr.insertBefore(t),this.table.updateAllRows())},moveDown:function(){var t=this.nextRow;t.length&&(this.$tr.insertAfter(t),this.table.updateAllRows())},onTextareaFocus:function(t){this.onTextareaHeightChange();var e=$(t.currentTarget);e.data("ignoreNextFocus")?e.data("ignoreNextFocus",!1):window.setTimeout((function(){Craft.selectFullValue(e)}),0)},onRadioCheckboxChange:function(t){if(t.currentTarget.checked)for(var e=0;et&&(t=this.niceTexts[e].height);this.$textareas.css("min-height",t);var n=this.$textareas.filter(":visible").first().parent().height();n>t&&this.$textareas.css("min-height",n)},deleteRow:function(){this.table.deleteRow(this)}},{numericKeyCodes:[9,8,37,38,39,40,45,91,46,190,48,49,50,51,52,53,54,55,56,57]})},8468: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 i};var n,i={},r=Object.prototype,a=r.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",h=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(n){u=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var r=e&&e.prototype instanceof y?e:y,a=Object.create(r.prototype),o=new P(i||[]);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}}}i.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function C(){}function $(){}var w={};u(w,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==r&&a.call(S,l)&&(w=S);var x=$.prototype=y.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function i(r,s,o,l){var c=f(e[r],e,s);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==t(u)&&a.call(u,"__await")?n.resolve(u.__await).then((function(t){i("next",t,o,l)}),(function(t){i("throw",t,o,l)})):n.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,l)}))}l(c.arg)}var r;s(this,"_invoke",{value:function(t,e){function a(){return new n((function(n,r){i(t,e,n,r)}))}return r=r?r.then(a,a):a()}})}function E(t,e,i){var r=p;return function(a,s){if(r===m)throw new Error("Generator is already running");if(r===v){if("throw"===a)throw s;return{value:n,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===b)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=f(t,e,i);if("normal"===c.type){if(r=i.done?v:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=v,i.method="throw",i.arg=c.arg)}}}function k(t,e){var i=e.method,r=t.iterator[i];if(r===n)return e.delegate=null,"throw"===i&&t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method)||"return"!==i&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var a=f(r,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 A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(e){if(e||""===e){var i=e[l];if(i)return i.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,s=function t(){for(;++r=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return i("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 i=this.tryEntries[n];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(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 i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,i){return this.delegate={iterator:M(t),resultName:e,nextLoc:i},"next"===this.method&&(this.arg=n),b}},i}function n(t,e,n,i,r,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(i,r)}function i(t){return function(){var e=this,i=arguments;return new Promise((function(r,a){var s=t.apply(e,i);function o(t){n(s,r,a,o,l,"next",t)}function l(t){n(s,r,a,o,l,"throw",t)}o(void 0)}))}}var r,a;Craft.ElementActionTrigger=Garnish.Base.extend({elementIndex:null,maxLevels:null,newChildUrl:null,$trigger:null,$selectedItems:null,triggerEnabled:!0,init:function(t){if(this.elementIndex=Craft.currentElementIndex,this.elementIndex.triggers.push(this),$.isPlainObject(t)||(t={}),void 0!==t.batch&&(t.bulk=t.batch,delete t.batch),Object.defineProperty(t,"batch",{get:function(){return this.bulk},set:function(t){this.bulk=t}}),this.setSettings(t,Craft.ElementActionTrigger.defaults),this.$trigger=$("#".concat(this.elementIndex.namespaceId(t.type),"-actiontrigger")).data("trigger",this),this.settings.activate){this.$trigger.data("custom-handler",!0);var e=this.$trigger.find("button,.btn");e.length||(e=this.$trigger),this.addListener(e,"activate","handleTriggerActivation")}this.updateTrigger(),this.elementIndex.on("selectionChange",this.updateTrigger.bind(this))},updateTrigger:function(){0!==this.elementIndex.getSelectedElements().length&&(this.validateSelection()?this.enableTrigger():this.disableTrigger())},validateSelection:function(){var t=this;if(this.$selectedItems=this.elementIndex.getSelectedElements(),!this.settings.bulk&&this.$selectedItems.length>1)return!1;if(this.settings.requireId)for(var e=0;e=t.length?{done:!0}:{done:!1,value:t[i++]}},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(){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 r(e,n,i){var r;return r=function(e,n){if("object"!=t(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,"string");if("object"!=t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n),(n="symbol"==t(r)?r:String(r))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}function a(){"use strict";a=function(){return n};var e,n={},i=Object.prototype,r=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",h=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(e){u=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var r=e&&e.prototype instanceof y?e:y,a=Object.create(r.prototype),o=new P(i||[]);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}}}n.wrap=d;var p="suspendedStart",g="suspendedYield",m="executing",v="completed",b={};function y(){}function C(){}function $(){}var w={};u(w,l,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(M([])));S&&S!==i&&r.call(S,l)&&(w=S);var x=$.prototype=y.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function T(e,n){function i(a,s,o,l){var c=f(e[a],e,s);if("throw"!==c.type){var h=c.arg,u=h.value;return u&&"object"==t(u)&&r.call(u,"__await")?n.resolve(u.__await).then((function(t){i("next",t,o,l)}),(function(t){i("throw",t,o,l)})):n.resolve(u).then((function(t){h.value=t,o(h)}),(function(t){return i("throw",t,o,l)}))}l(c.arg)}var a;s(this,"_invoke",{value:function(t,e){function r(){return new n((function(n,r){i(t,e,n,r)}))}return a=a?a.then(r,r):r()}})}function E(t,n,i){var r=p;return function(a,s){if(r===m)throw new Error("Generator is already running");if(r===v){if("throw"===a)throw s;return{value:e,done:!0}}for(i.method=a,i.arg=s;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===b)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===p)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var c=f(t,n,i);if("normal"===c.type){if(r=i.done?v:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=v,i.method="throw",i.arg=c.arg)}}}function k(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var a=f(r,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,b;var s=a.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.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 A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(n){if(n||""===n){var i=n[l];if(i)return i.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var a=-1,s=function t(){for(;++a=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),A(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 i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:M(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},n}function s(t,e,n,i,r,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(i,r)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(i,r){var a=t.apply(e,n);function o(t){s(a,i,r,o,l,"next",t)}function l(t){s(a,i,r,o,l,"throw",t)}o(void 0)}))}}function l(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 i,r,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=(i=a.call(n)).done)&&(o.push(i.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw r}}return o}}(t,e)||c(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 c(t,e){if(t){if("string"==typeof t)return h(t,e);var n=Object.prototype.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)?h(t,e):void 0}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n",{class:"revision-spinner spinner hidden",title:Craft.t("app","Saving")}).appendTo(g),this.$statusIcon=$("",{class:"revision-status ".concat(this.isFullPage?"invisible":"hidden")}).appendTo(g),this.$expandSiteStatusesBtn=this.$container.find(".expand-status-btn"),this.settings.canEditMultipleSites&&this.addListener(this.$expandSiteStatusesBtn,"click","expandSiteStatuses"),this.settings.previewTargets.length&&this.isFullPage){this.settings.enablePreview&&this.addListener(this.$previewBtn,"click","openPreview");var m=this.$container.find(".preview-btn-container");if(1===this.settings.previewTargets.length){var v=l(this.settings.previewTargets,1)[0];this.createPreviewLink(v).addClass("view-btn btn").attr("aria-label",Craft.t("app","View")).appendTo(m)}else this.createShareMenu(m)}if(this.settings.canSave){if("FORM"!==this.$container.prop("tagName"))throw"Element editors may only be used with forms.";this.isFullPage&&Craft.edition!==Craft.Solo&&(this.$activityContainer=this.$container.find(".activity-container"),this._checkActivity()),this.$container.data("serializer",(function(){return o.serializeForm(!0)})),this.$container.data("initialSerializedValue",this.serializeForm(!0)),Garnish.requestAnimationFrame((function(){o.$container.data("initialSerializedValue",o.serializeForm(!0))})),this.slideout||this.addListener(this.$container,"submit","handleSubmit"),this.settings.isProvisionalDraft?this.initForProvisionalDraft():this.settings.draftId&&!this.settings.isUnpublishedDraft?this.initForDraft():this.settings.canSaveCanonical||this.addListener(this.$container,"submit.saveShortcut",(function(t){t.saveShortcut&&(t.preventDefault(),o.saveDraft(),o.removeListener(o.$container,"submit.saveShortcut"))})),this.listenForChanges(),this.addListener(this.$statusIcon,"click",(function(){o.showStatusHud(o.$statusIcon)})),this.handleDismissibleTips(),this.isFullPage&&Craft.messageReceiver&&Craft.broadcaster.addEventListener("message",(function(t){if("saveDraft"===t.data.event&&t.data.canonicalId===o.settings.canonicalId&&(t.data.draftId===o.settings.draftId||t.data.isProvisionalDraft&&!o.settings.draftId)||"saveElement"===t.data.event&&t.data.id===o.settings.canonicalId&&!o.settings.draftId)(o.settings.reloadOnBroadcastSave||t.data.draftId!==o.settings.draftId)&&(Craft.setUrl(Craft.getUrl(document.location.href,{scrollY:window.scrollY})),window.location.reload());else if("deleteDraft"===t.data.event&&t.data.canonicalId===o.settings.canonicalId&&t.data.draftId===o.settings.draftId){var e=new URL(window.location.href);e.searchParams.delete("draftId"),e.href!==document.location.href?window.location.href=e:(Craft.setUrl(Craft.getUrl(document.location.href,{scrollY:window.scrollY})),window.location.reload())}})),this.activityTooltips={},this.isFullPage&&Craft.ui.setFocusOnErrorSummary(this.$container)}},_createQueue:function(){var t=this,e=new Craft.Queue;return e.on("beforeRun",(function(){t.showSpinner()})),e.on("afterRun",(function(){t.hideSpinner()})),e},get namespace(){return this.settings.namespace},namespaceInputName:function(t){return Craft.namespaceInputName(t,this.namespace)},namespaceId:function(t){return Craft.namespaceId(t,this.namespace)},get listeningForChanges(){return!!this.formObserver},get pauseLevel(){var t,e;return null!==(t=null===(e=this.formObserver)||void 0===e?void 0:e._pauseLevel)&&void 0!==t?t:0},listenForChanges:function(){var t=this;this.formObserver||(this.formObserver=new Craft.FormObserver(this.$container,(function(){t.checkForm()})))},stopListeningForChanges:function(){this.formObserver&&(this.formObserver.destroy(),this.formObserver=null)},pause:function(){var t;null===(t=this.formObserver)||void 0===t||t.pause()},resume:function(){var t;null===(t=this.formObserver)||void 0===t||t.resume()},initForProvisionalDraft:function(){var t,e=this,n=this.$container.find(".discard-changes-btn");if(!n.length){var i,r,a,s=null!==(i=this.settings.$noticeContainer)&&void 0!==i?i:this.isFullPage?Craft.cp.$noticeContainer:this.$container.find(".so-notice");this.isFullPage&&(r=$("#content").height(),a=Garnish.$win.scrollTop());var o=$("",{class:"draft-notice"}).append($("",{class:"draft-icon","aria-hidden":"true","data-icon":"edit"})).append($("",{text:Craft.t("app","Showing your unsaved changes.")})).appendTo(s);if(n=$("",{type:"button",class:"discard-changes-btn btn",text:Craft.t("app","Discard")}).appendTo(o),this.isFullPage){var l=$("#content").height()-r;if(Garnish.$win.scrollTop(a+l),Garnish.$win.scrollTop()===a){Craft.cp.$contentContainer.css("pointer-events","none"),$("#content-header").css("min-height","auto");var c=s.height();s.css({height:c-l,overflow:"hidden"}).velocity({height:c},"fast",(function(){$("#content-header").css("min-height",""),s.css({height:"",overflow:""}),setTimeout((function(){Craft.cp.$contentContainer.css("pointer-events","")}),300)}))}}}this.addListener(n,"keypress,keyup,change,focus,blur,click,mousedown,mouseup",(function(t){t.stopPropagation()})),this.addListener(n,"click",(function(){confirm(Craft.t("app","Are you sure you want to discard your changes?"))&&e.queue.unshift((function(){return new Promise((function(t,n){e.isFullPage?Craft.submitForm(e.$container,{action:"elements/delete-draft",redirect:e.settings.hashedCpEditUrl,params:{draftId:e.settings.draftId,fieldId:e.settings.fieldId,ownerId:e.settings.ownerId,provisional:1}}):Craft.sendActionRequest("POST","elements/delete-draft",{data:{elementId:e.settings.canonicalId,draftId:e.settings.draftId,fieldId:e.settings.fieldId,ownerId:e.settings.ownerId,siteId:e.settings.siteId,provisional:1}}).then((function(t){var n;Craft.cp.displaySuccess(t.data.message),Craft.broadcaster.postMessage({event:"saveElement",id:e.settings.canonicalId}),null===(n=e.slideout)||void 0===n||n.close()})).catch(n)}))}))})),this.isFullPage||null===(t=this.slideout)||void 0===t||t.$cancelBtn.text(Craft.t("app","Close"))},initForDraft:function(){var t=this;this.createEditMetaAction(),this.settings.canSaveCanonical&&Garnish.uiLayerManager.registerShortcut({keyCode:Garnish.S_KEY,ctrl:!0,alt:!0},(function(){Craft.submitForm(t.$container,{action:"elements/apply-draft",redirect:t.settings.hashedCpEditUrl})}),0)},expandSiteStatuses:function(){var t=this;this.removeListener(this.$expandSiteStatusesBtn,"click"),this.$expandSiteStatusesBtn.velocity({opacity:0},"fast",(function(){t.$expandSiteStatusesBtn.remove()}));var e=this.$container.find(".enabled-for-site-".concat(this.settings.siteId,"-field"));if(this.$siteStatusPane=e.parent(),this.settings.revisionId)this._getOtherSupportedSites().forEach((function(e){return t._createSiteStatusField(e)}));else{e.addClass("nested");var n=Craft.ui.createLightswitchField({label:Craft.t("app","Enabled for all sites"),name:this.namespaceInputName("enabled")}).insertBefore(e);n.find("label").css("font-weight","bold"),this.$globalLightswitch=n.find(".lightswitch"),this.settings.revisionId||this._showField(n);var i=Object.values(this.settings.siteStatuses),r=i.includes(!0),a=i.includes(!1),s=r&&a?"-":r?"1":"",o=encodeURIComponent(this.namespaceInputName("enabledForSite[".concat(this.settings.siteId,"]")))+"="+(this.settings.enabledForSite?"1":"");this.$siteLightswitches=e.find(".lightswitch").on("change",this._updateGlobalStatus.bind(this)),this._getOtherSupportedSites().forEach((function(e){return t._createSiteStatusField(e)}));for(var l=encodeURIComponent(this.namespaceInputName("enabled"))+"=".concat(s),c=0;c",{text:Craft.t("app","Add a site..."),class:"visually-hidden",id:i}),a=Craft.ui.createSelect({options:[{label:Craft.t("app","Add a site…")}].concat((t=n.map((function(t){return{label:t.name,value:t.id}})),function(t){if(Array.isArray(t))return h(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||c(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.")}())),labelledBy:i}).addClass("fullwidth");this.$additionalSiteField=Craft.ui.createField(a,{}).addClass("nested add").appendTo(this.$siteStatusPane),r.prependTo(this.$additionalSiteField);var s=a.find("select");s.on("change",(function(){var t=parseInt(s.val()),n=Craft.sites.find((function(e){return e.id===t}));if(n){var i=e.settings.additionalSites.find((function(t){return t.siteId==n.id}));e._createSiteStatusField(n,i.enabledByDefault),e._updateGlobalStatus(),s.val("").find('option[value="'.concat(t,'"]')).remove(),null===e.newSiteIds&&(e.newSiteIds=[]),e.siteIds.push(t),e.newSiteIds.push(t),1===s.find("option").length&&e._removeField(e.$additionalSiteField)}})),this._showField(this.$additionalSiteField)}},showStatusHud:function(t){var e;this.failed?(e='
'.concat(this._saveFailMessage(),"
"),this.httpError&&(e+='
'.concat(Craft.escapeHtml(this.httpError),"
")),400===this.httpStatus&&(e+='"))):e="
".concat(this._saveSuccessMessage(),"
");var n=new Garnish.HUD(t,e,{hudClass:"hud revision-status-hud",onHide:function(){n.destroy()}});n.$mainContainer.find(".refresh-btn").on("click",(function(){window.location.reload()}))},_saveSuccessMessage:function(){return this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft?Craft.t("app","Your changes have been stored."):Craft.t("app","The draft has been saved.")},_saveFailMessage:function(){return this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft?Craft.t("app","Your changes could not be stored."):Craft.t("app","The draft could not be saved.")},spinners:function(){return this.$spinner},showSpinner:function(){this.spinners().removeClass("hidden")},hideSpinner:function(){this.spinners().addClass("hidden")},statusIcons:function(){return this.$statusIcon},createEditMetaAction:function(){if(this.isFullPage){var t=$("#action-menu").disclosureMenu().data("disclosureMenu"),e=t.getFirstDestructiveGroup(),n=t.addGroup(null,!0,e),i=t.addItem({type:"button",icon:"edit",label:Craft.t("app","Edit draft settings")},n);this.addListener(i,"click","showMetaModal")}},createPreviewLink:function(t,e){var n=this,i=$("",{href:this.getTokenizedPreviewUrl(t.url,null,!1),text:e||Craft.t("app","View"),target:"_blank",data:{targetUrl:t.url,targetLabel:t.label}});return this.addListener(i,"click",(function(){setTimeout((function(){n.activatePreviewToken()}),1)})),this.previewLinks.push(i),i},updatePreviewLinks:function(){var t=this;this.previewLinks.forEach((function(e){t.updatePreviewLinkHref(e),t.activatedPreviewToken&&t.removeListener(e,"click")}))},updatePreviewLinkHref:function(t){t.attr("href",this.getTokenizedPreviewUrl(t.data("targetUrl"),null,!1))},activatePreviewToken:function(){this.settings.isLive||(this.activatedPreviewToken=!0,this.updatePreviewLinks())},createShareMenu:function(t){var e=this,n=$("",{type:"button",class:"view-btn btn menubtn",text:Craft.t("app","View")}).appendTo(t),i=$("",{class:"menu"}).appendTo(t),r=$("
").appendTo(i);this.settings.previewTargets.forEach((function(t){$("").append(e.createPreviewLink(t,t.label)).appendTo(r)})),new Garnish.MenuBtn(n)},getPreviewTokenParams:function(){var t={elementType:this.settings.elementType,canonicalId:this.settings.canonicalId,siteId:this.settings.siteId,revisionId:this.settings.revisionId,previewToken:this.settings.previewToken};return this.settings.draftId&&!this.settings.isProvisionalDraft&&(t.draftId=this.settings.draftId),t},getPreviewToken:function(){var t=this;return this.previewTokenQueue.push((function(){return new Promise((function(e,n){t.activatedPreviewToken?e(t.settings.previewToken):Craft.sendActionRequest("POST","preview/create-token",{data:t.getPreviewTokenParams()}).then((function(){t.activatePreviewToken(),e(t.settings.previewToken)})).catch(n)}))}))},getTokenizedPreviewUrl:function(t,e){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r={};if(!this.settings.previewParamValue||!e&&this.settings.isLive||(r[e||"x-craft-preview"]=this.settings.previewParamValue),this.settings.siteToken&&(r[Craft.siteToken]=this.settings.siteToken),this.settings.isLive){var a=Craft.getUrl(t,r);return i?new Promise((function(t){t(a)})):a}if(!this.settings.previewToken)throw"Missing preview token";r[Craft.tokenParam]=this.settings.previewToken;var s=Craft.getUrl(t,r);if(this.activatedPreviewToken)return i?new Promise((function(t){t(s)})):s;if(i)return new Promise((function(t,e){n.getPreviewToken().then((function(){t(s)})).catch(e)}));var o=this.getPreviewTokenParams();return o.redirect=s,Craft.getActionUrl("preview/create-token",o)},getPreview:function(){var t,e,n,i=this;return this.preview&&!this.preview.isVisible&&(null===(t=this.preview.elementEditor)||void 0===t?void 0:t.settings.updatedTimestamp)!==this.settings.updatedTimestamp&&(this.preview.destroy(),delete this.preview),this.preview||(this.preview=new Craft.Preview({elementType:this.settings.elementType,elementId:this.settings.isProvisionalDraft?this.settings.canonicalId:this.settings.elementId,draftId:this.settings.isProvisionalDraft?null:this.settings.draftId,revisionId:this.settings.revisionId,siteId:this.settings.siteId,onBeforeLoad:(n=o(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i.checkForm(!1,!0);case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})}),this.preview.on("open",(function(){e=i.settings.updatedTimestamp,i.pause()})),this.preview.on("close",o(a().mark((function t(){var n,r,s,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.$previewBtn&&i.$previewBtn.focus(),i.settings.updatedTimestamp===e){t.next=4;break}return t.next=4,i.refreshContent();case 4:null!==(s=null!==(n=null===(r=i.preview.tabManager)||void 0===r?void 0:r.getSelectedTabIndex())&&void 0!==n?n:null)&&(null===(o=i.tabManager)||void 0===o||o.selectTab(s)),i.resume();case 7:case"end":return t.stop()}}),t)})))),this.preview.on("afterSaveDraft",(function(t){var e=t.response;i._handleSaveDraftResponse(e)}))),this.preview},openPreview:(d=o(a().mark((function t(){var e,n,i,r,s;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Garnish.hasAttr(this.$previewBtn,"aria-disabled")){t.next=2;break}return t.abrupt("return");case 2:return this.$previewBtn.attr("aria-disabled",!0),t.prev=3,i=this.getPreview(),t.next=7,i.open();case 7:null!==(r=null!==(e=null===(n=this.tabManager)||void 0===n?void 0:n.getSelectedTabIndex())&&void 0!==e?e:null)&&(null===(s=i.tabManager)||void 0===s||s.selectTab(r));case 9:return t.prev=9,this.$previewBtn.removeAttr("aria-disabled"),t.finish(9);case 12:case"end":return t.stop()}}),t,this,[[3,,9,12]])}))),function(){return d.apply(this,arguments)}),ensureIsDraftOrRevision:function(t){var e=this;return new Promise((function(n,i){if(e.settings.draftId||e.settings.revisionId)n();else{if(t&&e.serializeForm(!0)===e.$container.data("initialSerializedValue"))return void n();e.saveDraft().then(n).catch(i)}}))},setFormValue:function(t,e){var n=this;return o(a().mark((function i(){return a().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n.settings.revisionId){i.next=2;break}throw"Unable to set form values on a revision.";case 2:return i.next=4,n.checkForm();case 4:if(!n.$container.serialize().split("&").includes("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e)))){i.next=7;break}return i.abrupt("return",!1);case 7:if($("",{type:"hidden",name:t,value:e}).prependTo(n.$container),!n.settings.canCreateDrafts){i.next=11;break}return i.next=11,n.saveDraft();case 11:return i.abrupt("return",!0);case 12:case"end":return i.stop()}}),i)})))()},markDeltaNameAsModified:function(t){var e=this;return o(a().mark((function n(){var i;return a().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((i=e.$container.data("modified-delta-names")||[]).includes(t)){n.next=6;break}return i.push(t),e.$container.data("modified-delta-names",i),n.next=6,e.saveDraft();case 6:case"end":return n.stop()}}),n)})))()},serializeForm:function(t){var e=this.$container.serialize();if(t&&!this.settings.isUnpublishedDraft){var n=encodeURIComponent(this.namespaceInputName("action")),i=encodeURIComponent(this.namespaceInputName("redirect"));e=(e=e.replace(new RegExp("&".concat(Craft.escapeRegex(n),"=[^&]*")),"")).replace(new RegExp("&".concat(Craft.escapeRegex(i),"=[^&]*")),"")}var r={serialized:e=e.replace(/&elementindex-[^&]*/g,"")};return this.trigger("serializeForm",{data:r}),r.serialized},checkForm:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.queue.push((function(){return new Promise((function(i,r){if(e.settings.revisionId)i();else if(void 0!==e.$container.data("initialSerializedValue")){var a=e.serializeForm(!0);t||a!==(e.lastSerializedValue||e.$container.data("initialSerializedValue"))?(null!=n?n:e.enableAutosave)&&e.settings.canCreateDrafts?e._saveDraftInternal(a).then(i).catch((function(t){console.warn("Couldn’t save draft:",t),r(t)})):e.updateFieldLayout(a).then(i).catch((function(t){console.warn("Couldn’t update field layout:",t),r(t)})):i()}else setTimeout((function(){e.checkForm(t).then(i).catch(r)}),500)}))}))},refreshContent:function(t){var e=this;return o(a().mark((function n(){var i;return a().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return e.settings.visibleLayoutElements=[],(i=[e.serializeForm(!0)]).push($.param(r({},e.namespaceInputName("applyParams"),0))),t&&!$.isEmptyObject(t)&&i.push($.param(t)),n.next=6,e.updateFieldLayout(i.join("&"));case 6:case"end":return n.stop()}}),n)})))()},isPreviewActive:function(){return this.preview&&this.preview.isActive},saveDraft:function(t){var e=this;return this.queue.push((function(){return new Promise((function(n,i){e._saveDraftInternal(e.serializeForm(!0),t).then(n).catch(i)}))}))},_saveDraftInternal:function(t,e){var a=this;return new Promise((function(e,s){if(a.submittingForm)s("Form already being submitted.");else{a.lastSerializedValue=t,a.failed=!1,a.httpStatus=null,a.httpError=null,a.cancelToken=axios.CancelToken.source(),a.statusIcons().velocity("stop").css("opacity","").removeClass("hidden invisible checkmark-icon alert-icon fade-out").addClass("hidden"),a.$saveMetaBtn&&a.$saveMetaBtn.addClass("active");var o,c=l(Craft.findModifiedDeltaNames(a.$container.data("initialSerializedValue"),t,a.$container.data("delta-names"),a.$container.data("initial-delta-values"),a.$container.data("modified-delta-names"),!0),1)[0],h=a.prepareData(t,null,!0),u=$(),d=i(c);try{for(d.s();!(o=d.n()).done;){var f=o.value,p=u=u.add(a.$container.find('.field[data-base-input-name="'.concat($.escapeSelector(f),'"]')));u=u.add(p).add(p.parentsUntil(a.$container,".field"))}}catch(t){d.e(t)}finally{d.f()}h.push($.param(r({},a.namespaceInputName("visibleLayoutElements"),a.settings.visibleLayoutElements))),!a.settings.isProvisionalDraft&&a.settings.draftId||h.push("".concat(a.namespaceInputName("provisional"),"=1"));var g=a.$contentContainer.children("[data-layout-tab]:not(.hidden)").data("id");g&&h.push("".concat(a.namespaceInputName("selectedTab"),"=").concat(g)),Craft.sendActionRequest("POST","elements/save-draft",{cancelToken:a.cancelToken.token,headers:a._saveHeaders,data:h.join("&")}).then((function(i){var r;a._afterSaveDraft(),a.settings.previewParamValue=i.data.previewParamValue,a._afterUpdateFieldLayout(t,g,i),a._handleSaveDraftResponse(i),$.isPlainObject(i.data.draftElementUids)&&(a.draftElementUids=n(n({},a.draftElementUids),i.data.draftElementUids));var s=i.data.modifiedAttributes.map((function(t){return t=a.namespaceInputName(t),['[name="'.concat(t,'"]'),'[name^="'.concat(t,'["]')]})).flat().join(",");u=u.add(a.$contentContainer.find(s).parentsUntil(a.$container,".flex-fields > .field")).add(null===(r=a.$sidebar)||void 0===r?void 0:r.find(s).closest(".field")).not(":has(> .status-badge)");for(var o=0;o",{class:"status-badge modified","aria-hidden":"true",title:Craft.t("app","This field has been modified.")}).append($("",{class:"visually-hidden",html:Craft.t("app","This field has been modified.")})));a.afterUpdate(t),a.trigger("afterSaveDraft",{response:i}),Craft.broadcaster&&Craft.broadcaster.postMessage({pageId:Craft.pageId,event:"saveDraft",canonicalId:a.settings.canonicalId,draftId:a.settings.draftId,isProvisionalDraft:a.settings.isProvisionalDraft}),e()})).catch((function(t){a._afterSaveDraft(),a.ignoreFailedRequest||(a.failed=!0,t&&t.response&&(a.httpStatus=t.response.status,a.httpError=t.response.data?t.response.data.message:null),a._showFailStatus(),s(t)),a.ignoreFailedRequest=!1}))}}))},_handleSaveDraftResponse:function(t){var e=this,i=!this.settings.draftId;i&&(this.settings.isProvisionalDraft=!0),this.isFullPage&&(t.data.title&&this.$container.find(".screen-title").text(t.data.title),t.data.docTitle&&(document.title=t.data.docTitle)),this.newSiteIds&&(this.newSiteIds.forEach((function(t){var n=e.settings.additionalSites.find((function(e){return e.siteId==t})),i=!n||void 0===n.enabledByDefault||n.enabledByDefault;Craft.cp.showSiteCrumbMenuItem(t),Craft.cp.setSiteCrumbMenuItemStatus(t,i?"enabled":"disabled")})),this.newSiteIds=null),this.settings.isProvisionalDraft?i&&(this.$container.find("input.action-input").attr("value","elements/apply-draft"),this.settings.elementId=t.data.elementId,this.settings.draftId=t.data.draftId,this.settings.isLive=!1,this.previewToken=null,this.initForProvisionalDraft()):(this.settings.draftName=t.data.draftName,this.isFullPage&&Craft.cp.updateContext(t.data.draftName,t.data.creator?Craft.t("app","Saved {timestamp} by {creator}",{timestamp:t.data.timestamp,creator:t.data.creator}):Craft.t("app","Saved {timestamp}",{timestamp:t.data.timestamp}))),t.data.previewTargets&&JSON.stringify(t.data.previewTargets)!==JSON.stringify(this.settings.previewTargets)&&this.updatePreviewTargets(t.data.previewTargets),i&&(this.updatePreviewLinks(),this.trigger("createProvisionalDraft")),this.$nameTextInput&&this.checkMetaValues(),$.isPlainObject(t.data.draftElementIds)&&(this.draftElementIds=n(n({},this.draftElementIds),t.data.draftElementIds)),this.settings.updatedTimestamp=t.data.updatedTimestamp,this.settings.canonicalUpdatedTimestamp=t.data.canonicalUpdatedTimestamp},_afterSaveDraft:function(){this.$saveMetaBtn&&this.$saveMetaBtn.removeClass("active")},_showFailStatus:function(){this.statusIcons().velocity("stop").css("opacity","").removeClass("hidden checkmark-icon").addClass("alert-icon"),this.setStatusMessage(this._saveFailMessage())},updateFieldLayout:function(t){var e=this;return new Promise((function(n,i){if(e.submittingForm)i("Form already being submitted.");else{e.lastSerializedValue=t,e.cancelToken=axios.CancelToken.source();var a=e.prepareData(t),s=r({},e.namespaceInputName("visibleLayoutElements"),e.settings.visibleLayoutElements);e.settings.isProvisionalDraft&&(s[e.namespaceInputName("provisional")]=1);var o=e.$contentContainer.children("[data-layout-tab]:not(.hidden)").data("id");o&&(s[e.namespaceInputName("selectedTab")]=o),a+="&".concat($.param(s)),Craft.sendActionRequest("POST","elements/update-field-layout",{cancelToken:e.cancelToken.token,headers:e._saveHeaders,data:a}).then((function(i){e._afterUpdateFieldLayout(t,o,i),n()})).catch((function(t){e._afterSaveDraft(),e.ignoreFailedRequest||(e.failed=!0,t&&t.response&&(e.httpStatus=t.response.status,e.httpError=t.response.data?t.response.data.message:null),e._showFailStatus(),i(t)),e.ignoreFailedRequest=!1}))}}))},prepareData:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Craft.findDeltaData(this.$container.data("initialSerializedValue"),t,this.$container.data("delta-names"),e,this.$container.data("initial-delta-values"),this.$container.data("modified-delta-names"),!0);if(this.settings.draftId&&(i.push("".concat(this.namespaceInputName("draftId"),"=").concat(this.settings.draftId)),this.settings.isProvisionalDraft&&i.push("".concat(this.namespaceInputName("provisional"),"=1"))),null!==this.settings.draftName&&i.push("".concat(this.namespaceInputName("draftName"),"=").concat(this.settings.draftName)),null!==this.settings.fieldId&&i.push("".concat(this.namespaceInputName("fieldId"),"=").concat(this.settings.fieldId)),null!==this.settings.ownerId&&i.push("".concat(this.namespaceInputName("ownerId"),"=").concat(this.settings.ownerId)),this.settings.saveParams)for(var r=0,a=Object.entries(this.settings.saveParams);r",{id:r.namespaceId(g.id),class:"flex-fields","data-id":g.id,"data-layout-tab":g.uid}),g.id!==e&&m.addClass("hidden"),m.appendTo(r.$contentContainer)),h=h.add(m),v=i(g.elements);try{for(v.s();!(b=v.n()).done;)!1!==(y=b.value).html?(u[g.uid]||(u[g.uid]=[]),u[g.uid].push(y.uid),"string"==typeof y.html&&(C=m.children('[data-layout-element="'.concat(y.uid,'"]')),w=$(y.html),C.length?C.replaceWith(w):w.appendTo(m),Craft.initUiElements(w),d=!0)):(_=m.children('[data-layout-element="'.concat(y.uid,'"]'))).length&&Garnish.hasAttr(_,"data-layout-element-placeholder")||(S=$("",{class:"hidden","data-layout-element":y.uid,"data-layout-element-placeholder":""}),_.length?_.replaceWith(S):S.appendTo(m),d=!0)}catch(t){v.e(t)}finally{v.f()}}}catch(t){f.e(t)}finally{f.f()}return(x=r.$contentContainer.children("[data-layout-tab]").not(h).not('[data-layout-tab=""]')).length&&(x.remove(),d=!0),h.filter(":not(.hidden)").length||h.first().removeClass("hidden"),r.settings.visibleLayoutElements=u,(null!==(o=r.settings.updateTabs)&&void 0!==o?o:r.isFullPage?function(t){return Craft.cp.updateTabs(t)}:function(){})(n.data.tabs),e&&c&&e!==c&&(I=r.tabManager)&&((T=I.$tabs.filter('[data-id="'.concat(c,'"]'))).length?I.selectTab(T):I.selectTab(I.$tabs.first())),a.next=16,Craft.appendHeadHtml(n.data.headHtml);case 16:return a.next=18,Craft.appendBodyHtml(n.data.bodyHtml);case 18:d&&(n.data.initialDeltaValues&&Object.assign(r.$container.data("initial-delta-values"),n.data.initialDeltaValues),l&&(r.lastSerializedValue=r.serializeForm(!0))),r.handleDismissibleTips();case 20:case"end":return a.stop()}}),s)})))()},afterUpdate:function(t){this.$container.data("initialSerializedValue",t),this.$container.data("initial-delta-values",{});var e=this.statusIcons().velocity("stop").css("opacity","").removeClass("hidden").addClass("checkmark-icon");this.setStatusMessage(this._saveSuccessMessage()),this.settings.autosaveDrafts||e.velocity("stop").velocity({opacity:0},{delay:2e3,complete:function(){e.addClass("hidden")}}),this.trigger("update"),(this.settings.isProvisionalDraft||this.settings.isUnpublishedDraft)&&Craft.broadcaster&&Craft.broadcaster.postMessage({event:"saveElement",id:this.settings.canonicalId})},setStatusMessage:function(t){this.statusIcons().attr("title",t),Craft.cp.announce(t)},showMetaModal:function(){var t=this;this.metaModal?this.metaModal.show():this.createMetaModal(),Garnish.isMobileBrowser(!0)||setTimeout((function(){t.$nameTextInput.focus()}),100)},createMetaModal:function(){var t=this,e=$("",{class:"modal fitted"}),n=$("",{class:"body"}).appendTo(e),i=$('