import{d as F}from"./chunk-GGRJXSHG.js";import{e as m,f as M,k as d}from"./chunk-ZBW5K2E4.js";import{d as O}from"./chunk-LONA56H5.js";import{Cb as k,Fb as f,J as I,N as y,S as A,Va as _,a as b,ba as E,f as u,fa as T,g as p,la as w,oa as C,qa as h,ud as L,z as v}from"./chunk-EGEFJ2EU.js";import{a as l}from"./chunk-BVRCJKVE.js";var g=class{constructor(e,t){this._items=e,this._activeItemIndex=-1,this._activeItem=null,this._wrap=!1,this._letterKeyStream=new u,this._typeaheadSubscription=b.EMPTY,this._vertical=!0,this._allowedModifierKeys=[],this._homeAndEnd=!1,this._pageUpAndDown={enabled:!1,delta:10},this._skipPredicateFn=i=>i.disabled,this._pressedLetters=[],this.tabOut=new u,this.change=new u,e instanceof _?this._itemChangesSubscription=e.changes.subscribe(i=>this._itemsChanged(i.toArray())):f(e)&&(this._effectRef=L(()=>this._itemsChanged(e()),{injector:t}))}skipPredicate(e){return this._skipPredicateFn=e,this}withWrap(e=!0){return this._wrap=e,this}withVerticalOrientation(e=!0){return this._vertical=e,this}withHorizontalOrientation(e){return this._horizontal=e,this}withAllowedModifierKeys(e){return this._allowedModifierKeys=e,this}withTypeAhead(e=200){return this._typeaheadSubscription.unsubscribe(),this._typeaheadSubscription=this._letterKeyStream.pipe(T(t=>this._pressedLetters.push(t)),y(e),I(()=>this._pressedLetters.length>0),v(()=>this._pressedLetters.join(""))).subscribe(t=>{let i=this._getItemsArray();for(let s=1;s<i.length+1;s++){let n=(this._activeItemIndex+s)%i.length,c=i[n];if(!this._skipPredicateFn(c)&&c.getLabel().toUpperCase().trim().indexOf(t)===0){this.setActiveItem(n);break}}this._pressedLetters=[]}),this}cancelTypeahead(){return this._pressedLetters=[],this}withHomeAndEnd(e=!0){return this._homeAndEnd=e,this}withPageUpDown(e=!0,t=10){return this._pageUpAndDown={enabled:e,delta:t},this}setActiveItem(e){let t=this._activeItem;this.updateActiveItem(e),this._activeItem!==t&&this.change.next(this._activeItemIndex)}onKeydown(e){let t=e.keyCode,s=["altKey","ctrlKey","metaKey","shiftKey"].every(n=>!e[n]||this._allowedModifierKeys.indexOf(n)>-1);switch(t){case 9:this.tabOut.next();return;case 40:if(this._vertical&&s){this.setNextItemActive();break}else return;case 38:if(this._vertical&&s){this.setPreviousItemActive();break}else return;case 39:if(this._horizontal&&s){this._horizontal==="rtl"?this.setPreviousItemActive():this.setNextItemActive();break}else return;case 37:if(this._horizontal&&s){this._horizontal==="rtl"?this.setNextItemActive():this.setPreviousItemActive();break}else return;case 36:if(this._homeAndEnd&&s){this.setFirstItemActive();break}else return;case 35:if(this._homeAndEnd&&s){this.setLastItemActive();break}else return;case 33:if(this._pageUpAndDown.enabled&&s){let n=this._activeItemIndex-this._pageUpAndDown.delta;this._setActiveItemByIndex(n>0?n:0,1);break}else return;case 34:if(this._pageUpAndDown.enabled&&s){let n=this._activeItemIndex+this._pageUpAndDown.delta,c=this._getItemsArray().length;this._setActiveItemByIndex(n<c?n:c-1,-1);break}else return;default:(s||F(e,"shiftKey"))&&(e.key&&e.key.length===1?this._letterKeyStream.next(e.key.toLocaleUpperCase()):(t>=65&&t<=90||t>=48&&t<=57)&&this._letterKeyStream.next(String.fromCharCode(t)));return}this._pressedLetters=[],e.preventDefault()}get activeItemIndex(){return this._activeItemIndex}get activeItem(){return this._activeItem}isTyping(){return this._pressedLetters.length>0}setFirstItemActive(){this._setActiveItemByIndex(0,1)}setLastItemActive(){this._setActiveItemByIndex(this._getItemsArray().length-1,-1)}setNextItemActive(){this._activeItemIndex<0?this.setFirstItemActive():this._setActiveItemByDelta(1)}setPreviousItemActive(){this._activeItemIndex<0&&this._wrap?this.setLastItemActive():this._setActiveItemByDelta(-1)}updateActiveItem(e){let t=this._getItemsArray(),i=typeof e=="number"?e:t.indexOf(e),s=t[i];this._activeItem=s??null,this._activeItemIndex=i}destroy(){this._typeaheadSubscription.unsubscribe(),this._itemChangesSubscription?.unsubscribe(),this._effectRef?.destroy(),this._letterKeyStream.complete(),this.tabOut.complete(),this.change.complete(),this._pressedLetters=[]}_setActiveItemByDelta(e){this._wrap?this._setActiveInWrapMode(e):this._setActiveInDefaultMode(e)}_setActiveInWrapMode(e){let t=this._getItemsArray();for(let i=1;i<=t.length;i++){let s=(this._activeItemIndex+e*i+t.length)%t.length,n=t[s];if(!this._skipPredicateFn(n)){this.setActiveItem(s);return}}}_setActiveInDefaultMode(e){this._setActiveItemByIndex(this._activeItemIndex+e,e)}_setActiveItemByIndex(e,t){let i=this._getItemsArray();if(i[e]){for(;this._skipPredicateFn(i[e]);)if(e+=t,!i[e])return;this.setActiveItem(e)}}_getItemsArray(){return f(this._items)?this._items():this._items instanceof _?this._items.toArray():this._items}_itemsChanged(e){if(this._activeItem){let t=e.indexOf(this._activeItem);t>-1&&t!==this._activeItemIndex&&(this._activeItemIndex=t)}}};var N=class extends g{constructor(){super(...arguments),this._origin="program"}setFocusOrigin(e){return this._origin=e,this}setActiveItem(e){super.setActiveItem(e),this.activeItem&&this.activeItem.focus(this._origin)}};function Q(r){return r.buttons===0||r.detail===0}function J(r){let e=r.touches&&r.touches[0]||r.changedTouches&&r.changedTouches[0];return!!e&&e.identifier===-1&&(e.radiusX==null||e.radiusX===1)&&(e.radiusY==null||e.radiusY===1)}var ee=new C("cdk-input-modality-detector-options"),te={ignoreKeys:[18,17,224,91,16]},ie=650,a=M({passive:!0,capture:!0}),Se=(()=>{let e=class e{get mostRecentModality(){return this._modality.value}constructor(i,s,n,c){this._platform=i,this._mostRecentTarget=null,this._modality=new p(null),this._lastTouchMs=0,this._onKeydown=o=>{this._options?.ignoreKeys?.some(D=>D===o.keyCode)||(this._modality.next("keyboard"),this._mostRecentTarget=d(o))},this._onMousedown=o=>{Date.now()-this._lastTouchMs<ie||(this._modality.next(Q(o)?"keyboard":"mouse"),this._mostRecentTarget=d(o))},this._onTouchstart=o=>{if(J(o)){this._modality.next("keyboard");return}this._lastTouchMs=Date.now(),this._modality.next("touch"),this._mostRecentTarget=d(o)},this._options=l(l({},te),c),this.modalityDetected=this._modality.pipe(E(1)),this.modalityChanged=this.modalityDetected.pipe(A()),i.isBrowser&&s.runOutsideAngular(()=>{n.addEventListener("keydown",this._onKeydown,a),n.addEventListener("mousedown",this._onMousedown,a),n.addEventListener("touchstart",this._onTouchstart,a)})}ngOnDestroy(){this._modality.complete(),this._platform.isBrowser&&(document.removeEventListener("keydown",this._onKeydown,a),document.removeEventListener("mousedown",this._onMousedown,a),document.removeEventListener("touchstart",this._onTouchstart,a))}};e.\u0275fac=function(s){return new(s||e)(h(m),h(k),h(O),h(ee,8))},e.\u0275prov=w({token:e,factory:e.\u0275fac,providedIn:"root"});let r=e;return r})();export{N as a,Se as b};
