@vunk/plus 0.2.0 → 1.1.1

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.
@@ -0,0 +1,4115 @@
1
+ import { computed, ref, watch, inject, isVNode, Comment, Fragment, shallowRef, watchEffect, provide, onBeforeUnmount, onBeforeMount, toRef, defineComponent, h, createVNode, resolveComponent, openBlock, createBlock, withCtx, mergeProps, toHandlers } from 'vue';
2
+ import { _VkTabelsV1Ctx, VkTablesV1 } from '@vunk/plus/components/tables-v1';
3
+ import { VkCheckRecordLogicProvider, VkCheckRecordLogic } from '@vunk/core';
4
+ import { noop } from '@vunk/shared/function';
5
+ import { ElCheckbox } from 'element-plus';
6
+ import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
7
+
8
+ /* eslint-disable @typescript-eslint/restrict-template-expressions */
9
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions */
10
+ function plugin$1(options) {
11
+ let _bPrefix = '.';
12
+ let _ePrefix = '__';
13
+ let _mPrefix = '--';
14
+ let c;
15
+ if (options) {
16
+ let t = options.blockPrefix;
17
+ if (t) {
18
+ _bPrefix = t;
19
+ }
20
+ t = options.elementPrefix;
21
+ if (t) {
22
+ _ePrefix = t;
23
+ }
24
+ t = options.modifierPrefix;
25
+ if (t) {
26
+ _mPrefix = t;
27
+ }
28
+ }
29
+ const _plugin = {
30
+ install(instance) {
31
+ c = instance.c;
32
+ const ctx = instance.context;
33
+ ctx.bem = {};
34
+ ctx.bem.b = null;
35
+ ctx.bem.els = null;
36
+ }
37
+ };
38
+ function b(arg) {
39
+ let memorizedB;
40
+ let memorizedE;
41
+ return {
42
+ before(ctx) {
43
+ memorizedB = ctx.bem.b;
44
+ memorizedE = ctx.bem.els;
45
+ ctx.bem.els = null;
46
+ },
47
+ after(ctx) {
48
+ ctx.bem.b = memorizedB;
49
+ ctx.bem.els = memorizedE;
50
+ },
51
+ $({ context, props }) {
52
+ arg = typeof arg === 'string' ? arg : arg({ context, props });
53
+ context.bem.b = arg;
54
+ return `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}`;
55
+ }
56
+ };
57
+ }
58
+ function e(arg) {
59
+ let memorizedE;
60
+ return {
61
+ before(ctx) {
62
+ memorizedE = ctx.bem.els;
63
+ },
64
+ after(ctx) {
65
+ ctx.bem.els = memorizedE;
66
+ },
67
+ $({ context, props }) {
68
+ arg = typeof arg === 'string' ? arg : arg({ context, props });
69
+ context.bem.els = arg.split(',').map(v => v.trim());
70
+ return context.bem.els
71
+ .map(el => `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${_ePrefix}${el}`).join(', ');
72
+ }
73
+ };
74
+ }
75
+ function m(arg) {
76
+ return {
77
+ $({ context, props }) {
78
+ arg = typeof arg === 'string' ? arg : arg({ context, props });
79
+ const modifiers = arg.split(',').map(v => v.trim());
80
+ function elementToSelector(el) {
81
+ return modifiers.map(modifier => `&${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${el !== undefined ? `${_ePrefix}${el}` : ''}${_mPrefix}${modifier}`).join(', ');
82
+ }
83
+ const els = context.bem.els;
84
+ if (els !== null) {
85
+ if (process.env.NODE_ENV !== 'production' && els.length >= 2) {
86
+ throw Error(`[css-render/plugin-bem]: m(${arg}) is invalid, using modifier inside multiple elements is not allowed`);
87
+ }
88
+ return elementToSelector(els[0]);
89
+ }
90
+ else {
91
+ return elementToSelector();
92
+ }
93
+ }
94
+ };
95
+ }
96
+ function notM(arg) {
97
+ return {
98
+ $({ context, props }) {
99
+ arg = typeof arg === 'string' ? arg : arg({ context, props });
100
+ const els = context.bem.els;
101
+ if (process.env.NODE_ENV !== 'production' && els !== null && els.length >= 2) {
102
+ throw Error(`[css-render/plugin-bem]: notM(${arg}) is invalid, using modifier inside multiple elements is not allowed`);
103
+ }
104
+ return `&:not(${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${(els !== null && els.length > 0) ? `${_ePrefix}${els[0]}` : ''}${_mPrefix}${arg})`;
105
+ }
106
+ };
107
+ }
108
+ const cB = ((...args) => c(b(args[0]), args[1], args[2]));
109
+ const cE = ((...args) => c(e(args[0]), args[1], args[2]));
110
+ const cM = ((...args) => c(m(args[0]), args[1], args[2]));
111
+ const cNotM = ((...args) => c(notM(args[0]), args[1], args[2]));
112
+ Object.assign(_plugin, {
113
+ cB, cE, cM, cNotM
114
+ });
115
+ return _plugin;
116
+ }
117
+
118
+ function ampCount(selector) {
119
+ let cnt = 0;
120
+ for (let i = 0; i < selector.length; ++i) {
121
+ if (selector[i] === '&')
122
+ ++cnt;
123
+ }
124
+ return cnt;
125
+ }
126
+ /**
127
+ * Don't just use ',' to separate css selector. For example:
128
+ * x:(a, b) {} will be split into 'x:(a' and 'b)', which is not expected.
129
+ * Make sure comma doesn't exist inside parentheses.
130
+ */
131
+ const separatorRegex = /\s*,(?![^(]*\))\s*/g;
132
+ const extraSpaceRegex = /\s+/g;
133
+ /**
134
+ * selector must includes '&'
135
+ * selector is trimmed
136
+ * every part of amp is trimmed
137
+ */
138
+ function resolveSelectorWithAmp(amp, selector) {
139
+ const nextAmp = [];
140
+ selector.split(separatorRegex).forEach(partialSelector => {
141
+ let round = ampCount(partialSelector);
142
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
143
+ if (!round) {
144
+ amp.forEach(partialAmp => {
145
+ nextAmp.push(
146
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
147
+ (partialAmp && partialAmp + ' ') + partialSelector);
148
+ });
149
+ return;
150
+ }
151
+ else if (round === 1) {
152
+ amp.forEach(partialAmp => {
153
+ nextAmp.push(partialSelector.replace('&', partialAmp));
154
+ });
155
+ return;
156
+ }
157
+ let partialNextAmp = [
158
+ partialSelector
159
+ ];
160
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
161
+ while (round--) {
162
+ const nextPartialNextAmp = [];
163
+ partialNextAmp.forEach(selectorItr => {
164
+ amp.forEach(partialAmp => {
165
+ nextPartialNextAmp.push(selectorItr.replace('&', partialAmp));
166
+ });
167
+ });
168
+ partialNextAmp = nextPartialNextAmp;
169
+ }
170
+ partialNextAmp.forEach(part => nextAmp.push(part));
171
+ });
172
+ return nextAmp;
173
+ }
174
+ /**
175
+ * selector mustn't includes '&'
176
+ * selector is trimmed
177
+ */
178
+ function resolveSelector(amp, selector) {
179
+ const nextAmp = [];
180
+ selector.split(separatorRegex).forEach(partialSelector => {
181
+ amp.forEach(partialAmp => {
182
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
183
+ nextAmp.push(((partialAmp && partialAmp + ' ') + partialSelector));
184
+ });
185
+ });
186
+ return nextAmp;
187
+ }
188
+ function parseSelectorPath(selectorPaths) {
189
+ let amp = [''];
190
+ selectorPaths.forEach(selector => {
191
+ // eslint-disable-next-line
192
+ selector = selector && selector.trim();
193
+ if (
194
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
195
+ !selector) {
196
+ /**
197
+ * if it's a empty selector, do nothing
198
+ */
199
+ return;
200
+ }
201
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
202
+ if (selector.includes('&')) {
203
+ amp = resolveSelectorWithAmp(amp, selector);
204
+ }
205
+ else {
206
+ amp = resolveSelector(amp, selector);
207
+ }
208
+ });
209
+ return amp.join(', ').replace(extraSpaceRegex, ' ');
210
+ }
211
+
212
+ function removeElement(el) {
213
+ /* istanbul ignore if */
214
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
215
+ if (!el)
216
+ return;
217
+ const parentElement = el.parentElement;
218
+ /* istanbul ignore else */
219
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
220
+ if (parentElement)
221
+ parentElement.removeChild(el);
222
+ }
223
+ function queryElement(id, parent) {
224
+ return (parent !== null && parent !== void 0 ? parent : document.head).querySelector(`style[cssr-id="${id}"]`);
225
+ }
226
+ function createElement(id) {
227
+ const el = document.createElement('style');
228
+ el.setAttribute('cssr-id', id);
229
+ return el;
230
+ }
231
+ function isMediaOrSupports(selector) {
232
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
233
+ if (!selector)
234
+ return false;
235
+ return /^\s*@(s|m)/.test(selector);
236
+ }
237
+
238
+ const kebabRegex = /[A-Z]/g;
239
+ function kebabCase(pattern) {
240
+ return pattern.replace(kebabRegex, match => '-' + match.toLowerCase());
241
+ }
242
+ /** TODO: refine it to solve nested object */
243
+ function unwrapProperty(prop, indent = ' ') {
244
+ if (typeof prop === 'object' && prop !== null) {
245
+ return (' {\n' +
246
+ Object.entries(prop).map(v => {
247
+ return indent + ` ${kebabCase(v[0])}: ${v[1]};`;
248
+ }).join('\n') +
249
+ '\n' + indent + '}');
250
+ }
251
+ return `: ${prop};`;
252
+ }
253
+ /** unwrap properties */
254
+ function unwrapProperties(props, instance, params) {
255
+ if (typeof props === 'function') {
256
+ return props({
257
+ context: instance.context,
258
+ props: params
259
+ });
260
+ }
261
+ return props;
262
+ }
263
+ function createStyle(selector, props, instance, params) {
264
+ if (!props)
265
+ return '';
266
+ // eslint-disable-next-line
267
+ const unwrappedProps = unwrapProperties(props, instance, params);
268
+ if (!unwrappedProps)
269
+ return '';
270
+ if (typeof unwrappedProps === 'string') {
271
+ return `${selector} {\n${unwrappedProps}\n}`;
272
+ }
273
+ const propertyNames = Object.keys(unwrappedProps);
274
+ if (propertyNames.length === 0) {
275
+ if (instance.config.keepEmptyBlock)
276
+ return selector + ' {\n}';
277
+ return '';
278
+ }
279
+ const statements = selector
280
+ ? [
281
+ selector + ' {'
282
+ ]
283
+ : [];
284
+ propertyNames.forEach(propertyName => {
285
+ const property = unwrappedProps[propertyName];
286
+ if (propertyName === 'raw') {
287
+ statements.push('\n' + property + '\n');
288
+ return;
289
+ }
290
+ propertyName = kebabCase(propertyName);
291
+ if (property !== null && property !== undefined) {
292
+ statements.push(` ${propertyName}${unwrapProperty(property)}`);
293
+ }
294
+ });
295
+ if (selector) {
296
+ statements.push('}');
297
+ }
298
+ return statements.join('\n');
299
+ }
300
+ function loopCNodeListWithCallback(children, options, callback) {
301
+ /* istanbul ignore if */
302
+ if (!children)
303
+ return;
304
+ children.forEach(child => {
305
+ if (Array.isArray(child)) {
306
+ loopCNodeListWithCallback(child, options, callback);
307
+ }
308
+ else if (typeof child === 'function') {
309
+ const grandChildren = child(options);
310
+ if (Array.isArray(grandChildren)) {
311
+ loopCNodeListWithCallback(grandChildren, options, callback);
312
+ }
313
+ else if (grandChildren) {
314
+ callback(grandChildren);
315
+ }
316
+ }
317
+ else if (child) {
318
+ callback(child);
319
+ }
320
+ });
321
+ }
322
+ function traverseCNode(node, selectorPaths, styles, instance, params) {
323
+ const $ = node.$;
324
+ let blockSelector = '';
325
+ if (!$ || typeof $ === 'string') {
326
+ if (isMediaOrSupports($)) {
327
+ blockSelector = $;
328
+ }
329
+ else {
330
+ // as a string selector
331
+ selectorPaths.push($);
332
+ }
333
+ }
334
+ else if (typeof $ === 'function') {
335
+ const selector = $({
336
+ context: instance.context,
337
+ props: params
338
+ });
339
+ if (isMediaOrSupports(selector)) {
340
+ blockSelector = selector;
341
+ }
342
+ else {
343
+ // as a lazy selector
344
+ selectorPaths.push(selector);
345
+ }
346
+ }
347
+ else { // as a option selector
348
+ if ($.before)
349
+ $.before(instance.context);
350
+ if (!$.$ || typeof $.$ === 'string') {
351
+ if (isMediaOrSupports($.$)) {
352
+ blockSelector = $.$;
353
+ }
354
+ else {
355
+ // as a string selector
356
+ selectorPaths.push($.$);
357
+ }
358
+ }
359
+ else /* istanbul ignore else */ if ($.$) {
360
+ const selector = $.$({
361
+ context: instance.context,
362
+ props: params
363
+ });
364
+ if (isMediaOrSupports(selector)) {
365
+ blockSelector = selector;
366
+ }
367
+ else {
368
+ // as a lazy selector
369
+ selectorPaths.push(selector);
370
+ }
371
+ }
372
+ }
373
+ const selector = parseSelectorPath(selectorPaths);
374
+ const style = createStyle(selector, node.props, instance, params);
375
+ if (blockSelector) {
376
+ styles.push(`${blockSelector} {`);
377
+ }
378
+ else if (style.length) {
379
+ styles.push(style);
380
+ }
381
+ if (node.children) {
382
+ loopCNodeListWithCallback(node.children, {
383
+ context: instance.context,
384
+ props: params
385
+ }, childNode => {
386
+ if (typeof childNode === 'string') {
387
+ const style = createStyle(selector, { raw: childNode }, instance, params);
388
+ styles.push(style);
389
+ }
390
+ else {
391
+ traverseCNode(childNode, selectorPaths, styles, instance, params);
392
+ }
393
+ });
394
+ }
395
+ selectorPaths.pop();
396
+ if (blockSelector) {
397
+ styles.push('}');
398
+ }
399
+ if ($ && $.after)
400
+ $.after(instance.context);
401
+ }
402
+ function render(node, instance, props) {
403
+ const styles = [];
404
+ traverseCNode(node, [], styles, instance, props);
405
+ return styles.join('\n\n');
406
+ }
407
+
408
+ /* eslint-disable */
409
+ // Inspired by https://github.com/garycourt/murmurhash-js
410
+ // Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
411
+ function murmur2(str) {
412
+ // 'm' and 'r' are mixing constants generated offline.
413
+ // They're not really 'magic', they just happen to work well.
414
+ // const m = 0x5bd1e995;
415
+ // const r = 24;
416
+ // Initialize the hash
417
+ var h = 0; // Mix 4 bytes at a time into the hash
418
+
419
+ var k,
420
+ i = 0,
421
+ len = str.length;
422
+
423
+ for (; len >= 4; ++i, len -= 4) {
424
+ k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
425
+ k =
426
+ /* Math.imul(k, m): */
427
+ (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
428
+ k ^=
429
+ /* k >>> r: */
430
+ k >>> 24;
431
+ h =
432
+ /* Math.imul(k, m): */
433
+ (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
434
+ /* Math.imul(h, m): */
435
+ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
436
+ } // Handle the last few bytes of the input array
437
+
438
+
439
+ switch (len) {
440
+ case 3:
441
+ h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
442
+
443
+ case 2:
444
+ h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
445
+
446
+ case 1:
447
+ h ^= str.charCodeAt(i) & 0xff;
448
+ h =
449
+ /* Math.imul(h, m): */
450
+ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
451
+ } // Do a few final mixes of the hash to ensure the last few
452
+ // bytes are well-incorporated.
453
+
454
+
455
+ h ^= h >>> 13;
456
+ h =
457
+ /* Math.imul(h, m): */
458
+ (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
459
+ return ((h ^ h >>> 15) >>> 0).toString(36);
460
+ }
461
+
462
+ /* eslint-disable @typescript-eslint/prefer-ts-expect-error */
463
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions */
464
+ if (typeof window !== 'undefined') {
465
+ window.__cssrContext = {};
466
+ }
467
+ function unmount(instance, node, id, parent) {
468
+ const { els } = node;
469
+ // If id is undefined, unmount all styles
470
+ if (id === undefined) {
471
+ els.forEach(removeElement);
472
+ node.els = [];
473
+ }
474
+ else {
475
+ const target = queryElement(id, parent);
476
+ // eslint-disable-next-line
477
+ if (target && els.includes(target)) {
478
+ removeElement(target);
479
+ node.els = els.filter((el) => el !== target);
480
+ }
481
+ }
482
+ }
483
+ function addElementToList(els, target) {
484
+ els.push(target);
485
+ }
486
+ function mount(instance, node, id, props, head, force, anchorMetaName, parent, ssrAdapter
487
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
488
+ ) {
489
+ let style;
490
+ if (id === undefined) {
491
+ style = node.render(props);
492
+ id = murmur2(style);
493
+ }
494
+ if (ssrAdapter) {
495
+ ssrAdapter.adapter(id, style !== null && style !== void 0 ? style : node.render(props));
496
+ return;
497
+ }
498
+ if (parent === undefined) {
499
+ parent = document.head;
500
+ }
501
+ const queriedTarget = queryElement(id, parent);
502
+ if (queriedTarget !== null && !force) {
503
+ return queriedTarget;
504
+ }
505
+ const target = queriedTarget !== null && queriedTarget !== void 0 ? queriedTarget : createElement(id);
506
+ if (style === undefined)
507
+ style = node.render(props);
508
+ target.textContent = style;
509
+ if (queriedTarget !== null)
510
+ return queriedTarget;
511
+ if (anchorMetaName) {
512
+ const anchorMetaEl = parent.querySelector(`meta[name="${anchorMetaName}"]`);
513
+ if (anchorMetaEl) {
514
+ parent.insertBefore(target, anchorMetaEl);
515
+ addElementToList(node.els, target);
516
+ return target;
517
+ }
518
+ }
519
+ if (head) {
520
+ parent.insertBefore(target, parent.querySelector('style, link'));
521
+ }
522
+ else {
523
+ parent.appendChild(target);
524
+ }
525
+ addElementToList(node.els, target);
526
+ return target;
527
+ }
528
+
529
+ function wrappedRender(props) {
530
+ return render(this, this.instance, props);
531
+ }
532
+ // do not guard node calling, it should throw an error.
533
+ function wrappedMount(options = {}
534
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
535
+ ) {
536
+ const { id, ssr, props, head = false, force = false, anchorMetaName, parent } = options;
537
+ const targetElement = mount(this.instance, this, id, props, head, force, anchorMetaName, parent, ssr);
538
+ return targetElement;
539
+ }
540
+ function wrappedUnmount(options = {}) {
541
+ /* istanbul ignore next */
542
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
543
+ const { id, parent } = options;
544
+ unmount(this.instance, this, id, parent);
545
+ }
546
+ const createCNode = function (instance, $, props, children) {
547
+ return {
548
+ instance,
549
+ $,
550
+ props,
551
+ children,
552
+ els: [],
553
+ render: wrappedRender,
554
+ mount: wrappedMount,
555
+ unmount: wrappedUnmount
556
+ };
557
+ };
558
+ const c$1 = function (instance, $, props, children) {
559
+ if (Array.isArray($)) {
560
+ return createCNode(instance, { $: null }, null, $);
561
+ }
562
+ else if (Array.isArray(props)) {
563
+ return createCNode(instance, $, null, props);
564
+ }
565
+ else if (Array.isArray(children)) {
566
+ return createCNode(instance, $, props, children);
567
+ }
568
+ else {
569
+ return createCNode(instance, $, props, null);
570
+ }
571
+ };
572
+
573
+ function CssRender(config = {}) {
574
+ const cssr = {
575
+ c: ((...args) => c$1(cssr, ...args)),
576
+ use: (plugin, ...args) => plugin.install(cssr, ...args),
577
+ find: queryElement,
578
+ context: {},
579
+ config
580
+ };
581
+ return cssr;
582
+ }
583
+
584
+ function exists(id, ssr) {
585
+ if (id === undefined)
586
+ return false;
587
+ if (ssr) {
588
+ const { context: { ids } } = ssr;
589
+ return ids.has(id);
590
+ }
591
+ return queryElement(id) !== null;
592
+ }
593
+
594
+ const namespace = 'n';
595
+ const prefix$1 = `.${namespace}-`;
596
+ const elementPrefix = '__';
597
+ const modifierPrefix = '--';
598
+ const cssr = CssRender();
599
+ const plugin = plugin$1({
600
+ blockPrefix: prefix$1,
601
+ elementPrefix,
602
+ modifierPrefix
603
+ });
604
+ cssr.use(plugin);
605
+ const {
606
+ c,
607
+ find
608
+ } = cssr;
609
+ const {
610
+ cB,
611
+ cE,
612
+ cM,
613
+ cNotM
614
+ } = plugin;
615
+ function createKey(prefix, suffix) {
616
+ return prefix + (suffix === 'default' ? '' : suffix.replace(/^[a-z]/, startChar => startChar.toUpperCase()));
617
+ }
618
+
619
+ var colors = {
620
+ black: '#000',
621
+ silver: '#C0C0C0',
622
+ gray: '#808080',
623
+ white: '#FFF',
624
+ maroon: '#800000',
625
+ red: '#F00',
626
+ purple: '#800080',
627
+ fuchsia: '#F0F',
628
+ green: '#008000',
629
+ lime: '#0F0',
630
+ olive: '#808000',
631
+ yellow: '#FF0',
632
+ navy: '#000080',
633
+ blue: '#00F',
634
+ teal: '#008080',
635
+ aqua: '#0FF',
636
+ transparent: '#0000'
637
+ };
638
+
639
+ const prefix = '^\\s*';
640
+ const suffix = '\\s*$';
641
+ const float = '\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))\\s*'; // 4 offset
642
+ const hex = '([0-9A-Fa-f])';
643
+ const dhex = '([0-9A-Fa-f]{2})';
644
+ const rgbRegex = new RegExp(`${prefix}rgb\\s*\\(${float},${float},${float}\\)${suffix}`);
645
+ const rgbaRegex = new RegExp(`${prefix}rgba\\s*\\(${float},${float},${float},${float}\\)${suffix}`);
646
+ const sHexRegex = new RegExp(`${prefix}#${hex}${hex}${hex}${suffix}`);
647
+ const hexRegex = new RegExp(`${prefix}#${dhex}${dhex}${dhex}${suffix}`);
648
+ const sHexaRegex = new RegExp(`${prefix}#${hex}${hex}${hex}${hex}${suffix}`);
649
+ const hexaRegex = new RegExp(`${prefix}#${dhex}${dhex}${dhex}${dhex}${suffix}`);
650
+ function parseHex(value) {
651
+ return parseInt(value, 16);
652
+ }
653
+ /**
654
+ * Convert color string to rgba array.
655
+ * @param color format like #000[0], #000000[00], rgb(0, 0, 0), rgba(0, 0, 0, 0) and basic color keywords https://www.w3.org/TR/css-color-3/#html4 and transparent
656
+ * @returns
657
+ */
658
+ function rgba(color) {
659
+ try {
660
+ let i;
661
+ if ((i = hexRegex.exec(color))) {
662
+ return [parseHex(i[1]), parseHex(i[2]), parseHex(i[3]), 1];
663
+ }
664
+ else if ((i = rgbRegex.exec(color))) {
665
+ return [roundChannel(i[1]), roundChannel(i[5]), roundChannel(i[9]), 1];
666
+ }
667
+ else if ((i = rgbaRegex.exec(color))) {
668
+ return [
669
+ roundChannel(i[1]),
670
+ roundChannel(i[5]),
671
+ roundChannel(i[9]),
672
+ roundAlpha(i[13])
673
+ ];
674
+ }
675
+ else if ((i = sHexRegex.exec(color))) {
676
+ return [
677
+ parseHex(i[1] + i[1]),
678
+ parseHex(i[2] + i[2]),
679
+ parseHex(i[3] + i[3]),
680
+ 1
681
+ ];
682
+ }
683
+ else if ((i = hexaRegex.exec(color))) {
684
+ return [
685
+ parseHex(i[1]),
686
+ parseHex(i[2]),
687
+ parseHex(i[3]),
688
+ roundAlpha(parseHex(i[4]) / 255)
689
+ ];
690
+ }
691
+ else if ((i = sHexaRegex.exec(color))) {
692
+ return [
693
+ parseHex(i[1] + i[1]),
694
+ parseHex(i[2] + i[2]),
695
+ parseHex(i[3] + i[3]),
696
+ roundAlpha(parseHex(i[4] + i[4]) / 255)
697
+ ];
698
+ }
699
+ else if (color in colors) {
700
+ return rgba(colors[color]);
701
+ }
702
+ throw new Error(`[seemly/rgba]: Invalid color value ${color}.`);
703
+ }
704
+ catch (e) {
705
+ throw e;
706
+ }
707
+ }
708
+ function normalizeAlpha(alphaValue) {
709
+ return alphaValue > 1 ? 1 : alphaValue < 0 ? 0 : alphaValue;
710
+ }
711
+ function stringifyRgba(r, g, b, a) {
712
+ return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${normalizeAlpha(a)})`;
713
+ }
714
+ function compositeChannel(v1, a1, v2, a2, a) {
715
+ return roundChannel((v1 * a1 * (1 - a2) + v2 * a2) / a);
716
+ }
717
+ function composite(background, overlay) {
718
+ if (!Array.isArray(background))
719
+ background = rgba(background);
720
+ if (!Array.isArray(overlay))
721
+ overlay = rgba(overlay);
722
+ const a1 = background[3];
723
+ const a2 = overlay[3];
724
+ const alpha = roundAlpha(a1 + a2 - a1 * a2);
725
+ return stringifyRgba(compositeChannel(background[0], a1, overlay[0], a2, alpha), compositeChannel(background[1], a1, overlay[1], a2, alpha), compositeChannel(background[2], a1, overlay[2], a2, alpha), alpha);
726
+ }
727
+ function changeColor(base, options) {
728
+ const [r, g, b, a = 1] = Array.isArray(base) ? base : rgba(base);
729
+ if (options.alpha) {
730
+ return stringifyRgba(r, g, b, options.alpha);
731
+ }
732
+ return stringifyRgba(r, g, b, a);
733
+ }
734
+ function scaleColor(base, options) {
735
+ const [r, g, b, a = 1] = Array.isArray(base) ? base : rgba(base);
736
+ const { lightness = 1, alpha = 1 } = options;
737
+ return toRgbaString([r * lightness, g * lightness, b * lightness, a * alpha]);
738
+ }
739
+ function roundAlpha(value) {
740
+ const v = Math.round(Number(value) * 100) / 100;
741
+ if (v > 1)
742
+ return 1;
743
+ if (v < 0)
744
+ return 0;
745
+ return v;
746
+ }
747
+ function roundChannel(value) {
748
+ const v = Math.round(Number(value));
749
+ if (v > 255)
750
+ return 255;
751
+ if (v < 0)
752
+ return 0;
753
+ return v;
754
+ }
755
+ function toRgbaString(base) {
756
+ const [r, g, b] = base;
757
+ if (3 in base) {
758
+ return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${roundAlpha(base[3])})`;
759
+ }
760
+ return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, 1)`;
761
+ }
762
+
763
+ function useMemo(getterOrOptions) {
764
+ const computedValueRef = computed(getterOrOptions);
765
+ // Maybe it's not possible to lazy evaluate the value, since we can't make
766
+ // render phase capture the deps behind useMemo
767
+ const valueRef = ref(computedValueRef.value);
768
+ watch(computedValueRef, (value) => {
769
+ valueRef.value = value;
770
+ });
771
+ if (typeof getterOrOptions === 'function') {
772
+ return valueRef;
773
+ }
774
+ else {
775
+ return {
776
+ __v_isRef: true,
777
+ get value() {
778
+ return valueRef.value;
779
+ },
780
+ set value(v) {
781
+ getterOrOptions.set(v);
782
+ }
783
+ };
784
+ }
785
+ }
786
+
787
+ function useMergedState(controlledStateRef, uncontrolledStateRef) {
788
+ watch(controlledStateRef, value => {
789
+ if (value !== undefined) {
790
+ uncontrolledStateRef.value = value;
791
+ }
792
+ });
793
+ return computed(() => {
794
+ if (controlledStateRef.value === undefined) {
795
+ return uncontrolledStateRef.value;
796
+ }
797
+ return controlledStateRef.value;
798
+ });
799
+ }
800
+
801
+ function createInjectionKey(key) {
802
+ return key;
803
+ }
804
+
805
+ const ssrContextKey = '@css-render/vue3-ssr';
806
+ function createStyleString(id, style) {
807
+ return `<style cssr-id="${id}">\n${style}\n</style>`;
808
+ }
809
+ function ssrAdapter(id, style, ssrContext) {
810
+ const { styles, ids } = ssrContext;
811
+ // we need to impl other options to make it behaves the same as the client side
812
+ if (ids.has(id))
813
+ return;
814
+ if (styles !== null) {
815
+ ids.add(id);
816
+ styles.push(createStyleString(id, style));
817
+ }
818
+ }
819
+ const isBrowser = typeof document !== 'undefined';
820
+ function useSsrAdapter() {
821
+ if (isBrowser)
822
+ return undefined;
823
+ const context = inject(ssrContextKey, null);
824
+ if (context === null)
825
+ return undefined;
826
+ return {
827
+ adapter: (id, style) => ssrAdapter(id, style, context),
828
+ context
829
+ };
830
+ }
831
+
832
+ const warnedMessages = new Set();
833
+ function warnOnce(location, message) {
834
+ const mergedMessage = `[naive/${location}]: ${message}`;
835
+ if (warnedMessages.has(mergedMessage)) return;
836
+ warnedMessages.add(mergedMessage);
837
+ console.error(mergedMessage);
838
+ }
839
+ function throwError(location, message) {
840
+ throw new Error(`[naive/${location}]: ${message}`);
841
+ }
842
+
843
+ function call(funcs, ...args) {
844
+ if (Array.isArray(funcs)) {
845
+ funcs.forEach(func => call(func, ...args));
846
+ } else {
847
+ return funcs(...args);
848
+ }
849
+ }
850
+
851
+ function ensureValidVNode(vnodes) {
852
+ return vnodes.some(child => {
853
+ if (!isVNode(child)) {
854
+ return true;
855
+ }
856
+ if (child.type === Comment) {
857
+ return false;
858
+ }
859
+ if (child.type === Fragment && !ensureValidVNode(child.children)) {
860
+ return false;
861
+ }
862
+ return true;
863
+ }) ? vnodes : null;
864
+ }
865
+ /**
866
+ * Resolve slot with wrapper if content exists, no fallback
867
+ */
868
+ function resolveWrappedSlot(slot, wrapper) {
869
+ const children = slot && ensureValidVNode(slot());
870
+ return wrapper(children || null);
871
+ }
872
+
873
+ const configProviderInjectionKey = createInjectionKey('n-config-provider');
874
+
875
+ const defaultClsPrefix = 'n';
876
+ function useConfig(props = {}, options = {
877
+ defaultBordered: true
878
+ }) {
879
+ const NConfigProvider = inject(configProviderInjectionKey, null);
880
+ return {
881
+ // NConfigProvider,
882
+ inlineThemeDisabled: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.inlineThemeDisabled,
883
+ mergedRtlRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedRtlRef,
884
+ mergedComponentPropsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedComponentPropsRef,
885
+ mergedBreakpointsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBreakpointsRef,
886
+ mergedBorderedRef: computed(() => {
887
+ var _a, _b;
888
+ const {
889
+ bordered
890
+ } = props;
891
+ if (bordered !== undefined) return bordered;
892
+ return (_b = (_a = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBorderedRef.value) !== null && _a !== void 0 ? _a : options.defaultBordered) !== null && _b !== void 0 ? _b : true;
893
+ }),
894
+ mergedClsPrefixRef: NConfigProvider ? NConfigProvider.mergedClsPrefixRef : shallowRef(defaultClsPrefix),
895
+ namespaceRef: computed(() => NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedNamespaceRef.value)
896
+ };
897
+ }
898
+
899
+ function useThemeClass(componentName, hashRef, cssVarsRef, props) {
900
+ if (!cssVarsRef) throwError('useThemeClass', 'cssVarsRef is not passed');
901
+ const NConfigProvider = inject(configProviderInjectionKey, null);
902
+ const mergedThemeHashRef = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeHashRef;
903
+ const styleMountTarget = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget;
904
+ const themeClassRef = ref('');
905
+ const ssrAdapter = useSsrAdapter();
906
+ let renderCallback;
907
+ const hashClassPrefix = `__${componentName}`;
908
+ const mountStyle = () => {
909
+ let finalThemeHash = hashClassPrefix;
910
+ const hashValue = hashRef ? hashRef.value : undefined;
911
+ const themeHash = mergedThemeHashRef === null || mergedThemeHashRef === void 0 ? void 0 : mergedThemeHashRef.value;
912
+ if (themeHash) finalThemeHash += `-${themeHash}`;
913
+ if (hashValue) finalThemeHash += `-${hashValue}`;
914
+ const {
915
+ themeOverrides,
916
+ builtinThemeOverrides
917
+ } = props;
918
+ if (themeOverrides) {
919
+ finalThemeHash += `-${murmur2(JSON.stringify(themeOverrides))}`;
920
+ }
921
+ if (builtinThemeOverrides) {
922
+ finalThemeHash += `-${murmur2(JSON.stringify(builtinThemeOverrides))}`;
923
+ }
924
+ themeClassRef.value = finalThemeHash;
925
+ renderCallback = () => {
926
+ const cssVars = cssVarsRef.value;
927
+ let style = '';
928
+ for (const key in cssVars) {
929
+ style += `${key}: ${cssVars[key]};`;
930
+ }
931
+ c(`.${finalThemeHash}`, style).mount({
932
+ id: finalThemeHash,
933
+ ssr: ssrAdapter,
934
+ parent: styleMountTarget
935
+ });
936
+ renderCallback = undefined;
937
+ };
938
+ };
939
+ watchEffect(() => {
940
+ mountStyle();
941
+ });
942
+ return {
943
+ themeClass: themeClassRef,
944
+ onRender: () => {
945
+ renderCallback === null || renderCallback === void 0 ? void 0 : renderCallback();
946
+ }
947
+ };
948
+ }
949
+
950
+ const formItemInjectionKey = createInjectionKey('n-form-item');
951
+ function useFormItem(props, {
952
+ defaultSize = 'medium',
953
+ mergedSize,
954
+ mergedDisabled
955
+ } = {}) {
956
+ const NFormItem = inject(formItemInjectionKey, null);
957
+ provide(formItemInjectionKey, null);
958
+ const mergedSizeRef = computed(mergedSize ? () => mergedSize(NFormItem) : () => {
959
+ const {
960
+ size
961
+ } = props;
962
+ if (size) return size;
963
+ if (NFormItem) {
964
+ const {
965
+ mergedSize
966
+ } = NFormItem;
967
+ if (mergedSize.value !== undefined) {
968
+ return mergedSize.value;
969
+ }
970
+ }
971
+ return defaultSize;
972
+ });
973
+ const mergedDisabledRef = computed(mergedDisabled ? () => mergedDisabled(NFormItem) : () => {
974
+ const {
975
+ disabled
976
+ } = props;
977
+ if (disabled !== undefined) {
978
+ return disabled;
979
+ }
980
+ if (NFormItem) {
981
+ return NFormItem.disabled.value;
982
+ }
983
+ return false;
984
+ });
985
+ const mergedStatusRef = computed(() => {
986
+ const {
987
+ status
988
+ } = props;
989
+ if (status) return status;
990
+ return NFormItem === null || NFormItem === void 0 ? void 0 : NFormItem.mergedValidationStatus.value;
991
+ });
992
+ onBeforeUnmount(() => {
993
+ if (NFormItem) {
994
+ NFormItem.restoreValidation();
995
+ }
996
+ });
997
+ return {
998
+ mergedSizeRef,
999
+ mergedDisabledRef,
1000
+ mergedStatusRef,
1001
+ nTriggerFormBlur() {
1002
+ if (NFormItem) {
1003
+ NFormItem.handleContentBlur();
1004
+ }
1005
+ },
1006
+ nTriggerFormChange() {
1007
+ if (NFormItem) {
1008
+ NFormItem.handleContentChange();
1009
+ }
1010
+ },
1011
+ nTriggerFormFocus() {
1012
+ if (NFormItem) {
1013
+ NFormItem.handleContentFocus();
1014
+ }
1015
+ },
1016
+ nTriggerFormInput() {
1017
+ if (NFormItem) {
1018
+ NFormItem.handleContentInput();
1019
+ }
1020
+ }
1021
+ };
1022
+ }
1023
+
1024
+ /** Detect free variable `global` from Node.js. */
1025
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
1026
+
1027
+ /** Detect free variable `self`. */
1028
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1029
+
1030
+ /** Used as a reference to the global object. */
1031
+ var root = freeGlobal || freeSelf || Function('return this')();
1032
+
1033
+ /** Built-in value references. */
1034
+ var Symbol = root.Symbol;
1035
+
1036
+ /** Used for built-in method references. */
1037
+ var objectProto$9 = Object.prototype;
1038
+
1039
+ /** Used to check objects for own properties. */
1040
+ var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
1041
+
1042
+ /**
1043
+ * Used to resolve the
1044
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1045
+ * of values.
1046
+ */
1047
+ var nativeObjectToString$1 = objectProto$9.toString;
1048
+
1049
+ /** Built-in value references. */
1050
+ var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
1051
+
1052
+ /**
1053
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1054
+ *
1055
+ * @private
1056
+ * @param {*} value The value to query.
1057
+ * @returns {string} Returns the raw `toStringTag`.
1058
+ */
1059
+ function getRawTag(value) {
1060
+ var isOwn = hasOwnProperty$7.call(value, symToStringTag$1),
1061
+ tag = value[symToStringTag$1];
1062
+
1063
+ try {
1064
+ value[symToStringTag$1] = undefined;
1065
+ var unmasked = true;
1066
+ } catch (e) {}
1067
+
1068
+ var result = nativeObjectToString$1.call(value);
1069
+ if (unmasked) {
1070
+ if (isOwn) {
1071
+ value[symToStringTag$1] = tag;
1072
+ } else {
1073
+ delete value[symToStringTag$1];
1074
+ }
1075
+ }
1076
+ return result;
1077
+ }
1078
+
1079
+ /** Used for built-in method references. */
1080
+ var objectProto$8 = Object.prototype;
1081
+
1082
+ /**
1083
+ * Used to resolve the
1084
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1085
+ * of values.
1086
+ */
1087
+ var nativeObjectToString = objectProto$8.toString;
1088
+
1089
+ /**
1090
+ * Converts `value` to a string using `Object.prototype.toString`.
1091
+ *
1092
+ * @private
1093
+ * @param {*} value The value to convert.
1094
+ * @returns {string} Returns the converted string.
1095
+ */
1096
+ function objectToString(value) {
1097
+ return nativeObjectToString.call(value);
1098
+ }
1099
+
1100
+ /** `Object#toString` result references. */
1101
+ var nullTag = '[object Null]',
1102
+ undefinedTag = '[object Undefined]';
1103
+
1104
+ /** Built-in value references. */
1105
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1106
+
1107
+ /**
1108
+ * The base implementation of `getTag` without fallbacks for buggy environments.
1109
+ *
1110
+ * @private
1111
+ * @param {*} value The value to query.
1112
+ * @returns {string} Returns the `toStringTag`.
1113
+ */
1114
+ function baseGetTag(value) {
1115
+ if (value == null) {
1116
+ return value === undefined ? undefinedTag : nullTag;
1117
+ }
1118
+ return (symToStringTag && symToStringTag in Object(value))
1119
+ ? getRawTag(value)
1120
+ : objectToString(value);
1121
+ }
1122
+
1123
+ /**
1124
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
1125
+ * and has a `typeof` result of "object".
1126
+ *
1127
+ * @static
1128
+ * @memberOf _
1129
+ * @since 4.0.0
1130
+ * @category Lang
1131
+ * @param {*} value The value to check.
1132
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1133
+ * @example
1134
+ *
1135
+ * _.isObjectLike({});
1136
+ * // => true
1137
+ *
1138
+ * _.isObjectLike([1, 2, 3]);
1139
+ * // => true
1140
+ *
1141
+ * _.isObjectLike(_.noop);
1142
+ * // => false
1143
+ *
1144
+ * _.isObjectLike(null);
1145
+ * // => false
1146
+ */
1147
+ function isObjectLike(value) {
1148
+ return value != null && typeof value == 'object';
1149
+ }
1150
+
1151
+ /**
1152
+ * Checks if `value` is classified as an `Array` object.
1153
+ *
1154
+ * @static
1155
+ * @memberOf _
1156
+ * @since 0.1.0
1157
+ * @category Lang
1158
+ * @param {*} value The value to check.
1159
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1160
+ * @example
1161
+ *
1162
+ * _.isArray([1, 2, 3]);
1163
+ * // => true
1164
+ *
1165
+ * _.isArray(document.body.children);
1166
+ * // => false
1167
+ *
1168
+ * _.isArray('abc');
1169
+ * // => false
1170
+ *
1171
+ * _.isArray(_.noop);
1172
+ * // => false
1173
+ */
1174
+ var isArray = Array.isArray;
1175
+
1176
+ /**
1177
+ * Checks if `value` is the
1178
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1179
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1180
+ *
1181
+ * @static
1182
+ * @memberOf _
1183
+ * @since 0.1.0
1184
+ * @category Lang
1185
+ * @param {*} value The value to check.
1186
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1187
+ * @example
1188
+ *
1189
+ * _.isObject({});
1190
+ * // => true
1191
+ *
1192
+ * _.isObject([1, 2, 3]);
1193
+ * // => true
1194
+ *
1195
+ * _.isObject(_.noop);
1196
+ * // => true
1197
+ *
1198
+ * _.isObject(null);
1199
+ * // => false
1200
+ */
1201
+ function isObject(value) {
1202
+ var type = typeof value;
1203
+ return value != null && (type == 'object' || type == 'function');
1204
+ }
1205
+
1206
+ /**
1207
+ * This method returns the first argument it receives.
1208
+ *
1209
+ * @static
1210
+ * @since 0.1.0
1211
+ * @memberOf _
1212
+ * @category Util
1213
+ * @param {*} value Any value.
1214
+ * @returns {*} Returns `value`.
1215
+ * @example
1216
+ *
1217
+ * var object = { 'a': 1 };
1218
+ *
1219
+ * console.log(_.identity(object) === object);
1220
+ * // => true
1221
+ */
1222
+ function identity(value) {
1223
+ return value;
1224
+ }
1225
+
1226
+ /** `Object#toString` result references. */
1227
+ var asyncTag = '[object AsyncFunction]',
1228
+ funcTag$1 = '[object Function]',
1229
+ genTag = '[object GeneratorFunction]',
1230
+ proxyTag = '[object Proxy]';
1231
+
1232
+ /**
1233
+ * Checks if `value` is classified as a `Function` object.
1234
+ *
1235
+ * @static
1236
+ * @memberOf _
1237
+ * @since 0.1.0
1238
+ * @category Lang
1239
+ * @param {*} value The value to check.
1240
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1241
+ * @example
1242
+ *
1243
+ * _.isFunction(_);
1244
+ * // => true
1245
+ *
1246
+ * _.isFunction(/abc/);
1247
+ * // => false
1248
+ */
1249
+ function isFunction(value) {
1250
+ if (!isObject(value)) {
1251
+ return false;
1252
+ }
1253
+ // The use of `Object#toString` avoids issues with the `typeof` operator
1254
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
1255
+ var tag = baseGetTag(value);
1256
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
1257
+ }
1258
+
1259
+ /** Used to detect overreaching core-js shims. */
1260
+ var coreJsData = root['__core-js_shared__'];
1261
+
1262
+ /** Used to detect methods masquerading as native. */
1263
+ var maskSrcKey = (function() {
1264
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1265
+ return uid ? ('Symbol(src)_1.' + uid) : '';
1266
+ }());
1267
+
1268
+ /**
1269
+ * Checks if `func` has its source masked.
1270
+ *
1271
+ * @private
1272
+ * @param {Function} func The function to check.
1273
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1274
+ */
1275
+ function isMasked(func) {
1276
+ return !!maskSrcKey && (maskSrcKey in func);
1277
+ }
1278
+
1279
+ /** Used for built-in method references. */
1280
+ var funcProto$2 = Function.prototype;
1281
+
1282
+ /** Used to resolve the decompiled source of functions. */
1283
+ var funcToString$2 = funcProto$2.toString;
1284
+
1285
+ /**
1286
+ * Converts `func` to its source code.
1287
+ *
1288
+ * @private
1289
+ * @param {Function} func The function to convert.
1290
+ * @returns {string} Returns the source code.
1291
+ */
1292
+ function toSource(func) {
1293
+ if (func != null) {
1294
+ try {
1295
+ return funcToString$2.call(func);
1296
+ } catch (e) {}
1297
+ try {
1298
+ return (func + '');
1299
+ } catch (e) {}
1300
+ }
1301
+ return '';
1302
+ }
1303
+
1304
+ /**
1305
+ * Used to match `RegExp`
1306
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1307
+ */
1308
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1309
+
1310
+ /** Used to detect host constructors (Safari). */
1311
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
1312
+
1313
+ /** Used for built-in method references. */
1314
+ var funcProto$1 = Function.prototype,
1315
+ objectProto$7 = Object.prototype;
1316
+
1317
+ /** Used to resolve the decompiled source of functions. */
1318
+ var funcToString$1 = funcProto$1.toString;
1319
+
1320
+ /** Used to check objects for own properties. */
1321
+ var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
1322
+
1323
+ /** Used to detect if a method is native. */
1324
+ var reIsNative = RegExp('^' +
1325
+ funcToString$1.call(hasOwnProperty$6).replace(reRegExpChar, '\\$&')
1326
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1327
+ );
1328
+
1329
+ /**
1330
+ * The base implementation of `_.isNative` without bad shim checks.
1331
+ *
1332
+ * @private
1333
+ * @param {*} value The value to check.
1334
+ * @returns {boolean} Returns `true` if `value` is a native function,
1335
+ * else `false`.
1336
+ */
1337
+ function baseIsNative(value) {
1338
+ if (!isObject(value) || isMasked(value)) {
1339
+ return false;
1340
+ }
1341
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1342
+ return pattern.test(toSource(value));
1343
+ }
1344
+
1345
+ /**
1346
+ * Gets the value at `key` of `object`.
1347
+ *
1348
+ * @private
1349
+ * @param {Object} [object] The object to query.
1350
+ * @param {string} key The key of the property to get.
1351
+ * @returns {*} Returns the property value.
1352
+ */
1353
+ function getValue(object, key) {
1354
+ return object == null ? undefined : object[key];
1355
+ }
1356
+
1357
+ /**
1358
+ * Gets the native function at `key` of `object`.
1359
+ *
1360
+ * @private
1361
+ * @param {Object} object The object to query.
1362
+ * @param {string} key The key of the method to get.
1363
+ * @returns {*} Returns the function if it's native, else `undefined`.
1364
+ */
1365
+ function getNative(object, key) {
1366
+ var value = getValue(object, key);
1367
+ return baseIsNative(value) ? value : undefined;
1368
+ }
1369
+
1370
+ /** Built-in value references. */
1371
+ var objectCreate = Object.create;
1372
+
1373
+ /**
1374
+ * The base implementation of `_.create` without support for assigning
1375
+ * properties to the created object.
1376
+ *
1377
+ * @private
1378
+ * @param {Object} proto The object to inherit from.
1379
+ * @returns {Object} Returns the new object.
1380
+ */
1381
+ var baseCreate = (function() {
1382
+ function object() {}
1383
+ return function(proto) {
1384
+ if (!isObject(proto)) {
1385
+ return {};
1386
+ }
1387
+ if (objectCreate) {
1388
+ return objectCreate(proto);
1389
+ }
1390
+ object.prototype = proto;
1391
+ var result = new object;
1392
+ object.prototype = undefined;
1393
+ return result;
1394
+ };
1395
+ }());
1396
+
1397
+ /**
1398
+ * A faster alternative to `Function#apply`, this function invokes `func`
1399
+ * with the `this` binding of `thisArg` and the arguments of `args`.
1400
+ *
1401
+ * @private
1402
+ * @param {Function} func The function to invoke.
1403
+ * @param {*} thisArg The `this` binding of `func`.
1404
+ * @param {Array} args The arguments to invoke `func` with.
1405
+ * @returns {*} Returns the result of `func`.
1406
+ */
1407
+ function apply(func, thisArg, args) {
1408
+ switch (args.length) {
1409
+ case 0: return func.call(thisArg);
1410
+ case 1: return func.call(thisArg, args[0]);
1411
+ case 2: return func.call(thisArg, args[0], args[1]);
1412
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
1413
+ }
1414
+ return func.apply(thisArg, args);
1415
+ }
1416
+
1417
+ /**
1418
+ * Copies the values of `source` to `array`.
1419
+ *
1420
+ * @private
1421
+ * @param {Array} source The array to copy values from.
1422
+ * @param {Array} [array=[]] The array to copy values to.
1423
+ * @returns {Array} Returns `array`.
1424
+ */
1425
+ function copyArray(source, array) {
1426
+ var index = -1,
1427
+ length = source.length;
1428
+
1429
+ array || (array = Array(length));
1430
+ while (++index < length) {
1431
+ array[index] = source[index];
1432
+ }
1433
+ return array;
1434
+ }
1435
+
1436
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
1437
+ var HOT_COUNT = 800,
1438
+ HOT_SPAN = 16;
1439
+
1440
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1441
+ var nativeNow = Date.now;
1442
+
1443
+ /**
1444
+ * Creates a function that'll short out and invoke `identity` instead
1445
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
1446
+ * milliseconds.
1447
+ *
1448
+ * @private
1449
+ * @param {Function} func The function to restrict.
1450
+ * @returns {Function} Returns the new shortable function.
1451
+ */
1452
+ function shortOut(func) {
1453
+ var count = 0,
1454
+ lastCalled = 0;
1455
+
1456
+ return function() {
1457
+ var stamp = nativeNow(),
1458
+ remaining = HOT_SPAN - (stamp - lastCalled);
1459
+
1460
+ lastCalled = stamp;
1461
+ if (remaining > 0) {
1462
+ if (++count >= HOT_COUNT) {
1463
+ return arguments[0];
1464
+ }
1465
+ } else {
1466
+ count = 0;
1467
+ }
1468
+ return func.apply(undefined, arguments);
1469
+ };
1470
+ }
1471
+
1472
+ /**
1473
+ * Creates a function that returns `value`.
1474
+ *
1475
+ * @static
1476
+ * @memberOf _
1477
+ * @since 2.4.0
1478
+ * @category Util
1479
+ * @param {*} value The value to return from the new function.
1480
+ * @returns {Function} Returns the new constant function.
1481
+ * @example
1482
+ *
1483
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
1484
+ *
1485
+ * console.log(objects);
1486
+ * // => [{ 'a': 1 }, { 'a': 1 }]
1487
+ *
1488
+ * console.log(objects[0] === objects[1]);
1489
+ * // => true
1490
+ */
1491
+ function constant(value) {
1492
+ return function() {
1493
+ return value;
1494
+ };
1495
+ }
1496
+
1497
+ var defineProperty = (function() {
1498
+ try {
1499
+ var func = getNative(Object, 'defineProperty');
1500
+ func({}, '', {});
1501
+ return func;
1502
+ } catch (e) {}
1503
+ }());
1504
+
1505
+ /**
1506
+ * The base implementation of `setToString` without support for hot loop shorting.
1507
+ *
1508
+ * @private
1509
+ * @param {Function} func The function to modify.
1510
+ * @param {Function} string The `toString` result.
1511
+ * @returns {Function} Returns `func`.
1512
+ */
1513
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
1514
+ return defineProperty(func, 'toString', {
1515
+ 'configurable': true,
1516
+ 'enumerable': false,
1517
+ 'value': constant(string),
1518
+ 'writable': true
1519
+ });
1520
+ };
1521
+
1522
+ /**
1523
+ * Sets the `toString` method of `func` to return `string`.
1524
+ *
1525
+ * @private
1526
+ * @param {Function} func The function to modify.
1527
+ * @param {Function} string The `toString` result.
1528
+ * @returns {Function} Returns `func`.
1529
+ */
1530
+ var setToString = shortOut(baseSetToString);
1531
+
1532
+ /** Used as references for various `Number` constants. */
1533
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
1534
+
1535
+ /** Used to detect unsigned integer values. */
1536
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1537
+
1538
+ /**
1539
+ * Checks if `value` is a valid array-like index.
1540
+ *
1541
+ * @private
1542
+ * @param {*} value The value to check.
1543
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1544
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1545
+ */
1546
+ function isIndex(value, length) {
1547
+ var type = typeof value;
1548
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
1549
+
1550
+ return !!length &&
1551
+ (type == 'number' ||
1552
+ (type != 'symbol' && reIsUint.test(value))) &&
1553
+ (value > -1 && value % 1 == 0 && value < length);
1554
+ }
1555
+
1556
+ /**
1557
+ * The base implementation of `assignValue` and `assignMergeValue` without
1558
+ * value checks.
1559
+ *
1560
+ * @private
1561
+ * @param {Object} object The object to modify.
1562
+ * @param {string} key The key of the property to assign.
1563
+ * @param {*} value The value to assign.
1564
+ */
1565
+ function baseAssignValue(object, key, value) {
1566
+ if (key == '__proto__' && defineProperty) {
1567
+ defineProperty(object, key, {
1568
+ 'configurable': true,
1569
+ 'enumerable': true,
1570
+ 'value': value,
1571
+ 'writable': true
1572
+ });
1573
+ } else {
1574
+ object[key] = value;
1575
+ }
1576
+ }
1577
+
1578
+ /**
1579
+ * Performs a
1580
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1581
+ * comparison between two values to determine if they are equivalent.
1582
+ *
1583
+ * @static
1584
+ * @memberOf _
1585
+ * @since 4.0.0
1586
+ * @category Lang
1587
+ * @param {*} value The value to compare.
1588
+ * @param {*} other The other value to compare.
1589
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1590
+ * @example
1591
+ *
1592
+ * var object = { 'a': 1 };
1593
+ * var other = { 'a': 1 };
1594
+ *
1595
+ * _.eq(object, object);
1596
+ * // => true
1597
+ *
1598
+ * _.eq(object, other);
1599
+ * // => false
1600
+ *
1601
+ * _.eq('a', 'a');
1602
+ * // => true
1603
+ *
1604
+ * _.eq('a', Object('a'));
1605
+ * // => false
1606
+ *
1607
+ * _.eq(NaN, NaN);
1608
+ * // => true
1609
+ */
1610
+ function eq(value, other) {
1611
+ return value === other || (value !== value && other !== other);
1612
+ }
1613
+
1614
+ /** Used for built-in method references. */
1615
+ var objectProto$6 = Object.prototype;
1616
+
1617
+ /** Used to check objects for own properties. */
1618
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
1619
+
1620
+ /**
1621
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
1622
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1623
+ * for equality comparisons.
1624
+ *
1625
+ * @private
1626
+ * @param {Object} object The object to modify.
1627
+ * @param {string} key The key of the property to assign.
1628
+ * @param {*} value The value to assign.
1629
+ */
1630
+ function assignValue(object, key, value) {
1631
+ var objValue = object[key];
1632
+ if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) ||
1633
+ (value === undefined && !(key in object))) {
1634
+ baseAssignValue(object, key, value);
1635
+ }
1636
+ }
1637
+
1638
+ /**
1639
+ * Copies properties of `source` to `object`.
1640
+ *
1641
+ * @private
1642
+ * @param {Object} source The object to copy properties from.
1643
+ * @param {Array} props The property identifiers to copy.
1644
+ * @param {Object} [object={}] The object to copy properties to.
1645
+ * @param {Function} [customizer] The function to customize copied values.
1646
+ * @returns {Object} Returns `object`.
1647
+ */
1648
+ function copyObject(source, props, object, customizer) {
1649
+ var isNew = !object;
1650
+ object || (object = {});
1651
+
1652
+ var index = -1,
1653
+ length = props.length;
1654
+
1655
+ while (++index < length) {
1656
+ var key = props[index];
1657
+
1658
+ var newValue = undefined;
1659
+
1660
+ if (newValue === undefined) {
1661
+ newValue = source[key];
1662
+ }
1663
+ if (isNew) {
1664
+ baseAssignValue(object, key, newValue);
1665
+ } else {
1666
+ assignValue(object, key, newValue);
1667
+ }
1668
+ }
1669
+ return object;
1670
+ }
1671
+
1672
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1673
+ var nativeMax = Math.max;
1674
+
1675
+ /**
1676
+ * A specialized version of `baseRest` which transforms the rest array.
1677
+ *
1678
+ * @private
1679
+ * @param {Function} func The function to apply a rest parameter to.
1680
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
1681
+ * @param {Function} transform The rest array transform.
1682
+ * @returns {Function} Returns the new function.
1683
+ */
1684
+ function overRest(func, start, transform) {
1685
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1686
+ return function() {
1687
+ var args = arguments,
1688
+ index = -1,
1689
+ length = nativeMax(args.length - start, 0),
1690
+ array = Array(length);
1691
+
1692
+ while (++index < length) {
1693
+ array[index] = args[start + index];
1694
+ }
1695
+ index = -1;
1696
+ var otherArgs = Array(start + 1);
1697
+ while (++index < start) {
1698
+ otherArgs[index] = args[index];
1699
+ }
1700
+ otherArgs[start] = transform(array);
1701
+ return apply(func, this, otherArgs);
1702
+ };
1703
+ }
1704
+
1705
+ /**
1706
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
1707
+ *
1708
+ * @private
1709
+ * @param {Function} func The function to apply a rest parameter to.
1710
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
1711
+ * @returns {Function} Returns the new function.
1712
+ */
1713
+ function baseRest(func, start) {
1714
+ return setToString(overRest(func, start, identity), func + '');
1715
+ }
1716
+
1717
+ /** Used as references for various `Number` constants. */
1718
+ var MAX_SAFE_INTEGER = 9007199254740991;
1719
+
1720
+ /**
1721
+ * Checks if `value` is a valid array-like length.
1722
+ *
1723
+ * **Note:** This method is loosely based on
1724
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1725
+ *
1726
+ * @static
1727
+ * @memberOf _
1728
+ * @since 4.0.0
1729
+ * @category Lang
1730
+ * @param {*} value The value to check.
1731
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1732
+ * @example
1733
+ *
1734
+ * _.isLength(3);
1735
+ * // => true
1736
+ *
1737
+ * _.isLength(Number.MIN_VALUE);
1738
+ * // => false
1739
+ *
1740
+ * _.isLength(Infinity);
1741
+ * // => false
1742
+ *
1743
+ * _.isLength('3');
1744
+ * // => false
1745
+ */
1746
+ function isLength(value) {
1747
+ return typeof value == 'number' &&
1748
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1749
+ }
1750
+
1751
+ /**
1752
+ * Checks if `value` is array-like. A value is considered array-like if it's
1753
+ * not a function and has a `value.length` that's an integer greater than or
1754
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1755
+ *
1756
+ * @static
1757
+ * @memberOf _
1758
+ * @since 4.0.0
1759
+ * @category Lang
1760
+ * @param {*} value The value to check.
1761
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1762
+ * @example
1763
+ *
1764
+ * _.isArrayLike([1, 2, 3]);
1765
+ * // => true
1766
+ *
1767
+ * _.isArrayLike(document.body.children);
1768
+ * // => true
1769
+ *
1770
+ * _.isArrayLike('abc');
1771
+ * // => true
1772
+ *
1773
+ * _.isArrayLike(_.noop);
1774
+ * // => false
1775
+ */
1776
+ function isArrayLike(value) {
1777
+ return value != null && isLength(value.length) && !isFunction(value);
1778
+ }
1779
+
1780
+ /**
1781
+ * Checks if the given arguments are from an iteratee call.
1782
+ *
1783
+ * @private
1784
+ * @param {*} value The potential iteratee value argument.
1785
+ * @param {*} index The potential iteratee index or key argument.
1786
+ * @param {*} object The potential iteratee object argument.
1787
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1788
+ * else `false`.
1789
+ */
1790
+ function isIterateeCall(value, index, object) {
1791
+ if (!isObject(object)) {
1792
+ return false;
1793
+ }
1794
+ var type = typeof index;
1795
+ if (type == 'number'
1796
+ ? (isArrayLike(object) && isIndex(index, object.length))
1797
+ : (type == 'string' && index in object)
1798
+ ) {
1799
+ return eq(object[index], value);
1800
+ }
1801
+ return false;
1802
+ }
1803
+
1804
+ /**
1805
+ * Creates a function like `_.assign`.
1806
+ *
1807
+ * @private
1808
+ * @param {Function} assigner The function to assign values.
1809
+ * @returns {Function} Returns the new assigner function.
1810
+ */
1811
+ function createAssigner(assigner) {
1812
+ return baseRest(function(object, sources) {
1813
+ var index = -1,
1814
+ length = sources.length,
1815
+ customizer = length > 1 ? sources[length - 1] : undefined,
1816
+ guard = length > 2 ? sources[2] : undefined;
1817
+
1818
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
1819
+ ? (length--, customizer)
1820
+ : undefined;
1821
+
1822
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
1823
+ customizer = length < 3 ? undefined : customizer;
1824
+ length = 1;
1825
+ }
1826
+ object = Object(object);
1827
+ while (++index < length) {
1828
+ var source = sources[index];
1829
+ if (source) {
1830
+ assigner(object, source, index, customizer);
1831
+ }
1832
+ }
1833
+ return object;
1834
+ });
1835
+ }
1836
+
1837
+ /** Used for built-in method references. */
1838
+ var objectProto$5 = Object.prototype;
1839
+
1840
+ /**
1841
+ * Checks if `value` is likely a prototype object.
1842
+ *
1843
+ * @private
1844
+ * @param {*} value The value to check.
1845
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1846
+ */
1847
+ function isPrototype(value) {
1848
+ var Ctor = value && value.constructor,
1849
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
1850
+
1851
+ return value === proto;
1852
+ }
1853
+
1854
+ /**
1855
+ * The base implementation of `_.times` without support for iteratee shorthands
1856
+ * or max array length checks.
1857
+ *
1858
+ * @private
1859
+ * @param {number} n The number of times to invoke `iteratee`.
1860
+ * @param {Function} iteratee The function invoked per iteration.
1861
+ * @returns {Array} Returns the array of results.
1862
+ */
1863
+ function baseTimes(n, iteratee) {
1864
+ var index = -1,
1865
+ result = Array(n);
1866
+
1867
+ while (++index < n) {
1868
+ result[index] = iteratee(index);
1869
+ }
1870
+ return result;
1871
+ }
1872
+
1873
+ /** `Object#toString` result references. */
1874
+ var argsTag$1 = '[object Arguments]';
1875
+
1876
+ /**
1877
+ * The base implementation of `_.isArguments`.
1878
+ *
1879
+ * @private
1880
+ * @param {*} value The value to check.
1881
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1882
+ */
1883
+ function baseIsArguments(value) {
1884
+ return isObjectLike(value) && baseGetTag(value) == argsTag$1;
1885
+ }
1886
+
1887
+ /** Used for built-in method references. */
1888
+ var objectProto$4 = Object.prototype;
1889
+
1890
+ /** Used to check objects for own properties. */
1891
+ var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
1892
+
1893
+ /** Built-in value references. */
1894
+ var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
1895
+
1896
+ /**
1897
+ * Checks if `value` is likely an `arguments` object.
1898
+ *
1899
+ * @static
1900
+ * @memberOf _
1901
+ * @since 0.1.0
1902
+ * @category Lang
1903
+ * @param {*} value The value to check.
1904
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1905
+ * else `false`.
1906
+ * @example
1907
+ *
1908
+ * _.isArguments(function() { return arguments; }());
1909
+ * // => true
1910
+ *
1911
+ * _.isArguments([1, 2, 3]);
1912
+ * // => false
1913
+ */
1914
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1915
+ return isObjectLike(value) && hasOwnProperty$4.call(value, 'callee') &&
1916
+ !propertyIsEnumerable.call(value, 'callee');
1917
+ };
1918
+
1919
+ /**
1920
+ * This method returns `false`.
1921
+ *
1922
+ * @static
1923
+ * @memberOf _
1924
+ * @since 4.13.0
1925
+ * @category Util
1926
+ * @returns {boolean} Returns `false`.
1927
+ * @example
1928
+ *
1929
+ * _.times(2, _.stubFalse);
1930
+ * // => [false, false]
1931
+ */
1932
+ function stubFalse() {
1933
+ return false;
1934
+ }
1935
+
1936
+ /** Detect free variable `exports`. */
1937
+ var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1938
+
1939
+ /** Detect free variable `module`. */
1940
+ var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
1941
+
1942
+ /** Detect the popular CommonJS extension `module.exports`. */
1943
+ var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
1944
+
1945
+ /** Built-in value references. */
1946
+ var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
1947
+
1948
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1949
+ var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
1950
+
1951
+ /**
1952
+ * Checks if `value` is a buffer.
1953
+ *
1954
+ * @static
1955
+ * @memberOf _
1956
+ * @since 4.3.0
1957
+ * @category Lang
1958
+ * @param {*} value The value to check.
1959
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1960
+ * @example
1961
+ *
1962
+ * _.isBuffer(new Buffer(2));
1963
+ * // => true
1964
+ *
1965
+ * _.isBuffer(new Uint8Array(2));
1966
+ * // => false
1967
+ */
1968
+ var isBuffer = nativeIsBuffer || stubFalse;
1969
+
1970
+ /** `Object#toString` result references. */
1971
+ var argsTag = '[object Arguments]',
1972
+ arrayTag = '[object Array]',
1973
+ boolTag = '[object Boolean]',
1974
+ dateTag = '[object Date]',
1975
+ errorTag = '[object Error]',
1976
+ funcTag = '[object Function]',
1977
+ mapTag = '[object Map]',
1978
+ numberTag = '[object Number]',
1979
+ objectTag$1 = '[object Object]',
1980
+ regexpTag = '[object RegExp]',
1981
+ setTag = '[object Set]',
1982
+ stringTag = '[object String]',
1983
+ weakMapTag = '[object WeakMap]';
1984
+
1985
+ var arrayBufferTag = '[object ArrayBuffer]',
1986
+ dataViewTag = '[object DataView]',
1987
+ float32Tag = '[object Float32Array]',
1988
+ float64Tag = '[object Float64Array]',
1989
+ int8Tag = '[object Int8Array]',
1990
+ int16Tag = '[object Int16Array]',
1991
+ int32Tag = '[object Int32Array]',
1992
+ uint8Tag = '[object Uint8Array]',
1993
+ uint8ClampedTag = '[object Uint8ClampedArray]',
1994
+ uint16Tag = '[object Uint16Array]',
1995
+ uint32Tag = '[object Uint32Array]';
1996
+
1997
+ /** Used to identify `toStringTag` values of typed arrays. */
1998
+ var typedArrayTags = {};
1999
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
2000
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
2001
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
2002
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
2003
+ typedArrayTags[uint32Tag] = true;
2004
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
2005
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
2006
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
2007
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
2008
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
2009
+ typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
2010
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
2011
+ typedArrayTags[weakMapTag] = false;
2012
+
2013
+ /**
2014
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
2015
+ *
2016
+ * @private
2017
+ * @param {*} value The value to check.
2018
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2019
+ */
2020
+ function baseIsTypedArray(value) {
2021
+ return isObjectLike(value) &&
2022
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
2023
+ }
2024
+
2025
+ /**
2026
+ * The base implementation of `_.unary` without support for storing metadata.
2027
+ *
2028
+ * @private
2029
+ * @param {Function} func The function to cap arguments for.
2030
+ * @returns {Function} Returns the new capped function.
2031
+ */
2032
+ function baseUnary(func) {
2033
+ return function(value) {
2034
+ return func(value);
2035
+ };
2036
+ }
2037
+
2038
+ /** Detect free variable `exports`. */
2039
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
2040
+
2041
+ /** Detect free variable `module`. */
2042
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
2043
+
2044
+ /** Detect the popular CommonJS extension `module.exports`. */
2045
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
2046
+
2047
+ /** Detect free variable `process` from Node.js. */
2048
+ var freeProcess = moduleExports$1 && freeGlobal.process;
2049
+
2050
+ /** Used to access faster Node.js helpers. */
2051
+ var nodeUtil = (function() {
2052
+ try {
2053
+ // Use `util.types` for Node.js 10+.
2054
+ var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
2055
+
2056
+ if (types) {
2057
+ return types;
2058
+ }
2059
+
2060
+ // Legacy `process.binding('util')` for Node.js < 10.
2061
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
2062
+ } catch (e) {}
2063
+ }());
2064
+
2065
+ /* Node.js helper references. */
2066
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
2067
+
2068
+ /**
2069
+ * Checks if `value` is classified as a typed array.
2070
+ *
2071
+ * @static
2072
+ * @memberOf _
2073
+ * @since 3.0.0
2074
+ * @category Lang
2075
+ * @param {*} value The value to check.
2076
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2077
+ * @example
2078
+ *
2079
+ * _.isTypedArray(new Uint8Array);
2080
+ * // => true
2081
+ *
2082
+ * _.isTypedArray([]);
2083
+ * // => false
2084
+ */
2085
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2086
+
2087
+ /**
2088
+ * Creates an array of the enumerable property names of the array-like `value`.
2089
+ *
2090
+ * @private
2091
+ * @param {*} value The value to query.
2092
+ * @param {boolean} inherited Specify returning inherited property names.
2093
+ * @returns {Array} Returns the array of property names.
2094
+ */
2095
+ function arrayLikeKeys(value, inherited) {
2096
+ var isArr = isArray(value),
2097
+ isArg = !isArr && isArguments(value),
2098
+ isBuff = !isArr && !isArg && isBuffer(value),
2099
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2100
+ skipIndexes = isArr || isArg || isBuff || isType,
2101
+ result = skipIndexes ? baseTimes(value.length, String) : [],
2102
+ length = result.length;
2103
+
2104
+ for (var key in value) {
2105
+ if (!(skipIndexes && (
2106
+ // Safari 9 has enumerable `arguments.length` in strict mode.
2107
+ key == 'length' ||
2108
+ // Node.js 0.10 has enumerable non-index properties on buffers.
2109
+ (isBuff && (key == 'offset' || key == 'parent')) ||
2110
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
2111
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2112
+ // Skip index properties.
2113
+ isIndex(key, length)
2114
+ ))) {
2115
+ result.push(key);
2116
+ }
2117
+ }
2118
+ return result;
2119
+ }
2120
+
2121
+ /**
2122
+ * Creates a unary function that invokes `func` with its argument transformed.
2123
+ *
2124
+ * @private
2125
+ * @param {Function} func The function to wrap.
2126
+ * @param {Function} transform The argument transform.
2127
+ * @returns {Function} Returns the new function.
2128
+ */
2129
+ function overArg(func, transform) {
2130
+ return function(arg) {
2131
+ return func(transform(arg));
2132
+ };
2133
+ }
2134
+
2135
+ /**
2136
+ * This function is like
2137
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2138
+ * except that it includes inherited enumerable properties.
2139
+ *
2140
+ * @private
2141
+ * @param {Object} object The object to query.
2142
+ * @returns {Array} Returns the array of property names.
2143
+ */
2144
+ function nativeKeysIn(object) {
2145
+ var result = [];
2146
+ if (object != null) {
2147
+ for (var key in Object(object)) {
2148
+ result.push(key);
2149
+ }
2150
+ }
2151
+ return result;
2152
+ }
2153
+
2154
+ /** Used for built-in method references. */
2155
+ var objectProto$3 = Object.prototype;
2156
+
2157
+ /** Used to check objects for own properties. */
2158
+ var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
2159
+
2160
+ /**
2161
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
2162
+ *
2163
+ * @private
2164
+ * @param {Object} object The object to query.
2165
+ * @returns {Array} Returns the array of property names.
2166
+ */
2167
+ function baseKeysIn(object) {
2168
+ if (!isObject(object)) {
2169
+ return nativeKeysIn(object);
2170
+ }
2171
+ var isProto = isPrototype(object),
2172
+ result = [];
2173
+
2174
+ for (var key in object) {
2175
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
2176
+ result.push(key);
2177
+ }
2178
+ }
2179
+ return result;
2180
+ }
2181
+
2182
+ /**
2183
+ * Creates an array of the own and inherited enumerable property names of `object`.
2184
+ *
2185
+ * **Note:** Non-object values are coerced to objects.
2186
+ *
2187
+ * @static
2188
+ * @memberOf _
2189
+ * @since 3.0.0
2190
+ * @category Object
2191
+ * @param {Object} object The object to query.
2192
+ * @returns {Array} Returns the array of property names.
2193
+ * @example
2194
+ *
2195
+ * function Foo() {
2196
+ * this.a = 1;
2197
+ * this.b = 2;
2198
+ * }
2199
+ *
2200
+ * Foo.prototype.c = 3;
2201
+ *
2202
+ * _.keysIn(new Foo);
2203
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
2204
+ */
2205
+ function keysIn(object) {
2206
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeysIn(object);
2207
+ }
2208
+
2209
+ /* Built-in method references that are verified to be native. */
2210
+ var nativeCreate = getNative(Object, 'create');
2211
+
2212
+ /**
2213
+ * Removes all key-value entries from the hash.
2214
+ *
2215
+ * @private
2216
+ * @name clear
2217
+ * @memberOf Hash
2218
+ */
2219
+ function hashClear() {
2220
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
2221
+ this.size = 0;
2222
+ }
2223
+
2224
+ /**
2225
+ * Removes `key` and its value from the hash.
2226
+ *
2227
+ * @private
2228
+ * @name delete
2229
+ * @memberOf Hash
2230
+ * @param {Object} hash The hash to modify.
2231
+ * @param {string} key The key of the value to remove.
2232
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2233
+ */
2234
+ function hashDelete(key) {
2235
+ var result = this.has(key) && delete this.__data__[key];
2236
+ this.size -= result ? 1 : 0;
2237
+ return result;
2238
+ }
2239
+
2240
+ /** Used to stand-in for `undefined` hash values. */
2241
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
2242
+
2243
+ /** Used for built-in method references. */
2244
+ var objectProto$2 = Object.prototype;
2245
+
2246
+ /** Used to check objects for own properties. */
2247
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
2248
+
2249
+ /**
2250
+ * Gets the hash value for `key`.
2251
+ *
2252
+ * @private
2253
+ * @name get
2254
+ * @memberOf Hash
2255
+ * @param {string} key The key of the value to get.
2256
+ * @returns {*} Returns the entry value.
2257
+ */
2258
+ function hashGet(key) {
2259
+ var data = this.__data__;
2260
+ if (nativeCreate) {
2261
+ var result = data[key];
2262
+ return result === HASH_UNDEFINED$1 ? undefined : result;
2263
+ }
2264
+ return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
2265
+ }
2266
+
2267
+ /** Used for built-in method references. */
2268
+ var objectProto$1 = Object.prototype;
2269
+
2270
+ /** Used to check objects for own properties. */
2271
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2272
+
2273
+ /**
2274
+ * Checks if a hash value for `key` exists.
2275
+ *
2276
+ * @private
2277
+ * @name has
2278
+ * @memberOf Hash
2279
+ * @param {string} key The key of the entry to check.
2280
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2281
+ */
2282
+ function hashHas(key) {
2283
+ var data = this.__data__;
2284
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key);
2285
+ }
2286
+
2287
+ /** Used to stand-in for `undefined` hash values. */
2288
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
2289
+
2290
+ /**
2291
+ * Sets the hash `key` to `value`.
2292
+ *
2293
+ * @private
2294
+ * @name set
2295
+ * @memberOf Hash
2296
+ * @param {string} key The key of the value to set.
2297
+ * @param {*} value The value to set.
2298
+ * @returns {Object} Returns the hash instance.
2299
+ */
2300
+ function hashSet(key, value) {
2301
+ var data = this.__data__;
2302
+ this.size += this.has(key) ? 0 : 1;
2303
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2304
+ return this;
2305
+ }
2306
+
2307
+ /**
2308
+ * Creates a hash object.
2309
+ *
2310
+ * @private
2311
+ * @constructor
2312
+ * @param {Array} [entries] The key-value pairs to cache.
2313
+ */
2314
+ function Hash(entries) {
2315
+ var index = -1,
2316
+ length = entries == null ? 0 : entries.length;
2317
+
2318
+ this.clear();
2319
+ while (++index < length) {
2320
+ var entry = entries[index];
2321
+ this.set(entry[0], entry[1]);
2322
+ }
2323
+ }
2324
+
2325
+ // Add methods to `Hash`.
2326
+ Hash.prototype.clear = hashClear;
2327
+ Hash.prototype['delete'] = hashDelete;
2328
+ Hash.prototype.get = hashGet;
2329
+ Hash.prototype.has = hashHas;
2330
+ Hash.prototype.set = hashSet;
2331
+
2332
+ /**
2333
+ * Removes all key-value entries from the list cache.
2334
+ *
2335
+ * @private
2336
+ * @name clear
2337
+ * @memberOf ListCache
2338
+ */
2339
+ function listCacheClear() {
2340
+ this.__data__ = [];
2341
+ this.size = 0;
2342
+ }
2343
+
2344
+ /**
2345
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
2346
+ *
2347
+ * @private
2348
+ * @param {Array} array The array to inspect.
2349
+ * @param {*} key The key to search for.
2350
+ * @returns {number} Returns the index of the matched value, else `-1`.
2351
+ */
2352
+ function assocIndexOf(array, key) {
2353
+ var length = array.length;
2354
+ while (length--) {
2355
+ if (eq(array[length][0], key)) {
2356
+ return length;
2357
+ }
2358
+ }
2359
+ return -1;
2360
+ }
2361
+
2362
+ /** Used for built-in method references. */
2363
+ var arrayProto = Array.prototype;
2364
+
2365
+ /** Built-in value references. */
2366
+ var splice = arrayProto.splice;
2367
+
2368
+ /**
2369
+ * Removes `key` and its value from the list cache.
2370
+ *
2371
+ * @private
2372
+ * @name delete
2373
+ * @memberOf ListCache
2374
+ * @param {string} key The key of the value to remove.
2375
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2376
+ */
2377
+ function listCacheDelete(key) {
2378
+ var data = this.__data__,
2379
+ index = assocIndexOf(data, key);
2380
+
2381
+ if (index < 0) {
2382
+ return false;
2383
+ }
2384
+ var lastIndex = data.length - 1;
2385
+ if (index == lastIndex) {
2386
+ data.pop();
2387
+ } else {
2388
+ splice.call(data, index, 1);
2389
+ }
2390
+ --this.size;
2391
+ return true;
2392
+ }
2393
+
2394
+ /**
2395
+ * Gets the list cache value for `key`.
2396
+ *
2397
+ * @private
2398
+ * @name get
2399
+ * @memberOf ListCache
2400
+ * @param {string} key The key of the value to get.
2401
+ * @returns {*} Returns the entry value.
2402
+ */
2403
+ function listCacheGet(key) {
2404
+ var data = this.__data__,
2405
+ index = assocIndexOf(data, key);
2406
+
2407
+ return index < 0 ? undefined : data[index][1];
2408
+ }
2409
+
2410
+ /**
2411
+ * Checks if a list cache value for `key` exists.
2412
+ *
2413
+ * @private
2414
+ * @name has
2415
+ * @memberOf ListCache
2416
+ * @param {string} key The key of the entry to check.
2417
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2418
+ */
2419
+ function listCacheHas(key) {
2420
+ return assocIndexOf(this.__data__, key) > -1;
2421
+ }
2422
+
2423
+ /**
2424
+ * Sets the list cache `key` to `value`.
2425
+ *
2426
+ * @private
2427
+ * @name set
2428
+ * @memberOf ListCache
2429
+ * @param {string} key The key of the value to set.
2430
+ * @param {*} value The value to set.
2431
+ * @returns {Object} Returns the list cache instance.
2432
+ */
2433
+ function listCacheSet(key, value) {
2434
+ var data = this.__data__,
2435
+ index = assocIndexOf(data, key);
2436
+
2437
+ if (index < 0) {
2438
+ ++this.size;
2439
+ data.push([key, value]);
2440
+ } else {
2441
+ data[index][1] = value;
2442
+ }
2443
+ return this;
2444
+ }
2445
+
2446
+ /**
2447
+ * Creates an list cache object.
2448
+ *
2449
+ * @private
2450
+ * @constructor
2451
+ * @param {Array} [entries] The key-value pairs to cache.
2452
+ */
2453
+ function ListCache(entries) {
2454
+ var index = -1,
2455
+ length = entries == null ? 0 : entries.length;
2456
+
2457
+ this.clear();
2458
+ while (++index < length) {
2459
+ var entry = entries[index];
2460
+ this.set(entry[0], entry[1]);
2461
+ }
2462
+ }
2463
+
2464
+ // Add methods to `ListCache`.
2465
+ ListCache.prototype.clear = listCacheClear;
2466
+ ListCache.prototype['delete'] = listCacheDelete;
2467
+ ListCache.prototype.get = listCacheGet;
2468
+ ListCache.prototype.has = listCacheHas;
2469
+ ListCache.prototype.set = listCacheSet;
2470
+
2471
+ /* Built-in method references that are verified to be native. */
2472
+ var Map = getNative(root, 'Map');
2473
+
2474
+ /**
2475
+ * Removes all key-value entries from the map.
2476
+ *
2477
+ * @private
2478
+ * @name clear
2479
+ * @memberOf MapCache
2480
+ */
2481
+ function mapCacheClear() {
2482
+ this.size = 0;
2483
+ this.__data__ = {
2484
+ 'hash': new Hash,
2485
+ 'map': new (Map || ListCache),
2486
+ 'string': new Hash
2487
+ };
2488
+ }
2489
+
2490
+ /**
2491
+ * Checks if `value` is suitable for use as unique object key.
2492
+ *
2493
+ * @private
2494
+ * @param {*} value The value to check.
2495
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
2496
+ */
2497
+ function isKeyable(value) {
2498
+ var type = typeof value;
2499
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
2500
+ ? (value !== '__proto__')
2501
+ : (value === null);
2502
+ }
2503
+
2504
+ /**
2505
+ * Gets the data for `map`.
2506
+ *
2507
+ * @private
2508
+ * @param {Object} map The map to query.
2509
+ * @param {string} key The reference key.
2510
+ * @returns {*} Returns the map data.
2511
+ */
2512
+ function getMapData(map, key) {
2513
+ var data = map.__data__;
2514
+ return isKeyable(key)
2515
+ ? data[typeof key == 'string' ? 'string' : 'hash']
2516
+ : data.map;
2517
+ }
2518
+
2519
+ /**
2520
+ * Removes `key` and its value from the map.
2521
+ *
2522
+ * @private
2523
+ * @name delete
2524
+ * @memberOf MapCache
2525
+ * @param {string} key The key of the value to remove.
2526
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2527
+ */
2528
+ function mapCacheDelete(key) {
2529
+ var result = getMapData(this, key)['delete'](key);
2530
+ this.size -= result ? 1 : 0;
2531
+ return result;
2532
+ }
2533
+
2534
+ /**
2535
+ * Gets the map value for `key`.
2536
+ *
2537
+ * @private
2538
+ * @name get
2539
+ * @memberOf MapCache
2540
+ * @param {string} key The key of the value to get.
2541
+ * @returns {*} Returns the entry value.
2542
+ */
2543
+ function mapCacheGet(key) {
2544
+ return getMapData(this, key).get(key);
2545
+ }
2546
+
2547
+ /**
2548
+ * Checks if a map value for `key` exists.
2549
+ *
2550
+ * @private
2551
+ * @name has
2552
+ * @memberOf MapCache
2553
+ * @param {string} key The key of the entry to check.
2554
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2555
+ */
2556
+ function mapCacheHas(key) {
2557
+ return getMapData(this, key).has(key);
2558
+ }
2559
+
2560
+ /**
2561
+ * Sets the map `key` to `value`.
2562
+ *
2563
+ * @private
2564
+ * @name set
2565
+ * @memberOf MapCache
2566
+ * @param {string} key The key of the value to set.
2567
+ * @param {*} value The value to set.
2568
+ * @returns {Object} Returns the map cache instance.
2569
+ */
2570
+ function mapCacheSet(key, value) {
2571
+ var data = getMapData(this, key),
2572
+ size = data.size;
2573
+
2574
+ data.set(key, value);
2575
+ this.size += data.size == size ? 0 : 1;
2576
+ return this;
2577
+ }
2578
+
2579
+ /**
2580
+ * Creates a map cache object to store key-value pairs.
2581
+ *
2582
+ * @private
2583
+ * @constructor
2584
+ * @param {Array} [entries] The key-value pairs to cache.
2585
+ */
2586
+ function MapCache(entries) {
2587
+ var index = -1,
2588
+ length = entries == null ? 0 : entries.length;
2589
+
2590
+ this.clear();
2591
+ while (++index < length) {
2592
+ var entry = entries[index];
2593
+ this.set(entry[0], entry[1]);
2594
+ }
2595
+ }
2596
+
2597
+ // Add methods to `MapCache`.
2598
+ MapCache.prototype.clear = mapCacheClear;
2599
+ MapCache.prototype['delete'] = mapCacheDelete;
2600
+ MapCache.prototype.get = mapCacheGet;
2601
+ MapCache.prototype.has = mapCacheHas;
2602
+ MapCache.prototype.set = mapCacheSet;
2603
+
2604
+ /** Built-in value references. */
2605
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
2606
+
2607
+ /** `Object#toString` result references. */
2608
+ var objectTag = '[object Object]';
2609
+
2610
+ /** Used for built-in method references. */
2611
+ var funcProto = Function.prototype,
2612
+ objectProto = Object.prototype;
2613
+
2614
+ /** Used to resolve the decompiled source of functions. */
2615
+ var funcToString = funcProto.toString;
2616
+
2617
+ /** Used to check objects for own properties. */
2618
+ var hasOwnProperty = objectProto.hasOwnProperty;
2619
+
2620
+ /** Used to infer the `Object` constructor. */
2621
+ var objectCtorString = funcToString.call(Object);
2622
+
2623
+ /**
2624
+ * Checks if `value` is a plain object, that is, an object created by the
2625
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
2626
+ *
2627
+ * @static
2628
+ * @memberOf _
2629
+ * @since 0.8.0
2630
+ * @category Lang
2631
+ * @param {*} value The value to check.
2632
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2633
+ * @example
2634
+ *
2635
+ * function Foo() {
2636
+ * this.a = 1;
2637
+ * }
2638
+ *
2639
+ * _.isPlainObject(new Foo);
2640
+ * // => false
2641
+ *
2642
+ * _.isPlainObject([1, 2, 3]);
2643
+ * // => false
2644
+ *
2645
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
2646
+ * // => true
2647
+ *
2648
+ * _.isPlainObject(Object.create(null));
2649
+ * // => true
2650
+ */
2651
+ function isPlainObject(value) {
2652
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
2653
+ return false;
2654
+ }
2655
+ var proto = getPrototype(value);
2656
+ if (proto === null) {
2657
+ return true;
2658
+ }
2659
+ var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
2660
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
2661
+ funcToString.call(Ctor) == objectCtorString;
2662
+ }
2663
+
2664
+ /**
2665
+ * Removes all key-value entries from the stack.
2666
+ *
2667
+ * @private
2668
+ * @name clear
2669
+ * @memberOf Stack
2670
+ */
2671
+ function stackClear() {
2672
+ this.__data__ = new ListCache;
2673
+ this.size = 0;
2674
+ }
2675
+
2676
+ /**
2677
+ * Removes `key` and its value from the stack.
2678
+ *
2679
+ * @private
2680
+ * @name delete
2681
+ * @memberOf Stack
2682
+ * @param {string} key The key of the value to remove.
2683
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2684
+ */
2685
+ function stackDelete(key) {
2686
+ var data = this.__data__,
2687
+ result = data['delete'](key);
2688
+
2689
+ this.size = data.size;
2690
+ return result;
2691
+ }
2692
+
2693
+ /**
2694
+ * Gets the stack value for `key`.
2695
+ *
2696
+ * @private
2697
+ * @name get
2698
+ * @memberOf Stack
2699
+ * @param {string} key The key of the value to get.
2700
+ * @returns {*} Returns the entry value.
2701
+ */
2702
+ function stackGet(key) {
2703
+ return this.__data__.get(key);
2704
+ }
2705
+
2706
+ /**
2707
+ * Checks if a stack value for `key` exists.
2708
+ *
2709
+ * @private
2710
+ * @name has
2711
+ * @memberOf Stack
2712
+ * @param {string} key The key of the entry to check.
2713
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2714
+ */
2715
+ function stackHas(key) {
2716
+ return this.__data__.has(key);
2717
+ }
2718
+
2719
+ /** Used as the size to enable large array optimizations. */
2720
+ var LARGE_ARRAY_SIZE = 200;
2721
+
2722
+ /**
2723
+ * Sets the stack `key` to `value`.
2724
+ *
2725
+ * @private
2726
+ * @name set
2727
+ * @memberOf Stack
2728
+ * @param {string} key The key of the value to set.
2729
+ * @param {*} value The value to set.
2730
+ * @returns {Object} Returns the stack cache instance.
2731
+ */
2732
+ function stackSet(key, value) {
2733
+ var data = this.__data__;
2734
+ if (data instanceof ListCache) {
2735
+ var pairs = data.__data__;
2736
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2737
+ pairs.push([key, value]);
2738
+ this.size = ++data.size;
2739
+ return this;
2740
+ }
2741
+ data = this.__data__ = new MapCache(pairs);
2742
+ }
2743
+ data.set(key, value);
2744
+ this.size = data.size;
2745
+ return this;
2746
+ }
2747
+
2748
+ /**
2749
+ * Creates a stack cache object to store key-value pairs.
2750
+ *
2751
+ * @private
2752
+ * @constructor
2753
+ * @param {Array} [entries] The key-value pairs to cache.
2754
+ */
2755
+ function Stack(entries) {
2756
+ var data = this.__data__ = new ListCache(entries);
2757
+ this.size = data.size;
2758
+ }
2759
+
2760
+ // Add methods to `Stack`.
2761
+ Stack.prototype.clear = stackClear;
2762
+ Stack.prototype['delete'] = stackDelete;
2763
+ Stack.prototype.get = stackGet;
2764
+ Stack.prototype.has = stackHas;
2765
+ Stack.prototype.set = stackSet;
2766
+
2767
+ /** Detect free variable `exports`. */
2768
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
2769
+
2770
+ /** Detect free variable `module`. */
2771
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
2772
+
2773
+ /** Detect the popular CommonJS extension `module.exports`. */
2774
+ var moduleExports = freeModule && freeModule.exports === freeExports;
2775
+
2776
+ /** Built-in value references. */
2777
+ var Buffer = moduleExports ? root.Buffer : undefined;
2778
+ Buffer ? Buffer.allocUnsafe : undefined;
2779
+
2780
+ /**
2781
+ * Creates a clone of `buffer`.
2782
+ *
2783
+ * @private
2784
+ * @param {Buffer} buffer The buffer to clone.
2785
+ * @param {boolean} [isDeep] Specify a deep clone.
2786
+ * @returns {Buffer} Returns the cloned buffer.
2787
+ */
2788
+ function cloneBuffer(buffer, isDeep) {
2789
+ {
2790
+ return buffer.slice();
2791
+ }
2792
+ }
2793
+
2794
+ /** Built-in value references. */
2795
+ var Uint8Array = root.Uint8Array;
2796
+
2797
+ /**
2798
+ * Creates a clone of `arrayBuffer`.
2799
+ *
2800
+ * @private
2801
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2802
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
2803
+ */
2804
+ function cloneArrayBuffer(arrayBuffer) {
2805
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2806
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2807
+ return result;
2808
+ }
2809
+
2810
+ /**
2811
+ * Creates a clone of `typedArray`.
2812
+ *
2813
+ * @private
2814
+ * @param {Object} typedArray The typed array to clone.
2815
+ * @param {boolean} [isDeep] Specify a deep clone.
2816
+ * @returns {Object} Returns the cloned typed array.
2817
+ */
2818
+ function cloneTypedArray(typedArray, isDeep) {
2819
+ var buffer = cloneArrayBuffer(typedArray.buffer) ;
2820
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2821
+ }
2822
+
2823
+ /**
2824
+ * Initializes an object clone.
2825
+ *
2826
+ * @private
2827
+ * @param {Object} object The object to clone.
2828
+ * @returns {Object} Returns the initialized clone.
2829
+ */
2830
+ function initCloneObject(object) {
2831
+ return (typeof object.constructor == 'function' && !isPrototype(object))
2832
+ ? baseCreate(getPrototype(object))
2833
+ : {};
2834
+ }
2835
+
2836
+ /**
2837
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
2838
+ *
2839
+ * @private
2840
+ * @param {boolean} [fromRight] Specify iterating from right to left.
2841
+ * @returns {Function} Returns the new base function.
2842
+ */
2843
+ function createBaseFor(fromRight) {
2844
+ return function(object, iteratee, keysFunc) {
2845
+ var index = -1,
2846
+ iterable = Object(object),
2847
+ props = keysFunc(object),
2848
+ length = props.length;
2849
+
2850
+ while (length--) {
2851
+ var key = props[++index];
2852
+ if (iteratee(iterable[key], key, iterable) === false) {
2853
+ break;
2854
+ }
2855
+ }
2856
+ return object;
2857
+ };
2858
+ }
2859
+
2860
+ /**
2861
+ * The base implementation of `baseForOwn` which iterates over `object`
2862
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
2863
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
2864
+ *
2865
+ * @private
2866
+ * @param {Object} object The object to iterate over.
2867
+ * @param {Function} iteratee The function invoked per iteration.
2868
+ * @param {Function} keysFunc The function to get the keys of `object`.
2869
+ * @returns {Object} Returns `object`.
2870
+ */
2871
+ var baseFor = createBaseFor();
2872
+
2873
+ /**
2874
+ * This function is like `assignValue` except that it doesn't assign
2875
+ * `undefined` values.
2876
+ *
2877
+ * @private
2878
+ * @param {Object} object The object to modify.
2879
+ * @param {string} key The key of the property to assign.
2880
+ * @param {*} value The value to assign.
2881
+ */
2882
+ function assignMergeValue(object, key, value) {
2883
+ if ((value !== undefined && !eq(object[key], value)) ||
2884
+ (value === undefined && !(key in object))) {
2885
+ baseAssignValue(object, key, value);
2886
+ }
2887
+ }
2888
+
2889
+ /**
2890
+ * This method is like `_.isArrayLike` except that it also checks if `value`
2891
+ * is an object.
2892
+ *
2893
+ * @static
2894
+ * @memberOf _
2895
+ * @since 4.0.0
2896
+ * @category Lang
2897
+ * @param {*} value The value to check.
2898
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
2899
+ * else `false`.
2900
+ * @example
2901
+ *
2902
+ * _.isArrayLikeObject([1, 2, 3]);
2903
+ * // => true
2904
+ *
2905
+ * _.isArrayLikeObject(document.body.children);
2906
+ * // => true
2907
+ *
2908
+ * _.isArrayLikeObject('abc');
2909
+ * // => false
2910
+ *
2911
+ * _.isArrayLikeObject(_.noop);
2912
+ * // => false
2913
+ */
2914
+ function isArrayLikeObject(value) {
2915
+ return isObjectLike(value) && isArrayLike(value);
2916
+ }
2917
+
2918
+ /**
2919
+ * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
2920
+ *
2921
+ * @private
2922
+ * @param {Object} object The object to query.
2923
+ * @param {string} key The key of the property to get.
2924
+ * @returns {*} Returns the property value.
2925
+ */
2926
+ function safeGet(object, key) {
2927
+ if (key === 'constructor' && typeof object[key] === 'function') {
2928
+ return;
2929
+ }
2930
+
2931
+ if (key == '__proto__') {
2932
+ return;
2933
+ }
2934
+
2935
+ return object[key];
2936
+ }
2937
+
2938
+ /**
2939
+ * Converts `value` to a plain object flattening inherited enumerable string
2940
+ * keyed properties of `value` to own properties of the plain object.
2941
+ *
2942
+ * @static
2943
+ * @memberOf _
2944
+ * @since 3.0.0
2945
+ * @category Lang
2946
+ * @param {*} value The value to convert.
2947
+ * @returns {Object} Returns the converted plain object.
2948
+ * @example
2949
+ *
2950
+ * function Foo() {
2951
+ * this.b = 2;
2952
+ * }
2953
+ *
2954
+ * Foo.prototype.c = 3;
2955
+ *
2956
+ * _.assign({ 'a': 1 }, new Foo);
2957
+ * // => { 'a': 1, 'b': 2 }
2958
+ *
2959
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
2960
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
2961
+ */
2962
+ function toPlainObject(value) {
2963
+ return copyObject(value, keysIn(value));
2964
+ }
2965
+
2966
+ /**
2967
+ * A specialized version of `baseMerge` for arrays and objects which performs
2968
+ * deep merges and tracks traversed objects enabling objects with circular
2969
+ * references to be merged.
2970
+ *
2971
+ * @private
2972
+ * @param {Object} object The destination object.
2973
+ * @param {Object} source The source object.
2974
+ * @param {string} key The key of the value to merge.
2975
+ * @param {number} srcIndex The index of `source`.
2976
+ * @param {Function} mergeFunc The function to merge values.
2977
+ * @param {Function} [customizer] The function to customize assigned values.
2978
+ * @param {Object} [stack] Tracks traversed source values and their merged
2979
+ * counterparts.
2980
+ */
2981
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
2982
+ var objValue = safeGet(object, key),
2983
+ srcValue = safeGet(source, key),
2984
+ stacked = stack.get(srcValue);
2985
+
2986
+ if (stacked) {
2987
+ assignMergeValue(object, key, stacked);
2988
+ return;
2989
+ }
2990
+ var newValue = customizer
2991
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
2992
+ : undefined;
2993
+
2994
+ var isCommon = newValue === undefined;
2995
+
2996
+ if (isCommon) {
2997
+ var isArr = isArray(srcValue),
2998
+ isBuff = !isArr && isBuffer(srcValue),
2999
+ isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3000
+
3001
+ newValue = srcValue;
3002
+ if (isArr || isBuff || isTyped) {
3003
+ if (isArray(objValue)) {
3004
+ newValue = objValue;
3005
+ }
3006
+ else if (isArrayLikeObject(objValue)) {
3007
+ newValue = copyArray(objValue);
3008
+ }
3009
+ else if (isBuff) {
3010
+ isCommon = false;
3011
+ newValue = cloneBuffer(srcValue);
3012
+ }
3013
+ else if (isTyped) {
3014
+ isCommon = false;
3015
+ newValue = cloneTypedArray(srcValue);
3016
+ }
3017
+ else {
3018
+ newValue = [];
3019
+ }
3020
+ }
3021
+ else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3022
+ newValue = objValue;
3023
+ if (isArguments(objValue)) {
3024
+ newValue = toPlainObject(objValue);
3025
+ }
3026
+ else if (!isObject(objValue) || isFunction(objValue)) {
3027
+ newValue = initCloneObject(srcValue);
3028
+ }
3029
+ }
3030
+ else {
3031
+ isCommon = false;
3032
+ }
3033
+ }
3034
+ if (isCommon) {
3035
+ // Recursively merge objects and arrays (susceptible to call stack limits).
3036
+ stack.set(srcValue, newValue);
3037
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3038
+ stack['delete'](srcValue);
3039
+ }
3040
+ assignMergeValue(object, key, newValue);
3041
+ }
3042
+
3043
+ /**
3044
+ * The base implementation of `_.merge` without support for multiple sources.
3045
+ *
3046
+ * @private
3047
+ * @param {Object} object The destination object.
3048
+ * @param {Object} source The source object.
3049
+ * @param {number} srcIndex The index of `source`.
3050
+ * @param {Function} [customizer] The function to customize merged values.
3051
+ * @param {Object} [stack] Tracks traversed source values and their merged
3052
+ * counterparts.
3053
+ */
3054
+ function baseMerge(object, source, srcIndex, customizer, stack) {
3055
+ if (object === source) {
3056
+ return;
3057
+ }
3058
+ baseFor(source, function(srcValue, key) {
3059
+ stack || (stack = new Stack);
3060
+ if (isObject(srcValue)) {
3061
+ baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3062
+ }
3063
+ else {
3064
+ var newValue = customizer
3065
+ ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3066
+ : undefined;
3067
+
3068
+ if (newValue === undefined) {
3069
+ newValue = srcValue;
3070
+ }
3071
+ assignMergeValue(object, key, newValue);
3072
+ }
3073
+ }, keysIn);
3074
+ }
3075
+
3076
+ /**
3077
+ * This method is like `_.assign` except that it recursively merges own and
3078
+ * inherited enumerable string keyed properties of source objects into the
3079
+ * destination object. Source properties that resolve to `undefined` are
3080
+ * skipped if a destination value exists. Array and plain object properties
3081
+ * are merged recursively. Other objects and value types are overridden by
3082
+ * assignment. Source objects are applied from left to right. Subsequent
3083
+ * sources overwrite property assignments of previous sources.
3084
+ *
3085
+ * **Note:** This method mutates `object`.
3086
+ *
3087
+ * @static
3088
+ * @memberOf _
3089
+ * @since 0.5.0
3090
+ * @category Object
3091
+ * @param {Object} object The destination object.
3092
+ * @param {...Object} [sources] The source objects.
3093
+ * @returns {Object} Returns `object`.
3094
+ * @example
3095
+ *
3096
+ * var object = {
3097
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
3098
+ * };
3099
+ *
3100
+ * var other = {
3101
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
3102
+ * };
3103
+ *
3104
+ * _.merge(object, other);
3105
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
3106
+ */
3107
+ var merge = createAssigner(function(object, source, srcIndex) {
3108
+ baseMerge(object, source, srcIndex);
3109
+ });
3110
+
3111
+ const cssrAnchorMetaName = 'naive-ui-style';
3112
+
3113
+ function useRtl(mountId, rtlStateRef, clsPrefixRef) {
3114
+ if (!rtlStateRef) return undefined;
3115
+ const ssrAdapter = useSsrAdapter();
3116
+ const componentRtlStateRef = computed(() => {
3117
+ const {
3118
+ value: rtlState
3119
+ } = rtlStateRef;
3120
+ if (!rtlState) {
3121
+ return undefined;
3122
+ }
3123
+ const componentRtlState = rtlState[mountId];
3124
+ if (!componentRtlState) {
3125
+ return undefined;
3126
+ }
3127
+ return componentRtlState;
3128
+ });
3129
+ const NConfigProvider = inject(configProviderInjectionKey, null);
3130
+ const mountStyle = () => {
3131
+ watchEffect(() => {
3132
+ const {
3133
+ value: clsPrefix
3134
+ } = clsPrefixRef;
3135
+ const id = `${clsPrefix}${mountId}Rtl`;
3136
+ // if it already exists, we only need to watch clsPrefix, although in most
3137
+ // of time it's unnecessary... However we can at least listen less
3138
+ // handlers, which is great.
3139
+ if (exists(id, ssrAdapter)) return;
3140
+ const {
3141
+ value: componentRtlState
3142
+ } = componentRtlStateRef;
3143
+ if (!componentRtlState) return;
3144
+ componentRtlState.style.mount({
3145
+ id,
3146
+ head: true,
3147
+ anchorMetaName: cssrAnchorMetaName,
3148
+ props: {
3149
+ bPrefix: clsPrefix ? `.${clsPrefix}-` : undefined
3150
+ },
3151
+ ssr: ssrAdapter,
3152
+ parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
3153
+ });
3154
+ });
3155
+ };
3156
+ if (ssrAdapter) {
3157
+ mountStyle();
3158
+ } else {
3159
+ onBeforeMount(mountStyle);
3160
+ }
3161
+ return componentRtlStateRef;
3162
+ }
3163
+
3164
+ var commonVariables$1 = {
3165
+ fontFamily: 'v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
3166
+ fontFamilyMono: 'v-mono, SFMono-Regular, Menlo, Consolas, Courier, monospace',
3167
+ fontWeight: '400',
3168
+ fontWeightStrong: '500',
3169
+ cubicBezierEaseInOut: 'cubic-bezier(.4, 0, .2, 1)',
3170
+ cubicBezierEaseOut: 'cubic-bezier(0, 0, .2, 1)',
3171
+ cubicBezierEaseIn: 'cubic-bezier(.4, 0, 1, 1)',
3172
+ borderRadius: '3px',
3173
+ borderRadiusSmall: '2px',
3174
+ fontSize: '14px',
3175
+ fontSizeMini: '12px',
3176
+ fontSizeTiny: '12px',
3177
+ fontSizeSmall: '14px',
3178
+ fontSizeMedium: '14px',
3179
+ fontSizeLarge: '15px',
3180
+ fontSizeHuge: '16px',
3181
+ lineHeight: '1.6',
3182
+ heightMini: '16px',
3183
+ // private now, it's too small
3184
+ heightTiny: '22px',
3185
+ heightSmall: '28px',
3186
+ heightMedium: '34px',
3187
+ heightLarge: '40px',
3188
+ heightHuge: '46px'
3189
+ };
3190
+
3191
+ const {
3192
+ fontSize,
3193
+ fontFamily,
3194
+ lineHeight
3195
+ } = commonVariables$1;
3196
+ // All the components need the style
3197
+ // It is static and won't be changed in the app's lifetime
3198
+ // If user want to overrides it they need to use `n-global-style` is provided
3199
+ //
3200
+ // Technically we can remove font-size & font-family & line-height to make
3201
+ // it pure. However the coding cost doesn't worth it.
3202
+ //
3203
+ // -webkit-tap-hilight-color:
3204
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color
3205
+ // In some android devices, there will be the style.
3206
+ var globalStyle = c('body', `
3207
+ margin: 0;
3208
+ font-size: ${fontSize};
3209
+ font-family: ${fontFamily};
3210
+ line-height: ${lineHeight};
3211
+ -webkit-text-size-adjust: 100%;
3212
+ -webkit-tap-highlight-color: transparent;
3213
+ `, [c('input', `
3214
+ font-family: inherit;
3215
+ font-size: inherit;
3216
+ `)]);
3217
+
3218
+ function useTheme(resolveId, mountId, style, defaultTheme, props, clsPrefixRef) {
3219
+ const ssrAdapter = useSsrAdapter();
3220
+ const NConfigProvider = inject(configProviderInjectionKey, null);
3221
+ if (style) {
3222
+ const mountStyle = () => {
3223
+ const clsPrefix = clsPrefixRef === null || clsPrefixRef === void 0 ? void 0 : clsPrefixRef.value;
3224
+ style.mount({
3225
+ id: clsPrefix === undefined ? mountId : clsPrefix + mountId,
3226
+ head: true,
3227
+ props: {
3228
+ bPrefix: clsPrefix ? `.${clsPrefix}-` : undefined
3229
+ },
3230
+ anchorMetaName: cssrAnchorMetaName,
3231
+ ssr: ssrAdapter,
3232
+ parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
3233
+ });
3234
+ if (!(NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled)) {
3235
+ globalStyle.mount({
3236
+ id: 'n-global',
3237
+ head: true,
3238
+ anchorMetaName: cssrAnchorMetaName,
3239
+ ssr: ssrAdapter,
3240
+ parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
3241
+ });
3242
+ }
3243
+ };
3244
+ if (ssrAdapter) {
3245
+ mountStyle();
3246
+ } else {
3247
+ onBeforeMount(mountStyle);
3248
+ }
3249
+ }
3250
+ const mergedThemeRef = computed(() => {
3251
+ var _a;
3252
+ // keep props to make theme overrideable
3253
+ const {
3254
+ theme: {
3255
+ common: selfCommon,
3256
+ self,
3257
+ peers = {}
3258
+ } = {},
3259
+ themeOverrides: selfOverrides = {},
3260
+ builtinThemeOverrides: builtinOverrides = {}
3261
+ } = props;
3262
+ const {
3263
+ common: selfCommonOverrides,
3264
+ peers: peersOverrides
3265
+ } = selfOverrides;
3266
+ const {
3267
+ common: globalCommon = undefined,
3268
+ [resolveId]: {
3269
+ common: globalSelfCommon = undefined,
3270
+ self: globalSelf = undefined,
3271
+ peers: globalPeers = {}
3272
+ } = {}
3273
+ } = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeRef.value) || {};
3274
+ const {
3275
+ common: globalCommonOverrides = undefined,
3276
+ [resolveId]: globalSelfOverrides = {}
3277
+ } = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeOverridesRef.value) || {};
3278
+ const {
3279
+ common: globalSelfCommonOverrides,
3280
+ peers: globalPeersOverrides = {}
3281
+ } = globalSelfOverrides;
3282
+ const mergedCommon = merge({}, selfCommon || globalSelfCommon || globalCommon || defaultTheme.common, globalCommonOverrides, globalSelfCommonOverrides, selfCommonOverrides);
3283
+ const mergedSelf = merge(
3284
+ // {}, executed every time, no need for empty obj
3285
+ (_a = self || globalSelf || defaultTheme.self) === null || _a === void 0 ? void 0 : _a(mergedCommon), builtinOverrides, globalSelfOverrides, selfOverrides);
3286
+ return {
3287
+ common: mergedCommon,
3288
+ self: mergedSelf,
3289
+ peers: merge({}, defaultTheme.peers, globalPeers, peers),
3290
+ peerOverrides: merge({}, builtinOverrides.peers, globalPeersOverrides, peersOverrides)
3291
+ };
3292
+ });
3293
+ return mergedThemeRef;
3294
+ }
3295
+ useTheme.props = {
3296
+ theme: Object,
3297
+ themeOverrides: Object,
3298
+ builtinThemeOverrides: Object
3299
+ };
3300
+
3301
+ const base = {
3302
+ neutralBase: '#FFF',
3303
+ neutralInvertBase: '#000',
3304
+ neutralTextBase: '#000',
3305
+ neutralPopover: '#fff',
3306
+ neutralCard: '#fff',
3307
+ neutralModal: '#fff',
3308
+ neutralBody: '#fff',
3309
+ alpha1: '0.82',
3310
+ alpha2: '0.72',
3311
+ alpha3: '0.38',
3312
+ alpha4: '0.24',
3313
+ // disabled text, placeholder, icon
3314
+ alpha5: '0.18',
3315
+ // disabled placeholder
3316
+ alphaClose: '0.6',
3317
+ alphaDisabled: '0.5',
3318
+ alphaDisabledInput: '0.02',
3319
+ alphaPending: '0.05',
3320
+ alphaTablePending: '0.02',
3321
+ alphaPressed: '0.07',
3322
+ alphaAvatar: '0.2',
3323
+ alphaRail: '0.14',
3324
+ alphaProgressRail: '.08',
3325
+ alphaBorder: '0.12',
3326
+ alphaDivider: '0.06',
3327
+ alphaInput: '0',
3328
+ alphaAction: '0.02',
3329
+ alphaTab: '0.04',
3330
+ alphaScrollbar: '0.25',
3331
+ alphaScrollbarHover: '0.4',
3332
+ alphaCode: '0.05',
3333
+ alphaTag: '0.02',
3334
+ // primary
3335
+ primaryHover: '#36ad6a',
3336
+ primaryDefault: '#18a058',
3337
+ primaryActive: '#0c7a43',
3338
+ primarySuppl: '#36ad6a',
3339
+ // info
3340
+ infoHover: '#4098fc',
3341
+ infoDefault: '#2080f0',
3342
+ infoActive: '#1060c9',
3343
+ infoSuppl: '#4098fc',
3344
+ // error
3345
+ errorHover: '#de576d',
3346
+ errorDefault: '#d03050',
3347
+ errorActive: '#ab1f3f',
3348
+ errorSuppl: '#de576d',
3349
+ // warning
3350
+ warningHover: '#fcb040',
3351
+ warningDefault: '#f0a020',
3352
+ warningActive: '#c97c10',
3353
+ warningSuppl: '#fcb040',
3354
+ // success
3355
+ successHover: '#36ad6a',
3356
+ successDefault: '#18a058',
3357
+ successActive: '#0c7a43',
3358
+ successSuppl: '#36ad6a'
3359
+ };
3360
+ const baseBackgroundRgb = rgba(base.neutralBase);
3361
+ const baseInvertBackgroundRgb = rgba(base.neutralInvertBase);
3362
+ const overlayPrefix = `rgba(${baseInvertBackgroundRgb.slice(0, 3).join(', ')}, `;
3363
+ function overlay(alpha) {
3364
+ return `${overlayPrefix + String(alpha)})`;
3365
+ }
3366
+ function neutral(alpha) {
3367
+ const overlayRgba = Array.from(baseInvertBackgroundRgb);
3368
+ overlayRgba[3] = Number(alpha);
3369
+ return composite(baseBackgroundRgb, overlayRgba);
3370
+ }
3371
+ const derived = Object.assign(Object.assign({
3372
+ name: 'common'
3373
+ }, commonVariables$1), {
3374
+ baseColor: base.neutralBase,
3375
+ // primary color
3376
+ primaryColor: base.primaryDefault,
3377
+ primaryColorHover: base.primaryHover,
3378
+ primaryColorPressed: base.primaryActive,
3379
+ primaryColorSuppl: base.primarySuppl,
3380
+ // info color
3381
+ infoColor: base.infoDefault,
3382
+ infoColorHover: base.infoHover,
3383
+ infoColorPressed: base.infoActive,
3384
+ infoColorSuppl: base.infoSuppl,
3385
+ // success color
3386
+ successColor: base.successDefault,
3387
+ successColorHover: base.successHover,
3388
+ successColorPressed: base.successActive,
3389
+ successColorSuppl: base.successSuppl,
3390
+ // warning color
3391
+ warningColor: base.warningDefault,
3392
+ warningColorHover: base.warningHover,
3393
+ warningColorPressed: base.warningActive,
3394
+ warningColorSuppl: base.warningSuppl,
3395
+ // error color
3396
+ errorColor: base.errorDefault,
3397
+ errorColorHover: base.errorHover,
3398
+ errorColorPressed: base.errorActive,
3399
+ errorColorSuppl: base.errorSuppl,
3400
+ // text color
3401
+ textColorBase: base.neutralTextBase,
3402
+ textColor1: 'rgb(31, 34, 37)',
3403
+ textColor2: 'rgb(51, 54, 57)',
3404
+ textColor3: 'rgb(118, 124, 130)',
3405
+ // textColor4: neutral(base.alpha4), // disabled, placeholder, icon
3406
+ // textColor5: neutral(base.alpha5),
3407
+ textColorDisabled: neutral(base.alpha4),
3408
+ placeholderColor: neutral(base.alpha4),
3409
+ placeholderColorDisabled: neutral(base.alpha5),
3410
+ iconColor: neutral(base.alpha4),
3411
+ iconColorHover: scaleColor(neutral(base.alpha4), {
3412
+ lightness: 0.75
3413
+ }),
3414
+ iconColorPressed: scaleColor(neutral(base.alpha4), {
3415
+ lightness: 0.9
3416
+ }),
3417
+ iconColorDisabled: neutral(base.alpha5),
3418
+ opacity1: base.alpha1,
3419
+ opacity2: base.alpha2,
3420
+ opacity3: base.alpha3,
3421
+ opacity4: base.alpha4,
3422
+ opacity5: base.alpha5,
3423
+ dividerColor: 'rgb(239, 239, 245)',
3424
+ borderColor: 'rgb(224, 224, 230)',
3425
+ // close
3426
+ closeIconColor: neutral(Number(base.alphaClose)),
3427
+ closeIconColorHover: neutral(Number(base.alphaClose)),
3428
+ closeIconColorPressed: neutral(Number(base.alphaClose)),
3429
+ closeColorHover: 'rgba(0, 0, 0, .09)',
3430
+ closeColorPressed: 'rgba(0, 0, 0, .13)',
3431
+ // clear
3432
+ clearColor: neutral(base.alpha4),
3433
+ clearColorHover: scaleColor(neutral(base.alpha4), {
3434
+ lightness: 0.75
3435
+ }),
3436
+ clearColorPressed: scaleColor(neutral(base.alpha4), {
3437
+ lightness: 0.9
3438
+ }),
3439
+ scrollbarColor: overlay(base.alphaScrollbar),
3440
+ scrollbarColorHover: overlay(base.alphaScrollbarHover),
3441
+ scrollbarWidth: '5px',
3442
+ scrollbarHeight: '5px',
3443
+ scrollbarBorderRadius: '5px',
3444
+ progressRailColor: neutral(base.alphaProgressRail),
3445
+ railColor: 'rgb(219, 219, 223)',
3446
+ popoverColor: base.neutralPopover,
3447
+ tableColor: base.neutralCard,
3448
+ cardColor: base.neutralCard,
3449
+ modalColor: base.neutralModal,
3450
+ bodyColor: base.neutralBody,
3451
+ tagColor: '#eee',
3452
+ avatarColor: neutral(base.alphaAvatar),
3453
+ invertedColor: 'rgb(0, 20, 40)',
3454
+ inputColor: neutral(base.alphaInput),
3455
+ codeColor: 'rgb(244, 244, 248)',
3456
+ tabColor: 'rgb(247, 247, 250)',
3457
+ actionColor: 'rgb(250, 250, 252)',
3458
+ tableHeaderColor: 'rgb(250, 250, 252)',
3459
+ hoverColor: 'rgb(243, 243, 245)',
3460
+ // use color with alpha since it can be nested with header filter & sorter effect
3461
+ tableColorHover: 'rgba(0, 0, 100, 0.03)',
3462
+ tableColorStriped: 'rgba(0, 0, 100, 0.02)',
3463
+ pressedColor: 'rgb(237, 237, 239)',
3464
+ opacityDisabled: base.alphaDisabled,
3465
+ inputColorDisabled: 'rgb(250, 250, 252)',
3466
+ // secondary button color
3467
+ // can also be used in tertiary button & quaternary button
3468
+ buttonColor2: 'rgba(46, 51, 56, .05)',
3469
+ buttonColor2Hover: 'rgba(46, 51, 56, .09)',
3470
+ buttonColor2Pressed: 'rgba(46, 51, 56, .13)',
3471
+ boxShadow1: '0 1px 2px -2px rgba(0, 0, 0, .08), 0 3px 6px 0 rgba(0, 0, 0, .06), 0 5px 12px 4px rgba(0, 0, 0, .04)',
3472
+ boxShadow2: '0 3px 6px -4px rgba(0, 0, 0, .12), 0 6px 16px 0 rgba(0, 0, 0, .08), 0 9px 28px 8px rgba(0, 0, 0, .05)',
3473
+ boxShadow3: '0 6px 16px -9px rgba(0, 0, 0, .08), 0 9px 28px 0 rgba(0, 0, 0, .05), 0 12px 48px 16px rgba(0, 0, 0, .03)'
3474
+ });
3475
+
3476
+ var commonVariables = {
3477
+ radioSizeSmall: '14px',
3478
+ radioSizeMedium: '16px',
3479
+ radioSizeLarge: '18px',
3480
+ labelPadding: '0 8px',
3481
+ labelFontWeight: '400'
3482
+ };
3483
+
3484
+ function self$1(vars) {
3485
+ const {
3486
+ borderColor,
3487
+ primaryColor,
3488
+ baseColor,
3489
+ textColorDisabled,
3490
+ inputColorDisabled,
3491
+ textColor2,
3492
+ opacityDisabled,
3493
+ borderRadius,
3494
+ fontSizeSmall,
3495
+ fontSizeMedium,
3496
+ fontSizeLarge,
3497
+ heightSmall,
3498
+ heightMedium,
3499
+ heightLarge,
3500
+ lineHeight
3501
+ } = vars;
3502
+ return Object.assign(Object.assign({}, commonVariables), {
3503
+ labelLineHeight: lineHeight,
3504
+ buttonHeightSmall: heightSmall,
3505
+ buttonHeightMedium: heightMedium,
3506
+ buttonHeightLarge: heightLarge,
3507
+ fontSizeSmall,
3508
+ fontSizeMedium,
3509
+ fontSizeLarge,
3510
+ boxShadow: `inset 0 0 0 1px ${borderColor}`,
3511
+ boxShadowActive: `inset 0 0 0 1px ${primaryColor}`,
3512
+ boxShadowFocus: `inset 0 0 0 1px ${primaryColor}, 0 0 0 2px ${changeColor(primaryColor, {
3513
+ alpha: 0.2
3514
+ })}`,
3515
+ boxShadowHover: `inset 0 0 0 1px ${primaryColor}`,
3516
+ boxShadowDisabled: `inset 0 0 0 1px ${borderColor}`,
3517
+ color: baseColor,
3518
+ colorDisabled: inputColorDisabled,
3519
+ colorActive: '#0000',
3520
+ textColor: textColor2,
3521
+ textColorDisabled,
3522
+ dotColorActive: primaryColor,
3523
+ dotColorDisabled: borderColor,
3524
+ buttonBorderColor: borderColor,
3525
+ buttonBorderColorActive: primaryColor,
3526
+ buttonBorderColorHover: borderColor,
3527
+ buttonColor: baseColor,
3528
+ buttonColorActive: baseColor,
3529
+ buttonTextColor: textColor2,
3530
+ buttonTextColorActive: primaryColor,
3531
+ buttonTextColorHover: primaryColor,
3532
+ opacityDisabled,
3533
+ buttonBoxShadowFocus: `inset 0 0 0 1px ${primaryColor}, 0 0 0 2px ${changeColor(primaryColor, {
3534
+ alpha: 0.3
3535
+ })}`,
3536
+ buttonBoxShadowHover: 'inset 0 0 0 1px #0000',
3537
+ buttonBoxShadow: 'inset 0 0 0 1px #0000',
3538
+ buttonBorderRadius: borderRadius
3539
+ });
3540
+ }
3541
+ const radioLight = {
3542
+ name: 'Radio',
3543
+ common: derived,
3544
+ self: self$1
3545
+ };
3546
+
3547
+ // vars:
3548
+ // --n-bezier
3549
+ // --n-box-shadow
3550
+ // --n-box-shadow-active
3551
+ // --n-box-shadow-disabled
3552
+ // --n-box-shadow-focus
3553
+ // --n-box-shadow-hover
3554
+ // --n-color
3555
+ // --n-color-disabled
3556
+ // --n-dot-color-active
3557
+ // --n-dot-color-disabled
3558
+ // --n-font-size
3559
+ // --n-radio-size
3560
+ // --n-text-color
3561
+ // --n-text-color-disabled
3562
+ // --n-label-padding
3563
+ // --n-label-line-height
3564
+ // --n-color-active
3565
+ var style = cB('radio', `
3566
+ line-height: var(--n-label-line-height);
3567
+ outline: none;
3568
+ position: relative;
3569
+ user-select: none;
3570
+ -webkit-user-select: none;
3571
+ display: inline-flex;
3572
+ align-items: flex-start;
3573
+ flex-wrap: nowrap;
3574
+ font-size: var(--n-font-size);
3575
+ word-break: break-word;
3576
+ `, [cM('checked', [cE('dot', `
3577
+ background-color: var(--n-color-active);
3578
+ `)]), cE('dot-wrapper', `
3579
+ position: relative;
3580
+ flex-shrink: 0;
3581
+ flex-grow: 0;
3582
+ width: var(--n-radio-size);
3583
+ `), cB('radio-input', `
3584
+ position: absolute;
3585
+ border: 0;
3586
+ border-radius: inherit;
3587
+ left: 0;
3588
+ right: 0;
3589
+ top: 0;
3590
+ bottom: 0;
3591
+ opacity: 0;
3592
+ z-index: 1;
3593
+ cursor: pointer;
3594
+ `), cE('dot', `
3595
+ position: absolute;
3596
+ top: 50%;
3597
+ left: 0;
3598
+ transform: translateY(-50%);
3599
+ height: var(--n-radio-size);
3600
+ width: var(--n-radio-size);
3601
+ background: var(--n-color);
3602
+ box-shadow: var(--n-box-shadow);
3603
+ border-radius: 50%;
3604
+ transition:
3605
+ background-color .3s var(--n-bezier),
3606
+ box-shadow .3s var(--n-bezier);
3607
+ `, [c('&::before', `
3608
+ content: "";
3609
+ opacity: 0;
3610
+ position: absolute;
3611
+ left: 4px;
3612
+ top: 4px;
3613
+ height: calc(100% - 8px);
3614
+ width: calc(100% - 8px);
3615
+ border-radius: 50%;
3616
+ transform: scale(.8);
3617
+ background: var(--n-dot-color-active);
3618
+ transition:
3619
+ opacity .3s var(--n-bezier),
3620
+ background-color .3s var(--n-bezier),
3621
+ transform .3s var(--n-bezier);
3622
+ `), cM('checked', {
3623
+ boxShadow: 'var(--n-box-shadow-active)'
3624
+ }, [c('&::before', `
3625
+ opacity: 1;
3626
+ transform: scale(1);
3627
+ `)])]), cE('label', `
3628
+ color: var(--n-text-color);
3629
+ padding: var(--n-label-padding);
3630
+ font-weight: var(--n-label-font-weight);
3631
+ display: inline-block;
3632
+ transition: color .3s var(--n-bezier);
3633
+ `), cNotM('disabled', `
3634
+ cursor: pointer;
3635
+ `, [c('&:hover', [cE('dot', {
3636
+ boxShadow: 'var(--n-box-shadow-hover)'
3637
+ })]), cM('focus', [c('&:not(:active)', [cE('dot', {
3638
+ boxShadow: 'var(--n-box-shadow-focus)'
3639
+ })])])]), cM('disabled', `
3640
+ cursor: not-allowed;
3641
+ `, [cE('dot', {
3642
+ boxShadow: 'var(--n-box-shadow-disabled)',
3643
+ backgroundColor: 'var(--n-color-disabled)'
3644
+ }, [c('&::before', {
3645
+ backgroundColor: 'var(--n-dot-color-disabled)'
3646
+ }), cM('checked', `
3647
+ opacity: 1;
3648
+ `)]), cE('label', {
3649
+ color: 'var(--n-text-color-disabled)'
3650
+ }), cB('radio-input', `
3651
+ cursor: not-allowed;
3652
+ `)])]);
3653
+
3654
+ const radioBaseProps = {
3655
+ name: String,
3656
+ value: {
3657
+ type: [String, Number, Boolean],
3658
+ default: 'on'
3659
+ },
3660
+ checked: {
3661
+ type: Boolean,
3662
+ default: undefined
3663
+ },
3664
+ defaultChecked: Boolean,
3665
+ disabled: {
3666
+ type: Boolean,
3667
+ default: undefined
3668
+ },
3669
+ label: String,
3670
+ size: String,
3671
+ onUpdateChecked: [Function, Array],
3672
+ 'onUpdate:checked': [Function, Array],
3673
+ // deprecated
3674
+ checkedValue: {
3675
+ type: Boolean,
3676
+ default: undefined
3677
+ }
3678
+ };
3679
+ const radioGroupInjectionKey = createInjectionKey('n-radio-group');
3680
+ function setup(props) {
3681
+ if (process.env.NODE_ENV !== 'production') {
3682
+ watchEffect(() => {
3683
+ if (props.checkedValue !== undefined) {
3684
+ warnOnce('radio', '`checked-value` is deprecated, please use `checked` instead.');
3685
+ }
3686
+ });
3687
+ }
3688
+ const NRadioGroup = inject(radioGroupInjectionKey, null);
3689
+ const formItem = useFormItem(props, {
3690
+ mergedSize(NFormItem) {
3691
+ const {
3692
+ size
3693
+ } = props;
3694
+ if (size !== undefined) return size;
3695
+ if (NRadioGroup) {
3696
+ const {
3697
+ mergedSizeRef: {
3698
+ value: mergedSize
3699
+ }
3700
+ } = NRadioGroup;
3701
+ if (mergedSize !== undefined) {
3702
+ return mergedSize;
3703
+ }
3704
+ }
3705
+ if (NFormItem) {
3706
+ return NFormItem.mergedSize.value;
3707
+ }
3708
+ return 'medium';
3709
+ },
3710
+ mergedDisabled(NFormItem) {
3711
+ if (props.disabled) return true;
3712
+ if (NRadioGroup === null || NRadioGroup === void 0 ? void 0 : NRadioGroup.disabledRef.value) return true;
3713
+ if (NFormItem === null || NFormItem === void 0 ? void 0 : NFormItem.disabled.value) return true;
3714
+ return false;
3715
+ }
3716
+ });
3717
+ const {
3718
+ mergedSizeRef,
3719
+ mergedDisabledRef
3720
+ } = formItem;
3721
+ const inputRef = ref(null);
3722
+ const labelRef = ref(null);
3723
+ const uncontrolledCheckedRef = ref(props.defaultChecked);
3724
+ const controlledCheckedRef = toRef(props, 'checked');
3725
+ const mergedCheckedRef = useMergedState(controlledCheckedRef, uncontrolledCheckedRef);
3726
+ const renderSafeCheckedRef = useMemo(() => {
3727
+ if (NRadioGroup) return NRadioGroup.valueRef.value === props.value;
3728
+ return mergedCheckedRef.value;
3729
+ });
3730
+ const mergedNameRef = useMemo(() => {
3731
+ const {
3732
+ name
3733
+ } = props;
3734
+ if (name !== undefined) return name;
3735
+ if (NRadioGroup) return NRadioGroup.nameRef.value;
3736
+ });
3737
+ const focusRef = ref(false);
3738
+ function doUpdateChecked() {
3739
+ if (NRadioGroup) {
3740
+ const {
3741
+ doUpdateValue
3742
+ } = NRadioGroup;
3743
+ const {
3744
+ value
3745
+ } = props;
3746
+ call(doUpdateValue, value);
3747
+ } else {
3748
+ const {
3749
+ onUpdateChecked,
3750
+ 'onUpdate:checked': _onUpdateChecked
3751
+ } = props;
3752
+ const {
3753
+ nTriggerFormInput,
3754
+ nTriggerFormChange
3755
+ } = formItem;
3756
+ if (onUpdateChecked) call(onUpdateChecked, true);
3757
+ if (_onUpdateChecked) call(_onUpdateChecked, true);
3758
+ nTriggerFormInput();
3759
+ nTriggerFormChange();
3760
+ uncontrolledCheckedRef.value = true;
3761
+ }
3762
+ }
3763
+ function toggle() {
3764
+ if (mergedDisabledRef.value) return;
3765
+ if (!renderSafeCheckedRef.value) {
3766
+ doUpdateChecked();
3767
+ }
3768
+ }
3769
+ function handleRadioInputChange() {
3770
+ toggle();
3771
+ // Restore element check prop's value to current state, since if doesn't
3772
+ // reflect current VNode. If not, bug will happens in component with element
3773
+ // that has internal state such as <input />.
3774
+ if (inputRef.value) {
3775
+ inputRef.value.checked = renderSafeCheckedRef.value;
3776
+ }
3777
+ }
3778
+ function handleRadioInputBlur() {
3779
+ focusRef.value = false;
3780
+ }
3781
+ function handleRadioInputFocus() {
3782
+ focusRef.value = true;
3783
+ }
3784
+ return {
3785
+ mergedClsPrefix: NRadioGroup ? NRadioGroup.mergedClsPrefixRef : useConfig(props).mergedClsPrefixRef,
3786
+ inputRef,
3787
+ labelRef,
3788
+ mergedName: mergedNameRef,
3789
+ mergedDisabled: mergedDisabledRef,
3790
+ renderSafeChecked: renderSafeCheckedRef,
3791
+ focus: focusRef,
3792
+ mergedSize: mergedSizeRef,
3793
+ handleRadioInputChange,
3794
+ handleRadioInputBlur,
3795
+ handleRadioInputFocus
3796
+ };
3797
+ }
3798
+
3799
+ const radioProps = Object.assign(Object.assign({}, useTheme.props), radioBaseProps);
3800
+ var NRadio = defineComponent({
3801
+ name: 'Radio',
3802
+ props: radioProps,
3803
+ setup(props) {
3804
+ const radio = setup(props);
3805
+ const themeRef = useTheme('Radio', '-radio', style, radioLight, props, radio.mergedClsPrefix);
3806
+ const cssVarsRef = computed(() => {
3807
+ const {
3808
+ mergedSize: {
3809
+ value: size
3810
+ }
3811
+ } = radio;
3812
+ const {
3813
+ common: {
3814
+ cubicBezierEaseInOut
3815
+ },
3816
+ self: {
3817
+ boxShadow,
3818
+ boxShadowActive,
3819
+ boxShadowDisabled,
3820
+ boxShadowFocus,
3821
+ boxShadowHover,
3822
+ color,
3823
+ colorDisabled,
3824
+ colorActive,
3825
+ textColor,
3826
+ textColorDisabled,
3827
+ dotColorActive,
3828
+ dotColorDisabled,
3829
+ labelPadding,
3830
+ labelLineHeight,
3831
+ labelFontWeight,
3832
+ [createKey('fontSize', size)]: fontSize,
3833
+ [createKey('radioSize', size)]: radioSize
3834
+ }
3835
+ } = themeRef.value;
3836
+ return {
3837
+ '--n-bezier': cubicBezierEaseInOut,
3838
+ '--n-label-line-height': labelLineHeight,
3839
+ '--n-label-font-weight': labelFontWeight,
3840
+ '--n-box-shadow': boxShadow,
3841
+ '--n-box-shadow-active': boxShadowActive,
3842
+ '--n-box-shadow-disabled': boxShadowDisabled,
3843
+ '--n-box-shadow-focus': boxShadowFocus,
3844
+ '--n-box-shadow-hover': boxShadowHover,
3845
+ '--n-color': color,
3846
+ '--n-color-active': colorActive,
3847
+ '--n-color-disabled': colorDisabled,
3848
+ '--n-dot-color-active': dotColorActive,
3849
+ '--n-dot-color-disabled': dotColorDisabled,
3850
+ '--n-font-size': fontSize,
3851
+ '--n-radio-size': radioSize,
3852
+ '--n-text-color': textColor,
3853
+ '--n-text-color-disabled': textColorDisabled,
3854
+ '--n-label-padding': labelPadding
3855
+ };
3856
+ });
3857
+ const {
3858
+ inlineThemeDisabled,
3859
+ mergedClsPrefixRef,
3860
+ mergedRtlRef
3861
+ } = useConfig(props);
3862
+ const rtlEnabledRef = useRtl('Radio', mergedRtlRef, mergedClsPrefixRef);
3863
+ const themeClassHandle = inlineThemeDisabled ? useThemeClass('radio', computed(() => radio.mergedSize.value[0]), cssVarsRef, props) : undefined;
3864
+ return Object.assign(radio, {
3865
+ rtlEnabled: rtlEnabledRef,
3866
+ cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
3867
+ themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
3868
+ onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
3869
+ });
3870
+ },
3871
+ render() {
3872
+ const {
3873
+ $slots,
3874
+ mergedClsPrefix,
3875
+ onRender,
3876
+ label
3877
+ } = this;
3878
+ onRender === null || onRender === void 0 ? void 0 : onRender();
3879
+ return h("label", {
3880
+ class: [`${mergedClsPrefix}-radio`, this.themeClass, this.rtlEnabled && `${mergedClsPrefix}-radio--rtl`, this.mergedDisabled && `${mergedClsPrefix}-radio--disabled`, this.renderSafeChecked && `${mergedClsPrefix}-radio--checked`, this.focus && `${mergedClsPrefix}-radio--focus`],
3881
+ style: this.cssVars
3882
+ }, h("input", {
3883
+ ref: "inputRef",
3884
+ type: "radio",
3885
+ class: `${mergedClsPrefix}-radio-input`,
3886
+ value: this.value,
3887
+ name: this.mergedName,
3888
+ checked: this.renderSafeChecked,
3889
+ disabled: this.mergedDisabled,
3890
+ onChange: this.handleRadioInputChange,
3891
+ onFocus: this.handleRadioInputFocus,
3892
+ onBlur: this.handleRadioInputBlur
3893
+ }), h("div", {
3894
+ class: `${mergedClsPrefix}-radio__dot-wrapper`
3895
+ }, "\u00A0", h("div", {
3896
+ class: [`${mergedClsPrefix}-radio__dot`, this.renderSafeChecked && `${mergedClsPrefix}-radio__dot--checked`]
3897
+ })), resolveWrappedSlot($slots.default, children => {
3898
+ if (!children && !label) return null;
3899
+ return h("div", {
3900
+ ref: "labelRef",
3901
+ class: `${mergedClsPrefix}-radio__label`
3902
+ }, children || label);
3903
+ }));
3904
+ }
3905
+ });
3906
+
3907
+ const props = {
3908
+ ..._VkTabelsV1Ctx.props,
3909
+ /**
3910
+ * @description v-model 绑定值
3911
+ * @property {Array} modelValue
3912
+ */
3913
+ modelValue: {
3914
+ type: Array,
3915
+ default: () => []
3916
+ },
3917
+ /**
3918
+ * 必须保证主键唯一且生效,选择逻辑才生效
3919
+ *
3920
+ */
3921
+ oidField: {
3922
+ type: String,
3923
+ default: "id"
3924
+ },
3925
+ /**
3926
+ * 是否禁用
3927
+ * @property
3928
+ */
3929
+ disabled: {
3930
+ type: Boolean,
3931
+ default: void 0
3932
+ },
3933
+ /**
3934
+ * 允许多个
3935
+ */
3936
+ multiple: {
3937
+ type: Boolean,
3938
+ default: true
3939
+ },
3940
+ /**
3941
+ * 隐藏选择列
3942
+ */
3943
+ selectionHidden: {
3944
+ type: Boolean,
3945
+ default: false
3946
+ },
3947
+ /**
3948
+ * check触发方式
3949
+ */
3950
+ checkTrigger: {
3951
+ type: String,
3952
+ default: "check"
3953
+ }
3954
+ };
3955
+ const emits = {
3956
+ ..._VkTabelsV1Ctx.emits,
3957
+ "update:modelValue": (val) => Array.isArray(val)
3958
+ };
3959
+
3960
+ const radioThemeOverrides = {
3961
+ dotColorActive: "var(--el-color-primary)",
3962
+ boxShadowActive: "inset 0 0 0 1px var(--el-color-primary)",
3963
+ boxShadowHover: "inset 0 0 0 1px var(--el-color-primary)",
3964
+ boxShadowFocus: "inset 0 0 0 1px var(--el-color-primary), 0 0 0 2px rgba(24, 160, 88, 0.2)"
3965
+ };
3966
+ var _sfc_main = /* @__PURE__ */ defineComponent({
3967
+ name: "VkTablesV1Checkbox",
3968
+ components: {
3969
+ VkCheckRecordLogicProvider,
3970
+ VkTablesV1
3971
+ },
3972
+ inheritAttrs: false,
3973
+ props,
3974
+ emits,
3975
+ setup(props2, {
3976
+ emit
3977
+ }) {
3978
+ const coreProps = _VkTabelsV1Ctx.createBindProps(props2, ["columns"]);
3979
+ const coreEmits = _VkTabelsV1Ctx.createOnEmits(emit, ["row-click"]);
3980
+ const getCurrentPageCheckInfo = () => {
3981
+ const oidField = props2.oidField;
3982
+ const allCheckedId = props2.modelValue.map(d => d[oidField]);
3983
+ const checkedNodes = [];
3984
+ const uncheckedNodes = [];
3985
+ props2.data.forEach(d => {
3986
+ if (allCheckedId.includes(d[oidField])) {
3987
+ checkedNodes.push(d);
3988
+ } else {
3989
+ uncheckedNodes.push(d);
3990
+ }
3991
+ });
3992
+ return {
3993
+ checkedNodes,
3994
+ uncheckedNodes
3995
+ };
3996
+ };
3997
+ function singleChange(row) {
3998
+ const current = props2.modelValue[0];
3999
+ if (current && current[props2.oidField] === row[props2.oidField]) {
4000
+ emit("update:modelValue", []);
4001
+ return;
4002
+ }
4003
+ emit("update:modelValue", [row]);
4004
+ }
4005
+ function headerCheckboxChange(checked, uncheckedNodes) {
4006
+ if (checked) {
4007
+ emit("update:modelValue", [...props2.modelValue, ...uncheckedNodes]);
4008
+ } else {
4009
+ emit("update:modelValue", props2.modelValue.filter(d => {
4010
+ const id = d[props2.oidField];
4011
+ return !props2.data.some(d2 => d2[props2.oidField] === id);
4012
+ }));
4013
+ }
4014
+ }
4015
+ const changeEvents = {};
4016
+ const checkboxCol = {
4017
+ prop: void 0,
4018
+ label: "",
4019
+ width: "50",
4020
+ align: "center",
4021
+ headerAlign: "center",
4022
+ slots: {
4023
+ default: e => createVNode(VkCheckRecordLogic, {
4024
+ "custom": true,
4025
+ "name": e.row
4026
+ }, {
4027
+ default: ({
4028
+ toggle,
4029
+ isActive
4030
+ }) => {
4031
+ const onChange = props2.multiple ? toggle : () => singleChange(e.row);
4032
+ if (!props2.disabled) {
4033
+ changeEvents[e.row[props2.oidField]] = onChange;
4034
+ }
4035
+ const handleCheck = props2.checkTrigger === "check" ? onChange : noop;
4036
+ return props2.multiple ? createVNode(ElCheckbox, {
4037
+ "disabled": props2.disabled,
4038
+ "modelValue": isActive,
4039
+ "onChange": handleCheck
4040
+ }, null) : createVNode(NRadio, {
4041
+ "disabled": props2.disabled,
4042
+ "checked": isActive,
4043
+ "onUpdate:checked": handleCheck,
4044
+ "theme-overrides": radioThemeOverrides
4045
+ }, null);
4046
+ }
4047
+ }),
4048
+ header: () => {
4049
+ if (!props2.multiple) return "";
4050
+ const {
4051
+ checkedNodes,
4052
+ uncheckedNodes
4053
+ } = getCurrentPageCheckInfo();
4054
+ return createVNode(ElCheckbox, {
4055
+ "disabled": props2.disabled,
4056
+ "indeterminate": checkedNodes.length > 0 && checkedNodes.length < props2.data.length,
4057
+ "modelValue": checkedNodes.length && checkedNodes.length === props2.data.length,
4058
+ "onUpdate:modelValue": checked => headerCheckboxChange(checked, uncheckedNodes)
4059
+ }, null);
4060
+ }
4061
+ }
4062
+ };
4063
+ function handleRowClick(...e) {
4064
+ const [row] = e;
4065
+ if (props2.checkTrigger === "rowClick") {
4066
+ const id = row[props2.oidField];
4067
+ changeEvents[id]?.();
4068
+ }
4069
+ emit("row-click", ...e);
4070
+ }
4071
+ return {
4072
+ coreProps,
4073
+ coreEmits,
4074
+ checkboxCol,
4075
+ handleRowClick
4076
+ };
4077
+ }
4078
+ });
4079
+
4080
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4081
+ const _component_VkTablesV1 = resolveComponent("VkTablesV1");
4082
+ const _component_VkCheckRecordLogicProvider = resolveComponent("VkCheckRecordLogicProvider");
4083
+ return openBlock(), createBlock(_component_VkCheckRecordLogicProvider, {
4084
+ "allow-extra": true,
4085
+ "model-value": _ctx.modelValue,
4086
+ "oid-field": _ctx.oidField,
4087
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:modelValue", $event))
4088
+ }, {
4089
+ default: withCtx(() => [
4090
+ createVNode(_component_VkTablesV1, mergeProps({
4091
+ ..._ctx.coreProps,
4092
+ ..._ctx.$attrs
4093
+ }, {
4094
+ columns: [
4095
+ _ctx.selectionHidden ? { hidden: true } : _ctx.checkboxCol,
4096
+ ..._ctx.columns
4097
+ ],
4098
+ onRowClick: _ctx.handleRowClick
4099
+ }, toHandlers(_ctx.coreEmits)), null, 16, ["columns", "onRowClick"])
4100
+ ]),
4101
+ _: 1
4102
+ /* STABLE */
4103
+ }, 8, ["model-value", "oid-field"]);
4104
+ }
4105
+ var VkTablesV1Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/tables-v1-checkbox/src/index.vue"]]);
4106
+
4107
+ var types = /*#__PURE__*/Object.freeze({
4108
+ __proto__: null
4109
+ });
4110
+
4111
+ VkTablesV1Checkbox.install = (app) => {
4112
+ app.component(VkTablesV1Checkbox.name || "VkTablesV1Checkbox", VkTablesV1Checkbox);
4113
+ };
4114
+
4115
+ export { VkTablesV1Checkbox, types as __VkTablesV1Checkbox, VkTablesV1Checkbox as default };