@keload/node-red-contrib-ultimate-toolkit
Version:
A collection of (moderns) useful tools for Node-RED
10 lines (9 loc) • 21.5 kB
JavaScript
var H=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var wr=Object.prototype.hasOwnProperty;var br=(t,r)=>{for(var e in r)H(t,e,{get:r[e],enumerable:!0})},Mr=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of yr(r))!wr.call(t,n)&&n!==e&&H(t,n,{get:()=>r[n],enumerable:!(o=gr(r,n))||o.enumerable});return t};var kr=t=>Mr(H({},"__esModule",{value:!0}),t);var Zr={};br(Zr,{default:()=>Wr});module.exports=kr(Zr);function jt(t,r){return typeof t!="boolean"?(console.warn("Payload must be a boolean (true or false)."),[null,null]):t?[r,null]:[null,r]}function Yt(t){return new Promise(r=>{try{RED.util.evaluateNodeProperty(t.value,t.type,t.node,t.msg,(e,o)=>{r([e,o])})}catch(e){r([e,void 0])}})}var W=Array.isArray,_t=t=>!!t&&t.constructor===Object;var Sr=t=>!!(t&&t.constructor&&t.call&&t.apply);var Ut=t=>!(!t||!t.then||!Sr(t.then));function S(t,r){return(t||[]).reduce((e,o)=>e+(r?r(o):o),0)}var Z=(t,r,e="asc")=>{if(!t)return[];let o=(i,m)=>`${r(i)}`.localeCompare(r(m)),n=(i,m)=>`${r(m)}`.localeCompare(r(i));return t.slice().sort(e==="desc"?n:o)};var z=(t,r)=>{let e=t.reduce((o,n)=>{let i=r?r(n):n;return o[i]||(o[i]=n),o},{});return Object.values(e)};var L=(t,r,e,o)=>{var p;if(!t&&!r)return[];if(!t)return[r];if(!r)return[...t];let n=e?(a,c)=>e(a,c)===e(r,c):a=>a===r;return t.find(n)?t.filter((a,c)=>!n(a,c)):((p=o==null?void 0:o.strategy)!=null?p:"append")==="append"?[...t,r]:[r,...t]};var V=t=>new Promise(r=>setTimeout(r,t)),$=t=>(...r)=>{try{let e=t(...r);return Ut(e)?e.then(o=>[void 0,o]).catch(o=>[o,void 0]):[void 0,e]}catch(e){return[e,void 0]}};var q=t=>{if(!t)return[];let r=(e,o)=>_t(e)?Object.entries(e).flatMap(([n,i])=>r(i,[...o,n])):W(e)?e.flatMap((n,i)=>r(n,[...o,`${i}`])):[o.join(".")];return r(t,[])};var K=(t,r)=>Math.floor(Math.random()*(r-t+1)+t);function v(t){return`
\u{1F4D6} <a href="https://radash-docs.vercel.app/docs/${t}" target="_blank">View documentation on <span class="font-bold">Radash</span> <i class="fa fa-external-link"></a></i>
`}function N(t){return`
\u{1F4D6} <a href="https://es-toolkit.slash.page/reference/${t}.html" target="_blank">View documentation on <span class="font-bold">ES Toolkit</span> <i class="fa fa-external-link"></a></i>
`}var X={array_utilities:{toggle:{docs:v("array/toggle")},shuffle:{docs:N("array/shuffle")},groupBy:{mainValue:{label:"Property"},docs:N("array/groupBy")},keyBy:{mainValue:{label:"Property"},docs:N("array/keyBy")},sum:{mainValue:{label:"Property"},docs:v("array/sum")},unique:{mainValue:{label:"Property"},docs:v("array/unique")},take:{mainValue:{label:"Count"},docs:N("array/take")},takeRight:{mainValue:{label:"Count"},docs:N("array/takeRight")},getRandomItem:{docs:"Get a random item from input array"}},date_utilities:{now:{description:"Returns the current date with lot of formatting options",docs:"If token is provided, <code>Format</code> will not be used",revealClasses:["dateUtilities_now"],configArgs:"dateUtilities"},format:{description:"Return formatted date from a date",docs:"If token is provided, <code>Format</code> will not be used",revealClasses:["dateUtilities_now"],configArgs:"dateUtilities"},timeRange:{description:"Routes messages depending on the time",docs:"Time range checker that validates if current time is<br>between given start and end times (HH:mm format).",revealClasses:["dateUtilities_timeRange"],configArgs:"dateUtilities",forceSplitBooleanOutputs:!0},currentTimezone:{description:"Returns the current timezone"}},string_utilities:{camelCase:{},capitalize:{},constantCase:{},escape:{},kebabCase:{},lowerCase:{},lowerFirst:{},pascalCase:{},snakeCase:{},startCase:{},trim:{},trimEnd:{},trimStart:{},unescape:{},upperCase:{},upperFirst:{},words:{}},utility_functions:{toNumber:{},toNumberNonStrict:{label:"toNumber (non-strict)",docs:"If the value is not a number, it will return the original value"},toString:{},toSafeInteger:{},toBoolean:{},toBooleanNumber:{},gt:{mainValue:{},canSplitBooleanOutputs:!0,inverseReturnValue:!0},gte:{mainValue:{},canSplitBooleanOutputs:!0,inverseReturnValue:!0},lt:{mainValue:{},canSplitBooleanOutputs:!0,inverseReturnValue:!0},lte:{mainValue:{},canSplitBooleanOutputs:!0,inverseReturnValue:!0},eq:{mainValue:{},canSplitBooleanOutputs:!0,inverseReturnValue:!0},size:{docs:"Returns the size of an array, string, or object."}},predicates:{isBoolean:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isNaN:{label:"Is NaN",canSplitBooleanOutputs:!0,inverseReturnValue:!0},isNil:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isNull:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isNumber:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isString:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isUndefined:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isIp:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isUrl:{canSplitBooleanOutputs:!0,inverseReturnValue:!0},isBuffer:{canSplitBooleanOutputs:!0,inverseReturnValue:!0}},object_utilities:{getKeys:{docs:v("object/keys")}},network_utilities:{ipInformation:{description:"Fetches detailed information about an IP address",docs:"By default is your current IP address"},ipVersion:{description:"Returns IP version (4, 6, or 0 if invalid) for a given IP address string"},networkInterfaces:{description:"Lists all network interfaces of the current machine (ethernet, wifi, etc.)"}},math_utilities:{abs:{},acos:{},asin:{},atan:{},ceil:{},cos:{},exp:{},floor:{},log:{},max:{},mean:{},min:{},median:{},random:{},round:{},sin:{},sum:{},tan:{},trunc:{}},async_utilities:{delay:{description:"Delays the message by the specified amount of time",mainValue:{label:"Milliseconds"}}}};var fo=Z(Object.keys(X),t=>t);function Ht(t,r){var o,n;let e=(n=(o=X)==null?void 0:o[t])==null?void 0:n[r];return{...e,nodeDocs:`
${(e==null?void 0:e.description)||""}
<br><br>
${(e==null?void 0:e.docs)||""}
`.trim()}}function J(t,r){let e={};for(let o=0;o<t.length;o++){let n=t[o],i=r(n);Object.hasOwn(e,i)||(e[i]=[]),e[i].push(n)}return e}function G(t,r){let e={};for(let o=0;o<t.length;o++){let n=t[o],i=r(n);e[i]=n}return e}function Q(t){let r=t.slice();for(let e=r.length-1;e>=1;e--){let o=Math.floor(Math.random()*(e+1));[r[e],r[o]]=[r[o],r[e]]}return r}function Wt(t){return typeof t=="symbol"||t instanceof Symbol}function d(t){return Wt(t)?NaN:Number(t)}function Zt(t){return t?(t=d(t),t===1/0||t===-1/0?(t<0?-1:1)*Number.MAX_VALUE:t===t?t:0):t===0?t:0}function D(t){let r=Zt(t),e=r%1;return e?r-e:r}function tt(t,r,e){return r=e||r===void 0?1:D(r),t.slice(0,r)}function rt(t,r=1,e){return r=e||r===void 0?1:D(r),r<=0||t==null||t.length===0?[]:t.slice(-r)}function zt(t,r,e){return e==null?Math.min(t,r):Math.min(Math.max(t,r),e)}function et(t){if(t.length===0)return NaN;let r=t.slice().sort((o,n)=>o-n),e=Math.floor(r.length/2);return r.length%2===0?(r[e-1]+r[e])/2:r[e]}function k(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}var Dr=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function g(t){var r;return Array.from((r=t.match(Dr))!=null?r:[])}function ot(t){let r=g(t);if(r.length===0)return"";let[e,...o]=r;return`${e.toLowerCase()}${o.map(n=>k(n)).join("")}`}function nt(t){return g(t).map(e=>e.toLowerCase()).join("_")}function it(t){return typeof Buffer!="undefined"&&Buffer.isBuffer(t)}function st(t,r){return t===r||Number.isNaN(t)&&Number.isNaN(r)}function Lt(t){return t==null}function ft(t){return g(t).map(e=>e.toUpperCase()).join("_")}var vr={"&":"&","<":"<",">":">",'"':""","'":"'"};function at(t){return t.replace(/[&<>"']/g,r=>vr[r])}function mt(t){return g(t).map(e=>e.toLowerCase()).join("-")}function ut(t){return g(t).map(e=>e.toLowerCase()).join(" ")}function pt(t){return t.substring(0,1).toLowerCase()+t.substring(1)}function ct(t){return g(t).map(e=>k(e)).join("")}function lt(t){let r=g(t.trim()),e="";for(let o=0;o<r.length;o++){let n=r[o];e&&(e+=" "),e+=n[0].toUpperCase()+n.slice(1).toLowerCase()}return e}function P(t,r){if(r===void 0)return t.trimEnd();let e=t.length;switch(typeof r){case"string":{if(r.length!==1)throw new Error("The 'chars' parameter should be a single character string.");for(;e>0&&t[e-1]===r;)e--;break}case"object":for(;e>0&&r.includes(t[e-1]);)e--}return t.substring(0,e)}function C(t,r){if(r===void 0)return t.trimStart();let e=0;switch(typeof r){case"string":{for(;e<t.length&&t[e]===r;)e++;break}case"object":for(;e<t.length&&r.includes(t[e]);)e++}return t.substring(e)}function dt(t,r){return r===void 0?t.trim():C(P(t,r),r)}var Pr={"&":"&","<":"<",">":">",""":'"',"'":"'"};function xt(t){return t.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g,r=>Pr[r]||"'")}function ht(t){let r=g(t),e="";for(let o=0;o<r.length;o++)e+=r[o].toUpperCase(),o<r.length-1&&(e+=" ");return e}function gt(t){return t.substring(0,1).toUpperCase()+t.substring(1)}var Vt={toggle:L,shuffle:Q,groupBy:(t,r)=>{let e=r;return J(t,o=>o[e.trim()])},keyBy:(t,r)=>{let e=r;return G(t,o=>o[e.trim()])},sum:(t,r)=>{let e=r;return S(t,o=>o[e.trim()])},unique:(t,r)=>{let e=r;return z(t,o=>o[e.trim()])},take:(t,r)=>tt(t,r),takeRight:(t,r)=>rt(t,r),getRandomItem:t=>{if(!t.length)return null;let r=t.length-1;return t[K(0,r)]}};var qt={delay:(t,r)=>V(r)};var yt=/^([0-9]{4})-([0-1][0-9])(?:-([0-3][0-9]))?(?:[T ]?([0-2][0-9])(?::([0-5][0-9]))?(?::([0-5][0-9]))?)?(?:\.[0-9]+)?(Z|(?:\+|\-)[0-9]{2}:?[0-9]{2})?$/;function wt(t){let r=t.match(yt);if(r){let e=Number(r[2]);if(e<1||e>12)return!1;if(typeof r[3]!==void 0){let o=Number(r[3]);if(o<1||o>31)return!1}if(typeof r[4]!==void 0){let o=Number(r[4]);if(o<0||o>23)return!1}return!0}return!1}function Cr(t){let r=t.match(yt);return r&&typeof r[4]=="undefined"?t+="T00:00:00":t}function f(t){if(t||(t=new Date),t instanceof Date){let r=new Date(t);return r.setMilliseconds(0),r}if(t=t.trim(),wt(t))return new Date(Cr(t));throw new Error(`Non ISO 8601 compliant date (${t}).`)}var T="1999-03-04T02:05:01.000Z",F=new Map,bt=[["YYYY",{year:"numeric"}],["YY",{year:"2-digit"}],["MMMM",{month:"long"}],["MMM",{month:"short"}],["MM",{month:"2-digit"}],["M",{month:"numeric"}],["DD",{day:"2-digit"}],["D",{day:"numeric"}],["dddd",{weekday:"long"}],["ddd",{weekday:"short"}],["d",{weekday:"narrow"}],["mm",{minute:"2-digit"}],["m",{minute:"numeric"}],["ss",{second:"2-digit"}],["s",{second:"numeric"}],["ZZ",{timeZoneName:"long"}],["Z",{timeZoneName:"short"}]],Mt=[["HH",{hour:"2-digit"}],["H",{hour:"numeric"}]],kt=[["hh",{hour:"2-digit"}],["h",{hour:"numeric"}],["a",{dayPeriod:"narrow"}],["A",{dayPeriod:"narrow"}]];function St(t){if(/^[+-]\d{2}:\d{2}/.test(t))return 6;if(/^[+-]\d{4}/.test(t))return 5;throw new Error("Invalid offset format")}var Tr=["MMMM","MMM","dddd","ddd"],l=new Map([...bt,...Mt,...kt].map(t=>[t[0],t])),Nt=new Map,Dt=["full","long","medium","short"];function w(t){return t.type==="literal"&&(t.value=t.value.normalize("NFKC")),t}function Kt(t,r,e,o=!1,n=null){let i=Rr(t,r,e,o),m=f(t);function p({partName:a,partValue:c,token:s}){if(a==="literal")return c;let u=i[a];if(a==="hour"&&s==="H")return u.replace(/^0/,"")||"0";if(["mm","ss","MM"].includes(s)&&u.length===1)return`0${u}`;if(a==="dayPeriod"){let x=R(m.getUTCHours()<12?"am":"pm",e);return s==="A"?x.toUpperCase():x.toLowerCase()}return a==="timeZoneName"?n!=null?n:vt(-1*m.getTimezoneOffset(),s):u}return r.map(a=>({...a,value:p(a)}))}function Rr(t,r,e,o=!1){let n=f(t),i=r.filter(s=>s.hour12),m=r.filter(s=>!s.hour12),p=[],a=[];function c(s,u=!1){let x=`${e}-u-hc-${u?"h12":"h23"}`;if(p.push(...new Intl.DateTimeFormat(x,s.reduce((h,y)=>y.partName==="literal"?h:(o&&Tr.includes(y.token)&&a.push(y),Object.assign(h,y.option)),{timeZone:"UTC"})).formatToParts(n).map(w)),o&&a.length)for(let h of a){let y=[];switch(h.token){case"MMMM":y=new Intl.DateTimeFormat(x,{dateStyle:"long",timeZone:"UTC"}).formatToParts(n).map(w);break;case"MMM":y=new Intl.DateTimeFormat(x,{dateStyle:"medium",timeZone:"UTC"}).formatToParts(n).map(w);break}let M=y.find(U=>U.type===h.partName),At=p.findIndex(U=>U.type===h.partName);M&&At>-1&&(p[At]=M)}}return i.length&&c(i,!0),m.length&&c(m),p.reduce((s,u)=>(s[u.type]=u.value,s),{})}function vt(t,r="Z"){let e=String(Math.floor(Math.abs(t/60))).padStart(2,"0"),o=String(Math.abs(t%60)).padStart(2,"0"),n=t<0?"-":"+";return r==="ZZ"?`${n}${e}${o}`:`${n}${e}:${o}`}function Xt(t,r){Jt(t,r);let[e,o,n,i]=t.match(/([+-])([0-3][0-9]):?([0-6][0-9])/),m=Number(n)*60+Number(i);return o==="+"?m:-m}function Jt(t,r="Z"){if(!(o=>{switch(o){case"Z":return/^([+-])[0-3][0-9]:[0-6][0-9]$/.test(t);case"ZZ":return/^([+-])[0-3][0-9][0-6][0-9]$/.test(t)}})(r))throw new Error(`Invalid offset: ${t}`);return t}function Gt(t){return typeof t=="string"?t.includes("ZZ")?"ZZ":"Z":"time"in t&&t.time==="full"?"Z":"ZZ"}function R(t,r){let e=Nt.get(r);if(e&&e[t])return e[t];let o=new Date(T);o.setUTCHours(t==="am"?5:20);let i=new Intl.DateTimeFormat(r,{timeStyle:"full",timeZone:"UTC",hour12:!0}).formatToParts(o).map(w).find(m=>m.type==="dayPeriod");if(i){let m=e||{};return Nt.set(r,Object.assign(m,{[t]:i.value})),i.value}return t}function A(t,r="+00:00"){let e=f(t),o=(()=>{switch(St(r)){case 5:return"ZZ";case 6:return"Z"}})(),n=Xt(r,o);return new Date(e.getTime()+n*1e3*60)}function j(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function Qt(t,r){let e=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZone:r,hourCycle:"h23"}).formatToParts(t).map(w),o={};return e.forEach(n=>{o[n.type]=n.value}),new Date(`${o.year}-${o.month}-${o.day}T${o.hour}:${o.minute}:${o.second}Z`)}function I(t,r="UTC",e="device",o="Z"){var n;e=e==="device"?(n=j())!=null?n:"utc":e;let i=f(t),m=Qt(i,r),p=Qt(i,e),a=Math.round((p.getTime()-m.getTime())/1e3/60);return vt(a,o)}function B(t,r){if(Dt.includes(t)||typeof t=="object")return Ir(t,r);let e=t,o=0,n=s=>{if(s[2]||(s[2]=new RegExp(`(.)?(${s[0]})`,"g")),s[2].test(e)){let u=0;return e=e.replace(s[2],(x,h,y)=>h==="\\"?y:`${typeof h=="string"?h:""}{!${u++?o:o++}!}`),!!u}return!1};function i(s){let u=s.map(h=>h.partName),x=new Set(u);if(u.length>x.size)throw new Error("Cannot reuse format tokens.");return s}function m(s,[u,x,h]){let y=Object.keys(x)[0],M=x[y];return{option:x,partName:y,partValue:M,token:u,pattern:h,hour12:s}}let p=bt.filter(n).concat(Mt.filter(n)).map(m.bind(null,!1)),a=i(p.concat(kt.filter(n).map(m.bind(null,!0)))),c=/^\{!(\d+)!\}$/;return e.split(/(\{!\d+!\})/).map(s=>{let u=s.match(c);return u?a[Number(u[1])]:{option:{literal:s},partName:"literal",partValue:s,token:s,pattern:new RegExp(""),hour12:!1}}).filter(s=>!(s.partName==="literal"&&s.partValue===""))}function Ir(t,r){let e={timeZone:"UTC"};typeof t=="string"?e.dateStyle=t:("date"in t&&(e.dateStyle=t.date),"time"in t&&(e.timeStyle=t.time));let o=new Intl.DateTimeFormat(r,e),n=o.formatToParts(new Date(T)).map(w),m=o.formatToParts(new Date("1999-04-05T23:05:01.000Z")).map(w).find(a=>a.type==="hour"),p=m&&m.value==="23"?24:12;return n.map(a=>{let c=a.type,s=Br(a.type,a.value,r,a.type==="hour"?p:void 0,e);if(s===void 0)return;let u=s[1][c];if(u)return s[2]||(s[2]=new RegExp(`${s[0]}`,"g")),{option:{[c]:u},partName:c,partValue:u,token:s[0],pattern:s[2],hour12:p===12}}).filter(a=>!!a)}function Br(t,r,e,o,n){let i=r.length,m=!isNaN(Number(r)),p;switch(t){case"year":return i===2?l.get("YY"):l.get("YYYY");case"month":if(m)return i===1?l.get("M"):l.get("MM");switch(p=tr(e,t,r),p){case"long":return l.get("MMMM");default:return l.get("MMM")}case"day":return i===1?l.get("D"):l.get("DD");case"weekday":switch(p=tr(e,t,r),p){case"narrow":return l.get("d");case"short":return l.get("ddd");default:return l.get("dddd")}case"hour":return o===12?i===1?l.get("h"):l.get("hh"):i===1?l.get("H"):l.get("HH");case"minute":return i===1?l.get("m"):l.get("mm");case"second":return i===1?l.get("s"):l.get("ss");case"dayPeriod":return/^[A-Z]+$/u.test(r)?l.get("A"):l.get("a");case"literal":return[r,{literal:r},new RegExp("")];case"timeZoneName":return n.timeStyle==="full"?l.get("Z"):l.get("ZZ");default:return}}function tr(t,r,e){if(!F.has(t)){let n=new Date(T),i=[3,8,9,7,6,4,3],m=["weekday","month","dayPeriod"],p=["long","short","narrow"],a={};for(let c=0;c<12;c++){n.setMonth(0+c),c in i&&n.setDate(i[c]),n.setUTCHours(8+c);for(let s of p){let u=new Intl.DateTimeFormat(t,m.reduce((x,h)=>Object.assign(x,{[h]:s}),{hour12:!0,timeZone:"UTC"})).formatToParts(n).map(w);if(s==="long"||s==="short"){let h=new Intl.DateTimeFormat(t,{dateStyle:s==="short"?"medium":"long",timeZone:"UTC"}).formatToParts(n).map(w).find(M=>M.type==="month"),y=u.findIndex(M=>M.type==="month");y>-1&&h&&(u[y]=h)}u.forEach(x=>{if(x.type==="literal")return;let h=x.type;a[h]=Object.assign(a[h]||{},{[x.value]:s})})}}F.set(t,a)}let o=F.get(t);return o?o[r][e]:void 0}function Pt(t,r="+00:00"){let e=r.slice(0,1)==="+";return A(t,r.replace(e?"+":"-",e?"-":"+"))}function rr(){return Intl.DateTimeFormat().resolvedOptions().locale}function b(t,r="long",e="device",o=!1,n){let i,m;return typeof t=="object"&&!(t instanceof Date)&&({date:t,format:r,locale:e,genitive:o,partFilter:n,tz:i}=t),r==="ISO8601"?f(t).toISOString():(i&&(m=I(t,"utc",i,Gt(r))),i!=null||(i=j()),(i==null?void 0:i.toLowerCase())!=="utc"&&(t=Pt(t,I(t,i,"utc"))),(!e||e==="device")&&(e=rr()),Kt(t,B(r,e).filter(n!=null?n:()=>!0),e,o,m).map(p=>p.value).join(""))}function Hr(){let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return RED.settings.timezone||process.env.TZ||t}function er(t,r){let e=f(t);return r!=null&&r.nowFormatToken.trim()?b(e,r.nowFormatToken.trim()):{timestamp:()=>Date.now(),full:()=>b(e,"full"),long:()=>b(e,"long"),medium:()=>b(e,"medium"),short:()=>b(e,"short"),iso8601:()=>e.toISOString(),utcString:()=>e.toUTCString()}[r.nowFormat]()}var or={now:(t,r)=>er(new Date,r),format:(t,r)=>{if(!t)throw new Error("payloadDate is required");return er(t,r)},timeRange:(t,r)=>{let e=b(new Date,"HH:mm");if(!(r!=null&&r.rangeStartTime)||!(r!=null&&r.rangeEndTime))throw new Error("rangeStartTime and rangeEndTime are required");return(r==null?void 0:r.rangeStartTime)>(r==null?void 0:r.rangeEndTime)?e>=(r==null?void 0:r.rangeStartTime)||e<=(r==null?void 0:r.rangeEndTime):e>=(r==null?void 0:r.rangeStartTime)&&e<=(r==null?void 0:r.rangeEndTime)},currentTimezone:Hr};var nr={abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:t=>Math.max(...t),mean:t=>S(t)/t.length,median:et,min:t=>Math.min(...t),random:Math.random,round:Math.round,sin:Math.sin,sum:t=>S(t),tan:Math.tan,trunc:Math.trunc};var Ct=require("node:net"),ir=require("node:os"),sr={ipInformation:async t=>{if(t!==void 0&&!(0,Ct.isIP)(t))throw new Error("Invalid IP address");return(await fetch(`http://ip-api.com/json/${t||""}`)).json()},ipVersion:Ct.isIP,networkInterfaces:ir.networkInterfaces};var fr={getKeys:q};var ar=require("node:net"),mr=require("node:url");var Et=t=>Number.isNaN(t),ur={isBoolean:t=>typeof t=="boolean",isBuffer:it,isNaN:Et,isNil:t=>t==null,isNull:t=>t===null,isNumber:t=>typeof t=="number",isString:t=>typeof t=="string",isUndefined:t=>t===void 0,isIp:t=>!!(0,ar.isIP)(t),isUrl:t=>{try{return new mr.URL(t),!0}catch(r){return!1}}};var pr={camelCase:ot,capitalize:k,constantCase:ft,escape:at,kebabCase:mt,lowerCase:ut,lowerFirst:pt,pascalCase:ct,snakeCase:nt,startCase:lt,trim:dt,trimEnd:P,trimStart:C,unescape:xt,upperCase:ht,upperFirst:gt,words:g};function cr(t,r,e){return Number.isNaN(r)&&(r=0),Number.isNaN(e)&&(e=0),zt(t,r,e)}function Tt(t){return Lt(t)?0:t instanceof Map||t instanceof Set?t.size:Object.keys(t).length}function _(t){if(t==null)return"";if(typeof t=="string")return t;if(Array.isArray(t))return t.map(_).join(",");let r=String(t);return r==="0"&&Object.is(Number(t),-0)?"-0":r}function Rt(t,r){return typeof t=="string"&&typeof r=="string"?t>r:d(t)>d(r)}function It(t,r){return typeof t=="string"&&typeof r=="string"?t>=r:d(t)>=d(r)}function Bt(t,r){return typeof t=="string"&&typeof r=="string"?t<r:d(t)<d(r)}function Ot(t,r){return typeof t=="string"&&typeof r=="string"?t<=r:d(t)<=d(r)}var $t=Number.MAX_SAFE_INTEGER;function Ft(t){return t==null?0:cr(D(t),-$t,$t)}var lr={toNumber:d,toNumberNonStrict:t=>Et(d(t))?t:d(t),toString:_,toSafeInteger:Ft,toBoolean:t=>!!t,toBooleanNumber:t=>t?0:1,gt:(...t)=>{let[r,e]=t.map(d);return Rt(r,e)},gte:(...t)=>{let[r,e]=t.map(d);return It(r,e)},lt:(...t)=>{let[r,e]=t.map(d);return Bt(r,e)},lte:(...t)=>{let[r,e]=t.map(d);return Ot(r,e)},eq:st,size:Tt};var dr={array_utilities:Vt,async_utilities:qt,date_utilities:or,math_utilities:nr,network_utilities:sr,object_utilities:fr,predicates:ur,string_utilities:pr,utility_functions:lr};function xr(t){RED.nodes.createNode(this,t),this.on("input",async r=>{let e=[],[,o]=await Yt({msg:r,type:t.entryType,node:this,value:t.entry});e.push(o);let n=Ht(t.category,t.function);n!=null&&n.mainValue&&e.push(t.mainValue),n!=null&&n.configArgs&&e.push(t[n==null?void 0:n.configArgs]);let i=dr[t.category][t.function],m=$(i),[p,a]=await m(...e);if(p){this.error(p,r),this.status({fill:"red",shape:"ring",text:"Error"});return}this.status({});let c={nodeParams:{callWith:e,callFunction:t.function}},s=n!=null&&n.inverseReturnValue&&t.inverseReturnValue?!a:a,u={...r,payload:s,...c};if(n!=null&&n.canSplitBooleanOutputs&&t.splitBooleanOutputs||n!=null&&n.forceSplitBooleanOutputs){let x=jt(!!s,u);this.send(x)}else this.send(u)})}var hr={};var Wr=async t=>{global.RED=t,global.RED.nodes.registerType("main",xr,{credentials:hr})};