import{E as F,c as U,g as z,o as $}from"./chunk-OSAEZL4I.js";import{a as L}from"./chunk-7YUUTAV6.js";import{Da as _,Dc as x,Ec as c,F as y,Gd as k,Hb as h,I,Jb as R,Kd as H,Mc as f,Na as O,Tb as A,Wc as D,Yg as W,ba as m,cc as E,d as P,dc as V,ec as T,ga as s,gb as v,ha as l,hb as w,mb as g,mc as N,nb as a,ob as u,pb as S,zb as C}from"./chunk-RKSLYOIW.js";import{a as p,g as Q,i as d}from"./chunk-QQ7SJNXU.js";var X=Q(W());var j=i=>({"has-icon":i});function B(i,r){if(i&1){let q=C();a(0,"button",6),h("click",function(){s(q);let t=R();return l(t.onSearchClick());}),S(1,"my-global-icon",7),u();}}var G=(0,X.default)("peertube:SearchInputComponent"),ae=(()=>{let r=class r{route=m(k);router=m(H);placeholder=c("Sizdeg\u2026");inputId=c("search-input");icon=c(!1,{transform:f});emitOnInit=c(!1,{transform:f});search=x();searchValue;searchStream;viewInitialized=!1;emitSearchAfterViewInit=!1;ngOnInit(){this.initSearchStream(),this.listenToRouteSearchChange();}ngAfterViewInit(){this.viewInitialized=!0,this.emitOnInit()&&this.emitSearchAfterViewInit&&this.emitSearch();}onInputSearch(e){this.scheduleSearchUpdate(e.target.value);}onSearchClick(){this.scheduleSearchUpdate(this.searchValue);}onClear(){this.immediateSearchUpdate("");}scheduleSearchUpdate(e){this.searchValue=e,this.searchStream.next(this.searchValue);}immediateSearchUpdate(e){this.searchValue=e,this.setQueryParam(this.searchValue),this.emitSearch();}listenToRouteSearchChange(){this.route.queryParams.subscribe(e=>{let t=e.search||"";G('On route search change "%s".',t),this.searchValue!==t&&(this.searchValue=t,this.emitSearch());});}initSearchStream(){this.searchStream=new P(),this.searchStream.pipe(y(300),I()).subscribe(()=>{this.setQueryParam(this.searchValue),this.emitSearch();});}emitSearch(){if(!this.viewInitialized){this.emitSearchAfterViewInit=!0;return;}G('On search "%s".',this.searchValue),this.search.emit(this.searchValue);}setQueryParam(e){let t=e?{search:e.trim()}:{search:void 0};this.router.navigate(["."],{relativeTo:this.route,queryParams:p(p({},this.route.snapshot.queryParams),t)});}};d(r,"\u0275fac",function(t){return new(t||r)();}),d(r,"\u0275cmp",O({type:r,selectors:[["my-search-input"]],inputs:{placeholder:[1,"placeholder"],inputId:[1,"inputId"],icon:[1,"icon"],emitOnInit:[1,"emitOnInit"]},outputs:{search:"search"},decls:6,vars:8,consts:()=>{let e;e="Nadi";let t;return t="Sfe\u1E0D",[["input",""],[1,"input-group","has-clear","flex-nowrap",3,"ngClass"],["title",e,"type","button",1,"button-unstyle","search-button"],["type","text",1,"last-in-group","first-in-group",3,"ngModelChange","keyup","name","id","placeholder","ngModel"],["title",t,"type","button",1,"p-0","border-0","form-control-clear",3,"click"],["iconName","cross"],["title",e,"type","button",1,"button-unstyle","search-button",3,"click"],["iconName","search"]];},template:function(t,n){if(t&1){let b=C();a(0,"div",1),v(1,B,2,0,"button",2),a(2,"input",3,0),T("ngModelChange",function(o){return s(b),V(n.searchValue,o)||(n.searchValue=o),l(o);}),h("keyup",function(o){return n.onInputSearch(o);}),u(),a(4,"button",4),h("click",function(){s(b);let o=A(3);return n.onClear(),l(o.focus());}),S(5,"my-global-icon",5),u()();}t&2&&(g("ngClass",N(6,j,n.icon())),_(),w(n.icon()?1:-1),_(),g("name",n.inputId())("id",n.inputId())("placeholder",n.placeholder()),E("ngModel",n.searchValue));},dependencies:[D,F,U,z,$,L],styles:[`.input-group[_ngcontent-%COMP%]{width:fit-content}input[_ngcontent-%COMP%]{font-size:16px;padding:var(--input-y-padding) var(--input-x-padding);width:250px;max-width:250px;color:var(--input-fg);background-color:var(--input-bg);border:var(--input-border-width) solid var(--input-border-color);border-radius:var(--input-border-radius);line-height:24px}input[_ngcontent-%COMP%]::placeholder{color:var(--input-placeholder-color);font-size:var(--input-placeholder-font-size)}input[readonly][_ngcontent-%COMP%]{color:var(--fg-300)}input[_ngcontent-%COMP%]:focus, input[_ngcontent-%COMP%]:focus-visible{box-shadow:0 0 0 .2rem var(--fg-100);outline:0}input[disabled][_ngcontent-%COMP%]{color:var(--fg-300);opacity:.8}@media screen and (max-width:290px){input[_ngcontent-%COMP%]{width:100%}}.has-icon[_ngcontent-%COMP%]   input[_ngcontent-%COMP%]{padding-inline-start:46px}.search-button[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;left:20px;color:var(--fg-200)}.search-button[_ngcontent-%COMP%]   my-global-icon[_ngcontent-%COMP%]{display:inline-block;width:19px;height:19px;line-height:19px}.form-control-clear[_ngcontent-%COMP%]   my-global-icon[_ngcontent-%COMP%]{display:inline-block;width:19px;height:19px;line-height:19px}
/*# sourceMappingURL=search-input.component-C46AGDLR.css.map */`]}));let i=r;return i;})();export{ae as a};/**i18n:5a85df092a135682c90bae008e37ec28160e04e5f445e29af2927333ba91ffa1*///# sourceMappingURL=chunk-HG3TFEYQ.js.map