"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[692],{50692(n,t,e){e.r(t),e.d(t,{registerFunctions:()=>g});var a=e(66131),i=e(15695),r=e(85935),c=e(78878),u=e(334),s=e(55612),o=e(88368),f=e(92647),d=e(54218);async function l(n,t,e,a){if(1===e.length){if((0,d.cy)(e[0]))return(0,u.t)(n,e[0],(0,c.J)(e[1],-1));if((0,c.j)(e[0]))return(0,u.t)(n,e[0].toArray(),(0,c.J)(e[1],-1))}else if(2===e.length){if((0,d.cy)(e[0]))return(0,u.t)(n,e[0],(0,c.J)(e[1],-1));if((0,c.j)(e[0]))return(0,u.t)(n,e[0].toArray(),(0,c.J)(e[1],-1));if((0,c.m)(e[0])){const i=await e[0].load(),r=await y(o.A.create(e[1],{fieldsIndex:i.getFieldsIndex(),timeZone:i.dateFieldsTimeZoneDefaultUTC}),a,t);return m(t,await e[0].calculateStatistic(n,r,(0,c.J)(e[2],1e3),t.abortSignal))}}else if(3===e.length&&(0,c.m)(e[0])){const i=await e[0].load(),r=await y(o.A.create(e[1],{fieldsIndex:i.getFieldsIndex(),timeZone:i.dateFieldsTimeZoneDefaultUTC}),a,t);return m(t,await e[0].calculateStatistic(n,r,(0,c.J)(e[2],1e3),t.abortSignal))}return(0,u.t)(n,e,-1)}function m(n,t){return s.g.isTimestampOffset(t)?a.lY.fromReaderAsTimeStampOffset(t.toStorageFormat()):(0,d.$P)(t)?a.lY.dateJSAndZoneToArcadeDate(t,(0,c.K)(n)):f.c9.isDateTime(t)?a.lY.dateTimeToArcadeDate(t):t}async function y(n,t,e){const a=n.getVariables();if(a.length>0){const i={};for(const n of a)i[n]=t.evaluateIdentifier(e,{name:n});n.parameters=i}return n}function g(n){"async"===n.mode&&(n.functions.stdev=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("stdev",t,i,n))},n.functions.variance=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("variance",t,i,n))},n.functions.average=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("mean",t,i,n))},n.functions.mean=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("mean",t,i,n))},n.functions.sum=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("sum",t,i,n))},n.functions.min=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("min",t,i,n))},n.functions.max=function(t,e){return n.standardFunctionAsync(t,e,(e,a,i)=>l("max",t,i,n))},n.functions.count=function(t,e){return n.standardFunctionAsync(t,e,async(n,a,i)=>{if((0,c.B)(i,1,1,t,e),null==i[0])return 0;if((0,c.m)(i[0]))return i[0].count(n.abortSignal);if((0,d.cy)(i[0])||(0,d.Kg)(i[0]))return i[0].length;if((0,c.j)(i[0]))return i[0].length();if((0,c.n)(i[0]))return i[0].entryCount();throw new r.D$(t,"InvalidParameter",e)})},n.functions.isempty=function(t,e){return n.standardFunctionAsync(t,e,async(n,t,e)=>{if((0,c.B)(e,1,2,n,t),e.length>=2&&!(0,d.Lm)(e[1]))throw new r.D$(n,"InvalidParameter",t);return(0,c.J)(e[1],!1)?(0,c.m)(e[0])?await e[0].isEmpty(n.abortSignal):(0,i.Im)(e[0]):(0,c.L)(e[0])})})}}}]);