import type { Keys , Keys1 , Keys2 , Keys3 , Keys4 , Keys5 , Keys6 , Keys7 , Path , Without , Without2 , Without3 , Without4 , Without5 , Without6 , Without7 , Without8 , } from "@thi.ng/api" ; import { toPath } from "./path.js" ; import { updateIn } from "./update-in.js" ; /**
 * Unchecked version of  deleteIn . Path can be given as string or
 * tuple.
 *
 *  example param state param path export const deleteInUnsafe = ( state , path ) : any => deleteIn ( state , < any > path ) ; /**
 * Uses  updateIn and returns updated state with key for given
 * path removed. Does not modify original state. Returns `undefined` if
 * `path` is an empty string or array.
 *
 *  remarks Only the first 8 path levels are type checked. The result type will
 * have the path value removed too.
 *
 * See  deleteInUnsafe for unchecked version.
 *
 *  example param state param path export function deleteIn < T , A extends Keys < T > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > , C extends Keys2 < T , A , B > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > , C extends Keys2 < T , A , B > , D extends Keys3 < T , A , B , C > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > , C extends Keys2 < T , A , B > , D extends Keys3 < T , A , B , C > , E extends Keys4 < T , A , B , C , D > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > , C extends Keys2 < T , A , B > , D extends Keys3 < T , A , B , C > , E extends Keys4 < T , A , B , C , D > , F extends Keys5 < T , A , B , C , D , E > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > , C extends Keys2 < T , A , B > , D extends Keys3 < T , A , B , C > , E extends Keys4 < T , A , B , C , D > , F extends Keys5 < T , A , B , C , D , E > , G extends Keys6 < T , A , B , C , D , E , F > > ( state , path ) ; export function deleteIn < T , A extends Keys < T > , B extends Keys1 < T , A > , C extends Keys2 < T , A , B > , D extends Keys3 < T , A , B , C > , E extends Keys4 < T , A , B , C , D > , F extends Keys5 < T , A , B , C , D , E > , G extends Keys6 < T , A , B , C , D , E , F > , H extends Keys7 < T , A , B , C , D , E , F , G > > ( state , path ) ; export function deleteIn ( state , path ) { const ks = toPath ( path ) . slice ( ) ; if ( ks . length ) { const k = ks . pop ( ) ! ; return updateIn ( state , < any > ks , ( x ) => ( ( x = { ... x } ) , delete x [ k ] , x ) ) ; } }