| 333 | return ((o.newDocument = e), o); |
| 334 | } |
| 335 | function I(e, t, n, r) { |
| 336 | if ("object" != typeof e || null === e || Array.isArray(e)) |
| 337 | throw new E( |
| 338 | "Operation is not an object", |
| 339 | "OPERATION_NOT_AN_OBJECT", |
| 340 | t, |
| 341 | e, |
| 342 | n, |
| 343 | ); |
| 344 | if (!b[e.op]) |
| 345 | throw new E( |
| 346 | "Operation `op` property is not one of operations defined in RFC-6902", |
| 347 | "OPERATION_OP_INVALID", |
| 348 | t, |
| 349 | e, |
| 350 | n, |
| 351 | ); |
| 352 | if ("string" != typeof e.path) |
| 353 | throw new E( |
| 354 | "Operation `path` property is not a string", |
| 355 | "OPERATION_PATH_INVALID", |
| 356 | t, |
| 357 | e, |
| 358 | n, |
| 359 | ); |
| 360 | if (0 !== e.path.indexOf("/") && e.path.length > 0) |
| 361 | throw new E( |
| 362 | 'Operation `path` property must start with "/"', |
| 363 | "OPERATION_PATH_INVALID", |
| 364 | t, |
| 365 | e, |
| 366 | n, |
| 367 | ); |
| 368 | if (("move" === e.op || "copy" === e.op) && "string" != typeof e.from) |
| 369 | throw new E( |
| 370 | "Operation `from` property is not present (applicable in `move` and `copy` operations)", |
| 371 | "OPERATION_FROM_REQUIRED", |
| 372 | t, |
| 373 | e, |
| 374 | n, |
| 375 | ); |
| 376 | if ( |
| 377 | ("add" === e.op || "replace" === e.op || "test" === e.op) && |
| 378 | void 0 === e.value |
| 379 | ) |
| 380 | throw new E( |
| 381 | "Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", |
| 382 | "OPERATION_VALUE_REQUIRED", |
| 383 | t, |
| 384 | e, |
| 385 | n, |
| 386 | ); |
| 387 | if (("add" === e.op || "replace" === e.op || "test" === e.op) && h(e.value)) |
| 388 | throw new E( |
| 389 | "Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", |
| 390 | "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", |
| 391 | t, |
| 392 | e, |