{"version":3,"sources":["../src/lib/private/isObject.ts","../src/lib/private/isObjectOrArray.ts","../src/lib/hasProperty.ts","../src/lib/setProperty.ts","../src/lib/deleteProperty.ts","../src/lib/getProperty.ts"],"names":[],"mappings":";;;;AAEO,SAAS,SAAS,OAAwC;AAC/D,SAAO,OAAO,UAAU,WAAW,OAAO,gBAAgB,SAAS;AACrE;AAFgB;;;ACCT,SAAS,gBAAgB,OAAgD;AAC9E,SAAO,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK;AAC/C;AAFgB;;;ACMT,SAAS,YAAY,OAAgB,MAAyB;AACnE,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,gBAAgB,KAAK,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AAEb,OAAK,OAAiC,CAAC,cAAc,MAAM,UAAU;AACnE,QAAI,CAAC,gBAAgB,YAAY,GAAG;AAClC,aAAO;AAAA,IACT;AAEA,QAAI,UAAU,KAAK,SAAS,MAAO,MAAM,QAAQ,YAAY,KAAK,aAAa,SAAS,OAAO,IAAI,KAAM,QAAQ,eAAe;AAC9H,eAAS;AAAA,IACX;AAEA,WAAQ,aAA0C,IAAI;AAAA,EACxD,GAAG,KAAK;AAER,SAAO;AACT;AAxBgB;;;ACCT,SAAS,YAAe,OAAgB,MAAgB,OAAmB;AAChF,MAAI,KAAK,WAAW,GAAG;AACrB,YAAQ;AAER,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,gBAAgB,KAAK,GAAG;AAC3B,WAAO,YAAY,CAAC,GAAG,MAAM,KAAK;AAAA,EACpC;AAEA,OAAK,OAAiC,CAAC,cAAc,MAAM,UAAU;AACnE,QAAI,CAAC,gBAAgB,aAAa,IAAI,CAAC,GAAG;AACxC,mBAAa,IAAI,IAAI,CAAC;AAAA,IACxB;AAEA,QAAI,UAAU,KAAK,SAAS,GAAG;AAC7B,UAAI,MAAM,QAAQ,YAAY,GAAG;AAC/B,qBAAa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Q,cAAc;AAC/F,aAAQ,aAA0C,IAAI;AAAA,IACxD;AAEA,WAAO;AAAA,EACT,GAAG,KAAK;AACV;AApBgB","sourcesContent":["import type { NonNullObject } from './NonNullObject';\n\nexport function isObject(input: unknown): input is NonNullObject {\n  return typeof input === 'object' ? input?.constructor === Object : false;\n}\n","import { isObject } from './isObject';\nimport type { NonNullObject } from './NonNullObject';\n\nexport function isObjectOrArray(input: unknown): input is NonNullObject | any[] {\n  return isObject(input) || Array.isArray(input);\n}\n","import { isObjectOrArray } from './private/isObjectOrArray';\n\n/**\n * A helper function to check if an object or array has a property at a path.\n * @since 1.0.0\n * @param input The object or array to check the property at the path.\n * @param path  The path to the property to check.\n * @returns Whether the property at the path exists.\n */\nexport function hasProperty(input: unknown, path: string[]): boolean {\n  if (path.length === 0) {\n    return true;\n  }\n\n  if (!isObjectOrArray(input)) {\n    return false;\n  }\n\n  let result = false;\n\n  path.reduce<Record<PropertyKey, any>>((previousStep, step, index) => {\n    if (!isObjectOrArray(previousStep)) {\n      return previousStep;\n    }\n\n    if (index === path.length - 1 && ((Array.isArray(previousStep) && previousStep.length > Number(step)) || step in previousStep)) {\n      result = true;\n    }\n\n    return (previousStep as Record<PropertyKey, any>)[step];\n  }, input);\n\n  return result;\n}\n","import { isObjectOrArray } from './private/isObjectOrArray';\n\n/**\n * A helper function to set a property on an object or array at a path.\n * @since 1.0.0\n * @param input The object or array to set the property on.\n * @param path The path to the property to set.\n * @param value The value to set the property to.\n * @returns The input object or array.\n */\nexport function setProperty<T>(input: unknown, path: string[], value: unknown): T {\n  if (path.length === 0) {\n    input = value;\n\n    return input as unknown as T;\n  }\n\n  if (!isObjectOrArray(input)) {\n    return setProperty({}, path, value);\n  }\n\n  path.reduce<Record<PropertyKey, any>>((previousStep, step, index) => {\n    if (!isObjectOrArray(previousStep[step])) {\n      previousStep[step] = {};\n    }\n\n    if (index === path.length - 1) {\n      if (Array.isArray(previousStep)) {\n        previousStep[Number(step)] = value;\n      } else {\n        Reflect.set(previousStep, step, value);\n      }\n    }\n\n    return previousStep[step];\n  }, input);\n\n  return input as unknown as T;\n}\n","import { hasProperty } from './hasProperty';\nimport { isObjectOrArray } from './private/isObjectOrArray';\nimport { setProperty } from './setProperty';\n\n/**\n * A helper function to delete a property from an object or array at a path.\n * @since 1.0.0\n * @param input The object or array to delete the property from.\n * @param path The path to the property to delete.\n * @returns The input object or array.\n */\nexport function deleteProperty<T>(input: unknown, path: string[]): T {\n  if (path.length === 0 || !isObjectOrArray(input) || !hasProperty(input, path)) {\n    return input as unknown as T;\n  }\n\n  path.reduce<Record<PropertyKey, any>>((previousStep, step, index) => {\n    if (!isObjectOrArray(previousStep)) {\n      return previousStep;\n    }\n\n    if (index === path.length - 1) {\n      if (Array.isArray(previousStep) && previousStep.length > Number(step)) {\n        input = setProperty(\n          input,\n          path.slice(0, -1),\n          previousStep.filter((_, i) => i !== Number(step))\n        );\n      } else if (step in previousStep) {\n        Reflect.deleteProperty(previousStep, step);\n      }\n    }\n\n    return (previousStep as Record<PropertyKey, any>)[step];\n  }, input);\n\n  return input as unknown as T;\n}\n","import { isObjectOrArray } from './private/isObjectOrArray';\n\nexport const PROPERTY_NOT_FOUND = Symbol('PROPERTY_NOT_FOUND');\n\n/**\n * A helper function to get a property from an object or array at a path.\n * @since 1.0.0\n * @param input The object or array to get the property from.\n * @param path The path to the property to get.\n * @param fallbackToInput Whether to return the input if path has a length of 0.\n * @returns The property at the path or {@link PROPERTY_NOT_FOUND} if the property does not exist.\n */\nexport function getProperty<T = unknown>(input: unknown, path: string[], fallbackToInput = true): T | typeof PROPERTY_NOT_FOUND {\n  if (path.length === 0) {\n    return fallbackToInput ? (input as unknown as T) : PROPERTY_NOT_FOUND;\n  }\n\n  if (!isObjectOrArray(input)) {\n    return PROPERTY_NOT_FOUND;\n  }\n\n  return path.reduce<Record<PropertyKey, any>>((previousStep, step) => {\n    if (!isObjectOrArray(previousStep)) {\n      return PROPERTY_NOT_FOUND;\n    }\n\n    if ((Array.isArray(previousStep) && previousStep.length > Number(step)) || step in previousStep) {\n      return (previousStep as Record<PropertyKey, any>)[step];\n    }\n\n    return PROPERTY_NOT_FOUND;\n  }, input);\n}\n"]}