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,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACd,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAPD,gCAOC","sourcesContent":["function isObject(x: any) {\n if (Array.isArray(x)) {\n return false\n }\n\n const type = typeof x\n return type === \"object\" || type === \"function\"\n}\n\nfunction assignKey(target: any, from: any, key: string) {\n const value = from[key]\n // https://github.com/electron-userland/electron-builder/pull/562\n if (value === undefined) {\n return\n }\n\n const prevValue = target[key]\n if (prevValue == null || value == null || !isObject(prevValue) || !isObject(value)) {\n target[key] = value\n }\n else {\n target[key] = assign(prevValue, value)\n }\n}\n\nfunction assign(to: any, from: any) {\n if (to !== from) {\n for (const key of Object.getOwnPropertyNames(from)) {\n assignKey(to, from, key)\n }\n }\n return to\n}\n\nexport function deepAssign<T>(target: T, ...objects: Array<any>): T {\n for (const o of objects) {\n if (o != null) {\n assign(target, o)\n }\n }\n return target\n}"]}
\No newline at end of file