avo 3.5.5 → 3.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ (()=>{var Ae=Object.defineProperty;var Ee=(s,e,t)=>e in s?Ae(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var v=(s,e,t)=>(Ee(s,typeof e!="symbol"?e+"":e,t),t);var O=(s,e,t)=>new Promise((r,n)=>{var i=c=>{try{a(t.next(c))}catch(l){n(l)}},o=c=>{try{a(t.throw(c))}catch(l){n(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);a((t=t.apply(s,e)).next())});var k=class{constructor(e,t,r){this.eventTarget=e,this.eventName=t,this.eventOptions=r,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){let t=we(e);for(let r of this.bindings){if(t.immediatePropagationStopped)break;r.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{let r=e.index,n=t.index;return r<n?-1:r>n?1:0})}};function we(s){if("immediatePropagationStopped"in s)return s;{let{stopImmediatePropagation:e}=s;return Object.assign(s,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}var B=class{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(e=>e.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(e=>e.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((e,t)=>e.concat(Array.from(t.values())),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,r={}){this.application.handleError(e,`Error ${t}`,r)}clearEventListenersForBinding(e){let t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){let{eventTarget:t,eventName:r,eventOptions:n}=e,i=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(r,n);i.delete(o),i.size==0&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:r,eventOptions:n}=e;return this.fetchEventListener(t,r,n)}fetchEventListener(e,t,r){let n=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,r),o=n.get(i);return o||(o=this.createEventListener(e,t,r),n.set(i,o)),o}createEventListener(e,t,r){let n=new k(e,t,r);return this.started&&n.connect(),n}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){let r=[e];return Object.keys(t).sort().forEach(n=>{r.push(`${t[n]?"":"!"}${n}`)}),r.join(":")}},Fe={stop({event:s,value:e}){return e&&s.stopPropagation(),!0},prevent({event:s,value:e}){return e&&s.preventDefault(),!0},self({event:s,value:e,element:t}){return e?t===s.target:!0}},Me=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function Te(s){let t=s.trim().match(Me)||[],r=t[2],n=t[3];return n&&!["keydown","keyup","keypress"].includes(r)&&(r+=`.${n}`,n=""),{eventTarget:Ce(t[4]),eventName:r,eventOptions:t[7]?Se(t[7]):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||n}}function Ce(s){if(s=="window")return window;if(s=="document")return document}function Se(s){return s.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})}function ke(s){if(s==window)return"window";if(s==document)return"document"}function Q(s){return s.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function $(s){return Q(s.replace(/--/g,"-").replace(/__/g,"_"))}function y(s){return s.charAt(0).toUpperCase()+s.slice(1)}function ue(s){return s.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function Be(s){return s.match(/[^\s]+/g)||[]}function re(s){return s!=null}function N(s,e){return Object.prototype.hasOwnProperty.call(s,e)}var se=["meta","ctrl","alt","shift"],D=class{constructor(e,t,r,n){this.element=e,this.index=t,this.eventTarget=r.eventTarget||e,this.eventName=r.eventName||$e(e)||A("missing event name"),this.eventOptions=r.eventOptions||{},this.identifier=r.identifier||A("missing identifier"),this.methodName=r.methodName||A("missing method name"),this.keyFilter=r.keyFilter||"",this.schema=n}static forToken(e,t){return new this(e.element,e.index,Te(e.content),t)}toString(){let e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;let t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;let r=t.filter(n=>!se.includes(n))[0];return r?(N(this.keyMappings,r)||A(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[r].toLowerCase()!==e.key.toLowerCase()):!1}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;let t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){let e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:r,value:n}of Array.from(this.element.attributes)){let i=r.match(t),o=i&&i[1];o&&(e[Q(o)]=Ne(n))}return e}get eventTargetName(){return ke(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){let[r,n,i,o]=se.map(a=>t.includes(a));return e.metaKey!==r||e.ctrlKey!==n||e.altKey!==i||e.shiftKey!==o}},ne={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:s=>s.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function $e(s){let e=s.tagName.toLowerCase();if(e in ne)return ne[e](s)}function A(s){throw new Error(s)}function Ne(s){try{return JSON.parse(s)}catch{return s}}var x=class{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){let t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){let e=this.controller[this.methodName];if(typeof e=="function")return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){let{element:t}=this.action,{actionDescriptorFilters:r}=this.context.application,{controller:n}=this.context,i=!0;for(let[o,a]of Object.entries(this.eventOptions))if(o in r){let c=r[o];i=i&&c({name:o,value:a,event:e,element:t,controller:n})}else continue;return i}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){let{target:t,currentTarget:r}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:r,action:this.methodName})}catch(n){let{identifier:i,controller:o,element:a,index:c}=this,l={identifier:i,controller:o,element:a,index:c,event:e};this.context.handleError(n,`invoking action "${this.action}"`,l)}}willBeInvokedByEvent(e){let t=e.target;return e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e)||e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e)?!1:this.element===t?!0:t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}},E=class{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver(r=>this.processMutations(r))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){let e=new Set(this.matchElementsInTree());for(let t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(let t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){e.type=="attributes"?this.processAttributeChange(e.target,e.attributeName):e.type=="childList"&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(let t of Array.from(e)){let r=this.elementFromNode(t);r&&this.processTree(r,this.removeElement)}}processAddedNodes(e){for(let t of Array.from(e)){let r=this.elementFromNode(t);r&&this.elementIsActive(r)&&this.processTree(r,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(let r of this.matchElementsInTree(e))t.call(this,r)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected!=this.element.isConnected?!1:this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}},w=class{constructor(e,t,r){this.attributeName=t,this.delegate=r,this.elementObserver=new E(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){let t=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(this.selector));return t.concat(r)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}};function De(s,e,t){de(s,e).add(t)}function xe(s,e,t){de(s,e).delete(t),Ve(s,e)}function de(s,e){let t=s.get(e);return t||(t=new Set,s.set(e,t)),t}function Ve(s,e){let t=s.get(e);t!=null&&t.size==0&&s.delete(e)}var h=class{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((t,r)=>t.concat(Array.from(r)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((t,r)=>t+r.size,0)}add(e,t){De(this.valuesByKey,e,t)}delete(e,t){xe(this.valuesByKey,e,t)}has(e,t){let r=this.valuesByKey.get(e);return r!=null&&r.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(r=>r.has(e))}getValuesForKey(e){let t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,r])=>r.has(e)).map(([t,r])=>t)}};var V=class{constructor(e,t,r,n){this._selector=t,this.details=n,this.elementObserver=new E(e,this),this.delegate=r,this.matchesByElement=new h}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){let{selector:t}=this;if(t){let r=e.matches(t);return this.delegate.selectorMatchElement?r&&this.delegate.selectorMatchElement(e,this.details):r}else return!1}matchElementsInTree(e){let{selector:t}=this;if(t){let r=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(t)).filter(i=>this.matchElement(i));return r.concat(n)}else return[]}elementMatched(e){let{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){let t=this.matchesByElement.getKeysForValue(e);for(let r of t)this.selectorUnmatched(e,r)}elementAttributeChanged(e,t){let{selector:r}=this;if(r){let n=this.matchElement(e),i=this.matchesByElement.has(r,e);n&&!i?this.selectorMatched(e,r):!n&&i&&this.selectorUnmatched(e,r)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}},j=class{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(r=>this.processMutations(r))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(let e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){let t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){let r=this.delegate.getStringMapKeyForAttribute(e);if(r!=null){this.stringMap.has(e)||this.stringMapKeyAdded(r,e);let n=this.element.getAttribute(e);if(this.stringMap.get(e)!=n&&this.stringMapValueChanged(n,r,t),n==null){let i=this.stringMap.get(e);this.stringMap.delete(e),i&&this.stringMapKeyRemoved(r,e,i)}else this.stringMap.set(e,n)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,r){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,r)}stringMapKeyRemoved(e,t,r){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,r)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(e=>e.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}},F=class{constructor(e,t,r){this.attributeObserver=new w(e,t,this),this.delegate=r,this.tokensByElement=new h}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){let[t,r]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(r)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach(t=>this.tokenMatched(t))}tokensUnmatched(e){e.forEach(t=>this.tokenUnmatched(t))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){let t=this.tokensByElement.getValuesForKey(e),r=this.readTokensForElement(e),n=Ie(t,r).findIndex(([i,o])=>!Le(i,o));return n==-1?[[],[]]:[t.slice(n),r.slice(n)]}readTokensForElement(e){let t=this.attributeName,r=e.getAttribute(t)||"";return je(r,e,t)}};function je(s,e,t){return s.trim().split(/\s+/).filter(r=>r.length).map((r,n)=>({element:e,attributeName:t,content:r,index:n}))}function Ie(s,e){let t=Math.max(s.length,e.length);return Array.from({length:t},(r,n)=>[s[n],e[n]])}function Le(s,e){return s&&e&&s.index==e.index&&s.content==e.content}var M=class{constructor(e,t,r){this.tokenListObserver=new F(e,t,this),this.delegate=r,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){let{element:t}=e,{value:r}=this.fetchParseResultForToken(e);r&&(this.fetchValuesByTokenForElement(t).set(e,r),this.delegate.elementMatchedValue(t,r))}tokenUnmatched(e){let{element:t}=e,{value:r}=this.fetchParseResultForToken(e);r&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,r))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(t){return{error:t}}}},I=class{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new M(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){let t=new x(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){let t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach(e=>this.delegate.bindingDisconnected(e,!0)),this.bindingsByAction.clear()}parseValueForToken(e){let t=D.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}},L=class{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new j(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){let r=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,r.writer(this.receiver[e]),r.writer(r.defaultValue))}stringMapValueChanged(e,t,r){let n=this.valueDescriptorNameMap[t];e!==null&&(r===null&&(r=n.writer(n.defaultValue)),this.invokeChangedCallback(t,e,r))}stringMapKeyRemoved(e,t,r){let n=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,n.writer(this.receiver[e]),r):this.invokeChangedCallback(e,n.writer(n.defaultValue),r)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:r,writer:n}of this.valueDescriptors)r!=null&&!this.controller.data.has(e)&&this.invokeChangedCallback(t,n(r),void 0)}invokeChangedCallback(e,t,r){let n=`${e}Changed`,i=this.receiver[n];if(typeof i=="function"){let o=this.valueDescriptorNameMap[e];try{let a=o.reader(t),c=r;r&&(c=o.reader(r)),i.call(this.receiver,a,c)}catch(a){throw a instanceof TypeError&&(a.message=`Stimulus Value "${this.context.identifier}.${o.name}" - ${a.message}`),a}}}get valueDescriptors(){let{valueDescriptorMap:e}=this;return Object.keys(e).map(t=>e[t])}get valueDescriptorNameMap(){let e={};return Object.keys(this.valueDescriptorMap).forEach(t=>{let r=this.valueDescriptorMap[t];e[r.name]=r}),e}hasValue(e){let t=this.valueDescriptorNameMap[e],r=`has${y(t.name)}`;return this.receiver[r]}},K=class{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new h}start(){this.tokenListObserver||(this.tokenListObserver=new F(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var r;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),(r=this.tokenListObserver)===null||r===void 0||r.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var r;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),(r=this.tokenListObserver)===null||r===void 0||r.pause(()=>this.delegate.targetDisconnected(e,t)))}disconnectAllTargets(){for(let e of this.targetsByName.keys)for(let t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}};function b(s,e){let t=fe(s);return Array.from(t.reduce((r,n)=>(Pe(n,e).forEach(i=>r.add(i)),r),new Set))}function Ke(s,e){return fe(s).reduce((r,n)=>(r.push(...Re(n,e)),r),[])}function fe(s){let e=[];for(;s;)e.push(s),s=Object.getPrototypeOf(s);return e.reverse()}function Pe(s,e){let t=s[e];return Array.isArray(t)?t:[]}function Re(s,e){let t=s[e];return t?Object.keys(t).map(r=>[r,t[r]]):[]}var P=class{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new h,this.outletElementsByName=new h,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)}),this.started=!0,this.dependentContexts.forEach(e=>e.refresh()))}refresh(){this.selectorObserverMap.forEach(e=>e.refresh()),this.attributeObserverMap.forEach(e=>e.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(e=>e.stop()),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:r}){let n=this.getOutlet(e,r);n&&this.connectOutlet(n,e,r)}selectorUnmatched(e,t,{outletName:r}){let n=this.getOutletFromMap(e,r);n&&this.disconnectOutlet(n,e,r)}selectorMatchElement(e,{outletName:t}){let r=this.selector(t),n=this.hasOutlet(e,t),i=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return r?n&&i&&e.matches(r):!1}elementMatchedAttribute(e,t){let r=this.getOutletNameFromOutletAttributeName(t);r&&this.updateSelectorObserverForOutlet(r)}elementAttributeValueChanged(e,t){let r=this.getOutletNameFromOutletAttributeName(t);r&&this.updateSelectorObserverForOutlet(r)}elementUnmatchedAttribute(e,t){let r=this.getOutletNameFromOutletAttributeName(t);r&&this.updateSelectorObserverForOutlet(r)}connectOutlet(e,t,r){var n;this.outletElementsByName.has(r,t)||(this.outletsByName.add(r,e),this.outletElementsByName.add(r,t),(n=this.selectorObserverMap.get(r))===null||n===void 0||n.pause(()=>this.delegate.outletConnected(e,t,r)))}disconnectOutlet(e,t,r){var n;this.outletElementsByName.has(r,t)&&(this.outletsByName.delete(r,e),this.outletElementsByName.delete(r,t),(n=this.selectorObserverMap.get(r))===null||n===void 0||n.pause(()=>this.delegate.outletDisconnected(e,t,r)))}disconnectAllOutlets(){for(let e of this.outletElementsByName.keys)for(let t of this.outletElementsByName.getValuesForKey(e))for(let r of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(r,t,e)}updateSelectorObserverForOutlet(e){let t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){let t=this.selector(e),r=new V(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,r),r.start()}setupAttributeObserverForOutlet(e){let t=this.attributeNameForOutletName(e),r=new w(this.scope.element,t,this);this.attributeObserverMap.set(e,r),r.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find(t=>this.attributeNameForOutletName(t)===e)}get outletDependencies(){let e=new h;return this.router.modules.forEach(t=>{let r=t.definition.controllerConstructor;b(r,"outlets").forEach(i=>e.add(i,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){let e=this.dependentControllerIdentifiers;return this.router.contexts.filter(t=>e.includes(t.identifier))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find(r=>r.element===e)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}},R=class{constructor(e,t){this.logDebugActivity=(r,n={})=>{let{identifier:i,controller:o,element:a}=this;n=Object.assign({identifier:i,controller:o,element:a},n),this.application.logDebugActivity(this.identifier,r,n)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new I(this,this.dispatcher),this.valueObserver=new L(this,this.controller),this.targetObserver=new K(this,this),this.outletObserver=new P(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(r){this.handleError(r,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,r={}){let{identifier:n,controller:i,element:o}=this;r=Object.assign({identifier:n,controller:i,element:o},r),this.application.handleError(e,`Error ${t}`,r)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,r){this.invokeControllerMethod(`${$(r)}OutletConnected`,e,t)}outletDisconnected(e,t,r){this.invokeControllerMethod(`${$(r)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let r=this.controller;typeof r[e]=="function"&&r[e](...t)}};function _e(s){return Ue(s,ze(s))}function Ue(s,e){let t=He(s),r=We(s.prototype,e);return Object.defineProperties(t.prototype,r),t}function ze(s){return b(s,"blessings").reduce((t,r)=>{let n=r(s);for(let i in n){let o=t[i]||{};t[i]=Object.assign(o,n[i])}return t},{})}function We(s,e){return Je(e).reduce((t,r)=>{let n=qe(s,e,r);return n&&Object.assign(t,{[r]:n}),t},{})}function qe(s,e,t){let r=Object.getOwnPropertyDescriptor(s,t);if(!(r&&"value"in r)){let i=Object.getOwnPropertyDescriptor(e,t).value;return r&&(i.get=r.get||i.get,i.set=r.set||i.set),i}}var Je=(()=>typeof Object.getOwnPropertySymbols=="function"?s=>[...Object.getOwnPropertyNames(s),...Object.getOwnPropertySymbols(s)]:Object.getOwnPropertyNames)(),He=(()=>{function s(t){function r(){return Reflect.construct(t,arguments,new.target)}return r.prototype=Object.create(t.prototype,{constructor:{value:r}}),Reflect.setPrototypeOf(r,t),r}function e(){let r=s(function(){this.a.call(this)});return r.prototype.a=function(){},new r}try{return e(),s}catch{return r=>class extends r{}}})();function Ze(s){return{identifier:s.identifier,controllerConstructor:_e(s.controllerConstructor)}}var _=class{constructor(e,t){this.application=e,this.definition=Ze(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){let t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){let t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new R(this,e),this.contextsByScope.set(e,t)),t}},U=class{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){let t=this.data.get(this.getDataKey(e))||"";return Be(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}},z=class{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){let t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){let r=this.getAttributeNameForKey(e);return this.element.setAttribute(r,t),this.get(e)}has(e){let t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){let t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}else return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${ue(e)}`}},W=class{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,r){let n=this.warnedKeysByObject.get(e);n||(n=new Set,this.warnedKeysByObject.set(e,n)),n.has(t)||(n.add(t),this.logger.warn(r,e))}};function q(s,e){return`[${s}~="${e}"]`}var J=class{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,r)=>t||this.findTarget(r)||this.findLegacyTarget(r),void 0)}findAll(...e){return e.reduce((t,r)=>[...t,...this.findAllTargets(r),...this.findAllLegacyTargets(r)],[])}findTarget(e){let t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){let t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){let t=this.schema.targetAttributeForScope(this.identifier);return q(t,e)}findLegacyTarget(e){let t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){let t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map(r=>this.deprecate(r,e))}getLegacySelectorForTargetName(e){let t=`${this.identifier}.${e}`;return q(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:r}=this,n=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(r);this.guide.warn(e,`target:${t}`,`Please replace ${n}="${r}.${t}" with ${i}="${t}". The ${n} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}},H=class{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,r)=>t||this.findOutlet(r),void 0)}findAll(...e){return e.reduce((t,r)=>[...t,...this.findAllOutlets(r)],[])}getSelectorForOutletName(e){let t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){let t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){let t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))}matchesElement(e,t,r){let n=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&n.split(" ").includes(r)}},g=class{constructor(e,t,r,n){this.targets=new J(this),this.classes=new U(this),this.data=new z(this),this.containsElement=i=>i.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=r,this.guide=new W(n),this.outlets=new H(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return q(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new g(this.schema,document.documentElement,this.identifier,this.guide.logger)}},Z=class{constructor(e,t,r){this.element=e,this.schema=t,this.delegate=r,this.valueListObserver=new M(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){let{element:t,content:r}=e;return this.parseValueForElementAndIdentifier(t,r)}parseValueForElementAndIdentifier(e,t){let r=this.fetchScopesByIdentifierForElement(e),n=r.get(t);return n||(n=this.delegate.createScopeForElementAndIdentifier(e,t),r.set(t,n)),n}elementMatchedValue(e,t){let r=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,r),r==1&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){let r=this.scopeReferenceCounts.get(t);r&&(this.scopeReferenceCounts.set(t,r-1),r==1&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}},G=class{constructor(e){this.application=e,this.scopeObserver=new Z(this.element,this.schema,this),this.scopesByIdentifier=new h,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((e,t)=>e.concat(t.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);let t=new _(this.application,e);this.connectModule(t);let r=e.controllerConstructor.afterLoad;r&&r.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){let t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){let r=this.modulesByIdentifier.get(t);if(r)return r.contexts.find(n=>n.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){let r=this.scopeObserver.parseValueForElementAndIdentifier(e,t);r?this.scopeObserver.elementMatchedValue(r.element,r):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,r){this.application.handleError(e,t,r)}createScopeForElementAndIdentifier(e,t){return new g(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(r=>e.connectContextForScope(r))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(r=>e.disconnectContextForScope(r))}},Ge={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:s=>`data-${s}-target`,outletAttributeForScope:(s,e)=>`data-${s}-${e}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},ie("abcdefghijklmnopqrstuvwxyz".split("").map(s=>[s,s]))),ie("0123456789".split("").map(s=>[s,s])))};function ie(s){return s.reduce((e,[t,r])=>Object.assign(Object.assign({},e),{[t]:r}),{})}var T=class{constructor(e=document.documentElement,t=Ge){this.logger=console,this.debug=!1,this.logDebugActivity=(r,n,i={})=>{this.debug&&this.logFormattedMessage(r,n,i)},this.element=e,this.schema=t,this.dispatcher=new B(this),this.router=new G(this),this.actionDescriptorFilters=Object.assign({},Fe)}static start(e,t){let r=new this(e,t);return r.start(),r}async start(){await Qe(),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(n=>{n.controllerConstructor.shouldLoad&&this.router.loadDefinition(n)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(n=>this.router.unloadIdentifier(n))}get controllers(){return this.router.contexts.map(e=>e.controller)}getControllerForElementAndIdentifier(e,t){let r=this.router.getContextForElementAndIdentifier(e,t);return r?r.controller:null}handleError(e,t,r){var n;this.logger.error(`%s
2
+
3
+ %o
4
+
5
+ %o`,t,e,r),(n=window.onerror)===null||n===void 0||n.call(window,t,"",0,0,e)}logFormattedMessage(e,t,r={}){r=Object.assign({application:this},r),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},r)),this.logger.groupEnd()}};function Qe(){return new Promise(s=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>s()):s()})}function Xe(s){return b(s,"classes").reduce((t,r)=>Object.assign(t,Ye(r)),{})}function Ye(s){return{[`${s}Class`]:{get(){let{classes:e}=this;if(e.has(s))return e.get(s);{let t=e.getAttributeName(s);throw new Error(`Missing attribute "${t}"`)}}},[`${s}Classes`]:{get(){return this.classes.getAll(s)}},[`has${y(s)}Class`]:{get(){return this.classes.has(s)}}}}function et(s){return b(s,"outlets").reduce((t,r)=>Object.assign(t,tt(r)),{})}function oe(s,e,t){return s.application.getControllerForElementAndIdentifier(e,t)}function ae(s,e,t){let r=oe(s,e,t);if(r||(s.application.router.proposeToConnectScopeForElementAndIdentifier(e,t),r=oe(s,e,t),r))return r}function tt(s){let e=$(s);return{[`${e}Outlet`]:{get(){let t=this.outlets.find(s),r=this.outlets.getSelectorForOutletName(s);if(t){let n=ae(this,t,s);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${s}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${s}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${r}".`)}},[`${e}Outlets`]:{get(){let t=this.outlets.findAll(s);return t.length>0?t.map(r=>{let n=ae(this,r,s);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${s}" instance for host controller "${this.identifier}"`,r)}).filter(r=>r):[]}},[`${e}OutletElement`]:{get(){let t=this.outlets.find(s),r=this.outlets.getSelectorForOutletName(s);if(t)return t;throw new Error(`Missing outlet element "${s}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${r}".`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(s)}},[`has${y(e)}Outlet`]:{get(){return this.outlets.has(s)}}}}function rt(s){return b(s,"targets").reduce((t,r)=>Object.assign(t,st(r)),{})}function st(s){return{[`${s}Target`]:{get(){let e=this.targets.find(s);if(e)return e;throw new Error(`Missing target element "${s}" for "${this.identifier}" controller`)}},[`${s}Targets`]:{get(){return this.targets.findAll(s)}},[`has${y(s)}Target`]:{get(){return this.targets.has(s)}}}}function nt(s){let e=Ke(s,"values"),t={valueDescriptorMap:{get(){return e.reduce((r,n)=>{let i=pe(n,this.identifier),o=this.data.getAttributeNameForKey(i.key);return Object.assign(r,{[o]:i})},{})}}};return e.reduce((r,n)=>Object.assign(r,it(n)),t)}function it(s,e){let t=pe(s,e),{key:r,name:n,reader:i,writer:o}=t;return{[n]:{get(){let a=this.data.get(r);return a!==null?i(a):t.defaultValue},set(a){a===void 0?this.data.delete(r):this.data.set(r,o(a))}},[`has${y(n)}`]:{get(){return this.data.has(r)||t.hasCustomDefaultValue}}}}function pe([s,e],t){return lt({controller:t,token:s,typeDefinition:e})}function C(s){switch(s){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function m(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(s))return"array";if(Object.prototype.toString.call(s)==="[object Object]")return"object"}function ot(s){let{controller:e,token:t,typeObject:r}=s,n=re(r.type),i=re(r.default),o=n&&i,a=n&&!i,c=!n&&i,l=C(r.type),S=m(s.typeObject.default);if(a)return l;if(c)return S;if(l!==S){let Oe=e?`${e}.${t}`:t;throw new Error(`The specified default value for the Stimulus Value "${Oe}" must match the defined type "${l}". The provided default value of "${r.default}" is of type "${S}".`)}if(o)return l}function at(s){let{controller:e,token:t,typeDefinition:r}=s,i=ot({controller:e,token:t,typeObject:r}),o=m(r),a=C(r),c=i||o||a;if(c)return c;let l=e?`${e}.${r}`:t;throw new Error(`Unknown value type "${l}" for "${t}" value`)}function ct(s){let e=C(s);if(e)return ce[e];let t=N(s,"default"),r=N(s,"type"),n=s;if(t)return n.default;if(r){let{type:i}=n,o=C(i);if(o)return ce[o]}return s}function lt(s){let{token:e,typeDefinition:t}=s,r=`${ue(e)}-value`,n=at(s);return{type:n,key:r,name:Q(r),get defaultValue(){return ct(t)},get hasCustomDefaultValue(){return m(t)!==void 0},reader:ht[n],writer:le[n]||le.default}}var ce={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},ht={array(s){let e=JSON.parse(s);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${s}" of type "${m(e)}"`);return e},boolean(s){return!(s=="0"||String(s).toLowerCase()=="false")},number(s){return Number(s.replace(/_/g,""))},object(s){let e=JSON.parse(s);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${s}" of type "${m(e)}"`);return e},string(s){return s}},le={default:ut,array:he,object:he};function he(s){return JSON.stringify(s)}function ut(s){return`${s}`}var u=class{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:r={},prefix:n=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){let a=n?`${n}:${e}`:e,c=new CustomEvent(a,{detail:r,bubbles:i,cancelable:o});return t.dispatchEvent(c),c}};u.blessings=[Xe,rt,nt,et];u.targets=[];u.outlets=[];u.values={};var dt="absolute bg-gray-100 opacity-10 w-full h-full",d=class extends u{get placeholder(){return this.citySelectInputTarget.getAttribute("aria-placeholder")}set loading(s){if(s){let e=document.createElement("div");e.className=dt,e.dataset.target="city-loader",this.citySelectWrapperTarget.prepend(e),this.citySelectWrapperTarget.classList.add("opacity-50")}else this.citySelectWrapperTarget.querySelector('[data-target="city-loader"]').remove(),this.citySelectWrapperTarget.classList.remove("opacity-50")}connect(){return O(this,null,function*(){this.captureTheInitialValue(),yield this.onCountryChange()})}onCountryChange(){return O(this,null,function*(){if(this.hasCountrySelectInputTarget&&this.countrySelectInputTarget){let s=this.countrySelectInputTarget.value,e=yield this.fetchCitiesForCountry(s);Object.keys(this.citySelectInputTarget.options).forEach(()=>{this.citySelectInputTarget.options.remove(0)}),this.citySelectInputTarget.add(new Option(this.placeholder)),e.forEach(r=>{this.citySelectInputTarget.add(new Option(r,r))}),Array.from(this.citySelectInputTarget.options).map(r=>r.value).includes(this.initialValue)?this.citySelectInputTarget.value=this.initialValue:this.citySelectInputTarget.value=this.citySelectInputTarget.options[0].value}})}captureTheInitialValue(){this.initialValue=this.citySelectInputTarget.value}fetchCitiesForCountry(s){return O(this,null,function*(){if(!s)return[];this.loading=!0;let t=yield(yield fetch(`${window.Avo.configuration.root_path}/resources/courses/cities?country=${s}`)).json();return this.loading=!1,t})}};v(d,"targets",["countrySelectInput","citySelectInput","citySelectWrapper"]),v(d,"values",{view:String}),v(d,"initialValue");function ft(s){return s.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function X(s){return s.charAt(0).toUpperCase()+s.slice(1)}function pt(s){return s.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function ye(s,e){let t=be(s);return Array.from(t.reduce((r,n)=>(mt(n,e).forEach(i=>r.add(i)),r),new Set))}function gt(s,e){return be(s).reduce((r,n)=>(r.push(...yt(n,e)),r),[])}function be(s){let e=[];for(;s;)e.push(s),s=Object.getPrototypeOf(s);return e.reverse()}function mt(s,e){let t=s[e];return Array.isArray(t)?t:[]}function yt(s,e){let t=s[e];return t?Object.keys(t).map(r=>[r,t[r]]):[]}(()=>{function s(t){function r(){return Reflect.construct(t,arguments,new.target)}return r.prototype=Object.create(t.prototype,{constructor:{value:r}}),Reflect.setPrototypeOf(r,t),r}function e(){let r=s(function(){this.a.call(this)});return r.prototype.a=function(){},new r}try{return e(),s}catch{return r=>class extends r{}}})();function bt(s){return ye(s,"classes").reduce((t,r)=>Object.assign(t,vt(r)),{})}function vt(s){return{[`${s}Class`]:{get(){let{classes:e}=this;if(e.has(s))return e.get(s);{let t=e.getAttributeName(s);throw new Error(`Missing attribute "${t}"`)}}},[`${s}Classes`]:{get(){return this.classes.getAll(s)}},[`has${X(s)}Class`]:{get(){return this.classes.has(s)}}}}function Ot(s){return ye(s,"targets").reduce((t,r)=>Object.assign(t,At(r)),{})}function At(s){return{[`${s}Target`]:{get(){let e=this.targets.find(s);if(e)return e;throw new Error(`Missing target element "${s}" for "${this.identifier}" controller`)}},[`${s}Targets`]:{get(){return this.targets.findAll(s)}},[`has${X(s)}Target`]:{get(){return this.targets.has(s)}}}}function Et(s){let e=gt(s,"values"),t={valueDescriptorMap:{get(){return e.reduce((r,n)=>{let i=ve(n),o=this.data.getAttributeNameForKey(i.key);return Object.assign(r,{[o]:i})},{})}}};return e.reduce((r,n)=>Object.assign(r,wt(n)),t)}function wt(s){let e=ve(s),{key:t,name:r,reader:n,writer:i}=e;return{[r]:{get(){let o=this.data.get(t);return o!==null?n(o):e.defaultValue},set(o){o===void 0?this.data.delete(t):this.data.set(t,i(o))}},[`has${X(r)}`]:{get(){return this.data.has(t)||e.hasCustomDefaultValue}}}}function ve([s,e]){return Ct(s,e)}function Y(s){switch(s){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function ee(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(s))return"array";if(Object.prototype.toString.call(s)==="[object Object]")return"object"}function Ft(s){let e=Y(s.type);if(e){let t=ee(s.default);if(e!==t)throw new Error(`Type "${e}" must match the type of the default value. Given default value: "${s.default}" as "${t}"`);return e}}function Mt(s){let e=Ft(s),t=ee(s),r=Y(s),n=e||t||r;if(n)return n;throw new Error(`Unknown value type "${s}"`)}function Tt(s){let e=Y(s);if(e)return St[e];let t=s.default;return t!==void 0?t:s}function Ct(s,e){let t=`${pt(s)}-value`,r=Mt(e);return{type:r,key:t,name:ft(t),get defaultValue(){return Tt(e)},get hasCustomDefaultValue(){return ee(e)!==void 0},reader:kt[r],writer:ge[r]||ge.default}}var St={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},kt={array(s){let e=JSON.parse(s);if(!Array.isArray(e))throw new TypeError("Expected array");return e},boolean(s){return!(s=="0"||s=="false")},number(s){return Number(s)},object(s){let e=JSON.parse(s);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Expected object");return e},string(s){return s}},ge={default:Bt,array:me,object:me};function me(s){return JSON.stringify(s)}function Bt(s){return`${s}`}var f=class{constructor(e){this.context=e}static get shouldLoad(){return!0}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:r={},prefix:n=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){let a=n?`${n}:${e}`:e,c=new CustomEvent(a,{detail:r,bubbles:i,cancelable:o});return t.dispatchEvent(c),c}};f.blessings=[bt,Ot,Et];f.targets=[];f.values={};var p=class extends f{add(e){e.preventDefault();let t=this.templateTarget.innerHTML.replace(/NEW_RECORD/g,new Date().getTime().toString());this.targetTarget.insertAdjacentHTML("beforebegin",t)}remove(e){e.preventDefault();let t=e.target.closest(this.wrapperSelectorValue);if(t.dataset.newRecord==="true")t.remove();else{t.style.display="none";let r=t.querySelector("input[name*='_destroy']");r.value="1"}}};p.targets=["target","template"];p.values={wrapperSelector:{type:String,default:".nested-form-wrapper"}};var te=T.start();te.debug=window==null?void 0:window.localStorage.getItem("avo.debug");te.register("city-in-country",d);te.register("nested-form",p);console.log("Hi from Avo custom JS \u{1F44B}");})();
6
+ //# sourceMappingURL=avo.custom.js.map
@@ -31,21 +31,8 @@
31
31
  data-transition-leave-end="transform opacity-0 -translate-y-1"
32
32
  >
33
33
  <div data-target="actions-list" class="w-full space divide-y">
34
- <% actions.each_with_index do |action, index| %>
35
- <%= link_to action_path(action),
36
- data: {
37
- action_name: action.action_name,
38
- 'turbo-frame': Avo::ACTIONS_TURBO_FRAME_ID,
39
- 'action': 'click->actions-picker#visitAction',
40
- 'actions-picker-target': action.standalone ? 'standaloneAction' : 'resourceAction',
41
- 'disabled': is_disabled?(action),
42
- # for some reason InstantClick fetches the URL even if it's prefetched.
43
- turbo_prefetch: false,
44
- },
45
- title: action.action_name,
46
- class: "flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100 #{is_disabled?(action) ? 'text-gray-500' : 'text-black'}" do %>
47
- <%= svg 'play', class: 'h-5 mr-1 inline pointer-events-none' %> <%= action.action_name %>
48
- <% end %>
34
+ <% actions.each do |action| %>
35
+ <%= render_item(action)%>
49
36
  <% end %>
50
37
  </div>
51
38
  </div>
@@ -79,4 +79,42 @@ class Avo::ActionsComponent < ViewComponent::Base
79
79
  }.compact
80
80
  ).to_s
81
81
  end
82
+
83
+ def icon(action)
84
+ svg action.icon, class: "h-5 mr-1 inline pointer-events-none"
85
+ end
86
+
87
+ def render_item(action)
88
+ if action.is_a?(Avo::DividerComponent)
89
+ render Avo::DividerComponent.new
90
+ else
91
+ render_action_link(action)
92
+ end
93
+ end
94
+
95
+ private
96
+
97
+ def render_action_link(action)
98
+ link_to action_path(action),
99
+ data: action_data_attributes(action),
100
+ title: action.action_name,
101
+ class: action_css_class(action) do
102
+ raw("#{icon(action)} #{action.action_name}")
103
+ end
104
+ end
105
+
106
+ def action_data_attributes(action)
107
+ {
108
+ action_name: action.action_name,
109
+ "turbo-frame": Avo::ACTIONS_TURBO_FRAME_ID,
110
+ action: "click->actions-picker#visitAction",
111
+ "actions-picker-target": action.standalone ? "standaloneAction" : "resourceAction",
112
+ disabled: is_disabled?(action),
113
+ turbo_prefetch: false,
114
+ }
115
+ end
116
+
117
+ def action_css_class(action)
118
+ "flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100 border-b#{is_disabled?(action) ? " text-gray-500" : " text-black"}"
119
+ end
82
120
  end
@@ -0,0 +1,3 @@
1
+ <div class="relative col-span-full border-t border-gray-300 border-solid" style= "border-width: 1.75px;">
2
+ <div class="absolute inset-auto -translate-y-1/2 -translate-x-1/2 ml-1/2 z-20 text-xs font-semibold uppercase leading-none text-gray-500 bg-application px-2"></div>
3
+ </div>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Avo::DividerComponent < ViewComponent::Base
4
+ def initialize(**args)
5
+ end
6
+ end
@@ -335,7 +335,11 @@ module Avo
335
335
  elsif available_view_types.size == 1
336
336
  available_view_types.first
337
337
  else
338
- @resource.default_view_type || Avo.configuration.default_view_type
338
+ Avo::ExecutionContext.new(
339
+ target: @resource.default_view_type || Avo.configuration.default_view_type,
340
+ resource: @resource,
341
+ view: @view
342
+ ).handle
339
343
  end
340
344
 
341
345
  if available_view_types.exclude? @index_params[:view_type].to_sym
@@ -357,11 +361,11 @@ module Avo
357
361
  def set_actions
358
362
  @actions = @resource
359
363
  .get_actions
360
- .map do |action|
361
- action[:class].new(record: @record, resource: @resource, view: @view, arguments: action[:arguments])
364
+ .map do |action_bag|
365
+ action_bag.delete(:class).new(record: @record, resource: @resource, view: @view, **action_bag)
362
366
  end
363
367
  .select do |action|
364
- action.visible_in_view(parent_resource: @parent_resource)
368
+ action.is_a?(DividerComponent) || action.visible_in_view(parent_resource: @parent_resource)
365
369
  end
366
370
  end
367
371
 
@@ -126,10 +126,16 @@ module Avo
126
126
  title = item&.dig(:title) || resource.record_title
127
127
  highlighted_title = highlight(title&.to_s, params[:q])
128
128
 
129
+ record_path = if resource.link_to_child_resource
130
+ Avo.resource_manager.get_resource_by_model_class(record.class).new(record: record).record_path
131
+ else
132
+ resource.record_path
133
+ end
134
+
129
135
  {
130
136
  _id: record.id,
131
137
  _label: highlighted_title,
132
- _url: resource.class.fetch_search(:result_path, record: resource.record) || resource.record_path
138
+ _url: resource.class.fetch_search(:result_path, record: resource.record) || record_path
133
139
  }
134
140
  end
135
141
 
data/avo.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.post_install_message = "Thank you for using Avo 💪 Docs are available at https://docs.avohq.io"
33
33
 
34
34
  spec.files = Dir["{bin,app,config,db,lib,public}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "avo.gemspec", "Gemfile", "Gemfile.lock", "tailwind.preset.js", "tailwind.custom.js"]
35
- spec.files.reject! { |file_name| %w[application.js application.js.map avo.custom.js avo.custom.js.map].any? { |rejected_file| file_name.include? rejected_file } }
35
+ spec.files.reject! { |file_name| %w[application.js application.js.map spec/dummy/app/javascript/avo.custom.js avo.custom.js.map].any? { |rejected_file| file_name.include? rejected_file } }
36
36
 
37
37
  spec.add_dependency "activerecord", ">= 6.1"
38
38
  spec.add_dependency "activesupport", ">= 6.1"
@@ -20,6 +20,7 @@ module Avo
20
20
  attr_accessor :resource
21
21
  attr_accessor :user
22
22
  attr_reader :arguments
23
+ attr_reader :icon
23
24
 
24
25
  # TODO: find a differnet way to delegate this to the uninitialized Current variable
25
26
  delegate :context, to: Avo::Current
@@ -101,11 +102,12 @@ module Avo
101
102
  self.class.to_s.demodulize.underscore.humanize(keep_id_suffix: true)
102
103
  end
103
104
 
104
- def initialize(record: nil, resource: nil, user: nil, view: nil, arguments: {})
105
+ def initialize(record: nil, resource: nil, user: nil, view: nil, arguments: {}, icon: :play)
105
106
  @record = record
106
107
  @resource = resource
107
108
  @user = user
108
109
  @view = Avo::ViewInquirer.new(view)
110
+ @icon = icon
109
111
  @arguments = Avo::ExecutionContext.new(
110
112
  target: arguments,
111
113
  resource: resource,
@@ -294,6 +294,10 @@ module Avo
294
294
  cards
295
295
  end
296
296
 
297
+ def divider
298
+ action DividerComponent
299
+ end
300
+
297
301
  # def fields / def cards
298
302
  [:fields, :cards].each do |method_name|
299
303
  define_method method_name do
@@ -310,8 +314,8 @@ module Avo
310
314
  end
311
315
 
312
316
  # def action / def filter / def scope
313
- define_method entity do |entity_class, arguments: {}|
314
- entity_loader(entity).use({class: entity_class, arguments: arguments})
317
+ define_method entity do |entity_class, arguments: {}, icon: nil|
318
+ entity_loader(entity).use({class: entity_class, arguments: arguments, icon: icon}.compact)
315
319
  end
316
320
 
317
321
  # def get_actions / def get_filters / def get_scopes
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.5.5" unless const_defined?(:VERSION)
2
+ VERSION = "3.5.6" unless const_defined?(:VERSION)
3
3
  end
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line no-console
2
+ console.log('Hi from Avo custom JS 👋')
@@ -8231,6 +8231,10 @@ tag.tagify__tag{
8231
8231
  border-top-width:0px
8232
8232
  }
8233
8233
 
8234
+ .border-solid{
8235
+ border-style:solid
8236
+ }
8237
+
8234
8238
  .border-dashed{
8235
8239
  border-style:dashed
8236
8240
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.5
4
+ version: 3.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-03-25 00:00:00.000000000 Z
13
+ date: 2024-04-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -239,6 +239,7 @@ files:
239
239
  - app/assets/builds/avo.base.css
240
240
  - app/assets/builds/avo.base.js
241
241
  - app/assets/builds/avo.base.js.map
242
+ - app/assets/builds/avo.custom.js
242
243
  - app/assets/config/avo_manifest.js
243
244
  - app/assets/stylesheets/avo.base.css
244
245
  - app/assets/stylesheets/css/active-storage.css
@@ -1772,6 +1773,8 @@ files:
1772
1773
  - app/components/avo/blank_field_component.html.erb
1773
1774
  - app/components/avo/blank_field_component.rb
1774
1775
  - app/components/avo/button_component.rb
1776
+ - app/components/avo/divider_component.html.erb
1777
+ - app/components/avo/divider_component.rb
1775
1778
  - app/components/avo/empty_state_component.html.erb
1776
1779
  - app/components/avo/empty_state_component.rb
1777
1780
  - app/components/avo/field_wrapper_component.html.erb
@@ -2341,6 +2344,7 @@ files:
2341
2344
  - lib/generators/avo/templates/filters/select_filter.tt
2342
2345
  - lib/generators/avo/templates/filters/text_filter.tt
2343
2346
  - lib/generators/avo/templates/initializer/avo.tt
2347
+ - lib/generators/avo/templates/js/avo.custom.js
2344
2348
  - lib/generators/avo/templates/locales/avo.ar.yml
2345
2349
  - lib/generators/avo/templates/locales/avo.en.yml
2346
2350
  - lib/generators/avo/templates/locales/avo.es.yml