!function(){var e,t;e=this,t=function(e){"use strict";var s,i,t,a,n;let o=Spina.spina(I=class extends Spina.BaseModel{})||I;function r(e,t,i){t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i}function l(e,t){t=h(e,t,"get");return t.get?t.get.call(e):t.value}function d(e,t,i){t=h(e,t,"set");if(t.set)t.set.call(e,i);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=i}}function h(e,t,i){if(t.has(e))return t.get(e);throw new TypeError("attempted to "+i+" private field on non-instance")}function p(e,t,i){if(t.has(e))return i;throw new TypeError("attempted to get private field on non-instance")}function c(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function m(e,t,i){c(e,t),t.set(e,i)}let u=Spina.spina((r(I=class extends Spina.BaseModel{constructor(){super(...arguments),r(this,"actions",[]),r(this,"itemStateTexts",{disabled:gettext("Disabled"),enabled:gettext("Enabled"),error:gettext("Error")})}initialize(){console.assert(void 0===(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}).actions,`Passing in actions to the Djblets.Config.ListItem constructor
has been removed as of Djblets 5.0. Actions should be passed
to the setActions() method instead.`),this.get("showRemove")&&this.actions.push({danger:!0,enabled:this.get("canRemove"),id:"delete",label:this.get("removeLabel")})}setActions(e){this.actions=e,this.trigger("actionsChanged")}},"defaults",{canRemove:!0,editURL:null,itemState:null,loading:!1,removeLabel:gettext("Remove"),showRemove:!1,text:null}),I=I))||I,f=Spina.spina({prototypeAttrs:["actionHandlers","iconBaseClassName","itemStateClasses","template"]})((s=new WeakMap,r(I=class extends Spina.BaseView{constructor(){super(...arguments),r(this,"$spinnerParent",null),r(this,"$spinner",null),m(this,s,{writable:!0,value:null})}onRender(){var e=this.model;this.$el.empty().append(this.template(_.defaults(e.attributes,this.getRenderContext()))),d(this,s,this.$(".djblets-c-config-forms-list__item-state")),this._onItemStateChanged(),this.addActions(this.getActionsParent())}getRenderContext(){return{}}remove(){return this.$el.fadeOut("normal",()=>super.remove()),this}getActionsParent(){return this.$el}showSpinner(){this.$spinner||(this.$el.attr("aria-busy","true"),this.$spinner=$("<span>").addClass("djblets-o-spinner").attr("aria-hidden","true").prependTo(this.$spinnerParent).hide().css("visibility","visible").fadeIn())}hideSpinner(){this.$spinner&&(this.$spinner.fadeOut("slow",()=>{this.$spinner.remove(),this.$spinner=null}),this.$el.removeAttr("aria-busy"))}addActions(e){const i=$("<span>").addClass("djblets-c-config-forms-list__item-actions");this.model.actions.forEach(e=>{const t=this._buildActionEl(e).appendTo(i);e.children&&(e.label&&t.append(" &#9662;"),t.click(()=>_.defer(()=>this._showActionDropdown(e,t))))}),(this.$spinnerParent=i).prependTo(e)}_showActionDropdown(e,t){var i=t.position();const s=$("<div>").css({minWidth:t.outerWidth(),position:"absolute"}).addClass("djblets-c-config-forms-popup-menu").click(e=>e.stopPropagation()),a=$("<ul>").addClass("djblets-c-config-forms-popup-menu__items").appendTo(s);var n=i.left+t.getExtents("m","l"),o=(e.children.forEach(e=>$("<li>").addClass("djblets-c-config-forms-popup-menu__item config-forms-list-action-row-"+e.id).append(this._buildActionEl(e)).appendTo(a)),this.trigger("actionMenuPopUp",{$action:t,$menu:s,action:e}),s.appendTo(t.parent()),$(window).width()),r=s.width();s.move(t.offset().left+r>o?n+t.innerWidth()-r:n,i.top+t.outerHeight(),"absolute"),$(document).one("click",()=>{this.trigger("actionMenuPopDown",{$action:t,$menu:s,action:e}),s.remove()})}_buildActionEl(e){var t=!1!==e.enabled;const i=t?this.actionHandlers[e.id]:null;var s,a="checkbox"===e.type,n="radio"===e.type;let o,r;return a||n?(s=_.uniqueId("action_"+e.type),o=$("<input>").attr({id:s,name:e.name,type:e.type}),s=$("<label>").attr("for",s).text(e.label),e.id&&s.addClass("config-forms-list-action-label-"+e.id),r=$("<span>").append(o).append(s),e.propName&&(a?o.bindProperty("checked",this.model,e.propName):n&&o.bindProperty("checked",this.model,e.propName,{radioValue:e.radioValue})),e.enabledPropName&&o.bindProperty("disabled",this.model,e.enabledPropName,{inverse:!0!==e.enabledPropInverse}),i&&(s=_.debounce(this[i].bind(this),50,!0),o.change(s),n)&&e.dispatchOnClick&&o.click(s)):(o=e.url?$('<a class="ink-c-button" role="button">').attr("href",e.url):$('<button class="ink-c-button" type="button">'),r=o,e.label&&o.text(e.label),e.ariaLabel&&o.attr("aria-label",e.ariaLabel),e.iconName&&o.prepend($("<span>").addClass(this.iconBaseClassName).addClass(this.iconBaseClassName+"-"+e.iconName)),i&&o.click(e=>{e.preventDefault(),e.stopPropagation(),this._onActionButtonClicked(e,i,o)})),o.addClass("djblets-c-config-forms-list__item-action"),e.id&&o.addClass("config-forms-list-action-"+e.id),e.danger&&o.addClass("-is-danger"),e.primary&&o.addClass("-is-primary"),t||o.prop("disabled",!0),r}_onItemStateChanged(){var e=this.model,t=e.previous("itemState"),i=e.get("itemState");t&&this.$el.removeClass(this.itemStateClasses[t]),i&&(this.$el.addClass(this.itemStateClasses[i]),l(this,s).text(e.itemStateTexts[i]))}_onActionButtonClicked(e,t,i){t=this[t].call(this,e);if(t&&"function"==typeof t.then){i.prop("disabled",!0);const s=i.html(),a=(i.empty(),$('<span class="ink-c-spinner">').appendTo(i));t.finally(()=>{a.remove(),i.html(s),i.prop("disabled",!1)})}}},"className","djblets-c-config-forms-list__item"),r(I,"tagName","li"),r(I,"iconBaseClassName","djblets-icon"),r(I,"itemStateClasses",{disabled:"-is-disabled",enabled:"-is-enabled",error:"-has-error"}),r(I,"template",_.template(`<% if (editURL) { %>
<a href="<%- editURL %>"><%- text %></a>
<% } else { %>
<%- text %>
<% } %>`)),r(I,"actionHandlers",{}),r(I,"modelEvents",{actionsChanged:"render","change:itemState":"_onItemStateChanged",destroy:"remove",request:"showSpinner",sync:"hideSpinner"}),I=I))||I,g=Spina.spina(I=class extends Spina.BaseCollection{initialize(e,t){this.options=t}fetch(e){return this.trigger("fetching"),super.fetch(e)}})||I,b=Spina.spina({prototypeAttrs:["defaultItemView"]})((i=new WeakSet,r(I=class extends Spina.BaseView{constructor(){var e,t;super(...arguments),c(e=this,t=i),t.add(e),r(this,"$listBody",null)}initialize(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};const t=this.model.collection;this.ItemView=e.ItemView||this.defaultItemView,this.views=[],this.animateItems=!!e.animateItems,this.once("rendered",()=>{this.listenTo(t,"add",this.addItem),this.listenTo(t,"remove",this.removeItem),this.listenTo(t,"reset",p(this,i,v))})}getBody(){return this.$el}onRender(){this.$listBody=this.getBody(),p(this,i,v).call(this),this.trigger("rendered")}addItem(e,t){var i=!1!==(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).animate,e=new this.ItemView({model:e});e.render(),this.animateItems&&i&&e.$el.fadeIn(),this.$listBody.append(e.$el),this.views.push(e)}removeItem(t,e){var i=!1!==(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).animate;const s=_.find(this.views,e=>e.model===t);s&&(this.views=_.without(this.views,s),this.animateItems&&i?s.$el.fadeOut(function(){s.remove()}):s.remove())}},"className","djblets-c-config-forms-list"),r(I,"tagName","ul"),r(I,"defaultItemView",f),I=I))||I;function v(){this.views.forEach(e=>e.remove()),this.views=[],this.$listBody.empty(),this.model.collection.each(e=>{this.addItem(e,e.collection,{animate:!1})})}let w=Spina.spina((t=new WeakMap,a=new WeakMap,n=new WeakMap,I=class extends Spina.BaseView{constructor(){super(...arguments),m(this,t,{writable:!0,value:void 0}),m(this,a,{writable:!0,value:void 0}),m(this,n,{writable:!0,value:void 0})}initialize(){this.router=new Backbone.Router({routes:{":pageID":"page"}}),this.listenTo(this.router,"route:page",this._onPageChanged),d(this,t,null),d(this,a,null),d(this,n,!0)}onInitialRender(){this._$pageNavs=this.$(".djblets-c-config-forms-page-nav__item"),this._$pages=this.$(".djblets-c-config-forms-subpage"),d(this,t,this._$pageNavs.eq(0).addClass("-is-active")),d(this,a,this._$pages.eq(0).addClass("-is-active")),Backbone.history.start({root:window.location.pathname})}_onPageChanged(e){l(this,t).removeClass("-is-active"),l(this,a).removeClass("-is-active"),d(this,a,$("#page_"+e)),0===l(this,a).length?this.router.navigate(this._$pageNavs.find("a").attr("href").substr(1),{replace:!0,trigger:!0}):(d(this,t,this._$pageNavs.filter(`:has(a[href="#${e}"])`).addClass("-is-active")),l(this,a).addClass("-is-active"),l(this,n)||$("#messages").remove(),d(this,n,!1))}}))||I,C=Spina.spina((r(I=class extends f{getActionsParent(){return this.$("td:last")}},"tagName","tr"),r(I,"template",_.template(`<td>
<% if (editURL) { %>
<a href="<%- editURL %>"><%- text %></a>
<% } else { %>
<%- text %>
<% } %>
</td>`)),I=I))||I,y=Spina.spina({prototypeAttrs:["defaultItemView"]})((r(I=class extends b{onInitialRender(){0===this.getBody().length&&this.$el.append("<tbody>"),super.onInitialRender()}getBody(){return this.$("tbody")}},"tagName","table"),r(I,"defaultItemView",C),I=I))||I;var I={List:o,ListItem:u,ListItemView:f,ListItems:g,ListView:b,PagesView:w,TableItemView:C,TableView:y};e.Config=I,e.ConfigFormsList=o,e.ConfigFormsListItem=u,e.ConfigFormsListItemView=f,e.ConfigFormsListItems=g,e.ConfigFormsListView=b,e.ConfigFormsPagesView=w,e.ConfigFormsTableItemView=C,e.ConfigFormsTableView=y},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Djblets=e.Djblets||{})}.call(this);
