impulse_view_components 0.7.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,67 +1,5 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@floating-ui/dom")):"function"==typeof define&&define.amd?define(["@floating-ui/dom"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM)}(this,function(y){"use strict";function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;0<=a;a--)(o=t[a])&&(r=(n<3?o(r):3<n?o(e,i,r):o(e,i))||r);return 3<n&&r&&Object.defineProperty(e,i,r),r}const e=Symbol.for("impulse");class r{constructor(t,e){this.ctor=t,this.name=e,this.map=new Map,this.ctor=t,this.name=e,this.initialize()}add(t){var e;null!=(e=this.value)&&e.add(t)}get value(){return this.map.get(this.name)}initialize(){Object.prototype.hasOwnProperty.call(this.ctor,e)||(this.ctor[e]=new Map),this.map=this.ctor[e],this.map.has(this.name)||this.map.set(this.name,new Set)}}function i({type:i=String}={}){return(t,e)=>{new r(t,"property").add({key:e,type:i})}}function s(e){return t=>{try{window.customElements.define(e,t),window[t.name]=customElements.get(e)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}}}function o(){return(t,e)=>{new r(t,"target").add({key:e,multiple:!1})}}function I(){return(t,e)=>{new r(t,"target").add({key:e,multiple:!0})}}function B(t,e){var i={};for(o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(i[o[s]]=t[o[s]]);return i}const R=/(?:(.+?)?(?:\.(.+?))?(?:@(window|document))?->)?(.+)#(.+)?$/,K=["stop","prevent","self"],z=["capture","once","passive"];function F(t){var[,t,e,i,s,o]=t.trim().match(R)||[],e=(null==e?void 0:e.split("."))||[];return{eventName:t,eventModifiers:e.filter(t=>K.includes(t)),eventListenerOptions:function(t){var e={};for(const i of t)z.includes(i)&&(e[i]=!0);return e}(e),eventTarget:"window"===(t=i)?window:"document"===t?document:void 0,methodName:o,identifier:s}}const j={prevent:t=>Boolean(t.preventDefault()),stop:t=>Boolean(t.stopPropagation()),self:t=>t.target!==t.currentTarget};class n{constructor(){this.map=new Map}add(t,e){H(this.map,t).add(e)}delete(t,e){H(this.map,t).delete(e),0===(null==(e=this.get(t))?void 0:e.size)&&this.deleteKey(t)}deleteKey(t){this.map.delete(t)}clear(){this.map.clear()}getValuesForKey(t){t=this.map.get(t);return t?Array.from(t):[]}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values()).reduce((t,e)=>t.concat(Array.from(e)),[])}get(t){return this.map.get(t)}has(t,e){return!(null==(t=this.get(t))||!t.has(e))}}function H(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}class U{constructor(t,e){this.instance=t,this.eventTarget=e.eventTarget,this.eventName=e.eventName,this.eventModifiers=e.eventModifiers,this.eventListenerOptions=e.eventListenerOptions,this.methodName=e.methodName}start(){this.eventTarget.addEventListener(this.eventName,this,this.eventListenerOptions)}stop(){this.eventTarget.removeEventListener(this.eventName,this,this.eventListenerOptions)}handleEvent(t){var e=this.instance[this.methodName];if("function"==typeof e){for(const s of this.eventModifiers){var i=j[s];if(null!=i&&i(t))return}e.call(this.instance,t)}}}class _{constructor(t,e,i){this.element=t,this.delegate=e,this.observerOptions=i,this.elements=new Set,this.started=!1,this.element=t,this.delegate=e,this.observer=new MutationObserver(t=>this.processMutations(t)),this.observerOptions=i}start(){this.started||(this.started=!0,this.observer.observe(this.element,Object.assign({childList:!0,subtree:!0},this.observerOptions)),this.initializeElements())}stop(){this.started&&(this.observer.takeRecords(),this.observer.disconnect(),this.started=!1)}initializeElements(){for(const t of this.getMatchingElements())this.addElement(t)}processMutations(t){if(this.started)for(const e of t)"attributes"===e.type&&e.target instanceof Element?this.processAttributeChange(e.target,e.attributeName):"childList"===e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(t,e){this.elements.has(t)?this.delegate.elementAttributeChanged&&this.matchesElement(t)?this.delegate.elementAttributeChanged(t,e||""):this.removeElement(t):this.matchesElement(t)&&this.addElement(t)}processRemovedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);if(e)for(const s of this.getMatchingElements(e))this.removeElement(s)}}processAddedNodes(t){for(const i of Array.from(t)){var e=this.elementFromNode(i);if(e)for(const s of this.getMatchingElements(e))this.addElement(s)}}getMatchingElements(t=this.element){var e,i;return(null==(i=(e=this.delegate).getMatchingElements)?void 0:i.call(e,t))||[]}matchesElement(t){var e,i;return null==(i=null==(i=(e=this.delegate).matchesElement)?void 0:i.call(e,t))||i}addElement(t){var e,i;!this.elements.has(t)&&this.elementIsActive(t)&&(this.elements.add(t),null!=(i=(e=this.delegate).elementConnected))&&i.call(e,t)}removeElement(t){var e,i;this.elements.has(t)&&(this.elements.delete(t),null!=(i=(e=this.delegate).elementDisconnected))&&i.call(e,t)}elementFromNode(t){if(t.nodeType===Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected===this.element.isConnected&&this.element.contains(t)}}class W{constructor(t,e,i){this.instance=t,this.attributeName=e,this.delegate=i,this.instance=t,this.attributeName=e,this.elementObserver=new _(this.instance,this,{attributeFilter:[this.attributeName]}),this.delegate=i}start(){this.elementObserver.start()}stop(){this.elementObserver.stop()}elementConnected(t){var e,i;null!=(i=(e=this.delegate).elementConnected)&&i.call(e,t)}elementDisconnected(t){var e,i;null!=(i=(e=this.delegate).elementDisconnected)&&i.call(e,t)}elementAttributeChanged(t,e){var i,s;e===this.attributeName&&null!=(s=(i=this.delegate).elementAttributeChanged)&&s.call(i,t,e)}getMatchingElements(t){var e=Array.from(t.querySelectorAll(`[${this.attributeName}]`));return t.hasAttribute(this.attributeName)&&e.unshift(t),e}matchesElement(t){return t.hasAttribute(this.attributeName)}}class ${constructor(t,e,i){this.element=t,this.attributeName=e,this.delegate=i,this.element=t,this.attributeName=e,this.delegate=i,this.elementTokens=new n}start(){this.attributeObserver||(this.attributeObserver=new W(this.element,this.attributeName,this),this.attributeObserver.start())}stop(){this.attributeObserver&&(this.attributeObserver.stop(),this.attributeObserver=void 0)}elementConnected(t){this.readTokensForElement(t).forEach(t=>this.tokenMatched(t))}elementDisconnected(t){this.elementTokens.getValuesForKey(t).forEach(t=>this.tokenUnmatched(t))}elementAttributeChanged(t){var[t,e]=function(t,e){const i=new Set(t.map(({content:t})=>t)),s=new Set(e.map(({content:t})=>t)),o=e.filter(t=>!i.has(t.content)),n=t.filter(t=>!s.has(t.content));return[o,n]}(this.elementTokens.getValuesForKey(t),this.readTokensForElement(t));e.forEach(t=>this.tokenUnmatched(t)),t.forEach(t=>this.tokenMatched(t))}tokenMatched(t){var e,i;this.elementTokens.add(t.element,t),null!=(i=(e=this.delegate).tokenMatched)&&i.call(e,t)}tokenUnmatched(t){var e,i;this.elementTokens.delete(t.element,t),null!=(i=(e=this.delegate).tokenUnmatched)&&i.call(e,t)}readTokensForElement(t){var e,i,s=t.getAttribute(this.attributeName)||"";return e=t,i=this.attributeName,s.trim().split(/\s+/).filter(t=>t.length).map(t=>({element:e,attributeName:i,content:t}))}}class J{constructor(t){this.instance=t,this.scopedTarget=t=>t.closest(this.identifier)===this.instance,this.instance=t}findTarget(t){return this.instance.matches(t)?this.instance:this.getElements(t).find(this.scopedTarget)||null}findTargets(t){return[...this.instance.matches(t)?[this.instance]:[],...this.getElements(t).filter(this.scopedTarget)]}getElements(t){return Array.from(this.instance.querySelectorAll(t))}get identifier(){return this.instance.identifier}}class X{constructor(t){this.instance=t,this.eventListenerMap=new n,this.instance=t,this.scope=new J(this.instance)}start(){this.tokenListObserver||(this.tokenListObserver=new $(this.instance,"data-action",this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.destroyActions(),this.tokenListObserver.stop(),this.tokenListObserver=void 0)}tokenMatched({content:t,element:e}){var t=F(t),{identifier:i,eventTarget:s}=t,t=B(t,["identifier","eventTarget"]);t.eventName&&i===this.identifier&&t.methodName&&this.scope.scopedTarget(e)&&(i=new U(this.instance,Object.assign(Object.assign({},t),{eventTarget:s||e})),this.eventListenerMap.add(e,i),i.start())}tokenUnmatched({element:t}){var e=this.eventListenerMap.get(t);if(e)for(const i of e)i.stop(),this.eventListenerMap.delete(t,i)}destroyActions(){var t;for(const e of this.eventListenerMap.keys)null!=(t=this.tokenListObserver)&&t.elementDisconnected(e)}get identifier(){return this.instance.identifier}}const Y=/(-|_|\.|\s)+(.)?/g,G=/(^|\/)([A-Z])/g,Z=/[ _]/g,Q=/([a-z\d])([A-Z])/g;function tt(t){return t.replace(Q,"$1_$2").toLowerCase().replace(Z,"-")}function a(t,e=""){if(!t)return e;try{return JSON.parse(t)}catch(t){return e}}class et{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"property")}start(){for(var[{key:t,type:e}]of this.properties.entries())this.initializeProperty(t,e)}stop(){}initializeProperty(t,e){var i=tt(t),s=this.instance[t],e=Object.assign({configurable:!0},function(e,i,t){switch(t){case Number:return{get:()=>{var t;return Number((null==(t=e.getAttribute(i))?void 0:t.replace(/_/g,""))||0)},set:t=>e.setAttribute(i,(t||0).toString())};case Boolean:return{get:()=>e.hasAttribute(i)&&"false"!==e.getAttribute(i),set:t=>{t?e.setAttribute(i,""):e.removeAttribute(i)}};case Array:return{get:()=>JSON.parse(e.getAttribute(i)||"[]"),set:t=>e.setAttribute(i,JSON.stringify(t)||"[]")};case Object:return{get:()=>JSON.parse(e.getAttribute(i)||"{}"),set:t=>e.setAttribute(i,JSON.stringify(t)||"{}")};default:return{get:()=>e.getAttribute(i)||"",set:t=>e.setAttribute(i,t||"")}}}(this.instance,i,e));Object.defineProperty(this.instance,t,e),this.instance.hasAttribute(i)||null!=(t=e.set)&&t.call(e,s)}get properties(){return this.store.value}}class it{constructor(t){this.instance=t,this.instance=t,this.store=new r(Object.getPrototypeOf(this.instance),"target"),this.scope=new J(this.instance),this.targetsByKey=new n}start(){for(const t of this.keys)this.defineProperty(t,this.isKeyMultiple(t)?[]:null);this.tokenListObserver||(this.tokenListObserver=new $(this.instance,"data-target",this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.destroyTargets(),this.tokenListObserver.stop(),this.tokenListObserver=void 0)}tokenMatched({content:t,element:e}){var[t,i]=t.split(".");if(this.isValidIdKeyPair(t,i)&&!this.targetsByKey.has(i,e)&&this.scope.scopedTarget(e)){this.targetsByKey.add(i,e);var s=this.targetsByKey.getValuesForKey(i);if(1<s.length&&!this.isKeyMultiple(i))throw new Error(`
2
- Multiple "${i}" targets in the "${t}" element were defined using the @target() decorator.
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("@floating-ui/dom")):"function"==typeof define&&define.amd?define(["@floating-ui/dom"],e):e(("undefined"!=typeof globalThis?globalThis:t||self).FloatingUIDOM)}(this,function(C){"use strict";function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;0<=a;a--)(s=t[a])&&(r=(o<3?s(r):3<o?s(e,i,r):s(e,i))||r);return 3<o&&r&&Object.defineProperty(e,i,r),r}function K(e,i,n){let s=0,o=null;for(let t=i;t<e.length;t+=1){var r=e[t];if(o)r===o&&(o=null);else if('"'===r||"'"===r)o=r;else{if("("===r||"["===r?s+=1:")"!==r&&"]"!==r||--s,s<0)return null;if(n(r,t,s))return t}}return 0===s&&null===o?-1:null}const F=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function V(n){const s=[];let o=0;return K(n,0,(t,e,i)=>{","===t&&0===i&&(s.push(n.slice(o,e)),o=e+1)}),s.push(n.slice(o)),s.map(t=>t.replace(F,"")).filter(t=>0<t.length)}function D(t,n){t=K(t,n,(t,e,i)=>n<e&&0===i);return null===t||-1===t?null:t}const R=/^[\w\u0080-\uFFFF-]+/,z=/^[a-z][\w\u0080-\uFFFF-]*/i,W=/^[\t\n\f\r ]*([\w\u0080-\uFFFF-]+)[\t\n\f\r ]*(?:[~|^$*]?=|$)/;function _(t){return!t.includes("\\")&&!t.includes("/*")}function j(t){document.createDocumentFragment().querySelector(t)}function U(i){var n=[];let s=0;var t=z.exec(i);for(t?(n.push({kind:"tag",source:t[0],name:t[0]}),s=t[0].length):"*"===i[0]&&(n.push({kind:"universal",source:"*"}),s=1);s<i.length;){var o=i[s];if("#"===o||"."===o){var e=R.exec(i.slice(s+1));if(!e)return null;var r=s+1+e[0].length;n.push({kind:"#"===o?"id":"class",source:i.slice(s,r),name:e[0]}),s=r}else if("["===o){e=D(i,s);if(null===e)return null;r=W.exec(i.slice(s+1,e));n.push({kind:"attribute",source:i.slice(s,e+1),name:r?r[1]:null}),s=e+1}else{if(":"!==o)return null;{var o=":"===i[s+1],a=s+(o?2:1),l=R.exec(i.slice(a));if(!l)return null;let t=a+l[0].length,e=null;if("("===i[t]){a=D(i,t);if(null===a)return null;e=i.slice(t+1,a),t=a+1}n.push({kind:"pseudo",source:i.slice(s,t),name:l[0].toLowerCase(),element:o,argument:e}),s=t}}}return n}const H=new Set(["is","where","not"]);function Q(t,n){t=V(t);return 0<t.length&&t.every(t=>{var e=n;if(null===(t=U(t)))return!1;for(const i of t)if("id"===i.kind)e.add("id");else if("class"===i.kind)e.add("class");else if("attribute"===i.kind){if(null===i.name)return!1;e.add(i.name),e.add(i.name.toLowerCase())}else if("pseudo"===i.kind){if(i.element||null===i.argument||!H.has(i.name))return!1;if(!Q(i.argument,e))return!1}return!0})}const $=/[\t\n\f\r ]/;function J(t){let n=0;return null===K(t,0,(t,e,i)=>{0!==i||">"!==t&&"+"!==t&&"~"!==t&&!$.test(t)||(n=e+1)})?null:t.slice(n)}function X(t){if(!_(t))return null;var e=[];for(const n of V(t)){var i=function(t){t=J(t);if(null===t)return null;t=U(t);if(null===t)return null;let e="";for(const i of t)"pseudo"!==i.kind&&"universal"!==i.kind&&(e+=i.source);return 0<e.length?e:null}(n);if(null===i)return null;e.push(i)}return 0<e.length?e:null}class h{constructor(){this.map=new Map}add(t,e){let i=this.map.get(t);return i||(i=new Set,this.map.set(t,i)),i.add(e),this}delete(t,e){var i=this.map.get(t);return!!i&&((e=i.delete(e))&&0===i.size&&this.map.delete(t),e)}deleteKey(t){return this.map.delete(t)}clear(){this.map.clear()}valuesForKey(t){t=this.map.get(t);return t?Array.from(t):[]}get keys(){return Array.from(this.map.keys())}get values(){var t=[];for(const e of this.map.values())for(const i of e)t.push(i);return t}get(t){return this.map.get(t)}has(t,e){return!!this.get(t)?.has(e)}}const Y=[];class G{constructor(){this.idIndex=new h,this.attributeIndex=new h,this.classIndex=new h,this.tagIndex=new h,this.fallback=new Set,this.count=0,this.generation=0,this.selectorCounts=new Map,this.matchQueryString=null,this.subjectQueryString=null,this.attributeNames=null}add(t,e){var i={selector:t,value:e,generation:0},e=this.bucketsFor(t);if(e)for(const n of e)n.map.add(n.key,i);else this.fallback.add(i);this.count+=1,this.countSelector(t,1)}delete(t,e){var i=this.bucketsFor(t),n=i?i[0].map.get(i[0].key):this.fallback;if(n)for(const s of n)if(s.selector===t&&s.value===e){if(i)for(const o of i)o.map.delete(o.key,s);else this.fallback.delete(s);return--this.count,void this.countSelector(t,-1)}}matches(e){var i=[],n=(this.generation+=1,this.generation),t=this.tagIndex.get(e.localName.toLowerCase());t&&l(t,i,n),e.id&&(t=this.idIndex.get(e.id))&&l(t,i,n);for(const a of e.classList){var s=this.classIndex.get(a);s&&l(s,i,n)}var o=this.attributeNames??(this.attributeNames=this.attributeIndex.keys);for(let t=0;t<o.length;t+=1){var r=o[t];e.hasAttribute(r)&&(r=this.attributeIndex.get(r))&&l(r,i,n)}return 0<this.fallback.size&&l(this.fallback,i,n),i}queryAll(t){return 0===this.count?Y:(this.matchQueryString??(this.matchQueryString=Array.from(this.selectorCounts.keys()).join(", ")),t.querySelectorAll(this.matchQueryString))}querySubjects(t){return 0===this.count?Y:(this.subjectQueryString??(this.subjectQueryString=function(t){var e=new Set;for(const n of t){var i=X(n);if(null===i)return"*";for(const s of i)e.add(s)}return 0<e.size?Array.from(e).join(", "):"*"}(this.selectorCounts.keys())),t.querySelectorAll(this.subjectQueryString))}get size(){return this.count}countSelector(t,e){var i=this.selectorCounts.get(t)??0,e=i+e;0===e?this.selectorCounts.delete(t):this.selectorCounts.set(t,e),0!==i&&0!==e||(this.matchQueryString=null,this.subjectQueryString=null,this.attributeNames=null)}bucketsFor(t){if(!_(t))return null;var e=[],i=new Set;for(const o of V(t)){var n=function(t){t=J(t);if(null===t)return null;t=U(t);if(null===t)return null;let e,i,n,s;for(const o of t)"id"===o.kind?e=e??o.name:"attribute"===o.kind?null!==o.name&&(i=i??o.name):"class"===o.kind?n=n??o.name:"tag"===o.kind&&(s=s??o.name.toLowerCase());return void 0!==e?{kind:"id",value:e}:void 0!==i?{kind:"attribute",value:i}:void 0!==n?{kind:"class",value:n}:void 0!==s?{kind:"tag",value:s}:null}(o);if(!n)return null;var s=n.kind+":"+n.value;i.has(s)||(i.add(s),"id"===n.kind?e.push({map:this.idIndex,key:n.value}):"attribute"===n.kind?(e.push({map:this.attributeIndex,key:n.value}),(s=n.value.toLowerCase())!==n.value&&e.push({map:this.attributeIndex,key:s})):"class"===n.kind?e.push({map:this.classIndex,key:n.value}):e.push({map:this.tagIndex,key:n.value}))}return 0<e.length?e:null}}function l(t,e,i){for(const n of t)n.generation!==i&&(n.generation=i,e.push(n))}const o=Symbol.for("impulse"),Z={name:"property"},tt={name:"target"};function et(t,e,i){let n=st(t),s=(n||(n=new Map,Object.defineProperty(t,o,{value:n,configurable:!0})),n.get(e.name));s||(s=new Map,n.set(e.name,s)),s.set(i.key,i)}function it(t,e){return st(t)?.get(e.name)??new Map}function nt(t,e){return it(Object.getPrototypeOf(t),e)}function st(t){if(Object.hasOwn(t,o))return t[o]}function e({type:i=String}={}){return(t,e)=>{et(t,Z,{key:e,type:i})}}function ot(e,i){var t,n;return!!Object.is(e,i)||"object"==typeof e&&"object"==typeof i&&null!==e&&null!==i&&(Array.isArray(e)||Array.isArray(i)?!(!Array.isArray(e)||!Array.isArray(i)||e.length!==i.length)&&e.every((t,e)=>ot(t,i[e])):(t=Object.keys(e),n=Object.keys(i),t.length===n.length&&t.every(t=>Object.hasOwn(i,t)&&ot(e[t],i[t]))))}const rt=/([\-_.\s])+(.)?/g,at=/(^|\/)([A-Z])/g,lt=/[ _]/g,ct=/([a-z\d])([A-Z])/g;function ht(t){return t.replace(ct,"$1_$2").toLowerCase().replace(lt,"-")}const ut=new WeakMap;class dt{constructor(t){this.instance=t,this.bound=new Map,this.declarations=nt(this.instance,Z),ut.set(this.instance,this)}start(){this.bind()}bind(){for(var{key:t,type:e}of this.declarations.values())if(!this.bound.has(t)){var i=this.instance[t];const n=new mt(this.instance,t,e,i);this.bound.set(t,n),Object.defineProperty(this.instance,t,{configurable:!0,get:()=>n.value,set:t=>n.write(t)})}}stop(){}change(t,e,i){var n=this.bound.get(t);if(n)return n.change(e,i);throw new Error(`Unregistered attribute changed: ${ht(t)}. Register the attribute using the @property() decorator.`)}}var i=t=>t;function pt(e,t){return{empty:t,fromAttribute:t=>{t=function(t,e){if(!t)return e;try{return JSON.parse(t)}catch{return e}}(t,null);return e(t)?t:void 0},toAttribute:t=>JSON.stringify(t),equals:ot,copy:t=>JSON.parse(JSON.stringify(t))}}const ft=new Map([[String,{empty:()=>"",fromAttribute:i,toAttribute:String,equals:Object.is,copy:i}],[Number,{empty:()=>0,fromAttribute:t=>{var t=t.replace(/_/g,"").trim(),e=Number(t);return""===t||Number.isNaN(e)?void 0:e},toAttribute:String,equals:Object.is,copy:i}],[Boolean,{empty:()=>!1,fromAttribute:t=>"false"!==t,toAttribute:(t,e)=>t?"":e?"false":null,equals:Object.is,copy:i}],[Array,pt(Array.isArray,()=>[])],[Object,pt(t=>"object"==typeof t&&null!==t&&!Array.isArray(t),()=>({}))]]);class mt{constructor(t,e,i,n){this.element=t,this.attributeName=ht(e),this.type=ft.get(i),this.defaultValue=n??this.type.empty()}get value(){return this.read(this.element.getAttribute(this.attributeName))}write(t){t=null==t?null:this.type.toAttribute(t,this.defaultValue);null===t?this.element.removeAttribute(this.attributeName):this.element.setAttribute(this.attributeName,t)}change(t,e){t=this.read(t),e=this.read(e);return this.type.equals(e,t)?null:{newValue:e,oldValue:t}}read(t){t=null===t?void 0:this.type.fromAttribute(t);return void 0===t?this.type.copy(this.defaultValue):t}}function n(s){return t=>{const e=class extends t{constructor(...t){super(...t),new.target===e&&(t=this,ut.get(t)?.bind())}};var i,n;Object.defineProperty(e,"name",{value:t.name}),i=t.prototype,n=e.prototype,(i=st(i))&&Object.defineProperty(n,o,{value:i,configurable:!0});try{window.customElements.define(s,e),window[t.name]=customElements.get(s)}catch(t){if(!(t instanceof DOMException&&"NotSupportedError"===t.name))throw t}return e}}function s(){return(t,e)=>{et(t,tt,{key:e,multiple:!1})}}function vt(){return(t,e)=>{et(t,tt,{key:e,multiple:!0})}}const yt=/(?:(.+?)?(?:\.(.+?))?(?:@(window|document))?->)?(.+)#(.+)?$/,gt=["stop","prevent","self"],bt=["capture","once","passive"],wt=new Map;function kt(t){var e,i,n,s,t=t.trim(),o=wt.get(t);return o||([,o,s,e,i,n]=t.match(yt)||[],o={eventName:o,eventModifiers:(o=s?.split(".")||[]).filter(t=>gt.includes(t)),eventListenerOptions:function(t){var e={};for(const i of t)bt.includes(i)&&(e[i]=!0);return e}(o),eventTarget:"window"===(s=e)?window:"document"===s?document:void 0,methodName:n,identifier:i},wt.set(t,o),o)}const St={prevent:t=>Boolean(t.preventDefault()),stop:t=>Boolean(t.stopPropagation()),self:t=>t.target!==t.currentTarget};class At{constructor(t,e){this.instance=t,this.eventTarget=e.eventTarget,this.eventName=e.eventName,this.eventModifiers=e.eventModifiers,this.eventListenerOptions=e.eventListenerOptions,this.methodName=e.methodName}start(){this.eventTarget.addEventListener(this.eventName,this,this.eventListenerOptions)}stop(){this.eventTarget.removeEventListener(this.eventName,this,this.eventListenerOptions)}handleEvent(t){var e=this.instance[this.methodName];if("function"==typeof e){for(const i of this.eventModifiers)if((0,St[i])?.(t))return;e.call(this.instance,t)}}}function Et(t){"function"==typeof reportError?reportError(t):setTimeout(()=>{throw t})}function p(t){try{t()}catch(t){Et(t)}}function u(t,e){let i=!1,n;for(const s of t)try{e(s)}catch(t){i||(i=!0,n=t)}if(i)throw n}function Ot(){return new Promise(t=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t(),{once:!0}):t()})}let xt;const c=new G,d=new WeakMap;let r=null,Ct=null;const a=new Map;let Pt=0,f=null,Nt=!1,m=null,Tt=0,v=!1,Mt=0,y=[],Bt=0,g=null;function Lt(n,t){j(n);const s={selector:n,elementConnected:t.elementConnected,elementDisconnected:t.elementDisconnected,elementAttributeChanged:t.elementAttributeChanged,elements:new Map,attributes:_(t=n)&&Q(t,t=new Set)?Array.from(t):null};"loading"===document.readyState?(t=s,m||(m=new Set,Ot().then(qt)),m.add(t)):(v||Kt(),It(s),S(()=>{for(const t of document.querySelectorAll(n))$t(t,s)}));let o=!1;return()=>{if(!o&&(o=!0,!m?.delete(s))){c.delete(n,s),Rt(s.attributes,-1)&&(Nt=!0);for(const i of s.elements.keys())Xt(i,s);var t,e;s.elements.clear(),0===c.size&&r&&(t=Ft(),e=r,r=null,Wt(t),e.disconnect())}}}function It(t){c.add(t.selector,t),Rt(t.attributes,1),t=t.attributes,r?function(t){const e=f;return!e||null!==t&&t.every(t=>e.has(t))}(t)||Dt():(r=new MutationObserver(zt),Ct=document.documentElement,r.observe(Ct,{childList:!0,subtree:!0}),g=g??document.createTextNode(""),r.observe(g,{characterData:!0}),Dt())}function qt(){var t=m;if(m=null,t&&0!==t.size){for(const e of t)It(e);S(()=>_t(document.documentElement))}}function Kt(){for(let t=Ft();t.length;t=Ft())Wt(t)}function Ft(){return Vt(r?.takeRecords()??[])}function Vt(t){return 0===y.length||(t=y.concat(t),y=[]),t}function b(){return v?Mt:0}function w(){var t=v;return t||(Mt+=1),v=!0,t}function k(t){v=t}function S(t){var e=w();try{t()}finally{k(e)}}function Dt(){var t={attributes:!(Nt=!1),subtree:!0};0<Pt?f=null:(f=new Set(a.keys()),t.attributeFilter=Array.from(f)),r?.observe(document,t)}function Rt(t,e){if(!t)return 0===(Pt+=e);let i=!1;for(const s of t){var n=(a.get(s)??0)+e;0===n?(a.delete(s),i=!0):a.set(s,n)}return i}function zt(t){Nt&&Dt(),Wt(Vt(t))}function Wt(t){var e,i=document.documentElement!==Ct,n=Tt+=1,s=w();try{for(const a of t)if("childList"===a.type){if(0<(e=a).removedNodes.length&&1===e.addedNodes.length&&function(){var t,e,i;return void 0===xt&&(e=(t=document.createElement("div")).appendChild(document.createElement("div")).appendChild(document.createElement("div")),(i=new MutationObserver(()=>{})).observe(t,{childList:!0,subtree:!0}),t.replaceChildren?.(e),xt=1===i.takeRecords().length,i.disconnect()),xt}()){r=o=void 0;var o=a.addedNodes[0],r=n;if(o.nodeType===Node.ELEMENT_NODE){Qt(o,r);for(const l of c.querySubjects(o))Qt(l,r)}}a.removedNodes.forEach(jt),a.addedNodes.forEach(_t)}else"attributes"===a.type&&!i&&a.target instanceof Element&&!function(t,e){if(t.isConnected){var i=d.get(t);if(i)for(const n of Array.from(i))t.matches(n.selector)?p(()=>n.elementAttributeChanged?.(t,e??"")):Jt(t,n);Ut(t)}else Ht(t)}(a.target,a.attributeName)}finally{k(s)}}function _t(t){if(t.nodeType===Node.ELEMENT_NODE){var e=c.queryAll(t);Ut(t);for(const i of e)Ut(i)}}function jt(t){if(t.nodeType===Node.ELEMENT_NODE){Ht(t);for(const e of c.querySubjects(t))Ht(e)}}function Ut(t){if(t.isConnected)for(var{value:e}of c.matches(t))!e.elements.has(t)&&t.matches(e.selector)&&$t(t,e)}function Ht(t){var e=d.get(t);if(e)for(const i of Array.from(e))Jt(t,i)}function Qt(t,e){var i=d.get(t);if(i)for(const n of Array.from(i))n.elements.get(t)<e&&Jt(t,n)}function $t(e,i){{var n=e,s=i;s.elements.set(n,Tt);let t=d.get(n);t||(t=new Set,d.set(n,t)),t.add(s)}p(()=>i.elementConnected?.(e))}function Jt(t,e){var i,n;i=t,(n=e).elements.delete(i),Xt(i,n),p(()=>e.elementDisconnected?.(t))}function Xt(t,e){var i=d.get(t);i&&(i.delete(e),0===i.size)&&d.delete(t)}function Yt(o,r,i){const a=new h,l=(t,e)=>{a.add(t,e),i.tokenMatched?.(e)},c=(t,e)=>{a.delete(t,e),i.tokenUnmatched?.(e)},e=Lt(`[${r}]`,{elementConnected(t){if(o.contains(t))for(const e of Gt(t,r))p(()=>l(t,e))},elementDisconnected(t){for(const e of a.valuesForKey(t))p(()=>c(t,e))},elementAttributeChanged(t,e){if(e===r&&o.contains(t)){var e=a.valuesForKey(t),[e,i]=function(t,e){const i=new h;for(const o of e)i.add(o.content,o);var n=[];for(const r of t){var[s]=i.valuesForKey(r.content);s?i.delete(r.content,s):n.push(r)}return[n,e.filter(t=>i.has(t.content,t))]}(Gt(t,r),e);for(const n of i)p(()=>c(t,n));for(const s of e)p(()=>l(t,s))}}});return()=>{var t=a.values;a.clear();try{u(t,t=>i.tokenUnmatched?.(t))}finally{e()}}}function Gt(e,i){return Zt(e,i).map(t=>({element:e,attributeName:i,content:t}))}function Zt(t,e){return(t.getAttribute(e)||"").trim().split(/\s+/).filter(t=>t.length)}class te{constructor(t,e){this.attributeName=t,this.identifierFor=e,this.delegates=new WeakMap,this.tokensByOwner=new WeakMap,this.ownerByToken=new WeakMap,this.subscriberCount=0}subscribe(t,e){if(this.delegates.has(t))throw new Error(`<${t.localName}> is already subscribed to the "${this.attributeName}" token router.`);const i=e;this.stopWatching?Kt():this.stopWatching=Yt(document.documentElement,this.attributeName,{tokenMatched:t=>this.tokenMatched(t),tokenUnmatched:t=>this.tokenUnmatched(t)}),this.delegates.set(t,i),this.subscriberCount+=1;e=w();try{for(const s of this.ownedTokens(t))p(()=>i.tokenMatched?.(s))}finally{k(e)}let n=!1;return()=>{n||(n=!0,this.unsubscribe(t,i))}}stillRoutesTo(t,e){return{attributeName:i,content:n,element:s}=[e][0],Gt(s,i).some(t=>t.content===n)&&this.ownerOf(e)===t;var i,n,s}routesTo(e,i,n){return Zt(i,this.attributeName).some(t=>n(t)&&this.ownerFor(i,t)===e)}unsubscribe(t,e){this.delegates.delete(t),--this.subscriberCount;var i,t=this.ownedTokens(t),n=w();try{u(t,t=>e.tokenUnmatched?.(t))}finally{try{0===this.subscriberCount&&(i=this.stopWatching,this.stopWatching=void 0,i?.())}finally{k(n)}}}tokenMatched(e){var i=this.ownerOf(e);if(i){let t=this.tokensByOwner.get(i);t||(t=new Set,this.tokensByOwner.set(i,t)),t.add(e),this.ownerByToken.set(e,i),this.delegates.get(i)?.tokenMatched?.(e)}}tokenUnmatched(t){var e,i=this.ownerByToken.get(t);i&&(this.ownerByToken.delete(t),(e=this.tokensByOwner.get(i))&&(e.delete(t),0===e.size)&&this.tokensByOwner.delete(i),this.delegates.get(i)?.tokenUnmatched?.(t))}ownedTokens(t){t=this.tokensByOwner.get(t);return t?Array.from(t):[]}ownerOf(t){return this.ownerFor(t.element,t.content)}ownerFor(t,e){e=this.identifierFor(e);if(!e)return null;try{return t.closest(e)}catch{return null}}}const ee=new te("data-action",t=>kt(t).identifier);class ie{constructor(t){this.instance=t,this.eventListenerMap=new Map}start(){this.stopWatching||(this.stopWatching=ee.subscribe(this.instance,this))}stop(){var t=this.stopWatching;t&&(this.stopWatching=void 0,t())}tokenMatched(t){var{content:e,element:i}=t;const{identifier:n,eventTarget:s,...o}=kt(e);o.eventName&&n===this.identifier&&o.methodName&&(e=new At(this.instance,{...o,eventTarget:s||i}),this.eventListenerMap.set(t,e),e.start())}tokenUnmatched(t){var e=this.eventListenerMap.get(t);e&&(e.stop(),this.eventListenerMap.delete(t))}get identifier(){return this.instance.identifier}}const ne="data-impulse-element",A=new Map,se=new WeakSet;function E(t,e,i,n){j(e);var n="boolean"==typeof n?{capture:n}:n??{},s=!!n.capture,o=!!n.once;const{passive:r,signal:a}=n;if(!a?.aborted){const c={selector:e,callback:i,once:o,removed:!1,detach:()=>a?.removeEventListener("abort",l)},h=function(t,e,i){var n=function(t,e,i){i=void 0===i?"":i?"p":"n";return(e?"c":"b")+i+":"+t}(t,e,i),s=A.get(n);if(s)return s;const o=new G,d={key:n,eventName:t,capture:e,selectorSet:o,listener:t=>{try{var n=t,s=d.selectorSet,e=d.capture;try{n.eventPhase}catch{return}if(se.has(n)){if(n.cancelBubble)return;se.delete(n)}if((i=n.target)instanceof Node){var i="function"==typeof n.composedPath?n.composedPath():function(t){var e=[];let i=t;for(;i;)e.push(i),i=i.parentNode;return e}(i),e=e?i.slice().reverse():i,o=[];for(const a of e)if(a instanceof Element)for(var{value:r}of s.matches(a))!r.removed&&a.matches(r.selector)&&o.push({node:a,handler:r});if(0!==o.length){let e=!1,i=!1;const l=n.stopPropagation,c=n.stopImmediatePropagation;n.stopPropagation=function(){e=!0,l.call(n)},n.stopImmediatePropagation=function(){e=!0,i=!0,c.call(n)};try{let t;for(const{node:h,handler:u}of o){if(i)break;if(e&&void 0!==t&&h!==t)break;u.removed||(t=h,Object.defineProperty(n,"currentTarget",{configurable:!0,get:()=>h}),u.once&&(u.removed=!0,u.detach(),s.delete(u.selector,u)),p(()=>u.callback.call(h,n)))}}finally{e&&se.add(n),delete n.currentTarget,delete n.stopPropagation,delete n.stopImmediatePropagation}}}}finally{oe(d)}}};return document.addEventListener(t,d.listener,void 0===i?e:{capture:e,passive:i}),A.set(n,d),d}(t,s,r);function l(){c.removed||(c.removed=!0,c.detach(),h.selectorSet.delete(e,c),oe(h))}h.selectorSet.add(e,c),a?.addEventListener("abort",l)}}function oe(t){0<t.selectorSet.size||A.get(t.key)!==t||(document.removeEventListener(t.eventName,t.listener,t.capture),A.delete(t.key))}const re=new WeakSet,ae=new WeakMap;function le(t){return re.has(t)}function O(t){var[t,e]=t.split(".");return{identifier:t,key:e}}const x=new te("data-target",t=>O(t).identifier);function ce(t,e){return t===e?0:t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}class he{constructor(t){this.instance=t,this.orderedByKey=new Map,this.nowByKey=new Map,this.stableByKey=new Map,this.heldSinceByKey=new Map,this.departedByKey=new Map,this.declarations=nt(this.instance,tt),this.targetsByKey=new h,this.tokensByElement=new h,this.waitingByKey=new h}start(){for(const{key:e,multiple:t}of this.declarations.values()){const i=t?{delivered:()=>this.stableArray(e,this.orderedTargets(e)),now:()=>this.stableArray(e,this.claimants(e))}:{delivered:()=>this.targetsByKey.valuesForKey(e)[0]??null,now:()=>this.claimantNow(e)};Object.defineProperty(this.instance,e,{configurable:!0,get:()=>{var t;return this.stopWatching?(t=function(){if(v||!r)return 0;var t=r.takeRecords();if(0===t.length)return 0<y.length?Bt:0;let e=!1;for(const i of t)i.target!==g&&(y.push(i),e=!0);return e&&(Bt+=1),0===y.length?0:(g.data="",Bt)}())&&this.isInDocumentTree()?this.readNow(e,t,i.now):(0<this.nowByKey.size&&this.nowByKey.clear(),i.delivered()):0===b()&&this.isInDocumentTree()?i.now():i.delivered()}})}this.stopWatching||(this.stopWatching=x.subscribe(this.instance,this))}stop(){var t=this.stopWatching;if(t){this.stopWatching=void 0,this.nowByKey.clear();try{t()}finally{this.stableByKey.clear(),this.heldSinceByKey.clear(),this.departedByKey.clear()}}}tokenMatched(t){var{content:e,element:i}=t;const{identifier:n,key:s}=O(e);if(this.isValidIdKeyPair(n,s))if(this.targetsByKey.has(s,i))this.tokensByElement.add(i,t);else{if(!this.isKeyMultiple(s)){var[e]=this.targetsByKey.valuesForKey(s);if(e&&this.takesOver(s,e,i))return void this.handOver(s,e,t);if(e||this.keptForMovedTarget(s,i))return this.waitingByKey.add(s,t),this.reportIfLeftWaiting(s,t),void(e||Promise.resolve().then(()=>S(()=>this.adoptWaiting(s))))}this.tokensByElement.add(i,t),this.connect(s,i)}}tokenUnmatched(t){var{content:e,element:i}=t,{identifier:n,key:s}=O(e);if(this.isValidIdKeyPair(n,s)&&!this.waitingByKey.delete(s,t)&&this.targetsByKey.has(s,i)&&(this.tokensByElement.delete(i,t),!this.isStillReferenced(i,e)))try{this.invokeCallback(s,i,"disconnected")}finally{this.targetsByKey.delete(s,i),this.orderedByKey.delete(s),this.isKeyMultiple(s)||(n=this.heldSinceByKey.get(s)??b(),this.departedByKey.set(s,{element:i,since:n,delivery:b()})),this.adoptWaiting(s,t)}}reportIfLeftWaiting(t,e){Promise.resolve().then(()=>{this.waitingByKey.has(t,e)&&Et(new Error(`
2
+ Multiple "${t}" targets in the "${this.identifier}" element were defined using the @target() decorator.
3
3
  Please use the @targets() decorator instead if you want to define multiple targets for the same key.
4
4
  Learn more about the @targets() decorator: https://ambiki.github.io/impulse/reference/targets.html#multiple-targets
5
- `);this.defineProperty(i,this.isKeyMultiple(i)?s:e),this.invokeCallback(i,e,"connected")}}tokenUnmatched({content:t,element:e}){var[t,i]=t.split(".");this.isValidIdKeyPair(t,i)&&this.targetsByKey.has(i,e)&&(this.targetsByKey.delete(i,e),this.invokeCallback(i,e,"disconnected"),this.defineProperty(i,this.isKeyMultiple(i)?this.targetsByKey.getValuesForKey(i):null))}destroyTargets(){for(const t of this.targetsByKey.keys)this.targetsByKey.getValuesForKey(t).forEach(t=>{var e;return null==(e=this.tokenListObserver)?void 0:e.elementDisconnected(t)})}defineProperty(t,e){Object.defineProperty(this.instance,t,{configurable:!0,get:()=>e})}isValidIdKeyPair(t,e){return!(!e||t!==this.identifier||!this.keys.includes(e))}invokeCallback(t,e,i){i=this.instance[""+t+((t=i).charAt(0).toUpperCase()+t.slice(1))];"function"==typeof i&&i.call(this.instance,e)}isKeyMultiple(e){var t;return null!=(t=null==(t=Array.from(this.targetKeys).find(t=>t.key===e))?void 0:t.multiple)&&t}get keys(){return Array.from(this.targetKeys).map(({key:t})=>t)}get targetKeys(){return this.store.value}get identifier(){return this.instance.identifier}}class l extends HTMLElement{constructor(){super(...arguments),this.property=new et(this),this.target=new it(this),this.action=new X(this),this._started=!1}connectedCallback(){this._started||this._asyncConnect()}static get observedAttributes(){var t=new r(this.prototype,"property");return Array.from(t.value).map(({key:t})=>tt(t))}attributeChangedCallback(t,e,i){if(this._started&&e!==i){const n=t.replace(Y,(t,e,i)=>i?i.toUpperCase():"").replace(G,t=>t.toLowerCase());var s=this[n+"Changed"];if("function"==typeof s){var o=new r(Object.getPrototypeOf(this),"property"),o=Array.from(o.value).map(({key:t,type:e})=>({key:t,type:e})).find(({key:t})=>t===n);if(!o)throw new Error(`Unregistered attribute changed: ${t}. Register the attribute using the @property() decorator.`);var{newValue:t,oldValue:i}=function(t,e,i){switch(i){case Boolean:var s=t=>null!==t&&"false"!==t;return{newValue:s(t),oldValue:s(e)};case Number:s=t=>null==t?void 0:t.replace(/_/g,"");return{newValue:Number(s(t)),oldValue:Number(s(e))};case Array:return{newValue:a(t,[]),oldValue:a(e,[])};case Object:return{newValue:a(t,{}),oldValue:a(e,{})};default:return{newValue:t,oldValue:e}}}(i,e,o.type);t!==i&&s.call(this,t,i)}}}disconnectedCallback(){this._started&&(this.disconnected(),this.action.stop(),this.target.stop(),this.property.stop(),this._started=!1)}connected(){}disconnected(){}emit(t,e={}){var{target:i=this,prefix:s=this.identifier,detail:o={}}=e,e=B(e,["target","prefix","detail"]),s=new CustomEvent(s?s+":"+t:t,Object.assign({bubbles:!0,composed:!0,detail:o},e));return i.dispatchEvent(s),s}get identifier(){return this.tagName.toLowerCase()}async _asyncConnect(){await new Promise(t=>{"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>t()):t()}),customElements.upgrade(this),this.property.start(),await this._resolveUndefinedElements(),this.target.start(),this.action.start(),this._started=!0,this.setAttribute("data-impulse-element",""),this.connected()}_resolveUndefinedElements(){var t=Array.from(this.querySelectorAll(":not(:defined)")).map(t=>customElements.whenDefined(t.localName));return Promise.all(t)}}function st(t){return Number(t.replace(/[^-\d.]/g,""))}let h=class extends l{constructor(){super(...arguments),this.placement="bottom",this.active=!1,this.strategy="fixed",this.distance=0,this.skidding=0,this.flip=!0,this.flipPadding=0,this.fallbackPlacements=[],this.fallbackStrategy="bestFit",this.shift=!1,this.shiftPadding=0}connected(){this.start()}disconnected(){this.stop()}async anchorIdChanged(t){await this.stop(),t&&this.anchorElement&&this.start()}async activeChanged(t){t?this.start():await this.stop()}start(){this.anchorElement&&(this.style.position=this.strategy,this.style.top="0px",this.style.left="0px",this.cleanup=y.autoUpdate(this.anchorElement,this,this.reposition.bind(this)))}async stop(){return new Promise(t=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,requestAnimationFrame(()=>t())):t()})}async reposition(){if(this.active&&this.anchorElement){var t=[y.offset({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?t.push(y.size({apply:({rects:t})=>{var e="width"===this.sync||"both"===this.sync,i="height"===this.sync||"both"===this.sync;this.style.width=e?t.reference.width+"px":"",this.style.height=i?t.reference.height+"px":""}})):(this.style.width="",this.style.height=""),this.flip&&t.push(y.flip({fallbackPlacements:this.fallbackPlacements.length?this.fallbackPlacements:void 0,fallbackStrategy:this.fallbackStrategy,padding:this.flipPadding})),this.shift&&t.push(y.shift({padding:this.shiftPadding})),this.arrowElement&&t.push(y.arrow({element:this.arrowElement,padding:this._arrowPadding}));const{x:e,y:i,placement:s,strategy:o,middlewareData:n}=await y.computePosition(this.anchorElement,this,{placement:this.placement,middleware:t,strategy:this.strategy});if(Object.assign(this.style,{left:e+"px",top:i+"px",position:o}),n.arrow&&this.arrowElement){const{x:e,y:i}=n.arrow;Object.assign(this.arrowElement.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}this.setAttribute("x-placement",s)}}get anchorElement(){return document.getElementById(this.anchorId)}get arrowElement(){return this.querySelector("[data-arrow]")}get _arrowPadding(){return"number"==typeof this.arrowPadding?this.arrowPadding:st(getComputedStyle(this).borderRadius)||2}};t([i()],h.prototype,"anchorId",void 0),t([i()],h.prototype,"placement",void 0),t([i({type:Boolean})],h.prototype,"active",void 0),t([i()],h.prototype,"strategy",void 0),t([i({type:Number})],h.prototype,"distance",void 0),t([i({type:Number})],h.prototype,"skidding",void 0),t([i()],h.prototype,"sync",void 0),t([i({type:Boolean})],h.prototype,"flip",void 0),t([i({type:Number})],h.prototype,"flipPadding",void 0),t([i({type:Array})],h.prototype,"fallbackPlacements",void 0),t([i()],h.prototype,"fallbackStrategy",void 0),t([i({type:Boolean})],h.prototype,"shift",void 0),t([i({type:Number})],h.prototype,"shiftPadding",void 0),t([i({type:Number})],h.prototype,"arrowPadding",void 0),h=t([s("awc-anchor")],h);var ot=0;function nt(){return ot+=1,`ambiki-${Math.random().toString().slice(2,6)}-`+ot}function rt(t){return!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled")}var at=!!navigator.userAgent.match(/Macintosh/),lt=class{input;list;multiple;isMouseMoving=!1;constructor(t,e,{multiple:i=!1}={}){this.input=t,this.list=e,this.multiple=i,this.list.id||(this.list.id=nt()),this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.multiple&&this.input.setAttribute("aria-multiselectable","true"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-haspopup","listbox"),this.input.setAttribute("aria-autocomplete","list"),this.list.setAttribute("role","listbox"),this.onKeydown=this.onKeydown.bind(this),this.onClick=this.onClick.bind(this),this.onListMouseover=this.onListMouseover.bind(this),this.onListMousemove=this.onListMousemove.bind(this)}start(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","true"),this.input.setAttribute("aria-controls",this.list.id),this.input.addEventListener("keydown",this.onKeydown),this.list.addEventListener("click",this.onClick),this.list.addEventListener("mouseover",this.onListMouseover),this.list.addEventListener("mousemove",this.onListMousemove),this.initializeOptions()}stop(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","false"),this.input.removeAttribute("aria-controls"),this.input.removeEventListener("keydown",this.onKeydown),this.list.removeEventListener("click",this.onClick),this.list.removeEventListener("mouseover",this.onListMouseover),this.list.removeEventListener("mousemove",this.onListMousemove),this.deselectAll(),this.deactivate()}onKeydown(t){if(this.isMouseMoving=!1,!(t.shiftKey||t.metaKey||t.altKey||!at&&t.ctrlKey))switch(t.key){case"Enter":case"Tab":this.activeOption&&rt(this.activeOption)&&(t.preventDefault(),t.stopPropagation(),this.activeOption.click());break;case"Escape":this.deactivate();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(1):this.activate(this.visibleOptions[0],{scroll:!0});break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(-1):this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;case"Home":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[0],{scroll:!0});break;case"End":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;default:t.ctrlKey||this.deactivate()}}onClick(t){t=c(t.target);t&&rt(t)&&(this.multiple&&this.isSelected(t)?this.deselect(t):this.select(t),t.dispatchEvent(new CustomEvent("combobox:commit",{bubbles:!0})))}onListMouseover(t){var e;this.isMouseMoving?(e=c(t.target))&&this.activate(e):t.preventDefault()}onListMousemove(t){!this.isMouseMoving&&(this.isMouseMoving=!0,t=c(t.target))&&this.activate(t)}select(t){if(this.multiple)t.setAttribute("aria-selected","true");else for(var e of this.options)e.setAttribute("aria-selected",(e===t).toString())}deselect(t){t.setAttribute("aria-selected","false")}deselectAll(){for(var t of this.options)this.deselect(t)}activate(t,{scroll:e=!1}={}){for(var i of this.options)i.id===t.id?(i.setAttribute("data-active",""),this.input.setAttribute("aria-activedescendant",i.id),e&&i.scrollIntoView({block:"nearest"})):i.removeAttribute("data-active")}deactivate(){this.input.removeAttribute("aria-activedescendant");for(var t of Array.from(this.list.querySelectorAll('[role="option"][data-active]')))t.removeAttribute("data-active")}isSelected(t){return"true"===t.getAttribute("aria-selected")}get options(){return Array.from(this.list.querySelectorAll('[role="option"]'))}get visibleOptions(){return this.options.filter(ht)}get activeOption(){return this.list.querySelector("[data-active]")}move(t){this.activeOption&&(t=function(t,e,i){let s=t.indexOf(e),o=(s===t.length-1&&1===i&&(s=-1),1===i?0:t.length-1);return t[o=e&&0<=s&&0<=(e=s+i)&&e<t.length?e:o]}(this.visibleOptions,this.activeOption,t),this.activate(t,{scroll:!0}))}initializeOptions(){for(var t of this.options)t.setAttribute("tabindex","-1"),t.id||(t.id=nt()),t.hasAttribute("aria-selected")||this.deselect(t)}};function c(t){return t&&t.closest('[role="option"]')||!1}function ht(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(0<t.offsetWidth||0<t.offsetHeight)}function ct(t,e){void 0===e&&(e=!0);var i=null==t||null==(i=t.getAttribute)?void 0:i.call(t,"inert");return""===i||"true"===i||e&&t&&ct(t.parentNode)}function dt(t){var e=(t=t.getBoundingClientRect()).width,t=t.height;return 0===e&&0===t}function ut(t,e){var i=e.displayCheck,s=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return 1;if(e=d.call(t,"details>summary:first-of-type")?t.parentElement:t,d.call(e,"details:not([open]) *"))return 1;if(i&&"full"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return dt(t)}else{if("function"==typeof s){for(e=t;t;){var o=t.parentElement,n=u(t);if(o&&!o.shadowRoot&&!0===s(o))return dt(t);t=t.assignedSlot||(o||n===t.ownerDocument?o:n.host)}t=e}if(function(t){var e,i=t&&u(t),s=null==(e=i)?void 0:e.host,o=!1;if(i&&i!==t)for(o=!!(null!=(e=s)&&null!=(e=e.ownerDocument)&&e.contains(s)||null!=t&&null!=(e=t.ownerDocument)&&e.contains(t));!o&&s;)var n,o=!(null==(n=s=null==(n=i=u(s))?void 0:n.host)||null==(n=n.ownerDocument)||!n.contains(s));return o}(t))return!t.getClientRects().length;if("legacy-full"!==i)return 1}}var pt="undefined"==typeof Element,d=pt?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,u=!pt&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},mt=function(t,e){var i;return!(e.disabled||ct(e)||"INPUT"===(i=e).tagName&&"hidden"===i.type||ut(e,t)||"DETAILS"===(i=e).tagName&&Array.prototype.slice.apply(i.children).some(function(t){return"SUMMARY"===t.tagName})||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var s=e.children.item(i);if("LEGEND"===s.tagName)return!!d.call(e,"fieldset[disabled] *")||!s.contains(t)}return!0}e=e.parentElement}return!1}(e))},vt=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].concat("iframe").join(",");function ft(t){let e=t;for(;null!==e;){if(function(t,e){if(e=e||{},t)return!1!==d.call(t,vt)&&mt(e,t);throw new Error("No node provided")}(e)||e.hasAttribute("data-loosely-focusable"))return 1;e=e.parentElement}}function gt(t,{referenceElement:r,popupElement:a,arrowElement:l,arrowPadding:h=0,middleware:c=[],offsetOptions:d=0,placement:u="bottom-start",flipOptions:p,shiftOptions:m,strategy:v="fixed",sync:f,autoSize:g,autoSizePadding:b=0}){let e;async function i(t=!1){if(t&&r&&a){t=[y.offset(d)];f?t.push(y.size({apply:({rects:t})=>{var e="height"===f||"both"===f;a.style.width="width"===f||"both"===f?t.reference.width+"px":"",a.style.height=e?t.reference.height+"px":""}})):(a.style.width="",a.style.height=""),t.push(y.flip(p)),t.push(y.shift(m)),g?t.push(y.size({padding:b,apply:({availableWidth:t,availableHeight:e})=>{"height"===g||"both"===g?a.style.setProperty("--awc-auto-size-height",e+"px"):a.style.removeProperty("--awc-auto-size-height"),"width"===g||"both"===g?a.style.setProperty("--awc-auto-size-width",t+"px"):a.style.removeProperty("--awc-auto-size-width")}})):(a.style.removeProperty("--awc-auto-size-height"),a.style.removeProperty("--awc-auto-size-width")),l&&t.push(y.arrow({element:l,padding:h})),t.concat(c);const{x:e,y:i,placement:s,strategy:o,middlewareData:n}=await y.computePosition(r,a,{placement:u,middleware:t,strategy:v});if(Object.assign(a.style,{left:e+"px",top:i+"px",position:o}),n.arrow&&l){const{x:e,y:i}=n.arrow;Object.assign(l.style,{left:"number"==typeof e?e+"px":"",top:"number"==typeof i?i+"px":""})}a.setAttribute("x-placement",s)}}async function s(){return new Promise(t=>{e?(e(),e=void 0,requestAnimationFrame(()=>t())):t()})}a&&(a.style.position=v,a.style.top="0px",a.style.left="0px",r)&&(e=y.autoUpdate(r,a,()=>i(!0)),s());const o=t.disconnected.bind(t);return Object.assign(t,{disconnected(){s(),o()}}),{start:function(){r&&a&&(e=y.autoUpdate(r,a,()=>i(t.open)))},update:async function(){await i(t.open)},stop:s}}function bt(t,{boundaries:o,callback:n}){let r=null;function e(t){var e;r=(null==(e=null==(e=t.composedPath)?void 0:e.call(t))?void 0:e[0])||t.target}function i(t,e){if(r&&!t.defaultPrevented){var i=e(t);if(i&&i.getRootNode().contains(i)&&i.isConnected){for(const s of o)if(null!==s){if(s.contains(i))return;if(t.composed&&t.composedPath().includes(s))return}n(t,i),r=null}}}document.addEventListener("mousedown",e,!0),document.addEventListener("click",t=>i(t,()=>r),!0);const s=t.disconnected.bind(t);Object.assign(t,{disconnected(){r=null,document.removeEventListener("mousedown",e,!0),document.removeEventListener("click",t=>i(t,()=>r),!0),s()}})}class yt{constructor(t){this.autocomplete=t}search(t){this.autocomplete.options.forEach((s=t,t=>{var e,i=t.closest('[role="group"]');s?(e=null==(e=t.getAttribute("data-text"))?void 0:e.toLowerCase().includes(s.toLowerCase()),t.hidden=!e,i&&(e=Array.from(i.querySelectorAll('[role="option"]')),i.hidden=e.every(t=>t.hidden))):(t.hidden=!1,i&&(i.hidden=!1))}));var s,t=this.autocomplete.visibleOptions[0];t&&this.autocomplete.combobox.activate(t),this.autocomplete.checkIfListIsEmpty()}start(){this.autocomplete.checkIfListIsEmpty()}stop(){this.resetOptions()}resetOptions(){for(const t of this.autocomplete.groups)t.hidden=!1;for(const e of this.autocomplete.options)e.hidden=!1}}class wt{constructor(t){this.selectedValues=new Set,this.defaultSelectedValues=[],this.findByValue=e=>t=>t.getAttribute("value")===e,this.autocomplete=t}connected(){this.defaultSelectedValues=this.tags.reduce((t,e)=>{var e=e.querySelector('[data-behavior="hidden-field"]'),i=e.value;return this.selectedValues.add(i),t.push({value:i,text:e.getAttribute("data-text")||""}),t},[])}start(){this.selectOrDeselectOptions(),this.firstActivableOption&&this.autocomplete.combobox.activate(this.firstActivableOption,{scroll:!0})}stop(){this.autocomplete.input.value=""}reset(){this.clear(),this.defaultSelectedValues.forEach(({value:t,text:e})=>this.setValue(t,e))}select(t){var e=t.getAttribute("value"),t=t.dataset["text"];e&&(this.selectedValues.has(e)?this.removeValue(e):this.setValue(e,t||""))}setValue(t,e){this.selectedValues.has(t)||(this.selectedValues.add(t),this.insertTag(t,e.trim()),this.toggleSelectedClass(),this.required=this.autocomplete.required,this.autocomplete.open&&(e=this.autocomplete.options.find(this.findByValue(t)))&&this.autocomplete.combobox.select(e))}clear(){this.selectedValues.forEach(t=>this.removeValue(t))}removeValue(t){this.selectedValues.has(t)&&(this.selectedValues.delete(t),this.removeTag(t),this.toggleSelectedClass(),this.required=this.autocomplete.required,t=this.autocomplete.options.find(this.findByValue(t)))&&this.autocomplete.combobox.deselect(t)}set required(t){!t||0<this.selectedValues.size?this.autocomplete.input.required=!1:this.autocomplete.input.required=!0}selectOrDeselectOptions(){for(const e of this.autocomplete.options){var t=e.getAttribute("value");t&&this.selectedValues.has(t)?this.autocomplete.combobox.select(e):this.autocomplete.combobox.deselect(e)}}insertTag(t,e){var i=this.template.content.cloneNode(!0),s=i.querySelector('[data-behavior="tag"]'),o=i.querySelector('[data-behavior="text"]'),n=i.querySelector('[data-behavior="hidden-field"]');s.setAttribute("value",t),s.setAttribute("data-text",e),o.innerText=e,n.value=t,n.setAttribute("data-text",e),this.autocomplete.control.insertBefore(i,this.template)}removeTag(t){t=this.tags.find(this.findByValue(t));null!=t&&t.remove()}toggleSelectedClass(){this.autocomplete.toggleSelectedClass(!!this.selectedValues.size)}get firstActivableOption(){return this.autocomplete.options.find(t=>this.selectedValues.has(t.getAttribute("value")))||this.autocomplete.visibleOptions[0]}get tags(){return this.autocomplete.tags}get template(){return this.autocomplete.querySelector('[data-behavior="tag-template"]')}}class Et{constructor(t){this.cachedOptions="",this.autocomplete=t,this.makeRequest=function(e,i){let s;function t(...t){clearTimeout(s),s=setTimeout(()=>{e.apply(this,t)},i)}return t.clear=()=>{clearTimeout(s)},t}(this.makeRequest.bind(this),300)}async search(t){this.autocomplete.setAttribute("loading",""),this.autocomplete.removeAttribute("error"),await this.makeRequest(t)}start(){this.cachedOptions?this.insertOptions(this.cachedOptions,{cached:!0}):this.search("")}stop(){}async makeRequest(t){var e=(this.emit("loadstart"),null!=(e=this.abortController)&&e.abort(),this.abortController=new AbortController)["signal"],i=new URL(this.autocomplete.src,window.location.href),s=new URLSearchParams(i.search.slice(1));s.append(this.autocomplete.param,t),i.search=s.toString();try{var o=await fetch(i.toString(),{signal:e,credentials:"same-origin",headers:{accept:"text/fragment+html"}});if(!o.ok)throw new Error(await o.text());var n=await o.text();""===t&&(this.cachedOptions=n),await this.insertOptions(n),this.abortController=void 0,this.emit("load"),this.autocomplete.removeAttribute("loading"),this.emit("loadend")}catch(t){t instanceof Error&&"AbortError"===t.name||(this.abortController=void 0,this.autocomplete.setAttribute("error",""),this.emit("error"),this.autocomplete.removeAttribute("loading"),this.emit("loadend"))}}async insertOptions(t,{cached:e=!1}={}){this.autocomplete.optionsContainer.innerHTML=t,this.autocomplete.checkIfListIsEmpty(),e||this.autocomplete.combobox.initializeOptions(),this.autocomplete.selectVariant.start(),await this.autocomplete.reposition()}emit(t){this.autocomplete.emit(t,{bubbles:!1,prefix:!1})}}class At{constructor(t){this.defaultValue="",this.defaultText="",this.autocomplete=t}connected(){var t;this.defaultValue=this.hiddenField.value,this.defaultText=null!=(t=this.hiddenField.getAttribute("data-text"))?t:""}start(){var t;this.selectedOption?(this.autocomplete.combobox.select(this.selectedOption),this.autocomplete.combobox.activate(this.selectedOption,{scroll:!0})):(t=this.autocomplete.visibleOptions[0])&&this.autocomplete.combobox.activate(t,{scroll:!0})}stop(){var t=this.hiddenField.dataset["text"];this.autocomplete.input.value=null!=t?t:""}reset(){this.setValue(this.defaultValue,this.defaultText)}select(t){var e=null!=(e=t.getAttribute("value"))?e:"",t=t.dataset["text"];this.setValue(e,t||""),this.autocomplete.hide()}setValue(t,e){this.hiddenField.value=t;e=e.trim();this.hiddenField.setAttribute("data-text",e),this.autocomplete.input.value=e,this.autocomplete.toggleSelectedClass(!!t)}clear(){this.setValue("","")}set required(t){this.autocomplete.input.required=t}get selectedOption(){return this.autocomplete.options.find(t=>t.getAttribute("value")===this.autocomplete.value)}get hiddenField(){return this.autocomplete.querySelector('input[data-behavior="hidden-field"]')}}let p=class extends l{constructor(){super(),this.open=!1,this.disabled=!1,this.required=!1,this.multiple=!1,this.param="q",this.autoSize=!1,this.autoSizePadding=4,this.firstFocus=!0,this.preventOutsideClickEvent=!1,this.handleFormReset=this.handleFormReset.bind(this)}connected(){var t;null!=(t=this.form)&&t.addEventListener("reset",this.handleFormReset),this.floatingUI=gt(this,{referenceElement:this.control,popupElement:this.listbox,placement:"bottom",sync:"width",offsetOptions:4,autoSize:this.autoSize?"height":void 0,autoSizePadding:this.autoSizePadding}),bt(this,{boundaries:[this.control,this.listbox],callback:(t,e)=>{this.preventOutsideClickEvent&&!ft(e)?t.preventDefault():this.open&&this.hide(),this.preventOutsideClickEvent=!1}}),this.combobox=new lt(this.input,this.listbox,{multiple:this.multiple}),this.selectVariant=new(this.multiple?wt:At)(this),this.selectVariant.connected(),this.searchVariant=new(this.src?Et:yt)(this),this.selectVariant.required=this.required}disconnected(){var t;this.hide(),null!=(t=this.form)&&t.removeEventListener("reset",this.handleFormReset),this.firstFocus=!0,this.preventOutsideClickEvent=!1}disabledChanged(t){this.input.disabled=t,this.clearButton&&(this.clearButton.disabled=t);for(const e of this.tagDismissButtons)e.disabled=t}requiredChanged(t){this.selectVariant.required=t}srcChanged(t){this.clear(),this.searchVariant=new(t?Et:yt)(this)}handleMousedown(t){t.target!==this.input&&t.preventDefault()}handleClick(t){this.disabled||(this.focus(),t.target.hasAttribute("data-trigger")&&this.show(),this.firstFocus&&this.input.value&&this.input.select(),this.firstFocus=!1)}handleInputMousedown(t){this.disabled||1===t.buttons&&this.show()}async handleInputBlur(){this.preventOutsideClickEvent=this.open,await this.hide(),this.firstFocus=!0}handleInputKeydown(t){var e,i,s;switch(t.key){case"Enter":this.open&&t.preventDefault();break;case"Escape":this.open&&(t.preventDefault(),t.stopPropagation(),this.hide());break;case"ArrowDown":t.altKey&&!this.open&&(t.preventDefault(),this.show());break;case"ArrowUp":t.altKey&&this.open&&(t.preventDefault(),this.hide());break;case"Backspace":this.multiple&&!this.input.value&&(e=this.removeLastTag())&&(t.preventDefault(),i=null!=(i=e.getAttribute("value"))?i:"",s=e.dataset["text"],this.emit("remove",{detail:{target:e,value:i,text:s||""}}))}}handleCommit(t){t.stopPropagation();var e,i,t=t.target;t instanceof HTMLElement&&(this.selectVariant.select(t),e=null!=(e=t.getAttribute("value"))?e:"",i=t.dataset["text"],this.emit("commit",{detail:{target:t,value:e,text:i||""}}))}handleFormReset(){this.reset(),this.hide(),this.emit("reset")}handleClear(){this.clear(),this.hide(),this.emit("clear")}handleTagRemove(t){var e,i,t=t.target.closest('[data-behavior="tag"]');t&&(this.removeTag(t),e=null!=(e=t.getAttribute("value"))?e:"",i=t.dataset["text"],this.emit("remove",{detail:{target:t,value:e,text:i||""}}))}handleInput(t){var t=t["target"];t instanceof HTMLInputElement&&(t=t.value.trim(),this.show(),this.searchVariant.search(t))}show(){this.open||(this.emit("show"),this.open=!0,this.floatingUI.start(),this.combobox.start(),this.selectVariant.start(),this.searchVariant.start(),this.emit("shown"))}async hide(){this.open&&(this.emit("hide"),this.open=!1,this.combobox.stop(),this.selectVariant.stop(),this.searchVariant.stop(),this.removeAttribute("no-options"),this.removeAttribute("error"),await this.floatingUI.stop(),this.emit("hidden"))}setValue(e,t){var i=this.options.find(t=>t.getAttribute("value")===e),t=t||(null==i?void 0:i.getAttribute("data-text"))||"";this.selectVariant.setValue(e,t)}removeValue(t){this.multiple&&t?this.selectVariant.removeValue(t):this.selectVariant.clear()}activate(t,{scroll:e=!0}={}){this.combobox.activate(t,{scroll:e})}deactivate(){this.combobox.deactivate()}focus(t){this.input.focus(t)}blur(){this.input.blur()}reset(){this.selectVariant.reset()}clear(){this.selectVariant.clear()}async reposition(){await this.floatingUI.update()}removeLastTag(){var t=this.tags[this.tags.length-1];if(t)return this.removeTag(t),t}removeTag(t){t=t.getAttribute("value");t&&this.removeValue(t)}checkIfListIsEmpty(){this.toggleAttribute("no-options",0===this.visibleOptions.length)}toggleSelectedClass(t){this.classList.toggle("awc-autocomplete--selected",t)}get value(){var t;return this.multiple?this.tags.map(t=>{return null!=(t=t.getAttribute("value"))?t:""}):null!=(t=null==(t=this.querySelector('input[data-behavior="hidden-field"]'))?void 0:t.value)?t:""}get options(){return this.combobox.options}get visibleOptions(){return this.options.filter(t=>!t.hidden)}get activeOption(){return this.combobox.activeOption}get form(){return this.closest("form")}get tags(){return[...this.querySelectorAll('[data-behavior="tag"]')]}};t([i({type:Boolean})],p.prototype,"open",void 0),t([i({type:Boolean})],p.prototype,"disabled",void 0),t([i({type:Boolean})],p.prototype,"required",void 0),t([i({type:Boolean})],p.prototype,"multiple",void 0),t([i()],p.prototype,"src",void 0),t([i()],p.prototype,"param",void 0),t([i({type:Boolean})],p.prototype,"autoSize",void 0),t([i({type:Number})],p.prototype,"autoSizePadding",void 0),t([o()],p.prototype,"control",void 0),t([o()],p.prototype,"input",void 0),t([o()],p.prototype,"listbox",void 0),t([o()],p.prototype,"optionsContainer",void 0),t([o()],p.prototype,"clearButton",void 0),t([I()],p.prototype,"tagDismissButtons",void 0),t([I()],p.prototype,"groups",void 0),p=t([s("awc-autocomplete")],p);const m=new Set;let v=class extends l{constructor(){super(...arguments),this.open=!1,this.hideOnOutsideClick=!0}connected(){this.open&&this.show()}disconnected(){this.hideWithoutEmitting()}show(){this.dialog.showModal(),this.hideOverflow(),this.open=!0}hide(){this.hideWithoutEmitting(),this.emit("hidden")}handleClick(t){var e;this.hideOnOutsideClick&&!t.defaultPrevented&&(e=t.target)instanceof HTMLElement&&e===this.dialog&&((e=e.getBoundingClientRect()).top<=t.clientY&&t.clientY<=e.top+e.height&&e.left<=t.clientX&&t.clientX<=e.left+e.width||this.hide())}handleKeydown(t){"Escape"===t.key&&(t.stopPropagation(),this.emit("hidden"))}hideWithoutEmitting(){var t;this.dialog.open&&(this.dialog.close(),null!=(t=this.nestedDialog))&&t.hide(),this.showOverflow(),this.open=!1}hideOverflow(){this._scrollLockController=function(t,{abortSignal:e}={}){m.add(t);var i,s=new AbortController,e=e||s.signal,o=window.innerWidth-document.documentElement.clientWidth;let n,r;return void 0===n&&0<o&&(i=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10),n=document.body.style.paddingRight,document.body.style.paddingRight=i+o+"px"),void 0===r&&(r=document.body.style.overflow,document.body.style.overflow="hidden"),e.addEventListener("abort",()=>{m.delete(t),0===m.size&&(void 0!==n&&(document.body.style.paddingRight=n,n=void 0),void 0!==r)&&(document.body.style.overflow=r,r=void 0)}),s}(this)}showOverflow(){var t;null!=(t=this._scrollLockController)&&t.abort()}get nestedDialog(){return this.querySelector(this.identifier)}};t([i({type:Boolean})],v.prototype,"open",void 0),t([i({type:Boolean})],v.prototype,"hideOnOutsideClick",void 0),t([o()],v.prototype,"dialog",void 0),v=t([s("awc-dialog")],v);var f=class extends Event{oldState;newState;constructor(t,{oldState:e="",newState:i="",...s}={}){super(t,s),this.oldState=String(e||""),this.newState=String(i||"")}},Ot=new WeakMap;function kt(t,e,i){Ot.set(t,setTimeout(()=>{Ot.has(t)&&t.dispatchEvent(new f("toggle",{cancelable:!1,oldState:e,newState:i}))},0))}var g=globalThis.ShadowRoot||function(){},St=globalThis.HTMLDialogElement||function(){},b=new WeakMap,w=new WeakMap,E=new WeakMap;function A(t){return E.get(t)||"hidden"}var O=new WeakMap;function k(t,e){return("auto"===t.popover||"manual"===t.popover)&&t.isConnected&&!(e&&"showing"!==A(t)||!e&&"hidden"!==A(t)||t instanceof St&&t.hasAttribute("open")||document.fullscreenElement===t)}function xt(t){return t?Array.from(w.get(t.ownerDocument)||[]).indexOf(t)+1:0}function Lt(t){var e=Mt(t),t=function(t){for(;t;){var e=t.popoverTargetElement;if(e instanceof HTMLElement)return e;if((t=(t=t.parentElement||x(t))instanceof g?t.host:t)instanceof Document)return}}(t);return xt(e)>xt(t)?e:t}function S(t){var e=w.get(t);for(const i of e||[]){if(i.isConnected)return i;e.delete(i)}return null}function x(t){return"function"==typeof t.getRootNode?t.getRootNode():t.parentNode?x(t.parentNode):t}function Mt(t){for(;t;){if(t instanceof HTMLElement&&"auto"===t.popover&&"showing"===E.get(t))return t;if((t=(t=t instanceof Element&&t.assignedSlot||t.parentElement||x(t))instanceof g?t.host:t)instanceof Document)return}}function Tt(t){if(t.shadowRoot&&!0!==t.shadowRoot.delegatesFocus)return null;let e=t,i=(e=e.shadowRoot?e.shadowRoot:e).querySelector("[autofocus]");if(i)return i;for(const r of e.querySelectorAll("slot"))for(const a of r.assignedElements({flatten:!0})){if(a.hasAttribute("autofocus"))return a;if(i=a.querySelector("[autofocus]"))return i}var s,o=t.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=o.currentNode;for(;n;){if(!((s=n).hidden||s instanceof g||(s instanceof HTMLButtonElement||s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement||s instanceof HTMLOptGroupElement||s instanceof HTMLOptionElement||s instanceof HTMLFieldSetElement)&&s.disabled||s instanceof HTMLInputElement&&"hidden"===s.type||s instanceof HTMLAnchorElement&&""===s.href||"number"!=typeof s.tabIndex||-1===s.tabIndex))return n;n=o.nextNode()}}var L=new WeakMap;function M(e){if(k(e,!1)){var i=e.ownerDocument;if(e.dispatchEvent(new f("beforetoggle",{cancelable:!0,oldState:"closed",newState:"open"}))&&k(e,!1)){let t=!1;if("auto"===e.popover){var s=e.getAttribute("popover");if(P(function(t){const e=new Map;let i=0;for(const n of w.get(t.ownerDocument)||[])e.set(n,i),i+=1;e.set(t,i),i+=1;let s=null;var o;return t=t.parentElement||x(t),s=null!==(t=Mt(t))&&(o=e.get(t),null===s||e.get(s)<o)?t:s}(e)||i,!1,!0),s!==e.getAttribute("popover")||!k(e,!1))return}S(i)||(t=!0),L.delete(e);s=i.activeElement;e.classList.add(":popover-open"),E.set(e,"showing"),b.has(i)||b.set(i,new Set),b.get(i).add(e),Tt(e)?.focus(),"auto"===e.popover&&(w.has(i)||w.set(i,new Set),w.get(i).add(e),Vt(O.get(e),!0)),t&&s&&"auto"===e.popover&&L.set(e,s),kt(e,"closed","open")}}}function T(t,e=!1,i=!1){var s;k(t,!0)&&(s=t.ownerDocument,"auto"===t.popover&&(P(t,e,i),!k(t,!0))||(Vt(O.get(t),!1),O.delete(t),i&&(t.dispatchEvent(new f("beforetoggle",{oldState:"open",newState:"closed"})),!k(t,!0)))||(b.get(s)?.delete(t),w.get(s)?.delete(t),t.classList.remove(":popover-open"),E.set(t,"hidden"),i&&kt(t,"open","closed"),(s=L.get(t))&&(L.delete(t),e)&&s.focus()))}function Pt(t,e=!1,i=!1){let s=S(t);for(;s;)T(s,e,i),s=S(t)}function P(t,e,i){var s=t.ownerDocument||t;if(t instanceof Document)return Pt(s,e,i);let o=null,n=!1;for(const r of w.get(s)||[])if(r===t)n=!0;else if(n){o=r;break}if(!n)return Pt(s,e,i);for(;o&&"showing"===A(o)&&w.get(s)?.size;)T(o,e,i)}var C=new WeakMap;function Ct(t){var e,i;t.isTrusted&&(i=t.composedPath()[0])&&S(e=i.ownerDocument)&&((i=Lt(i))&&"pointerdown"===t.type?C.set(e,i):"pointerup"===t.type&&(t=C.get(e)===i,C.delete(e),t)&&P(i||e,!1,!0))}var Nt=new WeakMap;function Vt(t,e=!1){var i;t&&(Nt.has(t)||Nt.set(t,t.getAttribute("aria-expanded")),(i=t.popoverTargetElement)instanceof HTMLElement&&"auto"===i.popover?t.setAttribute("aria-expanded",String(e)):(i=Nt.get(t))?t.setAttribute("aria-expanded",i):t.removeAttribute("aria-expanded"))}var Dt=globalThis.ShadowRoot||function(){};function N(t,e,i){const s=t[e];Object.defineProperty(t,e,{value(t){return s.call(this,i(t))}})}var qt=/(^|[^\\]):popover-open\b/g;function It(){var t="function"==typeof globalThis.CSSLayerBlockRule;return`
6
- ${t?"@layer popover-polyfill {":""}
7
- :where([popover]) {
8
- position: fixed;
9
- z-index: 2147483647;
10
- inset: 0;
11
- padding: 0.25em;
12
- width: fit-content;
13
- height: fit-content;
14
- border-width: initial;
15
- border-color: initial;
16
- border-image: initial;
17
- border-style: solid;
18
- background-color: canvas;
19
- color: canvastext;
20
- overflow: auto;
21
- margin: auto;
22
- }
23
-
24
- :where([popover]:not(.\\:popover-open)) {
25
- display: none;
26
- }
27
-
28
- :where(dialog[popover].\\:popover-open) {
29
- display: block;
30
- }
31
-
32
- :where(dialog[popover][open]) {
33
- display: revert;
34
- }
35
-
36
- :where([anchor].\\:popover-open) {
37
- inset: auto;
38
- }
39
-
40
- :where([anchor]:popover-open) {
41
- inset: auto;
42
- }
43
-
44
- @supports not (background-color: canvas) {
45
- :where([popover]) {
46
- background-color: white;
47
- color: black;
48
- }
49
- }
50
-
51
- @supports (width: -moz-fit-content) {
52
- :where([popover]) {
53
- width: -moz-fit-content;
54
- height: -moz-fit-content;
55
- }
56
- }
57
-
58
- @supports not (inset: 0) {
59
- :where([popover]) {
60
- top: 0;
61
- left: 0;
62
- right: 0;
63
- bottom: 0;
64
- }
65
- }
66
- ${t?"}":""}
67
- `}var V=null;function Bt(t){var e,i=It();if(null===V)try{(V=new CSSStyleSheet).replaceSync(i)}catch{V=!1}!1===V?((e=document.createElement("style")).textContent=i,(t instanceof Document?t.head:t).prepend(e)):t.adoptedStyleSheets=[V,...t.adoptedStyleSheets]}function Rt(){if("undefined"!=typeof window){window.ToggleEvent=window.ToggleEvent||f,N(Document.prototype,"querySelector",e),N(Document.prototype,"querySelectorAll",e),N(Element.prototype,"querySelector",e),N(Element.prototype,"querySelectorAll",e),N(Element.prototype,"matches",e),N(Element.prototype,"closest",e),N(DocumentFragment.prototype,"querySelectorAll",e),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){var t;return this.hasAttribute("popover")?""===(t=(this.getAttribute("popover")||"").toLowerCase())||"auto"==t?"auto":"manual":null},set(t){this.setAttribute("popover",t)}},showPopover:{enumerable:!0,configurable:!0,value(){M(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){T(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(t){"showing"===E.get(this)&&void 0===t||!1===t?T(this,!0,!0):void 0!==t&&!0!==t||M(this)}}});const s=Element.prototype.attachShadow,o=(s&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(t){t=s.call(this,t);return Bt(t),t}}}),HTMLElement.prototype.attachInternals),n=(o&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){var t=o.call(this);return t.shadowRoot&&Bt(t.shadowRoot),t}}}),new WeakMap),r=(i(HTMLButtonElement),i(HTMLInputElement),t=>{var e,i=t.composedPath(),s=i[0];s instanceof Element&&!s?.shadowRoot&&((s=x(s))instanceof Dt||s instanceof Document)&&(s=i.find(t=>t.matches?.("[popovertargetaction],[popovertarget]")))&&((s=(i=s).popoverTargetElement)instanceof HTMLElement&&(e=A(s),"show"===i.popoverTargetAction&&"showing"===e||"hide"===i.popoverTargetAction&&"hidden"===e||("showing"===e?T(s,!0,!0):k(s,!1)&&(O.set(s,i),M(s)))),t.preventDefault())}),a=t=>{var e=t.key,i=t.target;t.defaultPrevented||!i||"Escape"!==e&&"Esc"!==e||P(i.ownerDocument,!0,!0)};var t;function e(t){return t=t?.includes(":popover-open")?t.replace(qt,"$1.\\:popover-open"):t}function i(t){Object.defineProperties(t.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(t){if(null===t)this.removeAttribute("popovertarget"),n.delete(this);else{if(!(t instanceof Element))throw new TypeError("popoverTargetElement must be an element or null");this.setAttribute("popovertarget",""),n.set(this,t)}},get(){var t,e;return"button"!==this.localName&&"input"!==this.localName||"input"===this.localName&&"reset"!==this.type&&"image"!==this.type&&"button"!==this.type||this.disabled||this.form&&"submit"===this.type?null:(t=n.get(this))&&t.isConnected?t:t&&!t.isConnected?(n.delete(this),null):(t=x(this),e=this.getAttribute("popovertarget"),(t instanceof Document||t instanceof Dt)&&e&&t.getElementById(e)||null)}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){var t=(this.getAttribute("popovertargetaction")||"").toLowerCase();return"show"===t||"hide"===t?t:"toggle"},set(t){this.setAttribute("popovertargetaction",t)}}})}(t=document).addEventListener("click",r),t.addEventListener("keydown",a),t.addEventListener("pointerdown",Ct),t.addEventListener("pointerup",Ct),Bt(document)}}"undefined"!=typeof HTMLElement&&"object"==typeof HTMLElement.prototype&&"popover"in HTMLElement.prototype||Rt();const D=new Set;let q=class extends l{constructor(){super(...arguments),this.placement="bottom",this.strategy="fixed",this.clickBoundaries=[]}connected(){this.floatingUI=gt(this,{referenceElement:this.button,popupElement:this.panel,arrowElement:this.arrow,arrowPadding:this.arrowPadding,placement:this.placement,strategy:this.strategy,offsetOptions:8,flipOptions:{fallbackAxisSideDirection:"end"}}),bt(this,{boundaries:this.boundaries,callback:(t,e)=>{this.open&&!this.hasNestedOpenPopovers&&(this.hide(),ft(e)||(t.preventDefault(),this.button.focus()))}})}disconnected(){this.hide()}async handleToggle(){this.open?(D.add(this),this.closeOtherPopovers(),this.emit("show"),this.button.setAttribute("aria-expanded","true"),this.floatingUI.start(),this.emit("shown")):(this.emit("hide"),this.button.setAttribute("aria-expanded","false"),await this.floatingUI.stop(),D.delete(this),this.emit("hidden"))}toggle(){this.panel.togglePopover()}show(){this.open||this.panel.showPopover()}hide(t){this.open&&(this.panel.hidePopover(),t)&&this.button.focus()}handleKeydown(t){var e;"Escape"!==t.key||(e=t.target.closest(this.identifier))!==this&&null!=e&&e.open||this.open&&(t.preventDefault(),t.stopPropagation(),this.hide(),this.button.focus())}async reposition(){await this.floatingUI.update()}closeOtherPopovers(){for(const t of D)t===this||t.contains(this)||t.hide()}get hasNestedOpenPopovers(){var t=[...D].find(t=>t===this);return!!t&&Array.from(t.querySelectorAll(this.identifier)).some(t=>D.has(t))}get arrowPadding(){return st(getComputedStyle(this.panel).borderRadius)||2}get boundaries(){return this.clickBoundaries.map(t=>document.querySelector(t)).concat([this.button,this.panel])}get open(){if(!this.panel)return!1;try{return this.panel.matches(":popover-open")}catch(t){return this.panel.matches(".\\:popover-open")}}};t([i()],q.prototype,"placement",void 0),t([i()],q.prototype,"strategy",void 0),t([i({type:Array})],q.prototype,"clickBoundaries",void 0),t([o()],q.prototype,"button",void 0),t([o()],q.prototype,"panel",void 0),t([o()],q.prototype,"arrow",void 0),q=t([s("awc-popover")],q)});
5
+ `.trim()))})}connect(t,e){var i,n;this.targetsByKey.add(t,e),this.orderedByKey.delete(t),this.isKeyMultiple(t)||(n=(i=this.departedByKey.get(t))?.element===e&&i.delivery===b(),this.heldSinceByKey.set(t,n?i.since:b())),this.invokeCallback(t,e,"connected")}takesOver(t,e,i){return this.heldSinceByKey.get(t)===b()&&ce(i,e)<0&&this.claims(i,t)&&this.claims(e,t)}handOver(e,t,i){var n=this.tokensByElement.valuesForKey(t).filter(t=>O(t.content).key===e);for(const s of n)this.tokensByElement.delete(t,s),this.waitingByKey.add(e,s);try{this.invokeCallback(e,t,"disconnected")}finally{this.targetsByKey.delete(e,t),this.stopWatching&&(n[0]&&this.reportIfLeftWaiting(e,n[0]),this.tokensByElement.add(i.element,i),p(()=>this.connect(e,i.element)))}}keptForMovedTarget(t,e){var i=this.departedByKey.get(t);return void 0!==i&&i.element!==e&&i.delivery===b()&&i.since!==i.delivery&&this.claims(i.element,t)}adoptWaiting(t,e){if(this.stopWatching&&this.waitingByKey.get(t)&&!this.targetsByKey.get(t)&&(!e||!x.stillRoutesTo(this.instance,e))){var i=this.waitingByKey.valuesForKey(t).filter(t=>x.stillRoutesTo(this.instance,t));const[n]=i.sort((t,e)=>ce(t.element,e.element));if(n){for(const s of i)s.element===n.element&&(this.waitingByKey.delete(t,s),this.tokensByElement.add(s.element,s));p(()=>this.connect(t,n.element))}else e&&Promise.resolve().then(()=>S(()=>this.adoptWaiting(t)))}}orderedTargets(t){let e=this.orderedByKey.get(t);return e||(e=this.targetsByKey.valuesForKey(t).sort(ce),this.orderedByKey.set(t,e)),e}readNow(t,e,i){var n=this.nowByKey.get(t);return n?.version===e?n.value:(n=i(),this.nowByKey.set(t,{version:e,value:n}),n)}stableArray(t,e){var i,n,s=this.stableByKey.get(t);return s===e||s&&(n=e,(i=s).length===n.length)&&i.every((t,e)=>t===n[e])?s:(this.stableByKey.set(t,e),e)}isInDocumentTree(){return this.instance.getRootNode()===document}claimants(t){var e=this.instance,i=`[data-target*="${CSS.escape(this.identifier+"."+t)}"]`,n=[];e.matches(i)&&this.claims(e,t)&&n.push(e);for(const s of e.querySelectorAll(i))this.claims(s,t)&&n.push(s);return n}claimantNow(t){var[e]=this.targetsByKey.valuesForKey(t);return e&&this.claims(e,t)?e:this.claimants(t)[0]??null}claims(t,e){return x.routesTo(this.instance,t,t=>{t=O(t);return t.identifier===this.identifier&&t.key===e})}isStillReferenced(t,e){return this.tokensByElement.valuesForKey(t).some(t=>t.content===e)}isValidIdKeyPair(t,e){return!(!e||t!==this.identifier||!this.declarations.has(e))}invokeCallback(t,e,i){i=this.instance[""+t+((t=i).charAt(0).toUpperCase()+t.slice(1))];"function"==typeof i&&i.call(this.instance,e)}isKeyMultiple(t){return this.declarations.get(t)?.multiple??!1}get identifier(){return this.instance.identifier}}const ue={phase:"idle"},de={phase:"initialized"};class pe extends HTMLElement{constructor(){super(...arguments),this.property=new dt(this),this.target=new he(this),this.action=new ie(this),this._lifecycle=ue}connectedCallback(){var t=this._lifecycle;"tearingDown"===t.phase?t.reconnected=!0:"idle"===t.phase&&this._asyncConnect()}static get observedAttributes(){return Array.from(it(this.prototype,Z).keys(),ht)}attributeChangedCallback(t,e,i){var n=this._lifecycle["phase"];"initialized"!==n&&"tearingDown"!==n||e===i||"function"==typeof(t=this[(n=t.replace(rt,(t,e,i)=>i?i.toUpperCase():"").replace(at,t=>t.toLowerCase()))+"Changed"])&&(n=this.property.change(n,e,i))&&t.call(this,n.newValue,n.oldValue)}disconnectedCallback(){if("initialized"===this._lifecycle.phase){var t={phase:"tearingDown",reconnected:!1},e=(this._lifecycle=t,this.removeAttribute(ne),e=this,re.delete(e),[()=>this.disconnected(),()=>this.action.stop(),()=>this.target.stop(),()=>this.property.stop()]);try{u(e,t=>t())}finally{this._lifecycle=ue,t.reconnected&&this.isConnected&&this._asyncConnect()}}}connected(){}disconnected(){}emit(t,{target:e=this,prefix:i=this.identifier,...n}={}){return[e,i,{detail:t={},...n}={}]=[e,i?i+":"+t:t,n],i=new CustomEvent(i,{bubbles:!0,composed:!0,detail:t,...n}),e.dispatchEvent(i),i}get identifier(){return this.tagName.toLowerCase()}async _asyncConnect(){var t={phase:"initializing"};this._lifecycle=t;try{if(this.property.start(),await Ot(),this.isConnected&&(customElements.upgrade(this),await this._resolveUndefinedElements(),this.isConnected))if(this.target.start(),this.isConnected)if(this.action.start(),this.isConnected){this._lifecycle=de,this.setAttribute(ne,"");var e=this,i=(re.add(e),ae.get(e));if(i){ae.delete(e);for(const n of i)p(()=>n(e))}this.connected()}else this._abandonInit();else this._abandonInit()}finally{this._lifecycle===t&&(this._lifecycle=ue)}}_abandonInit(){this._lifecycle=ue,u([()=>this.action.stop(),()=>this.target.stop()],t=>t())}_resolveUndefinedElements(){var t=Array.from(this.querySelectorAll(":not(:defined)")),e=this.constructor.migratedToWhenInitialized,e=(0<t.length&&!e&&console.warn(`[impulse] <${this.identifier}> waits for descendant custom elements to be defined before invoking target `+"connected callbacks. This is deprecated and will be removed in the next major version. If a connected callback reads properties on a target element, await whenInitialized(target) inside the callback instead. Set ImpulseElement.migratedToWhenInitialized = true to silence this warning."),t.map(t=>customElements.whenDefined(t.localName)));return Promise.all(e)}}function P(t,e){return t===e||"both"===t}function fe(t){return t.split("-")[0]}const N={placement:"bottom",strategy:"fixed",flip:!(pe.migratedToWhenInitialized=!1),keepFlipped:!1,shift:!0};function me(S){let A,E=!1,O=0,x;return{prime:function(){var{floating:t,strategy:e=N.strategy}=S();t&&(t.style.position=e,t.style.top="0px",t.style.left="0px")},reposition:async function(){var t=S();const{anchor:e,floating:i,floatingUI:n={}}=t;if(e&&i){const p=++O,f=()=>p!==O;var s,o,r,a=t.placement??N.placement,l=t.flip??N.flip,c=!0!==l&&l?l:{},h=n.flip?.fallbackPlacements??c.fallbackPlacements,u=(x=l&&t.keepFlipped&&x?.requested===a?x:void 0)?(d=a,o=x.placement,r=h,(u=fe(o))===fe(d)?d:r?o:(r=u,(o=(o=d).split("-")[1])?r+"-"+o:r)):a,d=[C.offset(n.offset??{mainAxis:t.distance??0,crossAxis:t.skidding??0})];const m=t["sync"];m?d.push(C.size({apply:({rects:t})=>{f()||(i.style.width=P(m,"width")?t.reference.width+"px":"",i.style.height=P(m,"height")?t.reference.height+"px":"")}})):(i.style.width="",i.style.height=""),l&&d.push(C.flip({...c,padding:([o=0,{autoSize:r,autoSizePadding:l=0}]=[c.padding,t],r?(l=Math.max(o,l+1),{top:c=P(r,"height")?l:o,bottom:c,left:c=P(r,"width")?l:o,right:c}):o),...n.flip,fallbackPlacements:(l=a,s=u,(c=h)&&s!==l?[l,...c].filter(t=>t!==s):c)}));h=t.shift??N.shift;h&&d.push(C.shift({...!0===h?{}:h,...n.shift}));const v=t["autoSize"];v?(d.push(C.size({padding:t.autoSizePadding??0,apply:({availableWidth:t,availableHeight:e})=>{f()||(P(v,"height")?i.style.setProperty("--awc-auto-size-height",e+"px"):i.style.removeProperty("--awc-auto-size-height"),P(v,"width")?i.style.setProperty("--awc-auto-size-width",t+"px"):i.style.removeProperty("--awc-auto-size-width"))}})),E=!0):E&&(i.style.removeProperty("--awc-auto-size-height"),i.style.removeProperty("--awc-auto-size-width"),E=!1),d.push(...n.middleware??[]);l=t.arrow;l&&d.push(C.arrow({element:l,padding:t.arrowPadding??0}));const{x:y,y:g,placement:b,strategy:w,middlewareData:k}=await C.computePosition(e,i,{placement:u,middleware:d,strategy:t.strategy??N.strategy});if(!f()){if(Object.assign(i.style,{left:y+"px",top:g+"px",position:w}),k.arrow&&l){const{x:y,y:g}=k.arrow;Object.assign(l.style,{left:"number"==typeof y?y+"px":"",top:"number"==typeof g?g+"px":""})}i.setAttribute("x-placement",b),t.keepFlipped&&A&&(x={placement:b,requested:a})}}},start:function(t){var{anchor:e,floating:i}=S();e&&i&&(A?.(),A=C.autoUpdate(e,i,t))},stop:async function(){return x=void 0,new Promise(t=>{A?(A(),A=void 0,requestAnimationFrame(()=>t())):t()})}}}let T=class extends pe{constructor(){super(...arguments),this.placement=N.placement,this.active=!1,this.strategy=N.strategy,this.distance=0,this.skidding=0,this.flip=N.flip,this.flipPadding=0,this.fallbackPlacements=[],this.fallbackStrategy="bestFit",this.keepFlipped=N.keepFlipped,this.shift=N.shift,this.shiftPadding=0,this.autoSizePadding=0,this.positioner=me(()=>this.positioningOptions)}connected(){this.follow()}disconnected(){this.unfollow()}async anchorIdChanged(t){await this.unfollow(),t&&this.anchorElement&&this.follow()}async activeChanged(t){t?this.follow():await this.unfollow()}start(){this.active?this.follow():this.active=!0}async stop(){var t=this.unfollow();return this.active=!1,t}async reposition(){this.active&&this.anchorElement&&await this.positioner.reposition()}follow(){this.anchorElement&&(this.positioner.prime(),this.positioner.start(()=>this.reposition()))}unfollow(){return this.positioner.stop()}get anchorElement(){return document.getElementById(this.anchorId)}get arrowElement(){return this.querySelector("[data-arrow]")}get positioningOptions(){return{anchor:this.anchorElement,floating:this,placement:this.placement,strategy:this.strategy,distance:this.distance,skidding:this.skidding,flip:this.flip&&{padding:this.flipPadding,fallbackPlacements:this.fallbackPlacements.length?this.fallbackPlacements:void 0,fallbackStrategy:this.fallbackStrategy},keepFlipped:this.keepFlipped,shift:this.shift&&{padding:this.shiftPadding},sync:this.sync,autoSize:this.autoSize,autoSizePadding:this.autoSizePadding,arrow:this.arrowElement,arrowPadding:this.arrowPadding}}};t([e()],T.prototype,"anchorId",void 0),t([e()],T.prototype,"placement",void 0),t([e({type:Boolean})],T.prototype,"active",void 0),t([e()],T.prototype,"strategy",void 0),t([e({type:Number})],T.prototype,"distance",void 0),t([e({type:Number})],T.prototype,"skidding",void 0),t([e()],T.prototype,"sync",void 0),t([e({type:Boolean})],T.prototype,"flip",void 0),t([e({type:Number})],T.prototype,"flipPadding",void 0),t([e({type:Array})],T.prototype,"fallbackPlacements",void 0),t([e()],T.prototype,"fallbackStrategy",void 0),t([e({type:Boolean})],T.prototype,"keepFlipped",void 0),t([e({type:Boolean})],T.prototype,"shift",void 0),t([e({type:Number})],T.prototype,"shiftPadding",void 0),t([e()],T.prototype,"autoSize",void 0),t([e({type:Number})],T.prototype,"autoSizePadding",void 0),t([e({type:Number})],T.prototype,"arrowPadding",void 0),T=t([n("awc-anchor")],T);var ve=0;function ye(){return ve+=1,`ambiki-${Math.random().toString().slice(2,6)}-`+ve}function ge(t){return!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled")}var be=!!navigator.userAgent.match(/Macintosh/),we=class{input;list;multiple;isMouseMoving=!1;constructor(t,e,{multiple:i=!1}={}){this.input=t,this.list=e,this.multiple=i,this.list.id||(this.list.id=ye()),this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.multiple&&this.input.setAttribute("aria-multiselectable","true"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-haspopup","listbox"),this.input.setAttribute("aria-autocomplete","list"),this.list.setAttribute("role","listbox"),this.onKeydown=this.onKeydown.bind(this),this.onClick=this.onClick.bind(this),this.onListMouseover=this.onListMouseover.bind(this),this.onListMousemove=this.onListMousemove.bind(this)}start(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","true"),this.input.setAttribute("aria-controls",this.list.id),this.input.addEventListener("keydown",this.onKeydown),this.list.addEventListener("click",this.onClick),this.list.addEventListener("mouseover",this.onListMouseover),this.list.addEventListener("mousemove",this.onListMousemove),this.initializeOptions()}stop(){this.isMouseMoving=!1,this.input.setAttribute("aria-expanded","false"),this.input.removeAttribute("aria-controls"),this.input.removeEventListener("keydown",this.onKeydown),this.list.removeEventListener("click",this.onClick),this.list.removeEventListener("mouseover",this.onListMouseover),this.list.removeEventListener("mousemove",this.onListMousemove),this.deselectAll(),this.deactivate()}onKeydown(t){if(this.isMouseMoving=!1,!(t.shiftKey||t.metaKey||t.altKey||!be&&t.ctrlKey))switch(t.key){case"Enter":case"Tab":this.activeOption&&ge(this.activeOption)&&(t.preventDefault(),t.stopPropagation(),this.activeOption.click());break;case"Escape":this.deactivate();break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(1):this.activate(this.visibleOptions[0],{scroll:!0});break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.activeOption?this.move(-1):this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;case"Home":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[0],{scroll:!0});break;case"End":t.preventDefault(),t.stopPropagation(),this.activate(this.visibleOptions[this.visibleOptions.length-1],{scroll:!0});break;default:t.ctrlKey||this.deactivate()}}onClick(t){t=ke(t.target);t&&ge(t)&&(this.multiple&&this.isSelected(t)?this.deselect(t):this.select(t),t.dispatchEvent(new CustomEvent("combobox:commit",{bubbles:!0})))}onListMouseover(t){var e;this.isMouseMoving?(e=ke(t.target))&&this.activate(e):t.preventDefault()}onListMousemove(t){!this.isMouseMoving&&(this.isMouseMoving=!0,t=ke(t.target))&&this.activate(t)}select(t){if(this.multiple)t.setAttribute("aria-selected","true");else for(var e of this.options)e.setAttribute("aria-selected",(e===t).toString())}deselect(t){t.setAttribute("aria-selected","false")}deselectAll(){for(var t of this.options)this.deselect(t)}activate(t,{scroll:e=!1}={}){for(var i of this.options)i.id===t.id?(i.setAttribute("data-active",""),this.input.setAttribute("aria-activedescendant",i.id),e&&i.scrollIntoView({block:"nearest"})):i.removeAttribute("data-active")}deactivate(){this.input.removeAttribute("aria-activedescendant");for(var t of Array.from(this.list.querySelectorAll('[role="option"][data-active]')))t.removeAttribute("data-active")}isSelected(t){return"true"===t.getAttribute("aria-selected")}get options(){return Array.from(this.list.querySelectorAll('[role="option"]'))}get visibleOptions(){return this.options.filter(Se)}get activeOption(){return this.list.querySelector("[data-active]")}move(t){this.activeOption&&(t=function(t,e,i){let n=t.indexOf(e),s=(n===t.length-1&&1===i&&(n=-1),1===i?0:t.length-1);return t[s=e&&0<=n&&0<=(e=n+i)&&e<t.length?e:s]}(this.visibleOptions,this.activeOption,t),this.activate(t,{scroll:!0}))}initializeOptions(){for(var t of this.options)t.setAttribute("tabindex","-1"),t.id||(t.id=ye()),t.hasAttribute("aria-selected")||this.deselect(t)}};function ke(t){return t&&t.closest('[role="option"]')||!1}function Se(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(0<t.offsetWidth||0<t.offsetHeight)}function Ae(t,e){void 0===e&&(e=!0);var i=null==t||null==(i=t.getAttribute)?void 0:i.call(t,"inert");return""===i||"true"===i||e&&t&&("function"==typeof t.closest?t.closest("[inert]"):Ae(t.parentNode))}function Ee(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))}function Oe(t){var e,i;if(t)return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||""===(i=null==(e=t)||null==(i=e.getAttribute)?void 0:i.call(e,"contenteditable"))||"true"===i)&&!Ee(t)?0:t.tabIndex;throw new Error("No node provided")}function xe(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex}function Ce(t){return"INPUT"===t.tagName}function Pe(t){if(!t.name)return 1;function e(t){return i.querySelectorAll('input[type="radio"][name="'+t+'"]')}var i=t.form||Ie(t);if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)n=e(window.CSS.escape(t.name));else try{n=e(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),0}var n=function(t,e){for(var i=0;i<t.length;i++)if(t[i].checked&&t[i].form===e)return t[i]}(n,t.form);return!n||n===t}function Ne(t){return Ce(e=t)&&"radio"===e.type&&!Pe(t);var e}function Te(t){var e=(t=t.getBoundingClientRect()).width,t=t.height;return 0===e&&0===t}function Me(t,e){var i=e.displayCheck,n=e.getShadowRoot;if("full-native"===i&&"checkVisibility"in t)return!t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if("hidden"===(e=getComputedStyle(t).visibility)||"collapse"===e)return 1;if(e=M.call(t,"details>summary:first-of-type")?t.parentElement:t,M.call(e,"details:not([open]) *"))return 1;if(i&&"full"!==i&&"full-native"!==i&&"legacy-full"!==i){if("non-zero-area"===i)return Te(t)}else{if("function"==typeof n){for(e=t;t;){var s=t.parentElement,o=Ie(t);if(s&&!s.shadowRoot&&!0===n(s))return Te(t);t=t.assignedSlot||(s||o===t.ownerDocument?s:o.host)}t=e}if(function(t){var e,i=t&&Ie(t),n=null==(e=i)?void 0:e.host,s=!1;if(i&&i!==t)for(s=!!(null!=(e=n)&&null!=(e=e.ownerDocument)&&e.contains(n)||null!=t&&null!=(e=t.ownerDocument)&&e.contains(t));!s&&n;)var o,s=!(null==(o=n=null==(o=i=Ie(n))?void 0:o.host)||null==(o=o.ownerDocument)||!o.contains(n));return s}(t))return!t.getClientRects().length;if("legacy-full"!==i)return 1}}var i=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","area[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Be=i.join(","),Le="undefined"==typeof Element,M=Le?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ie=!Le&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},qe=function(t,e,i){var n;return Ae(t)?[]:(n=Array.prototype.slice.apply(t.querySelectorAll(Be)),e&&M.call(t,Be)&&n.unshift(t),n.filter(i))},Ke=function(t,e,i){for(var n=[],s=Array.from(t);s.length;){var o,r,a=s.shift();Ae(a,!1)||("SLOT"===a.tagName?(o=(o=a.assignedElements()).length?o:a.children,o=Ke(o,!0,i),i.flatten?n.push.apply(n,o):n.push({scopeParent:a,candidates:o})):(M.call(a,Be)&&i.filter(a)&&(e||!t.includes(a))&&n.push(a),o=a.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(a),r=!Ae(o,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a)),o&&r?(r=Ke((!0===o?a:o).children,!0,i),i.flatten?n.push.apply(n,r):n.push({scopeParent:a,candidates:r})):s.unshift.apply(s,a.children)))}return n},Fe=function(t,e){var i;return!(e.disabled||Ce(i=e)&&"hidden"===i.type||Me(e,t)||"DETAILS"===(i=e).tagName&&Array.prototype.slice.apply(i.children).some(function(t){return"SUMMARY"===t.tagName})||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var i=0;i<e.children.length;i++){var n=e.children.item(i);if("LEGEND"===n.tagName)return!!M.call(e,"fieldset[disabled] *")||!n.contains(t)}return!0}e=e.parentElement}return!1}(e))},Ve=function(t,e){return!(Ne(e)||Oe(e)<0||!Fe(t,e))},De=function(t){t=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(t)||0<=t)},Re=function(t){var a=[],l=[];return t.forEach(function(t,e){var i,n=!!t.scopeParent,s=n?t.scopeParent:t,o=(o=n,(i=Oe(r=s))<0&&o&&!Ee(r)?0:i),r=n?Re(t.candidates):s;0===o?n?a.push.apply(a,r):a.push(s):l.push({documentOrder:e,tabIndex:o,item:t,isScope:n,content:r})}),l.sort(xe).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(a)},ze=i.concat("iframe:not([inert]):not([inert] *)").join(",");function We(t){let e=t;for(;null!==e;){if(function(t,e){if(e=e||{},t)return!1!==M.call(t,ze)&&Fe(e,t);throw new Error("No node provided")}(e)||e.hasAttribute("data-loosely-focusable"))return 1;e=e.parentElement}}const _e=new WeakMap;function je(t,e){let i=_e.get(t);if(!i){i=[],_e.set(t,i);{var n=i;const s=t.disconnected.bind(t);Object.assign(t,{disconnected(){for(const t of n.splice(0).reverse())t();s()}})}}i.push(e)}function Ue(t,e){const f=function(t){if("function"==typeof t)return t;const e={...t};return()=>e}(e),i=me(()=>{return[{anchorElement:t,floatingElement:e,arrowElement:i,arrowPadding:n=0,middleware:s=[],offsetOptions:o=0,placement:r,flipOptions:a,shiftOptions:l,keepFlipped:c,strategy:h,sync:u,autoSize:d,autoSizePadding:p=0}]=[f()],{anchor:t,floating:e,placement:r,keepFlipped:c,strategy:h,sync:u,autoSize:d,autoSizePadding:p,arrow:i,arrowPadding:n,floatingUI:{offset:o,flip:a,shift:l,middleware:s}};var t,e,i,n,s,o,r,a,l,c,h,u,d,p});async function n(){t.open&&await i.reposition()}function s(){return i.stop()}return i.prime(),i.reposition(),je(t,()=>{s()}),{start:function(){i.start(n)},update:n,stop:s}}function He(t,{boundaries:n,callback:s}){const e=new AbortController;var i=e["signal"];let o=null;function r(){o=null}document.addEventListener("mousedown",function(t){o=0<t.button?null:t.composedPath?.()?.[0]||t.target},{capture:!0,signal:i}),document.addEventListener("click",function(t){var e=o;if(o=null,e&&!t.defaultPrevented&&e.getRootNode().contains(e)&&e.isConnected){for(const i of n)if(null!==i){if(i.contains(e))return;if(t.composed&&t.composedPath().includes(i))return}s(t,e)}},{capture:!0,signal:i}),document.addEventListener("contextmenu",r,{capture:!0,signal:i}),document.addEventListener("dragstart",r,{capture:!0,signal:i}),je(t,()=>{r(),e.abort()})}class Qe extends pe{constructor(){super(...arguments),this._opened=!1}connected(){this.open&&this.openQuietly({initial:!0})}disconnected(){this.closeQuietly()}openChanged(t){t?this.show():this.hide()}requestShow(){le(this)&&!this._opened&&this.emitRequest("show")&&this.othersAllowShow()&&this.show()}async requestHide(t){this._opened&&this.emitRequest("hide")&&await this.hide(t)}show(){this._opened||(le(this)?(this.openQuietly({initial:!1}),this.emit("shown")):this.open=!0)}async hide(t){this._opened?(t=this.closeQuietly(t),this.open=!1,t&&await t,this._opened||this.emit("hidden")):this.open=!1}get opened(){return this._opened}othersAllowShow(){return!0}emitRequest(t){return!this.emit(t,{cancelable:!0}).defaultPrevented}closeQuietly(t){if(this._opened)return this._opened=!1,this.closeParts(t)}openQuietly(t){this._opened=!0,this.open=!0;try{this.openParts(t)}catch(t){throw this._opened=!1,this.open=!1,t}}}function $e(t){return{target:t,value:t.getAttribute("value")??"",text:t.dataset.text||""}}const Je={bubbles:!1,prefix:!1};class Xe{constructor(t){this.cachedOptions="",this.autocomplete=t,this.debouncedRequest=function(e,i){let n;function t(...t){clearTimeout(n),n=setTimeout(()=>{e.apply(this,t)},i)}return t.clear=()=>{clearTimeout(n)},t}(t=>this.makeRequest(t),300)}search(t){this.autocomplete.setAttribute("loading",""),this.autocomplete.removeAttribute("error"),this.autocomplete.combobox.deactivate(),this.abortController?.abort(),this.debouncedRequest(t)}start(){this.cachedOptions?this.insertOptions(this.cachedOptions,{cached:!0}):this.search("")}stop(){}disconnected(){var t=Boolean(this.abortController);this.debouncedRequest.clear(),this.abortController?.abort(),this.abortController=void 0,this.autocomplete.removeAttribute("loading"),t&&this.emit("loadend")}async makeRequest(t){this.emit("loadstart"),this.abortController?.abort();var e=(this.abortController=new AbortController)["signal"],i=new URL(this.autocomplete.src,window.location.href),n=new URLSearchParams(i.search.slice(1));n.append(this.autocomplete.param,t),i.search=n.toString();try{var s=await fetch(i.toString(),{signal:e,credentials:"same-origin",headers:{accept:"text/fragment+html"}});if(!s.ok)throw new Error(await s.text());var o=await s.text();""===t&&(this.cachedOptions=o),await this.insertOptions(o),this.abortController=void 0,this.emit("load"),this.autocomplete.removeAttribute("loading"),this.emit("loadend")}catch(t){t instanceof Error&&"AbortError"===t.name||(this.abortController=void 0,this.autocomplete.open&&this.autocomplete.setAttribute("error",""),this.emit("error"),this.autocomplete.removeAttribute("loading"),this.emit("loadend"))}}async insertOptions(t,{cached:e=!1}={}){this.autocomplete.optionsContainer.innerHTML=t,e||this.autocomplete.combobox.initializeOptions(),this.autocomplete.open&&(this.autocomplete.checkIfListIsEmpty(),this.autocomplete.selectVariant.start(),await this.autocomplete.reposition())}emit(t){this.autocomplete.emit(t,Je)}}class Ye{constructor(t){this.autocomplete=t}search(t){var e,i,n=this.autocomplete.options,s=t.toLowerCase(),o=new Map;for(const l of n){var r=l.closest('[role="group"]'),a=!s||!!l.getAttribute("data-text")?.toLowerCase().includes(s);l.hidden=!a,r&&o.set(r,o.get(r)||a)}for([e,i]of o)e.hidden=!i;t=this.autocomplete.visibleOptions[0];t?this.autocomplete.combobox.activate(t):this.autocomplete.combobox.deactivate(),this.autocomplete.checkIfListIsEmpty()}start(){this.autocomplete.checkIfListIsEmpty()}stop(){this.resetOptions()}disconnected(){}resetOptions(){for(const t of this.autocomplete.groups)t.hidden=!1;for(const e of this.autocomplete.options)e.hidden=!1}}class Ge{constructor(t){this.selectedValues=new Set,this.defaultSelectedValues=[],this.findByValue=e=>t=>t.getAttribute("value")===e,this.autocomplete=t}connected(){this.defaultSelectedValues=this.tags.reduce((t,e)=>{var e=e.querySelector('[data-behavior="hidden-field"]'),i=e.value;return this.selectedValues.add(i),t.push({value:i,text:e.getAttribute("data-text")||""}),t},[])}start(){this.selectOrDeselectOptions(),this.firstActivableOption&&this.autocomplete.combobox.activate(this.firstActivableOption,{scroll:!0})}stop(){this.autocomplete.input.value=""}reset(){this.clear(),this.defaultSelectedValues.forEach(({value:t,text:e})=>this.setValue(t,e))}select(t){var e=t.getAttribute("value"),t=t.dataset["text"];e&&(this.selectedValues.has(e)?this.removeValue(e):this.setValue(e,t||""))}setValue(t,e){this.selectedValues.has(t)||(this.selectedValues.add(t),this.insertTag(t,e.trim()),this.toggleSelectedClass(),this.required=this.autocomplete.required,this.autocomplete.open&&(e=this.autocomplete.options.find(this.findByValue(t)))&&this.autocomplete.combobox.select(e))}clear(){this.selectedValues.forEach(t=>this.removeValue(t))}removeValue(t){this.selectedValues.has(t)&&(this.selectedValues.delete(t),this.removeTag(t),this.toggleSelectedClass(),this.required=this.autocomplete.required,t=this.autocomplete.options.find(this.findByValue(t)))&&this.autocomplete.combobox.deselect(t)}isSelected(t){return this.selectedValues.has(t)}set required(t){!t||0<this.selectedValues.size?this.autocomplete.input.required=!1:this.autocomplete.input.required=!0}selectOrDeselectOptions(){for(const e of this.autocomplete.options){var t=e.getAttribute("value");t&&this.selectedValues.has(t)?this.autocomplete.combobox.select(e):this.autocomplete.combobox.deselect(e)}}insertTag(t,e){var i=this.template.content.cloneNode(!0),n=i.querySelector('[data-behavior="tag"]'),s=i.querySelector('[data-behavior="text"]'),o=i.querySelector('[data-behavior="hidden-field"]');n.setAttribute("value",t),n.setAttribute("data-text",e),s.innerText=e,o.value=t,o.setAttribute("data-text",e),this.autocomplete.control.insertBefore(i,this.template);for(const r of this.autocomplete.tagDismissButtons)r.disabled=this.autocomplete.disabled}removeTag(t){this.tags.find(this.findByValue(t))?.remove()}toggleSelectedClass(){this.autocomplete.toggleSelectedClass(!!this.selectedValues.size)}get firstActivableOption(){return this.autocomplete.options.find(t=>this.selectedValues.has(t.getAttribute("value")))||this.autocomplete.visibleOptions[0]}get tags(){return this.autocomplete.tags}get template(){return this.autocomplete.querySelector('[data-behavior="tag-template"]')}}class Ze{constructor(t){this.defaultValue="",this.defaultText="",this.autocomplete=t}connected(){this.defaultValue=this.hiddenField.value,this.defaultText=this.hiddenField.getAttribute("data-text")??""}start(){var t;this.selectedOption?(this.autocomplete.combobox.select(this.selectedOption),this.autocomplete.combobox.activate(this.selectedOption,{scroll:!0})):(t=this.autocomplete.visibleOptions[0])&&this.autocomplete.combobox.activate(t,{scroll:!0})}stop(){var t=this.hiddenField.dataset["text"];this.autocomplete.input.value=t??""}reset(){this.setValue(this.defaultValue,this.defaultText)}select(t){var e=t.getAttribute("value")??"",t=t.dataset["text"];this.setValue(e,t||""),this.autocomplete.requestHide()}setValue(t,e){this.hiddenField.value=t;var e=e.trim();this.hiddenField.setAttribute("data-text",e),this.autocomplete.input.value=e,this.autocomplete.toggleSelectedClass(!!t),this.autocomplete.open&&((e=this.selectedOption)?this.autocomplete.combobox.select(e):this.autocomplete.combobox.deselectAll())}clear(){this.setValue("","")}removeValue(t){this.clear()}isSelected(t){return this.hiddenField.value===t}set required(t){this.autocomplete.input.required=t}get selectedOption(){return this.autocomplete.options.find(t=>t.getAttribute("value")===this.hiddenField.value)}get hiddenField(){return this.autocomplete.querySelector('input[data-behavior="hidden-field"]')}}let B=class extends Qe{constructor(){super(),this.open=!1,this.disabled=!1,this.required=!1,this.multiple=!1,this.param="q",this.autoSize=!0,this.autoSizePadding=4,this.firstFocus=!0,this.preventOutsideClickEvent=!1,this.handleFormReset=this.handleFormReset.bind(this)}connected(){this.form?.addEventListener("reset",this.handleFormReset),this.floatingUI=Ue(this,()=>({anchorElement:this.control,floatingElement:this.listbox,placement:"bottom",sync:"width",keepFlipped:!0,offsetOptions:4,autoSize:this.autoSize?"height":void 0,autoSizePadding:this.autoSizePadding})),He(this,{boundaries:[this.control,this.listbox],callback:(t,e)=>{this.preventOutsideClickEvent&&!We(e)?t.preventDefault():this.open&&this.requestHide(),this.preventOutsideClickEvent=!1}}),this.combobox=new we(this.input,this.listbox,{multiple:this.multiple}),this.selectVariant=new(this.multiple?Ge:Ze)(this),this.selectVariant.connected(),this.searchVariant=new(this.src?Xe:Ye)(this),this.selectVariant.required=this.required,super.connected()}disconnected(){super.disconnected(),this.searchVariant?.disconnected(),this.form?.removeEventListener("reset",this.handleFormReset),this.firstFocus=!0,this.preventOutsideClickEvent=!1}disabledChanged(t){this.input.disabled=t,this.clearButton&&(this.clearButton.disabled=t);for(const e of this.tagDismissButtons)e.disabled=t}requiredChanged(t){this.selectVariant.required=t}srcChanged(t){this.clear(),this.searchVariant?.disconnected(),this.searchVariant=new(t?Xe:Ye)(this)}autoSizeChanged(){this.reposition()}autoSizePaddingChanged(){this.reposition()}handleMousedown(t){t.target!==this.input&&t.preventDefault()}handleClick(t){this.disabled||(this.focus(),t.target.hasAttribute("data-trigger")&&this.requestShow(),this.firstFocus&&this.input.value&&this.input.select(),this.firstFocus=!1)}handleInputMousedown(t){this.disabled||1===t.buttons&&this.requestShow()}async handleInputBlur(){this.preventOutsideClickEvent=this.open,await this.requestHide(),this.firstFocus=!0}handleInputKeydown(t){switch(t.key){case"Enter":this.open&&t.preventDefault();break;case"Escape":this.open&&(t.preventDefault(),t.stopPropagation(),this.requestHide());break;case"ArrowDown":t.altKey&&!this.open&&(t.preventDefault(),this.requestShow());break;case"ArrowUp":t.altKey&&this.open&&(t.preventDefault(),this.requestHide());break;case"Backspace":var e;this.multiple&&!this.input.value&&(e=this.removeLastTag())&&(t.preventDefault(),this.emitEvent("remove",$e(e)))}}handleCommit(t){t.stopPropagation();var t=t.target;t instanceof HTMLElement&&(this.selectVariant.select(t),t=$e(t),this.emitEvent("commit",{...t,selected:this.selectVariant.isSelected(t.value)}))}handleFormReset(){this.reset(),this.hide(),this.emitEvent("reset")}handleClear(){this.clear(),this.requestHide(),this.emitEvent("clear")}handleTagRemove(t){this.disabled||(t=t.target.closest('[data-behavior="tag"]'))&&(this.removeTag(t),this.emitEvent("remove",$e(t)))}handleInput(t){var t=t["target"];t instanceof HTMLInputElement&&(t=t.value.trim(),this.requestShow(),this.searchVariant.search(t))}setValue(e,...t){var[t]=t,i=this.options.find(t=>t.getAttribute("value")===e),t=t||i?.getAttribute("data-text")||"";this.selectVariant.setValue(e,t)}removeValue(...t){var[t]=t;t?this.selectVariant.removeValue(t):this.selectVariant.clear()}activate(t,{scroll:e=!0}={}){this.combobox.activate(t,{scroll:e})}deactivate(){this.combobox.deactivate()}focus(t){this.input.focus(t)}blur(){this.input.blur()}reset(){this.selectVariant.reset()}clear(){this.selectVariant.clear()}async reposition(){await this.floatingUI.update()}emitEvent(t,...e){var[e]=e;return this.emit(t,{detail:e})}openParts(){this.floatingUI.start(),this.combobox.start(),this.selectVariant.start(),this.searchVariant.start()}async closeParts(){this.combobox.stop(),this.selectVariant.stop(),this.searchVariant.stop(),this.removeAttribute("no-options"),this.removeAttribute("error"),await this.floatingUI.stop()}removeLastTag(){var t=this.tags[this.tags.length-1];if(t)return this.removeTag(t),t}removeTag(t){t=t.getAttribute("value");t&&this.removeValue(t)}checkIfListIsEmpty(){this.toggleAttribute("no-options",0===this.visibleOptions.length)}toggleSelectedClass(t){this.classList.toggle("awc-autocomplete--selected",t)}get ajax(){return Boolean(this.src)}get value(){return this.multiple?this.tags.map(t=>t.getAttribute("value")??""):this.querySelector('input[data-behavior="hidden-field"]')?.value??""}get options(){return this.combobox.options}get visibleOptions(){return this.options.filter(t=>!t.hidden)}get activeOption(){return this.combobox.activeOption}get form(){return this.closest("form")}get tags(){return[...this.querySelectorAll('[data-behavior="tag"]')]}},L=(t([e({type:Boolean})],B.prototype,"open",void 0),t([e({type:Boolean})],B.prototype,"disabled",void 0),t([e({type:Boolean})],B.prototype,"required",void 0),t([e({type:Boolean})],B.prototype,"multiple",void 0),t([e()],B.prototype,"src",void 0),t([e()],B.prototype,"param",void 0),t([e({type:Boolean})],B.prototype,"autoSize",void 0),t([e({type:Number})],B.prototype,"autoSizePadding",void 0),t([s()],B.prototype,"control",void 0),t([s()],B.prototype,"input",void 0),t([s()],B.prototype,"listbox",void 0),t([s()],B.prototype,"optionsContainer",void 0),t([s()],B.prototype,"clearButton",void 0),t([vt()],B.prototype,"tagDismissButtons",void 0),t([vt()],B.prototype,"groups",void 0),B=t([n("awc-autocomplete")],B),class extends pe{constructor(){super(),this.disabled=!1,this.value="",this.for="",this.feedbackDuration=2e3,this.internals=this.attachInternals(),this.spacePressed=!1,this.handleClick=t=>{t.currentTarget===this&&(this.disabled?(t.preventDefault(),t.stopImmediatePropagation()):this.copy())},this.handleKeydown=t=>{this.isTargetOf(t)&&!this.disabled&&("Enter"===t.key?this.click():" "===t.key&&(t.preventDefault(),this.spacePressed=!0))},this.handleKeyup=t=>{this.isTargetOf(t)&&" "===t.key&&this.spacePressed&&(this.spacePressed=!1,this.click())},this.handleBlur=t=>{this.isTargetOf(t)&&(this.spacePressed=!1)},this.internals.role="button"}connected(){this.disabled===this.hasAttribute("tabindex")&&this.syncTabIndex(),this.internals.ariaDisabled=this.disabled?"true":null,this.listeners=new AbortController;var t={capture:!0,signal:this.listeners.signal};E("click",this.localName,this.handleClick,t),E("keydown",this.localName,this.handleKeydown,t),E("keyup",this.localName,this.handleKeyup,t),E("blur",this.localName,this.handleBlur,t)}disconnected(){this.listeners?.abort(),this.spacePressed=!1,this.showFeedback(null)}disabledChanged(t){this.internals.ariaDisabled=t?"true":null,this.syncTabIndex(),t&&(this.spacePressed=!1)}syncTabIndex(){this.disabled?this.removeAttribute("tabindex"):this.tabIndex=0}isTargetOf(t){return t.composedPath()[0]===this}async copy(){let t;try{if(t=this.copiedText(),!navigator.clipboard)throw new DOMException("The Clipboard API is unavailable.","NotSupportedError");await navigator.clipboard.writeText(t)}catch(t){return this.isConnected&&this.showFeedback("error"),void this.emit("error",{detail:{error:t}})}this.isConnected&&this.showFeedback("copied"),this.emit("copied",{detail:{text:t}})}showFeedback(t){clearTimeout(this.feedbackTimeout);try{this.internals.states.delete("copied"),this.internals.states.delete("error"),t&&(this.internals.states.add(t),this.feedbackTimeout=setTimeout(()=>this.showFeedback(null),this.feedbackDuration))}catch{}}copiedText(){if(this.value)return this.value;var t=this.for,e=this.getRootNode(),e=t&&(e instanceof Document||e instanceof ShadowRoot)?e.getElementById(t):null;if(e)return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value:e.innerText;throw new DOMException(`No copy source has the id "${t}".`,"NotFoundError")}});t([e({type:Boolean})],L.prototype,"disabled",void 0),t([e()],L.prototype,"value",void 0),t([e()],L.prototype,"for",void 0),t([e({type:Number})],L.prototype,"feedbackDuration",void 0),L=t([n("awc-clipboard-copy")],L);const ti=new Set;let I=class extends Qe{constructor(){super(...arguments),this.open=!1,this.hideOnOutsideClick=!0}hide(t){return this.opened&&this.nestedDialog?.hide(),super.hide(t)}handleClick(t){var e;this.hideOnOutsideClick&&!t.defaultPrevented&&(e=t.target)instanceof HTMLElement&&e===this.dialog&&((e=e.getBoundingClientRect()).top<=t.clientY&&t.clientY<=e.top+e.height&&e.left<=t.clientX&&t.clientX<=e.left+e.width||this.requestHide())}handleKeydown(t){"Escape"===t.key&&t.stopPropagation()}handleCancel(t){t.cancelable&&(t.preventDefault(),this.requestHide())}handleClose(){this.dialog.open||this.hide()}hideWithoutEmitting(){this.dialog.open&&this.nestedDialog?.hideWithoutEmitting(),this.closeQuietly(),this.open=!1}openParts(){this.dialog.showModal(),this.hideOverflow()}closeParts(){this.dialog.open&&(this.nestedDialog?.closeQuietly(),this.dialog.close()),this.showOverflow()}hideOverflow(){this._scrollLockController=function(t,{abortSignal:e}={}){ti.add(t);var i,n=new AbortController,e=e||n.signal,s=window.innerWidth-document.documentElement.clientWidth;let o,r;return void 0===o&&0<s&&(i=Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10),o=document.body.style.paddingRight,document.body.style.paddingRight=i+s+"px"),void 0===r&&(r=document.body.style.overflow,document.body.style.overflow="hidden"),e.addEventListener("abort",()=>{ti.delete(t),0===ti.size&&(void 0!==o&&(document.body.style.paddingRight=o,o=void 0),void 0!==r)&&(document.body.style.overflow=r,r=void 0)}),n}(this)}showOverflow(){this._scrollLockController?.abort()}get nestedDialog(){return this.querySelector(this.identifier)}};function ei(t){var e,i;e=t,(((i=i||{}).getShadowRoot?Ke([e],i.includeContainer,{filter:Fe.bind(null,i),flatten:!0,getShadowRoot:i.getShadowRoot}):qe(e,i.includeContainer,Fe.bind(null,i))).find(t=>t.hasAttribute("autofocus"))??function(t,e){t=(e=e||{}).getShadowRoot?Ke([t],e.includeContainer,{filter:Ve.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:De}):qe(t,e.includeContainer,Ve.bind(null,e));return Re(t)}(t)[0]??t).focus({preventScroll:!0})}t([e({type:Boolean})],I.prototype,"open",void 0),t([e({type:Boolean})],I.prototype,"hideOnOutsideClick",void 0),t([s()],I.prototype,"dialog",void 0),I=t([n("awc-dialog")],I);let q=class extends Qe{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.strategy="fixed",this.opening=!1}connected(){const t=this.arrowPadding;this.floatingUI=Ue(this,()=>({anchorElement:this.button,floatingElement:this.panel,arrowElement:this.arrow,arrowPadding:t,placement:this.placement,strategy:this.strategy,offsetOptions:8,flipOptions:{fallbackAxisSideDirection:"end"}})),He(this,{boundaries:this.boundaries,callback:(t,e)=>{this.isClosedPopoverTrigger(e)||this.open&&!this.isAlsoOutsideParent(t,e)&&this.requestHide(t)}});{var[e,{boundaries:n,callback:s}]=[this,{boundaries:this.boundaries,callback:(t,e)=>{!this.open||this.opening||this.isAlsoOutsideParent(t,e)||this.requestHide(t)}}];const r=new AbortController;var o=r["signal"];const a=e=>n.some(t=>t?.contains(e));let i=null;document.addEventListener("pointerdown",t=>{t=t.target;i=a(t)?null:t},{capture:!0,signal:o}),document.addEventListener("click",()=>setTimeout(()=>i=null),{capture:!0,signal:o}),document.addEventListener("keydown",()=>i=null,{capture:!0,signal:o}),document.addEventListener("focusin",t=>{var e=t.target;a(e)||i&&e.contains(i)||s(t,e)},{capture:!0,signal:o}),je(e,()=>r.abort())}super.connected()}placementChanged(){this.reposition()}async toggle(t){this.opened?await this.requestHide(t):this.requestShow()}handleKeydown(t){var e;"Escape"!==t.key||(e=t.target.closest(this.identifier))!==this&&e?.open||this.open&&(t.preventDefault(),t.stopPropagation(),this.requestHide(t))}requestHide(t){var e;return t&&this.hideRequest?.event===t?this.hideRequest.done:(e=this.requestHideInnermostFirst(t),t&&(this.hideRequest={event:t,done:e}),e)}hide(t){if(this.opened)for(const e of this.nestedOpenPopovers)e.hide();return super.hide(t)}async reposition(){await this.floatingUI.update()}async requestHideInnermostFirst(t){if(this.opened){for(const e of this.nestedPopovers.reverse())if(await e.requestHide(t),e.opened)return;await super.requestHide(t)}}openParts({initial:t}){this.opening=!0;try{this.closeOtherPopovers();var e=document.activeElement;this.panel.showPopover(),t?this.panel.contains(document.activeElement)&&((i=e)instanceof HTMLElement&&i!==document.body?i.focus({preventScroll:!0}):document.activeElement?.blur()):ei(this.panel)}finally{this.opening=!1}var i;this.button.setAttribute("aria-expanded","true"),this.floatingUI.start()}async closeParts(){var t,e,i=this.button,n=this.panel;n.isConnected&&(t=n,t=!(e=document.activeElement)||e===document.body||t.contains(e),n.hidePopover(),t)&&i.focus(),await this.floatingUI.stop(),this.opened||i.setAttribute("aria-expanded","false")}othersAllowShow(){return this.otherOpenPopovers.every(t=>t.emitRequest("hide"))}closeOtherPopovers(){for(const t of this.otherOpenPopovers)t.hide()}isClosedPopoverTrigger(t){var e=t.closest(this.identifier);return!!e&&e!==this&&!e.open&&e.button.contains(t)}get otherOpenPopovers(){return Array.from(document.querySelectorAll(this.identifier)).filter(t=>t!==this&&!t.contains(this)&&t.open)}get nestedPopovers(){return Array.from(this.querySelectorAll(this.identifier))}get nestedOpenPopovers(){return this.nestedPopovers.filter(t=>t.open)}isAlsoOutsideParent(t,e){var i=this.parentElement?.closest(this.identifier);if(!i?.open)return!1;const n=t.composedPath();return!i.boundaries.some(t=>t.contains(e)||n.includes(t))}get arrowPadding(){var t=getComputedStyle(this.panel).borderRadius;return Number(t.replace(/[^-\d.]/g,""))||2}get boundaries(){return[this.button,this.panel]}};t([e({type:Boolean})],q.prototype,"open",void 0),t([e()],q.prototype,"placement",void 0),t([e()],q.prototype,"strategy",void 0),t([s()],q.prototype,"button",void 0),t([s()],q.prototype,"panel",void 0),t([s()],q.prototype,"arrow",void 0),q=t([n("awc-popover")],q)});
@@ -3,6 +3,9 @@ module Impulse
3
3
  renders_one :blankslate
4
4
  renders_one :error
5
5
 
6
+ Option = Struct.new(:value, :text)
7
+ private_constant :Option
8
+
6
9
  def initialize(object_name, method_name, value_method, text_method, selected: nil, **system_args)
7
10
  @object_name = object_name
8
11
  @method_name = method_name
@@ -23,8 +26,7 @@ module Impulse
23
26
  end
24
27
 
25
28
  def build_option(element)
26
- tuple = [value_for_collection(element, @text_method), value_for_collection(element, @value_method)]
27
- OpenStruct.new(value: tuple.last, text: tuple.first)
29
+ Option.new(value: value_for_collection(element, @value_method), text: value_for_collection(element, @text_method))
28
30
  end
29
31
 
30
32
  def multiple?
@@ -1,8 +1,8 @@
1
- <%= render(Impulse::BaseRenderer.new(**@system_args)) do %>
1
+ <%= render(Impulse::BaseRenderer.new(**root_args)) do %>
2
2
  <%= content_tag :div, class: class_names("awc-autocomplete-control form-control", "form-control-sm": @size == "sm", "form-control-lg": @size == "lg"), data: { target: "awc-autocomplete.control", trigger: "" } do %>
3
3
  <% if multiple? %>
4
4
  <%= hidden_field @object_name, @method_name, id: nil, multiple: true, value: nil, data: { behavior: "hidden-field" }, **hidden_field_args if @include_hidden %>
5
- <% @selected&.each do |selected| %>
5
+ <% selection&.each do |selected| %>
6
6
  <div class="awc-autocomplete-tag" value="<%= selected.value %>" data-text="<%= selected.text %>" data-behavior="tag" data-persisted>
7
7
  <span class="awc-autocomplete-tag-text" data-behavior="text"><%= selected.text %></span>
8
8
  <span class="awc-autocomplete-tag-end-adornment">
@@ -26,13 +26,13 @@
26
26
  </div>
27
27
  </template>
28
28
  <% else %>
29
- <%= hidden_field @object_name, @method_name, id: nil, value: @selected&.value, data: { behavior: "hidden-field", text: @selected&.text }, **hidden_field_args %>
29
+ <%= hidden_field @object_name, @method_name, id: nil, value: selection&.value, data: { behavior: "hidden-field", text: selection&.text }, **hidden_field_args %>
30
30
  <% end %>
31
31
 
32
32
  <%= text_field @object_name,
33
33
  @method_name,
34
34
  class: "awc-autocomplete-input",
35
- value: multiple? ? nil : @selected&.text,
35
+ value: multiple? ? nil : selection&.text,
36
36
  name: nil,
37
37
  autocomplete: "off",
38
38
  spellcheck: false,
@@ -72,7 +72,7 @@
72
72
  <% end %>
73
73
 
74
74
  <div role="presentation" class="awc-autocomplete-blankslate">
75
- <%= blankslate.presence || "We couldn't find that!" %>
75
+ <%= blankslate.presence || default_blankslate %>
76
76
  </div>
77
77
 
78
78
  <% if ajax? %>
@@ -46,15 +46,9 @@ module Impulse
46
46
  @system_args = system_args
47
47
  @system_args[:tag] = :"awc-autocomplete"
48
48
  @system_args[:disabled] = disabled
49
-
50
- @system_args[:class] = class_names(
51
- system_args[:class],
52
- SIZE_MAPPINGS[fetch_or_fallback(SIZE_MAPPINGS.keys, size, DEFAULT_SIZE)],
53
- "awc-autocomplete",
54
- "awc-autocomplete--selected": @selected.present?,
55
- "awc-autocomplete--clearable": @clearable
56
- )
57
-
49
+ # Holds `class` in its place among the attributes even when none is given. `root_args` fills it in when
50
+ # rendering, once the selection is known.
51
+ @system_args[:class] = system_args[:class]
58
52
  @system_args[:"data-loosely-focusable"] = "true"
59
53
  @system_args[:data] = merge_attributes(
60
54
  system_args[:data],
@@ -64,6 +58,29 @@ module Impulse
64
58
 
65
59
  private
66
60
 
61
+ def root_args
62
+ @system_args.merge(
63
+ class: class_names(
64
+ @system_args[:class],
65
+ SIZE_MAPPINGS[fetch_or_fallback(SIZE_MAPPINGS.keys, @size, DEFAULT_SIZE)],
66
+ "awc-autocomplete",
67
+ "awc-autocomplete--selected": selection.present?,
68
+ "awc-autocomplete--clearable": @clearable
69
+ )
70
+ )
71
+ end
72
+
73
+ # The selected option, or options when `multiple`, each responding to `value` and `text`. Subclasses that hold
74
+ # their own options look the selection up among them instead.
75
+ def selection
76
+ @selected
77
+ end
78
+
79
+ # Shown when no option matches and no `blankslate` is given.
80
+ def default_blankslate
81
+ "We couldn't find that!"
82
+ end
83
+
67
84
  def search_field_args
68
85
  {}.tap do |args|
69
86
  args[:id] = @input_id if @input_id
@@ -0,0 +1,20 @@
1
+ module Impulse
2
+ # A button that copies text to the clipboard: its `value`, or the text of the copy source its `for` names. It emits
3
+ # `awc-clipboard-copy:copied` or `awc-clipboard-copy:error`, and is in `:state(copied)` or `:state(error)` for
4
+ # `feedback_duration:` milliseconds after, for the app to style. It shows and announces nothing of its own.
5
+ class ClipboardCopyComponent < ApplicationComponent
6
+ def initialize(value: nil, disabled: false, **system_args)
7
+ @system_args = system_args
8
+ @system_args[:tag] = :"awc-clipboard-copy"
9
+ @system_args[:value] = value unless value.nil?
10
+ @system_args[:disabled] = disabled
11
+ # The element is the button, so it needs `tabindex` to be focusable, and none when disabled, as a native disabled
12
+ # button takes no focus. It keeps it in step with `disabled` changed after rendering; this is the one it starts with.
13
+ @system_args[:tabindex] = disabled ? nil : 0
14
+ end
15
+
16
+ def call
17
+ render(Impulse::BaseRenderer.new(**@system_args)) { content }
18
+ end
19
+ end
20
+ end
@@ -3,7 +3,7 @@
3
3
  <%= tag.h2 @title, id: @title_id, class: "awc-dialog-title" %>
4
4
  </div>
5
5
 
6
- <button type="button" class="btn btn-light awc-dialog-close-btn" data-action="click->awc-dialog#hide" aria-label="Close dialog">
6
+ <button type="button" class="btn btn-light awc-dialog-close-btn" data-action="click->awc-dialog#requestHide" aria-label="Close dialog">
7
7
  <i class="bi bi-x" aria-hidden="true"></i>
8
8
  </button>
9
9
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= render(Impulse::BaseRenderer.new(**@system_args)) do %>
2
- <dialog class="<%= class_names("awc-dialog-dialog", "awc-dialog-dialog--centered": @center) %>" data-action="click->awc-dialog#handleClick keydown->awc-dialog#handleKeydown close->awc-dialog#hideWithoutEmitting" data-target="awc-dialog.dialog" aria-labelledby="<%= title_id %>">
2
+ <dialog class="<%= class_names("awc-dialog-dialog", "awc-dialog-dialog--centered": @center) %>" data-action="click->awc-dialog#handleClick keydown->awc-dialog#handleKeydown cancel->awc-dialog#handleCancel close->awc-dialog#handleClose" data-target="awc-dialog.dialog" aria-labelledby="<%= title_id %>">
3
3
  <%= header %>
4
4
  <% if content.present? %>
5
5
  <%= content %>
@@ -2,8 +2,8 @@
2
2
  <% if content.present? %>
3
3
  <%= content %>
4
4
  <% else %>
5
- <%= @title %>
6
- <button type="button" class="close" aria-label="Close" data-action="click->awc-popover#hide" autofocus>
5
+ <%= content_tag(:span, @title, id: @title_id) %>
6
+ <button type="button" class="close" aria-label="Close" data-action="click->awc-popover#requestHide">
7
7
  &times;
8
8
  </button>
9
9
  <% end %>
@@ -1,8 +1,9 @@
1
1
  module Impulse
2
2
  module Popover
3
3
  class HeaderComponent < ApplicationComponent
4
- def initialize(title: nil, **system_args)
4
+ def initialize(title: nil, title_id: nil, **system_args)
5
5
  @title = title
6
+ @title_id = title_id
6
7
  @system_args = system_args
7
8
  @system_args[:tag] = :div
8
9
  @system_args[:class] = class_names(
@@ -1,7 +1,7 @@
1
1
  <%= render(Impulse::BaseRenderer.new(**@system_args)) do %>
2
2
  <%= trigger %>
3
3
 
4
- <div id="<%= @panel_id %>" popover="manual" class="awc-popover-container bs-popover-auto" tabindex="-1" data-target="awc-popover.panel" data-action="toggle->awc-popover#handleToggle">
4
+ <div id="<%= @panel_id %>" class="awc-popover-container bs-popover-auto" role="dialog" popover="manual" tabindex="-1" aria-labelledby="<%= label_id %>" data-target="awc-popover.panel">
5
5
  <div class="arrow" data-target="awc-popover.arrow"></div>
6
6
  <%= header %>
7
7
  <%= body %>
@@ -3,23 +3,24 @@ module Impulse
3
3
  renders_one :trigger, lambda { |**system_args|
4
4
  system_args[:tag] = :button
5
5
  system_args[:type] = system_args.fetch(:type, "button")
6
- system_args[:role] = :button
6
+ # Labels the panel when the popover has no title, so it needs an id even when the caller didn't give one.
7
+ @trigger_id = system_args[:id] ||= "#{@panel_id}-trigger"
7
8
  system_args[:"aria-haspopup"] = :dialog
8
9
  system_args[:"aria-expanded"] = false
9
10
  system_args[:"aria-controls"] = @panel_id
10
- system_args[:popovertarget] = @panel_id
11
11
  system_args[:"aria-disabled"] = (!!system_args[:disabled]).to_s
12
12
 
13
13
  system_args[:data] = merge_attributes(
14
14
  system_args[:data],
15
- target: "awc-popover.button"
15
+ target: "awc-popover.button",
16
+ action: "click->awc-popover#toggle"
16
17
  )
17
18
 
18
19
  Impulse::BaseRenderer.new(**system_args)
19
20
  }
20
21
 
21
22
  renders_one :header, lambda { |**system_args|
22
- Impulse::Popover::HeaderComponent.new(title: @title, **system_args)
23
+ Impulse::Popover::HeaderComponent.new(title: @title, title_id: @title_id, **system_args)
23
24
  }
24
25
 
25
26
  renders_one :body, lambda { |**system_args|
@@ -29,12 +30,12 @@ module Impulse
29
30
  Impulse::BaseRenderer.new(**system_args)
30
31
  }
31
32
 
32
- def initialize(title: nil, click_boundaries: [], **system_args)
33
+ def initialize(title: nil, **system_args)
33
34
  @title = title
34
35
  @system_args = system_args
35
36
  @system_args[:tag] = :"awc-popover"
36
- @system_args[:"click-boundaries"] = click_boundaries.to_json
37
37
  @panel_id = self.class.generate_id
38
+ @title_id = "#{@panel_id}-title"
38
39
 
39
40
  @system_args[:class] = class_names(
40
41
  system_args[:class],
@@ -54,5 +55,13 @@ module Impulse
54
55
  def before_render
55
56
  with_header unless header?
56
57
  end
58
+
59
+ private
60
+
61
+ # The id of what names the popover, which is a dialog and needs an accessible name: its title, or its trigger when a
62
+ # custom header replaces the title or there is none.
63
+ def label_id
64
+ (header.content? || @title.blank?) ? @trigger_id : @title_id
65
+ end
57
66
  end
58
67
  end