ariadne_view_components 0.0.77 → 0.0.78

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- function Vs(n,t=0,{start:e=!0,middle:s=!0,once:i=!1}={}){let r=e,o=0,a,c=!1;function l(...u){if(c)return;const d=Date.now()-o;o=Date.now(),e&&s&&d>=t&&(r=!0),r?(r=!1,n.apply(this,u),i&&l.cancel()):(s&&d<t||!s)&&(clearTimeout(a),a=setTimeout(()=>{o=Date.now(),n.apply(this,u),i&&l.cancel()},s?t-d:t))}return l.cancel=()=>{clearTimeout(a),c=!0},l}function Ws(n,t=0,{start:e=!1,middle:s=!1,once:i=!1}={}){return Vs(n,t,{start:e,middle:s,once:i})}var oe=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},Ks=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},nt;const kt=new WeakMap;class ne extends Event{constructor(t){super(`auto-check-${t}`,{bubbles:!0}),this.phase=t}get detail(){return this}}class Gn extends ne{constructor(t,e=""){super(t),this.phase=t,this.message=e,this.setValidity=s=>{this.message=s}}}class ze extends ne{constructor(){super("complete")}}class Us extends ne{constructor(t){super("success"),this.response=t}}class qs extends Gn{constructor(){super("start","Verifying…")}}class zs extends Gn{constructor(t){super("error","Validation failed"),this.response=t}}class Ys extends ne{constructor(t){super("send"),this.body=t}}class Zn extends HTMLElement{constructor(){super(...arguments),nt.set(this,null)}static define(t="auto-check",e=customElements){return e.define(t,this),this}get onloadend(){return oe(this,nt,"f")}set onloadend(t){oe(this,nt,"f")&&this.removeEventListener("loadend",oe(this,nt,"f")),Ks(this,nt,typeof t=="object"||typeof t=="function"?t:null,"f"),typeof t=="function"&&this.addEventListener("loadend",t)}connectedCallback(){const t=this.input;if(!t)return;const e=Ws(Zs.bind(null,this),300),s={check:e,controller:null};kt.set(this,s),t.addEventListener("input",Ye),t.addEventListener("input",e),t.autocomplete="off",t.spellcheck=!1}disconnectedCallback(){const t=this.input;if(!t)return;const e=kt.get(this);e&&(kt.delete(this),t.removeEventListener("input",Ye),t.removeEventListener("input",e.check),t.setCustomValidity(""))}attributeChangedCallback(t){if(t==="required"){const e=this.input;if(!e)return;e.required=this.required}}static get observedAttributes(){return["required"]}get input(){return this.querySelector("input")}get src(){const t=this.getAttribute("src");if(!t)return"";const e=this.ownerDocument.createElement("a");return e.href=t,e.href}set src(t){this.setAttribute("src",t)}get csrf(){const t=this.querySelector("[data-csrf]");return this.getAttribute("csrf")||t instanceof HTMLInputElement&&t.value||""}set csrf(t){this.setAttribute("csrf",t)}get required(){return this.hasAttribute("required")}set required(t){t?this.setAttribute("required",""):this.removeAttribute("required")}get csrfField(){return this.getAttribute("csrf-field")||"authenticity_token"}set csrfField(t){this.setAttribute("csrf-field",t)}}nt=new WeakMap;function Ye(n){const t=n.currentTarget;if(!(t instanceof HTMLInputElement))return;const e=t.closest("auto-check");if(!(e instanceof Zn))return;const s=e.src,i=e.csrf,r=kt.get(e);if(!s||!i||!r)return;const o=new qs;t.dispatchEvent(o),e.required&&t.setCustomValidity(o.message)}function Xs(){return"AbortController"in window?new AbortController:{signal:null,abort(){}}}async function Gs(n,t,e){try{const s=await fetch(t,e);return n.dispatchEvent(new Event("load")),n.dispatchEvent(new Event("loadend")),s}catch(s){throw s.name!=="AbortError"&&(n.dispatchEvent(new Event("error")),n.dispatchEvent(new Event("loadend"))),s}}async function Zs(n){const t=n.input;if(!t)return;const e=n.csrfField,s=n.src,i=n.csrf,r=kt.get(n);if(!s||!i||!r){n.required&&t.setCustomValidity("");return}if(!t.value.trim()){n.required&&t.setCustomValidity("");return}const o=new FormData;o.append(e,i),o.append("value",t.value),t.dispatchEvent(new Ys(o)),r.controller?r.controller.abort():n.dispatchEvent(new Event("loadstart")),r.controller=Xs();try{const a=await Gs(n,s,{credentials:"same-origin",signal:r.controller.signal,method:"POST",body:o});if(a.ok)n.required&&t.setCustomValidity(""),t.dispatchEvent(new Us(a.clone()));else{const c=new zs(a.clone());t.dispatchEvent(c),n.required&&t.setCustomValidity(c.message)}r.controller=null,t.dispatchEvent(new ze)}catch(a){a.name!=="AbortError"&&(r.controller=null,t.dispatchEvent(new ze))}}const Xe=typeof globalThis<"u"?globalThis:window;try{Xe.AutoCheckElement=Zn.define()}catch(n){if(!(Xe.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}class Js{constructor(t,e,{tabInsertsSuggestions:s,defaultFirstOption:i}={}){this.input=t,this.list=e,this.tabInsertsSuggestions=s??!0,this.defaultFirstOption=i??!1,this.isComposing=!1,e.id||(e.id=`combobox-${Math.random().toString().slice(2,6)}`),this.ctrlBindings=!!navigator.userAgent.match(/Macintosh/),this.keyboardEventHandler=r=>Qs(r,this),this.compositionEventHandler=r=>ei(r,this),this.inputHandler=this.clearSelection.bind(this),t.setAttribute("role","combobox"),t.setAttribute("aria-controls",e.id),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",Ge),this.indicateDefaultOption()}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",Ge)}indicateDefaultOption(){var t;this.defaultFirstOption&&((t=Array.from(this.list.querySelectorAll('[role="option"]:not([aria-disabled="true"])')).filter(ae)[0])===null||t===void 0||t.setAttribute("data-combobox-option-default","true"))}navigate(t=1){const e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(ae)[0],s=Array.from(this.list.querySelectorAll('[role="option"]')).filter(ae),i=s.indexOf(e);if(i===s.length-1&&t===1||i===0&&t===-1){this.clearSelection(),this.input.focus();return}let r=t===1?0:s.length-1;if(e&&i>=0){const a=i+t;a>=0&&a<s.length&&(r=a)}const o=s[r];if(o)for(const a of s)a.removeAttribute("data-combobox-option-default"),o===a?(this.input.setAttribute("aria-activedescendant",o.id),o.setAttribute("aria-selected","true"),ni(this.list,o)):a.removeAttribute("aria-selected")}clearSelection(){this.input.removeAttribute("aria-activedescendant");for(const t of this.list.querySelectorAll('[aria-selected="true"]'))t.removeAttribute("aria-selected");this.indicateDefaultOption()}}function Qs(n,t){if(!(n.shiftKey||n.metaKey||n.altKey)&&!(!t.ctrlBindings&&n.ctrlKey)&&!t.isComposing)switch(n.key){case"Enter":Ze(t.input,t.list)&&n.preventDefault();break;case"Tab":t.tabInsertsSuggestions&&Ze(t.input,t.list)&&n.preventDefault();break;case"Escape":t.clearSelection();break;case"ArrowDown":t.navigate(1),n.preventDefault();break;case"ArrowUp":t.navigate(-1),n.preventDefault();break;case"n":t.ctrlBindings&&n.ctrlKey&&(t.navigate(1),n.preventDefault());break;case"p":t.ctrlBindings&&n.ctrlKey&&(t.navigate(-1),n.preventDefault());break;default:if(n.ctrlKey)break;t.clearSelection()}}function Ge(n){if(!(n.target instanceof Element))return;const t=n.target.closest('[role="option"]');t&&t.getAttribute("aria-disabled")!=="true"&&ti(t,{event:n})}function Ze(n,t){const e=t.querySelector('[aria-selected="true"], [data-combobox-option-default="true"]');return e?(e.getAttribute("aria-disabled")==="true"||e.click(),!0):!1}function ti(n,t){n.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0,detail:t}))}function ae(n){return!n.hidden&&!(n instanceof HTMLInputElement&&n.type==="hidden")&&(n.offsetWidth>0||n.offsetHeight>0)}function ei(n,t){t.isComposing=n.type==="compositionstart",document.getElementById(t.input.getAttribute("aria-controls")||"")&&t.clearSelection()}function ni(n,t){si(n,t)||(n.scrollTop=t.offsetTop)}function si(n,t){const e=n.scrollTop,s=e+n.clientHeight,i=t.offsetTop,r=i+t.clientHeight;return i>=e&&r<=s}function ii(n,t=0){let e;return function(...s){clearTimeout(e),e=window.setTimeout(()=>{clearTimeout(e),n(...s)},t)}}const ri=window.testScreenReaderDelay||100;class oi{constructor(t,e,s,i=!1){var r;if(this.container=t,this.input=e,this.results=s,this.combobox=new Js(e,s,{defaultFirstOption:i}),this.feedback=t.getRootNode().getElementById(`${this.results.id}-feedback`),this.autoselectEnabled=i,this.clearButton=t.getRootNode().getElementById(`${this.input.id||this.input.name}-clear`),this.clientOptions=s.querySelectorAll("[role=option]"),this.feedback&&(this.feedback.setAttribute("aria-live","polite"),this.feedback.setAttribute("aria-atomic","true")),this.clearButton&&!this.clearButton.getAttribute("aria-label")){const o=document.querySelector(`label[for="${this.input.name}"]`);this.clearButton.setAttribute("aria-label","clear:"),this.clearButton.setAttribute("aria-labelledby",`${this.clearButton.id} ${(o==null?void 0:o.id)||""}`)}this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.results.popover?this.results.matches(":popover-open")&&this.results.hidePopover():this.results.hidden=!0,this.results.getAttribute("aria-label")||this.results.setAttribute("aria-label","results"),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("spellcheck","false"),this.interactingWithList=!1,this.onInputChange=ii(this.onInputChange.bind(this),300),this.onResultsMouseDown=this.onResultsMouseDown.bind(this),this.onInputBlur=this.onInputBlur.bind(this),this.onInputFocus=this.onInputFocus.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onCommit=this.onCommit.bind(this),this.handleClear=this.handleClear.bind(this),this.input.addEventListener("keydown",this.onKeydown),this.input.addEventListener("focus",this.onInputFocus),this.input.addEventListener("blur",this.onInputBlur),this.input.addEventListener("input",this.onInputChange),this.results.addEventListener("mousedown",this.onResultsMouseDown),this.results.addEventListener("combobox-commit",this.onCommit),(r=this.clearButton)===null||r===void 0||r.addEventListener("click",this.handleClear)}destroy(){this.input.removeEventListener("keydown",this.onKeydown),this.input.removeEventListener("focus",this.onInputFocus),this.input.removeEventListener("blur",this.onInputBlur),this.input.removeEventListener("input",this.onInputChange),this.results.removeEventListener("mousedown",this.onResultsMouseDown),this.results.removeEventListener("combobox-commit",this.onCommit)}handleClear(t){t.preventDefault(),this.input.getAttribute("aria-expanded")==="true"&&(this.input.setAttribute("aria-expanded","false"),this.updateFeedbackForScreenReaders("Results hidden.")),this.input.value="",this.container.value="",this.input.focus(),this.input.dispatchEvent(new Event("change")),this.close()}onKeydown(t){if(t.key==="Escape"&&this.container.open)this.close(),t.stopPropagation(),t.preventDefault();else if(t.altKey&&t.key==="ArrowUp"&&this.container.open)this.close(),t.stopPropagation(),t.preventDefault();else if(t.altKey&&t.key==="ArrowDown"&&!this.container.open){if(!this.input.value.trim())return;this.open(),t.stopPropagation(),t.preventDefault()}}onInputFocus(){this.interactingWithList||this.fetchResults()}onInputBlur(){this.interactingWithList||this.close()}onCommit({target:t}){const e=t;if(!(e instanceof HTMLElement)||(this.close(),e instanceof HTMLAnchorElement))return;const s=e.getAttribute("data-autocomplete-value")||e.textContent;this.updateFeedbackForScreenReaders(`${e.textContent||""} selected.`),this.container.value=s,s||this.updateFeedbackForScreenReaders("Results hidden.")}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){this.feedback&&this.feedback.textContent&&(this.feedback.textContent=""),this.container.removeAttribute("value"),this.fetchResults()}identifyOptions(){let t=0;for(const e of this.results.querySelectorAll('[role="option"]:not([id])'))e.id=`${this.results.id}-option-${t++}`}updateFeedbackForScreenReaders(t){setTimeout(()=>{this.feedback&&(this.feedback.textContent=t)},ri)}fetchResults(){const t=this.input.value.trim();if(!t&&!this.container.fetchOnEmpty){this.close();return}const e=this.container.src;if(!e)return;const s=new URL(e,window.location.href),i=new URLSearchParams(s.search.slice(1));i.append("q",t),s.search=i.toString(),this.container.dispatchEvent(new CustomEvent("loadstart")),this.container.fetchResult(s).then(r=>{this.results.innerHTML=r,this.identifyOptions(),this.combobox.indicateDefaultOption();const o=this.results.querySelectorAll('[role="option"]'),a=!!o.length,c=o.length,[l]=o,u=l==null?void 0:l.textContent;this.autoselectEnabled&&u?this.updateFeedbackForScreenReaders(`${c} results. ${u} is the top result: Press Enter to activate.`):this.updateFeedbackForScreenReaders(`${c||"No"} results.`),a?this.open():this.close(),this.container.dispatchEvent(new CustomEvent("load")),this.container.dispatchEvent(new CustomEvent("loadend"))}).catch(()=>{this.container.dispatchEvent(new CustomEvent("error")),this.container.dispatchEvent(new CustomEvent("loadend"))})}open(){(this.results.popover?!this.results.matches(":popover-open"):this.results.hidden)&&(this.combobox.start(),this.results.popover?this.results.showPopover():this.results.hidden=!1),this.container.open=!0,this.interactingWithList=!0}close(){(this.results.popover?this.results.matches(":popover-open"):!this.results.hidden)&&(this.combobox.stop(),this.results.popover?this.results.hidePopover():this.results.hidden=!0),this.container.open=!1,this.interactingWithList=!1}}var R=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},ce=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},ai=function(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e},st,yt,wt,Et,Kt;const ci=globalThis.HTMLElement||null;class li extends Event{constructor(t,e){var{relatedTarget:s}=e,i=ai(e,["relatedTarget"]);super(t,i),this.relatedTarget=s}}const H=new WeakMap;let le=null;class ui extends ci{constructor(){super(...arguments),st.add(this),yt.set(this,null),wt.set(this,null),Kt.set(this,void 0)}static define(t="auto-complete",e=customElements){return e.define(t,this),this}static setCSPTrustedTypesPolicy(t){le=t===null?t:Promise.resolve(t)}get forElement(){var t;if(!((t=R(this,yt,"f"))===null||t===void 0)&&t.isConnected)return R(this,yt,"f");const e=this.getAttribute("for"),s=this.getRootNode();return e&&(s instanceof Document||s instanceof ShadowRoot)?s.getElementById(e):null}set forElement(t){ce(this,yt,t,"f"),this.setAttribute("for","")}get inputElement(){var t;return!((t=R(this,wt,"f"))===null||t===void 0)&&t.isConnected?R(this,wt,"f"):this.querySelector("input")}set inputElement(t){ce(this,wt,t,"f"),R(this,st,"m",Et).call(this)}connectedCallback(){this.isConnected&&(R(this,st,"m",Et).call(this),new MutationObserver(()=>{H.get(this)||R(this,st,"m",Et).call(this)}).observe(this,{subtree:!0,childList:!0}))}disconnectedCallback(){const t=H.get(this);t&&(t.destroy(),H.delete(this))}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}get fetchOnEmpty(){return this.hasAttribute("fetch-on-empty")}set fetchOnEmpty(t){this.toggleAttribute("fetch-on-empty",t)}async fetchResult(t){var e;(e=R(this,Kt,"f"))===null||e===void 0||e.abort();const{signal:s}=ce(this,Kt,new AbortController,"f"),i=await fetch(t.toString(),{signal:s,headers:{Accept:"text/fragment+html"}});if(!i.ok)throw new Error(await i.text());return le?(await le).createHTML(await i.text(),i):await i.text()}static get observedAttributes(){return["open","value","for"]}attributeChangedCallback(t,e,s){var i,r;if(e===s)return;const o=H.get(this);if(o)switch((this.forElement!==((i=H.get(this))===null||i===void 0?void 0:i.results)||this.inputElement!==((r=H.get(this))===null||r===void 0?void 0:r.input))&&R(this,st,"m",Et).call(this),t){case"open":s===null?o.close():o.open();break;case"value":s!==null&&(o.input.value=s),this.dispatchEvent(new li("auto-complete-change",{bubbles:!0,relatedTarget:o.input}));break}}}yt=new WeakMap,wt=new WeakMap,Kt=new WeakMap,st=new WeakSet,Et=function(){var t;(t=H.get(this))===null||t===void 0||t.destroy();const{forElement:e,inputElement:s}=this;if(!e||!s)return;const i=this.getAttribute("data-autoselect")==="true";H.set(this,new oi(this,s,e,i)),e.setAttribute("role","listbox")};const ue=typeof globalThis<"u"?globalThis:window;try{ue.AutocompleteElement=ue.AutoCompleteElement=ui.define()}catch(n){if(!(ue.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}class Je extends HTMLElement{get preload(){return this.hasAttribute("preload")}set preload(t){t?this.setAttribute("preload",""):this.removeAttribute("preload")}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","menu");const t=this.parentElement;if(!t)return;const e=t.querySelector("summary");e&&(e.setAttribute("aria-haspopup","menu"),e.hasAttribute("role")||e.setAttribute("role","button"));const s=[_(t,"compositionstart",i=>sn(this,i)),_(t,"compositionend",i=>sn(this,i)),_(t,"click",i=>en(t,i)),_(t,"change",i=>en(t,i)),_(t,"keydown",i=>gi(t,this,i)),_(t,"toggle",()=>Qe(t,this),{once:!0}),_(t,"toggle",()=>fi(t)),this.preload?_(t,"mouseover",()=>Qe(t,this),{once:!0}):di,...hi(t)];at.set(this,{subscriptions:s,loaded:!1,isComposing:!1})}disconnectedCallback(){const t=at.get(this);if(t){at.delete(this);for(const e of t.subscriptions)e.unsubscribe()}}}const at=new WeakMap,di={unsubscribe(){}};function _(n,t,e,s=!1){return n.addEventListener(t,e,s),{unsubscribe:()=>{n.removeEventListener(t,e,s)}}}function Qe(n,t){const e=t.getAttribute("src");if(!e)return;const s=at.get(t);if(!s||s.loaded)return;s.loaded=!0;const i=t.querySelector("include-fragment");i&&!i.hasAttribute("src")&&(i.addEventListener("loadend",()=>Jn(n)),i.setAttribute("src",e))}function hi(n){let t=!1;const e=()=>t=!0,s=()=>t=!1,i=()=>{n.hasAttribute("open")&&(Jn(n)||t||mi(n))};return[_(n,"mousedown",e),_(n,"keydown",s),_(n,"toggle",i)]}function fi(n){if(n.hasAttribute("open"))for(const t of document.querySelectorAll("details[open] > details-menu")){const e=t.closest("details");e&&e!==n&&!e.contains(n)&&e.removeAttribute("open")}}function Jn(n){if(!n.hasAttribute("open"))return!1;const t=n.querySelector("details-menu [autofocus]");return t?(t.focus(),!0):!1}function mi(n){const t=document.activeElement;if(t&&Qn(t)&&n.contains(t))return;const e=At(n,!0);e&&e.focus()}function At(n,t){const e=Array.from(n.querySelectorAll('[role^="menuitem"]:not([hidden]):not([disabled])')),s=document.activeElement,i=s instanceof HTMLElement?e.indexOf(s):-1,r=t?e[i+1]:e[i-1],o=t?e[0]:e[e.length-1];return r||o}const tn=navigator.userAgent.match(/Macintosh/);function en(n,t){const e=t.target;if(e instanceof Element&&e.closest("details")===n){if(t.type==="click"){const s=e.closest('[role="menuitem"], [role="menuitemradio"]');if(!s)return;const i=s.querySelector("input");if(s.tagName==="LABEL"&&e===i)return;s.tagName==="LABEL"&&i&&!i.checked||nn(s,n)}else if(t.type==="change"){const s=e.closest('[role="menuitemradio"], [role="menuitemcheckbox"]');s&&nn(s,n)}}}function pi(n,t){for(const e of t.querySelectorAll('[role="menuitemradio"], [role="menuitemcheckbox"]')){const s=e.querySelector('input[type="radio"], input[type="checkbox"]');let i=(e===n).toString();s instanceof HTMLInputElement&&(i=s.indeterminate?"mixed":s.checked.toString()),e.setAttribute("aria-checked",i)}}function nn(n,t){if(n.hasAttribute("disabled")||n.getAttribute("aria-disabled")==="true")return;const e=n.closest("details-menu");!e||!e.dispatchEvent(new CustomEvent("details-menu-select",{cancelable:!0,detail:{relatedTarget:n}}))||(bi(n,t),pi(n,t),n.getAttribute("role")!=="menuitemcheckbox"&&ts(t),e.dispatchEvent(new CustomEvent("details-menu-selected",{detail:{relatedTarget:n}})))}function gi(n,t,e){if(!(e instanceof KeyboardEvent)||n.querySelector("details[open]"))return;const s=at.get(t);if(!s||s.isComposing)return;const i=e.target instanceof Element&&e.target.tagName==="SUMMARY";switch(e.key){case"Escape":n.hasAttribute("open")&&(ts(n),e.preventDefault(),e.stopPropagation());break;case"ArrowDown":{i&&!n.hasAttribute("open")&&n.setAttribute("open","");const r=At(n,!0);r&&r.focus(),e.preventDefault()}break;case"ArrowUp":{i&&!n.hasAttribute("open")&&n.setAttribute("open","");const r=At(n,!1);r&&r.focus(),e.preventDefault()}break;case"n":if(tn&&e.ctrlKey){const r=At(n,!0);r&&r.focus(),e.preventDefault()}break;case"p":if(tn&&e.ctrlKey){const r=At(n,!1);r&&r.focus(),e.preventDefault()}break;case" ":case"Enter":{const r=document.activeElement;r instanceof HTMLElement&&Qn(r)&&r.closest("details")===n&&(e.preventDefault(),e.stopPropagation(),r.click())}break}}function Qn(n){const t=n.getAttribute("role");return t==="menuitem"||t==="menuitemcheckbox"||t==="menuitemradio"}function ts(n){if(!n.hasAttribute("open"))return;n.removeAttribute("open");const e=n.querySelector("summary");e&&e.focus()}function bi(n,t){const e=t.querySelector("[data-menu-button]");if(!e)return;const s=vi(n);if(s)e.textContent=s;else{const i=yi(n);i&&(e.innerHTML=i)}}function vi(n){if(!n)return null;const t=n.hasAttribute("data-menu-button-text")?n:n.querySelector("[data-menu-button-text]");return t?t.getAttribute("data-menu-button-text")||t.textContent:null}function yi(n){if(!n)return null;const t=n.hasAttribute("data-menu-button-contents")?n:n.querySelector("[data-menu-button-contents]");return t?t.innerHTML:null}function sn(n,t){const e=at.get(n);e&&(e.isComposing=t.type==="compositionstart")}window.customElements.get("details-menu")||(window.DetailsMenuElement=Je,window.customElements.define("details-menu",Je));const ct=new WeakMap,Y=new WeakMap,$=new WeakMap;function Lt(n){const t=n.currentTarget;if(!(t instanceof dt))return;const{box:e,image:s}=$.get(t)||{};if(!e||!s)return;let i=0,r=0;if(n instanceof KeyboardEvent)n.key==="ArrowUp"?r=-1:n.key==="ArrowDown"?r=1:n.key==="ArrowLeft"?i=-1:n.key==="ArrowRight"&&(i=1);else if(Y.has(t)&&n instanceof MouseEvent){const o=Y.get(t);i=n.pageX-o.dragStartX,r=n.pageY-o.dragStartY}else if(Y.has(t)&&n instanceof TouchEvent){const{pageX:o,pageY:a}=n.changedTouches[0],{dragStartX:c,dragStartY:l}=Y.get(t);i=o-c,r=a-l}if(i!==0||r!==0){const o=Math.min(Math.max(0,e.offsetLeft+i),s.width-e.offsetWidth),a=Math.min(Math.max(0,e.offsetTop+r),s.height-e.offsetHeight);e.style.left=`${o}px`,e.style.top=`${a}px`,is(t,{x:o,y:a,width:e.offsetWidth,height:e.offsetHeight})}if(n instanceof MouseEvent)Y.set(t,{dragStartX:n.pageX,dragStartY:n.pageY});else if(n instanceof TouchEvent){const{pageX:o,pageY:a}=n.changedTouches[0];Y.set(t,{dragStartX:o,dragStartY:a})}}function lt(n){const t=n.target;if(!(t instanceof HTMLElement))return;const e=es(t);if(!(e instanceof dt))return;const{box:s}=$.get(e)||{};if(!s)return;const i=e.getBoundingClientRect();let r,o,a;if(n instanceof KeyboardEvent){if(n.key==="Escape")return ss(e);if(n.key==="-"&&(a=-10),n.key==="="&&(a=10),!a)return;r=s.offsetWidth+a,o=s.offsetHeight+a,ct.set(e,{startX:s.offsetLeft,startY:s.offsetTop})}else if(n instanceof MouseEvent){const c=ct.get(e);if(!c)return;r=n.pageX-c.startX-i.left-window.pageXOffset,o=n.pageY-c.startY-i.top-window.pageYOffset}else if(n instanceof TouchEvent){const c=ct.get(e);if(!c)return;r=n.changedTouches[0].pageX-c.startX-i.left-window.pageXOffset,o=n.changedTouches[0].pageY-c.startY-i.top-window.pageYOffset}r&&o&&ns(e,r,o,!(n instanceof KeyboardEvent))}function es(n){const t=n.getRootNode();return t instanceof ShadowRoot?t.host:n}function rn(n){const t=n.currentTarget;if(!(t instanceof HTMLElement))return;const e=es(t);if(!(e instanceof dt))return;const{box:s}=$.get(e)||{};if(!s)return;const i=n.target;if(i instanceof HTMLElement)if(i.hasAttribute("data-direction")){const r=i.getAttribute("data-direction")||"";e.addEventListener("mousemove",lt),e.addEventListener("touchmove",lt,{passive:!0}),["nw","se"].indexOf(r)>=0&&e.classList.add("nwse"),["ne","sw"].indexOf(r)>=0&&e.classList.add("nesw"),ct.set(e,{startX:s.offsetLeft+(["se","ne"].indexOf(r)>=0?0:s.offsetWidth),startY:s.offsetTop+(["se","sw"].indexOf(r)>=0?0:s.offsetHeight)}),lt(n)}else e.addEventListener("mousemove",Lt),e.addEventListener("touchmove",Lt,{passive:!0})}function ns(n,t,e,s=!0){let i=Math.max(Math.abs(t),Math.abs(e),10);const r=ct.get(n);if(!r)return;const{box:o,image:a}=$.get(n)||{};if(!o||!a)return;i=Math.min(i,e>0?a.height-r.startY:r.startY,t>0?a.width-r.startX:r.startX);const c=s?Math.round(Math.max(0,t>0?r.startX:r.startX-i)):o.offsetLeft,l=s?Math.round(Math.max(0,e>0?r.startY:r.startY-i)):o.offsetTop;o.style.left=`${c}px`,o.style.top=`${l}px`,o.style.width=`${i}px`,o.style.height=`${i}px`,is(n,{x:c,y:l,width:i,height:i})}function ss(n){const{image:t}=$.get(n)||{};if(!t)return;const e=Math.round(t.clientWidth>t.clientHeight?t.clientHeight:t.clientWidth);ct.set(n,{startX:(t.clientWidth-e)/2,startY:(t.clientHeight-e)/2}),ns(n,e,e)}function de(n){const t=n.currentTarget;t instanceof dt&&(Y.delete(t),t.classList.remove("nwse","nesw"),t.removeEventListener("mousemove",lt),t.removeEventListener("mousemove",Lt),t.removeEventListener("touchmove",lt),t.removeEventListener("touchmove",Lt))}function is(n,t){const{image:e}=$.get(n)||{};if(!e)return;const s=e.naturalWidth/e.width;for(const i in t){const r=Math.round(t[i]*s);t[i]=r;const o=n.querySelector(`[data-image-crop-input='${i}']`);o instanceof HTMLInputElement&&(o.value=r.toString())}n.dispatchEvent(new CustomEvent("image-crop-change",{bubbles:!0,detail:t}))}class dt extends HTMLElement{connectedCallback(){if($.has(this))return;const t=this.attachShadow({mode:"open"});t.innerHTML=`
1
+ function zs(n,t=0,{start:e=!0,middle:s=!0,once:i=!1}={}){let r=e,o=0,a,c=!1;function l(...u){if(c)return;const d=Date.now()-o;o=Date.now(),e&&s&&d>=t&&(r=!0),r?(r=!1,n.apply(this,u),i&&l.cancel()):(s&&d<t||!s)&&(clearTimeout(a),a=setTimeout(()=>{o=Date.now(),n.apply(this,u),i&&l.cancel()},s?t-d:t))}return l.cancel=()=>{clearTimeout(a),c=!0},l}function Ys(n,t=0,{start:e=!1,middle:s=!1,once:i=!1}={}){return zs(n,t,{start:e,middle:s,once:i})}var ae=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},Xs=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},nt;const kt=new WeakMap;class se extends Event{constructor(t){super(`auto-check-${t}`,{bubbles:!0}),this.phase=t}get detail(){return this}}class ts extends se{constructor(t,e=""){super(t),this.phase=t,this.message=e,this.setValidity=s=>{this.message=s}}}class Ze extends se{constructor(){super("complete")}}class Gs extends se{constructor(t){super("success"),this.response=t}}class Zs extends ts{constructor(){super("start","Verifying…")}}class Js extends ts{constructor(t){super("error","Validation failed"),this.response=t}}class Qs extends se{constructor(t){super("send"),this.body=t}}class es extends HTMLElement{constructor(){super(...arguments),nt.set(this,null)}static define(t="auto-check",e=customElements){return e.define(t,this),this}get onloadend(){return ae(this,nt,"f")}set onloadend(t){ae(this,nt,"f")&&this.removeEventListener("loadend",ae(this,nt,"f")),Xs(this,nt,typeof t=="object"||typeof t=="function"?t:null,"f"),typeof t=="function"&&this.addEventListener("loadend",t)}connectedCallback(){const t=this.input;if(!t)return;const e=Ys(ni.bind(null,this),300),s={check:e,controller:null};kt.set(this,s),t.addEventListener("input",Je),t.addEventListener("input",e),t.autocomplete="off",t.spellcheck=!1}disconnectedCallback(){const t=this.input;if(!t)return;const e=kt.get(this);e&&(kt.delete(this),t.removeEventListener("input",Je),t.removeEventListener("input",e.check),t.setCustomValidity(""))}attributeChangedCallback(t){if(t==="required"){const e=this.input;if(!e)return;e.required=this.required}}static get observedAttributes(){return["required"]}get input(){return this.querySelector("input")}get src(){const t=this.getAttribute("src");if(!t)return"";const e=this.ownerDocument.createElement("a");return e.href=t,e.href}set src(t){this.setAttribute("src",t)}get csrf(){const t=this.querySelector("[data-csrf]");return this.getAttribute("csrf")||t instanceof HTMLInputElement&&t.value||""}set csrf(t){this.setAttribute("csrf",t)}get required(){return this.hasAttribute("required")}set required(t){t?this.setAttribute("required",""):this.removeAttribute("required")}get csrfField(){return this.getAttribute("csrf-field")||"authenticity_token"}set csrfField(t){this.setAttribute("csrf-field",t)}}nt=new WeakMap;function Je(n){const t=n.currentTarget;if(!(t instanceof HTMLInputElement))return;const e=t.closest("auto-check");if(!(e instanceof es))return;const s=e.src,i=e.csrf,r=kt.get(e);if(!s||!i||!r)return;const o=new Zs;t.dispatchEvent(o),e.required&&t.setCustomValidity(o.message)}function ti(){return"AbortController"in window?new AbortController:{signal:null,abort(){}}}async function ei(n,t,e){try{const s=await fetch(t,e);return n.dispatchEvent(new Event("load")),n.dispatchEvent(new Event("loadend")),s}catch(s){throw s.name!=="AbortError"&&(n.dispatchEvent(new Event("error")),n.dispatchEvent(new Event("loadend"))),s}}async function ni(n){const t=n.input;if(!t)return;const e=n.csrfField,s=n.src,i=n.csrf,r=kt.get(n);if(!s||!i||!r){n.required&&t.setCustomValidity("");return}if(!t.value.trim()){n.required&&t.setCustomValidity("");return}const o=new FormData;o.append(e,i),o.append("value",t.value),t.dispatchEvent(new Qs(o)),r.controller?r.controller.abort():n.dispatchEvent(new Event("loadstart")),r.controller=ti();try{const a=await ei(n,s,{credentials:"same-origin",signal:r.controller.signal,method:"POST",body:o});if(a.ok)n.required&&t.setCustomValidity(""),t.dispatchEvent(new Gs(a.clone()));else{const c=new Js(a.clone());t.dispatchEvent(c),n.required&&t.setCustomValidity(c.message)}r.controller=null,t.dispatchEvent(new Ze)}catch(a){a.name!=="AbortError"&&(r.controller=null,t.dispatchEvent(new Ze))}}const Qe=typeof globalThis<"u"?globalThis:window;try{Qe.AutoCheckElement=es.define()}catch(n){if(!(Qe.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}class si{constructor(t,e,{tabInsertsSuggestions:s,defaultFirstOption:i}={}){this.input=t,this.list=e,this.tabInsertsSuggestions=s??!0,this.defaultFirstOption=i??!1,this.isComposing=!1,e.id||(e.id=`combobox-${Math.random().toString().slice(2,6)}`),this.ctrlBindings=!!navigator.userAgent.match(/Macintosh/),this.keyboardEventHandler=r=>ii(r,this),this.compositionEventHandler=r=>oi(r,this),this.inputHandler=this.clearSelection.bind(this),t.setAttribute("role","combobox"),t.setAttribute("aria-controls",e.id),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox")}destroy(){this.clearSelection(),this.stop(),this.input.removeAttribute("role"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-haspopup")}start(){this.input.setAttribute("aria-expanded","true"),this.input.addEventListener("compositionstart",this.compositionEventHandler),this.input.addEventListener("compositionend",this.compositionEventHandler),this.input.addEventListener("input",this.inputHandler),this.input.addEventListener("keydown",this.keyboardEventHandler),this.list.addEventListener("click",tn),this.indicateDefaultOption()}stop(){this.clearSelection(),this.input.setAttribute("aria-expanded","false"),this.input.removeEventListener("compositionstart",this.compositionEventHandler),this.input.removeEventListener("compositionend",this.compositionEventHandler),this.input.removeEventListener("input",this.inputHandler),this.input.removeEventListener("keydown",this.keyboardEventHandler),this.list.removeEventListener("click",tn)}indicateDefaultOption(){var t;this.defaultFirstOption&&((t=Array.from(this.list.querySelectorAll('[role="option"]:not([aria-disabled="true"])')).filter(ce)[0])===null||t===void 0||t.setAttribute("data-combobox-option-default","true"))}navigate(t=1){const e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(ce)[0],s=Array.from(this.list.querySelectorAll('[role="option"]')).filter(ce),i=s.indexOf(e);if(i===s.length-1&&t===1||i===0&&t===-1){this.clearSelection(),this.input.focus();return}let r=t===1?0:s.length-1;if(e&&i>=0){const a=i+t;a>=0&&a<s.length&&(r=a)}const o=s[r];if(o)for(const a of s)a.removeAttribute("data-combobox-option-default"),o===a?(this.input.setAttribute("aria-activedescendant",o.id),o.setAttribute("aria-selected","true"),ai(this.list,o)):a.removeAttribute("aria-selected")}clearSelection(){this.input.removeAttribute("aria-activedescendant");for(const t of this.list.querySelectorAll('[aria-selected="true"]'))t.removeAttribute("aria-selected");this.indicateDefaultOption()}}function ii(n,t){if(!(n.shiftKey||n.metaKey||n.altKey)&&!(!t.ctrlBindings&&n.ctrlKey)&&!t.isComposing)switch(n.key){case"Enter":en(t.input,t.list)&&n.preventDefault();break;case"Tab":t.tabInsertsSuggestions&&en(t.input,t.list)&&n.preventDefault();break;case"Escape":t.clearSelection();break;case"ArrowDown":t.navigate(1),n.preventDefault();break;case"ArrowUp":t.navigate(-1),n.preventDefault();break;case"n":t.ctrlBindings&&n.ctrlKey&&(t.navigate(1),n.preventDefault());break;case"p":t.ctrlBindings&&n.ctrlKey&&(t.navigate(-1),n.preventDefault());break;default:if(n.ctrlKey)break;t.clearSelection()}}function tn(n){if(!(n.target instanceof Element))return;const t=n.target.closest('[role="option"]');t&&t.getAttribute("aria-disabled")!=="true"&&ri(t,{event:n})}function en(n,t){const e=t.querySelector('[aria-selected="true"], [data-combobox-option-default="true"]');return e?(e.getAttribute("aria-disabled")==="true"||e.click(),!0):!1}function ri(n,t){n.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0,detail:t}))}function ce(n){return!n.hidden&&!(n instanceof HTMLInputElement&&n.type==="hidden")&&(n.offsetWidth>0||n.offsetHeight>0)}function oi(n,t){t.isComposing=n.type==="compositionstart",document.getElementById(t.input.getAttribute("aria-controls")||"")&&t.clearSelection()}function ai(n,t){ci(n,t)||(n.scrollTop=t.offsetTop)}function ci(n,t){const e=n.scrollTop,s=e+n.clientHeight,i=t.offsetTop,r=i+t.clientHeight;return i>=e&&r<=s}function li(n,t=0){let e;return function(...s){clearTimeout(e),e=window.setTimeout(()=>{clearTimeout(e),n(...s)},t)}}const ui=window.testScreenReaderDelay||100;class di{constructor(t,e,s,i=!1){var r;if(this.container=t,this.input=e,this.results=s,this.combobox=new si(e,s,{defaultFirstOption:i}),this.feedback=t.getRootNode().getElementById(`${this.results.id}-feedback`),this.autoselectEnabled=i,this.clearButton=t.getRootNode().getElementById(`${this.input.id||this.input.name}-clear`),this.clientOptions=s.querySelectorAll("[role=option]"),this.feedback&&(this.feedback.setAttribute("aria-live","polite"),this.feedback.setAttribute("aria-atomic","true")),this.clearButton&&!this.clearButton.getAttribute("aria-label")){const o=document.querySelector(`label[for="${this.input.name}"]`);this.clearButton.setAttribute("aria-label","clear:"),this.clearButton.setAttribute("aria-labelledby",`${this.clearButton.id} ${(o==null?void 0:o.id)||""}`)}this.input.getAttribute("aria-expanded")||this.input.setAttribute("aria-expanded","false"),this.results.popover?this.results.matches(":popover-open")&&this.results.hidePopover():this.results.hidden=!0,this.results.getAttribute("aria-label")||this.results.setAttribute("aria-label","results"),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("spellcheck","false"),this.interactingWithList=!1,this.onInputChange=li(this.onInputChange.bind(this),300),this.onResultsMouseDown=this.onResultsMouseDown.bind(this),this.onInputBlur=this.onInputBlur.bind(this),this.onInputFocus=this.onInputFocus.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onCommit=this.onCommit.bind(this),this.handleClear=this.handleClear.bind(this),this.input.addEventListener("keydown",this.onKeydown),this.input.addEventListener("focus",this.onInputFocus),this.input.addEventListener("blur",this.onInputBlur),this.input.addEventListener("input",this.onInputChange),this.results.addEventListener("mousedown",this.onResultsMouseDown),this.results.addEventListener("combobox-commit",this.onCommit),(r=this.clearButton)===null||r===void 0||r.addEventListener("click",this.handleClear)}destroy(){this.input.removeEventListener("keydown",this.onKeydown),this.input.removeEventListener("focus",this.onInputFocus),this.input.removeEventListener("blur",this.onInputBlur),this.input.removeEventListener("input",this.onInputChange),this.results.removeEventListener("mousedown",this.onResultsMouseDown),this.results.removeEventListener("combobox-commit",this.onCommit)}handleClear(t){t.preventDefault(),this.input.getAttribute("aria-expanded")==="true"&&(this.input.setAttribute("aria-expanded","false"),this.updateFeedbackForScreenReaders("Results hidden.")),this.input.value="",this.container.value="",this.input.focus(),this.input.dispatchEvent(new Event("change")),this.close()}onKeydown(t){if(t.key==="Escape"&&this.container.open)this.close(),t.stopPropagation(),t.preventDefault();else if(t.altKey&&t.key==="ArrowUp"&&this.container.open)this.close(),t.stopPropagation(),t.preventDefault();else if(t.altKey&&t.key==="ArrowDown"&&!this.container.open){if(!this.input.value.trim())return;this.open(),t.stopPropagation(),t.preventDefault()}}onInputFocus(){this.interactingWithList||this.fetchResults()}onInputBlur(){this.interactingWithList||this.close()}onCommit({target:t}){const e=t;if(!(e instanceof HTMLElement)||(this.close(),e instanceof HTMLAnchorElement))return;const s=e.getAttribute("data-autocomplete-value")||e.textContent;this.updateFeedbackForScreenReaders(`${e.textContent||""} selected.`),this.container.value=s,s||this.updateFeedbackForScreenReaders("Results hidden.")}onResultsMouseDown(){this.interactingWithList=!0}onInputChange(){this.feedback&&this.feedback.textContent&&(this.feedback.textContent=""),this.container.removeAttribute("value"),this.fetchResults()}identifyOptions(){let t=0;for(const e of this.results.querySelectorAll('[role="option"]:not([id])'))e.id=`${this.results.id}-option-${t++}`}updateFeedbackForScreenReaders(t){setTimeout(()=>{this.feedback&&(this.feedback.textContent=t)},ui)}fetchResults(){const t=this.input.value.trim();if(!t&&!this.container.fetchOnEmpty){this.close();return}const e=this.container.src;if(!e)return;const s=new URL(e,window.location.href),i=new URLSearchParams(s.search.slice(1));i.append("q",t),s.search=i.toString(),this.container.dispatchEvent(new CustomEvent("loadstart")),this.container.fetchResult(s).then(r=>{this.results.innerHTML=r,this.identifyOptions(),this.combobox.indicateDefaultOption();const o=this.results.querySelectorAll('[role="option"]'),a=!!o.length,c=o.length,[l]=o,u=l==null?void 0:l.textContent;this.autoselectEnabled&&u?this.updateFeedbackForScreenReaders(`${c} results. ${u} is the top result: Press Enter to activate.`):this.updateFeedbackForScreenReaders(`${c||"No"} results.`),a?this.open():this.close(),this.container.dispatchEvent(new CustomEvent("load")),this.container.dispatchEvent(new CustomEvent("loadend"))}).catch(()=>{this.container.dispatchEvent(new CustomEvent("error")),this.container.dispatchEvent(new CustomEvent("loadend"))})}open(){(this.results.popover?!this.results.matches(":popover-open"):this.results.hidden)&&(this.combobox.start(),this.results.popover?this.results.showPopover():this.results.hidden=!1),this.container.open=!0,this.interactingWithList=!0}close(){(this.results.popover?this.results.matches(":popover-open"):!this.results.hidden)&&(this.combobox.stop(),this.results.popover?this.results.hidePopover():this.results.hidden=!0),this.container.open=!1,this.interactingWithList=!1}}var P=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},le=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},hi=function(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e},st,yt,wt,Et,Kt;const fi=globalThis.HTMLElement||null;class mi extends Event{constructor(t,e){var{relatedTarget:s}=e,i=hi(e,["relatedTarget"]);super(t,i),this.relatedTarget=s}}const V=new WeakMap;let ue=null;class pi extends fi{constructor(){super(...arguments),st.add(this),yt.set(this,null),wt.set(this,null),Kt.set(this,void 0)}static define(t="auto-complete",e=customElements){return e.define(t,this),this}static setCSPTrustedTypesPolicy(t){ue=t===null?t:Promise.resolve(t)}get forElement(){var t;if(!((t=P(this,yt,"f"))===null||t===void 0)&&t.isConnected)return P(this,yt,"f");const e=this.getAttribute("for"),s=this.getRootNode();return e&&(s instanceof Document||s instanceof ShadowRoot)?s.getElementById(e):null}set forElement(t){le(this,yt,t,"f"),this.setAttribute("for","")}get inputElement(){var t;return!((t=P(this,wt,"f"))===null||t===void 0)&&t.isConnected?P(this,wt,"f"):this.querySelector("input")}set inputElement(t){le(this,wt,t,"f"),P(this,st,"m",Et).call(this)}connectedCallback(){this.isConnected&&(P(this,st,"m",Et).call(this),new MutationObserver(()=>{V.get(this)||P(this,st,"m",Et).call(this)}).observe(this,{subtree:!0,childList:!0}))}disconnectedCallback(){const t=V.get(this);t&&(t.destroy(),V.delete(this))}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}get fetchOnEmpty(){return this.hasAttribute("fetch-on-empty")}set fetchOnEmpty(t){this.toggleAttribute("fetch-on-empty",t)}async fetchResult(t){var e;(e=P(this,Kt,"f"))===null||e===void 0||e.abort();const{signal:s}=le(this,Kt,new AbortController,"f"),i=await fetch(t.toString(),{signal:s,headers:{Accept:"text/fragment+html"}});if(!i.ok)throw new Error(await i.text());return ue?(await ue).createHTML(await i.text(),i):await i.text()}static get observedAttributes(){return["open","value","for"]}attributeChangedCallback(t,e,s){var i,r;if(e===s)return;const o=V.get(this);if(o)switch((this.forElement!==((i=V.get(this))===null||i===void 0?void 0:i.results)||this.inputElement!==((r=V.get(this))===null||r===void 0?void 0:r.input))&&P(this,st,"m",Et).call(this),t){case"open":s===null?o.close():o.open();break;case"value":s!==null&&(o.input.value=s),this.dispatchEvent(new mi("auto-complete-change",{bubbles:!0,relatedTarget:o.input}));break}}}yt=new WeakMap,wt=new WeakMap,Kt=new WeakMap,st=new WeakSet,Et=function(){var t;(t=V.get(this))===null||t===void 0||t.destroy();const{forElement:e,inputElement:s}=this;if(!e||!s)return;const i=this.getAttribute("data-autoselect")==="true";V.set(this,new di(this,s,e,i)),e.setAttribute("role","listbox")};const de=typeof globalThis<"u"?globalThis:window;try{de.AutocompleteElement=de.AutoCompleteElement=pi.define()}catch(n){if(!(de.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}class nn extends HTMLElement{get preload(){return this.hasAttribute("preload")}set preload(t){t?this.setAttribute("preload",""):this.removeAttribute("preload")}get src(){return this.getAttribute("src")||""}set src(t){this.setAttribute("src",t)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","menu");const t=this.parentElement;if(!t)return;const e=t.querySelector("summary");e&&(e.setAttribute("aria-haspopup","menu"),e.hasAttribute("role")||e.setAttribute("role","button"));const s=[_(t,"compositionstart",i=>cn(this,i)),_(t,"compositionend",i=>cn(this,i)),_(t,"click",i=>on(t,i)),_(t,"change",i=>on(t,i)),_(t,"keydown",i=>Ei(t,this,i)),_(t,"toggle",()=>sn(t,this),{once:!0}),_(t,"toggle",()=>vi(t)),this.preload?_(t,"mouseover",()=>sn(t,this),{once:!0}):gi,...bi(t)];at.set(this,{subscriptions:s,loaded:!1,isComposing:!1})}disconnectedCallback(){const t=at.get(this);if(t){at.delete(this);for(const e of t.subscriptions)e.unsubscribe()}}}const at=new WeakMap,gi={unsubscribe(){}};function _(n,t,e,s=!1){return n.addEventListener(t,e,s),{unsubscribe:()=>{n.removeEventListener(t,e,s)}}}function sn(n,t){const e=t.getAttribute("src");if(!e)return;const s=at.get(t);if(!s||s.loaded)return;s.loaded=!0;const i=t.querySelector("include-fragment");i&&!i.hasAttribute("src")&&(i.addEventListener("loadend",()=>ns(n)),i.setAttribute("src",e))}function bi(n){let t=!1;const e=()=>t=!0,s=()=>t=!1,i=()=>{n.hasAttribute("open")&&(ns(n)||t||yi(n))};return[_(n,"mousedown",e),_(n,"keydown",s),_(n,"toggle",i)]}function vi(n){if(n.hasAttribute("open"))for(const t of document.querySelectorAll("details[open] > details-menu")){const e=t.closest("details");e&&e!==n&&!e.contains(n)&&e.removeAttribute("open")}}function ns(n){if(!n.hasAttribute("open"))return!1;const t=n.querySelector("details-menu [autofocus]");return t?(t.focus(),!0):!1}function yi(n){const t=document.activeElement;if(t&&ss(t)&&n.contains(t))return;const e=At(n,!0);e&&e.focus()}function At(n,t){const e=Array.from(n.querySelectorAll('[role^="menuitem"]:not([hidden]):not([disabled])')),s=document.activeElement,i=s instanceof HTMLElement?e.indexOf(s):-1,r=t?e[i+1]:e[i-1],o=t?e[0]:e[e.length-1];return r||o}const rn=navigator.userAgent.match(/Macintosh/);function on(n,t){const e=t.target;if(e instanceof Element&&e.closest("details")===n){if(t.type==="click"){const s=e.closest('[role="menuitem"], [role="menuitemradio"]');if(!s)return;const i=s.querySelector("input");if(s.tagName==="LABEL"&&e===i)return;s.tagName==="LABEL"&&i&&!i.checked||an(s,n)}else if(t.type==="change"){const s=e.closest('[role="menuitemradio"], [role="menuitemcheckbox"]');s&&an(s,n)}}}function wi(n,t){for(const e of t.querySelectorAll('[role="menuitemradio"], [role="menuitemcheckbox"]')){const s=e.querySelector('input[type="radio"], input[type="checkbox"]');let i=(e===n).toString();s instanceof HTMLInputElement&&(i=s.indeterminate?"mixed":s.checked.toString()),e.setAttribute("aria-checked",i)}}function an(n,t){if(n.hasAttribute("disabled")||n.getAttribute("aria-disabled")==="true")return;const e=n.closest("details-menu");!e||!e.dispatchEvent(new CustomEvent("details-menu-select",{cancelable:!0,detail:{relatedTarget:n}}))||(Ai(n,t),wi(n,t),n.getAttribute("role")!=="menuitemcheckbox"&&is(t),e.dispatchEvent(new CustomEvent("details-menu-selected",{detail:{relatedTarget:n}})))}function Ei(n,t,e){if(!(e instanceof KeyboardEvent)||n.querySelector("details[open]"))return;const s=at.get(t);if(!s||s.isComposing)return;const i=e.target instanceof Element&&e.target.tagName==="SUMMARY";switch(e.key){case"Escape":n.hasAttribute("open")&&(is(n),e.preventDefault(),e.stopPropagation());break;case"ArrowDown":{i&&!n.hasAttribute("open")&&n.setAttribute("open","");const r=At(n,!0);r&&r.focus(),e.preventDefault()}break;case"ArrowUp":{i&&!n.hasAttribute("open")&&n.setAttribute("open","");const r=At(n,!1);r&&r.focus(),e.preventDefault()}break;case"n":if(rn&&e.ctrlKey){const r=At(n,!0);r&&r.focus(),e.preventDefault()}break;case"p":if(rn&&e.ctrlKey){const r=At(n,!1);r&&r.focus(),e.preventDefault()}break;case" ":case"Enter":{const r=document.activeElement;r instanceof HTMLElement&&ss(r)&&r.closest("details")===n&&(e.preventDefault(),e.stopPropagation(),r.click())}break}}function ss(n){const t=n.getAttribute("role");return t==="menuitem"||t==="menuitemcheckbox"||t==="menuitemradio"}function is(n){if(!n.hasAttribute("open"))return;n.removeAttribute("open");const e=n.querySelector("summary");e&&e.focus()}function Ai(n,t){const e=t.querySelector("[data-menu-button]");if(!e)return;const s=xi(n);if(s)e.textContent=s;else{const i=Ti(n);i&&(e.innerHTML=i)}}function xi(n){if(!n)return null;const t=n.hasAttribute("data-menu-button-text")?n:n.querySelector("[data-menu-button-text]");return t?t.getAttribute("data-menu-button-text")||t.textContent:null}function Ti(n){if(!n)return null;const t=n.hasAttribute("data-menu-button-contents")?n:n.querySelector("[data-menu-button-contents]");return t?t.innerHTML:null}function cn(n,t){const e=at.get(n);e&&(e.isComposing=t.type==="compositionstart")}window.customElements.get("details-menu")||(window.DetailsMenuElement=nn,window.customElements.define("details-menu",nn));const ct=new WeakMap,Y=new WeakMap,R=new WeakMap;function Lt(n){const t=n.currentTarget;if(!(t instanceof dt))return;const{box:e,image:s}=R.get(t)||{};if(!e||!s)return;let i=0,r=0;if(n instanceof KeyboardEvent)n.key==="ArrowUp"?r=-1:n.key==="ArrowDown"?r=1:n.key==="ArrowLeft"?i=-1:n.key==="ArrowRight"&&(i=1);else if(Y.has(t)&&n instanceof MouseEvent){const o=Y.get(t);i=n.pageX-o.dragStartX,r=n.pageY-o.dragStartY}else if(Y.has(t)&&n instanceof TouchEvent){const{pageX:o,pageY:a}=n.changedTouches[0],{dragStartX:c,dragStartY:l}=Y.get(t);i=o-c,r=a-l}if(i!==0||r!==0){const o=Math.min(Math.max(0,e.offsetLeft+i),s.width-e.offsetWidth),a=Math.min(Math.max(0,e.offsetTop+r),s.height-e.offsetHeight);e.style.left=`${o}px`,e.style.top=`${a}px`,cs(t,{x:o,y:a,width:e.offsetWidth,height:e.offsetHeight})}if(n instanceof MouseEvent)Y.set(t,{dragStartX:n.pageX,dragStartY:n.pageY});else if(n instanceof TouchEvent){const{pageX:o,pageY:a}=n.changedTouches[0];Y.set(t,{dragStartX:o,dragStartY:a})}}function lt(n){const t=n.target;if(!(t instanceof HTMLElement))return;const e=rs(t);if(!(e instanceof dt))return;const{box:s}=R.get(e)||{};if(!s)return;const i=e.getBoundingClientRect();let r,o,a;if(n instanceof KeyboardEvent){if(n.key==="Escape")return as(e);if(n.key==="-"&&(a=-10),n.key==="="&&(a=10),!a)return;r=s.offsetWidth+a,o=s.offsetHeight+a,ct.set(e,{startX:s.offsetLeft,startY:s.offsetTop})}else if(n instanceof MouseEvent){const c=ct.get(e);if(!c)return;r=n.pageX-c.startX-i.left-window.pageXOffset,o=n.pageY-c.startY-i.top-window.pageYOffset}else if(n instanceof TouchEvent){const c=ct.get(e);if(!c)return;r=n.changedTouches[0].pageX-c.startX-i.left-window.pageXOffset,o=n.changedTouches[0].pageY-c.startY-i.top-window.pageYOffset}r&&o&&os(e,r,o,!(n instanceof KeyboardEvent))}function rs(n){const t=n.getRootNode();return t instanceof ShadowRoot?t.host:n}function ln(n){const t=n.currentTarget;if(!(t instanceof HTMLElement))return;const e=rs(t);if(!(e instanceof dt))return;const{box:s}=R.get(e)||{};if(!s)return;const i=n.target;if(i instanceof HTMLElement)if(i.hasAttribute("data-direction")){const r=i.getAttribute("data-direction")||"";e.addEventListener("mousemove",lt),e.addEventListener("touchmove",lt,{passive:!0}),["nw","se"].indexOf(r)>=0&&e.classList.add("nwse"),["ne","sw"].indexOf(r)>=0&&e.classList.add("nesw"),ct.set(e,{startX:s.offsetLeft+(["se","ne"].indexOf(r)>=0?0:s.offsetWidth),startY:s.offsetTop+(["se","sw"].indexOf(r)>=0?0:s.offsetHeight)}),lt(n)}else e.addEventListener("mousemove",Lt),e.addEventListener("touchmove",Lt,{passive:!0})}function os(n,t,e,s=!0){let i=Math.max(Math.abs(t),Math.abs(e),10);const r=ct.get(n);if(!r)return;const{box:o,image:a}=R.get(n)||{};if(!o||!a)return;i=Math.min(i,e>0?a.height-r.startY:r.startY,t>0?a.width-r.startX:r.startX);const c=s?Math.round(Math.max(0,t>0?r.startX:r.startX-i)):o.offsetLeft,l=s?Math.round(Math.max(0,e>0?r.startY:r.startY-i)):o.offsetTop;o.style.left=`${c}px`,o.style.top=`${l}px`,o.style.width=`${i}px`,o.style.height=`${i}px`,cs(n,{x:c,y:l,width:i,height:i})}function as(n){const{image:t}=R.get(n)||{};if(!t)return;const e=Math.round(t.clientWidth>t.clientHeight?t.clientHeight:t.clientWidth);ct.set(n,{startX:(t.clientWidth-e)/2,startY:(t.clientHeight-e)/2}),os(n,e,e)}function he(n){const t=n.currentTarget;t instanceof dt&&(Y.delete(t),t.classList.remove("nwse","nesw"),t.removeEventListener("mousemove",lt),t.removeEventListener("mousemove",Lt),t.removeEventListener("touchmove",lt),t.removeEventListener("touchmove",Lt))}function cs(n,t){const{image:e}=R.get(n)||{};if(!e)return;const s=e.naturalWidth/e.width;for(const i in t){const r=Math.round(t[i]*s);t[i]=r;const o=n.querySelector(`[data-image-crop-input='${i}']`);o instanceof HTMLInputElement&&(o.value=r.toString())}n.dispatchEvent(new CustomEvent("image-crop-change",{bubbles:!0,detail:t}))}class dt extends HTMLElement{connectedCallback(){if(R.has(this))return;const t=this.attachShadow({mode:"open"});t.innerHTML=`
2
2
  <style>
3
3
  :host { touch-action: none; display: block; }
4
4
  :host(.nesw) { cursor: nesw-resize; }
@@ -76,24 +76,24 @@ function Vs(n,t=0,{start:e=!0,middle:s=!0,once:i=!1}={}){let r=e,o=0,a,c=!1;func
76
76
  </div>
77
77
  </div>
78
78
  </div>
79
- `;const e=t.querySelector("[data-crop-box]");if(!(e instanceof HTMLElement))return;const s=t.querySelector("img");s instanceof HTMLImageElement&&($.set(this,{box:e,image:s}),s.addEventListener("load",()=>{this.loaded=!0,ss(this)}),this.addEventListener("mouseleave",de),this.addEventListener("touchend",de),this.addEventListener("mouseup",de),e.addEventListener("mousedown",rn),e.addEventListener("touchstart",rn,{passive:!0}),this.addEventListener("keydown",Lt),this.addEventListener("keydown",lt),this.src&&(s.src=this.src))}static get observedAttributes(){return["src"]}get src(){return this.getAttribute("src")}set src(t){t?this.setAttribute("src",t):this.removeAttribute("src")}get loaded(){return this.hasAttribute("loaded")}set loaded(t){t?this.setAttribute("loaded",""):this.removeAttribute("loaded")}attributeChangedCallback(t,e,s){const{image:i}=$.get(this)||{};t==="src"&&(this.loaded=!1,i&&(i.src=s))}}window.customElements.get("image-crop")||(window.ImageCropElement=dt,window.customElements.define("image-crop",dt));var T=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},he=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},O,it,Mt,rt,fe,be,jt,on;const ve=new WeakMap;function wi(n){return n&&!!n.split(",").find(t=>t.match(/^\s*\*\/\*/))}let ye=null;class Le extends HTMLElement{constructor(){super(...arguments),O.add(this),it.set(this,!1),Mt.set(this,new IntersectionObserver(t=>{for(const e of t)if(e.isIntersecting){const{target:s}=e;if(T(this,Mt,"f").unobserve(s),!(s instanceof Le))return;s.loading==="lazy"&&T(this,O,"m",rt).call(this)}},{rootMargin:"0px 0px 256px 0px",threshold:.01}))}static define(t="include-fragment",e=customElements){return e.define(t,this),this}static setCSPTrustedTypesPolicy(t){ye=t===null?t:Promise.resolve(t)}static get observedAttributes(){return["src","loading"]}get src(){const t=this.getAttribute("src");if(t){const e=this.ownerDocument.createElement("a");return e.href=t,e.href}else return""}set src(t){this.setAttribute("src",t)}get loading(){return this.getAttribute("loading")==="lazy"?"lazy":"eager"}set loading(t){this.setAttribute("loading",t)}get accept(){return this.getAttribute("accept")||""}set accept(t){this.setAttribute("accept",t)}get data(){return T(this,O,"m",be).call(this)}attributeChangedCallback(t,e){t==="src"?this.isConnected&&this.loading==="eager"&&T(this,O,"m",rt).call(this):t==="loading"&&this.isConnected&&e!=="eager"&&this.loading==="eager"&&T(this,O,"m",rt).call(this)}connectedCallback(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=":host {display: block;}",this.shadowRoot.append(t,document.createElement("slot"))}this.src&&this.loading==="eager"&&T(this,O,"m",rt).call(this),this.loading==="lazy"&&T(this,Mt,"f").observe(this)}request(){const t=this.src;if(!t)throw new Error("missing src");return new Request(t,{method:"GET",credentials:"same-origin",headers:{Accept:this.accept||"text/html"}})}load(){return T(this,O,"m",be).call(this)}fetch(t){return fetch(t)}refetch(){ve.delete(this),T(this,O,"m",rt).call(this)}}it=new WeakMap,Mt=new WeakMap,O=new WeakSet,rt=async function(){if(!T(this,it,"f")){he(this,it,!0,"f"),T(this,Mt,"f").unobserve(this);try{const t=await T(this,O,"m",fe).call(this);if(t instanceof Error)throw t;const e=t,s=document.createElement("template");s.innerHTML=e;const i=document.importNode(s.content,!0);if(!this.dispatchEvent(new CustomEvent("include-fragment-replace",{cancelable:!0,detail:{fragment:i}}))){he(this,it,!1,"f");return}this.replaceWith(i),this.dispatchEvent(new CustomEvent("include-fragment-replaced"))}catch{this.classList.add("is-error")}finally{he(this,it,!1,"f")}}},fe=async function(){const t=this.src,e=ve.get(this);if(e&&e.src===t)return e.data;{let s;return t?s=T(this,O,"m",on).call(this):s=Promise.reject(new Error("missing src")),ve.set(this,{src:t,data:s}),s}},be=async function(){const t=await T(this,O,"m",fe).call(this);if(t instanceof Error)throw t;return t.toString()},jt=async function(t){await new Promise(e=>setTimeout(e,0));for(const e of t)this.dispatchEvent(new Event(e))},on=async function(){try{await T(this,O,"m",jt).call(this,["loadstart"]);const t=await this.fetch(this.request());if(t.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${t.status}`);const e=t.headers.get("Content-Type");if(!wi(this.accept)&&(!e||!e.includes(this.accept?this.accept:"text/html")))throw new Error(`Failed to load resource: expected ${this.accept||"text/html"} but was ${e}`);const s=await t.text();let i=s;return ye&&(i=(await ye).createHTML(s,t)),T(this,O,"m",jt).call(this,["load","loadend"]),i}catch(t){throw T(this,O,"m",jt).call(this,["error","loadend"]),t}};const an=typeof globalThis<"u"?globalThis:window;try{an.IncludeFragmentElement=Le.define()}catch(n){if(!(an.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}var cn=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},Ut,we;const Ei=["[data-md-button]","md-header","md-bold","md-italic","md-quote","md-code","md-link","md-image","md-unordered-list","md-ordered-list","md-task-list","md-mention","md-ref","md-strikethrough"];function rs(n){const t=[];for(const e of n.querySelectorAll(Ei.join(", ")))e.hidden||e.offsetWidth<=0&&e.offsetHeight<=0||e.closest("markdown-toolbar")===n&&t.push(e);return t}function os(n){return function(t){(t.key===" "||t.key==="Enter")&&n(t)}}const k=new WeakMap,Ai={"header-1":{prefix:"# "},"header-2":{prefix:"## "},"header-3":{prefix:"### "},"header-4":{prefix:"#### "},"header-5":{prefix:"##### "},"header-6":{prefix:"###### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},image:{prefix:"![",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},"unordered-list":{prefix:"- ",multiline:!0,unorderedList:!0},"ordered-list":{prefix:"1. ",multiline:!0,orderedList:!0},"task-list":{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},mention:{prefix:"@",prefixSpace:!0},ref:{prefix:"#",prefixSpace:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0}};class L extends HTMLElement{constructor(){super();const t=e=>{const s=k.get(this);s&&(e.preventDefault(),Ae(this,s))};this.addEventListener("keydown",os(t)),this.addEventListener("click",t)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","button")}click(){const t=k.get(this);t&&Ae(this,t)}}class ln extends L{constructor(){super(...arguments),Ut.add(this)}connectedCallback(){const t=parseInt(this.getAttribute("level")||"3",10);cn(this,Ut,"m",we).call(this,t)}static get observedAttributes(){return["level"]}attributeChangedCallback(t,e,s){if(t!=="level")return;const i=parseInt(s||"3",10);cn(this,Ut,"m",we).call(this,i)}}Ut=new WeakSet,we=function(t){if(t<1||t>6)return;const e=`${"#".repeat(t)} `;k.set(this,{prefix:e})};window.customElements.get("md-header")||(window.MarkdownHeaderButtonElement=ln,window.customElements.define("md-header",ln));class un extends L{connectedCallback(){k.set(this,{prefix:"**",suffix:"**",trimFirst:!0})}}window.customElements.get("md-bold")||(window.MarkdownBoldButtonElement=un,window.customElements.define("md-bold",un));class dn extends L{connectedCallback(){k.set(this,{prefix:"_",suffix:"_",trimFirst:!0})}}window.customElements.get("md-italic")||(window.MarkdownItalicButtonElement=dn,window.customElements.define("md-italic",dn));class hn extends L{connectedCallback(){k.set(this,{prefix:"> ",multiline:!0,surroundWithNewlines:!0})}}window.customElements.get("md-quote")||(window.MarkdownQuoteButtonElement=hn,window.customElements.define("md-quote",hn));class fn extends L{connectedCallback(){k.set(this,{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"})}}window.customElements.get("md-code")||(window.MarkdownCodeButtonElement=fn,window.customElements.define("md-code",fn));class mn extends L{connectedCallback(){k.set(this,{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"})}}window.customElements.get("md-link")||(window.MarkdownLinkButtonElement=mn,window.customElements.define("md-link",mn));class pn extends L{connectedCallback(){k.set(this,{prefix:"![",suffix:"](url)",replaceNext:"url",scanFor:"https?://"})}}window.customElements.get("md-image")||(window.MarkdownImageButtonElement=pn,window.customElements.define("md-image",pn));class gn extends L{connectedCallback(){k.set(this,{prefix:"- ",multiline:!0,unorderedList:!0})}}window.customElements.get("md-unordered-list")||(window.MarkdownUnorderedListButtonElement=gn,window.customElements.define("md-unordered-list",gn));class bn extends L{connectedCallback(){k.set(this,{prefix:"1. ",multiline:!0,orderedList:!0})}}window.customElements.get("md-ordered-list")||(window.MarkdownOrderedListButtonElement=bn,window.customElements.define("md-ordered-list",bn));class vn extends L{connectedCallback(){k.set(this,{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0})}}window.customElements.get("md-task-list")||(window.MarkdownTaskListButtonElement=vn,window.customElements.define("md-task-list",vn));class yn extends L{connectedCallback(){k.set(this,{prefix:"@",prefixSpace:!0})}}window.customElements.get("md-mention")||(window.MarkdownMentionButtonElement=yn,window.customElements.define("md-mention",yn));class wn extends L{connectedCallback(){k.set(this,{prefix:"#",prefixSpace:!0})}}window.customElements.get("md-ref")||(window.MarkdownRefButtonElement=wn,window.customElements.define("md-ref",wn));class En extends L{connectedCallback(){k.set(this,{prefix:"~~",suffix:"~~",trimFirst:!0})}}window.customElements.get("md-strikethrough")||(window.MarkdownStrikethroughButtonElement=En,window.customElements.define("md-strikethrough",En));function An(n){const{target:t,currentTarget:e}=n;if(!(t instanceof Element))return;const s=t.closest("[data-md-button]");if(!s||s.closest("markdown-toolbar")!==e)return;const i=s.getAttribute("data-md-button"),r=Ai[i];r&&(n.preventDefault(),Ae(t,r))}function xn(n){n.addEventListener("keydown",cs),n.setAttribute("tabindex","0"),n.addEventListener("focus",as,{once:!0})}function Tn(n){n.removeEventListener("keydown",cs),n.removeAttribute("tabindex"),n.removeEventListener("focus",as)}class qt extends HTMLElement{connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","toolbar"),this.hasAttribute("data-no-focus")||xn(this),this.addEventListener("keydown",os(An)),this.addEventListener("click",An)}attributeChangedCallback(t,e,s){t==="data-no-focus"&&(s===null?xn(this):Tn(this))}disconnectedCallback(){Tn(this)}get field(){const t=this.getAttribute("for");if(!t)return null;const e="getRootNode"in this?this.getRootNode():document;let s;return(e instanceof Document||e instanceof ShadowRoot)&&(s=e.getElementById(t)),s instanceof HTMLTextAreaElement?s:null}}qt.observedAttributes=["data-no-focus"];function as({target:n}){if(!(n instanceof Element))return;n.removeAttribute("tabindex");let t="0";for(const e of rs(n))e.setAttribute("tabindex",t),t==="0"&&(e.focus(),t="-1")}function cs(n){const t=n.key;if(t!=="ArrowRight"&&t!=="ArrowLeft"&&t!=="Home"&&t!=="End")return;const e=n.currentTarget;if(!(e instanceof HTMLElement))return;const s=rs(e),i=s.indexOf(n.target),r=s.length;if(i===-1)return;let o=0;t==="ArrowLeft"&&(o=i-1),t==="ArrowRight"&&(o=i+1),t==="End"&&(o=r-1),o<0&&(o=r-1),o>r-1&&(o=0);for(let a=0;a<r;a+=1)s[a].setAttribute("tabindex",a===o?"0":"-1");n.preventDefault(),s[o].focus()}window.customElements.get("markdown-toolbar")||(window.MarkdownToolbarElement=qt,window.customElements.define("markdown-toolbar",qt));function Ee(n){return n.trim().split(`
80
- `).length>1}function On(n,t){return Array(t+1).join(n)}function xi(n,t){let e=t;for(;n[e]&&n[e-1]!=null&&!n[e-1].match(/\s/);)e--;return e}function Ti(n,t,e){let s=t;const i=e?/\n/:/\s/;for(;n[s]&&!n[s].match(i);)s++;return s}let z=null;function Oi(n,{text:t,selectionStart:e,selectionEnd:s}){const i=n.selectionStart,r=n.value.slice(0,i),o=n.value.slice(n.selectionEnd);if(z===null||z===!0){n.contentEditable="true";try{z=document.execCommand("insertText",!1,t)}catch{z=!1}n.contentEditable="false"}if(z&&!n.value.slice(0,n.selectionStart).endsWith(t)&&(z=!1),!z){try{document.execCommand("ms-beginUndoUnit")}catch{}n.value=r+t+o;try{document.execCommand("ms-endUndoUnit")}catch{}n.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}e!=null&&s!=null?n.setSelectionRange(e,s):n.setSelectionRange(i,n.selectionEnd)}function ki(n,t){const e=n.value.slice(n.selectionStart,n.selectionEnd);let s;t.orderedList||t.unorderedList?s=Di(n,t):t.multiline&&Ee(e)?s=Li(n,t):s=Ci(n,t),Oi(n,s)}function Mi(n){const t=n.value.split(`
81
- `);let e=0;for(let s=0;s<t.length;s++){const i=t[s].length+1;n.selectionStart>=e&&n.selectionStart<e+i&&(n.selectionStart=e),n.selectionEnd>=e&&n.selectionEnd<e+i&&(n.selectionEnd=e+i-1),e+=i}}function Si(n,t,e,s=!1){if(n.selectionStart===n.selectionEnd)n.selectionStart=xi(n.value,n.selectionStart),n.selectionEnd=Ti(n.value,n.selectionEnd,s);else{const i=n.selectionStart-t.length,r=n.selectionEnd+e.length,o=n.value.slice(i,n.selectionStart)===t,a=n.value.slice(n.selectionEnd,r)===e;o&&a&&(n.selectionStart=i,n.selectionEnd=r)}return n.value.slice(n.selectionStart,n.selectionEnd)}function Fe(n){const t=n.value.slice(0,n.selectionStart),e=n.value.slice(n.selectionEnd),s=t.match(/\n*$/),i=e.match(/^\n*/),r=s?s[0].length:0,o=i?i[0].length:0;let a,c;return t.match(/\S/)&&r<2&&(a=On(`
82
- `,2-r)),e.match(/\S/)&&o<2&&(c=On(`
83
- `,2-o)),a==null&&(a=""),c==null&&(c=""),{newlinesToAppend:a,newlinesToPrepend:c}}function Ci(n,t){let e,s;const{prefix:i,suffix:r,blockPrefix:o,blockSuffix:a,replaceNext:c,prefixSpace:l,scanFor:u,surroundWithNewlines:d}=t,h=n.selectionStart,g=n.selectionEnd;let f=n.value.slice(n.selectionStart,n.selectionEnd),m=Ee(f)&&o.length>0?`${o}
84
- `:i,b=Ee(f)&&a.length>0?`
85
- ${a}`:r;if(l){const y=n.value[n.selectionStart-1];n.selectionStart!==0&&y!=null&&!y.match(/\s/)&&(m=` ${m}`)}f=Si(n,m,b,t.multiline);let p=n.selectionStart,v=n.selectionEnd;const E=c.length>0&&b.indexOf(c)>-1&&f.length>0;if(d){const y=Fe(n);e=y.newlinesToAppend,s=y.newlinesToPrepend,m=e+i,b+=s}if(f.startsWith(m)&&f.endsWith(b)){const y=f.slice(m.length,f.length-b.length);if(h===g){let w=h-m.length;w=Math.max(w,p),w=Math.min(w,p+y.length),p=v=w}else v=p+y.length;return{text:y,selectionStart:p,selectionEnd:v}}else if(E)if(u.length>0&&f.match(u)){b=b.replace(c,f);const y=m+b;return p=v=p+m.length,{text:y,selectionStart:p,selectionEnd:v}}else{const y=m+f+b;return p=p+m.length+f.length+b.indexOf(c),v=p+c.length,{text:y,selectionStart:p,selectionEnd:v}}else{let y=m+f+b;p=h+m.length,v=g+m.length;const w=f.match(/^\s*|\s*$/g);if(t.trimFirst&&w){const x=w[0]||"",B=w[1]||"";y=x+m+f.trim()+b+B,p+=x.length,v-=B.length}return{text:y,selectionStart:p,selectionEnd:v}}}function Li(n,t){const{prefix:e,suffix:s,surroundWithNewlines:i}=t;let r=n.value.slice(n.selectionStart,n.selectionEnd),o=n.selectionStart,a=n.selectionEnd;const c=r.split(`
79
+ `;const e=t.querySelector("[data-crop-box]");if(!(e instanceof HTMLElement))return;const s=t.querySelector("img");s instanceof HTMLImageElement&&(R.set(this,{box:e,image:s}),s.addEventListener("load",()=>{this.loaded=!0,as(this)}),this.addEventListener("mouseleave",he),this.addEventListener("touchend",he),this.addEventListener("mouseup",he),e.addEventListener("mousedown",ln),e.addEventListener("touchstart",ln,{passive:!0}),this.addEventListener("keydown",Lt),this.addEventListener("keydown",lt),this.src&&(s.src=this.src))}static get observedAttributes(){return["src"]}get src(){return this.getAttribute("src")}set src(t){t?this.setAttribute("src",t):this.removeAttribute("src")}get loaded(){return this.hasAttribute("loaded")}set loaded(t){t?this.setAttribute("loaded",""):this.removeAttribute("loaded")}attributeChangedCallback(t,e,s){const{image:i}=R.get(this)||{};t==="src"&&(this.loaded=!1,i&&(i.src=s))}}window.customElements.get("image-crop")||(window.ImageCropElement=dt,window.customElements.define("image-crop",dt));var T=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},fe=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},O,it,Mt,rt,me,we,jt,un;const Ee=new WeakMap;function Oi(n){return n&&!!n.split(",").find(t=>t.match(/^\s*\*\/\*/))}let Ae=null;class Be extends HTMLElement{constructor(){super(...arguments),O.add(this),it.set(this,!1),Mt.set(this,new IntersectionObserver(t=>{for(const e of t)if(e.isIntersecting){const{target:s}=e;if(T(this,Mt,"f").unobserve(s),!(s instanceof Be))return;s.loading==="lazy"&&T(this,O,"m",rt).call(this)}},{rootMargin:"0px 0px 256px 0px",threshold:.01}))}static define(t="include-fragment",e=customElements){return e.define(t,this),this}static setCSPTrustedTypesPolicy(t){Ae=t===null?t:Promise.resolve(t)}static get observedAttributes(){return["src","loading"]}get src(){const t=this.getAttribute("src");if(t){const e=this.ownerDocument.createElement("a");return e.href=t,e.href}else return""}set src(t){this.setAttribute("src",t)}get loading(){return this.getAttribute("loading")==="lazy"?"lazy":"eager"}set loading(t){this.setAttribute("loading",t)}get accept(){return this.getAttribute("accept")||""}set accept(t){this.setAttribute("accept",t)}get data(){return T(this,O,"m",we).call(this)}attributeChangedCallback(t,e){t==="src"?this.isConnected&&this.loading==="eager"&&T(this,O,"m",rt).call(this):t==="loading"&&this.isConnected&&e!=="eager"&&this.loading==="eager"&&T(this,O,"m",rt).call(this)}connectedCallback(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=":host {display: block;}",this.shadowRoot.append(t,document.createElement("slot"))}this.src&&this.loading==="eager"&&T(this,O,"m",rt).call(this),this.loading==="lazy"&&T(this,Mt,"f").observe(this)}request(){const t=this.src;if(!t)throw new Error("missing src");return new Request(t,{method:"GET",credentials:"same-origin",headers:{Accept:this.accept||"text/html"}})}load(){return T(this,O,"m",we).call(this)}fetch(t){return fetch(t)}refetch(){Ee.delete(this),T(this,O,"m",rt).call(this)}}it=new WeakMap,Mt=new WeakMap,O=new WeakSet,rt=async function(){if(!T(this,it,"f")){fe(this,it,!0,"f"),T(this,Mt,"f").unobserve(this);try{const t=await T(this,O,"m",me).call(this);if(t instanceof Error)throw t;const e=t,s=document.createElement("template");s.innerHTML=e;const i=document.importNode(s.content,!0);if(!this.dispatchEvent(new CustomEvent("include-fragment-replace",{cancelable:!0,detail:{fragment:i}}))){fe(this,it,!1,"f");return}this.replaceWith(i),this.dispatchEvent(new CustomEvent("include-fragment-replaced"))}catch{this.classList.add("is-error")}finally{fe(this,it,!1,"f")}}},me=async function(){const t=this.src,e=Ee.get(this);if(e&&e.src===t)return e.data;{let s;return t?s=T(this,O,"m",un).call(this):s=Promise.reject(new Error("missing src")),Ee.set(this,{src:t,data:s}),s}},we=async function(){const t=await T(this,O,"m",me).call(this);if(t instanceof Error)throw t;return t.toString()},jt=async function(t){await new Promise(e=>setTimeout(e,0));for(const e of t)this.dispatchEvent(new Event(e))},un=async function(){try{await T(this,O,"m",jt).call(this,["loadstart"]);const t=await this.fetch(this.request());if(t.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${t.status}`);const e=t.headers.get("Content-Type");if(!Oi(this.accept)&&(!e||!e.includes(this.accept?this.accept:"text/html")))throw new Error(`Failed to load resource: expected ${this.accept||"text/html"} but was ${e}`);const s=await t.text();let i=s;return Ae&&(i=(await Ae).createHTML(s,t)),T(this,O,"m",jt).call(this,["load","loadend"]),i}catch(t){throw T(this,O,"m",jt).call(this,["error","loadend"]),t}};const dn=typeof globalThis<"u"?globalThis:window;try{dn.IncludeFragmentElement=Be.define()}catch(n){if(!(dn.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}var hn=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},Ut,xe;const ki=["[data-md-button]","md-header","md-bold","md-italic","md-quote","md-code","md-link","md-image","md-unordered-list","md-ordered-list","md-task-list","md-mention","md-ref","md-strikethrough"];function ls(n){const t=[];for(const e of n.querySelectorAll(ki.join(", ")))e.hidden||e.offsetWidth<=0&&e.offsetHeight<=0||e.closest("markdown-toolbar")===n&&t.push(e);return t}function us(n){return function(t){(t.key===" "||t.key==="Enter")&&n(t)}}const k=new WeakMap,Mi={"header-1":{prefix:"# "},"header-2":{prefix:"## "},"header-3":{prefix:"### "},"header-4":{prefix:"#### "},"header-5":{prefix:"##### "},"header-6":{prefix:"###### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},image:{prefix:"![",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},"unordered-list":{prefix:"- ",multiline:!0,unorderedList:!0},"ordered-list":{prefix:"1. ",multiline:!0,orderedList:!0},"task-list":{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},mention:{prefix:"@",prefixSpace:!0},ref:{prefix:"#",prefixSpace:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0}};class L extends HTMLElement{constructor(){super();const t=e=>{const s=k.get(this);s&&(e.preventDefault(),Oe(this,s))};this.addEventListener("keydown",us(t)),this.addEventListener("click",t)}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","button")}click(){const t=k.get(this);t&&Oe(this,t)}}class fn extends L{constructor(){super(...arguments),Ut.add(this)}connectedCallback(){const t=parseInt(this.getAttribute("level")||"3",10);hn(this,Ut,"m",xe).call(this,t)}static get observedAttributes(){return["level"]}attributeChangedCallback(t,e,s){if(t!=="level")return;const i=parseInt(s||"3",10);hn(this,Ut,"m",xe).call(this,i)}}Ut=new WeakSet,xe=function(t){if(t<1||t>6)return;const e=`${"#".repeat(t)} `;k.set(this,{prefix:e})};window.customElements.get("md-header")||(window.MarkdownHeaderButtonElement=fn,window.customElements.define("md-header",fn));class mn extends L{connectedCallback(){k.set(this,{prefix:"**",suffix:"**",trimFirst:!0})}}window.customElements.get("md-bold")||(window.MarkdownBoldButtonElement=mn,window.customElements.define("md-bold",mn));class pn extends L{connectedCallback(){k.set(this,{prefix:"_",suffix:"_",trimFirst:!0})}}window.customElements.get("md-italic")||(window.MarkdownItalicButtonElement=pn,window.customElements.define("md-italic",pn));class gn extends L{connectedCallback(){k.set(this,{prefix:"> ",multiline:!0,surroundWithNewlines:!0})}}window.customElements.get("md-quote")||(window.MarkdownQuoteButtonElement=gn,window.customElements.define("md-quote",gn));class bn extends L{connectedCallback(){k.set(this,{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"})}}window.customElements.get("md-code")||(window.MarkdownCodeButtonElement=bn,window.customElements.define("md-code",bn));class vn extends L{connectedCallback(){k.set(this,{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"})}}window.customElements.get("md-link")||(window.MarkdownLinkButtonElement=vn,window.customElements.define("md-link",vn));class yn extends L{connectedCallback(){k.set(this,{prefix:"![",suffix:"](url)",replaceNext:"url",scanFor:"https?://"})}}window.customElements.get("md-image")||(window.MarkdownImageButtonElement=yn,window.customElements.define("md-image",yn));class wn extends L{connectedCallback(){k.set(this,{prefix:"- ",multiline:!0,unorderedList:!0})}}window.customElements.get("md-unordered-list")||(window.MarkdownUnorderedListButtonElement=wn,window.customElements.define("md-unordered-list",wn));class En extends L{connectedCallback(){k.set(this,{prefix:"1. ",multiline:!0,orderedList:!0})}}window.customElements.get("md-ordered-list")||(window.MarkdownOrderedListButtonElement=En,window.customElements.define("md-ordered-list",En));class An extends L{connectedCallback(){k.set(this,{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0})}}window.customElements.get("md-task-list")||(window.MarkdownTaskListButtonElement=An,window.customElements.define("md-task-list",An));class xn extends L{connectedCallback(){k.set(this,{prefix:"@",prefixSpace:!0})}}window.customElements.get("md-mention")||(window.MarkdownMentionButtonElement=xn,window.customElements.define("md-mention",xn));class Tn extends L{connectedCallback(){k.set(this,{prefix:"#",prefixSpace:!0})}}window.customElements.get("md-ref")||(window.MarkdownRefButtonElement=Tn,window.customElements.define("md-ref",Tn));class On extends L{connectedCallback(){k.set(this,{prefix:"~~",suffix:"~~",trimFirst:!0})}}window.customElements.get("md-strikethrough")||(window.MarkdownStrikethroughButtonElement=On,window.customElements.define("md-strikethrough",On));function kn(n){const{target:t,currentTarget:e}=n;if(!(t instanceof Element))return;const s=t.closest("[data-md-button]");if(!s||s.closest("markdown-toolbar")!==e)return;const i=s.getAttribute("data-md-button"),r=Mi[i];r&&(n.preventDefault(),Oe(t,r))}function Mn(n){n.addEventListener("keydown",hs),n.setAttribute("tabindex","0"),n.addEventListener("focus",ds,{once:!0})}function Sn(n){n.removeEventListener("keydown",hs),n.removeAttribute("tabindex"),n.removeEventListener("focus",ds)}class qt extends HTMLElement{connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","toolbar"),this.hasAttribute("data-no-focus")||Mn(this),this.addEventListener("keydown",us(kn)),this.addEventListener("click",kn)}attributeChangedCallback(t,e,s){t==="data-no-focus"&&(s===null?Mn(this):Sn(this))}disconnectedCallback(){Sn(this)}get field(){const t=this.getAttribute("for");if(!t)return null;const e="getRootNode"in this?this.getRootNode():document;let s;return(e instanceof Document||e instanceof ShadowRoot)&&(s=e.getElementById(t)),s instanceof HTMLTextAreaElement?s:null}}qt.observedAttributes=["data-no-focus"];function ds({target:n}){if(!(n instanceof Element))return;n.removeAttribute("tabindex");let t="0";for(const e of ls(n))e.setAttribute("tabindex",t),t==="0"&&(e.focus(),t="-1")}function hs(n){const t=n.key;if(t!=="ArrowRight"&&t!=="ArrowLeft"&&t!=="Home"&&t!=="End")return;const e=n.currentTarget;if(!(e instanceof HTMLElement))return;const s=ls(e),i=s.indexOf(n.target),r=s.length;if(i===-1)return;let o=0;t==="ArrowLeft"&&(o=i-1),t==="ArrowRight"&&(o=i+1),t==="End"&&(o=r-1),o<0&&(o=r-1),o>r-1&&(o=0);for(let a=0;a<r;a+=1)s[a].setAttribute("tabindex",a===o?"0":"-1");n.preventDefault(),s[o].focus()}window.customElements.get("markdown-toolbar")||(window.MarkdownToolbarElement=qt,window.customElements.define("markdown-toolbar",qt));function Te(n){return n.trim().split(`
80
+ `).length>1}function Cn(n,t){return Array(t+1).join(n)}function Si(n,t){let e=t;for(;n[e]&&n[e-1]!=null&&!n[e-1].match(/\s/);)e--;return e}function Ci(n,t,e){let s=t;const i=e?/\n/:/\s/;for(;n[s]&&!n[s].match(i);)s++;return s}let z=null;function Li(n,{text:t,selectionStart:e,selectionEnd:s}){const i=n.selectionStart,r=n.value.slice(0,i),o=n.value.slice(n.selectionEnd);if(z===null||z===!0){n.contentEditable="true";try{z=document.execCommand("insertText",!1,t)}catch{z=!1}n.contentEditable="false"}if(z&&!n.value.slice(0,n.selectionStart).endsWith(t)&&(z=!1),!z){try{document.execCommand("ms-beginUndoUnit")}catch{}n.value=r+t+o;try{document.execCommand("ms-endUndoUnit")}catch{}n.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}e!=null&&s!=null?n.setSelectionRange(e,s):n.setSelectionRange(i,n.selectionEnd)}function Fi(n,t){const e=n.value.slice(n.selectionStart,n.selectionEnd);let s;t.orderedList||t.unorderedList?s=Ri(n,t):t.multiline&&Te(e)?s=$i(n,t):s=Bi(n,t),Li(n,s)}function Di(n){const t=n.value.split(`
81
+ `);let e=0;for(let s=0;s<t.length;s++){const i=t[s].length+1;n.selectionStart>=e&&n.selectionStart<e+i&&(n.selectionStart=e),n.selectionEnd>=e&&n.selectionEnd<e+i&&(n.selectionEnd=e+i-1),e+=i}}function _i(n,t,e,s=!1){if(n.selectionStart===n.selectionEnd)n.selectionStart=Si(n.value,n.selectionStart),n.selectionEnd=Ci(n.value,n.selectionEnd,s);else{const i=n.selectionStart-t.length,r=n.selectionEnd+e.length,o=n.value.slice(i,n.selectionStart)===t,a=n.value.slice(n.selectionEnd,r)===e;o&&a&&(n.selectionStart=i,n.selectionEnd=r)}return n.value.slice(n.selectionStart,n.selectionEnd)}function $e(n){const t=n.value.slice(0,n.selectionStart),e=n.value.slice(n.selectionEnd),s=t.match(/\n*$/),i=e.match(/^\n*/),r=s?s[0].length:0,o=i?i[0].length:0;let a,c;return t.match(/\S/)&&r<2&&(a=Cn(`
82
+ `,2-r)),e.match(/\S/)&&o<2&&(c=Cn(`
83
+ `,2-o)),a==null&&(a=""),c==null&&(c=""),{newlinesToAppend:a,newlinesToPrepend:c}}function Bi(n,t){let e,s;const{prefix:i,suffix:r,blockPrefix:o,blockSuffix:a,replaceNext:c,prefixSpace:l,scanFor:u,surroundWithNewlines:d}=t,h=n.selectionStart,g=n.selectionEnd;let f=n.value.slice(n.selectionStart,n.selectionEnd),m=Te(f)&&o.length>0?`${o}
84
+ `:i,b=Te(f)&&a.length>0?`
85
+ ${a}`:r;if(l){const y=n.value[n.selectionStart-1];n.selectionStart!==0&&y!=null&&!y.match(/\s/)&&(m=` ${m}`)}f=_i(n,m,b,t.multiline);let p=n.selectionStart,v=n.selectionEnd;const E=c.length>0&&b.indexOf(c)>-1&&f.length>0;if(d){const y=$e(n);e=y.newlinesToAppend,s=y.newlinesToPrepend,m=e+i,b+=s}if(f.startsWith(m)&&f.endsWith(b)){const y=f.slice(m.length,f.length-b.length);if(h===g){let w=h-m.length;w=Math.max(w,p),w=Math.min(w,p+y.length),p=v=w}else v=p+y.length;return{text:y,selectionStart:p,selectionEnd:v}}else if(E)if(u.length>0&&f.match(u)){b=b.replace(c,f);const y=m+b;return p=v=p+m.length,{text:y,selectionStart:p,selectionEnd:v}}else{const y=m+f+b;return p=p+m.length+f.length+b.indexOf(c),v=p+c.length,{text:y,selectionStart:p,selectionEnd:v}}else{let y=m+f+b;p=h+m.length,v=g+m.length;const w=f.match(/^\s*|\s*$/g);if(t.trimFirst&&w){const x=w[0]||"",B=w[1]||"";y=x+m+f.trim()+b+B,p+=x.length,v-=B.length}return{text:y,selectionStart:p,selectionEnd:v}}}function $i(n,t){const{prefix:e,suffix:s,surroundWithNewlines:i}=t;let r=n.value.slice(n.selectionStart,n.selectionEnd),o=n.selectionStart,a=n.selectionEnd;const c=r.split(`
86
86
  `);if(c.every(u=>u.startsWith(e)&&u.endsWith(s)))r=c.map(u=>u.slice(e.length,u.length-s.length)).join(`
87
87
  `),a=o+r.length;else if(r=c.map(u=>e+u+s).join(`
88
- `),i){const{newlinesToAppend:u,newlinesToPrepend:d}=Fe(n);o+=u.length,a=o+r.length,r=u+r+d}return{text:r,selectionStart:o,selectionEnd:a}}function kn(n){const t=n.split(`
88
+ `),i){const{newlinesToAppend:u,newlinesToPrepend:d}=$e(n);o+=u.length,a=o+r.length,r=u+r+d}return{text:r,selectionStart:o,selectionEnd:a}}function Ln(n){const t=n.split(`
89
89
  `),e=/^\d+\.\s+/,s=t.every(r=>e.test(r));let i=t;return s&&(i=t.map(r=>r.replace(e,""))),{text:i.join(`
90
- `),processed:s}}function Mn(n){const t=n.split(`
90
+ `),processed:s}}function Fn(n){const t=n.split(`
91
91
  `),e="- ",s=t.every(r=>r.startsWith(e));let i=t;return s&&(i=t.map(r=>r.slice(e.length,r.length))),{text:i.join(`
92
- `),processed:s}}function bt(n,t){return t?"- ":`${n+1}. `}function Fi(n,t){let e,s,i;return n.orderedList?(s=kn(t),e=Mn(s.text),i=e.text):(s=Mn(t),e=kn(s.text),i=e.text),[s,e,i]}function Di(n,t){const e=n.selectionStart===n.selectionEnd;let s=n.selectionStart,i=n.selectionEnd;Mi(n);const r=n.value.slice(n.selectionStart,n.selectionEnd),[o,a,c]=Fi(t,r),l=c.split(`
93
- `).map((m,b)=>`${bt(b,t.unorderedList)}${m}`),u=l.reduce((m,b,p)=>m+bt(p,t.unorderedList).length,0),d=l.reduce((m,b,p)=>m+bt(p,!t.unorderedList).length,0);if(o.processed)return e?(s=Math.max(s-bt(0,t.unorderedList).length,0),i=s):(s=n.selectionStart,i=n.selectionEnd-u),{text:c,selectionStart:s,selectionEnd:i};const{newlinesToAppend:h,newlinesToPrepend:g}=Fe(n),f=h+l.join(`
94
- `)+g;return e?(s=Math.max(s+bt(0,t.unorderedList).length+h.length,0),i=s):a.processed?(s=Math.max(n.selectionStart+h.length,0),i=n.selectionEnd+h.length+u-d):(s=Math.max(n.selectionStart+h.length,0),i=n.selectionEnd+h.length+u),{text:f,selectionStart:s,selectionEnd:i}}function Ae(n,t){const e=n.closest("markdown-toolbar");if(!(e instanceof qt))return;const i=Object.assign(Object.assign({},{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}),t),r=e.field;r&&(r.focus(),ki(r,i))}var _i=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},Sn=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},xt;class Bi{formatToParts(t){const e=[];for(const s of t)e.push({type:"element",value:s}),e.push({type:"literal",value:", "});return e.slice(0,-1)}}const Pi=typeof Intl<"u"&&Intl.ListFormat||Bi,Ri=[["years","year"],["months","month"],["weeks","week"],["days","day"],["hours","hour"],["minutes","minute"],["seconds","second"],["milliseconds","millisecond"]],$i={minimumIntegerDigits:2};class Ii{constructor(t,e={}){xt.set(this,void 0);let s=String(e.style||"short");s!=="long"&&s!=="short"&&s!=="narrow"&&s!=="digital"&&(s="short");let i=s==="digital"?"numeric":s;const r=e.hours||i;i=r==="2-digit"?"numeric":r;const o=e.minutes||i;i=o==="2-digit"?"numeric":o;const a=e.seconds||i;i=a==="2-digit"?"numeric":a;const c=e.milliseconds||i;_i(this,xt,{locale:t,style:s,years:e.years||s==="digital"?"short":s,yearsDisplay:e.yearsDisplay==="always"?"always":"auto",months:e.months||s==="digital"?"short":s,monthsDisplay:e.monthsDisplay==="always"?"always":"auto",weeks:e.weeks||s==="digital"?"short":s,weeksDisplay:e.weeksDisplay==="always"?"always":"auto",days:e.days||s==="digital"?"short":s,daysDisplay:e.daysDisplay==="always"?"always":"auto",hours:r,hoursDisplay:e.hoursDisplay==="always"||s==="digital"?"always":"auto",minutes:o,minutesDisplay:e.minutesDisplay==="always"||s==="digital"?"always":"auto",seconds:a,secondsDisplay:e.secondsDisplay==="always"||s==="digital"?"always":"auto",milliseconds:c,millisecondsDisplay:e.millisecondsDisplay==="always"?"always":"auto"},"f")}resolvedOptions(){return Sn(this,xt,"f")}formatToParts(t){const e=[],s=Sn(this,xt,"f"),i=s.style,r=s.locale;for(const[o,a]of Ri){const c=t[o];if(s[`${o}Display`]==="auto"&&!c)continue;const l=s[o],u=l==="2-digit"?$i:l==="numeric"?{}:{style:"unit",unit:a,unitDisplay:l};e.push(new Intl.NumberFormat(r,u).format(c))}return new Pi(r,{type:"unit",style:i==="digital"?"short":i}).formatToParts(e)}format(t){return this.formatToParts(t).map(e=>e.value).join("")}}xt=new WeakMap;const ls=/^[-+]?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,zt=["year","month","week","day","hour","minute","second","millisecond"],Ni=n=>ls.test(n);class M{constructor(t=0,e=0,s=0,i=0,r=0,o=0,a=0,c=0){this.years=t,this.months=e,this.weeks=s,this.days=i,this.hours=r,this.minutes=o,this.seconds=a,this.milliseconds=c,this.years||(this.years=0),this.sign||(this.sign=Math.sign(this.years)),this.months||(this.months=0),this.sign||(this.sign=Math.sign(this.months)),this.weeks||(this.weeks=0),this.sign||(this.sign=Math.sign(this.weeks)),this.days||(this.days=0),this.sign||(this.sign=Math.sign(this.days)),this.hours||(this.hours=0),this.sign||(this.sign=Math.sign(this.hours)),this.minutes||(this.minutes=0),this.sign||(this.sign=Math.sign(this.minutes)),this.seconds||(this.seconds=0),this.sign||(this.sign=Math.sign(this.seconds)),this.milliseconds||(this.milliseconds=0),this.sign||(this.sign=Math.sign(this.milliseconds)),this.blank=this.sign===0}abs(){return new M(Math.abs(this.years),Math.abs(this.months),Math.abs(this.weeks),Math.abs(this.days),Math.abs(this.hours),Math.abs(this.minutes),Math.abs(this.seconds),Math.abs(this.milliseconds))}static from(t){var e;if(typeof t=="string"){const s=String(t).trim(),i=s.startsWith("-")?-1:1,r=(e=s.match(ls))===null||e===void 0?void 0:e.slice(1).map(o=>(Number(o)||0)*i);return r?new M(...r):new M}else if(typeof t=="object"){const{years:s,months:i,weeks:r,days:o,hours:a,minutes:c,seconds:l,milliseconds:u}=t;return new M(s,i,r,o,a,c,l,u)}throw new RangeError("invalid duration")}static compare(t,e){const s=Date.now(),i=Math.abs(Cn(s,M.from(t)).getTime()-s),r=Math.abs(Cn(s,M.from(e)).getTime()-s);return i>r?-1:i<r?1:0}toLocaleString(t,e){return new Ii(t,e).format(this)}}function Cn(n,t){const e=new Date(n);return e.setFullYear(e.getFullYear()+t.years),e.setMonth(e.getMonth()+t.months),e.setDate(e.getDate()+t.weeks*7+t.days),e.setHours(e.getHours()+t.hours),e.setMinutes(e.getMinutes()+t.minutes),e.setSeconds(e.getSeconds()+t.seconds),e}function ji(n,t="second",e=Date.now()){const s=n.getTime()-e;if(s===0)return new M;const i=Math.sign(s),r=Math.abs(s),o=Math.floor(r/1e3),a=Math.floor(o/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/30),d=Math.floor(u/12),h=zt.indexOf(t)||zt.length;return new M(h>=0?d*i:0,h>=1?(u-d*12)*i:0,0,h>=3?(l-u*30)*i:0,h>=4?(c-l*24)*i:0,h>=5?(a-c*60)*i:0,h>=6?(o-a*60)*i:0,h>=7?(r-o*1e3)*i:0)}function us(n,{relativeTo:t=Date.now()}={}){if(t=new Date(t),n.blank)return n;const e=n.sign;let s=Math.abs(n.years),i=Math.abs(n.months),r=Math.abs(n.weeks),o=Math.abs(n.days),a=Math.abs(n.hours),c=Math.abs(n.minutes),l=Math.abs(n.seconds),u=Math.abs(n.milliseconds);u>=900&&(l+=Math.round(u/1e3)),(l||c||a||o||r||i||s)&&(u=0),l>=55&&(c+=Math.round(l/60)),(c||a||o||r||i||s)&&(l=0),c>=55&&(a+=Math.round(c/60)),(a||o||r||i||s)&&(c=0),o&&a>=12&&(o+=Math.round(a/24)),!o&&a>=21&&(o+=Math.round(a/24)),(o||r||i||s)&&(a=0);const d=t.getFullYear();let h=t.getMonth();const g=t.getDate();if(o>=27||s+i+o){const f=new Date(t);f.setFullYear(d+s*e),f.setMonth(h+i*e),f.setDate(g+o*e);const m=f.getFullYear()-t.getFullYear(),b=f.getMonth()-t.getMonth(),p=Math.abs(Math.round((Number(f)-Number(t))/864e5)),v=Math.abs(m*12+b);p<27?(o>=6?(r+=Math.round(o/7),o=0):o=p,i=s=0):v<11?(i=v,s=0):(i=0,s=m*e),(i||s)&&(o=0),h=t.getMonth()}return s&&(i=0),r>=4&&(i+=Math.round(r/4)),(i||s)&&(r=0),o&&r&&!i&&!s&&(r+=Math.round(o/7),o=0),new M(s*e,i*e,r*e,o*e,a*e,c*e,l*e,u*e)}function Hi(n,t){const e=us(n,t);if(e.blank)return[0,"second"];for(const s of zt){if(s==="millisecond")continue;const i=e[`${s}s`];if(i)return[i,s]}return[0,"second"]}var A=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},Ht=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},F,Tt,Ot,vt,X,xe,ds,hs,fs,ms,ot;const Vi=globalThis.HTMLElement||null,me=new M,Ln=new M(0,0,0,0,0,1);class Wi extends Event{constructor(t,e,s,i){super("relative-time-updated",{bubbles:!0,composed:!0}),this.oldText=t,this.newText=e,this.oldTitle=s,this.newTitle=i}}function Fn(n){if(!n.date)return 1/0;if(n.format==="duration"||n.format==="elapsed"){const e=n.precision;if(e==="second")return 1e3;if(e==="minute")return 60*1e3}const t=Math.abs(Date.now()-n.date.getTime());return t<60*1e3?1e3:t<60*60*1e3?60*1e3:60*60*1e3}const pe=new class{constructor(){this.elements=new Set,this.time=1/0,this.timer=-1}observe(n){if(this.elements.has(n))return;this.elements.add(n);const t=n.date;if(t&&t.getTime()){const e=Fn(n),s=Date.now()+e;s<this.time&&(clearTimeout(this.timer),this.timer=setTimeout(()=>this.update(),e),this.time=s)}}unobserve(n){this.elements.has(n)&&this.elements.delete(n)}update(){if(clearTimeout(this.timer),!this.elements.size)return;let n=1/0;for(const t of this.elements)n=Math.min(n,Fn(t)),t.update();this.time=Math.min(60*60*1e3,n),this.timer=setTimeout(()=>this.update(),this.time),this.time+=Date.now()}};class Ki extends Vi{constructor(){super(...arguments),F.add(this),Tt.set(this,!1),Ot.set(this,!1),X.set(this,this.shadowRoot?this.shadowRoot:this.attachShadow?this.attachShadow({mode:"open"}):this),ot.set(this,null)}static define(t="relative-time",e=customElements){return e.define(t,this),this}static get observedAttributes(){return["second","minute","hour","weekday","day","month","year","time-zone-name","prefix","threshold","tense","precision","format","format-style","datetime","lang","title"]}get onRelativeTimeUpdated(){return A(this,ot,"f")}set onRelativeTimeUpdated(t){A(this,ot,"f")&&this.removeEventListener("relative-time-updated",A(this,ot,"f")),Ht(this,ot,typeof t=="object"||typeof t=="function"?t:null,"f"),typeof t=="function"&&this.addEventListener("relative-time-updated",t)}get second(){const t=this.getAttribute("second");if(t==="numeric"||t==="2-digit")return t}set second(t){this.setAttribute("second",t||"")}get minute(){const t=this.getAttribute("minute");if(t==="numeric"||t==="2-digit")return t}set minute(t){this.setAttribute("minute",t||"")}get hour(){const t=this.getAttribute("hour");if(t==="numeric"||t==="2-digit")return t}set hour(t){this.setAttribute("hour",t||"")}get weekday(){const t=this.getAttribute("weekday");if(t==="long"||t==="short"||t==="narrow")return t;if(this.format==="datetime"&&t!=="")return this.formatStyle}set weekday(t){this.setAttribute("weekday",t||"")}get day(){var t;const e=(t=this.getAttribute("day"))!==null&&t!==void 0?t:"numeric";if(e==="numeric"||e==="2-digit")return e}set day(t){this.setAttribute("day",t||"")}get month(){const t=this.format;let e=this.getAttribute("month");if(e!==""&&(e??(e=t==="datetime"?this.formatStyle:"short"),e==="numeric"||e==="2-digit"||e==="short"||e==="long"||e==="narrow"))return e}set month(t){this.setAttribute("month",t||"")}get year(){var t;const e=this.getAttribute("year");if(e==="numeric"||e==="2-digit")return e;if(!this.hasAttribute("year")&&new Date().getUTCFullYear()!==((t=this.date)===null||t===void 0?void 0:t.getUTCFullYear()))return"numeric"}set year(t){this.setAttribute("year",t||"")}get timeZoneName(){const t=this.getAttribute("time-zone-name");if(t==="long"||t==="short"||t==="shortOffset"||t==="longOffset"||t==="shortGeneric"||t==="longGeneric")return t}set timeZoneName(t){this.setAttribute("time-zone-name",t||"")}get prefix(){var t;return(t=this.getAttribute("prefix"))!==null&&t!==void 0?t:this.format==="datetime"?"":"on"}set prefix(t){this.setAttribute("prefix",t)}get threshold(){const t=this.getAttribute("threshold");return t&&Ni(t)?t:"P30D"}set threshold(t){this.setAttribute("threshold",t)}get tense(){const t=this.getAttribute("tense");return t==="past"?"past":t==="future"?"future":"auto"}set tense(t){this.setAttribute("tense",t)}get precision(){const t=this.getAttribute("precision");return zt.includes(t)?t:this.format==="micro"?"minute":"second"}set precision(t){this.setAttribute("precision",t)}get format(){const t=this.getAttribute("format");return t==="datetime"?"datetime":t==="relative"?"relative":t==="duration"?"duration":t==="micro"?"micro":t==="elapsed"?"elapsed":"auto"}set format(t){this.setAttribute("format",t)}get formatStyle(){const t=this.getAttribute("format-style");if(t==="long")return"long";if(t==="short")return"short";if(t==="narrow")return"narrow";const e=this.format;return e==="elapsed"||e==="micro"?"narrow":e==="datetime"?"short":"long"}set formatStyle(t){this.setAttribute("format-style",t)}get datetime(){return this.getAttribute("datetime")||""}set datetime(t){this.setAttribute("datetime",t)}get date(){const t=Date.parse(this.datetime);return Number.isNaN(t)?null:new Date(t)}set date(t){this.datetime=(t==null?void 0:t.toISOString())||""}connectedCallback(){this.update()}disconnectedCallback(){pe.unobserve(this)}attributeChangedCallback(t,e,s){e!==s&&(t==="title"&&Ht(this,Tt,s!==null&&(this.date&&A(this,F,"m",xe).call(this,this.date))!==s,"f"),!A(this,Ot,"f")&&!(t==="title"&&A(this,Tt,"f"))&&Ht(this,Ot,(async()=>{await Promise.resolve(),this.update()})(),"f"))}update(){const t=A(this,X,"f").textContent||this.textContent||"",e=this.getAttribute("title")||"";let s=e;const i=this.date;if(typeof Intl>"u"||!Intl.DateTimeFormat||!i){A(this,X,"f").textContent=t;return}const r=Date.now();A(this,Tt,"f")||(s=A(this,F,"m",xe).call(this,i)||"",s&&this.setAttribute("title",s));const o=ji(i,this.precision,r),a=A(this,F,"m",ds).call(this,o);let c=t;a==="duration"?c=A(this,F,"m",hs).call(this,o):a==="relative"?c=A(this,F,"m",fs).call(this,o):c=A(this,F,"m",ms).call(this,i),c?A(this,X,"f").textContent=c:this.shadowRoot===A(this,X,"f")&&this.textContent&&(A(this,X,"f").textContent=this.textContent),(c!==t||s!==e)&&this.dispatchEvent(new Wi(t,c,e,s)),a==="relative"||a==="duration"?pe.observe(this):pe.unobserve(this),Ht(this,Ot,!1,"f")}}Tt=new WeakMap,Ot=new WeakMap,X=new WeakMap,ot=new WeakMap,F=new WeakSet,vt=function(){var t;return((t=this.closest("[lang]"))===null||t===void 0?void 0:t.getAttribute("lang"))||this.ownerDocument.documentElement.getAttribute("lang")||"default"},xe=function(t){return new Intl.DateTimeFormat(A(this,F,"a",vt),{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)},ds=function(t){const e=this.format;if(e==="datetime")return"datetime";if(e==="duration"||e==="elapsed"||e==="micro")return"duration";if((e==="auto"||e==="relative")&&typeof Intl<"u"&&Intl.RelativeTimeFormat){const s=this.tense;if(s==="past"||s==="future"||M.compare(t,this.threshold)===1)return"relative"}return"datetime"},hs=function(t){const e=A(this,F,"a",vt),s=this.format,i=this.formatStyle,r=this.tense;let o=me;s==="micro"?(t=us(t),o=Ln,(this.tense==="past"&&t.sign!==-1||this.tense==="future"&&t.sign!==1)&&(t=Ln)):(r==="past"&&t.sign!==-1||r==="future"&&t.sign!==1)&&(t=o);const a=`${this.precision}sDisplay`;return t.blank?o.toLocaleString(e,{style:i,[a]:"always"}):t.abs().toLocaleString(e,{style:i})},fs=function(t){const e=new Intl.RelativeTimeFormat(A(this,F,"a",vt),{numeric:"auto",style:this.formatStyle}),s=this.tense;s==="future"&&t.sign!==1&&(t=me),s==="past"&&t.sign!==-1&&(t=me);const[i,r]=Hi(t);return r==="second"&&i<10?e.format(0,this.precision==="millisecond"?"second":this.precision):e.format(i,r)},ms=function(t){const e=new Intl.DateTimeFormat(A(this,F,"a",vt),{second:this.second,minute:this.minute,hour:this.hour,weekday:this.weekday,day:this.day,month:this.month,year:this.year,timeZoneName:this.timeZoneName});return`${this.prefix} ${e.format(t)}`.trim()};const Dn=typeof globalThis<"u"?globalThis:window;try{Dn.RelativeTimeElement=Ki.define()}catch(n){if(!(Dn.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}localStorage.getItem("theme");window.matchMedia("(prefers-color-scheme: dark)").matches;class Ui{constructor(t,e,s){this.eventTarget=t,this.eventName=e,this.eventOptions=s,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(t){this.unorderedBindings.add(t)}bindingDisconnected(t){this.unorderedBindings.delete(t)}handleEvent(t){const e=qi(t);for(const s of this.bindings){if(e.immediatePropagationStopped)break;s.handleEvent(e)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((t,e)=>{const s=t.index,i=e.index;return s<i?-1:s>i?1:0})}}function qi(n){if("immediatePropagationStopped"in n)return n;{const{stopImmediatePropagation:t}=n;return Object.assign(n,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}class zi{constructor(t){this.application=t,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(t=>t.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(t=>t.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((t,e)=>t.concat(Array.from(e.values())),[])}bindingConnected(t){this.fetchEventListenerForBinding(t).bindingConnected(t)}bindingDisconnected(t,e=!1){this.fetchEventListenerForBinding(t).bindingDisconnected(t),e&&this.clearEventListenersForBinding(t)}handleError(t,e,s={}){this.application.handleError(t,`Error ${e}`,s)}clearEventListenersForBinding(t){const e=this.fetchEventListenerForBinding(t);e.hasBindings()||(e.disconnect(),this.removeMappedEventListenerFor(t))}removeMappedEventListenerFor(t){const{eventTarget:e,eventName:s,eventOptions:i}=t,r=this.fetchEventListenerMapForEventTarget(e),o=this.cacheKey(s,i);r.delete(o),r.size==0&&this.eventListenerMaps.delete(e)}fetchEventListenerForBinding(t){const{eventTarget:e,eventName:s,eventOptions:i}=t;return this.fetchEventListener(e,s,i)}fetchEventListener(t,e,s){const i=this.fetchEventListenerMapForEventTarget(t),r=this.cacheKey(e,s);let o=i.get(r);return o||(o=this.createEventListener(t,e,s),i.set(r,o)),o}createEventListener(t,e,s){const i=new Ui(t,e,s);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(t){let e=this.eventListenerMaps.get(t);return e||(e=new Map,this.eventListenerMaps.set(t,e)),e}cacheKey(t,e){const s=[t];return Object.keys(e).sort().forEach(i=>{s.push(`${e[i]?"":"!"}${i}`)}),s.join(":")}}const Yi={stop({event:n,value:t}){return t&&n.stopPropagation(),!0},prevent({event:n,value:t}){return t&&n.preventDefault(),!0},self({event:n,value:t,element:e}){return t?e===n.target:!0}},Xi=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function Gi(n){const e=n.trim().match(Xi)||[];let s=e[2],i=e[3];return i&&!["keydown","keyup","keypress"].includes(s)&&(s+=`.${i}`,i=""),{eventTarget:Zi(e[4]),eventName:s,eventOptions:e[7]?Ji(e[7]):{},identifier:e[5],methodName:e[6],keyFilter:e[1]||i}}function Zi(n){if(n=="window")return window;if(n=="document")return document}function Ji(n){return n.split(":").reduce((t,e)=>Object.assign(t,{[e.replace(/^!/,"")]:!/^!/.test(e)}),{})}function Qi(n){if(n==window)return"window";if(n==document)return"document"}function De(n){return n.replace(/(?:[_-])([a-z0-9])/g,(t,e)=>e.toUpperCase())}function Te(n){return De(n.replace(/--/g,"-").replace(/__/g,"_"))}function _t(n){return n.charAt(0).toUpperCase()+n.slice(1)}function ps(n){return n.replace(/([A-Z])/g,(t,e)=>`-${e.toLowerCase()}`)}function tr(n){return n.match(/[^\s]+/g)||[]}function _n(n){return n!=null}function Oe(n,t){return Object.prototype.hasOwnProperty.call(n,t)}const Bn=["meta","ctrl","alt","shift"];class er{constructor(t,e,s,i){this.element=t,this.index=e,this.eventTarget=s.eventTarget||t,this.eventName=s.eventName||nr(t)||Vt("missing event name"),this.eventOptions=s.eventOptions||{},this.identifier=s.identifier||Vt("missing identifier"),this.methodName=s.methodName||Vt("missing method name"),this.keyFilter=s.keyFilter||"",this.schema=i}static forToken(t,e){return new this(t.element,t.index,Gi(t.content),e)}toString(){const t=this.keyFilter?`.${this.keyFilter}`:"",e=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${t}${e}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(t){if(!this.keyFilter)return!1;const e=this.keyFilter.split("+");if(this.keyFilterDissatisfied(t,e))return!0;const s=e.filter(i=>!Bn.includes(i))[0];return s?(Oe(this.keyMappings,s)||Vt(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[s].toLowerCase()!==t.key.toLowerCase()):!1}shouldIgnoreMouseEvent(t){if(!this.keyFilter)return!1;const e=[this.keyFilter];return!!this.keyFilterDissatisfied(t,e)}get params(){const t={},e=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:s,value:i}of Array.from(this.element.attributes)){const r=s.match(e),o=r&&r[1];o&&(t[De(o)]=sr(i))}return t}get eventTargetName(){return Qi(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(t,e){const[s,i,r,o]=Bn.map(a=>e.includes(a));return t.metaKey!==s||t.ctrlKey!==i||t.altKey!==r||t.shiftKey!==o}}const Pn={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:n=>n.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function nr(n){const t=n.tagName.toLowerCase();if(t in Pn)return Pn[t](n)}function Vt(n){throw new Error(n)}function sr(n){try{return JSON.parse(n)}catch{return n}}class ir{constructor(t,e){this.context=t,this.action=e}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(t){const e=this.prepareActionEvent(t);this.willBeInvokedByEvent(t)&&this.applyEventModifiers(e)&&this.invokeWithEvent(e)}get eventName(){return this.action.eventName}get method(){const t=this.controller[this.methodName];if(typeof t=="function")return t;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(t){const{element:e}=this.action,{actionDescriptorFilters:s}=this.context.application,{controller:i}=this.context;let r=!0;for(const[o,a]of Object.entries(this.eventOptions))if(o in s){const c=s[o];r=r&&c({name:o,value:a,event:t,element:e,controller:i})}else continue;return r}prepareActionEvent(t){return Object.assign(t,{params:this.action.params})}invokeWithEvent(t){const{target:e,currentTarget:s}=t;try{this.method.call(this.controller,t),this.context.logDebugActivity(this.methodName,{event:t,target:e,currentTarget:s,action:this.methodName})}catch(i){const{identifier:r,controller:o,element:a,index:c}=this,l={identifier:r,controller:o,element:a,index:c,event:t};this.context.handleError(i,`invoking action "${this.action}"`,l)}}willBeInvokedByEvent(t){const e=t.target;return t instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(t)||t instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(t)?!1:this.element===e?!0:e instanceof Element&&this.element.contains(e)?this.scope.containsElement(e):this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class gs{constructor(t,e){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=t,this.started=!1,this.delegate=e,this.elements=new Set,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(t){this.started&&(this.mutationObserver.disconnect(),this.started=!1),t(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const t=new Set(this.matchElementsInTree());for(const e of Array.from(this.elements))t.has(e)||this.removeElement(e);for(const e of Array.from(t))this.addElement(e)}}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){t.type=="attributes"?this.processAttributeChange(t.target,t.attributeName):t.type=="childList"&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){this.elements.has(t)?this.delegate.elementAttributeChanged&&this.matchElement(t)?this.delegate.elementAttributeChanged(t,e):this.removeElement(t):this.matchElement(t)&&this.addElement(t)}processRemovedNodes(t){for(const e of Array.from(t)){const s=this.elementFromNode(e);s&&this.processTree(s,this.removeElement)}}processAddedNodes(t){for(const e of Array.from(t)){const s=this.elementFromNode(e);s&&this.elementIsActive(s)&&this.processTree(s,this.addElement)}}matchElement(t){return this.delegate.matchElement(t)}matchElementsInTree(t=this.element){return this.delegate.matchElementsInTree(t)}processTree(t,e){for(const s of this.matchElementsInTree(t))e.call(this,s)}elementFromNode(t){if(t.nodeType==Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected!=this.element.isConnected?!1:this.element.contains(t)}addElement(t){this.elements.has(t)||this.elementIsActive(t)&&(this.elements.add(t),this.delegate.elementMatched&&this.delegate.elementMatched(t))}removeElement(t){this.elements.has(t)&&(this.elements.delete(t),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(t))}}class bs{constructor(t,e,s){this.attributeName=e,this.delegate=s,this.elementObserver=new gs(t,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(t){return t.hasAttribute(this.attributeName)}matchElementsInTree(t){const e=this.matchElement(t)?[t]:[],s=Array.from(t.querySelectorAll(this.selector));return e.concat(s)}elementMatched(t){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(t,this.attributeName)}elementUnmatched(t){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(t,this.attributeName)}elementAttributeChanged(t,e){this.delegate.elementAttributeValueChanged&&this.attributeName==e&&this.delegate.elementAttributeValueChanged(t,e)}}function rr(n,t,e){vs(n,t).add(e)}function or(n,t,e){vs(n,t).delete(e),ar(n,t)}function vs(n,t){let e=n.get(t);return e||(e=new Set,n.set(t,e)),e}function ar(n,t){const e=n.get(t);e!=null&&e.size==0&&n.delete(t)}class Z{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((e,s)=>e.concat(Array.from(s)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((e,s)=>e+s.size,0)}add(t,e){rr(this.valuesByKey,t,e)}delete(t,e){or(this.valuesByKey,t,e)}has(t,e){const s=this.valuesByKey.get(t);return s!=null&&s.has(e)}hasKey(t){return this.valuesByKey.has(t)}hasValue(t){return Array.from(this.valuesByKey.values()).some(s=>s.has(t))}getValuesForKey(t){const e=this.valuesByKey.get(t);return e?Array.from(e):[]}getKeysForValue(t){return Array.from(this.valuesByKey).filter(([e,s])=>s.has(t)).map(([e,s])=>e)}}class cr{constructor(t,e,s,i){this._selector=e,this.details=i,this.elementObserver=new gs(t,this),this.delegate=s,this.matchesByElement=new Z}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(t){this._selector=t,this.refresh()}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(t){const{selector:e}=this;if(e){const s=t.matches(e);return this.delegate.selectorMatchElement?s&&this.delegate.selectorMatchElement(t,this.details):s}else return!1}matchElementsInTree(t){const{selector:e}=this;if(e){const s=this.matchElement(t)?[t]:[],i=Array.from(t.querySelectorAll(e)).filter(r=>this.matchElement(r));return s.concat(i)}else return[]}elementMatched(t){const{selector:e}=this;e&&this.selectorMatched(t,e)}elementUnmatched(t){const e=this.matchesByElement.getKeysForValue(t);for(const s of e)this.selectorUnmatched(t,s)}elementAttributeChanged(t,e){const{selector:s}=this;if(s){const i=this.matchElement(t),r=this.matchesByElement.has(s,t);i&&!r?this.selectorMatched(t,s):!i&&r&&this.selectorUnmatched(t,s)}}selectorMatched(t,e){this.delegate.selectorMatched(t,e,this.details),this.matchesByElement.add(e,t)}selectorUnmatched(t,e){this.delegate.selectorUnmatched(t,e,this.details),this.matchesByElement.delete(e,t)}}class lr{constructor(t,e){this.element=t,this.delegate=e,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const t of this.knownAttributeNames)this.refreshAttribute(t,null)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){const e=t.attributeName;e&&this.refreshAttribute(e,t.oldValue)}refreshAttribute(t,e){const s=this.delegate.getStringMapKeyForAttribute(t);if(s!=null){this.stringMap.has(t)||this.stringMapKeyAdded(s,t);const i=this.element.getAttribute(t);if(this.stringMap.get(t)!=i&&this.stringMapValueChanged(i,s,e),i==null){const r=this.stringMap.get(t);this.stringMap.delete(t),r&&this.stringMapKeyRemoved(s,t,r)}else this.stringMap.set(t,i)}}stringMapKeyAdded(t,e){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(t,e)}stringMapValueChanged(t,e,s){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(t,e,s)}stringMapKeyRemoved(t,e,s){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(t,e,s)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(t=>t.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class ys{constructor(t,e,s){this.attributeObserver=new bs(t,e,this),this.delegate=s,this.tokensByElement=new Z}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(t){this.attributeObserver.pause(t)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(t){this.tokensMatched(this.readTokensForElement(t))}elementAttributeValueChanged(t){const[e,s]=this.refreshTokensForElement(t);this.tokensUnmatched(e),this.tokensMatched(s)}elementUnmatchedAttribute(t){this.tokensUnmatched(this.tokensByElement.getValuesForKey(t))}tokensMatched(t){t.forEach(e=>this.tokenMatched(e))}tokensUnmatched(t){t.forEach(e=>this.tokenUnmatched(e))}tokenMatched(t){this.delegate.tokenMatched(t),this.tokensByElement.add(t.element,t)}tokenUnmatched(t){this.delegate.tokenUnmatched(t),this.tokensByElement.delete(t.element,t)}refreshTokensForElement(t){const e=this.tokensByElement.getValuesForKey(t),s=this.readTokensForElement(t),i=dr(e,s).findIndex(([r,o])=>!hr(r,o));return i==-1?[[],[]]:[e.slice(i),s.slice(i)]}readTokensForElement(t){const e=this.attributeName,s=t.getAttribute(e)||"";return ur(s,t,e)}}function ur(n,t,e){return n.trim().split(/\s+/).filter(s=>s.length).map((s,i)=>({element:t,attributeName:e,content:s,index:i}))}function dr(n,t){const e=Math.max(n.length,t.length);return Array.from({length:e},(s,i)=>[n[i],t[i]])}function hr(n,t){return n&&t&&n.index==t.index&&n.content==t.content}class ws{constructor(t,e,s){this.tokenListObserver=new ys(t,e,this),this.delegate=s,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(t){const{element:e}=t,{value:s}=this.fetchParseResultForToken(t);s&&(this.fetchValuesByTokenForElement(e).set(t,s),this.delegate.elementMatchedValue(e,s))}tokenUnmatched(t){const{element:e}=t,{value:s}=this.fetchParseResultForToken(t);s&&(this.fetchValuesByTokenForElement(e).delete(t),this.delegate.elementUnmatchedValue(e,s))}fetchParseResultForToken(t){let e=this.parseResultsByToken.get(t);return e||(e=this.parseToken(t),this.parseResultsByToken.set(t,e)),e}fetchValuesByTokenForElement(t){let e=this.valuesByTokenByElement.get(t);return e||(e=new Map,this.valuesByTokenByElement.set(t,e)),e}parseToken(t){try{return{value:this.delegate.parseValueForToken(t)}}catch(e){return{error:e}}}}class fr{constructor(t,e){this.context=t,this.delegate=e,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new ws(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(t){const e=new ir(this.context,t);this.bindingsByAction.set(t,e),this.delegate.bindingConnected(e)}disconnectAction(t){const e=this.bindingsByAction.get(t);e&&(this.bindingsByAction.delete(t),this.delegate.bindingDisconnected(e))}disconnectAllActions(){this.bindings.forEach(t=>this.delegate.bindingDisconnected(t,!0)),this.bindingsByAction.clear()}parseValueForToken(t){const e=er.forToken(t,this.schema);if(e.identifier==this.identifier)return e}elementMatchedValue(t,e){this.connectAction(e)}elementUnmatchedValue(t,e){this.disconnectAction(e)}}class mr{constructor(t,e){this.context=t,this.receiver=e,this.stringMapObserver=new lr(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(t){if(t in this.valueDescriptorMap)return this.valueDescriptorMap[t].name}stringMapKeyAdded(t,e){const s=this.valueDescriptorMap[e];this.hasValue(t)||this.invokeChangedCallback(t,s.writer(this.receiver[t]),s.writer(s.defaultValue))}stringMapValueChanged(t,e,s){const i=this.valueDescriptorNameMap[e];t!==null&&(s===null&&(s=i.writer(i.defaultValue)),this.invokeChangedCallback(e,t,s))}stringMapKeyRemoved(t,e,s){const i=this.valueDescriptorNameMap[t];this.hasValue(t)?this.invokeChangedCallback(t,i.writer(this.receiver[t]),s):this.invokeChangedCallback(t,i.writer(i.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(const{key:t,name:e,defaultValue:s,writer:i}of this.valueDescriptors)s!=null&&!this.controller.data.has(t)&&this.invokeChangedCallback(e,i(s),void 0)}invokeChangedCallback(t,e,s){const i=`${t}Changed`,r=this.receiver[i];if(typeof r=="function"){const o=this.valueDescriptorNameMap[t];try{const a=o.reader(e);let c=s;s&&(c=o.reader(s)),r.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(){const{valueDescriptorMap:t}=this;return Object.keys(t).map(e=>t[e])}get valueDescriptorNameMap(){const t={};return Object.keys(this.valueDescriptorMap).forEach(e=>{const s=this.valueDescriptorMap[e];t[s.name]=s}),t}hasValue(t){const e=this.valueDescriptorNameMap[t],s=`has${_t(e.name)}`;return this.receiver[s]}}class pr{constructor(t,e){this.context=t,this.delegate=e,this.targetsByName=new Z}start(){this.tokenListObserver||(this.tokenListObserver=new ys(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:t,content:e}){this.scope.containsElement(t)&&this.connectTarget(t,e)}tokenUnmatched({element:t,content:e}){this.disconnectTarget(t,e)}connectTarget(t,e){var s;this.targetsByName.has(e,t)||(this.targetsByName.add(e,t),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetConnected(t,e)))}disconnectTarget(t,e){var s;this.targetsByName.has(e,t)&&(this.targetsByName.delete(e,t),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetDisconnected(t,e)))}disconnectAllTargets(){for(const t of this.targetsByName.keys)for(const e of this.targetsByName.getValuesForKey(t))this.disconnectTarget(e,t)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function Bt(n,t){const e=Es(n);return Array.from(e.reduce((s,i)=>(br(i,t).forEach(r=>s.add(r)),s),new Set))}function gr(n,t){return Es(n).reduce((s,i)=>(s.push(...vr(i,t)),s),[])}function Es(n){const t=[];for(;n;)t.push(n),n=Object.getPrototypeOf(n);return t.reverse()}function br(n,t){const e=n[t];return Array.isArray(e)?e:[]}function vr(n,t){const e=n[t];return e?Object.keys(e).map(s=>[s,e[s]]):[]}class yr{constructor(t,e){this.started=!1,this.context=t,this.delegate=e,this.outletsByName=new Z,this.outletElementsByName=new Z,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(t=>{this.setupSelectorObserverForOutlet(t),this.setupAttributeObserverForOutlet(t)}),this.started=!0,this.dependentContexts.forEach(t=>t.refresh()))}refresh(){this.selectorObserverMap.forEach(t=>t.refresh()),this.attributeObserverMap.forEach(t=>t.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(t=>t.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(t=>t.stop()),this.attributeObserverMap.clear())}selectorMatched(t,e,{outletName:s}){const i=this.getOutlet(t,s);i&&this.connectOutlet(i,t,s)}selectorUnmatched(t,e,{outletName:s}){const i=this.getOutletFromMap(t,s);i&&this.disconnectOutlet(i,t,s)}selectorMatchElement(t,{outletName:e}){const s=this.selector(e),i=this.hasOutlet(t,e),r=t.matches(`[${this.schema.controllerAttribute}~=${e}]`);return s?i&&r&&t.matches(s):!1}elementMatchedAttribute(t,e){const s=this.getOutletNameFromOutletAttributeName(e);s&&this.updateSelectorObserverForOutlet(s)}elementAttributeValueChanged(t,e){const s=this.getOutletNameFromOutletAttributeName(e);s&&this.updateSelectorObserverForOutlet(s)}elementUnmatchedAttribute(t,e){const s=this.getOutletNameFromOutletAttributeName(e);s&&this.updateSelectorObserverForOutlet(s)}connectOutlet(t,e,s){var i;this.outletElementsByName.has(s,e)||(this.outletsByName.add(s,t),this.outletElementsByName.add(s,e),(i=this.selectorObserverMap.get(s))===null||i===void 0||i.pause(()=>this.delegate.outletConnected(t,e,s)))}disconnectOutlet(t,e,s){var i;this.outletElementsByName.has(s,e)&&(this.outletsByName.delete(s,t),this.outletElementsByName.delete(s,e),(i=this.selectorObserverMap.get(s))===null||i===void 0||i.pause(()=>this.delegate.outletDisconnected(t,e,s)))}disconnectAllOutlets(){for(const t of this.outletElementsByName.keys)for(const e of this.outletElementsByName.getValuesForKey(t))for(const s of this.outletsByName.getValuesForKey(t))this.disconnectOutlet(s,e,t)}updateSelectorObserverForOutlet(t){const e=this.selectorObserverMap.get(t);e&&(e.selector=this.selector(t))}setupSelectorObserverForOutlet(t){const e=this.selector(t),s=new cr(document.body,e,this,{outletName:t});this.selectorObserverMap.set(t,s),s.start()}setupAttributeObserverForOutlet(t){const e=this.attributeNameForOutletName(t),s=new bs(this.scope.element,e,this);this.attributeObserverMap.set(t,s),s.start()}selector(t){return this.scope.outlets.getSelectorForOutletName(t)}attributeNameForOutletName(t){return this.scope.schema.outletAttributeForScope(this.identifier,t)}getOutletNameFromOutletAttributeName(t){return this.outletDefinitions.find(e=>this.attributeNameForOutletName(e)===t)}get outletDependencies(){const t=new Z;return this.router.modules.forEach(e=>{const s=e.definition.controllerConstructor;Bt(s,"outlets").forEach(r=>t.add(r,e.identifier))}),t}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const t=this.dependentControllerIdentifiers;return this.router.contexts.filter(e=>t.includes(e.identifier))}hasOutlet(t,e){return!!this.getOutlet(t,e)||!!this.getOutletFromMap(t,e)}getOutlet(t,e){return this.application.getControllerForElementAndIdentifier(t,e)}getOutletFromMap(t,e){return this.outletsByName.getValuesForKey(e).find(s=>s.element===t)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class wr{constructor(t,e){this.logDebugActivity=(s,i={})=>{const{identifier:r,controller:o,element:a}=this;i=Object.assign({identifier:r,controller:o,element:a},i),this.application.logDebugActivity(this.identifier,s,i)},this.module=t,this.scope=e,this.controller=new t.controllerConstructor(this),this.bindingObserver=new fr(this,this.dispatcher),this.valueObserver=new mr(this,this.controller),this.targetObserver=new pr(this,this),this.outletObserver=new yr(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(s){this.handleError(s,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(t){this.handleError(t,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(t){this.handleError(t,"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(t,e,s={}){const{identifier:i,controller:r,element:o}=this;s=Object.assign({identifier:i,controller:r,element:o},s),this.application.handleError(t,`Error ${e}`,s)}targetConnected(t,e){this.invokeControllerMethod(`${e}TargetConnected`,t)}targetDisconnected(t,e){this.invokeControllerMethod(`${e}TargetDisconnected`,t)}outletConnected(t,e,s){this.invokeControllerMethod(`${Te(s)}OutletConnected`,t,e)}outletDisconnected(t,e,s){this.invokeControllerMethod(`${Te(s)}OutletDisconnected`,t,e)}invokeControllerMethod(t,...e){const s=this.controller;typeof s[t]=="function"&&s[t](...e)}}function Er(n){return Ar(n,xr(n))}function Ar(n,t){const e=Mr(n),s=Tr(n.prototype,t);return Object.defineProperties(e.prototype,s),e}function xr(n){return Bt(n,"blessings").reduce((e,s)=>{const i=s(n);for(const r in i){const o=e[r]||{};e[r]=Object.assign(o,i[r])}return e},{})}function Tr(n,t){return kr(t).reduce((e,s)=>{const i=Or(n,t,s);return i&&Object.assign(e,{[s]:i}),e},{})}function Or(n,t,e){const s=Object.getOwnPropertyDescriptor(n,e);if(!(s&&"value"in s)){const r=Object.getOwnPropertyDescriptor(t,e).value;return s&&(r.get=s.get||r.get,r.set=s.set||r.set),r}}const kr=typeof Object.getOwnPropertySymbols=="function"?n=>[...Object.getOwnPropertyNames(n),...Object.getOwnPropertySymbols(n)]:Object.getOwnPropertyNames,Mr=(()=>{function n(e){function s(){return Reflect.construct(e,arguments,new.target)}return s.prototype=Object.create(e.prototype,{constructor:{value:s}}),Reflect.setPrototypeOf(s,e),s}function t(){const s=n(function(){this.a.call(this)});return s.prototype.a=function(){},new s}try{return t(),n}catch{return s=>class extends s{}}})();function Sr(n){return{identifier:n.identifier,controllerConstructor:Er(n.controllerConstructor)}}class Cr{constructor(t,e){this.application=t,this.definition=Sr(e),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(t){const e=this.fetchContextForScope(t);this.connectedContexts.add(e),e.connect()}disconnectContextForScope(t){const e=this.contextsByScope.get(t);e&&(this.connectedContexts.delete(e),e.disconnect())}fetchContextForScope(t){let e=this.contextsByScope.get(t);return e||(e=new wr(this,t),this.contextsByScope.set(t,e)),e}}class Lr{constructor(t){this.scope=t}has(t){return this.data.has(this.getDataKey(t))}get(t){return this.getAll(t)[0]}getAll(t){const e=this.data.get(this.getDataKey(t))||"";return tr(e)}getAttributeName(t){return this.data.getAttributeNameForKey(this.getDataKey(t))}getDataKey(t){return`${t}-class`}get data(){return this.scope.data}}class Fr{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(t){const e=this.getAttributeNameForKey(t);return this.element.getAttribute(e)}set(t,e){const s=this.getAttributeNameForKey(t);return this.element.setAttribute(s,e),this.get(t)}has(t){const e=this.getAttributeNameForKey(t);return this.element.hasAttribute(e)}delete(t){if(this.has(t)){const e=this.getAttributeNameForKey(t);return this.element.removeAttribute(e),!0}else return!1}getAttributeNameForKey(t){return`data-${this.identifier}-${ps(t)}`}}class Dr{constructor(t){this.warnedKeysByObject=new WeakMap,this.logger=t}warn(t,e,s){let i=this.warnedKeysByObject.get(t);i||(i=new Set,this.warnedKeysByObject.set(t,i)),i.has(e)||(i.add(e),this.logger.warn(s,t))}}function ke(n,t){return`[${n}~="${t}"]`}class _r{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return this.find(t)!=null}find(...t){return t.reduce((e,s)=>e||this.findTarget(s)||this.findLegacyTarget(s),void 0)}findAll(...t){return t.reduce((e,s)=>[...e,...this.findAllTargets(s),...this.findAllLegacyTargets(s)],[])}findTarget(t){const e=this.getSelectorForTargetName(t);return this.scope.findElement(e)}findAllTargets(t){const e=this.getSelectorForTargetName(t);return this.scope.findAllElements(e)}getSelectorForTargetName(t){const e=this.schema.targetAttributeForScope(this.identifier);return ke(e,t)}findLegacyTarget(t){const e=this.getLegacySelectorForTargetName(t);return this.deprecate(this.scope.findElement(e),t)}findAllLegacyTargets(t){const e=this.getLegacySelectorForTargetName(t);return this.scope.findAllElements(e).map(s=>this.deprecate(s,t))}getLegacySelectorForTargetName(t){const e=`${this.identifier}.${t}`;return ke(this.schema.targetAttribute,e)}deprecate(t,e){if(t){const{identifier:s}=this,i=this.schema.targetAttribute,r=this.schema.targetAttributeForScope(s);this.guide.warn(t,`target:${e}`,`Please replace ${i}="${s}.${e}" with ${r}="${e}". The ${i} attribute is deprecated and will be removed in a future version of Stimulus.`)}return t}get guide(){return this.scope.guide}}class Br{constructor(t,e){this.scope=t,this.controllerElement=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return this.find(t)!=null}find(...t){return t.reduce((e,s)=>e||this.findOutlet(s),void 0)}findAll(...t){return t.reduce((e,s)=>[...e,...this.findAllOutlets(s)],[])}getSelectorForOutletName(t){const e=this.schema.outletAttributeForScope(this.identifier,t);return this.controllerElement.getAttribute(e)}findOutlet(t){const e=this.getSelectorForOutletName(t);if(e)return this.findElement(e,t)}findAllOutlets(t){const e=this.getSelectorForOutletName(t);return e?this.findAllElements(e,t):[]}findElement(t,e){return this.scope.queryElements(t).filter(i=>this.matchesElement(i,t,e))[0]}findAllElements(t,e){return this.scope.queryElements(t).filter(i=>this.matchesElement(i,t,e))}matchesElement(t,e,s){const i=t.getAttribute(this.scope.schema.controllerAttribute)||"";return t.matches(e)&&i.split(" ").includes(s)}}class _e{constructor(t,e,s,i){this.targets=new _r(this),this.classes=new Lr(this),this.data=new Fr(this),this.containsElement=r=>r.closest(this.controllerSelector)===this.element,this.schema=t,this.element=e,this.identifier=s,this.guide=new Dr(i),this.outlets=new Br(this.documentScope,e)}findElement(t){return this.element.matches(t)?this.element:this.queryElements(t).find(this.containsElement)}findAllElements(t){return[...this.element.matches(t)?[this.element]:[],...this.queryElements(t).filter(this.containsElement)]}queryElements(t){return Array.from(this.element.querySelectorAll(t))}get controllerSelector(){return ke(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new _e(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class Pr{constructor(t,e,s){this.element=t,this.schema=e,this.delegate=s,this.valueListObserver=new ws(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(t){const{element:e,content:s}=t;return this.parseValueForElementAndIdentifier(e,s)}parseValueForElementAndIdentifier(t,e){const s=this.fetchScopesByIdentifierForElement(t);let i=s.get(e);return i||(i=this.delegate.createScopeForElementAndIdentifier(t,e),s.set(e,i)),i}elementMatchedValue(t,e){const s=(this.scopeReferenceCounts.get(e)||0)+1;this.scopeReferenceCounts.set(e,s),s==1&&this.delegate.scopeConnected(e)}elementUnmatchedValue(t,e){const s=this.scopeReferenceCounts.get(e);s&&(this.scopeReferenceCounts.set(e,s-1),s==1&&this.delegate.scopeDisconnected(e))}fetchScopesByIdentifierForElement(t){let e=this.scopesByIdentifierByElement.get(t);return e||(e=new Map,this.scopesByIdentifierByElement.set(t,e)),e}}class Rr{constructor(t){this.application=t,this.scopeObserver=new Pr(this.element,this.schema,this),this.scopesByIdentifier=new Z,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((t,e)=>t.concat(e.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(t){this.unloadIdentifier(t.identifier);const e=new Cr(this.application,t);this.connectModule(e);const s=t.controllerConstructor.afterLoad;s&&s.call(t.controllerConstructor,t.identifier,this.application)}unloadIdentifier(t){const e=this.modulesByIdentifier.get(t);e&&this.disconnectModule(e)}getContextForElementAndIdentifier(t,e){const s=this.modulesByIdentifier.get(e);if(s)return s.contexts.find(i=>i.element==t)}proposeToConnectScopeForElementAndIdentifier(t,e){const s=this.scopeObserver.parseValueForElementAndIdentifier(t,e);s?this.scopeObserver.elementMatchedValue(s.element,s):console.error(`Couldn't find or create scope for identifier: "${e}" and element:`,t)}handleError(t,e,s){this.application.handleError(t,e,s)}createScopeForElementAndIdentifier(t,e){return new _e(this.schema,t,e,this.logger)}scopeConnected(t){this.scopesByIdentifier.add(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.connectContextForScope(t)}scopeDisconnected(t){this.scopesByIdentifier.delete(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.disconnectContextForScope(t)}connectModule(t){this.modulesByIdentifier.set(t.identifier,t),this.scopesByIdentifier.getValuesForKey(t.identifier).forEach(s=>t.connectContextForScope(s))}disconnectModule(t){this.modulesByIdentifier.delete(t.identifier),this.scopesByIdentifier.getValuesForKey(t.identifier).forEach(s=>t.disconnectContextForScope(s))}}const $r={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:n=>`data-${n}-target`,outletAttributeForScope:(n,t)=>`data-${n}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},Rn("abcdefghijklmnopqrstuvwxyz".split("").map(n=>[n,n]))),Rn("0123456789".split("").map(n=>[n,n])))};function Rn(n){return n.reduce((t,[e,s])=>Object.assign(Object.assign({},t),{[e]:s}),{})}class Ir{constructor(t=document.documentElement,e=$r){this.logger=console,this.debug=!1,this.logDebugActivity=(s,i,r={})=>{this.debug&&this.logFormattedMessage(s,i,r)},this.element=t,this.schema=e,this.dispatcher=new zi(this),this.router=new Rr(this),this.actionDescriptorFilters=Object.assign({},Yi)}static start(t,e){const s=new this(t,e);return s.start(),s}async start(){await Nr(),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(t,e){this.load({identifier:t,controllerConstructor:e})}registerActionOption(t,e){this.actionDescriptorFilters[t]=e}load(t,...e){(Array.isArray(t)?t:[t,...e]).forEach(i=>{i.controllerConstructor.shouldLoad&&this.router.loadDefinition(i)})}unload(t,...e){(Array.isArray(t)?t:[t,...e]).forEach(i=>this.router.unloadIdentifier(i))}get controllers(){return this.router.contexts.map(t=>t.controller)}getControllerForElementAndIdentifier(t,e){const s=this.router.getContextForElementAndIdentifier(t,e);return s?s.controller:null}handleError(t,e,s){var i;this.logger.error(`%s
92
+ `),processed:s}}function bt(n,t){return t?"- ":`${n+1}. `}function Pi(n,t){let e,s,i;return n.orderedList?(s=Ln(t),e=Fn(s.text),i=e.text):(s=Fn(t),e=Ln(s.text),i=e.text),[s,e,i]}function Ri(n,t){const e=n.selectionStart===n.selectionEnd;let s=n.selectionStart,i=n.selectionEnd;Di(n);const r=n.value.slice(n.selectionStart,n.selectionEnd),[o,a,c]=Pi(t,r),l=c.split(`
93
+ `).map((m,b)=>`${bt(b,t.unorderedList)}${m}`),u=l.reduce((m,b,p)=>m+bt(p,t.unorderedList).length,0),d=l.reduce((m,b,p)=>m+bt(p,!t.unorderedList).length,0);if(o.processed)return e?(s=Math.max(s-bt(0,t.unorderedList).length,0),i=s):(s=n.selectionStart,i=n.selectionEnd-u),{text:c,selectionStart:s,selectionEnd:i};const{newlinesToAppend:h,newlinesToPrepend:g}=$e(n),f=h+l.join(`
94
+ `)+g;return e?(s=Math.max(s+bt(0,t.unorderedList).length+h.length,0),i=s):a.processed?(s=Math.max(n.selectionStart+h.length,0),i=n.selectionEnd+h.length+u-d):(s=Math.max(n.selectionStart+h.length,0),i=n.selectionEnd+h.length+u),{text:f,selectionStart:s,selectionEnd:i}}function Oe(n,t){const e=n.closest("markdown-toolbar");if(!(e instanceof qt))return;const i=Object.assign(Object.assign({},{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}),t),r=e.field;r&&(r.focus(),Fi(r,i))}var Ii=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},Dn=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},xt;class Ni{formatToParts(t){const e=[];for(const s of t)e.push({type:"element",value:s}),e.push({type:"literal",value:", "});return e.slice(0,-1)}}const ji=typeof Intl<"u"&&Intl.ListFormat||Ni,Hi=[["years","year"],["months","month"],["weeks","week"],["days","day"],["hours","hour"],["minutes","minute"],["seconds","second"],["milliseconds","millisecond"]],Vi={minimumIntegerDigits:2};class Wi{constructor(t,e={}){xt.set(this,void 0);let s=String(e.style||"short");s!=="long"&&s!=="short"&&s!=="narrow"&&s!=="digital"&&(s="short");let i=s==="digital"?"numeric":s;const r=e.hours||i;i=r==="2-digit"?"numeric":r;const o=e.minutes||i;i=o==="2-digit"?"numeric":o;const a=e.seconds||i;i=a==="2-digit"?"numeric":a;const c=e.milliseconds||i;Ii(this,xt,{locale:t,style:s,years:e.years||s==="digital"?"short":s,yearsDisplay:e.yearsDisplay==="always"?"always":"auto",months:e.months||s==="digital"?"short":s,monthsDisplay:e.monthsDisplay==="always"?"always":"auto",weeks:e.weeks||s==="digital"?"short":s,weeksDisplay:e.weeksDisplay==="always"?"always":"auto",days:e.days||s==="digital"?"short":s,daysDisplay:e.daysDisplay==="always"?"always":"auto",hours:r,hoursDisplay:e.hoursDisplay==="always"||s==="digital"?"always":"auto",minutes:o,minutesDisplay:e.minutesDisplay==="always"||s==="digital"?"always":"auto",seconds:a,secondsDisplay:e.secondsDisplay==="always"||s==="digital"?"always":"auto",milliseconds:c,millisecondsDisplay:e.millisecondsDisplay==="always"?"always":"auto"},"f")}resolvedOptions(){return Dn(this,xt,"f")}formatToParts(t){const e=[],s=Dn(this,xt,"f"),i=s.style,r=s.locale;for(const[o,a]of Hi){const c=t[o];if(s[`${o}Display`]==="auto"&&!c)continue;const l=s[o],u=l==="2-digit"?Vi:l==="numeric"?{}:{style:"unit",unit:a,unitDisplay:l};e.push(new Intl.NumberFormat(r,u).format(c))}return new ji(r,{type:"unit",style:i==="digital"?"short":i}).formatToParts(e)}format(t){return this.formatToParts(t).map(e=>e.value).join("")}}xt=new WeakMap;const fs=/^[-+]?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,zt=["year","month","week","day","hour","minute","second","millisecond"],Ki=n=>fs.test(n);class M{constructor(t=0,e=0,s=0,i=0,r=0,o=0,a=0,c=0){this.years=t,this.months=e,this.weeks=s,this.days=i,this.hours=r,this.minutes=o,this.seconds=a,this.milliseconds=c,this.years||(this.years=0),this.sign||(this.sign=Math.sign(this.years)),this.months||(this.months=0),this.sign||(this.sign=Math.sign(this.months)),this.weeks||(this.weeks=0),this.sign||(this.sign=Math.sign(this.weeks)),this.days||(this.days=0),this.sign||(this.sign=Math.sign(this.days)),this.hours||(this.hours=0),this.sign||(this.sign=Math.sign(this.hours)),this.minutes||(this.minutes=0),this.sign||(this.sign=Math.sign(this.minutes)),this.seconds||(this.seconds=0),this.sign||(this.sign=Math.sign(this.seconds)),this.milliseconds||(this.milliseconds=0),this.sign||(this.sign=Math.sign(this.milliseconds)),this.blank=this.sign===0}abs(){return new M(Math.abs(this.years),Math.abs(this.months),Math.abs(this.weeks),Math.abs(this.days),Math.abs(this.hours),Math.abs(this.minutes),Math.abs(this.seconds),Math.abs(this.milliseconds))}static from(t){var e;if(typeof t=="string"){const s=String(t).trim(),i=s.startsWith("-")?-1:1,r=(e=s.match(fs))===null||e===void 0?void 0:e.slice(1).map(o=>(Number(o)||0)*i);return r?new M(...r):new M}else if(typeof t=="object"){const{years:s,months:i,weeks:r,days:o,hours:a,minutes:c,seconds:l,milliseconds:u}=t;return new M(s,i,r,o,a,c,l,u)}throw new RangeError("invalid duration")}static compare(t,e){const s=Date.now(),i=Math.abs(_n(s,M.from(t)).getTime()-s),r=Math.abs(_n(s,M.from(e)).getTime()-s);return i>r?-1:i<r?1:0}toLocaleString(t,e){return new Wi(t,e).format(this)}}function _n(n,t){const e=new Date(n);return e.setFullYear(e.getFullYear()+t.years),e.setMonth(e.getMonth()+t.months),e.setDate(e.getDate()+t.weeks*7+t.days),e.setHours(e.getHours()+t.hours),e.setMinutes(e.getMinutes()+t.minutes),e.setSeconds(e.getSeconds()+t.seconds),e}function Ui(n,t="second",e=Date.now()){const s=n.getTime()-e;if(s===0)return new M;const i=Math.sign(s),r=Math.abs(s),o=Math.floor(r/1e3),a=Math.floor(o/60),c=Math.floor(a/60),l=Math.floor(c/24),u=Math.floor(l/30),d=Math.floor(u/12),h=zt.indexOf(t)||zt.length;return new M(h>=0?d*i:0,h>=1?(u-d*12)*i:0,0,h>=3?(l-u*30)*i:0,h>=4?(c-l*24)*i:0,h>=5?(a-c*60)*i:0,h>=6?(o-a*60)*i:0,h>=7?(r-o*1e3)*i:0)}function ms(n,{relativeTo:t=Date.now()}={}){if(t=new Date(t),n.blank)return n;const e=n.sign;let s=Math.abs(n.years),i=Math.abs(n.months),r=Math.abs(n.weeks),o=Math.abs(n.days),a=Math.abs(n.hours),c=Math.abs(n.minutes),l=Math.abs(n.seconds),u=Math.abs(n.milliseconds);u>=900&&(l+=Math.round(u/1e3)),(l||c||a||o||r||i||s)&&(u=0),l>=55&&(c+=Math.round(l/60)),(c||a||o||r||i||s)&&(l=0),c>=55&&(a+=Math.round(c/60)),(a||o||r||i||s)&&(c=0),o&&a>=12&&(o+=Math.round(a/24)),!o&&a>=21&&(o+=Math.round(a/24)),(o||r||i||s)&&(a=0);const d=t.getFullYear();let h=t.getMonth();const g=t.getDate();if(o>=27||s+i+o){const f=new Date(t);f.setFullYear(d+s*e),f.setMonth(h+i*e),f.setDate(g+o*e);const m=f.getFullYear()-t.getFullYear(),b=f.getMonth()-t.getMonth(),p=Math.abs(Math.round((Number(f)-Number(t))/864e5)),v=Math.abs(m*12+b);p<27?(o>=6?(r+=Math.round(o/7),o=0):o=p,i=s=0):v<11?(i=v,s=0):(i=0,s=m*e),(i||s)&&(o=0),h=t.getMonth()}return s&&(i=0),r>=4&&(i+=Math.round(r/4)),(i||s)&&(r=0),o&&r&&!i&&!s&&(r+=Math.round(o/7),o=0),new M(s*e,i*e,r*e,o*e,a*e,c*e,l*e,u*e)}function qi(n,t){const e=ms(n,t);if(e.blank)return[0,"second"];for(const s of zt){if(s==="millisecond")continue;const i=e[`${s}s`];if(i)return[i,s]}return[0,"second"]}var A=function(n,t,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(n):s?s.value:t.get(n)},Ht=function(n,t,e,s,i){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?i.call(n,e):i?i.value=e:t.set(n,e),e},F,Tt,Ot,vt,X,ke,ps,gs,bs,vs,ot;const zi=globalThis.HTMLElement||null,pe=new M,Bn=new M(0,0,0,0,0,1);class Yi extends Event{constructor(t,e,s,i){super("relative-time-updated",{bubbles:!0,composed:!0}),this.oldText=t,this.newText=e,this.oldTitle=s,this.newTitle=i}}function $n(n){if(!n.date)return 1/0;if(n.format==="duration"||n.format==="elapsed"){const e=n.precision;if(e==="second")return 1e3;if(e==="minute")return 60*1e3}const t=Math.abs(Date.now()-n.date.getTime());return t<60*1e3?1e3:t<60*60*1e3?60*1e3:60*60*1e3}const ge=new class{constructor(){this.elements=new Set,this.time=1/0,this.timer=-1}observe(n){if(this.elements.has(n))return;this.elements.add(n);const t=n.date;if(t&&t.getTime()){const e=$n(n),s=Date.now()+e;s<this.time&&(clearTimeout(this.timer),this.timer=setTimeout(()=>this.update(),e),this.time=s)}}unobserve(n){this.elements.has(n)&&this.elements.delete(n)}update(){if(clearTimeout(this.timer),!this.elements.size)return;let n=1/0;for(const t of this.elements)n=Math.min(n,$n(t)),t.update();this.time=Math.min(60*60*1e3,n),this.timer=setTimeout(()=>this.update(),this.time),this.time+=Date.now()}};class Xi extends zi{constructor(){super(...arguments),F.add(this),Tt.set(this,!1),Ot.set(this,!1),X.set(this,this.shadowRoot?this.shadowRoot:this.attachShadow?this.attachShadow({mode:"open"}):this),ot.set(this,null)}static define(t="relative-time",e=customElements){return e.define(t,this),this}static get observedAttributes(){return["second","minute","hour","weekday","day","month","year","time-zone-name","prefix","threshold","tense","precision","format","format-style","datetime","lang","title"]}get onRelativeTimeUpdated(){return A(this,ot,"f")}set onRelativeTimeUpdated(t){A(this,ot,"f")&&this.removeEventListener("relative-time-updated",A(this,ot,"f")),Ht(this,ot,typeof t=="object"||typeof t=="function"?t:null,"f"),typeof t=="function"&&this.addEventListener("relative-time-updated",t)}get second(){const t=this.getAttribute("second");if(t==="numeric"||t==="2-digit")return t}set second(t){this.setAttribute("second",t||"")}get minute(){const t=this.getAttribute("minute");if(t==="numeric"||t==="2-digit")return t}set minute(t){this.setAttribute("minute",t||"")}get hour(){const t=this.getAttribute("hour");if(t==="numeric"||t==="2-digit")return t}set hour(t){this.setAttribute("hour",t||"")}get weekday(){const t=this.getAttribute("weekday");if(t==="long"||t==="short"||t==="narrow")return t;if(this.format==="datetime"&&t!=="")return this.formatStyle}set weekday(t){this.setAttribute("weekday",t||"")}get day(){var t;const e=(t=this.getAttribute("day"))!==null&&t!==void 0?t:"numeric";if(e==="numeric"||e==="2-digit")return e}set day(t){this.setAttribute("day",t||"")}get month(){const t=this.format;let e=this.getAttribute("month");if(e!==""&&(e??(e=t==="datetime"?this.formatStyle:"short"),e==="numeric"||e==="2-digit"||e==="short"||e==="long"||e==="narrow"))return e}set month(t){this.setAttribute("month",t||"")}get year(){var t;const e=this.getAttribute("year");if(e==="numeric"||e==="2-digit")return e;if(!this.hasAttribute("year")&&new Date().getUTCFullYear()!==((t=this.date)===null||t===void 0?void 0:t.getUTCFullYear()))return"numeric"}set year(t){this.setAttribute("year",t||"")}get timeZoneName(){const t=this.getAttribute("time-zone-name");if(t==="long"||t==="short"||t==="shortOffset"||t==="longOffset"||t==="shortGeneric"||t==="longGeneric")return t}set timeZoneName(t){this.setAttribute("time-zone-name",t||"")}get prefix(){var t;return(t=this.getAttribute("prefix"))!==null&&t!==void 0?t:this.format==="datetime"?"":"on"}set prefix(t){this.setAttribute("prefix",t)}get threshold(){const t=this.getAttribute("threshold");return t&&Ki(t)?t:"P30D"}set threshold(t){this.setAttribute("threshold",t)}get tense(){const t=this.getAttribute("tense");return t==="past"?"past":t==="future"?"future":"auto"}set tense(t){this.setAttribute("tense",t)}get precision(){const t=this.getAttribute("precision");return zt.includes(t)?t:this.format==="micro"?"minute":"second"}set precision(t){this.setAttribute("precision",t)}get format(){const t=this.getAttribute("format");return t==="datetime"?"datetime":t==="relative"?"relative":t==="duration"?"duration":t==="micro"?"micro":t==="elapsed"?"elapsed":"auto"}set format(t){this.setAttribute("format",t)}get formatStyle(){const t=this.getAttribute("format-style");if(t==="long")return"long";if(t==="short")return"short";if(t==="narrow")return"narrow";const e=this.format;return e==="elapsed"||e==="micro"?"narrow":e==="datetime"?"short":"long"}set formatStyle(t){this.setAttribute("format-style",t)}get datetime(){return this.getAttribute("datetime")||""}set datetime(t){this.setAttribute("datetime",t)}get date(){const t=Date.parse(this.datetime);return Number.isNaN(t)?null:new Date(t)}set date(t){this.datetime=(t==null?void 0:t.toISOString())||""}connectedCallback(){this.update()}disconnectedCallback(){ge.unobserve(this)}attributeChangedCallback(t,e,s){e!==s&&(t==="title"&&Ht(this,Tt,s!==null&&(this.date&&A(this,F,"m",ke).call(this,this.date))!==s,"f"),!A(this,Ot,"f")&&!(t==="title"&&A(this,Tt,"f"))&&Ht(this,Ot,(async()=>{await Promise.resolve(),this.update()})(),"f"))}update(){const t=A(this,X,"f").textContent||this.textContent||"",e=this.getAttribute("title")||"";let s=e;const i=this.date;if(typeof Intl>"u"||!Intl.DateTimeFormat||!i){A(this,X,"f").textContent=t;return}const r=Date.now();A(this,Tt,"f")||(s=A(this,F,"m",ke).call(this,i)||"",s&&this.setAttribute("title",s));const o=Ui(i,this.precision,r),a=A(this,F,"m",ps).call(this,o);let c=t;a==="duration"?c=A(this,F,"m",gs).call(this,o):a==="relative"?c=A(this,F,"m",bs).call(this,o):c=A(this,F,"m",vs).call(this,i),c?A(this,X,"f").textContent=c:this.shadowRoot===A(this,X,"f")&&this.textContent&&(A(this,X,"f").textContent=this.textContent),(c!==t||s!==e)&&this.dispatchEvent(new Yi(t,c,e,s)),a==="relative"||a==="duration"?ge.observe(this):ge.unobserve(this),Ht(this,Ot,!1,"f")}}Tt=new WeakMap,Ot=new WeakMap,X=new WeakMap,ot=new WeakMap,F=new WeakSet,vt=function(){var t;return((t=this.closest("[lang]"))===null||t===void 0?void 0:t.getAttribute("lang"))||this.ownerDocument.documentElement.getAttribute("lang")||"default"},ke=function(t){return new Intl.DateTimeFormat(A(this,F,"a",vt),{day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)},ps=function(t){const e=this.format;if(e==="datetime")return"datetime";if(e==="duration"||e==="elapsed"||e==="micro")return"duration";if((e==="auto"||e==="relative")&&typeof Intl<"u"&&Intl.RelativeTimeFormat){const s=this.tense;if(s==="past"||s==="future"||M.compare(t,this.threshold)===1)return"relative"}return"datetime"},gs=function(t){const e=A(this,F,"a",vt),s=this.format,i=this.formatStyle,r=this.tense;let o=pe;s==="micro"?(t=ms(t),o=Bn,(this.tense==="past"&&t.sign!==-1||this.tense==="future"&&t.sign!==1)&&(t=Bn)):(r==="past"&&t.sign!==-1||r==="future"&&t.sign!==1)&&(t=o);const a=`${this.precision}sDisplay`;return t.blank?o.toLocaleString(e,{style:i,[a]:"always"}):t.abs().toLocaleString(e,{style:i})},bs=function(t){const e=new Intl.RelativeTimeFormat(A(this,F,"a",vt),{numeric:"auto",style:this.formatStyle}),s=this.tense;s==="future"&&t.sign!==1&&(t=pe),s==="past"&&t.sign!==-1&&(t=pe);const[i,r]=qi(t);return r==="second"&&i<10?e.format(0,this.precision==="millisecond"?"second":this.precision):e.format(i,r)},vs=function(t){const e=new Intl.DateTimeFormat(A(this,F,"a",vt),{second:this.second,minute:this.minute,hour:this.hour,weekday:this.weekday,day:this.day,month:this.month,year:this.year,timeZoneName:this.timeZoneName});return`${this.prefix} ${e.format(t)}`.trim()};const Pn=typeof globalThis<"u"?globalThis:window;try{Pn.RelativeTimeElement=Xi.define()}catch(n){if(!(Pn.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}localStorage.getItem("theme");window.matchMedia("(prefers-color-scheme: dark)").matches;class Gi{constructor(t,e,s){this.eventTarget=t,this.eventName=e,this.eventOptions=s,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(t){this.unorderedBindings.add(t)}bindingDisconnected(t){this.unorderedBindings.delete(t)}handleEvent(t){const e=Zi(t);for(const s of this.bindings){if(e.immediatePropagationStopped)break;s.handleEvent(e)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((t,e)=>{const s=t.index,i=e.index;return s<i?-1:s>i?1:0})}}function Zi(n){if("immediatePropagationStopped"in n)return n;{const{stopImmediatePropagation:t}=n;return Object.assign(n,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}class Ji{constructor(t){this.application=t,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(t=>t.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(t=>t.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((t,e)=>t.concat(Array.from(e.values())),[])}bindingConnected(t){this.fetchEventListenerForBinding(t).bindingConnected(t)}bindingDisconnected(t,e=!1){this.fetchEventListenerForBinding(t).bindingDisconnected(t),e&&this.clearEventListenersForBinding(t)}handleError(t,e,s={}){this.application.handleError(t,`Error ${e}`,s)}clearEventListenersForBinding(t){const e=this.fetchEventListenerForBinding(t);e.hasBindings()||(e.disconnect(),this.removeMappedEventListenerFor(t))}removeMappedEventListenerFor(t){const{eventTarget:e,eventName:s,eventOptions:i}=t,r=this.fetchEventListenerMapForEventTarget(e),o=this.cacheKey(s,i);r.delete(o),r.size==0&&this.eventListenerMaps.delete(e)}fetchEventListenerForBinding(t){const{eventTarget:e,eventName:s,eventOptions:i}=t;return this.fetchEventListener(e,s,i)}fetchEventListener(t,e,s){const i=this.fetchEventListenerMapForEventTarget(t),r=this.cacheKey(e,s);let o=i.get(r);return o||(o=this.createEventListener(t,e,s),i.set(r,o)),o}createEventListener(t,e,s){const i=new Gi(t,e,s);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(t){let e=this.eventListenerMaps.get(t);return e||(e=new Map,this.eventListenerMaps.set(t,e)),e}cacheKey(t,e){const s=[t];return Object.keys(e).sort().forEach(i=>{s.push(`${e[i]?"":"!"}${i}`)}),s.join(":")}}const Qi={stop({event:n,value:t}){return t&&n.stopPropagation(),!0},prevent({event:n,value:t}){return t&&n.preventDefault(),!0},self({event:n,value:t,element:e}){return t?e===n.target:!0}},tr=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function er(n){const e=n.trim().match(tr)||[];let s=e[2],i=e[3];return i&&!["keydown","keyup","keypress"].includes(s)&&(s+=`.${i}`,i=""),{eventTarget:nr(e[4]),eventName:s,eventOptions:e[7]?sr(e[7]):{},identifier:e[5],methodName:e[6],keyFilter:e[1]||i}}function nr(n){if(n=="window")return window;if(n=="document")return document}function sr(n){return n.split(":").reduce((t,e)=>Object.assign(t,{[e.replace(/^!/,"")]:!/^!/.test(e)}),{})}function ir(n){if(n==window)return"window";if(n==document)return"document"}function Pe(n){return n.replace(/(?:[_-])([a-z0-9])/g,(t,e)=>e.toUpperCase())}function Me(n){return Pe(n.replace(/--/g,"-").replace(/__/g,"_"))}function _t(n){return n.charAt(0).toUpperCase()+n.slice(1)}function ys(n){return n.replace(/([A-Z])/g,(t,e)=>`-${e.toLowerCase()}`)}function rr(n){return n.match(/[^\s]+/g)||[]}function Rn(n){return n!=null}function Se(n,t){return Object.prototype.hasOwnProperty.call(n,t)}const In=["meta","ctrl","alt","shift"];class or{constructor(t,e,s,i){this.element=t,this.index=e,this.eventTarget=s.eventTarget||t,this.eventName=s.eventName||ar(t)||Vt("missing event name"),this.eventOptions=s.eventOptions||{},this.identifier=s.identifier||Vt("missing identifier"),this.methodName=s.methodName||Vt("missing method name"),this.keyFilter=s.keyFilter||"",this.schema=i}static forToken(t,e){return new this(t.element,t.index,er(t.content),e)}toString(){const t=this.keyFilter?`.${this.keyFilter}`:"",e=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${t}${e}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(t){if(!this.keyFilter)return!1;const e=this.keyFilter.split("+");if(this.keyFilterDissatisfied(t,e))return!0;const s=e.filter(i=>!In.includes(i))[0];return s?(Se(this.keyMappings,s)||Vt(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[s].toLowerCase()!==t.key.toLowerCase()):!1}shouldIgnoreMouseEvent(t){if(!this.keyFilter)return!1;const e=[this.keyFilter];return!!this.keyFilterDissatisfied(t,e)}get params(){const t={},e=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:s,value:i}of Array.from(this.element.attributes)){const r=s.match(e),o=r&&r[1];o&&(t[Pe(o)]=cr(i))}return t}get eventTargetName(){return ir(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(t,e){const[s,i,r,o]=In.map(a=>e.includes(a));return t.metaKey!==s||t.ctrlKey!==i||t.altKey!==r||t.shiftKey!==o}}const Nn={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:n=>n.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function ar(n){const t=n.tagName.toLowerCase();if(t in Nn)return Nn[t](n)}function Vt(n){throw new Error(n)}function cr(n){try{return JSON.parse(n)}catch{return n}}class lr{constructor(t,e){this.context=t,this.action=e}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(t){const e=this.prepareActionEvent(t);this.willBeInvokedByEvent(t)&&this.applyEventModifiers(e)&&this.invokeWithEvent(e)}get eventName(){return this.action.eventName}get method(){const t=this.controller[this.methodName];if(typeof t=="function")return t;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(t){const{element:e}=this.action,{actionDescriptorFilters:s}=this.context.application,{controller:i}=this.context;let r=!0;for(const[o,a]of Object.entries(this.eventOptions))if(o in s){const c=s[o];r=r&&c({name:o,value:a,event:t,element:e,controller:i})}else continue;return r}prepareActionEvent(t){return Object.assign(t,{params:this.action.params})}invokeWithEvent(t){const{target:e,currentTarget:s}=t;try{this.method.call(this.controller,t),this.context.logDebugActivity(this.methodName,{event:t,target:e,currentTarget:s,action:this.methodName})}catch(i){const{identifier:r,controller:o,element:a,index:c}=this,l={identifier:r,controller:o,element:a,index:c,event:t};this.context.handleError(i,`invoking action "${this.action}"`,l)}}willBeInvokedByEvent(t){const e=t.target;return t instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(t)||t instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(t)?!1:this.element===e?!0:e instanceof Element&&this.element.contains(e)?this.scope.containsElement(e):this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class ws{constructor(t,e){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=t,this.started=!1,this.delegate=e,this.elements=new Set,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(t){this.started&&(this.mutationObserver.disconnect(),this.started=!1),t(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const t=new Set(this.matchElementsInTree());for(const e of Array.from(this.elements))t.has(e)||this.removeElement(e);for(const e of Array.from(t))this.addElement(e)}}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){t.type=="attributes"?this.processAttributeChange(t.target,t.attributeName):t.type=="childList"&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){this.elements.has(t)?this.delegate.elementAttributeChanged&&this.matchElement(t)?this.delegate.elementAttributeChanged(t,e):this.removeElement(t):this.matchElement(t)&&this.addElement(t)}processRemovedNodes(t){for(const e of Array.from(t)){const s=this.elementFromNode(e);s&&this.processTree(s,this.removeElement)}}processAddedNodes(t){for(const e of Array.from(t)){const s=this.elementFromNode(e);s&&this.elementIsActive(s)&&this.processTree(s,this.addElement)}}matchElement(t){return this.delegate.matchElement(t)}matchElementsInTree(t=this.element){return this.delegate.matchElementsInTree(t)}processTree(t,e){for(const s of this.matchElementsInTree(t))e.call(this,s)}elementFromNode(t){if(t.nodeType==Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected!=this.element.isConnected?!1:this.element.contains(t)}addElement(t){this.elements.has(t)||this.elementIsActive(t)&&(this.elements.add(t),this.delegate.elementMatched&&this.delegate.elementMatched(t))}removeElement(t){this.elements.has(t)&&(this.elements.delete(t),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(t))}}class Es{constructor(t,e,s){this.attributeName=e,this.delegate=s,this.elementObserver=new ws(t,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(t){return t.hasAttribute(this.attributeName)}matchElementsInTree(t){const e=this.matchElement(t)?[t]:[],s=Array.from(t.querySelectorAll(this.selector));return e.concat(s)}elementMatched(t){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(t,this.attributeName)}elementUnmatched(t){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(t,this.attributeName)}elementAttributeChanged(t,e){this.delegate.elementAttributeValueChanged&&this.attributeName==e&&this.delegate.elementAttributeValueChanged(t,e)}}function ur(n,t,e){As(n,t).add(e)}function dr(n,t,e){As(n,t).delete(e),hr(n,t)}function As(n,t){let e=n.get(t);return e||(e=new Set,n.set(t,e)),e}function hr(n,t){const e=n.get(t);e!=null&&e.size==0&&n.delete(t)}class Z{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((e,s)=>e.concat(Array.from(s)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((e,s)=>e+s.size,0)}add(t,e){ur(this.valuesByKey,t,e)}delete(t,e){dr(this.valuesByKey,t,e)}has(t,e){const s=this.valuesByKey.get(t);return s!=null&&s.has(e)}hasKey(t){return this.valuesByKey.has(t)}hasValue(t){return Array.from(this.valuesByKey.values()).some(s=>s.has(t))}getValuesForKey(t){const e=this.valuesByKey.get(t);return e?Array.from(e):[]}getKeysForValue(t){return Array.from(this.valuesByKey).filter(([e,s])=>s.has(t)).map(([e,s])=>e)}}class fr{constructor(t,e,s,i){this._selector=e,this.details=i,this.elementObserver=new ws(t,this),this.delegate=s,this.matchesByElement=new Z}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(t){this._selector=t,this.refresh()}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(t){const{selector:e}=this;if(e){const s=t.matches(e);return this.delegate.selectorMatchElement?s&&this.delegate.selectorMatchElement(t,this.details):s}else return!1}matchElementsInTree(t){const{selector:e}=this;if(e){const s=this.matchElement(t)?[t]:[],i=Array.from(t.querySelectorAll(e)).filter(r=>this.matchElement(r));return s.concat(i)}else return[]}elementMatched(t){const{selector:e}=this;e&&this.selectorMatched(t,e)}elementUnmatched(t){const e=this.matchesByElement.getKeysForValue(t);for(const s of e)this.selectorUnmatched(t,s)}elementAttributeChanged(t,e){const{selector:s}=this;if(s){const i=this.matchElement(t),r=this.matchesByElement.has(s,t);i&&!r?this.selectorMatched(t,s):!i&&r&&this.selectorUnmatched(t,s)}}selectorMatched(t,e){this.delegate.selectorMatched(t,e,this.details),this.matchesByElement.add(e,t)}selectorUnmatched(t,e){this.delegate.selectorUnmatched(t,e,this.details),this.matchesByElement.delete(e,t)}}class mr{constructor(t,e){this.element=t,this.delegate=e,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const t of this.knownAttributeNames)this.refreshAttribute(t,null)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){const e=t.attributeName;e&&this.refreshAttribute(e,t.oldValue)}refreshAttribute(t,e){const s=this.delegate.getStringMapKeyForAttribute(t);if(s!=null){this.stringMap.has(t)||this.stringMapKeyAdded(s,t);const i=this.element.getAttribute(t);if(this.stringMap.get(t)!=i&&this.stringMapValueChanged(i,s,e),i==null){const r=this.stringMap.get(t);this.stringMap.delete(t),r&&this.stringMapKeyRemoved(s,t,r)}else this.stringMap.set(t,i)}}stringMapKeyAdded(t,e){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(t,e)}stringMapValueChanged(t,e,s){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(t,e,s)}stringMapKeyRemoved(t,e,s){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(t,e,s)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(t=>t.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class xs{constructor(t,e,s){this.attributeObserver=new Es(t,e,this),this.delegate=s,this.tokensByElement=new Z}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(t){this.attributeObserver.pause(t)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(t){this.tokensMatched(this.readTokensForElement(t))}elementAttributeValueChanged(t){const[e,s]=this.refreshTokensForElement(t);this.tokensUnmatched(e),this.tokensMatched(s)}elementUnmatchedAttribute(t){this.tokensUnmatched(this.tokensByElement.getValuesForKey(t))}tokensMatched(t){t.forEach(e=>this.tokenMatched(e))}tokensUnmatched(t){t.forEach(e=>this.tokenUnmatched(e))}tokenMatched(t){this.delegate.tokenMatched(t),this.tokensByElement.add(t.element,t)}tokenUnmatched(t){this.delegate.tokenUnmatched(t),this.tokensByElement.delete(t.element,t)}refreshTokensForElement(t){const e=this.tokensByElement.getValuesForKey(t),s=this.readTokensForElement(t),i=gr(e,s).findIndex(([r,o])=>!br(r,o));return i==-1?[[],[]]:[e.slice(i),s.slice(i)]}readTokensForElement(t){const e=this.attributeName,s=t.getAttribute(e)||"";return pr(s,t,e)}}function pr(n,t,e){return n.trim().split(/\s+/).filter(s=>s.length).map((s,i)=>({element:t,attributeName:e,content:s,index:i}))}function gr(n,t){const e=Math.max(n.length,t.length);return Array.from({length:e},(s,i)=>[n[i],t[i]])}function br(n,t){return n&&t&&n.index==t.index&&n.content==t.content}class Ts{constructor(t,e,s){this.tokenListObserver=new xs(t,e,this),this.delegate=s,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(t){const{element:e}=t,{value:s}=this.fetchParseResultForToken(t);s&&(this.fetchValuesByTokenForElement(e).set(t,s),this.delegate.elementMatchedValue(e,s))}tokenUnmatched(t){const{element:e}=t,{value:s}=this.fetchParseResultForToken(t);s&&(this.fetchValuesByTokenForElement(e).delete(t),this.delegate.elementUnmatchedValue(e,s))}fetchParseResultForToken(t){let e=this.parseResultsByToken.get(t);return e||(e=this.parseToken(t),this.parseResultsByToken.set(t,e)),e}fetchValuesByTokenForElement(t){let e=this.valuesByTokenByElement.get(t);return e||(e=new Map,this.valuesByTokenByElement.set(t,e)),e}parseToken(t){try{return{value:this.delegate.parseValueForToken(t)}}catch(e){return{error:e}}}}class vr{constructor(t,e){this.context=t,this.delegate=e,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new Ts(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(t){const e=new lr(this.context,t);this.bindingsByAction.set(t,e),this.delegate.bindingConnected(e)}disconnectAction(t){const e=this.bindingsByAction.get(t);e&&(this.bindingsByAction.delete(t),this.delegate.bindingDisconnected(e))}disconnectAllActions(){this.bindings.forEach(t=>this.delegate.bindingDisconnected(t,!0)),this.bindingsByAction.clear()}parseValueForToken(t){const e=or.forToken(t,this.schema);if(e.identifier==this.identifier)return e}elementMatchedValue(t,e){this.connectAction(e)}elementUnmatchedValue(t,e){this.disconnectAction(e)}}class yr{constructor(t,e){this.context=t,this.receiver=e,this.stringMapObserver=new mr(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(t){if(t in this.valueDescriptorMap)return this.valueDescriptorMap[t].name}stringMapKeyAdded(t,e){const s=this.valueDescriptorMap[e];this.hasValue(t)||this.invokeChangedCallback(t,s.writer(this.receiver[t]),s.writer(s.defaultValue))}stringMapValueChanged(t,e,s){const i=this.valueDescriptorNameMap[e];t!==null&&(s===null&&(s=i.writer(i.defaultValue)),this.invokeChangedCallback(e,t,s))}stringMapKeyRemoved(t,e,s){const i=this.valueDescriptorNameMap[t];this.hasValue(t)?this.invokeChangedCallback(t,i.writer(this.receiver[t]),s):this.invokeChangedCallback(t,i.writer(i.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(const{key:t,name:e,defaultValue:s,writer:i}of this.valueDescriptors)s!=null&&!this.controller.data.has(t)&&this.invokeChangedCallback(e,i(s),void 0)}invokeChangedCallback(t,e,s){const i=`${t}Changed`,r=this.receiver[i];if(typeof r=="function"){const o=this.valueDescriptorNameMap[t];try{const a=o.reader(e);let c=s;s&&(c=o.reader(s)),r.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(){const{valueDescriptorMap:t}=this;return Object.keys(t).map(e=>t[e])}get valueDescriptorNameMap(){const t={};return Object.keys(this.valueDescriptorMap).forEach(e=>{const s=this.valueDescriptorMap[e];t[s.name]=s}),t}hasValue(t){const e=this.valueDescriptorNameMap[t],s=`has${_t(e.name)}`;return this.receiver[s]}}class wr{constructor(t,e){this.context=t,this.delegate=e,this.targetsByName=new Z}start(){this.tokenListObserver||(this.tokenListObserver=new xs(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:t,content:e}){this.scope.containsElement(t)&&this.connectTarget(t,e)}tokenUnmatched({element:t,content:e}){this.disconnectTarget(t,e)}connectTarget(t,e){var s;this.targetsByName.has(e,t)||(this.targetsByName.add(e,t),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetConnected(t,e)))}disconnectTarget(t,e){var s;this.targetsByName.has(e,t)&&(this.targetsByName.delete(e,t),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetDisconnected(t,e)))}disconnectAllTargets(){for(const t of this.targetsByName.keys)for(const e of this.targetsByName.getValuesForKey(t))this.disconnectTarget(e,t)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function Bt(n,t){const e=Os(n);return Array.from(e.reduce((s,i)=>(Ar(i,t).forEach(r=>s.add(r)),s),new Set))}function Er(n,t){return Os(n).reduce((s,i)=>(s.push(...xr(i,t)),s),[])}function Os(n){const t=[];for(;n;)t.push(n),n=Object.getPrototypeOf(n);return t.reverse()}function Ar(n,t){const e=n[t];return Array.isArray(e)?e:[]}function xr(n,t){const e=n[t];return e?Object.keys(e).map(s=>[s,e[s]]):[]}class Tr{constructor(t,e){this.started=!1,this.context=t,this.delegate=e,this.outletsByName=new Z,this.outletElementsByName=new Z,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(t=>{this.setupSelectorObserverForOutlet(t),this.setupAttributeObserverForOutlet(t)}),this.started=!0,this.dependentContexts.forEach(t=>t.refresh()))}refresh(){this.selectorObserverMap.forEach(t=>t.refresh()),this.attributeObserverMap.forEach(t=>t.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(t=>t.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(t=>t.stop()),this.attributeObserverMap.clear())}selectorMatched(t,e,{outletName:s}){const i=this.getOutlet(t,s);i&&this.connectOutlet(i,t,s)}selectorUnmatched(t,e,{outletName:s}){const i=this.getOutletFromMap(t,s);i&&this.disconnectOutlet(i,t,s)}selectorMatchElement(t,{outletName:e}){const s=this.selector(e),i=this.hasOutlet(t,e),r=t.matches(`[${this.schema.controllerAttribute}~=${e}]`);return s?i&&r&&t.matches(s):!1}elementMatchedAttribute(t,e){const s=this.getOutletNameFromOutletAttributeName(e);s&&this.updateSelectorObserverForOutlet(s)}elementAttributeValueChanged(t,e){const s=this.getOutletNameFromOutletAttributeName(e);s&&this.updateSelectorObserverForOutlet(s)}elementUnmatchedAttribute(t,e){const s=this.getOutletNameFromOutletAttributeName(e);s&&this.updateSelectorObserverForOutlet(s)}connectOutlet(t,e,s){var i;this.outletElementsByName.has(s,e)||(this.outletsByName.add(s,t),this.outletElementsByName.add(s,e),(i=this.selectorObserverMap.get(s))===null||i===void 0||i.pause(()=>this.delegate.outletConnected(t,e,s)))}disconnectOutlet(t,e,s){var i;this.outletElementsByName.has(s,e)&&(this.outletsByName.delete(s,t),this.outletElementsByName.delete(s,e),(i=this.selectorObserverMap.get(s))===null||i===void 0||i.pause(()=>this.delegate.outletDisconnected(t,e,s)))}disconnectAllOutlets(){for(const t of this.outletElementsByName.keys)for(const e of this.outletElementsByName.getValuesForKey(t))for(const s of this.outletsByName.getValuesForKey(t))this.disconnectOutlet(s,e,t)}updateSelectorObserverForOutlet(t){const e=this.selectorObserverMap.get(t);e&&(e.selector=this.selector(t))}setupSelectorObserverForOutlet(t){const e=this.selector(t),s=new fr(document.body,e,this,{outletName:t});this.selectorObserverMap.set(t,s),s.start()}setupAttributeObserverForOutlet(t){const e=this.attributeNameForOutletName(t),s=new Es(this.scope.element,e,this);this.attributeObserverMap.set(t,s),s.start()}selector(t){return this.scope.outlets.getSelectorForOutletName(t)}attributeNameForOutletName(t){return this.scope.schema.outletAttributeForScope(this.identifier,t)}getOutletNameFromOutletAttributeName(t){return this.outletDefinitions.find(e=>this.attributeNameForOutletName(e)===t)}get outletDependencies(){const t=new Z;return this.router.modules.forEach(e=>{const s=e.definition.controllerConstructor;Bt(s,"outlets").forEach(r=>t.add(r,e.identifier))}),t}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const t=this.dependentControllerIdentifiers;return this.router.contexts.filter(e=>t.includes(e.identifier))}hasOutlet(t,e){return!!this.getOutlet(t,e)||!!this.getOutletFromMap(t,e)}getOutlet(t,e){return this.application.getControllerForElementAndIdentifier(t,e)}getOutletFromMap(t,e){return this.outletsByName.getValuesForKey(e).find(s=>s.element===t)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class Or{constructor(t,e){this.logDebugActivity=(s,i={})=>{const{identifier:r,controller:o,element:a}=this;i=Object.assign({identifier:r,controller:o,element:a},i),this.application.logDebugActivity(this.identifier,s,i)},this.module=t,this.scope=e,this.controller=new t.controllerConstructor(this),this.bindingObserver=new vr(this,this.dispatcher),this.valueObserver=new yr(this,this.controller),this.targetObserver=new wr(this,this),this.outletObserver=new Tr(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(s){this.handleError(s,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(t){this.handleError(t,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(t){this.handleError(t,"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(t,e,s={}){const{identifier:i,controller:r,element:o}=this;s=Object.assign({identifier:i,controller:r,element:o},s),this.application.handleError(t,`Error ${e}`,s)}targetConnected(t,e){this.invokeControllerMethod(`${e}TargetConnected`,t)}targetDisconnected(t,e){this.invokeControllerMethod(`${e}TargetDisconnected`,t)}outletConnected(t,e,s){this.invokeControllerMethod(`${Me(s)}OutletConnected`,t,e)}outletDisconnected(t,e,s){this.invokeControllerMethod(`${Me(s)}OutletDisconnected`,t,e)}invokeControllerMethod(t,...e){const s=this.controller;typeof s[t]=="function"&&s[t](...e)}}function kr(n){return Mr(n,Sr(n))}function Mr(n,t){const e=Dr(n),s=Cr(n.prototype,t);return Object.defineProperties(e.prototype,s),e}function Sr(n){return Bt(n,"blessings").reduce((e,s)=>{const i=s(n);for(const r in i){const o=e[r]||{};e[r]=Object.assign(o,i[r])}return e},{})}function Cr(n,t){return Fr(t).reduce((e,s)=>{const i=Lr(n,t,s);return i&&Object.assign(e,{[s]:i}),e},{})}function Lr(n,t,e){const s=Object.getOwnPropertyDescriptor(n,e);if(!(s&&"value"in s)){const r=Object.getOwnPropertyDescriptor(t,e).value;return s&&(r.get=s.get||r.get,r.set=s.set||r.set),r}}const Fr=typeof Object.getOwnPropertySymbols=="function"?n=>[...Object.getOwnPropertyNames(n),...Object.getOwnPropertySymbols(n)]:Object.getOwnPropertyNames,Dr=(()=>{function n(e){function s(){return Reflect.construct(e,arguments,new.target)}return s.prototype=Object.create(e.prototype,{constructor:{value:s}}),Reflect.setPrototypeOf(s,e),s}function t(){const s=n(function(){this.a.call(this)});return s.prototype.a=function(){},new s}try{return t(),n}catch{return s=>class extends s{}}})();function _r(n){return{identifier:n.identifier,controllerConstructor:kr(n.controllerConstructor)}}class Br{constructor(t,e){this.application=t,this.definition=_r(e),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(t){const e=this.fetchContextForScope(t);this.connectedContexts.add(e),e.connect()}disconnectContextForScope(t){const e=this.contextsByScope.get(t);e&&(this.connectedContexts.delete(e),e.disconnect())}fetchContextForScope(t){let e=this.contextsByScope.get(t);return e||(e=new Or(this,t),this.contextsByScope.set(t,e)),e}}class $r{constructor(t){this.scope=t}has(t){return this.data.has(this.getDataKey(t))}get(t){return this.getAll(t)[0]}getAll(t){const e=this.data.get(this.getDataKey(t))||"";return rr(e)}getAttributeName(t){return this.data.getAttributeNameForKey(this.getDataKey(t))}getDataKey(t){return`${t}-class`}get data(){return this.scope.data}}class Pr{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(t){const e=this.getAttributeNameForKey(t);return this.element.getAttribute(e)}set(t,e){const s=this.getAttributeNameForKey(t);return this.element.setAttribute(s,e),this.get(t)}has(t){const e=this.getAttributeNameForKey(t);return this.element.hasAttribute(e)}delete(t){if(this.has(t)){const e=this.getAttributeNameForKey(t);return this.element.removeAttribute(e),!0}else return!1}getAttributeNameForKey(t){return`data-${this.identifier}-${ys(t)}`}}class Rr{constructor(t){this.warnedKeysByObject=new WeakMap,this.logger=t}warn(t,e,s){let i=this.warnedKeysByObject.get(t);i||(i=new Set,this.warnedKeysByObject.set(t,i)),i.has(e)||(i.add(e),this.logger.warn(s,t))}}function Ce(n,t){return`[${n}~="${t}"]`}class Ir{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return this.find(t)!=null}find(...t){return t.reduce((e,s)=>e||this.findTarget(s)||this.findLegacyTarget(s),void 0)}findAll(...t){return t.reduce((e,s)=>[...e,...this.findAllTargets(s),...this.findAllLegacyTargets(s)],[])}findTarget(t){const e=this.getSelectorForTargetName(t);return this.scope.findElement(e)}findAllTargets(t){const e=this.getSelectorForTargetName(t);return this.scope.findAllElements(e)}getSelectorForTargetName(t){const e=this.schema.targetAttributeForScope(this.identifier);return Ce(e,t)}findLegacyTarget(t){const e=this.getLegacySelectorForTargetName(t);return this.deprecate(this.scope.findElement(e),t)}findAllLegacyTargets(t){const e=this.getLegacySelectorForTargetName(t);return this.scope.findAllElements(e).map(s=>this.deprecate(s,t))}getLegacySelectorForTargetName(t){const e=`${this.identifier}.${t}`;return Ce(this.schema.targetAttribute,e)}deprecate(t,e){if(t){const{identifier:s}=this,i=this.schema.targetAttribute,r=this.schema.targetAttributeForScope(s);this.guide.warn(t,`target:${e}`,`Please replace ${i}="${s}.${e}" with ${r}="${e}". The ${i} attribute is deprecated and will be removed in a future version of Stimulus.`)}return t}get guide(){return this.scope.guide}}class Nr{constructor(t,e){this.scope=t,this.controllerElement=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return this.find(t)!=null}find(...t){return t.reduce((e,s)=>e||this.findOutlet(s),void 0)}findAll(...t){return t.reduce((e,s)=>[...e,...this.findAllOutlets(s)],[])}getSelectorForOutletName(t){const e=this.schema.outletAttributeForScope(this.identifier,t);return this.controllerElement.getAttribute(e)}findOutlet(t){const e=this.getSelectorForOutletName(t);if(e)return this.findElement(e,t)}findAllOutlets(t){const e=this.getSelectorForOutletName(t);return e?this.findAllElements(e,t):[]}findElement(t,e){return this.scope.queryElements(t).filter(i=>this.matchesElement(i,t,e))[0]}findAllElements(t,e){return this.scope.queryElements(t).filter(i=>this.matchesElement(i,t,e))}matchesElement(t,e,s){const i=t.getAttribute(this.scope.schema.controllerAttribute)||"";return t.matches(e)&&i.split(" ").includes(s)}}class Re{constructor(t,e,s,i){this.targets=new Ir(this),this.classes=new $r(this),this.data=new Pr(this),this.containsElement=r=>r.closest(this.controllerSelector)===this.element,this.schema=t,this.element=e,this.identifier=s,this.guide=new Rr(i),this.outlets=new Nr(this.documentScope,e)}findElement(t){return this.element.matches(t)?this.element:this.queryElements(t).find(this.containsElement)}findAllElements(t){return[...this.element.matches(t)?[this.element]:[],...this.queryElements(t).filter(this.containsElement)]}queryElements(t){return Array.from(this.element.querySelectorAll(t))}get controllerSelector(){return Ce(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new Re(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class jr{constructor(t,e,s){this.element=t,this.schema=e,this.delegate=s,this.valueListObserver=new Ts(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(t){const{element:e,content:s}=t;return this.parseValueForElementAndIdentifier(e,s)}parseValueForElementAndIdentifier(t,e){const s=this.fetchScopesByIdentifierForElement(t);let i=s.get(e);return i||(i=this.delegate.createScopeForElementAndIdentifier(t,e),s.set(e,i)),i}elementMatchedValue(t,e){const s=(this.scopeReferenceCounts.get(e)||0)+1;this.scopeReferenceCounts.set(e,s),s==1&&this.delegate.scopeConnected(e)}elementUnmatchedValue(t,e){const s=this.scopeReferenceCounts.get(e);s&&(this.scopeReferenceCounts.set(e,s-1),s==1&&this.delegate.scopeDisconnected(e))}fetchScopesByIdentifierForElement(t){let e=this.scopesByIdentifierByElement.get(t);return e||(e=new Map,this.scopesByIdentifierByElement.set(t,e)),e}}class Hr{constructor(t){this.application=t,this.scopeObserver=new jr(this.element,this.schema,this),this.scopesByIdentifier=new Z,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((t,e)=>t.concat(e.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(t){this.unloadIdentifier(t.identifier);const e=new Br(this.application,t);this.connectModule(e);const s=t.controllerConstructor.afterLoad;s&&s.call(t.controllerConstructor,t.identifier,this.application)}unloadIdentifier(t){const e=this.modulesByIdentifier.get(t);e&&this.disconnectModule(e)}getContextForElementAndIdentifier(t,e){const s=this.modulesByIdentifier.get(e);if(s)return s.contexts.find(i=>i.element==t)}proposeToConnectScopeForElementAndIdentifier(t,e){const s=this.scopeObserver.parseValueForElementAndIdentifier(t,e);s?this.scopeObserver.elementMatchedValue(s.element,s):console.error(`Couldn't find or create scope for identifier: "${e}" and element:`,t)}handleError(t,e,s){this.application.handleError(t,e,s)}createScopeForElementAndIdentifier(t,e){return new Re(this.schema,t,e,this.logger)}scopeConnected(t){this.scopesByIdentifier.add(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.connectContextForScope(t)}scopeDisconnected(t){this.scopesByIdentifier.delete(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.disconnectContextForScope(t)}connectModule(t){this.modulesByIdentifier.set(t.identifier,t),this.scopesByIdentifier.getValuesForKey(t.identifier).forEach(s=>t.connectContextForScope(s))}disconnectModule(t){this.modulesByIdentifier.delete(t.identifier),this.scopesByIdentifier.getValuesForKey(t.identifier).forEach(s=>t.disconnectContextForScope(s))}}const Vr={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:n=>`data-${n}-target`,outletAttributeForScope:(n,t)=>`data-${n}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},jn("abcdefghijklmnopqrstuvwxyz".split("").map(n=>[n,n]))),jn("0123456789".split("").map(n=>[n,n])))};function jn(n){return n.reduce((t,[e,s])=>Object.assign(Object.assign({},t),{[e]:s}),{})}class Wr{constructor(t=document.documentElement,e=Vr){this.logger=console,this.debug=!1,this.logDebugActivity=(s,i,r={})=>{this.debug&&this.logFormattedMessage(s,i,r)},this.element=t,this.schema=e,this.dispatcher=new Ji(this),this.router=new Hr(this),this.actionDescriptorFilters=Object.assign({},Qi)}static start(t,e){const s=new this(t,e);return s.start(),s}async start(){await Kr(),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(t,e){this.load({identifier:t,controllerConstructor:e})}registerActionOption(t,e){this.actionDescriptorFilters[t]=e}load(t,...e){(Array.isArray(t)?t:[t,...e]).forEach(i=>{i.controllerConstructor.shouldLoad&&this.router.loadDefinition(i)})}unload(t,...e){(Array.isArray(t)?t:[t,...e]).forEach(i=>this.router.unloadIdentifier(i))}get controllers(){return this.router.contexts.map(t=>t.controller)}getControllerForElementAndIdentifier(t,e){const s=this.router.getContextForElementAndIdentifier(t,e);return s?s.controller:null}handleError(t,e,s){var i;this.logger.error(`%s
95
95
 
96
96
  %o
97
97
 
98
- %o`,e,t,s),(i=window.onerror)===null||i===void 0||i.call(window,e,"",0,0,t)}logFormattedMessage(t,e,s={}){s=Object.assign({application:this},s),this.logger.groupCollapsed(`${t} #${e}`),this.logger.log("details:",Object.assign({},s)),this.logger.groupEnd()}}function Nr(){return new Promise(n=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>n()):n()})}function jr(n){return Bt(n,"classes").reduce((e,s)=>Object.assign(e,Hr(s)),{})}function Hr(n){return{[`${n}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${_t(n)}Class`]:{get(){return this.classes.has(n)}}}}function Vr(n){return Bt(n,"outlets").reduce((e,s)=>Object.assign(e,Wr(s)),{})}function $n(n,t,e){return n.application.getControllerForElementAndIdentifier(t,e)}function In(n,t,e){let s=$n(n,t,e);if(s||(n.application.router.proposeToConnectScopeForElementAndIdentifier(t,e),s=$n(n,t,e),s))return s}function Wr(n){const t=Te(n);return{[`${t}Outlet`]:{get(){const e=this.outlets.find(n),s=this.outlets.getSelectorForOutletName(n);if(e){const i=In(this,e,n);if(i)return i;throw new Error(`The provided outlet element is missing an outlet controller "${n}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${n}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${t}Outlets`]:{get(){const e=this.outlets.findAll(n);return e.length>0?e.map(s=>{const i=In(this,s,n);if(i)return i;console.warn(`The provided outlet element is missing an outlet controller "${n}" instance for host controller "${this.identifier}"`,s)}).filter(s=>s):[]}},[`${t}OutletElement`]:{get(){const e=this.outlets.find(n),s=this.outlets.getSelectorForOutletName(n);if(e)return e;throw new Error(`Missing outlet element "${n}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(n)}},[`has${_t(t)}Outlet`]:{get(){return this.outlets.has(n)}}}}function Kr(n){return Bt(n,"targets").reduce((e,s)=>Object.assign(e,Ur(s)),{})}function Ur(n){return{[`${n}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${_t(n)}Target`]:{get(){return this.targets.has(n)}}}}function qr(n){const t=gr(n,"values"),e={valueDescriptorMap:{get(){return t.reduce((s,i)=>{const r=As(i,this.identifier),o=this.data.getAttributeNameForKey(r.key);return Object.assign(s,{[o]:r})},{})}}};return t.reduce((s,i)=>Object.assign(s,zr(i)),e)}function zr(n,t){const e=As(n,t),{key:s,name:i,reader:r,writer:o}=e;return{[i]:{get(){const a=this.data.get(s);return a!==null?r(a):e.defaultValue},set(a){a===void 0?this.data.delete(s):this.data.set(s,o(a))}},[`has${_t(i)}`]:{get(){return this.data.has(s)||e.hasCustomDefaultValue}}}}function As([n,t],e){return Zr({controller:e,token:n,typeDefinition:t})}function Yt(n){switch(n){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function Ft(n){switch(typeof n){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(n))return"array";if(Object.prototype.toString.call(n)==="[object Object]")return"object"}function Yr(n){const{controller:t,token:e,typeObject:s}=n,i=_n(s.type),r=_n(s.default),o=i&&r,a=i&&!r,c=!i&&r,l=Yt(s.type),u=Ft(n.typeObject.default);if(a)return l;if(c)return u;if(l!==u){const d=t?`${t}.${e}`:e;throw new Error(`The specified default value for the Stimulus Value "${d}" must match the defined type "${l}". The provided default value of "${s.default}" is of type "${u}".`)}if(o)return l}function Xr(n){const{controller:t,token:e,typeDefinition:s}=n,r=Yr({controller:t,token:e,typeObject:s}),o=Ft(s),a=Yt(s),c=r||o||a;if(c)return c;const l=t?`${t}.${s}`:e;throw new Error(`Unknown value type "${l}" for "${e}" value`)}function Gr(n){const t=Yt(n);if(t)return Nn[t];const e=Oe(n,"default"),s=Oe(n,"type"),i=n;if(e)return i.default;if(s){const{type:r}=i,o=Yt(r);if(o)return Nn[o]}return n}function Zr(n){const{token:t,typeDefinition:e}=n,s=`${ps(t)}-value`,i=Xr(n);return{type:i,key:s,name:De(s),get defaultValue(){return Gr(e)},get hasCustomDefaultValue(){return Ft(e)!==void 0},reader:Jr[i],writer:jn[i]||jn.default}}const Nn={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Jr={array(n){const t=JSON.parse(n);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${n}" of type "${Ft(t)}"`);return t},boolean(n){return!(n=="0"||String(n).toLowerCase()=="false")},number(n){return Number(n.replace(/_/g,""))},object(n){const t=JSON.parse(n);if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${n}" of type "${Ft(t)}"`);return t},string(n){return n}},jn={default:Qr,array:Hn,object:Hn};function Hn(n){return JSON.stringify(n)}function Qr(n){return`${n}`}class U{constructor(t){this.context=t}static get shouldLoad(){return!0}static afterLoad(t,e){}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(t,{target:e=this.element,detail:s={},prefix:i=this.identifier,bubbles:r=!0,cancelable:o=!0}={}){const a=i?`${i}:${t}`:t,c=new CustomEvent(a,{detail:s,bubbles:r,cancelable:o});return e.dispatchEvent(c),c}}U.blessings=[jr,Kr,qr,Vr];U.targets=[];U.outlets=[];U.values={};function Pt(){return function({targets:t,values:e}={}){const i=class i extends U{};i.targets=Object.keys(t??{}),i.values=e??{};let s=i;return s}}function to(n){const t=document.createElement("pre");return t.style.width="1px",t.style.height="1px",t.style.position="fixed",t.style.top="5px",t.textContent=n,t}function xs(n){if("clipboard"in navigator)return navigator.clipboard.writeText(n.textContent||"");const t=getSelection();if(t==null)return Promise.reject(new Error);t.removeAllRanges();const e=document.createRange();return e.selectNodeContents(n),t.addRange(e),document.execCommand("copy"),t.removeAllRanges(),Promise.resolve()}function Me(n){if("clipboard"in navigator)return navigator.clipboard.writeText(n);const t=document.body;if(!t)return Promise.reject(new Error);const e=to(n);return t.appendChild(e),xs(e),t.removeChild(e),Promise.resolve()}async function Ts(n){const t=n.getAttribute("for"),e=n.getAttribute("value");function s(){n.dispatchEvent(new CustomEvent("clipboard-copy",{bubbles:!0}))}if(n.getAttribute("aria-disabled")!=="true"){if(e)await Me(e),s();else if(t){const i="getRootNode"in Element.prototype?n.getRootNode():n.ownerDocument;if(!(i instanceof Document||"ShadowRoot"in window&&i instanceof ShadowRoot))return;const r=i.getElementById(t);r&&(await eo(r),s())}}}function eo(n){return n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?Me(n.value):n instanceof HTMLAnchorElement&&n.hasAttribute("href")?Me(n.href):xs(n)}function no(n){const t=n.currentTarget;t instanceof HTMLElement&&Ts(t)}function Os(n){if(n.key===" "||n.key==="Enter"){const t=n.currentTarget;t instanceof HTMLElement&&(n.preventDefault(),Ts(t))}}function so(n){n.currentTarget.addEventListener("keydown",Os)}function io(n){n.currentTarget.removeEventListener("keydown",Os)}class ro extends HTMLElement{static define(t="clipboard-copy",e=customElements){return e.define(t,this),this}constructor(){super(),this.addEventListener("click",no),this.addEventListener("focus",so),this.addEventListener("blur",io)}connectedCallback(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","button")}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}}const Vn=typeof globalThis<"u"?globalThis:window;try{Vn.ClipboardCopyElement=ro.define()}catch(n){if(!(Vn.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}const oo=2e3;class ao extends Pt()({targets:{initial:HTMLElement,confirmed:null}}){connect(){this.clipboardCopyElementTimers=new WeakMap}copy(t){const e=t.target,s=this.clipboardCopyElementTimers.get(e);s?(clearTimeout(s),this.clipboardCopyElementTimers.delete(e)):this.showConfirm(),this.clipboardCopyElementTimers.set(e,window.setTimeout(()=>{this.showInitial(),this.clipboardCopyElementTimers.delete(e)},oo))}showConfirm(){this.hasConfirmedTarget&&(this.confirmedTarget.classList.remove("hidden"),this.confirmedTarget.classList.add("inline-block"),this.initialTarget.classList.add("hidden"))}showInitial(){this.initialTarget.classList.remove("hidden"),this.initialTarget.classList.add("inline-block"),this.hasConfirmedTarget&&this.confirmedTarget.classList.add("hidden")}}const co=Object.freeze(Object.defineProperty({__proto__:null,default:ao},Symbol.toStringTag,{value:"Module"})),ht=Math.min,S=Math.max,Xt=Math.round,Wt=Math.floor,V=n=>({x:n,y:n}),lo={left:"right",right:"left",bottom:"top",top:"bottom"},uo={start:"end",end:"start"};function Wn(n,t,e){return S(n,ht(t,e))}function Rt(n,t){return typeof n=="function"?n(t):n}function W(n){return n.split("-")[0]}function $t(n){return n.split("-")[1]}function ks(n){return n==="x"?"y":"x"}function Ms(n){return n==="y"?"height":"width"}function It(n){return["top","bottom"].includes(W(n))?"y":"x"}function Ss(n){return ks(It(n))}function ho(n,t,e){e===void 0&&(e=!1);const s=$t(n),i=Ss(n),r=Ms(i);let o=i==="x"?s===(e?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(o=Gt(o)),[o,Gt(o)]}function fo(n){const t=Gt(n);return[Se(n),t,Se(t)]}function Se(n){return n.replace(/start|end/g,t=>uo[t])}function mo(n,t,e){const s=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return e?t?i:s:t?s:i;case"left":case"right":return t?r:o;default:return[]}}function po(n,t,e,s){const i=$t(n);let r=mo(W(n),e==="start",s);return i&&(r=r.map(o=>o+"-"+i),t&&(r=r.concat(r.map(Se)))),r}function Gt(n){return n.replace(/left|right|bottom|top/g,t=>lo[t])}function go(n){return{top:0,right:0,bottom:0,left:0,...n}}function bo(n){return typeof n!="number"?go(n):{top:n,right:n,bottom:n,left:n}}function Zt(n){return{...n,top:n.y,left:n.x,right:n.x+n.width,bottom:n.y+n.height}}function Kn(n,t,e){let{reference:s,floating:i}=n;const r=It(t),o=Ss(t),a=Ms(o),c=W(t),l=r==="y",u=s.x+s.width/2-i.width/2,d=s.y+s.height/2-i.height/2,h=s[a]/2-i[a]/2;let g;switch(c){case"top":g={x:u,y:s.y-i.height};break;case"bottom":g={x:u,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:d};break;case"left":g={x:s.x-i.width,y:d};break;default:g={x:s.x,y:s.y}}switch($t(t)){case"start":g[o]-=h*(e&&l?-1:1);break;case"end":g[o]+=h*(e&&l?-1:1);break}return g}const vo=async(n,t,e)=>{const{placement:s="bottom",strategy:i="absolute",middleware:r=[],platform:o}=e,a=r.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t));let l=await o.getElementRects({reference:n,floating:t,strategy:i}),{x:u,y:d}=Kn(l,s,c),h=s,g={},f=0;for(let m=0;m<a.length;m++){const{name:b,fn:p}=a[m],{x:v,y:E,data:y,reset:w}=await p({x:u,y:d,initialPlacement:s,placement:h,strategy:i,middlewareData:g,rects:l,platform:o,elements:{reference:n,floating:t}});u=v??u,d=E??d,g={...g,[b]:{...g[b],...y}},w&&f<=50&&(f++,typeof w=="object"&&(w.placement&&(h=w.placement),w.rects&&(l=w.rects===!0?await o.getElementRects({reference:n,floating:t,strategy:i}):w.rects),{x:u,y:d}=Kn(l,h,c)),m=-1)}return{x:u,y:d,placement:h,strategy:i,middlewareData:g}};async function Be(n,t){var e;t===void 0&&(t={});const{x:s,y:i,platform:r,rects:o,elements:a,strategy:c}=n,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:g=0}=Rt(t,n),f=bo(g),b=a[h?d==="floating"?"reference":"floating":d],p=Zt(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(b)))==null||e?b:b.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d==="floating"?{...o.floating,x:s,y:i}:o.reference,E=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),y=await(r.isElement==null?void 0:r.isElement(E))?await(r.getScale==null?void 0:r.getScale(E))||{x:1,y:1}:{x:1,y:1},w=Zt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:E,strategy:c}):v);return{top:(p.top-w.top+f.top)/y.y,bottom:(w.bottom-p.bottom+f.bottom)/y.y,left:(p.left-w.left+f.left)/y.x,right:(w.right-p.right+f.right)/y.x}}const yo=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,s;const{placement:i,middlewareData:r,rects:o,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...b}=Rt(n,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const p=W(i),v=W(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(l.floating)),y=h||(v||!m?[Gt(a)]:fo(a));!h&&f!=="none"&&y.push(...po(a,m,f,E));const w=[a,...y],x=await Be(t,b),B=[];let j=((s=r.flip)==null?void 0:s.overflows)||[];if(u&&B.push(x[p]),d){const q=ho(i,o,E);B.push(x[q[0]],x[q[1]])}if(j=[...j,{placement:i,overflows:B}],!B.every(q=>q<=0)){var mt,Ke;const q=(((mt=r.flip)==null?void 0:mt.index)||0)+1,qe=w[q];if(qe)return{data:{index:q,overflows:j},reset:{placement:qe}};let pt=(Ke=j.filter(tt=>tt.overflows[0]<=0).sort((tt,et)=>tt.overflows[1]-et.overflows[1])[0])==null?void 0:Ke.placement;if(!pt)switch(g){case"bestFit":{var Ue;const tt=(Ue=j.map(et=>[et.placement,et.overflows.filter(gt=>gt>0).reduce((gt,Hs)=>gt+Hs,0)]).sort((et,gt)=>et[1]-gt[1])[0])==null?void 0:Ue[0];tt&&(pt=tt);break}case"initialPlacement":pt=a;break}if(i!==pt)return{reset:{placement:pt}}}return{}}}};async function wo(n,t){const{placement:e,platform:s,elements:i}=n,r=await(s.isRTL==null?void 0:s.isRTL(i.floating)),o=W(e),a=$t(e),c=It(e)==="y",l=["left","top"].includes(o)?-1:1,u=r&&c?-1:1,d=Rt(t,n);let{mainAxis:h,crossAxis:g,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof f=="number"&&(g=a==="end"?f*-1:f),c?{x:g*u,y:h*l}:{x:h*l,y:g*u}}const Pe=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,s;const{x:i,y:r,placement:o,middlewareData:a}=t,c=await wo(t,n);return o===((e=a.offset)==null?void 0:e.placement)&&(s=a.arrow)!=null&&s.alignmentOffset?{}:{x:i+c.x,y:r+c.y,data:{...c,placement:o}}}}},Eo=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){const{x:e,y:s,placement:i}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:a={fn:b=>{let{x:p,y:v}=b;return{x:p,y:v}}},...c}=Rt(n,t),l={x:e,y:s},u=await Be(t,c),d=It(W(i)),h=ks(d);let g=l[h],f=l[d];if(r){const b=h==="y"?"top":"left",p=h==="y"?"bottom":"right",v=g+u[b],E=g-u[p];g=Wn(v,g,E)}if(o){const b=d==="y"?"top":"left",p=d==="y"?"bottom":"right",v=f+u[b],E=f-u[p];f=Wn(v,f,E)}const m=a.fn({...t,[h]:g,[d]:f});return{...m,data:{x:m.x-e,y:m.y-s}}}}},Ao=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(t){const{placement:e,rects:s,platform:i,elements:r}=t,{apply:o=()=>{},...a}=Rt(n,t),c=await Be(t,a),l=W(e),u=$t(e),d=It(e)==="y",{width:h,height:g}=s.floating;let f,m;l==="top"||l==="bottom"?(f=l,m=u===(await(i.isRTL==null?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(m=l,f=u==="end"?"top":"bottom");const b=g-c[f],p=h-c[m],v=!t.middlewareData.shift;let E=b,y=p;if(d){const x=h-c.left-c.right;y=u||v?ht(p,x):x}else{const x=g-c.top-c.bottom;E=u||v?ht(b,x):x}if(v&&!u){const x=S(c.left,0),B=S(c.right,0),j=S(c.top,0),mt=S(c.bottom,0);d?y=h-2*(x!==0||B!==0?x+B:S(c.left,c.right)):E=g-2*(j!==0||mt!==0?j+mt:S(c.top,c.bottom))}await o({...t,availableWidth:y,availableHeight:E});const w=await i.getDimensions(r.floating);return h!==w.width||g!==w.height?{reset:{rects:!0}}:{}}}};function K(n){return Cs(n)?(n.nodeName||"").toLowerCase():"#document"}function C(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function N(n){var t;return(t=(Cs(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function Cs(n){return n instanceof Node||n instanceof C(n).Node}function I(n){return n instanceof Element||n instanceof C(n).Element}function P(n){return n instanceof HTMLElement||n instanceof C(n).HTMLElement}function Un(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof C(n).ShadowRoot}function Nt(n){const{overflow:t,overflowX:e,overflowY:s,display:i}=D(n);return/auto|scroll|overlay|hidden|clip/.test(t+s+e)&&!["inline","contents"].includes(i)}function xo(n){return["table","td","th"].includes(K(n))}function Re(n){const t=$e(),e=D(n);return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(s=>(e.willChange||"").includes(s))||["paint","layout","strict","content"].some(s=>(e.contain||"").includes(s))}function To(n){let t=ft(n);for(;P(t)&&!se(t);){if(Re(t))return t;t=ft(t)}return null}function $e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function se(n){return["html","body","#document"].includes(K(n))}function D(n){return C(n).getComputedStyle(n)}function ie(n){return I(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function ft(n){if(K(n)==="html")return n;const t=n.assignedSlot||n.parentNode||Un(n)&&n.host||N(n);return Un(t)?t.host:t}function Ls(n){const t=ft(n);return se(t)?n.ownerDocument?n.ownerDocument.body:n.body:P(t)&&Nt(t)?t:Ls(t)}function Dt(n,t,e){var s;t===void 0&&(t=[]),e===void 0&&(e=!0);const i=Ls(n),r=i===((s=n.ownerDocument)==null?void 0:s.body),o=C(i);return r?t.concat(o,o.visualViewport||[],Nt(i)?i:[],o.frameElement&&e?Dt(o.frameElement):[]):t.concat(i,Dt(i,[],e))}function Fs(n){const t=D(n);let e=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=P(n),r=i?n.offsetWidth:e,o=i?n.offsetHeight:s,a=Xt(e)!==r||Xt(s)!==o;return a&&(e=r,s=o),{width:e,height:s,$:a}}function Ie(n){return I(n)?n:n.contextElement}function ut(n){const t=Ie(n);if(!P(t))return V(1);const e=t.getBoundingClientRect(),{width:s,height:i,$:r}=Fs(t);let o=(r?Xt(e.width):e.width)/s,a=(r?Xt(e.height):e.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Oo=V(0);function Ds(n){const t=C(n);return!$e()||!t.visualViewport?Oo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ko(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==C(n)?!1:t}function Q(n,t,e,s){t===void 0&&(t=!1),e===void 0&&(e=!1);const i=n.getBoundingClientRect(),r=Ie(n);let o=V(1);t&&(s?I(s)&&(o=ut(s)):o=ut(n));const a=ko(r,e,s)?Ds(r):V(0);let c=(i.left+a.x)/o.x,l=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(r){const h=C(r),g=s&&I(s)?C(s):s;let f=h,m=f.frameElement;for(;m&&s&&g!==f;){const b=ut(m),p=m.getBoundingClientRect(),v=D(m),E=p.left+(m.clientLeft+parseFloat(v.paddingLeft))*b.x,y=p.top+(m.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,l*=b.y,u*=b.x,d*=b.y,c+=E,l+=y,f=C(m),m=f.frameElement}}return Zt({width:u,height:d,x:c,y:l})}const Mo=[":popover-open",":modal"];function _s(n){return Mo.some(t=>{try{return n.matches(t)}catch{return!1}})}function So(n){let{elements:t,rect:e,offsetParent:s,strategy:i}=n;const r=i==="fixed",o=N(s),a=t?_s(t.floating):!1;if(s===o||a&&r)return e;let c={scrollLeft:0,scrollTop:0},l=V(1);const u=V(0),d=P(s);if((d||!d&&!r)&&((K(s)!=="body"||Nt(o))&&(c=ie(s)),P(s))){const h=Q(s);l=ut(s),u.x=h.x+s.clientLeft,u.y=h.y+s.clientTop}return{width:e.width*l.x,height:e.height*l.y,x:e.x*l.x-c.scrollLeft*l.x+u.x,y:e.y*l.y-c.scrollTop*l.y+u.y}}function Co(n){return Array.from(n.getClientRects())}function Bs(n){return Q(N(n)).left+ie(n).scrollLeft}function Lo(n){const t=N(n),e=ie(n),s=n.ownerDocument.body,i=S(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),r=S(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let o=-e.scrollLeft+Bs(n);const a=-e.scrollTop;return D(s).direction==="rtl"&&(o+=S(t.clientWidth,s.clientWidth)-i),{width:i,height:r,x:o,y:a}}function Fo(n,t){const e=C(n),s=N(n),i=e.visualViewport;let r=s.clientWidth,o=s.clientHeight,a=0,c=0;if(i){r=i.width,o=i.height;const l=$e();(!l||l&&t==="fixed")&&(a=i.offsetLeft,c=i.offsetTop)}return{width:r,height:o,x:a,y:c}}function Do(n,t){const e=Q(n,!0,t==="fixed"),s=e.top+n.clientTop,i=e.left+n.clientLeft,r=P(n)?ut(n):V(1),o=n.clientWidth*r.x,a=n.clientHeight*r.y,c=i*r.x,l=s*r.y;return{width:o,height:a,x:c,y:l}}function qn(n,t,e){let s;if(t==="viewport")s=Fo(n,e);else if(t==="document")s=Lo(N(n));else if(I(t))s=Do(t,e);else{const i=Ds(n);s={...t,x:t.x-i.x,y:t.y-i.y}}return Zt(s)}function Ps(n,t){const e=ft(n);return e===t||!I(e)||se(e)?!1:D(e).position==="fixed"||Ps(e,t)}function _o(n,t){const e=t.get(n);if(e)return e;let s=Dt(n,[],!1).filter(a=>I(a)&&K(a)!=="body"),i=null;const r=D(n).position==="fixed";let o=r?ft(n):n;for(;I(o)&&!se(o);){const a=D(o),c=Re(o);!c&&a.position==="fixed"&&(i=null),(r?!c&&!i:!c&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Nt(o)&&!c&&Ps(n,o))?s=s.filter(u=>u!==o):i=a,o=ft(o)}return t.set(n,s),s}function Bo(n){let{element:t,boundary:e,rootBoundary:s,strategy:i}=n;const o=[...e==="clippingAncestors"?_o(t,this._c):[].concat(e),s],a=o[0],c=o.reduce((l,u)=>{const d=qn(t,u,i);return l.top=S(d.top,l.top),l.right=ht(d.right,l.right),l.bottom=ht(d.bottom,l.bottom),l.left=S(d.left,l.left),l},qn(t,a,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Po(n){const{width:t,height:e}=Fs(n);return{width:t,height:e}}function Ro(n,t,e){const s=P(t),i=N(t),r=e==="fixed",o=Q(n,!0,r,t);let a={scrollLeft:0,scrollTop:0};const c=V(0);if(s||!s&&!r)if((K(t)!=="body"||Nt(i))&&(a=ie(t)),s){const d=Q(t,!0,r,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else i&&(c.x=Bs(i));const l=o.left+a.scrollLeft-c.x,u=o.top+a.scrollTop-c.y;return{x:l,y:u,width:o.width,height:o.height}}function zn(n,t){return!P(n)||D(n).position==="fixed"?null:t?t(n):n.offsetParent}function Rs(n,t){const e=C(n);if(!P(n)||_s(n))return e;let s=zn(n,t);for(;s&&xo(s)&&D(s).position==="static";)s=zn(s,t);return s&&(K(s)==="html"||K(s)==="body"&&D(s).position==="static"&&!Re(s))?e:s||To(n)||e}const $o=async function(n){const t=this.getOffsetParent||Rs,e=this.getDimensions;return{reference:Ro(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,...await e(n.floating)}}};function Io(n){return D(n).direction==="rtl"}const No={convertOffsetParentRelativeRectToViewportRelativeRect:So,getDocumentElement:N,getClippingRect:Bo,getOffsetParent:Rs,getElementRects:$o,getClientRects:Co,getDimensions:Po,getScale:ut,isElement:I,isRTL:Io};function jo(n,t){let e=null,s;const i=N(n);function r(){var a;clearTimeout(s),(a=e)==null||a.disconnect(),e=null}function o(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),r();const{left:l,top:u,width:d,height:h}=n.getBoundingClientRect();if(a||t(),!d||!h)return;const g=Wt(u),f=Wt(i.clientWidth-(l+d)),m=Wt(i.clientHeight-(u+h)),b=Wt(l),v={rootMargin:-g+"px "+-f+"px "+-m+"px "+-b+"px",threshold:S(0,ht(1,c))||1};let E=!0;function y(w){const x=w[0].intersectionRatio;if(x!==c){if(!E)return o();x?o(!1,x):s=setTimeout(()=>{o(!1,1e-7)},100)}E=!1}try{e=new IntersectionObserver(y,{...v,root:i.ownerDocument})}catch{e=new IntersectionObserver(y,v)}e.observe(n)}return o(!0),r}function Ne(n,t,e,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=s,l=Ie(n),u=i||r?[...l?Dt(l):[],...Dt(t)]:[];u.forEach(p=>{i&&p.addEventListener("scroll",e,{passive:!0}),r&&p.addEventListener("resize",e)});const d=l&&a?jo(l,e):null;let h=-1,g=null;o&&(g=new ResizeObserver(p=>{let[v]=p;v&&v.target===l&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var E;(E=g)==null||E.observe(t)})),e()}),l&&!c&&g.observe(l),g.observe(t));let f,m=c?Q(n):null;c&&b();function b(){const p=Q(n);m&&(p.x!==m.x||p.y!==m.y||p.width!==m.width||p.height!==m.height)&&e(),m=p,f=requestAnimationFrame(b)}return e(),()=>{var p;u.forEach(v=>{i&&v.removeEventListener("scroll",e),r&&v.removeEventListener("resize",e)}),d==null||d(),(p=g)==null||p.disconnect(),g=null,c&&cancelAnimationFrame(f)}}const je=Eo,He=yo,Ho=Ao,Ve=(n,t,e)=>{const s=new Map,i={platform:No,...e},r={...i.platform,_c:s};return vo(n,t,{...i,platform:r})},Vo=(n,t,e)=>{let s=n;return e===!0?s=`${t.identifier}:${n}`:typeof e=="string"&&(s=`${e}:${n}`),s},Wo=(n,t,e)=>{const{bubbles:s,cancelable:i,composed:r}=t||{bubbles:!0,cancelable:!0,composed:!0};return t&&Object.assign(e,{originalEvent:t}),new CustomEvent(n,{bubbles:s,cancelable:i,composed:r,detail:e})};function Ko(n){const t=n.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,i=t.top<=e&&t.top+t.height>0,r=t.left<=s&&t.left+t.width>0;return i&&r}function Uo(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}const ge={debug:!1,logger:console,dispatchEvent:!0,eventPrefix:!0};class qo{constructor(t,e={}){var s,i,r;this.log=(c,l)=>{this.debug&&(this.logger.groupCollapsed(`%c${this.controller.identifier} %c#${c}`,"color: #3B82F6","color: unset"),this.logger.log(Object.assign({controllerId:this.controllerId},l)),this.logger.groupEnd())},this.warn=c=>{this.logger.warn(`%c${this.controller.identifier} %c${c}`,"color: #3B82F6; font-weight: bold","color: unset")},this.dispatch=(c,l={})=>{if(this.dispatchEvent){const{event:u}=l,d=Uo(l,["event"]),h=this.extendedEvent(c,u||null,d);this.targetElement.dispatchEvent(h),this.log("dispatchEvent",Object.assign({eventName:h.type},d))}},this.call=(c,l={})=>{const u=this.controller[c];if(typeof u=="function")return u.call(this.controller,l)},this.extendedEvent=(c,l,u)=>{const{bubbles:d,cancelable:h,composed:g}=l||{bubbles:!0,cancelable:!0,composed:!0};return l&&Object.assign(u,{originalEvent:l}),new CustomEvent(this.composeEventName(c),{bubbles:d,cancelable:h,composed:g,detail:u})},this.composeEventName=c=>{let l=c;return this.eventPrefix===!0?l=`${this.controller.identifier}:${c}`:typeof this.eventPrefix=="string"&&(l=`${this.eventPrefix}:${c}`),l},this.debug=(i=(s=e==null?void 0:e.debug)!==null&&s!==void 0?s:t.application.stimulusUseDebug)!==null&&i!==void 0?i:ge.debug,this.logger=(r=e==null?void 0:e.logger)!==null&&r!==void 0?r:ge.logger,this.controller=t,this.controllerId=t.element.id||t.element.dataset.id,this.targetElement=(e==null?void 0:e.element)||t.element;const{dispatchEvent:o,eventPrefix:a}=Object.assign({},ge,e);Object.assign(this,{dispatchEvent:o,eventPrefix:a}),this.controllerInitialize=t.initialize.bind(t),this.controllerConnect=t.connect.bind(t),this.controllerDisconnect=t.disconnect.bind(t)}}const zo={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},$s=(n,t={})=>{const e=n,{onlyVisible:s,dispatchEvent:i,events:r,eventPrefix:o}=Object.assign({},zo,t),a=d=>{const h=(t==null?void 0:t.element)||e.element;if(!(h.contains(d.target)||!Ko(h)&&s)&&(e.clickOutside&&e.clickOutside(d),i)){const g=Vo("click:outside",e,o),f=Wo(g,d,{controller:e});h.dispatchEvent(f)}},c=()=>{r==null||r.forEach(d=>{window.addEventListener(d,a,!0)})},l=()=>{r==null||r.forEach(d=>{window.removeEventListener(d,a,!0)})},u=e.disconnect.bind(e);return Object.assign(e,{disconnect(){l(),u()}}),c(),[c,l]};class Yo extends U{}Yo.debounces=[];const Xo=200,Yn=(n,t=Xo)=>{let e=null;return function(){const s=Array.from(arguments),i=this,r=s.map(a=>a.params),o=()=>(s.forEach((a,c)=>a.params=r[c]),n.apply(i,s));e&&clearTimeout(e),e=setTimeout(o,t)}},Go=(n,t)=>{const e=n;e.constructor.debounces.forEach(i=>{if(typeof i=="string"&&(e[i]=Yn(e[i],t==null?void 0:t.wait)),typeof i=="object"){const{name:r,wait:o}=i;if(!r)return;e[r]=Yn(e[r],o||(t==null?void 0:t.wait))}})};class Zo extends qo{constructor(t,e={}){super(t,e),this.observe=()=>{try{this.observer.observe(this.targetElement,this.options)}catch(s){this.controller.application.handleError(s,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}},this.unobserve=()=>{this.observer.disconnect()},this.mutation=s=>{this.call("mutate",s),this.log("mutate",{entries:s}),this.dispatch("mutate",{entries:s})},this.targetElement=(e==null?void 0:e.element)||t.element,this.controller=t,this.options=e,this.observer=new MutationObserver(this.mutation),this.enhanceController(),this.observe()}enhanceController(){const t=this.controller.disconnect.bind(this.controller),e=()=>{this.unobserve(),t()};Object.assign(this.controller,{disconnect:e})}}const Is=(n,t={})=>{const e=new Zo(n,t);return[e.observe,e.unobserve]};class Jo extends U{}Jo.throttles=[];class Qo extends Pt()({targets:{anchor:null,options:null,popover:null,searchInput:HTMLInputElement},values:{clamped:Boolean,placement:String}}){constructor(){super(...arguments),this.changedIds=new Set,this.clickHandlers=[]}setupClickHandlers(){const t=()=>this.toggle();for(const e of this.clickHandlers)e();this.clickHandlers=[];for(const e of this.anchorTarget.querySelectorAll('button, [tabindex]:not([tabindex="-1"])'))e.addEventListener("click",t),this.clickHandlers.push(()=>e.removeEventListener("click",t))}checkboxClicked(t){const s=t.target.value;this.changedIds.has(s)?this.changedIds.delete(s):this.changedIds.add(s),this.dispatch("clicked",{detail:s})}clickOutside(){this.element.open=!1,this.setupAutoUpdate(),this.close()}close(){this.hasSearchInputTarget&&(this.searchInputTarget.value=""),this.changedIds.size>0&&(this.dispatch("changed"),this.changedIds.clear())}connect(){$s(this),Is(this,{childList:!0,subtree:!0}),this.setupAutoUpdate(),this.setupClickHandlers()}disconnect(){var t;(t=this.unsubAutoUpdate)==null||t.call(this)}setupAutoUpdate(){var e;if(!this.element.open){(e=this.unsubAutoUpdate)==null||e.call(this);return}const t=()=>{const s=this.optionsTarget,i=this.hasSearchInputTarget?this.searchInputTarget:null,r=this.clampedValue;Ve(this.anchorTarget,this.popoverTarget,{middleware:[Pe(6),He(),je({padding:6}),Ho({apply({availableHeight:o}){const a=i?i.getBoundingClientRect().height:0;let c=o-a-6;r&&c>400&&(c=400),Object.assign(s.style,{maxHeight:`${c}px`})}})],placement:this.placementValue,strategy:"fixed"}).then(({x:o,y:a})=>{Object.assign(this.popoverTarget.style,{left:`${o}px`,top:`${a}px`})})};t(),this.unsubAutoUpdate=Ne(this.anchorTarget,this.popoverTarget,t)}toggle(){this.element.open=!this.element.open,this.setupAutoUpdate()}}const ta=Object.freeze(Object.defineProperty({__proto__:null,default:Qo},Symbol.toStringTag,{value:"Module"}));function ea(n){if(Array.isArray(n)){for(var t=0,e=Array(n.length);t<n.length;t++)e[t]=n[t];return e}else return Array.from(n)}var We=!1;if(typeof window<"u"){var Xn={get passive(){We=!0}};window.addEventListener("testPassive",null,Xn),window.removeEventListener("testPassive",null,Xn)}var Jt=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),J=[],Qt=!1,Ns=-1,St=void 0,G=void 0,Ct=void 0,js=function(t){return J.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(t))})},te=function(t){var e=t||window.event;return js(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},na=function(t){if(Ct===void 0){var e=!!t&&t.reserveScrollBarGap===!0,s=window.innerWidth-document.documentElement.clientWidth;if(e&&s>0){var i=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Ct=document.body.style.paddingRight,document.body.style.paddingRight=i+s+"px"}}St===void 0&&(St=document.body.style.overflow,document.body.style.overflow="hidden")},sa=function(){Ct!==void 0&&(document.body.style.paddingRight=Ct,Ct=void 0),St!==void 0&&(document.body.style.overflow=St,St=void 0)},ia=function(){return window.requestAnimationFrame(function(){if(G===void 0){G={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var t=window,e=t.scrollY,s=t.scrollX,i=t.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-s,setTimeout(function(){return window.requestAnimationFrame(function(){var r=i-window.innerHeight;r&&e>=i&&(document.body.style.top=-(e+r))})},300)}})},ra=function(){if(G!==void 0){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=G.position,document.body.style.top=G.top,document.body.style.left=G.left,window.scrollTo(e,t),G=void 0}},oa=function(t){return t?t.scrollHeight-t.scrollTop<=t.clientHeight:!1},aa=function(t,e){var s=t.targetTouches[0].clientY-Ns;return js(t.target)?!1:e&&e.scrollTop===0&&s>0||oa(e)&&s<0?te(t):(t.stopPropagation(),!0)},ca=function(t,e){if(!t){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!J.some(function(i){return i.targetElement===t})){var s={targetElement:t,options:e||{}};J=[].concat(ea(J),[s]),Jt?ia():na(e),Jt&&(t.ontouchstart=function(i){i.targetTouches.length===1&&(Ns=i.targetTouches[0].clientY)},t.ontouchmove=function(i){i.targetTouches.length===1&&aa(i,t)},Qt||(document.addEventListener("touchmove",te,We?{passive:!1}:void 0),Qt=!0))}},la=function(t){if(!t){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}J=J.filter(function(e){return e.targetElement!==t}),Jt&&(t.ontouchstart=null,t.ontouchmove=null,Qt&&J.length===0&&(document.removeEventListener("touchmove",te,We?{passive:!1}:void 0),Qt=!1)),Jt?ra():sa()};class ua extends Pt()({targets:{dialog:HTMLDialogElement}}){close(){this.dialogTarget.close(),la(this.dialogTarget)}disconnect(){this.close()}open(){this.dialogTarget.showModal(),ca(this.dialogTarget,{reserveScrollBarGap:!0})}triggerClick(){this.dialogTarget.open?this.close():this.open()}windowClick(t){t.target===this.dialogTarget&&this.close()}}const da=Object.freeze(Object.defineProperty({__proto__:null,default:ua},Symbol.toStringTag,{value:"Module"}));class ha extends Pt()({targets:{anchor:null,popover:null},values:{clamped:Boolean,placement:String}}){constructor(){super(...arguments),this.changedIds=new Set,this.clickHandlers=[]}setupClickHandlers(){const t=()=>this.toggle();for(const e of this.clickHandlers)e();this.clickHandlers=[];for(const e of this.anchorTarget.querySelectorAll('button, [tabindex]:not([tabindex="-1"])'))e.addEventListener("click",t),this.clickHandlers.push(()=>e.removeEventListener("click",t))}checkboxClicked(t){const s=t.target.value;this.changedIds.has(s)?this.changedIds.delete(s):this.changedIds.add(s),this.dispatch("clicked",{detail:s})}clickOutside(){this.setupAutoUpdate(),this.close()}close(){this.element.open=!1}connect(){$s(this),Is(this,{childList:!0,subtree:!0}),this.setupAutoUpdate(),this.setupClickHandlers()}disconnect(){var t;(t=this.unsubAutoUpdate)==null||t.call(this)}setupAutoUpdate(){var e;if(!this.element.open){(e=this.unsubAutoUpdate)==null||e.call(this);return}const t=()=>{Ve(this.anchorTarget,this.popoverTarget,{middleware:[Pe(6),He(),je({padding:6})],placement:this.placementValue,strategy:"fixed"}).then(({x:s,y:i})=>{Object.assign(this.popoverTarget.style,{left:`${s}px`,top:`${i}px`})})};t(),this.unsubAutoUpdate=Ne(this.anchorTarget,this.popoverTarget,t)}toggle(){this.element.open=!this.element.open,this.setupAutoUpdate()}}const fa=Object.freeze(Object.defineProperty({__proto__:null,default:ha},Symbol.toStringTag,{value:"Module"}));class ma extends Pt()({targets:{button:HTMLButtonElement,popover:HTMLElement},values:{placement:String}}){connect(){this.popoverTarget.addEventListener("toggle",t=>{t.newState==="open"&&this.updatePosition()})}updatePosition(){Ne(this.buttonTarget,this.popoverTarget,()=>{Ve(this.buttonTarget,this.popoverTarget,{placement:this.placementValue,middleware:[Pe(5),He(),je({padding:5})]}).then(({x:t,y:e})=>{Object.assign(this.target.style,{left:`${t}px`,top:`${e}px`})})})}}const pa=Object.freeze(Object.defineProperty({__proto__:null,default:ma},Symbol.toStringTag,{value:"Module"})),ee=class ee extends U{connect(){Go(this)}save(){this.hasFormTarget?this.formTarget.requestSubmit():this.element.requestSubmit()}};ee.debounces=["save"],ee.targets=["form"];let Ce=ee;const ga=Object.freeze(Object.defineProperty({__proto__:null,default:Ce},Symbol.toStringTag,{value:"Module"})),re=Ir.start();re.debug=!1;window.Stimulus=re;const ba=Object.assign({"../../components/ariadne/ui/clipboard_copy/component.ts":co,"../../components/ariadne/ui/combobox/component.ts":ta,"../../components/ariadne/ui/dialog/component.ts":da,"../../components/ariadne/ui/overlay/component.ts":fa,"../../components/ariadne/ui/popover/component.ts":pa});for(const[n,t]of Object.entries(ba)){const e=n.split("/"),s=e.slice(3,e.length-1).join("-").replaceAll("_","-").toLocaleLowerCase();re.register(s,t.default)}const va=Object.assign({"/controllers/autosubmittable_controller.ts":ga});for(const[n,t]of Object.entries(va)){const e=n.split("/"),s=e.slice(2,e.length).join("-").replace(".ts","").replaceAll("_","-").toLocaleLowerCase();re.register(`ariadne-${s}`,t.default)}
98
+ %o`,e,t,s),(i=window.onerror)===null||i===void 0||i.call(window,e,"",0,0,t)}logFormattedMessage(t,e,s={}){s=Object.assign({application:this},s),this.logger.groupCollapsed(`${t} #${e}`),this.logger.log("details:",Object.assign({},s)),this.logger.groupEnd()}}function Kr(){return new Promise(n=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>n()):n()})}function Ur(n){return Bt(n,"classes").reduce((e,s)=>Object.assign(e,qr(s)),{})}function qr(n){return{[`${n}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${_t(n)}Class`]:{get(){return this.classes.has(n)}}}}function zr(n){return Bt(n,"outlets").reduce((e,s)=>Object.assign(e,Yr(s)),{})}function Hn(n,t,e){return n.application.getControllerForElementAndIdentifier(t,e)}function Vn(n,t,e){let s=Hn(n,t,e);if(s||(n.application.router.proposeToConnectScopeForElementAndIdentifier(t,e),s=Hn(n,t,e),s))return s}function Yr(n){const t=Me(n);return{[`${t}Outlet`]:{get(){const e=this.outlets.find(n),s=this.outlets.getSelectorForOutletName(n);if(e){const i=Vn(this,e,n);if(i)return i;throw new Error(`The provided outlet element is missing an outlet controller "${n}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${n}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${t}Outlets`]:{get(){const e=this.outlets.findAll(n);return e.length>0?e.map(s=>{const i=Vn(this,s,n);if(i)return i;console.warn(`The provided outlet element is missing an outlet controller "${n}" instance for host controller "${this.identifier}"`,s)}).filter(s=>s):[]}},[`${t}OutletElement`]:{get(){const e=this.outlets.find(n),s=this.outlets.getSelectorForOutletName(n);if(e)return e;throw new Error(`Missing outlet element "${n}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(n)}},[`has${_t(t)}Outlet`]:{get(){return this.outlets.has(n)}}}}function Xr(n){return Bt(n,"targets").reduce((e,s)=>Object.assign(e,Gr(s)),{})}function Gr(n){return{[`${n}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${_t(n)}Target`]:{get(){return this.targets.has(n)}}}}function Zr(n){const t=Er(n,"values"),e={valueDescriptorMap:{get(){return t.reduce((s,i)=>{const r=ks(i,this.identifier),o=this.data.getAttributeNameForKey(r.key);return Object.assign(s,{[o]:r})},{})}}};return t.reduce((s,i)=>Object.assign(s,Jr(i)),e)}function Jr(n,t){const e=ks(n,t),{key:s,name:i,reader:r,writer:o}=e;return{[i]:{get(){const a=this.data.get(s);return a!==null?r(a):e.defaultValue},set(a){a===void 0?this.data.delete(s):this.data.set(s,o(a))}},[`has${_t(i)}`]:{get(){return this.data.has(s)||e.hasCustomDefaultValue}}}}function ks([n,t],e){return no({controller:e,token:n,typeDefinition:t})}function Yt(n){switch(n){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function Ft(n){switch(typeof n){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(n))return"array";if(Object.prototype.toString.call(n)==="[object Object]")return"object"}function Qr(n){const{controller:t,token:e,typeObject:s}=n,i=Rn(s.type),r=Rn(s.default),o=i&&r,a=i&&!r,c=!i&&r,l=Yt(s.type),u=Ft(n.typeObject.default);if(a)return l;if(c)return u;if(l!==u){const d=t?`${t}.${e}`:e;throw new Error(`The specified default value for the Stimulus Value "${d}" must match the defined type "${l}". The provided default value of "${s.default}" is of type "${u}".`)}if(o)return l}function to(n){const{controller:t,token:e,typeDefinition:s}=n,r=Qr({controller:t,token:e,typeObject:s}),o=Ft(s),a=Yt(s),c=r||o||a;if(c)return c;const l=t?`${t}.${s}`:e;throw new Error(`Unknown value type "${l}" for "${e}" value`)}function eo(n){const t=Yt(n);if(t)return Wn[t];const e=Se(n,"default"),s=Se(n,"type"),i=n;if(e)return i.default;if(s){const{type:r}=i,o=Yt(r);if(o)return Wn[o]}return n}function no(n){const{token:t,typeDefinition:e}=n,s=`${ys(t)}-value`,i=to(n);return{type:i,key:s,name:Pe(s),get defaultValue(){return eo(e)},get hasCustomDefaultValue(){return Ft(e)!==void 0},reader:so[i],writer:Kn[i]||Kn.default}}const Wn={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},so={array(n){const t=JSON.parse(n);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${n}" of type "${Ft(t)}"`);return t},boolean(n){return!(n=="0"||String(n).toLowerCase()=="false")},number(n){return Number(n.replace(/_/g,""))},object(n){const t=JSON.parse(n);if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${n}" of type "${Ft(t)}"`);return t},string(n){return n}},Kn={default:io,array:Un,object:Un};function Un(n){return JSON.stringify(n)}function io(n){return`${n}`}class N{constructor(t){this.context=t}static get shouldLoad(){return!0}static afterLoad(t,e){}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(t,{target:e=this.element,detail:s={},prefix:i=this.identifier,bubbles:r=!0,cancelable:o=!0}={}){const a=i?`${i}:${t}`:t,c=new CustomEvent(a,{detail:s,bubbles:r,cancelable:o});return e.dispatchEvent(c),c}}N.blessings=[Ur,Xr,Zr,zr];N.targets=[];N.outlets=[];N.values={};function $t(){return function({targets:t,values:e}={}){const i=class i extends N{};i.targets=Object.keys(t??{}),i.values=e??{};let s=i;return s}}function ro(n){const t=document.createElement("pre");return t.style.width="1px",t.style.height="1px",t.style.position="fixed",t.style.top="5px",t.textContent=n,t}function Ms(n){if("clipboard"in navigator)return navigator.clipboard.writeText(n.textContent||"");const t=getSelection();if(t==null)return Promise.reject(new Error);t.removeAllRanges();const e=document.createRange();return e.selectNodeContents(n),t.addRange(e),document.execCommand("copy"),t.removeAllRanges(),Promise.resolve()}function Le(n){if("clipboard"in navigator)return navigator.clipboard.writeText(n);const t=document.body;if(!t)return Promise.reject(new Error);const e=ro(n);return t.appendChild(e),Ms(e),t.removeChild(e),Promise.resolve()}async function Ss(n){const t=n.getAttribute("for"),e=n.getAttribute("value");function s(){n.dispatchEvent(new CustomEvent("clipboard-copy",{bubbles:!0}))}if(n.getAttribute("aria-disabled")!=="true"){if(e)await Le(e),s();else if(t){const i="getRootNode"in Element.prototype?n.getRootNode():n.ownerDocument;if(!(i instanceof Document||"ShadowRoot"in window&&i instanceof ShadowRoot))return;const r=i.getElementById(t);r&&(await oo(r),s())}}}function oo(n){return n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?Le(n.value):n instanceof HTMLAnchorElement&&n.hasAttribute("href")?Le(n.href):Ms(n)}function ao(n){const t=n.currentTarget;t instanceof HTMLElement&&Ss(t)}function Cs(n){if(n.key===" "||n.key==="Enter"){const t=n.currentTarget;t instanceof HTMLElement&&(n.preventDefault(),Ss(t))}}function co(n){n.currentTarget.addEventListener("keydown",Cs)}function lo(n){n.currentTarget.removeEventListener("keydown",Cs)}class uo extends HTMLElement{static define(t="clipboard-copy",e=customElements){return e.define(t,this),this}constructor(){super(),this.addEventListener("click",ao),this.addEventListener("focus",co),this.addEventListener("blur",lo)}connectedCallback(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","button")}get value(){return this.getAttribute("value")||""}set value(t){this.setAttribute("value",t)}}const qn=typeof globalThis<"u"?globalThis:window;try{qn.ClipboardCopyElement=uo.define()}catch(n){if(!(qn.DOMException&&n instanceof DOMException&&n.name==="NotSupportedError")&&!(n instanceof ReferenceError))throw n}const ho=2e3;class fo extends $t()({targets:{initial:HTMLElement,confirmed:null}}){connect(){this.clipboardCopyElementTimers=new WeakMap}copy(t){const e=t.target,s=this.clipboardCopyElementTimers.get(e);s?(clearTimeout(s),this.clipboardCopyElementTimers.delete(e)):this.showConfirm(),this.clipboardCopyElementTimers.set(e,window.setTimeout(()=>{this.showInitial(),this.clipboardCopyElementTimers.delete(e)},ho))}showConfirm(){this.hasConfirmedTarget&&(this.confirmedTarget.classList.remove("hidden"),this.confirmedTarget.classList.add("inline-block"),this.initialTarget.classList.add("hidden"))}showInitial(){this.initialTarget.classList.remove("hidden"),this.initialTarget.classList.add("inline-block"),this.hasConfirmedTarget&&this.confirmedTarget.classList.add("hidden")}}const mo=Object.freeze(Object.defineProperty({__proto__:null,default:fo},Symbol.toStringTag,{value:"Module"})),ht=Math.min,S=Math.max,Xt=Math.round,Wt=Math.floor,W=n=>({x:n,y:n}),po={left:"right",right:"left",bottom:"top",top:"bottom"},go={start:"end",end:"start"};function zn(n,t,e){return S(n,ht(t,e))}function Pt(n,t){return typeof n=="function"?n(t):n}function K(n){return n.split("-")[0]}function Rt(n){return n.split("-")[1]}function Ls(n){return n==="x"?"y":"x"}function Fs(n){return n==="y"?"height":"width"}function It(n){return["top","bottom"].includes(K(n))?"y":"x"}function Ds(n){return Ls(It(n))}function bo(n,t,e){e===void 0&&(e=!1);const s=Rt(n),i=Ds(n),r=Fs(i);let o=i==="x"?s===(e?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(o=Gt(o)),[o,Gt(o)]}function vo(n){const t=Gt(n);return[Fe(n),t,Fe(t)]}function Fe(n){return n.replace(/start|end/g,t=>go[t])}function yo(n,t,e){const s=["left","right"],i=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return e?t?i:s:t?s:i;case"left":case"right":return t?r:o;default:return[]}}function wo(n,t,e,s){const i=Rt(n);let r=yo(K(n),e==="start",s);return i&&(r=r.map(o=>o+"-"+i),t&&(r=r.concat(r.map(Fe)))),r}function Gt(n){return n.replace(/left|right|bottom|top/g,t=>po[t])}function Eo(n){return{top:0,right:0,bottom:0,left:0,...n}}function Ao(n){return typeof n!="number"?Eo(n):{top:n,right:n,bottom:n,left:n}}function Zt(n){return{...n,top:n.y,left:n.x,right:n.x+n.width,bottom:n.y+n.height}}function Yn(n,t,e){let{reference:s,floating:i}=n;const r=It(t),o=Ds(t),a=Fs(o),c=K(t),l=r==="y",u=s.x+s.width/2-i.width/2,d=s.y+s.height/2-i.height/2,h=s[a]/2-i[a]/2;let g;switch(c){case"top":g={x:u,y:s.y-i.height};break;case"bottom":g={x:u,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:d};break;case"left":g={x:s.x-i.width,y:d};break;default:g={x:s.x,y:s.y}}switch(Rt(t)){case"start":g[o]-=h*(e&&l?-1:1);break;case"end":g[o]+=h*(e&&l?-1:1);break}return g}const xo=async(n,t,e)=>{const{placement:s="bottom",strategy:i="absolute",middleware:r=[],platform:o}=e,a=r.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t));let l=await o.getElementRects({reference:n,floating:t,strategy:i}),{x:u,y:d}=Yn(l,s,c),h=s,g={},f=0;for(let m=0;m<a.length;m++){const{name:b,fn:p}=a[m],{x:v,y:E,data:y,reset:w}=await p({x:u,y:d,initialPlacement:s,placement:h,strategy:i,middlewareData:g,rects:l,platform:o,elements:{reference:n,floating:t}});u=v??u,d=E??d,g={...g,[b]:{...g[b],...y}},w&&f<=50&&(f++,typeof w=="object"&&(w.placement&&(h=w.placement),w.rects&&(l=w.rects===!0?await o.getElementRects({reference:n,floating:t,strategy:i}):w.rects),{x:u,y:d}=Yn(l,h,c)),m=-1)}return{x:u,y:d,placement:h,strategy:i,middlewareData:g}};async function Ie(n,t){var e;t===void 0&&(t={});const{x:s,y:i,platform:r,rects:o,elements:a,strategy:c}=n,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:g=0}=Pt(t,n),f=Ao(g),b=a[h?d==="floating"?"reference":"floating":d],p=Zt(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(b)))==null||e?b:b.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d==="floating"?{...o.floating,x:s,y:i}:o.reference,E=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),y=await(r.isElement==null?void 0:r.isElement(E))?await(r.getScale==null?void 0:r.getScale(E))||{x:1,y:1}:{x:1,y:1},w=Zt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:E,strategy:c}):v);return{top:(p.top-w.top+f.top)/y.y,bottom:(w.bottom-p.bottom+f.bottom)/y.y,left:(p.left-w.left+f.left)/y.x,right:(w.right-p.right+f.right)/y.x}}const To=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,s;const{placement:i,middlewareData:r,rects:o,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...b}=Pt(n,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const p=K(i),v=K(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(l.floating)),y=h||(v||!m?[Gt(a)]:vo(a));!h&&f!=="none"&&y.push(...wo(a,m,f,E));const w=[a,...y],x=await Ie(t,b),B=[];let H=((s=r.flip)==null?void 0:s.overflows)||[];if(u&&B.push(x[p]),d){const q=bo(i,o,E);B.push(x[q[0]],x[q[1]])}if(H=[...H,{placement:i,overflows:B}],!B.every(q=>q<=0)){var mt,Ye;const q=(((mt=r.flip)==null?void 0:mt.index)||0)+1,Ge=w[q];if(Ge)return{data:{index:q,overflows:H},reset:{placement:Ge}};let pt=(Ye=H.filter(tt=>tt.overflows[0]<=0).sort((tt,et)=>tt.overflows[1]-et.overflows[1])[0])==null?void 0:Ye.placement;if(!pt)switch(g){case"bestFit":{var Xe;const tt=(Xe=H.map(et=>[et.placement,et.overflows.filter(gt=>gt>0).reduce((gt,qs)=>gt+qs,0)]).sort((et,gt)=>et[1]-gt[1])[0])==null?void 0:Xe[0];tt&&(pt=tt);break}case"initialPlacement":pt=a;break}if(i!==pt)return{reset:{placement:pt}}}return{}}}};async function Oo(n,t){const{placement:e,platform:s,elements:i}=n,r=await(s.isRTL==null?void 0:s.isRTL(i.floating)),o=K(e),a=Rt(e),c=It(e)==="y",l=["left","top"].includes(o)?-1:1,u=r&&c?-1:1,d=Pt(t,n);let{mainAxis:h,crossAxis:g,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof f=="number"&&(g=a==="end"?f*-1:f),c?{x:g*u,y:h*l}:{x:h*l,y:g*u}}const Ne=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,s;const{x:i,y:r,placement:o,middlewareData:a}=t,c=await Oo(t,n);return o===((e=a.offset)==null?void 0:e.placement)&&(s=a.arrow)!=null&&s.alignmentOffset?{}:{x:i+c.x,y:r+c.y,data:{...c,placement:o}}}}},ko=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){const{x:e,y:s,placement:i}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:a={fn:b=>{let{x:p,y:v}=b;return{x:p,y:v}}},...c}=Pt(n,t),l={x:e,y:s},u=await Ie(t,c),d=It(K(i)),h=Ls(d);let g=l[h],f=l[d];if(r){const b=h==="y"?"top":"left",p=h==="y"?"bottom":"right",v=g+u[b],E=g-u[p];g=zn(v,g,E)}if(o){const b=d==="y"?"top":"left",p=d==="y"?"bottom":"right",v=f+u[b],E=f-u[p];f=zn(v,f,E)}const m=a.fn({...t,[h]:g,[d]:f});return{...m,data:{x:m.x-e,y:m.y-s}}}}},Mo=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(t){const{placement:e,rects:s,platform:i,elements:r}=t,{apply:o=()=>{},...a}=Pt(n,t),c=await Ie(t,a),l=K(e),u=Rt(e),d=It(e)==="y",{width:h,height:g}=s.floating;let f,m;l==="top"||l==="bottom"?(f=l,m=u===(await(i.isRTL==null?void 0:i.isRTL(r.floating))?"start":"end")?"left":"right"):(m=l,f=u==="end"?"top":"bottom");const b=g-c[f],p=h-c[m],v=!t.middlewareData.shift;let E=b,y=p;if(d){const x=h-c.left-c.right;y=u||v?ht(p,x):x}else{const x=g-c.top-c.bottom;E=u||v?ht(b,x):x}if(v&&!u){const x=S(c.left,0),B=S(c.right,0),H=S(c.top,0),mt=S(c.bottom,0);d?y=h-2*(x!==0||B!==0?x+B:S(c.left,c.right)):E=g-2*(H!==0||mt!==0?H+mt:S(c.top,c.bottom))}await o({...t,availableWidth:y,availableHeight:E});const w=await i.getDimensions(r.floating);return h!==w.width||g!==w.height?{reset:{rects:!0}}:{}}}};function U(n){return _s(n)?(n.nodeName||"").toLowerCase():"#document"}function C(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function j(n){var t;return(t=(_s(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function _s(n){return n instanceof Node||n instanceof C(n).Node}function I(n){return n instanceof Element||n instanceof C(n).Element}function $(n){return n instanceof HTMLElement||n instanceof C(n).HTMLElement}function Xn(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof C(n).ShadowRoot}function Nt(n){const{overflow:t,overflowX:e,overflowY:s,display:i}=D(n);return/auto|scroll|overlay|hidden|clip/.test(t+s+e)&&!["inline","contents"].includes(i)}function So(n){return["table","td","th"].includes(U(n))}function je(n){const t=He(),e=D(n);return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(s=>(e.willChange||"").includes(s))||["paint","layout","strict","content"].some(s=>(e.contain||"").includes(s))}function Co(n){let t=ft(n);for(;$(t)&&!ie(t);){if(je(t))return t;t=ft(t)}return null}function He(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ie(n){return["html","body","#document"].includes(U(n))}function D(n){return C(n).getComputedStyle(n)}function re(n){return I(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function ft(n){if(U(n)==="html")return n;const t=n.assignedSlot||n.parentNode||Xn(n)&&n.host||j(n);return Xn(t)?t.host:t}function Bs(n){const t=ft(n);return ie(t)?n.ownerDocument?n.ownerDocument.body:n.body:$(t)&&Nt(t)?t:Bs(t)}function Dt(n,t,e){var s;t===void 0&&(t=[]),e===void 0&&(e=!0);const i=Bs(n),r=i===((s=n.ownerDocument)==null?void 0:s.body),o=C(i);return r?t.concat(o,o.visualViewport||[],Nt(i)?i:[],o.frameElement&&e?Dt(o.frameElement):[]):t.concat(i,Dt(i,[],e))}function $s(n){const t=D(n);let e=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const i=$(n),r=i?n.offsetWidth:e,o=i?n.offsetHeight:s,a=Xt(e)!==r||Xt(s)!==o;return a&&(e=r,s=o),{width:e,height:s,$:a}}function Ve(n){return I(n)?n:n.contextElement}function ut(n){const t=Ve(n);if(!$(t))return W(1);const e=t.getBoundingClientRect(),{width:s,height:i,$:r}=$s(t);let o=(r?Xt(e.width):e.width)/s,a=(r?Xt(e.height):e.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Lo=W(0);function Ps(n){const t=C(n);return!He()||!t.visualViewport?Lo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Fo(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==C(n)?!1:t}function Q(n,t,e,s){t===void 0&&(t=!1),e===void 0&&(e=!1);const i=n.getBoundingClientRect(),r=Ve(n);let o=W(1);t&&(s?I(s)&&(o=ut(s)):o=ut(n));const a=Fo(r,e,s)?Ps(r):W(0);let c=(i.left+a.x)/o.x,l=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(r){const h=C(r),g=s&&I(s)?C(s):s;let f=h,m=f.frameElement;for(;m&&s&&g!==f;){const b=ut(m),p=m.getBoundingClientRect(),v=D(m),E=p.left+(m.clientLeft+parseFloat(v.paddingLeft))*b.x,y=p.top+(m.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,l*=b.y,u*=b.x,d*=b.y,c+=E,l+=y,f=C(m),m=f.frameElement}}return Zt({width:u,height:d,x:c,y:l})}const Do=[":popover-open",":modal"];function Rs(n){return Do.some(t=>{try{return n.matches(t)}catch{return!1}})}function _o(n){let{elements:t,rect:e,offsetParent:s,strategy:i}=n;const r=i==="fixed",o=j(s),a=t?Rs(t.floating):!1;if(s===o||a&&r)return e;let c={scrollLeft:0,scrollTop:0},l=W(1);const u=W(0),d=$(s);if((d||!d&&!r)&&((U(s)!=="body"||Nt(o))&&(c=re(s)),$(s))){const h=Q(s);l=ut(s),u.x=h.x+s.clientLeft,u.y=h.y+s.clientTop}return{width:e.width*l.x,height:e.height*l.y,x:e.x*l.x-c.scrollLeft*l.x+u.x,y:e.y*l.y-c.scrollTop*l.y+u.y}}function Bo(n){return Array.from(n.getClientRects())}function Is(n){return Q(j(n)).left+re(n).scrollLeft}function $o(n){const t=j(n),e=re(n),s=n.ownerDocument.body,i=S(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),r=S(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let o=-e.scrollLeft+Is(n);const a=-e.scrollTop;return D(s).direction==="rtl"&&(o+=S(t.clientWidth,s.clientWidth)-i),{width:i,height:r,x:o,y:a}}function Po(n,t){const e=C(n),s=j(n),i=e.visualViewport;let r=s.clientWidth,o=s.clientHeight,a=0,c=0;if(i){r=i.width,o=i.height;const l=He();(!l||l&&t==="fixed")&&(a=i.offsetLeft,c=i.offsetTop)}return{width:r,height:o,x:a,y:c}}function Ro(n,t){const e=Q(n,!0,t==="fixed"),s=e.top+n.clientTop,i=e.left+n.clientLeft,r=$(n)?ut(n):W(1),o=n.clientWidth*r.x,a=n.clientHeight*r.y,c=i*r.x,l=s*r.y;return{width:o,height:a,x:c,y:l}}function Gn(n,t,e){let s;if(t==="viewport")s=Po(n,e);else if(t==="document")s=$o(j(n));else if(I(t))s=Ro(t,e);else{const i=Ps(n);s={...t,x:t.x-i.x,y:t.y-i.y}}return Zt(s)}function Ns(n,t){const e=ft(n);return e===t||!I(e)||ie(e)?!1:D(e).position==="fixed"||Ns(e,t)}function Io(n,t){const e=t.get(n);if(e)return e;let s=Dt(n,[],!1).filter(a=>I(a)&&U(a)!=="body"),i=null;const r=D(n).position==="fixed";let o=r?ft(n):n;for(;I(o)&&!ie(o);){const a=D(o),c=je(o);!c&&a.position==="fixed"&&(i=null),(r?!c&&!i:!c&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Nt(o)&&!c&&Ns(n,o))?s=s.filter(u=>u!==o):i=a,o=ft(o)}return t.set(n,s),s}function No(n){let{element:t,boundary:e,rootBoundary:s,strategy:i}=n;const o=[...e==="clippingAncestors"?Io(t,this._c):[].concat(e),s],a=o[0],c=o.reduce((l,u)=>{const d=Gn(t,u,i);return l.top=S(d.top,l.top),l.right=ht(d.right,l.right),l.bottom=ht(d.bottom,l.bottom),l.left=S(d.left,l.left),l},Gn(t,a,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function jo(n){const{width:t,height:e}=$s(n);return{width:t,height:e}}function Ho(n,t,e){const s=$(t),i=j(t),r=e==="fixed",o=Q(n,!0,r,t);let a={scrollLeft:0,scrollTop:0};const c=W(0);if(s||!s&&!r)if((U(t)!=="body"||Nt(i))&&(a=re(t)),s){const d=Q(t,!0,r,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else i&&(c.x=Is(i));const l=o.left+a.scrollLeft-c.x,u=o.top+a.scrollTop-c.y;return{x:l,y:u,width:o.width,height:o.height}}function Zn(n,t){return!$(n)||D(n).position==="fixed"?null:t?t(n):n.offsetParent}function js(n,t){const e=C(n);if(!$(n)||Rs(n))return e;let s=Zn(n,t);for(;s&&So(s)&&D(s).position==="static";)s=Zn(s,t);return s&&(U(s)==="html"||U(s)==="body"&&D(s).position==="static"&&!je(s))?e:s||Co(n)||e}const Vo=async function(n){const t=this.getOffsetParent||js,e=this.getDimensions;return{reference:Ho(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,...await e(n.floating)}}};function Wo(n){return D(n).direction==="rtl"}const Ko={convertOffsetParentRelativeRectToViewportRelativeRect:_o,getDocumentElement:j,getClippingRect:No,getOffsetParent:js,getElementRects:Vo,getClientRects:Bo,getDimensions:jo,getScale:ut,isElement:I,isRTL:Wo};function Uo(n,t){let e=null,s;const i=j(n);function r(){var a;clearTimeout(s),(a=e)==null||a.disconnect(),e=null}function o(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),r();const{left:l,top:u,width:d,height:h}=n.getBoundingClientRect();if(a||t(),!d||!h)return;const g=Wt(u),f=Wt(i.clientWidth-(l+d)),m=Wt(i.clientHeight-(u+h)),b=Wt(l),v={rootMargin:-g+"px "+-f+"px "+-m+"px "+-b+"px",threshold:S(0,ht(1,c))||1};let E=!0;function y(w){const x=w[0].intersectionRatio;if(x!==c){if(!E)return o();x?o(!1,x):s=setTimeout(()=>{o(!1,1e-7)},100)}E=!1}try{e=new IntersectionObserver(y,{...v,root:i.ownerDocument})}catch{e=new IntersectionObserver(y,v)}e.observe(n)}return o(!0),r}function We(n,t,e,s){s===void 0&&(s={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=s,l=Ve(n),u=i||r?[...l?Dt(l):[],...Dt(t)]:[];u.forEach(p=>{i&&p.addEventListener("scroll",e,{passive:!0}),r&&p.addEventListener("resize",e)});const d=l&&a?Uo(l,e):null;let h=-1,g=null;o&&(g=new ResizeObserver(p=>{let[v]=p;v&&v.target===l&&g&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var E;(E=g)==null||E.observe(t)})),e()}),l&&!c&&g.observe(l),g.observe(t));let f,m=c?Q(n):null;c&&b();function b(){const p=Q(n);m&&(p.x!==m.x||p.y!==m.y||p.width!==m.width||p.height!==m.height)&&e(),m=p,f=requestAnimationFrame(b)}return e(),()=>{var p;u.forEach(v=>{i&&v.removeEventListener("scroll",e),r&&v.removeEventListener("resize",e)}),d==null||d(),(p=g)==null||p.disconnect(),g=null,c&&cancelAnimationFrame(f)}}const Ke=ko,Ue=To,qo=Mo,qe=(n,t,e)=>{const s=new Map,i={platform:Ko,...e},r={...i.platform,_c:s};return xo(n,t,{...i,platform:r})},zo=(n,t,e)=>{let s=n;return e===!0?s=`${t.identifier}:${n}`:typeof e=="string"&&(s=`${e}:${n}`),s},Yo=(n,t,e)=>{const{bubbles:s,cancelable:i,composed:r}=t||{bubbles:!0,cancelable:!0,composed:!0};return t&&Object.assign(e,{originalEvent:t}),new CustomEvent(n,{bubbles:s,cancelable:i,composed:r,detail:e})};function Xo(n){const t=n.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,i=t.top<=e&&t.top+t.height>0,r=t.left<=s&&t.left+t.width>0;return i&&r}function Go(n,t){var e={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.indexOf(s)<0&&(e[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(n);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(n,s[i])&&(e[s[i]]=n[s[i]]);return e}const be={debug:!1,logger:console,dispatchEvent:!0,eventPrefix:!0};class Zo{constructor(t,e={}){var s,i,r;this.log=(c,l)=>{this.debug&&(this.logger.groupCollapsed(`%c${this.controller.identifier} %c#${c}`,"color: #3B82F6","color: unset"),this.logger.log(Object.assign({controllerId:this.controllerId},l)),this.logger.groupEnd())},this.warn=c=>{this.logger.warn(`%c${this.controller.identifier} %c${c}`,"color: #3B82F6; font-weight: bold","color: unset")},this.dispatch=(c,l={})=>{if(this.dispatchEvent){const{event:u}=l,d=Go(l,["event"]),h=this.extendedEvent(c,u||null,d);this.targetElement.dispatchEvent(h),this.log("dispatchEvent",Object.assign({eventName:h.type},d))}},this.call=(c,l={})=>{const u=this.controller[c];if(typeof u=="function")return u.call(this.controller,l)},this.extendedEvent=(c,l,u)=>{const{bubbles:d,cancelable:h,composed:g}=l||{bubbles:!0,cancelable:!0,composed:!0};return l&&Object.assign(u,{originalEvent:l}),new CustomEvent(this.composeEventName(c),{bubbles:d,cancelable:h,composed:g,detail:u})},this.composeEventName=c=>{let l=c;return this.eventPrefix===!0?l=`${this.controller.identifier}:${c}`:typeof this.eventPrefix=="string"&&(l=`${this.eventPrefix}:${c}`),l},this.debug=(i=(s=e==null?void 0:e.debug)!==null&&s!==void 0?s:t.application.stimulusUseDebug)!==null&&i!==void 0?i:be.debug,this.logger=(r=e==null?void 0:e.logger)!==null&&r!==void 0?r:be.logger,this.controller=t,this.controllerId=t.element.id||t.element.dataset.id,this.targetElement=(e==null?void 0:e.element)||t.element;const{dispatchEvent:o,eventPrefix:a}=Object.assign({},be,e);Object.assign(this,{dispatchEvent:o,eventPrefix:a}),this.controllerInitialize=t.initialize.bind(t),this.controllerConnect=t.connect.bind(t),this.controllerDisconnect=t.disconnect.bind(t)}}const Jo={events:["click","touchend"],onlyVisible:!0,dispatchEvent:!0,eventPrefix:!0},Hs=(n,t={})=>{const e=n,{onlyVisible:s,dispatchEvent:i,events:r,eventPrefix:o}=Object.assign({},Jo,t),a=d=>{const h=(t==null?void 0:t.element)||e.element;if(!(h.contains(d.target)||!Xo(h)&&s)&&(e.clickOutside&&e.clickOutside(d),i)){const g=zo("click:outside",e,o),f=Yo(g,d,{controller:e});h.dispatchEvent(f)}},c=()=>{r==null||r.forEach(d=>{window.addEventListener(d,a,!0)})},l=()=>{r==null||r.forEach(d=>{window.removeEventListener(d,a,!0)})},u=e.disconnect.bind(e);return Object.assign(e,{disconnect(){l(),u()}}),c(),[c,l]};class Qo extends N{}Qo.debounces=[];const ta=200,Jn=(n,t=ta)=>{let e=null;return function(){const s=Array.from(arguments),i=this,r=s.map(a=>a.params),o=()=>(s.forEach((a,c)=>a.params=r[c]),n.apply(i,s));e&&clearTimeout(e),e=setTimeout(o,t)}},ea=(n,t)=>{const e=n;e.constructor.debounces.forEach(i=>{if(typeof i=="string"&&(e[i]=Jn(e[i],t==null?void 0:t.wait)),typeof i=="object"){const{name:r,wait:o}=i;if(!r)return;e[r]=Jn(e[r],o||(t==null?void 0:t.wait))}})};class na extends Zo{constructor(t,e={}){super(t,e),this.observe=()=>{try{this.observer.observe(this.targetElement,this.options)}catch(s){this.controller.application.handleError(s,"At a minimum, one of childList, attributes, and/or characterData must be true",{})}},this.unobserve=()=>{this.observer.disconnect()},this.mutation=s=>{this.call("mutate",s),this.log("mutate",{entries:s}),this.dispatch("mutate",{entries:s})},this.targetElement=(e==null?void 0:e.element)||t.element,this.controller=t,this.options=e,this.observer=new MutationObserver(this.mutation),this.enhanceController(),this.observe()}enhanceController(){const t=this.controller.disconnect.bind(this.controller),e=()=>{this.unobserve(),t()};Object.assign(this.controller,{disconnect:e})}}const Vs=(n,t={})=>{const e=new na(n,t);return[e.observe,e.unobserve]};class sa extends N{}sa.throttles=[];class ia extends $t()({targets:{anchor:null,options:null,popover:null,searchInput:HTMLInputElement},values:{clamped:Boolean,placement:String}}){constructor(){super(...arguments),this.changedIds=new Set,this.clickHandlers=[]}setupClickHandlers(){const t=()=>this.toggle();for(const e of this.clickHandlers)e();this.clickHandlers=[];for(const e of this.anchorTarget.querySelectorAll('button, [tabindex]:not([tabindex="-1"])'))e.addEventListener("click",t),this.clickHandlers.push(()=>e.removeEventListener("click",t))}checkboxClicked(t){const s=t.target.value;this.changedIds.has(s)?this.changedIds.delete(s):this.changedIds.add(s),this.dispatch("clicked",{detail:s})}clickOutside(){this.element.open=!1,this.setupAutoUpdate(),this.close()}close(){this.hasSearchInputTarget&&(this.searchInputTarget.value=""),this.changedIds.size>0&&(this.dispatch("changed"),this.changedIds.clear())}connect(){Hs(this),Vs(this,{childList:!0,subtree:!0}),this.setupAutoUpdate(),this.setupClickHandlers()}disconnect(){var t;(t=this.unsubAutoUpdate)==null||t.call(this)}setupAutoUpdate(){var e;if(!this.element.open){(e=this.unsubAutoUpdate)==null||e.call(this);return}const t=()=>{const s=this.optionsTarget,i=this.hasSearchInputTarget?this.searchInputTarget:null,r=this.clampedValue;qe(this.anchorTarget,this.popoverTarget,{middleware:[Ne(6),Ue(),Ke({padding:6}),qo({apply({availableHeight:o}){const a=i?i.getBoundingClientRect().height:0;let c=o-a-6;r&&c>400&&(c=400),Object.assign(s.style,{maxHeight:`${c}px`})}})],placement:this.placementValue,strategy:"fixed"}).then(({x:o,y:a})=>{Object.assign(this.popoverTarget.style,{left:`${o}px`,top:`${a}px`})})};t(),this.unsubAutoUpdate=We(this.anchorTarget,this.popoverTarget,t)}toggle(){this.element.open=!this.element.open,this.setupAutoUpdate()}}const ra=Object.freeze(Object.defineProperty({__proto__:null,default:ia},Symbol.toStringTag,{value:"Module"}));function oa(n){if(Array.isArray(n)){for(var t=0,e=Array(n.length);t<n.length;t++)e[t]=n[t];return e}else return Array.from(n)}var ze=!1;if(typeof window<"u"){var Qn={get passive(){ze=!0}};window.addEventListener("testPassive",null,Qn),window.removeEventListener("testPassive",null,Qn)}var Jt=typeof window<"u"&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||window.navigator.platform==="MacIntel"&&window.navigator.maxTouchPoints>1),J=[],Qt=!1,Ws=-1,St=void 0,G=void 0,Ct=void 0,Ks=function(t){return J.some(function(e){return!!(e.options.allowTouchMove&&e.options.allowTouchMove(t))})},te=function(t){var e=t||window.event;return Ks(e.target)||e.touches.length>1?!0:(e.preventDefault&&e.preventDefault(),!1)},aa=function(t){if(Ct===void 0){var e=!!t&&t.reserveScrollBarGap===!0,s=window.innerWidth-document.documentElement.clientWidth;if(e&&s>0){var i=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Ct=document.body.style.paddingRight,document.body.style.paddingRight=i+s+"px"}}St===void 0&&(St=document.body.style.overflow,document.body.style.overflow="hidden")},ca=function(){Ct!==void 0&&(document.body.style.paddingRight=Ct,Ct=void 0),St!==void 0&&(document.body.style.overflow=St,St=void 0)},la=function(){return window.requestAnimationFrame(function(){if(G===void 0){G={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var t=window,e=t.scrollY,s=t.scrollX,i=t.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-s,setTimeout(function(){return window.requestAnimationFrame(function(){var r=i-window.innerHeight;r&&e>=i&&(document.body.style.top=-(e+r))})},300)}})},ua=function(){if(G!==void 0){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=G.position,document.body.style.top=G.top,document.body.style.left=G.left,window.scrollTo(e,t),G=void 0}},da=function(t){return t?t.scrollHeight-t.scrollTop<=t.clientHeight:!1},ha=function(t,e){var s=t.targetTouches[0].clientY-Ws;return Ks(t.target)?!1:e&&e.scrollTop===0&&s>0||da(e)&&s<0?te(t):(t.stopPropagation(),!0)},fa=function(t,e){if(!t){console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");return}if(!J.some(function(i){return i.targetElement===t})){var s={targetElement:t,options:e||{}};J=[].concat(oa(J),[s]),Jt?la():aa(e),Jt&&(t.ontouchstart=function(i){i.targetTouches.length===1&&(Ws=i.targetTouches[0].clientY)},t.ontouchmove=function(i){i.targetTouches.length===1&&ha(i,t)},Qt||(document.addEventListener("touchmove",te,ze?{passive:!1}:void 0),Qt=!0))}},ma=function(t){if(!t){console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");return}J=J.filter(function(e){return e.targetElement!==t}),Jt&&(t.ontouchstart=null,t.ontouchmove=null,Qt&&J.length===0&&(document.removeEventListener("touchmove",te,ze?{passive:!1}:void 0),Qt=!1)),Jt?ua():ca()};class pa extends $t()({targets:{dialog:HTMLDialogElement}}){close(){this.dialogTarget.close(),ma(this.dialogTarget)}disconnect(){this.close()}open(){this.dialogTarget.showModal(),fa(this.dialogTarget,{reserveScrollBarGap:!0})}triggerClick(){this.dialogTarget.open?this.close():this.open()}windowClick(t){t.target===this.dialogTarget&&this.close()}}const ga=Object.freeze(Object.defineProperty({__proto__:null,default:pa},Symbol.toStringTag,{value:"Module"}));async function ba(n,t=null){n.classList.remove("hidden"),await Us("enter",n,t)}async function va(n,t=null){await Us("leave",n,t),n.classList.add("hidden")}async function Us(n,t,e){const s=t.dataset,i=e?`${e}-${n}`:n;let r=`transition${n.charAt(0).toUpperCase()+n.slice(1)}`;const o=s[r]?s[r].split(" "):[i],a=s[`${r}Start`]?s[`${r}Start`].split(" "):[`${i}-start`],c=s[`${r}End`]?s[`${r}End`].split(" "):[`${i}-end`];ve(t,o),ve(t,a),await ya(),ye(t,a),ve(t,c),await wa(t),ye(t,c),ye(t,o)}function ve(n,t){n.classList.add(...t)}function ye(n,t){n.classList.remove(...t)}function ya(){return new Promise(n=>{requestAnimationFrame(()=>{requestAnimationFrame(n)})})}function wa(n){return new Promise(t=>{const e=getComputedStyle(n).transitionDuration.split(",")[0],s=Number(e.replace("s",""))*1e3;setTimeout(()=>{t()},s)})}const ee=class ee extends N{async connect(){await this.show();const t=()=>{};setTimeout(()=>{this.hide().then(t).catch(t)},this.timerValue)}async disconnect(){await this.hide()}async hide(){await va(this.element),this.hasHiddenClass?this.element.classList.add(this.hiddenClass):this.element.classList.add("hidden"),this.element.remove()}async show(){this.hasHiddenClass?this.element.classList.remove(this.hiddenClass):this.element.classList.remove("hidden"),await ba(this.element)}};ee.classes=["ariadne-hidden"],ee.values={timer:{default:4e3,type:Number}};let De=ee;const Ea=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"}));class Aa extends $t()({targets:{anchor:null,popover:null},values:{clamped:Boolean,placement:String}}){constructor(){super(...arguments),this.changedIds=new Set,this.clickHandlers=[]}setupClickHandlers(){const t=()=>this.toggle();for(const e of this.clickHandlers)e();this.clickHandlers=[];for(const e of this.anchorTarget.querySelectorAll('button, [tabindex]:not([tabindex="-1"])'))e.addEventListener("click",t),this.clickHandlers.push(()=>e.removeEventListener("click",t))}checkboxClicked(t){const s=t.target.value;this.changedIds.has(s)?this.changedIds.delete(s):this.changedIds.add(s),this.dispatch("clicked",{detail:s})}clickOutside(){this.setupAutoUpdate(),this.close()}close(){this.element.open=!1}connect(){Hs(this),Vs(this,{childList:!0,subtree:!0}),this.setupAutoUpdate(),this.setupClickHandlers()}disconnect(){var t;(t=this.unsubAutoUpdate)==null||t.call(this)}setupAutoUpdate(){var e;if(!this.element.open){(e=this.unsubAutoUpdate)==null||e.call(this);return}const t=()=>{qe(this.anchorTarget,this.popoverTarget,{middleware:[Ne(6),Ue(),Ke({padding:6})],placement:this.placementValue,strategy:"fixed"}).then(({x:s,y:i})=>{Object.assign(this.popoverTarget.style,{left:`${s}px`,top:`${i}px`})})};t(),this.unsubAutoUpdate=We(this.anchorTarget,this.popoverTarget,t)}toggle(){this.element.open=!this.element.open,this.setupAutoUpdate()}}const xa=Object.freeze(Object.defineProperty({__proto__:null,default:Aa},Symbol.toStringTag,{value:"Module"}));class Ta extends $t()({targets:{button:HTMLButtonElement,popover:HTMLElement},values:{placement:String}}){connect(){this.popoverTarget.addEventListener("toggle",t=>{t.newState==="open"&&this.updatePosition()})}updatePosition(){We(this.buttonTarget,this.popoverTarget,()=>{qe(this.buttonTarget,this.popoverTarget,{placement:this.placementValue,middleware:[Ne(5),Ue(),Ke({padding:5})]}).then(({x:t,y:e})=>{Object.assign(this.target.style,{left:`${t}px`,top:`${e}px`})})})}}const Oa=Object.freeze(Object.defineProperty({__proto__:null,default:Ta},Symbol.toStringTag,{value:"Module"})),ne=class ne extends N{connect(){ea(this)}save(){this.hasFormTarget?this.formTarget.requestSubmit():this.element.requestSubmit()}};ne.debounces=["save"],ne.targets=["form"];let _e=ne;const ka=Object.freeze(Object.defineProperty({__proto__:null,default:_e},Symbol.toStringTag,{value:"Module"})),oe=Wr.start();oe.debug=!1;window.Stimulus=oe;const Ma=Object.assign({"../../components/ariadne/ui/clipboard_copy/component.ts":mo,"../../components/ariadne/ui/combobox/component.ts":ra,"../../components/ariadne/ui/dialog/component.ts":ga,"../../components/ariadne/ui/flash/component.ts":Ea,"../../components/ariadne/ui/overlay/component.ts":xa,"../../components/ariadne/ui/popover/component.ts":Oa});for(const[n,t]of Object.entries(Ma)){const e=n.split("/"),s=e.slice(3,e.length-1).join("-").replaceAll("_","-").toLocaleLowerCase();oe.register(s,t.default)}const Sa=Object.assign({"/controllers/autosubmittable_controller.ts":ka});for(const[n,t]of Object.entries(Sa)){const e=n.split("/"),s=e.slice(2,e.length).join("-").replace(".ts","").replaceAll("_","-").toLocaleLowerCase();oe.register(`ariadne-${s}`,t.default)}
99
99
  //# sourceMappingURL=ariadne_view_components.js.map