| 198 | return (O(e, n), n.value); |
| 199 | } |
| 200 | function O(e, t, n, r, i, o) { |
| 201 | if ( |
| 202 | (void 0 === n && (n = !1), |
| 203 | void 0 === r && (r = !0), |
| 204 | void 0 === i && (i = !0), |
| 205 | void 0 === o && (o = 0), |
| 206 | n && ("function" == typeof n ? n(t, 0, e, t.path) : I(t, 0)), |
| 207 | "" === t.path) |
| 208 | ) { |
| 209 | var a = { newDocument: e }; |
| 210 | if ("add" === t.op) return ((a.newDocument = t.value), a); |
| 211 | if ("replace" === t.op) |
| 212 | return ((a.newDocument = t.value), (a.removed = e), a); |
| 213 | if ("move" === t.op || "copy" === t.op) |
| 214 | return ( |
| 215 | (a.newDocument = w(e, t.from)), |
| 216 | "move" === t.op && (a.removed = e), |
| 217 | a |
| 218 | ); |
| 219 | if ("test" === t.op) { |
| 220 | if (((a.test = L(e, t.value)), !1 === a.test)) |
| 221 | throw new E( |
| 222 | "Test operation failed", |
| 223 | "TEST_OPERATION_FAILED", |
| 224 | o, |
| 225 | t, |
| 226 | e, |
| 227 | ); |
| 228 | return ((a.newDocument = e), a); |
| 229 | } |
| 230 | if ("remove" === t.op) |
| 231 | return ((a.removed = e), (a.newDocument = null), a); |
| 232 | if ("_get" === t.op) return ((t.value = e), a); |
| 233 | if (n) |
| 234 | throw new E( |
| 235 | "Operation `op` property is not one of operations defined in RFC-6902", |
| 236 | "OPERATION_OP_INVALID", |
| 237 | o, |
| 238 | t, |
| 239 | e, |
| 240 | ); |
| 241 | return a; |
| 242 | } |
| 243 | r || (e = f(e)); |
| 244 | var s = (t.path || "").split("/"), |
| 245 | l = e, |
| 246 | c = 1, |
| 247 | p = s.length, |
| 248 | h = void 0, |
| 249 | g = void 0, |
| 250 | m = void 0; |
| 251 | for (m = "function" == typeof n ? n : I; ; ) { |
| 252 | if ( |
| 253 | ((g = s[c]) && -1 != g.indexOf("~") && (g = u(g)), |
| 254 | i && |
| 255 | ("__proto__" == g || |
| 256 | ("prototype" == g && c > 0 && "constructor" == s[c - 1]))) |
| 257 | ) |