From 666c9d9a927c22c520d9816d3c4ab23d09e8e192 Mon Sep 17 00:00:00 2001 From: camilleislasse Date: Tue, 13 Oct 2026 12:43:35 +0200 Subject: [PATCH] [BootstrapAdminUi] Allow choosing the displayed columns of grids --- docs/grid/fields.md | 85 +++++++++ .../controllers/column-selector-controller.js | 91 ++++++++++ .../config/app/twig_hooks/common/index.php | 6 + src/BootstrapAdminUi/public/symfony_ux.js | 2 +- .../index/content/grid/data_table.html.twig | 3 +- .../grid/data_table/column_selector.html.twig | 7 + .../crud/index/content/grid/filters.html.twig | 3 + .../templates/shared/helper/table.html.twig | 50 +++++- .../.application/src/Grid/BookGrid.php | 9 + .../tests/Functional/TemplatesTest.php | 30 ++++ .../column-selector-controller.test.mjs | 162 ++++++++++++++++++ .../translations/messages.de.yaml | 1 + .../translations/messages.en.yaml | 1 + .../translations/messages.es.yaml | 1 + .../translations/messages.fr.yaml | 1 + .../translations/messages.nl.yaml | 1 + .../translations/messages.pl.yaml | 1 + 17 files changed, 450 insertions(+), 4 deletions(-) create mode 100644 src/BootstrapAdminUi/assets/controllers/column-selector-controller.js create mode 100644 src/BootstrapAdminUi/templates/shared/crud/index/content/grid/data_table/column_selector.html.twig create mode 100644 src/BootstrapAdminUi/tests/JavaScript/column-selector-controller.test.mjs diff --git a/docs/grid/fields.md b/docs/grid/fields.md index 8a70dda4..5804498c 100644 --- a/docs/grid/fields.md +++ b/docs/grid/fields.md @@ -11,6 +11,8 @@ more suitable to your grid requirements. | label | string | Label displayed in the field header. By default, it is field name. | | path | string | Path to property displayed in field (can be property of resource or one of its referenced objects). | | position | int | Position of field in the grid index view. | +| enabled | bool | Whether the field is part of the grid. Disabled fields are never displayed. Defaults to `true`. | +| visible | bool | Whether the field is displayed by default (see "Hiding fields by default"). Defaults to `true`. | | options | array | Array of field options (see below). | The `options` field can itself contain the following fields: @@ -20,6 +22,89 @@ The `options` field can itself contain the following fields: | template | string | Available (and required) only for *twig* column type. Path to template that is used to render column value. | | | format | string | Available only for *datetime* field type. | `Y:m:d` `H:i:s` | +### Hiding fields by default + +Fields with `visible: false` are not displayed by default. It only sets the default visibility: +users can still display them, either with the columns selector of the Bootstrap Admin UI or with the `visibility` query parameter +(e.g. `/admin/users?visibility[phoneNumber]=visible&visibility[email]=hidden`). +To remove a field from the grid, use `enabled: false` instead. + +{% tabs %} +{% tab title="PHP (recommended)" %} +{% code title="src/Grid/UserGrid.php" lineNumbers="true" %} +```php +withFields( + StringField::create('email'), + StringField::create('phoneNumber') + ->setVisible(false) + ) + ; + } +} +``` +{% endcode %} +{% endtab %} + +{% tab title="YAML" %} +{% code title="config/packages/sylius_grid.yaml" lineNumbers="true" %} +```yaml +sylius_grid: + grids: + app_user: + fields: + email: + type: string + phoneNumber: + type: string + visible: false +``` +{% endcode %} +{% endtab %} + +{% tab title="PHP config file" %} +{% code title="config/packages/sylius_grid.php" lineNumbers="true" %} +```php +addGrid(GridBuilder::create('app_user', '%app.model.user.class%') + ->withFields( + StringField::create('email'), + StringField::create('phoneNumber') + ->setVisible(false) + ) + ) +}; +``` +{% endcode %} +{% endtab %} +{% endtabs %} + ## Field types This is the list of built-in field types. diff --git a/src/BootstrapAdminUi/assets/controllers/column-selector-controller.js b/src/BootstrapAdminUi/assets/controllers/column-selector-controller.js new file mode 100644 index 00000000..58e4b5de --- /dev/null +++ b/src/BootstrapAdminUi/assets/controllers/column-selector-controller.js @@ -0,0 +1,91 @@ +import { Controller } from '@hotwired/stimulus'; + +export default class extends Controller { + static targets = ['column']; + + static values = { + parameter: String, + }; + + connect() { + this.refresh(); + } + + toggle(event) { + event.preventDefault(); + + const column = event.currentTarget; + if (column.classList.contains('disabled')) { + return; + } + + this.setVisible(column, !this.isVisible(column)); + this.refresh(); + } + + apply(event) { + const url = this.buildUrl(); + if (this.normalize(url) === this.normalize(new URL(window.location.href))) { + return; + } + + // The click closing the dropdown may target a link or a submit button, whose navigation would cancel ours + event.clickEvent?.preventDefault(); + + window.location.assign(url.toString()); + } + + buildUrl() { + const url = new URL(window.location.href); + const keys = new Set(url.searchParams.keys()); + + keys.forEach((key) => { + if (key === this.parameterValue || key.startsWith(`${this.parameterValue}[`)) { + url.searchParams.delete(key); + } + }); + + this.columnTargets + .filter((column) => String(this.isVisible(column)) !== column.dataset.defaultVisible) + .forEach((column) => url.searchParams.append( + `${this.parameterValue}[${column.dataset.column}]`, + this.isVisible(column) ? 'visible' : 'hidden' + )); + + return url; + } + + normalize(url) { + const normalizedUrl = new URL(url); + normalizedUrl.searchParams.sort(); + + return normalizedUrl.toString(); + } + + isVisible(column) { + return column.getAttribute('aria-checked') === 'true'; + } + + setVisible(column, isVisible) { + column.setAttribute('aria-checked', String(isVisible)); + column.querySelector('[data-visible-icon]').classList.toggle('d-none', !isVisible); + column.querySelector('[data-hidden-icon]').classList.toggle('d-none', isVisible); + } + + refresh() { + const visibleColumns = this.columnTargets.filter((column) => this.isVisible(column)); + + this.columnTargets.forEach((column) => { + const isLastVisibleColumn = visibleColumns.length === 1 && visibleColumns[0] === column; + + column.classList.toggle('disabled', isLastVisibleColumn); + if (isLastVisibleColumn) { + column.setAttribute('aria-disabled', 'true'); + column.setAttribute('tabindex', '-1'); + } else { + column.removeAttribute('aria-disabled'); + column.removeAttribute('tabindex'); + } + }); + } +} diff --git a/src/BootstrapAdminUi/config/app/twig_hooks/common/index.php b/src/BootstrapAdminUi/config/app/twig_hooks/common/index.php index ba393a3b..fe6ae30e 100644 --- a/src/BootstrapAdminUi/config/app/twig_hooks/common/index.php +++ b/src/BootstrapAdminUi/config/app/twig_hooks/common/index.php @@ -89,6 +89,12 @@ ], ], + 'sylius_admin.common.index.content.grid.data_table#toolbar' => [ + 'column_selector' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/data_table/column_selector.html.twig', + ], + ], + 'sylius_admin.common.index.content.grid.no_results' => [ 'image' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/no_results/image.html.twig', diff --git a/src/BootstrapAdminUi/public/symfony_ux.js b/src/BootstrapAdminUi/public/symfony_ux.js index 00c6fca0..3d1176c5 100644 --- a/src/BootstrapAdminUi/public/symfony_ux.js +++ b/src/BootstrapAdminUi/public/symfony_ux.js @@ -1,2 +1,2 @@ /*! For license information please see symfony_ux.js.LICENSE.txt */ -(()=>{var e={490:(e,t,n)=>{var s={"./copy-to-clipboard-controller.js":500,"./theme-switcher-controller.js":431};function r(e){var t=i(e);return n(t)}function i(e){if(!n.o(s,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return s[e]}r.keys=function(){return Object.keys(s)},r.resolve=i,e.exports=r,r.id=490},891:(e,t,n)=>{"use strict";n.d(t,{lg:()=>Z,xI:()=>ce});class s{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=function(e){if("immediatePropagationStopped"in e)return e;{const{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(const e of this.bindings){if(t.immediatePropagationStopped)break;e.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort(((e,t)=>{const n=e.index,s=t.index;return ns?1:0}))}}class r{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach((e=>e.connect())))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach((e=>e.disconnect())))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce(((e,t)=>e.concat(Array.from(t.values()))),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,n={}){this.application.handleError(e,`Error ${t}`,n)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:n,eventOptions:s}=e,r=this.fetchEventListenerMapForEventTarget(t),i=this.cacheKey(n,s);r.delete(i),0==r.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:n,eventOptions:s}=e;return this.fetchEventListener(t,n,s)}fetchEventListener(e,t,n){const s=this.fetchEventListenerMapForEventTarget(e),r=this.cacheKey(t,n);let i=s.get(r);return i||(i=this.createEventListener(e,t,n),s.set(r,i)),i}createEventListener(e,t,n){const r=new s(e,t,n);return this.started&&r.connect(),r}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const n=[e];return Object.keys(t).sort().forEach((e=>{n.push(`${t[e]?"":"!"}${e}`)})),n.join(":")}}const i={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:n})=>!t||n===e.target},o=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function a(e){return"window"==e?window:"document"==e?document:void 0}function l(e){return e.replace(/(?:[_-])([a-z0-9])/g,((e,t)=>t.toUpperCase()))}function c(e){return l(e.replace(/--/g,"-").replace(/__/g,"_"))}function u(e){return e.charAt(0).toUpperCase()+e.slice(1)}function d(e){return e.replace(/([A-Z])/g,((e,t)=>`-${t.toLowerCase()}`))}function h(e){return null!=e}function p(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const m=["meta","ctrl","alt","shift"];class g{constructor(e,t,n,s){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){const t=e.tagName.toLowerCase();if(t in f)return f[t](e)}(e)||v("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||v("missing identifier"),this.methodName=n.methodName||v("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=s}static forToken(e,t){return new this(e.element,e.index,function(e){const t=e.trim().match(o)||[];let n=t[2],s=t[3];return s&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${s}`,s=""),{eventTarget:a(t[4]),eventName:n,eventOptions:t[7]?(r=t[7],r.split(":").reduce(((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)})),{})):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||s};var r}(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;const n=t.filter((e=>!m.includes(e)))[0];return!!n&&(p(this.keyMappings,n)||v(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[n].toLowerCase()!==e.key.toLowerCase())}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;const t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:s}of Array.from(this.element.attributes)){const r=n.match(t),i=r&&r[1];i&&(e[l(i)]=b(s))}return e}get eventTargetName(){return(e=this.eventTarget)==window?"window":e==document?"document":void 0;var e}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){const[n,s,r,i]=m.map((e=>t.includes(e)));return e.metaKey!==n||e.ctrlKey!==s||e.altKey!==r||e.shiftKey!==i}}const f={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function v(e){throw new Error(e)}function b(e){try{return JSON.parse(e)}catch(t){return e}}class y{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){const t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:n}=this.context.application,{controller:s}=this.context;let r=!0;for(const[i,o]of Object.entries(this.eventOptions))if(i in n){const a=n[i];r=r&&a({name:i,value:o,event:e,element:t,controller:s})}return r}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){const{target:t,currentTarget:n}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:n,action:this.methodName})}catch(t){const{identifier:n,controller:s,element:r,index:i}=this,o={identifier:n,controller:s,element:r,index:i,event:e};this.context.handleError(t,`invoking action "${this.action}"`,o)}}willBeInvokedByEvent(e){const t=e.target;return!(e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e))&&(!(e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e))&&(this.element===t||(t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element))))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class w{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.elementIsActive(e)&&this.processTree(e,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const n of this.matchElementsInTree(e))t.call(this,n)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class O{constructor(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new w(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function E(e,t,n){k(e,t).add(n)}function A(e,t,n){k(e,t).delete(n),function(e,t){const n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}function k(e,t){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n}class S{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e.concat(Array.from(t))),[])}get size(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e+t.size),0)}add(e,t){E(this.valuesByKey,e,t)}delete(e,t){A(this.valuesByKey,e,t)}has(e,t){const n=this.valuesByKey.get(e);return null!=n&&n.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some((t=>t.has(e)))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter((([t,n])=>n.has(e))).map((([e,t])=>e))}}class C{constructor(e,t,n,s){this._selector=t,this.details=s,this.elementObserver=new w(e,this),this.delegate=n,this.matchesByElement=new S}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const{selector:t}=this;if(t){const n=e.matches(t);return this.delegate.selectorMatchElement?n&&this.delegate.selectorMatchElement(e,this.details):n}return!1}matchElementsInTree(e){const{selector:t}=this;if(t){const n=this.matchElement(e)?[e]:[],s=Array.from(e.querySelectorAll(t)).filter((e=>this.matchElement(e)));return n.concat(s)}return[]}elementMatched(e){const{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){const t=this.matchesByElement.getKeysForValue(e);for(const n of t)this.selectorUnmatched(e,n)}elementAttributeChanged(e,t){const{selector:n}=this;if(n){const t=this.matchElement(e),s=this.matchesByElement.has(n,e);t&&!s?this.selectorMatched(e,n):!t&&s&&this.selectorUnmatched(e,n)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class M{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const n=this.delegate.getStringMapKeyForAttribute(e);if(null!=n){this.stringMap.has(e)||this.stringMapKeyAdded(n,e);const s=this.element.getAttribute(e);if(this.stringMap.get(e)!=s&&this.stringMapValueChanged(s,n,t),null==s){const t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(n,e,t)}else this.stringMap.set(e,s)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,n)}stringMapKeyRemoved(e,t,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((e=>e.name))}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class T{constructor(e,t,n){this.attributeObserver=new O(e,t,this),this.delegate=n,this.tokensByElement=new S}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,n]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(n)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach((e=>this.tokenMatched(e)))}tokensUnmatched(e){e.forEach((e=>this.tokenUnmatched(e)))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),s=function(e,t){const n=Math.max(e.length,t.length);return Array.from({length:n},((n,s)=>[e[s],t[s]]))}(t,n).findIndex((([e,t])=>{return s=t,!((n=e)&&s&&n.index==s.index&&n.content==s.content);var n,s}));return-1==s?[[],[]]:[t.slice(s),n.slice(s)]}readTokensForElement(e){const t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter((e=>e.length)).map(((e,s)=>({element:t,attributeName:n,content:e,index:s})))}(e.getAttribute(t)||"",e,t)}}class x{constructor(e,t,n){this.tokenListObserver=new T(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))}tokenUnmatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}}}class L{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new x(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new y(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach((e=>this.delegate.bindingDisconnected(e,!0))),this.bindingsByAction.clear()}parseValueForToken(e){const t=g.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class F{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new M(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const n=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,n.writer(this.receiver[e]),n.writer(n.defaultValue))}stringMapValueChanged(e,t,n){const s=this.valueDescriptorNameMap[t];null!==e&&(null===n&&(n=s.writer(s.defaultValue)),this.invokeChangedCallback(t,e,n))}stringMapKeyRemoved(e,t,n){const s=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,s.writer(this.receiver[e]),n):this.invokeChangedCallback(e,s.writer(s.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:n,writer:s}of this.valueDescriptors)null==n||this.controller.data.has(e)||this.invokeChangedCallback(t,s(n),void 0)}invokeChangedCallback(e,t,n){const s=`${e}Changed`,r=this.receiver[s];if("function"==typeof r){const s=this.valueDescriptorNameMap[e];try{const e=s.reader(t);let i=n;n&&(i=s.reader(n)),r.call(this.receiver,e,i)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${s.name}" - ${e.message}`),e}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map((t=>e[t]))}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach((t=>{const n=this.valueDescriptorMap[t];e[n.name]=n})),e}hasValue(e){const t=`has${u(this.valueDescriptorNameMap[e].name)}`;return this.receiver[t]}}class I{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new S}start(){this.tokenListObserver||(this.tokenListObserver=new T(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var n;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetConnected(e,t))))}disconnectTarget(e,t){var n;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetDisconnected(e,t))))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function N(e,t){const n=_(e);return Array.from(n.reduce(((e,n)=>(function(e,t){const n=e[t];return Array.isArray(n)?n:[]}(n,t).forEach((t=>e.add(t))),e)),new Set))}function P(e,t){return _(e).reduce(((e,n)=>(e.push(...function(e,t){const n=e[t];return n?Object.keys(n).map((e=>[e,n[e]])):[]}(n,t)),e)),[])}function _(e){const t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class ${constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new S,this.outletElementsByName=new S,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach((e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)})),this.started=!0,this.dependentContexts.forEach((e=>e.refresh())))}refresh(){this.selectorObserverMap.forEach((e=>e.refresh())),this.attributeObserverMap.forEach((e=>e.refresh()))}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach((e=>e.stop())),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach((e=>e.stop())),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:n}){const s=this.getOutlet(e,n);s&&this.connectOutlet(s,e,n)}selectorUnmatched(e,t,{outletName:n}){const s=this.getOutletFromMap(e,n);s&&this.disconnectOutlet(s,e,n)}selectorMatchElement(e,{outletName:t}){const n=this.selector(t),s=this.hasOutlet(e,t),r=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return!!n&&(s&&r&&e.matches(n))}elementMatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementAttributeValueChanged(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementUnmatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}connectOutlet(e,t,n){var s;this.outletElementsByName.has(n,t)||(this.outletsByName.add(n,e),this.outletElementsByName.add(n,t),null===(s=this.selectorObserverMap.get(n))||void 0===s||s.pause((()=>this.delegate.outletConnected(e,t,n))))}disconnectOutlet(e,t,n){var s;this.outletElementsByName.has(n,t)&&(this.outletsByName.delete(n,e),this.outletElementsByName.delete(n,t),null===(s=this.selectorObserverMap.get(n))||void 0===s||s.pause((()=>this.delegate.outletDisconnected(e,t,n))))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const n of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(n,t,e)}updateSelectorObserverForOutlet(e){const t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){const t=this.selector(e),n=new C(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,n),n.start()}setupAttributeObserverForOutlet(e){const t=this.attributeNameForOutletName(e),n=new O(this.scope.element,t,this);this.attributeObserverMap.set(e,n),n.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find((t=>this.attributeNameForOutletName(t)===e))}get outletDependencies(){const e=new S;return this.router.modules.forEach((t=>{N(t.definition.controllerConstructor,"outlets").forEach((n=>e.add(n,t.identifier)))})),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter((t=>e.includes(t.identifier)))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find((t=>t.element===e))}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class j{constructor(e,t){this.logDebugActivity=(e,t={})=>{const{identifier:n,controller:s,element:r}=this;t=Object.assign({identifier:n,controller:s,element:r},t),this.application.logDebugActivity(this.identifier,e,t)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new L(this,this.dispatcher),this.valueObserver=new F(this,this.controller),this.targetObserver=new I(this,this),this.outletObserver=new $(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(e){this.handleError(e,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,n={}){const{identifier:s,controller:r,element:i}=this;n=Object.assign({identifier:s,controller:r,element:i},n),this.application.handleError(e,`Error ${t}`,n)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,n){this.invokeControllerMethod(`${c(n)}OutletConnected`,e,t)}outletDisconnected(e,t,n){this.invokeControllerMethod(`${c(n)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const n=this.controller;"function"==typeof n[e]&&n[e](...t)}}function D(e){return function(e,t){const n=B(e),s=function(e,t){return V(t).reduce(((n,s)=>{const r=function(e,t,n){const s=Object.getOwnPropertyDescriptor(e,n);if(!s||!("value"in s)){const e=Object.getOwnPropertyDescriptor(t,n).value;return s&&(e.get=s.get||e.get,e.set=s.set||e.set),e}}(e,t,s);return r&&Object.assign(n,{[s]:r}),n}),{})}(e.prototype,t);return Object.defineProperties(n.prototype,s),n}(e,function(e){const t=N(e,"blessings");return t.reduce(((t,n)=>{const s=n(e);for(const e in s){const n=t[e]||{};t[e]=Object.assign(n,s[e])}return t}),{})}(e))}const V="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,B=(()=>{function e(e){function t(){return Reflect.construct(e,arguments,new.target)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){const t=e((function(){this.a.call(this)}));t.prototype.a=function(){},new t}(),e}catch(e){return e=>class extends e{}}})();class R{constructor(e,t){this.application=e,this.definition=function(e){return{identifier:e.identifier,controllerConstructor:D(e.controllerConstructor)}}(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new j(this,e),this.contextsByScope.set(e,t)),t}}class q{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){const t=this.data.get(this.getDataKey(e))||"";return t.match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class H{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const n=this.getAttributeNameForKey(e);return this.element.setAttribute(n,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${d(e)}`}}class U{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,n){let s=this.warnedKeysByObject.get(e);s||(s=new Set,this.warnedKeysByObject.set(e,s)),s.has(t)||(s.add(t),this.logger.warn(n,e))}}function K(e,t){return`[${e}~="${t}"]`}class z{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findTarget(t)||this.findLegacyTarget(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllTargets(t),...this.findAllLegacyTargets(t)]),[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return K(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map((t=>this.deprecate(t,e)))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return K(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:n}=this,s=this.schema.targetAttribute,r=this.schema.targetAttributeForScope(n);this.guide.warn(e,`target:${t}`,`Please replace ${s}="${n}.${t}" with ${r}="${t}". The ${s} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class W{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findOutlet(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllOutlets(t)]),[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))}matchesElement(e,t,n){const s=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&s.split(" ").includes(n)}}class G{constructor(e,t,n,s){this.targets=new z(this),this.classes=new q(this),this.data=new H(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=n,this.guide=new U(s),this.outlets=new W(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return K(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new G(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class J{constructor(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new x(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:n}=e;return this.parseValueForElementAndIdentifier(t,n)}parseValueForElementAndIdentifier(e,t){const n=this.fetchScopesByIdentifierForElement(e);let s=n.get(t);return s||(s=this.delegate.createScopeForElementAndIdentifier(e,t),n.set(t,s)),s}elementMatchedValue(e,t){const n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class Q{constructor(e){this.application=e,this.scopeObserver=new J(this.element,this.schema,this),this.scopesByIdentifier=new S,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce(((e,t)=>e.concat(t.contexts)),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new R(this.application,e);this.connectModule(t);const n=e.controllerConstructor.afterLoad;n&&n.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find((t=>t.element==e))}proposeToConnectScopeForElementAndIdentifier(e,t){const n=this.scopeObserver.parseValueForElementAndIdentifier(e,t);n?this.scopeObserver.elementMatchedValue(n.element,n):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,n){this.application.handleError(e,t,n)}createScopeForElementAndIdentifier(e,t){return new G(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.connectContextForScope(t)))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.disconnectContextForScope(t)))}}const X={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:e=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},Y("abcdefghijklmnopqrstuvwxyz".split("").map((e=>[e,e])))),Y("0123456789".split("").map((e=>[e,e]))))};function Y(e){return e.reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:n})),{})}class Z{constructor(e=document.documentElement,t=X){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,n={})=>{this.debug&&this.logFormattedMessage(e,t,n)},this.element=e,this.schema=t,this.dispatcher=new r(this),this.router=new Q(this),this.actionDescriptorFilters=Object.assign({},i)}static start(e,t){const n=new this(e,t);return n.start(),n}async start(){await new Promise((e=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>e())):e()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>{e.controllerConstructor.shouldLoad&&this.router.loadDefinition(e)}))}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>this.router.unloadIdentifier(e)))}get controllers(){return this.router.contexts.map((e=>e.controller))}getControllerForElementAndIdentifier(e,t){const n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null}handleError(e,t,n){var s;this.logger.error("%s\n\n%o\n\n%o",t,e,n),null===(s=window.onerror)||void 0===s||s.call(window,t,"",0,0,e)}logFormattedMessage(e,t,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}function ee(e,t,n){return e.application.getControllerForElementAndIdentifier(t,n)}function te(e,t,n){let s=ee(e,t,n);return s||(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,n),s=ee(e,t,n),s||void 0)}function ne([e,t],n){return function(e){const{token:t,typeDefinition:n}=e,s=`${d(t)}-value`,r=function(e){const{controller:t,token:n,typeDefinition:s}=e,r={controller:t,token:n,typeObject:s},i=function(e){const{controller:t,token:n,typeObject:s}=e,r=h(s.type),i=h(s.default),o=r&&i,a=r&&!i,l=!r&&i,c=se(s.type),u=re(e.typeObject.default);if(a)return c;if(l)return u;if(c!==u){throw new Error(`The specified default value for the Stimulus Value "${t?`${t}.${n}`:n}" must match the defined type "${c}". The provided default value of "${s.default}" is of type "${u}".`)}if(o)return c}(r),o=re(s),a=se(s),l=i||o||a;if(l)return l;const c=t?`${t}.${s}`:n;throw new Error(`Unknown value type "${c}" for "${n}" value`)}(e);return{type:r,key:s,name:l(s),get defaultValue(){return function(e){const t=se(e);if(t)return ie[t];const n=p(e,"default"),s=p(e,"type"),r=e;if(n)return r.default;if(s){const{type:e}=r,t=se(e);if(t)return ie[t]}return e}(n)},get hasCustomDefaultValue(){return void 0!==re(n)},reader:oe[r],writer:ae[r]||ae.default}}({controller:n,token:e,typeDefinition:t})}function se(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function re(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(e)?"array":"[object Object]"===Object.prototype.toString.call(e)?"object":void 0}const ie={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},oe={array(e){const t=JSON.parse(e);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${re(t)}"`);return t},boolean:e=>!("0"==e||"false"==String(e).toLowerCase()),number:e=>Number(e.replace(/_/g,"")),object(e){const t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${re(t)}"`);return t},string:e=>e},ae={default:function(e){return`${e}`},array:le,object:le};function le(e){return JSON.stringify(e)}class ce{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:n={},prefix:s=this.identifier,bubbles:r=!0,cancelable:i=!0}={}){const o=new CustomEvent(s?`${s}:${e}`:e,{detail:n,bubbles:r,cancelable:i});return t.dispatchEvent(o),o}}ce.blessings=[function(e){return N(e,"classes").reduce(((e,t)=>{return Object.assign(e,(n=t,{[`${n}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${u(n)}Class`]:{get(){return this.classes.has(n)}}}));var n}),{})},function(e){return N(e,"targets").reduce(((e,t)=>{return Object.assign(e,(n=t,{[`${n}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${u(n)}Target`]:{get(){return this.targets.has(n)}}}));var n}),{})},function(e){const t=P(e,"values"),n={valueDescriptorMap:{get(){return t.reduce(((e,t)=>{const n=ne(t,this.identifier),s=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[s]:n})}),{})}}};return t.reduce(((e,t)=>Object.assign(e,function(e,t){const n=ne(e,t),{key:s,name:r,reader:i,writer:o}=n;return{[r]:{get(){const e=this.data.get(s);return null!==e?i(e):n.defaultValue},set(e){void 0===e?this.data.delete(s):this.data.set(s,o(e))}},[`has${u(r)}`]:{get(){return this.data.has(s)||n.hasCustomDefaultValue}}}}(t))),n)},function(e){return N(e,"outlets").reduce(((e,t)=>Object.assign(e,function(e){const t=c(e);return{[`${t}Outlet`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t){const n=te(this,t,e);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}Outlets`]:{get(){const t=this.outlets.findAll(e);return t.length>0?t.map((t=>{const n=te(this,t,e);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`,t)})).filter((e=>e)):[]}},[`${t}OutletElement`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t)return t;throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${u(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}(t))),{})}],ce.targets=[],ce.outlets=[],ce.values={}},500:(e,t,n)=>{"use strict";function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(){r=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},l=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function d(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(e){d=function(e,t,n){return e[t]=n}}function h(e,t,n,s){var r=t&&t.prototype instanceof y?t:y,i=Object.create(r.prototype),a=new I(s||[]);return o(i,"_invoke",{value:T(e,n,a)}),i}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=h;var m="suspendedStart",g="suspendedYield",f="executing",v="completed",b={};function y(){}function w(){}function O(){}var E={};d(E,l,(function(){return this}));var A=Object.getPrototypeOf,k=A&&A(A(N([])));k&&k!==n&&i.call(k,l)&&(E=k);var S=O.prototype=y.prototype=Object.create(E);function C(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function M(e,t){function n(r,o,a,l){var c=p(e[r],e,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==s(d)&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,l)}))}l(c.arg)}var r;o(this,"_invoke",{value:function(e,s){function i(){return new t((function(t,r){n(e,s,t,r)}))}return r=r?r.then(i,i):i()}})}function T(t,n,s){var r=m;return function(i,o){if(r===f)throw Error("Generator is already running");if(r===v){if("throw"===i)throw o;return{value:e,done:!0}}for(s.method=i,s.arg=o;;){var a=s.delegate;if(a){var l=x(a,s);if(l){if(l===b)continue;return l}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if(r===m)throw r=v,s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);r=f;var c=p(t,n,s);if("normal"===c.type){if(r=s.done?v:g,c.arg===b)continue;return{value:c.arg,done:s.done}}"throw"===c.type&&(r=v,s.method="throw",s.arg=c.arg)}}}function x(t,n){var s=n.method,r=t.iterator[s];if(r===e)return n.delegate=null,"throw"===s&&t.iterator.return&&(n.method="return",n.arg=e,x(t,n),"throw"===n.method)||"return"!==s&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+s+"' method")),b;var i=p(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,b;var o=i.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function N(t){if(t||""===t){var n=t[l];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function n(){for(;++r=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return s("end");if(o.tryLoc<=this.prev){var l=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(l&&c){if(this.prev=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),F(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var s=n.completion;if("throw"===s.type){var r=s.arg;F(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,s){return this.delegate={iterator:N(t),resultName:n,nextLoc:s},"next"===this.method&&(this.arg=e),b}},t}function i(e,t,n,s,r,i,o){try{var a=e[i](o),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function o(e,t){for(var n=0;np});var p=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),n=t,s=[{key:"connect",value:function(){this.pendingCopy=null,this.reset()}},{key:"copy",value:(c=r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.pendingCopy&&!this.buttonTarget.disabled&&this.hasValueValue&&""!==this.valueValue){e.next=2;break}return e.abrupt("return");case 2:return this.reset(),t={},this.pendingCopy=t,this.buttonTarget.setAttribute("aria-busy","true"),e.prev=6,e.next=9,navigator.clipboard.writeText(this.valueValue);case 9:this.pendingCopy===t&&this.showFeedback(this.successIconTarget,this.copiedLabelValue),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(6),this.pendingCopy===t&&this.showFeedback(this.errorIconTarget,this.errorLabelValue,!0);case 15:return e.prev=15,this.pendingCopy===t&&(this.pendingCopy=null,this.buttonTarget.removeAttribute("aria-busy")),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[6,12,15,18]])})),d=function(){var e=this,t=arguments;return new Promise((function(n,s){var r=c.apply(e,t);function o(e){i(r,n,s,o,a,"next",e)}function a(e){i(r,n,s,o,a,"throw",e)}o(void 0)}))},function(){return d.apply(this,arguments)})},{key:"disconnect",value:function(){this.pendingCopy=null,clearTimeout(this.resetTimer),this.hasButtonTarget&&this.buttonTarget.removeAttribute("aria-busy")}},{key:"showFeedback",value:function(e,t){var n=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.reset(),this.copyIconTarget.classList.add("d-none"),e.classList.remove("d-none"),this.statusTarget.classList.toggle("visually-hidden",!s),this.statusTarget.textContent=t,this.resetTimer=setTimeout((function(){return n.reset()}),2e3)}},{key:"reset",value:function(){clearTimeout(this.resetTimer),this.resetTimer=null,this.copyIconTarget.classList.remove("d-none"),this.successIconTarget.classList.add("d-none"),this.errorIconTarget.classList.add("d-none"),this.statusTarget.classList.add("visually-hidden"),this.statusTarget.textContent=""}}],s&&o(n.prototype,s),l&&o(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,s,l,c,d}(n(891).xI);d(p,"targets",["button","copyIcon","successIcon","errorIcon","status"]),d(p,"values",{value:String,copiedLabel:String,errorLabel:String})},431:(e,t,n)=>{"use strict";function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function r(e,t){for(var n=0;nu});var u=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),o(this,t,arguments)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(t,e),n=t,(s=[{key:"toggle",value:function(){var e="dark"===(document.documentElement.getAttribute("data-bs-theme")||"light")?"light":"dark";localStorage.setItem("sylius-theme",e),document.documentElement.setAttribute("data-bs-theme",e)}}])&&r(n.prototype,s),i&&r(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,s,i}(n(891).xI)},371:function(e){e.exports=function(){"use strict";function e(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class t{constructor(){this._events=void 0,this._events={}}on(t,n){e(t,(e=>{const t=this._events[e]||[];t.push(n),this._events[e]=t}))}off(t,n){var s=arguments.length;0!==s?e(t,(e=>{if(1===s)return void delete this._events[e];const t=this._events[e];void 0!==t&&(t.splice(t.indexOf(n),1),this._events[e]=t)})):this._events={}}trigger(t,...n){var s=this;e(t,(e=>{const t=s._events[e];void 0!==t&&t.forEach((e=>{e.apply(s,n)}))}))}}function n(e){return e.plugins={},class extends e{constructor(...e){super(...e),this.plugins={names:[],settings:{},requested:{},loaded:{}}}static define(t,n){e.plugins[t]={name:t,fn:n}}initializePlugins(e){var t,n;const s=this,r=[];if(Array.isArray(e))e.forEach((e=>{"string"==typeof e?r.push(e):(s.plugins.settings[e.name]=e.options,r.push(e.name))}));else if(e)for(t in e)e.hasOwnProperty(t)&&(s.plugins.settings[t]=e[t],r.push(t));for(;n=r.shift();)s.require(n)}loadPlugin(t){var n=this,s=n.plugins,r=e.plugins[t];if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin');s.requested[t]=!0,s.loaded[t]=r.fn.apply(n,[n.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,n=t.plugins;if(!t.plugins.loaded.hasOwnProperty(e)){if(n.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")');t.loadPlugin(e)}return n.loaded[e]}}}const s=e=>(e=e.filter(Boolean)).length<2?e[0]||"":1==l(e)?"["+e.join("")+"]":"(?:"+e.join("|")+")",r=e=>{if(!o(e))return e.join("");let t="",n=0;const s=()=>{n>1&&(t+="{"+n+"}")};return e.forEach(((r,i)=>{r!==e[i-1]?(s(),t+=r,n=1):n++})),s(),t},i=e=>{let t=u(e);return s(t)},o=e=>new Set(e).size!==e.length,a=e=>(e+"").replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu,"\\$1"),l=e=>e.reduce(((e,t)=>Math.max(e,c(t))),0),c=e=>u(e).length,u=e=>Array.from(e),d=e=>{if(1===e.length)return[[e]];let t=[];const n=e.substring(1);return d(n).forEach((function(n){let s=n.slice(0);s[0]=e.charAt(0)+s[0],t.push(s),s=n.slice(0),s.unshift(e.charAt(0)),t.push(s)})),t},h=[[0,65535]],p="[̀-ͯ·ʾʼ]";let m,g;const f=3,v={},b={"/":"⁄∕",0:"߀",a:"ⱥɐɑ",aa:"ꜳ",ae:"æǽǣ",ao:"ꜵ",au:"ꜷ",av:"ꜹꜻ",ay:"ꜽ",b:"ƀɓƃ",c:"ꜿƈȼↄ",d:"đɗɖᴅƌꮷԁɦ",e:"ɛǝᴇɇ",f:"ꝼƒ",g:"ǥɠꞡᵹꝿɢ",h:"ħⱨⱶɥ",i:"ɨı",j:"ɉȷ",k:"ƙⱪꝁꝃꝅꞣ",l:"łƚɫⱡꝉꝇꞁɭ",m:"ɱɯϻ",n:"ꞥƞɲꞑᴎлԉ",o:"øǿɔɵꝋꝍᴑ",oe:"œ",oi:"ƣ",oo:"ꝏ",ou:"ȣ",p:"ƥᵽꝑꝓꝕρ",q:"ꝗꝙɋ",r:"ɍɽꝛꞧꞃ",s:"ßȿꞩꞅʂ",t:"ŧƭʈⱦꞇ",th:"þ",tz:"ꜩ",u:"ʉ",v:"ʋꝟʌ",vy:"ꝡ",w:"ⱳ",y:"ƴɏỿ",z:"ƶȥɀⱬꝣ",hv:"ƕ"};for(let e in b){let t=b[e]||"";for(let n=0;n{void 0===m&&(m=C(e||h))},O=(e,t="NFKD")=>e.normalize(t),E=e=>u(e).reduce(((e,t)=>e+A(t)),""),A=e=>(e=O(e).toLowerCase().replace(y,(e=>v[e]||"")),O(e,"NFC"));function*k(e){for(const[t,n]of e)for(let e=t;e<=n;e++){let t=String.fromCharCode(e),n=E(t);n!=t.toLowerCase()&&(n.length>f||0!=n.length&&(yield{folded:n,composed:t,code_point:e}))}}const S=e=>{const t={},n=(e,n)=>{const s=t[e]||new Set,r=new RegExp("^"+i(s)+"$","iu");n.match(r)||(s.add(a(n)),t[e]=s)};for(let t of k(e))n(t.folded,t.folded),n(t.folded,t.composed);return t},C=e=>{const t=S(e),n={};let r=[];for(let e in t){let s=t[e];s&&(n[e]=i(s)),e.length>1&&r.push(a(e))}r.sort(((e,t)=>t.length-e.length));const o=s(r);return g=new RegExp("^"+o,"u"),n},M=(e,t=1)=>{let n=0;return e=e.map((e=>(m[e]&&(n+=e.length),m[e]||e))),n>=t?r(e):""},T=(e,t=1)=>(t=Math.max(t,e.length-1),s(d(e).map((e=>M(e,t))))),x=(e,t=!0)=>{let n=e.length>1?1:0;return s(e.map((e=>{let s=[];const i=t?e.length():e.length()-1;for(let t=0;t{for(const n of t){if(n.start!=e.start||n.end!=e.end)continue;if(n.substrs.join("")!==e.substrs.join(""))continue;let t=e.parts;const s=e=>{for(const n of t){if(n.start===e.start&&n.substr===e.substr)return!1;if(1!=e.length&&1!=n.length){if(e.startn.start)return!0;if(n.starte.start)return!0}}return!1};if(!(n.parts.filter(s).length>0))return!0}return!1};class F{constructor(){this.parts=[],this.substrs=[],this.start=0,this.end=0}add(e){e&&(this.parts.push(e),this.substrs.push(e.substr),this.start=Math.min(e.start,this.start),this.end=Math.max(e.end,this.end))}last(){return this.parts[this.parts.length-1]}length(){return this.parts.length}clone(e,t){let n=new F,s=JSON.parse(JSON.stringify(this.parts)),r=s.pop();for(const e of s)n.add(e);let i=t.substr.substring(0,e-r.start),o=i.length;return n.add({start:r.start,end:r.start+o,length:o,substr:i}),n}}const I=e=>{w(),e=E(e);let t="",n=[new F];for(let s=0;s0){a=a.sort(((e,t)=>e.length()-t.length()));for(let e of a)L(e,n)||n.push(e)}else if(s>0&&1==l.size&&!l.has("3")){t+=x(n,!1);let e=new F;const s=n[0];s&&e.add(s.last()),n=[e]}}return t+=x(n,!0),t},N=(e,t)=>{if(e)return e[t]},P=(e,t)=>{if(e){for(var n,s=t.split(".");(n=s.shift())&&(e=e[n]););return e}},_=(e,t,n)=>{var s,r;return e?(e+="",null==t.regex||-1===(r=e.search(t.regex))?0:(s=t.string.length/e.length,0===r&&(s+=.5),s*n)):0},$=(e,t)=>{var n=e[t];if("function"==typeof n)return n;n&&!Array.isArray(n)&&(e[t]=[n])},j=(e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)},D=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e(t=E(t+"").toLowerCase())?1:t>e?-1:0;class V{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,n){if(!e||!e.length)return[];const s=[],r=e.split(/\s+/);var i;return n&&(i=new RegExp("^("+Object.keys(n).map(a).join("|")+"):(.*)$")),r.forEach((e=>{let n,r=null,o=null;i&&(n=e.match(i))&&(r=n[1],e=n[2]),e.length>0&&(o=this.settings.diacritics?I(e)||null:a(e),o&&t&&(o="\\b"+o)),s.push({string:e,regex:o?new RegExp(o,"iu"):null,field:r})})),s}getScoreFunction(e,t){var n=this.prepareSearch(e,t);return this._getScoreFunction(n)}_getScoreFunction(e){const t=e.tokens,n=t.length;if(!n)return function(){return 0};const s=e.options.fields,r=e.weights,i=s.length,o=e.getAttrFn;if(!i)return function(){return 1};const a=1===i?function(e,t){const n=s[0].field;return _(o(t,n),e,r[n]||1)}:function(e,t){var n=0;if(e.field){const s=o(t,e.field);!e.regex&&s?n+=1/i:n+=_(s,e,1)}else j(r,((s,r)=>{n+=_(o(t,r),e,s)}));return n/i};return 1===n?function(e){return a(t[0],e)}:"and"===e.options.conjunction?function(e){var s,r=0;for(let n of t){if((s=a(n,e))<=0)return 0;r+=s}return r/n}:function(e){var s=0;return j(t,(t=>{s+=a(t,e)})),s/n}}getSortFunction(e,t){var n=this.prepareSearch(e,t);return this._getSortFunction(n)}_getSortFunction(e){var t,n=[];const s=this,r=e.options,i=!e.query&&r.sort_empty?r.sort_empty:r.sort;if("function"==typeof i)return i.bind(this);const o=function(t,n){return"$score"===t?n.score:e.getAttrFn(s.items[n.id],t)};if(i)for(let t of i)(e.query||"$score"!==t.field)&&n.push(t);if(e.query){t=!0;for(let e of n)if("$score"===e.field){t=!1;break}t&&n.unshift({field:"$score",direction:"desc"})}else n=n.filter((e=>"$score"!==e.field));return n.length?function(e,t){var s,r;for(let i of n)if(r=i.field,s=("desc"===i.direction?-1:1)*D(o(r,e),o(r,t)))return s;return 0}:null}prepareSearch(e,t){const n={};var s=Object.assign({},t);if($(s,"sort"),$(s,"sort_empty"),s.fields){$(s,"fields");const e=[];s.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),n[t.field]="weight"in t?t.weight:1})),s.fields=e}return{options:s,query:e.toLowerCase().trim(),tokens:this.tokenize(e,s.respect_word_boundaries,n),total:0,items:[],weights:n,getAttrFn:s.nesting?P:N}}search(e,t){var n,s,r=this;s=this.prepareSearch(e,t),t=s.options,e=s.query;const i=t.score||r._getScoreFunction(s);e.length?j(r.items,((e,r)=>{n=i(e),(!1===t.filter||n>0)&&s.items.push({score:n,id:r})})):j(r.items,((e,t)=>{s.items.push({score:1,id:t})}));const o=r._getSortFunction(s);return o&&s.items.sort(o),s.total=s.items.length,"number"==typeof t.limit&&(s.items=s.items.slice(0,t.limit)),s}}const B=(e,t)=>{if(Array.isArray(e))e.forEach(t);else for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)},R=e=>{if(e.jquery)return e[0];if(e instanceof HTMLElement)return e;if(q(e)){var t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstChild}return document.querySelector(e)},q=e=>"string"==typeof e&&e.indexOf("<")>-1,H=e=>e.replace(/['"\\]/g,"\\$&"),U=(e,t)=>{var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!1),e.dispatchEvent(n)},K=(e,t)=>{Object.assign(e.style,t)},z=(e,...t)=>{var n=G(t);(e=J(e)).map((e=>{n.map((t=>{e.classList.add(t)}))}))},W=(e,...t)=>{var n=G(t);(e=J(e)).map((e=>{n.map((t=>{e.classList.remove(t)}))}))},G=e=>{var t=[];return B(e,(e=>{"string"==typeof e&&(e=e.trim().split(/[\11\12\14\15\40]/)),Array.isArray(e)&&(t=t.concat(e))})),t.filter(Boolean)},J=e=>(Array.isArray(e)||(e=[e]),e),Q=(e,t,n)=>{if(!n||n.contains(e))for(;e&&e.matches;){if(e.matches(t))return e;e=e.parentNode}},X=(e,t=0)=>t>0?e[e.length-1]:e[0],Y=e=>0===Object.keys(e).length,Z=(e,t)=>{if(!e)return-1;t=t||e.nodeName;for(var n=0;e=e.previousElementSibling;)e.matches(t)&&n++;return n},ee=(e,t)=>{B(t,((t,n)=>{null==t?e.removeAttribute(n):e.setAttribute(n,""+t)}))},te=(e,t)=>{e.parentNode&&e.parentNode.replaceChild(t,e)},ne=(e,t)=>{if(null===t)return;if("string"==typeof t){if(!t.length)return;t=new RegExp(t,"i")}const n=e=>{var n=e.data.match(t);if(n&&e.data.length>0){var s=document.createElement("span");s.className="highlight";var r=e.splitText(n.index);r.splitText(n[0].length);var i=r.cloneNode(!0);return s.appendChild(i),te(r,s),1}return 0},s=e=>{1!==e.nodeType||!e.childNodes||/(script|style)/i.test(e.tagName)||"highlight"===e.className&&"SPAN"===e.tagName||Array.from(e.childNodes).forEach((e=>{r(e)}))},r=e=>3===e.nodeType?n(e):(s(e),0);r(e)},se=e=>{var t=e.querySelectorAll("span.highlight");Array.prototype.forEach.call(t,(function(e){var t=e.parentNode;t.replaceChild(e.firstChild,e),t.normalize()}))},re=65,ie=13,oe=27,ae=37,le=38,ce=39,ue=40,de=8,he=46,pe=9,me="undefined"!=typeof navigator&&/Mac/.test(navigator.userAgent)?"metaKey":"ctrlKey";var ge={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:null,createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,shouldOpen:null,maxOptions:50,maxItems:null,hideSelected:null,duplicates:!1,addPrecedence:!1,selectOnTab:!1,preload:null,allowEmptyOption:!1,refreshThrottle:300,loadThrottle:300,loadingClass:"loading",dataAttr:null,optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"ts-wrapper",controlClass:"ts-control",dropdownClass:"ts-dropdown",dropdownContentClass:"ts-dropdown-content",itemClass:"item",optionClass:"option",dropdownParent:null,controlInput:'',copyClassesToDropdown:!1,placeholder:null,hidePlaceholder:null,shouldLoad:function(e){return e.length>0},render:{}};const fe=e=>null==e?null:ve(e),ve=e=>"boolean"==typeof e?e?"1":"0":e+"",be=e=>(e+"").replace(/&/g,"&").replace(//g,">").replace(/"/g,"""),ye=(e,t)=>t>0?setTimeout(e,t):(e.call(null),null),we=(e,t)=>{var n;return function(s,r){var i=this;n&&(i.loading=Math.max(i.loading-1,0),clearTimeout(n)),n=setTimeout((function(){n=null,i.loadedSearches[s]=!0,e.call(i,s,r)}),t)}},Oe=(e,t,n)=>{var s,r=e.trigger,i={};for(s of(e.trigger=function(){var n=arguments[0];if(-1===t.indexOf(n))return r.apply(e,arguments);i[n]=arguments},n.apply(e,[]),e.trigger=r,t))s in i&&r.apply(e,i[s])},Ee=e=>({start:e.selectionStart||0,length:(e.selectionEnd||0)-(e.selectionStart||0)}),Ae=(e,t=!1)=>{e&&(e.preventDefault(),t&&e.stopPropagation())},ke=(e,t,n,s)=>{e.addEventListener(t,n,s)},Se=(e,t)=>!!t&&!!t[e]&&1==(t.altKey?1:0)+(t.ctrlKey?1:0)+(t.shiftKey?1:0)+(t.metaKey?1:0),Ce=(e,t)=>{const n=e.getAttribute("id");return n||(e.setAttribute("id",t),t)},Me=e=>e.replace(/[\\"']/g,"\\$&"),Te=(e,t)=>{t&&e.append(t)};function xe(e,t){var n=Object.assign({},ge,t),s=n.dataAttr,r=n.labelField,i=n.valueField,o=n.disabledField,a=n.optgroupField,l=n.optgroupLabelField,c=n.optgroupValueField,u=e.tagName.toLowerCase(),d=e.getAttribute("placeholder")||e.getAttribute("data-placeholder");if(!d&&!n.allowEmptyOption){let t=e.querySelector('option[value=""]');t&&(d=t.textContent)}var h={placeholder:d,options:[],optgroups:[],items:[],maxItems:null},p=()=>{const t=e.getAttribute(s);if(t)h.options=JSON.parse(t),B(h.options,(e=>{h.items.push(e[i])}));else{var o=e.value.trim()||"";if(!n.allowEmptyOption&&!o.length)return;const t=o.split(n.delimiter);B(t,(e=>{const t={};t[r]=e,t[i]=e,h.options.push(t)})),h.items=t}};return"select"===u?(()=>{var t,u=h.options,d={},p=1;let m=0;var g=e=>{var t=Object.assign({},e.dataset),n=s&&t[s];return"string"==typeof n&&n.length&&(t=Object.assign(t,JSON.parse(n))),t},f=(e,t)=>{var s=fe(e.value);if(null!=s&&(s||n.allowEmptyOption)){if(d.hasOwnProperty(s)){if(t){var l=d[s][a];l?Array.isArray(l)?l.push(t):d[s][a]=[l,t]:d[s][a]=t}}else{var c=g(e);c[r]=c[r]||e.textContent,c[i]=c[i]||s,c[o]=c[o]||e.disabled,c[a]=c[a]||t,c.$option=e,c.$order=c.$order||++m,d[s]=c,u.push(c)}e.selected&&h.items.push(s)}},v=e=>{var t,n;(n=g(e))[l]=n[l]||e.getAttribute("label")||"",n[c]=n[c]||p++,n[o]=n[o]||e.disabled,n.$order=n.$order||++m,h.optgroups.push(n),t=n[c],B(e.children,(e=>{f(e,t)}))};h.maxItems=e.hasAttribute("multiple")?null:1,B(e.children,(e=>{"optgroup"===(t=e.tagName.toLowerCase())?v(e):"option"===t&&f(e)}))})():p(),Object.assign({},ge,h,t)}var Le=0;class Fe extends(n(t)){constructor(e,t){var n;super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.focus_node=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.isOpen=!1,this.isDisabled=!1,this.isReadOnly=!1,this.isRequired=void 0,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.ignoreHover=!1,this.hasOptions=!1,this.currentResults=void 0,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],this.refreshTimeout=null,Le++;var s=R(e);if(s.tomselect)throw new Error("Tom Select already initialized on this element");s.tomselect=this,n=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction");const r=xe(s,t);this.settings=r,this.input=s,this.tabIndex=s.tabIndex||0,this.is_select_tag="select"===s.tagName.toLowerCase(),this.rtl=/rtl/i.test(n),this.inputId=Ce(s,"tomselect-"+Le),this.isRequired=s.required,this.sifter=new V(this.options,{diacritics:r.diacritics}),r.mode=r.mode||(1===r.maxItems?"single":"multi"),"boolean"!=typeof r.hideSelected&&(r.hideSelected="multi"===r.mode),"boolean"!=typeof r.hidePlaceholder&&(r.hidePlaceholder="multi"!==r.mode);var i=r.createFilter;"function"!=typeof i&&("string"==typeof i&&(i=new RegExp(i)),i instanceof RegExp?r.createFilter=e=>i.test(e):r.createFilter=e=>this.settings.duplicates||!this.options[e]),this.initializePlugins(r.plugins),this.setupCallbacks(),this.setupTemplates();const o=R("
"),a=R("
"),l=this._render("dropdown"),c=R('
'),u=this.input.getAttribute("class")||"",d=r.mode;var h;z(o,r.wrapperClass,u,d),z(a,r.controlClass),Te(o,a),z(l,r.dropdownClass,d),r.copyClassesToDropdown&&z(l,u),z(c,r.dropdownContentClass),Te(l,c),R(r.dropdownParent||o).appendChild(l),q(r.controlInput)?(h=R(r.controlInput),j(["autocorrect","autocapitalize","autocomplete","spellcheck"],(e=>{s.getAttribute(e)&&ee(h,{[e]:s.getAttribute(e)})})),h.tabIndex=-1,a.appendChild(h),this.focus_node=h):r.controlInput?(h=R(r.controlInput),this.focus_node=h):(h=R(""),this.focus_node=a),this.wrapper=o,this.dropdown=l,this.dropdown_content=c,this.control=a,this.control_input=h,this.setup()}setup(){const e=this,t=e.settings,n=e.control_input,s=e.dropdown,r=e.dropdown_content,i=e.wrapper,o=e.control,l=e.input,c=e.focus_node,u={passive:!0},d=e.inputId+"-ts-dropdown";ee(r,{id:d}),ee(c,{role:"combobox","aria-haspopup":"listbox","aria-expanded":"false","aria-controls":d});const h=Ce(c,e.inputId+"-ts-control"),p="label[for='"+H(e.inputId)+"']",m=document.querySelector(p),g=e.focus.bind(e);if(m){ke(m,"click",g),ee(m,{for:h});const t=Ce(m,e.inputId+"-ts-label");ee(c,{"aria-labelledby":t}),ee(r,{"aria-labelledby":t})}if(i.style.width=l.style.width,e.plugins.names.length){const t="plugin-"+e.plugins.names.join(" plugin-");z([i,s],t)}(null===t.maxItems||t.maxItems>1)&&e.is_select_tag&&ee(l,{multiple:"multiple"}),t.placeholder&&ee(n,{placeholder:t.placeholder}),!t.splitOn&&t.delimiter&&(t.splitOn=new RegExp("\\s*"+a(t.delimiter)+"+\\s*")),t.load&&t.loadThrottle&&(t.load=we(t.load,t.loadThrottle)),ke(s,"mousemove",(()=>{e.ignoreHover=!1})),ke(s,"mouseenter",(t=>{var n=Q(t.target,"[data-selectable]",s);n&&e.onOptionHover(t,n)}),{capture:!0}),ke(s,"click",(t=>{const n=Q(t.target,"[data-selectable]");n&&(e.onOptionSelect(t,n),Ae(t,!0))})),ke(o,"click",(t=>{var s=Q(t.target,"[data-ts-item]",o);s&&e.onItemSelect(t,s)?Ae(t,!0):""==n.value&&(e.onClick(),Ae(t,!0))})),ke(c,"keydown",(t=>e.onKeyDown(t))),ke(n,"keypress",(t=>e.onKeyPress(t))),ke(n,"input",(t=>e.onInput(t))),ke(c,"blur",(t=>e.onBlur(t))),ke(c,"focus",(t=>e.onFocus(t))),ke(n,"paste",(t=>e.onPaste(t)));const f=t=>{const r=t.composedPath()[0];if(!i.contains(r)&&!s.contains(r))return e.isFocused&&e.blur(),void e.inputState();r==n&&e.isOpen?t.stopPropagation():Ae(t,!0)},v=()=>{e.isOpen&&e.positionDropdown()};ke(document,"mousedown",f),ke(window,"scroll",v,u),ke(window,"resize",v,u),this._destroy=()=>{document.removeEventListener("mousedown",f),window.removeEventListener("scroll",v),window.removeEventListener("resize",v),m&&m.removeEventListener("click",g)},this.revertSettings={innerHTML:l.innerHTML,tabIndex:l.tabIndex},l.tabIndex=-1,l.insertAdjacentElement("afterend",e.wrapper),e.sync(!1),t.items=[],delete t.optgroups,delete t.options,ke(l,"invalid",(()=>{e.isValid&&(e.isValid=!1,e.isInvalid=!0,e.refreshState())})),e.updateOriginalInput(),e.refreshItems(),e.close(!1),e.inputState(),e.isSetup=!0,l.disabled?e.disable():l.readOnly?e.setReadOnly(!0):e.enable(),e.on("change",this.onChange),z(l,"tomselected","ts-hidden-accessible"),e.trigger("initialize"),!0===t.preload&&e.preload()}setupOptions(e=[],t=[]){this.addOptions(e),j(t,(e=>{this.registerOptionGroup(e)}))}setupTemplates(){var e=this,t=e.settings.labelField,n=e.settings.optgroupLabelField,s={optgroup:e=>{let t=document.createElement("div");return t.className="optgroup",t.appendChild(e.options),t},optgroup_header:(e,t)=>'
'+t(e[n])+"
",option:(e,n)=>"
"+n(e[t])+"
",item:(e,n)=>"
"+n(e[t])+"
",option_create:(e,t)=>'
Add '+t(e.input)+"…
",no_results:()=>'
No results found
',loading:()=>'
',not_loading:()=>{},dropdown:()=>"
"};e.settings.render=Object.assign({},s,e.settings.render)}setupCallbacks(){var e,t,n={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",item_select:"onItemSelect",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(e in n)(t=this.settings[n[e]])&&this.on(e,t)}sync(e=!0){const t=this,n=e?xe(t.input,{delimiter:t.settings.delimiter}):t.settings;t.setupOptions(n.options,n.optgroups),t.setValue(n.items||[],!0),t.lastQuery=null}onClick(){var e=this;if(e.activeItems.length>0)return e.clearActiveItems(),void e.focus();e.isFocused&&e.isOpen?e.blur():e.focus()}onMouseDown(){}onChange(){U(this.input,"input"),U(this.input,"change")}onPaste(e){var t=this;t.isInputHidden||t.isLocked?Ae(e):t.settings.splitOn&&setTimeout((()=>{var e=t.inputValue();if(e.match(t.settings.splitOn)){var n=e.trim().split(t.settings.splitOn);j(n,(e=>{fe(e)&&(this.options[e]?t.addItem(e):t.createItem(e))}))}}),0)}onKeyPress(e){var t=this;if(!t.isLocked){var n=String.fromCharCode(e.keyCode||e.which);return t.settings.create&&"multi"===t.settings.mode&&n===t.settings.delimiter?(t.createItem(),void Ae(e)):void 0}Ae(e)}onKeyDown(e){var t=this;if(t.ignoreHover=!0,t.isLocked)e.keyCode!==pe&&Ae(e);else{switch(e.keyCode){case re:if(Se(me,e)&&""==t.control_input.value)return Ae(e),void t.selectAll();break;case oe:return t.isOpen&&(Ae(e,!0),t.close()),void t.clearActiveItems();case ue:if(!t.isOpen&&t.hasOptions)t.open();else if(t.activeOption){let e=t.getAdjacent(t.activeOption,1);e&&t.setActiveOption(e)}return void Ae(e);case le:if(t.activeOption){let e=t.getAdjacent(t.activeOption,-1);e&&t.setActiveOption(e)}return void Ae(e);case ie:return void(t.canSelect(t.activeOption)?(t.onOptionSelect(e,t.activeOption),Ae(e)):(t.settings.create&&t.createItem()||document.activeElement==t.control_input&&t.isOpen)&&Ae(e));case ae:return void t.advanceSelection(-1,e);case ce:return void t.advanceSelection(1,e);case pe:return void(t.settings.selectOnTab&&(t.canSelect(t.activeOption)&&(t.onOptionSelect(e,t.activeOption),Ae(e)),t.settings.create&&t.createItem()&&Ae(e)));case de:case he:return void t.deleteSelection(e)}t.isInputHidden&&!Se(me,e)&&Ae(e)}}onInput(e){if(this.isLocked)return;const t=this.inputValue();this.lastValue!==t&&(this.lastValue=t,""!=t?(this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=ye((()=>{this.refreshTimeout=null,this._onInput()}),this.settings.refreshThrottle)):this._onInput())}_onInput(){const e=this.lastValue;this.settings.shouldLoad.call(this,e)&&this.load(e),this.refreshOptions(),this.trigger("type",e)}onOptionHover(e,t){this.ignoreHover||this.setActiveOption(t,!1)}onFocus(e){var t=this,n=t.isFocused;if(t.isDisabled||t.isReadOnly)return t.blur(),void Ae(e);t.ignoreFocus||(t.isFocused=!0,"focus"===t.settings.preload&&t.preload(),n||t.trigger("focus"),t.activeItems.length||(t.inputState(),t.refreshOptions(!!t.settings.openOnFocus)),t.refreshState())}onBlur(e){if(!1!==document.hasFocus()){var t=this;if(t.isFocused){t.isFocused=!1,t.ignoreFocus=!1;var n=()=>{t.close(),t.setActiveItem(),t.setCaret(t.items.length),t.trigger("blur")};t.settings.create&&t.settings.createOnBlur?t.createItem(null,n):n()}}}onOptionSelect(e,t){var n,s=this;t.parentElement&&t.parentElement.matches("[data-disabled]")||(t.classList.contains("create")?s.createItem(null,(()=>{s.settings.closeAfterSelect&&s.close()})):void 0!==(n=t.dataset.value)&&(s.lastQuery=null,s.addItem(n),s.settings.closeAfterSelect&&s.close(),!s.settings.hideSelected&&e.type&&/click/.test(e.type)&&s.setActiveOption(t)))}canSelect(e){return!!(this.isOpen&&e&&this.dropdown_content.contains(e))}onItemSelect(e,t){var n=this;return!n.isLocked&&"multi"===n.settings.mode&&(Ae(e),n.setActiveItem(t,e),!0)}canLoad(e){return!!this.settings.load&&!this.loadedSearches.hasOwnProperty(e)}load(e){const t=this;if(!t.canLoad(e))return;z(t.wrapper,t.settings.loadingClass),t.loading++;const n=t.loadCallback.bind(t);t.settings.load.call(t,e,n)}loadCallback(e,t){const n=this;n.loading=Math.max(n.loading-1,0),n.lastQuery=null,n.clearActiveOption(),n.setupOptions(e,t),n.refreshOptions(n.isFocused&&!n.isInputHidden),n.loading||W(n.wrapper,n.settings.loadingClass),n.trigger("load",e,t)}preload(){var e=this.wrapper.classList;e.contains("preloaded")||(e.add("preloaded"),this.load(""))}setTextboxValue(e=""){var t=this.control_input;t.value!==e&&(t.value=e,U(t,"update"),this.lastValue=e)}getValue(){return this.is_select_tag&&this.input.hasAttribute("multiple")?this.items:this.items.join(this.settings.delimiter)}setValue(e,t){Oe(this,t?[]:["change"],(()=>{this.clear(t),this.addItems(e,t)}))}setMaxItems(e){0===e&&(e=null),this.settings.maxItems=e,this.refreshState()}setActiveItem(e,t){var n,s,r,i,o,a,l=this;if("single"!==l.settings.mode){if(!e)return l.clearActiveItems(),void(l.isFocused&&l.inputState());if("click"===(n=t&&t.type.toLowerCase())&&Se("shiftKey",t)&&l.activeItems.length){for(a=l.getLastActive(),(r=Array.prototype.indexOf.call(l.control.children,a))>(i=Array.prototype.indexOf.call(l.control.children,e))&&(o=r,r=i,i=o),s=r;s<=i;s++)e=l.control.children[s],-1===l.activeItems.indexOf(e)&&l.setActiveItemClass(e);Ae(t)}else"click"===n&&Se(me,t)||"keydown"===n&&Se("shiftKey",t)?e.classList.contains("active")?l.removeActiveItem(e):l.setActiveItemClass(e):(l.clearActiveItems(),l.setActiveItemClass(e));l.inputState(),l.isFocused||l.focus()}}setActiveItemClass(e){const t=this,n=t.control.querySelector(".last-active");n&&W(n,"last-active"),z(e,"active last-active"),t.trigger("item_select",e),-1==t.activeItems.indexOf(e)&&t.activeItems.push(e)}removeActiveItem(e){var t=this.activeItems.indexOf(e);this.activeItems.splice(t,1),W(e,"active")}clearActiveItems(){W(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e,t=!0){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,ee(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),ee(e,{"aria-selected":"true"}),z(e,"active"),t&&this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return;const n=this.dropdown_content,s=n.clientHeight,r=n.scrollTop||0,i=e.offsetHeight,o=e.getBoundingClientRect().top-n.getBoundingClientRect().top+r;o+i>s+r?this.scroll(o-s+i,t):o{e.setActiveItemClass(t)})))}inputState(){var e=this;e.control.contains(e.control_input)&&(ee(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&ee(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}inputValue(){return this.control_input.value.trim()}focus(){var e=this;e.isDisabled||e.isReadOnly||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField;return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,n,s=this,r=this.getSearchOptions();if(s.settings.score&&"function"!=typeof(n=s.settings.score.call(s,e)))throw new Error('Tom Select "score" setting must be a function that returns a function');return e!==s.lastQuery?(s.lastQuery=e,t=s.sifter.search(e,Object.assign(r,{score:n})),s.currentResults=t):t=Object.assign({},s.currentResults),s.settings.hideSelected&&(t.items=t.items.filter((e=>{let t=fe(e.id);return!(t&&-1!==s.items.indexOf(t))}))),t}refreshOptions(e=!0){var t,n,s,r,i,o,a,l,c,u;const d={},h=[];var p=this,m=p.inputValue();const g=m===p.lastQuery||""==m&&null==p.lastQuery;var f=p.search(m),v=null,b=p.settings.shouldOpen||!1,y=p.dropdown_content;g&&(v=p.activeOption)&&(c=v.closest("[data-group]")),r=f.items.length,"number"==typeof p.settings.maxOptions&&(r=Math.min(r,p.settings.maxOptions)),r>0&&(b=!0);const w=(e,t)=>{let n=d[e];if(void 0!==n){let e=h[n];if(void 0!==e)return[n,e.fragment]}let s=document.createDocumentFragment();return n=h.length,h.push({fragment:s,order:t,optgroup:e}),[n,s]};for(t=0;t0&&(u=u.cloneNode(!0),ee(u,{id:a.$id+"-clone-"+n,"aria-selected":null}),u.classList.add("ts-cloned"),W(u,"active"),p.activeOption&&p.activeOption.dataset.value==r&&c&&c.dataset.group===i.toString()&&(v=u)),l.appendChild(u),""!=i&&(d[i]=s)}}p.settings.lockOptgroupOrder&&h.sort(((e,t)=>e.order-t.order)),a=document.createDocumentFragment(),j(h,(e=>{let t=e.fragment,n=e.optgroup;if(!t||!t.children.length)return;let s=p.optgroups[n];if(void 0!==s){let e=document.createDocumentFragment(),n=p.render("optgroup_header",s);Te(e,n),Te(e,t);let r=p.render("optgroup",{group:s,options:e});Te(a,r)}else Te(a,t)})),y.innerHTML="",Te(y,a),p.settings.highlight&&(se(y),f.query.length&&f.tokens.length&&j(f.tokens,(e=>{ne(y,e.regex)})));var O=e=>{let t=p.render(e,{input:m});return t&&(b=!0,y.insertBefore(t,y.firstChild)),t};if(p.loading?O("loading"):p.settings.shouldLoad.call(p,m)?0===f.items.length&&O("no_results"):O("not_loading"),(l=p.canCreate(m))&&(u=O("option_create")),p.hasOptions=f.items.length>0||l,b){if(f.items.length>0){if(v||"single"!==p.settings.mode||null==p.items[0]||(v=p.getOption(p.items[0])),!y.contains(v)){let e=0;u&&!p.settings.addPrecedence&&(e=1),v=p.selectable()[e]}}else u&&(v=u);e&&!p.isOpen&&(p.open(),p.scrollToOption(v,"auto")),p.setActiveOption(v)}else p.clearActiveOption(),e&&p.isOpen&&p.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const n=this;if(Array.isArray(e))return n.addOptions(e,t),!1;const s=fe(e[n.settings.valueField]);return null!==s&&!n.options.hasOwnProperty(s)&&(e.$order=e.$order||++n.order,e.$id=n.inputId+"-opt-"+e.$order,n.options[s]=e,n.lastQuery=null,t&&(n.userOptions[s]=t,n.trigger("option_add",s,e)),s)}addOptions(e,t=!1){j(e,(e=>{this.addOption(e,t)}))}registerOption(e){return this.addOption(e)}registerOptionGroup(e){var t=fe(e[this.settings.optgroupValueField]);return null!==t&&(e.$order=e.$order||++this.order,this.optgroups[t]=e,t)}addOptionGroup(e,t){var n;t[this.settings.optgroupValueField]=e,(n=this.registerOptionGroup(t))&&this.trigger("optgroup_add",n,t)}removeOptionGroup(e){this.optgroups.hasOwnProperty(e)&&(delete this.optgroups[e],this.clearCache(),this.trigger("optgroup_remove",e))}clearOptionGroups(){this.optgroups={},this.clearCache(),this.trigger("optgroup_clear")}updateOption(e,t){const n=this;var s,r;const i=fe(e),o=fe(t[n.settings.valueField]);if(null===i)return;const a=n.options[i];if(null==a)return;if("string"!=typeof o)throw new Error("Value must be set in option data");const l=n.getOption(i),c=n.getItem(i);if(t.$order=t.$order||a.$order,delete n.options[i],n.uncacheValue(o),n.options[o]=t,l){if(n.dropdown_content.contains(l)){const e=n._render("option",t);te(l,e),n.activeOption===l&&n.setActiveOption(e)}l.remove()}c&&(-1!==(r=n.items.indexOf(i))&&n.items.splice(r,1,o),s=n._render("item",t),c.classList.contains("active")&&z(s,"active"),te(c,s)),n.lastQuery=null}removeOption(e,t){const n=this;e=ve(e),n.uncacheValue(e),delete n.userOptions[e],delete n.options[e],n.lastQuery=null,n.trigger("option_remove",e),n.removeItem(e,t)}clearOptions(e){const t=(e||this.clearFilter).bind(this);this.loadedSearches={},this.userOptions={},this.clearCache();const n={};j(this.options,((e,s)=>{t(e,s)&&(n[s]=e)})),this.options=this.sifter.items=n,this.lastQuery=null,this.trigger("option_clear")}clearFilter(e,t){return this.items.indexOf(t)>=0}getOption(e,t=!1){const n=fe(e);if(null===n)return null;const s=this.options[n];if(null!=s){if(s.$div)return s.$div;if(t)return this._render("option",s)}return null}getAdjacent(e,t,n="option"){var s,r=this;if(!e)return null;s="item"==n?r.controlChildren():r.dropdown_content.querySelectorAll("[data-selectable]");for(let n=0;n0?s[n+1]:s[n-1];return null}getItem(e){if("object"==typeof e)return e;var t=fe(e);return null!==t?this.control.querySelector(`[data-value="${Me(t)}"]`):null}addItems(e,t){var n=this,s=Array.isArray(e)?e:[e];const r=(s=s.filter((e=>-1===n.items.indexOf(e))))[s.length-1];s.forEach((e=>{n.isPending=e!==r,n.addItem(e,t)}))}addItem(e,t){Oe(this,t?[]:["change","dropdown_close"],(()=>{var n,s;const r=this,i=r.settings.mode,o=fe(e);if((!o||-1===r.items.indexOf(o)||("single"===i&&r.close(),"single"!==i&&r.settings.duplicates))&&null!==o&&r.options.hasOwnProperty(o)&&("single"===i&&r.clear(t),"multi"!==i||!r.isFull())){if(n=r._render("item",r.options[o]),r.control.contains(n)&&(n=n.cloneNode(!0)),s=r.isFull(),r.items.splice(r.caretPos,0,o),r.insertAtCaret(n),r.isSetup){if(!r.isPending&&r.settings.hideSelected){let e=r.getOption(o),t=r.getAdjacent(e,1);t&&r.setActiveOption(t)}r.isPending||r.settings.closeAfterSelect||r.refreshOptions(r.isFocused&&"single"!==i),0!=r.settings.closeAfterSelect&&r.isFull()?r.close():r.isPending||r.positionDropdown(),r.trigger("item_add",o,n),r.isPending||r.updateOriginalInput({silent:t})}(!r.isPending||!s&&r.isFull())&&(r.inputState(),r.refreshState())}}))}removeItem(e=null,t){const n=this;if(!(e=n.getItem(e)))return;var s,r;const i=e.dataset.value;s=Z(e),e.remove(),e.classList.contains("active")&&(r=n.activeItems.indexOf(e),n.activeItems.splice(r,1),W(e,"active")),n.items.splice(s,1),n.lastQuery=null,!n.settings.persist&&n.userOptions.hasOwnProperty(i)&&n.removeOption(i,t),s{}){3===arguments.length&&(t=arguments[2]),"function"!=typeof t&&(t=()=>{});var n,s=this,r=s.caretPos;if(e=e||s.inputValue(),!s.canCreate(e))return t(),!1;s.lock();var i=!1,o=e=>{if(s.unlock(),!e||"object"!=typeof e)return t();var n=fe(e[s.settings.valueField]);if("string"!=typeof n)return t();s.setTextboxValue(),s.addOption(e,!0),s.setCaret(r),s.addItem(n),t(e),i=!0};return n="function"==typeof s.settings.create?s.settings.create.call(this,e,o):{[s.settings.labelField]:e,[s.settings.valueField]:e},i||o(n),!0}refreshItems(){var e=this;e.lastQuery=null,e.isSetup&&e.addItems(e.items),e.updateOriginalInput(),e.refreshState()}refreshState(){const e=this;e.refreshValidityState();const t=e.isFull(),n=e.isLocked;e.wrapper.classList.toggle("rtl",e.rtl);const s=e.wrapper.classList;s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("readonly",e.isReadOnly),s.toggle("required",e.isRequired),s.toggle("invalid",!e.isValid),s.toggle("locked",n),s.toggle("full",t),s.toggle("input-active",e.isFocused&&!e.isInputHidden),s.toggle("dropdown-active",e.isOpen),s.toggle("has-options",Y(e.options)),s.toggle("has-items",e.items.length>0)}refreshValidityState(){var e=this;e.input.validity&&(e.isValid=e.input.validity.valid,e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this;var n,s;const r=t.input.querySelector('option[value=""]');if(t.is_select_tag){const i=[],o=t.input.querySelectorAll("option:checked").length;function a(e,n,s){return e||(e=R('")),e!=r&&t.input.append(e),i.push(e),(e!=r||o>0)&&(e.selected=!0),e}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?a(r,"",""):t.items.forEach((e=>{n=t.options[e],s=n[t.settings.labelField]||"",i.includes(n.$option)?a(t.input.querySelector(`option[value="${Me(e)}"]:not(:checked)`),e,s):n.$option=a(n.$option,e,s)}))}else t.input.value=t.getValue();t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this;e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,ee(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),K(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),K(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,n=t.isOpen;e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.inputState()),t.isOpen=!1,ee(t.focus_node,{"aria-expanded":"false"}),K(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),n&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),n=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX;K(this.dropdown,{width:t.width+"px",top:n+"px",left:s+"px"})}}clear(e){var t=this;if(t.items.length){var n=t.controlChildren();j(n,(e=>{t.removeItem(e,!0)})),t.inputState(),e||t.updateOriginalInput(),t.trigger("clear")}}insertAtCaret(e){const t=this,n=t.caretPos,s=t.control;s.insertBefore(e,s.children[n]||null),t.setCaret(n+1)}deleteSelection(e){var t,n,s,r,i=this;t=e&&e.keyCode===de?-1:1,n=Ee(i.control_input);const o=[];if(i.activeItems.length)r=X(i.activeItems,t),s=Z(r),t>0&&s++,j(i.activeItems,(e=>o.push(e)));else if((i.isFocused||"single"===i.settings.mode)&&i.items.length){const e=i.controlChildren();let s;t<0&&0===n.start&&0===n.length?s=e[i.caretPos-1]:t>0&&n.start===i.inputValue().length&&(s=e[i.caretPos]),void 0!==s&&o.push(s)}if(!i.shouldDelete(o,e))return!1;for(Ae(e,!0),void 0!==s&&i.setCaret(s);o.length;)i.removeItem(o.pop());return i.inputState(),i.positionDropdown(),i.refreshOptions(!1),!0}shouldDelete(e,t){const n=e.map((e=>e.dataset.value));return!(!n.length||"function"==typeof this.settings.onDelete&&!1===this.settings.onDelete(n,t))}advanceSelection(e,t){var n,s,r=this;r.rtl&&(e*=-1),r.inputValue().length||(Se(me,t)||Se("shiftKey",t)?(s=(n=r.getLastActive(e))?n.classList.contains("active")?r.getAdjacent(n,e,"item"):n:e>0?r.control_input.nextElementSibling:r.control_input.previousElementSibling)&&(s.classList.contains("active")&&r.removeActiveItem(n),r.setActiveItemClass(s)):r.moveCaret(e))}moveCaret(e){}getLastActive(e){let t=this.control.querySelector(".last-active");if(t)return t;var n=this.control.querySelectorAll(".active");return n?X(n,e):void 0}setCaret(e){this.caretPos=this.items.length}controlChildren(){return Array.from(this.control.querySelectorAll("[data-ts-item]"))}lock(){this.setLocked(!0)}unlock(){this.setLocked(!1)}setLocked(e=this.isReadOnly||this.isDisabled){this.isLocked=e,this.refreshState()}disable(){this.setDisabled(!0),this.close()}enable(){this.setDisabled(!1)}setDisabled(e){this.focus_node.tabIndex=e?-1:this.tabIndex,this.isDisabled=e,this.input.disabled=e,this.control_input.disabled=e,this.setLocked()}setReadOnly(e){this.isReadOnly=e,this.input.readOnly=e,this.control_input.readOnly=e,this.setLocked()}destroy(){var e=this,t=e.revertSettings;e.trigger("destroy"),e.off(),e.wrapper.remove(),e.dropdown.remove(),e.input.innerHTML=t.innerHTML,e.input.tabIndex=t.tabIndex,W(e.input,"tomselected","ts-hidden-accessible"),e._destroy(),delete e.input.tomselect}render(e,t){var n,s;const r=this;if("function"!=typeof this.settings.render[e])return null;if(!(s=r.settings.render[e].call(this,t,be)))return null;if(s=R(s),"option"===e||"option_create"===e?t[r.settings.disabledField]?ee(s,{"aria-disabled":"true"}):ee(s,{"data-selectable":""}):"optgroup"===e&&(n=t.group[r.settings.optgroupValueField],ee(s,{"data-group":n}),t.group[r.settings.disabledField]&&ee(s,{"data-disabled":""})),"option"===e||"item"===e){const n=ve(t[r.settings.valueField]);ee(s,{"data-value":n}),"item"===e?(z(s,r.settings.itemClass),ee(s,{"data-ts-item":""})):(z(s,r.settings.optionClass),ee(s,{role:"option",id:t.$id}),t.$div=s,r.options[n]=t)}return s}_render(e,t){const n=this.render(e,t);if(null==n)throw"HTMLElement expected";return n}clearCache(){j(this.options,(e=>{e.$div&&(e.$div.remove(),delete e.$div)}))}uncacheValue(e){const t=this.getOption(e);t&&t.remove()}canCreate(e){return this.settings.create&&e.length>0&&this.settings.createFilter.call(this,e)}hook(e,t,n){var s=this,r=s[t];s[t]=function(){var t,i;return"after"===e&&(t=r.apply(s,arguments)),i=n.apply(s,arguments),"instead"===e?i:("before"===e&&(t=r.apply(s,arguments)),t)}}}function Ie(){ke(this.input,"change",(()=>{this.sync()}))}function Ne(e){var t=this,n=t.onOptionSelect;t.settings.hideSelected=!1;const s=Object.assign({className:"tomselect-checkbox",checkedClassNames:void 0,uncheckedClassNames:void 0},e);var r=function(e,t){t?(e.checked=!0,s.uncheckedClassNames&&e.classList.remove(...s.uncheckedClassNames),s.checkedClassNames&&e.classList.add(...s.checkedClassNames)):(e.checked=!1,s.checkedClassNames&&e.classList.remove(...s.checkedClassNames),s.uncheckedClassNames&&e.classList.add(...s.uncheckedClassNames))},i=function(e){setTimeout((()=>{var t=e.querySelector("input."+s.className);t instanceof HTMLInputElement&&r(t,e.classList.contains("selected"))}),1)};t.hook("after","setupTemplates",(()=>{var e=t.settings.render.option;t.settings.render.option=(n,i)=>{var o=R(e.call(t,n,i)),a=document.createElement("input");s.className&&a.classList.add(s.className),a.addEventListener("click",(function(e){Ae(e)})),a.type="checkbox";const l=fe(n[t.settings.valueField]);return r(a,!!(l&&t.items.indexOf(l)>-1)),o.prepend(a),o}})),t.on("item_remove",(e=>{var n=t.getOption(e);n&&(n.classList.remove("selected"),i(n))})),t.on("item_add",(e=>{var n=t.getOption(e);n&&i(n)})),t.hook("instead","onOptionSelect",((e,s)=>{if(s.classList.contains("selected"))return s.classList.remove("selected"),t.removeItem(s.dataset.value),t.refreshOptions(),void Ae(e,!0);n.call(t,e,s),i(s)}))}function Pe(e){const t=this,n=Object.assign({className:"clear-button",title:"Clear All",html:e=>`
⨯
`},e);t.on("initialize",(()=>{var e=R(n.html(n));e.addEventListener("click",(e=>{t.isLocked||(t.clear(),"single"===t.settings.mode&&t.settings.allowEmptyOption&&t.addItem(""),e.preventDefault(),e.stopPropagation())})),t.control.appendChild(e)}))}const _e=(e,t)=>{var n;null==(n=e.parentNode)||n.insertBefore(t,e.nextSibling)},$e=(e,t)=>{var n;null==(n=e.parentNode)||n.insertBefore(t,e)},je=(e,t)=>{do{var n;if(e==(t=null==(n=t)?void 0:n.previousElementSibling))return!0}while(t&&t.previousElementSibling);return!1};function De(){var e=this;if("multi"!==e.settings.mode)return;var t=e.lock,n=e.unlock;let s,r=!0;e.hook("after","setupTemplates",(()=>{var t=e.settings.render.item;e.settings.render.item=(n,i)=>{const o=R(t.call(e,n,i));ee(o,{draggable:"true"});const a=e=>{s=o,setTimeout((()=>{o.classList.add("ts-dragging")}),0)},l=e=>{e.preventDefault(),o.classList.add("ts-drag-over"),u(o,s)},c=()=>{o.classList.remove("ts-drag-over")},u=(e,t)=>{void 0!==t&&(je(t,o)?_e(e,t):$e(e,t))},d=()=>{var t;document.querySelectorAll(".ts-drag-over").forEach((e=>e.classList.remove("ts-drag-over"))),null==(t=s)||t.classList.remove("ts-dragging"),s=void 0;var n=[];e.control.querySelectorAll("[data-value]").forEach((e=>{if(e.dataset.value){let t=e.dataset.value;t&&n.push(t)}})),e.setValue(n)};return ke(o,"mousedown",(e=>{r||Ae(e),e.stopPropagation()})),ke(o,"dragstart",a),ke(o,"dragenter",l),ke(o,"dragover",l),ke(o,"dragleave",c),ke(o,"dragend",d),o}})),e.hook("instead","lock",(()=>(r=!1,t.call(e)))),e.hook("instead","unlock",(()=>(r=!0,n.call(e))))}function Ve(e){const t=this,n=Object.assign({title:"Untitled",headerClass:"dropdown-header",titleRowClass:"dropdown-header-title",labelClass:"dropdown-header-label",closeClass:"dropdown-header-close",html:e=>'
'+e.title+'×
'},e);t.on("initialize",(()=>{var e=R(n.html(n)),s=e.querySelector("."+n.closeClass);s&&s.addEventListener("click",(e=>{Ae(e,!0),t.close()})),t.dropdown.insertBefore(e,t.dropdown.firstChild)}))}function Be(){var e=this;e.hook("instead","setCaret",(t=>{"single"!==e.settings.mode&&e.control.contains(e.control_input)?(t=Math.max(0,Math.min(e.items.length,t)))==e.caretPos||e.isPending||e.controlChildren().forEach(((n,s)=>{s{if(!e.isFocused)return;const n=e.getLastActive(t);if(n){const s=Z(n);e.setCaret(t>0?s+1:s),e.setActiveItem(),W(n,"last-active")}else e.setCaret(e.caretPos+t)}))}function Re(){const e=this;e.settings.shouldOpen=!0,e.hook("before","setup",(()=>{e.focus_node=e.control,z(e.control_input,"dropdown-input");const t=R('