import{a as B}from"./chunk-DMKKQOTX.js";import{B as V,c as k,g as w,l as F}from"./chunk-LPD7J4JW.js";import{e as H}from"./chunk-GH7I4V3C.js";import{Q as N}from"./chunk-2YE7XEKS.js";import{Ab as O,Cd as P,I as v,La as E,Mb as S,Ob as g,P as _,Qb as f,Sc as l,T as u,Tc as p,V as h,Vb as y,Wb as a,Xb as o,ba as T,gc as $,ic as C,jb as r,kc as x,l as c,se as D,va as I,w as m,wa as M,yc as d}from"./chunk-UNHECMG2.js";function z(n,s){if(n&1){let e=$();a(0,"button",6),C("click",function(t){I(e);let b=x();return M(b.modelChange(t))}),a(1,"i",2),d(2,"clear"),o()()}}function L(n,s){n&1&&(a(0,"div",5)(1,"div",7)(2,"span",8),d(3,"Loading..."),o()()())}var A=300,j=3,ne=(()=>{class n{constructor(){this.selectedItem$=new c(null),this.placeholder="shared.typeahead.default-placeholder",this.valueChange=this.selectedItem$.pipe(m(e=>e?e.Key:null),u()),this.componentId=N("bkd-typeahead-"),this.loading$=new c(!1),this.search=e=>e.pipe(q(j,A),T(this.fetchItems.bind(this)))}ngOnChanges(e){e.value&&e.value.currentValue&&e.value.currentValue!==this.selectedItemKey&&this.fetchItem(e.value.currentValue).subscribe(i=>{this.modelChange(i)})}format(e){return e.Value}modelChange(e){this.selectedItem$.next(e instanceof Object?e:null)}get selectedItemKey(){return this.selectedItem$.value?this.selectedItem$.value.Key:null}fetchItems(e){return this.loading$.next(!0),this.typeaheadService.getTypeaheadItems(e,this.additionalHttpParams).pipe(h(()=>this.loading$.next(!1)))}fetchItem(e){return this.loading$.next(!0),this.typeaheadService.getTypeaheadItemByKey(e).pipe(h(()=>this.loading$.next(!1)))}static{this.\u0275fac=function(i){return new(i||n)}}static{this.\u0275cmp=O({type:n,selectors:[["bkd-typeahead"]],inputs:{typeaheadService:"typeaheadService",placeholder:"placeholder",value:"value",additionalHttpParams:"additionalHttpParams"},outputs:{valueChange:"valueChange"},features:[E],decls:11,vars:18,consts:[[1,"input-group"],[1,"input-group-text",3,"id"],[1,"material-icons"],["type","text",1,"form-control",3,"ngModelChange","ngbTypeahead","inputFormatter","resultFormatter","ngModel"],["type","button",1,"btn","btn-link","text-decoration-none"],[1,"spinner-container"],["type","button",1,"btn","btn-link","text-decoration-none",3,"click"],["role","status",1,"spinner-border","spinner-border-sm"],[1,"visually-hidden"]],template:function(i,t){i&1&&(a(0,"div",0)(1,"span",1)(2,"i",2),d(3,"search"),o()(),a(4,"input",3),l(5,"async"),l(6,"translate"),l(7,"translate"),C("ngModelChange",function(K){return t.modelChange(K)}),o(),g(8,z,3,0,"button",4),o(),g(9,L,4,0,"div",5),l(10,"async")),i&2&&(r(),y("id",t.componentId),r(3),y("ngbTypeahead",t.search)("inputFormatter",t.format)("resultFormatter",t.format)("ngModel",p(5,10,t.selectedItem$)),S("placeholder",p(6,12,t.placeholder))("aria-label",p(7,14,t.placeholder))("aria-describedby",t.componentId),r(4),f(t.value?8:-1),r(),f(p(10,16,t.loading$)?9:-1))},dependencies:[B,V,k,w,F,P,D],styles:["[_nghost-%COMP%]{display:block;position:relative;background:#fff}.spinner-container[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;right:.75rem;display:flex;align-items:center;z-index:1001}.spinner-border[_ngcontent-%COMP%]{color:#6c757d}input[_ngcontent-%COMP%]{padding-right:2.5em}.input-group[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{position:absolute;right:0;z-index:5}"],changeDetection:0})}}return n})();function q(n,s){return e=>e.pipe(_(s),m(U),u(),v(H(n)))}function U(n){return n.trim().toLowerCase()}export{ne as a};
