class l{static set(i,n,r){const e=n.split(".");let t=i;for(;e.length>1;){const s=e.shift();t[s]||(t[s]={}),t=t[s]}t[e[0]]=r}static get(i,n,r=null){if(!n)return r;if(!(n||Array.isArray(i)||typeof i=="object"))return i;const e=n.trim().split(".");if(n.includes("*"))return l._getWithWildcard(i,e,r);let t=i;for(const s of e){if(!t||!t.hasOwnProperty(s))return r;t=t[s]}return t}static _getWithWildcard(i,n,r=null){let e=i;for(let t=0;t<n.length;t++){const s=n[t];if(s==="*")if(Array.isArray(e)){const c=n.slice(t+1).join(".");return c?e.map(o=>l.get(o,c,r)):e}else if(typeof e=="object"&&e!==null){const c=n.slice(t+1).join(".");return c?Object.values(e).map(o=>l.get(o,c,r)):Object.values(e)}else return r;else{if(!e||!e.hasOwnProperty(s))return r;e=e[s]}}return e}static resolvePath(i,n){if(!(i.includes(".")||n.includes(".")))return n;let r=i.split(".");r.pop();let e=n.split("../"),t=e.pop(),s=0,c="";for(let o=0;o<e.length;o++)e[o]===""&&s++;return r.splice(0,s),c=r.length?r.join(".")+".":"",c+`${t}`}static getByPath(i,n,r,e){const t=l.resolvePath(n,r);return l.get(i,t,e)}static whereIn(i,n,r){return!Array.isArray(i)||!Array.isArray(r)?[]:i.filter(e=>{if(typeof e=="object"&&e!==null){const t=l.get(e,n);return r.includes(t)}return r.includes(e)})}static where(i,n,r){return Array.isArray(i)?i.filter(e=>typeof e=="object"&&e!==null?l.get(e,n)===r:e===r):[]}static sum(i,n=""){if(n.includes("*")){const r=l.get(i,n,[]);return Array.isArray(r)?r.reduce((e,t)=>e+(typeof t=="number"?t:0),0):0}return i.reduce((r,e)=>{const t=typeof e=="object"&&e!==null?l.get(e,n,0):e;return r+(typeof t=="number"?t:0)},0)}}export{l as A};
