summaryrefslogtreecommitdiff
path: root/assets/outbox/Release v0.54.0 · hyprwm_Hyprland_files/51210-185739338ae8119b.js
blob: a7ef0388cdf486e815cb12df2883ce26fbe12ac0 (plain)
1
2
3
performance.mark("js-parse-end:51210-185739338ae8119b.js");
"use strict";(globalThis.webpackChunk_github_ui_github_ui=globalThis.webpackChunk_github_ui_github_ui||[]).push([["51210"],{9841(t,e,i){i.r(e),i.d(e,{default:()=>f});class n{constructor(t,e,{tabInsertsSuggestions:i,defaultFirstOption:n,scrollIntoViewOptions:s}={}){this.input=t,this.list=e,this.tabInsertsSuggestions=null==i||i,this.defaultFirstOption=null!=n&&n,this.scrollIntoViewOptions=null!=s?s:{block:"nearest",inline:"nearest"},this.isComposing=!1,e.id||(e.id=`combobox-${Math.random().toString().slice(2,6)}`),this.ctrlBindings=!!navigator.userAgent.match(/Macintosh/),this.keyboardEventHandler=t=>(function(t,e){if(!t.shiftKey&&!t.metaKey&&!t.altKey&&(e.ctrlBindings||!t.ctrlKey)&&!e.isComposing)switch(t.key){case"Enter":o(e.input,e.list)&&t.preventDefault();break;case"Tab":e.tabInsertsSuggestions&&o(e.input,e.list)&&t.preventDefault();break;case"Escape":e.clearSelection();break;case"ArrowDown":e.navigate(1),t.preventDefault();break;case"ArrowUp":e.navigate(-1),t.preventDefault();break;case"n":e.ctrlBindings&&t.ctrlKey&&(e.navigate(1),t.preventDefault());break;case"p":e.ctrlBindings&&t.ctrlKey&&(e.navigate(-1),t.preventDefault());break;default:if(t.ctrlKey)break;e.clearSelection()}})(t,this),this.compositionEventHandler=t=>{var e,i;return e=t,i=this,void(i.isComposing="compositionstart"===e.type,document.getElementById(i.input.getAttribute("aria-controls")||"")&&i.clearSelection())},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",s),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",s)}indicateDefaultOption(){var t;this.defaultFirstOption&&(null==(t=Array.from(this.list.querySelectorAll('[role="option"]:not([aria-disabled="true"])')).filter(l)[0])||t.setAttribute("data-combobox-option-default","true"))}navigate(t=1){let e=Array.from(this.list.querySelectorAll('[aria-selected="true"]')).filter(l)[0],i=Array.from(this.list.querySelectorAll('[role="option"]')).filter(l),n=i.indexOf(e);if(n===i.length-1&&1===t||0===n&&-1===t){this.clearSelection(),this.input.focus();return}let s=1===t?0:i.length-1;if(e&&n>=0){let e=n+t;e>=0&&e<i.length&&(s=e)}let o=i[s];if(o)for(let t of i)t.removeAttribute("data-combobox-option-default"),o===t?(this.input.setAttribute("aria-activedescendant",o.id),o.setAttribute("aria-selected","true"),o.dispatchEvent(new Event("combobox-select",{bubbles:!0})),o.scrollIntoView(this.scrollIntoViewOptions)):t.removeAttribute("aria-selected")}clearSelection(){for(let t of(this.input.removeAttribute("aria-activedescendant"),this.list.querySelectorAll('[aria-selected="true"]')))t.removeAttribute("aria-selected");this.indicateDefaultOption()}}function s(t){var e,i;if(!(t.target instanceof Element))return;let n=t.target.closest('[role="option"]');n&&"true"!==n.getAttribute("aria-disabled")&&(e=n,i={event:t},e.dispatchEvent(new CustomEvent("combobox-commit",{bubbles:!0,detail:i})))}function o(t,e){let i=e.querySelector('[aria-selected="true"], [data-combobox-option-default="true"]');return!!i&&("true"===i.getAttribute("aria-disabled")||(i.click(),!0))}function l(t){return!t.hidden&&!(t instanceof HTMLInputElement&&"hidden"===t.type)&&(t.offsetWidth>0||t.offsetHeight>0)}let r=/\s|\(|\[/;class a extends Event{constructor(){super("update")}}let h=new WeakMap;class u extends EventTarget{#t=new MutationObserver(()=>this.#e());#i=new ResizeObserver(()=>this.#n());#s;#o=document.createElement("div");#l=document.createElement("div");static for(t){let e=h.get(t);return e||(e=new u(t),h.set(t,e)),e}constructor(t){super(),this.#s=new WeakRef(t),this.#o.style.position="absolute",this.#o.style.pointerEvents="none",this.#o.setAttribute("aria-hidden","true"),this.#o.appendChild(this.#l),this.#l.style.pointerEvents="none",this.#l.style.userSelect="none",this.#l.style.overflow="hidden",this.#l.style.display="block",this.#l.style.visibility="hidden",t instanceof HTMLTextAreaElement?(this.#l.style.whiteSpace="pre-wrap",this.#l.style.wordWrap="break-word"):(this.#l.style.whiteSpace="nowrap",this.#l.style.display="table-cell",this.#l.style.verticalAlign="middle"),t.after(this.#o),this.#e(),this.#r(),this.#t.observe(t,{attributeFilter:["style","dir"]}),this.#i.observe(t),document.addEventListener("scroll",this.#a,{capture:!0}),window.addEventListener("resize",this.#a,{capture:!0}),t.addEventListener("input",this.#h,{capture:!0})}get element(){return this.#l}forceUpdate(){this.#e(),this.#r()}disconnect(){this.#o?.remove(),this.#t.disconnect(),this.#i.disconnect(),document.removeEventListener("scroll",this.#a,{capture:!0}),window.removeEventListener("resize",this.#a,{capture:!0});let t=this.#u;t&&(t.removeEventListener("input",this.#h,{capture:!0}),h.delete(t))}get #u(){return this.#s?.deref()}#c(t){let e=this.#u;return e?t(e):this.disconnect()}#d=0;#p=0;#m(){this.#c(t=>{let e=window.getComputedStyle(t);this.#l.style.height=e.height,this.#l.style.width=e.width,t.clientHeight!==this.#l.clientHeight&&(this.#l.style.height=`calc(${e.height} + ${t.clientHeight-this.#l.clientHeight}px)`),t.clientWidth!==this.#l.clientWidth&&(this.#l.style.width=`calc(${e.width} + ${t.clientWidth-this.#l.clientWidth}px)`);let i=t.getBoundingClientRect(),n=this.#l.getBoundingClientRect();this.#d=this.#d+i.left-n.left,this.#p=this.#p+i.top-n.top,this.#l.style.transform=`translate(${this.#d}px, ${this.#p}px)`,this.#l.scrollTop=t.scrollTop,this.#l.scrollLeft=t.scrollLeft,this.dispatchEvent(new a)})}#f=!1;#n(){this.#f||(this.#f=!0,requestAnimationFrame(()=>{this.#m(),this.#f=!1}))}#e(){this.#c(t=>{let e=window.getComputedStyle(t);for(let t of c)this.#l.style[t]=e[t];this.#n()})}#r(){this.#c(t=>{this.#l.textContent=t.value,this.#m()})}#h=()=>this.#r();#a=t=>{this.#c(e=>{(t.target===document||t.target===window||t.target instanceof Node&&t.target.contains(e))&&this.#n()})}}let c=["direction","writingMode","unicodeBidi","textOrientation","boxSizing","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"];class d{#v;#g;#b;constructor(t,e=0,i=e){this.#v=t,this.#g=e,this.#b=i}static fromSelection(t){let{selectionStart:e,selectionEnd:i}=t;return new d(t,e??void 0,i??void 0)}get collapsed(){return this.startOffset===this.endOffset}get commonAncestorContainer(){return this.#v}get endContainer(){return this.#v}get startContainer(){return this.#v}get startOffset(){return this.#g}get endOffset(){return this.#b}setStartOffset(t){this.#g=this.#E(t)}setEndOffset(t){this.#b=this.#E(t)}collapse(t=!1){t?this.setEndOffset(this.startOffset):this.setStartOffset(this.endOffset)}cloneContents(){return this.#y().cloneContents()}cloneRange(){return new d(this.#v,this.startOffset,this.endOffset)}getBoundingClientRect(){return this.#y().getBoundingClientRect()}getClientRects(){return this.#y().getClientRects()}toString(){return this.#y().toString()}getStyleClone(){return this.#x}get #x(){return u.for(this.#v)}get #l(){return this.#x}#E(t){return Math.max(0,Math.min(t,this.#v.value.length))}#y(){let t=document.createRange(),e=this.#l.element.childNodes[0];return e&&(t.setStart(e,this.startOffset),t.setEnd(e,this.endOffset)),t}}let p=new WeakMap;class m{constructor(t,e){this.expander=t,this.input=e,this.combobox=null,this.menu=null,this.match=null,this.justPasted=!1,this.lookBackIndex=0,this.oninput=this.onInput.bind(this),this.onpaste=this.onPaste.bind(this),this.onkeydown=this.onKeydown.bind(this),this.oncommit=this.onCommit.bind(this),this.onmousedown=this.onMousedown.bind(this),this.onblur=this.onBlur.bind(this),this.interactingWithList=!1,e.addEventListener("paste",this.onpaste),e.addEventListener("input",this.oninput),e.addEventListener("keydown",this.onkeydown),e.addEventListener("blur",this.onblur)}destroy(){this.input.removeEventListener("paste",this.onpaste),this.input.removeEventListener("input",this.oninput),this.input.removeEventListener("keydown",this.onkeydown),this.input.removeEventListener("blur",this.onblur)}dismissMenu(){this.deactivate()&&(this.lookBackIndex=this.input.selectionEnd||this.lookBackIndex)}activate(t,e){var i,s;(this.input===document.activeElement||this.input===(null==(s=null==(i=document.activeElement)?void 0:i.shadowRoot)?void 0:s.activeElement))&&(this.deactivate(),this.menu=e,e.id||(e.id=`text-expander-${Math.floor(1e5*Math.random()).toString()}`),this.expander.append(e),this.combobox=new n(this.input,e),this.expander.dispatchEvent(new Event("text-expander-activate")),this.positionMenu(e,t.position),this.combobox.start(),e.addEventListener("combobox-commit",this.oncommit),e.addEventListener("mousedown",this.onmousedown),this.combobox.navigate(1))}positionMenu(t,e){let i=Math.min(e,this.input.value.length),n=new d(this.input,i).getBoundingClientRect(),s={left:n.left,top:n.top+n.height},o=t.getBoundingClientRect(),l={left:s.left-o.left,top:s.top-o.top};if(0!==l.left||0!==l.top){let e=getComputedStyle(t);t.style.left=e.left?`calc(${e.left} + ${l.left}px)`:`${l.left}px`,t.style.top=e.top?`calc(${e.top} + ${l.top}px)`:`${l.top}px`}}deactivate(){let t=this.menu;return!!t&&!!this.combobox&&(this.expander.dispatchEvent(new Event("text-expander-deactivate")),this.menu=null,t.removeEventListener("combobox-commit",this.oncommit),t.removeEventListener("mousedown",this.onmousedown),this.combobox.destroy(),this.combobox=null,t.remove(),!0)}onCommit({target:t}){var e;if(!(t instanceof HTMLElement)||!this.combobox)return;let i=this.match;if(!i)return;let n=this.input.value.substring(0,i.position-i.key.length),s=this.input.value.substring(i.position+i.text.length),o={item:t,key:i.key,value:null,continue:!1};if(!this.expander.dispatchEvent(new CustomEvent("text-expander-value",{cancelable:!0,detail:o}))||!o.value)return;let l=null!=(e=this.expander.getAttribute("suffix"))?e:" ";o.continue&&(l="");let r=`${o.value}${l}`;this.input.value=n+r+s;let a=n.length+r.length;this.deactivate(),this.input.focus({preventScroll:!0}),this.input.selectionStart=a,this.input.selectionEnd=a,o.continue||(this.lookBackIndex=a,this.match=null),this.expander.dispatchEvent(new CustomEvent("text-expander-committed",{cancelable:!1,detail:{input:this.input}}))}onBlur(){if(this.interactingWithList){this.interactingWithList=!1;return}this.deactivate()}onPaste(){this.justPasted=!0}isMatchStillValid(t){return t.position<=this.input.value.length}async onInput(){if(this.justPasted){this.justPasted=!1;return}let t=this.findMatch();if(t){this.match=t;let e=await this.notifyProviders(t);if(!this.match||!this.isMatchStillValid(t)){this.match=null,this.deactivate();return}e?this.activate(t,e):this.deactivate()}else this.match=null,this.deactivate()}findMatch(){let t=this.input.selectionEnd||0,e=this.input.value;for(let{key:i,multiWord:n}of(t<=this.lookBackIndex&&(this.lookBackIndex=t-1),this.expander.keys)){let s=function(t,e,i,{multiWord:n,lookBackIndex:s,lastMatchPosition:o}={multiWord:!1,lookBackIndex:0,lastMatchPosition:null}){let l=t.lastIndexOf(e,i-1);if(-1===l||l<s)return;if(n){if(null!=o){if(o===l)return;l=o-e.length}if(" "===t[l+1]&&i>=l+e.length+1||t.lastIndexOf("\n",i-1)>l||t.lastIndexOf(".",i-1)>l)return}else if(t.lastIndexOf(" ",i-1)>l)return;let a=t[l-1];if(!a||r.test(a))return{text:t.substring(l+e.length,i),position:l+e.length}}(e,i,t,{multiWord:n,lookBackIndex:this.lookBackIndex,lastMatchPosition:this.match?this.match.position:null});if(s)return{text:s.text,key:i,position:s.position}}}async notifyProviders(t){let e=[],i=new CustomEvent("text-expander-change",{cancelable:!0,detail:{provide:t=>e.push(t),text:t.text,key:t.key}});if(this.expander.dispatchEvent(i))return(await Promise.all(e)).filter(t=>t.matched).map(t=>t.fragment)[0]}onMousedown(){this.interactingWithList=!0}onKeydown(t){"Escape"===t.key&&(this.match=null,this.deactivate()&&(this.lookBackIndex=this.input.selectionEnd||this.lookBackIndex,t.stopImmediatePropagation(),t.preventDefault()))}}class f extends HTMLElement{get keys(){let t=this.getAttribute("keys"),e=t?t.split(" "):[],i=this.getAttribute("multiword"),n=i?i.split(" "):[],s=0===n.length&&this.hasAttribute("multiword");return e.map(t=>({key:t,multiWord:s||n.includes(t)}))}set keys(t){this.setAttribute("keys",t)}connectedCallback(){let t=this.querySelector('input[type="text"], textarea');if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))return;let e=new m(this,t);p.set(this,e)}disconnectedCallback(){let t=p.get(this);t&&(t.destroy(),p.delete(this))}dismiss(){let t=p.get(this);t&&t.dismissMenu()}}window.customElements.get("text-expander")||(window.TextExpanderElement=f,window.customElements.define("text-expander",f))}}]);
//# sourceMappingURL=51210-185739338ae8119b-d25d24959512fc82.js.map