File: //var/www/web.enelar.com.co/dist/browser/chunk-PPPZ3P2H.js
import{a as xt}from"./chunk-VYJOTIQG.js";import{b as Bt,c as Wt}from"./chunk-GIXZYBBG.js";import{a as Dt,b as Lt,d as Pt,e as kt,f as G}from"./chunk-73QXNGVV.js";import{a as jt,b as Ft,c as At,d as Vt}from"./chunk-2DV2IJZ3.js";import"./chunk-DNVSFO2Q.js";import{a as St,b as Ut}from"./chunk-UGKVLYDY.js";import"./chunk-4T6JHK7T.js";import{a as Et,b as Mt}from"./chunk-FN4BVT7F.js";import{a as It,b as Rt}from"./chunk-IZBGWZHV.js";import"./chunk-MEI5P7PY.js";import"./chunk-FJX52BFR.js";import{a as ht,b as ut}from"./chunk-M2XGXZBH.js";import{a as ft,j as gt}from"./chunk-YZB5RIY6.js";import{a as M}from"./chunk-FWIIQLPA.js";import{a as f}from"./chunk-J5MNQ3LA.js";import{k as _t,l as bt,m as Ct,n as vt,o as Tt,p as yt,t as wt}from"./chunk-3PWCL6RG.js";import"./chunk-O3VRXXRR.js";import{a as rt,b as it}from"./chunk-ZUNNDRPI.js";import"./chunk-KDH6VC4N.js";import{b as ot,d as st,f as nt,g as lt,i as at,j as pt,k as mt,l as ct,n as dt,o as O,p as $}from"./chunk-FB5LCIVC.js";import"./chunk-RP3BBTTB.js";import{A as z,d as E,e as B,n as W,z as N}from"./chunk-VJI6KQJL.js";import{A as j,Ab as tt,C as T,D as y,Fa as g,Ga as J,Ha as Z,I as w,J as I,Ja as D,Ka as L,La as V,Nb as et,Oa as P,Q as _,Y as p,Ya as Q,Z as h,Za as X,h as b,ha as F,ja as m,ma as H,pa as s,qa as n,ra as d,va as A,vb as R,wa as u,x as k,xa as U,y as v,yb as Y}from"./chunk-MDSVL5BJ.js";import{i as K}from"./chunk-ODN5LVDJ.js";var S=class o{static fromApiToDomain(e){return{data:Array.isArray(e.data)?e.data.map(l=>o.dataMapper(l)):o.dataMapper(e.data),message:e.message,summary:e.summary,totalRecords:e.totalRecords,rows:e.rows}}static dataMapper(e){return{_id:e._id,url:e.url,code:e.code,createdAt:e.createdAt}}static fromDomainToApi(e){return{_id:e._id,url:e.url,code:e.code,createdAt:e.createdAt}}};var Nt=(()=>{let e=class e{constructor(t){this.http=t}addShortUrl(t){let r=S.fromDomainToApi(t);return this.http.post(`${f.apiDevWeb}links`,r).pipe(b(S.fromApiToDomain))}getShortUrls(t,r,i=!1){let c=new Y().set("page",t.toString()).set("pageSize",r.toString());return this.http.get(`${f.apiDevWeb}${i?"public/":""}links`,{params:c}).pipe(b(S.fromApiToDomain))}getShortUrl(t){return this.http.get(`${f.apiDevWeb}links/${t}`).pipe(b(S.fromApiToDomain))}updateShortUrl(t,r){let i=S.fromDomainToApi(t);return this.http.put(`${f.apiDevWeb}links/${r}`,i).pipe(b(S.fromApiToDomain))}deleteOneShortUrl(t){return this.http.delete(`${f.apiDevWeb}links/${t}`).pipe(b(S.fromApiToDomain))}deleteMultiShortUrls(t){return this.http.post(`${f.apiDevWeb}links/eliminar-varios`,t).pipe(b(S.fromApiToDomain))}};e.\u0275fac=function(r){return new(r||e)(j(tt))},e.\u0275prov=k({token:e,factory:e.\u0275fac,providedIn:"root"});let o=e;return o})();var x=(()=>{let e=class e{constructor(t){this.ShortUrlService=t}addShortUrl(t){return this.ShortUrlService.addShortUrl(t)}getShortUrls(t,r,i){return this.ShortUrlService.getShortUrls(t,r,i)}getShortUrl(t){return this.ShortUrlService.getShortUrl(t)}updateShortUrl(t,r){return this.ShortUrlService.updateShortUrl(t,r)}deleteOneShortUrl(t){return this.ShortUrlService.deleteOneShortUrl(t)}deleteMultiShortUrls(t){return this.ShortUrlService.deleteMultiShortUrls(t)}};e.\u0275fac=function(r){return new(r||e)(j(Nt))},e.\u0275prov=k({token:e,factory:e.\u0275fac,providedIn:"root"});let o=e;return o})();var Yt=()=>[5,10,20,30];function te(o,e){if(o&1){let l=A();s(0,"div",5)(1,"h5",6),g(2,"Lista de url"),n(),s(3,"span",7),d(4,"i",8),s(5,"input",9),u("input",function(r){w(l);let i=U();return I(i.dt.filterGlobal(r.target.value,"contains"))}),n()()()}}function ee(o,e){o&1&&(s(0,"tr")(1,"th",10),g(2,"Creado"),d(3,"p-sortIcon",11),n(),s(4,"th",12),g(5,"Url"),d(6,"p-sortIcon",13),n(),s(7,"th",14),g(8,"Url acotada"),d(9,"p-sortIcon",15),n(),d(10,"th",16),n())}function re(o,e){if(o&1){let l=A();s(0,"tr")(1,"td"),g(2),Q(3,"dateFormat"),n(),s(4,"td"),g(5),n(),s(6,"td"),g(7),n(),s(8,"td")(9,"p-button",17),u("click",function(){let r=w(l).$implicit,i=U();return I(i.copiarAlPortapapeles("enelar.com.co/e/"+r.code))}),n(),s(10,"p-button",18),u("click",function(){let r=w(l).$implicit,i=U();return I(i.redirecShortUrls(r.code))}),n(),s(11,"p-button",19),u("click",function(){let r=w(l).$implicit,i=U();return I(i.eliminar(r._id))}),n()()()}if(o&2){let l=e.$implicit,t=U();p(2),J(X(3,5,l.createdAt)),p(3),J(l.url),p(2),Z(" ","enelar.com.co/e/"+l.code," "),p(3),m("loading",t.isLoading),p(),m("loading",t.isLoading)}}function ie(o,e){if(o&1){let l=A();s(0,"p-paginator",20),u("onPageChange",function(r){w(l);let i=U();return I(i.paginate(r))}),n(),s(1,"div",21),g(2),n()}if(o&2){let l=U();m("rows",l.rows)("totalRecords",l.totalRecords)("rowsPerPageOptions",P(4,Yt)),p(2),Z(" En total son ",l.totalRecords," registros. ")}}var Ot=(()=>{let e=class e{set getLoadingTable(t){this.isLoadingTable=t}constructor(t,r,i){this.shortUrlRepository=t,this.confirmationService=r,this.manageResponse=i,this.shortUrls=[],this.setIdShortUrl=new _,this.getShortUrls=new _,this.setPaginate=new _,this.setSelectedShortUrls=new _,this.selectedShortUrls=[],this.globalFilterFields=["fechaShortUrl"],this.isLoading=!1,this.isLoadingTable=!1,this.first=0,this.rows=f.pageSize,this.rutaBack=f.apiDevWebStorage}paginate(t){this.setPaginate.emit(t)}redirecShortUrls(t){let r=`https://www.enelar.com.co/e/${t}`;window.open(r,"_blank")}getSelectShortUrls(){this.setSelectedShortUrls.emit(this.selectedShortUrls)}eliminar(t){this.confirmationService.confirm({message:"Estas seguro de eliminar el elemento?",accept:()=>{this.isLoading=!0,this.shortUrlRepository.deleteOneShortUrl(t).subscribe({next:r=>{this.manageResponse.success(r),this.isLoading=!1,this.getShortUrls.emit()},error:r=>{this.manageResponse.error(r),this.isLoading=!1}})},reject:r=>{switch(r){case E.REJECT:this.manageResponse.eventReject();break;case E.CANCEL:this.manageResponse.eventCancel();break}}})}copiarAlPortapapeles(t){navigator.clipboard.writeText(t).then(()=>{console.log("Texto copiado al portapapeles:",t)},r=>{console.error("Error al copiar al portapapeles:",r)})}};e.\u0275fac=function(r){return new(r||e)(h(x),h(B),h(M))},e.\u0275cmp=T({type:e,selectors:[["app-table-short-url"]],inputs:{shortUrls:"shortUrls",totalRecords:"totalRecords",getLoadingTable:"getLoadingTable"},outputs:{setIdShortUrl:"setIdShortUrl",getShortUrls:"getShortUrls",setPaginate:"setPaginate",setSelectedShortUrls:"setSelectedShortUrls"},decls:5,vars:7,consts:[["dataKey","_id",3,"firstChange","selectionChange","value","rows","first","globalFilterFields","showCurrentPageReport","loading","selection"],["pTemplate","caption"],["pTemplate","header"],["pTemplate","body"],["pTemplate","summary"],[1,"flex","align-items-center","justify-content-between"],[1,"m-0"],[1,"p-input-icon-left"],[1,"pi","pi-search"],["pInputText","","type","text","placeholder","Buscar...",3,"input"],["pSortableColumn","creado"],["field","creado"],["pSortableColumn","url"],["field","url"],["pSortableColumn","code"],["field","code"],["width","180px"],["icon","pi pi-copy","styleClass","p-button-plain mr-2","pTooltip","Copiar","tooltipPosition","top",3,"click"],["icon","pi pi-eye","styleClass","p-button-info mr-2","pTooltip","Ver","tooltipPosition","top",3,"click","loading"],["icon","pi pi-trash","styleClass","p-button-danger mr-2","pTooltip","Eliminar","tooltipPosition","top",3,"click","loading"],[3,"onPageChange","rows","totalRecords","rowsPerPageOptions"],[1,"flex","align-items-center","justify-content-between","mt-3"]],template:function(r,i){r&1&&(s(0,"p-table",0),V("firstChange",function(a){return L(i.first,a)||(i.first=a),a})("selectionChange",function(a){return L(i.selectedShortUrls,a)||(i.selectedShortUrls=a),a}),F(1,te,6,0,"ng-template",1)(2,ee,11,0,"ng-template",2)(3,re,12,7,"ng-template",3)(4,ie,3,5,"ng-template",4),n()),r&2&&(m("value",i.shortUrls)("rows",i.rows),D("first",i.first),m("globalFilterFields",i.globalFilterFields)("showCurrentPageReport",!0)("loading",i.isLoadingTable),D("selection",i.selectedShortUrls))},dependencies:[vt,W,Tt,yt,O,N,bt,rt,ft]});let o=e;return o})();var se=()=>({width:"60vw"}),ne=()=>({width:"25vw"});function le(o,e){if(o&1&&d(0,"app-title-dialog",14),o&2){let l=U();m("title",l.isEdit?"Editar ShortUrl de comunicaci\xF3n":"Crear ShortUrl de comunicaci\xF3n")}}var $t=(()=>{let e=class e{set getShortUrl(t){t!=null&&(this.idShortUrl=t._id,this.formulario.patchValue(t),this.display=!0,this.isEdit=!0)}set getSelectedShortUrls(t){this.selectedShortUrls=t}constructor(t,r,i,c,a){this.formBuilder=t,this.shortUrlRepository=r,this.confirmationService=i,this.manageResponse=c,this.parametroRepository=a,this.getShortUrls=new _,this.setIsEdit=new _,this.idShortUrl=null,this.display=!1,this.isLoading=!1,this.isLoadingDelete=!1,this.isEdit=!1}ngOnInit(){return K(this,null,function*(){this.crearFormulario()})}crearFormulario(){this.formulario=this.formBuilder.group({url:["",st.required]})}showDialog(){this.display=!this.display,this.isEdit&&(this.setIsEdit.emit(),this.isEdit=!1,this.formulario.reset())}guardar(){let t=this.formulario.value;this.isLoading=!0,this.isEdit?this.shortUrlRepository.updateShortUrl(t,this.idShortUrl).subscribe({next:r=>{this.manageResponse.success(r),this.isLoading=!1,this.getShortUrls.emit(),this.showDialog()},error:r=>{this.manageResponse.error(r),this.isLoading=!1}}):this.shortUrlRepository.addShortUrl(t).subscribe({next:r=>{this.manageResponse.success(r),this.isLoading=!1,this.formulario.reset(),this.getShortUrls.emit()},error:r=>{this.manageResponse.error(r),this.isLoading=!1}})}eliminarVarios(){this.confirmationService.confirm({message:"Estas seguro de eliminar los elmentos?",accept:()=>{this.isLoadingDelete=!0;let t=this.selectedShortUrls.map(function(r){return{_id:r._id}});this.shortUrlRepository.deleteMultiShortUrls(t).subscribe({next:r=>{this.manageResponse.success(r),this.isLoadingDelete=!1,this.getShortUrls.emit()},error:r=>{this.manageResponse.error(r),this.isLoadingDelete=!1}})},reject:t=>{switch(t){case E.REJECT:this.manageResponse.eventReject;break;case E.CANCEL:this.manageResponse.eventCancel;break}}})}};e.\u0275fac=function(r){return new(r||e)(h(ct),h(x),h(B),h(M),h(xt))},e.\u0275cmp=T({type:e,selectors:[["app-modal-short-url"]],inputs:{getShortUrl:"getShortUrl",getSelectedShortUrls:"getSelectedShortUrls"},outputs:{getShortUrls:"getShortUrls",setIsEdit:"setIsEdit"},decls:17,vars:13,consts:[[1,"p-toolbar-group-left"],["label","Crear","icon","pi pi-plus","styleClass","p-button-success mr-2",3,"click"],[3,"visibleChange","visible"],["pTemplate","header"],[3,"submit","formGroup"],[1,"grid","p-fluid"],[1,"field","col-12","md:col-12"],["for","float-input-invalid"],["formControlName","url","placeholder","Digite la url a acotar","type","text","pInputText",""],["campo","url","length","600",3,"formulario"],[1,"flex","flex-row-reverse","flex-wrap"],["icon","pi pi-check","type","submit","styleClass","p-button-success",3,"loading","label","disabled"],["icon","pi pi-times","label","Cancelar","styleClass","p-button-danger mr-2",3,"click"],["rejectButtonStyleClass","p-button-text","acceptLabel","Si",3,"baseZIndex"],[3,"title"]],template:function(r,i){r&1&&(s(0,"p-toolbar")(1,"div",0)(2,"p-button",1),u("click",function(){return i.showDialog()}),n()()(),s(3,"p-dialog",2),V("visibleChange",function(a){return L(i.display,a)||(i.display=a),a}),F(4,le,1,1,"ng-template",3),s(5,"form",4),u("submit",function(){return i.guardar()}),s(6,"div",5)(7,"div",6)(8,"label",7),g(9,"Url"),n(),d(10,"input",8)(11,"app-validations-input",9),n()(),d(12,"p-divider"),s(13,"div",10),d(14,"p-button",11),s(15,"p-button",12),u("click",function(){return i.display=!1}),n()()()(),d(16,"p-confirmDialog",13)),r&2&&(p(3),H(P(11,se)),D("visible",i.display),p(2),m("formGroup",i.formulario),p(6),m("formulario",i.formulario),p(3),m("loading",i.isLoading)("label",i.isLoading?"Guardando...":"Guardar")("disabled",!i.formulario.valid),p(2),H(P(12,ne)),m("baseZIndex",1e4))},dependencies:[at,ot,nt,lt,pt,mt,Dt,W,N,It,O,kt,Et,ht,St]});let o=e;return o})();var Gt=(()=>{let e=class e{constructor(t,r){this.shortUrlRepository=t,this.manageResponse=r,this.isEdit=!1,this.page=f.page,this.pageSize=f.pageSize,this.loadingTable=!1}ngOnInit(){this.getShortUrls(),this.inizialize()}inizialize(){this.items=[{label:"Gesti\xF3n"},{label:"urls"}],this.home={icon:"pi pi-home",routerLink:"/"}}getShortUrls(){this.loadingTable=!0,this.shortUrlRepository.getShortUrls(this.page,this.pageSize).subscribe({next:t=>{this.shortUrls=t.data,this.totalRecords=t.totalRecords,this.loadingTable=!1},error:t=>{this.manageResponse.error(t),this.loadingTable=!1}})}getIdShortUrl(t){this.isEdit=!0,this.getShortUrl(t)}getSelectedShortUrls(t){this.selectedShortUrls=t}getShortUrl(t){this.shortUrlRepository.getShortUrl(t).subscribe({next:r=>{this.shortUrl=r.data},error:r=>{this.manageResponse.error(r)}})}paginate(t){this.page=t.page+1,this.pageSize=t.rows,this.getShortUrls()}};e.\u0275fac=function(r){return new(r||e)(h(x),h(M))},e.\u0275cmp=T({type:e,selectors:[["app-short-url"]],decls:6,vars:7,consts:[[3,"model","home"],[1,"card","mt-5","p-3"],[3,"getShortUrls","setIsEdit","getShortUrl","getSelectedShortUrls"],[1,"mt-3"],[3,"setIdShortUrl","setSelectedShortUrls","getShortUrls","setPaginate","shortUrls","totalRecords","getLoadingTable"]],template:function(r,i){r&1&&(d(0,"p-toast")(1,"p-breadcrumb",0),s(2,"div",1)(3,"app-modal-short-url",2),u("getShortUrls",function(){return i.getShortUrls()})("setIsEdit",function(){return i.isEdit=!1}),n(),s(4,"div",3)(5,"app-table-short-url",4),u("setIdShortUrl",function(a){return i.getIdShortUrl(a)})("setSelectedShortUrls",function(a){return i.getSelectedShortUrls(a)})("getShortUrls",function(){return i.getShortUrls()})("setPaginate",function(a){return i.paginate(a)}),n()()()),r&2&&(p(),m("model",i.items)("home",i.home),p(2),m("getShortUrl",i.shortUrl)("getSelectedShortUrls",i.selectedShortUrls),p(2),m("shortUrls",i.shortUrls)("totalRecords",i.totalRecords)("getLoadingTable",i.loadingTable))},dependencies:[jt,At,Ot,$t]});let o=e;return o})();var pe=[{path:"",component:Gt}],Ht=et.forChild(pe);var Jt=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=y({type:e}),e.\u0275inj=v({imports:[R,wt,$,z,G,Ct,it,gt]});let o=e;return o})();var Zt=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=y({type:e}),e.\u0275inj=v({imports:[R,dt,Lt,z,Rt,$,_t,Pt,G,Mt,Bt,Wt,ut,Ut]});let o=e;return o})();var xr=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=y({type:e}),e.\u0275inj=v({imports:[R,Ht,Ft,Vt,Jt,Zt]});let o=e;return o})();export{xr as ShortUrlModule};