import{E as G,c as $,g as F,o as L}from"./chunk-5ZTU7T2J.js";import{a as b}from"./chunk-DL46GKS7.js";import{a as X}from"./chunk-HHXEF4AR.js";import{Da as _,Dc as k,Ec as s,F as I,Gd as U,Hb as h,I as O,Jb as E,Kd as z,Mc as C,Na as v,Tb as V,Wc as H,Zg as B,ba as c,cc as T,d as P,dc as N,ec as D,ga as l,gb as w,ha as u,hb as A,ma as R,mb as g,mc as x,nb as a,ob as p,pb as S,zb as f}from"./chunk-OTZZLUAJ.js";import{a as d,g as j,i as m}from"./chunk-XYZYVFXE.js";var Q=j(B());var J=i=>({"has-icon":i});function K(i,r){if(i&1){let W=f();a(0,"button",6),h("click",function(){l(W);let t=E();return u(t.onSearchClick());}),S(1,"my-global-icon",7),p();}}var q=(0,Q.default)("peertube:SearchInputComponent"),le=(()=>{let r=class r{route=c(U);router=c(z);destroyRef=c(R);placeholder=s("\u03A6\u03AF\u03BB\u03C4\u03C1\u03BF...");inputId=s("search-input");icon=s(!1,{transform:C});emitOnInit=s(!1,{transform:C});search=k();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.pipe(b(this.destroyRef)).subscribe(e=>{let t=e.search||"";q('On route search change "%s".',t),this.searchValue!==t&&(this.searchValue=t,this.emitSearch());});}initSearchStream(){this.searchStream=new P(),this.searchStream.pipe(I(300),O(),b(this.destroyRef)).subscribe(()=>{this.setQueryParam(this.searchValue),this.emitSearch();});}emitSearch(){if(!this.viewInitialized){this.emitSearchAfterViewInit=!0;return;}q('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:d(d({},this.route.snapshot.queryParams),t)});}};m(r,"\u0275fac",function(t){return new(t||r)();}),m(r,"\u0275cmp",v({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="\u0391\u03BD\u03B1\u03B6\u03AE\u03C4\u03B7\u03C3\u03B7";let t;return t="\u0395\u03BA\u03BA\u03B1\u03B8\u03AC\u03C1\u03B9\u03C3\u03B7",[["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 M=f();a(0,"div",1),w(1,K,2,0,"button",2),a(2,"input",3,0),D("ngModelChange",function(o){return l(M),N(n.searchValue,o)||(n.searchValue=o),u(o);}),h("keyup",function(o){return n.onInputSearch(o);}),p(),a(4,"button",4),h("click",function(){l(M);let o=V(3);return n.onClear(),u(o.focus());}),S(5,"my-global-icon",5),p()();}t&2&&(g("ngClass",x(6,J,n.icon())),_(),A(n.icon()?1:-1),_(),g("name",n.inputId())("id",n.inputId())("placeholder",n.placeholder()),T("ngModel",n.searchValue));},dependencies:[H,G,$,F,L,X],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{le as a};/**i18n:4caeb8e7a09648a9cf35d6229af8a685b503a6e2123779e5b0c4fb7602981338*///# sourceMappingURL=chunk-GSIESP3K.js.map