PageSourceSearch

https://bosques-sostenibles.web.app/chunk-U52THXSK.js

js bosques-sostenibles.web.app collected 2026-10-03 12:19:06 UTC 49,221 bytes, 3 lines download raw bytes

1import{a as Xt,b as Eo,d as Lo,e as at,f as Fo}from"./chunk-HNZHS4Q4.js";import"./chunk-XKVCPT22.js";import{a as Yt}from"./chunk-S3UYXMEV.js";import{a as vo,b as _o,c as bo,d as Mo,e as Io,f as So}from"./chunk-MZG4YQB3.js";import{a as Ce,b as Co}from"./chunk-5JIJ5Y75.js";import{a as xo}from"./chunk-G7QMWEB7.js";import{b as J}from"./chunk-U3YCRRCY.js";import{a as fo}from"./chunk-AMWXWV4N.js";import{b as go}from"./chunk-YDFIDM6E.js";import{a as uo}from"./chunk-ZTSCYD3A.js";import{a as Zt,b as so,c as yo,d as ho}from"./chunk-O5OQ64SW.js";import{b as ao}from"./chunk-QVIKB233.js";import{o as po}from"./chunk-5A732UDA.js";import{a as Q,b as z,c as We,d as He,e as Wt,f as gt,j as co}from"./chunk-YD5X547W.js";import"./chunk-7BW34AY5.js";import{C as rt,D as Rt,E as qt,H as Ut,I as X,J as Qt,K,P as to,aa as zt,b as Nt,c as Vt,e as y,f as it,g as O,j as Re,m as k,o as nt,t as qe,u as Ue,v as j,y as Bt}from"./chunk-XIS77F6W.js";import{a as Je,c as $t}from"./chunk-YTQ54LGG.js";import{c as lo,d as mo}from"./chunk-MQYSD4TA.js";import{S as Ot,U as Xe,V as Z,X as Ke,Y as kt,Z as Y,b as W,c as $,p as Ze,z as Ye}from"./chunk-AAN3FN23.js";import"./chunk-L7GWTBPF.js";import{a as $e,b as ge,f as ro}from"./chunk-6FB3VNU5.js";import{a as io,b as no}from"./chunk-627SM6Q5.js";import{c as he,g as oo,h as Ht}from"./chunk-A562AUMQ.js";import{b as ye}from"./chunk-ZNRV53YW.js";import{$ as Dt,$b as v,B as Pe,Bc as ft,Ec as Be,F as we,Fb as wt,Fc as yt,G as Ge,Gb as Gt,Gc as _,Hb as At,I as ut,Ka as Ae,Kb as F,Lb as l,Mb as et,Nb as M,Oa as s,Ob as vt,Pa as f,Q as ot,S as Tt,T as pt,Xa as je,_b as x,_c as Oe,aa as h,ab as u,bd as jt,cc as V,da as Pt,dd as ke,e as ue,eb as m,ed as fe,f as de,fd as Qe,gd as ze,hd as ht,ia as b,ic as Ne,id as H,ja as g,jd as D,kd as P,m as Te,md as eo,n as Lt,ob as a,od as E,pa as U,pb as r,q as Ft,qa as w,qb as d,r as De,ra as G,rb as I,s as mt,sb as S,ub as N,uc as Ve,xb as A,ya as dt,yc as T,zb as p}from"./chunk-6EMQB4ST.js";import"./chunk-HCHMONTU.js";import{a as B,b as xt,h as R,j as q}from"./chunk-OOG3N6XX.js";var xe=(()=>{class e{constructor(){}ngOnInit(){}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275cmp=b({type:e,selectors:[["app-loading-overlay"]],decls:1,vars:0,template:function(i,n){i&1&&d(0,"mat-spinner")},dependencies:[Je]})}}return e})();var ve=function(e){return e.genOrderRequestNew=o=>B({order:null,clientType:"particular",company:null},o),e}(ve||{});var Kt=(()=>{class e{constructor(t){this.aSS=t,this.create=i=>this.aSS.call("api/orders/create",i)}static{this.\u0275fac=function(i){return new(i||e)(Pt(Ht))}}static{this.\u0275prov=Dt({token:e,factory:e.\u0275fac})}}return e})();function fi(e,o){if(e&1){let t=N();I(0),a(1,"div",4)(2,"div")(3,"h2"),l(4," Esta empresa ya est\xE1 registrada en Bosques Sostenibles "),r()(),a(5,"span",5),l(6," Si ya tienes cuenta con nosotros, inicia sesi\xF3n con tu cuenta de empresa para poder realizar ap
1ortaciones. "),r(),a(7,"button",6),A("click",function(){w(t);let n=p(2);return G(n.onLogin())}),l(8," Identif\xEDcate "),r()(),S()}}function yi(e,o){if(e&1&&(I(0),u(1,fi,9,0,"ng-container",3),S()),e&2){let t=p();s(),m("ngIf",t.state.clientByTaxId)}}function hi(e,o){e&1&&(a(0,"h2"),l(1," Tu cuenta de usuario pertenece a un grupo. Cont\xE1ctanos si deseas compensar para alguna de las empresas del grupo. "),r())}function gi(e,o){e&1&&(a(0,"h2"),l(1," Te has identificado con una cuenta administrativa de Bosques Sostenibles."),d(2,"br"),l(3," Para comprar desde la web, debes usar una cuenta de cliente o no estar identificado. "),r())}function Ci(e,o){if(e&1&&(a(0,"div",4)(1,"div"),u(2,hi,2,0,"h2",3)(3,gi,4,0,"h2",3),r()()),e&2){let t=p();s(2),m("ngIf",!t.isAdmin),s(),m("ngIf",t.isAdmin)}}var Jt=class _e{constructor(o){this.dialog=o,this.isAdmin=!1}ngOnInit(){}ngOnChanges(o){this.isAdmin=this.state?.user?.roles?.includes("ADMIN")}onLogin(){this.dialog.open(Zt,{maxWidth:"100vw",maxHeight:"100vh",panelClass:"no-padding-dialog",data:{keepOnRoute:!0},disableClose:!0}).afterClosed().pipe(z(this)).subscribe(t=>{})}static{this.\u0275fac=function(t){return new(t||_e)(f(Bt))}}static{this.\u0275cmp=b({type:_e,selectors:[["app-info-not-payable"]],inputs:{formGroup:"formGroup",state:"state"},features:[U],decls:4,vars:2,consts:[["loggedInCase",""],["fxLayout","column","fxLayoutGap","15px",1,"data-card","bg-white","p-20"],[4,"ngIf","ngIfElse"],[4,"ngIf"],["fxLayout","column","fxLayoutAlign","space-between center","fxLayoutGap","15px"],[2,"max-width","500px"],["mat-raised-button","","color","primary","type","button",1,"formatted-submit-button","form-text",3,"click"]],template:function(t,i){if(t&1&&(a(0,"div",1),u(1,yi,2,1,"ng-container",2)(2,Ci,4,2,"ng-template",null,0,V),r()),t&2){let n=F(3);s(),m("ngIf",!i.state.isLoggedIn)("ngIfElse",n)}},dependencies:[T,P,D,H,Ot]})}};Jt=q([Q()],Jt);function vi(e,o){if(e&1&&(a(0,"div"),d(1,"shared-address",2),r()),e&2){let t=p();s(),m("addressForm",t.addressForm)("hasTwoLines",!1)}}function _i(e,o){if(e&1&&(I(0),a(1,"div",4)(2,"div",5)(3,"h4")(4,"b"),l(5,"Direcci\xF3n"),r()(),a(6,"span"),l(7),r()()(),S()),e&2){let t,i=p(2);s(7),et((t=i.fullAddress)!==null&&t!==void 0?t:"-")}}function bi(e,o){if(e&1&&u(0,_i,8,1,"ng-container",3),e&2){let t=p();m("ngIf",(t.state.client==null?null:t.state.client.type)==="business"&&(t.state.client==null||t.state.client.billingAddress==null?null:t.state.client.billingAddress.addressLine1))}}var Do=(()=>{class e{constructor(){this.fullAddress="-",this.canEditBillingAddress=!1}get addressLine1FormControl(){return this.addressForm.controls.addressLine1}get cityFormControl(){return this.addressForm.controls.city}get postalCodeFormControl(){return this.addressForm.controls.postalCode}ngOnChanges(){this.canEditBillingAddress=this.state.isLoggedIn&&this.state.client?.type==="particular"||!this.state.isLoggedIn||this.state.isLoggedIn&&this.state.client?.type==="business"&&!this.state.client?.billingAddress?.addressLine1,this.state.companyOptionChosen?(this.addressLine1FormControl.setValidators([y.required]),this.cityFormControl.setValidators([y.required]),this.postalCodeFormControl.setValidators([y.required])):(this.addressLine1FormControl.clearValidators(),this.cityFormControl.clearValidators(),this.postalCodeFormControl.clearValidators()),this.addressLine1FormControl.updateValueAndValidity(),this.cityFormControl.updateValueAndValidity(),this.postalCodeFormControl.updateValueAndValidity(),this.fullAddress=xo(this.state.client?.billingAddress)}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275cmp=b({type:e,selectors:[["app-billing-address"]],inputs:{state:"state",addressForm:"addressForm"},features:[U],decls:3,vars:2,consts:[["businessAddressData",""],[4,"ngIf","ngIfElse"],[3,"addressForm","hasTwoLines"],[4,"ngIf"],["fxLayout","column","fxLayoutGap","15px"],["fxLayout","column","fxLayoutGap","5px"]],template:function(i,n){if(i&1&&u(0,vi,2,2,"div",1)(1,bi,1,1,"ng-template",null,0,V),i&2){let c=F(2);m("ngIf",n.canEditBillingAddress)("ngIfElse",c)}},dependencies:[Mo,T,P,D]})}}return e})();function Li(e,o){if(e&1&&(a(0,"div",7)(1,"div")(2,"h4")(3,"b"),l(4,"Voy a hacer una aportaci\xF3n a nombre de:"),r()()(),d(5,"app-option-selector",8),r()),e&2){let t=p();
1s(5),m("options",t.contributorOptions)("selectControl",t.contributorTypeFormControl)}}function Fi(e,o){e&1&&(a(0,"h2")(1,"b"),l(2,"Datos de facturaci\xF3n"),r()())}function Ti(e,o){if(e&1&&(I(0),a(1,"div",7)(2,"h4")(3,"b"),l(4,"Empresa"),r()(),a(5,"span"),l(6),r()(),S()),e&2){let t=p(2);s(6),et(t.state.client.name)}}function Di(e,o){if(e&1&&(a(0,"mat-error")(1,"mat-icon"),l(2,"info"),r(),l(3),x(4,"translate"),r()),e&2){let t=p(3);s(3),M(" ",v(4,1,t.ui.getErrorMessage(t.formGroup==null?null:t.formGroup.controls.company,t.validationMessages))," ")}}function Pi(e,o){if(e&1&&(I(0),a(1,"mat-form-field",10)(2,"mat-label"),l(3,"Nombre de la empresa"),r(),d(4,"input",11),u(5,Di,5,3,"mat-error",4),r(),S()),e&2){let t=p(2);s(5),m("ngIf",t.formGroup==null||t.formGroup.controls==null||t.formGroup.controls.company==null?null:t.formGroup.controls.company.invalid)}}function wi(e,o){if(e&1&&(a(0,"div",9),u(1,Ti,7,1,"ng-container",4)(2,Pi,6,1,"ng-container",4),r()),e&2){let t=p();s(),m("ngIf",(t.state.client==null?null:t.state.client.type)==="business"),s(),m("ngIf",!t.state.isLoggedIn&&t.state.companyOptionChosen)}}function Gi(e,o){if(e&1&&(a(0,"mat-error")(1,"mat-icon"),l(2,"info"),r(),l(3),x(4,"translate"),r()),e&2){let t=p(2);s(3),M(" ",v(4,1,t.ui.getErrorMessage(t.formGroup==null?null:t.formGroup.controls.identification,t.validationMessages))," ")}}function Ai(e,o){e&1&&(I(0),a(1,"small",14),l(2," Esta empresa ya est\xE1 registrada en Bosques Sostenibles. Inicia sesi\xF3n con tu cuenta para realizar aportaciones. "),r(),S())}function ji(e,o){if(e&1){let t=N();a(0,"div",12)(1,"mat-form-field",10)(2,"mat-label"),l(3),r(),a(4,"input",13),A("blur",function(){w(t);let n=p();return G(n.onBlurIdentification())})("keyup",function(n){w(t);let c=p();return G(c.formGroup==null||c.formGroup.controls==null||c.formGroup.controls.identification==null?null:c.formGroup.controls.identification.setValue(n.target.value.toUpperCase().trim()))}),r(),u(5,Gi,5,3,"mat-error",4),r(),u(6,Ai,3,0,"ng-container",4),r()}if(e&2){let t=p();s(3),M(" ",t.state.isBusiness||t.state.companyOptionChosen?"CIF":"DNI / NIE"," "),s(2),m("ngIf",t.formGroup==null||t.formGroup.controls==null||t.formGroup.controls.identification==null?null:t.formGroup.controls.identification.invalid),s(),m("ngIf",t.state.clientByTaxId&&t.state.clientByTaxId.type==="business")}}function Ni(e,o){if(e&1&&(a(0,"div",16)(1,"h4")(2,"b"),l(3),r()(),a(4,"span"),l(5),r()()),e&2){let t=p(2);s(3),M(" ",t.state.isBusiness||t.state.companyOptionChosen?"CIF":"DNI / NIE"," "),s(2),et(t.state.client.taxId)}}function Vi(e,o){if(e&1&&u(0,Ni,6,2,"div",15),e&2){let t=p();m("ngIf",(t.state.client==null?null:t.state.client.type)==="business")}}var wo=(()=>{class e{constructor(t){this.ui=t,this.actions=new dt,this.contributorOptions=[{icon:"person",title:"Particular",isCustomIcon:!1,value:"particular"},{icon:"business",title:"De una empresa",isCustomIcon:!1,value:"business"}],this.validationMessages={company:[{type:"required",message:"Nombre de empresa requerido"}],identification:[{type:"required",message:"El n\xFAmero es requerido"},{type:"pattern",message:"Revisa que el n\xFAmero tenga un formato v\xE1lido"}]}}get contributorTypeFormControl(){return this.formGroup.controls.contributorType}get companyFormControl(){return this.formGroup.controls.company}get identificationFormControl(){return this.formGroup.controls.identification}onBlurIdentification(){this.actions.emit({type:"set",payload:{identification:this.identificationFormControl.value??null}})}ngOnChanges(){this.state.isLoggedIn||!this.state.isLoggedIn&&!this.state.companyOptionChosen?(this.companyFormControl.clearValidators(),this.identificationFormControl.clearValidators()):(this.companyFormControl.setValidators([y.required]),this.identificationFormControl.setValidators([y.required])),this.identificationFormControl.addValidators([y.pattern(/^[A-Z]{0,3}[0-9]+[A-Z]{0,1}$/)]),this.companyFormControl.updateValueAndValidity(),this.identificationFormControl.updateValueAndValidity()}static{this.\u0275fac=function(i){return new(i||e)(f(rt))}}static{this.\u0275cmp=b({type:e,selectors:[["app-business-data"]],inputs:{state:"state",formGroup:"formGroup"},outputs:{actions:"actions"},features:[U],decls:9,vars:6,consts:[["identificationDataTemplate",""],["fxLayout","column","fxLayoutGap","15px",3,"formGroup"],["fxFlex","","fxLayout","column","fxLayoutGap","5px",4,"ngIf"],["fxLayout","column","fxLayoutGap","15px"],[4,"ngIf"],["fxLayoutGap","15px",4,"ngIf"],["fxLayout","column",4,"ngIf","ngIfElse"],["fxFlex","","fxLayout","column","fxLayoutGap","5px"],["name","contributorTypeSelector",3,"options","selectControl"],["fxLayoutGap","15px"],["fxFlex","","floatLabel","always"],["matInput","","type","text","formControlName","company","name","company","autocomplete","organization"],["fxLayout","column"],["matInput","","type","text","formControlName","identification","name","identification","autocomplete","on",3,"blur","keyup"],["fxLayout","row wrap",2,"color","var(--primary-color)"],["fxLayout","column","fxLayoutGap","5px",4,"ngIf"],["fxLayout","column","fxLayoutGap","5px"]],template:function(i,n){if(i&1&&(a(0,"div",1),u(1,Li,6,2,"div",2),a(2,"div",3)(3,"div"),u(4,Fi,3,0,"h2",4),r(),u(5,wi,3,2,"div",5)(6,ji,7,3,"div",6)(7,Vi,1,1,"ng-template",null,0,V),r()()),i&2){let c=F(8);m("formGroup",n.formGroup),s(),m("ngIf",!n.state.isLoggedIn),s(3),m("ngIf",!(n.state.isLoggedIn&&((n.state.client==null?null:n.state.client.type)==="particular"||(n.state.client==null?null:n.state.client.type)==="group"))),s(),m("ngIf",n.state.isBusiness||n.state.companyOptionCh
1osen),s(),m("ngIf",!n.state.isLoggedIn)("ngIfElse",c)}},dependencies:[T,P,D,ht,Ut,Rt,qt,W,Qt,Xt,Vt,it,O,k,nt,kt]})}}return e})();function Oi(e,o){if(e&1&&(a(0,"mat-error")(1,"mat-icon",11),l(2,"info"),r(),l(3),x(4,"translate"),r()),e&2){let t=p(2);s(),m("inline",!0),s(2),M(" ",v(4,2,t.ui.getErrorMessage(t.nameFormControl,t.validationMessages))," ")}}function ki(e,o){if(e&1&&(a(0,"mat-error")(1,"mat-icon"),l(2,"info"),r(),l(3),x(4,"translate"),r()),e&2){let t=p(2);s(3),M(" ",v(4,1,t.ui.getErrorMessage(t.emailFormControl,t.validationMessages))," ")}}function $i(e,o){e&1&&(a(0,"div")(1,"small",12),l(2," Correo ya asociado a una cuenta. Inicia sesi\xF3n para poder realizar aportaciones. "),r()())}function Ri(e,o){if(e&1&&(I(0),u(1,$i,3,0,"div",5),S()),e&2){let t=o.$implicit;s(),m("ngIf",t.length>0)}}function qi(e,o){if(e&1&&(I(0),a(1,"mat-form-field",3)(2,"mat-label"),l(3,"Nombre"),r(),d(4,"input",4),u(5,Oi,5,4,"mat-error",5),r(),a(6,"div",6),d(7,"lib-phone-input",7),a(8,"div",8)(9,"mat-form-field",9)(10,"mat-label"),l(11,"Correo Electr\xF3nico"),r(),d(12,"input",10),u(13,ki,5,3,"mat-error",5),r(),u(14,Ri,2,1,"ng-container",5),x(15,"async"),r()(),S()),e&2){let t=p();s(5),m("ngIf",t.nameFormControl.invalid),s(2),m("phoneControl",t.phoneFormControl)("countryCode",t.countryCode),s(6),m("ngIf",t.emailFormControl.invalid),s(),m("ngIf",v(15,5,t.state.companyOptionChosen&&t.usersByEmail$))}}function Ui(e,o){if(e&1&&(a(0,"div",13)(1,"h4")(2,"b"),l(3,"Nombre"),r()(),a(4,"span"),l(5),r()(),a(6,"div",14)(7,"div",13)(8,"h4")(9,"b"),l(10,"Tel\xE9fono"),r()(),a(11,"span"),l(12),r()(),a(13,"div",13)(14,"h4")(15,"b"),l(16,"Correo Electr\xF3nico"),r()(),a(17,"span"),l(18),r()()()),e&2){let t=p();s(5),et(t.nameFormControl.value),s(7),M(" ",t.phoneFormControl.value?t.formattedPhoneNumber:"-"," "),s(6),M(" ",t.emailFormControl.value?t.emailFormControl.value:"-"," ")}}var Go=(()=>{class e{get contributorTypeFormControl(){return this.formGroup.controls.contributorType}get phoneFormControl(){return this.formGroup.controls.phone}get nameFormControl(){return this.formGroup.controls.name}get emailFormControl(){return this.formGroup.controls.email}constructor(t,i){this.ui=t,this.userDbService=i,this.checkMultipleWordsValidator=n=>(n?.value?n.value.trim().split(" "):[]).length<2?{multipleWords:!0}:null,this.validationMessages={name:[{type:"required",message:"Nombre es requerido"},{type:"minLength",message:"La longitud del nombre ha de ser de al menos 6 caracteres"},{type:"multipleWords",message:"El nombre debe contener al menos dos palabras"}],email:[{type:"required",message:"Correo electr\xF3nico es requerido"},{type:"invalidEmail",message:"El correo indicado no conicide con el registrado para el particular"}],phone:[{type:"required",message:"N\xFAmero de tel\xE9fono es requerido"}]}}ngOnChanges(){this.usersByEmail$=this.emailFormControl.valueChanges.pipe(ut(),Tt(this.emailFormControl.value),pt(t=>this.userDbService.getUsersByEmail$(t.toLowerCase())),ot(1)),this.state.isLoggedIn?(this.phoneFormControl.clearValidators(),this.emailFormControl.clearValidators()):(this.state.companyOptionChosen?(this.phoneFormControl.addValidators([y.required]),this.nameFormControl.addValidators([this.checkMultipleWordsValidator])):(this.phoneFormControl.removeValidators([y.required]),this.nameFormControl.removeValidators([this.checkMultipleWordsValidator])),this.emailFormControl.setValidators([y.required]),!this.state.companyOptionChosen&&this.state.clientByTaxId&&this.state.clientByTaxId.type==="particular"&&this.emailFormControl.addValidators([Qi(this.state.clientByTaxId)])),this.phoneFormControl.updateValueAndValidity(),this.emailFormControl.updateValueAndValidity(),this.nameFormControl.updateValueAndValidity(),this.phoneFormControl.value&&(this.formattedPhoneNumber=_o(this.phoneFormControl.value))}static{this.\u0275fac=function(i){return new(i||e)(f(rt),f(oo))}}static{this.\u0275cmp=b({type:e,selectors:[["app-contact-data"]],inputs:{formGroup:"formGroup",state:"state",countryCode:"countryCode"},features:[U],decls:4,vars:3,consts:[["clientContactData",""],["fxLayout","column","fxLayoutGap","15px",3,"formGroup"],[4,"ngIf","ngIfElse"],["fxFlex","","floatLabel","always"],["matInput","","type","text","formControlName","name","name","name","autocomplete","name"],[4,"ngIf"],["fxLayout.gt-sm","row","fxLayout.lt-md","column","fxLayoutGap","10px"],["fxFlex","","fxFlex.gt-sm","50",3,"phoneControl","countryCode"],["fxFlex.gt-sm","50","fxLayout","column"],["floatLabel","always"],["matInput","","type","email","formControlName","email","autocomplete","email","inputmode","email","name","email"],[3,"inline"],["fxLayout","row wrap",2,"color","var(--primary-color)"],["fxLayout","column","fxLayoutGap","5px"],["fxLayout.lt-md","column","fxLayoutGap.lt-md","5px","fxLayout","row","fxLayoutGap","50px"]],template:function(i,n){if(i&1&&(a(0,"div",1),u(1,qi,16,7,"ng-container",2)(2,Ui,19,3,"ng-template",null,0,V),r()),i&2){let c=F(3);m("formGroup",n.formGroup),s(),m("ngIf",!n.state.isLoggedIn)("ngIfElse",c)}},dependencies:[T,P,D,ht,Ut,Rt,qt,W,Qt,bo,Vt,it,O,k,nt,ft,kt]})}}return e})();function Qi(e){return o=>(e.contact?.email||e?.email)!==o.value?{invalidEmail:!0}:null}function Wi(e,o){if(e&1){let t=N();a(0,"div",5)(1,"span"),l(2," \xBFYa tienes cuenta? "),r(),a(3,"span",6),A("click",function(){w(t);let n=p();return G(n.onLogin())}),l(4,"Identif\xEDcate"),r()()}}var ee=class Me{constructor(o,t){this.ui=o,this.dialog=t,this.actions=new dt}ngOnInit(){this.addressForm=this.formGroup.controls.billingAddress}onLogin(){let o=this.dialog.open(Zt,{maxWidth:"100vw",maxHeight:"100vh",panelClass:"no-padding-dialog",data:{keepOnRoute:!0},disableClose:!0})}static{this.\u0275fac=function(t){return new(t||Me)(f(rt),f(Bt))}}static{this.\u0275cmp=b({type:Me,selectors:[["app-payment-personal-data"]],inputs:{formGroup:"formGroup",state:"state",countryCode:"countryCode"},outputs:{actions:"actions"},decls:9,vars:9,consts:[["fxLayout","column","fxLayoutAlign","start stretch","fxLayoutGap","15px",1,"data-card","bg-white","p-20",3,"formGroup"],["fxLayout","row wrap","fxLayoutAlign","start center",4,"ngIf"],[3,"formGroup","state","countryCode"],[3,"actions","formGroup","state"],[3,"addressForm","state"],["fxLayout","row wrap","fxLayoutAlign","start center"],[1,"accented-text","pl-10",3,"click"]],template:function(t,i){t&1&&(a(0,"div",0)(1,"div")(2,"h2")(3,"b"),l(4,"Datos personales"),r()(),u(5,Wi,5,0,"div",1),r(),d(6,"app-contact-data",2),a(7,"app-business-data",3),A("actions",function(c){return i.actions.emit(c)}),r(),d(8,"app-billing-address",4),r()),t&2&&(m("formGroup",i.formGroup),s(5),m("ngIf",!i.state.isLoggedIn),s(),m("formGroup",i.formGroup)("state",i.state)("countryCode",i.countryCode),s(),m("formGroup",i.formGroup)("state",i.state),s(),m("addressForm",i.addressForm)("state",i.state))},dependencies:[Do,wo,T,Go,P,D,H,O,k]})}};ee=q([Q()],ee);var oe=(()=>{class e{constructor(t){this.aSS=t,this.create=i=>this.aSS.call("api/payments/intents/create",i)}static{this.\u0275fac=function(i){return new(i||e)(Pt(Ht))}}static{this.\u0275prov=Dt({token:e,factory:e.\u0275fac})}}return e})();var Ao=(()=>{class e{constructor(){}ngOnInit(){this.formGroup.valueChanges.subscribe(t=>{this.errorMessage$.next("")})}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275cmp=b({type:e,selectors:[["app-error-messages"]],inputs:{formGroup:"formGroup",errorMessage$:"errorMessage$"},decls:3,vars:3,consts:[[1,"error"]],template:function(i,n){i&1&&(a(0,"p",0),l(1),x(2,"async"),r()),i&2&&(s(),M(" ",v(2,1,n.errorMessage$),`
2`))},dependencies:[ft]})}}return e})();var Vo="https://js.stripe.com/v3",Xi=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,jo="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Ki=function(){for(var o=document.querySelectorAll('script[src^="'.concat(Vo,'"]')),t=0;t<o.length;t++){var i=o[t];if(Xi.test(i.src))return i}return null},No=function(o){var t=o&&!o.advancedFraudSignals?"?advancedFraudSignals=false":"",i=document.createElement("script");i.src="".concat(Vo).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(i),i},Ji=function(o,t){!o||!o._registerWrapper||o._registerWrapper({name:"stripe-js",version:"3.4.1",startTime:t})},bt=null,ie=null,ne=null,tn=function(o){return function(){o(new Error("Failed to load Stripe.js"))}},en=function(o,t){return function(){window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))}},on=function(o){return bt!==null?bt:(bt=new Promise(function(t,i){if(typeof window>"u"||typeof document>"u"){t(null);return}if(window.Stripe&&o&&console.warn(jo),window.Stripe){t(window.Stripe);return}try{var n=Ki();if(n&&o)console.warn(jo);else if(!n)n=No(o);else if(n&&ne!==null&&ie!==null){var c;n.removeEventListener("load",ne),n.removeEventListener("error",ie),(c=n.parentNode)===null||c===void 0||c.removeChild(n),n=No(o)}ne=en(t,i),ie=tn(i),n.addEventListener("load",ne),n.addEventListener("error",ie)}catch(tt){i(tt);return}}),bt.catch(function(t){return bt=null,Promise.reject(t)}))},nn=function(o,t,i){if(o===null)return null;var n=o.apply(void 0,t);return Ji(n,i),n}
2,Mt,Bo=!1,Oo=function(){return Mt||(Mt=on(null).catch(function(o){return Mt=null,Promise.reject(o)}),Mt)};Promise.resolve().then(function(){return Oo()}).catch(function(e){Bo||console.warn(e)});var ko=function(){for(var o=arguments.length,t=new Array(o),i=0;i<o;i++)t[i]=arguments[i];Bo=!0;var n=Date.now();return Oo().then(function(c){return nn(c,t,n)})};var $o=()=>["localhost","127.0.0.1"].includes(window.location.hostname)?"https://redirectmeto.com/http://localhost:4200":window.location.protocol+"//"+window.location.host;var re=class Ie{set amount(o){this._amount$.next(o)}set recurringPayment(o){this._recurringPayment$.next(o??!1)}constructor(){this.currency="eur",this.formLoading=!1,this.stripeConfig=ye.stripe,this._amount$=new de,this.amount$=this._amount$.pipe(we(300),ut()),this._recurringPayment$=new de,this.stripe$=Te(ko(this.stripeConfig.pk))}ngOnInit(){console.log("Init stripe"),mt([this.stripe$,this.amount$,this._recurringPayment$]).pipe(z(this)).subscribe(([o,t,i])=>{this.stripe=o,t&&this.updateStripeElement(o,t,i)})}updateStripeElement(o,t,i){let n={mode:"payment",amount:Math.round(t*100),currency:this.currency,captureMethod:"manual",paymentMethodTypes:["card"],locale:"es",setupFutureUsage:i?"off_session":"on_session",appearance:{}};try{this.elements?this.elements.update(n):(this.elements=o.elements(n),this.elements.create("payment").mount("#payment-element"))}catch(c){console.log("Error",c)}}submit(){return R(this,null,function*(){let{error:o}=yield this.elements.submit();return o})}confirm(o,t){return R(this,null,function*(){let i=this.elements,n=$o()+ye.stripe.return_url+`?order_id=${t}`;console.log("return_url",n);let{error:c}=yield this.stripe.confirmPayment({elements:i,clientSecret:o,confirmParams:{return_url:n}});return console.log(c),c})}static{this.\u0275fac=function(t){return new(t||Ie)}}static{this.\u0275cmp=b({type:Ie,selectors:[["app-stripe"]],inputs:{amount:"amount",currency:"currency",recurringPayment:"recurringPayment"},decls:2,vars:0,consts:[["fxFill","","id","payment-form"],["id","payment-element"]],template:function(t,i){t&1&&(a(0,"form",0),d(1,"div",1),r())}})}};re=q([Q()],re);var ln=["stripe"];function mn(e,o){if(e&1&&d(0,"app-stripe",9,0),e&2){let t=p();m("amount",t.state.discountPriceBreakdown.fullPrice)("currency",t.formGroup.value.currency)("recurringPayment",t.monthlyActiveFormControl.value)}}function pn(e,o){if(e&1){let t=N();a(0,"div",10),d(1,"input",11),a(2,"div",12)(3,"span"),l(4,"Quiero aportar mensualmente"),r(),a(5,"mat-icon",13,1),A("click",function(){w(t);let n=F(6);return G(n.toggle())}),l(7," info "),r()()()}if(e&2){let t=p();s(5),m("inline",!0)("matTooltip",t.subscriptionTooltipMessage)}}function cn(e,o){e&1&&(I(0),a(1,"span",14),l(2," Tendr\xE1s acceso a la factura y la informaci\xF3n bancaria una vez que confirmes tu solicitud "),r(),S())}function un(e,o){if(e&1&&(a(0,"button",15),l(1),r()),e&2){let t=p();m("disabled",t.disable),s(),M(" ",t.payButtonText," ")}}var ae=class Se{get paymentFormControl(){return this.formGroup.controls.paymentType}get monthlyActiveFormControl(){return this.formGroup.controls.monthlyActive}constructor(o,t,i){this.paymentApi=o,this.router=t,this.currencyPipe=i,this.disable=!1,this.paymentOptions=[{icon:"credit_card",title:"Tarjeta de cr\xE9dito o d\xE9bito",isCustomIcon:!1,value:"creditcard"},{icon:"account_balance",title:"Transferencia bancaria",isCustomIcon:!1,value:"banktransfer"}],this.payButtonText="",this.subscriptionTooltipMessage="Crear una suscripci\xF3n para realizar este mismo aporte autom\xE1ticamente todos los meses, asociado a tu tarjeta de cr\xE9dito."}submit(){return R(this,null,function*(){return this.paymentFormControl.value==="creditcard"?this.stripe.submit():null})}confirm(o){return R(this,null,function*(){if(this.paymentFormControl.value==="banktransfer"){let t={queryParams:{order_id:o.id,redirect_status:"succeeded"},state:{formData:this.formGroup.value}};return this.router.navigate(["/compensar/resultado"],t),null}else{let{clientSecret:t}=yield this.paymentIntent(o);return t?this.stripe.confirm(t,o.id):{message:"Unknown Error"}}})}paymentIntent(o){return R(this,null,function*(){let t={amount:o.fullPrice,currency:o.currency,orderId:o.id,clientId:o.client?.id,userId:o.user?.id};return yield Ft(this.paymentApi.create(t))})}ngOnInit(){this.paymentFormControl.valueChanges.pipe(z(this),Tt(this.paymentFormControl.value)).subscribe(o=>{this.payButtonText=`Pagar ${this.currencyPipe.transform(this.state.discountPriceBreakdown.fullPrice)}`,o==="banktransfer"&&(this.monthlyActiveFormControl.setValue(!1),this.monthlyActiveFormControl.updateValueAndValidity(),this.payButtonText=`Reservar compensaci\xF3n por
3            ${this.currencyPipe.transform(this.state.discountPriceBreakdown.fullPrice)}`)})}static{this.\u0275fac=function(t){return new(t||Se)(f(oe),f(jt),f(yt))}}static{this.\u0275cmp=b({type:Se,selectors:[["app-payment-selector"]],viewQuery:function(t,i){if(t&1&&wt(ln,5),t&2){let n;Gt(n=At())&&(i.stripe=n.first)}},inputs:{formGroup:"formGroup",state:"state",disable:"disable",errorMessage$:"errorMessage$"},decls:11,vars:9,consts:[["stripe",""],["subscriptionTooltip","matTooltip"],["fxLayout","column","fxLayoutGap","15px",1,"data-card","bg-white","p-20",3,"formGroup"],["name","paymentSelectorOptions",3,"options","selectControl"],[3,"amount","currency","recurringPayment",4,"ngIf"],["fxLayout","row","fxLayoutAlign","end center","fxLayoutGap","5px",4,"ngIf"],[4,"ngIf"],["mat-raised-button","","color","primary","class","formatted-submit-button form-text","type","submit",3,"disabled",4,"ngIf"],[3,"formGroup","errorMessage$"],[3,"amount","currency","recurringPayment"],["fxLayout","row","fxLayoutAlign","end center","fxLayoutGap","5px"],["type","checkbox","formControlName","monthlyActive"],["fxLayout","row","fxLayoutAlign","center center","fxLayoutGap","2px"],["matTooltipPosition","below",1,"reduced-icon",3,"click","inline","matTooltip"],[1,"sub-title"],["mat-raised-button","","color","primary","type","submit",1,"formatted-submit-button","form-text",3,"disabled"]],template:function(t,i){t&1&&(a(0,"div",2)(1,"div")(2,"h2")(3,"b"),l(4,"M\xE9todos de Pago"),r()()(),d(5,"app-option-selector",3),u(6,mn,2,3,"app-stripe",4)(7,pn,8,2,"div",5)(8,cn,3,0,"ng-container",6)(9,un,2,2,"button",7),d(10,"app-error-messages",8),r()),t&2&&(m("formGroup",i.formGroup),s(5),m("options",i.paymentOptions)("selectControl",i.paymentFormControl),s(),m("ngIf",i.paymentFormControl.value==="creditcard"),s(),m("ngIf",i.paymentFormControl.value==="creditcard"),s(),m("ngIf",i.paymentFormControl.value==="banktransfer"),s(),m("ngIf",i.state.canPay),s(),m("formGroup",i.formGroup)("errorMessage$",i.errorMessage$))},dependencies:[T,Ao,P,D,H,Xt,Nt,it,O,k,nt,re,Ot,W,Wt]})}};ae=q([Q()],ae);function fn(e,o){if(e&1&&(I(0),a(1,"div",17)(2,"span")(3,"del"),l(4),x(5,"currency"),x(6,"currency"),r()(),a(7,"small",18),l(8,"Te mantenemos el precio"),r()(),a(9,"span"),l(10),x(11,"currency"),r(),S()),e&2){let t=p(2);s(4),vt(" ",t.contributionType==="tons"?v(5,4,t.state.project.price):v(6,6,t.state.project.priceTree)," /",t.contributionType==="tons"?"tonelada":"\xE1rbol"," "),s(6),vt(" ",v(11,8,t.compensationPriceData.discountUnitPrice)," /",t.contributionType==="tons"?"tonelada":"\xE1rbol"," ")}}function yn(e,o){if(e&1&&(a(0,"span"),l(1),x(2,"currency"),x(3,"currency"),r()),e&2){let t=p(2);s(),vt(" ",t.contributionType==="tons"?v(2,2,t.state.project.price):v(3,4,t.state.project.priceTree)," /",t.contributionType==="tons"?"tonelada":"\xE1rbol"," ")}}function hn(e,o){if(e&1){let t=N();a(0,"div",19),d(1,"input",20),a(2,"div",21)(3,"span"),l(4,"Necesito certificado del MITECO"),r(),a(5,"mat-icon",22,2),A("click",function(){w(t);let n=F(6);return G(n.toggle())}),l(7," info "),r()()()}if(e&2){let t=p(2);s(5),m("inline",!0)("matTooltip",t.mitecoTooltipMessage)}}function gn(e,o){if(e&1&&(I(0),a(1,"div",23)(2,"p"),l(3,"Total"),r(),a(4,"p")(5,"b"),l(6),x(7,"currency"),r()()(),a(8,"div",24)(9,"span",11),l(10),x(11,"currency"),r()(),S()),e&2){let t=p(2);s(6),M(" ",v(7,2,t.state.discountPriceBreakdown.fullPrice)," "),s(4),M(" Incluye ",v(11,4,t.state.discountPriceBreakdown.taxAmt)," de IVA ")}}function Cn(e,o){if(e&1&&(a(0,"div",25)(1,"span"),l(2),x(3,"currency"),r(),a(4,"span"),l(5),x(6,"number"),x(7,"currency"),r()(),a(8,"div",23)(9,"p"),l(10,"Total"),r(),a(11,"p")(12,"b"),l(13),x(14,"currency"),r()()()),e&2){let t=p(2);s(2),M(" Subtotal: ",v(3,4,t.state.discountPriceBreakdown.price)," "),s(3),vt(" IVA (",v(6,6,t.state.discountPriceBreakdown.tax*100),"%): ",v(7,8,t.state.discountPriceBreakdown.taxAmt)," "),s(8),M(" ",v(14,10,t.state.discountPriceBreakdown.fullPrice)," ")}}function xn(e,o){if(e&1&&(I(0),a(1,"div",5)(2,"div",6)(3,"div",7)(4,"div",8),d(5,"img",9),r(),a(6,"div",10)(7,"span",11)(8,"span"),l(9),r(),l(10),r(),a(11,"h4"),l(12),r()()(),a(13,"div",12)(14,"span"),l(15,"Precio"),r(),u(16,fn,12,10,"ng-container",13)(17,yn,4,6,"ng-template",null,0,V),r(),d(19,"app-contribution-quantity-input",14),u(20,hn,8,2,"div",15),a(21,"div",16),u(22,gn,12,6,"ng-container",13)(23,Cn,15,12,"ng-template",null,1,V),r()()(),S()),e&2){let t=F(18),i=F(24),n=p();s(5),m("src",n.urlImage,Ae),s(4),M(" ",n.state.project.address.province+", "+n.state.project.address.country," "),s(),M(" \u2022 ",n.state.project.name," "),s(2),et(n.state.project.nameLong),s(4),m("ngIf",n.compensationPriceData.isDiscount)("ngIfElse",t),s(3),m("form",n.formGroup),s(),m("ngIf",n.canChooseMitecoCertificateOption),s(2),m("ngIf",n.state.isLoggedIn&&(n.state.client==null?null:n.state.client.type)==="particular")("ngIfElse",i)}}var Ro=(()=>{class e{constructor(t){this.ui=t,this.actions=new dt,this.canChooseMitecoCertificateOption=!1,this.mitecoTooltipMessage="Para solicitar el sello Compenso, proporcionamos datos sobre la distribuci\xF3n de toneladas y la cesi\xF3n de derechos de absorci\xF3n de CO2.",this.validationMessages={contributionQuantity:[{type:"required",message:"Cantidad requerida"}]},this.urlImage="./assets/images/default/landscape.jpg"}get contributionQuantitytFormControl(){return this.formGroup.controls.contributionQuantity}ngOnInit(){this.isControlInvalid=lo(this.formGroup),this.getErrorMessage=mo(this.formGroup,this.validationMessages)}ngOnChanges(){this.state.project&&(this.urlImage=this.state.project.pictures?this.state.project.pictures[0]:"assets/images/default/landscape.jpg"),this.canChooseMitecoCertificateOption=this.state.isLoggedIn&&this.state?.client?.type!=="particular"&&this.contributionType==="tons"&&(this.state.project.registerStatus==="done"||this.state.project.registerStatus==="inProcess")}static{this.\u0275fac=function(i){return new(i||e)(f(rt))}}static{this.\u0275cmp=b({type:e,selectors:[["app-project-card-checkout-price"]],inputs:{state:"state",contributionType:"contributionType",formGroup:"formGroup",compensationPriceData:"compensationPriceData"},outputs:{actions:"actions"},features:[U],decls:6,vars:2,consts:[["regularPrice",""],["totalPriceNoTax",""],["mitecoTooltip","matTooltip"],["fxLayout","column","fxLayoutAlign.gt-sm","start stretch","fxLayoutAlign.lt-md","center stretch","fxLayoutGap","15px",1,"data-card","bg-white","p-20",3,"formGroup"],[4,"ngIf"],["fxLayoutAlign","center stretch","fxLayout","row","fxLayoutGap","20px"],["fxLayout","column","fxLayoutGap","15px",2,"width","100%"],["fxLayout","row","fxLayoutGap","15px"],["fxLayoutAlign","center"],[1,"thumbnail-image",3,"src"],["fxLayout","column","fxLayoutGap","5px"],[1,"sub-title"],["fxLayout","row","fxLayoutAlign","space-between start"],[4,"ngIf","ngIfElse"],[3,"form"],["fxLayout","row","fxLayoutAlign","end center","fxLayoutGap","5px",4,"ngIf"],["fxLayout","column","fxLayoutGap","15px"],["fxLayout","column","fxLAyoutGap","5px"],[2,"color","red"],["fxLayout","row","fxLayoutAlign","end center","fxLayoutGap","5px"],["type","checkbox","formControlName","needsMiteco"],["fxLayout","row","fxLayoutAlign","center center","fxLayoutGap","2px"],["matTooltipPosition","below",1,"reduced-icon",3,"click","inline","matTooltip"],["fxLayout","row","fxLayoutAlign","space-between center",1,"largest-text"],["fxLayoutAlign","end"],["fxLayout","column","fxLayoutAlign","center end",1,"sub-title"]],template:function(i,n){i&1&&(a(0,"div",3)(1,"div")(2,"h2")(3,"b"),l(4,"Detalles de la orden"),r()()(),u(5,xn,25,10,"ng-container",4),r()),i&2&&(m("formGroup",n.formGroup),s(5),m("ngIf",n.state.project))},dependencies:[T,Eo,P,D,H,W,Wt,Nt,it,O,k,nt,Be,yt]})}}return e})();var _n=["payment"];function bn(e,o){if(e&1){let t=N();a(0,"app-payment-personal-data",18),A("actions",function(n){w(t);let c=p(2);return G(c.onActions(n))}),r()}if(e&2){let t=p().$implicit,i=p();m("formGroup",i.form)("state",t)("countryCode",i.countryCode)}}function Mn(e,o){e&1&&(a(0,"div",19),d(1,"img",20),r())}function In(e,o){if(e&1&&d(0,"app-payment-selector",21,1),e&2){let t=p().$implicit,i=p();m("formGroup",i.form)("state",t)("errorMessage$",i.errorMessage$)("disable",i.submitInProcess)}}function Sn(e,o){if(e&1&&d(0,"app-info-not-payable",22),e&2){let t=p().$implicit,i=p();m("formGroup",i.form)("state",t)}}function En(e,o){if(e&1){let t=N();a(0,"div",3)(1,"mat-toolbar",4)(2,"a",5),A("click",function(){let n=w(t).$implicit,c=p();return G(c.navigateToConfirm(n))}),a(3,"mat-icon",6),l(4,"arrow_back"),r(),a(5,"span",7),l(6,"Volver"),r()(),d(7,"app-user-menu",8),r(),a(8,"div",9)(9,"div",10)(10,"form",11),A("submit",function(){let n=w(t).$implicit,c=p();return G(c.onSubmit(n))}),a(11,"div",12),u(12,bn,1,3,"app-payment-personal-data",13)(13,Mn,2,0,"div",14),x(14,"async"),r(),a(15,"div",15),d(16,"app-project-card-checkout-price",16),u(17,In,2,4,"app-payment-selector",17)(18,Sn,1,2,"ng-template",null,0,V),r()(),d(20,"br"),r()()()}if(e&2){let t=o.$implicit,i=F(19),n=p();s(7),m("keepOnRoute",!0),s(3),m("formGroup",n.form),s(2),m("ngIf",n.form&&t),s(),m("ngIf",v(14,10,n.isLoggedIn$)),s(3),m("state",t)("contributionType",n.contributionTypeFormControl.value)("formGroup",n.form)("compensationPriceData",t.compensationPriceData),s(),m("ngIf",t.canPay)("ngIfElse",i)}}var It=class Ee{onActions(o){let{type:t,payload:i}=o;t=="set"&&i.hasOwnProperty("identification")&&this.identificationValue$.next(i.identification)}get contributionTypeFormControl(){return this.form.controls.contributionType}get contributorTypeFormControl(){return this.form.controls.contributorType}get contributionQuantityFormControl(){return this.form.controls.contributionQuantity}get billingAddressFormControl(){return this.form.controls.billingAddress}get emailFormControl(){return this.form.controls.email}get phoneFormControl(){return this.form.controls.phone}get identificationFormControl(){return this.form.controls.identification}get nameFormControl(){return this.form.controls.name}get monthlyActiveFormControl(){return this.form.controls.monthlyActive}get needsMitecoFormControl(){return this.form.controls.needsMiteco}constructor(o,t,i,n,c,tt,lt,se,le,me,ei,oi,ii){this.fb=o,this.projectService=t,this.router=i,this.appService=n,this.authService=c,this.clientService=tt,this.checkoutService=lt,this.orderService=se,this.translate=le,this.orderApi=me,this.location=ei,this.default_currency_code=oi,this.overlay=ii,this.submitInProcess=!1,this.contributorsType=["particular","business"],this.contributionsType=["tons","trees"],this.paymentTypes=["banktransfer","creditcard"],this.countryCode=je("ES"),this.form=this.fb.group({name:["example",{validators:[y.required,y.minLength(1)],noNullable:!0}],phone:["",{validators:[y.required,y.pattern(/^(?:\+|00)?[1-9][0-9 \-\(\)\.]{7,32}$/)]}],email:["",{validators:[y.required],updateOn:"blur"}],contributionType:[,y.required],contributionQuantity:[1,{validators:[y.required,y.min(1),y.max(1e4)]}],contributorType:[this.contributorsType[0],y.required],currency:[this.default_currency_code.toLocaleLowerCase(),y.required],company:["",y.required],identification:["",{validators:[y.required,y.pattern(/^[A-Z]{0,3}[0-9]+[A-Z]{0,1}$/)]}],billingAddress:this.fb.group({recipient:[""],addressLine1:[""],postalCode:["",{validators:[y.pattern(/^(0[1-9]\d{3}|[1-4]\d{4}|5[0-2]\d{3})$/)],updateOn:"blur"}
3],city:[""],province:[""],provinceId:[""],country:["Espa\xF1a"]}),paymentType:[this.paymentTypes[1],y.required],needsMiteco:[!1],monthlyActive:[!1]}),this.localStorageData$=this.checkoutService.checkoutData$,this.project$=this.localStorageData$.pipe(pt(L=>!L||L&&!L?.id?(this.router.navigate(["/proyectos-colaborativos-reforestacion"]),Lt(null)):this.projectService.get$(L.id)),ot(1)),this.errorMessage$=new ue(""),this.isLoggedIn$=this.authService.user$,this.user$=this.appService.getUserProfile$(),this.client$=this.user$.pipe(pt(L=>L&&L.client?this.clientService.get$(L?.client?.id):Lt(null)),ot(1)),this.contributionQuantityValue$=this.contributionQuantityFormControl.valueChanges.pipe(),this.contributionTypeValue$=this.contributionTypeFormControl.valueChanges,this.contributorTypeValue$=this.contributorTypeFormControl.valueChanges,this.needsMitecoValue$=this.needsMitecoFormControl.valueChanges,this.identificationValue$=new ue(this.identificationFormControl.value),this.clientByTaxId$=this.identificationValue$.pipe(ut(),pt(L=>L?this.clientService.getClientByTaxId$(L.trim().toUpperCase()):Lt(null)),ot(1)),this.compensationPriceTonDistribution$=mt([this.contributionTypeValue$,this.contributionQuantityValue$,this.needsMitecoValue$,this.project$,this.user$,this.client$]).pipe(pt(([L,pe,Ct,ce,St])=>this.orderService.getCompensationPriceTonDistribution$(L,pe,ce,St,Ct)),ot(1)),this.stateUI$=mt([this.isLoggedIn$,this.contributionTypeValue$,this.user$,this.project$,this.client$,this.clientByTaxId$,this.compensationPriceTonDistribution$,this.contributorTypeValue$]).pipe(z(this),De(([L,pe,Ct,ce,St,Le,Et,ni])=>{let ri=!!Ct?.client?.id,ai=Ct?.roles?.includes("ADMIN"),si=ni==="business",li=!ai&&(!L&&Le?.type!=="business"||L&&St?.type!=="group");Et.notEnoughError&&(pe==="tons"?this.contributionQuantityFormControl.setErrors({notEnoughTons:!0}):this.contributionQuantityFormControl.setErrors({notEnoughTrees:!0}));let mi=Yt.priceBreakdown(Et.priceFull),Fe=Yt.priceBreakdown(Et.price),pi=Fe.price/this.contributionQuantityFormControl.value;return{isLoggedIn:L,user:Ct,project:ce,isBusiness:ri,client:St,companyOptionChosen:si,clientByTaxId:Le,canPay:li,compensationPriceData:B({discountUnitPrice:pi},Et),originalPriceBreakdown:mi,discountPriceBreakdown:Fe}}),ot(1))}ngOnInit(){}ngAfterViewInit(){mt([this.localStorageData$,this.client$,this.user$]).pipe(z(this)).subscribe(([o,t,i])=>{let n=o?.contributionQuantity??1,c=o?.contributorType??"particular";t&&(c=t?.type==="business"?"business":"particular");let tt=o?.contributionType??this.contributionsType[0],lt=o?.monthlyActive??!1,se=o?.needsMiteco??!1;this.countryCode.set(o.countryCode??"ES");let le=t?{name:t.name,company:t.type==="business"?t.name:"",phone:(t.type==="particular"?t.phoneNumber:t.contact?.phoneNumber)??"",email:i.email,identification:t.taxId??null,billingAddress:{recipient:t.billingAddress?.recipient,addressLine1:t.billingAddress?.addressLine1,postalCode:t.billingAddress?.postalCode,city:t.billingAddress?.city,province:t.billingAddress?.province,provinceId:t.billingAddress?.provinceId,country:t.billingAddress?.country||"Espa\xF1a"}}:{},me=i?B(B({},o),le):B({},o);this.form.reset({contributorType:this.contributorsType[0],currency:this.default_currency_code.toLocaleLowerCase(),email:"",paymentType:this.paymentTypes[1]}),this.form.patchValue(xt(B({},me),{contributionQuantity:n,contributionType:tt,contributorType:c,monthlyActive:lt,needsMiteco:se}))}),mt([this.project$,this.router.events]).pipe(z(this),Pe(([o,t])=>t instanceof Oe),Ge(1)).subscribe(o=>{let[t,i]=o;this.checkoutService.setCheckoutData(xt(B({id:t.id,slug:t.slug},this.form.value),{countryCode:this.countryCode()}),!0)})}navigateToConfirm(o){let t=this.form.value;this.checkoutService.setCheckoutData(xt(B({id:o.project.id,slug:o.project.slug},t),{countryCode:this.countryCode()}),!0),this.router.navigate(["/compensar/proyecto/"+o.project.slug])}onSubmit(o){return R(this,null,function*(){if(this.form.markAllAsTouched(),!this.form.valid)return;this.loadingOverlay=this.overlay.create({hasBackdrop:!0,positionStrategy:this.overlay.position().global().centerHorizontally().centerVertically(),disposeOnNavigation:!0}),this.loadingOverlay.attach(new Ze(xe)),this.checkoutService.setCheckoutData(xt(B({id:o.project.id},this.form.value),{countryCode:this.countryCode()}),!0),this.submitInProcess=!0;let t=this.normalize(this.form.value,o),i=ve.genOrderRequestNew(t),n=yield this.payment.submit();if(n){this.handleError(n);return}let c;try{c=yield Ft(this.orderApi.create(i))}catch(lt){this.handleError(lt);return}let tt;try{if(tt=yield this.payment.confirm(c),this.submitInProcess=!1,this.loadingOverlay.detach(),tt?.decline_code){this.errorMessage$.next(this.translate.instant(tt.message));return}}catch(lt){this.handleError(lt);return}})}normalize(o,t){let i=t.discountPriceBreakdown;if(o.phone&&o.phone){let c=vo(o.phone,this.countryCode());o.phone=c.format("E.164")}return{order:{paymentMethod:o.paymentType,project:Ce.genRef(t.project),items:this.generateItems(o,t.compensationPriceData),price:i.price,currency:o.currency.toUpperCase(),tax:i.tax,taxAmt:i.taxAmt,fullPrice:i.fullPrice,billingAddress:o.billingAddress,user:t.user?he.genRef(t.user):null,client:t.client?ge.genRef(t.client):null,email:o.email.trim().toLocaleLowerCase(),taxId:o.identification?o.identification.trim().toUpperCase():"",name:o.name.trim().toUpperCase(),phoneNumber:o.phone??"",createSubscription:o.monthlyActive},clientType:o.contributorType,company:o.contributorType==="business"?o.company:null}}generateItems(o,t){return[{itemType:"compensation",type:o.contributionType,trees:o.contributionType==="trees"?o.contributionQuantity:0,tCo2:o.contributionType==="tons"?o.contributionQuantity:0,tCo2Distribution:t.tonDistribution??null,price:t.price}]}handleError(o){this.loadingOverlay.detach(),this.submitInProcess=!1,console.log(o),this.errorMessage$.next("Ha ocurrido un error. Int\xE9ntalo de nuevo"),console.log("@%$ xERROR",o)}static{this.\u0275fac=function(t){return new(t||Ee)(f(qe),f($e),f(jt),f(no),f(io),f(ro),f(ao),f(Co),f(Ke),f(Kt),f(Ve),f(Ne),f(Ye))}}static{this.\u0275cmp=b({type:Ee,selectors:[["app-checkout"]],viewQuery:function(t,i){if(t&1&&wt(_n,5),t&2){let n;Gt(n=At())&&(i.payment=n.first)}},decls:2,vars:3,consts:[["infoNotPayable",""],["payment",""],["fxFill","","fxLayout","column","class","main-container wordpress-container",4,"ngIf"],["fxFill","","fxLayout","column",1,"main-container","wordpress-container"],["fxLayout","row","fxLayoutAlign","space-between center",1,"bg-white","mat-elevation-z2",2,"z-index","2"],["mat-icon-button","","routerLinkActive","active-link",1,"active-link",3,"click"],["aria-hidden","false"],[2,"margin-left","20px"],[3,"keepOnRoute"],["fxFlex","","fxLayout","row",2,"overflow","scroll","padding","20px 0"],["fxFlex","","fxLayout","column",1,"container-wrapper"],["fxFlex","","fxLayout","row","fxLayoutAlign","center","fxLayout.lt-md","column","fxLayoutAlign.lt-md","space-around","fxLayoutGap","20px",1,"formatted-
3page-contents","checkout",3,"submit","formGroup"],["fxFlex","","fxLayout","column","fxLayoutGap","30px"],["fxFlex","",3,"formGroup","state","countryCode","actions",4,"ngIf"],["fxFlex","","fxLayout","column","fxFlexAlign","center ","class","join-future","fxHide.lt-md","","fxLayoutAlign","start start",4,"ngIf"],["fxFlex","","fxLayout","column","fxLayoutGap","20px"],[3,"state","contributionType","formGroup","compensationPriceData"],[3,"formGroup","state","errorMessage$","disable",4,"ngIf","ngIfElse"],["fxFlex","",3,"actions","formGroup","state","countryCode"],["fxFlex","","fxLayout","column","fxFlexAlign","center ","fxHide.lt-md","","fxLayoutAlign","start start",1,"join-future"],["src","assets/join-for-the-future-green.png"],[3,"formGroup","state","errorMessage$","disable"],[3,"formGroup","state"]],template:function(t,i){t&1&&(u(0,En,21,12,"div",2),x(1,"async")),t&2&&m("ngIf",v(1,1,i.stateUI$))},dependencies:[ke,T,P,D,H,ze,Qe,ht,eo,Re,O,Jt,Xe,W,We,k,ee,ae,Ro,so,ft],styles:["[_nghost-%COMP%]{background-color:var(--primary-200)}.main-container[_ngcontent-%COMP%]{background-color:var(--primary-200);min-height:100%}@media (max-height: 900px){.join-future[_ngcontent-%COMP%]{display:none!important;opacity:0}}@media (max-width: 965px){.formatted-page-contents-checkout[_ngcontent-%COMP%]{margin:0;background-image:none;box-shadow:none;padding:0}.join-future[_ngcontent-%COMP%]{display:none!important}}"]})}};It=q([Q()],It);var Ln=[{path:"proyecto",loadChildren:()=>import("./chunk-KULSBLAJ.js").then(e=>e.ConfirmModule)},{path:"pago",component:It},{path:"pago/:slug",component:It},{path:"resultado",loadChildren:()=>import("./chunk-MLEJG3TF.js").then(e=>
3e.CheckoutResultModule)}],qo=(()=>{class e{constructor(){}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[fe.forChild(Ln),fe]})}}return e})();var Uo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_,Fo,uo,E,X,$,K,gt,J,co,j,fo,Y]})}}return e})();var Qo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[So,_,E]})}}return e})();var zo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_,E,X,$,K,J,Io,j,Y]})}}return e})();var Wo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_,E,X,$,K,J,at,j,Y]})}}return e})();var Ho=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[Qo,Wo,_,zo,E,yo,Z,X,$,K,zt,J,at,j,Y]})}}return e})();var Zo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_]})}}return e})();var Yo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_]})}}return e})();var Xo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({providers:[oe,yt],imports:[_,Yo,E,at,j,Zo,Z,$,gt]})}}return e})();var Ko=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_,E,j,Z,gt]})}}return e})();var Jo=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[Ko,_,E,Z]})}}return e})();var ti=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({imports:[_,$t]})}}return e})();var Vl=(()=>{class e{static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275mod=g({type:e})}static{this.\u0275inj=h({providers:[Kt],imports:[qo,_,Lo,E,Ue,go,Jo,ti,Z,X,$,K,to,$t,zt,He,J,at,j,Ho,Xo,Uo,po,Y,ho]})}}return e})();export{Vl as CheckoutModule};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.