@sanity/assist 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +4155 -559
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4314 -715
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/assistDocument/components/AssistDocumentForm.tsx +16 -10
- package/src/assistDocument/components/InstructionsArrayField.tsx +1 -1
- package/src/assistDocument/components/instruction/FieldRefInput.tsx +16 -1
- package/src/assistInspector/AssistInspector.tsx +50 -27
- package/src/assistInspector/FieldAutocomplete.tsx +49 -29
- package/src/assistInspector/helpers.ts +84 -4
- package/src/fieldActions/assistFieldActions.tsx +16 -5
- package/src/helpers/useAssistSupported.ts +1 -4
- package/src/schemas/assistDocumentSchema.tsx +1 -1
- package/src/useApiClient.ts +1 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, pathToString, isObjectSchemaType, useEditState, useCurrentUser, useValidationStatus, StatusButton, FormFieldHeaderText, PatchEvent, unset,
|
|
3
|
-
import { Card, Stack, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Badge, useTheme, rgba, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem
|
|
2
|
+
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, pathToString, isObjectSchemaType, stringToPath, isKeySegment, useEditState, useCurrentUser, useValidationStatus, StatusButton, FormFieldHeaderText, PatchEvent, unset, set, useFormCallbacks, FormCallbacksProvider, FormInput, setIfMissing, insert, PresenceOverlay, VirtualizerScrollInstanceProvider, useColorSchemeValue, isArraySchemaType, ObjectInputMember, defineType, defineField, defineArrayMember, getPublishedId, definePlugin } from 'sanity';
|
|
3
|
+
import { Card, Stack as Stack$1, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Autocomplete, Breadcrumbs, Badge, useTheme, rgba, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
4
4
|
import { useState, useRef, useEffect, useMemo, useCallback, createContext, useReducer, forwardRef, createElement, useContext, useId } from 'react';
|
|
5
|
-
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon,
|
|
5
|
+
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, ArrowLeftIcon, SearchIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon, icons, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon, LockIcon, ControlsIcon } from '@sanity/icons';
|
|
6
6
|
import { mergeMap, share, take, filter, distinctUntilChanged, catchError, tap } from 'rxjs/operators';
|
|
7
7
|
import isEqual from 'react-fast-compare';
|
|
8
8
|
import { throwError, of, partition, merge, switchMap, delay, defer } from 'rxjs';
|
|
9
9
|
import { exhaustMapToWithTrailing } from 'rxjs-exhaustmap-with-trailing';
|
|
10
10
|
import { useDocumentPane, usePaneRouter, DocumentInspectorHeader, DocumentPaneProvider } from 'sanity/desk';
|
|
11
|
+
import require$$1 from 'tty';
|
|
12
|
+
import require$$1$1 from 'util';
|
|
13
|
+
import require$$0 from 'os';
|
|
11
14
|
import styled, { keyframes } from 'styled-components';
|
|
12
15
|
import { minutesToMilliseconds, isAfter, addSeconds } from 'date-fns';
|
|
13
16
|
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
|
@@ -305,7 +308,7 @@ function SchemaTypeTool() {
|
|
|
305
308
|
style: {
|
|
306
309
|
height: "calc(100vh - 81px)"
|
|
307
310
|
},
|
|
308
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
311
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
309
312
|
space: 4,
|
|
310
313
|
children: [/* @__PURE__ */jsx(Box, {
|
|
311
314
|
children: /* @__PURE__ */jsx(Button, {
|
|
@@ -320,7 +323,7 @@ function SchemaTypeTool() {
|
|
|
320
323
|
})
|
|
321
324
|
}), /* @__PURE__ */jsxs(Flex, {
|
|
322
325
|
gap: 2,
|
|
323
|
-
children: [/* @__PURE__ */jsxs(Stack, {
|
|
326
|
+
children: [/* @__PURE__ */jsxs(Stack$1, {
|
|
324
327
|
space: 2,
|
|
325
328
|
children: [/* @__PURE__ */jsx(Label, {
|
|
326
329
|
children: "Studio schema"
|
|
@@ -331,7 +334,7 @@ function SchemaTypeTool() {
|
|
|
331
334
|
})
|
|
332
335
|
}, type.name))
|
|
333
336
|
})]
|
|
334
|
-
}), /* @__PURE__ */jsxs(Stack, {
|
|
337
|
+
}), /* @__PURE__ */jsxs(Stack$1, {
|
|
335
338
|
space: 2,
|
|
336
339
|
children: [/* @__PURE__ */jsx(Label, {
|
|
337
340
|
children: "Stored schema"
|
|
@@ -506,7 +509,3486 @@ function prepareRebaseEvent(event) {
|
|
|
506
509
|
}
|
|
507
510
|
const SelectedFieldContext = createContext(void 0);
|
|
508
511
|
const SelectedFieldContextProvider = SelectedFieldContext.Provider;
|
|
509
|
-
|
|
512
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
513
|
+
function getDefaultExportFromCjs(x) {
|
|
514
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Appends the elements of `values` to `array`.
|
|
519
|
+
*
|
|
520
|
+
* @private
|
|
521
|
+
* @param {Array} array The array to modify.
|
|
522
|
+
* @param {Array} values The values to append.
|
|
523
|
+
* @returns {Array} Returns `array`.
|
|
524
|
+
*/
|
|
525
|
+
|
|
526
|
+
function arrayPush$1(array, values) {
|
|
527
|
+
var index = -1,
|
|
528
|
+
length = values.length,
|
|
529
|
+
offset = array.length;
|
|
530
|
+
while (++index < length) {
|
|
531
|
+
array[offset + index] = values[index];
|
|
532
|
+
}
|
|
533
|
+
return array;
|
|
534
|
+
}
|
|
535
|
+
var _arrayPush = arrayPush$1;
|
|
536
|
+
|
|
537
|
+
/** Detect free variable `global` from Node.js. */
|
|
538
|
+
|
|
539
|
+
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
540
|
+
var _freeGlobal = freeGlobal$1;
|
|
541
|
+
var freeGlobal = _freeGlobal;
|
|
542
|
+
|
|
543
|
+
/** Detect free variable `self`. */
|
|
544
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
545
|
+
|
|
546
|
+
/** Used as a reference to the global object. */
|
|
547
|
+
var root$7 = freeGlobal || freeSelf || Function('return this')();
|
|
548
|
+
var _root = root$7;
|
|
549
|
+
var root$6 = _root;
|
|
550
|
+
|
|
551
|
+
/** Built-in value references. */
|
|
552
|
+
var Symbol$4 = root$6.Symbol;
|
|
553
|
+
var _Symbol = Symbol$4;
|
|
554
|
+
var Symbol$3 = _Symbol;
|
|
555
|
+
|
|
556
|
+
/** Used for built-in method references. */
|
|
557
|
+
var objectProto$5 = Object.prototype;
|
|
558
|
+
|
|
559
|
+
/** Used to check objects for own properties. */
|
|
560
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Used to resolve the
|
|
564
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
565
|
+
* of values.
|
|
566
|
+
*/
|
|
567
|
+
var nativeObjectToString$1 = objectProto$5.toString;
|
|
568
|
+
|
|
569
|
+
/** Built-in value references. */
|
|
570
|
+
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : undefined;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
574
|
+
*
|
|
575
|
+
* @private
|
|
576
|
+
* @param {*} value The value to query.
|
|
577
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
578
|
+
*/
|
|
579
|
+
function getRawTag$1(value) {
|
|
580
|
+
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1),
|
|
581
|
+
tag = value[symToStringTag$1];
|
|
582
|
+
try {
|
|
583
|
+
value[symToStringTag$1] = undefined;
|
|
584
|
+
var unmasked = true;
|
|
585
|
+
} catch (e) {}
|
|
586
|
+
var result = nativeObjectToString$1.call(value);
|
|
587
|
+
if (unmasked) {
|
|
588
|
+
if (isOwn) {
|
|
589
|
+
value[symToStringTag$1] = tag;
|
|
590
|
+
} else {
|
|
591
|
+
delete value[symToStringTag$1];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return result;
|
|
595
|
+
}
|
|
596
|
+
var _getRawTag = getRawTag$1;
|
|
597
|
+
|
|
598
|
+
/** Used for built-in method references. */
|
|
599
|
+
|
|
600
|
+
var objectProto$4 = Object.prototype;
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Used to resolve the
|
|
604
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
605
|
+
* of values.
|
|
606
|
+
*/
|
|
607
|
+
var nativeObjectToString = objectProto$4.toString;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
611
|
+
*
|
|
612
|
+
* @private
|
|
613
|
+
* @param {*} value The value to convert.
|
|
614
|
+
* @returns {string} Returns the converted string.
|
|
615
|
+
*/
|
|
616
|
+
function objectToString$1(value) {
|
|
617
|
+
return nativeObjectToString.call(value);
|
|
618
|
+
}
|
|
619
|
+
var _objectToString = objectToString$1;
|
|
620
|
+
var Symbol$2 = _Symbol,
|
|
621
|
+
getRawTag = _getRawTag,
|
|
622
|
+
objectToString = _objectToString;
|
|
623
|
+
|
|
624
|
+
/** `Object#toString` result references. */
|
|
625
|
+
var nullTag = '[object Null]',
|
|
626
|
+
undefinedTag = '[object Undefined]';
|
|
627
|
+
|
|
628
|
+
/** Built-in value references. */
|
|
629
|
+
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
633
|
+
*
|
|
634
|
+
* @private
|
|
635
|
+
* @param {*} value The value to query.
|
|
636
|
+
* @returns {string} Returns the `toStringTag`.
|
|
637
|
+
*/
|
|
638
|
+
function baseGetTag$3(value) {
|
|
639
|
+
if (value == null) {
|
|
640
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
641
|
+
}
|
|
642
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
643
|
+
}
|
|
644
|
+
var _baseGetTag = baseGetTag$3;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
648
|
+
* and has a `typeof` result of "object".
|
|
649
|
+
*
|
|
650
|
+
* @static
|
|
651
|
+
* @memberOf _
|
|
652
|
+
* @since 4.0.0
|
|
653
|
+
* @category Lang
|
|
654
|
+
* @param {*} value The value to check.
|
|
655
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
656
|
+
* @example
|
|
657
|
+
*
|
|
658
|
+
* _.isObjectLike({});
|
|
659
|
+
* // => true
|
|
660
|
+
*
|
|
661
|
+
* _.isObjectLike([1, 2, 3]);
|
|
662
|
+
* // => true
|
|
663
|
+
*
|
|
664
|
+
* _.isObjectLike(_.noop);
|
|
665
|
+
* // => false
|
|
666
|
+
*
|
|
667
|
+
* _.isObjectLike(null);
|
|
668
|
+
* // => false
|
|
669
|
+
*/
|
|
670
|
+
|
|
671
|
+
function isObjectLike$2(value) {
|
|
672
|
+
return value != null && typeof value == 'object';
|
|
673
|
+
}
|
|
674
|
+
var isObjectLike_1 = isObjectLike$2;
|
|
675
|
+
var baseGetTag$2 = _baseGetTag,
|
|
676
|
+
isObjectLike$1 = isObjectLike_1;
|
|
677
|
+
|
|
678
|
+
/** `Object#toString` result references. */
|
|
679
|
+
var argsTag = '[object Arguments]';
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* The base implementation of `_.isArguments`.
|
|
683
|
+
*
|
|
684
|
+
* @private
|
|
685
|
+
* @param {*} value The value to check.
|
|
686
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
687
|
+
*/
|
|
688
|
+
function baseIsArguments$1(value) {
|
|
689
|
+
return isObjectLike$1(value) && baseGetTag$2(value) == argsTag;
|
|
690
|
+
}
|
|
691
|
+
var _baseIsArguments = baseIsArguments$1;
|
|
692
|
+
var baseIsArguments = _baseIsArguments,
|
|
693
|
+
isObjectLike = isObjectLike_1;
|
|
694
|
+
|
|
695
|
+
/** Used for built-in method references. */
|
|
696
|
+
var objectProto$3 = Object.prototype;
|
|
697
|
+
|
|
698
|
+
/** Used to check objects for own properties. */
|
|
699
|
+
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
700
|
+
|
|
701
|
+
/** Built-in value references. */
|
|
702
|
+
var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Checks if `value` is likely an `arguments` object.
|
|
706
|
+
*
|
|
707
|
+
* @static
|
|
708
|
+
* @memberOf _
|
|
709
|
+
* @since 0.1.0
|
|
710
|
+
* @category Lang
|
|
711
|
+
* @param {*} value The value to check.
|
|
712
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
713
|
+
* else `false`.
|
|
714
|
+
* @example
|
|
715
|
+
*
|
|
716
|
+
* _.isArguments(function() { return arguments; }());
|
|
717
|
+
* // => true
|
|
718
|
+
*
|
|
719
|
+
* _.isArguments([1, 2, 3]);
|
|
720
|
+
* // => false
|
|
721
|
+
*/
|
|
722
|
+
var isArguments$1 = baseIsArguments(function () {
|
|
723
|
+
return arguments;
|
|
724
|
+
}()) ? baseIsArguments : function (value) {
|
|
725
|
+
return isObjectLike(value) && hasOwnProperty$3.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
|
|
726
|
+
};
|
|
727
|
+
var isArguments_1 = isArguments$1;
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Checks if `value` is classified as an `Array` object.
|
|
731
|
+
*
|
|
732
|
+
* @static
|
|
733
|
+
* @memberOf _
|
|
734
|
+
* @since 0.1.0
|
|
735
|
+
* @category Lang
|
|
736
|
+
* @param {*} value The value to check.
|
|
737
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
738
|
+
* @example
|
|
739
|
+
*
|
|
740
|
+
* _.isArray([1, 2, 3]);
|
|
741
|
+
* // => true
|
|
742
|
+
*
|
|
743
|
+
* _.isArray(document.body.children);
|
|
744
|
+
* // => false
|
|
745
|
+
*
|
|
746
|
+
* _.isArray('abc');
|
|
747
|
+
* // => false
|
|
748
|
+
*
|
|
749
|
+
* _.isArray(_.noop);
|
|
750
|
+
* // => false
|
|
751
|
+
*/
|
|
752
|
+
|
|
753
|
+
var isArray$1 = Array.isArray;
|
|
754
|
+
var isArray_1 = isArray$1;
|
|
755
|
+
var Symbol$1 = _Symbol,
|
|
756
|
+
isArguments = isArguments_1,
|
|
757
|
+
isArray = isArray_1;
|
|
758
|
+
|
|
759
|
+
/** Built-in value references. */
|
|
760
|
+
var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : undefined;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
764
|
+
*
|
|
765
|
+
* @private
|
|
766
|
+
* @param {*} value The value to check.
|
|
767
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
768
|
+
*/
|
|
769
|
+
function isFlattenable$1(value) {
|
|
770
|
+
return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
771
|
+
}
|
|
772
|
+
var _isFlattenable = isFlattenable$1;
|
|
773
|
+
var arrayPush = _arrayPush,
|
|
774
|
+
isFlattenable = _isFlattenable;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
778
|
+
*
|
|
779
|
+
* @private
|
|
780
|
+
* @param {Array} array The array to flatten.
|
|
781
|
+
* @param {number} depth The maximum recursion depth.
|
|
782
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
783
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
784
|
+
* @param {Array} [result=[]] The initial result value.
|
|
785
|
+
* @returns {Array} Returns the new flattened array.
|
|
786
|
+
*/
|
|
787
|
+
function baseFlatten$1(array, depth, predicate, isStrict, result) {
|
|
788
|
+
var index = -1,
|
|
789
|
+
length = array.length;
|
|
790
|
+
predicate || (predicate = isFlattenable);
|
|
791
|
+
result || (result = []);
|
|
792
|
+
while (++index < length) {
|
|
793
|
+
var value = array[index];
|
|
794
|
+
if (depth > 0 && predicate(value)) {
|
|
795
|
+
if (depth > 1) {
|
|
796
|
+
// Recursively flatten arrays (susceptible to call stack limits).
|
|
797
|
+
baseFlatten$1(value, depth - 1, predicate, isStrict, result);
|
|
798
|
+
} else {
|
|
799
|
+
arrayPush(result, value);
|
|
800
|
+
}
|
|
801
|
+
} else if (!isStrict) {
|
|
802
|
+
result[result.length] = value;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return result;
|
|
806
|
+
}
|
|
807
|
+
var _baseFlatten = baseFlatten$1;
|
|
808
|
+
var baseFlatten = _baseFlatten;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Flattens `array` a single level deep.
|
|
812
|
+
*
|
|
813
|
+
* @static
|
|
814
|
+
* @memberOf _
|
|
815
|
+
* @since 0.1.0
|
|
816
|
+
* @category Array
|
|
817
|
+
* @param {Array} array The array to flatten.
|
|
818
|
+
* @returns {Array} Returns the new flattened array.
|
|
819
|
+
* @example
|
|
820
|
+
*
|
|
821
|
+
* _.flatten([1, [2, [3, [4]], 5]]);
|
|
822
|
+
* // => [1, 2, [3, [4]], 5]
|
|
823
|
+
*/
|
|
824
|
+
function flatten(array) {
|
|
825
|
+
var length = array == null ? 0 : array.length;
|
|
826
|
+
return length ? baseFlatten(array, 1) : [];
|
|
827
|
+
}
|
|
828
|
+
var flatten_1 = flatten;
|
|
829
|
+
var flatten$1 = /*@__PURE__*/getDefaultExportFromCjs(flatten_1);
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Creates an array with all falsey values removed. The values `false`, `null`,
|
|
833
|
+
* `0`, `""`, `undefined`, and `NaN` are falsey.
|
|
834
|
+
*
|
|
835
|
+
* @static
|
|
836
|
+
* @memberOf _
|
|
837
|
+
* @since 0.1.0
|
|
838
|
+
* @category Array
|
|
839
|
+
* @param {Array} array The array to compact.
|
|
840
|
+
* @returns {Array} Returns the new array of filtered values.
|
|
841
|
+
* @example
|
|
842
|
+
*
|
|
843
|
+
* _.compact([0, 1, false, 2, '', 3]);
|
|
844
|
+
* // => [1, 2, 3]
|
|
845
|
+
*/
|
|
846
|
+
|
|
847
|
+
function compact(array) {
|
|
848
|
+
var index = -1,
|
|
849
|
+
length = array == null ? 0 : array.length,
|
|
850
|
+
resIndex = 0,
|
|
851
|
+
result = [];
|
|
852
|
+
while (++index < length) {
|
|
853
|
+
var value = array[index];
|
|
854
|
+
if (value) {
|
|
855
|
+
result[resIndex++] = value;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return result;
|
|
859
|
+
}
|
|
860
|
+
var compact_1 = compact;
|
|
861
|
+
var compact$1 = /*@__PURE__*/getDefaultExportFromCjs(compact_1);
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Removes all key-value entries from the list cache.
|
|
865
|
+
*
|
|
866
|
+
* @private
|
|
867
|
+
* @name clear
|
|
868
|
+
* @memberOf ListCache
|
|
869
|
+
*/
|
|
870
|
+
|
|
871
|
+
function listCacheClear$1() {
|
|
872
|
+
this.__data__ = [];
|
|
873
|
+
this.size = 0;
|
|
874
|
+
}
|
|
875
|
+
var _listCacheClear = listCacheClear$1;
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Performs a
|
|
879
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
880
|
+
* comparison between two values to determine if they are equivalent.
|
|
881
|
+
*
|
|
882
|
+
* @static
|
|
883
|
+
* @memberOf _
|
|
884
|
+
* @since 4.0.0
|
|
885
|
+
* @category Lang
|
|
886
|
+
* @param {*} value The value to compare.
|
|
887
|
+
* @param {*} other The other value to compare.
|
|
888
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
889
|
+
* @example
|
|
890
|
+
*
|
|
891
|
+
* var object = { 'a': 1 };
|
|
892
|
+
* var other = { 'a': 1 };
|
|
893
|
+
*
|
|
894
|
+
* _.eq(object, object);
|
|
895
|
+
* // => true
|
|
896
|
+
*
|
|
897
|
+
* _.eq(object, other);
|
|
898
|
+
* // => false
|
|
899
|
+
*
|
|
900
|
+
* _.eq('a', 'a');
|
|
901
|
+
* // => true
|
|
902
|
+
*
|
|
903
|
+
* _.eq('a', Object('a'));
|
|
904
|
+
* // => false
|
|
905
|
+
*
|
|
906
|
+
* _.eq(NaN, NaN);
|
|
907
|
+
* // => true
|
|
908
|
+
*/
|
|
909
|
+
|
|
910
|
+
function eq$1(value, other) {
|
|
911
|
+
return value === other || value !== value && other !== other;
|
|
912
|
+
}
|
|
913
|
+
var eq_1 = eq$1;
|
|
914
|
+
var eq = eq_1;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
918
|
+
*
|
|
919
|
+
* @private
|
|
920
|
+
* @param {Array} array The array to inspect.
|
|
921
|
+
* @param {*} key The key to search for.
|
|
922
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
923
|
+
*/
|
|
924
|
+
function assocIndexOf$4(array, key) {
|
|
925
|
+
var length = array.length;
|
|
926
|
+
while (length--) {
|
|
927
|
+
if (eq(array[length][0], key)) {
|
|
928
|
+
return length;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return -1;
|
|
932
|
+
}
|
|
933
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
934
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
935
|
+
|
|
936
|
+
/** Used for built-in method references. */
|
|
937
|
+
var arrayProto = Array.prototype;
|
|
938
|
+
|
|
939
|
+
/** Built-in value references. */
|
|
940
|
+
var splice = arrayProto.splice;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Removes `key` and its value from the list cache.
|
|
944
|
+
*
|
|
945
|
+
* @private
|
|
946
|
+
* @name delete
|
|
947
|
+
* @memberOf ListCache
|
|
948
|
+
* @param {string} key The key of the value to remove.
|
|
949
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
950
|
+
*/
|
|
951
|
+
function listCacheDelete$1(key) {
|
|
952
|
+
var data = this.__data__,
|
|
953
|
+
index = assocIndexOf$3(data, key);
|
|
954
|
+
if (index < 0) {
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
var lastIndex = data.length - 1;
|
|
958
|
+
if (index == lastIndex) {
|
|
959
|
+
data.pop();
|
|
960
|
+
} else {
|
|
961
|
+
splice.call(data, index, 1);
|
|
962
|
+
}
|
|
963
|
+
--this.size;
|
|
964
|
+
return true;
|
|
965
|
+
}
|
|
966
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
967
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Gets the list cache value for `key`.
|
|
971
|
+
*
|
|
972
|
+
* @private
|
|
973
|
+
* @name get
|
|
974
|
+
* @memberOf ListCache
|
|
975
|
+
* @param {string} key The key of the value to get.
|
|
976
|
+
* @returns {*} Returns the entry value.
|
|
977
|
+
*/
|
|
978
|
+
function listCacheGet$1(key) {
|
|
979
|
+
var data = this.__data__,
|
|
980
|
+
index = assocIndexOf$2(data, key);
|
|
981
|
+
return index < 0 ? undefined : data[index][1];
|
|
982
|
+
}
|
|
983
|
+
var _listCacheGet = listCacheGet$1;
|
|
984
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Checks if a list cache value for `key` exists.
|
|
988
|
+
*
|
|
989
|
+
* @private
|
|
990
|
+
* @name has
|
|
991
|
+
* @memberOf ListCache
|
|
992
|
+
* @param {string} key The key of the entry to check.
|
|
993
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
994
|
+
*/
|
|
995
|
+
function listCacheHas$1(key) {
|
|
996
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
997
|
+
}
|
|
998
|
+
var _listCacheHas = listCacheHas$1;
|
|
999
|
+
var assocIndexOf = _assocIndexOf;
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Sets the list cache `key` to `value`.
|
|
1003
|
+
*
|
|
1004
|
+
* @private
|
|
1005
|
+
* @name set
|
|
1006
|
+
* @memberOf ListCache
|
|
1007
|
+
* @param {string} key The key of the value to set.
|
|
1008
|
+
* @param {*} value The value to set.
|
|
1009
|
+
* @returns {Object} Returns the list cache instance.
|
|
1010
|
+
*/
|
|
1011
|
+
function listCacheSet$1(key, value) {
|
|
1012
|
+
var data = this.__data__,
|
|
1013
|
+
index = assocIndexOf(data, key);
|
|
1014
|
+
if (index < 0) {
|
|
1015
|
+
++this.size;
|
|
1016
|
+
data.push([key, value]);
|
|
1017
|
+
} else {
|
|
1018
|
+
data[index][1] = value;
|
|
1019
|
+
}
|
|
1020
|
+
return this;
|
|
1021
|
+
}
|
|
1022
|
+
var _listCacheSet = listCacheSet$1;
|
|
1023
|
+
var listCacheClear = _listCacheClear,
|
|
1024
|
+
listCacheDelete = _listCacheDelete,
|
|
1025
|
+
listCacheGet = _listCacheGet,
|
|
1026
|
+
listCacheHas = _listCacheHas,
|
|
1027
|
+
listCacheSet = _listCacheSet;
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Creates an list cache object.
|
|
1031
|
+
*
|
|
1032
|
+
* @private
|
|
1033
|
+
* @constructor
|
|
1034
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1035
|
+
*/
|
|
1036
|
+
function ListCache$4(entries) {
|
|
1037
|
+
var index = -1,
|
|
1038
|
+
length = entries == null ? 0 : entries.length;
|
|
1039
|
+
this.clear();
|
|
1040
|
+
while (++index < length) {
|
|
1041
|
+
var entry = entries[index];
|
|
1042
|
+
this.set(entry[0], entry[1]);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// Add methods to `ListCache`.
|
|
1047
|
+
ListCache$4.prototype.clear = listCacheClear;
|
|
1048
|
+
ListCache$4.prototype['delete'] = listCacheDelete;
|
|
1049
|
+
ListCache$4.prototype.get = listCacheGet;
|
|
1050
|
+
ListCache$4.prototype.has = listCacheHas;
|
|
1051
|
+
ListCache$4.prototype.set = listCacheSet;
|
|
1052
|
+
var _ListCache = ListCache$4;
|
|
1053
|
+
var ListCache$3 = _ListCache;
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Removes all key-value entries from the stack.
|
|
1057
|
+
*
|
|
1058
|
+
* @private
|
|
1059
|
+
* @name clear
|
|
1060
|
+
* @memberOf Stack
|
|
1061
|
+
*/
|
|
1062
|
+
function stackClear$1() {
|
|
1063
|
+
this.__data__ = new ListCache$3();
|
|
1064
|
+
this.size = 0;
|
|
1065
|
+
}
|
|
1066
|
+
var _stackClear = stackClear$1;
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Removes `key` and its value from the stack.
|
|
1070
|
+
*
|
|
1071
|
+
* @private
|
|
1072
|
+
* @name delete
|
|
1073
|
+
* @memberOf Stack
|
|
1074
|
+
* @param {string} key The key of the value to remove.
|
|
1075
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1076
|
+
*/
|
|
1077
|
+
|
|
1078
|
+
function stackDelete$1(key) {
|
|
1079
|
+
var data = this.__data__,
|
|
1080
|
+
result = data['delete'](key);
|
|
1081
|
+
this.size = data.size;
|
|
1082
|
+
return result;
|
|
1083
|
+
}
|
|
1084
|
+
var _stackDelete = stackDelete$1;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Gets the stack value for `key`.
|
|
1088
|
+
*
|
|
1089
|
+
* @private
|
|
1090
|
+
* @name get
|
|
1091
|
+
* @memberOf Stack
|
|
1092
|
+
* @param {string} key The key of the value to get.
|
|
1093
|
+
* @returns {*} Returns the entry value.
|
|
1094
|
+
*/
|
|
1095
|
+
|
|
1096
|
+
function stackGet$1(key) {
|
|
1097
|
+
return this.__data__.get(key);
|
|
1098
|
+
}
|
|
1099
|
+
var _stackGet = stackGet$1;
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Checks if a stack value for `key` exists.
|
|
1103
|
+
*
|
|
1104
|
+
* @private
|
|
1105
|
+
* @name has
|
|
1106
|
+
* @memberOf Stack
|
|
1107
|
+
* @param {string} key The key of the entry to check.
|
|
1108
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1109
|
+
*/
|
|
1110
|
+
|
|
1111
|
+
function stackHas$1(key) {
|
|
1112
|
+
return this.__data__.has(key);
|
|
1113
|
+
}
|
|
1114
|
+
var _stackHas = stackHas$1;
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Checks if `value` is the
|
|
1118
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
1119
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
1120
|
+
*
|
|
1121
|
+
* @static
|
|
1122
|
+
* @memberOf _
|
|
1123
|
+
* @since 0.1.0
|
|
1124
|
+
* @category Lang
|
|
1125
|
+
* @param {*} value The value to check.
|
|
1126
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
1127
|
+
* @example
|
|
1128
|
+
*
|
|
1129
|
+
* _.isObject({});
|
|
1130
|
+
* // => true
|
|
1131
|
+
*
|
|
1132
|
+
* _.isObject([1, 2, 3]);
|
|
1133
|
+
* // => true
|
|
1134
|
+
*
|
|
1135
|
+
* _.isObject(_.noop);
|
|
1136
|
+
* // => true
|
|
1137
|
+
*
|
|
1138
|
+
* _.isObject(null);
|
|
1139
|
+
* // => false
|
|
1140
|
+
*/
|
|
1141
|
+
|
|
1142
|
+
function isObject$2(value) {
|
|
1143
|
+
var type = typeof value;
|
|
1144
|
+
return value != null && (type == 'object' || type == 'function');
|
|
1145
|
+
}
|
|
1146
|
+
var isObject_1 = isObject$2;
|
|
1147
|
+
var baseGetTag$1 = _baseGetTag,
|
|
1148
|
+
isObject$1 = isObject_1;
|
|
1149
|
+
|
|
1150
|
+
/** `Object#toString` result references. */
|
|
1151
|
+
var asyncTag = '[object AsyncFunction]',
|
|
1152
|
+
funcTag = '[object Function]',
|
|
1153
|
+
genTag = '[object GeneratorFunction]',
|
|
1154
|
+
proxyTag = '[object Proxy]';
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Checks if `value` is classified as a `Function` object.
|
|
1158
|
+
*
|
|
1159
|
+
* @static
|
|
1160
|
+
* @memberOf _
|
|
1161
|
+
* @since 0.1.0
|
|
1162
|
+
* @category Lang
|
|
1163
|
+
* @param {*} value The value to check.
|
|
1164
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
1165
|
+
* @example
|
|
1166
|
+
*
|
|
1167
|
+
* _.isFunction(_);
|
|
1168
|
+
* // => true
|
|
1169
|
+
*
|
|
1170
|
+
* _.isFunction(/abc/);
|
|
1171
|
+
* // => false
|
|
1172
|
+
*/
|
|
1173
|
+
function isFunction$1(value) {
|
|
1174
|
+
if (!isObject$1(value)) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
1178
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
1179
|
+
var tag = baseGetTag$1(value);
|
|
1180
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
1181
|
+
}
|
|
1182
|
+
var isFunction_1 = isFunction$1;
|
|
1183
|
+
var root$5 = _root;
|
|
1184
|
+
|
|
1185
|
+
/** Used to detect overreaching core-js shims. */
|
|
1186
|
+
var coreJsData$1 = root$5['__core-js_shared__'];
|
|
1187
|
+
var _coreJsData = coreJsData$1;
|
|
1188
|
+
var coreJsData = _coreJsData;
|
|
1189
|
+
|
|
1190
|
+
/** Used to detect methods masquerading as native. */
|
|
1191
|
+
var maskSrcKey = function () {
|
|
1192
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
1193
|
+
return uid ? 'Symbol(src)_1.' + uid : '';
|
|
1194
|
+
}();
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* Checks if `func` has its source masked.
|
|
1198
|
+
*
|
|
1199
|
+
* @private
|
|
1200
|
+
* @param {Function} func The function to check.
|
|
1201
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
1202
|
+
*/
|
|
1203
|
+
function isMasked$1(func) {
|
|
1204
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
1205
|
+
}
|
|
1206
|
+
var _isMasked = isMasked$1;
|
|
1207
|
+
|
|
1208
|
+
/** Used for built-in method references. */
|
|
1209
|
+
|
|
1210
|
+
var funcProto$1 = Function.prototype;
|
|
1211
|
+
|
|
1212
|
+
/** Used to resolve the decompiled source of functions. */
|
|
1213
|
+
var funcToString$1 = funcProto$1.toString;
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* Converts `func` to its source code.
|
|
1217
|
+
*
|
|
1218
|
+
* @private
|
|
1219
|
+
* @param {Function} func The function to convert.
|
|
1220
|
+
* @returns {string} Returns the source code.
|
|
1221
|
+
*/
|
|
1222
|
+
function toSource$2(func) {
|
|
1223
|
+
if (func != null) {
|
|
1224
|
+
try {
|
|
1225
|
+
return funcToString$1.call(func);
|
|
1226
|
+
} catch (e) {}
|
|
1227
|
+
try {
|
|
1228
|
+
return func + '';
|
|
1229
|
+
} catch (e) {}
|
|
1230
|
+
}
|
|
1231
|
+
return '';
|
|
1232
|
+
}
|
|
1233
|
+
var _toSource = toSource$2;
|
|
1234
|
+
var isFunction = isFunction_1,
|
|
1235
|
+
isMasked = _isMasked,
|
|
1236
|
+
isObject = isObject_1,
|
|
1237
|
+
toSource$1 = _toSource;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Used to match `RegExp`
|
|
1241
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
1242
|
+
*/
|
|
1243
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
1244
|
+
|
|
1245
|
+
/** Used to detect host constructors (Safari). */
|
|
1246
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1247
|
+
|
|
1248
|
+
/** Used for built-in method references. */
|
|
1249
|
+
var funcProto = Function.prototype,
|
|
1250
|
+
objectProto$2 = Object.prototype;
|
|
1251
|
+
|
|
1252
|
+
/** Used to resolve the decompiled source of functions. */
|
|
1253
|
+
var funcToString = funcProto.toString;
|
|
1254
|
+
|
|
1255
|
+
/** Used to check objects for own properties. */
|
|
1256
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
1257
|
+
|
|
1258
|
+
/** Used to detect if a method is native. */
|
|
1259
|
+
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
1263
|
+
*
|
|
1264
|
+
* @private
|
|
1265
|
+
* @param {*} value The value to check.
|
|
1266
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
1267
|
+
* else `false`.
|
|
1268
|
+
*/
|
|
1269
|
+
function baseIsNative$1(value) {
|
|
1270
|
+
if (!isObject(value) || isMasked(value)) {
|
|
1271
|
+
return false;
|
|
1272
|
+
}
|
|
1273
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
1274
|
+
return pattern.test(toSource$1(value));
|
|
1275
|
+
}
|
|
1276
|
+
var _baseIsNative = baseIsNative$1;
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Gets the value at `key` of `object`.
|
|
1280
|
+
*
|
|
1281
|
+
* @private
|
|
1282
|
+
* @param {Object} [object] The object to query.
|
|
1283
|
+
* @param {string} key The key of the property to get.
|
|
1284
|
+
* @returns {*} Returns the property value.
|
|
1285
|
+
*/
|
|
1286
|
+
|
|
1287
|
+
function getValue$1(object, key) {
|
|
1288
|
+
return object == null ? undefined : object[key];
|
|
1289
|
+
}
|
|
1290
|
+
var _getValue = getValue$1;
|
|
1291
|
+
var baseIsNative = _baseIsNative,
|
|
1292
|
+
getValue = _getValue;
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Gets the native function at `key` of `object`.
|
|
1296
|
+
*
|
|
1297
|
+
* @private
|
|
1298
|
+
* @param {Object} object The object to query.
|
|
1299
|
+
* @param {string} key The key of the method to get.
|
|
1300
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
1301
|
+
*/
|
|
1302
|
+
function getNative$6(object, key) {
|
|
1303
|
+
var value = getValue(object, key);
|
|
1304
|
+
return baseIsNative(value) ? value : undefined;
|
|
1305
|
+
}
|
|
1306
|
+
var _getNative = getNative$6;
|
|
1307
|
+
var getNative$5 = _getNative,
|
|
1308
|
+
root$4 = _root;
|
|
1309
|
+
|
|
1310
|
+
/* Built-in method references that are verified to be native. */
|
|
1311
|
+
var Map$4 = getNative$5(root$4, 'Map');
|
|
1312
|
+
var _Map = Map$4;
|
|
1313
|
+
var getNative$4 = _getNative;
|
|
1314
|
+
|
|
1315
|
+
/* Built-in method references that are verified to be native. */
|
|
1316
|
+
var nativeCreate$4 = getNative$4(Object, 'create');
|
|
1317
|
+
var _nativeCreate = nativeCreate$4;
|
|
1318
|
+
var nativeCreate$3 = _nativeCreate;
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Removes all key-value entries from the hash.
|
|
1322
|
+
*
|
|
1323
|
+
* @private
|
|
1324
|
+
* @name clear
|
|
1325
|
+
* @memberOf Hash
|
|
1326
|
+
*/
|
|
1327
|
+
function hashClear$1() {
|
|
1328
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
1329
|
+
this.size = 0;
|
|
1330
|
+
}
|
|
1331
|
+
var _hashClear = hashClear$1;
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Removes `key` and its value from the hash.
|
|
1335
|
+
*
|
|
1336
|
+
* @private
|
|
1337
|
+
* @name delete
|
|
1338
|
+
* @memberOf Hash
|
|
1339
|
+
* @param {Object} hash The hash to modify.
|
|
1340
|
+
* @param {string} key The key of the value to remove.
|
|
1341
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1342
|
+
*/
|
|
1343
|
+
|
|
1344
|
+
function hashDelete$1(key) {
|
|
1345
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
1346
|
+
this.size -= result ? 1 : 0;
|
|
1347
|
+
return result;
|
|
1348
|
+
}
|
|
1349
|
+
var _hashDelete = hashDelete$1;
|
|
1350
|
+
var nativeCreate$2 = _nativeCreate;
|
|
1351
|
+
|
|
1352
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1353
|
+
var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
|
|
1354
|
+
|
|
1355
|
+
/** Used for built-in method references. */
|
|
1356
|
+
var objectProto$1 = Object.prototype;
|
|
1357
|
+
|
|
1358
|
+
/** Used to check objects for own properties. */
|
|
1359
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Gets the hash value for `key`.
|
|
1363
|
+
*
|
|
1364
|
+
* @private
|
|
1365
|
+
* @name get
|
|
1366
|
+
* @memberOf Hash
|
|
1367
|
+
* @param {string} key The key of the value to get.
|
|
1368
|
+
* @returns {*} Returns the entry value.
|
|
1369
|
+
*/
|
|
1370
|
+
function hashGet$1(key) {
|
|
1371
|
+
var data = this.__data__;
|
|
1372
|
+
if (nativeCreate$2) {
|
|
1373
|
+
var result = data[key];
|
|
1374
|
+
return result === HASH_UNDEFINED$2 ? undefined : result;
|
|
1375
|
+
}
|
|
1376
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
|
|
1377
|
+
}
|
|
1378
|
+
var _hashGet = hashGet$1;
|
|
1379
|
+
var nativeCreate$1 = _nativeCreate;
|
|
1380
|
+
|
|
1381
|
+
/** Used for built-in method references. */
|
|
1382
|
+
var objectProto = Object.prototype;
|
|
1383
|
+
|
|
1384
|
+
/** Used to check objects for own properties. */
|
|
1385
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Checks if a hash value for `key` exists.
|
|
1389
|
+
*
|
|
1390
|
+
* @private
|
|
1391
|
+
* @name has
|
|
1392
|
+
* @memberOf Hash
|
|
1393
|
+
* @param {string} key The key of the entry to check.
|
|
1394
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1395
|
+
*/
|
|
1396
|
+
function hashHas$1(key) {
|
|
1397
|
+
var data = this.__data__;
|
|
1398
|
+
return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
|
1399
|
+
}
|
|
1400
|
+
var _hashHas = hashHas$1;
|
|
1401
|
+
var nativeCreate = _nativeCreate;
|
|
1402
|
+
|
|
1403
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1404
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* Sets the hash `key` to `value`.
|
|
1408
|
+
*
|
|
1409
|
+
* @private
|
|
1410
|
+
* @name set
|
|
1411
|
+
* @memberOf Hash
|
|
1412
|
+
* @param {string} key The key of the value to set.
|
|
1413
|
+
* @param {*} value The value to set.
|
|
1414
|
+
* @returns {Object} Returns the hash instance.
|
|
1415
|
+
*/
|
|
1416
|
+
function hashSet$1(key, value) {
|
|
1417
|
+
var data = this.__data__;
|
|
1418
|
+
this.size += this.has(key) ? 0 : 1;
|
|
1419
|
+
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
|
|
1420
|
+
return this;
|
|
1421
|
+
}
|
|
1422
|
+
var _hashSet = hashSet$1;
|
|
1423
|
+
var hashClear = _hashClear,
|
|
1424
|
+
hashDelete = _hashDelete,
|
|
1425
|
+
hashGet = _hashGet,
|
|
1426
|
+
hashHas = _hashHas,
|
|
1427
|
+
hashSet = _hashSet;
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* Creates a hash object.
|
|
1431
|
+
*
|
|
1432
|
+
* @private
|
|
1433
|
+
* @constructor
|
|
1434
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1435
|
+
*/
|
|
1436
|
+
function Hash$1(entries) {
|
|
1437
|
+
var index = -1,
|
|
1438
|
+
length = entries == null ? 0 : entries.length;
|
|
1439
|
+
this.clear();
|
|
1440
|
+
while (++index < length) {
|
|
1441
|
+
var entry = entries[index];
|
|
1442
|
+
this.set(entry[0], entry[1]);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// Add methods to `Hash`.
|
|
1447
|
+
Hash$1.prototype.clear = hashClear;
|
|
1448
|
+
Hash$1.prototype['delete'] = hashDelete;
|
|
1449
|
+
Hash$1.prototype.get = hashGet;
|
|
1450
|
+
Hash$1.prototype.has = hashHas;
|
|
1451
|
+
Hash$1.prototype.set = hashSet;
|
|
1452
|
+
var _Hash = Hash$1;
|
|
1453
|
+
var Hash = _Hash,
|
|
1454
|
+
ListCache$2 = _ListCache,
|
|
1455
|
+
Map$3 = _Map;
|
|
1456
|
+
|
|
1457
|
+
/**
|
|
1458
|
+
* Removes all key-value entries from the map.
|
|
1459
|
+
*
|
|
1460
|
+
* @private
|
|
1461
|
+
* @name clear
|
|
1462
|
+
* @memberOf MapCache
|
|
1463
|
+
*/
|
|
1464
|
+
function mapCacheClear$1() {
|
|
1465
|
+
this.size = 0;
|
|
1466
|
+
this.__data__ = {
|
|
1467
|
+
'hash': new Hash(),
|
|
1468
|
+
'map': new (Map$3 || ListCache$2)(),
|
|
1469
|
+
'string': new Hash()
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
1473
|
+
|
|
1474
|
+
/**
|
|
1475
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
1476
|
+
*
|
|
1477
|
+
* @private
|
|
1478
|
+
* @param {*} value The value to check.
|
|
1479
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
1480
|
+
*/
|
|
1481
|
+
|
|
1482
|
+
function isKeyable$1(value) {
|
|
1483
|
+
var type = typeof value;
|
|
1484
|
+
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
|
1485
|
+
}
|
|
1486
|
+
var _isKeyable = isKeyable$1;
|
|
1487
|
+
var isKeyable = _isKeyable;
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* Gets the data for `map`.
|
|
1491
|
+
*
|
|
1492
|
+
* @private
|
|
1493
|
+
* @param {Object} map The map to query.
|
|
1494
|
+
* @param {string} key The reference key.
|
|
1495
|
+
* @returns {*} Returns the map data.
|
|
1496
|
+
*/
|
|
1497
|
+
function getMapData$4(map, key) {
|
|
1498
|
+
var data = map.__data__;
|
|
1499
|
+
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
|
1500
|
+
}
|
|
1501
|
+
var _getMapData = getMapData$4;
|
|
1502
|
+
var getMapData$3 = _getMapData;
|
|
1503
|
+
|
|
1504
|
+
/**
|
|
1505
|
+
* Removes `key` and its value from the map.
|
|
1506
|
+
*
|
|
1507
|
+
* @private
|
|
1508
|
+
* @name delete
|
|
1509
|
+
* @memberOf MapCache
|
|
1510
|
+
* @param {string} key The key of the value to remove.
|
|
1511
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
1512
|
+
*/
|
|
1513
|
+
function mapCacheDelete$1(key) {
|
|
1514
|
+
var result = getMapData$3(this, key)['delete'](key);
|
|
1515
|
+
this.size -= result ? 1 : 0;
|
|
1516
|
+
return result;
|
|
1517
|
+
}
|
|
1518
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
1519
|
+
var getMapData$2 = _getMapData;
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Gets the map value for `key`.
|
|
1523
|
+
*
|
|
1524
|
+
* @private
|
|
1525
|
+
* @name get
|
|
1526
|
+
* @memberOf MapCache
|
|
1527
|
+
* @param {string} key The key of the value to get.
|
|
1528
|
+
* @returns {*} Returns the entry value.
|
|
1529
|
+
*/
|
|
1530
|
+
function mapCacheGet$1(key) {
|
|
1531
|
+
return getMapData$2(this, key).get(key);
|
|
1532
|
+
}
|
|
1533
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
1534
|
+
var getMapData$1 = _getMapData;
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Checks if a map value for `key` exists.
|
|
1538
|
+
*
|
|
1539
|
+
* @private
|
|
1540
|
+
* @name has
|
|
1541
|
+
* @memberOf MapCache
|
|
1542
|
+
* @param {string} key The key of the entry to check.
|
|
1543
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
1544
|
+
*/
|
|
1545
|
+
function mapCacheHas$1(key) {
|
|
1546
|
+
return getMapData$1(this, key).has(key);
|
|
1547
|
+
}
|
|
1548
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
1549
|
+
var getMapData = _getMapData;
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* Sets the map `key` to `value`.
|
|
1553
|
+
*
|
|
1554
|
+
* @private
|
|
1555
|
+
* @name set
|
|
1556
|
+
* @memberOf MapCache
|
|
1557
|
+
* @param {string} key The key of the value to set.
|
|
1558
|
+
* @param {*} value The value to set.
|
|
1559
|
+
* @returns {Object} Returns the map cache instance.
|
|
1560
|
+
*/
|
|
1561
|
+
function mapCacheSet$1(key, value) {
|
|
1562
|
+
var data = getMapData(this, key),
|
|
1563
|
+
size = data.size;
|
|
1564
|
+
data.set(key, value);
|
|
1565
|
+
this.size += data.size == size ? 0 : 1;
|
|
1566
|
+
return this;
|
|
1567
|
+
}
|
|
1568
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
1569
|
+
var mapCacheClear = _mapCacheClear,
|
|
1570
|
+
mapCacheDelete = _mapCacheDelete,
|
|
1571
|
+
mapCacheGet = _mapCacheGet,
|
|
1572
|
+
mapCacheHas = _mapCacheHas,
|
|
1573
|
+
mapCacheSet = _mapCacheSet;
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Creates a map cache object to store key-value pairs.
|
|
1577
|
+
*
|
|
1578
|
+
* @private
|
|
1579
|
+
* @constructor
|
|
1580
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1581
|
+
*/
|
|
1582
|
+
function MapCache$2(entries) {
|
|
1583
|
+
var index = -1,
|
|
1584
|
+
length = entries == null ? 0 : entries.length;
|
|
1585
|
+
this.clear();
|
|
1586
|
+
while (++index < length) {
|
|
1587
|
+
var entry = entries[index];
|
|
1588
|
+
this.set(entry[0], entry[1]);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
// Add methods to `MapCache`.
|
|
1593
|
+
MapCache$2.prototype.clear = mapCacheClear;
|
|
1594
|
+
MapCache$2.prototype['delete'] = mapCacheDelete;
|
|
1595
|
+
MapCache$2.prototype.get = mapCacheGet;
|
|
1596
|
+
MapCache$2.prototype.has = mapCacheHas;
|
|
1597
|
+
MapCache$2.prototype.set = mapCacheSet;
|
|
1598
|
+
var _MapCache = MapCache$2;
|
|
1599
|
+
var ListCache$1 = _ListCache,
|
|
1600
|
+
Map$2 = _Map,
|
|
1601
|
+
MapCache$1 = _MapCache;
|
|
1602
|
+
|
|
1603
|
+
/** Used as the size to enable large array optimizations. */
|
|
1604
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Sets the stack `key` to `value`.
|
|
1608
|
+
*
|
|
1609
|
+
* @private
|
|
1610
|
+
* @name set
|
|
1611
|
+
* @memberOf Stack
|
|
1612
|
+
* @param {string} key The key of the value to set.
|
|
1613
|
+
* @param {*} value The value to set.
|
|
1614
|
+
* @returns {Object} Returns the stack cache instance.
|
|
1615
|
+
*/
|
|
1616
|
+
function stackSet$1(key, value) {
|
|
1617
|
+
var data = this.__data__;
|
|
1618
|
+
if (data instanceof ListCache$1) {
|
|
1619
|
+
var pairs = data.__data__;
|
|
1620
|
+
if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
1621
|
+
pairs.push([key, value]);
|
|
1622
|
+
this.size = ++data.size;
|
|
1623
|
+
return this;
|
|
1624
|
+
}
|
|
1625
|
+
data = this.__data__ = new MapCache$1(pairs);
|
|
1626
|
+
}
|
|
1627
|
+
data.set(key, value);
|
|
1628
|
+
this.size = data.size;
|
|
1629
|
+
return this;
|
|
1630
|
+
}
|
|
1631
|
+
var _stackSet = stackSet$1;
|
|
1632
|
+
var ListCache = _ListCache,
|
|
1633
|
+
stackClear = _stackClear,
|
|
1634
|
+
stackDelete = _stackDelete,
|
|
1635
|
+
stackGet = _stackGet,
|
|
1636
|
+
stackHas = _stackHas,
|
|
1637
|
+
stackSet = _stackSet;
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Creates a stack cache object to store key-value pairs.
|
|
1641
|
+
*
|
|
1642
|
+
* @private
|
|
1643
|
+
* @constructor
|
|
1644
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
1645
|
+
*/
|
|
1646
|
+
function Stack(entries) {
|
|
1647
|
+
var data = this.__data__ = new ListCache(entries);
|
|
1648
|
+
this.size = data.size;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// Add methods to `Stack`.
|
|
1652
|
+
Stack.prototype.clear = stackClear;
|
|
1653
|
+
Stack.prototype['delete'] = stackDelete;
|
|
1654
|
+
Stack.prototype.get = stackGet;
|
|
1655
|
+
Stack.prototype.has = stackHas;
|
|
1656
|
+
Stack.prototype.set = stackSet;
|
|
1657
|
+
|
|
1658
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
1659
|
+
|
|
1660
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Adds `value` to the array cache.
|
|
1664
|
+
*
|
|
1665
|
+
* @private
|
|
1666
|
+
* @name add
|
|
1667
|
+
* @memberOf SetCache
|
|
1668
|
+
* @alias push
|
|
1669
|
+
* @param {*} value The value to cache.
|
|
1670
|
+
* @returns {Object} Returns the cache instance.
|
|
1671
|
+
*/
|
|
1672
|
+
function setCacheAdd$1(value) {
|
|
1673
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
1674
|
+
return this;
|
|
1675
|
+
}
|
|
1676
|
+
var _setCacheAdd = setCacheAdd$1;
|
|
1677
|
+
|
|
1678
|
+
/**
|
|
1679
|
+
* Checks if `value` is in the array cache.
|
|
1680
|
+
*
|
|
1681
|
+
* @private
|
|
1682
|
+
* @name has
|
|
1683
|
+
* @memberOf SetCache
|
|
1684
|
+
* @param {*} value The value to search for.
|
|
1685
|
+
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
1686
|
+
*/
|
|
1687
|
+
|
|
1688
|
+
function setCacheHas$1(value) {
|
|
1689
|
+
return this.__data__.has(value);
|
|
1690
|
+
}
|
|
1691
|
+
var _setCacheHas = setCacheHas$1;
|
|
1692
|
+
var MapCache = _MapCache,
|
|
1693
|
+
setCacheAdd = _setCacheAdd,
|
|
1694
|
+
setCacheHas = _setCacheHas;
|
|
1695
|
+
|
|
1696
|
+
/**
|
|
1697
|
+
*
|
|
1698
|
+
* Creates an array cache object to store unique values.
|
|
1699
|
+
*
|
|
1700
|
+
* @private
|
|
1701
|
+
* @constructor
|
|
1702
|
+
* @param {Array} [values] The values to cache.
|
|
1703
|
+
*/
|
|
1704
|
+
function SetCache(values) {
|
|
1705
|
+
var index = -1,
|
|
1706
|
+
length = values == null ? 0 : values.length;
|
|
1707
|
+
this.__data__ = new MapCache();
|
|
1708
|
+
while (++index < length) {
|
|
1709
|
+
this.add(values[index]);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
// Add methods to `SetCache`.
|
|
1714
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
1715
|
+
SetCache.prototype.has = setCacheHas;
|
|
1716
|
+
var isBuffer = {
|
|
1717
|
+
exports: {}
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* This method returns `false`.
|
|
1722
|
+
*
|
|
1723
|
+
* @static
|
|
1724
|
+
* @memberOf _
|
|
1725
|
+
* @since 4.13.0
|
|
1726
|
+
* @category Util
|
|
1727
|
+
* @returns {boolean} Returns `false`.
|
|
1728
|
+
* @example
|
|
1729
|
+
*
|
|
1730
|
+
* _.times(2, _.stubFalse);
|
|
1731
|
+
* // => [false, false]
|
|
1732
|
+
*/
|
|
1733
|
+
|
|
1734
|
+
function stubFalse() {
|
|
1735
|
+
return false;
|
|
1736
|
+
}
|
|
1737
|
+
var stubFalse_1 = stubFalse;
|
|
1738
|
+
(function (module, exports) {
|
|
1739
|
+
var root = _root,
|
|
1740
|
+
stubFalse = stubFalse_1;
|
|
1741
|
+
|
|
1742
|
+
/** Detect free variable `exports`. */
|
|
1743
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
1744
|
+
|
|
1745
|
+
/** Detect free variable `module`. */
|
|
1746
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
1747
|
+
|
|
1748
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1749
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1750
|
+
|
|
1751
|
+
/** Built-in value references. */
|
|
1752
|
+
var Buffer = moduleExports ? root.Buffer : undefined;
|
|
1753
|
+
|
|
1754
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1755
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* Checks if `value` is a buffer.
|
|
1759
|
+
*
|
|
1760
|
+
* @static
|
|
1761
|
+
* @memberOf _
|
|
1762
|
+
* @since 4.3.0
|
|
1763
|
+
* @category Lang
|
|
1764
|
+
* @param {*} value The value to check.
|
|
1765
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
1766
|
+
* @example
|
|
1767
|
+
*
|
|
1768
|
+
* _.isBuffer(new Buffer(2));
|
|
1769
|
+
* // => true
|
|
1770
|
+
*
|
|
1771
|
+
* _.isBuffer(new Uint8Array(2));
|
|
1772
|
+
* // => false
|
|
1773
|
+
*/
|
|
1774
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1775
|
+
module.exports = isBuffer;
|
|
1776
|
+
})(isBuffer, isBuffer.exports);
|
|
1777
|
+
var _nodeUtil = {
|
|
1778
|
+
exports: {}
|
|
1779
|
+
};
|
|
1780
|
+
(function (module, exports) {
|
|
1781
|
+
var freeGlobal = _freeGlobal;
|
|
1782
|
+
|
|
1783
|
+
/** Detect free variable `exports`. */
|
|
1784
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
1785
|
+
|
|
1786
|
+
/** Detect free variable `module`. */
|
|
1787
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
1788
|
+
|
|
1789
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1790
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1791
|
+
|
|
1792
|
+
/** Detect free variable `process` from Node.js. */
|
|
1793
|
+
var freeProcess = moduleExports && freeGlobal.process;
|
|
1794
|
+
|
|
1795
|
+
/** Used to access faster Node.js helpers. */
|
|
1796
|
+
var nodeUtil = function () {
|
|
1797
|
+
try {
|
|
1798
|
+
// Use `util.types` for Node.js 10+.
|
|
1799
|
+
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
1800
|
+
if (types) {
|
|
1801
|
+
return types;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
// Legacy `process.binding('util')` for Node.js < 10.
|
|
1805
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
1806
|
+
} catch (e) {}
|
|
1807
|
+
}();
|
|
1808
|
+
module.exports = nodeUtil;
|
|
1809
|
+
})(_nodeUtil, _nodeUtil.exports);
|
|
1810
|
+
var getNative$3 = _getNative,
|
|
1811
|
+
root$3 = _root;
|
|
1812
|
+
|
|
1813
|
+
/* Built-in method references that are verified to be native. */
|
|
1814
|
+
var DataView$1 = getNative$3(root$3, 'DataView');
|
|
1815
|
+
var _DataView = DataView$1;
|
|
1816
|
+
var getNative$2 = _getNative,
|
|
1817
|
+
root$2 = _root;
|
|
1818
|
+
|
|
1819
|
+
/* Built-in method references that are verified to be native. */
|
|
1820
|
+
var Promise$2 = getNative$2(root$2, 'Promise');
|
|
1821
|
+
var _Promise = Promise$2;
|
|
1822
|
+
var getNative$1 = _getNative,
|
|
1823
|
+
root$1 = _root;
|
|
1824
|
+
|
|
1825
|
+
/* Built-in method references that are verified to be native. */
|
|
1826
|
+
var Set$1 = getNative$1(root$1, 'Set');
|
|
1827
|
+
var _Set = Set$1;
|
|
1828
|
+
var getNative = _getNative,
|
|
1829
|
+
root = _root;
|
|
1830
|
+
|
|
1831
|
+
/* Built-in method references that are verified to be native. */
|
|
1832
|
+
var WeakMap$1 = getNative(root, 'WeakMap');
|
|
1833
|
+
var _WeakMap = WeakMap$1;
|
|
1834
|
+
var DataView = _DataView,
|
|
1835
|
+
Map$1 = _Map,
|
|
1836
|
+
Promise$1 = _Promise,
|
|
1837
|
+
Set = _Set,
|
|
1838
|
+
WeakMap = _WeakMap,
|
|
1839
|
+
baseGetTag = _baseGetTag,
|
|
1840
|
+
toSource = _toSource;
|
|
1841
|
+
|
|
1842
|
+
/** `Object#toString` result references. */
|
|
1843
|
+
var mapTag = '[object Map]',
|
|
1844
|
+
objectTag = '[object Object]',
|
|
1845
|
+
promiseTag = '[object Promise]',
|
|
1846
|
+
setTag = '[object Set]',
|
|
1847
|
+
weakMapTag = '[object WeakMap]';
|
|
1848
|
+
var dataViewTag = '[object DataView]';
|
|
1849
|
+
|
|
1850
|
+
/** Used to detect maps, sets, and weakmaps. */
|
|
1851
|
+
var dataViewCtorString = toSource(DataView),
|
|
1852
|
+
mapCtorString = toSource(Map$1),
|
|
1853
|
+
promiseCtorString = toSource(Promise$1),
|
|
1854
|
+
setCtorString = toSource(Set),
|
|
1855
|
+
weakMapCtorString = toSource(WeakMap);
|
|
1856
|
+
|
|
1857
|
+
/**
|
|
1858
|
+
* Gets the `toStringTag` of `value`.
|
|
1859
|
+
*
|
|
1860
|
+
* @private
|
|
1861
|
+
* @param {*} value The value to query.
|
|
1862
|
+
* @returns {string} Returns the `toStringTag`.
|
|
1863
|
+
*/
|
|
1864
|
+
var getTag = baseGetTag;
|
|
1865
|
+
|
|
1866
|
+
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
1867
|
+
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag(new Map$1()) != mapTag || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) {
|
|
1868
|
+
getTag = function (value) {
|
|
1869
|
+
var result = baseGetTag(value),
|
|
1870
|
+
Ctor = result == objectTag ? value.constructor : undefined,
|
|
1871
|
+
ctorString = Ctor ? toSource(Ctor) : '';
|
|
1872
|
+
if (ctorString) {
|
|
1873
|
+
switch (ctorString) {
|
|
1874
|
+
case dataViewCtorString:
|
|
1875
|
+
return dataViewTag;
|
|
1876
|
+
case mapCtorString:
|
|
1877
|
+
return mapTag;
|
|
1878
|
+
case promiseCtorString:
|
|
1879
|
+
return promiseTag;
|
|
1880
|
+
case setCtorString:
|
|
1881
|
+
return setTag;
|
|
1882
|
+
case weakMapCtorString:
|
|
1883
|
+
return weakMapTag;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
return result;
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
var src = {
|
|
1890
|
+
exports: {}
|
|
1891
|
+
};
|
|
1892
|
+
var browser = {
|
|
1893
|
+
exports: {}
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Helpers.
|
|
1898
|
+
*/
|
|
1899
|
+
|
|
1900
|
+
var ms;
|
|
1901
|
+
var hasRequiredMs;
|
|
1902
|
+
function requireMs() {
|
|
1903
|
+
if (hasRequiredMs) return ms;
|
|
1904
|
+
hasRequiredMs = 1;
|
|
1905
|
+
var s = 1000;
|
|
1906
|
+
var m = s * 60;
|
|
1907
|
+
var h = m * 60;
|
|
1908
|
+
var d = h * 24;
|
|
1909
|
+
var w = d * 7;
|
|
1910
|
+
var y = d * 365.25;
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Parse or format the given `val`.
|
|
1914
|
+
*
|
|
1915
|
+
* Options:
|
|
1916
|
+
*
|
|
1917
|
+
* - `long` verbose formatting [false]
|
|
1918
|
+
*
|
|
1919
|
+
* @param {String|Number} val
|
|
1920
|
+
* @param {Object} [options]
|
|
1921
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
1922
|
+
* @return {String|Number}
|
|
1923
|
+
* @api public
|
|
1924
|
+
*/
|
|
1925
|
+
|
|
1926
|
+
ms = function (val, options) {
|
|
1927
|
+
options = options || {};
|
|
1928
|
+
var type = typeof val;
|
|
1929
|
+
if (type === 'string' && val.length > 0) {
|
|
1930
|
+
return parse(val);
|
|
1931
|
+
} else if (type === 'number' && isFinite(val)) {
|
|
1932
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
1933
|
+
}
|
|
1934
|
+
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Parse the given `str` and return milliseconds.
|
|
1939
|
+
*
|
|
1940
|
+
* @param {String} str
|
|
1941
|
+
* @return {Number}
|
|
1942
|
+
* @api private
|
|
1943
|
+
*/
|
|
1944
|
+
|
|
1945
|
+
function parse(str) {
|
|
1946
|
+
str = String(str);
|
|
1947
|
+
if (str.length > 100) {
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
1951
|
+
if (!match) {
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
var n = parseFloat(match[1]);
|
|
1955
|
+
var type = (match[2] || 'ms').toLowerCase();
|
|
1956
|
+
switch (type) {
|
|
1957
|
+
case 'years':
|
|
1958
|
+
case 'year':
|
|
1959
|
+
case 'yrs':
|
|
1960
|
+
case 'yr':
|
|
1961
|
+
case 'y':
|
|
1962
|
+
return n * y;
|
|
1963
|
+
case 'weeks':
|
|
1964
|
+
case 'week':
|
|
1965
|
+
case 'w':
|
|
1966
|
+
return n * w;
|
|
1967
|
+
case 'days':
|
|
1968
|
+
case 'day':
|
|
1969
|
+
case 'd':
|
|
1970
|
+
return n * d;
|
|
1971
|
+
case 'hours':
|
|
1972
|
+
case 'hour':
|
|
1973
|
+
case 'hrs':
|
|
1974
|
+
case 'hr':
|
|
1975
|
+
case 'h':
|
|
1976
|
+
return n * h;
|
|
1977
|
+
case 'minutes':
|
|
1978
|
+
case 'minute':
|
|
1979
|
+
case 'mins':
|
|
1980
|
+
case 'min':
|
|
1981
|
+
case 'm':
|
|
1982
|
+
return n * m;
|
|
1983
|
+
case 'seconds':
|
|
1984
|
+
case 'second':
|
|
1985
|
+
case 'secs':
|
|
1986
|
+
case 'sec':
|
|
1987
|
+
case 's':
|
|
1988
|
+
return n * s;
|
|
1989
|
+
case 'milliseconds':
|
|
1990
|
+
case 'millisecond':
|
|
1991
|
+
case 'msecs':
|
|
1992
|
+
case 'msec':
|
|
1993
|
+
case 'ms':
|
|
1994
|
+
return n;
|
|
1995
|
+
default:
|
|
1996
|
+
return undefined;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* Short format for `ms`.
|
|
2002
|
+
*
|
|
2003
|
+
* @param {Number} ms
|
|
2004
|
+
* @return {String}
|
|
2005
|
+
* @api private
|
|
2006
|
+
*/
|
|
2007
|
+
|
|
2008
|
+
function fmtShort(ms) {
|
|
2009
|
+
var msAbs = Math.abs(ms);
|
|
2010
|
+
if (msAbs >= d) {
|
|
2011
|
+
return Math.round(ms / d) + 'd';
|
|
2012
|
+
}
|
|
2013
|
+
if (msAbs >= h) {
|
|
2014
|
+
return Math.round(ms / h) + 'h';
|
|
2015
|
+
}
|
|
2016
|
+
if (msAbs >= m) {
|
|
2017
|
+
return Math.round(ms / m) + 'm';
|
|
2018
|
+
}
|
|
2019
|
+
if (msAbs >= s) {
|
|
2020
|
+
return Math.round(ms / s) + 's';
|
|
2021
|
+
}
|
|
2022
|
+
return ms + 'ms';
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* Long format for `ms`.
|
|
2027
|
+
*
|
|
2028
|
+
* @param {Number} ms
|
|
2029
|
+
* @return {String}
|
|
2030
|
+
* @api private
|
|
2031
|
+
*/
|
|
2032
|
+
|
|
2033
|
+
function fmtLong(ms) {
|
|
2034
|
+
var msAbs = Math.abs(ms);
|
|
2035
|
+
if (msAbs >= d) {
|
|
2036
|
+
return plural(ms, msAbs, d, 'day');
|
|
2037
|
+
}
|
|
2038
|
+
if (msAbs >= h) {
|
|
2039
|
+
return plural(ms, msAbs, h, 'hour');
|
|
2040
|
+
}
|
|
2041
|
+
if (msAbs >= m) {
|
|
2042
|
+
return plural(ms, msAbs, m, 'minute');
|
|
2043
|
+
}
|
|
2044
|
+
if (msAbs >= s) {
|
|
2045
|
+
return plural(ms, msAbs, s, 'second');
|
|
2046
|
+
}
|
|
2047
|
+
return ms + ' ms';
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* Pluralization helper.
|
|
2052
|
+
*/
|
|
2053
|
+
|
|
2054
|
+
function plural(ms, msAbs, n, name) {
|
|
2055
|
+
var isPlural = msAbs >= n * 1.5;
|
|
2056
|
+
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
2057
|
+
}
|
|
2058
|
+
return ms;
|
|
2059
|
+
}
|
|
2060
|
+
var common;
|
|
2061
|
+
var hasRequiredCommon;
|
|
2062
|
+
function requireCommon() {
|
|
2063
|
+
if (hasRequiredCommon) return common;
|
|
2064
|
+
hasRequiredCommon = 1;
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* This is the common logic for both the Node.js and web browser
|
|
2068
|
+
* implementations of `debug()`.
|
|
2069
|
+
*/
|
|
2070
|
+
function setup(env) {
|
|
2071
|
+
createDebug.debug = createDebug;
|
|
2072
|
+
createDebug.default = createDebug;
|
|
2073
|
+
createDebug.coerce = coerce;
|
|
2074
|
+
createDebug.disable = disable;
|
|
2075
|
+
createDebug.enable = enable;
|
|
2076
|
+
createDebug.enabled = enabled;
|
|
2077
|
+
createDebug.humanize = requireMs();
|
|
2078
|
+
Object.keys(env).forEach(function (key) {
|
|
2079
|
+
createDebug[key] = env[key];
|
|
2080
|
+
});
|
|
2081
|
+
/**
|
|
2082
|
+
* Active `debug` instances.
|
|
2083
|
+
*/
|
|
2084
|
+
|
|
2085
|
+
createDebug.instances = [];
|
|
2086
|
+
/**
|
|
2087
|
+
* The currently active debug mode names, and names to skip.
|
|
2088
|
+
*/
|
|
2089
|
+
|
|
2090
|
+
createDebug.names = [];
|
|
2091
|
+
createDebug.skips = [];
|
|
2092
|
+
/**
|
|
2093
|
+
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
2094
|
+
*
|
|
2095
|
+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
2096
|
+
*/
|
|
2097
|
+
|
|
2098
|
+
createDebug.formatters = {};
|
|
2099
|
+
/**
|
|
2100
|
+
* Selects a color for a debug namespace
|
|
2101
|
+
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
|
2102
|
+
* @return {Number|String} An ANSI color code for the given namespace
|
|
2103
|
+
* @api private
|
|
2104
|
+
*/
|
|
2105
|
+
|
|
2106
|
+
function selectColor(namespace) {
|
|
2107
|
+
var hash = 0;
|
|
2108
|
+
for (var i = 0; i < namespace.length; i++) {
|
|
2109
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
2110
|
+
hash |= 0; // Convert to 32bit integer
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
2114
|
+
}
|
|
2115
|
+
createDebug.selectColor = selectColor;
|
|
2116
|
+
/**
|
|
2117
|
+
* Create a debugger with the given `namespace`.
|
|
2118
|
+
*
|
|
2119
|
+
* @param {String} namespace
|
|
2120
|
+
* @return {Function}
|
|
2121
|
+
* @api public
|
|
2122
|
+
*/
|
|
2123
|
+
|
|
2124
|
+
function createDebug(namespace) {
|
|
2125
|
+
var prevTime;
|
|
2126
|
+
function debug() {
|
|
2127
|
+
// Disabled?
|
|
2128
|
+
if (!debug.enabled) {
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2132
|
+
args[_key] = arguments[_key];
|
|
2133
|
+
}
|
|
2134
|
+
var self = debug; // Set `diff` timestamp
|
|
2135
|
+
|
|
2136
|
+
var curr = Number(new Date());
|
|
2137
|
+
var ms = curr - (prevTime || curr);
|
|
2138
|
+
self.diff = ms;
|
|
2139
|
+
self.prev = prevTime;
|
|
2140
|
+
self.curr = curr;
|
|
2141
|
+
prevTime = curr;
|
|
2142
|
+
args[0] = createDebug.coerce(args[0]);
|
|
2143
|
+
if (typeof args[0] !== 'string') {
|
|
2144
|
+
// Anything else let's inspect with %O
|
|
2145
|
+
args.unshift('%O');
|
|
2146
|
+
} // Apply any `formatters` transformations
|
|
2147
|
+
|
|
2148
|
+
var index = 0;
|
|
2149
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
|
|
2150
|
+
// If we encounter an escaped % then don't increase the array index
|
|
2151
|
+
if (match === '%%') {
|
|
2152
|
+
return match;
|
|
2153
|
+
}
|
|
2154
|
+
index++;
|
|
2155
|
+
var formatter = createDebug.formatters[format];
|
|
2156
|
+
if (typeof formatter === 'function') {
|
|
2157
|
+
var val = args[index];
|
|
2158
|
+
match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
|
2159
|
+
|
|
2160
|
+
args.splice(index, 1);
|
|
2161
|
+
index--;
|
|
2162
|
+
}
|
|
2163
|
+
return match;
|
|
2164
|
+
}); // Apply env-specific formatting (colors, etc.)
|
|
2165
|
+
|
|
2166
|
+
createDebug.formatArgs.call(self, args);
|
|
2167
|
+
var logFn = self.log || createDebug.log;
|
|
2168
|
+
logFn.apply(self, args);
|
|
2169
|
+
}
|
|
2170
|
+
debug.namespace = namespace;
|
|
2171
|
+
debug.enabled = createDebug.enabled(namespace);
|
|
2172
|
+
debug.useColors = createDebug.useColors();
|
|
2173
|
+
debug.color = selectColor(namespace);
|
|
2174
|
+
debug.destroy = destroy;
|
|
2175
|
+
debug.extend = extend; // Debug.formatArgs = formatArgs;
|
|
2176
|
+
// debug.rawLog = rawLog;
|
|
2177
|
+
// env-specific initialization logic for debug instances
|
|
2178
|
+
|
|
2179
|
+
if (typeof createDebug.init === 'function') {
|
|
2180
|
+
createDebug.init(debug);
|
|
2181
|
+
}
|
|
2182
|
+
createDebug.instances.push(debug);
|
|
2183
|
+
return debug;
|
|
2184
|
+
}
|
|
2185
|
+
function destroy() {
|
|
2186
|
+
var index = createDebug.instances.indexOf(this);
|
|
2187
|
+
if (index !== -1) {
|
|
2188
|
+
createDebug.instances.splice(index, 1);
|
|
2189
|
+
return true;
|
|
2190
|
+
}
|
|
2191
|
+
return false;
|
|
2192
|
+
}
|
|
2193
|
+
function extend(namespace, delimiter) {
|
|
2194
|
+
return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Enables a debug mode by namespaces. This can include modes
|
|
2198
|
+
* separated by a colon and wildcards.
|
|
2199
|
+
*
|
|
2200
|
+
* @param {String} namespaces
|
|
2201
|
+
* @api public
|
|
2202
|
+
*/
|
|
2203
|
+
|
|
2204
|
+
function enable(namespaces) {
|
|
2205
|
+
createDebug.save(namespaces);
|
|
2206
|
+
createDebug.names = [];
|
|
2207
|
+
createDebug.skips = [];
|
|
2208
|
+
var i;
|
|
2209
|
+
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
|
2210
|
+
var len = split.length;
|
|
2211
|
+
for (i = 0; i < len; i++) {
|
|
2212
|
+
if (!split[i]) {
|
|
2213
|
+
// ignore empty strings
|
|
2214
|
+
continue;
|
|
2215
|
+
}
|
|
2216
|
+
namespaces = split[i].replace(/\*/g, '.*?');
|
|
2217
|
+
if (namespaces[0] === '-') {
|
|
2218
|
+
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
|
2219
|
+
} else {
|
|
2220
|
+
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
for (i = 0; i < createDebug.instances.length; i++) {
|
|
2224
|
+
var instance = createDebug.instances[i];
|
|
2225
|
+
instance.enabled = createDebug.enabled(instance.namespace);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Disable debug output.
|
|
2230
|
+
*
|
|
2231
|
+
* @api public
|
|
2232
|
+
*/
|
|
2233
|
+
|
|
2234
|
+
function disable() {
|
|
2235
|
+
createDebug.enable('');
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Returns true if the given mode name is enabled, false otherwise.
|
|
2239
|
+
*
|
|
2240
|
+
* @param {String} name
|
|
2241
|
+
* @return {Boolean}
|
|
2242
|
+
* @api public
|
|
2243
|
+
*/
|
|
2244
|
+
|
|
2245
|
+
function enabled(name) {
|
|
2246
|
+
if (name[name.length - 1] === '*') {
|
|
2247
|
+
return true;
|
|
2248
|
+
}
|
|
2249
|
+
var i;
|
|
2250
|
+
var len;
|
|
2251
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
2252
|
+
if (createDebug.skips[i].test(name)) {
|
|
2253
|
+
return false;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
2257
|
+
if (createDebug.names[i].test(name)) {
|
|
2258
|
+
return true;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
return false;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Coerce `val`.
|
|
2265
|
+
*
|
|
2266
|
+
* @param {Mixed} val
|
|
2267
|
+
* @return {Mixed}
|
|
2268
|
+
* @api private
|
|
2269
|
+
*/
|
|
2270
|
+
|
|
2271
|
+
function coerce(val) {
|
|
2272
|
+
if (val instanceof Error) {
|
|
2273
|
+
return val.stack || val.message;
|
|
2274
|
+
}
|
|
2275
|
+
return val;
|
|
2276
|
+
}
|
|
2277
|
+
createDebug.enable(createDebug.load());
|
|
2278
|
+
return createDebug;
|
|
2279
|
+
}
|
|
2280
|
+
common = setup;
|
|
2281
|
+
return common;
|
|
2282
|
+
}
|
|
2283
|
+
var hasRequiredBrowser;
|
|
2284
|
+
function requireBrowser() {
|
|
2285
|
+
if (hasRequiredBrowser) return browser.exports;
|
|
2286
|
+
hasRequiredBrowser = 1;
|
|
2287
|
+
(function (module, exports) {
|
|
2288
|
+
function _typeof(obj) {
|
|
2289
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
2290
|
+
_typeof = function _typeof(obj) {
|
|
2291
|
+
return typeof obj;
|
|
2292
|
+
};
|
|
2293
|
+
} else {
|
|
2294
|
+
_typeof = function _typeof(obj) {
|
|
2295
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
return _typeof(obj);
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
/* eslint-env browser */
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* This is the web browser implementation of `debug()`.
|
|
2305
|
+
*/
|
|
2306
|
+
exports.log = log;
|
|
2307
|
+
exports.formatArgs = formatArgs;
|
|
2308
|
+
exports.save = save;
|
|
2309
|
+
exports.load = load;
|
|
2310
|
+
exports.useColors = useColors;
|
|
2311
|
+
exports.storage = localstorage();
|
|
2312
|
+
/**
|
|
2313
|
+
* Colors.
|
|
2314
|
+
*/
|
|
2315
|
+
|
|
2316
|
+
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
|
2317
|
+
/**
|
|
2318
|
+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
2319
|
+
* and the Firebug extension (any Firefox version) are known
|
|
2320
|
+
* to support "%c" CSS customizations.
|
|
2321
|
+
*
|
|
2322
|
+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
2323
|
+
*/
|
|
2324
|
+
// eslint-disable-next-line complexity
|
|
2325
|
+
|
|
2326
|
+
function useColors() {
|
|
2327
|
+
// NB: In an Electron preload script, document will be defined but not fully
|
|
2328
|
+
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
2329
|
+
// explicitly
|
|
2330
|
+
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
|
2331
|
+
return true;
|
|
2332
|
+
} // Internet Explorer and Edge do not support colors.
|
|
2333
|
+
|
|
2334
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
2335
|
+
return false;
|
|
2336
|
+
} // Is webkit? http://stackoverflow.com/a/16459606/376773
|
|
2337
|
+
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
2338
|
+
|
|
2339
|
+
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
|
|
2340
|
+
// Is firebug? http://stackoverflow.com/a/398120/376773
|
|
2341
|
+
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) ||
|
|
2342
|
+
// Is firefox >= v31?
|
|
2343
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
2344
|
+
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 ||
|
|
2345
|
+
// Double check webkit in userAgent just in case we are in a worker
|
|
2346
|
+
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
2347
|
+
}
|
|
2348
|
+
/**
|
|
2349
|
+
* Colorize log arguments if enabled.
|
|
2350
|
+
*
|
|
2351
|
+
* @api public
|
|
2352
|
+
*/
|
|
2353
|
+
|
|
2354
|
+
function formatArgs(args) {
|
|
2355
|
+
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
|
2356
|
+
if (!this.useColors) {
|
|
2357
|
+
return;
|
|
2358
|
+
}
|
|
2359
|
+
var c = 'color: ' + this.color;
|
|
2360
|
+
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
|
2361
|
+
// arguments passed either before or after the %c, so we need to
|
|
2362
|
+
// figure out the correct index to insert the CSS into
|
|
2363
|
+
|
|
2364
|
+
var index = 0;
|
|
2365
|
+
var lastC = 0;
|
|
2366
|
+
args[0].replace(/%[a-zA-Z%]/g, function (match) {
|
|
2367
|
+
if (match === '%%') {
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
index++;
|
|
2371
|
+
if (match === '%c') {
|
|
2372
|
+
// We only are interested in the *last* %c
|
|
2373
|
+
// (the user may have provided their own)
|
|
2374
|
+
lastC = index;
|
|
2375
|
+
}
|
|
2376
|
+
});
|
|
2377
|
+
args.splice(lastC, 0, c);
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Invokes `console.log()` when available.
|
|
2381
|
+
* No-op when `console.log` is not a "function".
|
|
2382
|
+
*
|
|
2383
|
+
* @api public
|
|
2384
|
+
*/
|
|
2385
|
+
|
|
2386
|
+
function log() {
|
|
2387
|
+
var _console;
|
|
2388
|
+
|
|
2389
|
+
// This hackery is required for IE8/9, where
|
|
2390
|
+
// the `console.log` function doesn't have 'apply'
|
|
2391
|
+
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Save `namespaces`.
|
|
2395
|
+
*
|
|
2396
|
+
* @param {String} namespaces
|
|
2397
|
+
* @api private
|
|
2398
|
+
*/
|
|
2399
|
+
|
|
2400
|
+
function save(namespaces) {
|
|
2401
|
+
try {
|
|
2402
|
+
if (namespaces) {
|
|
2403
|
+
exports.storage.setItem('debug', namespaces);
|
|
2404
|
+
} else {
|
|
2405
|
+
exports.storage.removeItem('debug');
|
|
2406
|
+
}
|
|
2407
|
+
} catch (error) {// Swallow
|
|
2408
|
+
// XXX (@Qix-) should we be logging these?
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Load `namespaces`.
|
|
2413
|
+
*
|
|
2414
|
+
* @return {String} returns the previously persisted debug modes
|
|
2415
|
+
* @api private
|
|
2416
|
+
*/
|
|
2417
|
+
|
|
2418
|
+
function load() {
|
|
2419
|
+
var r;
|
|
2420
|
+
try {
|
|
2421
|
+
r = exports.storage.getItem('debug');
|
|
2422
|
+
} catch (error) {} // Swallow
|
|
2423
|
+
// XXX (@Qix-) should we be logging these?
|
|
2424
|
+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
2425
|
+
|
|
2426
|
+
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
2427
|
+
r = process.env.DEBUG;
|
|
2428
|
+
}
|
|
2429
|
+
return r;
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Localstorage attempts to return the localstorage.
|
|
2433
|
+
*
|
|
2434
|
+
* This is necessary because safari throws
|
|
2435
|
+
* when a user disables cookies/localstorage
|
|
2436
|
+
* and you attempt to access it.
|
|
2437
|
+
*
|
|
2438
|
+
* @return {LocalStorage}
|
|
2439
|
+
* @api private
|
|
2440
|
+
*/
|
|
2441
|
+
|
|
2442
|
+
function localstorage() {
|
|
2443
|
+
try {
|
|
2444
|
+
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
|
2445
|
+
// The Browser also has localStorage in the global context.
|
|
2446
|
+
return localStorage;
|
|
2447
|
+
} catch (error) {// Swallow
|
|
2448
|
+
// XXX (@Qix-) should we be logging these?
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
module.exports = requireCommon()(exports);
|
|
2452
|
+
var formatters = module.exports.formatters;
|
|
2453
|
+
/**
|
|
2454
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
2455
|
+
*/
|
|
2456
|
+
|
|
2457
|
+
formatters.j = function (v) {
|
|
2458
|
+
try {
|
|
2459
|
+
return JSON.stringify(v);
|
|
2460
|
+
} catch (error) {
|
|
2461
|
+
return '[UnexpectedJSONParseError]: ' + error.message;
|
|
2462
|
+
}
|
|
2463
|
+
};
|
|
2464
|
+
})(browser, browser.exports);
|
|
2465
|
+
return browser.exports;
|
|
2466
|
+
}
|
|
2467
|
+
var node$2 = {
|
|
2468
|
+
exports: {}
|
|
2469
|
+
};
|
|
2470
|
+
var hasFlag;
|
|
2471
|
+
var hasRequiredHasFlag;
|
|
2472
|
+
function requireHasFlag() {
|
|
2473
|
+
if (hasRequiredHasFlag) return hasFlag;
|
|
2474
|
+
hasRequiredHasFlag = 1;
|
|
2475
|
+
hasFlag = function (flag) {
|
|
2476
|
+
let argv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : process.argv;
|
|
2477
|
+
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
2478
|
+
const position = argv.indexOf(prefix + flag);
|
|
2479
|
+
const terminatorPosition = argv.indexOf('--');
|
|
2480
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2481
|
+
};
|
|
2482
|
+
return hasFlag;
|
|
2483
|
+
}
|
|
2484
|
+
var supportsColor_1;
|
|
2485
|
+
var hasRequiredSupportsColor;
|
|
2486
|
+
function requireSupportsColor() {
|
|
2487
|
+
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
2488
|
+
hasRequiredSupportsColor = 1;
|
|
2489
|
+
const os = require$$0;
|
|
2490
|
+
const tty = require$$1;
|
|
2491
|
+
const hasFlag = requireHasFlag();
|
|
2492
|
+
const {
|
|
2493
|
+
env
|
|
2494
|
+
} = process;
|
|
2495
|
+
let forceColor;
|
|
2496
|
+
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
|
|
2497
|
+
forceColor = 0;
|
|
2498
|
+
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
|
2499
|
+
forceColor = 1;
|
|
2500
|
+
}
|
|
2501
|
+
if ('FORCE_COLOR' in env) {
|
|
2502
|
+
if (env.FORCE_COLOR === 'true') {
|
|
2503
|
+
forceColor = 1;
|
|
2504
|
+
} else if (env.FORCE_COLOR === 'false') {
|
|
2505
|
+
forceColor = 0;
|
|
2506
|
+
} else {
|
|
2507
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
function translateLevel(level) {
|
|
2511
|
+
if (level === 0) {
|
|
2512
|
+
return false;
|
|
2513
|
+
}
|
|
2514
|
+
return {
|
|
2515
|
+
level,
|
|
2516
|
+
hasBasic: true,
|
|
2517
|
+
has256: level >= 2,
|
|
2518
|
+
has16m: level >= 3
|
|
2519
|
+
};
|
|
2520
|
+
}
|
|
2521
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
2522
|
+
if (forceColor === 0) {
|
|
2523
|
+
return 0;
|
|
2524
|
+
}
|
|
2525
|
+
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
|
2526
|
+
return 3;
|
|
2527
|
+
}
|
|
2528
|
+
if (hasFlag('color=256')) {
|
|
2529
|
+
return 2;
|
|
2530
|
+
}
|
|
2531
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
2532
|
+
return 0;
|
|
2533
|
+
}
|
|
2534
|
+
const min = forceColor || 0;
|
|
2535
|
+
if (env.TERM === 'dumb') {
|
|
2536
|
+
return min;
|
|
2537
|
+
}
|
|
2538
|
+
if (process.platform === 'win32') {
|
|
2539
|
+
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
2540
|
+
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
2541
|
+
const osRelease = os.release().split('.');
|
|
2542
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
2543
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
2544
|
+
}
|
|
2545
|
+
return 1;
|
|
2546
|
+
}
|
|
2547
|
+
if ('CI' in env) {
|
|
2548
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
2549
|
+
return 1;
|
|
2550
|
+
}
|
|
2551
|
+
return min;
|
|
2552
|
+
}
|
|
2553
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
2554
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
2555
|
+
}
|
|
2556
|
+
if (env.COLORTERM === 'truecolor') {
|
|
2557
|
+
return 3;
|
|
2558
|
+
}
|
|
2559
|
+
if ('TERM_PROGRAM' in env) {
|
|
2560
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2561
|
+
switch (env.TERM_PROGRAM) {
|
|
2562
|
+
case 'iTerm.app':
|
|
2563
|
+
return version >= 3 ? 3 : 2;
|
|
2564
|
+
case 'Apple_Terminal':
|
|
2565
|
+
return 2;
|
|
2566
|
+
// No default
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
2571
|
+
return 2;
|
|
2572
|
+
}
|
|
2573
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
2574
|
+
return 1;
|
|
2575
|
+
}
|
|
2576
|
+
if ('COLORTERM' in env) {
|
|
2577
|
+
return 1;
|
|
2578
|
+
}
|
|
2579
|
+
return min;
|
|
2580
|
+
}
|
|
2581
|
+
function getSupportLevel(stream) {
|
|
2582
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
2583
|
+
return translateLevel(level);
|
|
2584
|
+
}
|
|
2585
|
+
supportsColor_1 = {
|
|
2586
|
+
supportsColor: getSupportLevel,
|
|
2587
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
2588
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
2589
|
+
};
|
|
2590
|
+
return supportsColor_1;
|
|
2591
|
+
}
|
|
2592
|
+
var hasRequiredNode;
|
|
2593
|
+
function requireNode() {
|
|
2594
|
+
if (hasRequiredNode) return node$2.exports;
|
|
2595
|
+
hasRequiredNode = 1;
|
|
2596
|
+
(function (module, exports) {
|
|
2597
|
+
/**
|
|
2598
|
+
* Module dependencies.
|
|
2599
|
+
*/
|
|
2600
|
+
var tty = require$$1;
|
|
2601
|
+
var util = require$$1$1;
|
|
2602
|
+
/**
|
|
2603
|
+
* This is the Node.js implementation of `debug()`.
|
|
2604
|
+
*/
|
|
2605
|
+
|
|
2606
|
+
exports.init = init;
|
|
2607
|
+
exports.log = log;
|
|
2608
|
+
exports.formatArgs = formatArgs;
|
|
2609
|
+
exports.save = save;
|
|
2610
|
+
exports.load = load;
|
|
2611
|
+
exports.useColors = useColors;
|
|
2612
|
+
/**
|
|
2613
|
+
* Colors.
|
|
2614
|
+
*/
|
|
2615
|
+
|
|
2616
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
2617
|
+
try {
|
|
2618
|
+
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
2619
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2620
|
+
var supportsColor = requireSupportsColor();
|
|
2621
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
2622
|
+
exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
|
|
2623
|
+
}
|
|
2624
|
+
} catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
2625
|
+
|
|
2626
|
+
/**
|
|
2627
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
|
2628
|
+
*
|
|
2629
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
2630
|
+
*/
|
|
2631
|
+
|
|
2632
|
+
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
|
2633
|
+
return /^debug_/i.test(key);
|
|
2634
|
+
}).reduce(function (obj, key) {
|
|
2635
|
+
// Camel-case
|
|
2636
|
+
var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function (_, k) {
|
|
2637
|
+
return k.toUpperCase();
|
|
2638
|
+
}); // Coerce string value into JS value
|
|
2639
|
+
|
|
2640
|
+
var val = process.env[key];
|
|
2641
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
2642
|
+
val = true;
|
|
2643
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
2644
|
+
val = false;
|
|
2645
|
+
} else if (val === 'null') {
|
|
2646
|
+
val = null;
|
|
2647
|
+
} else {
|
|
2648
|
+
val = Number(val);
|
|
2649
|
+
}
|
|
2650
|
+
obj[prop] = val;
|
|
2651
|
+
return obj;
|
|
2652
|
+
}, {});
|
|
2653
|
+
/**
|
|
2654
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
2655
|
+
*/
|
|
2656
|
+
|
|
2657
|
+
function useColors() {
|
|
2658
|
+
return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2661
|
+
* Adds ANSI color escape codes if enabled.
|
|
2662
|
+
*
|
|
2663
|
+
* @api public
|
|
2664
|
+
*/
|
|
2665
|
+
|
|
2666
|
+
function formatArgs(args) {
|
|
2667
|
+
var name = this.namespace,
|
|
2668
|
+
useColors = this.useColors;
|
|
2669
|
+
if (useColors) {
|
|
2670
|
+
var c = this.color;
|
|
2671
|
+
var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c);
|
|
2672
|
+
var prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m");
|
|
2673
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
2674
|
+
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
2675
|
+
} else {
|
|
2676
|
+
args[0] = getDate() + name + ' ' + args[0];
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
function getDate() {
|
|
2680
|
+
if (exports.inspectOpts.hideDate) {
|
|
2681
|
+
return '';
|
|
2682
|
+
}
|
|
2683
|
+
return new Date().toISOString() + ' ';
|
|
2684
|
+
}
|
|
2685
|
+
/**
|
|
2686
|
+
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
|
2687
|
+
*/
|
|
2688
|
+
|
|
2689
|
+
function log() {
|
|
2690
|
+
return process.stderr.write(util.format.apply(util, arguments) + '\n');
|
|
2691
|
+
}
|
|
2692
|
+
/**
|
|
2693
|
+
* Save `namespaces`.
|
|
2694
|
+
*
|
|
2695
|
+
* @param {String} namespaces
|
|
2696
|
+
* @api private
|
|
2697
|
+
*/
|
|
2698
|
+
|
|
2699
|
+
function save(namespaces) {
|
|
2700
|
+
if (namespaces) {
|
|
2701
|
+
process.env.DEBUG = namespaces;
|
|
2702
|
+
} else {
|
|
2703
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
|
2704
|
+
// string 'null' or 'undefined'. Just delete instead.
|
|
2705
|
+
delete process.env.DEBUG;
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
/**
|
|
2709
|
+
* Load `namespaces`.
|
|
2710
|
+
*
|
|
2711
|
+
* @return {String} returns the previously persisted debug modes
|
|
2712
|
+
* @api private
|
|
2713
|
+
*/
|
|
2714
|
+
|
|
2715
|
+
function load() {
|
|
2716
|
+
return process.env.DEBUG;
|
|
2717
|
+
}
|
|
2718
|
+
/**
|
|
2719
|
+
* Init logic for `debug` instances.
|
|
2720
|
+
*
|
|
2721
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
|
2722
|
+
* differently for a particular `debug` instance.
|
|
2723
|
+
*/
|
|
2724
|
+
|
|
2725
|
+
function init(debug) {
|
|
2726
|
+
debug.inspectOpts = {};
|
|
2727
|
+
var keys = Object.keys(exports.inspectOpts);
|
|
2728
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2729
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
module.exports = requireCommon()(exports);
|
|
2733
|
+
var formatters = module.exports.formatters;
|
|
2734
|
+
/**
|
|
2735
|
+
* Map %o to `util.inspect()`, all on a single line.
|
|
2736
|
+
*/
|
|
2737
|
+
|
|
2738
|
+
formatters.o = function (v) {
|
|
2739
|
+
this.inspectOpts.colors = this.useColors;
|
|
2740
|
+
return util.inspect(v, this.inspectOpts).split('\n').map(function (str) {
|
|
2741
|
+
return str.trim();
|
|
2742
|
+
}).join(' ');
|
|
2743
|
+
};
|
|
2744
|
+
/**
|
|
2745
|
+
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
2746
|
+
*/
|
|
2747
|
+
|
|
2748
|
+
formatters.O = function (v) {
|
|
2749
|
+
this.inspectOpts.colors = this.useColors;
|
|
2750
|
+
return util.inspect(v, this.inspectOpts);
|
|
2751
|
+
};
|
|
2752
|
+
})(node$2, node$2.exports);
|
|
2753
|
+
return node$2.exports;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
/**
|
|
2757
|
+
* Detect Electron renderer / nwjs process, which is node, but we should
|
|
2758
|
+
* treat as a browser.
|
|
2759
|
+
*/
|
|
2760
|
+
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
|
2761
|
+
src.exports = requireBrowser();
|
|
2762
|
+
} else {
|
|
2763
|
+
src.exports = requireNode();
|
|
2764
|
+
}
|
|
2765
|
+
var srcExports = src.exports;
|
|
2766
|
+
var debugIt = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
|
|
2767
|
+
var __defProp$h = Object.defineProperty;
|
|
2768
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, {
|
|
2769
|
+
enumerable: true,
|
|
2770
|
+
configurable: true,
|
|
2771
|
+
writable: true,
|
|
2772
|
+
value
|
|
2773
|
+
}) : obj[key] = value;
|
|
2774
|
+
var __publicField$h = (obj, key, value) => {
|
|
2775
|
+
__defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2776
|
+
return value;
|
|
2777
|
+
};
|
|
2778
|
+
const digitChar = /[0-9]/;
|
|
2779
|
+
const attributeCharMatcher = /^[a-zA-Z0-9_]$/;
|
|
2780
|
+
const attributeFirstCharMatcher = /^[a-zA-Z_]$/;
|
|
2781
|
+
const symbols = {
|
|
2782
|
+
operator: ["..", ".", ",", ":", "?"],
|
|
2783
|
+
comparator: [">", ">=", "<", "<=", "==", "!="],
|
|
2784
|
+
keyword: ["$", "@"],
|
|
2785
|
+
boolean: ["true", "false"],
|
|
2786
|
+
paren: ["[", "]"]
|
|
2787
|
+
};
|
|
2788
|
+
const symbolClasses = Object.keys(symbols);
|
|
2789
|
+
class Tokenizer {
|
|
2790
|
+
constructor(path) {
|
|
2791
|
+
__publicField$h(this, "source");
|
|
2792
|
+
__publicField$h(this, "i");
|
|
2793
|
+
__publicField$h(this, "length");
|
|
2794
|
+
__publicField$h(this, "tokenizers");
|
|
2795
|
+
this.source = path;
|
|
2796
|
+
this.length = path.length;
|
|
2797
|
+
this.i = 0;
|
|
2798
|
+
this.tokenizers = [this.tokenizeSymbol, this.tokenizeIdentifier, this.tokenizeNumber, this.tokenizeQuoted].map(fn => fn.bind(this));
|
|
2799
|
+
}
|
|
2800
|
+
tokenize() {
|
|
2801
|
+
const result = [];
|
|
2802
|
+
while (!this.EOF()) {
|
|
2803
|
+
this.chompWhitespace();
|
|
2804
|
+
let token = null;
|
|
2805
|
+
const found = this.tokenizers.some(tokenizer => {
|
|
2806
|
+
token = tokenizer();
|
|
2807
|
+
return Boolean(token);
|
|
2808
|
+
});
|
|
2809
|
+
if (!found || !token) {
|
|
2810
|
+
throw new Error("Invalid tokens in jsonpath '".concat(this.source, "' @ ").concat(this.i));
|
|
2811
|
+
}
|
|
2812
|
+
result.push(token);
|
|
2813
|
+
}
|
|
2814
|
+
return result;
|
|
2815
|
+
}
|
|
2816
|
+
takeWhile(fn) {
|
|
2817
|
+
const start = this.i;
|
|
2818
|
+
let result = "";
|
|
2819
|
+
while (!this.EOF()) {
|
|
2820
|
+
const nextChar = fn(this.source[this.i]);
|
|
2821
|
+
if (nextChar === null) {
|
|
2822
|
+
break;
|
|
2823
|
+
}
|
|
2824
|
+
result += nextChar;
|
|
2825
|
+
this.i++;
|
|
2826
|
+
}
|
|
2827
|
+
if (this.i === start) {
|
|
2828
|
+
return null;
|
|
2829
|
+
}
|
|
2830
|
+
return result;
|
|
2831
|
+
}
|
|
2832
|
+
EOF() {
|
|
2833
|
+
return this.i >= this.length;
|
|
2834
|
+
}
|
|
2835
|
+
peek() {
|
|
2836
|
+
if (this.EOF()) {
|
|
2837
|
+
return null;
|
|
2838
|
+
}
|
|
2839
|
+
return this.source[this.i];
|
|
2840
|
+
}
|
|
2841
|
+
consume(str) {
|
|
2842
|
+
if (this.i + str.length > this.length) {
|
|
2843
|
+
throw new Error("Expected ".concat(str, " at end of jsonpath"));
|
|
2844
|
+
}
|
|
2845
|
+
if (str === this.source.slice(this.i, this.i + str.length)) {
|
|
2846
|
+
this.i += str.length;
|
|
2847
|
+
} else {
|
|
2848
|
+
throw new Error('Expected "'.concat(str, '", but source contained "').concat(this.source.slice()));
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
// Tries to match the upcoming bit of string with the provided string. If it matches, returns
|
|
2852
|
+
// the string, then advances the read pointer to the next bit. If not, returns null and nothing
|
|
2853
|
+
// happens.
|
|
2854
|
+
tryConsume(str) {
|
|
2855
|
+
if (this.i + str.length > this.length) {
|
|
2856
|
+
return null;
|
|
2857
|
+
}
|
|
2858
|
+
if (str === this.source.slice(this.i, this.i + str.length)) {
|
|
2859
|
+
this.i += str.length;
|
|
2860
|
+
return str;
|
|
2861
|
+
}
|
|
2862
|
+
return null;
|
|
2863
|
+
}
|
|
2864
|
+
chompWhitespace() {
|
|
2865
|
+
this.takeWhile(char => {
|
|
2866
|
+
return char === " " ? "" : null;
|
|
2867
|
+
});
|
|
2868
|
+
}
|
|
2869
|
+
tokenizeQuoted() {
|
|
2870
|
+
const quote = this.peek();
|
|
2871
|
+
if (quote === "'" || quote === '"') {
|
|
2872
|
+
this.consume(quote);
|
|
2873
|
+
let escape = false;
|
|
2874
|
+
const inner = this.takeWhile(char => {
|
|
2875
|
+
if (escape) {
|
|
2876
|
+
escape = false;
|
|
2877
|
+
return char;
|
|
2878
|
+
}
|
|
2879
|
+
if (char === "\\") {
|
|
2880
|
+
escape = true;
|
|
2881
|
+
return "";
|
|
2882
|
+
}
|
|
2883
|
+
if (char != quote) {
|
|
2884
|
+
return char;
|
|
2885
|
+
}
|
|
2886
|
+
return null;
|
|
2887
|
+
});
|
|
2888
|
+
this.consume(quote);
|
|
2889
|
+
return {
|
|
2890
|
+
type: "quoted",
|
|
2891
|
+
value: inner,
|
|
2892
|
+
quote: quote === '"' ? "double" : "single"
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
return null;
|
|
2896
|
+
}
|
|
2897
|
+
tokenizeIdentifier() {
|
|
2898
|
+
let first = true;
|
|
2899
|
+
const identifier = this.takeWhile(char => {
|
|
2900
|
+
if (first) {
|
|
2901
|
+
first = false;
|
|
2902
|
+
return char.match(attributeFirstCharMatcher) ? char : null;
|
|
2903
|
+
}
|
|
2904
|
+
return char.match(attributeCharMatcher) ? char : null;
|
|
2905
|
+
});
|
|
2906
|
+
if (identifier !== null) {
|
|
2907
|
+
return {
|
|
2908
|
+
type: "identifier",
|
|
2909
|
+
name: identifier
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2912
|
+
return null;
|
|
2913
|
+
}
|
|
2914
|
+
tokenizeNumber() {
|
|
2915
|
+
const start = this.i;
|
|
2916
|
+
let dotSeen = false;
|
|
2917
|
+
let digitSeen = false;
|
|
2918
|
+
let negative = false;
|
|
2919
|
+
if (this.peek() === "-") {
|
|
2920
|
+
negative = true;
|
|
2921
|
+
this.consume("-");
|
|
2922
|
+
}
|
|
2923
|
+
const number = this.takeWhile(char => {
|
|
2924
|
+
if (char === "." && !dotSeen && digitSeen) {
|
|
2925
|
+
dotSeen = true;
|
|
2926
|
+
return char;
|
|
2927
|
+
}
|
|
2928
|
+
digitSeen = true;
|
|
2929
|
+
return char.match(digitChar) ? char : null;
|
|
2930
|
+
});
|
|
2931
|
+
if (number !== null) {
|
|
2932
|
+
return {
|
|
2933
|
+
type: "number",
|
|
2934
|
+
value: negative ? -number : +number,
|
|
2935
|
+
raw: negative ? "-".concat(number) : number
|
|
2936
|
+
};
|
|
2937
|
+
}
|
|
2938
|
+
this.i = start;
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
tokenizeSymbol() {
|
|
2942
|
+
for (const symbolClass of symbolClasses) {
|
|
2943
|
+
const patterns = symbols[symbolClass];
|
|
2944
|
+
const symbol = patterns.find(pattern => this.tryConsume(pattern));
|
|
2945
|
+
if (symbol) {
|
|
2946
|
+
return {
|
|
2947
|
+
type: symbolClass,
|
|
2948
|
+
symbol
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
return null;
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
function tokenize(jsonpath) {
|
|
2956
|
+
return new Tokenizer(jsonpath).tokenize();
|
|
2957
|
+
}
|
|
2958
|
+
var __defProp$g = Object.defineProperty;
|
|
2959
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, {
|
|
2960
|
+
enumerable: true,
|
|
2961
|
+
configurable: true,
|
|
2962
|
+
writable: true,
|
|
2963
|
+
value
|
|
2964
|
+
}) : obj[key] = value;
|
|
2965
|
+
var __publicField$g = (obj, key, value) => {
|
|
2966
|
+
__defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2967
|
+
return value;
|
|
2968
|
+
};
|
|
2969
|
+
class Parser {
|
|
2970
|
+
constructor(path) {
|
|
2971
|
+
__publicField$g(this, "tokens");
|
|
2972
|
+
__publicField$g(this, "length");
|
|
2973
|
+
__publicField$g(this, "i");
|
|
2974
|
+
this.tokens = tokenize(path);
|
|
2975
|
+
this.length = this.tokens.length;
|
|
2976
|
+
this.i = 0;
|
|
2977
|
+
}
|
|
2978
|
+
parse() {
|
|
2979
|
+
return this.parsePath();
|
|
2980
|
+
}
|
|
2981
|
+
EOF() {
|
|
2982
|
+
return this.i >= this.length;
|
|
2983
|
+
}
|
|
2984
|
+
// Look at upcoming token
|
|
2985
|
+
peek() {
|
|
2986
|
+
if (this.EOF()) {
|
|
2987
|
+
return null;
|
|
2988
|
+
}
|
|
2989
|
+
return this.tokens[this.i];
|
|
2990
|
+
}
|
|
2991
|
+
consume() {
|
|
2992
|
+
const result = this.peek();
|
|
2993
|
+
this.i += 1;
|
|
2994
|
+
return result;
|
|
2995
|
+
}
|
|
2996
|
+
// Return next token if it matches the pattern
|
|
2997
|
+
probe(pattern) {
|
|
2998
|
+
const token = this.peek();
|
|
2999
|
+
if (!token) {
|
|
3000
|
+
return null;
|
|
3001
|
+
}
|
|
3002
|
+
const record = token;
|
|
3003
|
+
const match = Object.keys(pattern).every(key => {
|
|
3004
|
+
return key in token && pattern[key] === record[key];
|
|
3005
|
+
});
|
|
3006
|
+
return match ? token : null;
|
|
3007
|
+
}
|
|
3008
|
+
// Return and consume next token if it matches the pattern
|
|
3009
|
+
match(pattern) {
|
|
3010
|
+
return this.probe(pattern) ? this.consume() : null;
|
|
3011
|
+
}
|
|
3012
|
+
parseAttribute() {
|
|
3013
|
+
const token = this.match({
|
|
3014
|
+
type: "identifier"
|
|
3015
|
+
});
|
|
3016
|
+
if (token && token.type === "identifier") {
|
|
3017
|
+
return {
|
|
3018
|
+
type: "attribute",
|
|
3019
|
+
name: token.name
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
const quoted = this.match({
|
|
3023
|
+
type: "quoted",
|
|
3024
|
+
quote: "single"
|
|
3025
|
+
});
|
|
3026
|
+
if (quoted && quoted.type === "quoted") {
|
|
3027
|
+
return {
|
|
3028
|
+
type: "attribute",
|
|
3029
|
+
name: quoted.value || ""
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
return null;
|
|
3033
|
+
}
|
|
3034
|
+
parseAlias() {
|
|
3035
|
+
if (this.match({
|
|
3036
|
+
type: "keyword",
|
|
3037
|
+
symbol: "@"
|
|
3038
|
+
}) || this.match({
|
|
3039
|
+
type: "keyword",
|
|
3040
|
+
symbol: "$"
|
|
3041
|
+
})) {
|
|
3042
|
+
return {
|
|
3043
|
+
type: "alias",
|
|
3044
|
+
target: "self"
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
3047
|
+
return null;
|
|
3048
|
+
}
|
|
3049
|
+
parseNumber() {
|
|
3050
|
+
const token = this.match({
|
|
3051
|
+
type: "number"
|
|
3052
|
+
});
|
|
3053
|
+
if (token && token.type === "number") {
|
|
3054
|
+
return {
|
|
3055
|
+
type: "number",
|
|
3056
|
+
value: token.value
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
return null;
|
|
3060
|
+
}
|
|
3061
|
+
parseNumberValue() {
|
|
3062
|
+
const expr = this.parseNumber();
|
|
3063
|
+
if (expr) {
|
|
3064
|
+
return expr.value;
|
|
3065
|
+
}
|
|
3066
|
+
return null;
|
|
3067
|
+
}
|
|
3068
|
+
parseSliceSelector() {
|
|
3069
|
+
const start = this.i;
|
|
3070
|
+
const rangeStart = this.parseNumberValue();
|
|
3071
|
+
const colon1 = this.match({
|
|
3072
|
+
type: "operator",
|
|
3073
|
+
symbol: ":"
|
|
3074
|
+
});
|
|
3075
|
+
if (!colon1) {
|
|
3076
|
+
if (rangeStart === null) {
|
|
3077
|
+
this.i = start;
|
|
3078
|
+
return null;
|
|
3079
|
+
}
|
|
3080
|
+
return {
|
|
3081
|
+
type: "index",
|
|
3082
|
+
value: rangeStart
|
|
3083
|
+
};
|
|
3084
|
+
}
|
|
3085
|
+
const result = {
|
|
3086
|
+
type: "range",
|
|
3087
|
+
start: rangeStart,
|
|
3088
|
+
end: this.parseNumberValue()
|
|
3089
|
+
};
|
|
3090
|
+
const colon2 = this.match({
|
|
3091
|
+
type: "operator",
|
|
3092
|
+
symbol: ":"
|
|
3093
|
+
});
|
|
3094
|
+
if (colon2) {
|
|
3095
|
+
result.step = this.parseNumberValue();
|
|
3096
|
+
}
|
|
3097
|
+
if (result.start === null && result.end === null) {
|
|
3098
|
+
this.i = start;
|
|
3099
|
+
return null;
|
|
3100
|
+
}
|
|
3101
|
+
return result;
|
|
3102
|
+
}
|
|
3103
|
+
parseValueReference() {
|
|
3104
|
+
return this.parseAttribute() || this.parseSliceSelector();
|
|
3105
|
+
}
|
|
3106
|
+
parseLiteralValue() {
|
|
3107
|
+
const literalString = this.match({
|
|
3108
|
+
type: "quoted",
|
|
3109
|
+
quote: "double"
|
|
3110
|
+
});
|
|
3111
|
+
if (literalString && literalString.type === "quoted") {
|
|
3112
|
+
return {
|
|
3113
|
+
type: "string",
|
|
3114
|
+
value: literalString.value || ""
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
const literalBoolean = this.match({
|
|
3118
|
+
type: "boolean"
|
|
3119
|
+
});
|
|
3120
|
+
if (literalBoolean && literalBoolean.type === "boolean") {
|
|
3121
|
+
return {
|
|
3122
|
+
type: "boolean",
|
|
3123
|
+
value: literalBoolean.symbol === "true"
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
return this.parseNumber();
|
|
3127
|
+
}
|
|
3128
|
+
// TODO: Reorder constraints so that literal value is always on rhs, and variable is always
|
|
3129
|
+
// on lhs.
|
|
3130
|
+
parseFilterExpression() {
|
|
3131
|
+
const start = this.i;
|
|
3132
|
+
const expr = this.parseAttribute() || this.parseAlias();
|
|
3133
|
+
if (!expr) {
|
|
3134
|
+
return null;
|
|
3135
|
+
}
|
|
3136
|
+
if (this.match({
|
|
3137
|
+
type: "operator",
|
|
3138
|
+
symbol: "?"
|
|
3139
|
+
})) {
|
|
3140
|
+
return {
|
|
3141
|
+
type: "constraint",
|
|
3142
|
+
operator: "?",
|
|
3143
|
+
lhs: expr
|
|
3144
|
+
};
|
|
3145
|
+
}
|
|
3146
|
+
const binOp = this.match({
|
|
3147
|
+
type: "comparator"
|
|
3148
|
+
});
|
|
3149
|
+
if (!binOp || binOp.type !== "comparator") {
|
|
3150
|
+
this.i = start;
|
|
3151
|
+
return null;
|
|
3152
|
+
}
|
|
3153
|
+
const lhs = expr;
|
|
3154
|
+
const rhs = this.parseLiteralValue();
|
|
3155
|
+
if (!rhs) {
|
|
3156
|
+
throw new Error("Operator ".concat(binOp.symbol, " needs a literal value at the right hand side"));
|
|
3157
|
+
}
|
|
3158
|
+
return {
|
|
3159
|
+
type: "constraint",
|
|
3160
|
+
operator: binOp.symbol,
|
|
3161
|
+
lhs,
|
|
3162
|
+
rhs
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
parseExpression() {
|
|
3166
|
+
return this.parseFilterExpression() || this.parseValueReference();
|
|
3167
|
+
}
|
|
3168
|
+
parseUnion() {
|
|
3169
|
+
if (!this.match({
|
|
3170
|
+
type: "paren",
|
|
3171
|
+
symbol: "["
|
|
3172
|
+
})) {
|
|
3173
|
+
return null;
|
|
3174
|
+
}
|
|
3175
|
+
const terms = [];
|
|
3176
|
+
let expr = this.parseFilterExpression() || this.parsePath() || this.parseValueReference();
|
|
3177
|
+
while (expr) {
|
|
3178
|
+
terms.push(expr);
|
|
3179
|
+
if (this.match({
|
|
3180
|
+
type: "paren",
|
|
3181
|
+
symbol: "]"
|
|
3182
|
+
})) {
|
|
3183
|
+
break;
|
|
3184
|
+
}
|
|
3185
|
+
if (!this.match({
|
|
3186
|
+
type: "operator",
|
|
3187
|
+
symbol: ","
|
|
3188
|
+
})) {
|
|
3189
|
+
throw new Error("Expected ]");
|
|
3190
|
+
}
|
|
3191
|
+
expr = this.parseFilterExpression() || this.parsePath() || this.parseValueReference();
|
|
3192
|
+
if (!expr) {
|
|
3193
|
+
throw new Error("Expected expression following ','");
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
return {
|
|
3197
|
+
type: "union",
|
|
3198
|
+
nodes: terms
|
|
3199
|
+
};
|
|
3200
|
+
}
|
|
3201
|
+
parseRecursive() {
|
|
3202
|
+
if (!this.match({
|
|
3203
|
+
type: "operator",
|
|
3204
|
+
symbol: ".."
|
|
3205
|
+
})) {
|
|
3206
|
+
return null;
|
|
3207
|
+
}
|
|
3208
|
+
const subpath = this.parsePath();
|
|
3209
|
+
if (!subpath) {
|
|
3210
|
+
throw new Error("Expected path following '..' operator");
|
|
3211
|
+
}
|
|
3212
|
+
return {
|
|
3213
|
+
type: "recursive",
|
|
3214
|
+
term: subpath
|
|
3215
|
+
};
|
|
3216
|
+
}
|
|
3217
|
+
parsePath() {
|
|
3218
|
+
const nodes = [];
|
|
3219
|
+
const expr = this.parseAttribute() || this.parseUnion() || this.parseRecursive();
|
|
3220
|
+
if (!expr) {
|
|
3221
|
+
return null;
|
|
3222
|
+
}
|
|
3223
|
+
nodes.push(expr);
|
|
3224
|
+
while (!this.EOF()) {
|
|
3225
|
+
if (this.match({
|
|
3226
|
+
type: "operator",
|
|
3227
|
+
symbol: "."
|
|
3228
|
+
})) {
|
|
3229
|
+
const attr = this.parseAttribute();
|
|
3230
|
+
if (!attr) {
|
|
3231
|
+
throw new Error("Expected attribute name following '.");
|
|
3232
|
+
}
|
|
3233
|
+
nodes.push(attr);
|
|
3234
|
+
continue;
|
|
3235
|
+
} else if (this.probe({
|
|
3236
|
+
type: "paren",
|
|
3237
|
+
symbol: "["
|
|
3238
|
+
})) {
|
|
3239
|
+
const union = this.parseUnion();
|
|
3240
|
+
if (!union) {
|
|
3241
|
+
throw new Error("Expected union following '['");
|
|
3242
|
+
}
|
|
3243
|
+
nodes.push(union);
|
|
3244
|
+
} else {
|
|
3245
|
+
const recursive = this.parseRecursive();
|
|
3246
|
+
if (recursive) {
|
|
3247
|
+
nodes.push(recursive);
|
|
3248
|
+
}
|
|
3249
|
+
break;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
if (nodes.length === 1) {
|
|
3253
|
+
return nodes[0];
|
|
3254
|
+
}
|
|
3255
|
+
return {
|
|
3256
|
+
type: "path",
|
|
3257
|
+
nodes
|
|
3258
|
+
};
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
function parseJsonPath(path) {
|
|
3262
|
+
const parsed = new Parser(path).parse();
|
|
3263
|
+
if (!parsed) {
|
|
3264
|
+
throw new Error('Failed to parse JSON path "'.concat(path, '"'));
|
|
3265
|
+
}
|
|
3266
|
+
return parsed;
|
|
3267
|
+
}
|
|
3268
|
+
function descend$1(tail) {
|
|
3269
|
+
const [head, newTail] = splitIfPath(tail);
|
|
3270
|
+
if (!head) {
|
|
3271
|
+
throw new Error("Head cannot be null");
|
|
3272
|
+
}
|
|
3273
|
+
return spreadIfUnionHead(head, newTail);
|
|
3274
|
+
}
|
|
3275
|
+
function splitIfPath(tail) {
|
|
3276
|
+
if (tail.type !== "path") {
|
|
3277
|
+
return [tail, null];
|
|
3278
|
+
}
|
|
3279
|
+
const nodes = tail.nodes;
|
|
3280
|
+
if (nodes.length === 0) {
|
|
3281
|
+
return [null, null];
|
|
3282
|
+
}
|
|
3283
|
+
if (nodes.length === 1) {
|
|
3284
|
+
return [nodes[0], null];
|
|
3285
|
+
}
|
|
3286
|
+
return [nodes[0], {
|
|
3287
|
+
type: "path",
|
|
3288
|
+
nodes: nodes.slice(1)
|
|
3289
|
+
}];
|
|
3290
|
+
}
|
|
3291
|
+
function concatPaths(path1, path2) {
|
|
3292
|
+
if (!path1 && !path2) {
|
|
3293
|
+
return null;
|
|
3294
|
+
}
|
|
3295
|
+
const nodes1 = path1 ? path1.nodes : [];
|
|
3296
|
+
const nodes2 = path2 ? path2.nodes : [];
|
|
3297
|
+
return {
|
|
3298
|
+
type: "path",
|
|
3299
|
+
nodes: nodes1.concat(nodes2)
|
|
3300
|
+
};
|
|
3301
|
+
}
|
|
3302
|
+
function spreadIfUnionHead(head, tail) {
|
|
3303
|
+
if (head.type !== "union") {
|
|
3304
|
+
return [[head, tail]];
|
|
3305
|
+
}
|
|
3306
|
+
return head.nodes.map(node => {
|
|
3307
|
+
if (node.type === "path") {
|
|
3308
|
+
const [subHead, subTail] = splitIfPath(node);
|
|
3309
|
+
return [subHead, concatPaths(subTail, tail)];
|
|
3310
|
+
}
|
|
3311
|
+
return [node, tail];
|
|
3312
|
+
});
|
|
3313
|
+
}
|
|
3314
|
+
function toPath(expr) {
|
|
3315
|
+
return toPathInner(expr, false);
|
|
3316
|
+
}
|
|
3317
|
+
function toPathInner(expr, inUnion) {
|
|
3318
|
+
switch (expr.type) {
|
|
3319
|
+
case "attribute":
|
|
3320
|
+
return expr.name;
|
|
3321
|
+
case "alias":
|
|
3322
|
+
return expr.target === "self" ? "@" : "$";
|
|
3323
|
+
case "number":
|
|
3324
|
+
return "".concat(expr.value);
|
|
3325
|
+
case "range":
|
|
3326
|
+
{
|
|
3327
|
+
const result = [];
|
|
3328
|
+
if (!inUnion) {
|
|
3329
|
+
result.push("[");
|
|
3330
|
+
}
|
|
3331
|
+
if (expr.start) {
|
|
3332
|
+
result.push("".concat(expr.start));
|
|
3333
|
+
}
|
|
3334
|
+
result.push(":");
|
|
3335
|
+
if (expr.end) {
|
|
3336
|
+
result.push("".concat(expr.end));
|
|
3337
|
+
}
|
|
3338
|
+
if (expr.step) {
|
|
3339
|
+
result.push(":".concat(expr.step));
|
|
3340
|
+
}
|
|
3341
|
+
if (!inUnion) {
|
|
3342
|
+
result.push("]");
|
|
3343
|
+
}
|
|
3344
|
+
return result.join("");
|
|
3345
|
+
}
|
|
3346
|
+
case "index":
|
|
3347
|
+
if (inUnion) {
|
|
3348
|
+
return "".concat(expr.value);
|
|
3349
|
+
}
|
|
3350
|
+
return "[".concat(expr.value, "]");
|
|
3351
|
+
case "constraint":
|
|
3352
|
+
{
|
|
3353
|
+
const rhs = expr.rhs ? " ".concat(toPathInner(expr.rhs, false)) : "";
|
|
3354
|
+
const inner = "".concat(toPathInner(expr.lhs, false), " ").concat(expr.operator).concat(rhs);
|
|
3355
|
+
if (inUnion) {
|
|
3356
|
+
return inner;
|
|
3357
|
+
}
|
|
3358
|
+
return "[".concat(inner, "]");
|
|
3359
|
+
}
|
|
3360
|
+
case "string":
|
|
3361
|
+
return JSON.stringify(expr.value);
|
|
3362
|
+
case "path":
|
|
3363
|
+
{
|
|
3364
|
+
const result = [];
|
|
3365
|
+
const nodes = expr.nodes.slice();
|
|
3366
|
+
while (nodes.length > 0) {
|
|
3367
|
+
const node = nodes.shift();
|
|
3368
|
+
if (node) {
|
|
3369
|
+
result.push(toPath(node));
|
|
3370
|
+
}
|
|
3371
|
+
const upcoming = nodes[0];
|
|
3372
|
+
if (upcoming && toPathInner(upcoming, false)[0] !== "[") {
|
|
3373
|
+
result.push(".");
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
return result.join("");
|
|
3377
|
+
}
|
|
3378
|
+
case "union":
|
|
3379
|
+
return "[".concat(expr.nodes.map(e => toPathInner(e, true)).join(","), "]");
|
|
3380
|
+
default:
|
|
3381
|
+
throw new Error("Unknown node type ".concat(expr.type));
|
|
3382
|
+
case "recursive":
|
|
3383
|
+
return "..".concat(toPathInner(expr.term, false));
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
var __defProp$f = Object.defineProperty;
|
|
3387
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, {
|
|
3388
|
+
enumerable: true,
|
|
3389
|
+
configurable: true,
|
|
3390
|
+
writable: true,
|
|
3391
|
+
value
|
|
3392
|
+
}) : obj[key] = value;
|
|
3393
|
+
var __publicField$f = (obj, key, value) => {
|
|
3394
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3395
|
+
return value;
|
|
3396
|
+
};
|
|
3397
|
+
class Expression {
|
|
3398
|
+
constructor(expr) {
|
|
3399
|
+
__publicField$f(this, "expr");
|
|
3400
|
+
if (!expr) {
|
|
3401
|
+
throw new Error("Attempted to create Expression from null-value");
|
|
3402
|
+
}
|
|
3403
|
+
if ("expr" in expr) {
|
|
3404
|
+
this.expr = expr.expr;
|
|
3405
|
+
} else {
|
|
3406
|
+
this.expr = expr;
|
|
3407
|
+
}
|
|
3408
|
+
if (!("type" in this.expr)) {
|
|
3409
|
+
throw new Error("Attempt to create Expression for expression with no type");
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
isPath() {
|
|
3413
|
+
return this.expr.type === "path";
|
|
3414
|
+
}
|
|
3415
|
+
isUnion() {
|
|
3416
|
+
return this.expr.type === "union";
|
|
3417
|
+
}
|
|
3418
|
+
isCollection() {
|
|
3419
|
+
return this.isPath() || this.isUnion();
|
|
3420
|
+
}
|
|
3421
|
+
isConstraint() {
|
|
3422
|
+
return this.expr.type === "constraint";
|
|
3423
|
+
}
|
|
3424
|
+
isRecursive() {
|
|
3425
|
+
return this.expr.type === "recursive";
|
|
3426
|
+
}
|
|
3427
|
+
isExistenceConstraint() {
|
|
3428
|
+
return this.expr.type === "constraint" && this.expr.operator === "?";
|
|
3429
|
+
}
|
|
3430
|
+
isIndex() {
|
|
3431
|
+
return this.expr.type === "index";
|
|
3432
|
+
}
|
|
3433
|
+
isRange() {
|
|
3434
|
+
return this.expr.type === "range";
|
|
3435
|
+
}
|
|
3436
|
+
expandRange(probe) {
|
|
3437
|
+
const probeLength = () => {
|
|
3438
|
+
if (!probe) {
|
|
3439
|
+
throw new Error("expandRange() required a probe that was not passed");
|
|
3440
|
+
}
|
|
3441
|
+
return probe.length();
|
|
3442
|
+
};
|
|
3443
|
+
let start = "start" in this.expr ? this.expr.start || 0 : 0;
|
|
3444
|
+
start = interpretNegativeIndex(start, probe);
|
|
3445
|
+
let end = "end" in this.expr ? this.expr.end || probeLength() : probeLength();
|
|
3446
|
+
end = interpretNegativeIndex(end, probe);
|
|
3447
|
+
const step = "step" in this.expr ? this.expr.step || 1 : 1;
|
|
3448
|
+
return {
|
|
3449
|
+
start,
|
|
3450
|
+
end,
|
|
3451
|
+
step
|
|
3452
|
+
};
|
|
3453
|
+
}
|
|
3454
|
+
isAttributeReference() {
|
|
3455
|
+
return this.expr.type === "attribute";
|
|
3456
|
+
}
|
|
3457
|
+
// Is a range or index -> something referencing indexes
|
|
3458
|
+
isIndexReference() {
|
|
3459
|
+
return this.isIndex() || this.isRange();
|
|
3460
|
+
}
|
|
3461
|
+
name() {
|
|
3462
|
+
return "name" in this.expr ? this.expr.name : "";
|
|
3463
|
+
}
|
|
3464
|
+
isSelfReference() {
|
|
3465
|
+
return this.expr.type === "alias" && this.expr.target === "self";
|
|
3466
|
+
}
|
|
3467
|
+
constraintTargetIsSelf() {
|
|
3468
|
+
return this.expr.type === "constraint" && this.expr.lhs.type === "alias" && this.expr.lhs.target === "self";
|
|
3469
|
+
}
|
|
3470
|
+
constraintTargetIsAttribute() {
|
|
3471
|
+
return this.expr.type === "constraint" && this.expr.lhs.type === "attribute";
|
|
3472
|
+
}
|
|
3473
|
+
testConstraint(probe) {
|
|
3474
|
+
const expr = this.expr;
|
|
3475
|
+
if (expr.type === "constraint" && expr.lhs.type === "alias" && expr.lhs.target === "self") {
|
|
3476
|
+
if (probe.containerType() !== "primitive") {
|
|
3477
|
+
return false;
|
|
3478
|
+
}
|
|
3479
|
+
if (expr.type === "constraint" && expr.operator === "?") {
|
|
3480
|
+
return true;
|
|
3481
|
+
}
|
|
3482
|
+
const lhs2 = probe.get();
|
|
3483
|
+
const rhs2 = expr.rhs && "value" in expr.rhs ? expr.rhs.value : void 0;
|
|
3484
|
+
return testBinaryOperator(lhs2, expr.operator, rhs2);
|
|
3485
|
+
}
|
|
3486
|
+
if (expr.type !== "constraint") {
|
|
3487
|
+
return false;
|
|
3488
|
+
}
|
|
3489
|
+
const lhs = expr.lhs;
|
|
3490
|
+
if (!lhs) {
|
|
3491
|
+
throw new Error("No LHS of expression");
|
|
3492
|
+
}
|
|
3493
|
+
if (lhs.type !== "attribute") {
|
|
3494
|
+
throw new Error("Constraint target ".concat(lhs.type, " not supported"));
|
|
3495
|
+
}
|
|
3496
|
+
if (probe.containerType() !== "object") {
|
|
3497
|
+
return false;
|
|
3498
|
+
}
|
|
3499
|
+
const lhsValue = probe.getAttribute(lhs.name);
|
|
3500
|
+
if (lhsValue === void 0 || lhsValue === null || lhsValue.containerType() !== "primitive") {
|
|
3501
|
+
return false;
|
|
3502
|
+
}
|
|
3503
|
+
if (this.isExistenceConstraint()) {
|
|
3504
|
+
return true;
|
|
3505
|
+
}
|
|
3506
|
+
const rhs = expr.rhs && "value" in expr.rhs ? expr.rhs.value : void 0;
|
|
3507
|
+
return testBinaryOperator(lhsValue.get(), expr.operator, rhs);
|
|
3508
|
+
}
|
|
3509
|
+
pathNodes() {
|
|
3510
|
+
return this.expr.type === "path" ? this.expr.nodes : [this.expr];
|
|
3511
|
+
}
|
|
3512
|
+
prepend(node) {
|
|
3513
|
+
if (!node) {
|
|
3514
|
+
return this;
|
|
3515
|
+
}
|
|
3516
|
+
return new Expression({
|
|
3517
|
+
type: "path",
|
|
3518
|
+
nodes: node.pathNodes().concat(this.pathNodes())
|
|
3519
|
+
});
|
|
3520
|
+
}
|
|
3521
|
+
concat(other) {
|
|
3522
|
+
return other ? other.prepend(this) : this;
|
|
3523
|
+
}
|
|
3524
|
+
descend() {
|
|
3525
|
+
return descend$1(this.expr).map(headTail => {
|
|
3526
|
+
const [head, tail] = headTail;
|
|
3527
|
+
return {
|
|
3528
|
+
head: head ? new Expression(head) : null,
|
|
3529
|
+
tail: tail ? new Expression(tail) : null
|
|
3530
|
+
};
|
|
3531
|
+
});
|
|
3532
|
+
}
|
|
3533
|
+
unwrapRecursive() {
|
|
3534
|
+
if (this.expr.type !== "recursive") {
|
|
3535
|
+
throw new Error("Attempt to unwrap recursive on type ".concat(this.expr.type));
|
|
3536
|
+
}
|
|
3537
|
+
return new Expression(this.expr.term);
|
|
3538
|
+
}
|
|
3539
|
+
toIndicies(probe) {
|
|
3540
|
+
if (this.expr.type !== "index" && this.expr.type !== "range") {
|
|
3541
|
+
throw new Error("Node cannot be converted to indexes");
|
|
3542
|
+
}
|
|
3543
|
+
if (this.expr.type === "index") {
|
|
3544
|
+
return [interpretNegativeIndex(this.expr.value, probe)];
|
|
3545
|
+
}
|
|
3546
|
+
const result = [];
|
|
3547
|
+
const range = this.expandRange(probe);
|
|
3548
|
+
let {
|
|
3549
|
+
start,
|
|
3550
|
+
end
|
|
3551
|
+
} = range;
|
|
3552
|
+
if (range.step < 0) {
|
|
3553
|
+
[start, end] = [end, start];
|
|
3554
|
+
}
|
|
3555
|
+
for (let i = start; i < end; i++) {
|
|
3556
|
+
result.push(i);
|
|
3557
|
+
}
|
|
3558
|
+
return result;
|
|
3559
|
+
}
|
|
3560
|
+
toFieldReferences() {
|
|
3561
|
+
if (this.isIndexReference()) {
|
|
3562
|
+
return this.toIndicies();
|
|
3563
|
+
}
|
|
3564
|
+
if (this.expr.type === "attribute") {
|
|
3565
|
+
return [this.expr.name];
|
|
3566
|
+
}
|
|
3567
|
+
throw new Error("Can't convert ".concat(this.expr.type, " to field references"));
|
|
3568
|
+
}
|
|
3569
|
+
toString() {
|
|
3570
|
+
return toPath(this.expr);
|
|
3571
|
+
}
|
|
3572
|
+
static fromPath(path) {
|
|
3573
|
+
const parsed = parseJsonPath(path);
|
|
3574
|
+
if (!parsed) {
|
|
3575
|
+
throw new Error('Failed to parse path "'.concat(path, '"'));
|
|
3576
|
+
}
|
|
3577
|
+
return new Expression(parsed);
|
|
3578
|
+
}
|
|
3579
|
+
static attributeReference(name) {
|
|
3580
|
+
return new Expression({
|
|
3581
|
+
type: "attribute",
|
|
3582
|
+
name
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3585
|
+
static indexReference(i) {
|
|
3586
|
+
return new Expression({
|
|
3587
|
+
type: "index",
|
|
3588
|
+
value: i
|
|
3589
|
+
});
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
function testBinaryOperator(lhsValue, operator, rhsValue) {
|
|
3593
|
+
switch (operator) {
|
|
3594
|
+
case ">":
|
|
3595
|
+
return lhsValue > rhsValue;
|
|
3596
|
+
case ">=":
|
|
3597
|
+
return lhsValue >= rhsValue;
|
|
3598
|
+
case "<":
|
|
3599
|
+
return lhsValue < rhsValue;
|
|
3600
|
+
case "<=":
|
|
3601
|
+
return lhsValue <= rhsValue;
|
|
3602
|
+
case "==":
|
|
3603
|
+
return lhsValue === rhsValue;
|
|
3604
|
+
case "!=":
|
|
3605
|
+
return lhsValue !== rhsValue;
|
|
3606
|
+
default:
|
|
3607
|
+
throw new Error("Unsupported binary operator ".concat(operator));
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
function interpretNegativeIndex(index, probe) {
|
|
3611
|
+
if (index >= 0) {
|
|
3612
|
+
return index;
|
|
3613
|
+
}
|
|
3614
|
+
if (!probe) {
|
|
3615
|
+
throw new Error("interpretNegativeIndex() must have a probe when < 0");
|
|
3616
|
+
}
|
|
3617
|
+
return index + probe.length();
|
|
3618
|
+
}
|
|
3619
|
+
var __defProp$e = Object.defineProperty;
|
|
3620
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, {
|
|
3621
|
+
enumerable: true,
|
|
3622
|
+
configurable: true,
|
|
3623
|
+
writable: true,
|
|
3624
|
+
value
|
|
3625
|
+
}) : obj[key] = value;
|
|
3626
|
+
var __publicField$e = (obj, key, value) => {
|
|
3627
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3628
|
+
return value;
|
|
3629
|
+
};
|
|
3630
|
+
class Descender {
|
|
3631
|
+
constructor(head, tail) {
|
|
3632
|
+
__publicField$e(this, "head");
|
|
3633
|
+
__publicField$e(this, "tail");
|
|
3634
|
+
this.head = head;
|
|
3635
|
+
this.tail = tail;
|
|
3636
|
+
}
|
|
3637
|
+
// Iterate this descender once processing any constraints that are
|
|
3638
|
+
// resolvable on the current value. Returns an array of new descenders
|
|
3639
|
+
// that are guaranteed to be without constraints in the head
|
|
3640
|
+
iterate(probe) {
|
|
3641
|
+
let result = [this];
|
|
3642
|
+
if (this.head && this.head.isConstraint()) {
|
|
3643
|
+
let anyConstraints = true;
|
|
3644
|
+
while (anyConstraints) {
|
|
3645
|
+
result = flatten$1(result.map(descender => {
|
|
3646
|
+
return descender.iterateConstraints(probe);
|
|
3647
|
+
}));
|
|
3648
|
+
anyConstraints = result.some(descender => {
|
|
3649
|
+
return descender.head && descender.head.isConstraint();
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
return result;
|
|
3654
|
+
}
|
|
3655
|
+
isRecursive() {
|
|
3656
|
+
return Boolean(this.head && this.head.isRecursive());
|
|
3657
|
+
}
|
|
3658
|
+
hasArrived() {
|
|
3659
|
+
return this.head === null && this.tail === null;
|
|
3660
|
+
}
|
|
3661
|
+
extractRecursives() {
|
|
3662
|
+
if (this.head && this.head.isRecursive()) {
|
|
3663
|
+
const term = this.head.unwrapRecursive();
|
|
3664
|
+
return new Descender(null, term.concat(this.tail)).descend();
|
|
3665
|
+
}
|
|
3666
|
+
return [];
|
|
3667
|
+
}
|
|
3668
|
+
iterateConstraints(probe) {
|
|
3669
|
+
const head = this.head;
|
|
3670
|
+
if (head === null || !head.isConstraint()) {
|
|
3671
|
+
return [this];
|
|
3672
|
+
}
|
|
3673
|
+
const result = [];
|
|
3674
|
+
if (probe.containerType() === "primitive" && head.constraintTargetIsSelf()) {
|
|
3675
|
+
if (head.testConstraint(probe)) {
|
|
3676
|
+
result.push(...this.descend());
|
|
3677
|
+
}
|
|
3678
|
+
return result;
|
|
3679
|
+
}
|
|
3680
|
+
if (probe.containerType() === "array") {
|
|
3681
|
+
const length = probe.length();
|
|
3682
|
+
for (let i = 0; i < length; i++) {
|
|
3683
|
+
const constraint = probe.getIndex(i);
|
|
3684
|
+
if (constraint && head.testConstraint(constraint)) {
|
|
3685
|
+
result.push(new Descender(new Expression({
|
|
3686
|
+
type: "index",
|
|
3687
|
+
value: i
|
|
3688
|
+
}), this.tail));
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
return result;
|
|
3692
|
+
}
|
|
3693
|
+
if (probe.containerType() === "object") {
|
|
3694
|
+
if (head.constraintTargetIsSelf()) {
|
|
3695
|
+
return [];
|
|
3696
|
+
}
|
|
3697
|
+
if (head.testConstraint(probe)) {
|
|
3698
|
+
return this.descend();
|
|
3699
|
+
}
|
|
3700
|
+
return result;
|
|
3701
|
+
}
|
|
3702
|
+
return result;
|
|
3703
|
+
}
|
|
3704
|
+
descend() {
|
|
3705
|
+
if (!this.tail) {
|
|
3706
|
+
return [new Descender(null, null)];
|
|
3707
|
+
}
|
|
3708
|
+
return this.tail.descend().map(ht => {
|
|
3709
|
+
return new Descender(ht.head, ht.tail);
|
|
3710
|
+
});
|
|
3711
|
+
}
|
|
3712
|
+
toString() {
|
|
3713
|
+
const result = ["<"];
|
|
3714
|
+
if (this.head) {
|
|
3715
|
+
result.push(this.head.toString());
|
|
3716
|
+
}
|
|
3717
|
+
result.push("|");
|
|
3718
|
+
if (this.tail) {
|
|
3719
|
+
result.push(this.tail.toString());
|
|
3720
|
+
}
|
|
3721
|
+
result.push(">");
|
|
3722
|
+
return result.join("");
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
var __defProp$d = Object.defineProperty;
|
|
3726
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, {
|
|
3727
|
+
enumerable: true,
|
|
3728
|
+
configurable: true,
|
|
3729
|
+
writable: true,
|
|
3730
|
+
value
|
|
3731
|
+
}) : obj[key] = value;
|
|
3732
|
+
var __publicField$d = (obj, key, value) => {
|
|
3733
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3734
|
+
return value;
|
|
3735
|
+
};
|
|
3736
|
+
class Matcher {
|
|
3737
|
+
constructor(active, parent) {
|
|
3738
|
+
__publicField$d(this, "active");
|
|
3739
|
+
__publicField$d(this, "recursives");
|
|
3740
|
+
__publicField$d(this, "payload");
|
|
3741
|
+
this.active = active || [];
|
|
3742
|
+
if (parent) {
|
|
3743
|
+
this.recursives = parent.recursives;
|
|
3744
|
+
this.payload = parent.payload;
|
|
3745
|
+
} else {
|
|
3746
|
+
this.recursives = [];
|
|
3747
|
+
}
|
|
3748
|
+
this.extractRecursives();
|
|
3749
|
+
}
|
|
3750
|
+
setPayload(payload) {
|
|
3751
|
+
this.payload = payload;
|
|
3752
|
+
return this;
|
|
3753
|
+
}
|
|
3754
|
+
// Moves any recursive descenders onto the recursive track, removing them from
|
|
3755
|
+
// the active set
|
|
3756
|
+
extractRecursives() {
|
|
3757
|
+
this.active = this.active.filter(descender => {
|
|
3758
|
+
if (descender.isRecursive()) {
|
|
3759
|
+
this.recursives.push(...descender.extractRecursives());
|
|
3760
|
+
return false;
|
|
3761
|
+
}
|
|
3762
|
+
return true;
|
|
3763
|
+
});
|
|
3764
|
+
}
|
|
3765
|
+
// Find recursives that are relevant now and should be considered part of the active set
|
|
3766
|
+
activeRecursives(probe) {
|
|
3767
|
+
return this.recursives.filter(descender => {
|
|
3768
|
+
const head = descender.head;
|
|
3769
|
+
if (!head) {
|
|
3770
|
+
return false;
|
|
3771
|
+
}
|
|
3772
|
+
if (head.isConstraint()) {
|
|
3773
|
+
return true;
|
|
3774
|
+
}
|
|
3775
|
+
if (probe.containerType() === "array" && head.isIndexReference()) {
|
|
3776
|
+
return true;
|
|
3777
|
+
}
|
|
3778
|
+
if (probe.containerType() === "object") {
|
|
3779
|
+
return head.isAttributeReference() && probe.hasAttribute(head.name());
|
|
3780
|
+
}
|
|
3781
|
+
return false;
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
match(probe) {
|
|
3785
|
+
return this.iterate(probe).extractMatches(probe);
|
|
3786
|
+
}
|
|
3787
|
+
iterate(probe) {
|
|
3788
|
+
const newActiveSet = [];
|
|
3789
|
+
this.active.concat(this.activeRecursives(probe)).forEach(descender => {
|
|
3790
|
+
newActiveSet.push(...descender.iterate(probe));
|
|
3791
|
+
});
|
|
3792
|
+
return new Matcher(newActiveSet, this);
|
|
3793
|
+
}
|
|
3794
|
+
// Returns true if any of the descenders in the active or recursive set
|
|
3795
|
+
// consider the current state a final destination
|
|
3796
|
+
isDestination() {
|
|
3797
|
+
return this.active.some(descender => descender.hasArrived());
|
|
3798
|
+
}
|
|
3799
|
+
hasRecursives() {
|
|
3800
|
+
return this.recursives.length > 0;
|
|
3801
|
+
}
|
|
3802
|
+
// Returns any payload delivieries and leads that needs to be followed to complete
|
|
3803
|
+
// the process.
|
|
3804
|
+
extractMatches(probe) {
|
|
3805
|
+
const leads = [];
|
|
3806
|
+
const targets = [];
|
|
3807
|
+
this.active.forEach(descender => {
|
|
3808
|
+
if (descender.hasArrived()) {
|
|
3809
|
+
targets.push(new Expression({
|
|
3810
|
+
type: "alias",
|
|
3811
|
+
target: "self"
|
|
3812
|
+
}));
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
const descenderHead = descender.head;
|
|
3816
|
+
if (!descenderHead) {
|
|
3817
|
+
return;
|
|
3818
|
+
}
|
|
3819
|
+
if (probe.containerType() === "array" && !descenderHead.isIndexReference()) {
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3822
|
+
if (probe.containerType() === "object" && !descenderHead.isAttributeReference()) {
|
|
3823
|
+
return;
|
|
3824
|
+
}
|
|
3825
|
+
if (descender.tail) {
|
|
3826
|
+
const matcher = new Matcher(descender.descend(), this);
|
|
3827
|
+
descenderHead.toFieldReferences().forEach(() => {
|
|
3828
|
+
leads.push({
|
|
3829
|
+
target: descenderHead,
|
|
3830
|
+
matcher
|
|
3831
|
+
});
|
|
3832
|
+
});
|
|
3833
|
+
} else {
|
|
3834
|
+
targets.push(descenderHead);
|
|
3835
|
+
}
|
|
3836
|
+
});
|
|
3837
|
+
if (this.hasRecursives()) {
|
|
3838
|
+
const recursivesMatcher = new Matcher([], this);
|
|
3839
|
+
if (probe.containerType() === "array") {
|
|
3840
|
+
const length = probe.length();
|
|
3841
|
+
for (let i = 0; i < length; i++) {
|
|
3842
|
+
leads.push({
|
|
3843
|
+
target: Expression.indexReference(i),
|
|
3844
|
+
matcher: recursivesMatcher
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
} else if (probe.containerType() === "object") {
|
|
3848
|
+
probe.attributeKeys().forEach(name => {
|
|
3849
|
+
leads.push({
|
|
3850
|
+
target: Expression.attributeReference(name),
|
|
3851
|
+
matcher: recursivesMatcher
|
|
3852
|
+
});
|
|
3853
|
+
});
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
return targets.length > 0 ? {
|
|
3857
|
+
leads,
|
|
3858
|
+
delivery: {
|
|
3859
|
+
targets,
|
|
3860
|
+
payload: this.payload
|
|
3861
|
+
}
|
|
3862
|
+
} : {
|
|
3863
|
+
leads
|
|
3864
|
+
};
|
|
3865
|
+
}
|
|
3866
|
+
static fromPath(jsonpath) {
|
|
3867
|
+
const path = parseJsonPath(jsonpath);
|
|
3868
|
+
if (!path) {
|
|
3869
|
+
throw new Error('Failed to parse path from "'.concat(jsonpath, '"'));
|
|
3870
|
+
}
|
|
3871
|
+
const descender = new Descender(null, new Expression(path));
|
|
3872
|
+
return new Matcher(descender.descend());
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
function isRecord$1(value) {
|
|
3876
|
+
return value !== null && typeof value === "object";
|
|
3877
|
+
}
|
|
3878
|
+
var __defProp$c = Object.defineProperty;
|
|
3879
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, {
|
|
3880
|
+
enumerable: true,
|
|
3881
|
+
configurable: true,
|
|
3882
|
+
writable: true,
|
|
3883
|
+
value
|
|
3884
|
+
}) : obj[key] = value;
|
|
3885
|
+
var __publicField$c = (obj, key, value) => {
|
|
3886
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3887
|
+
return value;
|
|
3888
|
+
};
|
|
3889
|
+
class PlainProbe {
|
|
3890
|
+
constructor(value, path) {
|
|
3891
|
+
__publicField$c(this, "_value");
|
|
3892
|
+
__publicField$c(this, "path");
|
|
3893
|
+
this._value = value;
|
|
3894
|
+
this.path = path || [];
|
|
3895
|
+
}
|
|
3896
|
+
containerType() {
|
|
3897
|
+
if (Array.isArray(this._value)) {
|
|
3898
|
+
return "array";
|
|
3899
|
+
} else if (this._value !== null && typeof this._value === "object") {
|
|
3900
|
+
return "object";
|
|
3901
|
+
}
|
|
3902
|
+
return "primitive";
|
|
3903
|
+
}
|
|
3904
|
+
length() {
|
|
3905
|
+
if (!Array.isArray(this._value)) {
|
|
3906
|
+
throw new Error("Won't return length of non-indexable _value");
|
|
3907
|
+
}
|
|
3908
|
+
return this._value.length;
|
|
3909
|
+
}
|
|
3910
|
+
getIndex(i) {
|
|
3911
|
+
if (!Array.isArray(this._value)) {
|
|
3912
|
+
return false;
|
|
3913
|
+
}
|
|
3914
|
+
if (i >= this.length()) {
|
|
3915
|
+
return null;
|
|
3916
|
+
}
|
|
3917
|
+
return new PlainProbe(this._value[i], this.path.concat(i));
|
|
3918
|
+
}
|
|
3919
|
+
hasAttribute(key) {
|
|
3920
|
+
if (!isRecord$1(this._value)) {
|
|
3921
|
+
return false;
|
|
3922
|
+
}
|
|
3923
|
+
return this._value.hasOwnProperty(key);
|
|
3924
|
+
}
|
|
3925
|
+
attributeKeys() {
|
|
3926
|
+
return isRecord$1(this._value) ? Object.keys(this._value) : [];
|
|
3927
|
+
}
|
|
3928
|
+
getAttribute(key) {
|
|
3929
|
+
if (!isRecord$1(this._value)) {
|
|
3930
|
+
throw new Error("getAttribute only applies to plain objects");
|
|
3931
|
+
}
|
|
3932
|
+
if (!this.hasAttribute(key)) {
|
|
3933
|
+
return null;
|
|
3934
|
+
}
|
|
3935
|
+
return new PlainProbe(this._value[key], this.path.concat(key));
|
|
3936
|
+
}
|
|
3937
|
+
get() {
|
|
3938
|
+
return this._value;
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
function extractAccessors(path, value) {
|
|
3942
|
+
const result = [];
|
|
3943
|
+
const matcher = Matcher.fromPath(path).setPayload(function appendResult(values) {
|
|
3944
|
+
result.push(...values);
|
|
3945
|
+
});
|
|
3946
|
+
const accessor = new PlainProbe(value);
|
|
3947
|
+
descend(matcher, accessor);
|
|
3948
|
+
return result;
|
|
3949
|
+
}
|
|
3950
|
+
function descend(matcher, accessor) {
|
|
3951
|
+
const {
|
|
3952
|
+
leads,
|
|
3953
|
+
delivery
|
|
3954
|
+
} = matcher.match(accessor);
|
|
3955
|
+
leads.forEach(lead => {
|
|
3956
|
+
accessorsFromTarget(lead.target, accessor).forEach(childAccessor => {
|
|
3957
|
+
descend(lead.matcher, childAccessor);
|
|
3958
|
+
});
|
|
3959
|
+
});
|
|
3960
|
+
if (delivery) {
|
|
3961
|
+
delivery.targets.forEach(target => {
|
|
3962
|
+
if (typeof delivery.payload === "function") {
|
|
3963
|
+
delivery.payload(accessorsFromTarget(target, accessor));
|
|
3964
|
+
}
|
|
3965
|
+
});
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
function accessorsFromTarget(target, accessor) {
|
|
3969
|
+
const result = [];
|
|
3970
|
+
if (target.isIndexReference()) {
|
|
3971
|
+
target.toIndicies(accessor).forEach(i => {
|
|
3972
|
+
result.push(accessor.getIndex(i));
|
|
3973
|
+
});
|
|
3974
|
+
} else if (target.isAttributeReference()) {
|
|
3975
|
+
result.push(accessor.getAttribute(target.name()));
|
|
3976
|
+
} else if (target.isSelfReference()) {
|
|
3977
|
+
result.push(accessor);
|
|
3978
|
+
} else {
|
|
3979
|
+
throw new Error("Unable to derive accessor for target ".concat(target.toString()));
|
|
3980
|
+
}
|
|
3981
|
+
return compact$1(result);
|
|
3982
|
+
}
|
|
3983
|
+
function extractWithPath(path, value) {
|
|
3984
|
+
const accessors = extractAccessors(path, value);
|
|
3985
|
+
return accessors.map(acc => ({
|
|
3986
|
+
path: acc.path,
|
|
3987
|
+
value: acc.get()
|
|
3988
|
+
}));
|
|
3989
|
+
}
|
|
3990
|
+
debugIt("mutator-document");
|
|
3991
|
+
const maxDepth = 6;
|
|
510
3992
|
function getTypeIcon(schemaType) {
|
|
511
3993
|
let t = schemaType;
|
|
512
3994
|
while (t) {
|
|
@@ -542,19 +4024,76 @@ function getFieldRefs(schemaType, parent) {
|
|
|
542
4024
|
const path = parent ? [...parent.path, field.name] : [field.name];
|
|
543
4025
|
const title = (_a = field.type.title) != null ? _a : field.name;
|
|
544
4026
|
const fieldRef = {
|
|
545
|
-
key: pathToString(path),
|
|
4027
|
+
key: patchableKey(pathToString(path)),
|
|
546
4028
|
path,
|
|
547
4029
|
title: parent ? [parent.title, title].join(" / ") : title,
|
|
548
4030
|
schemaType: field.type,
|
|
549
4031
|
icon: getTypeIcon(field.type)
|
|
550
4032
|
};
|
|
551
4033
|
const fields = field.type.jsonType === "object" ? getFieldRefs(field.type, fieldRef, depth + 1) : [];
|
|
4034
|
+
const syntheticFields = field.type.jsonType === "array" ? getSyntheticFields(field.type, fieldRef, depth + 1) : [];
|
|
552
4035
|
if (!isAssistSupported(field.type, true)) {
|
|
4036
|
+
return [...fields, ...syntheticFields];
|
|
4037
|
+
}
|
|
4038
|
+
return [fieldRef, ...fields, ...syntheticFields];
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
function getSyntheticFields(schemaType, parent) {
|
|
4042
|
+
let depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
4043
|
+
if (depth >= maxDepth) {
|
|
4044
|
+
return [];
|
|
4045
|
+
}
|
|
4046
|
+
return schemaType.of.filter(itemType => !isType(itemType, "block")).flatMap(itemType => {
|
|
4047
|
+
var _a;
|
|
4048
|
+
const segment = {
|
|
4049
|
+
_key: itemType.name
|
|
4050
|
+
};
|
|
4051
|
+
const title = (_a = itemType.title) != null ? _a : itemType.name;
|
|
4052
|
+
const path = parent ? [...parent.path, segment] : [segment];
|
|
4053
|
+
const fieldRef = {
|
|
4054
|
+
key: patchableKey(pathToString(path)),
|
|
4055
|
+
path,
|
|
4056
|
+
title: parent ? [parent.title, title].join(" / ") : title,
|
|
4057
|
+
schemaType: itemType,
|
|
4058
|
+
icon: getTypeIcon(itemType),
|
|
4059
|
+
synthetic: true
|
|
4060
|
+
};
|
|
4061
|
+
const fields = itemType.jsonType === "object" ? getFieldRefs(itemType, fieldRef, depth + 1) : [];
|
|
4062
|
+
if (!isAssistSupported(itemType, true)) {
|
|
553
4063
|
return fields;
|
|
554
4064
|
}
|
|
555
4065
|
return [fieldRef, ...fields];
|
|
556
4066
|
});
|
|
557
4067
|
}
|
|
4068
|
+
function getTypePath(doc, pathString) {
|
|
4069
|
+
if (!pathString) {
|
|
4070
|
+
return void 0;
|
|
4071
|
+
}
|
|
4072
|
+
const path = stringToPath(pathString);
|
|
4073
|
+
const currentPath = [];
|
|
4074
|
+
let valid = true;
|
|
4075
|
+
const syntheticPath = path.map(segment => {
|
|
4076
|
+
currentPath.push(segment);
|
|
4077
|
+
if (isKeySegment(segment)) {
|
|
4078
|
+
const match = extractWithPath(pathToString(currentPath), doc)[0];
|
|
4079
|
+
const value = match == null ? void 0 : match.value;
|
|
4080
|
+
if (match && value && typeof value === "object" && "_type" in value) {
|
|
4081
|
+
return {
|
|
4082
|
+
_key: value._type
|
|
4083
|
+
};
|
|
4084
|
+
}
|
|
4085
|
+
valid = false;
|
|
4086
|
+
}
|
|
4087
|
+
return segment;
|
|
4088
|
+
});
|
|
4089
|
+
return valid ? patchableKey(pathToString(syntheticPath)) : void 0;
|
|
4090
|
+
}
|
|
4091
|
+
function patchableKey(pathKey) {
|
|
4092
|
+
return pathKey.replace(/[=]=/g, ":").replace(/[[\]]/g, "|").replace(/"/g, "");
|
|
4093
|
+
}
|
|
4094
|
+
function useTypePath(doc, pathString) {
|
|
4095
|
+
return useMemo(() => getTypePath(doc, pathString), [doc, pathString]);
|
|
4096
|
+
}
|
|
558
4097
|
function useSelectedField(documentSchemaType, path) {
|
|
559
4098
|
const selectableFields = useMemo(() => documentSchemaType && isObjectSchemaType(documentSchemaType) ? getFieldRefsWithDocument(documentSchemaType) : [], [documentSchemaType]);
|
|
560
4099
|
return useMemo(() => {
|
|
@@ -562,9 +4101,9 @@ function useSelectedField(documentSchemaType, path) {
|
|
|
562
4101
|
}, [selectableFields, path]);
|
|
563
4102
|
}
|
|
564
4103
|
function getFieldTitle(field) {
|
|
565
|
-
var _a, _b;
|
|
4104
|
+
var _a, _b, _c;
|
|
566
4105
|
const schemaType = field == null ? void 0 : field.schemaType;
|
|
567
|
-
return (_b = (_a = schemaType == null ? void 0 : schemaType.title) != null ?
|
|
4106
|
+
return (_c = (_b = (_a = field == null ? void 0 : field.title) != null ? _a : schemaType == null ? void 0 : schemaType.title) != null ? _b : schemaType == null ? void 0 : schemaType.name) != null ? _c : "Untitled";
|
|
568
4107
|
}
|
|
569
4108
|
function useAiPaneRouter() {
|
|
570
4109
|
const paneRouter = usePaneRouter();
|
|
@@ -836,7 +4375,7 @@ function TaskList(props) {
|
|
|
836
4375
|
onEscape();
|
|
837
4376
|
}
|
|
838
4377
|
}, [isTopLayer, onEscape]));
|
|
839
|
-
return /* @__PURE__ */jsx(Stack, {
|
|
4378
|
+
return /* @__PURE__ */jsx(Stack$1, {
|
|
840
4379
|
padding: 1,
|
|
841
4380
|
space: 1,
|
|
842
4381
|
children: tasks.map(task => /* @__PURE__ */jsx(TaskItem, {
|
|
@@ -867,7 +4406,7 @@ function TaskItem(props) {
|
|
|
867
4406
|
size: 1,
|
|
868
4407
|
children: [taskType && createElement(taskType.icon), !task.reason && /* @__PURE__ */jsx(Spinner, {})]
|
|
869
4408
|
})
|
|
870
|
-
}), /* @__PURE__ */jsxs(Stack, {
|
|
4409
|
+
}), /* @__PURE__ */jsxs(Stack$1, {
|
|
871
4410
|
flex: 1,
|
|
872
4411
|
space: 2,
|
|
873
4412
|
children: [/* @__PURE__ */jsxs(Text, {
|
|
@@ -1209,7 +4748,7 @@ function RunInstructionProvider(props) {
|
|
|
1209
4748
|
})
|
|
1210
4749
|
}) : runButton
|
|
1211
4750
|
}),
|
|
1212
|
-
children: /* @__PURE__ */jsx(Stack, {
|
|
4751
|
+
children: /* @__PURE__ */jsx(Stack$1, {
|
|
1213
4752
|
padding: 4,
|
|
1214
4753
|
space: 2,
|
|
1215
4754
|
children: (_a = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a.map((block, i) => /* @__PURE__ */jsx(UserInput, {
|
|
@@ -1251,7 +4790,7 @@ function UserInput(props) {
|
|
|
1251
4790
|
return (_a2 = textAreaRef.current) == null ? void 0 : _a2.focus();
|
|
1252
4791
|
}, 0);
|
|
1253
4792
|
}, [autoFocus]);
|
|
1254
|
-
return /* @__PURE__ */jsxs(Stack, {
|
|
4793
|
+
return /* @__PURE__ */jsxs(Stack$1, {
|
|
1255
4794
|
padding: 2,
|
|
1256
4795
|
space: 3,
|
|
1257
4796
|
children: [/* @__PURE__ */jsx(FormFieldHeaderText, {
|
|
@@ -1268,114 +4807,420 @@ function UserInput(props) {
|
|
|
1268
4807
|
})]
|
|
1269
4808
|
});
|
|
1270
4809
|
}
|
|
1271
|
-
function isDocAssistable(documentSchemaType, published, draft) {
|
|
1272
|
-
return !!(documentSchemaType.liveEdit ? published : draft);
|
|
1273
|
-
}
|
|
1274
|
-
function getAssistableDocId(documentSchemaType, documentId) {
|
|
1275
|
-
const baseId = publicId(documentId);
|
|
1276
|
-
return documentSchemaType.liveEdit ? baseId : "drafts.".concat(baseId);
|
|
4810
|
+
function isDocAssistable(documentSchemaType, published, draft) {
|
|
4811
|
+
return !!(documentSchemaType.liveEdit ? published : draft);
|
|
4812
|
+
}
|
|
4813
|
+
function getAssistableDocId(documentSchemaType, documentId) {
|
|
4814
|
+
const baseId = publicId(documentId);
|
|
4815
|
+
return documentSchemaType.liveEdit ? baseId : "drafts.".concat(baseId);
|
|
4816
|
+
}
|
|
4817
|
+
function useRequestRunInstruction(args) {
|
|
4818
|
+
const {
|
|
4819
|
+
documentOnChange,
|
|
4820
|
+
isDocAssistable: isDocAssistable2
|
|
4821
|
+
} = args;
|
|
4822
|
+
const {
|
|
4823
|
+
runInstruction,
|
|
4824
|
+
instructionLoading
|
|
4825
|
+
} = useRunInstruction();
|
|
4826
|
+
const [queuedTask, setQueuedTask] = useState(void 0);
|
|
4827
|
+
useEffect(() => {
|
|
4828
|
+
if (queuedTask && isDocAssistable2) {
|
|
4829
|
+
runInstruction(queuedTask);
|
|
4830
|
+
setQueuedTask(void 0);
|
|
4831
|
+
}
|
|
4832
|
+
}, [queuedTask, isDocAssistable2, runInstruction]);
|
|
4833
|
+
return {
|
|
4834
|
+
instructionLoading,
|
|
4835
|
+
requestRunInstruction: useCallback(task => {
|
|
4836
|
+
documentOnChange(PatchEvent.from([unset(["_force_document_creation"])]));
|
|
4837
|
+
setQueuedTask(task);
|
|
4838
|
+
}, [setQueuedTask, documentOnChange])
|
|
4839
|
+
};
|
|
4840
|
+
}
|
|
4841
|
+
const SparklesIllustration = styled(SparklesIcon)({
|
|
4842
|
+
fontSize: "3.125em",
|
|
4843
|
+
"& path": {
|
|
4844
|
+
strokeWidth: "0.6px !important"
|
|
4845
|
+
}
|
|
4846
|
+
});
|
|
4847
|
+
function InspectorOnboarding(props) {
|
|
4848
|
+
const {
|
|
4849
|
+
onDismiss
|
|
4850
|
+
} = props;
|
|
4851
|
+
return /* @__PURE__ */jsx(Box, {
|
|
4852
|
+
padding: 4,
|
|
4853
|
+
children: /* @__PURE__ */jsx(Container, {
|
|
4854
|
+
width: 0,
|
|
4855
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
4856
|
+
space: 4,
|
|
4857
|
+
children: [/* @__PURE__ */jsx("div", {
|
|
4858
|
+
style: {
|
|
4859
|
+
textAlign: "center"
|
|
4860
|
+
},
|
|
4861
|
+
children: /* @__PURE__ */jsx(SparklesIllustration, {})
|
|
4862
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4863
|
+
align: "center",
|
|
4864
|
+
size: 1,
|
|
4865
|
+
children: "Create reusable AI instructions that can be applied across all documents of a certain type."
|
|
4866
|
+
}), /* @__PURE__ */jsxs(Flex, {
|
|
4867
|
+
align: "center",
|
|
4868
|
+
gap: 2,
|
|
4869
|
+
justify: "center",
|
|
4870
|
+
children: [/* @__PURE__ */jsx(Button, {
|
|
4871
|
+
as: "a",
|
|
4872
|
+
href: releaseAnnouncementUrl,
|
|
4873
|
+
rel: "noreferrer",
|
|
4874
|
+
target: "_blank",
|
|
4875
|
+
fontSize: 1,
|
|
4876
|
+
mode: "default",
|
|
4877
|
+
onClick: onDismiss,
|
|
4878
|
+
padding: 2,
|
|
4879
|
+
text: "Learn more",
|
|
4880
|
+
tone: "primary"
|
|
4881
|
+
}), /* @__PURE__ */jsx(Button, {
|
|
4882
|
+
fontSize: 1,
|
|
4883
|
+
mode: "bleed",
|
|
4884
|
+
onClick: onDismiss,
|
|
4885
|
+
padding: 2,
|
|
4886
|
+
text: "Dismiss"
|
|
4887
|
+
})]
|
|
4888
|
+
})]
|
|
4889
|
+
})
|
|
4890
|
+
})
|
|
4891
|
+
});
|
|
4892
|
+
}
|
|
4893
|
+
const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed";
|
|
4894
|
+
const fieldOnboardingKey = "sanityStudio:assist:field:onboarding:dismissed";
|
|
4895
|
+
function isFeatureOnboardingDismissed(featureKey) {
|
|
4896
|
+
if (typeof localStorage === "undefined") {
|
|
4897
|
+
return false;
|
|
4898
|
+
}
|
|
4899
|
+
const value = localStorage.getItem(featureKey);
|
|
4900
|
+
return value === "true";
|
|
4901
|
+
}
|
|
4902
|
+
function dismissFeatureOnboarding(featureKey) {
|
|
4903
|
+
if (typeof localStorage === "undefined") {
|
|
4904
|
+
return;
|
|
4905
|
+
}
|
|
4906
|
+
localStorage.setItem(featureKey, "true");
|
|
4907
|
+
}
|
|
4908
|
+
function useOnboardingFeature(featureKey) {
|
|
4909
|
+
const [showOnboarding, setShowOnboarding] = useState(() => !isFeatureOnboardingDismissed(featureKey));
|
|
4910
|
+
const dismissOnboarding = useCallback(() => {
|
|
4911
|
+
setShowOnboarding(false);
|
|
4912
|
+
dismissFeatureOnboarding(featureKey);
|
|
4913
|
+
}, [setShowOnboarding, featureKey]);
|
|
4914
|
+
return {
|
|
4915
|
+
showOnboarding,
|
|
4916
|
+
dismissOnboarding
|
|
4917
|
+
};
|
|
4918
|
+
}
|
|
4919
|
+
function BackToInstructionListLink() {
|
|
4920
|
+
const {
|
|
4921
|
+
openInspector
|
|
4922
|
+
} = useDocumentPane();
|
|
4923
|
+
const goBack = useCallback(() => openInspector(aiInspectorId, {
|
|
4924
|
+
[instructionParam]: void 0
|
|
4925
|
+
}), [openInspector]);
|
|
4926
|
+
return /* @__PURE__ */jsx("div", {
|
|
4927
|
+
children: /* @__PURE__ */jsx(Button, {
|
|
4928
|
+
as: "a",
|
|
4929
|
+
fontSize: 1,
|
|
4930
|
+
icon: ArrowLeftIcon,
|
|
4931
|
+
mode: "bleed",
|
|
4932
|
+
padding: 1,
|
|
4933
|
+
space: 2,
|
|
4934
|
+
onClick: goBack,
|
|
4935
|
+
text: " Instructions",
|
|
4936
|
+
textAlign: "left"
|
|
4937
|
+
})
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
const EMPTY_FIELDS = [];
|
|
4941
|
+
const TypePathContext = createContext(void 0);
|
|
4942
|
+
function AssistDocumentForm(props) {
|
|
4943
|
+
const {
|
|
4944
|
+
onChange
|
|
4945
|
+
} = props;
|
|
4946
|
+
const value = props.value;
|
|
4947
|
+
const id = value == null ? void 0 : value._id;
|
|
4948
|
+
const fields = value == null ? void 0 : value.fields;
|
|
4949
|
+
const targetDocumentType = useMemo(() => {
|
|
4950
|
+
if (!id) {
|
|
4951
|
+
return void 0;
|
|
4952
|
+
}
|
|
4953
|
+
return documentTypeFromAiDocumentId(id);
|
|
4954
|
+
}, [id]);
|
|
4955
|
+
const {
|
|
4956
|
+
params,
|
|
4957
|
+
setParams
|
|
4958
|
+
} = useAiPaneRouter();
|
|
4959
|
+
const pathKey = params[fieldPathParam];
|
|
4960
|
+
const typePath = useContext(TypePathContext);
|
|
4961
|
+
const instruction = params[instructionParam];
|
|
4962
|
+
const activeKey = useMemo(() => {
|
|
4963
|
+
var _a;
|
|
4964
|
+
if (!typePath) {
|
|
4965
|
+
return void 0;
|
|
4966
|
+
}
|
|
4967
|
+
return (_a = (fields != null ? fields : EMPTY_FIELDS).find(f => f.path === typePath)) == null ? void 0 : _a._key;
|
|
4968
|
+
}, [fields, typePath]);
|
|
4969
|
+
const activePath = useMemo(() => {
|
|
4970
|
+
if (!activeKey) {
|
|
4971
|
+
return void 0;
|
|
4972
|
+
}
|
|
4973
|
+
const base = ["fields", {
|
|
4974
|
+
_key: activeKey
|
|
4975
|
+
}];
|
|
4976
|
+
return instruction ? [...base, "instructions", {
|
|
4977
|
+
_key: instruction
|
|
4978
|
+
}] : base;
|
|
4979
|
+
}, [activeKey, instruction]);
|
|
4980
|
+
const schema = useSchema();
|
|
4981
|
+
const documentSchema = useMemo(() => {
|
|
4982
|
+
if (!targetDocumentType) {
|
|
4983
|
+
return void 0;
|
|
4984
|
+
}
|
|
4985
|
+
return schema.get(targetDocumentType);
|
|
4986
|
+
}, [schema, targetDocumentType]);
|
|
4987
|
+
const fieldSchema = useSelectedSchema(pathKey, documentSchema);
|
|
4988
|
+
const context = useMemo(() => ({
|
|
4989
|
+
documentSchema,
|
|
4990
|
+
fieldSchema: fieldSchema != null ? fieldSchema : documentSchema
|
|
4991
|
+
}), [fieldSchema, documentSchema]);
|
|
4992
|
+
const title = value == null ? void 0 : value.title;
|
|
4993
|
+
useEffect(() => {
|
|
4994
|
+
var _a;
|
|
4995
|
+
if (!title && documentSchema && !(id == null ? void 0 : id.startsWith("drafts."))) {
|
|
4996
|
+
onChange(set((_a = documentSchema.title) != null ? _a : documentSchema.name, ["title"]));
|
|
4997
|
+
}
|
|
4998
|
+
}, [title, documentSchema, onChange, id]);
|
|
4999
|
+
const fieldExists = !!(fields == null ? void 0 : fields.some(f => f._key === typePath));
|
|
5000
|
+
const {
|
|
5001
|
+
onPathOpen,
|
|
5002
|
+
...formCallbacks
|
|
5003
|
+
} = useFormCallbacks();
|
|
5004
|
+
const newCallbacks = useMemo(() => ({
|
|
5005
|
+
...formCallbacks,
|
|
5006
|
+
onPathOpen: path => {
|
|
5007
|
+
var _a;
|
|
5008
|
+
if (!instruction && path.length === 4 && path[2] === "instructions") {
|
|
5009
|
+
setParams(typed({
|
|
5010
|
+
...params,
|
|
5011
|
+
[instructionParam]: (_a = path[3]) == null ? void 0 : _a._key
|
|
5012
|
+
}));
|
|
5013
|
+
onPathOpen([]);
|
|
5014
|
+
} else {
|
|
5015
|
+
setTimeout(() => onPathOpen(path), 0);
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
}), [formCallbacks, onPathOpen, params, setParams, instruction]);
|
|
5019
|
+
useEffect(() => {
|
|
5020
|
+
if (activePath && !instruction) {
|
|
5021
|
+
onPathOpen([]);
|
|
5022
|
+
}
|
|
5023
|
+
}, [activePath, instruction, onPathOpen]);
|
|
5024
|
+
return /* @__PURE__ */jsx(SelectedFieldContextProvider, {
|
|
5025
|
+
value: context,
|
|
5026
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
5027
|
+
space: 5,
|
|
5028
|
+
children: [/* @__PURE__ */jsx(FieldsInitializer, {
|
|
5029
|
+
pathKey: typePath,
|
|
5030
|
+
activePath,
|
|
5031
|
+
fieldExists,
|
|
5032
|
+
onChange
|
|
5033
|
+
}, typePath), instruction && /* @__PURE__ */jsx(BackToInstructionListLink, {}), activePath && /* @__PURE__ */jsx(FormCallbacksProvider, {
|
|
5034
|
+
...newCallbacks,
|
|
5035
|
+
children: /* @__PURE__ */jsx("div", {
|
|
5036
|
+
style: {
|
|
5037
|
+
lineHeight: "1.25em"
|
|
5038
|
+
},
|
|
5039
|
+
children: /* @__PURE__ */jsx(FormInput, {
|
|
5040
|
+
...props,
|
|
5041
|
+
absolutePath: activePath
|
|
5042
|
+
})
|
|
5043
|
+
})
|
|
5044
|
+
}), !activePath && props.renderDefault(props)]
|
|
5045
|
+
})
|
|
5046
|
+
});
|
|
5047
|
+
}
|
|
5048
|
+
function useSelectedSchema(fieldPath, documentSchema) {
|
|
5049
|
+
return useMemo(() => {
|
|
5050
|
+
if (!fieldPath) {
|
|
5051
|
+
return void 0;
|
|
5052
|
+
}
|
|
5053
|
+
if (fieldPath === documentRootKey) {
|
|
5054
|
+
return documentSchema;
|
|
5055
|
+
}
|
|
5056
|
+
const path = stringToPath(fieldPath);
|
|
5057
|
+
let currentSchema = documentSchema;
|
|
5058
|
+
for (let i = 0; i < path.length; i++) {
|
|
5059
|
+
const segment = path[i];
|
|
5060
|
+
const field = currentSchema == null ? void 0 : currentSchema.fields.find(f => f.name === segment);
|
|
5061
|
+
if (!field) {
|
|
5062
|
+
return void 0;
|
|
5063
|
+
}
|
|
5064
|
+
if (i === path.length - 1) {
|
|
5065
|
+
return field.type;
|
|
5066
|
+
}
|
|
5067
|
+
if (field.type.jsonType !== "object") {
|
|
5068
|
+
return void 0;
|
|
5069
|
+
}
|
|
5070
|
+
currentSchema = field.type;
|
|
5071
|
+
}
|
|
5072
|
+
return currentSchema;
|
|
5073
|
+
}, [documentSchema, fieldPath]);
|
|
1277
5074
|
}
|
|
1278
|
-
function
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
} = useRunInstruction();
|
|
1287
|
-
const [queuedTask, setQueuedTask] = useState(void 0);
|
|
5075
|
+
function FieldsInitializer(_ref7) {
|
|
5076
|
+
let {
|
|
5077
|
+
pathKey,
|
|
5078
|
+
activePath,
|
|
5079
|
+
fieldExists,
|
|
5080
|
+
onChange
|
|
5081
|
+
} = _ref7;
|
|
5082
|
+
const initialized = useRef(false);
|
|
1288
5083
|
useEffect(() => {
|
|
1289
|
-
if (
|
|
1290
|
-
|
|
1291
|
-
setQueuedTask(void 0);
|
|
5084
|
+
if (initialized.current || fieldExists || activePath || !pathKey) {
|
|
5085
|
+
return;
|
|
1292
5086
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
5087
|
+
onChange([setIfMissing([], ["fields"]), insert([typed({
|
|
5088
|
+
_key: pathKey,
|
|
5089
|
+
_type: assistFieldTypeName,
|
|
5090
|
+
path: pathKey
|
|
5091
|
+
})], "after", ["fields", -1])]);
|
|
5092
|
+
initialized.current = true;
|
|
5093
|
+
}, [activePath, onChange, pathKey, fieldExists]);
|
|
5094
|
+
return null;
|
|
1301
5095
|
}
|
|
1302
|
-
|
|
1303
|
-
fontSize: "3.125em",
|
|
1304
|
-
"& path": {
|
|
1305
|
-
strokeWidth: "0.6px !important"
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1308
|
-
function InspectorOnboarding(props) {
|
|
5096
|
+
function FieldAutocomplete(props) {
|
|
1309
5097
|
const {
|
|
1310
|
-
|
|
5098
|
+
id,
|
|
5099
|
+
schemaType,
|
|
5100
|
+
fieldPath,
|
|
5101
|
+
onSelect,
|
|
5102
|
+
includeDocument,
|
|
5103
|
+
filter
|
|
1311
5104
|
} = props;
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
5105
|
+
const fieldRefs = useMemo(() => {
|
|
5106
|
+
if (includeDocument) {
|
|
5107
|
+
return getFieldRefsWithDocument(schemaType);
|
|
5108
|
+
}
|
|
5109
|
+
return getFieldRefs(schemaType);
|
|
5110
|
+
}, [schemaType, includeDocument]);
|
|
5111
|
+
const currentField = useMemo(() => fieldRefs.find(f => f.key === fieldPath), [fieldPath, fieldRefs]);
|
|
5112
|
+
const autocompleteOptions = useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).map(field => ({
|
|
5113
|
+
value: field.key,
|
|
5114
|
+
field
|
|
5115
|
+
})), [fieldRefs, filter]);
|
|
5116
|
+
const renderOption = useCallback(option => {
|
|
5117
|
+
const {
|
|
5118
|
+
value,
|
|
5119
|
+
field
|
|
5120
|
+
} = option;
|
|
5121
|
+
if (!value) {
|
|
5122
|
+
return /* @__PURE__ */jsx(Card, {
|
|
5123
|
+
as: "button",
|
|
5124
|
+
padding: 3,
|
|
5125
|
+
radius: 1,
|
|
5126
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5127
|
+
accent: true,
|
|
1325
5128
|
size: 1,
|
|
1326
|
-
children:
|
|
1327
|
-
})
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
5129
|
+
children: option.value
|
|
5130
|
+
})
|
|
5131
|
+
});
|
|
5132
|
+
}
|
|
5133
|
+
if (isType(field.schemaType, "document")) {
|
|
5134
|
+
return /* @__PURE__ */jsx(Card, {
|
|
5135
|
+
as: "button",
|
|
5136
|
+
padding: 3,
|
|
5137
|
+
radius: 1,
|
|
5138
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5139
|
+
size: 1,
|
|
5140
|
+
weight: "semibold",
|
|
5141
|
+
children: "The entire document"
|
|
5142
|
+
})
|
|
5143
|
+
});
|
|
5144
|
+
}
|
|
5145
|
+
return /* @__PURE__ */jsx(Card, {
|
|
5146
|
+
as: "button",
|
|
5147
|
+
padding: 3,
|
|
5148
|
+
radius: 1,
|
|
5149
|
+
children: /* @__PURE__ */jsxs(Flex, {
|
|
5150
|
+
gap: 3,
|
|
5151
|
+
children: [/* @__PURE__ */jsx(Text, {
|
|
5152
|
+
size: 1,
|
|
5153
|
+
children: createElement(field.icon)
|
|
5154
|
+
}), /* @__PURE__ */jsx(FieldTitle, {
|
|
5155
|
+
field
|
|
1349
5156
|
})]
|
|
1350
5157
|
})
|
|
1351
|
-
})
|
|
5158
|
+
});
|
|
5159
|
+
}, []);
|
|
5160
|
+
const renderValue = useCallback((value, option) => {
|
|
5161
|
+
var _a;
|
|
5162
|
+
return (_a = option == null ? void 0 : option.field.title) != null ? _a : value;
|
|
5163
|
+
}, []);
|
|
5164
|
+
const filterOption = useCallback((query, option) => {
|
|
5165
|
+
var _a, _b, _c;
|
|
5166
|
+
const lQuery = query.toLowerCase();
|
|
5167
|
+
return ((_a = option == null ? void 0 : option.value) == null ? void 0 : _a.toLowerCase().includes(lQuery)) || ((_c = (_b = option == null ? void 0 : option.field) == null ? void 0 : _b.title) == null ? void 0 : _c.toLowerCase().includes(lQuery));
|
|
5168
|
+
}, []);
|
|
5169
|
+
return /* @__PURE__ */jsx(Autocomplete, {
|
|
5170
|
+
fontSize: 1,
|
|
5171
|
+
icon: currentField ? currentField.icon : SearchIcon,
|
|
5172
|
+
onChange: onSelect,
|
|
5173
|
+
openButton: true,
|
|
5174
|
+
id,
|
|
5175
|
+
options: autocompleteOptions,
|
|
5176
|
+
placeholder: "Search for a field",
|
|
5177
|
+
radius: 2,
|
|
5178
|
+
renderOption,
|
|
5179
|
+
renderValue,
|
|
5180
|
+
value: currentField == null ? void 0 : currentField.key,
|
|
5181
|
+
filterOption
|
|
1352
5182
|
});
|
|
1353
5183
|
}
|
|
1354
|
-
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
5184
|
+
function FieldTitle(props) {
|
|
5185
|
+
const splitTitle = props.field.title.split("/");
|
|
5186
|
+
return /* @__PURE__ */jsx(Box, {
|
|
5187
|
+
flex: "none",
|
|
5188
|
+
children: /* @__PURE__ */jsxs(Breadcrumbs, {
|
|
5189
|
+
style: {
|
|
5190
|
+
display: "flex",
|
|
5191
|
+
flexWrap: "wrap",
|
|
5192
|
+
alignItems: "center",
|
|
5193
|
+
marginTop: "-4px"
|
|
5194
|
+
},
|
|
5195
|
+
separator: /* @__PURE__ */jsx(Box, {
|
|
5196
|
+
marginTop: 1,
|
|
5197
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5198
|
+
muted: true,
|
|
5199
|
+
size: 1,
|
|
5200
|
+
children: "/"
|
|
5201
|
+
})
|
|
5202
|
+
}),
|
|
5203
|
+
space: 1,
|
|
5204
|
+
children: [splitTitle.slice(0, splitTitle.length - 1).map((pt, i) =>
|
|
5205
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
5206
|
+
/* @__PURE__ */
|
|
5207
|
+
jsx(Box, {
|
|
5208
|
+
marginTop: 1,
|
|
5209
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5210
|
+
muted: true,
|
|
5211
|
+
size: 1,
|
|
5212
|
+
children: pt.trim()
|
|
5213
|
+
})
|
|
5214
|
+
}, i)), /* @__PURE__ */jsx(Box, {
|
|
5215
|
+
marginTop: 1,
|
|
5216
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5217
|
+
size: 1,
|
|
5218
|
+
weight: "medium",
|
|
5219
|
+
children: splitTitle[splitTitle.length - 1]
|
|
5220
|
+
})
|
|
5221
|
+
})]
|
|
5222
|
+
})
|
|
5223
|
+
});
|
|
1379
5224
|
}
|
|
1380
5225
|
var __freeze$4 = Object.freeze;
|
|
1381
5226
|
var __defProp$4 = Object.defineProperty;
|
|
@@ -1394,7 +5239,7 @@ function AssistInspectorWrapper(props) {
|
|
|
1394
5239
|
justify: "center",
|
|
1395
5240
|
padding: 4,
|
|
1396
5241
|
sizing: "border",
|
|
1397
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
5242
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
1398
5243
|
space: 3,
|
|
1399
5244
|
style: {
|
|
1400
5245
|
textAlign: "center"
|
|
@@ -1418,7 +5263,7 @@ function AssistInspectorWrapper(props) {
|
|
|
1418
5263
|
closeButtonLabel: "Close",
|
|
1419
5264
|
onClose: props.onClose,
|
|
1420
5265
|
title: pluginTitle
|
|
1421
|
-
}), /* @__PURE__ */jsxs(Stack, {
|
|
5266
|
+
}), /* @__PURE__ */jsxs(Stack$1, {
|
|
1422
5267
|
flex: 1,
|
|
1423
5268
|
overflow: "auto",
|
|
1424
5269
|
padding: 4,
|
|
@@ -1455,7 +5300,7 @@ function AssistInspectorWrapper(props) {
|
|
|
1455
5300
|
closeButtonLabel: "Close",
|
|
1456
5301
|
onClose: props.onClose,
|
|
1457
5302
|
title: pluginTitle
|
|
1458
|
-
}), /* @__PURE__ */jsxs(Stack, {
|
|
5303
|
+
}), /* @__PURE__ */jsxs(Stack$1, {
|
|
1459
5304
|
padding: 4,
|
|
1460
5305
|
space: 3,
|
|
1461
5306
|
children: [context.error ? /* @__PURE__ */jsxs(Text, {
|
|
@@ -1514,6 +5359,7 @@ function AssistInspector(props) {
|
|
|
1514
5359
|
const {
|
|
1515
5360
|
documentId,
|
|
1516
5361
|
documentType,
|
|
5362
|
+
value: docValue,
|
|
1517
5363
|
schemaType,
|
|
1518
5364
|
onChange: documentOnChange
|
|
1519
5365
|
} = documentPane;
|
|
@@ -1529,13 +5375,14 @@ function AssistInspector(props) {
|
|
|
1529
5375
|
documentOnChange,
|
|
1530
5376
|
isDocAssistable: isDocAssistable(schemaType, published, draft)
|
|
1531
5377
|
});
|
|
1532
|
-
const
|
|
5378
|
+
const typePath = useTypePath(docValue, pathKey != null ? pathKey : "");
|
|
5379
|
+
const selectedField = useSelectedField(schemaType, typePath);
|
|
1533
5380
|
const aiDocId = assistDocumentId(documentType);
|
|
1534
5381
|
const assistDocument = useStudioAssistDocument({
|
|
1535
5382
|
documentId,
|
|
1536
5383
|
schemaType
|
|
1537
5384
|
});
|
|
1538
|
-
const assistField = (_a2 = assistDocument == null ? void 0 : assistDocument.fields) == null ? void 0 : _a2.find(f => f.path ===
|
|
5385
|
+
const assistField = (_a2 = assistDocument == null ? void 0 : assistDocument.fields) == null ? void 0 : _a2.find(f => f.path === typePath);
|
|
1539
5386
|
const instruction = (_b2 = assistField == null ? void 0 : assistField.instructions) == null ? void 0 : _b2.find(i => i._key === instructionKey);
|
|
1540
5387
|
const tasks = useMemo(() => {
|
|
1541
5388
|
var _a3;
|
|
@@ -1567,12 +5414,13 @@ function AssistInspector(props) {
|
|
|
1567
5414
|
type: assistDocumentTypeName
|
|
1568
5415
|
}
|
|
1569
5416
|
}), [aiDocId]);
|
|
1570
|
-
const runCurrentInstruction = useCallback(() => instruction && pathKey && requestRunInstruction({
|
|
5417
|
+
const runCurrentInstruction = useCallback(() => instruction && pathKey && typePath && requestRunInstruction({
|
|
1571
5418
|
documentId: assistableDocId,
|
|
1572
5419
|
path: pathKey,
|
|
5420
|
+
typePath,
|
|
1573
5421
|
assistDocumentId: assistDocumentId(documentType),
|
|
1574
5422
|
instruction
|
|
1575
|
-
}), [instruction,
|
|
5423
|
+
}), [pathKey, instruction, typePath, documentType, assistableDocId, requestRunInstruction]);
|
|
1576
5424
|
const Region = useCallback(_props => {
|
|
1577
5425
|
return /* @__PURE__ */jsx("div", {
|
|
1578
5426
|
..._props,
|
|
@@ -1603,6 +5451,7 @@ function AssistInspector(props) {
|
|
|
1603
5451
|
},
|
|
1604
5452
|
children: [/* @__PURE__ */jsx(AiInspectorHeader, {
|
|
1605
5453
|
onClose: props.onClose,
|
|
5454
|
+
field: selectedField,
|
|
1606
5455
|
fieldTitle: getFieldTitle(selectedField)
|
|
1607
5456
|
}), /* @__PURE__ */jsx(Card, {
|
|
1608
5457
|
as: Region,
|
|
@@ -1618,15 +5467,18 @@ function AssistInspector(props) {
|
|
|
1618
5467
|
children: /* @__PURE__ */jsx(PresenceOverlay, {
|
|
1619
5468
|
children: /* @__PURE__ */jsx(Box, {
|
|
1620
5469
|
padding: 4,
|
|
1621
|
-
children: selectedField && /* @__PURE__ */jsx(
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
5470
|
+
children: selectedField && /* @__PURE__ */jsx(TypePathContext.Provider, {
|
|
5471
|
+
value: typePath,
|
|
5472
|
+
children: /* @__PURE__ */jsx(VirtualizerScrollInstanceProvider, {
|
|
5473
|
+
scrollElement: boundary.current,
|
|
5474
|
+
containerElement: boundary,
|
|
5475
|
+
children: /* @__PURE__ */jsx(DocumentPaneProvider, {
|
|
5476
|
+
paneKey: documentPane.paneKey,
|
|
5477
|
+
index: documentPane.index,
|
|
5478
|
+
itemId: "ai",
|
|
5479
|
+
pane: paneNode,
|
|
5480
|
+
children: /* @__PURE__ */jsx(DocumentForm, {})
|
|
5481
|
+
})
|
|
1630
5482
|
})
|
|
1631
5483
|
})
|
|
1632
5484
|
})
|
|
@@ -1660,7 +5512,7 @@ function AssistInspector(props) {
|
|
|
1660
5512
|
gap: 2,
|
|
1661
5513
|
flex: 1,
|
|
1662
5514
|
justify: "flex-end",
|
|
1663
|
-
children: [(schemaType == null ? void 0 : schemaType.name) && pathKey && instructionKey && /* @__PURE__ */jsx(Stack, {
|
|
5515
|
+
children: [(schemaType == null ? void 0 : schemaType.name) && pathKey && instructionKey && /* @__PURE__ */jsx(Stack$1, {
|
|
1664
5516
|
flex: 1,
|
|
1665
5517
|
children: /* @__PURE__ */jsx(Button, {
|
|
1666
5518
|
mode: "ghost",
|
|
@@ -1684,6 +5536,7 @@ function AssistInspector(props) {
|
|
|
1684
5536
|
function AiInspectorHeader(props) {
|
|
1685
5537
|
const {
|
|
1686
5538
|
onClose,
|
|
5539
|
+
field,
|
|
1687
5540
|
fieldTitle
|
|
1688
5541
|
} = props;
|
|
1689
5542
|
const {
|
|
@@ -1704,18 +5557,25 @@ function AiInspectorHeader(props) {
|
|
|
1704
5557
|
children: /* @__PURE__ */jsxs(Flex, {
|
|
1705
5558
|
gap: 1,
|
|
1706
5559
|
align: "center",
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
5560
|
+
wrap: "wrap",
|
|
5561
|
+
style: {
|
|
5562
|
+
marginTop: "-4px"
|
|
5563
|
+
},
|
|
5564
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
5565
|
+
marginTop: 1,
|
|
5566
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5567
|
+
size: 1,
|
|
5568
|
+
weight: "semibold",
|
|
5569
|
+
children: "AI instructions for"
|
|
5570
|
+
})
|
|
1711
5571
|
}), /* @__PURE__ */jsx(Card, {
|
|
1712
5572
|
radius: 2,
|
|
1713
5573
|
border: true,
|
|
1714
5574
|
padding: 1,
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
5575
|
+
marginTop: 1,
|
|
5576
|
+
children: field ? /* @__PURE__ */jsx(FieldTitle, {
|
|
5577
|
+
field
|
|
5578
|
+
}) : /* @__PURE__ */jsx(Text, {
|
|
1719
5579
|
size: 1,
|
|
1720
5580
|
weight: "semibold",
|
|
1721
5581
|
children: fieldTitle
|
|
@@ -1745,10 +5605,10 @@ const assistInspector = {
|
|
|
1745
5605
|
showAsAction: false
|
|
1746
5606
|
}),
|
|
1747
5607
|
component: AssistInspectorWrapper,
|
|
1748
|
-
onClose(
|
|
5608
|
+
onClose(_ref8) {
|
|
1749
5609
|
let {
|
|
1750
5610
|
params
|
|
1751
|
-
} =
|
|
5611
|
+
} = _ref8;
|
|
1752
5612
|
return {
|
|
1753
5613
|
params: typed({
|
|
1754
5614
|
...params,
|
|
@@ -1821,11 +5681,11 @@ var __template$3 = (cooked, raw) => __freeze$3(__defProp$3(cooked, "raw", {
|
|
|
1821
5681
|
var _a$3, _b$1;
|
|
1822
5682
|
const fadeIn = keyframes(_a$3 || (_a$3 = __template$3(["\n 0% {\n opacity: 0;\n transform: scale(0.75);\n }\n 40% {\n opacity: 0;\n transform: scale(0.75);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n"])));
|
|
1823
5683
|
const FadeInDiv = styled.div(_b$1 || (_b$1 = __template$3(["\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n"])), fadeIn);
|
|
1824
|
-
const FadeInContent = forwardRef(function FadeInContent2(
|
|
5684
|
+
const FadeInContent = forwardRef(function FadeInContent2(_ref9, ref) {
|
|
1825
5685
|
let {
|
|
1826
5686
|
children,
|
|
1827
5687
|
durationMs = 250
|
|
1828
|
-
} =
|
|
5688
|
+
} = _ref9;
|
|
1829
5689
|
return /* @__PURE__ */jsx(FadeInDiv, {
|
|
1830
5690
|
ref,
|
|
1831
5691
|
style: {
|
|
@@ -2004,11 +5864,11 @@ function AssistOnboardingPopover(props) {
|
|
|
2004
5864
|
}
|
|
2005
5865
|
function AssistIntroCard(props) {
|
|
2006
5866
|
const buttonRef = useRef(null);
|
|
2007
|
-
return /* @__PURE__ */jsxs(Stack, {
|
|
5867
|
+
return /* @__PURE__ */jsxs(Stack$1, {
|
|
2008
5868
|
as: "section",
|
|
2009
5869
|
padding: 3,
|
|
2010
5870
|
space: 3,
|
|
2011
|
-
children: [/* @__PURE__ */jsxs(Stack, {
|
|
5871
|
+
children: [/* @__PURE__ */jsxs(Stack$1, {
|
|
2012
5872
|
padding: 2,
|
|
2013
5873
|
space: 4,
|
|
2014
5874
|
children: [/* @__PURE__ */jsxs(Flex, {
|
|
@@ -2027,7 +5887,7 @@ function AssistIntroCard(props) {
|
|
|
2027
5887
|
},
|
|
2028
5888
|
children: /* @__PURE__ */jsx(AssistFeatureBadge, {})
|
|
2029
5889
|
})]
|
|
2030
|
-
}), /* @__PURE__ */jsx(Stack, {
|
|
5890
|
+
}), /* @__PURE__ */jsx(Stack$1, {
|
|
2031
5891
|
space: 3,
|
|
2032
5892
|
children: /* @__PURE__ */jsxs(Text, {
|
|
2033
5893
|
as: "p",
|
|
@@ -2651,7 +6511,7 @@ function AlphaMigration() {
|
|
|
2651
6511
|
header: pluginTitle,
|
|
2652
6512
|
children: /* @__PURE__ */jsx(Card, {
|
|
2653
6513
|
padding: 3,
|
|
2654
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
6514
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
2655
6515
|
space: 4,
|
|
2656
6516
|
style: {
|
|
2657
6517
|
maxWidth: 500
|
|
@@ -2834,307 +6694,135 @@ function AssistLayout(props) {
|
|
|
2834
6694
|
}
|
|
2835
6695
|
var __freeze$1 = Object.freeze;
|
|
2836
6696
|
var __defProp$1 = Object.defineProperty;
|
|
2837
|
-
var __template$1 = (cooked, raw) => __freeze$1(__defProp$1(cooked, "raw", {
|
|
2838
|
-
value: __freeze$1(raw || cooked.slice())
|
|
2839
|
-
}));
|
|
2840
|
-
var _a$1;
|
|
2841
|
-
const WrapPreCard = styled(Card)(_a$1 || (_a$1 = __template$1(["\n & pre {\n white-space: pre-wrap !important;\n }\n"])));
|
|
2842
|
-
function SafeValueInput(props) {
|
|
2843
|
-
return /* @__PURE__ */jsx(ErrorWrapper, {
|
|
2844
|
-
onChange: props.onChange,
|
|
2845
|
-
children: /* @__PURE__ */jsx(PteValueFixer, {
|
|
2846
|
-
...props
|
|
2847
|
-
})
|
|
2848
|
-
});
|
|
2849
|
-
}
|
|
2850
|
-
function ErrorWrapper(props) {
|
|
2851
|
-
const {
|
|
2852
|
-
onChange
|
|
2853
|
-
} = props;
|
|
2854
|
-
const [error, setError] = useState();
|
|
2855
|
-
const catchError = useCallback(params => {
|
|
2856
|
-
setError(params.error);
|
|
2857
|
-
}, [setError]);
|
|
2858
|
-
const unsetValue = useCallback(() => onChange(PatchEvent.from(unset())), [onChange]);
|
|
2859
|
-
const dismiss = useCallback(() => setError(void 0), []);
|
|
2860
|
-
const catcher = /* @__PURE__ */jsx(ErrorBoundary, {
|
|
2861
|
-
onCatch: catchError,
|
|
2862
|
-
children: props.children
|
|
2863
|
-
});
|
|
2864
|
-
return error ? /* @__PURE__ */jsx(Card, {
|
|
2865
|
-
border: true,
|
|
2866
|
-
tone: "critical",
|
|
2867
|
-
padding: 2,
|
|
2868
|
-
contentEditable: false,
|
|
2869
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
2870
|
-
space: 3,
|
|
2871
|
-
children: [/* @__PURE__ */jsx(Text, {
|
|
2872
|
-
muted: true,
|
|
2873
|
-
weight: "semibold",
|
|
2874
|
-
children: "An error occurred."
|
|
2875
|
-
}), /* @__PURE__ */jsx(WrapPreCard, {
|
|
2876
|
-
flex: 1,
|
|
2877
|
-
padding: 2,
|
|
2878
|
-
tone: "critical",
|
|
2879
|
-
border: true,
|
|
2880
|
-
children: catcher
|
|
2881
|
-
}), /* @__PURE__ */jsxs(Flex, {
|
|
2882
|
-
width: "fill",
|
|
2883
|
-
flex: 1,
|
|
2884
|
-
gap: 3,
|
|
2885
|
-
children: [/* @__PURE__ */jsx(Box, {
|
|
2886
|
-
flex: 1,
|
|
2887
|
-
children: /* @__PURE__ */jsx(Button, {
|
|
2888
|
-
text: "Dismiss",
|
|
2889
|
-
onClick: dismiss,
|
|
2890
|
-
tone: "primary"
|
|
2891
|
-
})
|
|
2892
|
-
}), /* @__PURE__ */jsx(Button, {
|
|
2893
|
-
text: "Unset value",
|
|
2894
|
-
onClick: unsetValue,
|
|
2895
|
-
tone: "critical"
|
|
2896
|
-
})]
|
|
2897
|
-
})]
|
|
2898
|
-
})
|
|
2899
|
-
}) : catcher;
|
|
2900
|
-
}
|
|
2901
|
-
function PteValueFixer(props) {
|
|
2902
|
-
const isPortableText = useMemo(() => isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType), [props.schemaType]);
|
|
2903
|
-
const value = props.value;
|
|
2904
|
-
if (isPortableText && value && !value.length) {
|
|
2905
|
-
return props.renderDefault({
|
|
2906
|
-
...props,
|
|
2907
|
-
value: void 0
|
|
2908
|
-
});
|
|
2909
|
-
}
|
|
2910
|
-
return props.renderDefault(props);
|
|
2911
|
-
}
|
|
2912
|
-
function AssistFormBlock(props) {
|
|
2913
|
-
const presence = useAssistPresence(props.path, true);
|
|
2914
|
-
const {
|
|
2915
|
-
onChange
|
|
2916
|
-
} = useFormCallbacks();
|
|
2917
|
-
const key = props.value._key;
|
|
2918
|
-
const localOnChange = useCallback(patchEvent => {
|
|
2919
|
-
if (!key) {
|
|
2920
|
-
return;
|
|
2921
|
-
}
|
|
2922
|
-
onChange(PatchEvent.from(patchEvent).prefixAll({
|
|
2923
|
-
_key: key
|
|
2924
|
-
}));
|
|
2925
|
-
}, [onChange, key]);
|
|
2926
|
-
return /* @__PURE__ */jsx(ErrorWrapper, {
|
|
2927
|
-
onChange: localOnChange,
|
|
2928
|
-
children: /* @__PURE__ */jsxs(Flex, {
|
|
2929
|
-
align: "center",
|
|
2930
|
-
justify: "space-between",
|
|
2931
|
-
children: [/* @__PURE__ */jsx(Box, {
|
|
2932
|
-
flex: 1,
|
|
2933
|
-
children: props.renderDefault(props)
|
|
2934
|
-
}), presence.map(pre => /* @__PURE__ */jsx(AiFieldPresence, {
|
|
2935
|
-
presence: pre
|
|
2936
|
-
}, pre.lastActiveAt))]
|
|
2937
|
-
})
|
|
2938
|
-
});
|
|
2939
|
-
}
|
|
2940
|
-
function AssistItem(props) {
|
|
2941
|
-
const {
|
|
2942
|
-
path
|
|
2943
|
-
} = props;
|
|
2944
|
-
const presence = useAssistPresence(path, true);
|
|
2945
|
-
return /* @__PURE__ */jsxs(Flex, {
|
|
2946
|
-
align: "center",
|
|
2947
|
-
width: "fill",
|
|
2948
|
-
style: {
|
|
2949
|
-
position: "relative"
|
|
2950
|
-
},
|
|
2951
|
-
children: [/* @__PURE__ */jsx(Box, {
|
|
2952
|
-
flex: 1,
|
|
2953
|
-
children: props.renderDefault({
|
|
2954
|
-
...props
|
|
2955
|
-
})
|
|
2956
|
-
}), presence.map(pre => /* @__PURE__ */jsx(Box, {
|
|
2957
|
-
style: {
|
|
2958
|
-
position: "absolute",
|
|
2959
|
-
right: 35
|
|
2960
|
-
},
|
|
2961
|
-
children: /* @__PURE__ */jsx(AiFieldPresence, {
|
|
2962
|
-
presence: pre
|
|
2963
|
-
})
|
|
2964
|
-
}, pre.user.id))]
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2967
|
-
function BackToInstructionListLink() {
|
|
2968
|
-
const {
|
|
2969
|
-
openInspector
|
|
2970
|
-
} = useDocumentPane();
|
|
2971
|
-
const goBack = useCallback(() => openInspector(aiInspectorId, {
|
|
2972
|
-
[instructionParam]: void 0
|
|
2973
|
-
}), [openInspector]);
|
|
2974
|
-
return /* @__PURE__ */jsx("div", {
|
|
2975
|
-
children: /* @__PURE__ */jsx(Button, {
|
|
2976
|
-
as: "a",
|
|
2977
|
-
fontSize: 1,
|
|
2978
|
-
icon: ArrowLeftIcon,
|
|
2979
|
-
mode: "bleed",
|
|
2980
|
-
padding: 1,
|
|
2981
|
-
space: 2,
|
|
2982
|
-
onClick: goBack,
|
|
2983
|
-
text: " Instructions",
|
|
2984
|
-
textAlign: "left"
|
|
2985
|
-
})
|
|
2986
|
-
});
|
|
2987
|
-
}
|
|
2988
|
-
const EMPTY_FIELDS = [];
|
|
2989
|
-
function AssistDocumentForm(props) {
|
|
2990
|
-
const {
|
|
2991
|
-
onChange
|
|
2992
|
-
} = props;
|
|
2993
|
-
const value = props.value;
|
|
2994
|
-
const id = value == null ? void 0 : value._id;
|
|
2995
|
-
const fields = value == null ? void 0 : value.fields;
|
|
2996
|
-
const targetDocumentType = useMemo(() => {
|
|
2997
|
-
if (!id) {
|
|
2998
|
-
return void 0;
|
|
2999
|
-
}
|
|
3000
|
-
return documentTypeFromAiDocumentId(id);
|
|
3001
|
-
}, [id]);
|
|
3002
|
-
const {
|
|
3003
|
-
params,
|
|
3004
|
-
setParams
|
|
3005
|
-
} = useAiPaneRouter();
|
|
3006
|
-
const pathKey = params[fieldPathParam];
|
|
3007
|
-
const instruction = params[instructionParam];
|
|
3008
|
-
const activeKey = useMemo(() => {
|
|
3009
|
-
var _a;
|
|
3010
|
-
return (_a = (fields != null ? fields : EMPTY_FIELDS).find(f => f.path === pathKey)) == null ? void 0 : _a._key;
|
|
3011
|
-
}, [fields, pathKey]);
|
|
3012
|
-
const activePath = useMemo(() => {
|
|
3013
|
-
if (!activeKey) {
|
|
3014
|
-
return void 0;
|
|
3015
|
-
}
|
|
3016
|
-
const base = ["fields", {
|
|
3017
|
-
_key: activeKey
|
|
3018
|
-
}];
|
|
3019
|
-
return instruction ? [...base, "instructions", {
|
|
3020
|
-
_key: instruction
|
|
3021
|
-
}] : base;
|
|
3022
|
-
}, [activeKey, instruction]);
|
|
3023
|
-
const schema = useSchema();
|
|
3024
|
-
const documentSchema = useMemo(() => {
|
|
3025
|
-
if (!targetDocumentType) {
|
|
3026
|
-
return void 0;
|
|
3027
|
-
}
|
|
3028
|
-
return schema.get(targetDocumentType);
|
|
3029
|
-
}, [schema, targetDocumentType]);
|
|
3030
|
-
const fieldSchema = useSelectedSchema(pathKey, documentSchema);
|
|
3031
|
-
const context = useMemo(() => ({
|
|
3032
|
-
documentSchema,
|
|
3033
|
-
fieldSchema: fieldSchema != null ? fieldSchema : documentSchema
|
|
3034
|
-
}), [fieldSchema, documentSchema]);
|
|
3035
|
-
const title = value == null ? void 0 : value.title;
|
|
3036
|
-
useEffect(() => {
|
|
3037
|
-
var _a;
|
|
3038
|
-
if (!title && documentSchema && !(id == null ? void 0 : id.startsWith("drafts."))) {
|
|
3039
|
-
onChange(set((_a = documentSchema.title) != null ? _a : documentSchema.name, ["title"]));
|
|
3040
|
-
}
|
|
3041
|
-
}, [title, documentSchema, onChange, id]);
|
|
3042
|
-
const fieldExists = !!(fields == null ? void 0 : fields.some(f => f._key === pathKey));
|
|
3043
|
-
const {
|
|
3044
|
-
onPathOpen,
|
|
3045
|
-
...formCallbacks
|
|
3046
|
-
} = useFormCallbacks();
|
|
3047
|
-
const newCallbacks = useMemo(() => ({
|
|
3048
|
-
...formCallbacks,
|
|
3049
|
-
onPathOpen: path => {
|
|
3050
|
-
var _a;
|
|
3051
|
-
if (!instruction && path.length === 4 && path[2] === "instructions") {
|
|
3052
|
-
setParams(typed({
|
|
3053
|
-
...params,
|
|
3054
|
-
[instructionParam]: (_a = path[3]) == null ? void 0 : _a._key
|
|
3055
|
-
}));
|
|
3056
|
-
onPathOpen([]);
|
|
3057
|
-
} else {
|
|
3058
|
-
setTimeout(() => onPathOpen(path), 0);
|
|
3059
|
-
}
|
|
3060
|
-
}
|
|
3061
|
-
}), [formCallbacks, onPathOpen, params, setParams, instruction]);
|
|
3062
|
-
useEffect(() => {
|
|
3063
|
-
if (activePath && !instruction) {
|
|
3064
|
-
onPathOpen([]);
|
|
3065
|
-
}
|
|
3066
|
-
}, [activePath, instruction, onPathOpen]);
|
|
3067
|
-
return /* @__PURE__ */jsx(SelectedFieldContextProvider, {
|
|
3068
|
-
value: context,
|
|
3069
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
3070
|
-
space: 5,
|
|
3071
|
-
children: [/* @__PURE__ */jsx(FieldsInitializer, {
|
|
3072
|
-
pathKey,
|
|
3073
|
-
activePath,
|
|
3074
|
-
fieldExists,
|
|
3075
|
-
onChange
|
|
3076
|
-
}, pathKey), instruction && /* @__PURE__ */jsx(BackToInstructionListLink, {}), activePath && /* @__PURE__ */jsx(FormCallbacksProvider, {
|
|
3077
|
-
...newCallbacks,
|
|
3078
|
-
children: /* @__PURE__ */jsx("div", {
|
|
3079
|
-
style: {
|
|
3080
|
-
lineHeight: "1.25em"
|
|
3081
|
-
},
|
|
3082
|
-
children: /* @__PURE__ */jsx(FormInput, {
|
|
3083
|
-
...props,
|
|
3084
|
-
absolutePath: activePath
|
|
3085
|
-
})
|
|
3086
|
-
})
|
|
3087
|
-
}), !activePath && props.renderDefault(props)]
|
|
6697
|
+
var __template$1 = (cooked, raw) => __freeze$1(__defProp$1(cooked, "raw", {
|
|
6698
|
+
value: __freeze$1(raw || cooked.slice())
|
|
6699
|
+
}));
|
|
6700
|
+
var _a$1;
|
|
6701
|
+
const WrapPreCard = styled(Card)(_a$1 || (_a$1 = __template$1(["\n & pre {\n white-space: pre-wrap !important;\n }\n"])));
|
|
6702
|
+
function SafeValueInput(props) {
|
|
6703
|
+
return /* @__PURE__ */jsx(ErrorWrapper, {
|
|
6704
|
+
onChange: props.onChange,
|
|
6705
|
+
children: /* @__PURE__ */jsx(PteValueFixer, {
|
|
6706
|
+
...props
|
|
3088
6707
|
})
|
|
3089
6708
|
});
|
|
3090
6709
|
}
|
|
3091
|
-
function
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
6710
|
+
function ErrorWrapper(props) {
|
|
6711
|
+
const {
|
|
6712
|
+
onChange
|
|
6713
|
+
} = props;
|
|
6714
|
+
const [error, setError] = useState();
|
|
6715
|
+
const catchError = useCallback(params => {
|
|
6716
|
+
setError(params.error);
|
|
6717
|
+
}, [setError]);
|
|
6718
|
+
const unsetValue = useCallback(() => onChange(PatchEvent.from(unset())), [onChange]);
|
|
6719
|
+
const dismiss = useCallback(() => setError(void 0), []);
|
|
6720
|
+
const catcher = /* @__PURE__ */jsx(ErrorBoundary, {
|
|
6721
|
+
onCatch: catchError,
|
|
6722
|
+
children: props.children
|
|
6723
|
+
});
|
|
6724
|
+
return error ? /* @__PURE__ */jsx(Card, {
|
|
6725
|
+
border: true,
|
|
6726
|
+
tone: "critical",
|
|
6727
|
+
padding: 2,
|
|
6728
|
+
contentEditable: false,
|
|
6729
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
6730
|
+
space: 3,
|
|
6731
|
+
children: [/* @__PURE__ */jsx(Text, {
|
|
6732
|
+
muted: true,
|
|
6733
|
+
weight: "semibold",
|
|
6734
|
+
children: "An error occurred."
|
|
6735
|
+
}), /* @__PURE__ */jsx(WrapPreCard, {
|
|
6736
|
+
flex: 1,
|
|
6737
|
+
padding: 2,
|
|
6738
|
+
tone: "critical",
|
|
6739
|
+
border: true,
|
|
6740
|
+
children: catcher
|
|
6741
|
+
}), /* @__PURE__ */jsxs(Flex, {
|
|
6742
|
+
width: "fill",
|
|
6743
|
+
flex: 1,
|
|
6744
|
+
gap: 3,
|
|
6745
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
6746
|
+
flex: 1,
|
|
6747
|
+
children: /* @__PURE__ */jsx(Button, {
|
|
6748
|
+
text: "Dismiss",
|
|
6749
|
+
onClick: dismiss,
|
|
6750
|
+
tone: "primary"
|
|
6751
|
+
})
|
|
6752
|
+
}), /* @__PURE__ */jsx(Button, {
|
|
6753
|
+
text: "Unset value",
|
|
6754
|
+
onClick: unsetValue,
|
|
6755
|
+
tone: "critical"
|
|
6756
|
+
})]
|
|
6757
|
+
})]
|
|
6758
|
+
})
|
|
6759
|
+
}) : catcher;
|
|
3117
6760
|
}
|
|
3118
|
-
function
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
6761
|
+
function PteValueFixer(props) {
|
|
6762
|
+
const isPortableText = useMemo(() => isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType), [props.schemaType]);
|
|
6763
|
+
const value = props.value;
|
|
6764
|
+
if (isPortableText && value && !value.length) {
|
|
6765
|
+
return props.renderDefault({
|
|
6766
|
+
...props,
|
|
6767
|
+
value: void 0
|
|
6768
|
+
});
|
|
6769
|
+
}
|
|
6770
|
+
return props.renderDefault(props);
|
|
6771
|
+
}
|
|
6772
|
+
function AssistFormBlock(props) {
|
|
6773
|
+
const presence = useAssistPresence(props.path, true);
|
|
6774
|
+
const {
|
|
3123
6775
|
onChange
|
|
3124
|
-
} =
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3127
|
-
if (
|
|
6776
|
+
} = useFormCallbacks();
|
|
6777
|
+
const key = props.value._key;
|
|
6778
|
+
const localOnChange = useCallback(patchEvent => {
|
|
6779
|
+
if (!key) {
|
|
3128
6780
|
return;
|
|
3129
6781
|
}
|
|
3130
|
-
onChange(
|
|
3131
|
-
_key:
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
6782
|
+
onChange(PatchEvent.from(patchEvent).prefixAll({
|
|
6783
|
+
_key: key
|
|
6784
|
+
}));
|
|
6785
|
+
}, [onChange, key]);
|
|
6786
|
+
return /* @__PURE__ */jsx(ErrorWrapper, {
|
|
6787
|
+
onChange: localOnChange,
|
|
6788
|
+
children: /* @__PURE__ */jsxs(Flex, {
|
|
6789
|
+
align: "center",
|
|
6790
|
+
justify: "space-between",
|
|
6791
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
6792
|
+
flex: 1,
|
|
6793
|
+
children: props.renderDefault(props)
|
|
6794
|
+
}), presence.map(pre => /* @__PURE__ */jsx(AiFieldPresence, {
|
|
6795
|
+
presence: pre
|
|
6796
|
+
}, pre.lastActiveAt))]
|
|
6797
|
+
})
|
|
6798
|
+
});
|
|
6799
|
+
}
|
|
6800
|
+
function AssistItem(props) {
|
|
6801
|
+
const {
|
|
6802
|
+
path
|
|
6803
|
+
} = props;
|
|
6804
|
+
const presence = useAssistPresence(path, true);
|
|
6805
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
6806
|
+
align: "center",
|
|
6807
|
+
width: "fill",
|
|
6808
|
+
style: {
|
|
6809
|
+
position: "relative"
|
|
6810
|
+
},
|
|
6811
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
6812
|
+
flex: 1,
|
|
6813
|
+
children: props.renderDefault({
|
|
6814
|
+
...props
|
|
6815
|
+
})
|
|
6816
|
+
}), presence.map(pre => /* @__PURE__ */jsx(Box, {
|
|
6817
|
+
style: {
|
|
6818
|
+
position: "absolute",
|
|
6819
|
+
right: 35
|
|
6820
|
+
},
|
|
6821
|
+
children: /* @__PURE__ */jsx(AiFieldPresence, {
|
|
6822
|
+
presence: pre
|
|
6823
|
+
})
|
|
6824
|
+
}, pre.user.id))]
|
|
6825
|
+
});
|
|
3138
6826
|
}
|
|
3139
6827
|
function findFieldMember(members, fieldName) {
|
|
3140
6828
|
return members.find(m => m.kind === "field" && m.name === fieldName || m.kind === "error" && m.fieldName === fieldName);
|
|
@@ -3143,7 +6831,7 @@ function findFieldsetMember(members, fieldsetName) {
|
|
|
3143
6831
|
return members.find(m => m.kind === "fieldSet" && m.fieldSet.name === fieldsetName);
|
|
3144
6832
|
}
|
|
3145
6833
|
function InstructionInput(props) {
|
|
3146
|
-
return /* @__PURE__ */jsxs(Stack, {
|
|
6834
|
+
return /* @__PURE__ */jsxs(Stack$1, {
|
|
3147
6835
|
space: [4, 4, 4, 5],
|
|
3148
6836
|
children: [/* @__PURE__ */jsx(NameField, {
|
|
3149
6837
|
...props
|
|
@@ -3188,9 +6876,9 @@ function NameField(props) {
|
|
|
3188
6876
|
}
|
|
3189
6877
|
};
|
|
3190
6878
|
}, [titleMember, titlePlaceholder]);
|
|
3191
|
-
return /* @__PURE__ */jsx(Stack, {
|
|
6879
|
+
return /* @__PURE__ */jsx(Stack$1, {
|
|
3192
6880
|
space: 5,
|
|
3193
|
-
children: /* @__PURE__ */jsxs(Stack, {
|
|
6881
|
+
children: /* @__PURE__ */jsxs(Stack$1, {
|
|
3194
6882
|
space: 2,
|
|
3195
6883
|
children: [/* @__PURE__ */jsx(Flex, {
|
|
3196
6884
|
gap: 1,
|
|
@@ -3343,117 +7031,10 @@ function getIcon(iconName) {
|
|
|
3343
7031
|
return key === iconName;
|
|
3344
7032
|
})) == null ? void 0 : _a[1]) != null ? _b : icons.sparkles;
|
|
3345
7033
|
}
|
|
3346
|
-
function FieldAutocomplete(props) {
|
|
3347
|
-
const {
|
|
3348
|
-
id,
|
|
3349
|
-
schemaType,
|
|
3350
|
-
fieldPath,
|
|
3351
|
-
onSelect,
|
|
3352
|
-
includeDocument
|
|
3353
|
-
} = props;
|
|
3354
|
-
const fieldNames = useMemo(() => {
|
|
3355
|
-
if (includeDocument) {
|
|
3356
|
-
return getFieldRefsWithDocument(schemaType);
|
|
3357
|
-
}
|
|
3358
|
-
return getFieldRefs(schemaType);
|
|
3359
|
-
}, [schemaType, includeDocument]);
|
|
3360
|
-
const currentField = useMemo(() => fieldNames.find(f => f.key === fieldPath), [fieldPath, fieldNames]);
|
|
3361
|
-
const autocompleteOptions = useMemo(() => fieldNames.map(field => ({
|
|
3362
|
-
value: field.key,
|
|
3363
|
-
field
|
|
3364
|
-
})), [fieldNames]);
|
|
3365
|
-
const renderOption = useCallback(option => {
|
|
3366
|
-
const {
|
|
3367
|
-
value,
|
|
3368
|
-
field
|
|
3369
|
-
} = option;
|
|
3370
|
-
if (!value) {
|
|
3371
|
-
return /* @__PURE__ */jsx(Card, {
|
|
3372
|
-
as: "button",
|
|
3373
|
-
padding: 3,
|
|
3374
|
-
radius: 1,
|
|
3375
|
-
children: /* @__PURE__ */jsx(Text, {
|
|
3376
|
-
accent: true,
|
|
3377
|
-
size: 1,
|
|
3378
|
-
children: option.value
|
|
3379
|
-
})
|
|
3380
|
-
});
|
|
3381
|
-
}
|
|
3382
|
-
if (isType(field.schemaType, "document")) {
|
|
3383
|
-
return /* @__PURE__ */jsx(Card, {
|
|
3384
|
-
as: "button",
|
|
3385
|
-
padding: 3,
|
|
3386
|
-
radius: 1,
|
|
3387
|
-
children: /* @__PURE__ */jsx(Text, {
|
|
3388
|
-
size: 1,
|
|
3389
|
-
weight: "semibold",
|
|
3390
|
-
children: "The entire document"
|
|
3391
|
-
})
|
|
3392
|
-
});
|
|
3393
|
-
}
|
|
3394
|
-
const splitTitle = field.title.split("/");
|
|
3395
|
-
return /* @__PURE__ */jsx(Card, {
|
|
3396
|
-
as: "button",
|
|
3397
|
-
padding: 3,
|
|
3398
|
-
radius: 1,
|
|
3399
|
-
children: /* @__PURE__ */jsxs(Flex, {
|
|
3400
|
-
gap: 3,
|
|
3401
|
-
children: [/* @__PURE__ */jsx(Text, {
|
|
3402
|
-
size: 1,
|
|
3403
|
-
children: createElement(field.icon)
|
|
3404
|
-
}), /* @__PURE__ */jsx(Box, {
|
|
3405
|
-
flex: "none",
|
|
3406
|
-
children: /* @__PURE__ */jsxs(Breadcrumbs, {
|
|
3407
|
-
separator: /* @__PURE__ */jsx(Text, {
|
|
3408
|
-
muted: true,
|
|
3409
|
-
size: 1,
|
|
3410
|
-
children: "/"
|
|
3411
|
-
}),
|
|
3412
|
-
space: 1,
|
|
3413
|
-
children: [splitTitle.slice(0, splitTitle.length - 1).map((pt, i) =>
|
|
3414
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
3415
|
-
/* @__PURE__ */
|
|
3416
|
-
jsx(Text, {
|
|
3417
|
-
muted: true,
|
|
3418
|
-
size: 1,
|
|
3419
|
-
children: pt.trim()
|
|
3420
|
-
}, i)), /* @__PURE__ */jsx(Text, {
|
|
3421
|
-
size: 1,
|
|
3422
|
-
weight: "medium",
|
|
3423
|
-
children: splitTitle[splitTitle.length - 1]
|
|
3424
|
-
})]
|
|
3425
|
-
})
|
|
3426
|
-
})]
|
|
3427
|
-
})
|
|
3428
|
-
});
|
|
3429
|
-
}, []);
|
|
3430
|
-
const renderValue = useCallback((value, option) => {
|
|
3431
|
-
var _a;
|
|
3432
|
-
return (_a = option == null ? void 0 : option.field.title) != null ? _a : value;
|
|
3433
|
-
}, []);
|
|
3434
|
-
const filterOption = useCallback((query, option) => {
|
|
3435
|
-
var _a, _b, _c;
|
|
3436
|
-
const lQuery = query.toLowerCase();
|
|
3437
|
-
return ((_a = option == null ? void 0 : option.value) == null ? void 0 : _a.toLowerCase().includes(lQuery)) || ((_c = (_b = option == null ? void 0 : option.field) == null ? void 0 : _b.title) == null ? void 0 : _c.toLowerCase().includes(lQuery));
|
|
3438
|
-
}, []);
|
|
3439
|
-
return /* @__PURE__ */jsx(Autocomplete, {
|
|
3440
|
-
fontSize: 1,
|
|
3441
|
-
icon: currentField ? currentField.icon : SearchIcon,
|
|
3442
|
-
onChange: onSelect,
|
|
3443
|
-
openButton: true,
|
|
3444
|
-
id,
|
|
3445
|
-
options: autocompleteOptions,
|
|
3446
|
-
placeholder: "Search for a field",
|
|
3447
|
-
radius: 2,
|
|
3448
|
-
renderOption,
|
|
3449
|
-
renderValue,
|
|
3450
|
-
value: currentField == null ? void 0 : currentField.key,
|
|
3451
|
-
filterOption
|
|
3452
|
-
});
|
|
3453
|
-
}
|
|
3454
7034
|
function FieldRefPathInput(props) {
|
|
3455
7035
|
var _a;
|
|
3456
7036
|
const documentSchema = (_a = useContext(SelectedFieldContext)) == null ? void 0 : _a.documentSchema;
|
|
7037
|
+
const typePath = useContext(TypePathContext);
|
|
3457
7038
|
const ref = useRef(null);
|
|
3458
7039
|
const id = useId();
|
|
3459
7040
|
const {
|
|
@@ -3464,20 +7045,29 @@ function FieldRefPathInput(props) {
|
|
|
3464
7045
|
(_b = (_a2 = ref.current) == null ? void 0 : _a2.querySelector("input")) == null ? void 0 : _b.focus();
|
|
3465
7046
|
}, []);
|
|
3466
7047
|
const onSelect = useCallback(path => onChange(set(path)), [onChange]);
|
|
7048
|
+
const filter = useCallback(field => {
|
|
7049
|
+
if (!field.key.includes("|") || !typePath) {
|
|
7050
|
+
return true;
|
|
7051
|
+
}
|
|
7052
|
+
const dotSplit = typePath.split(".");
|
|
7053
|
+
const base = dotSplit.slice(0, dotSplit.length - 1).join(".");
|
|
7054
|
+
return field.key.includes(base);
|
|
7055
|
+
}, [typePath]);
|
|
3467
7056
|
if (!documentSchema) {
|
|
3468
7057
|
return props.renderDefault(props);
|
|
3469
7058
|
}
|
|
3470
7059
|
return /* @__PURE__ */jsx(Box, {
|
|
3471
7060
|
flex: 1,
|
|
3472
7061
|
style: {
|
|
3473
|
-
minWidth:
|
|
7062
|
+
minWidth: 300
|
|
3474
7063
|
},
|
|
3475
7064
|
ref,
|
|
3476
7065
|
children: /* @__PURE__ */jsx(FieldAutocomplete, {
|
|
3477
7066
|
id,
|
|
3478
7067
|
schemaType: documentSchema,
|
|
3479
7068
|
onSelect,
|
|
3480
|
-
fieldPath: props.value
|
|
7069
|
+
fieldPath: props.value,
|
|
7070
|
+
filter
|
|
3481
7071
|
})
|
|
3482
7072
|
});
|
|
3483
7073
|
}
|
|
@@ -3680,7 +7270,7 @@ function useOnlyInlineBlocks(props) {
|
|
|
3680
7270
|
function InstructionsArrayField(props) {
|
|
3681
7271
|
return props.renderDefault({
|
|
3682
7272
|
...props,
|
|
3683
|
-
title:
|
|
7273
|
+
title: " "
|
|
3684
7274
|
});
|
|
3685
7275
|
}
|
|
3686
7276
|
const fieldReference = defineType({
|
|
@@ -3901,7 +7491,7 @@ const instruction = defineType({
|
|
|
3901
7491
|
size: 1,
|
|
3902
7492
|
children: createElement(props.icon)
|
|
3903
7493
|
})
|
|
3904
|
-
}), /* @__PURE__ */jsx(Stack, {
|
|
7494
|
+
}), /* @__PURE__ */jsx(Stack$1, {
|
|
3905
7495
|
flex: 1,
|
|
3906
7496
|
space: 2,
|
|
3907
7497
|
children: /* @__PURE__ */jsx(Text, {
|
|
@@ -4020,7 +7610,7 @@ const fieldInstructions = defineType({
|
|
|
4020
7610
|
});
|
|
4021
7611
|
const assistDocumentSchema = defineType({
|
|
4022
7612
|
//NOTE: this is a document type. Using object here ensures it does not appear in structure menus
|
|
4023
|
-
type: "
|
|
7613
|
+
type: "document",
|
|
4024
7614
|
//workaround for using object and not document
|
|
4025
7615
|
...{
|
|
4026
7616
|
liveEdit: true
|
|
@@ -4100,7 +7690,7 @@ const documentInstructionStatus = defineType({
|
|
|
4100
7690
|
});
|
|
4101
7691
|
const schemaTypes = [fieldInstructions, assistDocumentSchema, prompt, fieldReference, instruction, documentInstructionStatus, instructionTask, contextDocumentSchema, userInput, promptContext];
|
|
4102
7692
|
function useAssistSupported(path, schemaType) {
|
|
4103
|
-
return useMemo(() =>
|
|
7693
|
+
return useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
4104
7694
|
}
|
|
4105
7695
|
function useAssistDocumentContextValue(documentId, documentSchemaType) {
|
|
4106
7696
|
const {
|
|
@@ -4271,7 +7861,6 @@ const assistFieldActions = {
|
|
|
4271
7861
|
const {
|
|
4272
7862
|
schemaType
|
|
4273
7863
|
} = props;
|
|
4274
|
-
const assistSupported = useAssistSupported(props.path, schemaType);
|
|
4275
7864
|
const isDocumentLevel = props.path.length === 0;
|
|
4276
7865
|
const {
|
|
4277
7866
|
assistDocument,
|
|
@@ -4292,9 +7881,13 @@ const assistFieldActions = {
|
|
|
4292
7881
|
useAssistDocumentContextValue(props.documentId, schemaType) :
|
|
4293
7882
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
4294
7883
|
useAssistDocumentContext();
|
|
7884
|
+
const {
|
|
7885
|
+
value: docValue
|
|
7886
|
+
} = useDocumentPane();
|
|
4295
7887
|
const currentUser = useCurrentUser();
|
|
4296
7888
|
const isHidden = !assistDocument;
|
|
4297
7889
|
const pathKey = usePathKey(props.path);
|
|
7890
|
+
const typePath = useTypePath(docValue, pathKey);
|
|
4298
7891
|
const assistDocumentId = assistDocument == null ? void 0 : assistDocument._id;
|
|
4299
7892
|
const assistableDocId = getAssistableDocId(documentSchemaType, documentId);
|
|
4300
7893
|
const {
|
|
@@ -4303,10 +7896,12 @@ const assistFieldActions = {
|
|
|
4303
7896
|
documentOnChange,
|
|
4304
7897
|
isDocAssistable: documentIsAssistable != null ? documentIsAssistable : false
|
|
4305
7898
|
});
|
|
7899
|
+
const isSelectable = !!useSelectedField(documentSchemaType, typePath);
|
|
7900
|
+
const assistSupported = useAssistSupported(props.path, schemaType) && isSelectable;
|
|
4306
7901
|
const fieldAssist = useMemo(() => {
|
|
4307
7902
|
var _a;
|
|
4308
|
-
return ((_a = assistDocument == null ? void 0 : assistDocument.fields) != null ? _a : []).find(f => f.path
|
|
4309
|
-
}, [assistDocument == null ? void 0 : assistDocument.fields, pathKey]);
|
|
7903
|
+
return ((_a = assistDocument == null ? void 0 : assistDocument.fields) != null ? _a : []).find(f => f.path === typePath || pathKey === documentRootKey && f.path === pathKey);
|
|
7904
|
+
}, [assistDocument == null ? void 0 : assistDocument.fields, pathKey, typePath]);
|
|
4310
7905
|
const fieldAssistKey = fieldAssist == null ? void 0 : fieldAssist._key;
|
|
4311
7906
|
const isInspectorOpen = (inspector == null ? void 0 : inspector.name) === aiInspectorId;
|
|
4312
7907
|
const isPathSelected = pathKey === selectedPath;
|
|
@@ -4324,9 +7919,10 @@ const assistFieldActions = {
|
|
|
4324
7919
|
documentId: assistableDocId,
|
|
4325
7920
|
assistDocumentId,
|
|
4326
7921
|
path: pathKey,
|
|
7922
|
+
typePath,
|
|
4327
7923
|
instruction
|
|
4328
7924
|
});
|
|
4329
|
-
}, [requestRunInstruction, assistableDocId, pathKey, assistDocumentId, fieldAssistKey]);
|
|
7925
|
+
}, [requestRunInstruction, assistableDocId, pathKey, typePath, assistDocumentId, fieldAssistKey]);
|
|
4330
7926
|
const privateInstructions = useMemo(() => {
|
|
4331
7927
|
var _a;
|
|
4332
7928
|
return ((_a = fieldAssist == null ? void 0 : fieldAssist.instructions) == null ? void 0 : _a.filter(i => i.userId && i.userId === (currentUser == null ? void 0 : currentUser.id))) || [];
|