1import{$a as me,$c as Ho,B as $o,C as Fo,D as Io,E as Le,F as Lo,H as Ao,Sc as Qo,W as le,Xb as Po,_a as Ae,ab as oe,cc as Uo,db as Do,dc as Bo,ec as ko,fc as Vo,kc as zo,la as vo,pa as Wo,qc as ve,rc as qe,sa as No,w as Fe,wc as Go,x as Ie,xc as Xo,yc as jo,ye as Yo,zc as qo}from"./chunk-6QDVQ5WV.js";import{$a as w,$e as vt,$n as Kt,$r as _o,A as Se,Ap as ro,B as ue,Ba as N,Bn as Me,Bp as so,Bv as wo,Ca as v,Cc as Q,Cl as be,Cn as qt,D as ct,Db as yt,Dv as go,Ed as H,Ev as li,Fo as no,Fv as Ro,Gv as yo,Ha as y,Hc as xt,Hd as Lt,Hl as Gt,Hv as bo,Ib as p,Iv as mi,Ja as b,Jb as c,Jn as K,Ju as To,Jv as $e,K as ut,Kn as J,L as dt,Lp as ao,M as he,Mb as Ue,N as W,Nn as Z,O as A,Oa as s,On as ee,Op as lo,Pa as m,Pe as Xe,Qa as d,Ra as C,Ri as Wt,Rk as Bt,Sb as bt,Sc as $t,Se as At,Sl as P,Sn as k,Uc as ze,Up as mo,V as se,Va as G,W as _t,Wa as X,Wb as F,Wn as Qt,Wu as ai,Xn as Ht,Xu as I,Ya as x,Yu as So,Z as r,Za as Re,Zt as ae,_a as ye,_b as Mt,_n as Yt,ac as Ot,ao as Jt,as as Co,bb as ft,c as Te,ca as S,cb as Et,da as h,db as Tt,dm as Xt,dy as pi,e as mt,eb as T,eo as Zt,eq as po,ev as L,ey as Mo,fb as _,fq as co,ga as we,gl as Y,gu as xe,hl as kt,hy as Oo,i as ne,id as Ft,jb as St,k as ce,kb as ht,ko as eo,kq as uo,l as u,la as ge,lb as wt,lo as to,m as re,md as Ge,nl as B,ob as Pe,ot as fo,pj as Nt,pl as de,pm as jt,rc as j,rj as Dt,rm as U,ro as oo,sa as l,sl as Vt,so as io,t as pt,tb as gt,tc as q,tj as Pt,uj as Ut,uy as xo,vb as Rt,vc as Be,vu as Eo,w as De,wc as ke,wd as It,wl as zt,xo as Oe,ya as $,yc as D,za as Ct,zc as Ve,zl as je,zv as ho}from"./chunk-6VDOBKBI.js";import"./chunk-UNNH6OJB.js";import{a as R,b as O,f as Ee,h as te}from"./chunk-HE2D45TV.js";function Ko(o){return!!o&&o.type==="create"}function Jo(o){return!!o&&o.type==="update"}var Qe=Ee(ai()),He=Ee(mi());var Zo=(()=>{class o{constructor(){this.customerUpdateProperties=r(ko),this.customerCreateProperties=r(Uo),this.locationRx=r(ae),this.customerUpdateSchemaOptions$=De([this.customerUpdateProperties.getPermittedProperties(),this.locationRx.getCurrentLocation(["address","requireName","requirePhone","requireEmail"])]).pipe(u(([e,t])=>{let i=me(He.PAYLOAD_SCHEMA,new ke(Object.keys(e).reduce((a,E)=>O(R({},a),{[E]:new Ve(null)}),{}))),n={};t.requireName&&(n.name=n.firstName=n.lastName=[j.required]),t.requirePhone&&(n.phone=[j.required]),t.requireEmail&&(n.email=[j.required]);for(let[a,E]of Object.entries(n))i.get(a)?.setValidators(E);return{formGroup:i,description:He.PAYLOAD_SCHEMA,labels:{name:$localize`Name`,firstName:$localize`First name`,lastName:$localize`Last name`,phone:$localize`Phone`,email:$localize`Email`},placeholders:{name:$localize`Ex. Walter Wait`,firstName:$localize`Ex. Walter`,lastName:$localize`Ex. Wait`,phone:$localize`Ex. ${ze(t.address?.country?.code??"US",qe)?.formatNational()}`,email:$localize`Ex. [email protected]`},componentModifiers:{phone:a=>this.showCountryCode(a,t.address?.country?.code)}}}),ue(1)),this.customerCreateSchemaOptions$=De([this.customerCreateProperties.getPermittedProperties(),this.locationRx.getCurrentLocation(["address","requireName","requirePhone","requireCustomerId","requireEmail"])]).pipe(u(([e,t])=>{let i=me(Qe.PAYLOAD_SCHEMA,new ke(Object.keys(e).reduce((a,E)=>O(R({},a),{[E]:new Ve(null)}),{}))),n={};t.requireName&&(n.name=n.firstName=n.lastName=[j.required]),t.requirePhone&&(n.phone=[j.required]),t.requireCustomerId&&(n.externalId=[j.required]),t.requireEmail&&(n.email=[j.required]);for(let[a,E]of Object.entries(n))i.get(a)?.setValidators(E);return{formGroup:i,description:Qe.PAYLOAD_SCHEMA,labels:{name:$localize`Name`,firstName:$localize`First name`,lastName:$localize`Last name`,phone:$localize`Phone`,email:$localize`Email`,externalId:$localize`Customer ID`},placeholders:{name:$localize`Ex. Walter Wait`,firstName:$localize`Ex. Walter`,lastName:$localize`Ex. Wait`,phone:$localize`Ex. ${ze(t.address?.country?.code??"US",qe)?.formatNational()}`,email:$localize`Ex. [email protected]`,externalId:$localize`Ex. 12345`},componentModifiers:{phone:a=>this.showCountryCode(a,t.address?.country?.code)}}}),ue(1))}
1showCountryCode(e,t){return!t||!de(lo,e)?e:B(e,{countryCode:t})}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275prov=se({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();function di(o,f){o&1&&C(0,"ww-customer-external-profile",8),o&2&&s("entityId",f)}function _i(o,f){o&1&&(G(0),w(1,1),X())}function Ci(o,f){o&1&&(G(0),w(1,2),X())}function fi(o,f){if(o&1){let e=x();m(0,"ww-section")(1,"ww-section-title"),C(2,"ww-text",3),m(3,"button",4),T("click",function(){S(e);let i=_();return h(i.cancel())}),C(4,"ww-icon",5),d()(),m(5,"ww-section-content",6),C(6,"ww-joi-form",7),y(7,di,1,1,"ww-customer-external-profile",8),d(),m(8,"ww-section-actions")(9,"button",9),T("click",function(){S(e);let i=_();return h(i.cancel())}),w(10,0),d(),m(11,"button",10),T("click",function(){let i=S(e),n=_();return h(n.save(i.options.formGroup.value))}),y(12,_i,2,0,"ng-container"),y(13,Ci,2,0,"ng-container"),d()()()}if(o&2){let e,t=f,i=_();l(2),s("content",(i.customer==null?null:i.customer.name)??i.title),l(4),s("form",t),l(),b((e=i.customer==null?null:i.customer.id)?7:-1,e),l(4),s("disabled",t.options.formGroup.invalid),l(),b(i.customer?12:-1),l(),b(i.customer?-1:13)}}var et=(()=>{class o extends Y{constructor(){super(...arguments),this.layout=r(L),this.customerSchemaOptions=r(Zo),this.addCustomerWrite=r(ho),this.updateCustomerWrite=r($e),this.joiForm$=re([this.customerSchemaOptions.customerUpdateSchemaOptions$,this.customerSchemaOptions.customerCreateSchemaOptions$]).pipe(Se(0,mt),ue(1),u(([e,t])=>{let n=!!this.customer?oe(e):oe(t);return this.customer&&n.options.formGroup.patchValue(this.customer),n.items=n.items.map((a,E)=>(this.autoFocusKey?this.autoFocusKey===a.key:E===0)?O(R({},a),{component:B(a.component,{autoFocus:!0})}):a),n}),ut({bufferSize:1,refCount:!0}))}cancel(){this.layout.close()}save(e){let t=this.getFormValue(e);Ko(t)?this.addCustomerWrite.payload.next(t.payload):Jo(t)&&this.updateCustomerWrite.payload.next(t.payload),this.layout.close()}getFormValue(e){if(!this.customer)return{type:"create",payload:e};if(At(e))return null;let t=e;return{type:"update",payload:{customerId:this.customer.id,updates:t}}}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=ge(o)))(i||o)}})()}static{this.\u0275cmp=$({type:o,selectors:[["ww-customer-editor"]],hostAttrs:[1,"ww-customer-editor"],inputs:{title:"title",customer:"customer",autoFocusKey:"autoFocusKey"},standalone:!1,features:[N],decls:2,vars:3,consts:()=>{let e;e=$localize`Cancel`;let t;t=$localize`Save`;let i;return i=$localize`Add`,[e,t,i,[3,"content"],["wwButton","tertiary",3,"click"],["icon","bx-x"],[1,"flex","flex-col","gap-4"],[3,"form"],[3,"entityId"],["wwButton","secondary",3,"click"],["wwButton","",3,"click","disabled"]]},template:function(t,i){if(t&1&&(y(0,fi,14,6,"ww-section"),p(1,"async")),t&2){let n;b((n=c(1,1,i.joiForm$))?0:-1,n)}},dependencies:[zo,P,U,K,ee,J,Z,be,Ae,F],encapsulation:2,changeDetection:0})}}return o})();var tt=Ee(li()),ot=Ee(pi());function Ti(o,f){if(o&1){let e=x();m(0,"ww-section")(1,"ww-section-title")(2,"span"),w(3,0),d(),m(4,"button",4),C(5,"ww-icon",5),d()(),m(6,"ww-section-content",6),C(7,"ww-select",7),p(8,"async"),p(9,"async"),C(10,"ww-select",8),p(11,"async"),C(12,"ww-joi-form",9),m(13,"ww-info-bubble")(14,"p"),Re(15,1),C(16,"span"),p(17,"number"),ye(),d()()(),m(18,"ww-section-actions")(19,"button",10),w(20,2),d(),m(21,"button",11),p(22,"async"),T("click",function(){S(e);let i=_();return h(i.export())}),w(23,3),d()()()}if(o&2){let e=f,t=_();l(6),s("padding","large"),l(),s("formControl",t.exportTypeFormControl)("data",c(8,10,t.exportTypes$))("pluckLabel",c(9,12,t.pluckExportTypeLabel$)),l(3),s("data",c(11,14,t.locationData$))("pluckLabel",t.pluckLocationLabel)("formControl",t.locationFormControl),l(2),s("form",e),l(5),ft(c(17,16,1e4)),Et(15),l(4),s("disabled",e.options.formGroup.invalid||c(22,18,t.exportInProgress$))}}var nt=(()=>{class o extends Y{constructor(){super(),this.businessTerms=r(I),this.exportCustomerWrite=r(Ro),this.exportVisitWrite=r(Mo),this.locationRx=r(ae),this.exportTypeFormControl=new D("visits",{nonNullable:!0}),this.locationAllOption="ALL_LOCATIONS",this.locationFormControl=new D(this.locationAllOption,{nonNullable:!0}),this.locationData$=this.locationRx.getCurrentLocation(["name","id"]).pipe(u(e=>[this.locationAllOption,e])),this.pluckLocationLabel=e=>e===this.locationAllOption?$localize`All locations`:e.name,this.exportType$=H(this.exportTypeFormControl),this.exportTypes$=this.locationRx.getCurrentLocation(["isBookingActive"]).pipe(u(({isBookingActive:e})=>e?["visits","bookings","customers"]:["visits","customers"])),this.pluckExportTypeLabel$=this.businessTerms.businessTerms$.pipe(u(e=>t=>{switch(t){case"customers":return $localize`Unique ${e.customerTerm.pluralCapitalized}`;case"visits":return $localize`All ${e.visitTerm.pluralLower}`;case"bookings":return e.bookedStateTerm.pluralCapitalized}}
1)),this.form$=this.exportType$.pipe(u(e=>this.createJoiForm(e))),this.exportInProgress$=pt(this.exportCustomerWrite.isLoading$,this.exportVisitWrite.isLoading$).pipe(he(!1)),this.joiFormLocale=R(R({created:$localize`Date created`,updated:$localize`Last updated`,date:$localize`Date`},So),Bt),this.customersQueryFormGroup=me(tt.QUERY_SCHEMA,new Be(je()({dateRangeField:[void 0],format:[void 0],fromDate:[new Date],toDate:[new Date]}))),this.customersQueryFormOptions={description:tt.QUERY_SCHEMA,formGroup:this.customersQueryFormGroup,labels:{dateRangeField:$localize`Based on`,format:$localize`File format`,fromDate:$localize`From`,toDate:$localize`To`},placeholders:{},locale:this.joiFormLocale},this.visitsQueryFormGroup=me(ot.QUERY_SCHEMA,new Be(je()({dateRangeField:[void 0],state:[void 0],tag:[void 0],format:[void 0],fromTime:[new Date],toTime:[new Date]}))),this.visitsQueryFormOptions={description:ot.QUERY_SCHEMA,formGroup:this.visitsQueryFormGroup,locale:this.joiFormLocale,labels:{dateRangeField:$localize`Based on`,format:$localize`File format`,fromTime:$localize`From`,toTime:$localize`To`,state:$localize`State`,tag:$localize`Tag`},placeholders:{state:$localize`Any`,tag:$localize`Any`}},this.subscribe()}export(){return te(this,null,function*(){let e=this.locationFormControl.value===this.locationAllOption?void 0:this.locationFormControl.value.id;this.exportTypeFormControl.value==="customers"?this.exportCustomerWrite.payload.next(Xe(O(R({},this.customersQueryFormGroup.value),{locationId:e}),Ge)):this.exportVisitWrite.payload.next(Xe(O(R({},this.visitsQueryFormGroup.value),{locationId:e}),Ge))})}createJoiForm(e){return e==="customers"?oe(O(R({},this.customersQueryFormOptions),{componentModifiers:{dateRangeField:this.disableDateOption}})):e==="bookings"?oe(O(R({},this.visitsQueryFormOptions),{componentModifiers:{dateRangeField:t=>this.onlyReadonlyDateOption(t)}})):oe(O(R({},this.visitsQueryFormOptions),{componentModifiers:{dateRangeField:t=>this.disableDateOption(t)}}))}subscribe(){this.exportType$.pipe(A(this.ngOnDestroy$)).subscribe(e=>{this.visitsQueryFormGroup.controls.dateRangeField.setValue(e==="bookings"?"date":void 0)})}onlyReadonlyDateOption(e){return de(k,e)?B(e,{data:["date"],readonly:!0}):e}disableDateOption(e){return de(k,e)?B(e,{pluckDisabled:t=>t==="date"}):e}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275cmp=$({type:o,selectors:[["ww-customer-export"]],hostAttrs:[1,"ww-customer-export"],standalone:!1,features:[N],decls:2,vars:3,consts:()=>{let e;e=$localize`Export`;let t;t=$localize`Location`;let i;i=$localize`Export`;let n;n=$localize` The export limit is ${"\uFFFD#16\uFFFD"}:START_TAG_SPAN:${"\uFFFD0\uFFFD"}:INTERPOLATION:${"\uFFFD/#16\uFFFD"}:CLOSE_TAG_SPAN: hits per query. `;let a;a=$localize`Cancel`;let E;return E=$localize` Export `,[i,n,a,E,["wwButton","tertiary","wwLayoutClose",""],["icon","bx-x"],[1,"gap-y-6",3,"padding"],["label",e,3,"formControl","data","pluckLabel"],["label",t,3,"data","pluckLabel","formControl"],[3,"form"],["wwButton","secondary","wwLayoutClose",""],["wwButton","",3,"click","disabled"]]},template:function(t,i){if(t&1&&(y(0,Ti,24,20,"ww-section"),p(1,"async")),t&2){let n;b((n=c(1,1,i.form$))?0:-1,n)}},dependencies:[q,Q,le,P,U,Me,K,ee,J,Z,k,Ae,F,Mt],encapsulation:2,changeDetection:0})}}return o})();var rt=(()=>{class o{constructor(){this.importCustomer=r(yo),this.importVisit=r(Oo),this.layout=r(L),this.changeDetectorRef=r(bt),this.businessTerms=r(I),this.options=["customer","waitlist","bookings"],this.selectFormControl=new D(this.options[0],{nonNullable:!0}),this.pluckLabel$=this.businessTerms.businessTerms$.pipe(u(e=>t=>({customer:e.customerTerm.capitalized,waitlist:e.waitingStateTerm.capitalized,bookings:e.bookedStateTerm.capitalized})[t]))}browseFile(){return te(this,null,function*(){this.selectedFile=void 0,this.selectedFile=yield Ft([".csv"]),this.changeDetectorRef.markForCheck()})}import(){return te(this,null,function*(){if(!this.selectedFile)return;let{content:e}=this.selectedFile;this.selectFormControl.value==="customer"?(this.importCustomer.payload.next(e),(yield ce(this.importCustomer.response$))&&this.layout.close()):(this.importVisit.payload.next({content:e,visitState:this.selectFormControl.value==="waitlist"?"WAITING":"BOOKED"}),(yield ce(this.importVisit.response$))&&this.layout.close())})}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275cmp=$({type:o,selectors:[["ww-customer-import"]],hostAttrs:[1,"ww-cu
1stomer-import"],standalone:!1,decls:27,vars:8,consts:()=>{let e;e=$localize`Import to`;let t;t=$localize`Import`;let i;i=$localize`CSV file`;let n;n=$localize` Please make sure that your file follows the same format as our ${"\uFFFD#16\uFFFD"}:START_LINK:Customers CSV template${"[\uFFFD/#16\uFFFD|\uFFFD/#17\uFFFD]"}:CLOSE_LINK: (0.2kb). For more help, read ${"\uFFFD#17\uFFFD"}:START_LINK_1:How to import Customers${"[\uFFFD/#16\uFFFD|\uFFFD/#17\uFFFD]"}:CLOSE_LINK:. `,n=Tt(n);let a;a=$localize` Browse... `;let E;E=$localize`Cancel`;let g;return g=$localize` Import `,[t,i,n,a,E,g,["wwButton","tertiary","wwLayoutClose",""],["icon","bx-x"],[3,"padding"],[1,"flex","flex-col","gap-5"],["label",e,3,"formControl","data","pluckLabel"],["href","https://firebasestorage.googleapis.com/v0/b/waitwhile-app.appspot.com/o/files%2FGuest_Visit_Import_Template.xlsx?alt=media&token=88b42571-823e-4ede-b115-84c742c22d78","target","_blank","wwColor","primary"],["href","https://help.waitwhile.com/en/articles/5342231-how-to-import-customers","target","_blank","wwColor","primary"],[1,"flex","items-center","gap-4"],["wwButton","secondary",3,"click"],["wwButton","secondary","wwLayoutClose",""],["wwButton","",3,"click","disabled"]]},template:function(t,i){t&1&&(m(0,"ww-section")(1,"ww-section-title")(2,"span"),w(3,0),d(),m(4,"button",6),C(5,"ww-icon",7),d()(),m(6,"ww-section-content",8)(7,"span",9),C(8,"ww-select",10),p(9,"async"),m(10,"span")(11,"ww-label"),w(12,1),d(),m(13,"ww-info-bubble")(14,"p"),Re(15,2),C(16,"a",11)(17,"a",12),ye(),d()()(),m(18,"span",13)(19,"button",14),T("click",function(){return i.browseFile()}),w(20,3),d(),gt(21),d()()(),m(22,"ww-section-actions")(23,"button",15),w(24,4),d(),m(25,"button",16),T("click",function(){return i.import()}),w(26,5),d()()()),t&2&&(l(6),s("padding","large"),l(2),s("formControl",i.selectFormControl)("data",i.options)("pluckLabel",c(9,6,i.pluckLabel$)),l(13),Rt(" ",i.selectedFile==null?null:i.selectedFile.name," "),l(4),s("disabled",!i.selectedFile))},dependencies:[q,Q,le,P,jt,Xt,U,Me,K,ee,J,Z,k,F],encapsulation:2,changeDetection:0})}}return o})();var oi={details:0,notes:1,visits:2,messages:3};function gi(o,f){if(o&1){let e=x();m(0,"ww-customer-details",11),p(1,"async"),T("editKey",function(i){S(e);let n=_(),a=_();return h(a.customerService.openEditor({customer:n,autoFocusKey:i}))}),m(2,"ww-section-actions")(3,"button",12),T("click",function(){S(e);let i=_(),n=_();return h(n.visitCoreService.openCustomerVisitCreator({entity:i}))}),w(4,0),d()()()}if(o&2){let e=_(2);s("entityId",c(1,2,e._entityId$)),l(3),s("wwEventLogger","opened_create_visit_from_customer")}}function Ri(o,f){if(o&1&&(C(0,"ww-customer-notes",14),p(1,"async")),o&2){let e=_(3);s("entityId",c(1,1,e._entityId$))}}function yi(o,f){o&1&&v(0,Ri,2,3,"ng-template",13)}function bi(o,f){if(o&1&&(C(0,"ww-customer-history",14),p(1,"async")),o&2){let e=_(3);s("entityId",c(1,1,e._entityId$))}}function Mi(o,f){if(o&1&&(v(0,bi,2,3,"ng-template",15),p(1,"async")),o&2){let e=_(2);s("label",c(1,1,e.visitsLabel$))}}function Oi(o,f){if(o&1&&(C(0,"ww-customer-chat",14),p(1,"async")),o&2){let e=_(3);s("entityId",c(1,1,e._entityId$))}}function xi(o,f){o&1&&v(0,Oi,2,3,"ng-template",16)}function $i(o,f){if(o&1&&(m(0,"ww-section")(1,"ww-section-title"),C(2,"ww-text",1),m(3,"div",2),C(4,"ww-model-action-menu",3),p(5,"async"),C(6,"ww-model-action-button",4),p(7,"async"),m(8,"button",5),C(9,"ww-icon",6),d()()(),m(10,"ww-section-content",7)(11,"ww-tab-group",8),p(12,"async"),v(13,gi,5,4,"ng-template",9)(14,yi,1,0,null,10)(15,Mi,2,3,null,10)(16,xi,1,0,null,10),d()()()),o&2){let e=_();l(2),s("truncate",!0)("content",f.name),l(2),s("actions",c(5,12,e.actions$)),l(2),s("type","tertiary")("action",c(7,14,e.editAction$))("withLabel",!1),l(4),s("padding","none"),l(),s("selectedIndex",c(12,16,e.selectedTabIndex$))("rendering","hide"),l(3),s("wwPermission","customer-notes.show"),l(),s("wwPermission","visits.show"),l(),s("wwPermission","messages.show")}}var Fi=Vt(kt),st=(()=>{class o extends Fi{constructor(){super(),this.customerService=r(pe),this.visitCoreService=r(ve),this.businessTerms=r(I),this.customerActions=r(ie),this.customerRx=r(xe),this.layout=r(L),this.queryParams=r(vt),this.selectedTab="details",this.selectedTab$=this.observe("selectedTab"),this.selectedTabIndex$=this.selectedTab$.pipe(u(e=>oi[e]??0)),this.actions$=this._entity$.pipe(W(e=>e?this.customerActions.getActions([e]):ne([]))),this.editAction$=this._entity$.pipe(W(e=>e?this.customerActions.getAction([e],"edit"):ne(null))),this.restoreLastVisitAction$=this._entity$.pipe(W(e=>e?this.customerActions.getAction([e],"restoreLastVisit"):ne(null))),this.visitsLabel$=this.businessTerms.businessTerms$.pipe(u(e=>e.visitTerm.pluralCapitalized)),this._entityApi=e=>this.customerRx.getCustomer(e),this.subscribe()}subscribe(){this._entityRemoved$.pipe(A(this.ngOnDestroy$)).subscribe(()=>{this.layout.close()})}ngOnDestroy(){this.queryParams.update({remove:["viewCustomerId"],disableEmitEvent:!0})}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275cmp=$({type:o,selectors:[["ng-component"]],hostAttrs:[1,"ww-cu
1stomers-viewer"],inputs:{entity:"entity",entityId:"entityId",disableEntityUpdates:"disableEntityUpdates",selectedTab:"selectedTab"},standalone:!1,features:[N],decls:2,vars:3,consts:()=>{let e;e=$localize`Details`;let t;t=$localize` Create visit `;let i;i=$localize`Notes`;let n;return n=$localize`Messages`,[t,[3,"truncate","content"],[1,"flex","items-center"],[3,"actions"],[3,"type","action","withLabel"],["wwButton","tertiary","wwLayoutClose",""],["icon","bx-x"],[3,"padding"],[3,"selectedIndex","rendering"],["wwTab","","label",e],[4,"wwPermission"],[3,"editKey","entityId"],["wwButton","",3,"click","wwEventLogger"],["wwTab","","label",i],[3,"entityId"],["wwTab","",3,"label"],["wwTab","","label",n]]},template:function(t,i){if(t&1&&(y(0,$i,17,18,"ww-section"),p(1,"async")),t&2){let n;b((n=c(1,1,i._entity$))?0:-1,n)}},dependencies:[Go,Xo,jo,qo,Ie,le,Io,Le,Fe,P,U,K,ee,J,Z,co,po,be,F],encapsulation:2,changeDetection:0})}}return o})();var pe=(()=>{class o{constructor(){this.layout=r(L)}openBatchChat(e){return this.layout.open({component:{type:Po,inputs:e}})}
1openEditor(e){return this.layout.open({component:{type:et,inputs:e},disableClose:!0})}openExport(e){return this.layout.open({component:{type:nt,inputs:e},disableClose:!0})}openImport(e){return this.layout.open({component:{type:rt,inputs:e},disableClose:!0})}openViewer(e,t=(i,n)=>i?.entityId===n?.entityId&&i?.entity?.id===n?.entity?.id){return this.layout.open({component:{type:st,inputs:e},isEqualInputs:t})}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275prov=se({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var ie=(()=>{class o extends Ao{constructor(){super(...arguments),this.businessTerms=r(I),this.coreLocationRx=r(xo),this.customerService=r(pe),this.deleteCustomerWrite=r(wo),this.deleteCustomersWrite=r(go),this.dialog=r(qt),this.restoreLastVisitCustomer=r(bo),this.updateCustomer=r($e),this.visitRx=r(To),this.add={api:()=>{this.customerService.openEditor({title:$localize`Add ${this.businessTerms.businessTerms.customerTerm.capitalized}`})},key:"add",eventLoggerName:"opened_create_customer",label:$localize`Add`,icon:"bx-plus",enabledConfig:{permissions:["customers.update"]},disabled:!1},this.export={api:()=>this.customerService.openExport({}),key:"export",eventLoggerName:"opened_export_customer",label:$localize`Export`,icon:"bx-export",disabled:!1,enabledConfig:{accountFeatures:["enableCustomerDataExport"]}},this.import={api:()=>this.customerService.openImport({}),key:"import",eventLoggerName:"opened_import_customer",label:$localize`Import`,icon:"bx-import",disabled:!1,enabledConfig:{accountFeatures:["enableCustomerImport"]}}}createActions(e){let t=e[0];return!t||!t.id?{}:{restoreLastVisit:ne(t).pipe(W(i=>this.visitRx.getCompletedVisitsForCustomer(i.id)),u(i=>i.length>0?{api:()=>{t&&this.restoreLastVisitCustomer.payload.next({customerId:t.id})},label:$localize`Restore last ${this.businessTerms.businessTerms.visitTerm.lower}`,icon:"bx-move",enabledConfig:{permissions:["visits.update"]},disabled:!1}:null)),edit:{api:()=>this.customerService.openEditor({customer:t}),label:$localize`Edit`,icon:"bx-edit-alt",enabledConfig:{permissions:["customers.update"]},disabled:!1},message:{api:()=>this.customerService.openBatchChat({customers:e}),label:$localize`Message`,icon:"bx-message",type:"secondary",eventLoggerName:"opened_batch_customer_chat",eventLoggerParams:{count:e.length},enabledConfig:{permissions:["messages.create"]},disabled:!1},delete:{api:()=>te(this,null,function*(){let i=e.filter(a=>a.locationIds.length===1).map(a=>a.id),n=e.filter(a=>a.locationIds.length>1);if(n.length>0){let a="DELETE_CUSTOMER",E="UPDATE_CUSTOMER_LOCATION",g=yield ce(this.dialog.openPrompt({title:$localize`Delete ${this.businessTerms.businessTerms.customerTerm.lower}`,confirmLabel:$localize`Delete`,confirmType:"warning",cancelLabel:$localize`Cancel`,message:$localize`Some ${this.businessTerms.businessTerms.customerTerm.pluralLower} belong to multiple locations. Do you want to remove all selected customers from this location only, or completely delete them from all locations?`,controls:[{defaultValue:E,component:B(mo,{data:[E,a],pluckLabel:z=>z===a?$localize`Delete from all locations`:$localize`Delete from this location only`})}]}).afterClosed$);if(!g)return;if(g[0]===E)for(let z of n)this.updateCustomer.payload.next({customerId:z.id,updates:{locationIds:z.locationIds.filter(si=>si!==this.coreLocationRx.nullableLocationId)}});else i.push(...n.map(z=>z.id))}i.length>0&&this.deleteCustomers(i)}),label:$localize`Delete`,icon:"bx-trash",color:"warning",type:"warning",enabledConfig:{permissions:["customers.delete"]},disabled:!1}}}deleteCustomers(e){e.length===1?this.deleteCustomerWrite.payload.next(e[0]):this.deleteCustomersWrite.payload.next(e)}static{this.\u0275fac=(()=>{let e;return function(i){return(e||(e=ge(o)))(i||o)}})()}static{this.\u0275prov=se({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var Ce={pageIndex:0,pageSize:20,length:20},at=Oe,fe="updated",ii=50,ni={ANY:"Any state",WAITING:"Waiting",SERVING:"Serving",COMPLETE:"Complete",BOOKED:"Booked","NO-SHOW":"No-show"};var Ii=["actionsMenuTmpl"],Li=()=>["customer","id"];function Ai(o,f){if(o&1){let e=x();m(0,"ww-table",4),p(1,"async"),p(2,"async"),T("rowClicked",function(i){S(e);let n=_();return h(n.onRowClicked(i))})("headerClicked",function(i){S(e);let n=_();return h(n.onHeaderClicked(i))}),d()}if(o&2){let e=_(),t=Pe(5);s("loading",e.loading)("data",e.customers)("selection","multiple")("formControl",e.formControl)("trackByProperty",yt(14,Li))("columns",c(1,10,e.tableColumns$))("placeholder",t)("pluckCellLabel",c(2,12,e.pluckCellLabel$))("pluckActions",e.pluckActions)("pluckDisabled",e.pluckDisabled)}}function vi(o,f){if(o&1){let e=x();m(0,"ww-list",5),T("itemClicked",function(i){S(e);let n=_();return h(n.onRowClicked(i))}),d()}if(o&2){let e=_(),t=Pe(5);s("loading",e.loading)("data",e.customers)("pluckLabel",e.pluckListLabel)("pluckSuffix",e.pluckActions)("placeholder",t)}}function Wi(o,f){if(o&1&&(C(0,"ww-empty-state",6),p(1,"async")),o&2){let e=_();s("message",c(1,1,e.emptyStateMessage$))}}function Ni(o,f){if(o&1){let e=x();m(0,"div",7)(1,"button",8),T("click",function(){let i=S(e).$implicit,n=_();return h(n.visitCoreService.openCustomerVisitCreator({entity:i.customer}))}),C(2,"ww-icon",9),d(),C(3,"ww-model-action-menu",10),p(4,"async"),d()}if(o&2){let e=f.$implicit;l(),s("wwEventLogger","opened_create_visit_from_customer"),l(),s("icon","bx-plus"),l(),s("actions",c(4,4,e.actions$))("label",e.customer.name)}}var lt=(()=>{class o extends Y{constructor(){super(),this.businessTerms=r(I),this.commonDisplay=r(Fo),this.customerActions=r(ie),this.customerDisplay=r(Vo),this.customerProperties=r(Bo),this.messageRx=r(Eo),this.visitCoreService=r(ve),this.layout=r(L),this.loading=!1,this.orderBy=null,this.pageEvent=null,this.pageEvent$=this.observe("pageEvent"),this.customers=[],this.customers$=this.observe("customers").pipe(u(e=>e??[])),this.sortableColumns=[],this.sortableColumns$=this.observe("sortableColumns").pipe(u(e=>e??[])),this.selected=new we,this.dropped=new we,this.headerSelected=new we,this.pluckActions=()=>this.actionsMenuTmpl,this.pluckDisabled=e=>!e.customer.id,this.formControl=new D([],{nonNullable:!0}),this.selectedCustomerTableItems$=H(this.formControl).pipe(u(e=>e??[])),this.selectedCustomersCount$=this.selectedCustomerTableItems$.pipe(u(e=>e.length)),this.tableColumns$=re([this.customerProperties.getCurrentPermittedProperties(),this.sortableColumns$]).pipe(u(([e,t])=>$o(e,["id","phone","email"],t))),this.pluckCellLabel$=this.customerProperties.getCurrentPermittedProperties().pipe(u(e=>{let t=this.customerDisplay.getDisplayTableCellsSpacious(fo(e,{name:{display:i=>Gt({components:[this.commonDisplay.displayCustomerBadge(i),i.name||"-"],$element:{classList:"flex gap-x-3 items-center"}})}}));return i=>t(i.customer)})),this.pluckListLabel=e=>this.customerDisplay.displayListItem(e.customer),this.emptyStateMessage$=this.businessTerms.businessTerms$.pipe(u(e=>$localize`No ${e.customerTerm.pluralLower} found`)),this.batchActions={data$:this.customers$,formControl:this.formControl,pageEvent$:this.pageEvent$,getActions:e=>this.messageRx.getAvailableChannelsForContactables(e.map(({customer:t})=>t)).pipe(W(t=>{let i=["delete"];return t.length>0&&i.unshift("message"),this.customerActions.getActions(e.map(({customer:n})=>n),{pick:i})}))},this.subscribe(),this.layout.updateFeatureContext({batchActions:this.batchActions})}onRowClicked(e){this.selected.emit(e)}onHeaderClicked(e){this.headerSelected.emit(e)}subscribe(){zt(this.customers$,this.formControl,this.ngOnDestroy$,(e,t)=>e.customer.id===t.customer.id)}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275cmp=$({type:o,selectors:[["ww-customers-table"]],viewQuery:function(t,i){if(t&1&&St(Ii,7),t&2){let n;
1ht(n=wt())&&(i.actionsMenuTmpl=n.first)}},hostAttrs:[1,"ww-customers-table"],inputs:{loading:"loading",orderBy:"orderBy",pageEvent:"pageEvent",customers:"customers",sortableColumns:"sortableColumns"},outputs:{selected:"selected",dropped:"dropped",headerSelected:"headerSelected"},standalone:!1,features:[N],decls:8,vars:6,consts:[["emptyStateTmpl",""],["actionsMenuTmpl",""],[3,"loading","data","selection","formControl","trackByProperty","columns","placeholder","pluckCellLabel","pluckActions","pluckDisabled"],[3,"loading","data","pluckLabel","pluckSuffix","placeholder"],[3,"rowClicked","headerClicked","loading","data","selection","formControl","trackByProperty","columns","placeholder","pluckCellLabel","pluckActions","pluckDisabled"],[3,"itemClicked","loading","data","pluckLabel","pluckSuffix","placeholder"],["icon","ww-empty-state-customers",3,"message"],[1,"flex"],["wwButton","tertiary",3,"click","wwEventLogger"],[3,"icon"],[3,"actions","label"]],template:function(t,i){t&1&&(y(0,Ai,3,15,"ww-table",2),p(1,"async"),y(2,vi,1,5,"ww-list",3),p(3,"async"),v(4,Wi,2,3,"ng-template",null,0,Ue)(6,Ni,5,6,"ng-template",null,1,Ue)),t&2&&(b(c(1,2,i.layout.isMobile$)===!1?0:-1),l(2),b(c(3,4,i.layout.isMobile$)?2:-1))},dependencies:[q,Q,Qo,Ie,Le,P,U,ro,so,F],styles:[`.ww-breakpoints-below-small .ww-customers-table .ww-list-item{padding-left:0;padding-right:0} 2/*noopcustomers-table.component-YV6WM65Y.css.map */ 3`],encapsulation:2,changeDetection:0})}}return o})();function Pi(o,f){if(o&1&&(G(0),C(1,"ww-model-action-menu-item",10),X()),o&2){let e=_(2);l(),s("action",e.actions.import)}}function Ui(o,f){o&1&&(G(0),v(1,Pi,2,1,"ng-container",9),X())}function Bi(o,f){if(o&1&&(G(0),C(1,"ww-model-action-menu-item",10),X()),o&2){let e=_(2);l(),s("action",e.actions.export)}}function ki(o,f){o&1&&(G(0),v(1,Bi,2,1,"ng-container",9),X())}function Vi(o,f){if(o&1){let e=x();m(0,"ww-page-search",11),T("searchChanged",function(i){S(e);let n=_();return h(n.search(i??""))}),d()}o&2&&s("defaultState","expanded")}function zi(o,f){if(o&1){let e=x();m(0,"ww-paginator",12),p(1,"async"),T("page",function(i){S(e);let n=_();return h(n.onPage(i))}),d()}if(o&2){let e=_();s("pageSizeOptions",e.pageSizeOptions)("pageIndex",e.pageEventSub.value.pageIndex)("pageSize",e.pageEventSub.value.pageSize)("length",c(1,4,e.pageLength$))}}var ri=(()=>{class o extends Y{constructor(){super(),this.actions=r(ie),this.layout=r(L),this.businessTerms=r(I),this.customerActions=r(ie),this.customerRx=r(xe),this.customerService=r(pe),this.locationRx=r(ae),this.orderBySub=new Te({property:fe,direction:"desc"}),this.orderBy$=this.orderBySub.asObservable(),this.queryArgs={limit:[ii]},this.pageEventSub=new Te(Ce),this.pageSizeOptions=[10,20,50,100],this.dateRangeFormControl=new D(at.createDateRange()),this.stateFormControl=new D("ANY"),this.state$=H(this.stateFormControl).pipe(u(e=>e==="ANY"||e==="NO-SHOW"?null:e)),this.tag$=H(this.stateFormControl).pipe(u(e=>e==="NO-SHOW"?e:null)),this.stateFilters=It()(["ANY","WAITING","SERVING","COMPLETE","BOOKED","NO-SHOW"]),this.pluckStateLabel=e=>ni[e],this.dateRange$=H(this.dateRangeFormControl).pipe(u(e=>e??at.createDateRange())),this.dateRangeFilters=[Ht,Yt,Zt,oo,Qt,Jt,Kt,to,eo,io,Oe],this.dateRangeQueryArgs$=this.dateRange$.pipe(u(e=>{let{end:t,start:i}=e;return _o(fe,i,t)})),this.searchSub=new Te(""),this.search$=this.searchSub.asObservable().pipe(Se(200),ct()),this.customers$=re([this.locationRx.locationId$,this.orderBy$,this.dateRangeQueryArgs$,this.dateRange$,this.search$,this.state$,this.tag$]).pipe(W(([e,t,i,n,a,E,g])=>a||E||g?Dt(this.pageEventSub,M=>this.customerRx.searchCustomers(O(R({},M),{locationId:e,query:a,state:E,tag:g,dateRange:n}))).pipe(u(M=>M.map(z=>Wt(z)))):Nt(this.pageEventSub,M=>this.customerRx.getCustomers(Co(this.queryArgs,M,i)),t.property,t.direction))),this.sortableColumns$=this.dateRange$.pipe(u(e=>{let{start:t,end:i}=e;return!t&&!i?["updated","name","numVisits"]:["updated"]})),this.customerTableItems$=this.customers$.pipe(u(e=>e.length===0?[]:e.map(t=>({customer:t,actions$:this.customerActions.getActions([t])})))),this.hasItems$=this.customerTableItems$.pipe(u(e=>e.length>0)),this.canPaginate$=Ut(this.customers$,this.pageEventSub),this.loading$=this.customers$.pipe(u(()=>!1),he(!0)),this.pageLength$=Pt(this.customers$,this.pageEventSub),this.subscribeToDateRange(),this.subscribeToState(),this.subscribeToSearch(),this.subscribeUpdateFeatureContext(),this.subscribeToQueryParams()}search(e){this.searchSub.next(e)}onHeaderSelected(e){let{property:t,direction:i}=this.orderBySub.value;t===e?this.orderBySub.next({property:e,direction:i==="asc"?"desc":"asc"}):this.orderBySub.next({property:e,direction:"desc"})}onCustomerSelected(e){this.customerService.openViewer({entity:e.customer})}onPage(e){this.pageEventSub.next(e)}editCustomer(e,t){this.customerService.openEditor({customer:e,autoFocusKey:t})}subscribeUpdateFeatureContext(){this.businessTerms.businessTerms$.pipe(A(this.ngOnDestroy$)).subscribe(e=>{this.layout.setFeatureContext({name:e.customerTerm.pluralCapitalized,addActions:[{label:$localize`Add ${e.customerTerm.lower}`,eventLoggerName:"opened_create_customer",enabled:{permissions:["customers.create"]},api:()=>this.actions.add.api()}]})}),this.layout.isMobile$.pipe(A(this.ngOnDestroy$)).subscribe(e=>{e?this.layout.updateFeatureContext({search:{api:t=>{this.search(t??"")}}}):this.layout.updateFeatureContext({search:null})})}subscribeToDateRange(){this.dateRangeFormControl.valueChanges.pipe(A(this.ngOnDestroy$)).subscribe(()=>{this.pageEventSub.next(Ce),this.orderBySub.next({property:fe,direction:"desc"})})}subscribeToState(){this.stateFormControl.valueChanges.pipe(A(this.ngOnDestroy$)).subscribe(()=>{this.pageEventSub.next(Ce),this.orderBySub.next({property:fe,direction:"desc"})})}subscribeToSearch(){this.search$.pipe(dt(1),A(this.ngOnDestroy$)).subscribe(()=>{this.pageEventSub.next(Ce)})}subscribeToQueryParams(){Lt().pipe(A(this.ngOnDestroy$)).subscribe(e=>{let t=e.customerId||e.viewCustomerId,i=e.selectedTab||void 0;t&&this.customerService.openViewer({entityId:t,selectedTab:i},()=>!1)})}static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275cmp=$({type:o,selectors:[["ww-customers"]],hostAttrs:[1,"ww-cu
3stomers","h-full","flex","flex-col","relative"],standalone:!1,features:[N],decls:17,vars:26,consts:[["customersTable",""],[4,"wwPermission"],["wwLayoutPadding","",1,"flex","flex-col","gap-6","below-small:gap-4"],[3,"defaultState"],[3,"filters","formControl"],[3,"data","formControl","pluckLabel","maxVisibleOptions"],[1,"flex","flex-col","gap-6"],[3,"selected","headerSelected","customers","loading","orderBy","sortableColumns"],[3,"pageSizeOptions","pageIndex","pageSize","length"],[4,"wwLayoutSecondaryAction"],[3,"action"],[3,"searchChanged","defaultState"],[3,"page","pageSizeOptions","pageIndex","pageSize","length"]],template:function(t,i){t&1&&(v(0,Ui,2,0,"ng-container",1)(1,ki,2,0,"ng-container",1),m(2,"div",2)(3,"ww-page-toolbar"),y(4,Vi,1,1,"ww-page-search",3),p(5,"async"),C(6,"ww-date-range-picker",4)(7,"ww-select",5),d(),m(8,"div",6)(9,"ww-customers-table",7,0),p(11,"async"),p(12,"async"),p(13,"async"),p(14,"async"),T("selected",function(a){return i.onCustomerSelected(a)})("headerSelected",function(a){return i.onHeaderSelected(a)}),d(),y(15,zi,2,6,"ww-paginator",8),p(16,"async"),d()()),t&2&&(s("wwPermission","customers.create"),l(),s("wwPermission","customers.show"),l(3),b(c(5,14,i.layout.isDesktop$)?4:-1),l(2),s("filters",i.dateRangeFilters)("formControl",i.dateRangeFormControl),l(),s("data",i.stateFilters)("formControl",i.stateFormControl)("pluckLabel",i.pluckStateLabel)("maxVisibleOptions",6),l(2),s("customers",c(11,16,i.customerTableItems$))("loading",c(12,18,i.loading$))("orderBy",c(13,20,i.orderBy$))("sortableColumns",c(14,22,i.sortableColumns$)),l(6),b(c(16,24,i.canPaginate$)?15:-1))},dependencies:[q,Q,Wo,No,Lo,vo,Ho,Fe,no,ao,k,lt,F],encapsulation:2,changeDetection:0})}}return o})();var Qs=(()=>{class o{static{this.\u0275fac=function(t){return new(t||o)}}static{this.\u0275mod=Ct({type:o})}static{this.\u0275inj=_t({imports:[Ot,xt,$t.forChild([{path:"",component:ri}]),Yo,uo,Do]})}}return o})();export{et as WwCustomerEditorComponent,nt as WwCustomerExportComponent,rt as WwCustomerImportComponent,ri as WwCustomersComponent,Qs as WwCustomersModule,lt as WwCustomersTableComponent,st as WwCustomersViewerComponent,Ko as isCustomerEditorCreate,Jo as isCustomerEditorUpdate}; 4//noopchunk-ATRKOUA3.js.map
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.