115+

为115网盘添加一些功能

2024-05-19 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name 115+
  3. // @namespace npm/vite-plugin-monkey
  4. // @version 1.0.0
  5. // @author monkey
  6. // @description 为115网盘添加一些功能
  7. // @license MIT
  8. // @icon https://115.com/favicon.ico
  9. // @match https://115.com/*
  10. // @require https://cdn.jsdelivr.net/npm/vue@3.4.27/dist/vue.global.prod.js
  11. // @grant GM_addStyle
  12. // @grant GM_getValue
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_setValue
  15. // ==/UserScript==
  16.  
  17. (e=>{if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const t=document.createElement("style");t.textContent=e,document.head.append(t)})(" .main[data-v-8fb240a8]{border-right:1px solid #edeeef;height:100%} ");
  18.  
  19. (function (vue) {
  20. 'use strict';
  21.  
  22. var __getOwnPropNames = Object.getOwnPropertyNames;
  23. var __commonJS = (cb, mod) => function __require() {
  24. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  25. };
  26. var require_main_001 = __commonJS({
  27. "main-BzOViHoL.js"(exports, module) {
  28. let onceCbs = [];
  29. const paramsMap = /* @__PURE__ */ new WeakMap();
  30. function flushOnceCallbacks() {
  31. onceCbs.forEach((cb) => cb(...paramsMap.get(cb)));
  32. onceCbs = [];
  33. }
  34. function beforeNextFrameOnce(cb, ...params) {
  35. paramsMap.set(cb, params);
  36. if (onceCbs.includes(cb))
  37. return;
  38. onceCbs.push(cb) === 1 && requestAnimationFrame(flushOnceCallbacks);
  39. }
  40. function happensIn(e, dataSetPropName) {
  41. let { target } = e;
  42. while (target) {
  43. if (target.dataset) {
  44. if (target.dataset[dataSetPropName] !== void 0)
  45. return true;
  46. }
  47. target = target.parentElement;
  48. }
  49. return false;
  50. }
  51. function getPreciseEventTarget(event) {
  52. return event.composedPath()[0] || null;
  53. }
  54. function depx(value) {
  55. if (typeof value === "string") {
  56. if (value.endsWith("px")) {
  57. return Number(value.slice(0, value.length - 2));
  58. }
  59. return Number(value);
  60. }
  61. return value;
  62. }
  63. function getMargin(value, position) {
  64. const parts = value.trim().split(/\s+/g);
  65. const margin = {
  66. top: parts[0]
  67. };
  68. switch (parts.length) {
  69. case 1:
  70. margin.right = parts[0];
  71. margin.bottom = parts[0];
  72. margin.left = parts[0];
  73. break;
  74. case 2:
  75. margin.right = parts[1];
  76. margin.left = parts[1];
  77. margin.bottom = parts[0];
  78. break;
  79. case 3:
  80. margin.right = parts[1];
  81. margin.bottom = parts[2];
  82. margin.left = parts[1];
  83. break;
  84. case 4:
  85. margin.right = parts[1];
  86. margin.bottom = parts[2];
  87. margin.left = parts[3];
  88. break;
  89. default:
  90. throw new Error("[seemly/getMargin]:" + value + " is not a valid value.");
  91. }
  92. return margin;
  93. }
  94. const colors = {
  95. black: "#000",
  96. silver: "#C0C0C0",
  97. gray: "#808080",
  98. white: "#FFF",
  99. maroon: "#800000",
  100. red: "#F00",
  101. purple: "#800080",
  102. fuchsia: "#F0F",
  103. green: "#008000",
  104. lime: "#0F0",
  105. olive: "#808000",
  106. yellow: "#FF0",
  107. navy: "#000080",
  108. blue: "#00F",
  109. teal: "#008080",
  110. aqua: "#0FF",
  111. transparent: "#0000"
  112. };
  113. const prefix$1 = "^\\s*";
  114. const suffix = "\\s*$";
  115. const float = "\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))\\s*";
  116. const hex = "([0-9A-Fa-f])";
  117. const dhex = "([0-9A-Fa-f]{2})";
  118. const rgbRegex = new RegExp(`${prefix$1}rgb\\s*\\(${float},${float},${float}\\)${suffix}`);
  119. const rgbaRegex = new RegExp(`${prefix$1}rgba\\s*\\(${float},${float},${float},${float}\\)${suffix}`);
  120. const sHexRegex = new RegExp(`${prefix$1}#${hex}${hex}${hex}${suffix}`);
  121. const hexRegex = new RegExp(`${prefix$1}#${dhex}${dhex}${dhex}${suffix}`);
  122. const sHexaRegex = new RegExp(`${prefix$1}#${hex}${hex}${hex}${hex}${suffix}`);
  123. const hexaRegex = new RegExp(`${prefix$1}#${dhex}${dhex}${dhex}${dhex}${suffix}`);
  124. function parseHex(value) {
  125. return parseInt(value, 16);
  126. }
  127. function rgba(color) {
  128. try {
  129. let i;
  130. if (i = hexRegex.exec(color)) {
  131. return [parseHex(i[1]), parseHex(i[2]), parseHex(i[3]), 1];
  132. } else if (i = rgbRegex.exec(color)) {
  133. return [roundChannel(i[1]), roundChannel(i[5]), roundChannel(i[9]), 1];
  134. } else if (i = rgbaRegex.exec(color)) {
  135. return [
  136. roundChannel(i[1]),
  137. roundChannel(i[5]),
  138. roundChannel(i[9]),
  139. roundAlpha(i[13])
  140. ];
  141. } else if (i = sHexRegex.exec(color)) {
  142. return [
  143. parseHex(i[1] + i[1]),
  144. parseHex(i[2] + i[2]),
  145. parseHex(i[3] + i[3]),
  146. 1
  147. ];
  148. } else if (i = hexaRegex.exec(color)) {
  149. return [
  150. parseHex(i[1]),
  151. parseHex(i[2]),
  152. parseHex(i[3]),
  153. roundAlpha(parseHex(i[4]) / 255)
  154. ];
  155. } else if (i = sHexaRegex.exec(color)) {
  156. return [
  157. parseHex(i[1] + i[1]),
  158. parseHex(i[2] + i[2]),
  159. parseHex(i[3] + i[3]),
  160. roundAlpha(parseHex(i[4] + i[4]) / 255)
  161. ];
  162. } else if (color in colors) {
  163. return rgba(colors[color]);
  164. }
  165. throw new Error(`[seemly/rgba]: Invalid color value ${color}.`);
  166. } catch (e) {
  167. throw e;
  168. }
  169. }
  170. function normalizeAlpha(alphaValue) {
  171. return alphaValue > 1 ? 1 : alphaValue < 0 ? 0 : alphaValue;
  172. }
  173. function stringifyRgba(r, g, b, a) {
  174. return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${normalizeAlpha(a)})`;
  175. }
  176. function compositeChannel(v1, a1, v2, a2, a) {
  177. return roundChannel((v1 * a1 * (1 - a2) + v2 * a2) / a);
  178. }
  179. function composite(background, overlay2) {
  180. if (!Array.isArray(background))
  181. background = rgba(background);
  182. if (!Array.isArray(overlay2))
  183. overlay2 = rgba(overlay2);
  184. const a1 = background[3];
  185. const a2 = overlay2[3];
  186. const alpha = roundAlpha(a1 + a2 - a1 * a2);
  187. return stringifyRgba(compositeChannel(background[0], a1, overlay2[0], a2, alpha), compositeChannel(background[1], a1, overlay2[1], a2, alpha), compositeChannel(background[2], a1, overlay2[2], a2, alpha), alpha);
  188. }
  189. function changeColor(base2, options) {
  190. const [r, g, b, a = 1] = Array.isArray(base2) ? base2 : rgba(base2);
  191. if (options.alpha) {
  192. return stringifyRgba(r, g, b, options.alpha);
  193. }
  194. return stringifyRgba(r, g, b, a);
  195. }
  196. function scaleColor(base2, options) {
  197. const [r, g, b, a = 1] = Array.isArray(base2) ? base2 : rgba(base2);
  198. const { lightness = 1, alpha = 1 } = options;
  199. return toRgbaString([r * lightness, g * lightness, b * lightness, a * alpha]);
  200. }
  201. function roundAlpha(value) {
  202. const v = Math.round(Number(value) * 100) / 100;
  203. if (v > 1)
  204. return 1;
  205. if (v < 0)
  206. return 0;
  207. return v;
  208. }
  209. function roundChannel(value) {
  210. const v = Math.round(Number(value));
  211. if (v > 255)
  212. return 255;
  213. if (v < 0)
  214. return 0;
  215. return v;
  216. }
  217. function toRgbaString(base2) {
  218. const [r, g, b] = base2;
  219. if (3 in base2) {
  220. return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${roundAlpha(base2[3])})`;
  221. }
  222. return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, 1)`;
  223. }
  224. function createId(length = 8) {
  225. return Math.random().toString(16).slice(2, 2 + length);
  226. }
  227. function keep(object, keys2 = [], rest) {
  228. const keepedObject = {};
  229. keys2.forEach((key) => {
  230. keepedObject[key] = object[key];
  231. });
  232. return Object.assign(keepedObject, rest);
  233. }
  234. function flatten$2(vNodes, filterCommentNode = true, result = []) {
  235. vNodes.forEach((vNode) => {
  236. if (vNode === null)
  237. return;
  238. if (typeof vNode !== "object") {
  239. if (typeof vNode === "string" || typeof vNode === "number") {
  240. result.push(vue.createTextVNode(String(vNode)));
  241. }
  242. return;
  243. }
  244. if (Array.isArray(vNode)) {
  245. flatten$2(vNode, filterCommentNode, result);
  246. return;
  247. }
  248. if (vNode.type === vue.Fragment) {
  249. if (vNode.children === null)
  250. return;
  251. if (Array.isArray(vNode.children)) {
  252. flatten$2(vNode.children, filterCommentNode, result);
  253. }
  254. } else {
  255. if (vNode.type === vue.Comment && filterCommentNode)
  256. return;
  257. result.push(vNode);
  258. }
  259. });
  260. return result;
  261. }
  262. function call(funcs, ...args) {
  263. if (Array.isArray(funcs)) {
  264. funcs.forEach((func) => call(func, ...args));
  265. } else
  266. return funcs(...args);
  267. }
  268. function keysOf(obj) {
  269. return Object.keys(obj);
  270. }
  271. const render$1 = (r, ...args) => {
  272. if (typeof r === "function") {
  273. return r(...args);
  274. } else if (typeof r === "string") {
  275. return vue.createTextVNode(r);
  276. } else if (typeof r === "number") {
  277. return vue.createTextVNode(String(r));
  278. } else {
  279. return null;
  280. }
  281. };
  282. function warn$2(location, message) {
  283. console.error(`[naive/${location}]: ${message}`);
  284. }
  285. function throwError(location, message) {
  286. throw new Error(`[naive/${location}]: ${message}`);
  287. }
  288. function getFirstSlotVNode(slots, slotName = "default", props = void 0) {
  289. const slot = slots[slotName];
  290. if (!slot) {
  291. warn$2("getFirstSlotVNode", `slot[${slotName}] is empty`);
  292. return null;
  293. }
  294. const slotContent = flatten$2(slot(props));
  295. if (slotContent.length === 1) {
  296. return slotContent[0];
  297. } else {
  298. warn$2("getFirstSlotVNode", `slot[${slotName}] should have exactly one child`);
  299. return null;
  300. }
  301. }
  302. function createRefSetter(ref2) {
  303. return (inst) => {
  304. if (inst) {
  305. ref2.value = inst.$el;
  306. } else {
  307. ref2.value = null;
  308. }
  309. };
  310. }
  311. function createInjectionKey(key) {
  312. return key;
  313. }
  314. function ensureValidVNode(vnodes) {
  315. return vnodes.some((child) => {
  316. if (!vue.isVNode(child)) {
  317. return true;
  318. }
  319. if (child.type === vue.Comment) {
  320. return false;
  321. }
  322. if (child.type === vue.Fragment && !ensureValidVNode(child.children)) {
  323. return false;
  324. }
  325. return true;
  326. }) ? vnodes : null;
  327. }
  328. function resolveWrappedSlot(slot, wrapper) {
  329. const children = slot && ensureValidVNode(slot());
  330. return wrapper(children || null);
  331. }
  332. function isSlotEmpty(slot) {
  333. return !(slot && ensureValidVNode(slot()));
  334. }
  335. const Wrapper = vue.defineComponent({
  336. render() {
  337. var _a, _b;
  338. return (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a);
  339. }
  340. });
  341. const pureNumberRegex = /^(\d|\.)+$/;
  342. const numberRegex = /(\d|\.)+/;
  343. function formatLength(length, {
  344. c: c2 = 1,
  345. offset = 0,
  346. attachPx = true
  347. } = {}) {
  348. if (typeof length === "number") {
  349. const result = (length + offset) * c2;
  350. if (result === 0)
  351. return "0";
  352. return `${result}px`;
  353. } else if (typeof length === "string") {
  354. if (pureNumberRegex.test(length)) {
  355. const result = (Number(length) + offset) * c2;
  356. if (attachPx) {
  357. if (result === 0)
  358. return "0";
  359. return `${result}px`;
  360. } else {
  361. return `${result}`;
  362. }
  363. } else {
  364. const result = numberRegex.exec(length);
  365. if (!result)
  366. return length;
  367. return length.replace(numberRegex, String((Number(result[0]) + offset) * c2));
  368. }
  369. }
  370. return length;
  371. }
  372. function rtlInset(inset) {
  373. const {
  374. left,
  375. right,
  376. top,
  377. bottom
  378. } = getMargin(inset);
  379. return `${top} ${right} ${bottom} ${left}`;
  380. }
  381. function ampCount(selector) {
  382. let cnt = 0;
  383. for (let i = 0; i < selector.length; ++i) {
  384. if (selector[i] === "&")
  385. ++cnt;
  386. }
  387. return cnt;
  388. }
  389. const separatorRegex = /\s*,(?![^(]*\))\s*/g;
  390. const extraSpaceRegex = /\s+/g;
  391. function resolveSelectorWithAmp(amp, selector) {
  392. const nextAmp = [];
  393. selector.split(separatorRegex).forEach((partialSelector) => {
  394. let round = ampCount(partialSelector);
  395. if (!round) {
  396. amp.forEach((partialAmp) => {
  397. nextAmp.push(
  398. // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
  399. (partialAmp && partialAmp + " ") + partialSelector
  400. );
  401. });
  402. return;
  403. } else if (round === 1) {
  404. amp.forEach((partialAmp) => {
  405. nextAmp.push(partialSelector.replace("&", partialAmp));
  406. });
  407. return;
  408. }
  409. let partialNextAmp = [
  410. partialSelector
  411. ];
  412. while (round--) {
  413. const nextPartialNextAmp = [];
  414. partialNextAmp.forEach((selectorItr) => {
  415. amp.forEach((partialAmp) => {
  416. nextPartialNextAmp.push(selectorItr.replace("&", partialAmp));
  417. });
  418. });
  419. partialNextAmp = nextPartialNextAmp;
  420. }
  421. partialNextAmp.forEach((part) => nextAmp.push(part));
  422. });
  423. return nextAmp;
  424. }
  425. function resolveSelector(amp, selector) {
  426. const nextAmp = [];
  427. selector.split(separatorRegex).forEach((partialSelector) => {
  428. amp.forEach((partialAmp) => {
  429. nextAmp.push((partialAmp && partialAmp + " ") + partialSelector);
  430. });
  431. });
  432. return nextAmp;
  433. }
  434. function parseSelectorPath(selectorPaths) {
  435. let amp = [""];
  436. selectorPaths.forEach((selector) => {
  437. selector = selector && selector.trim();
  438. if (
  439. // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
  440. !selector
  441. ) {
  442. return;
  443. }
  444. if (selector.includes("&")) {
  445. amp = resolveSelectorWithAmp(amp, selector);
  446. } else {
  447. amp = resolveSelector(amp, selector);
  448. }
  449. });
  450. return amp.join(", ").replace(extraSpaceRegex, " ");
  451. }
  452. function removeElement(el) {
  453. if (!el)
  454. return;
  455. const parentElement = el.parentElement;
  456. if (parentElement)
  457. parentElement.removeChild(el);
  458. }
  459. function queryElement(id, parent) {
  460. return (parent !== null && parent !== void 0 ? parent : document.head).querySelector(`style[cssr-id="${id}"]`);
  461. }
  462. function createElement(id) {
  463. const el = document.createElement("style");
  464. el.setAttribute("cssr-id", id);
  465. return el;
  466. }
  467. function isMediaOrSupports(selector) {
  468. if (!selector)
  469. return false;
  470. return /^\s*@(s|m)/.test(selector);
  471. }
  472. const kebabRegex = /[A-Z]/g;
  473. function kebabCase(pattern) {
  474. return pattern.replace(kebabRegex, (match) => "-" + match.toLowerCase());
  475. }
  476. function unwrapProperty(prop, indent = " ") {
  477. if (typeof prop === "object" && prop !== null) {
  478. return " {\n" + Object.entries(prop).map((v) => {
  479. return indent + ` ${kebabCase(v[0])}: ${v[1]};`;
  480. }).join("\n") + "\n" + indent + "}";
  481. }
  482. return `: ${prop};`;
  483. }
  484. function unwrapProperties(props, instance, params) {
  485. if (typeof props === "function") {
  486. return props({
  487. context: instance.context,
  488. props: params
  489. });
  490. }
  491. return props;
  492. }
  493. function createStyle(selector, props, instance, params) {
  494. if (!props)
  495. return "";
  496. const unwrappedProps = unwrapProperties(props, instance, params);
  497. if (!unwrappedProps)
  498. return "";
  499. if (typeof unwrappedProps === "string") {
  500. return `${selector} {
  501. ${unwrappedProps}
  502. }`;
  503. }
  504. const propertyNames = Object.keys(unwrappedProps);
  505. if (propertyNames.length === 0) {
  506. if (instance.config.keepEmptyBlock)
  507. return selector + " {\n}";
  508. return "";
  509. }
  510. const statements = selector ? [
  511. selector + " {"
  512. ] : [];
  513. propertyNames.forEach((propertyName) => {
  514. const property2 = unwrappedProps[propertyName];
  515. if (propertyName === "raw") {
  516. statements.push("\n" + property2 + "\n");
  517. return;
  518. }
  519. propertyName = kebabCase(propertyName);
  520. if (property2 !== null && property2 !== void 0) {
  521. statements.push(` ${propertyName}${unwrapProperty(property2)}`);
  522. }
  523. });
  524. if (selector) {
  525. statements.push("}");
  526. }
  527. return statements.join("\n");
  528. }
  529. function loopCNodeListWithCallback(children, options, callback) {
  530. if (!children)
  531. return;
  532. children.forEach((child) => {
  533. if (Array.isArray(child)) {
  534. loopCNodeListWithCallback(child, options, callback);
  535. } else if (typeof child === "function") {
  536. const grandChildren = child(options);
  537. if (Array.isArray(grandChildren)) {
  538. loopCNodeListWithCallback(grandChildren, options, callback);
  539. } else if (grandChildren) {
  540. callback(grandChildren);
  541. }
  542. } else if (child) {
  543. callback(child);
  544. }
  545. });
  546. }
  547. function traverseCNode(node, selectorPaths, styles, instance, params) {
  548. const $ = node.$;
  549. let blockSelector = "";
  550. if (!$ || typeof $ === "string") {
  551. if (isMediaOrSupports($)) {
  552. blockSelector = $;
  553. } else {
  554. selectorPaths.push($);
  555. }
  556. } else if (typeof $ === "function") {
  557. const selector2 = $({
  558. context: instance.context,
  559. props: params
  560. });
  561. if (isMediaOrSupports(selector2)) {
  562. blockSelector = selector2;
  563. } else {
  564. selectorPaths.push(selector2);
  565. }
  566. } else {
  567. if ($.before)
  568. $.before(instance.context);
  569. if (!$.$ || typeof $.$ === "string") {
  570. if (isMediaOrSupports($.$)) {
  571. blockSelector = $.$;
  572. } else {
  573. selectorPaths.push($.$);
  574. }
  575. } else if ($.$) {
  576. const selector2 = $.$({
  577. context: instance.context,
  578. props: params
  579. });
  580. if (isMediaOrSupports(selector2)) {
  581. blockSelector = selector2;
  582. } else {
  583. selectorPaths.push(selector2);
  584. }
  585. }
  586. }
  587. const selector = parseSelectorPath(selectorPaths);
  588. const style2 = createStyle(selector, node.props, instance, params);
  589. if (blockSelector) {
  590. styles.push(`${blockSelector} {`);
  591. } else if (style2.length) {
  592. styles.push(style2);
  593. }
  594. if (node.children) {
  595. loopCNodeListWithCallback(node.children, {
  596. context: instance.context,
  597. props: params
  598. }, (childNode) => {
  599. if (typeof childNode === "string") {
  600. const style3 = createStyle(selector, { raw: childNode }, instance, params);
  601. styles.push(style3);
  602. } else {
  603. traverseCNode(childNode, selectorPaths, styles, instance, params);
  604. }
  605. });
  606. }
  607. selectorPaths.pop();
  608. if (blockSelector) {
  609. styles.push("}");
  610. }
  611. if ($ && $.after)
  612. $.after(instance.context);
  613. }
  614. function render(node, instance, props) {
  615. const styles = [];
  616. traverseCNode(node, [], styles, instance, props);
  617. return styles.join("\n\n");
  618. }
  619. function murmur2(str) {
  620. var h2 = 0;
  621. var k, i = 0, len = str.length;
  622. for (; len >= 4; ++i, len -= 4) {
  623. k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
  624. k = /* Math.imul(k, m): */
  625. (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
  626. k ^= /* k >>> r: */
  627. k >>> 24;
  628. h2 = /* Math.imul(k, m): */
  629. (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */
  630. (h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
  631. }
  632. switch (len) {
  633. case 3:
  634. h2 ^= (str.charCodeAt(i + 2) & 255) << 16;
  635. case 2:
  636. h2 ^= (str.charCodeAt(i + 1) & 255) << 8;
  637. case 1:
  638. h2 ^= str.charCodeAt(i) & 255;
  639. h2 = /* Math.imul(h, m): */
  640. (h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
  641. }
  642. h2 ^= h2 >>> 13;
  643. h2 = /* Math.imul(h, m): */
  644. (h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
  645. return ((h2 ^ h2 >>> 15) >>> 0).toString(36);
  646. }
  647. if (typeof window !== "undefined") {
  648. window.__cssrContext = {};
  649. }
  650. function unmount(instance, node, id, parent) {
  651. const { els } = node;
  652. if (id === void 0) {
  653. els.forEach(removeElement);
  654. node.els = [];
  655. } else {
  656. const target = queryElement(id, parent);
  657. if (target && els.includes(target)) {
  658. removeElement(target);
  659. node.els = els.filter((el) => el !== target);
  660. }
  661. }
  662. }
  663. function addElementToList(els, target) {
  664. els.push(target);
  665. }
  666. function mount(instance, node, id, props, head, force, anchorMetaName, parent, ssrAdapter2) {
  667. let style2;
  668. if (id === void 0) {
  669. style2 = node.render(props);
  670. id = murmur2(style2);
  671. }
  672. if (ssrAdapter2) {
  673. ssrAdapter2.adapter(id, style2 !== null && style2 !== void 0 ? style2 : node.render(props));
  674. return;
  675. }
  676. if (parent === void 0) {
  677. parent = document.head;
  678. }
  679. const queriedTarget = queryElement(id, parent);
  680. if (queriedTarget !== null && !force) {
  681. return queriedTarget;
  682. }
  683. const target = queriedTarget !== null && queriedTarget !== void 0 ? queriedTarget : createElement(id);
  684. if (style2 === void 0)
  685. style2 = node.render(props);
  686. target.textContent = style2;
  687. if (queriedTarget !== null)
  688. return queriedTarget;
  689. if (anchorMetaName) {
  690. const anchorMetaEl = parent.querySelector(`meta[name="${anchorMetaName}"]`);
  691. if (anchorMetaEl) {
  692. parent.insertBefore(target, anchorMetaEl);
  693. addElementToList(node.els, target);
  694. return target;
  695. }
  696. }
  697. if (head) {
  698. parent.insertBefore(target, parent.querySelector("style, link"));
  699. } else {
  700. parent.appendChild(target);
  701. }
  702. addElementToList(node.els, target);
  703. return target;
  704. }
  705. function wrappedRender(props) {
  706. return render(this, this.instance, props);
  707. }
  708. function wrappedMount(options = {}) {
  709. const { id, ssr, props, head = false, force = false, anchorMetaName, parent } = options;
  710. const targetElement = mount(this.instance, this, id, props, head, force, anchorMetaName, parent, ssr);
  711. return targetElement;
  712. }
  713. function wrappedUnmount(options = {}) {
  714. const { id, parent } = options;
  715. unmount(this.instance, this, id, parent);
  716. }
  717. const createCNode = function(instance, $, props, children) {
  718. return {
  719. instance,
  720. $,
  721. props,
  722. children,
  723. els: [],
  724. render: wrappedRender,
  725. mount: wrappedMount,
  726. unmount: wrappedUnmount
  727. };
  728. };
  729. const c$2 = function(instance, $, props, children) {
  730. if (Array.isArray($)) {
  731. return createCNode(instance, { $: null }, null, $);
  732. } else if (Array.isArray(props)) {
  733. return createCNode(instance, $, null, props);
  734. } else if (Array.isArray(children)) {
  735. return createCNode(instance, $, props, children);
  736. } else {
  737. return createCNode(instance, $, props, null);
  738. }
  739. };
  740. function CssRender(config = {}) {
  741. const cssr2 = {
  742. c: (...args) => c$2(cssr2, ...args),
  743. use: (plugin2, ...args) => plugin2.install(cssr2, ...args),
  744. find: queryElement,
  745. context: {},
  746. config
  747. };
  748. return cssr2;
  749. }
  750. function exists(id, ssr) {
  751. if (id === void 0)
  752. return false;
  753. if (ssr) {
  754. const { context: { ids } } = ssr;
  755. return ids.has(id);
  756. }
  757. return queryElement(id) !== null;
  758. }
  759. function plugin$1(options) {
  760. let _bPrefix = ".";
  761. let _ePrefix = "__";
  762. let _mPrefix = "--";
  763. let c2;
  764. if (options) {
  765. let t = options.blockPrefix;
  766. if (t) {
  767. _bPrefix = t;
  768. }
  769. t = options.elementPrefix;
  770. if (t) {
  771. _ePrefix = t;
  772. }
  773. t = options.modifierPrefix;
  774. if (t) {
  775. _mPrefix = t;
  776. }
  777. }
  778. const _plugin = {
  779. install(instance) {
  780. c2 = instance.c;
  781. const ctx2 = instance.context;
  782. ctx2.bem = {};
  783. ctx2.bem.b = null;
  784. ctx2.bem.els = null;
  785. }
  786. };
  787. function b(arg) {
  788. let memorizedB;
  789. let memorizedE;
  790. return {
  791. before(ctx2) {
  792. memorizedB = ctx2.bem.b;
  793. memorizedE = ctx2.bem.els;
  794. ctx2.bem.els = null;
  795. },
  796. after(ctx2) {
  797. ctx2.bem.b = memorizedB;
  798. ctx2.bem.els = memorizedE;
  799. },
  800. $({ context, props }) {
  801. arg = typeof arg === "string" ? arg : arg({ context, props });
  802. context.bem.b = arg;
  803. return `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}`;
  804. }
  805. };
  806. }
  807. function e(arg) {
  808. let memorizedE;
  809. return {
  810. before(ctx2) {
  811. memorizedE = ctx2.bem.els;
  812. },
  813. after(ctx2) {
  814. ctx2.bem.els = memorizedE;
  815. },
  816. $({ context, props }) {
  817. arg = typeof arg === "string" ? arg : arg({ context, props });
  818. context.bem.els = arg.split(",").map((v) => v.trim());
  819. return context.bem.els.map((el) => `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${_ePrefix}${el}`).join(", ");
  820. }
  821. };
  822. }
  823. function m(arg) {
  824. return {
  825. $({ context, props }) {
  826. arg = typeof arg === "string" ? arg : arg({ context, props });
  827. const modifiers = arg.split(",").map((v) => v.trim());
  828. function elementToSelector(el) {
  829. return modifiers.map((modifier) => `&${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${el !== void 0 ? `${_ePrefix}${el}` : ""}${_mPrefix}${modifier}`).join(", ");
  830. }
  831. const els = context.bem.els;
  832. if (els !== null) {
  833. return elementToSelector(els[0]);
  834. } else {
  835. return elementToSelector();
  836. }
  837. }
  838. };
  839. }
  840. function notM(arg) {
  841. return {
  842. $({ context, props }) {
  843. arg = typeof arg === "string" ? arg : arg({ context, props });
  844. const els = context.bem.els;
  845. 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})`;
  846. }
  847. };
  848. }
  849. const cB2 = (...args) => c2(b(args[0]), args[1], args[2]);
  850. const cE2 = (...args) => c2(e(args[0]), args[1], args[2]);
  851. const cM2 = (...args) => c2(m(args[0]), args[1], args[2]);
  852. const cNotM2 = (...args) => c2(notM(args[0]), args[1], args[2]);
  853. Object.assign(_plugin, {
  854. cB: cB2,
  855. cE: cE2,
  856. cM: cM2,
  857. cNotM: cNotM2
  858. });
  859. return _plugin;
  860. }
  861. const namespace = "n";
  862. const prefix = `.${namespace}-`;
  863. const elementPrefix = "__";
  864. const modifierPrefix = "--";
  865. const cssr = CssRender();
  866. const plugin = plugin$1({
  867. blockPrefix: prefix,
  868. elementPrefix,
  869. modifierPrefix
  870. });
  871. cssr.use(plugin);
  872. const {
  873. c: c$1,
  874. find
  875. } = cssr;
  876. const {
  877. cB,
  878. cE,
  879. cM,
  880. cNotM
  881. } = plugin;
  882. const cCB = (...args) => {
  883. return c$1(">", [cB(...args)]);
  884. };
  885. function createKey(prefix2, suffix2) {
  886. return prefix2 + (suffix2 === "default" ? "" : suffix2.replace(/^[a-z]/, (startChar) => startChar.toUpperCase()));
  887. }
  888. let _isJsdom;
  889. function isJsdom() {
  890. if (_isJsdom === void 0) {
  891. _isJsdom = navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom");
  892. }
  893. return _isJsdom;
  894. }
  895. function useDeferredTrue(valueRef, delay, shouldDelayRef) {
  896. const delayedRef = vue.ref(valueRef.value);
  897. let timerId = null;
  898. vue.watch(valueRef, (value) => {
  899. if (timerId !== null)
  900. window.clearTimeout(timerId);
  901. if (value === true) {
  902. if (shouldDelayRef && !shouldDelayRef.value) {
  903. delayedRef.value = true;
  904. } else {
  905. timerId = window.setTimeout(() => {
  906. delayedRef.value = true;
  907. }, delay);
  908. }
  909. } else {
  910. delayedRef.value = false;
  911. }
  912. });
  913. return delayedRef;
  914. }
  915. function useFalseUntilTruthy(originalRef) {
  916. const currentRef = vue.ref(!!originalRef.value);
  917. if (currentRef.value)
  918. return vue.readonly(currentRef);
  919. const stop = vue.watch(originalRef, (value) => {
  920. if (value) {
  921. currentRef.value = true;
  922. stop();
  923. }
  924. });
  925. return vue.readonly(currentRef);
  926. }
  927. function useMemo(getterOrOptions) {
  928. const computedValueRef = vue.computed(getterOrOptions);
  929. const valueRef = vue.ref(computedValueRef.value);
  930. vue.watch(computedValueRef, (value) => {
  931. valueRef.value = value;
  932. });
  933. if (typeof getterOrOptions === "function") {
  934. return valueRef;
  935. } else {
  936. return {
  937. __v_isRef: true,
  938. get value() {
  939. return valueRef.value;
  940. },
  941. set value(v) {
  942. getterOrOptions.set(v);
  943. }
  944. };
  945. }
  946. }
  947. function hasInstance() {
  948. return vue.getCurrentInstance() !== null;
  949. }
  950. const isBrowser$1 = typeof window !== "undefined";
  951. let fontsReady;
  952. let isFontReady;
  953. const init = () => {
  954. var _a, _b;
  955. fontsReady = isBrowser$1 ? (_b = (_a = document) === null || _a === void 0 ? void 0 : _a.fonts) === null || _b === void 0 ? void 0 : _b.ready : void 0;
  956. isFontReady = false;
  957. if (fontsReady !== void 0) {
  958. void fontsReady.then(() => {
  959. isFontReady = true;
  960. });
  961. } else {
  962. isFontReady = true;
  963. }
  964. };
  965. init();
  966. function onFontsReady(cb) {
  967. if (isFontReady)
  968. return;
  969. let deactivated = false;
  970. vue.onMounted(() => {
  971. if (!isFontReady) {
  972. fontsReady === null || fontsReady === void 0 ? void 0 : fontsReady.then(() => {
  973. if (deactivated)
  974. return;
  975. cb();
  976. });
  977. }
  978. });
  979. vue.onBeforeUnmount(() => {
  980. deactivated = true;
  981. });
  982. }
  983. function getEventTarget(e) {
  984. const path = e.composedPath();
  985. return path[0];
  986. }
  987. const traps = {
  988. mousemoveoutside: /* @__PURE__ */ new WeakMap(),
  989. clickoutside: /* @__PURE__ */ new WeakMap()
  990. };
  991. function createTrapHandler(name, el, originalHandler) {
  992. if (name === "mousemoveoutside") {
  993. const moveHandler = (e) => {
  994. if (el.contains(getEventTarget(e)))
  995. return;
  996. originalHandler(e);
  997. };
  998. return {
  999. mousemove: moveHandler,
  1000. touchstart: moveHandler
  1001. };
  1002. } else if (name === "clickoutside") {
  1003. let mouseDownOutside = false;
  1004. const downHandler = (e) => {
  1005. mouseDownOutside = !el.contains(getEventTarget(e));
  1006. };
  1007. const upHanlder = (e) => {
  1008. if (!mouseDownOutside)
  1009. return;
  1010. if (el.contains(getEventTarget(e)))
  1011. return;
  1012. originalHandler(e);
  1013. };
  1014. return {
  1015. mousedown: downHandler,
  1016. mouseup: upHanlder,
  1017. touchstart: downHandler,
  1018. touchend: upHanlder
  1019. };
  1020. }
  1021. console.error(
  1022. // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
  1023. `[evtd/create-trap-handler]: name \`${name}\` is invalid. This could be a bug of evtd.`
  1024. );
  1025. return {};
  1026. }
  1027. function ensureTrapHandlers(name, el, handler) {
  1028. const handlers = traps[name];
  1029. let elHandlers = handlers.get(el);
  1030. if (elHandlers === void 0) {
  1031. handlers.set(el, elHandlers = /* @__PURE__ */ new WeakMap());
  1032. }
  1033. let trapHandler = elHandlers.get(handler);
  1034. if (trapHandler === void 0) {
  1035. elHandlers.set(handler, trapHandler = createTrapHandler(name, el, handler));
  1036. }
  1037. return trapHandler;
  1038. }
  1039. function trapOn(name, el, handler, options) {
  1040. if (name === "mousemoveoutside" || name === "clickoutside") {
  1041. const trapHandlers = ensureTrapHandlers(name, el, handler);
  1042. Object.keys(trapHandlers).forEach((key) => {
  1043. on(key, document, trapHandlers[key], options);
  1044. });
  1045. return true;
  1046. }
  1047. return false;
  1048. }
  1049. function trapOff(name, el, handler, options) {
  1050. if (name === "mousemoveoutside" || name === "clickoutside") {
  1051. const trapHandlers = ensureTrapHandlers(name, el, handler);
  1052. Object.keys(trapHandlers).forEach((key) => {
  1053. off(key, document, trapHandlers[key], options);
  1054. });
  1055. return true;
  1056. }
  1057. return false;
  1058. }
  1059. function createDelegate() {
  1060. if (typeof window === "undefined") {
  1061. return {
  1062. on: () => {
  1063. },
  1064. off: () => {
  1065. }
  1066. };
  1067. }
  1068. const propagationStopped = /* @__PURE__ */ new WeakMap();
  1069. const immediatePropagationStopped = /* @__PURE__ */ new WeakMap();
  1070. function trackPropagation() {
  1071. propagationStopped.set(this, true);
  1072. }
  1073. function trackImmediate() {
  1074. propagationStopped.set(this, true);
  1075. immediatePropagationStopped.set(this, true);
  1076. }
  1077. function spy(event, propName, fn) {
  1078. const source = event[propName];
  1079. event[propName] = function() {
  1080. fn.apply(event, arguments);
  1081. return source.apply(event, arguments);
  1082. };
  1083. return event;
  1084. }
  1085. function unspy(event, propName) {
  1086. event[propName] = Event.prototype[propName];
  1087. }
  1088. const currentTargets = /* @__PURE__ */ new WeakMap();
  1089. const currentTargetDescriptor = Object.getOwnPropertyDescriptor(Event.prototype, "currentTarget");
  1090. function getCurrentTarget() {
  1091. var _a;
  1092. return (_a = currentTargets.get(this)) !== null && _a !== void 0 ? _a : null;
  1093. }
  1094. function defineCurrentTarget(event, getter) {
  1095. if (currentTargetDescriptor === void 0)
  1096. return;
  1097. Object.defineProperty(event, "currentTarget", {
  1098. configurable: true,
  1099. enumerable: true,
  1100. get: getter !== null && getter !== void 0 ? getter : currentTargetDescriptor.get
  1101. });
  1102. }
  1103. const phaseToTypeToElToHandlers = {
  1104. bubble: {},
  1105. capture: {}
  1106. };
  1107. const typeToWindowEventHandlers = {};
  1108. function createUnifiedHandler() {
  1109. const delegeteHandler = function(e) {
  1110. const { type, eventPhase, bubbles } = e;
  1111. const target = getEventTarget(e);
  1112. if (eventPhase === 2)
  1113. return;
  1114. const phase = eventPhase === 1 ? "capture" : "bubble";
  1115. let cursor = target;
  1116. const path = [];
  1117. while (true) {
  1118. if (cursor === null)
  1119. cursor = window;
  1120. path.push(cursor);
  1121. if (cursor === window) {
  1122. break;
  1123. }
  1124. cursor = cursor.parentNode || null;
  1125. }
  1126. const captureElToHandlers = phaseToTypeToElToHandlers.capture[type];
  1127. const bubbleElToHandlers = phaseToTypeToElToHandlers.bubble[type];
  1128. spy(e, "stopPropagation", trackPropagation);
  1129. spy(e, "stopImmediatePropagation", trackImmediate);
  1130. defineCurrentTarget(e, getCurrentTarget);
  1131. if (phase === "capture") {
  1132. if (captureElToHandlers === void 0)
  1133. return;
  1134. for (let i = path.length - 1; i >= 0; --i) {
  1135. if (propagationStopped.has(e))
  1136. break;
  1137. const target2 = path[i];
  1138. const handlers = captureElToHandlers.get(target2);
  1139. if (handlers !== void 0) {
  1140. currentTargets.set(e, target2);
  1141. for (const handler of handlers) {
  1142. if (immediatePropagationStopped.has(e))
  1143. break;
  1144. handler(e);
  1145. }
  1146. }
  1147. if (i === 0 && !bubbles && bubbleElToHandlers !== void 0) {
  1148. const bubbleHandlers = bubbleElToHandlers.get(target2);
  1149. if (bubbleHandlers !== void 0) {
  1150. for (const handler of bubbleHandlers) {
  1151. if (immediatePropagationStopped.has(e))
  1152. break;
  1153. handler(e);
  1154. }
  1155. }
  1156. }
  1157. }
  1158. } else if (phase === "bubble") {
  1159. if (bubbleElToHandlers === void 0)
  1160. return;
  1161. for (let i = 0; i < path.length; ++i) {
  1162. if (propagationStopped.has(e))
  1163. break;
  1164. const target2 = path[i];
  1165. const handlers = bubbleElToHandlers.get(target2);
  1166. if (handlers !== void 0) {
  1167. currentTargets.set(e, target2);
  1168. for (const handler of handlers) {
  1169. if (immediatePropagationStopped.has(e))
  1170. break;
  1171. handler(e);
  1172. }
  1173. }
  1174. }
  1175. }
  1176. unspy(e, "stopPropagation");
  1177. unspy(e, "stopImmediatePropagation");
  1178. defineCurrentTarget(e);
  1179. };
  1180. delegeteHandler.displayName = "evtdUnifiedHandler";
  1181. return delegeteHandler;
  1182. }
  1183. function createUnifiedWindowEventHandler() {
  1184. const delegateHandler = function(e) {
  1185. const { type, eventPhase } = e;
  1186. if (eventPhase !== 2)
  1187. return;
  1188. const handlers = typeToWindowEventHandlers[type];
  1189. if (handlers === void 0)
  1190. return;
  1191. handlers.forEach((handler) => handler(e));
  1192. };
  1193. delegateHandler.displayName = "evtdUnifiedWindowEventHandler";
  1194. return delegateHandler;
  1195. }
  1196. const unifiedHandler = createUnifiedHandler();
  1197. const unfiendWindowEventHandler = createUnifiedWindowEventHandler();
  1198. function ensureElToHandlers(phase, type) {
  1199. const phaseHandlers = phaseToTypeToElToHandlers[phase];
  1200. if (phaseHandlers[type] === void 0) {
  1201. phaseHandlers[type] = /* @__PURE__ */ new Map();
  1202. window.addEventListener(type, unifiedHandler, phase === "capture");
  1203. }
  1204. return phaseHandlers[type];
  1205. }
  1206. function ensureWindowEventHandlers(type) {
  1207. const windowEventHandlers = typeToWindowEventHandlers[type];
  1208. if (windowEventHandlers === void 0) {
  1209. typeToWindowEventHandlers[type] = /* @__PURE__ */ new Set();
  1210. window.addEventListener(type, unfiendWindowEventHandler);
  1211. }
  1212. return typeToWindowEventHandlers[type];
  1213. }
  1214. function ensureHandlers(elToHandlers, el) {
  1215. let elHandlers = elToHandlers.get(el);
  1216. if (elHandlers === void 0) {
  1217. elToHandlers.set(el, elHandlers = /* @__PURE__ */ new Set());
  1218. }
  1219. return elHandlers;
  1220. }
  1221. function handlerExist(el, phase, type, handler) {
  1222. const elToHandlers = phaseToTypeToElToHandlers[phase][type];
  1223. if (elToHandlers !== void 0) {
  1224. const handlers = elToHandlers.get(el);
  1225. if (handlers !== void 0) {
  1226. if (handlers.has(handler))
  1227. return true;
  1228. }
  1229. }
  1230. return false;
  1231. }
  1232. function windowEventHandlerExist(type, handler) {
  1233. const handlers = typeToWindowEventHandlers[type];
  1234. if (handlers !== void 0) {
  1235. if (handlers.has(handler)) {
  1236. return true;
  1237. }
  1238. }
  1239. return false;
  1240. }
  1241. function on2(type, el, handler, options) {
  1242. let mergedHandler;
  1243. if (typeof options === "object" && options.once === true) {
  1244. mergedHandler = (e) => {
  1245. off2(type, el, mergedHandler, options);
  1246. handler(e);
  1247. };
  1248. } else {
  1249. mergedHandler = handler;
  1250. }
  1251. const trapped = trapOn(type, el, mergedHandler, options);
  1252. if (trapped)
  1253. return;
  1254. const phase = options === true || typeof options === "object" && options.capture === true ? "capture" : "bubble";
  1255. const elToHandlers = ensureElToHandlers(phase, type);
  1256. const handlers = ensureHandlers(elToHandlers, el);
  1257. if (!handlers.has(mergedHandler))
  1258. handlers.add(mergedHandler);
  1259. if (el === window) {
  1260. const windowEventHandlers = ensureWindowEventHandlers(type);
  1261. if (!windowEventHandlers.has(mergedHandler)) {
  1262. windowEventHandlers.add(mergedHandler);
  1263. }
  1264. }
  1265. }
  1266. function off2(type, el, handler, options) {
  1267. const trapped = trapOff(type, el, handler, options);
  1268. if (trapped)
  1269. return;
  1270. const capture = options === true || typeof options === "object" && options.capture === true;
  1271. const phase = capture ? "capture" : "bubble";
  1272. const elToHandlers = ensureElToHandlers(phase, type);
  1273. const handlers = ensureHandlers(elToHandlers, el);
  1274. if (el === window) {
  1275. const mirrorPhase = capture ? "bubble" : "capture";
  1276. if (!handlerExist(el, mirrorPhase, type, handler) && windowEventHandlerExist(type, handler)) {
  1277. const windowEventHandlers = typeToWindowEventHandlers[type];
  1278. windowEventHandlers.delete(handler);
  1279. if (windowEventHandlers.size === 0) {
  1280. window.removeEventListener(type, unfiendWindowEventHandler);
  1281. typeToWindowEventHandlers[type] = void 0;
  1282. }
  1283. }
  1284. }
  1285. if (handlers.has(handler))
  1286. handlers.delete(handler);
  1287. if (handlers.size === 0) {
  1288. elToHandlers.delete(el);
  1289. }
  1290. if (elToHandlers.size === 0) {
  1291. window.removeEventListener(type, unifiedHandler, phase === "capture");
  1292. phaseToTypeToElToHandlers[phase][type] = void 0;
  1293. }
  1294. }
  1295. return {
  1296. on: on2,
  1297. off: off2
  1298. };
  1299. }
  1300. const { on, off } = createDelegate();
  1301. function useMergedState(controlledStateRef, uncontrolledStateRef) {
  1302. vue.watch(controlledStateRef, (value) => {
  1303. if (value !== void 0) {
  1304. uncontrolledStateRef.value = value;
  1305. }
  1306. });
  1307. return vue.computed(() => {
  1308. if (controlledStateRef.value === void 0) {
  1309. return uncontrolledStateRef.value;
  1310. }
  1311. return controlledStateRef.value;
  1312. });
  1313. }
  1314. function isMounted() {
  1315. const isMounted2 = vue.ref(false);
  1316. vue.onMounted(() => {
  1317. isMounted2.value = true;
  1318. });
  1319. return vue.readonly(isMounted2);
  1320. }
  1321. function useCompitable(reactive2, keys2) {
  1322. return vue.computed(() => {
  1323. for (const key of keys2) {
  1324. if (reactive2[key] !== void 0)
  1325. return reactive2[key];
  1326. }
  1327. return reactive2[keys2[keys2.length - 1]];
  1328. });
  1329. }
  1330. const isIos = (typeof window === "undefined" ? false : /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
  1331. !window.MSStream;
  1332. function useIsIos() {
  1333. return isIos;
  1334. }
  1335. function useKeyboard(options = {}, enabledRef) {
  1336. const state = vue.reactive({
  1337. ctrl: false,
  1338. command: false,
  1339. win: false,
  1340. shift: false,
  1341. tab: false
  1342. });
  1343. const { keydown, keyup } = options;
  1344. const keydownHandler = (e) => {
  1345. switch (e.key) {
  1346. case "Control":
  1347. state.ctrl = true;
  1348. break;
  1349. case "Meta":
  1350. state.command = true;
  1351. state.win = true;
  1352. break;
  1353. case "Shift":
  1354. state.shift = true;
  1355. break;
  1356. case "Tab":
  1357. state.tab = true;
  1358. break;
  1359. }
  1360. if (keydown !== void 0) {
  1361. Object.keys(keydown).forEach((key) => {
  1362. if (key !== e.key)
  1363. return;
  1364. const handler = keydown[key];
  1365. if (typeof handler === "function") {
  1366. handler(e);
  1367. } else {
  1368. const { stop = false, prevent = false } = handler;
  1369. if (stop)
  1370. e.stopPropagation();
  1371. if (prevent)
  1372. e.preventDefault();
  1373. handler.handler(e);
  1374. }
  1375. });
  1376. }
  1377. };
  1378. const keyupHandler = (e) => {
  1379. switch (e.key) {
  1380. case "Control":
  1381. state.ctrl = false;
  1382. break;
  1383. case "Meta":
  1384. state.command = false;
  1385. state.win = false;
  1386. break;
  1387. case "Shift":
  1388. state.shift = false;
  1389. break;
  1390. case "Tab":
  1391. state.tab = false;
  1392. break;
  1393. }
  1394. if (keyup !== void 0) {
  1395. Object.keys(keyup).forEach((key) => {
  1396. if (key !== e.key)
  1397. return;
  1398. const handler = keyup[key];
  1399. if (typeof handler === "function") {
  1400. handler(e);
  1401. } else {
  1402. const { stop = false, prevent = false } = handler;
  1403. if (stop)
  1404. e.stopPropagation();
  1405. if (prevent)
  1406. e.preventDefault();
  1407. handler.handler(e);
  1408. }
  1409. });
  1410. }
  1411. };
  1412. const setup = () => {
  1413. if (enabledRef === void 0 || enabledRef.value) {
  1414. on("keydown", document, keydownHandler);
  1415. on("keyup", document, keyupHandler);
  1416. }
  1417. if (enabledRef !== void 0) {
  1418. vue.watch(enabledRef, (value) => {
  1419. if (value) {
  1420. on("keydown", document, keydownHandler);
  1421. on("keyup", document, keyupHandler);
  1422. } else {
  1423. off("keydown", document, keydownHandler);
  1424. off("keyup", document, keyupHandler);
  1425. }
  1426. });
  1427. }
  1428. };
  1429. if (hasInstance()) {
  1430. vue.onBeforeMount(setup);
  1431. vue.onBeforeUnmount(() => {
  1432. if (enabledRef === void 0 || enabledRef.value) {
  1433. off("keydown", document, keydownHandler);
  1434. off("keyup", document, keyupHandler);
  1435. }
  1436. });
  1437. } else {
  1438. setup();
  1439. }
  1440. return vue.readonly(state);
  1441. }
  1442. const internalSelectionMenuBodyInjectionKey = createInjectionKey("n-internal-select-menu-body");
  1443. const modalBodyInjectionKey = createInjectionKey("n-modal-body");
  1444. const drawerBodyInjectionKey = createInjectionKey("n-drawer-body");
  1445. const popoverBodyInjectionKey = createInjectionKey("n-popover-body");
  1446. const teleportDisabled = "__disabled__";
  1447. function useAdjustedTo(props) {
  1448. const modal = vue.inject(modalBodyInjectionKey, null);
  1449. const drawer = vue.inject(drawerBodyInjectionKey, null);
  1450. const popover = vue.inject(popoverBodyInjectionKey, null);
  1451. const selectMenu = vue.inject(internalSelectionMenuBodyInjectionKey, null);
  1452. const fullscreenElementRef = vue.ref();
  1453. if (typeof document !== "undefined") {
  1454. fullscreenElementRef.value = document.fullscreenElement;
  1455. const handleFullscreenChange = () => {
  1456. fullscreenElementRef.value = document.fullscreenElement;
  1457. };
  1458. vue.onMounted(() => {
  1459. on("fullscreenchange", document, handleFullscreenChange);
  1460. });
  1461. vue.onBeforeUnmount(() => {
  1462. off("fullscreenchange", document, handleFullscreenChange);
  1463. });
  1464. }
  1465. return useMemo(() => {
  1466. var _a;
  1467. const {
  1468. to
  1469. } = props;
  1470. if (to !== void 0) {
  1471. if (to === false)
  1472. return teleportDisabled;
  1473. if (to === true)
  1474. return fullscreenElementRef.value || "body";
  1475. return to;
  1476. }
  1477. if (modal === null || modal === void 0 ? void 0 : modal.value) {
  1478. return (_a = modal.value.$el) !== null && _a !== void 0 ? _a : modal.value;
  1479. }
  1480. if (drawer === null || drawer === void 0 ? void 0 : drawer.value)
  1481. return drawer.value;
  1482. if (popover === null || popover === void 0 ? void 0 : popover.value)
  1483. return popover.value;
  1484. if (selectMenu === null || selectMenu === void 0 ? void 0 : selectMenu.value)
  1485. return selectMenu.value;
  1486. return to !== null && to !== void 0 ? to : fullscreenElementRef.value || "body";
  1487. });
  1488. }
  1489. useAdjustedTo.tdkey = teleportDisabled;
  1490. useAdjustedTo.propTo = {
  1491. type: [String, Object, Boolean],
  1492. default: void 0
  1493. };
  1494. function getSlot(scope, slots, slotName = "default") {
  1495. const slot = slots[slotName];
  1496. if (slot === void 0) {
  1497. throw new Error(`[vueuc/${scope}]: slot[${slotName}] is empty.`);
  1498. }
  1499. return slot();
  1500. }
  1501. function flatten$1(vNodes, filterCommentNode = true, result = []) {
  1502. vNodes.forEach((vNode) => {
  1503. if (vNode === null)
  1504. return;
  1505. if (typeof vNode !== "object") {
  1506. if (typeof vNode === "string" || typeof vNode === "number") {
  1507. result.push(vue.createTextVNode(String(vNode)));
  1508. }
  1509. return;
  1510. }
  1511. if (Array.isArray(vNode)) {
  1512. flatten$1(vNode, filterCommentNode, result);
  1513. return;
  1514. }
  1515. if (vNode.type === vue.Fragment) {
  1516. if (vNode.children === null)
  1517. return;
  1518. if (Array.isArray(vNode.children)) {
  1519. flatten$1(vNode.children, filterCommentNode, result);
  1520. }
  1521. } else if (vNode.type !== vue.Comment) {
  1522. result.push(vNode);
  1523. }
  1524. });
  1525. return result;
  1526. }
  1527. function getFirstVNode(scope, slots, slotName = "default") {
  1528. const slot = slots[slotName];
  1529. if (slot === void 0) {
  1530. throw new Error(`[vueuc/${scope}]: slot[${slotName}] is empty.`);
  1531. }
  1532. const content = flatten$1(slot());
  1533. if (content.length === 1) {
  1534. return content[0];
  1535. } else {
  1536. throw new Error(`[vueuc/${scope}]: slot[${slotName}] should have exactly one child.`);
  1537. }
  1538. }
  1539. let viewMeasurer = null;
  1540. function ensureViewBoundingRect() {
  1541. if (viewMeasurer === null) {
  1542. viewMeasurer = document.getElementById("v-binder-view-measurer");
  1543. if (viewMeasurer === null) {
  1544. viewMeasurer = document.createElement("div");
  1545. viewMeasurer.id = "v-binder-view-measurer";
  1546. const { style: style2 } = viewMeasurer;
  1547. style2.position = "fixed";
  1548. style2.left = "0";
  1549. style2.right = "0";
  1550. style2.top = "0";
  1551. style2.bottom = "0";
  1552. style2.pointerEvents = "none";
  1553. style2.visibility = "hidden";
  1554. document.body.appendChild(viewMeasurer);
  1555. }
  1556. }
  1557. return viewMeasurer.getBoundingClientRect();
  1558. }
  1559. function getPointRect(x, y) {
  1560. const viewRect = ensureViewBoundingRect();
  1561. return {
  1562. top: y,
  1563. left: x,
  1564. height: 0,
  1565. width: 0,
  1566. right: viewRect.width - x,
  1567. bottom: viewRect.height - y
  1568. };
  1569. }
  1570. function getRect(el) {
  1571. const elRect = el.getBoundingClientRect();
  1572. const viewRect = ensureViewBoundingRect();
  1573. return {
  1574. left: elRect.left - viewRect.left,
  1575. top: elRect.top - viewRect.top,
  1576. bottom: viewRect.height + viewRect.top - elRect.bottom,
  1577. right: viewRect.width + viewRect.left - elRect.right,
  1578. width: elRect.width,
  1579. height: elRect.height
  1580. };
  1581. }
  1582. function getParentNode(node) {
  1583. if (node.nodeType === 9) {
  1584. return null;
  1585. }
  1586. return node.parentNode;
  1587. }
  1588. function getScrollParent(node) {
  1589. if (node === null)
  1590. return null;
  1591. const parentNode = getParentNode(node);
  1592. if (parentNode === null) {
  1593. return null;
  1594. }
  1595. if (parentNode.nodeType === 9) {
  1596. return document;
  1597. }
  1598. if (parentNode.nodeType === 1) {
  1599. const { overflow, overflowX, overflowY } = getComputedStyle(parentNode);
  1600. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  1601. return parentNode;
  1602. }
  1603. }
  1604. return getScrollParent(parentNode);
  1605. }
  1606. const Binder = vue.defineComponent({
  1607. name: "Binder",
  1608. props: {
  1609. syncTargetWithParent: Boolean,
  1610. syncTarget: {
  1611. type: Boolean,
  1612. default: true
  1613. }
  1614. },
  1615. setup(props) {
  1616. var _a;
  1617. vue.provide("VBinder", (_a = vue.getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy);
  1618. const VBinder = vue.inject("VBinder", null);
  1619. const targetRef = vue.ref(null);
  1620. const setTargetRef = (el) => {
  1621. targetRef.value = el;
  1622. if (VBinder && props.syncTargetWithParent) {
  1623. VBinder.setTargetRef(el);
  1624. }
  1625. };
  1626. let scrollableNodes = [];
  1627. const ensureScrollListener = () => {
  1628. let cursor = targetRef.value;
  1629. while (true) {
  1630. cursor = getScrollParent(cursor);
  1631. if (cursor === null)
  1632. break;
  1633. scrollableNodes.push(cursor);
  1634. }
  1635. for (const el of scrollableNodes) {
  1636. on("scroll", el, onScroll, true);
  1637. }
  1638. };
  1639. const removeScrollListeners = () => {
  1640. for (const el of scrollableNodes) {
  1641. off("scroll", el, onScroll, true);
  1642. }
  1643. scrollableNodes = [];
  1644. };
  1645. const followerScrollListeners = /* @__PURE__ */ new Set();
  1646. const addScrollListener = (listener) => {
  1647. if (followerScrollListeners.size === 0) {
  1648. ensureScrollListener();
  1649. }
  1650. if (!followerScrollListeners.has(listener)) {
  1651. followerScrollListeners.add(listener);
  1652. }
  1653. };
  1654. const removeScrollListener = (listener) => {
  1655. if (followerScrollListeners.has(listener)) {
  1656. followerScrollListeners.delete(listener);
  1657. }
  1658. if (followerScrollListeners.size === 0) {
  1659. removeScrollListeners();
  1660. }
  1661. };
  1662. const onScroll = () => {
  1663. beforeNextFrameOnce(onScrollRaf);
  1664. };
  1665. const onScrollRaf = () => {
  1666. followerScrollListeners.forEach((listener) => listener());
  1667. };
  1668. const followerResizeListeners = /* @__PURE__ */ new Set();
  1669. const addResizeListener = (listener) => {
  1670. if (followerResizeListeners.size === 0) {
  1671. on("resize", window, onResize);
  1672. }
  1673. if (!followerResizeListeners.has(listener)) {
  1674. followerResizeListeners.add(listener);
  1675. }
  1676. };
  1677. const removeResizeListener = (listener) => {
  1678. if (followerResizeListeners.has(listener)) {
  1679. followerResizeListeners.delete(listener);
  1680. }
  1681. if (followerResizeListeners.size === 0) {
  1682. off("resize", window, onResize);
  1683. }
  1684. };
  1685. const onResize = () => {
  1686. followerResizeListeners.forEach((listener) => listener());
  1687. };
  1688. vue.onBeforeUnmount(() => {
  1689. off("resize", window, onResize);
  1690. removeScrollListeners();
  1691. });
  1692. return {
  1693. targetRef,
  1694. setTargetRef,
  1695. addScrollListener,
  1696. removeScrollListener,
  1697. addResizeListener,
  1698. removeResizeListener
  1699. };
  1700. },
  1701. render() {
  1702. return getSlot("binder", this.$slots);
  1703. }
  1704. });
  1705. const VTarget = vue.defineComponent({
  1706. name: "Target",
  1707. setup() {
  1708. const { setTargetRef, syncTarget } = vue.inject("VBinder");
  1709. const setTargetDirective = {
  1710. mounted: setTargetRef,
  1711. updated: setTargetRef
  1712. };
  1713. return {
  1714. syncTarget,
  1715. setTargetDirective
  1716. };
  1717. },
  1718. render() {
  1719. const { syncTarget, setTargetDirective } = this;
  1720. if (syncTarget) {
  1721. return vue.withDirectives(getFirstVNode("follower", this.$slots), [
  1722. [setTargetDirective]
  1723. ]);
  1724. }
  1725. return getFirstVNode("follower", this.$slots);
  1726. }
  1727. });
  1728. const ctxKey$1 = "@@mmoContext";
  1729. const mousemoveoutside = {
  1730. mounted(el, { value }) {
  1731. el[ctxKey$1] = {
  1732. handler: void 0
  1733. };
  1734. if (typeof value === "function") {
  1735. el[ctxKey$1].handler = value;
  1736. on("mousemoveoutside", el, value);
  1737. }
  1738. },
  1739. updated(el, { value }) {
  1740. const ctx2 = el[ctxKey$1];
  1741. if (typeof value === "function") {
  1742. if (ctx2.handler) {
  1743. if (ctx2.handler !== value) {
  1744. off("mousemoveoutside", el, ctx2.handler);
  1745. ctx2.handler = value;
  1746. on("mousemoveoutside", el, value);
  1747. }
  1748. } else {
  1749. el[ctxKey$1].handler = value;
  1750. on("mousemoveoutside", el, value);
  1751. }
  1752. } else {
  1753. if (ctx2.handler) {
  1754. off("mousemoveoutside", el, ctx2.handler);
  1755. ctx2.handler = void 0;
  1756. }
  1757. }
  1758. },
  1759. unmounted(el) {
  1760. const { handler } = el[ctxKey$1];
  1761. if (handler) {
  1762. off("mousemoveoutside", el, handler);
  1763. }
  1764. el[ctxKey$1].handler = void 0;
  1765. }
  1766. };
  1767. const ctxKey = "@@coContext";
  1768. const clickoutside = {
  1769. mounted(el, { value, modifiers }) {
  1770. el[ctxKey] = {
  1771. handler: void 0
  1772. };
  1773. if (typeof value === "function") {
  1774. el[ctxKey].handler = value;
  1775. on("clickoutside", el, value, {
  1776. capture: modifiers.capture
  1777. });
  1778. }
  1779. },
  1780. updated(el, { value, modifiers }) {
  1781. const ctx2 = el[ctxKey];
  1782. if (typeof value === "function") {
  1783. if (ctx2.handler) {
  1784. if (ctx2.handler !== value) {
  1785. off("clickoutside", el, ctx2.handler, {
  1786. capture: modifiers.capture
  1787. });
  1788. ctx2.handler = value;
  1789. on("clickoutside", el, value, {
  1790. capture: modifiers.capture
  1791. });
  1792. }
  1793. } else {
  1794. el[ctxKey].handler = value;
  1795. on("clickoutside", el, value, {
  1796. capture: modifiers.capture
  1797. });
  1798. }
  1799. } else {
  1800. if (ctx2.handler) {
  1801. off("clickoutside", el, ctx2.handler, {
  1802. capture: modifiers.capture
  1803. });
  1804. ctx2.handler = void 0;
  1805. }
  1806. }
  1807. },
  1808. unmounted(el, { modifiers }) {
  1809. const { handler } = el[ctxKey];
  1810. if (handler) {
  1811. off("clickoutside", el, handler, {
  1812. capture: modifiers.capture
  1813. });
  1814. }
  1815. el[ctxKey].handler = void 0;
  1816. }
  1817. };
  1818. function warn$1(location, message) {
  1819. console.error(`[vdirs/${location}]: ${message}`);
  1820. }
  1821. class ZIndexManager {
  1822. constructor() {
  1823. this.elementZIndex = /* @__PURE__ */ new Map();
  1824. this.nextZIndex = 2e3;
  1825. }
  1826. get elementCount() {
  1827. return this.elementZIndex.size;
  1828. }
  1829. ensureZIndex(el, zIndex) {
  1830. const { elementZIndex } = this;
  1831. if (zIndex !== void 0) {
  1832. el.style.zIndex = `${zIndex}`;
  1833. elementZIndex.delete(el);
  1834. return;
  1835. }
  1836. const { nextZIndex } = this;
  1837. if (elementZIndex.has(el)) {
  1838. const currentZIndex = elementZIndex.get(el);
  1839. if (currentZIndex + 1 === this.nextZIndex)
  1840. return;
  1841. }
  1842. el.style.zIndex = `${nextZIndex}`;
  1843. elementZIndex.set(el, nextZIndex);
  1844. this.nextZIndex = nextZIndex + 1;
  1845. this.squashState();
  1846. }
  1847. unregister(el, zIndex) {
  1848. const { elementZIndex } = this;
  1849. if (elementZIndex.has(el)) {
  1850. elementZIndex.delete(el);
  1851. } else if (zIndex === void 0) {
  1852. warn$1("z-index-manager/unregister-element", "Element not found when unregistering.");
  1853. }
  1854. this.squashState();
  1855. }
  1856. squashState() {
  1857. const { elementCount } = this;
  1858. if (!elementCount) {
  1859. this.nextZIndex = 2e3;
  1860. }
  1861. if (this.nextZIndex - elementCount > 2500)
  1862. this.rearrange();
  1863. }
  1864. rearrange() {
  1865. const elementZIndexPair = Array.from(this.elementZIndex.entries());
  1866. elementZIndexPair.sort((pair1, pair2) => {
  1867. return pair1[1] - pair2[1];
  1868. });
  1869. this.nextZIndex = 2e3;
  1870. elementZIndexPair.forEach((pair) => {
  1871. const el = pair[0];
  1872. const zIndex = this.nextZIndex++;
  1873. if (`${zIndex}` !== el.style.zIndex)
  1874. el.style.zIndex = `${zIndex}`;
  1875. });
  1876. }
  1877. }
  1878. const zIndexManager = new ZIndexManager();
  1879. const ctx = "@@ziContext";
  1880. const zindexable = {
  1881. mounted(el, bindings) {
  1882. const { value = {} } = bindings;
  1883. const { zIndex, enabled } = value;
  1884. el[ctx] = {
  1885. enabled: !!enabled,
  1886. initialized: false
  1887. };
  1888. if (enabled) {
  1889. zIndexManager.ensureZIndex(el, zIndex);
  1890. el[ctx].initialized = true;
  1891. }
  1892. },
  1893. updated(el, bindings) {
  1894. const { value = {} } = bindings;
  1895. const { zIndex, enabled } = value;
  1896. const cachedEnabled = el[ctx].enabled;
  1897. if (enabled && !cachedEnabled) {
  1898. zIndexManager.ensureZIndex(el, zIndex);
  1899. el[ctx].initialized = true;
  1900. }
  1901. el[ctx].enabled = !!enabled;
  1902. },
  1903. unmounted(el, bindings) {
  1904. if (!el[ctx].initialized)
  1905. return;
  1906. const { value = {} } = bindings;
  1907. const { zIndex } = value;
  1908. zIndexManager.unregister(el, zIndex);
  1909. }
  1910. };
  1911. const ssrContextKey = "@css-render/vue3-ssr";
  1912. function createStyleString(id, style2) {
  1913. return `<style cssr-id="${id}">
  1914. ${style2}
  1915. </style>`;
  1916. }
  1917. function ssrAdapter(id, style2, ssrContext) {
  1918. const { styles, ids } = ssrContext;
  1919. if (ids.has(id))
  1920. return;
  1921. if (styles !== null) {
  1922. ids.add(id);
  1923. styles.push(createStyleString(id, style2));
  1924. }
  1925. }
  1926. const isBrowser = typeof document !== "undefined";
  1927. function useSsrAdapter() {
  1928. if (isBrowser)
  1929. return void 0;
  1930. const context = vue.inject(ssrContextKey, null);
  1931. if (context === null)
  1932. return void 0;
  1933. return {
  1934. adapter: (id, style2) => ssrAdapter(id, style2, context),
  1935. context
  1936. };
  1937. }
  1938. function warn(location, message) {
  1939. console.error(`[vueuc/${location}]: ${message}`);
  1940. }
  1941. const { c } = CssRender();
  1942. const cssrAnchorMetaName$1 = "vueuc-style";
  1943. function resolveTo(selector) {
  1944. if (typeof selector === "string") {
  1945. return document.querySelector(selector);
  1946. }
  1947. return selector();
  1948. }
  1949. const LazyTeleport = vue.defineComponent({
  1950. name: "LazyTeleport",
  1951. props: {
  1952. to: {
  1953. type: [String, Object],
  1954. default: void 0
  1955. },
  1956. disabled: Boolean,
  1957. show: {
  1958. type: Boolean,
  1959. required: true
  1960. }
  1961. },
  1962. setup(props) {
  1963. return {
  1964. showTeleport: useFalseUntilTruthy(vue.toRef(props, "show")),
  1965. mergedTo: vue.computed(() => {
  1966. const { to } = props;
  1967. return to !== null && to !== void 0 ? to : "body";
  1968. })
  1969. };
  1970. },
  1971. render() {
  1972. return this.showTeleport ? this.disabled ? getSlot("lazy-teleport", this.$slots) : vue.h(vue.Teleport, {
  1973. disabled: this.disabled,
  1974. to: this.mergedTo
  1975. }, getSlot("lazy-teleport", this.$slots)) : null;
  1976. }
  1977. });
  1978. const oppositionPositions = {
  1979. top: "bottom",
  1980. bottom: "top",
  1981. left: "right",
  1982. right: "left"
  1983. };
  1984. const oppositeAligns = {
  1985. start: "end",
  1986. center: "center",
  1987. end: "start"
  1988. };
  1989. const propToCompare = {
  1990. top: "height",
  1991. bottom: "height",
  1992. left: "width",
  1993. right: "width"
  1994. };
  1995. const transformOrigins = {
  1996. "bottom-start": "top left",
  1997. bottom: "top center",
  1998. "bottom-end": "top right",
  1999. "top-start": "bottom left",
  2000. top: "bottom center",
  2001. "top-end": "bottom right",
  2002. "right-start": "top left",
  2003. right: "center left",
  2004. "right-end": "bottom left",
  2005. "left-start": "top right",
  2006. left: "center right",
  2007. "left-end": "bottom right"
  2008. };
  2009. const overlapTransformOrigin = {
  2010. "bottom-start": "bottom left",
  2011. bottom: "bottom center",
  2012. "bottom-end": "bottom right",
  2013. "top-start": "top left",
  2014. top: "top center",
  2015. "top-end": "top right",
  2016. "right-start": "top right",
  2017. right: "center right",
  2018. "right-end": "bottom right",
  2019. "left-start": "top left",
  2020. left: "center left",
  2021. "left-end": "bottom left"
  2022. };
  2023. const oppositeAlignCssPositionProps = {
  2024. "bottom-start": "right",
  2025. "bottom-end": "left",
  2026. "top-start": "right",
  2027. "top-end": "left",
  2028. "right-start": "bottom",
  2029. "right-end": "top",
  2030. "left-start": "bottom",
  2031. "left-end": "top"
  2032. };
  2033. const keepOffsetDirection = {
  2034. top: true,
  2035. bottom: false,
  2036. left: true,
  2037. right: false
  2038. // left--
  2039. };
  2040. const cssPositionToOppositeAlign = {
  2041. top: "end",
  2042. bottom: "start",
  2043. left: "end",
  2044. right: "start"
  2045. };
  2046. function getPlacementAndOffsetOfFollower(placement, targetRect, followerRect, shift, flip, overlap) {
  2047. if (!flip || overlap) {
  2048. return { placement, top: 0, left: 0 };
  2049. }
  2050. const [position, align] = placement.split("-");
  2051. let properAlign = align !== null && align !== void 0 ? align : "center";
  2052. let properOffset = {
  2053. top: 0,
  2054. left: 0
  2055. };
  2056. const deriveOffset = (oppositeAlignCssSizeProp, alignCssPositionProp, offsetVertically2) => {
  2057. let left = 0;
  2058. let top = 0;
  2059. const diff = followerRect[oppositeAlignCssSizeProp] - targetRect[alignCssPositionProp] - targetRect[oppositeAlignCssSizeProp];
  2060. if (diff > 0 && shift) {
  2061. if (offsetVertically2) {
  2062. top = keepOffsetDirection[alignCssPositionProp] ? diff : -diff;
  2063. } else {
  2064. left = keepOffsetDirection[alignCssPositionProp] ? diff : -diff;
  2065. }
  2066. }
  2067. return {
  2068. left,
  2069. top
  2070. };
  2071. };
  2072. const offsetVertically = position === "left" || position === "right";
  2073. if (properAlign !== "center") {
  2074. const oppositeAlignCssPositionProp = oppositeAlignCssPositionProps[placement];
  2075. const currentAlignCssPositionProp = oppositionPositions[oppositeAlignCssPositionProp];
  2076. const oppositeAlignCssSizeProp = propToCompare[oppositeAlignCssPositionProp];
  2077. if (followerRect[oppositeAlignCssSizeProp] > targetRect[oppositeAlignCssSizeProp]) {
  2078. if (
  2079. // current space is not enough
  2080. // ----------[ target ]---------|
  2081. // -------[ follower ]
  2082. targetRect[oppositeAlignCssPositionProp] + targetRect[oppositeAlignCssSizeProp] < followerRect[oppositeAlignCssSizeProp]
  2083. ) {
  2084. const followerOverTargetSize = (followerRect[oppositeAlignCssSizeProp] - targetRect[oppositeAlignCssSizeProp]) / 2;
  2085. if (targetRect[oppositeAlignCssPositionProp] < followerOverTargetSize || targetRect[currentAlignCssPositionProp] < followerOverTargetSize) {
  2086. if (targetRect[oppositeAlignCssPositionProp] < targetRect[currentAlignCssPositionProp]) {
  2087. properAlign = oppositeAligns[align];
  2088. properOffset = deriveOffset(oppositeAlignCssSizeProp, currentAlignCssPositionProp, offsetVertically);
  2089. } else {
  2090. properOffset = deriveOffset(oppositeAlignCssSizeProp, oppositeAlignCssPositionProp, offsetVertically);
  2091. }
  2092. } else {
  2093. properAlign = "center";
  2094. }
  2095. }
  2096. } else if (followerRect[oppositeAlignCssSizeProp] < targetRect[oppositeAlignCssSizeProp]) {
  2097. if (targetRect[currentAlignCssPositionProp] < 0 && // opposite align has larger space
  2098. // ------------[ target ]
  2099. // ----------------[follower]
  2100. targetRect[oppositeAlignCssPositionProp] > targetRect[currentAlignCssPositionProp]) {
  2101. properAlign = oppositeAligns[align];
  2102. }
  2103. }
  2104. } else {
  2105. const possibleAlternativeAlignCssPositionProp1 = position === "bottom" || position === "top" ? "left" : "top";
  2106. const possibleAlternativeAlignCssPositionProp2 = oppositionPositions[possibleAlternativeAlignCssPositionProp1];
  2107. const alternativeAlignCssSizeProp = propToCompare[possibleAlternativeAlignCssPositionProp1];
  2108. const followerOverTargetSize = (followerRect[alternativeAlignCssSizeProp] - targetRect[alternativeAlignCssSizeProp]) / 2;
  2109. if (
  2110. // center is not enough
  2111. // ----------- [ target ]--|
  2112. // -------[ follower ]
  2113. targetRect[possibleAlternativeAlignCssPositionProp1] < followerOverTargetSize || targetRect[possibleAlternativeAlignCssPositionProp2] < followerOverTargetSize
  2114. ) {
  2115. if (targetRect[possibleAlternativeAlignCssPositionProp1] > targetRect[possibleAlternativeAlignCssPositionProp2]) {
  2116. properAlign = cssPositionToOppositeAlign[possibleAlternativeAlignCssPositionProp1];
  2117. properOffset = deriveOffset(alternativeAlignCssSizeProp, possibleAlternativeAlignCssPositionProp1, offsetVertically);
  2118. } else {
  2119. properAlign = cssPositionToOppositeAlign[possibleAlternativeAlignCssPositionProp2];
  2120. properOffset = deriveOffset(alternativeAlignCssSizeProp, possibleAlternativeAlignCssPositionProp2, offsetVertically);
  2121. }
  2122. }
  2123. }
  2124. let properPosition = position;
  2125. if (
  2126. // space is not enough
  2127. targetRect[position] < followerRect[propToCompare[position]] && // opposite position's space is larger
  2128. targetRect[position] < targetRect[oppositionPositions[position]]
  2129. ) {
  2130. properPosition = oppositionPositions[position];
  2131. }
  2132. return {
  2133. placement: properAlign !== "center" ? `${properPosition}-${properAlign}` : properPosition,
  2134. left: properOffset.left,
  2135. top: properOffset.top
  2136. };
  2137. }
  2138. function getProperTransformOrigin(placement, overlap) {
  2139. if (overlap)
  2140. return overlapTransformOrigin[placement];
  2141. return transformOrigins[placement];
  2142. }
  2143. function getOffset(placement, offsetRect, targetRect, offsetTopToStandardPlacement, offsetLeftToStandardPlacement, overlap) {
  2144. if (overlap) {
  2145. switch (placement) {
  2146. case "bottom-start":
  2147. return {
  2148. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
  2149. left: `${Math.round(targetRect.left - offsetRect.left)}px`,
  2150. transform: "translateY(-100%)"
  2151. };
  2152. case "bottom-end":
  2153. return {
  2154. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
  2155. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
  2156. transform: "translateX(-100%) translateY(-100%)"
  2157. };
  2158. case "top-start":
  2159. return {
  2160. top: `${Math.round(targetRect.top - offsetRect.top)}px`,
  2161. left: `${Math.round(targetRect.left - offsetRect.left)}px`,
  2162. transform: ""
  2163. };
  2164. case "top-end":
  2165. return {
  2166. top: `${Math.round(targetRect.top - offsetRect.top)}px`,
  2167. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
  2168. transform: "translateX(-100%)"
  2169. };
  2170. case "right-start":
  2171. return {
  2172. top: `${Math.round(targetRect.top - offsetRect.top)}px`,
  2173. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
  2174. transform: "translateX(-100%)"
  2175. };
  2176. case "right-end":
  2177. return {
  2178. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
  2179. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
  2180. transform: "translateX(-100%) translateY(-100%)"
  2181. };
  2182. case "left-start":
  2183. return {
  2184. top: `${Math.round(targetRect.top - offsetRect.top)}px`,
  2185. left: `${Math.round(targetRect.left - offsetRect.left)}px`,
  2186. transform: ""
  2187. };
  2188. case "left-end":
  2189. return {
  2190. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
  2191. left: `${Math.round(targetRect.left - offsetRect.left)}px`,
  2192. transform: "translateY(-100%)"
  2193. };
  2194. case "top":
  2195. return {
  2196. top: `${Math.round(targetRect.top - offsetRect.top)}px`,
  2197. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2)}px`,
  2198. transform: "translateX(-50%)"
  2199. };
  2200. case "right":
  2201. return {
  2202. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2)}px`,
  2203. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width)}px`,
  2204. transform: "translateX(-100%) translateY(-50%)"
  2205. };
  2206. case "left":
  2207. return {
  2208. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2)}px`,
  2209. left: `${Math.round(targetRect.left - offsetRect.left)}px`,
  2210. transform: "translateY(-50%)"
  2211. };
  2212. case "bottom":
  2213. default:
  2214. return {
  2215. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height)}px`,
  2216. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2)}px`,
  2217. transform: "translateX(-50%) translateY(-100%)"
  2218. };
  2219. }
  2220. }
  2221. switch (placement) {
  2222. case "bottom-start":
  2223. return {
  2224. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
  2225. left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
  2226. transform: ""
  2227. };
  2228. case "bottom-end":
  2229. return {
  2230. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
  2231. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
  2232. transform: "translateX(-100%)"
  2233. };
  2234. case "top-start":
  2235. return {
  2236. top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
  2237. left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
  2238. transform: "translateY(-100%)"
  2239. };
  2240. case "top-end":
  2241. return {
  2242. top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
  2243. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
  2244. transform: "translateX(-100%) translateY(-100%)"
  2245. };
  2246. case "right-start":
  2247. return {
  2248. top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
  2249. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
  2250. transform: ""
  2251. };
  2252. case "right-end":
  2253. return {
  2254. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
  2255. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
  2256. transform: "translateY(-100%)"
  2257. };
  2258. case "left-start":
  2259. return {
  2260. top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
  2261. left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
  2262. transform: "translateX(-100%)"
  2263. };
  2264. case "left-end":
  2265. return {
  2266. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
  2267. left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
  2268. transform: "translateX(-100%) translateY(-100%)"
  2269. };
  2270. case "top":
  2271. return {
  2272. top: `${Math.round(targetRect.top - offsetRect.top + offsetTopToStandardPlacement)}px`,
  2273. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2 + offsetLeftToStandardPlacement)}px`,
  2274. transform: "translateY(-100%) translateX(-50%)"
  2275. };
  2276. case "right":
  2277. return {
  2278. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2 + offsetTopToStandardPlacement)}px`,
  2279. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width + offsetLeftToStandardPlacement)}px`,
  2280. transform: "translateY(-50%)"
  2281. };
  2282. case "left":
  2283. return {
  2284. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height / 2 + offsetTopToStandardPlacement)}px`,
  2285. left: `${Math.round(targetRect.left - offsetRect.left + offsetLeftToStandardPlacement)}px`,
  2286. transform: "translateY(-50%) translateX(-100%)"
  2287. };
  2288. case "bottom":
  2289. default:
  2290. return {
  2291. top: `${Math.round(targetRect.top - offsetRect.top + targetRect.height + offsetTopToStandardPlacement)}px`,
  2292. left: `${Math.round(targetRect.left - offsetRect.left + targetRect.width / 2 + offsetLeftToStandardPlacement)}px`,
  2293. transform: "translateX(-50%)"
  2294. };
  2295. }
  2296. }
  2297. const style$7 = c([
  2298. c(".v-binder-follower-container", {
  2299. position: "absolute",
  2300. left: "0",
  2301. right: "0",
  2302. top: "0",
  2303. height: "0",
  2304. pointerEvents: "none",
  2305. zIndex: "auto"
  2306. }),
  2307. c(".v-binder-follower-content", {
  2308. position: "absolute",
  2309. zIndex: "auto"
  2310. }, [
  2311. c("> *", {
  2312. pointerEvents: "all"
  2313. })
  2314. ])
  2315. ]);
  2316. const VFollower = vue.defineComponent({
  2317. name: "Follower",
  2318. inheritAttrs: false,
  2319. props: {
  2320. show: Boolean,
  2321. enabled: {
  2322. type: Boolean,
  2323. default: void 0
  2324. },
  2325. placement: {
  2326. type: String,
  2327. default: "bottom"
  2328. },
  2329. syncTrigger: {
  2330. type: Array,
  2331. default: ["resize", "scroll"]
  2332. },
  2333. to: [String, Object],
  2334. flip: {
  2335. type: Boolean,
  2336. default: true
  2337. },
  2338. internalShift: Boolean,
  2339. x: Number,
  2340. y: Number,
  2341. width: String,
  2342. minWidth: String,
  2343. containerClass: String,
  2344. teleportDisabled: Boolean,
  2345. zindexable: {
  2346. type: Boolean,
  2347. default: true
  2348. },
  2349. zIndex: Number,
  2350. overlap: Boolean
  2351. },
  2352. setup(props) {
  2353. const VBinder = vue.inject("VBinder");
  2354. const mergedEnabledRef = useMemo(() => {
  2355. return props.enabled !== void 0 ? props.enabled : props.show;
  2356. });
  2357. const followerRef = vue.ref(null);
  2358. const offsetContainerRef = vue.ref(null);
  2359. const ensureListeners = () => {
  2360. const { syncTrigger } = props;
  2361. if (syncTrigger.includes("scroll")) {
  2362. VBinder.addScrollListener(syncPosition);
  2363. }
  2364. if (syncTrigger.includes("resize")) {
  2365. VBinder.addResizeListener(syncPosition);
  2366. }
  2367. };
  2368. const removeListeners = () => {
  2369. VBinder.removeScrollListener(syncPosition);
  2370. VBinder.removeResizeListener(syncPosition);
  2371. };
  2372. vue.onMounted(() => {
  2373. if (mergedEnabledRef.value) {
  2374. syncPosition();
  2375. ensureListeners();
  2376. }
  2377. });
  2378. const ssrAdapter2 = useSsrAdapter();
  2379. style$7.mount({
  2380. id: "vueuc/binder",
  2381. head: true,
  2382. anchorMetaName: cssrAnchorMetaName$1,
  2383. ssr: ssrAdapter2
  2384. });
  2385. vue.onBeforeUnmount(() => {
  2386. removeListeners();
  2387. });
  2388. onFontsReady(() => {
  2389. if (mergedEnabledRef.value) {
  2390. syncPosition();
  2391. }
  2392. });
  2393. const syncPosition = () => {
  2394. if (!mergedEnabledRef.value) {
  2395. return;
  2396. }
  2397. const follower = followerRef.value;
  2398. if (follower === null)
  2399. return;
  2400. const target = VBinder.targetRef;
  2401. const { x, y, overlap } = props;
  2402. const targetRect = x !== void 0 && y !== void 0 ? getPointRect(x, y) : getRect(target);
  2403. follower.style.setProperty("--v-target-width", `${Math.round(targetRect.width)}px`);
  2404. follower.style.setProperty("--v-target-height", `${Math.round(targetRect.height)}px`);
  2405. const { width, minWidth, placement, internalShift, flip } = props;
  2406. follower.setAttribute("v-placement", placement);
  2407. if (overlap) {
  2408. follower.setAttribute("v-overlap", "");
  2409. } else {
  2410. follower.removeAttribute("v-overlap");
  2411. }
  2412. const { style: style2 } = follower;
  2413. if (width === "target") {
  2414. style2.width = `${targetRect.width}px`;
  2415. } else if (width !== void 0) {
  2416. style2.width = width;
  2417. } else {
  2418. style2.width = "";
  2419. }
  2420. if (minWidth === "target") {
  2421. style2.minWidth = `${targetRect.width}px`;
  2422. } else if (minWidth !== void 0) {
  2423. style2.minWidth = minWidth;
  2424. } else {
  2425. style2.minWidth = "";
  2426. }
  2427. const followerRect = getRect(follower);
  2428. const offsetContainerRect = getRect(offsetContainerRef.value);
  2429. const { left: offsetLeftToStandardPlacement, top: offsetTopToStandardPlacement, placement: properPlacement } = getPlacementAndOffsetOfFollower(placement, targetRect, followerRect, internalShift, flip, overlap);
  2430. const properTransformOrigin = getProperTransformOrigin(properPlacement, overlap);
  2431. const { left, top, transform } = getOffset(properPlacement, offsetContainerRect, targetRect, offsetTopToStandardPlacement, offsetLeftToStandardPlacement, overlap);
  2432. follower.setAttribute("v-placement", properPlacement);
  2433. follower.style.setProperty("--v-offset-left", `${Math.round(offsetLeftToStandardPlacement)}px`);
  2434. follower.style.setProperty("--v-offset-top", `${Math.round(offsetTopToStandardPlacement)}px`);
  2435. follower.style.transform = `translateX(${left}) translateY(${top}) ${transform}`;
  2436. follower.style.setProperty("--v-transform-origin", properTransformOrigin);
  2437. follower.style.transformOrigin = properTransformOrigin;
  2438. };
  2439. vue.watch(mergedEnabledRef, (value) => {
  2440. if (value) {
  2441. ensureListeners();
  2442. syncOnNextTick();
  2443. } else {
  2444. removeListeners();
  2445. }
  2446. });
  2447. const syncOnNextTick = () => {
  2448. vue.nextTick().then(syncPosition).catch((e) => console.error(e));
  2449. };
  2450. [
  2451. "placement",
  2452. "x",
  2453. "y",
  2454. "internalShift",
  2455. "flip",
  2456. "width",
  2457. "overlap",
  2458. "minWidth"
  2459. ].forEach((prop) => {
  2460. vue.watch(vue.toRef(props, prop), syncPosition);
  2461. });
  2462. ["teleportDisabled"].forEach((prop) => {
  2463. vue.watch(vue.toRef(props, prop), syncOnNextTick);
  2464. });
  2465. vue.watch(vue.toRef(props, "syncTrigger"), (value) => {
  2466. if (!value.includes("resize")) {
  2467. VBinder.removeResizeListener(syncPosition);
  2468. } else {
  2469. VBinder.addResizeListener(syncPosition);
  2470. }
  2471. if (!value.includes("scroll")) {
  2472. VBinder.removeScrollListener(syncPosition);
  2473. } else {
  2474. VBinder.addScrollListener(syncPosition);
  2475. }
  2476. });
  2477. const isMountedRef = isMounted();
  2478. const mergedToRef = useMemo(() => {
  2479. const { to } = props;
  2480. if (to !== void 0)
  2481. return to;
  2482. if (isMountedRef.value) {
  2483. return void 0;
  2484. }
  2485. return void 0;
  2486. });
  2487. return {
  2488. VBinder,
  2489. mergedEnabled: mergedEnabledRef,
  2490. offsetContainerRef,
  2491. followerRef,
  2492. mergedTo: mergedToRef,
  2493. syncPosition
  2494. };
  2495. },
  2496. render() {
  2497. return vue.h(LazyTeleport, {
  2498. show: this.show,
  2499. to: this.mergedTo,
  2500. disabled: this.teleportDisabled
  2501. }, {
  2502. default: () => {
  2503. var _a, _b;
  2504. const vNode = vue.h("div", {
  2505. class: ["v-binder-follower-container", this.containerClass],
  2506. ref: "offsetContainerRef"
  2507. }, [
  2508. vue.h("div", {
  2509. class: "v-binder-follower-content",
  2510. ref: "followerRef"
  2511. }, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a))
  2512. ]);
  2513. if (this.zindexable) {
  2514. return vue.withDirectives(vNode, [
  2515. [
  2516. zindexable,
  2517. {
  2518. enabled: this.mergedEnabled,
  2519. zIndex: this.zIndex
  2520. }
  2521. ]
  2522. ]);
  2523. }
  2524. return vNode;
  2525. }
  2526. });
  2527. }
  2528. });
  2529. var resizeObservers = [];
  2530. var hasActiveObservations = function() {
  2531. return resizeObservers.some(function(ro) {
  2532. return ro.activeTargets.length > 0;
  2533. });
  2534. };
  2535. var hasSkippedObservations = function() {
  2536. return resizeObservers.some(function(ro) {
  2537. return ro.skippedTargets.length > 0;
  2538. });
  2539. };
  2540. var msg = "ResizeObserver loop completed with undelivered notifications.";
  2541. var deliverResizeLoopError = function() {
  2542. var event;
  2543. if (typeof ErrorEvent === "function") {
  2544. event = new ErrorEvent("error", {
  2545. message: msg
  2546. });
  2547. } else {
  2548. event = document.createEvent("Event");
  2549. event.initEvent("error", false, false);
  2550. event.message = msg;
  2551. }
  2552. window.dispatchEvent(event);
  2553. };
  2554. var ResizeObserverBoxOptions;
  2555. (function(ResizeObserverBoxOptions2) {
  2556. ResizeObserverBoxOptions2["BORDER_BOX"] = "border-box";
  2557. ResizeObserverBoxOptions2["CONTENT_BOX"] = "content-box";
  2558. ResizeObserverBoxOptions2["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
  2559. })(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
  2560. var freeze = function(obj) {
  2561. return Object.freeze(obj);
  2562. };
  2563. var ResizeObserverSize = /* @__PURE__ */ function() {
  2564. function ResizeObserverSize2(inlineSize, blockSize) {
  2565. this.inlineSize = inlineSize;
  2566. this.blockSize = blockSize;
  2567. freeze(this);
  2568. }
  2569. return ResizeObserverSize2;
  2570. }();
  2571. var DOMRectReadOnly = function() {
  2572. function DOMRectReadOnly2(x, y, width, height) {
  2573. this.x = x;
  2574. this.y = y;
  2575. this.width = width;
  2576. this.height = height;
  2577. this.top = this.y;
  2578. this.left = this.x;
  2579. this.bottom = this.top + this.height;
  2580. this.right = this.left + this.width;
  2581. return freeze(this);
  2582. }
  2583. DOMRectReadOnly2.prototype.toJSON = function() {
  2584. var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
  2585. return { x, y, top, right, bottom, left, width, height };
  2586. };
  2587. DOMRectReadOnly2.fromRect = function(rectangle) {
  2588. return new DOMRectReadOnly2(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
  2589. };
  2590. return DOMRectReadOnly2;
  2591. }();
  2592. var isSVG = function(target) {
  2593. return target instanceof SVGElement && "getBBox" in target;
  2594. };
  2595. var isHidden = function(target) {
  2596. if (isSVG(target)) {
  2597. var _a = target.getBBox(), width = _a.width, height = _a.height;
  2598. return !width && !height;
  2599. }
  2600. var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
  2601. return !(offsetWidth || offsetHeight || target.getClientRects().length);
  2602. };
  2603. var isElement = function(obj) {
  2604. var _a;
  2605. if (obj instanceof Element) {
  2606. return true;
  2607. }
  2608. var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
  2609. return !!(scope && obj instanceof scope.Element);
  2610. };
  2611. var isReplacedElement = function(target) {
  2612. switch (target.tagName) {
  2613. case "INPUT":
  2614. if (target.type !== "image") {
  2615. break;
  2616. }
  2617. case "VIDEO":
  2618. case "AUDIO":
  2619. case "EMBED":
  2620. case "OBJECT":
  2621. case "CANVAS":
  2622. case "IFRAME":
  2623. case "IMG":
  2624. return true;
  2625. }
  2626. return false;
  2627. };
  2628. var global$1 = typeof window !== "undefined" ? window : {};
  2629. var cache = /* @__PURE__ */ new WeakMap();
  2630. var scrollRegexp = /auto|scroll/;
  2631. var verticalRegexp = /^tb|vertical/;
  2632. var IE = /msie|trident/i.test(global$1.navigator && global$1.navigator.userAgent);
  2633. var parseDimension = function(pixel) {
  2634. return parseFloat(pixel || "0");
  2635. };
  2636. var size = function(inlineSize, blockSize, switchSizes) {
  2637. if (inlineSize === void 0) {
  2638. inlineSize = 0;
  2639. }
  2640. if (blockSize === void 0) {
  2641. blockSize = 0;
  2642. }
  2643. if (switchSizes === void 0) {
  2644. switchSizes = false;
  2645. }
  2646. return new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
  2647. };
  2648. var zeroBoxes = freeze({
  2649. devicePixelContentBoxSize: size(),
  2650. borderBoxSize: size(),
  2651. contentBoxSize: size(),
  2652. contentRect: new DOMRectReadOnly(0, 0, 0, 0)
  2653. });
  2654. var calculateBoxSizes = function(target, forceRecalculation) {
  2655. if (forceRecalculation === void 0) {
  2656. forceRecalculation = false;
  2657. }
  2658. if (cache.has(target) && !forceRecalculation) {
  2659. return cache.get(target);
  2660. }
  2661. if (isHidden(target)) {
  2662. cache.set(target, zeroBoxes);
  2663. return zeroBoxes;
  2664. }
  2665. var cs = getComputedStyle(target);
  2666. var svg = isSVG(target) && target.ownerSVGElement && target.getBBox();
  2667. var removePadding = !IE && cs.boxSizing === "border-box";
  2668. var switchSizes = verticalRegexp.test(cs.writingMode || "");
  2669. var canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || "");
  2670. var canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || "");
  2671. var paddingTop = svg ? 0 : parseDimension(cs.paddingTop);
  2672. var paddingRight = svg ? 0 : parseDimension(cs.paddingRight);
  2673. var paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom);
  2674. var paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft);
  2675. var borderTop = svg ? 0 : parseDimension(cs.borderTopWidth);
  2676. var borderRight = svg ? 0 : parseDimension(cs.borderRightWidth);
  2677. var borderBottom = svg ? 0 : parseDimension(cs.borderBottomWidth);
  2678. var borderLeft = svg ? 0 : parseDimension(cs.borderLeftWidth);
  2679. var horizontalPadding = paddingLeft + paddingRight;
  2680. var verticalPadding = paddingTop + paddingBottom;
  2681. var horizontalBorderArea = borderLeft + borderRight;
  2682. var verticalBorderArea = borderTop + borderBottom;
  2683. var horizontalScrollbarThickness = !canScrollHorizontally ? 0 : target.offsetHeight - verticalBorderArea - target.clientHeight;
  2684. var verticalScrollbarThickness = !canScrollVertically ? 0 : target.offsetWidth - horizontalBorderArea - target.clientWidth;
  2685. var widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0;
  2686. var heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0;
  2687. var contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness;
  2688. var contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness;
  2689. var borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea;
  2690. var borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea;
  2691. var boxes = freeze({
  2692. devicePixelContentBoxSize: size(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
  2693. borderBoxSize: size(borderBoxWidth, borderBoxHeight, switchSizes),
  2694. contentBoxSize: size(contentWidth, contentHeight, switchSizes),
  2695. contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
  2696. });
  2697. cache.set(target, boxes);
  2698. return boxes;
  2699. };
  2700. var calculateBoxSize = function(target, observedBox, forceRecalculation) {
  2701. var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize, contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
  2702. switch (observedBox) {
  2703. case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
  2704. return devicePixelContentBoxSize;
  2705. case ResizeObserverBoxOptions.BORDER_BOX:
  2706. return borderBoxSize;
  2707. default:
  2708. return contentBoxSize;
  2709. }
  2710. };
  2711. var ResizeObserverEntry = /* @__PURE__ */ function() {
  2712. function ResizeObserverEntry2(target) {
  2713. var boxes = calculateBoxSizes(target);
  2714. this.target = target;
  2715. this.contentRect = boxes.contentRect;
  2716. this.borderBoxSize = freeze([boxes.borderBoxSize]);
  2717. this.contentBoxSize = freeze([boxes.contentBoxSize]);
  2718. this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
  2719. }
  2720. return ResizeObserverEntry2;
  2721. }();
  2722. var calculateDepthForNode = function(node) {
  2723. if (isHidden(node)) {
  2724. return Infinity;
  2725. }
  2726. var depth = 0;
  2727. var parent = node.parentNode;
  2728. while (parent) {
  2729. depth += 1;
  2730. parent = parent.parentNode;
  2731. }
  2732. return depth;
  2733. };
  2734. var broadcastActiveObservations = function() {
  2735. var shallowestDepth = Infinity;
  2736. var callbacks2 = [];
  2737. resizeObservers.forEach(function processObserver(ro) {
  2738. if (ro.activeTargets.length === 0) {
  2739. return;
  2740. }
  2741. var entries = [];
  2742. ro.activeTargets.forEach(function processTarget(ot) {
  2743. var entry = new ResizeObserverEntry(ot.target);
  2744. var targetDepth = calculateDepthForNode(ot.target);
  2745. entries.push(entry);
  2746. ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
  2747. if (targetDepth < shallowestDepth) {
  2748. shallowestDepth = targetDepth;
  2749. }
  2750. });
  2751. callbacks2.push(function resizeObserverCallback() {
  2752. ro.callback.call(ro.observer, entries, ro.observer);
  2753. });
  2754. ro.activeTargets.splice(0, ro.activeTargets.length);
  2755. });
  2756. for (var _i = 0, callbacks_1 = callbacks2; _i < callbacks_1.length; _i++) {
  2757. var callback = callbacks_1[_i];
  2758. callback();
  2759. }
  2760. return shallowestDepth;
  2761. };
  2762. var gatherActiveObservationsAtDepth = function(depth) {
  2763. resizeObservers.forEach(function processObserver(ro) {
  2764. ro.activeTargets.splice(0, ro.activeTargets.length);
  2765. ro.skippedTargets.splice(0, ro.skippedTargets.length);
  2766. ro.observationTargets.forEach(function processTarget(ot) {
  2767. if (ot.isActive()) {
  2768. if (calculateDepthForNode(ot.target) > depth) {
  2769. ro.activeTargets.push(ot);
  2770. } else {
  2771. ro.skippedTargets.push(ot);
  2772. }
  2773. }
  2774. });
  2775. });
  2776. };
  2777. var process = function() {
  2778. var depth = 0;
  2779. gatherActiveObservationsAtDepth(depth);
  2780. while (hasActiveObservations()) {
  2781. depth = broadcastActiveObservations();
  2782. gatherActiveObservationsAtDepth(depth);
  2783. }
  2784. if (hasSkippedObservations()) {
  2785. deliverResizeLoopError();
  2786. }
  2787. return depth > 0;
  2788. };
  2789. var trigger;
  2790. var callbacks = [];
  2791. var notify = function() {
  2792. return callbacks.splice(0).forEach(function(cb) {
  2793. return cb();
  2794. });
  2795. };
  2796. var queueMicroTask = function(callback) {
  2797. if (!trigger) {
  2798. var toggle_1 = 0;
  2799. var el_1 = document.createTextNode("");
  2800. var config = { characterData: true };
  2801. new MutationObserver(function() {
  2802. return notify();
  2803. }).observe(el_1, config);
  2804. trigger = function() {
  2805. el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++);
  2806. };
  2807. }
  2808. callbacks.push(callback);
  2809. trigger();
  2810. };
  2811. var queueResizeObserver = function(cb) {
  2812. queueMicroTask(function ResizeObserver2() {
  2813. requestAnimationFrame(cb);
  2814. });
  2815. };
  2816. var watching = 0;
  2817. var isWatching = function() {
  2818. return !!watching;
  2819. };
  2820. var CATCH_PERIOD = 250;
  2821. var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
  2822. var events = [
  2823. "resize",
  2824. "load",
  2825. "transitionend",
  2826. "animationend",
  2827. "animationstart",
  2828. "animationiteration",
  2829. "keyup",
  2830. "keydown",
  2831. "mouseup",
  2832. "mousedown",
  2833. "mouseover",
  2834. "mouseout",
  2835. "blur",
  2836. "focus"
  2837. ];
  2838. var time = function(timeout) {
  2839. if (timeout === void 0) {
  2840. timeout = 0;
  2841. }
  2842. return Date.now() + timeout;
  2843. };
  2844. var scheduled = false;
  2845. var Scheduler = function() {
  2846. function Scheduler2() {
  2847. var _this = this;
  2848. this.stopped = true;
  2849. this.listener = function() {
  2850. return _this.schedule();
  2851. };
  2852. }
  2853. Scheduler2.prototype.run = function(timeout) {
  2854. var _this = this;
  2855. if (timeout === void 0) {
  2856. timeout = CATCH_PERIOD;
  2857. }
  2858. if (scheduled) {
  2859. return;
  2860. }
  2861. scheduled = true;
  2862. var until = time(timeout);
  2863. queueResizeObserver(function() {
  2864. var elementsHaveResized = false;
  2865. try {
  2866. elementsHaveResized = process();
  2867. } finally {
  2868. scheduled = false;
  2869. timeout = until - time();
  2870. if (!isWatching()) {
  2871. return;
  2872. }
  2873. if (elementsHaveResized) {
  2874. _this.run(1e3);
  2875. } else if (timeout > 0) {
  2876. _this.run(timeout);
  2877. } else {
  2878. _this.start();
  2879. }
  2880. }
  2881. });
  2882. };
  2883. Scheduler2.prototype.schedule = function() {
  2884. this.stop();
  2885. this.run();
  2886. };
  2887. Scheduler2.prototype.observe = function() {
  2888. var _this = this;
  2889. var cb = function() {
  2890. return _this.observer && _this.observer.observe(document.body, observerConfig);
  2891. };
  2892. document.body ? cb() : global$1.addEventListener("DOMContentLoaded", cb);
  2893. };
  2894. Scheduler2.prototype.start = function() {
  2895. var _this = this;
  2896. if (this.stopped) {
  2897. this.stopped = false;
  2898. this.observer = new MutationObserver(this.listener);
  2899. this.observe();
  2900. events.forEach(function(name) {
  2901. return global$1.addEventListener(name, _this.listener, true);
  2902. });
  2903. }
  2904. };
  2905. Scheduler2.prototype.stop = function() {
  2906. var _this = this;
  2907. if (!this.stopped) {
  2908. this.observer && this.observer.disconnect();
  2909. events.forEach(function(name) {
  2910. return global$1.removeEventListener(name, _this.listener, true);
  2911. });
  2912. this.stopped = true;
  2913. }
  2914. };
  2915. return Scheduler2;
  2916. }();
  2917. var scheduler = new Scheduler();
  2918. var updateCount = function(n) {
  2919. !watching && n > 0 && scheduler.start();
  2920. watching += n;
  2921. !watching && scheduler.stop();
  2922. };
  2923. var skipNotifyOnElement = function(target) {
  2924. return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === "inline";
  2925. };
  2926. var ResizeObservation = function() {
  2927. function ResizeObservation2(target, observedBox) {
  2928. this.target = target;
  2929. this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
  2930. this.lastReportedSize = {
  2931. inlineSize: 0,
  2932. blockSize: 0
  2933. };
  2934. }
  2935. ResizeObservation2.prototype.isActive = function() {
  2936. var size2 = calculateBoxSize(this.target, this.observedBox, true);
  2937. if (skipNotifyOnElement(this.target)) {
  2938. this.lastReportedSize = size2;
  2939. }
  2940. if (this.lastReportedSize.inlineSize !== size2.inlineSize || this.lastReportedSize.blockSize !== size2.blockSize) {
  2941. return true;
  2942. }
  2943. return false;
  2944. };
  2945. return ResizeObservation2;
  2946. }();
  2947. var ResizeObserverDetail = /* @__PURE__ */ function() {
  2948. function ResizeObserverDetail2(resizeObserver, callback) {
  2949. this.activeTargets = [];
  2950. this.skippedTargets = [];
  2951. this.observationTargets = [];
  2952. this.observer = resizeObserver;
  2953. this.callback = callback;
  2954. }
  2955. return ResizeObserverDetail2;
  2956. }();
  2957. var observerMap = /* @__PURE__ */ new WeakMap();
  2958. var getObservationIndex = function(observationTargets, target) {
  2959. for (var i = 0; i < observationTargets.length; i += 1) {
  2960. if (observationTargets[i].target === target) {
  2961. return i;
  2962. }
  2963. }
  2964. return -1;
  2965. };
  2966. var ResizeObserverController = function() {
  2967. function ResizeObserverController2() {
  2968. }
  2969. ResizeObserverController2.connect = function(resizeObserver, callback) {
  2970. var detail = new ResizeObserverDetail(resizeObserver, callback);
  2971. observerMap.set(resizeObserver, detail);
  2972. };
  2973. ResizeObserverController2.observe = function(resizeObserver, target, options) {
  2974. var detail = observerMap.get(resizeObserver);
  2975. var firstObservation = detail.observationTargets.length === 0;
  2976. if (getObservationIndex(detail.observationTargets, target) < 0) {
  2977. firstObservation && resizeObservers.push(detail);
  2978. detail.observationTargets.push(new ResizeObservation(target, options && options.box));
  2979. updateCount(1);
  2980. scheduler.schedule();
  2981. }
  2982. };
  2983. ResizeObserverController2.unobserve = function(resizeObserver, target) {
  2984. var detail = observerMap.get(resizeObserver);
  2985. var index = getObservationIndex(detail.observationTargets, target);
  2986. var lastObservation = detail.observationTargets.length === 1;
  2987. if (index >= 0) {
  2988. lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1);
  2989. detail.observationTargets.splice(index, 1);
  2990. updateCount(-1);
  2991. }
  2992. };
  2993. ResizeObserverController2.disconnect = function(resizeObserver) {
  2994. var _this = this;
  2995. var detail = observerMap.get(resizeObserver);
  2996. detail.observationTargets.slice().forEach(function(ot) {
  2997. return _this.unobserve(resizeObserver, ot.target);
  2998. });
  2999. detail.activeTargets.splice(0, detail.activeTargets.length);
  3000. };
  3001. return ResizeObserverController2;
  3002. }();
  3003. var ResizeObserver = function() {
  3004. function ResizeObserver2(callback) {
  3005. if (arguments.length === 0) {
  3006. throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
  3007. }
  3008. if (typeof callback !== "function") {
  3009. throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
  3010. }
  3011. ResizeObserverController.connect(this, callback);
  3012. }
  3013. ResizeObserver2.prototype.observe = function(target, options) {
  3014. if (arguments.length === 0) {
  3015. throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
  3016. }
  3017. if (!isElement(target)) {
  3018. throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
  3019. }
  3020. ResizeObserverController.observe(this, target, options);
  3021. };
  3022. ResizeObserver2.prototype.unobserve = function(target) {
  3023. if (arguments.length === 0) {
  3024. throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
  3025. }
  3026. if (!isElement(target)) {
  3027. throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
  3028. }
  3029. ResizeObserverController.unobserve(this, target);
  3030. };
  3031. ResizeObserver2.prototype.disconnect = function() {
  3032. ResizeObserverController.disconnect(this);
  3033. };
  3034. ResizeObserver2.toString = function() {
  3035. return "function ResizeObserver () { [polyfill code] }";
  3036. };
  3037. return ResizeObserver2;
  3038. }();
  3039. class ResizeObserverDelegate {
  3040. constructor() {
  3041. this.handleResize = this.handleResize.bind(this);
  3042. this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver)(this.handleResize);
  3043. this.elHandlersMap = /* @__PURE__ */ new Map();
  3044. }
  3045. handleResize(entries) {
  3046. for (const entry of entries) {
  3047. const handler = this.elHandlersMap.get(entry.target);
  3048. if (handler !== void 0) {
  3049. handler(entry);
  3050. }
  3051. }
  3052. }
  3053. registerHandler(el, handler) {
  3054. this.elHandlersMap.set(el, handler);
  3055. this.observer.observe(el);
  3056. }
  3057. unregisterHandler(el) {
  3058. if (!this.elHandlersMap.has(el)) {
  3059. return;
  3060. }
  3061. this.elHandlersMap.delete(el);
  3062. this.observer.unobserve(el);
  3063. }
  3064. }
  3065. const resizeObserverManager = new ResizeObserverDelegate();
  3066. const VResizeObserver = vue.defineComponent({
  3067. name: "ResizeObserver",
  3068. props: {
  3069. onResize: Function
  3070. },
  3071. setup(props) {
  3072. let registered = false;
  3073. const proxy = vue.getCurrentInstance().proxy;
  3074. function handleResize(entry) {
  3075. const { onResize } = props;
  3076. if (onResize !== void 0)
  3077. onResize(entry);
  3078. }
  3079. vue.onMounted(() => {
  3080. const el = proxy.$el;
  3081. if (el === void 0) {
  3082. warn("resize-observer", "$el does not exist.");
  3083. return;
  3084. }
  3085. if (el.nextElementSibling !== el.nextSibling) {
  3086. if (el.nodeType === 3 && el.nodeValue !== "") {
  3087. warn("resize-observer", "$el can not be observed (it may be a text node).");
  3088. return;
  3089. }
  3090. }
  3091. if (el.nextElementSibling !== null) {
  3092. resizeObserverManager.registerHandler(el.nextElementSibling, handleResize);
  3093. registered = true;
  3094. }
  3095. });
  3096. vue.onBeforeUnmount(() => {
  3097. if (registered) {
  3098. resizeObserverManager.unregisterHandler(proxy.$el.nextElementSibling);
  3099. }
  3100. });
  3101. },
  3102. render() {
  3103. return vue.renderSlot(this.$slots, "default");
  3104. }
  3105. });
  3106. const hiddenAttr = "v-hidden";
  3107. const style$6 = c("[v-hidden]", {
  3108. display: "none!important"
  3109. });
  3110. const VOverflow = vue.defineComponent({
  3111. name: "Overflow",
  3112. props: {
  3113. getCounter: Function,
  3114. getTail: Function,
  3115. updateCounter: Function,
  3116. onUpdateCount: Function,
  3117. onUpdateOverflow: Function
  3118. },
  3119. setup(props, { slots }) {
  3120. const selfRef = vue.ref(null);
  3121. const counterRef = vue.ref(null);
  3122. function deriveCounter(options) {
  3123. const { value: self2 } = selfRef;
  3124. const { getCounter, getTail } = props;
  3125. let counter;
  3126. if (getCounter !== void 0)
  3127. counter = getCounter();
  3128. else {
  3129. counter = counterRef.value;
  3130. }
  3131. if (!self2 || !counter)
  3132. return;
  3133. if (counter.hasAttribute(hiddenAttr)) {
  3134. counter.removeAttribute(hiddenAttr);
  3135. }
  3136. const { children } = self2;
  3137. if (options.showAllItemsBeforeCalculate) {
  3138. for (const child of children) {
  3139. if (child.hasAttribute(hiddenAttr)) {
  3140. child.removeAttribute(hiddenAttr);
  3141. }
  3142. }
  3143. }
  3144. const containerWidth = self2.offsetWidth;
  3145. const childWidths = [];
  3146. const tail = slots.tail ? getTail === null || getTail === void 0 ? void 0 : getTail() : null;
  3147. let childWidthSum = tail ? tail.offsetWidth : 0;
  3148. let overflow = false;
  3149. const len = self2.children.length - (slots.tail ? 1 : 0);
  3150. for (let i = 0; i < len - 1; ++i) {
  3151. if (i < 0)
  3152. continue;
  3153. const child = children[i];
  3154. if (overflow) {
  3155. if (!child.hasAttribute(hiddenAttr)) {
  3156. child.setAttribute(hiddenAttr, "");
  3157. }
  3158. continue;
  3159. } else if (child.hasAttribute(hiddenAttr)) {
  3160. child.removeAttribute(hiddenAttr);
  3161. }
  3162. const childWidth = child.offsetWidth;
  3163. childWidthSum += childWidth;
  3164. childWidths[i] = childWidth;
  3165. if (childWidthSum > containerWidth) {
  3166. const { updateCounter } = props;
  3167. for (let j = i; j >= 0; --j) {
  3168. const restCount = len - 1 - j;
  3169. if (updateCounter !== void 0) {
  3170. updateCounter(restCount);
  3171. } else {
  3172. counter.textContent = `${restCount}`;
  3173. }
  3174. const counterWidth = counter.offsetWidth;
  3175. childWidthSum -= childWidths[j];
  3176. if (childWidthSum + counterWidth <= containerWidth || j === 0) {
  3177. overflow = true;
  3178. i = j - 1;
  3179. if (tail) {
  3180. if (i === -1) {
  3181. tail.style.maxWidth = `${containerWidth - counterWidth}px`;
  3182. tail.style.boxSizing = "border-box";
  3183. } else {
  3184. tail.style.maxWidth = "";
  3185. }
  3186. }
  3187. const { onUpdateCount } = props;
  3188. if (onUpdateCount)
  3189. onUpdateCount(restCount);
  3190. break;
  3191. }
  3192. }
  3193. }
  3194. }
  3195. const { onUpdateOverflow } = props;
  3196. if (!overflow) {
  3197. if (onUpdateOverflow !== void 0) {
  3198. onUpdateOverflow(false);
  3199. }
  3200. counter.setAttribute(hiddenAttr, "");
  3201. } else {
  3202. if (onUpdateOverflow !== void 0) {
  3203. onUpdateOverflow(true);
  3204. }
  3205. }
  3206. }
  3207. const ssrAdapter2 = useSsrAdapter();
  3208. style$6.mount({
  3209. id: "vueuc/overflow",
  3210. head: true,
  3211. anchorMetaName: cssrAnchorMetaName$1,
  3212. ssr: ssrAdapter2
  3213. });
  3214. vue.onMounted(() => deriveCounter({
  3215. showAllItemsBeforeCalculate: false
  3216. }));
  3217. return {
  3218. selfRef,
  3219. counterRef,
  3220. sync: deriveCounter
  3221. };
  3222. },
  3223. render() {
  3224. const { $slots } = this;
  3225. vue.nextTick(() => this.sync({
  3226. showAllItemsBeforeCalculate: false
  3227. }));
  3228. return vue.h("div", {
  3229. class: "v-overflow",
  3230. ref: "selfRef"
  3231. }, [
  3232. vue.renderSlot($slots, "default"),
  3233. // $slots.counter should only has 1 element
  3234. $slots.counter ? $slots.counter() : vue.h("span", {
  3235. style: {
  3236. display: "inline-block"
  3237. },
  3238. ref: "counterRef"
  3239. }),
  3240. // $slots.tail should only has 1 element
  3241. $slots.tail ? $slots.tail() : null
  3242. ]);
  3243. }
  3244. });
  3245. function isHTMLElement(node) {
  3246. return node instanceof HTMLElement;
  3247. }
  3248. function focusFirstDescendant(node) {
  3249. for (let i = 0; i < node.childNodes.length; i++) {
  3250. const child = node.childNodes[i];
  3251. if (isHTMLElement(child)) {
  3252. if (attemptFocus(child) || focusFirstDescendant(child)) {
  3253. return true;
  3254. }
  3255. }
  3256. }
  3257. return false;
  3258. }
  3259. function focusLastDescendant(element) {
  3260. for (let i = element.childNodes.length - 1; i >= 0; i--) {
  3261. const child = element.childNodes[i];
  3262. if (isHTMLElement(child)) {
  3263. if (attemptFocus(child) || focusLastDescendant(child)) {
  3264. return true;
  3265. }
  3266. }
  3267. }
  3268. return false;
  3269. }
  3270. function attemptFocus(element) {
  3271. if (!isFocusable(element)) {
  3272. return false;
  3273. }
  3274. try {
  3275. element.focus({ preventScroll: true });
  3276. } catch (e) {
  3277. }
  3278. return document.activeElement === element;
  3279. }
  3280. function isFocusable(element) {
  3281. if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null) {
  3282. return true;
  3283. }
  3284. if (element.getAttribute("disabled")) {
  3285. return false;
  3286. }
  3287. switch (element.nodeName) {
  3288. case "A":
  3289. return !!element.href && element.rel !== "ignore";
  3290. case "INPUT":
  3291. return element.type !== "hidden" && element.type !== "file";
  3292. case "BUTTON":
  3293. case "SELECT":
  3294. case "TEXTAREA":
  3295. return true;
  3296. default:
  3297. return false;
  3298. }
  3299. }
  3300. let stack = [];
  3301. const FocusTrap = vue.defineComponent({
  3302. name: "FocusTrap",
  3303. props: {
  3304. disabled: Boolean,
  3305. active: Boolean,
  3306. autoFocus: {
  3307. type: Boolean,
  3308. default: true
  3309. },
  3310. onEsc: Function,
  3311. initialFocusTo: String,
  3312. finalFocusTo: String,
  3313. returnFocusOnDeactivated: {
  3314. type: Boolean,
  3315. default: true
  3316. }
  3317. },
  3318. setup(props) {
  3319. const id = createId();
  3320. const focusableStartRef = vue.ref(null);
  3321. const focusableEndRef = vue.ref(null);
  3322. let activated = false;
  3323. let ignoreInternalFocusChange = false;
  3324. const lastFocusedElement = typeof document === "undefined" ? null : document.activeElement;
  3325. function isCurrentActive() {
  3326. const currentActiveId = stack[stack.length - 1];
  3327. return currentActiveId === id;
  3328. }
  3329. function handleDocumentKeydown(e) {
  3330. var _a;
  3331. if (e.code === "Escape") {
  3332. if (isCurrentActive()) {
  3333. (_a = props.onEsc) === null || _a === void 0 ? void 0 : _a.call(props, e);
  3334. }
  3335. }
  3336. }
  3337. vue.onMounted(() => {
  3338. vue.watch(() => props.active, (value) => {
  3339. if (value) {
  3340. activate();
  3341. on("keydown", document, handleDocumentKeydown);
  3342. } else {
  3343. off("keydown", document, handleDocumentKeydown);
  3344. if (activated) {
  3345. deactivate();
  3346. }
  3347. }
  3348. }, {
  3349. immediate: true
  3350. });
  3351. });
  3352. vue.onBeforeUnmount(() => {
  3353. off("keydown", document, handleDocumentKeydown);
  3354. if (activated)
  3355. deactivate();
  3356. });
  3357. function handleDocumentFocus(e) {
  3358. if (ignoreInternalFocusChange)
  3359. return;
  3360. if (isCurrentActive()) {
  3361. const mainEl = getMainEl();
  3362. if (mainEl === null)
  3363. return;
  3364. if (mainEl.contains(getPreciseEventTarget(e)))
  3365. return;
  3366. resetFocusTo("first");
  3367. }
  3368. }
  3369. function getMainEl() {
  3370. const focusableStartEl = focusableStartRef.value;
  3371. if (focusableStartEl === null)
  3372. return null;
  3373. let mainEl = focusableStartEl;
  3374. while (true) {
  3375. mainEl = mainEl.nextSibling;
  3376. if (mainEl === null)
  3377. break;
  3378. if (mainEl instanceof Element && mainEl.tagName === "DIV") {
  3379. break;
  3380. }
  3381. }
  3382. return mainEl;
  3383. }
  3384. function activate() {
  3385. var _a;
  3386. if (props.disabled)
  3387. return;
  3388. stack.push(id);
  3389. if (props.autoFocus) {
  3390. const { initialFocusTo } = props;
  3391. if (initialFocusTo === void 0) {
  3392. resetFocusTo("first");
  3393. } else {
  3394. (_a = resolveTo(initialFocusTo)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
  3395. }
  3396. }
  3397. activated = true;
  3398. document.addEventListener("focus", handleDocumentFocus, true);
  3399. }
  3400. function deactivate() {
  3401. var _a;
  3402. if (props.disabled)
  3403. return;
  3404. document.removeEventListener("focus", handleDocumentFocus, true);
  3405. stack = stack.filter((idInStack) => idInStack !== id);
  3406. if (isCurrentActive())
  3407. return;
  3408. const { finalFocusTo } = props;
  3409. if (finalFocusTo !== void 0) {
  3410. (_a = resolveTo(finalFocusTo)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
  3411. } else if (props.returnFocusOnDeactivated) {
  3412. if (lastFocusedElement instanceof HTMLElement) {
  3413. ignoreInternalFocusChange = true;
  3414. lastFocusedElement.focus({ preventScroll: true });
  3415. ignoreInternalFocusChange = false;
  3416. }
  3417. }
  3418. }
  3419. function resetFocusTo(target) {
  3420. if (!isCurrentActive())
  3421. return;
  3422. if (props.active) {
  3423. const focusableStartEl = focusableStartRef.value;
  3424. const focusableEndEl = focusableEndRef.value;
  3425. if (focusableStartEl !== null && focusableEndEl !== null) {
  3426. const mainEl = getMainEl();
  3427. if (mainEl == null || mainEl === focusableEndEl) {
  3428. ignoreInternalFocusChange = true;
  3429. focusableStartEl.focus({ preventScroll: true });
  3430. ignoreInternalFocusChange = false;
  3431. return;
  3432. }
  3433. ignoreInternalFocusChange = true;
  3434. const focused = target === "first" ? focusFirstDescendant(mainEl) : focusLastDescendant(mainEl);
  3435. ignoreInternalFocusChange = false;
  3436. if (!focused) {
  3437. ignoreInternalFocusChange = true;
  3438. focusableStartEl.focus({ preventScroll: true });
  3439. ignoreInternalFocusChange = false;
  3440. }
  3441. }
  3442. }
  3443. }
  3444. function handleStartFocus(e) {
  3445. if (ignoreInternalFocusChange)
  3446. return;
  3447. const mainEl = getMainEl();
  3448. if (mainEl === null)
  3449. return;
  3450. if (e.relatedTarget !== null && mainEl.contains(e.relatedTarget)) {
  3451. resetFocusTo("last");
  3452. } else {
  3453. resetFocusTo("first");
  3454. }
  3455. }
  3456. function handleEndFocus(e) {
  3457. if (ignoreInternalFocusChange)
  3458. return;
  3459. if (e.relatedTarget !== null && e.relatedTarget === focusableStartRef.value) {
  3460. resetFocusTo("last");
  3461. } else {
  3462. resetFocusTo("first");
  3463. }
  3464. }
  3465. return {
  3466. focusableStartRef,
  3467. focusableEndRef,
  3468. focusableStyle: "position: absolute; height: 0; width: 0;",
  3469. handleStartFocus,
  3470. handleEndFocus
  3471. };
  3472. },
  3473. render() {
  3474. const { default: defaultSlot } = this.$slots;
  3475. if (defaultSlot === void 0)
  3476. return null;
  3477. if (this.disabled)
  3478. return defaultSlot();
  3479. const { active, focusableStyle } = this;
  3480. return vue.h(vue.Fragment, null, [
  3481. vue.h("div", {
  3482. "aria-hidden": "true",
  3483. tabindex: active ? "0" : "-1",
  3484. ref: "focusableStartRef",
  3485. style: focusableStyle,
  3486. onFocus: this.handleStartFocus
  3487. }),
  3488. defaultSlot(),
  3489. vue.h("div", {
  3490. "aria-hidden": "true",
  3491. style: focusableStyle,
  3492. ref: "focusableEndRef",
  3493. tabindex: active ? "0" : "-1",
  3494. onFocus: this.handleEndFocus
  3495. })
  3496. ]);
  3497. }
  3498. });
  3499. function useReactivated(callback) {
  3500. const isDeactivatedRef = {
  3501. isDeactivated: false
  3502. };
  3503. let activateStateInitialized = false;
  3504. vue.onActivated(() => {
  3505. isDeactivatedRef.isDeactivated = false;
  3506. if (!activateStateInitialized) {
  3507. activateStateInitialized = true;
  3508. return;
  3509. }
  3510. callback();
  3511. });
  3512. vue.onDeactivated(() => {
  3513. isDeactivatedRef.isDeactivated = true;
  3514. if (!activateStateInitialized) {
  3515. activateStateInitialized = true;
  3516. }
  3517. });
  3518. return isDeactivatedRef;
  3519. }
  3520. var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
  3521. var freeSelf = typeof self == "object" && self && self.Object === Object && self;
  3522. var root = freeGlobal || freeSelf || Function("return this")();
  3523. var Symbol$1 = root.Symbol;
  3524. var objectProto$e = Object.prototype;
  3525. var hasOwnProperty$b = objectProto$e.hasOwnProperty;
  3526. var nativeObjectToString$1 = objectProto$e.toString;
  3527. var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
  3528. function getRawTag(value) {
  3529. var isOwn = hasOwnProperty$b.call(value, symToStringTag$1), tag = value[symToStringTag$1];
  3530. try {
  3531. value[symToStringTag$1] = void 0;
  3532. var unmasked = true;
  3533. } catch (e) {
  3534. }
  3535. var result = nativeObjectToString$1.call(value);
  3536. if (unmasked) {
  3537. if (isOwn) {
  3538. value[symToStringTag$1] = tag;
  3539. } else {
  3540. delete value[symToStringTag$1];
  3541. }
  3542. }
  3543. return result;
  3544. }
  3545. var objectProto$d = Object.prototype;
  3546. var nativeObjectToString = objectProto$d.toString;
  3547. function objectToString(value) {
  3548. return nativeObjectToString.call(value);
  3549. }
  3550. var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
  3551. var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
  3552. function baseGetTag(value) {
  3553. if (value == null) {
  3554. return value === void 0 ? undefinedTag : nullTag;
  3555. }
  3556. return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
  3557. }
  3558. function isObjectLike(value) {
  3559. return value != null && typeof value == "object";
  3560. }
  3561. var symbolTag$1 = "[object Symbol]";
  3562. function isSymbol(value) {
  3563. return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$1;
  3564. }
  3565. function arrayMap(array, iteratee) {
  3566. var index = -1, length = array == null ? 0 : array.length, result = Array(length);
  3567. while (++index < length) {
  3568. result[index] = iteratee(array[index], index, array);
  3569. }
  3570. return result;
  3571. }
  3572. var isArray = Array.isArray;
  3573. var INFINITY$1 = 1 / 0;
  3574. var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
  3575. function baseToString(value) {
  3576. if (typeof value == "string") {
  3577. return value;
  3578. }
  3579. if (isArray(value)) {
  3580. return arrayMap(value, baseToString) + "";
  3581. }
  3582. if (isSymbol(value)) {
  3583. return symbolToString ? symbolToString.call(value) : "";
  3584. }
  3585. var result = value + "";
  3586. return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
  3587. }
  3588. function isObject(value) {
  3589. var type = typeof value;
  3590. return value != null && (type == "object" || type == "function");
  3591. }
  3592. function identity(value) {
  3593. return value;
  3594. }
  3595. var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
  3596. function isFunction(value) {
  3597. if (!isObject(value)) {
  3598. return false;
  3599. }
  3600. var tag = baseGetTag(value);
  3601. return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
  3602. }
  3603. var coreJsData = root["__core-js_shared__"];
  3604. var maskSrcKey = function() {
  3605. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
  3606. return uid ? "Symbol(src)_1." + uid : "";
  3607. }();
  3608. function isMasked(func) {
  3609. return !!maskSrcKey && maskSrcKey in func;
  3610. }
  3611. var funcProto$2 = Function.prototype;
  3612. var funcToString$2 = funcProto$2.toString;
  3613. function toSource(func) {
  3614. if (func != null) {
  3615. try {
  3616. return funcToString$2.call(func);
  3617. } catch (e) {
  3618. }
  3619. try {
  3620. return func + "";
  3621. } catch (e) {
  3622. }
  3623. }
  3624. return "";
  3625. }
  3626. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  3627. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  3628. var funcProto$1 = Function.prototype, objectProto$c = Object.prototype;
  3629. var funcToString$1 = funcProto$1.toString;
  3630. var hasOwnProperty$a = objectProto$c.hasOwnProperty;
  3631. var reIsNative = RegExp(
  3632. "^" + funcToString$1.call(hasOwnProperty$a).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
  3633. );
  3634. function baseIsNative(value) {
  3635. if (!isObject(value) || isMasked(value)) {
  3636. return false;
  3637. }
  3638. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  3639. return pattern.test(toSource(value));
  3640. }
  3641. function getValue(object, key) {
  3642. return object == null ? void 0 : object[key];
  3643. }
  3644. function getNative(object, key) {
  3645. var value = getValue(object, key);
  3646. return baseIsNative(value) ? value : void 0;
  3647. }
  3648. var WeakMap$1 = getNative(root, "WeakMap");
  3649. var objectCreate = Object.create;
  3650. var baseCreate = /* @__PURE__ */ function() {
  3651. function object() {
  3652. }
  3653. return function(proto) {
  3654. if (!isObject(proto)) {
  3655. return {};
  3656. }
  3657. if (objectCreate) {
  3658. return objectCreate(proto);
  3659. }
  3660. object.prototype = proto;
  3661. var result = new object();
  3662. object.prototype = void 0;
  3663. return result;
  3664. };
  3665. }();
  3666. function apply(func, thisArg, args) {
  3667. switch (args.length) {
  3668. case 0:
  3669. return func.call(thisArg);
  3670. case 1:
  3671. return func.call(thisArg, args[0]);
  3672. case 2:
  3673. return func.call(thisArg, args[0], args[1]);
  3674. case 3:
  3675. return func.call(thisArg, args[0], args[1], args[2]);
  3676. }
  3677. return func.apply(thisArg, args);
  3678. }
  3679. function copyArray(source, array) {
  3680. var index = -1, length = source.length;
  3681. array || (array = Array(length));
  3682. while (++index < length) {
  3683. array[index] = source[index];
  3684. }
  3685. return array;
  3686. }
  3687. var HOT_COUNT = 800, HOT_SPAN = 16;
  3688. var nativeNow = Date.now;
  3689. function shortOut(func) {
  3690. var count = 0, lastCalled = 0;
  3691. return function() {
  3692. var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
  3693. lastCalled = stamp;
  3694. if (remaining > 0) {
  3695. if (++count >= HOT_COUNT) {
  3696. return arguments[0];
  3697. }
  3698. } else {
  3699. count = 0;
  3700. }
  3701. return func.apply(void 0, arguments);
  3702. };
  3703. }
  3704. function constant(value) {
  3705. return function() {
  3706. return value;
  3707. };
  3708. }
  3709. var defineProperty = function() {
  3710. try {
  3711. var func = getNative(Object, "defineProperty");
  3712. func({}, "", {});
  3713. return func;
  3714. } catch (e) {
  3715. }
  3716. }();
  3717. var baseSetToString = !defineProperty ? identity : function(func, string) {
  3718. return defineProperty(func, "toString", {
  3719. "configurable": true,
  3720. "enumerable": false,
  3721. "value": constant(string),
  3722. "writable": true
  3723. });
  3724. };
  3725. var setToString = shortOut(baseSetToString);
  3726. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  3727. var reIsUint = /^(?:0|[1-9]\d*)$/;
  3728. function isIndex(value, length) {
  3729. var type = typeof value;
  3730. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  3731. return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
  3732. }
  3733. function baseAssignValue(object, key, value) {
  3734. if (key == "__proto__" && defineProperty) {
  3735. defineProperty(object, key, {
  3736. "configurable": true,
  3737. "enumerable": true,
  3738. "value": value,
  3739. "writable": true
  3740. });
  3741. } else {
  3742. object[key] = value;
  3743. }
  3744. }
  3745. function eq(value, other) {
  3746. return value === other || value !== value && other !== other;
  3747. }
  3748. var objectProto$b = Object.prototype;
  3749. var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
  3750. function assignValue(object, key, value) {
  3751. var objValue = object[key];
  3752. if (!(hasOwnProperty$9.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
  3753. baseAssignValue(object, key, value);
  3754. }
  3755. }
  3756. function copyObject(source, props, object, customizer) {
  3757. var isNew = !object;
  3758. object || (object = {});
  3759. var index = -1, length = props.length;
  3760. while (++index < length) {
  3761. var key = props[index];
  3762. var newValue = void 0;
  3763. if (newValue === void 0) {
  3764. newValue = source[key];
  3765. }
  3766. if (isNew) {
  3767. baseAssignValue(object, key, newValue);
  3768. } else {
  3769. assignValue(object, key, newValue);
  3770. }
  3771. }
  3772. return object;
  3773. }
  3774. var nativeMax = Math.max;
  3775. function overRest(func, start, transform) {
  3776. start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
  3777. return function() {
  3778. var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
  3779. while (++index < length) {
  3780. array[index] = args[start + index];
  3781. }
  3782. index = -1;
  3783. var otherArgs = Array(start + 1);
  3784. while (++index < start) {
  3785. otherArgs[index] = args[index];
  3786. }
  3787. otherArgs[start] = transform(array);
  3788. return apply(func, this, otherArgs);
  3789. };
  3790. }
  3791. function baseRest(func, start) {
  3792. return setToString(overRest(func, start, identity), func + "");
  3793. }
  3794. var MAX_SAFE_INTEGER = 9007199254740991;
  3795. function isLength(value) {
  3796. return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  3797. }
  3798. function isArrayLike(value) {
  3799. return value != null && isLength(value.length) && !isFunction(value);
  3800. }
  3801. function isIterateeCall(value, index, object) {
  3802. if (!isObject(object)) {
  3803. return false;
  3804. }
  3805. var type = typeof index;
  3806. if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) {
  3807. return eq(object[index], value);
  3808. }
  3809. return false;
  3810. }
  3811. function createAssigner(assigner) {
  3812. return baseRest(function(object, sources) {
  3813. var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0;
  3814. customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0;
  3815. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  3816. customizer = length < 3 ? void 0 : customizer;
  3817. length = 1;
  3818. }
  3819. object = Object(object);
  3820. while (++index < length) {
  3821. var source = sources[index];
  3822. if (source) {
  3823. assigner(object, source, index, customizer);
  3824. }
  3825. }
  3826. return object;
  3827. });
  3828. }
  3829. var objectProto$a = Object.prototype;
  3830. function isPrototype(value) {
  3831. var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$a;
  3832. return value === proto;
  3833. }
  3834. function baseTimes(n, iteratee) {
  3835. var index = -1, result = Array(n);
  3836. while (++index < n) {
  3837. result[index] = iteratee(index);
  3838. }
  3839. return result;
  3840. }
  3841. var argsTag$2 = "[object Arguments]";
  3842. function baseIsArguments(value) {
  3843. return isObjectLike(value) && baseGetTag(value) == argsTag$2;
  3844. }
  3845. var objectProto$9 = Object.prototype;
  3846. var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
  3847. var propertyIsEnumerable$1 = objectProto$9.propertyIsEnumerable;
  3848. var isArguments = baseIsArguments(/* @__PURE__ */ function() {
  3849. return arguments;
  3850. }()) ? baseIsArguments : function(value) {
  3851. return isObjectLike(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
  3852. };
  3853. function stubFalse() {
  3854. return false;
  3855. }
  3856. var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
  3857. var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
  3858. var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
  3859. var Buffer$1 = moduleExports$2 ? root.Buffer : void 0;
  3860. var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : void 0;
  3861. var isBuffer = nativeIsBuffer || stubFalse;
  3862. var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", objectTag$3 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", weakMapTag$1 = "[object WeakMap]";
  3863. var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
  3864. var typedArrayTags = {};
  3865. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  3866. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
  3867. function baseIsTypedArray(value) {
  3868. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  3869. }
  3870. function baseUnary(func) {
  3871. return function(value) {
  3872. return func(value);
  3873. };
  3874. }
  3875. var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
  3876. var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
  3877. var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
  3878. var freeProcess = moduleExports$1 && freeGlobal.process;
  3879. var nodeUtil = function() {
  3880. try {
  3881. var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
  3882. if (types) {
  3883. return types;
  3884. }
  3885. return freeProcess && freeProcess.binding && freeProcess.binding("util");
  3886. } catch (e) {
  3887. }
  3888. }();
  3889. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  3890. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  3891. var objectProto$8 = Object.prototype;
  3892. var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
  3893. function arrayLikeKeys(value, inherited) {
  3894. var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
  3895. for (var key in value) {
  3896. if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
  3897. (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
  3898. isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3899. isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
  3900. isIndex(key, length)))) {
  3901. result.push(key);
  3902. }
  3903. }
  3904. return result;
  3905. }
  3906. function overArg(func, transform) {
  3907. return function(arg) {
  3908. return func(transform(arg));
  3909. };
  3910. }
  3911. var nativeKeys = overArg(Object.keys, Object);
  3912. var objectProto$7 = Object.prototype;
  3913. var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
  3914. function baseKeys(object) {
  3915. if (!isPrototype(object)) {
  3916. return nativeKeys(object);
  3917. }
  3918. var result = [];
  3919. for (var key in Object(object)) {
  3920. if (hasOwnProperty$6.call(object, key) && key != "constructor") {
  3921. result.push(key);
  3922. }
  3923. }
  3924. return result;
  3925. }
  3926. function keys(object) {
  3927. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  3928. }
  3929. function nativeKeysIn(object) {
  3930. var result = [];
  3931. if (object != null) {
  3932. for (var key in Object(object)) {
  3933. result.push(key);
  3934. }
  3935. }
  3936. return result;
  3937. }
  3938. var objectProto$6 = Object.prototype;
  3939. var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
  3940. function baseKeysIn(object) {
  3941. if (!isObject(object)) {
  3942. return nativeKeysIn(object);
  3943. }
  3944. var isProto = isPrototype(object), result = [];
  3945. for (var key in object) {
  3946. if (!(key == "constructor" && (isProto || !hasOwnProperty$5.call(object, key)))) {
  3947. result.push(key);
  3948. }
  3949. }
  3950. return result;
  3951. }
  3952. function keysIn(object) {
  3953. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  3954. }
  3955. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
  3956. function isKey(value, object) {
  3957. if (isArray(value)) {
  3958. return false;
  3959. }
  3960. var type = typeof value;
  3961. if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
  3962. return true;
  3963. }
  3964. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
  3965. }
  3966. var nativeCreate = getNative(Object, "create");
  3967. function hashClear() {
  3968. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  3969. this.size = 0;
  3970. }
  3971. function hashDelete(key) {
  3972. var result = this.has(key) && delete this.__data__[key];
  3973. this.size -= result ? 1 : 0;
  3974. return result;
  3975. }
  3976. var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
  3977. var objectProto$5 = Object.prototype;
  3978. var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
  3979. function hashGet(key) {
  3980. var data = this.__data__;
  3981. if (nativeCreate) {
  3982. var result = data[key];
  3983. return result === HASH_UNDEFINED$2 ? void 0 : result;
  3984. }
  3985. return hasOwnProperty$4.call(data, key) ? data[key] : void 0;
  3986. }
  3987. var objectProto$4 = Object.prototype;
  3988. var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
  3989. function hashHas(key) {
  3990. var data = this.__data__;
  3991. return nativeCreate ? data[key] !== void 0 : hasOwnProperty$3.call(data, key);
  3992. }
  3993. var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
  3994. function hashSet(key, value) {
  3995. var data = this.__data__;
  3996. this.size += this.has(key) ? 0 : 1;
  3997. data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED$1 : value;
  3998. return this;
  3999. }
  4000. function Hash(entries) {
  4001. var index = -1, length = entries == null ? 0 : entries.length;
  4002. this.clear();
  4003. while (++index < length) {
  4004. var entry = entries[index];
  4005. this.set(entry[0], entry[1]);
  4006. }
  4007. }
  4008. Hash.prototype.clear = hashClear;
  4009. Hash.prototype["delete"] = hashDelete;
  4010. Hash.prototype.get = hashGet;
  4011. Hash.prototype.has = hashHas;
  4012. Hash.prototype.set = hashSet;
  4013. function listCacheClear() {
  4014. this.__data__ = [];
  4015. this.size = 0;
  4016. }
  4017. function assocIndexOf(array, key) {
  4018. var length = array.length;
  4019. while (length--) {
  4020. if (eq(array[length][0], key)) {
  4021. return length;
  4022. }
  4023. }
  4024. return -1;
  4025. }
  4026. var arrayProto = Array.prototype;
  4027. var splice = arrayProto.splice;
  4028. function listCacheDelete(key) {
  4029. var data = this.__data__, index = assocIndexOf(data, key);
  4030. if (index < 0) {
  4031. return false;
  4032. }
  4033. var lastIndex = data.length - 1;
  4034. if (index == lastIndex) {
  4035. data.pop();
  4036. } else {
  4037. splice.call(data, index, 1);
  4038. }
  4039. --this.size;
  4040. return true;
  4041. }
  4042. function listCacheGet(key) {
  4043. var data = this.__data__, index = assocIndexOf(data, key);
  4044. return index < 0 ? void 0 : data[index][1];
  4045. }
  4046. function listCacheHas(key) {
  4047. return assocIndexOf(this.__data__, key) > -1;
  4048. }
  4049. function listCacheSet(key, value) {
  4050. var data = this.__data__, index = assocIndexOf(data, key);
  4051. if (index < 0) {
  4052. ++this.size;
  4053. data.push([key, value]);
  4054. } else {
  4055. data[index][1] = value;
  4056. }
  4057. return this;
  4058. }
  4059. function ListCache(entries) {
  4060. var index = -1, length = entries == null ? 0 : entries.length;
  4061. this.clear();
  4062. while (++index < length) {
  4063. var entry = entries[index];
  4064. this.set(entry[0], entry[1]);
  4065. }
  4066. }
  4067. ListCache.prototype.clear = listCacheClear;
  4068. ListCache.prototype["delete"] = listCacheDelete;
  4069. ListCache.prototype.get = listCacheGet;
  4070. ListCache.prototype.has = listCacheHas;
  4071. ListCache.prototype.set = listCacheSet;
  4072. var Map$1 = getNative(root, "Map");
  4073. function mapCacheClear() {
  4074. this.size = 0;
  4075. this.__data__ = {
  4076. "hash": new Hash(),
  4077. "map": new (Map$1 || ListCache)(),
  4078. "string": new Hash()
  4079. };
  4080. }
  4081. function isKeyable(value) {
  4082. var type = typeof value;
  4083. return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
  4084. }
  4085. function getMapData(map2, key) {
  4086. var data = map2.__data__;
  4087. return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
  4088. }
  4089. function mapCacheDelete(key) {
  4090. var result = getMapData(this, key)["delete"](key);
  4091. this.size -= result ? 1 : 0;
  4092. return result;
  4093. }
  4094. function mapCacheGet(key) {
  4095. return getMapData(this, key).get(key);
  4096. }
  4097. function mapCacheHas(key) {
  4098. return getMapData(this, key).has(key);
  4099. }
  4100. function mapCacheSet(key, value) {
  4101. var data = getMapData(this, key), size2 = data.size;
  4102. data.set(key, value);
  4103. this.size += data.size == size2 ? 0 : 1;
  4104. return this;
  4105. }
  4106. function MapCache(entries) {
  4107. var index = -1, length = entries == null ? 0 : entries.length;
  4108. this.clear();
  4109. while (++index < length) {
  4110. var entry = entries[index];
  4111. this.set(entry[0], entry[1]);
  4112. }
  4113. }
  4114. MapCache.prototype.clear = mapCacheClear;
  4115. MapCache.prototype["delete"] = mapCacheDelete;
  4116. MapCache.prototype.get = mapCacheGet;
  4117. MapCache.prototype.has = mapCacheHas;
  4118. MapCache.prototype.set = mapCacheSet;
  4119. var FUNC_ERROR_TEXT = "Expected a function";
  4120. function memoize(func, resolver) {
  4121. if (typeof func != "function" || resolver != null && typeof resolver != "function") {
  4122. throw new TypeError(FUNC_ERROR_TEXT);
  4123. }
  4124. var memoized = function() {
  4125. var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache2 = memoized.cache;
  4126. if (cache2.has(key)) {
  4127. return cache2.get(key);
  4128. }
  4129. var result = func.apply(this, args);
  4130. memoized.cache = cache2.set(key, result) || cache2;
  4131. return result;
  4132. };
  4133. memoized.cache = new (memoize.Cache || MapCache)();
  4134. return memoized;
  4135. }
  4136. memoize.Cache = MapCache;
  4137. var MAX_MEMOIZE_SIZE = 500;
  4138. function memoizeCapped(func) {
  4139. var result = memoize(func, function(key) {
  4140. if (cache2.size === MAX_MEMOIZE_SIZE) {
  4141. cache2.clear();
  4142. }
  4143. return key;
  4144. });
  4145. var cache2 = result.cache;
  4146. return result;
  4147. }
  4148. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  4149. var reEscapeChar = /\\(\\)?/g;
  4150. var stringToPath = memoizeCapped(function(string) {
  4151. var result = [];
  4152. if (string.charCodeAt(0) === 46) {
  4153. result.push("");
  4154. }
  4155. string.replace(rePropName, function(match, number, quote, subString) {
  4156. result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
  4157. });
  4158. return result;
  4159. });
  4160. function toString(value) {
  4161. return value == null ? "" : baseToString(value);
  4162. }
  4163. function castPath(value, object) {
  4164. if (isArray(value)) {
  4165. return value;
  4166. }
  4167. return isKey(value, object) ? [value] : stringToPath(toString(value));
  4168. }
  4169. var INFINITY = 1 / 0;
  4170. function toKey(value) {
  4171. if (typeof value == "string" || isSymbol(value)) {
  4172. return value;
  4173. }
  4174. var result = value + "";
  4175. return result == "0" && 1 / value == -INFINITY ? "-0" : result;
  4176. }
  4177. function baseGet(object, path) {
  4178. path = castPath(path, object);
  4179. var index = 0, length = path.length;
  4180. while (object != null && index < length) {
  4181. object = object[toKey(path[index++])];
  4182. }
  4183. return index && index == length ? object : void 0;
  4184. }
  4185. function get(object, path, defaultValue) {
  4186. var result = object == null ? void 0 : baseGet(object, path);
  4187. return result === void 0 ? defaultValue : result;
  4188. }
  4189. function arrayPush(array, values) {
  4190. var index = -1, length = values.length, offset = array.length;
  4191. while (++index < length) {
  4192. array[offset + index] = values[index];
  4193. }
  4194. return array;
  4195. }
  4196. var getPrototype = overArg(Object.getPrototypeOf, Object);
  4197. var objectTag$2 = "[object Object]";
  4198. var funcProto = Function.prototype, objectProto$3 = Object.prototype;
  4199. var funcToString = funcProto.toString;
  4200. var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
  4201. var objectCtorString = funcToString.call(Object);
  4202. function isPlainObject(value) {
  4203. if (!isObjectLike(value) || baseGetTag(value) != objectTag$2) {
  4204. return false;
  4205. }
  4206. var proto = getPrototype(value);
  4207. if (proto === null) {
  4208. return true;
  4209. }
  4210. var Ctor = hasOwnProperty$2.call(proto, "constructor") && proto.constructor;
  4211. return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
  4212. }
  4213. function stackClear() {
  4214. this.__data__ = new ListCache();
  4215. this.size = 0;
  4216. }
  4217. function stackDelete(key) {
  4218. var data = this.__data__, result = data["delete"](key);
  4219. this.size = data.size;
  4220. return result;
  4221. }
  4222. function stackGet(key) {
  4223. return this.__data__.get(key);
  4224. }
  4225. function stackHas(key) {
  4226. return this.__data__.has(key);
  4227. }
  4228. var LARGE_ARRAY_SIZE = 200;
  4229. function stackSet(key, value) {
  4230. var data = this.__data__;
  4231. if (data instanceof ListCache) {
  4232. var pairs = data.__data__;
  4233. if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
  4234. pairs.push([key, value]);
  4235. this.size = ++data.size;
  4236. return this;
  4237. }
  4238. data = this.__data__ = new MapCache(pairs);
  4239. }
  4240. data.set(key, value);
  4241. this.size = data.size;
  4242. return this;
  4243. }
  4244. function Stack(entries) {
  4245. var data = this.__data__ = new ListCache(entries);
  4246. this.size = data.size;
  4247. }
  4248. Stack.prototype.clear = stackClear;
  4249. Stack.prototype["delete"] = stackDelete;
  4250. Stack.prototype.get = stackGet;
  4251. Stack.prototype.has = stackHas;
  4252. Stack.prototype.set = stackSet;
  4253. var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
  4254. var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
  4255. var moduleExports = freeModule && freeModule.exports === freeExports;
  4256. var Buffer2 = moduleExports ? root.Buffer : void 0;
  4257. Buffer2 ? Buffer2.allocUnsafe : void 0;
  4258. function cloneBuffer(buffer, isDeep) {
  4259. {
  4260. return buffer.slice();
  4261. }
  4262. }
  4263. function arrayFilter(array, predicate) {
  4264. var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
  4265. while (++index < length) {
  4266. var value = array[index];
  4267. if (predicate(value, index, array)) {
  4268. result[resIndex++] = value;
  4269. }
  4270. }
  4271. return result;
  4272. }
  4273. function stubArray() {
  4274. return [];
  4275. }
  4276. var objectProto$2 = Object.prototype;
  4277. var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
  4278. var nativeGetSymbols = Object.getOwnPropertySymbols;
  4279. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  4280. if (object == null) {
  4281. return [];
  4282. }
  4283. object = Object(object);
  4284. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  4285. return propertyIsEnumerable.call(object, symbol);
  4286. });
  4287. };
  4288. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  4289. var result = keysFunc(object);
  4290. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  4291. }
  4292. function getAllKeys(object) {
  4293. return baseGetAllKeys(object, keys, getSymbols);
  4294. }
  4295. var DataView = getNative(root, "DataView");
  4296. var Promise$1 = getNative(root, "Promise");
  4297. var Set$1 = getNative(root, "Set");
  4298. var mapTag$1 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$1 = "[object Set]", weakMapTag = "[object WeakMap]";
  4299. var dataViewTag$1 = "[object DataView]";
  4300. var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
  4301. var getTag = baseGetTag;
  4302. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1 || Map$1 && getTag(new Map$1()) != mapTag$1 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$1 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag) {
  4303. getTag = function(value) {
  4304. var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
  4305. if (ctorString) {
  4306. switch (ctorString) {
  4307. case dataViewCtorString:
  4308. return dataViewTag$1;
  4309. case mapCtorString:
  4310. return mapTag$1;
  4311. case promiseCtorString:
  4312. return promiseTag;
  4313. case setCtorString:
  4314. return setTag$1;
  4315. case weakMapCtorString:
  4316. return weakMapTag;
  4317. }
  4318. }
  4319. return result;
  4320. };
  4321. }
  4322. var Uint8Array2 = root.Uint8Array;
  4323. function cloneArrayBuffer(arrayBuffer) {
  4324. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  4325. new Uint8Array2(result).set(new Uint8Array2(arrayBuffer));
  4326. return result;
  4327. }
  4328. function cloneTypedArray(typedArray, isDeep) {
  4329. var buffer = cloneArrayBuffer(typedArray.buffer);
  4330. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  4331. }
  4332. function initCloneObject(object) {
  4333. return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
  4334. }
  4335. var HASH_UNDEFINED = "__lodash_hash_undefined__";
  4336. function setCacheAdd(value) {
  4337. this.__data__.set(value, HASH_UNDEFINED);
  4338. return this;
  4339. }
  4340. function setCacheHas(value) {
  4341. return this.__data__.has(value);
  4342. }
  4343. function SetCache(values) {
  4344. var index = -1, length = values == null ? 0 : values.length;
  4345. this.__data__ = new MapCache();
  4346. while (++index < length) {
  4347. this.add(values[index]);
  4348. }
  4349. }
  4350. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  4351. SetCache.prototype.has = setCacheHas;
  4352. function arraySome(array, predicate) {
  4353. var index = -1, length = array == null ? 0 : array.length;
  4354. while (++index < length) {
  4355. if (predicate(array[index], index, array)) {
  4356. return true;
  4357. }
  4358. }
  4359. return false;
  4360. }
  4361. function cacheHas(cache2, key) {
  4362. return cache2.has(key);
  4363. }
  4364. var COMPARE_PARTIAL_FLAG$5 = 1, COMPARE_UNORDERED_FLAG$3 = 2;
  4365. function equalArrays(array, other, bitmask, customizer, equalFunc, stack2) {
  4366. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, arrLength = array.length, othLength = other.length;
  4367. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  4368. return false;
  4369. }
  4370. var arrStacked = stack2.get(array);
  4371. var othStacked = stack2.get(other);
  4372. if (arrStacked && othStacked) {
  4373. return arrStacked == other && othStacked == array;
  4374. }
  4375. var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : void 0;
  4376. stack2.set(array, other);
  4377. stack2.set(other, array);
  4378. while (++index < arrLength) {
  4379. var arrValue = array[index], othValue = other[index];
  4380. if (customizer) {
  4381. var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack2) : customizer(arrValue, othValue, index, array, other, stack2);
  4382. }
  4383. if (compared !== void 0) {
  4384. if (compared) {
  4385. continue;
  4386. }
  4387. result = false;
  4388. break;
  4389. }
  4390. if (seen) {
  4391. if (!arraySome(other, function(othValue2, othIndex) {
  4392. if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack2))) {
  4393. return seen.push(othIndex);
  4394. }
  4395. })) {
  4396. result = false;
  4397. break;
  4398. }
  4399. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack2))) {
  4400. result = false;
  4401. break;
  4402. }
  4403. }
  4404. stack2["delete"](array);
  4405. stack2["delete"](other);
  4406. return result;
  4407. }
  4408. function mapToArray(map2) {
  4409. var index = -1, result = Array(map2.size);
  4410. map2.forEach(function(value, key) {
  4411. result[++index] = [key, value];
  4412. });
  4413. return result;
  4414. }
  4415. function setToArray(set) {
  4416. var index = -1, result = Array(set.size);
  4417. set.forEach(function(value) {
  4418. result[++index] = value;
  4419. });
  4420. return result;
  4421. }
  4422. var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
  4423. var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
  4424. var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]";
  4425. var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
  4426. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack2) {
  4427. switch (tag) {
  4428. case dataViewTag:
  4429. if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
  4430. return false;
  4431. }
  4432. object = object.buffer;
  4433. other = other.buffer;
  4434. case arrayBufferTag:
  4435. if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
  4436. return false;
  4437. }
  4438. return true;
  4439. case boolTag:
  4440. case dateTag:
  4441. case numberTag:
  4442. return eq(+object, +other);
  4443. case errorTag:
  4444. return object.name == other.name && object.message == other.message;
  4445. case regexpTag:
  4446. case stringTag:
  4447. return object == other + "";
  4448. case mapTag:
  4449. var convert = mapToArray;
  4450. case setTag:
  4451. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
  4452. convert || (convert = setToArray);
  4453. if (object.size != other.size && !isPartial) {
  4454. return false;
  4455. }
  4456. var stacked = stack2.get(object);
  4457. if (stacked) {
  4458. return stacked == other;
  4459. }
  4460. bitmask |= COMPARE_UNORDERED_FLAG$2;
  4461. stack2.set(object, other);
  4462. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack2);
  4463. stack2["delete"](object);
  4464. return result;
  4465. case symbolTag:
  4466. if (symbolValueOf) {
  4467. return symbolValueOf.call(object) == symbolValueOf.call(other);
  4468. }
  4469. }
  4470. return false;
  4471. }
  4472. var COMPARE_PARTIAL_FLAG$3 = 1;
  4473. var objectProto$1 = Object.prototype;
  4474. var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
  4475. function equalObjects(object, other, bitmask, customizer, equalFunc, stack2) {
  4476. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
  4477. if (objLength != othLength && !isPartial) {
  4478. return false;
  4479. }
  4480. var index = objLength;
  4481. while (index--) {
  4482. var key = objProps[index];
  4483. if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
  4484. return false;
  4485. }
  4486. }
  4487. var objStacked = stack2.get(object);
  4488. var othStacked = stack2.get(other);
  4489. if (objStacked && othStacked) {
  4490. return objStacked == other && othStacked == object;
  4491. }
  4492. var result = true;
  4493. stack2.set(object, other);
  4494. stack2.set(other, object);
  4495. var skipCtor = isPartial;
  4496. while (++index < objLength) {
  4497. key = objProps[index];
  4498. var objValue = object[key], othValue = other[key];
  4499. if (customizer) {
  4500. var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack2) : customizer(objValue, othValue, key, object, other, stack2);
  4501. }
  4502. if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack2) : compared)) {
  4503. result = false;
  4504. break;
  4505. }
  4506. skipCtor || (skipCtor = key == "constructor");
  4507. }
  4508. if (result && !skipCtor) {
  4509. var objCtor = object.constructor, othCtor = other.constructor;
  4510. if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
  4511. result = false;
  4512. }
  4513. }
  4514. stack2["delete"](object);
  4515. stack2["delete"](other);
  4516. return result;
  4517. }
  4518. var COMPARE_PARTIAL_FLAG$2 = 1;
  4519. var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
  4520. var objectProto = Object.prototype;
  4521. var hasOwnProperty = objectProto.hasOwnProperty;
  4522. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack2) {
  4523. var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
  4524. objTag = objTag == argsTag ? objectTag : objTag;
  4525. othTag = othTag == argsTag ? objectTag : othTag;
  4526. var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
  4527. if (isSameTag && isBuffer(object)) {
  4528. if (!isBuffer(other)) {
  4529. return false;
  4530. }
  4531. objIsArr = true;
  4532. objIsObj = false;
  4533. }
  4534. if (isSameTag && !objIsObj) {
  4535. stack2 || (stack2 = new Stack());
  4536. return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack2) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack2);
  4537. }
  4538. if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
  4539. var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
  4540. if (objIsWrapped || othIsWrapped) {
  4541. var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
  4542. stack2 || (stack2 = new Stack());
  4543. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack2);
  4544. }
  4545. }
  4546. if (!isSameTag) {
  4547. return false;
  4548. }
  4549. stack2 || (stack2 = new Stack());
  4550. return equalObjects(object, other, bitmask, customizer, equalFunc, stack2);
  4551. }
  4552. function baseIsEqual(value, other, bitmask, customizer, stack2) {
  4553. if (value === other) {
  4554. return true;
  4555. }
  4556. if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
  4557. return value !== value && other !== other;
  4558. }
  4559. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack2);
  4560. }
  4561. var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
  4562. function baseIsMatch(object, source, matchData, customizer) {
  4563. var index = matchData.length, length = index;
  4564. if (object == null) {
  4565. return !length;
  4566. }
  4567. object = Object(object);
  4568. while (index--) {
  4569. var data = matchData[index];
  4570. if (data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
  4571. return false;
  4572. }
  4573. }
  4574. while (++index < length) {
  4575. data = matchData[index];
  4576. var key = data[0], objValue = object[key], srcValue = data[1];
  4577. if (data[2]) {
  4578. if (objValue === void 0 && !(key in object)) {
  4579. return false;
  4580. }
  4581. } else {
  4582. var stack2 = new Stack();
  4583. var result;
  4584. if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack2) : result)) {
  4585. return false;
  4586. }
  4587. }
  4588. }
  4589. return true;
  4590. }
  4591. function isStrictComparable(value) {
  4592. return value === value && !isObject(value);
  4593. }
  4594. function getMatchData(object) {
  4595. var result = keys(object), length = result.length;
  4596. while (length--) {
  4597. var key = result[length], value = object[key];
  4598. result[length] = [key, value, isStrictComparable(value)];
  4599. }
  4600. return result;
  4601. }
  4602. function matchesStrictComparable(key, srcValue) {
  4603. return function(object) {
  4604. if (object == null) {
  4605. return false;
  4606. }
  4607. return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
  4608. };
  4609. }
  4610. function baseMatches(source) {
  4611. var matchData = getMatchData(source);
  4612. if (matchData.length == 1 && matchData[0][2]) {
  4613. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4614. }
  4615. return function(object) {
  4616. return object === source || baseIsMatch(object, source, matchData);
  4617. };
  4618. }
  4619. function baseHasIn(object, key) {
  4620. return object != null && key in Object(object);
  4621. }
  4622. function hasPath(object, path, hasFunc) {
  4623. path = castPath(path, object);
  4624. var index = -1, length = path.length, result = false;
  4625. while (++index < length) {
  4626. var key = toKey(path[index]);
  4627. if (!(result = object != null && hasFunc(object, key))) {
  4628. break;
  4629. }
  4630. object = object[key];
  4631. }
  4632. if (result || ++index != length) {
  4633. return result;
  4634. }
  4635. length = object == null ? 0 : object.length;
  4636. return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
  4637. }
  4638. function hasIn(object, path) {
  4639. return object != null && hasPath(object, path, baseHasIn);
  4640. }
  4641. var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
  4642. function baseMatchesProperty(path, srcValue) {
  4643. if (isKey(path) && isStrictComparable(srcValue)) {
  4644. return matchesStrictComparable(toKey(path), srcValue);
  4645. }
  4646. return function(object) {
  4647. var objValue = get(object, path);
  4648. return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  4649. };
  4650. }
  4651. function baseProperty(key) {
  4652. return function(object) {
  4653. return object == null ? void 0 : object[key];
  4654. };
  4655. }
  4656. function basePropertyDeep(path) {
  4657. return function(object) {
  4658. return baseGet(object, path);
  4659. };
  4660. }
  4661. function property(path) {
  4662. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4663. }
  4664. function baseIteratee(value) {
  4665. if (typeof value == "function") {
  4666. return value;
  4667. }
  4668. if (value == null) {
  4669. return identity;
  4670. }
  4671. if (typeof value == "object") {
  4672. return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
  4673. }
  4674. return property(value);
  4675. }
  4676. function createBaseFor(fromRight) {
  4677. return function(object, iteratee, keysFunc) {
  4678. var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
  4679. while (length--) {
  4680. var key = props[++index];
  4681. if (iteratee(iterable[key], key, iterable) === false) {
  4682. break;
  4683. }
  4684. }
  4685. return object;
  4686. };
  4687. }
  4688. var baseFor = createBaseFor();
  4689. function baseForOwn(object, iteratee) {
  4690. return object && baseFor(object, iteratee, keys);
  4691. }
  4692. function createBaseEach(eachFunc, fromRight) {
  4693. return function(collection, iteratee) {
  4694. if (collection == null) {
  4695. return collection;
  4696. }
  4697. if (!isArrayLike(collection)) {
  4698. return eachFunc(collection, iteratee);
  4699. }
  4700. var length = collection.length, index = -1, iterable = Object(collection);
  4701. while (++index < length) {
  4702. if (iteratee(iterable[index], index, iterable) === false) {
  4703. break;
  4704. }
  4705. }
  4706. return collection;
  4707. };
  4708. }
  4709. var baseEach = createBaseEach(baseForOwn);
  4710. function assignMergeValue(object, key, value) {
  4711. if (value !== void 0 && !eq(object[key], value) || value === void 0 && !(key in object)) {
  4712. baseAssignValue(object, key, value);
  4713. }
  4714. }
  4715. function isArrayLikeObject(value) {
  4716. return isObjectLike(value) && isArrayLike(value);
  4717. }
  4718. function safeGet(object, key) {
  4719. if (key === "constructor" && typeof object[key] === "function") {
  4720. return;
  4721. }
  4722. if (key == "__proto__") {
  4723. return;
  4724. }
  4725. return object[key];
  4726. }
  4727. function toPlainObject(value) {
  4728. return copyObject(value, keysIn(value));
  4729. }
  4730. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack2) {
  4731. var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack2.get(srcValue);
  4732. if (stacked) {
  4733. assignMergeValue(object, key, stacked);
  4734. return;
  4735. }
  4736. var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack2) : void 0;
  4737. var isCommon = newValue === void 0;
  4738. if (isCommon) {
  4739. var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4740. newValue = srcValue;
  4741. if (isArr || isBuff || isTyped) {
  4742. if (isArray(objValue)) {
  4743. newValue = objValue;
  4744. } else if (isArrayLikeObject(objValue)) {
  4745. newValue = copyArray(objValue);
  4746. } else if (isBuff) {
  4747. isCommon = false;
  4748. newValue = cloneBuffer(srcValue);
  4749. } else if (isTyped) {
  4750. isCommon = false;
  4751. newValue = cloneTypedArray(srcValue);
  4752. } else {
  4753. newValue = [];
  4754. }
  4755. } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4756. newValue = objValue;
  4757. if (isArguments(objValue)) {
  4758. newValue = toPlainObject(objValue);
  4759. } else if (!isObject(objValue) || isFunction(objValue)) {
  4760. newValue = initCloneObject(srcValue);
  4761. }
  4762. } else {
  4763. isCommon = false;
  4764. }
  4765. }
  4766. if (isCommon) {
  4767. stack2.set(srcValue, newValue);
  4768. mergeFunc(newValue, srcValue, srcIndex, customizer, stack2);
  4769. stack2["delete"](srcValue);
  4770. }
  4771. assignMergeValue(object, key, newValue);
  4772. }
  4773. function baseMerge(object, source, srcIndex, customizer, stack2) {
  4774. if (object === source) {
  4775. return;
  4776. }
  4777. baseFor(source, function(srcValue, key) {
  4778. stack2 || (stack2 = new Stack());
  4779. if (isObject(srcValue)) {
  4780. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack2);
  4781. } else {
  4782. var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack2) : void 0;
  4783. if (newValue === void 0) {
  4784. newValue = srcValue;
  4785. }
  4786. assignMergeValue(object, key, newValue);
  4787. }
  4788. }, keysIn);
  4789. }
  4790. function baseMap(collection, iteratee) {
  4791. var index = -1, result = isArrayLike(collection) ? Array(collection.length) : [];
  4792. baseEach(collection, function(value, key, collection2) {
  4793. result[++index] = iteratee(value, key, collection2);
  4794. });
  4795. return result;
  4796. }
  4797. function map(collection, iteratee) {
  4798. var func = isArray(collection) ? arrayMap : baseMap;
  4799. return func(collection, baseIteratee(iteratee));
  4800. }
  4801. var merge$1 = createAssigner(function(object, source, srcIndex) {
  4802. baseMerge(object, source, srcIndex);
  4803. });
  4804. const commonVariables$2 = {
  4805. fontFamily: 'v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
  4806. fontFamilyMono: "v-mono, SFMono-Regular, Menlo, Consolas, Courier, monospace",
  4807. fontWeight: "400",
  4808. fontWeightStrong: "500",
  4809. cubicBezierEaseInOut: "cubic-bezier(.4, 0, .2, 1)",
  4810. cubicBezierEaseOut: "cubic-bezier(0, 0, .2, 1)",
  4811. cubicBezierEaseIn: "cubic-bezier(.4, 0, 1, 1)",
  4812. borderRadius: "3px",
  4813. borderRadiusSmall: "2px",
  4814. fontSize: "14px",
  4815. fontSizeMini: "12px",
  4816. fontSizeTiny: "12px",
  4817. fontSizeSmall: "14px",
  4818. fontSizeMedium: "14px",
  4819. fontSizeLarge: "15px",
  4820. fontSizeHuge: "16px",
  4821. lineHeight: "1.6",
  4822. heightMini: "16px",
  4823. // private now, it's too small
  4824. heightTiny: "22px",
  4825. heightSmall: "28px",
  4826. heightMedium: "34px",
  4827. heightLarge: "40px",
  4828. heightHuge: "46px"
  4829. };
  4830. const {
  4831. fontSize,
  4832. fontFamily,
  4833. lineHeight
  4834. } = commonVariables$2;
  4835. const globalStyle = c$1("body", `
  4836. margin: 0;
  4837. font-size: ${fontSize};
  4838. font-family: ${fontFamily};
  4839. line-height: ${lineHeight};
  4840. -webkit-text-size-adjust: 100%;
  4841. -webkit-tap-highlight-color: transparent;
  4842. `, [c$1("input", `
  4843. font-family: inherit;
  4844. font-size: inherit;
  4845. `)]);
  4846. const configProviderInjectionKey = createInjectionKey("n-config-provider");
  4847. const cssrAnchorMetaName = "naive-ui-style";
  4848. function createTheme(theme) {
  4849. return theme;
  4850. }
  4851. function useTheme(resolveId, mountId, style2, defaultTheme, props, clsPrefixRef) {
  4852. const ssrAdapter2 = useSsrAdapter();
  4853. const NConfigProvider = vue.inject(configProviderInjectionKey, null);
  4854. if (style2) {
  4855. const mountStyle = () => {
  4856. const clsPrefix = clsPrefixRef === null || clsPrefixRef === void 0 ? void 0 : clsPrefixRef.value;
  4857. style2.mount({
  4858. id: clsPrefix === void 0 ? mountId : clsPrefix + mountId,
  4859. head: true,
  4860. props: {
  4861. bPrefix: clsPrefix ? `.${clsPrefix}-` : void 0
  4862. },
  4863. anchorMetaName: cssrAnchorMetaName,
  4864. ssr: ssrAdapter2
  4865. });
  4866. if (!(NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled)) {
  4867. globalStyle.mount({
  4868. id: "n-global",
  4869. head: true,
  4870. anchorMetaName: cssrAnchorMetaName,
  4871. ssr: ssrAdapter2
  4872. });
  4873. }
  4874. };
  4875. if (ssrAdapter2) {
  4876. mountStyle();
  4877. } else {
  4878. vue.onBeforeMount(mountStyle);
  4879. }
  4880. }
  4881. const mergedThemeRef = vue.computed(() => {
  4882. var _a;
  4883. const {
  4884. theme: {
  4885. common: selfCommon,
  4886. self: self2,
  4887. peers = {}
  4888. } = {},
  4889. themeOverrides: selfOverrides = {},
  4890. builtinThemeOverrides: builtinOverrides = {}
  4891. } = props;
  4892. const {
  4893. common: selfCommonOverrides,
  4894. peers: peersOverrides
  4895. } = selfOverrides;
  4896. const {
  4897. common: globalCommon = void 0,
  4898. [resolveId]: {
  4899. common: globalSelfCommon = void 0,
  4900. self: globalSelf = void 0,
  4901. peers: globalPeers = {}
  4902. } = {}
  4903. } = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeRef.value) || {};
  4904. const {
  4905. common: globalCommonOverrides = void 0,
  4906. [resolveId]: globalSelfOverrides = {}
  4907. } = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeOverridesRef.value) || {};
  4908. const {
  4909. common: globalSelfCommonOverrides,
  4910. peers: globalPeersOverrides = {}
  4911. } = globalSelfOverrides;
  4912. const mergedCommon = merge$1({}, selfCommon || globalSelfCommon || globalCommon || defaultTheme.common, globalCommonOverrides, globalSelfCommonOverrides, selfCommonOverrides);
  4913. const mergedSelf = merge$1(
  4914. // {}, executed every time, no need for empty obj
  4915. (_a = self2 || globalSelf || defaultTheme.self) === null || _a === void 0 ? void 0 : _a(mergedCommon),
  4916. builtinOverrides,
  4917. globalSelfOverrides,
  4918. selfOverrides
  4919. );
  4920. return {
  4921. common: mergedCommon,
  4922. self: mergedSelf,
  4923. peers: merge$1({}, defaultTheme.peers, globalPeers, peers),
  4924. peerOverrides: merge$1({}, builtinOverrides.peers, globalPeersOverrides, peersOverrides)
  4925. };
  4926. });
  4927. return mergedThemeRef;
  4928. }
  4929. useTheme.props = {
  4930. theme: Object,
  4931. themeOverrides: Object,
  4932. builtinThemeOverrides: Object
  4933. };
  4934. const defaultClsPrefix = "n";
  4935. function useConfig(props = {}, options = {
  4936. defaultBordered: true
  4937. }) {
  4938. const NConfigProvider = vue.inject(configProviderInjectionKey, null);
  4939. return {
  4940. // NConfigProvider,
  4941. inlineThemeDisabled: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.inlineThemeDisabled,
  4942. mergedRtlRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedRtlRef,
  4943. mergedComponentPropsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedComponentPropsRef,
  4944. mergedBreakpointsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBreakpointsRef,
  4945. mergedBorderedRef: vue.computed(() => {
  4946. var _a, _b;
  4947. const {
  4948. bordered
  4949. } = props;
  4950. if (bordered !== void 0)
  4951. return bordered;
  4952. 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;
  4953. }),
  4954. mergedClsPrefixRef: NConfigProvider ? NConfigProvider.mergedClsPrefixRef : vue.shallowRef(defaultClsPrefix),
  4955. namespaceRef: vue.computed(() => NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedNamespaceRef.value)
  4956. };
  4957. }
  4958. function useStyle(mountId, style2, clsPrefixRef) {
  4959. if (!style2) {
  4960. return;
  4961. }
  4962. const ssrAdapter2 = useSsrAdapter();
  4963. const NConfigProvider = vue.inject(configProviderInjectionKey, null);
  4964. const mountStyle = () => {
  4965. const clsPrefix = clsPrefixRef.value;
  4966. style2.mount({
  4967. id: clsPrefix === void 0 ? mountId : clsPrefix + mountId,
  4968. head: true,
  4969. anchorMetaName: cssrAnchorMetaName,
  4970. props: {
  4971. bPrefix: clsPrefix ? `.${clsPrefix}-` : void 0
  4972. },
  4973. ssr: ssrAdapter2
  4974. });
  4975. if (!(NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled)) {
  4976. globalStyle.mount({
  4977. id: "n-global",
  4978. head: true,
  4979. anchorMetaName: cssrAnchorMetaName,
  4980. ssr: ssrAdapter2
  4981. });
  4982. }
  4983. };
  4984. if (ssrAdapter2) {
  4985. mountStyle();
  4986. } else {
  4987. vue.onBeforeMount(mountStyle);
  4988. }
  4989. }
  4990. function useThemeClass(componentName, hashRef, cssVarsRef, props) {
  4991. var _a;
  4992. if (!cssVarsRef)
  4993. throwError("useThemeClass", "cssVarsRef is not passed");
  4994. const mergedThemeHashRef = (_a = vue.inject(configProviderInjectionKey, null)) === null || _a === void 0 ? void 0 : _a.mergedThemeHashRef;
  4995. const themeClassRef = vue.ref("");
  4996. const ssrAdapter2 = useSsrAdapter();
  4997. let renderCallback;
  4998. const hashClassPrefix = `__${componentName}`;
  4999. const mountStyle = () => {
  5000. let finalThemeHash = hashClassPrefix;
  5001. const hashValue = hashRef ? hashRef.value : void 0;
  5002. const themeHash = mergedThemeHashRef === null || mergedThemeHashRef === void 0 ? void 0 : mergedThemeHashRef.value;
  5003. if (themeHash)
  5004. finalThemeHash += "-" + themeHash;
  5005. if (hashValue)
  5006. finalThemeHash += "-" + hashValue;
  5007. const {
  5008. themeOverrides,
  5009. builtinThemeOverrides
  5010. } = props;
  5011. if (themeOverrides) {
  5012. finalThemeHash += "-" + murmur2(JSON.stringify(themeOverrides));
  5013. }
  5014. if (builtinThemeOverrides) {
  5015. finalThemeHash += "-" + murmur2(JSON.stringify(builtinThemeOverrides));
  5016. }
  5017. themeClassRef.value = finalThemeHash;
  5018. renderCallback = () => {
  5019. const cssVars = cssVarsRef.value;
  5020. let style2 = "";
  5021. for (const key in cssVars) {
  5022. style2 += `${key}: ${cssVars[key]};`;
  5023. }
  5024. c$1(`.${finalThemeHash}`, style2).mount({
  5025. id: finalThemeHash,
  5026. ssr: ssrAdapter2
  5027. });
  5028. renderCallback = void 0;
  5029. };
  5030. };
  5031. vue.watchEffect(() => {
  5032. mountStyle();
  5033. });
  5034. return {
  5035. themeClass: themeClassRef,
  5036. onRender: () => {
  5037. renderCallback === null || renderCallback === void 0 ? void 0 : renderCallback();
  5038. }
  5039. };
  5040. }
  5041. function useRtl(mountId, rtlStateRef, clsPrefixRef) {
  5042. if (!rtlStateRef)
  5043. return void 0;
  5044. const ssrAdapter2 = useSsrAdapter();
  5045. const componentRtlStateRef = vue.computed(() => {
  5046. const {
  5047. value: rtlState
  5048. } = rtlStateRef;
  5049. if (!rtlState) {
  5050. return void 0;
  5051. }
  5052. const componentRtlState = rtlState[mountId];
  5053. if (!componentRtlState) {
  5054. return void 0;
  5055. }
  5056. return componentRtlState;
  5057. });
  5058. const mountStyle = () => {
  5059. vue.watchEffect(() => {
  5060. const {
  5061. value: clsPrefix
  5062. } = clsPrefixRef;
  5063. const id = `${clsPrefix}${mountId}Rtl`;
  5064. if (exists(id, ssrAdapter2))
  5065. return;
  5066. const {
  5067. value: componentRtlState
  5068. } = componentRtlStateRef;
  5069. if (!componentRtlState)
  5070. return;
  5071. componentRtlState.style.mount({
  5072. id,
  5073. head: true,
  5074. anchorMetaName: cssrAnchorMetaName,
  5075. props: {
  5076. bPrefix: clsPrefix ? `.${clsPrefix}-` : void 0
  5077. },
  5078. ssr: ssrAdapter2
  5079. });
  5080. });
  5081. };
  5082. if (ssrAdapter2) {
  5083. mountStyle();
  5084. } else {
  5085. vue.onBeforeMount(mountStyle);
  5086. }
  5087. return componentRtlStateRef;
  5088. }
  5089. const ChevronRightIcon = vue.defineComponent({
  5090. name: "ChevronRight",
  5091. render() {
  5092. return vue.h("svg", {
  5093. viewBox: "0 0 16 16",
  5094. fill: "none",
  5095. xmlns: "http://www.w3.org/2000/svg"
  5096. }, vue.h("path", {
  5097. d: "M5.64645 3.14645C5.45118 3.34171 5.45118 3.65829 5.64645 3.85355L9.79289 8L5.64645 12.1464C5.45118 12.3417 5.45118 12.6583 5.64645 12.8536C5.84171 13.0488 6.15829 13.0488 6.35355 12.8536L10.8536 8.35355C11.0488 8.15829 11.0488 7.84171 10.8536 7.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645Z",
  5098. fill: "currentColor"
  5099. }));
  5100. }
  5101. });
  5102. const ChevronDownFilledIcon = vue.defineComponent({
  5103. name: "ChevronDownFilled",
  5104. render() {
  5105. return vue.h("svg", {
  5106. viewBox: "0 0 16 16",
  5107. fill: "none",
  5108. xmlns: "http://www.w3.org/2000/svg"
  5109. }, vue.h("path", {
  5110. d: "M3.20041 5.73966C3.48226 5.43613 3.95681 5.41856 4.26034 5.70041L8 9.22652L11.7397 5.70041C12.0432 5.41856 12.5177 5.43613 12.7996 5.73966C13.0815 6.0432 13.0639 6.51775 12.7603 6.7996L8.51034 10.7996C8.22258 11.0668 7.77743 11.0668 7.48967 10.7996L3.23966 6.7996C2.93613 6.51775 2.91856 6.0432 3.20041 5.73966Z",
  5111. fill: "currentColor"
  5112. }));
  5113. }
  5114. });
  5115. const NFadeInExpandTransition = vue.defineComponent({
  5116. name: "FadeInExpandTransition",
  5117. props: {
  5118. appear: Boolean,
  5119. group: Boolean,
  5120. mode: String,
  5121. onLeave: Function,
  5122. onAfterLeave: Function,
  5123. onAfterEnter: Function,
  5124. width: Boolean,
  5125. // reverse mode is only used in tree
  5126. // it make it from expanded to collapsed after mounted
  5127. reverse: Boolean
  5128. },
  5129. setup(props, {
  5130. slots
  5131. }) {
  5132. function handleBeforeLeave(el) {
  5133. if (props.width) {
  5134. el.style.maxWidth = `${el.offsetWidth}px`;
  5135. } else {
  5136. el.style.maxHeight = `${el.offsetHeight}px`;
  5137. }
  5138. void el.offsetWidth;
  5139. }
  5140. function handleLeave(el) {
  5141. if (props.width) {
  5142. el.style.maxWidth = "0";
  5143. } else {
  5144. el.style.maxHeight = "0";
  5145. }
  5146. void el.offsetWidth;
  5147. const {
  5148. onLeave
  5149. } = props;
  5150. if (onLeave)
  5151. onLeave();
  5152. }
  5153. function handleAfterLeave(el) {
  5154. if (props.width) {
  5155. el.style.maxWidth = "";
  5156. } else {
  5157. el.style.maxHeight = "";
  5158. }
  5159. const {
  5160. onAfterLeave
  5161. } = props;
  5162. if (onAfterLeave)
  5163. onAfterLeave();
  5164. }
  5165. function handleEnter(el) {
  5166. el.style.transition = "none";
  5167. if (props.width) {
  5168. const memorizedWidth = el.offsetWidth;
  5169. el.style.maxWidth = "0";
  5170. void el.offsetWidth;
  5171. el.style.transition = "";
  5172. el.style.maxWidth = `${memorizedWidth}px`;
  5173. } else {
  5174. if (props.reverse) {
  5175. el.style.maxHeight = `${el.offsetHeight}px`;
  5176. void el.offsetHeight;
  5177. el.style.transition = "";
  5178. el.style.maxHeight = "0";
  5179. } else {
  5180. const memorizedHeight = el.offsetHeight;
  5181. el.style.maxHeight = "0";
  5182. void el.offsetWidth;
  5183. el.style.transition = "";
  5184. el.style.maxHeight = `${memorizedHeight}px`;
  5185. }
  5186. }
  5187. void el.offsetWidth;
  5188. }
  5189. function handleAfterEnter(el) {
  5190. var _a;
  5191. if (props.width) {
  5192. el.style.maxWidth = "";
  5193. } else {
  5194. if (!props.reverse) {
  5195. el.style.maxHeight = "";
  5196. }
  5197. }
  5198. (_a = props.onAfterEnter) === null || _a === void 0 ? void 0 : _a.call(props);
  5199. }
  5200. return () => {
  5201. const {
  5202. group,
  5203. width,
  5204. appear,
  5205. mode
  5206. } = props;
  5207. const type = group ? vue.TransitionGroup : vue.Transition;
  5208. const resolvedProps = {
  5209. name: width ? "fade-in-width-expand-transition" : "fade-in-height-expand-transition",
  5210. appear,
  5211. onEnter: handleEnter,
  5212. onAfterEnter: handleAfterEnter,
  5213. onBeforeLeave: handleBeforeLeave,
  5214. onLeave: handleLeave,
  5215. onAfterLeave: handleAfterLeave
  5216. };
  5217. if (!group) {
  5218. resolvedProps.mode = mode;
  5219. }
  5220. return vue.h(type, resolvedProps, slots);
  5221. };
  5222. }
  5223. });
  5224. const style$5 = cB("base-icon", `
  5225. height: 1em;
  5226. width: 1em;
  5227. line-height: 1em;
  5228. text-align: center;
  5229. display: inline-block;
  5230. position: relative;
  5231. fill: currentColor;
  5232. transform: translateZ(0);
  5233. `, [c$1("svg", `
  5234. height: 1em;
  5235. width: 1em;
  5236. `)]);
  5237. const NBaseIcon = vue.defineComponent({
  5238. name: "BaseIcon",
  5239. props: {
  5240. role: String,
  5241. ariaLabel: String,
  5242. ariaDisabled: {
  5243. type: Boolean,
  5244. default: void 0
  5245. },
  5246. ariaHidden: {
  5247. type: Boolean,
  5248. default: void 0
  5249. },
  5250. clsPrefix: {
  5251. type: String,
  5252. required: true
  5253. },
  5254. onClick: Function,
  5255. onMousedown: Function,
  5256. onMouseup: Function
  5257. },
  5258. setup(props) {
  5259. useStyle("-base-icon", style$5, vue.toRef(props, "clsPrefix"));
  5260. },
  5261. render() {
  5262. return vue.h("i", {
  5263. class: `${this.clsPrefix}-base-icon`,
  5264. onClick: this.onClick,
  5265. onMousedown: this.onMousedown,
  5266. onMouseup: this.onMouseup,
  5267. role: this.role,
  5268. "aria-label": this.ariaLabel,
  5269. "aria-hidden": this.ariaHidden,
  5270. "aria-disabled": this.ariaDisabled
  5271. }, this.$slots);
  5272. }
  5273. });
  5274. function toArray(arg) {
  5275. if (Array.isArray(arg))
  5276. return arg;
  5277. return [arg];
  5278. }
  5279. const TRAVERSE_COMMAND = {
  5280. STOP: "STOP"
  5281. };
  5282. function traverseWithCb(treeNode, callback) {
  5283. const command = callback(treeNode);
  5284. if (treeNode.children !== void 0 && command !== TRAVERSE_COMMAND.STOP) {
  5285. treeNode.children.forEach((childNode) => traverseWithCb(childNode, callback));
  5286. }
  5287. }
  5288. function getNonLeafKeys(treeNodes, options = {}) {
  5289. const { preserveGroup = false } = options;
  5290. const keys2 = [];
  5291. const cb = preserveGroup ? (node) => {
  5292. if (!node.isLeaf) {
  5293. keys2.push(node.key);
  5294. traverse(node.children);
  5295. }
  5296. } : (node) => {
  5297. if (!node.isLeaf) {
  5298. if (!node.isGroup)
  5299. keys2.push(node.key);
  5300. traverse(node.children);
  5301. }
  5302. };
  5303. function traverse(nodes) {
  5304. nodes.forEach(cb);
  5305. }
  5306. traverse(treeNodes);
  5307. return keys2;
  5308. }
  5309. function isLeaf(rawNode, getChildren) {
  5310. const { isLeaf: isLeaf2 } = rawNode;
  5311. if (isLeaf2 !== void 0)
  5312. return isLeaf2;
  5313. else if (!getChildren(rawNode))
  5314. return true;
  5315. return false;
  5316. }
  5317. function defaultGetChildren(node) {
  5318. return node.children;
  5319. }
  5320. function defaultGetKey(node) {
  5321. return node.key;
  5322. }
  5323. function isIgnored() {
  5324. return false;
  5325. }
  5326. function isShallowLoaded(rawNode, getChildren) {
  5327. const { isLeaf: isLeaf2 } = rawNode;
  5328. if (isLeaf2 === false && !Array.isArray(getChildren(rawNode)))
  5329. return false;
  5330. return true;
  5331. }
  5332. function isDisabled(rawNode) {
  5333. return rawNode.disabled === true;
  5334. }
  5335. function isExpilicitlyNotLoaded(rawNode, getChildren) {
  5336. return rawNode.isLeaf === false && !Array.isArray(getChildren(rawNode));
  5337. }
  5338. function unwrapCheckedKeys(result) {
  5339. var _a;
  5340. if (result === void 0 || result === null)
  5341. return [];
  5342. if (Array.isArray(result))
  5343. return result;
  5344. return (_a = result.checkedKeys) !== null && _a !== void 0 ? _a : [];
  5345. }
  5346. function unwrapIndeterminateKeys(result) {
  5347. var _a;
  5348. if (result === void 0 || result === null || Array.isArray(result)) {
  5349. return [];
  5350. }
  5351. return (_a = result.indeterminateKeys) !== null && _a !== void 0 ? _a : [];
  5352. }
  5353. function merge(originalKeys, keysToAdd) {
  5354. const set = new Set(originalKeys);
  5355. keysToAdd.forEach((key) => {
  5356. if (!set.has(key)) {
  5357. set.add(key);
  5358. }
  5359. });
  5360. return Array.from(set);
  5361. }
  5362. function minus(originalKeys, keysToRemove) {
  5363. const set = new Set(originalKeys);
  5364. keysToRemove.forEach((key) => {
  5365. if (set.has(key)) {
  5366. set.delete(key);
  5367. }
  5368. });
  5369. return Array.from(set);
  5370. }
  5371. function isGroup(rawNode) {
  5372. return (rawNode === null || rawNode === void 0 ? void 0 : rawNode.type) === "group";
  5373. }
  5374. class SubtreeNotLoadedError extends Error {
  5375. constructor() {
  5376. super();
  5377. this.message = "SubtreeNotLoadedError: checking a subtree whose required nodes are not fully loaded.";
  5378. }
  5379. }
  5380. function getExtendedCheckedKeySetAfterCheck(checkKeys, currentCheckedKeys, treeMate, allowNotLoaded) {
  5381. return getExtendedCheckedKeySet(currentCheckedKeys.concat(checkKeys), treeMate, allowNotLoaded, false);
  5382. }
  5383. function getAvailableAscendantNodeSet(uncheckedKeys, treeMate) {
  5384. const visitedKeys = /* @__PURE__ */ new Set();
  5385. uncheckedKeys.forEach((uncheckedKey) => {
  5386. const uncheckedTreeNode = treeMate.treeNodeMap.get(uncheckedKey);
  5387. if (uncheckedTreeNode !== void 0) {
  5388. let nodeCursor = uncheckedTreeNode.parent;
  5389. while (nodeCursor !== null) {
  5390. if (nodeCursor.disabled)
  5391. break;
  5392. if (visitedKeys.has(nodeCursor.key))
  5393. break;
  5394. else {
  5395. visitedKeys.add(nodeCursor.key);
  5396. }
  5397. nodeCursor = nodeCursor.parent;
  5398. }
  5399. }
  5400. });
  5401. return visitedKeys;
  5402. }
  5403. function getExtendedCheckedKeySetAfterUncheck(uncheckedKeys, currentCheckedKeys, treeMate, allowNotLoaded) {
  5404. const extendedCheckedKeySet = getExtendedCheckedKeySet(currentCheckedKeys, treeMate, allowNotLoaded, false);
  5405. const extendedKeySetToUncheck = getExtendedCheckedKeySet(uncheckedKeys, treeMate, allowNotLoaded, true);
  5406. const ascendantKeySet = getAvailableAscendantNodeSet(uncheckedKeys, treeMate);
  5407. const keysToRemove = [];
  5408. extendedCheckedKeySet.forEach((key) => {
  5409. if (extendedKeySetToUncheck.has(key) || ascendantKeySet.has(key)) {
  5410. keysToRemove.push(key);
  5411. }
  5412. });
  5413. keysToRemove.forEach((key) => extendedCheckedKeySet.delete(key));
  5414. return extendedCheckedKeySet;
  5415. }
  5416. function getCheckedKeys(options, treeMate) {
  5417. const { checkedKeys, keysToCheck, keysToUncheck, indeterminateKeys, cascade, leafOnly, checkStrategy, allowNotLoaded } = options;
  5418. if (!cascade) {
  5419. if (keysToCheck !== void 0) {
  5420. return {
  5421. checkedKeys: merge(checkedKeys, keysToCheck),
  5422. indeterminateKeys: Array.from(indeterminateKeys)
  5423. };
  5424. } else if (keysToUncheck !== void 0) {
  5425. return {
  5426. checkedKeys: minus(checkedKeys, keysToUncheck),
  5427. indeterminateKeys: Array.from(indeterminateKeys)
  5428. };
  5429. } else {
  5430. return {
  5431. checkedKeys: Array.from(checkedKeys),
  5432. indeterminateKeys: Array.from(indeterminateKeys)
  5433. };
  5434. }
  5435. }
  5436. const { levelTreeNodeMap } = treeMate;
  5437. let extendedCheckedKeySet;
  5438. if (keysToUncheck !== void 0) {
  5439. extendedCheckedKeySet = getExtendedCheckedKeySetAfterUncheck(keysToUncheck, checkedKeys, treeMate, allowNotLoaded);
  5440. } else if (keysToCheck !== void 0) {
  5441. extendedCheckedKeySet = getExtendedCheckedKeySetAfterCheck(keysToCheck, checkedKeys, treeMate, allowNotLoaded);
  5442. } else {
  5443. extendedCheckedKeySet = getExtendedCheckedKeySet(checkedKeys, treeMate, allowNotLoaded, false);
  5444. }
  5445. const checkStrategyIsParent = checkStrategy === "parent";
  5446. const checkStrategyIsChild = checkStrategy === "child" || leafOnly;
  5447. const syntheticCheckedKeySet = extendedCheckedKeySet;
  5448. const syntheticIndeterminateKeySet = /* @__PURE__ */ new Set();
  5449. const maxLevel = Math.max.apply(null, Array.from(levelTreeNodeMap.keys()));
  5450. for (let level = maxLevel; level >= 0; level -= 1) {
  5451. const levelIsZero = level === 0;
  5452. const levelTreeNodes = levelTreeNodeMap.get(level);
  5453. for (const levelTreeNode of levelTreeNodes) {
  5454. if (levelTreeNode.isLeaf)
  5455. continue;
  5456. const { key: levelTreeNodeKey, shallowLoaded } = levelTreeNode;
  5457. if (checkStrategyIsChild && shallowLoaded) {
  5458. levelTreeNode.children.forEach((v) => {
  5459. if (!v.disabled && !v.isLeaf && v.shallowLoaded && syntheticCheckedKeySet.has(v.key)) {
  5460. syntheticCheckedKeySet.delete(v.key);
  5461. }
  5462. });
  5463. }
  5464. if (levelTreeNode.disabled || !shallowLoaded) {
  5465. continue;
  5466. }
  5467. let fullyChecked = true;
  5468. let partialChecked = false;
  5469. let allDisabled = true;
  5470. for (const childNode of levelTreeNode.children) {
  5471. const childKey = childNode.key;
  5472. if (childNode.disabled)
  5473. continue;
  5474. if (allDisabled)
  5475. allDisabled = false;
  5476. if (syntheticCheckedKeySet.has(childKey)) {
  5477. partialChecked = true;
  5478. } else if (syntheticIndeterminateKeySet.has(childKey)) {
  5479. partialChecked = true;
  5480. fullyChecked = false;
  5481. break;
  5482. } else {
  5483. fullyChecked = false;
  5484. if (partialChecked) {
  5485. break;
  5486. }
  5487. }
  5488. }
  5489. if (fullyChecked && !allDisabled) {
  5490. if (checkStrategyIsParent) {
  5491. levelTreeNode.children.forEach((v) => {
  5492. if (!v.disabled && syntheticCheckedKeySet.has(v.key)) {
  5493. syntheticCheckedKeySet.delete(v.key);
  5494. }
  5495. });
  5496. }
  5497. syntheticCheckedKeySet.add(levelTreeNodeKey);
  5498. } else if (partialChecked) {
  5499. syntheticIndeterminateKeySet.add(levelTreeNodeKey);
  5500. }
  5501. if (levelIsZero && checkStrategyIsChild && syntheticCheckedKeySet.has(levelTreeNodeKey)) {
  5502. syntheticCheckedKeySet.delete(levelTreeNodeKey);
  5503. }
  5504. }
  5505. }
  5506. return {
  5507. checkedKeys: Array.from(syntheticCheckedKeySet),
  5508. indeterminateKeys: Array.from(syntheticIndeterminateKeySet)
  5509. };
  5510. }
  5511. function getExtendedCheckedKeySet(checkedKeys, treeMate, allowNotLoaded, isUnchecking) {
  5512. const { treeNodeMap, getChildren } = treeMate;
  5513. const visitedKeySet = /* @__PURE__ */ new Set();
  5514. const extendedKeySet = new Set(checkedKeys);
  5515. checkedKeys.forEach((checkedKey) => {
  5516. const checkedTreeNode = treeNodeMap.get(checkedKey);
  5517. if (checkedTreeNode !== void 0) {
  5518. traverseWithCb(checkedTreeNode, (treeNode) => {
  5519. if (treeNode.disabled) {
  5520. return TRAVERSE_COMMAND.STOP;
  5521. }
  5522. const { key } = treeNode;
  5523. if (visitedKeySet.has(key))
  5524. return;
  5525. visitedKeySet.add(key);
  5526. extendedKeySet.add(key);
  5527. if (isExpilicitlyNotLoaded(treeNode.rawNode, getChildren)) {
  5528. if (isUnchecking) {
  5529. return TRAVERSE_COMMAND.STOP;
  5530. } else if (!allowNotLoaded) {
  5531. throw new SubtreeNotLoadedError();
  5532. }
  5533. }
  5534. });
  5535. }
  5536. });
  5537. return extendedKeySet;
  5538. }
  5539. function getPath(key, { includeGroup = false, includeSelf = true }, treeMate) {
  5540. var _a;
  5541. const treeNodeMap = treeMate.treeNodeMap;
  5542. let treeNode = key === null || key === void 0 ? null : (_a = treeNodeMap.get(key)) !== null && _a !== void 0 ? _a : null;
  5543. const mergedPath = {
  5544. keyPath: [],
  5545. treeNodePath: [],
  5546. treeNode
  5547. };
  5548. if (treeNode === null || treeNode === void 0 ? void 0 : treeNode.ignored) {
  5549. mergedPath.treeNode = null;
  5550. return mergedPath;
  5551. }
  5552. while (treeNode) {
  5553. if (!treeNode.ignored && (includeGroup || !treeNode.isGroup)) {
  5554. mergedPath.treeNodePath.push(treeNode);
  5555. }
  5556. treeNode = treeNode.parent;
  5557. }
  5558. mergedPath.treeNodePath.reverse();
  5559. if (!includeSelf)
  5560. mergedPath.treeNodePath.pop();
  5561. mergedPath.keyPath = mergedPath.treeNodePath.map((treeNode2) => treeNode2.key);
  5562. return mergedPath;
  5563. }
  5564. function getFirstAvailableNode(nodes) {
  5565. if (nodes.length === 0)
  5566. return null;
  5567. const node = nodes[0];
  5568. if (node.isGroup || node.ignored || node.disabled) {
  5569. return node.getNext();
  5570. }
  5571. return node;
  5572. }
  5573. function rawGetNext(node, loop) {
  5574. const sibs = node.siblings;
  5575. const l = sibs.length;
  5576. const { index } = node;
  5577. if (loop) {
  5578. return sibs[(index + 1) % l];
  5579. } else {
  5580. if (index === sibs.length - 1)
  5581. return null;
  5582. return sibs[index + 1];
  5583. }
  5584. }
  5585. function move(fromNode, dir, { loop = false, includeDisabled = false } = {}) {
  5586. const iterate = dir === "prev" ? rawGetPrev : rawGetNext;
  5587. const getChildOptions = {
  5588. reverse: dir === "prev"
  5589. };
  5590. let meet = false;
  5591. let endNode = null;
  5592. function traverse(node) {
  5593. if (node === null)
  5594. return;
  5595. if (node === fromNode) {
  5596. if (!meet) {
  5597. meet = true;
  5598. } else if (!fromNode.disabled && !fromNode.isGroup) {
  5599. endNode = fromNode;
  5600. return;
  5601. }
  5602. } else {
  5603. if ((!node.disabled || includeDisabled) && !node.ignored && !node.isGroup) {
  5604. endNode = node;
  5605. return;
  5606. }
  5607. }
  5608. if (node.isGroup) {
  5609. const child = getChild(node, getChildOptions);
  5610. if (child !== null) {
  5611. endNode = child;
  5612. } else {
  5613. traverse(iterate(node, loop));
  5614. }
  5615. } else {
  5616. const nextNode = iterate(node, false);
  5617. if (nextNode !== null) {
  5618. traverse(nextNode);
  5619. } else {
  5620. const parent = rawGetParent(node);
  5621. if (parent === null || parent === void 0 ? void 0 : parent.isGroup) {
  5622. traverse(iterate(parent, loop));
  5623. } else if (loop) {
  5624. traverse(iterate(node, true));
  5625. }
  5626. }
  5627. }
  5628. }
  5629. traverse(fromNode);
  5630. return endNode;
  5631. }
  5632. function rawGetPrev(node, loop) {
  5633. const sibs = node.siblings;
  5634. const l = sibs.length;
  5635. const { index } = node;
  5636. if (loop) {
  5637. return sibs[(index - 1 + l) % l];
  5638. } else {
  5639. if (index === 0)
  5640. return null;
  5641. return sibs[index - 1];
  5642. }
  5643. }
  5644. function rawGetParent(node) {
  5645. return node.parent;
  5646. }
  5647. function getChild(node, options = {}) {
  5648. const { reverse = false } = options;
  5649. const { children } = node;
  5650. if (children) {
  5651. const { length } = children;
  5652. const start = reverse ? length - 1 : 0;
  5653. const end = reverse ? -1 : length;
  5654. const delta = reverse ? -1 : 1;
  5655. for (let i = start; i !== end; i += delta) {
  5656. const child = children[i];
  5657. if (!child.disabled && !child.ignored) {
  5658. if (child.isGroup) {
  5659. const childInGroup = getChild(child, options);
  5660. if (childInGroup !== null)
  5661. return childInGroup;
  5662. } else {
  5663. return child;
  5664. }
  5665. }
  5666. }
  5667. }
  5668. return null;
  5669. }
  5670. const moveMethods = {
  5671. getChild() {
  5672. if (this.ignored)
  5673. return null;
  5674. return getChild(this);
  5675. },
  5676. getParent() {
  5677. const { parent } = this;
  5678. if (parent === null || parent === void 0 ? void 0 : parent.isGroup) {
  5679. return parent.getParent();
  5680. }
  5681. return parent;
  5682. },
  5683. getNext(options = {}) {
  5684. return move(this, "next", options);
  5685. },
  5686. getPrev(options = {}) {
  5687. return move(this, "prev", options);
  5688. }
  5689. };
  5690. function flatten(treeNodes, expandedKeys) {
  5691. const expandedKeySet = expandedKeys ? new Set(expandedKeys) : void 0;
  5692. const flattenedNodes = [];
  5693. function traverse(treeNodes2) {
  5694. treeNodes2.forEach((treeNode) => {
  5695. flattenedNodes.push(treeNode);
  5696. if (treeNode.isLeaf || !treeNode.children || treeNode.ignored)
  5697. return;
  5698. if (treeNode.isGroup) {
  5699. traverse(treeNode.children);
  5700. } else if (
  5701. // normal non-leaf node
  5702. expandedKeySet === void 0 || expandedKeySet.has(treeNode.key)
  5703. ) {
  5704. traverse(treeNode.children);
  5705. }
  5706. });
  5707. }
  5708. traverse(treeNodes);
  5709. return flattenedNodes;
  5710. }
  5711. function contains(parent, child) {
  5712. const parentKey = parent.key;
  5713. while (child) {
  5714. if (child.key === parentKey)
  5715. return true;
  5716. child = child.parent;
  5717. }
  5718. return false;
  5719. }
  5720. function createTreeNodes(rawNodes, treeNodeMap, levelTreeNodeMap, nodeProto, getChildren, parent = null, level = 0) {
  5721. const treeNodes = [];
  5722. rawNodes.forEach((rawNode, index) => {
  5723. var _a;
  5724. const treeNode = Object.create(nodeProto);
  5725. treeNode.rawNode = rawNode;
  5726. treeNode.siblings = treeNodes;
  5727. treeNode.level = level;
  5728. treeNode.index = index;
  5729. treeNode.isFirstChild = index === 0;
  5730. treeNode.isLastChild = index + 1 === rawNodes.length;
  5731. treeNode.parent = parent;
  5732. if (!treeNode.ignored) {
  5733. const rawChildren = getChildren(rawNode);
  5734. if (Array.isArray(rawChildren)) {
  5735. treeNode.children = createTreeNodes(rawChildren, treeNodeMap, levelTreeNodeMap, nodeProto, getChildren, treeNode, level + 1);
  5736. }
  5737. }
  5738. treeNodes.push(treeNode);
  5739. treeNodeMap.set(treeNode.key, treeNode);
  5740. if (!levelTreeNodeMap.has(level))
  5741. levelTreeNodeMap.set(level, []);
  5742. (_a = levelTreeNodeMap.get(level)) === null || _a === void 0 ? void 0 : _a.push(treeNode);
  5743. });
  5744. return treeNodes;
  5745. }
  5746. function createTreeMate(rawNodes, options = {}) {
  5747. var _a;
  5748. const treeNodeMap = /* @__PURE__ */ new Map();
  5749. const levelTreeNodeMap = /* @__PURE__ */ new Map();
  5750. const { getDisabled = isDisabled, getIgnored = isIgnored, getIsGroup = isGroup, getKey = defaultGetKey } = options;
  5751. const _getChildren = (_a = options.getChildren) !== null && _a !== void 0 ? _a : defaultGetChildren;
  5752. const getChildren = options.ignoreEmptyChildren ? (node) => {
  5753. const children = _getChildren(node);
  5754. if (Array.isArray(children)) {
  5755. if (!children.length)
  5756. return null;
  5757. return children;
  5758. }
  5759. return children;
  5760. } : _getChildren;
  5761. const nodeProto = Object.assign({
  5762. get key() {
  5763. return getKey(this.rawNode);
  5764. },
  5765. get disabled() {
  5766. return getDisabled(this.rawNode);
  5767. },
  5768. get isGroup() {
  5769. return getIsGroup(this.rawNode);
  5770. },
  5771. get isLeaf() {
  5772. return isLeaf(this.rawNode, getChildren);
  5773. },
  5774. get shallowLoaded() {
  5775. return isShallowLoaded(this.rawNode, getChildren);
  5776. },
  5777. get ignored() {
  5778. return getIgnored(this.rawNode);
  5779. },
  5780. contains(node) {
  5781. return contains(this, node);
  5782. }
  5783. }, moveMethods);
  5784. const treeNodes = createTreeNodes(rawNodes, treeNodeMap, levelTreeNodeMap, nodeProto, getChildren);
  5785. function getNode(key) {
  5786. if (key === null || key === void 0)
  5787. return null;
  5788. const tmNode = treeNodeMap.get(key);
  5789. if (tmNode && !tmNode.isGroup && !tmNode.ignored) {
  5790. return tmNode;
  5791. }
  5792. return null;
  5793. }
  5794. function _getNode(key) {
  5795. if (key === null || key === void 0)
  5796. return null;
  5797. const tmNode = treeNodeMap.get(key);
  5798. if (tmNode && !tmNode.ignored) {
  5799. return tmNode;
  5800. }
  5801. return null;
  5802. }
  5803. function getPrev(key, options2) {
  5804. const node = _getNode(key);
  5805. if (!node)
  5806. return null;
  5807. return node.getPrev(options2);
  5808. }
  5809. function getNext(key, options2) {
  5810. const node = _getNode(key);
  5811. if (!node)
  5812. return null;
  5813. return node.getNext(options2);
  5814. }
  5815. function getParent(key) {
  5816. const node = _getNode(key);
  5817. if (!node)
  5818. return null;
  5819. return node.getParent();
  5820. }
  5821. function getChild2(key) {
  5822. const node = _getNode(key);
  5823. if (!node)
  5824. return null;
  5825. return node.getChild();
  5826. }
  5827. const treemate = {
  5828. treeNodes,
  5829. treeNodeMap,
  5830. levelTreeNodeMap,
  5831. maxLevel: Math.max(...levelTreeNodeMap.keys()),
  5832. getChildren,
  5833. getFlattenedNodes(expandedKeys) {
  5834. return flatten(treeNodes, expandedKeys);
  5835. },
  5836. getNode,
  5837. getPrev,
  5838. getNext,
  5839. getParent,
  5840. getChild: getChild2,
  5841. getFirstAvailableNode() {
  5842. return getFirstAvailableNode(treeNodes);
  5843. },
  5844. getPath(key, options2 = {}) {
  5845. return getPath(key, options2, treemate);
  5846. },
  5847. getCheckedKeys(checkedKeys, options2 = {}) {
  5848. const { cascade = true, leafOnly = false, checkStrategy = "all", allowNotLoaded = false } = options2;
  5849. return getCheckedKeys({
  5850. checkedKeys: unwrapCheckedKeys(checkedKeys),
  5851. indeterminateKeys: unwrapIndeterminateKeys(checkedKeys),
  5852. cascade,
  5853. leafOnly,
  5854. checkStrategy,
  5855. allowNotLoaded
  5856. }, treemate);
  5857. },
  5858. check(keysToCheck, checkedKeys, options2 = {}) {
  5859. const { cascade = true, leafOnly = false, checkStrategy = "all", allowNotLoaded = false } = options2;
  5860. return getCheckedKeys({
  5861. checkedKeys: unwrapCheckedKeys(checkedKeys),
  5862. indeterminateKeys: unwrapIndeterminateKeys(checkedKeys),
  5863. keysToCheck: keysToCheck === void 0 || keysToCheck === null ? [] : toArray(keysToCheck),
  5864. cascade,
  5865. leafOnly,
  5866. checkStrategy,
  5867. allowNotLoaded
  5868. }, treemate);
  5869. },
  5870. uncheck(keysToUncheck, checkedKeys, options2 = {}) {
  5871. const { cascade = true, leafOnly = false, checkStrategy = "all", allowNotLoaded = false } = options2;
  5872. return getCheckedKeys({
  5873. checkedKeys: unwrapCheckedKeys(checkedKeys),
  5874. indeterminateKeys: unwrapIndeterminateKeys(checkedKeys),
  5875. keysToUncheck: keysToUncheck === null || keysToUncheck === void 0 ? [] : toArray(keysToUncheck),
  5876. cascade,
  5877. leafOnly,
  5878. checkStrategy,
  5879. allowNotLoaded
  5880. }, treemate);
  5881. },
  5882. getNonLeafKeys(options2 = {}) {
  5883. return getNonLeafKeys(treeNodes, options2);
  5884. }
  5885. };
  5886. return treemate;
  5887. }
  5888. const base = {
  5889. neutralBase: "#FFF",
  5890. neutralInvertBase: "#000",
  5891. neutralTextBase: "#000",
  5892. neutralPopover: "#fff",
  5893. neutralCard: "#fff",
  5894. neutralModal: "#fff",
  5895. neutralBody: "#fff",
  5896. alpha1: "0.82",
  5897. alpha2: "0.72",
  5898. alpha3: "0.38",
  5899. alpha4: "0.24",
  5900. // disabled text, placeholder, icon
  5901. alpha5: "0.18",
  5902. // disabled placeholder
  5903. alphaClose: "0.6",
  5904. alphaDisabled: "0.5",
  5905. alphaDisabledInput: "0.02",
  5906. alphaPending: "0.05",
  5907. alphaTablePending: "0.02",
  5908. alphaPressed: "0.07",
  5909. alphaAvatar: "0.2",
  5910. alphaRail: "0.14",
  5911. alphaProgressRail: ".08",
  5912. alphaBorder: "0.12",
  5913. alphaDivider: "0.06",
  5914. alphaInput: "0",
  5915. alphaAction: "0.02",
  5916. alphaTab: "0.04",
  5917. alphaScrollbar: "0.25",
  5918. alphaScrollbarHover: "0.4",
  5919. alphaCode: "0.05",
  5920. alphaTag: "0.02",
  5921. // primary
  5922. primaryHover: "#36ad6a",
  5923. primaryDefault: "#18a058",
  5924. primaryActive: "#0c7a43",
  5925. primarySuppl: "#36ad6a",
  5926. // info
  5927. infoHover: "#4098fc",
  5928. infoDefault: "#2080f0",
  5929. infoActive: "#1060c9",
  5930. infoSuppl: "#4098fc",
  5931. // error
  5932. errorHover: "#de576d",
  5933. errorDefault: "#d03050",
  5934. errorActive: "#ab1f3f",
  5935. errorSuppl: "#de576d",
  5936. // warning
  5937. warningHover: "#fcb040",
  5938. warningDefault: "#f0a020",
  5939. warningActive: "#c97c10",
  5940. warningSuppl: "#fcb040",
  5941. // success
  5942. successHover: "#36ad6a",
  5943. successDefault: "#18a058",
  5944. successActive: "#0c7a43",
  5945. successSuppl: "#36ad6a"
  5946. };
  5947. const baseBackgroundRgb = rgba(base.neutralBase);
  5948. const baseInvertBackgroundRgb = rgba(base.neutralInvertBase);
  5949. const overlayPrefix = "rgba(" + baseInvertBackgroundRgb.slice(0, 3).join(", ") + ", ";
  5950. function overlay(alpha) {
  5951. return overlayPrefix + String(alpha) + ")";
  5952. }
  5953. function neutral(alpha) {
  5954. const overlayRgba = Array.from(baseInvertBackgroundRgb);
  5955. overlayRgba[3] = Number(alpha);
  5956. return composite(baseBackgroundRgb, overlayRgba);
  5957. }
  5958. const derived = Object.assign(Object.assign({
  5959. name: "common"
  5960. }, commonVariables$2), {
  5961. baseColor: base.neutralBase,
  5962. // primary color
  5963. primaryColor: base.primaryDefault,
  5964. primaryColorHover: base.primaryHover,
  5965. primaryColorPressed: base.primaryActive,
  5966. primaryColorSuppl: base.primarySuppl,
  5967. // info color
  5968. infoColor: base.infoDefault,
  5969. infoColorHover: base.infoHover,
  5970. infoColorPressed: base.infoActive,
  5971. infoColorSuppl: base.infoSuppl,
  5972. // success color
  5973. successColor: base.successDefault,
  5974. successColorHover: base.successHover,
  5975. successColorPressed: base.successActive,
  5976. successColorSuppl: base.successSuppl,
  5977. // warning color
  5978. warningColor: base.warningDefault,
  5979. warningColorHover: base.warningHover,
  5980. warningColorPressed: base.warningActive,
  5981. warningColorSuppl: base.warningSuppl,
  5982. // error color
  5983. errorColor: base.errorDefault,
  5984. errorColorHover: base.errorHover,
  5985. errorColorPressed: base.errorActive,
  5986. errorColorSuppl: base.errorSuppl,
  5987. // text color
  5988. textColorBase: base.neutralTextBase,
  5989. textColor1: "rgb(31, 34, 37)",
  5990. textColor2: "rgb(51, 54, 57)",
  5991. textColor3: "rgb(118, 124, 130)",
  5992. // textColor4: neutral(base.alpha4), // disabled, placeholder, icon
  5993. // textColor5: neutral(base.alpha5),
  5994. textColorDisabled: neutral(base.alpha4),
  5995. placeholderColor: neutral(base.alpha4),
  5996. placeholderColorDisabled: neutral(base.alpha5),
  5997. iconColor: neutral(base.alpha4),
  5998. iconColorHover: scaleColor(neutral(base.alpha4), {
  5999. lightness: 0.75
  6000. }),
  6001. iconColorPressed: scaleColor(neutral(base.alpha4), {
  6002. lightness: 0.9
  6003. }),
  6004. iconColorDisabled: neutral(base.alpha5),
  6005. opacity1: base.alpha1,
  6006. opacity2: base.alpha2,
  6007. opacity3: base.alpha3,
  6008. opacity4: base.alpha4,
  6009. opacity5: base.alpha5,
  6010. dividerColor: "rgb(239, 239, 245)",
  6011. borderColor: "rgb(224, 224, 230)",
  6012. // close
  6013. closeIconColor: neutral(Number(base.alphaClose)),
  6014. closeIconColorHover: neutral(Number(base.alphaClose)),
  6015. closeIconColorPressed: neutral(Number(base.alphaClose)),
  6016. closeColorHover: "rgba(0, 0, 0, .09)",
  6017. closeColorPressed: "rgba(0, 0, 0, .13)",
  6018. // clear
  6019. clearColor: neutral(base.alpha4),
  6020. clearColorHover: scaleColor(neutral(base.alpha4), {
  6021. lightness: 0.75
  6022. }),
  6023. clearColorPressed: scaleColor(neutral(base.alpha4), {
  6024. lightness: 0.9
  6025. }),
  6026. scrollbarColor: overlay(base.alphaScrollbar),
  6027. scrollbarColorHover: overlay(base.alphaScrollbarHover),
  6028. scrollbarWidth: "5px",
  6029. scrollbarHeight: "5px",
  6030. scrollbarBorderRadius: "5px",
  6031. progressRailColor: neutral(base.alphaProgressRail),
  6032. railColor: "rgb(219, 219, 223)",
  6033. popoverColor: base.neutralPopover,
  6034. tableColor: base.neutralCard,
  6035. cardColor: base.neutralCard,
  6036. modalColor: base.neutralModal,
  6037. bodyColor: base.neutralBody,
  6038. tagColor: "#eee",
  6039. avatarColor: neutral(base.alphaAvatar),
  6040. invertedColor: "rgb(0, 20, 40)",
  6041. inputColor: neutral(base.alphaInput),
  6042. codeColor: "rgb(244, 244, 248)",
  6043. tabColor: "rgb(247, 247, 250)",
  6044. actionColor: "rgb(250, 250, 252)",
  6045. tableHeaderColor: "rgb(250, 250, 252)",
  6046. hoverColor: "rgb(243, 243, 245)",
  6047. // use color with alpha since it can be nested with header filter & sorter effect
  6048. tableColorHover: "rgba(0, 0, 100, 0.03)",
  6049. tableColorStriped: "rgba(0, 0, 100, 0.02)",
  6050. pressedColor: "rgb(237, 237, 239)",
  6051. opacityDisabled: base.alphaDisabled,
  6052. inputColorDisabled: "rgb(250, 250, 252)",
  6053. // secondary button color
  6054. // can also be used in tertiary button & quaternary button
  6055. buttonColor2: "rgba(46, 51, 56, .05)",
  6056. buttonColor2Hover: "rgba(46, 51, 56, .09)",
  6057. buttonColor2Pressed: "rgba(46, 51, 56, .13)",
  6058. 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)",
  6059. 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)",
  6060. 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)"
  6061. });
  6062. const commonVars$1 = {
  6063. railInsetHorizontal: "auto 2px 4px 2px",
  6064. railInsetVertical: "2px 4px 2px auto",
  6065. railColor: "transparent"
  6066. };
  6067. const self$6 = (vars) => {
  6068. const {
  6069. scrollbarColor,
  6070. scrollbarColorHover,
  6071. scrollbarHeight,
  6072. scrollbarWidth,
  6073. scrollbarBorderRadius
  6074. } = vars;
  6075. return Object.assign(Object.assign({}, commonVars$1), {
  6076. height: scrollbarHeight,
  6077. width: scrollbarWidth,
  6078. borderRadius: scrollbarBorderRadius,
  6079. color: scrollbarColor,
  6080. colorHover: scrollbarColorHover
  6081. });
  6082. };
  6083. const scrollbarLight = {
  6084. name: "Scrollbar",
  6085. common: derived,
  6086. self: self$6
  6087. };
  6088. const {
  6089. cubicBezierEaseInOut: cubicBezierEaseInOut$1
  6090. } = commonVariables$2;
  6091. function fadeInTransition({
  6092. name = "fade-in",
  6093. enterDuration = "0.2s",
  6094. leaveDuration = "0.2s",
  6095. enterCubicBezier = cubicBezierEaseInOut$1,
  6096. leaveCubicBezier = cubicBezierEaseInOut$1
  6097. } = {}) {
  6098. return [c$1(`&.${name}-transition-enter-active`, {
  6099. transition: `all ${enterDuration} ${enterCubicBezier}!important`
  6100. }), c$1(`&.${name}-transition-leave-active`, {
  6101. transition: `all ${leaveDuration} ${leaveCubicBezier}!important`
  6102. }), c$1(`&.${name}-transition-enter-from, &.${name}-transition-leave-to`, {
  6103. opacity: 0
  6104. }), c$1(`&.${name}-transition-leave-from, &.${name}-transition-enter-to`, {
  6105. opacity: 1
  6106. })];
  6107. }
  6108. const style$4 = cB("scrollbar", `
  6109. overflow: hidden;
  6110. position: relative;
  6111. z-index: auto;
  6112. height: 100%;
  6113. width: 100%;
  6114. `, [c$1(">", [cB("scrollbar-container", `
  6115. width: 100%;
  6116. overflow: scroll;
  6117. height: 100%;
  6118. min-height: inherit;
  6119. max-height: inherit;
  6120. scrollbar-width: none;
  6121. `, [c$1("&::-webkit-scrollbar, &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb", `
  6122. width: 0;
  6123. height: 0;
  6124. display: none;
  6125. `), c$1(">", [
  6126. // We can't set overflow hidden since it affects positioning.
  6127. cB("scrollbar-content", `
  6128. box-sizing: border-box;
  6129. min-width: 100%;
  6130. `)
  6131. ])])]), c$1(">, +", [cB("scrollbar-rail", `
  6132. position: absolute;
  6133. pointer-events: none;
  6134. user-select: none;
  6135. background: var(--n-scrollbar-rail-color);
  6136. -webkit-user-select: none;
  6137. `, [cM("horizontal", `
  6138. inset: var(--n-scrollbar-rail-inset-horizontal);
  6139. height: var(--n-scrollbar-height);
  6140. `, [c$1(">", [cE("scrollbar", `
  6141. height: var(--n-scrollbar-height);
  6142. border-radius: var(--n-scrollbar-border-radius);
  6143. right: 0;
  6144. `)])]), cM("vertical", `
  6145. inset: var(--n-scrollbar-rail-inset-vertical);
  6146. width: var(--n-scrollbar-width);
  6147. `, [c$1(">", [cE("scrollbar", `
  6148. width: var(--n-scrollbar-width);
  6149. border-radius: var(--n-scrollbar-border-radius);
  6150. bottom: 0;
  6151. `)])]), cM("disabled", [c$1(">", [cE("scrollbar", "pointer-events: none;")])]), c$1(">", [cE("scrollbar", `
  6152. z-index: 1;
  6153. position: absolute;
  6154. cursor: pointer;
  6155. pointer-events: all;
  6156. background-color: var(--n-scrollbar-color);
  6157. transition: background-color .2s var(--n-scrollbar-bezier);
  6158. `, [fadeInTransition(), c$1("&:hover", "background-color: var(--n-scrollbar-color-hover);")])])])])]);
  6159. const scrollbarProps = Object.assign(Object.assign({}, useTheme.props), {
  6160. duration: {
  6161. type: Number,
  6162. default: 0
  6163. },
  6164. scrollable: {
  6165. type: Boolean,
  6166. default: true
  6167. },
  6168. xScrollable: Boolean,
  6169. trigger: {
  6170. type: String,
  6171. default: "hover"
  6172. },
  6173. useUnifiedContainer: Boolean,
  6174. triggerDisplayManually: Boolean,
  6175. // If container is set, resize observer won't not attached
  6176. container: Function,
  6177. content: Function,
  6178. containerClass: String,
  6179. containerStyle: [String, Object],
  6180. contentClass: [String, Array],
  6181. contentStyle: [String, Object],
  6182. horizontalRailStyle: [String, Object],
  6183. verticalRailStyle: [String, Object],
  6184. onScroll: Function,
  6185. onWheel: Function,
  6186. onResize: Function,
  6187. internalOnUpdateScrollLeft: Function,
  6188. internalHoistYRail: Boolean
  6189. });
  6190. const Scrollbar = vue.defineComponent({
  6191. name: "Scrollbar",
  6192. props: scrollbarProps,
  6193. inheritAttrs: false,
  6194. setup(props) {
  6195. const {
  6196. mergedClsPrefixRef,
  6197. inlineThemeDisabled,
  6198. mergedRtlRef
  6199. } = useConfig(props);
  6200. const rtlEnabledRef = useRtl("Scrollbar", mergedRtlRef, mergedClsPrefixRef);
  6201. const wrapperRef = vue.ref(null);
  6202. const containerRef = vue.ref(null);
  6203. const contentRef = vue.ref(null);
  6204. const yRailRef = vue.ref(null);
  6205. const xRailRef = vue.ref(null);
  6206. const contentHeightRef = vue.ref(null);
  6207. const contentWidthRef = vue.ref(null);
  6208. const containerHeightRef = vue.ref(null);
  6209. const containerWidthRef = vue.ref(null);
  6210. const yRailSizeRef = vue.ref(null);
  6211. const xRailSizeRef = vue.ref(null);
  6212. const containerScrollTopRef = vue.ref(0);
  6213. const containerScrollLeftRef = vue.ref(0);
  6214. const isShowXBarRef = vue.ref(false);
  6215. const isShowYBarRef = vue.ref(false);
  6216. let yBarPressed = false;
  6217. let xBarPressed = false;
  6218. let xBarVanishTimerId;
  6219. let yBarVanishTimerId;
  6220. let memoYTop = 0;
  6221. let memoXLeft = 0;
  6222. let memoMouseX = 0;
  6223. let memoMouseY = 0;
  6224. const isIos2 = useIsIos();
  6225. const themeRef = useTheme("Scrollbar", "-scrollbar", style$4, scrollbarLight, props, mergedClsPrefixRef);
  6226. const yBarSizeRef = vue.computed(() => {
  6227. const {
  6228. value: containerHeight
  6229. } = containerHeightRef;
  6230. const {
  6231. value: contentHeight
  6232. } = contentHeightRef;
  6233. const {
  6234. value: yRailSize
  6235. } = yRailSizeRef;
  6236. if (containerHeight === null || contentHeight === null || yRailSize === null) {
  6237. return 0;
  6238. } else {
  6239. return Math.min(containerHeight, yRailSize * containerHeight / contentHeight + depx(themeRef.value.self.width) * 1.5);
  6240. }
  6241. });
  6242. const yBarSizePxRef = vue.computed(() => {
  6243. return `${yBarSizeRef.value}px`;
  6244. });
  6245. const xBarSizeRef = vue.computed(() => {
  6246. const {
  6247. value: containerWidth
  6248. } = containerWidthRef;
  6249. const {
  6250. value: contentWidth
  6251. } = contentWidthRef;
  6252. const {
  6253. value: xRailSize
  6254. } = xRailSizeRef;
  6255. if (containerWidth === null || contentWidth === null || xRailSize === null) {
  6256. return 0;
  6257. } else {
  6258. return xRailSize * containerWidth / contentWidth + depx(themeRef.value.self.height) * 1.5;
  6259. }
  6260. });
  6261. const xBarSizePxRef = vue.computed(() => {
  6262. return `${xBarSizeRef.value}px`;
  6263. });
  6264. const yBarTopRef = vue.computed(() => {
  6265. const {
  6266. value: containerHeight
  6267. } = containerHeightRef;
  6268. const {
  6269. value: containerScrollTop
  6270. } = containerScrollTopRef;
  6271. const {
  6272. value: contentHeight
  6273. } = contentHeightRef;
  6274. const {
  6275. value: yRailSize
  6276. } = yRailSizeRef;
  6277. if (containerHeight === null || contentHeight === null || yRailSize === null) {
  6278. return 0;
  6279. } else {
  6280. const heightDiff = contentHeight - containerHeight;
  6281. if (!heightDiff)
  6282. return 0;
  6283. return containerScrollTop / heightDiff * (yRailSize - yBarSizeRef.value);
  6284. }
  6285. });
  6286. const yBarTopPxRef = vue.computed(() => {
  6287. return `${yBarTopRef.value}px`;
  6288. });
  6289. const xBarLeftRef = vue.computed(() => {
  6290. const {
  6291. value: containerWidth
  6292. } = containerWidthRef;
  6293. const {
  6294. value: containerScrollLeft
  6295. } = containerScrollLeftRef;
  6296. const {
  6297. value: contentWidth
  6298. } = contentWidthRef;
  6299. const {
  6300. value: xRailSize
  6301. } = xRailSizeRef;
  6302. if (containerWidth === null || contentWidth === null || xRailSize === null) {
  6303. return 0;
  6304. } else {
  6305. const widthDiff = contentWidth - containerWidth;
  6306. if (!widthDiff)
  6307. return 0;
  6308. return containerScrollLeft / widthDiff * (xRailSize - xBarSizeRef.value);
  6309. }
  6310. });
  6311. const xBarLeftPxRef = vue.computed(() => {
  6312. return `${xBarLeftRef.value}px`;
  6313. });
  6314. const needYBarRef = vue.computed(() => {
  6315. const {
  6316. value: containerHeight
  6317. } = containerHeightRef;
  6318. const {
  6319. value: contentHeight
  6320. } = contentHeightRef;
  6321. return containerHeight !== null && contentHeight !== null && contentHeight > containerHeight;
  6322. });
  6323. const needXBarRef = vue.computed(() => {
  6324. const {
  6325. value: containerWidth
  6326. } = containerWidthRef;
  6327. const {
  6328. value: contentWidth
  6329. } = contentWidthRef;
  6330. return containerWidth !== null && contentWidth !== null && contentWidth > containerWidth;
  6331. });
  6332. const mergedShowXBarRef = vue.computed(() => {
  6333. const {
  6334. trigger: trigger2
  6335. } = props;
  6336. return trigger2 === "none" || isShowXBarRef.value;
  6337. });
  6338. const mergedShowYBarRef = vue.computed(() => {
  6339. const {
  6340. trigger: trigger2
  6341. } = props;
  6342. return trigger2 === "none" || isShowYBarRef.value;
  6343. });
  6344. const mergedContainerRef = vue.computed(() => {
  6345. const {
  6346. container
  6347. } = props;
  6348. if (container)
  6349. return container();
  6350. return containerRef.value;
  6351. });
  6352. const mergedContentRef = vue.computed(() => {
  6353. const {
  6354. content
  6355. } = props;
  6356. if (content)
  6357. return content();
  6358. return contentRef.value;
  6359. });
  6360. const activateState = useReactivated(() => {
  6361. if (!props.container) {
  6362. scrollTo({
  6363. top: containerScrollTopRef.value,
  6364. left: containerScrollLeftRef.value
  6365. });
  6366. }
  6367. });
  6368. const handleContentResize = () => {
  6369. if (activateState.isDeactivated)
  6370. return;
  6371. sync();
  6372. };
  6373. const handleContainerResize = (e) => {
  6374. if (activateState.isDeactivated)
  6375. return;
  6376. const {
  6377. onResize
  6378. } = props;
  6379. if (onResize)
  6380. onResize(e);
  6381. sync();
  6382. };
  6383. const scrollTo = (options, y) => {
  6384. if (!props.scrollable)
  6385. return;
  6386. if (typeof options === "number") {
  6387. scrollToPosition(options, y !== null && y !== void 0 ? y : 0, 0, false, "auto");
  6388. return;
  6389. }
  6390. const {
  6391. left,
  6392. top,
  6393. index,
  6394. elSize,
  6395. position,
  6396. behavior,
  6397. el,
  6398. debounce = true
  6399. } = options;
  6400. if (left !== void 0 || top !== void 0) {
  6401. scrollToPosition(left !== null && left !== void 0 ? left : 0, top !== null && top !== void 0 ? top : 0, 0, false, behavior);
  6402. }
  6403. if (el !== void 0) {
  6404. scrollToPosition(0, el.offsetTop, el.offsetHeight, debounce, behavior);
  6405. } else if (index !== void 0 && elSize !== void 0) {
  6406. scrollToPosition(0, index * elSize, elSize, debounce, behavior);
  6407. } else if (position === "bottom") {
  6408. scrollToPosition(0, Number.MAX_SAFE_INTEGER, 0, false, behavior);
  6409. } else if (position === "top") {
  6410. scrollToPosition(0, 0, 0, false, behavior);
  6411. }
  6412. };
  6413. const scrollBy = (options, y) => {
  6414. if (!props.scrollable)
  6415. return;
  6416. const {
  6417. value: container
  6418. } = mergedContainerRef;
  6419. if (!container)
  6420. return;
  6421. if (typeof options === "object") {
  6422. container.scrollBy(options);
  6423. } else {
  6424. container.scrollBy(options, y || 0);
  6425. }
  6426. };
  6427. function scrollToPosition(left, top, elSize, debounce, behavior) {
  6428. const {
  6429. value: container
  6430. } = mergedContainerRef;
  6431. if (!container)
  6432. return;
  6433. if (debounce) {
  6434. const {
  6435. scrollTop,
  6436. offsetHeight
  6437. } = container;
  6438. if (top > scrollTop) {
  6439. if (top + elSize <= scrollTop + offsetHeight)
  6440. ;
  6441. else {
  6442. container.scrollTo({
  6443. left,
  6444. top: top + elSize - offsetHeight,
  6445. behavior
  6446. });
  6447. }
  6448. return;
  6449. }
  6450. }
  6451. container.scrollTo({
  6452. left,
  6453. top,
  6454. behavior
  6455. });
  6456. }
  6457. function handleMouseEnterWrapper() {
  6458. showXBar();
  6459. showYBar();
  6460. sync();
  6461. }
  6462. function handleMouseLeaveWrapper() {
  6463. hideBar();
  6464. }
  6465. function hideBar() {
  6466. hideYBar();
  6467. hideXBar();
  6468. }
  6469. function hideYBar() {
  6470. if (yBarVanishTimerId !== void 0) {
  6471. window.clearTimeout(yBarVanishTimerId);
  6472. }
  6473. yBarVanishTimerId = window.setTimeout(() => {
  6474. isShowYBarRef.value = false;
  6475. }, props.duration);
  6476. }
  6477. function hideXBar() {
  6478. if (xBarVanishTimerId !== void 0) {
  6479. window.clearTimeout(xBarVanishTimerId);
  6480. }
  6481. xBarVanishTimerId = window.setTimeout(() => {
  6482. isShowXBarRef.value = false;
  6483. }, props.duration);
  6484. }
  6485. function showXBar() {
  6486. if (xBarVanishTimerId !== void 0) {
  6487. window.clearTimeout(xBarVanishTimerId);
  6488. }
  6489. isShowXBarRef.value = true;
  6490. }
  6491. function showYBar() {
  6492. if (yBarVanishTimerId !== void 0) {
  6493. window.clearTimeout(yBarVanishTimerId);
  6494. }
  6495. isShowYBarRef.value = true;
  6496. }
  6497. function handleScroll(e) {
  6498. const {
  6499. onScroll
  6500. } = props;
  6501. if (onScroll)
  6502. onScroll(e);
  6503. syncScrollState();
  6504. }
  6505. function syncScrollState() {
  6506. const {
  6507. value: container
  6508. } = mergedContainerRef;
  6509. if (container) {
  6510. containerScrollTopRef.value = container.scrollTop;
  6511. containerScrollLeftRef.value = container.scrollLeft * ((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? -1 : 1);
  6512. }
  6513. }
  6514. function syncPositionState() {
  6515. const {
  6516. value: content
  6517. } = mergedContentRef;
  6518. if (content) {
  6519. contentHeightRef.value = content.offsetHeight;
  6520. contentWidthRef.value = content.offsetWidth;
  6521. }
  6522. const {
  6523. value: container
  6524. } = mergedContainerRef;
  6525. if (container) {
  6526. containerHeightRef.value = container.offsetHeight;
  6527. containerWidthRef.value = container.offsetWidth;
  6528. }
  6529. const {
  6530. value: xRailEl
  6531. } = xRailRef;
  6532. const {
  6533. value: yRailEl
  6534. } = yRailRef;
  6535. if (xRailEl) {
  6536. xRailSizeRef.value = xRailEl.offsetWidth;
  6537. }
  6538. if (yRailEl) {
  6539. yRailSizeRef.value = yRailEl.offsetHeight;
  6540. }
  6541. }
  6542. function syncUnifiedContainer() {
  6543. const {
  6544. value: container
  6545. } = mergedContainerRef;
  6546. if (container) {
  6547. containerScrollTopRef.value = container.scrollTop;
  6548. containerScrollLeftRef.value = container.scrollLeft * ((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? -1 : 1);
  6549. containerHeightRef.value = container.offsetHeight;
  6550. containerWidthRef.value = container.offsetWidth;
  6551. contentHeightRef.value = container.scrollHeight;
  6552. contentWidthRef.value = container.scrollWidth;
  6553. }
  6554. const {
  6555. value: xRailEl
  6556. } = xRailRef;
  6557. const {
  6558. value: yRailEl
  6559. } = yRailRef;
  6560. if (xRailEl) {
  6561. xRailSizeRef.value = xRailEl.offsetWidth;
  6562. }
  6563. if (yRailEl) {
  6564. yRailSizeRef.value = yRailEl.offsetHeight;
  6565. }
  6566. }
  6567. function sync() {
  6568. if (!props.scrollable)
  6569. return;
  6570. if (props.useUnifiedContainer) {
  6571. syncUnifiedContainer();
  6572. } else {
  6573. syncPositionState();
  6574. syncScrollState();
  6575. }
  6576. }
  6577. function isMouseUpAway(e) {
  6578. var _a;
  6579. return !((_a = wrapperRef.value) === null || _a === void 0 ? void 0 : _a.contains(getPreciseEventTarget(e)));
  6580. }
  6581. function handleXScrollMouseDown(e) {
  6582. e.preventDefault();
  6583. e.stopPropagation();
  6584. xBarPressed = true;
  6585. on("mousemove", window, handleXScrollMouseMove, true);
  6586. on("mouseup", window, handleXScrollMouseUp, true);
  6587. memoXLeft = containerScrollLeftRef.value;
  6588. memoMouseX = (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? window.innerWidth - e.clientX : e.clientX;
  6589. }
  6590. function handleXScrollMouseMove(e) {
  6591. if (!xBarPressed)
  6592. return;
  6593. if (xBarVanishTimerId !== void 0) {
  6594. window.clearTimeout(xBarVanishTimerId);
  6595. }
  6596. if (yBarVanishTimerId !== void 0) {
  6597. window.clearTimeout(yBarVanishTimerId);
  6598. }
  6599. const {
  6600. value: containerWidth
  6601. } = containerWidthRef;
  6602. const {
  6603. value: contentWidth
  6604. } = contentWidthRef;
  6605. const {
  6606. value: xBarSize
  6607. } = xBarSizeRef;
  6608. if (containerWidth === null || contentWidth === null)
  6609. return;
  6610. const dX = (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? window.innerWidth - e.clientX - memoMouseX : e.clientX - memoMouseX;
  6611. const dScrollLeft = dX * (contentWidth - containerWidth) / (containerWidth - xBarSize);
  6612. const toScrollLeftUpperBound = contentWidth - containerWidth;
  6613. let toScrollLeft = memoXLeft + dScrollLeft;
  6614. toScrollLeft = Math.min(toScrollLeftUpperBound, toScrollLeft);
  6615. toScrollLeft = Math.max(toScrollLeft, 0);
  6616. const {
  6617. value: container
  6618. } = mergedContainerRef;
  6619. if (container) {
  6620. container.scrollLeft = toScrollLeft * ((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? -1 : 1);
  6621. const {
  6622. internalOnUpdateScrollLeft
  6623. } = props;
  6624. if (internalOnUpdateScrollLeft)
  6625. internalOnUpdateScrollLeft(toScrollLeft);
  6626. }
  6627. }
  6628. function handleXScrollMouseUp(e) {
  6629. e.preventDefault();
  6630. e.stopPropagation();
  6631. off("mousemove", window, handleXScrollMouseMove, true);
  6632. off("mouseup", window, handleXScrollMouseUp, true);
  6633. xBarPressed = false;
  6634. sync();
  6635. if (isMouseUpAway(e)) {
  6636. hideBar();
  6637. }
  6638. }
  6639. function handleYScrollMouseDown(e) {
  6640. e.preventDefault();
  6641. e.stopPropagation();
  6642. yBarPressed = true;
  6643. on("mousemove", window, handleYScrollMouseMove, true);
  6644. on("mouseup", window, handleYScrollMouseUp, true);
  6645. memoYTop = containerScrollTopRef.value;
  6646. memoMouseY = e.clientY;
  6647. }
  6648. function handleYScrollMouseMove(e) {
  6649. if (!yBarPressed)
  6650. return;
  6651. if (xBarVanishTimerId !== void 0) {
  6652. window.clearTimeout(xBarVanishTimerId);
  6653. }
  6654. if (yBarVanishTimerId !== void 0) {
  6655. window.clearTimeout(yBarVanishTimerId);
  6656. }
  6657. const {
  6658. value: containerHeight
  6659. } = containerHeightRef;
  6660. const {
  6661. value: contentHeight
  6662. } = contentHeightRef;
  6663. const {
  6664. value: yBarSize
  6665. } = yBarSizeRef;
  6666. if (containerHeight === null || contentHeight === null)
  6667. return;
  6668. const dY = e.clientY - memoMouseY;
  6669. const dScrollTop = dY * (contentHeight - containerHeight) / (containerHeight - yBarSize);
  6670. const toScrollTopUpperBound = contentHeight - containerHeight;
  6671. let toScrollTop = memoYTop + dScrollTop;
  6672. toScrollTop = Math.min(toScrollTopUpperBound, toScrollTop);
  6673. toScrollTop = Math.max(toScrollTop, 0);
  6674. const {
  6675. value: container
  6676. } = mergedContainerRef;
  6677. if (container) {
  6678. container.scrollTop = toScrollTop;
  6679. }
  6680. }
  6681. function handleYScrollMouseUp(e) {
  6682. e.preventDefault();
  6683. e.stopPropagation();
  6684. off("mousemove", window, handleYScrollMouseMove, true);
  6685. off("mouseup", window, handleYScrollMouseUp, true);
  6686. yBarPressed = false;
  6687. sync();
  6688. if (isMouseUpAway(e)) {
  6689. hideBar();
  6690. }
  6691. }
  6692. vue.watchEffect(() => {
  6693. const {
  6694. value: needXBar
  6695. } = needXBarRef;
  6696. const {
  6697. value: needYBar
  6698. } = needYBarRef;
  6699. const {
  6700. value: mergedClsPrefix
  6701. } = mergedClsPrefixRef;
  6702. const {
  6703. value: xRailEl
  6704. } = xRailRef;
  6705. const {
  6706. value: yRailEl
  6707. } = yRailRef;
  6708. if (xRailEl) {
  6709. if (!needXBar) {
  6710. xRailEl.classList.add(`${mergedClsPrefix}-scrollbar-rail--disabled`);
  6711. } else {
  6712. xRailEl.classList.remove(`${mergedClsPrefix}-scrollbar-rail--disabled`);
  6713. }
  6714. }
  6715. if (yRailEl) {
  6716. if (!needYBar) {
  6717. yRailEl.classList.add(`${mergedClsPrefix}-scrollbar-rail--disabled`);
  6718. } else {
  6719. yRailEl.classList.remove(`${mergedClsPrefix}-scrollbar-rail--disabled`);
  6720. }
  6721. }
  6722. });
  6723. vue.onMounted(() => {
  6724. if (props.container)
  6725. return;
  6726. sync();
  6727. });
  6728. vue.onBeforeUnmount(() => {
  6729. if (xBarVanishTimerId !== void 0) {
  6730. window.clearTimeout(xBarVanishTimerId);
  6731. }
  6732. if (yBarVanishTimerId !== void 0) {
  6733. window.clearTimeout(yBarVanishTimerId);
  6734. }
  6735. off("mousemove", window, handleYScrollMouseMove, true);
  6736. off("mouseup", window, handleYScrollMouseUp, true);
  6737. });
  6738. const cssVarsRef = vue.computed(() => {
  6739. const {
  6740. common: {
  6741. cubicBezierEaseInOut: cubicBezierEaseInOut2
  6742. },
  6743. self: {
  6744. color,
  6745. colorHover,
  6746. height,
  6747. width,
  6748. borderRadius,
  6749. railInsetHorizontal,
  6750. railInsetVertical,
  6751. railColor
  6752. }
  6753. } = themeRef.value;
  6754. return {
  6755. "--n-scrollbar-bezier": cubicBezierEaseInOut2,
  6756. "--n-scrollbar-color": color,
  6757. "--n-scrollbar-color-hover": colorHover,
  6758. "--n-scrollbar-border-radius": borderRadius,
  6759. "--n-scrollbar-width": width,
  6760. "--n-scrollbar-height": height,
  6761. "--n-scrollbar-rail-inset-horizontal": railInsetHorizontal,
  6762. "--n-scrollbar-rail-inset-vertical": (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? rtlInset(railInsetVertical) : railInsetVertical,
  6763. "--n-scrollbar-rail-color": railColor
  6764. };
  6765. });
  6766. const themeClassHandle = inlineThemeDisabled ? useThemeClass("scrollbar", void 0, cssVarsRef, props) : void 0;
  6767. const exposedMethods = {
  6768. scrollTo,
  6769. scrollBy,
  6770. sync,
  6771. syncUnifiedContainer,
  6772. handleMouseEnterWrapper,
  6773. handleMouseLeaveWrapper
  6774. };
  6775. return Object.assign(Object.assign({}, exposedMethods), {
  6776. mergedClsPrefix: mergedClsPrefixRef,
  6777. rtlEnabled: rtlEnabledRef,
  6778. containerScrollTop: containerScrollTopRef,
  6779. wrapperRef,
  6780. containerRef,
  6781. contentRef,
  6782. yRailRef,
  6783. xRailRef,
  6784. needYBar: needYBarRef,
  6785. needXBar: needXBarRef,
  6786. yBarSizePx: yBarSizePxRef,
  6787. xBarSizePx: xBarSizePxRef,
  6788. yBarTopPx: yBarTopPxRef,
  6789. xBarLeftPx: xBarLeftPxRef,
  6790. isShowXBar: mergedShowXBarRef,
  6791. isShowYBar: mergedShowYBarRef,
  6792. isIos: isIos2,
  6793. handleScroll,
  6794. handleContentResize,
  6795. handleContainerResize,
  6796. handleYScrollMouseDown,
  6797. handleXScrollMouseDown,
  6798. cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
  6799. themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
  6800. onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
  6801. });
  6802. },
  6803. render() {
  6804. var _a;
  6805. const {
  6806. $slots,
  6807. mergedClsPrefix,
  6808. triggerDisplayManually,
  6809. rtlEnabled,
  6810. internalHoistYRail
  6811. } = this;
  6812. if (!this.scrollable)
  6813. return (_a = $slots.default) === null || _a === void 0 ? void 0 : _a.call($slots);
  6814. const triggerIsNone = this.trigger === "none";
  6815. const createYRail = (className, style2) => {
  6816. return vue.h("div", {
  6817. ref: "yRailRef",
  6818. class: [`${mergedClsPrefix}-scrollbar-rail`, `${mergedClsPrefix}-scrollbar-rail--vertical`, className],
  6819. "data-scrollbar-rail": true,
  6820. style: [style2 || "", this.verticalRailStyle],
  6821. "aria-hidden": true
  6822. }, vue.h(
  6823. // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
  6824. triggerIsNone ? Wrapper : vue.Transition,
  6825. triggerIsNone ? null : {
  6826. name: "fade-in-transition"
  6827. },
  6828. {
  6829. default: () => this.needYBar && this.isShowYBar && !this.isIos ? vue.h("div", {
  6830. class: `${mergedClsPrefix}-scrollbar-rail__scrollbar`,
  6831. style: {
  6832. height: this.yBarSizePx,
  6833. top: this.yBarTopPx
  6834. },
  6835. onMousedown: this.handleYScrollMouseDown
  6836. }) : null
  6837. }
  6838. ));
  6839. };
  6840. const createChildren = () => {
  6841. var _a2, _b;
  6842. (_a2 = this.onRender) === null || _a2 === void 0 ? void 0 : _a2.call(this);
  6843. return vue.h("div", vue.mergeProps(this.$attrs, {
  6844. role: "none",
  6845. ref: "wrapperRef",
  6846. class: [`${mergedClsPrefix}-scrollbar`, this.themeClass, rtlEnabled && `${mergedClsPrefix}-scrollbar--rtl`],
  6847. style: this.cssVars,
  6848. onMouseenter: triggerDisplayManually ? void 0 : this.handleMouseEnterWrapper,
  6849. onMouseleave: triggerDisplayManually ? void 0 : this.handleMouseLeaveWrapper
  6850. }), [this.container ? (_b = $slots.default) === null || _b === void 0 ? void 0 : _b.call($slots) : vue.h("div", {
  6851. role: "none",
  6852. ref: "containerRef",
  6853. class: [`${mergedClsPrefix}-scrollbar-container`, this.containerClass],
  6854. style: this.containerStyle,
  6855. onScroll: this.handleScroll,
  6856. onWheel: this.onWheel
  6857. }, vue.h(VResizeObserver, {
  6858. onResize: this.handleContentResize
  6859. }, {
  6860. default: () => vue.h("div", {
  6861. ref: "contentRef",
  6862. role: "none",
  6863. style: [{
  6864. width: this.xScrollable ? "fit-content" : null
  6865. }, this.contentStyle],
  6866. class: [`${mergedClsPrefix}-scrollbar-content`, this.contentClass]
  6867. }, $slots)
  6868. })), internalHoistYRail ? null : createYRail(void 0, void 0), this.xScrollable && vue.h("div", {
  6869. ref: "xRailRef",
  6870. class: [`${mergedClsPrefix}-scrollbar-rail`, `${mergedClsPrefix}-scrollbar-rail--horizontal`],
  6871. style: this.horizontalRailStyle,
  6872. "data-scrollbar-rail": true,
  6873. "aria-hidden": true
  6874. }, vue.h(
  6875. // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
  6876. triggerIsNone ? Wrapper : vue.Transition,
  6877. triggerIsNone ? null : {
  6878. name: "fade-in-transition"
  6879. },
  6880. {
  6881. default: () => this.needXBar && this.isShowXBar && !this.isIos ? vue.h("div", {
  6882. class: `${mergedClsPrefix}-scrollbar-rail__scrollbar`,
  6883. style: {
  6884. width: this.xBarSizePx,
  6885. right: rtlEnabled ? this.xBarLeftPx : void 0,
  6886. left: rtlEnabled ? void 0 : this.xBarLeftPx
  6887. },
  6888. onMousedown: this.handleXScrollMouseDown
  6889. }) : null
  6890. }
  6891. ))]);
  6892. };
  6893. const scrollbarNode = this.container ? createChildren() : vue.h(VResizeObserver, {
  6894. onResize: this.handleContainerResize
  6895. }, {
  6896. default: createChildren
  6897. });
  6898. if (internalHoistYRail) {
  6899. return vue.h(vue.Fragment, null, scrollbarNode, createYRail(this.themeClass, this.cssVars));
  6900. } else {
  6901. return scrollbarNode;
  6902. }
  6903. }
  6904. });
  6905. const XScrollbar = Scrollbar;
  6906. const {
  6907. cubicBezierEaseIn: cubicBezierEaseIn$1,
  6908. cubicBezierEaseOut: cubicBezierEaseOut$1
  6909. } = commonVariables$2;
  6910. function fadeInScaleUpTransition({
  6911. transformOrigin = "inherit",
  6912. duration = ".2s",
  6913. enterScale = ".9",
  6914. originalTransform = "",
  6915. originalTransition = ""
  6916. } = {}) {
  6917. return [c$1("&.fade-in-scale-up-transition-leave-active", {
  6918. transformOrigin,
  6919. transition: `opacity ${duration} ${cubicBezierEaseIn$1}, transform ${duration} ${cubicBezierEaseIn$1} ${originalTransition && "," + originalTransition}`
  6920. }), c$1("&.fade-in-scale-up-transition-enter-active", {
  6921. transformOrigin,
  6922. transition: `opacity ${duration} ${cubicBezierEaseOut$1}, transform ${duration} ${cubicBezierEaseOut$1} ${originalTransition && "," + originalTransition}`
  6923. }), c$1("&.fade-in-scale-up-transition-enter-from, &.fade-in-scale-up-transition-leave-to", {
  6924. opacity: 0,
  6925. transform: `${originalTransform} scale(${enterScale})`
  6926. }), c$1("&.fade-in-scale-up-transition-leave-from, &.fade-in-scale-up-transition-enter-to", {
  6927. opacity: 1,
  6928. transform: `${originalTransform} scale(1)`
  6929. })];
  6930. }
  6931. const commonVariables$1 = {
  6932. space: "6px",
  6933. spaceArrow: "10px",
  6934. arrowOffset: "10px",
  6935. arrowOffsetVertical: "10px",
  6936. arrowHeight: "6px",
  6937. padding: "8px 14px"
  6938. };
  6939. const self$5 = (vars) => {
  6940. const {
  6941. boxShadow2,
  6942. popoverColor,
  6943. textColor2,
  6944. borderRadius,
  6945. fontSize: fontSize2,
  6946. dividerColor
  6947. } = vars;
  6948. return Object.assign(Object.assign({}, commonVariables$1), {
  6949. fontSize: fontSize2,
  6950. borderRadius,
  6951. color: popoverColor,
  6952. dividerColor,
  6953. textColor: textColor2,
  6954. boxShadow: boxShadow2
  6955. });
  6956. };
  6957. const popoverLight = {
  6958. name: "Popover",
  6959. common: derived,
  6960. self: self$5
  6961. };
  6962. const oppositePlacement = {
  6963. top: "bottom",
  6964. bottom: "top",
  6965. left: "right",
  6966. right: "left"
  6967. };
  6968. const arrowSize = "var(--n-arrow-height) * 1.414";
  6969. const style$3 = c$1([cB("popover", `
  6970. transition:
  6971. box-shadow .3s var(--n-bezier),
  6972. background-color .3s var(--n-bezier),
  6973. color .3s var(--n-bezier);
  6974. position: relative;
  6975. font-size: var(--n-font-size);
  6976. color: var(--n-text-color);
  6977. box-shadow: var(--n-box-shadow);
  6978. word-break: break-word;
  6979. `, [c$1(">", [cB("scrollbar", `
  6980. height: inherit;
  6981. max-height: inherit;
  6982. `)]), cNotM("raw", `
  6983. background-color: var(--n-color);
  6984. border-radius: var(--n-border-radius);
  6985. `, [cNotM("scrollable", [cNotM("show-header-or-footer", "padding: var(--n-padding);")])]), cE("header", `
  6986. padding: var(--n-padding);
  6987. border-bottom: 1px solid var(--n-divider-color);
  6988. transition: border-color .3s var(--n-bezier);
  6989. `), cE("footer", `
  6990. padding: var(--n-padding);
  6991. border-top: 1px solid var(--n-divider-color);
  6992. transition: border-color .3s var(--n-bezier);
  6993. `), cM("scrollable, show-header-or-footer", [cE("content", `
  6994. padding: var(--n-padding);
  6995. `)])]), cB("popover-shared", `
  6996. transform-origin: inherit;
  6997. `, [
  6998. cB("popover-arrow-wrapper", `
  6999. position: absolute;
  7000. overflow: hidden;
  7001. pointer-events: none;
  7002. `, [cB("popover-arrow", `
  7003. transition: background-color .3s var(--n-bezier);
  7004. position: absolute;
  7005. display: block;
  7006. width: calc(${arrowSize});
  7007. height: calc(${arrowSize});
  7008. box-shadow: 0 0 8px 0 rgba(0, 0, 0, .12);
  7009. transform: rotate(45deg);
  7010. background-color: var(--n-color);
  7011. pointer-events: all;
  7012. `)]),
  7013. // body transition
  7014. c$1("&.popover-transition-enter-from, &.popover-transition-leave-to", `
  7015. opacity: 0;
  7016. transform: scale(.85);
  7017. `),
  7018. c$1("&.popover-transition-enter-to, &.popover-transition-leave-from", `
  7019. transform: scale(1);
  7020. opacity: 1;
  7021. `),
  7022. c$1("&.popover-transition-enter-active", `
  7023. transition:
  7024. box-shadow .3s var(--n-bezier),
  7025. background-color .3s var(--n-bezier),
  7026. color .3s var(--n-bezier),
  7027. opacity .15s var(--n-bezier-ease-out),
  7028. transform .15s var(--n-bezier-ease-out);
  7029. `),
  7030. c$1("&.popover-transition-leave-active", `
  7031. transition:
  7032. box-shadow .3s var(--n-bezier),
  7033. background-color .3s var(--n-bezier),
  7034. color .3s var(--n-bezier),
  7035. opacity .15s var(--n-bezier-ease-in),
  7036. transform .15s var(--n-bezier-ease-in);
  7037. `)
  7038. ]), placementStyle("top-start", `
  7039. top: calc(${arrowSize} / -2);
  7040. left: calc(${getArrowOffset("top-start")} - var(--v-offset-left));
  7041. `), placementStyle("top", `
  7042. top: calc(${arrowSize} / -2);
  7043. transform: translateX(calc(${arrowSize} / -2)) rotate(45deg);
  7044. left: 50%;
  7045. `), placementStyle("top-end", `
  7046. top: calc(${arrowSize} / -2);
  7047. right: calc(${getArrowOffset("top-end")} + var(--v-offset-left));
  7048. `), placementStyle("bottom-start", `
  7049. bottom: calc(${arrowSize} / -2);
  7050. left: calc(${getArrowOffset("bottom-start")} - var(--v-offset-left));
  7051. `), placementStyle("bottom", `
  7052. bottom: calc(${arrowSize} / -2);
  7053. transform: translateX(calc(${arrowSize} / -2)) rotate(45deg);
  7054. left: 50%;
  7055. `), placementStyle("bottom-end", `
  7056. bottom: calc(${arrowSize} / -2);
  7057. right: calc(${getArrowOffset("bottom-end")} + var(--v-offset-left));
  7058. `), placementStyle("left-start", `
  7059. left: calc(${arrowSize} / -2);
  7060. top: calc(${getArrowOffset("left-start")} - var(--v-offset-top));
  7061. `), placementStyle("left", `
  7062. left: calc(${arrowSize} / -2);
  7063. transform: translateY(calc(${arrowSize} / -2)) rotate(45deg);
  7064. top: 50%;
  7065. `), placementStyle("left-end", `
  7066. left: calc(${arrowSize} / -2);
  7067. bottom: calc(${getArrowOffset("left-end")} + var(--v-offset-top));
  7068. `), placementStyle("right-start", `
  7069. right: calc(${arrowSize} / -2);
  7070. top: calc(${getArrowOffset("right-start")} - var(--v-offset-top));
  7071. `), placementStyle("right", `
  7072. right: calc(${arrowSize} / -2);
  7073. transform: translateY(calc(${arrowSize} / -2)) rotate(45deg);
  7074. top: 50%;
  7075. `), placementStyle("right-end", `
  7076. right: calc(${arrowSize} / -2);
  7077. bottom: calc(${getArrowOffset("right-end")} + var(--v-offset-top));
  7078. `), ...map({
  7079. top: ["right-start", "left-start"],
  7080. right: ["top-end", "bottom-end"],
  7081. bottom: ["right-end", "left-end"],
  7082. left: ["top-start", "bottom-start"]
  7083. }, (placements, direction) => {
  7084. const isVertical = ["right", "left"].includes(direction);
  7085. const sizeType = isVertical ? "width" : "height";
  7086. return placements.map((placement) => {
  7087. const isReverse = placement.split("-")[1] === "end";
  7088. const targetSize = `var(--v-target-${sizeType}, 0px)`;
  7089. const centerOffset = `calc((${targetSize} - ${arrowSize}) / 2)`;
  7090. const offset = getArrowOffset(placement);
  7091. return c$1(`[v-placement="${placement}"] >`, [cB("popover-shared", [cM("center-arrow", [cB("popover-arrow", `${direction}: calc(max(${centerOffset}, ${offset}) ${isReverse ? "+" : "-"} var(--v-offset-${isVertical ? "left" : "top"}));`)])])]);
  7092. });
  7093. })]);
  7094. function getArrowOffset(placement) {
  7095. return ["top", "bottom"].includes(placement.split("-")[0]) ? "var(--n-arrow-offset)" : "var(--n-arrow-offset-vertical)";
  7096. }
  7097. function placementStyle(placement, arrowStyleLiteral) {
  7098. const position = placement.split("-")[0];
  7099. const sizeStyle = ["top", "bottom"].includes(position) ? "height: var(--n-space-arrow);" : "width: var(--n-space-arrow);";
  7100. return c$1(`[v-placement="${placement}"] >`, [cB("popover-shared", `
  7101. margin-${oppositePlacement[position]}: var(--n-space);
  7102. `, [cM("show-arrow", `
  7103. margin-${oppositePlacement[position]}: var(--n-space-arrow);
  7104. `), cM("overlap", `
  7105. margin: 0;
  7106. `), cCB("popover-arrow-wrapper", `
  7107. right: 0;
  7108. left: 0;
  7109. top: 0;
  7110. bottom: 0;
  7111. ${position}: 100%;
  7112. ${oppositePlacement[position]}: auto;
  7113. ${sizeStyle}
  7114. `, [cB("popover-arrow", arrowStyleLiteral)])])]);
  7115. }
  7116. const popoverBodyProps = Object.assign(Object.assign({}, useTheme.props), {
  7117. to: useAdjustedTo.propTo,
  7118. show: Boolean,
  7119. trigger: String,
  7120. showArrow: Boolean,
  7121. delay: Number,
  7122. duration: Number,
  7123. raw: Boolean,
  7124. arrowPointToCenter: Boolean,
  7125. arrowClass: String,
  7126. arrowStyle: [String, Object],
  7127. arrowWrapperClass: String,
  7128. arrowWrapperStyle: [String, Object],
  7129. displayDirective: String,
  7130. x: Number,
  7131. y: Number,
  7132. flip: Boolean,
  7133. overlap: Boolean,
  7134. placement: String,
  7135. width: [Number, String],
  7136. keepAliveOnHover: Boolean,
  7137. scrollable: Boolean,
  7138. contentClass: String,
  7139. contentStyle: [Object, String],
  7140. headerClass: String,
  7141. headerStyle: [Object, String],
  7142. footerClass: String,
  7143. footerStyle: [Object, String],
  7144. // private
  7145. internalDeactivateImmediately: Boolean,
  7146. animated: Boolean,
  7147. onClickoutside: Function,
  7148. internalTrapFocus: Boolean,
  7149. internalOnAfterLeave: Function,
  7150. // deprecated
  7151. minWidth: Number,
  7152. maxWidth: Number
  7153. });
  7154. const renderArrow = ({
  7155. arrowClass,
  7156. arrowStyle,
  7157. arrowWrapperClass,
  7158. arrowWrapperStyle,
  7159. clsPrefix
  7160. }) => {
  7161. return vue.h("div", {
  7162. key: "__popover-arrow__",
  7163. style: arrowWrapperStyle,
  7164. class: [`${clsPrefix}-popover-arrow-wrapper`, arrowWrapperClass]
  7165. }, vue.h("div", {
  7166. class: [`${clsPrefix}-popover-arrow`, arrowClass],
  7167. style: arrowStyle
  7168. }));
  7169. };
  7170. const NPopoverBody = vue.defineComponent({
  7171. name: "PopoverBody",
  7172. inheritAttrs: false,
  7173. props: popoverBodyProps,
  7174. setup(props, {
  7175. slots,
  7176. attrs
  7177. }) {
  7178. const {
  7179. namespaceRef,
  7180. mergedClsPrefixRef,
  7181. inlineThemeDisabled
  7182. } = useConfig(props);
  7183. const themeRef = useTheme("Popover", "-popover", style$3, popoverLight, props, mergedClsPrefixRef);
  7184. const followerRef = vue.ref(null);
  7185. const NPopover2 = vue.inject("NPopover");
  7186. const bodyRef = vue.ref(null);
  7187. const followerEnabledRef = vue.ref(props.show);
  7188. const displayedRef = vue.ref(false);
  7189. vue.watchEffect(() => {
  7190. const {
  7191. show
  7192. } = props;
  7193. if (show && !isJsdom() && !props.internalDeactivateImmediately) {
  7194. displayedRef.value = true;
  7195. }
  7196. });
  7197. const directivesRef = vue.computed(() => {
  7198. const {
  7199. trigger: trigger2,
  7200. onClickoutside
  7201. } = props;
  7202. const directives = [];
  7203. const {
  7204. positionManuallyRef: {
  7205. value: positionManually
  7206. }
  7207. } = NPopover2;
  7208. if (!positionManually) {
  7209. if (trigger2 === "click" && !onClickoutside) {
  7210. directives.push([clickoutside, handleClickOutside, void 0, {
  7211. capture: true
  7212. }]);
  7213. }
  7214. if (trigger2 === "hover") {
  7215. directives.push([mousemoveoutside, handleMouseMoveOutside]);
  7216. }
  7217. }
  7218. if (onClickoutside) {
  7219. directives.push([clickoutside, handleClickOutside, void 0, {
  7220. capture: true
  7221. }]);
  7222. }
  7223. if (props.displayDirective === "show" || props.animated && displayedRef.value) {
  7224. directives.push([vue.vShow, props.show]);
  7225. }
  7226. return directives;
  7227. });
  7228. const styleRef = vue.computed(() => {
  7229. const width = props.width === "trigger" ? void 0 : formatLength(props.width);
  7230. const style2 = [];
  7231. if (width) {
  7232. style2.push({
  7233. width
  7234. });
  7235. }
  7236. const {
  7237. maxWidth,
  7238. minWidth
  7239. } = props;
  7240. if (maxWidth) {
  7241. style2.push({
  7242. maxWidth: formatLength(maxWidth)
  7243. });
  7244. }
  7245. if (minWidth) {
  7246. style2.push({
  7247. maxWidth: formatLength(minWidth)
  7248. });
  7249. }
  7250. if (!inlineThemeDisabled) {
  7251. style2.push(cssVarsRef.value);
  7252. }
  7253. return style2;
  7254. });
  7255. const cssVarsRef = vue.computed(() => {
  7256. const {
  7257. common: {
  7258. cubicBezierEaseInOut: cubicBezierEaseInOut2,
  7259. cubicBezierEaseIn: cubicBezierEaseIn2,
  7260. cubicBezierEaseOut: cubicBezierEaseOut2
  7261. },
  7262. self: {
  7263. space,
  7264. spaceArrow,
  7265. padding,
  7266. fontSize: fontSize2,
  7267. textColor,
  7268. dividerColor,
  7269. color,
  7270. boxShadow,
  7271. borderRadius,
  7272. arrowHeight,
  7273. arrowOffset,
  7274. arrowOffsetVertical
  7275. }
  7276. } = themeRef.value;
  7277. return {
  7278. "--n-box-shadow": boxShadow,
  7279. "--n-bezier": cubicBezierEaseInOut2,
  7280. "--n-bezier-ease-in": cubicBezierEaseIn2,
  7281. "--n-bezier-ease-out": cubicBezierEaseOut2,
  7282. "--n-font-size": fontSize2,
  7283. "--n-text-color": textColor,
  7284. "--n-color": color,
  7285. "--n-divider-color": dividerColor,
  7286. "--n-border-radius": borderRadius,
  7287. "--n-arrow-height": arrowHeight,
  7288. "--n-arrow-offset": arrowOffset,
  7289. "--n-arrow-offset-vertical": arrowOffsetVertical,
  7290. "--n-padding": padding,
  7291. "--n-space": space,
  7292. "--n-space-arrow": spaceArrow
  7293. };
  7294. });
  7295. const themeClassHandle = inlineThemeDisabled ? useThemeClass("popover", void 0, cssVarsRef, props) : void 0;
  7296. NPopover2.setBodyInstance({
  7297. syncPosition
  7298. });
  7299. vue.onBeforeUnmount(() => {
  7300. NPopover2.setBodyInstance(null);
  7301. });
  7302. vue.watch(vue.toRef(props, "show"), (value) => {
  7303. if (props.animated)
  7304. return;
  7305. if (value) {
  7306. followerEnabledRef.value = true;
  7307. } else {
  7308. followerEnabledRef.value = false;
  7309. }
  7310. });
  7311. function syncPosition() {
  7312. var _a;
  7313. (_a = followerRef.value) === null || _a === void 0 ? void 0 : _a.syncPosition();
  7314. }
  7315. function handleMouseEnter(e) {
  7316. if (props.trigger === "hover" && props.keepAliveOnHover && props.show) {
  7317. NPopover2.handleMouseEnter(e);
  7318. }
  7319. }
  7320. function handleMouseLeave(e) {
  7321. if (props.trigger === "hover" && props.keepAliveOnHover) {
  7322. NPopover2.handleMouseLeave(e);
  7323. }
  7324. }
  7325. function handleMouseMoveOutside(e) {
  7326. if (props.trigger === "hover" && !getTriggerElement().contains(getPreciseEventTarget(e))) {
  7327. NPopover2.handleMouseMoveOutside(e);
  7328. }
  7329. }
  7330. function handleClickOutside(e) {
  7331. if (props.trigger === "click" && !getTriggerElement().contains(getPreciseEventTarget(e)) || props.onClickoutside) {
  7332. NPopover2.handleClickOutside(e);
  7333. }
  7334. }
  7335. function getTriggerElement() {
  7336. return NPopover2.getTriggerElement();
  7337. }
  7338. vue.provide(popoverBodyInjectionKey, bodyRef);
  7339. vue.provide(drawerBodyInjectionKey, null);
  7340. vue.provide(modalBodyInjectionKey, null);
  7341. function renderContentNode() {
  7342. themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender();
  7343. const shouldRenderDom = props.displayDirective === "show" || props.show || props.animated && displayedRef.value;
  7344. if (!shouldRenderDom) {
  7345. return null;
  7346. }
  7347. let contentNode;
  7348. const renderBody = NPopover2.internalRenderBodyRef.value;
  7349. const {
  7350. value: mergedClsPrefix
  7351. } = mergedClsPrefixRef;
  7352. if (!renderBody) {
  7353. const {
  7354. value: extraClass
  7355. } = NPopover2.extraClassRef;
  7356. const {
  7357. internalTrapFocus
  7358. } = props;
  7359. const hasHeaderOrFooter = !isSlotEmpty(slots.header) || !isSlotEmpty(slots.footer);
  7360. const renderContentInnerNode = () => {
  7361. var _a, _b;
  7362. const body = hasHeaderOrFooter ? vue.h(vue.Fragment, null, resolveWrappedSlot(slots.header, (children) => {
  7363. return children ? vue.h("div", {
  7364. class: [`${mergedClsPrefix}-popover__header`, props.headerClass],
  7365. style: props.headerStyle
  7366. }, children) : null;
  7367. }), resolveWrappedSlot(slots.default, (children) => {
  7368. return children ? vue.h("div", {
  7369. class: [`${mergedClsPrefix}-popover__content`, props.contentClass],
  7370. style: props.contentStyle
  7371. }, slots) : null;
  7372. }), resolveWrappedSlot(slots.footer, (children) => {
  7373. return children ? vue.h("div", {
  7374. class: [`${mergedClsPrefix}-popover__footer`, props.footerClass],
  7375. style: props.footerStyle
  7376. }, children) : null;
  7377. })) : props.scrollable ? (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots) : vue.h("div", {
  7378. class: [`${mergedClsPrefix}-popover__content`, props.contentClass],
  7379. style: props.contentStyle
  7380. }, slots);
  7381. const maybeScrollableBody = props.scrollable ? vue.h(XScrollbar, {
  7382. contentClass: hasHeaderOrFooter ? void 0 : `${mergedClsPrefix}-popover__content ${(_b = props.contentClass) !== null && _b !== void 0 ? _b : ""}`,
  7383. contentStyle: hasHeaderOrFooter ? void 0 : props.contentStyle
  7384. }, {
  7385. default: () => body
  7386. }) : body;
  7387. const arrow = props.showArrow ? renderArrow({
  7388. arrowClass: props.arrowClass,
  7389. arrowStyle: props.arrowStyle,
  7390. arrowWrapperClass: props.arrowWrapperClass,
  7391. arrowWrapperStyle: props.arrowWrapperStyle,
  7392. clsPrefix: mergedClsPrefix
  7393. }) : null;
  7394. return [maybeScrollableBody, arrow];
  7395. };
  7396. contentNode = vue.h("div", vue.mergeProps({
  7397. class: [`${mergedClsPrefix}-popover`, `${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, extraClass.map((v) => `${mergedClsPrefix}-${v}`), {
  7398. [`${mergedClsPrefix}-popover--scrollable`]: props.scrollable,
  7399. [`${mergedClsPrefix}-popover--show-header-or-footer`]: hasHeaderOrFooter,
  7400. [`${mergedClsPrefix}-popover--raw`]: props.raw,
  7401. [`${mergedClsPrefix}-popover-shared--overlap`]: props.overlap,
  7402. [`${mergedClsPrefix}-popover-shared--show-arrow`]: props.showArrow,
  7403. [`${mergedClsPrefix}-popover-shared--center-arrow`]: props.arrowPointToCenter
  7404. }],
  7405. ref: bodyRef,
  7406. style: styleRef.value,
  7407. onKeydown: NPopover2.handleKeydown,
  7408. onMouseenter: handleMouseEnter,
  7409. onMouseleave: handleMouseLeave
  7410. }, attrs), internalTrapFocus ? vue.h(FocusTrap, {
  7411. active: props.show,
  7412. autoFocus: true
  7413. }, {
  7414. default: renderContentInnerNode
  7415. }) : renderContentInnerNode());
  7416. } else {
  7417. contentNode = renderBody(
  7418. // The popover class and overlap class must exists, they will be used
  7419. // to place the body & transition animation.
  7420. // Shadow class exists for reuse box-shadow.
  7421. [`${mergedClsPrefix}-popover-shared`, themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass.value, props.overlap && `${mergedClsPrefix}-popover-shared--overlap`, props.showArrow && `${mergedClsPrefix}-popover-shared--show-arrow`, props.arrowPointToCenter && `${mergedClsPrefix}-popover-shared--center-arrow`],
  7422. bodyRef,
  7423. styleRef.value,
  7424. handleMouseEnter,
  7425. handleMouseLeave
  7426. );
  7427. }
  7428. return vue.withDirectives(contentNode, directivesRef.value);
  7429. }
  7430. return {
  7431. displayed: displayedRef,
  7432. namespace: namespaceRef,
  7433. isMounted: NPopover2.isMountedRef,
  7434. zIndex: NPopover2.zIndexRef,
  7435. followerRef,
  7436. adjustedTo: useAdjustedTo(props),
  7437. followerEnabled: followerEnabledRef,
  7438. renderContentNode
  7439. };
  7440. },
  7441. render() {
  7442. return vue.h(VFollower, {
  7443. ref: "followerRef",
  7444. zIndex: this.zIndex,
  7445. show: this.show,
  7446. enabled: this.followerEnabled,
  7447. to: this.adjustedTo,
  7448. x: this.x,
  7449. y: this.y,
  7450. flip: this.flip,
  7451. placement: this.placement,
  7452. containerClass: this.namespace,
  7453. overlap: this.overlap,
  7454. width: this.width === "trigger" ? "target" : void 0,
  7455. teleportDisabled: this.adjustedTo === useAdjustedTo.tdkey
  7456. }, {
  7457. default: () => {
  7458. return this.animated ? vue.h(vue.Transition, {
  7459. name: "popover-transition",
  7460. appear: this.isMounted,
  7461. // Don't use watch to enable follower, since the transition may
  7462. // make position sync timing very subtle and buggy.
  7463. onEnter: () => {
  7464. this.followerEnabled = true;
  7465. },
  7466. onAfterLeave: () => {
  7467. var _a;
  7468. (_a = this.internalOnAfterLeave) === null || _a === void 0 ? void 0 : _a.call(this);
  7469. this.followerEnabled = false;
  7470. this.displayed = false;
  7471. }
  7472. }, {
  7473. default: this.renderContentNode
  7474. }) : this.renderContentNode();
  7475. }
  7476. });
  7477. }
  7478. });
  7479. const bodyPropKeys = Object.keys(popoverBodyProps);
  7480. const triggerEventMap = {
  7481. focus: ["onFocus", "onBlur"],
  7482. click: ["onClick"],
  7483. hover: ["onMouseenter", "onMouseleave"],
  7484. manual: [],
  7485. nested: ["onFocus", "onBlur", "onMouseenter", "onMouseleave", "onClick"]
  7486. };
  7487. function appendEvents(vNode, trigger2, events2) {
  7488. triggerEventMap[trigger2].forEach((eventName) => {
  7489. if (!vNode.props)
  7490. vNode.props = {};
  7491. else {
  7492. vNode.props = Object.assign({}, vNode.props);
  7493. }
  7494. const originalHandler = vNode.props[eventName];
  7495. const handler = events2[eventName];
  7496. if (!originalHandler)
  7497. vNode.props[eventName] = handler;
  7498. else {
  7499. vNode.props[eventName] = (...args) => {
  7500. originalHandler(...args);
  7501. handler(...args);
  7502. };
  7503. }
  7504. });
  7505. }
  7506. const popoverBaseProps = {
  7507. show: {
  7508. type: Boolean,
  7509. default: void 0
  7510. },
  7511. defaultShow: Boolean,
  7512. showArrow: {
  7513. type: Boolean,
  7514. default: true
  7515. },
  7516. trigger: {
  7517. type: String,
  7518. default: "hover"
  7519. },
  7520. delay: {
  7521. type: Number,
  7522. default: 100
  7523. },
  7524. duration: {
  7525. type: Number,
  7526. default: 100
  7527. },
  7528. raw: Boolean,
  7529. placement: {
  7530. type: String,
  7531. default: "top"
  7532. },
  7533. x: Number,
  7534. y: Number,
  7535. arrowPointToCenter: Boolean,
  7536. disabled: Boolean,
  7537. getDisabled: Function,
  7538. displayDirective: {
  7539. type: String,
  7540. default: "if"
  7541. },
  7542. arrowClass: String,
  7543. arrowStyle: [String, Object],
  7544. arrowWrapperClass: String,
  7545. arrowWrapperStyle: [String, Object],
  7546. flip: {
  7547. type: Boolean,
  7548. default: true
  7549. },
  7550. animated: {
  7551. type: Boolean,
  7552. default: true
  7553. },
  7554. width: {
  7555. type: [Number, String],
  7556. default: void 0
  7557. },
  7558. overlap: Boolean,
  7559. keepAliveOnHover: {
  7560. type: Boolean,
  7561. default: true
  7562. },
  7563. zIndex: Number,
  7564. to: useAdjustedTo.propTo,
  7565. scrollable: Boolean,
  7566. contentClass: String,
  7567. contentStyle: [Object, String],
  7568. headerClass: String,
  7569. headerStyle: [Object, String],
  7570. footerClass: String,
  7571. footerStyle: [Object, String],
  7572. // events
  7573. onClickoutside: Function,
  7574. "onUpdate:show": [Function, Array],
  7575. onUpdateShow: [Function, Array],
  7576. // internal
  7577. internalDeactivateImmediately: Boolean,
  7578. internalSyncTargetWithParent: Boolean,
  7579. internalInheritedEventHandlers: {
  7580. type: Array,
  7581. default: () => []
  7582. },
  7583. internalTrapFocus: Boolean,
  7584. internalExtraClass: {
  7585. type: Array,
  7586. default: () => []
  7587. },
  7588. // deprecated
  7589. onShow: [Function, Array],
  7590. onHide: [Function, Array],
  7591. arrow: {
  7592. type: Boolean,
  7593. default: void 0
  7594. },
  7595. minWidth: Number,
  7596. maxWidth: Number
  7597. };
  7598. const popoverProps = Object.assign(Object.assign(Object.assign({}, useTheme.props), popoverBaseProps), {
  7599. internalOnAfterLeave: Function,
  7600. internalRenderBody: Function
  7601. });
  7602. const NPopover = vue.defineComponent({
  7603. name: "Popover",
  7604. inheritAttrs: false,
  7605. props: popoverProps,
  7606. __popover__: true,
  7607. setup(props) {
  7608. const isMountedRef = isMounted();
  7609. const binderInstRef = vue.ref(null);
  7610. const controlledShowRef = vue.computed(() => props.show);
  7611. const uncontrolledShowRef = vue.ref(props.defaultShow);
  7612. const mergedShowWithoutDisabledRef = useMergedState(controlledShowRef, uncontrolledShowRef);
  7613. const mergedShowConsideringDisabledPropRef = useMemo(() => {
  7614. if (props.disabled)
  7615. return false;
  7616. return mergedShowWithoutDisabledRef.value;
  7617. });
  7618. const getMergedDisabled = () => {
  7619. if (props.disabled)
  7620. return true;
  7621. const {
  7622. getDisabled
  7623. } = props;
  7624. if (getDisabled === null || getDisabled === void 0 ? void 0 : getDisabled())
  7625. return true;
  7626. return false;
  7627. };
  7628. const getMergedShow = () => {
  7629. if (getMergedDisabled())
  7630. return false;
  7631. return mergedShowWithoutDisabledRef.value;
  7632. };
  7633. const compatibleShowArrowRef = useCompitable(props, ["arrow", "showArrow"]);
  7634. const mergedShowArrowRef = vue.computed(() => {
  7635. if (props.overlap)
  7636. return false;
  7637. return compatibleShowArrowRef.value;
  7638. });
  7639. let bodyInstance = null;
  7640. const showTimerIdRef = vue.ref(null);
  7641. const hideTimerIdRef = vue.ref(null);
  7642. const positionManuallyRef = useMemo(() => {
  7643. return props.x !== void 0 && props.y !== void 0;
  7644. });
  7645. function doUpdateShow(value) {
  7646. const {
  7647. "onUpdate:show": _onUpdateShow,
  7648. onUpdateShow,
  7649. onShow,
  7650. onHide
  7651. } = props;
  7652. uncontrolledShowRef.value = value;
  7653. if (_onUpdateShow) {
  7654. call(_onUpdateShow, value);
  7655. }
  7656. if (onUpdateShow) {
  7657. call(onUpdateShow, value);
  7658. }
  7659. if (value && onShow) {
  7660. call(onShow, true);
  7661. }
  7662. if (value && onHide) {
  7663. call(onHide, false);
  7664. }
  7665. }
  7666. function syncPosition() {
  7667. if (bodyInstance) {
  7668. bodyInstance.syncPosition();
  7669. }
  7670. }
  7671. function clearShowTimer() {
  7672. const {
  7673. value: showTimerId
  7674. } = showTimerIdRef;
  7675. if (showTimerId) {
  7676. window.clearTimeout(showTimerId);
  7677. showTimerIdRef.value = null;
  7678. }
  7679. }
  7680. function clearHideTimer() {
  7681. const {
  7682. value: hideTimerId
  7683. } = hideTimerIdRef;
  7684. if (hideTimerId) {
  7685. window.clearTimeout(hideTimerId);
  7686. hideTimerIdRef.value = null;
  7687. }
  7688. }
  7689. function handleFocus() {
  7690. const mergedDisabled = getMergedDisabled();
  7691. if (props.trigger === "focus" && !mergedDisabled) {
  7692. if (getMergedShow())
  7693. return;
  7694. doUpdateShow(true);
  7695. }
  7696. }
  7697. function handleBlur() {
  7698. const mergedDisabled = getMergedDisabled();
  7699. if (props.trigger === "focus" && !mergedDisabled) {
  7700. if (!getMergedShow())
  7701. return;
  7702. doUpdateShow(false);
  7703. }
  7704. }
  7705. function handleMouseEnter() {
  7706. const mergedDisabled = getMergedDisabled();
  7707. if (props.trigger === "hover" && !mergedDisabled) {
  7708. clearHideTimer();
  7709. if (showTimerIdRef.value !== null)
  7710. return;
  7711. if (getMergedShow())
  7712. return;
  7713. const delayCallback = () => {
  7714. doUpdateShow(true);
  7715. showTimerIdRef.value = null;
  7716. };
  7717. const {
  7718. delay
  7719. } = props;
  7720. if (delay === 0) {
  7721. delayCallback();
  7722. } else {
  7723. showTimerIdRef.value = window.setTimeout(delayCallback, delay);
  7724. }
  7725. }
  7726. }
  7727. function handleMouseLeave() {
  7728. const mergedDisabled = getMergedDisabled();
  7729. if (props.trigger === "hover" && !mergedDisabled) {
  7730. clearShowTimer();
  7731. if (hideTimerIdRef.value !== null)
  7732. return;
  7733. if (!getMergedShow())
  7734. return;
  7735. const delayedCallback = () => {
  7736. doUpdateShow(false);
  7737. hideTimerIdRef.value = null;
  7738. };
  7739. const {
  7740. duration
  7741. } = props;
  7742. if (duration === 0) {
  7743. delayedCallback();
  7744. } else {
  7745. hideTimerIdRef.value = window.setTimeout(delayedCallback, duration);
  7746. }
  7747. }
  7748. }
  7749. function handleMouseMoveOutside() {
  7750. handleMouseLeave();
  7751. }
  7752. function handleClickOutside(e) {
  7753. var _a;
  7754. if (!getMergedShow())
  7755. return;
  7756. if (props.trigger === "click") {
  7757. clearShowTimer();
  7758. clearHideTimer();
  7759. doUpdateShow(false);
  7760. }
  7761. (_a = props.onClickoutside) === null || _a === void 0 ? void 0 : _a.call(props, e);
  7762. }
  7763. function handleClick() {
  7764. if (props.trigger === "click" && !getMergedDisabled()) {
  7765. clearShowTimer();
  7766. clearHideTimer();
  7767. const nextShow = !getMergedShow();
  7768. doUpdateShow(nextShow);
  7769. }
  7770. }
  7771. function handleKeydown(e) {
  7772. if (!props.internalTrapFocus)
  7773. return;
  7774. if (e.key === "Escape") {
  7775. clearShowTimer();
  7776. clearHideTimer();
  7777. doUpdateShow(false);
  7778. }
  7779. }
  7780. function setShow(value) {
  7781. uncontrolledShowRef.value = value;
  7782. }
  7783. function getTriggerElement() {
  7784. var _a;
  7785. return (_a = binderInstRef.value) === null || _a === void 0 ? void 0 : _a.targetRef;
  7786. }
  7787. function setBodyInstance(value) {
  7788. bodyInstance = value;
  7789. }
  7790. vue.provide("NPopover", {
  7791. getTriggerElement,
  7792. handleKeydown,
  7793. handleMouseEnter,
  7794. handleMouseLeave,
  7795. handleClickOutside,
  7796. handleMouseMoveOutside,
  7797. setBodyInstance,
  7798. positionManuallyRef,
  7799. isMountedRef,
  7800. zIndexRef: vue.toRef(props, "zIndex"),
  7801. extraClassRef: vue.toRef(props, "internalExtraClass"),
  7802. internalRenderBodyRef: vue.toRef(props, "internalRenderBody")
  7803. });
  7804. vue.watchEffect(() => {
  7805. if (mergedShowWithoutDisabledRef.value && getMergedDisabled()) {
  7806. doUpdateShow(false);
  7807. }
  7808. });
  7809. const returned = {
  7810. binderInstRef,
  7811. positionManually: positionManuallyRef,
  7812. mergedShowConsideringDisabledProp: mergedShowConsideringDisabledPropRef,
  7813. // if to show popover body
  7814. uncontrolledShow: uncontrolledShowRef,
  7815. mergedShowArrow: mergedShowArrowRef,
  7816. getMergedShow,
  7817. setShow,
  7818. handleClick,
  7819. handleMouseEnter,
  7820. handleMouseLeave,
  7821. handleFocus,
  7822. handleBlur,
  7823. syncPosition
  7824. };
  7825. return returned;
  7826. },
  7827. render() {
  7828. var _a;
  7829. const {
  7830. positionManually,
  7831. $slots: slots
  7832. } = this;
  7833. let triggerVNode;
  7834. let popoverInside = false;
  7835. if (!positionManually) {
  7836. if (slots.activator) {
  7837. triggerVNode = getFirstSlotVNode(slots, "activator");
  7838. } else {
  7839. triggerVNode = getFirstSlotVNode(slots, "trigger");
  7840. }
  7841. if (triggerVNode) {
  7842. triggerVNode = vue.cloneVNode(triggerVNode);
  7843. triggerVNode = triggerVNode.type === vue.Text ? vue.h("span", [triggerVNode]) : triggerVNode;
  7844. const handlers = {
  7845. onClick: this.handleClick,
  7846. onMouseenter: this.handleMouseEnter,
  7847. onMouseleave: this.handleMouseLeave,
  7848. onFocus: this.handleFocus,
  7849. onBlur: this.handleBlur
  7850. };
  7851. if ((_a = triggerVNode.type) === null || _a === void 0 ? void 0 : _a.__popover__) {
  7852. popoverInside = true;
  7853. if (!triggerVNode.props) {
  7854. triggerVNode.props = {
  7855. internalSyncTargetWithParent: true,
  7856. internalInheritedEventHandlers: []
  7857. };
  7858. }
  7859. triggerVNode.props.internalSyncTargetWithParent = true;
  7860. if (!triggerVNode.props.internalInheritedEventHandlers) {
  7861. triggerVNode.props.internalInheritedEventHandlers = [handlers];
  7862. } else {
  7863. triggerVNode.props.internalInheritedEventHandlers = [handlers, ...triggerVNode.props.internalInheritedEventHandlers];
  7864. }
  7865. } else {
  7866. const {
  7867. internalInheritedEventHandlers
  7868. } = this;
  7869. const ascendantAndCurrentHandlers = [handlers, ...internalInheritedEventHandlers];
  7870. const mergedHandlers = {
  7871. onBlur: (e) => {
  7872. ascendantAndCurrentHandlers.forEach((_handlers) => {
  7873. _handlers.onBlur(e);
  7874. });
  7875. },
  7876. onFocus: (e) => {
  7877. ascendantAndCurrentHandlers.forEach((_handlers) => {
  7878. _handlers.onFocus(e);
  7879. });
  7880. },
  7881. onClick: (e) => {
  7882. ascendantAndCurrentHandlers.forEach((_handlers) => {
  7883. _handlers.onClick(e);
  7884. });
  7885. },
  7886. onMouseenter: (e) => {
  7887. ascendantAndCurrentHandlers.forEach((_handlers) => {
  7888. _handlers.onMouseenter(e);
  7889. });
  7890. },
  7891. onMouseleave: (e) => {
  7892. ascendantAndCurrentHandlers.forEach((_handlers) => {
  7893. _handlers.onMouseleave(e);
  7894. });
  7895. }
  7896. };
  7897. appendEvents(triggerVNode, internalInheritedEventHandlers ? "nested" : positionManually ? "manual" : this.trigger, mergedHandlers);
  7898. }
  7899. }
  7900. }
  7901. return vue.h(Binder, {
  7902. ref: "binderInstRef",
  7903. syncTarget: !popoverInside,
  7904. syncTargetWithParent: this.internalSyncTargetWithParent
  7905. }, {
  7906. default: () => {
  7907. void this.mergedShowConsideringDisabledProp;
  7908. const mergedShow = this.getMergedShow();
  7909. return [this.internalTrapFocus && mergedShow ? vue.withDirectives(vue.h("div", {
  7910. style: {
  7911. position: "fixed",
  7912. inset: 0
  7913. }
  7914. }), [[zindexable, {
  7915. enabled: mergedShow,
  7916. zIndex: this.zIndex
  7917. }]]) : null, positionManually ? null : vue.h(VTarget, null, {
  7918. default: () => triggerVNode
  7919. }), vue.h(NPopoverBody, keep(this.$props, bodyPropKeys, Object.assign(Object.assign({}, this.$attrs), {
  7920. showArrow: this.mergedShowArrow,
  7921. show: mergedShow
  7922. })), {
  7923. default: () => {
  7924. var _a2, _b;
  7925. return (_b = (_a2 = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a2);
  7926. },
  7927. header: () => {
  7928. var _a2, _b;
  7929. return (_b = (_a2 = this.$slots).header) === null || _b === void 0 ? void 0 : _b.call(_a2);
  7930. },
  7931. footer: () => {
  7932. var _a2, _b;
  7933. return (_b = (_a2 = this.$slots).footer) === null || _b === void 0 ? void 0 : _b.call(_a2);
  7934. }
  7935. })];
  7936. }
  7937. });
  7938. }
  7939. });
  7940. const {
  7941. cubicBezierEaseInOut,
  7942. cubicBezierEaseOut,
  7943. cubicBezierEaseIn
  7944. } = commonVariables$2;
  7945. function fadeInHeightExpandTransition({
  7946. overflow = "hidden",
  7947. duration = ".3s",
  7948. originalTransition = "",
  7949. leavingDelay = "0s",
  7950. foldPadding = false,
  7951. enterToProps = void 0,
  7952. leaveToProps = void 0,
  7953. reverse = false
  7954. } = {}) {
  7955. const enterClass = reverse ? "leave" : "enter";
  7956. const leaveClass = reverse ? "enter" : "leave";
  7957. return [c$1(`&.fade-in-height-expand-transition-${leaveClass}-from,
  7958. &.fade-in-height-expand-transition-${enterClass}-to`, Object.assign(Object.assign({}, enterToProps), {
  7959. opacity: 1
  7960. })), c$1(`&.fade-in-height-expand-transition-${leaveClass}-to,
  7961. &.fade-in-height-expand-transition-${enterClass}-from`, Object.assign(Object.assign({}, leaveToProps), {
  7962. opacity: 0,
  7963. marginTop: "0 !important",
  7964. marginBottom: "0 !important",
  7965. paddingTop: foldPadding ? "0 !important" : void 0,
  7966. paddingBottom: foldPadding ? "0 !important" : void 0
  7967. })), c$1(`&.fade-in-height-expand-transition-${leaveClass}-active`, `
  7968. overflow: ${overflow};
  7969. transition:
  7970. max-height ${duration} ${cubicBezierEaseInOut} ${leavingDelay},
  7971. opacity ${duration} ${cubicBezierEaseOut} ${leavingDelay},
  7972. margin-top ${duration} ${cubicBezierEaseInOut} ${leavingDelay},
  7973. margin-bottom ${duration} ${cubicBezierEaseInOut} ${leavingDelay},
  7974. padding-top ${duration} ${cubicBezierEaseInOut} ${leavingDelay},
  7975. padding-bottom ${duration} ${cubicBezierEaseInOut} ${leavingDelay}
  7976. ${originalTransition ? "," + originalTransition : ""}
  7977. `), c$1(`&.fade-in-height-expand-transition-${enterClass}-active`, `
  7978. overflow: ${overflow};
  7979. transition:
  7980. max-height ${duration} ${cubicBezierEaseInOut},
  7981. opacity ${duration} ${cubicBezierEaseIn},
  7982. margin-top ${duration} ${cubicBezierEaseInOut},
  7983. margin-bottom ${duration} ${cubicBezierEaseInOut},
  7984. padding-top ${duration} ${cubicBezierEaseInOut},
  7985. padding-bottom ${duration} ${cubicBezierEaseInOut}
  7986. ${originalTransition ? "," + originalTransition : ""}
  7987. `)];
  7988. }
  7989. const commonVars = {
  7990. padding: "8px 14px"
  7991. };
  7992. const self$4 = (vars) => {
  7993. const {
  7994. borderRadius,
  7995. boxShadow2,
  7996. baseColor
  7997. } = vars;
  7998. return Object.assign(Object.assign({}, commonVars), {
  7999. borderRadius,
  8000. boxShadow: boxShadow2,
  8001. color: composite(baseColor, "rgba(0, 0, 0, .85)"),
  8002. textColor: baseColor
  8003. });
  8004. };
  8005. const tooltipLight = createTheme({
  8006. name: "Tooltip",
  8007. common: derived,
  8008. peers: {
  8009. Popover: popoverLight
  8010. },
  8011. self: self$4
  8012. });
  8013. const commonVariables = {
  8014. padding: "4px 0",
  8015. optionIconSizeSmall: "14px",
  8016. optionIconSizeMedium: "16px",
  8017. optionIconSizeLarge: "16px",
  8018. optionIconSizeHuge: "18px",
  8019. optionSuffixWidthSmall: "14px",
  8020. optionSuffixWidthMedium: "14px",
  8021. optionSuffixWidthLarge: "16px",
  8022. optionSuffixWidthHuge: "16px",
  8023. optionIconSuffixWidthSmall: "32px",
  8024. optionIconSuffixWidthMedium: "32px",
  8025. optionIconSuffixWidthLarge: "36px",
  8026. optionIconSuffixWidthHuge: "36px",
  8027. optionPrefixWidthSmall: "14px",
  8028. optionPrefixWidthMedium: "14px",
  8029. optionPrefixWidthLarge: "16px",
  8030. optionPrefixWidthHuge: "16px",
  8031. optionIconPrefixWidthSmall: "36px",
  8032. optionIconPrefixWidthMedium: "36px",
  8033. optionIconPrefixWidthLarge: "40px",
  8034. optionIconPrefixWidthHuge: "40px"
  8035. };
  8036. const self$3 = (vars) => {
  8037. const {
  8038. primaryColor,
  8039. textColor2,
  8040. dividerColor,
  8041. hoverColor,
  8042. popoverColor,
  8043. invertedColor,
  8044. borderRadius,
  8045. fontSizeSmall,
  8046. fontSizeMedium,
  8047. fontSizeLarge,
  8048. fontSizeHuge,
  8049. heightSmall,
  8050. heightMedium,
  8051. heightLarge,
  8052. heightHuge,
  8053. textColor3,
  8054. opacityDisabled
  8055. } = vars;
  8056. return Object.assign(Object.assign({}, commonVariables), {
  8057. optionHeightSmall: heightSmall,
  8058. optionHeightMedium: heightMedium,
  8059. optionHeightLarge: heightLarge,
  8060. optionHeightHuge: heightHuge,
  8061. borderRadius,
  8062. fontSizeSmall,
  8063. fontSizeMedium,
  8064. fontSizeLarge,
  8065. fontSizeHuge,
  8066. // non-inverted
  8067. optionTextColor: textColor2,
  8068. optionTextColorHover: textColor2,
  8069. optionTextColorActive: primaryColor,
  8070. optionTextColorChildActive: primaryColor,
  8071. color: popoverColor,
  8072. dividerColor,
  8073. suffixColor: textColor2,
  8074. prefixColor: textColor2,
  8075. optionColorHover: hoverColor,
  8076. optionColorActive: changeColor(primaryColor, {
  8077. alpha: 0.1
  8078. }),
  8079. groupHeaderTextColor: textColor3,
  8080. // inverted
  8081. optionTextColorInverted: "#BBB",
  8082. optionTextColorHoverInverted: "#FFF",
  8083. optionTextColorActiveInverted: "#FFF",
  8084. optionTextColorChildActiveInverted: "#FFF",
  8085. colorInverted: invertedColor,
  8086. dividerColorInverted: "#BBB",
  8087. suffixColorInverted: "#BBB",
  8088. prefixColorInverted: "#BBB",
  8089. optionColorHoverInverted: primaryColor,
  8090. optionColorActiveInverted: primaryColor,
  8091. groupHeaderTextColorInverted: "#AAA",
  8092. optionOpacityDisabled: opacityDisabled
  8093. });
  8094. };
  8095. const dropdownLight = createTheme({
  8096. name: "Dropdown",
  8097. common: derived,
  8098. peers: {
  8099. Popover: popoverLight
  8100. },
  8101. self: self$3
  8102. });
  8103. const tooltipProps = Object.assign(Object.assign({}, popoverBaseProps), useTheme.props);
  8104. const NTooltip = vue.defineComponent({
  8105. name: "Tooltip",
  8106. props: tooltipProps,
  8107. __popover__: true,
  8108. setup(props) {
  8109. const {
  8110. mergedClsPrefixRef
  8111. } = useConfig(props);
  8112. const themeRef = useTheme("Tooltip", "-tooltip", void 0, tooltipLight, props, mergedClsPrefixRef);
  8113. const popoverRef = vue.ref(null);
  8114. const tooltipExposedMethod = {
  8115. syncPosition() {
  8116. popoverRef.value.syncPosition();
  8117. },
  8118. setShow(show) {
  8119. popoverRef.value.setShow(show);
  8120. }
  8121. };
  8122. return Object.assign(Object.assign({}, tooltipExposedMethod), {
  8123. popoverRef,
  8124. mergedTheme: themeRef,
  8125. popoverThemeOverrides: vue.computed(() => {
  8126. return themeRef.value.self;
  8127. })
  8128. });
  8129. },
  8130. render() {
  8131. const {
  8132. mergedTheme,
  8133. internalExtraClass
  8134. } = this;
  8135. return vue.h(NPopover, Object.assign(Object.assign({}, this.$props), {
  8136. theme: mergedTheme.peers.Popover,
  8137. themeOverrides: mergedTheme.peerOverrides.Popover,
  8138. builtinThemeOverrides: this.popoverThemeOverrides,
  8139. internalExtraClass: internalExtraClass.concat("tooltip"),
  8140. ref: "popoverRef"
  8141. }), this.$slots);
  8142. }
  8143. });
  8144. const NDropdownDivider = vue.defineComponent({
  8145. name: "DropdownDivider",
  8146. props: {
  8147. clsPrefix: {
  8148. type: String,
  8149. required: true
  8150. }
  8151. },
  8152. render() {
  8153. return vue.h("div", {
  8154. class: `${this.clsPrefix}-dropdown-divider`
  8155. });
  8156. }
  8157. });
  8158. const self$2 = (vars) => {
  8159. const {
  8160. textColorBase,
  8161. opacity1,
  8162. opacity2,
  8163. opacity3,
  8164. opacity4,
  8165. opacity5
  8166. } = vars;
  8167. return {
  8168. color: textColorBase,
  8169. opacity1Depth: opacity1,
  8170. opacity2Depth: opacity2,
  8171. opacity3Depth: opacity3,
  8172. opacity4Depth: opacity4,
  8173. opacity5Depth: opacity5
  8174. };
  8175. };
  8176. const iconLight = {
  8177. name: "Icon",
  8178. common: derived,
  8179. self: self$2
  8180. };
  8181. const style$2 = cB("icon", `
  8182. height: 1em;
  8183. width: 1em;
  8184. line-height: 1em;
  8185. text-align: center;
  8186. display: inline-block;
  8187. position: relative;
  8188. fill: currentColor;
  8189. transform: translateZ(0);
  8190. `, [cM("color-transition", {
  8191. transition: "color .3s var(--n-bezier)"
  8192. }), cM("depth", {
  8193. color: "var(--n-color)"
  8194. }, [c$1("svg", {
  8195. opacity: "var(--n-opacity)",
  8196. transition: "opacity .3s var(--n-bezier)"
  8197. })]), c$1("svg", {
  8198. height: "1em",
  8199. width: "1em"
  8200. })]);
  8201. const iconProps = Object.assign(Object.assign({}, useTheme.props), {
  8202. depth: [String, Number],
  8203. size: [Number, String],
  8204. color: String,
  8205. component: Object
  8206. });
  8207. const NIcon = vue.defineComponent({
  8208. _n_icon__: true,
  8209. name: "Icon",
  8210. inheritAttrs: false,
  8211. props: iconProps,
  8212. setup(props) {
  8213. const {
  8214. mergedClsPrefixRef,
  8215. inlineThemeDisabled
  8216. } = useConfig(props);
  8217. const themeRef = useTheme("Icon", "-icon", style$2, iconLight, props, mergedClsPrefixRef);
  8218. const cssVarsRef = vue.computed(() => {
  8219. const {
  8220. depth
  8221. } = props;
  8222. const {
  8223. common: {
  8224. cubicBezierEaseInOut: cubicBezierEaseInOut2
  8225. },
  8226. self: self2
  8227. } = themeRef.value;
  8228. if (depth !== void 0) {
  8229. const {
  8230. color,
  8231. [`opacity${depth}Depth`]: opacity
  8232. } = self2;
  8233. return {
  8234. "--n-bezier": cubicBezierEaseInOut2,
  8235. "--n-color": color,
  8236. "--n-opacity": opacity
  8237. };
  8238. }
  8239. return {
  8240. "--n-bezier": cubicBezierEaseInOut2,
  8241. "--n-color": "",
  8242. "--n-opacity": ""
  8243. };
  8244. });
  8245. const themeClassHandle = inlineThemeDisabled ? useThemeClass("icon", vue.computed(() => `${props.depth || "d"}`), cssVarsRef, props) : void 0;
  8246. return {
  8247. mergedClsPrefix: mergedClsPrefixRef,
  8248. mergedStyle: vue.computed(() => {
  8249. const {
  8250. size: size2,
  8251. color
  8252. } = props;
  8253. return {
  8254. fontSize: formatLength(size2),
  8255. color
  8256. };
  8257. }),
  8258. cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
  8259. themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
  8260. onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
  8261. };
  8262. },
  8263. render() {
  8264. var _a;
  8265. const {
  8266. $parent,
  8267. depth,
  8268. mergedClsPrefix,
  8269. component,
  8270. onRender,
  8271. themeClass
  8272. } = this;
  8273. if ((_a = $parent === null || $parent === void 0 ? void 0 : $parent.$options) === null || _a === void 0 ? void 0 : _a._n_icon__) {
  8274. warn$2("icon", "don't wrap `n-icon` inside `n-icon`");
  8275. }
  8276. onRender === null || onRender === void 0 ? void 0 : onRender();
  8277. return vue.h("i", vue.mergeProps(this.$attrs, {
  8278. role: "img",
  8279. class: [`${mergedClsPrefix}-icon`, themeClass, {
  8280. [`${mergedClsPrefix}-icon--depth`]: depth,
  8281. [`${mergedClsPrefix}-icon--color-transition`]: depth !== void 0
  8282. }],
  8283. style: [this.cssVars, this.mergedStyle]
  8284. }), component ? vue.h(component) : this.$slots);
  8285. }
  8286. });
  8287. const dropdownMenuInjectionKey = createInjectionKey("n-dropdown-menu");
  8288. const dropdownInjectionKey = createInjectionKey("n-dropdown");
  8289. const dropdownOptionInjectionKey = createInjectionKey("n-dropdown-option");
  8290. function isSubmenuNode(rawNode, childrenField) {
  8291. return rawNode.type === "submenu" || rawNode.type === void 0 && rawNode[childrenField] !== void 0;
  8292. }
  8293. function isGroupNode(rawNode) {
  8294. return rawNode.type === "group";
  8295. }
  8296. function isDividerNode$1(rawNode) {
  8297. return rawNode.type === "divider";
  8298. }
  8299. function isRenderNode(rawNode) {
  8300. return rawNode.type === "render";
  8301. }
  8302. const NDropdownOption = vue.defineComponent({
  8303. name: "DropdownOption",
  8304. props: {
  8305. clsPrefix: {
  8306. type: String,
  8307. required: true
  8308. },
  8309. tmNode: {
  8310. type: Object,
  8311. required: true
  8312. },
  8313. parentKey: {
  8314. type: [String, Number],
  8315. default: null
  8316. },
  8317. placement: {
  8318. type: String,
  8319. default: "right-start"
  8320. },
  8321. props: Object,
  8322. scrollable: Boolean
  8323. },
  8324. setup(props) {
  8325. const NDropdown2 = vue.inject(dropdownInjectionKey);
  8326. const {
  8327. hoverKeyRef,
  8328. keyboardKeyRef,
  8329. lastToggledSubmenuKeyRef,
  8330. pendingKeyPathRef,
  8331. activeKeyPathRef,
  8332. animatedRef,
  8333. mergedShowRef,
  8334. renderLabelRef,
  8335. renderIconRef,
  8336. labelFieldRef,
  8337. childrenFieldRef,
  8338. renderOptionRef,
  8339. nodePropsRef,
  8340. menuPropsRef
  8341. } = NDropdown2;
  8342. const NDropdownOption2 = vue.inject(dropdownOptionInjectionKey, null);
  8343. const NDropdownMenu2 = vue.inject(dropdownMenuInjectionKey);
  8344. const NPopoverBody2 = vue.inject(popoverBodyInjectionKey);
  8345. const rawNodeRef = vue.computed(() => props.tmNode.rawNode);
  8346. const hasSubmenuRef = vue.computed(() => {
  8347. const {
  8348. value: childrenField
  8349. } = childrenFieldRef;
  8350. return isSubmenuNode(props.tmNode.rawNode, childrenField);
  8351. });
  8352. const mergedDisabledRef = vue.computed(() => {
  8353. const {
  8354. disabled
  8355. } = props.tmNode;
  8356. return disabled;
  8357. });
  8358. const showSubmenuRef = vue.computed(() => {
  8359. if (!hasSubmenuRef.value)
  8360. return false;
  8361. const {
  8362. key,
  8363. disabled
  8364. } = props.tmNode;
  8365. if (disabled)
  8366. return false;
  8367. const {
  8368. value: hoverKey
  8369. } = hoverKeyRef;
  8370. const {
  8371. value: keyboardKey
  8372. } = keyboardKeyRef;
  8373. const {
  8374. value: lastToggledSubmenuKey
  8375. } = lastToggledSubmenuKeyRef;
  8376. const {
  8377. value: pendingKeyPath
  8378. } = pendingKeyPathRef;
  8379. if (hoverKey !== null)
  8380. return pendingKeyPath.includes(key);
  8381. if (keyboardKey !== null) {
  8382. return pendingKeyPath.includes(key) && pendingKeyPath[pendingKeyPath.length - 1] !== key;
  8383. }
  8384. if (lastToggledSubmenuKey !== null)
  8385. return pendingKeyPath.includes(key);
  8386. return false;
  8387. });
  8388. const shouldDelayRef = vue.computed(() => {
  8389. return keyboardKeyRef.value === null && !animatedRef.value;
  8390. });
  8391. const deferredShowSubmenuRef = useDeferredTrue(showSubmenuRef, 300, shouldDelayRef);
  8392. const parentEnteringSubmenuRef = vue.computed(() => {
  8393. return !!(NDropdownOption2 === null || NDropdownOption2 === void 0 ? void 0 : NDropdownOption2.enteringSubmenuRef.value);
  8394. });
  8395. const enteringSubmenuRef = vue.ref(false);
  8396. vue.provide(dropdownOptionInjectionKey, {
  8397. enteringSubmenuRef
  8398. });
  8399. function handleSubmenuBeforeEnter() {
  8400. enteringSubmenuRef.value = true;
  8401. }
  8402. function handleSubmenuAfterEnter() {
  8403. enteringSubmenuRef.value = false;
  8404. }
  8405. function handleMouseEnter() {
  8406. const {
  8407. parentKey,
  8408. tmNode
  8409. } = props;
  8410. if (tmNode.disabled)
  8411. return;
  8412. if (!mergedShowRef.value)
  8413. return;
  8414. lastToggledSubmenuKeyRef.value = parentKey;
  8415. keyboardKeyRef.value = null;
  8416. hoverKeyRef.value = tmNode.key;
  8417. }
  8418. function handleMouseMove() {
  8419. const {
  8420. tmNode
  8421. } = props;
  8422. if (tmNode.disabled)
  8423. return;
  8424. if (!mergedShowRef.value)
  8425. return;
  8426. if (hoverKeyRef.value === tmNode.key)
  8427. return;
  8428. handleMouseEnter();
  8429. }
  8430. function handleMouseLeave(e) {
  8431. if (props.tmNode.disabled)
  8432. return;
  8433. if (!mergedShowRef.value)
  8434. return;
  8435. const {
  8436. relatedTarget
  8437. } = e;
  8438. if (relatedTarget && !happensIn({
  8439. target: relatedTarget
  8440. }, "dropdownOption") && !happensIn({
  8441. target: relatedTarget
  8442. }, "scrollbarRail")) {
  8443. hoverKeyRef.value = null;
  8444. }
  8445. }
  8446. function handleClick() {
  8447. const {
  8448. value: hasSubmenu
  8449. } = hasSubmenuRef;
  8450. const {
  8451. tmNode
  8452. } = props;
  8453. if (!mergedShowRef.value)
  8454. return;
  8455. if (!hasSubmenu && !tmNode.disabled) {
  8456. NDropdown2.doSelect(tmNode.key, tmNode.rawNode);
  8457. NDropdown2.doUpdateShow(false);
  8458. }
  8459. }
  8460. return {
  8461. labelField: labelFieldRef,
  8462. renderLabel: renderLabelRef,
  8463. renderIcon: renderIconRef,
  8464. siblingHasIcon: NDropdownMenu2.showIconRef,
  8465. siblingHasSubmenu: NDropdownMenu2.hasSubmenuRef,
  8466. menuProps: menuPropsRef,
  8467. popoverBody: NPopoverBody2,
  8468. animated: animatedRef,
  8469. mergedShowSubmenu: vue.computed(() => {
  8470. return deferredShowSubmenuRef.value && !parentEnteringSubmenuRef.value;
  8471. }),
  8472. rawNode: rawNodeRef,
  8473. hasSubmenu: hasSubmenuRef,
  8474. pending: useMemo(() => {
  8475. const {
  8476. value: pendingKeyPath
  8477. } = pendingKeyPathRef;
  8478. const {
  8479. key
  8480. } = props.tmNode;
  8481. return pendingKeyPath.includes(key);
  8482. }),
  8483. childActive: useMemo(() => {
  8484. const {
  8485. value: activeKeyPath
  8486. } = activeKeyPathRef;
  8487. const {
  8488. key
  8489. } = props.tmNode;
  8490. const index = activeKeyPath.findIndex((k) => key === k);
  8491. if (index === -1)
  8492. return false;
  8493. return index < activeKeyPath.length - 1;
  8494. }),
  8495. active: useMemo(() => {
  8496. const {
  8497. value: activeKeyPath
  8498. } = activeKeyPathRef;
  8499. const {
  8500. key
  8501. } = props.tmNode;
  8502. const index = activeKeyPath.findIndex((k) => key === k);
  8503. if (index === -1)
  8504. return false;
  8505. return index === activeKeyPath.length - 1;
  8506. }),
  8507. mergedDisabled: mergedDisabledRef,
  8508. renderOption: renderOptionRef,
  8509. nodeProps: nodePropsRef,
  8510. handleClick,
  8511. handleMouseMove,
  8512. handleMouseEnter,
  8513. handleMouseLeave,
  8514. handleSubmenuBeforeEnter,
  8515. handleSubmenuAfterEnter
  8516. };
  8517. },
  8518. render() {
  8519. var _a, _b;
  8520. const {
  8521. animated,
  8522. rawNode,
  8523. mergedShowSubmenu,
  8524. clsPrefix,
  8525. siblingHasIcon,
  8526. siblingHasSubmenu,
  8527. renderLabel,
  8528. renderIcon,
  8529. renderOption,
  8530. nodeProps,
  8531. props,
  8532. scrollable
  8533. } = this;
  8534. let submenuVNode = null;
  8535. if (mergedShowSubmenu) {
  8536. const submenuNodeProps = (_a = this.menuProps) === null || _a === void 0 ? void 0 : _a.call(this, rawNode, rawNode.children);
  8537. submenuVNode = vue.h(NDropdownMenu, Object.assign({}, submenuNodeProps, {
  8538. clsPrefix,
  8539. scrollable: this.scrollable,
  8540. tmNodes: this.tmNode.children,
  8541. parentKey: this.tmNode.key
  8542. }));
  8543. }
  8544. const builtinProps = {
  8545. class: [`${clsPrefix}-dropdown-option-body`, this.pending && `${clsPrefix}-dropdown-option-body--pending`, this.active && `${clsPrefix}-dropdown-option-body--active`, this.childActive && `${clsPrefix}-dropdown-option-body--child-active`, this.mergedDisabled && `${clsPrefix}-dropdown-option-body--disabled`],
  8546. onMousemove: this.handleMouseMove,
  8547. onMouseenter: this.handleMouseEnter,
  8548. onMouseleave: this.handleMouseLeave,
  8549. onClick: this.handleClick
  8550. };
  8551. const optionNodeProps = nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(rawNode);
  8552. const node = vue.h("div", Object.assign({
  8553. class: [`${clsPrefix}-dropdown-option`, optionNodeProps === null || optionNodeProps === void 0 ? void 0 : optionNodeProps.class],
  8554. "data-dropdown-option": true
  8555. }, optionNodeProps), vue.h("div", vue.mergeProps(builtinProps, props), [vue.h("div", {
  8556. class: [`${clsPrefix}-dropdown-option-body__prefix`, siblingHasIcon && `${clsPrefix}-dropdown-option-body__prefix--show-icon`]
  8557. }, [renderIcon ? renderIcon(rawNode) : render$1(rawNode.icon)]), vue.h("div", {
  8558. "data-dropdown-option": true,
  8559. class: `${clsPrefix}-dropdown-option-body__label`
  8560. }, renderLabel ? renderLabel(rawNode) : render$1((_b = rawNode[this.labelField]) !== null && _b !== void 0 ? _b : rawNode.title)), vue.h("div", {
  8561. "data-dropdown-option": true,
  8562. class: [`${clsPrefix}-dropdown-option-body__suffix`, siblingHasSubmenu && `${clsPrefix}-dropdown-option-body__suffix--has-submenu`]
  8563. }, this.hasSubmenu ? vue.h(NIcon, null, {
  8564. default: () => vue.h(ChevronRightIcon, null)
  8565. }) : null)]), this.hasSubmenu ? vue.h(Binder, null, {
  8566. default: () => [vue.h(VTarget, null, {
  8567. default: () => vue.h("div", {
  8568. class: `${clsPrefix}-dropdown-offset-container`
  8569. }, vue.h(VFollower, {
  8570. show: this.mergedShowSubmenu,
  8571. placement: this.placement,
  8572. to: scrollable ? this.popoverBody || void 0 : void 0,
  8573. teleportDisabled: !scrollable
  8574. }, {
  8575. default: () => {
  8576. return vue.h("div", {
  8577. class: `${clsPrefix}-dropdown-menu-wrapper`
  8578. }, animated ? vue.h(vue.Transition, {
  8579. onBeforeEnter: this.handleSubmenuBeforeEnter,
  8580. onAfterEnter: this.handleSubmenuAfterEnter,
  8581. name: "fade-in-scale-up-transition",
  8582. appear: true
  8583. }, {
  8584. default: () => submenuVNode
  8585. }) : submenuVNode);
  8586. }
  8587. }))
  8588. })]
  8589. }) : null);
  8590. if (renderOption) {
  8591. return renderOption({
  8592. node,
  8593. option: rawNode
  8594. });
  8595. }
  8596. return node;
  8597. }
  8598. });
  8599. const NDropdownGroupHeader = vue.defineComponent({
  8600. name: "DropdownGroupHeader",
  8601. props: {
  8602. clsPrefix: {
  8603. type: String,
  8604. required: true
  8605. },
  8606. tmNode: {
  8607. type: Object,
  8608. required: true
  8609. }
  8610. },
  8611. setup() {
  8612. const {
  8613. showIconRef,
  8614. hasSubmenuRef
  8615. // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  8616. } = vue.inject(dropdownMenuInjectionKey);
  8617. const {
  8618. renderLabelRef,
  8619. labelFieldRef,
  8620. nodePropsRef,
  8621. renderOptionRef
  8622. } = (
  8623. // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  8624. vue.inject(dropdownInjectionKey)
  8625. );
  8626. return {
  8627. labelField: labelFieldRef,
  8628. showIcon: showIconRef,
  8629. hasSubmenu: hasSubmenuRef,
  8630. renderLabel: renderLabelRef,
  8631. nodeProps: nodePropsRef,
  8632. renderOption: renderOptionRef
  8633. };
  8634. },
  8635. render() {
  8636. var _a;
  8637. const {
  8638. clsPrefix,
  8639. hasSubmenu,
  8640. showIcon,
  8641. nodeProps,
  8642. renderLabel,
  8643. renderOption
  8644. } = this;
  8645. const {
  8646. rawNode
  8647. } = this.tmNode;
  8648. const node = vue.h("div", Object.assign({
  8649. class: `${clsPrefix}-dropdown-option`
  8650. }, nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(rawNode)), vue.h("div", {
  8651. class: `${clsPrefix}-dropdown-option-body ${clsPrefix}-dropdown-option-body--group`
  8652. }, vue.h("div", {
  8653. "data-dropdown-option": true,
  8654. class: [`${clsPrefix}-dropdown-option-body__prefix`, showIcon && `${clsPrefix}-dropdown-option-body__prefix--show-icon`]
  8655. }, render$1(rawNode.icon)), vue.h("div", {
  8656. class: `${clsPrefix}-dropdown-option-body__label`,
  8657. "data-dropdown-option": true
  8658. }, renderLabel ? renderLabel(rawNode) : render$1((_a = rawNode.title) !== null && _a !== void 0 ? _a : rawNode[this.labelField])), vue.h("div", {
  8659. class: [`${clsPrefix}-dropdown-option-body__suffix`, hasSubmenu && `${clsPrefix}-dropdown-option-body__suffix--has-submenu`],
  8660. "data-dropdown-option": true
  8661. })));
  8662. if (renderOption) {
  8663. return renderOption({
  8664. node,
  8665. option: rawNode
  8666. });
  8667. }
  8668. return node;
  8669. }
  8670. });
  8671. const NDropdownGroup = vue.defineComponent({
  8672. name: "NDropdownGroup",
  8673. props: {
  8674. clsPrefix: {
  8675. type: String,
  8676. required: true
  8677. },
  8678. tmNode: {
  8679. type: Object,
  8680. required: true
  8681. },
  8682. parentKey: {
  8683. type: [String, Number],
  8684. default: null
  8685. }
  8686. },
  8687. render() {
  8688. const {
  8689. tmNode,
  8690. parentKey,
  8691. clsPrefix
  8692. } = this;
  8693. const {
  8694. children
  8695. } = tmNode;
  8696. return vue.h(vue.Fragment, null, vue.h(NDropdownGroupHeader, {
  8697. clsPrefix,
  8698. tmNode,
  8699. key: tmNode.key
  8700. }), children === null || children === void 0 ? void 0 : children.map((child) => {
  8701. const {
  8702. rawNode
  8703. } = child;
  8704. if (rawNode.show === false)
  8705. return null;
  8706. if (isDividerNode$1(rawNode)) {
  8707. return vue.h(NDropdownDivider, {
  8708. clsPrefix,
  8709. key: child.key
  8710. });
  8711. }
  8712. if (child.isGroup) {
  8713. warn$2("dropdown", "`group` node is not allowed to be put in `group` node.");
  8714. return null;
  8715. }
  8716. return vue.h(NDropdownOption, {
  8717. clsPrefix,
  8718. tmNode: child,
  8719. parentKey,
  8720. key: child.key
  8721. });
  8722. }));
  8723. }
  8724. });
  8725. const NDropdownRenderOption = vue.defineComponent({
  8726. name: "DropdownRenderOption",
  8727. props: {
  8728. tmNode: {
  8729. type: Object,
  8730. required: true
  8731. }
  8732. },
  8733. render() {
  8734. const {
  8735. rawNode: {
  8736. render: render2,
  8737. props
  8738. }
  8739. } = this.tmNode;
  8740. return vue.h("div", props, [render2 === null || render2 === void 0 ? void 0 : render2()]);
  8741. }
  8742. });
  8743. const NDropdownMenu = vue.defineComponent({
  8744. name: "DropdownMenu",
  8745. props: {
  8746. scrollable: Boolean,
  8747. showArrow: Boolean,
  8748. arrowStyle: [String, Object],
  8749. clsPrefix: {
  8750. type: String,
  8751. required: true
  8752. },
  8753. tmNodes: {
  8754. type: Array,
  8755. default: () => []
  8756. },
  8757. parentKey: {
  8758. type: [String, Number],
  8759. default: null
  8760. }
  8761. },
  8762. setup(props) {
  8763. const {
  8764. renderIconRef,
  8765. childrenFieldRef
  8766. } = vue.inject(dropdownInjectionKey);
  8767. vue.provide(dropdownMenuInjectionKey, {
  8768. showIconRef: vue.computed(() => {
  8769. const renderIcon = renderIconRef.value;
  8770. return props.tmNodes.some((tmNode) => {
  8771. var _a;
  8772. if (tmNode.isGroup) {
  8773. return (_a = tmNode.children) === null || _a === void 0 ? void 0 : _a.some(({
  8774. rawNode: rawChild
  8775. }) => renderIcon ? renderIcon(rawChild) : rawChild.icon);
  8776. }
  8777. const {
  8778. rawNode
  8779. } = tmNode;
  8780. return renderIcon ? renderIcon(rawNode) : rawNode.icon;
  8781. });
  8782. }),
  8783. hasSubmenuRef: vue.computed(() => {
  8784. const {
  8785. value: childrenField
  8786. } = childrenFieldRef;
  8787. return props.tmNodes.some((tmNode) => {
  8788. var _a;
  8789. if (tmNode.isGroup) {
  8790. return (_a = tmNode.children) === null || _a === void 0 ? void 0 : _a.some(({
  8791. rawNode: rawChild
  8792. }) => isSubmenuNode(rawChild, childrenField));
  8793. }
  8794. const {
  8795. rawNode
  8796. } = tmNode;
  8797. return isSubmenuNode(rawNode, childrenField);
  8798. });
  8799. })
  8800. });
  8801. const bodyRef = vue.ref(null);
  8802. vue.provide(modalBodyInjectionKey, null);
  8803. vue.provide(drawerBodyInjectionKey, null);
  8804. vue.provide(popoverBodyInjectionKey, bodyRef);
  8805. return {
  8806. bodyRef
  8807. };
  8808. },
  8809. render() {
  8810. const {
  8811. parentKey,
  8812. clsPrefix,
  8813. scrollable
  8814. } = this;
  8815. const menuOptionsNode = this.tmNodes.map((tmNode) => {
  8816. const {
  8817. rawNode
  8818. } = tmNode;
  8819. if (rawNode.show === false)
  8820. return null;
  8821. if (isRenderNode(rawNode)) {
  8822. return vue.h(NDropdownRenderOption, {
  8823. tmNode,
  8824. key: tmNode.key
  8825. });
  8826. }
  8827. if (isDividerNode$1(rawNode)) {
  8828. return vue.h(NDropdownDivider, {
  8829. clsPrefix,
  8830. key: tmNode.key
  8831. });
  8832. }
  8833. if (isGroupNode(rawNode)) {
  8834. return vue.h(NDropdownGroup, {
  8835. clsPrefix,
  8836. tmNode,
  8837. parentKey,
  8838. key: tmNode.key
  8839. });
  8840. }
  8841. return vue.h(NDropdownOption, {
  8842. clsPrefix,
  8843. tmNode,
  8844. parentKey,
  8845. key: tmNode.key,
  8846. props: rawNode.props,
  8847. scrollable
  8848. });
  8849. });
  8850. return vue.h("div", {
  8851. class: [`${clsPrefix}-dropdown-menu`, scrollable && `${clsPrefix}-dropdown-menu--scrollable`],
  8852. ref: "bodyRef"
  8853. }, scrollable ? vue.h(XScrollbar, {
  8854. contentClass: `${clsPrefix}-dropdown-menu__content`
  8855. }, {
  8856. default: () => menuOptionsNode
  8857. }) : menuOptionsNode, this.showArrow ? renderArrow({
  8858. clsPrefix,
  8859. arrowStyle: this.arrowStyle,
  8860. arrowClass: void 0,
  8861. arrowWrapperClass: void 0,
  8862. arrowWrapperStyle: void 0
  8863. }) : null);
  8864. }
  8865. });
  8866. const style$1 = cB("dropdown-menu", `
  8867. transform-origin: var(--v-transform-origin);
  8868. background-color: var(--n-color);
  8869. border-radius: var(--n-border-radius);
  8870. box-shadow: var(--n-box-shadow);
  8871. position: relative;
  8872. transition:
  8873. background-color .3s var(--n-bezier),
  8874. box-shadow .3s var(--n-bezier);
  8875. `, [fadeInScaleUpTransition(), cB("dropdown-option", `
  8876. position: relative;
  8877. `, [c$1("a", `
  8878. text-decoration: none;
  8879. color: inherit;
  8880. outline: none;
  8881. `, [c$1("&::before", `
  8882. content: "";
  8883. position: absolute;
  8884. left: 0;
  8885. right: 0;
  8886. top: 0;
  8887. bottom: 0;
  8888. `)]), cB("dropdown-option-body", `
  8889. display: flex;
  8890. cursor: pointer;
  8891. position: relative;
  8892. height: var(--n-option-height);
  8893. line-height: var(--n-option-height);
  8894. font-size: var(--n-font-size);
  8895. color: var(--n-option-text-color);
  8896. transition: color .3s var(--n-bezier);
  8897. `, [c$1("&::before", `
  8898. content: "";
  8899. position: absolute;
  8900. top: 0;
  8901. bottom: 0;
  8902. left: 4px;
  8903. right: 4px;
  8904. transition: background-color .3s var(--n-bezier);
  8905. border-radius: var(--n-border-radius);
  8906. `), cNotM("disabled", [cM("pending", `
  8907. color: var(--n-option-text-color-hover);
  8908. `, [cE("prefix, suffix", `
  8909. color: var(--n-option-text-color-hover);
  8910. `), c$1("&::before", "background-color: var(--n-option-color-hover);")]), cM("active", `
  8911. color: var(--n-option-text-color-active);
  8912. `, [cE("prefix, suffix", `
  8913. color: var(--n-option-text-color-active);
  8914. `), c$1("&::before", "background-color: var(--n-option-color-active);")]), cM("child-active", `
  8915. color: var(--n-option-text-color-child-active);
  8916. `, [cE("prefix, suffix", `
  8917. color: var(--n-option-text-color-child-active);
  8918. `)])]), cM("disabled", `
  8919. cursor: not-allowed;
  8920. opacity: var(--n-option-opacity-disabled);
  8921. `), cM("group", `
  8922. font-size: calc(var(--n-font-size) - 1px);
  8923. color: var(--n-group-header-text-color);
  8924. `, [cE("prefix", `
  8925. width: calc(var(--n-option-prefix-width) / 2);
  8926. `, [cM("show-icon", `
  8927. width: calc(var(--n-option-icon-prefix-width) / 2);
  8928. `)])]), cE("prefix", `
  8929. width: var(--n-option-prefix-width);
  8930. display: flex;
  8931. justify-content: center;
  8932. align-items: center;
  8933. color: var(--n-prefix-color);
  8934. transition: color .3s var(--n-bezier);
  8935. z-index: 1;
  8936. `, [cM("show-icon", `
  8937. width: var(--n-option-icon-prefix-width);
  8938. `), cB("icon", `
  8939. font-size: var(--n-option-icon-size);
  8940. `)]), cE("label", `
  8941. white-space: nowrap;
  8942. flex: 1;
  8943. z-index: 1;
  8944. `), cE("suffix", `
  8945. box-sizing: border-box;
  8946. flex-grow: 0;
  8947. flex-shrink: 0;
  8948. display: flex;
  8949. justify-content: flex-end;
  8950. align-items: center;
  8951. min-width: var(--n-option-suffix-width);
  8952. padding: 0 8px;
  8953. transition: color .3s var(--n-bezier);
  8954. color: var(--n-suffix-color);
  8955. z-index: 1;
  8956. `, [cM("has-submenu", `
  8957. width: var(--n-option-icon-suffix-width);
  8958. `), cB("icon", `
  8959. font-size: var(--n-option-icon-size);
  8960. `)]), cB("dropdown-menu", "pointer-events: all;")]), cB("dropdown-offset-container", `
  8961. pointer-events: none;
  8962. position: absolute;
  8963. left: 0;
  8964. right: 0;
  8965. top: -4px;
  8966. bottom: -4px;
  8967. `)]), cB("dropdown-divider", `
  8968. transition: background-color .3s var(--n-bezier);
  8969. background-color: var(--n-divider-color);
  8970. height: 1px;
  8971. margin: 4px 0;
  8972. `), cB("dropdown-menu-wrapper", `
  8973. transform-origin: var(--v-transform-origin);
  8974. width: fit-content;
  8975. `), c$1(">", [cB("scrollbar", `
  8976. height: inherit;
  8977. max-height: inherit;
  8978. `)]), cNotM("scrollable", `
  8979. padding: var(--n-padding);
  8980. `), cM("scrollable", [cE("content", `
  8981. padding: var(--n-padding);
  8982. `)])]);
  8983. const dropdownBaseProps = {
  8984. animated: {
  8985. type: Boolean,
  8986. default: true
  8987. },
  8988. keyboard: {
  8989. type: Boolean,
  8990. default: true
  8991. },
  8992. size: {
  8993. type: String,
  8994. default: "medium"
  8995. },
  8996. inverted: Boolean,
  8997. placement: {
  8998. type: String,
  8999. default: "bottom"
  9000. },
  9001. onSelect: [Function, Array],
  9002. options: {
  9003. type: Array,
  9004. default: () => []
  9005. },
  9006. menuProps: Function,
  9007. showArrow: Boolean,
  9008. renderLabel: Function,
  9009. renderIcon: Function,
  9010. renderOption: Function,
  9011. nodeProps: Function,
  9012. labelField: {
  9013. type: String,
  9014. default: "label"
  9015. },
  9016. keyField: {
  9017. type: String,
  9018. default: "key"
  9019. },
  9020. childrenField: {
  9021. type: String,
  9022. default: "children"
  9023. },
  9024. // for menu, not documented
  9025. value: [String, Number]
  9026. };
  9027. const popoverPropKeys = Object.keys(popoverBaseProps);
  9028. const dropdownProps = Object.assign(Object.assign(Object.assign({}, popoverBaseProps), dropdownBaseProps), useTheme.props);
  9029. const NDropdown = vue.defineComponent({
  9030. name: "Dropdown",
  9031. inheritAttrs: false,
  9032. props: dropdownProps,
  9033. setup(props) {
  9034. const uncontrolledShowRef = vue.ref(false);
  9035. const mergedShowRef = useMergedState(vue.toRef(props, "show"), uncontrolledShowRef);
  9036. const treemateRef = vue.computed(() => {
  9037. const {
  9038. keyField,
  9039. childrenField
  9040. } = props;
  9041. return createTreeMate(props.options, {
  9042. getKey(node) {
  9043. return node[keyField];
  9044. },
  9045. getDisabled(node) {
  9046. return node.disabled === true;
  9047. },
  9048. getIgnored(node) {
  9049. return node.type === "divider" || node.type === "render";
  9050. },
  9051. getChildren(node) {
  9052. return node[childrenField];
  9053. }
  9054. });
  9055. });
  9056. const tmNodesRef = vue.computed(() => {
  9057. return treemateRef.value.treeNodes;
  9058. });
  9059. const hoverKeyRef = vue.ref(null);
  9060. const keyboardKeyRef = vue.ref(null);
  9061. const lastToggledSubmenuKeyRef = vue.ref(null);
  9062. const pendingKeyRef = vue.computed(() => {
  9063. var _a, _b, _c;
  9064. return (_c = (_b = (_a = hoverKeyRef.value) !== null && _a !== void 0 ? _a : keyboardKeyRef.value) !== null && _b !== void 0 ? _b : lastToggledSubmenuKeyRef.value) !== null && _c !== void 0 ? _c : null;
  9065. });
  9066. const pendingKeyPathRef = vue.computed(() => treemateRef.value.getPath(pendingKeyRef.value).keyPath);
  9067. const activeKeyPathRef = vue.computed(() => treemateRef.value.getPath(props.value).keyPath);
  9068. const keyboardEnabledRef = useMemo(() => {
  9069. return props.keyboard && mergedShowRef.value;
  9070. });
  9071. useKeyboard({
  9072. keydown: {
  9073. ArrowUp: {
  9074. prevent: true,
  9075. handler: handleKeydownUp
  9076. },
  9077. ArrowRight: {
  9078. prevent: true,
  9079. handler: handleKeydownRight
  9080. },
  9081. ArrowDown: {
  9082. prevent: true,
  9083. handler: handleKeydownDown
  9084. },
  9085. ArrowLeft: {
  9086. prevent: true,
  9087. handler: handleKeydownLeft
  9088. },
  9089. Enter: {
  9090. prevent: true,
  9091. handler: handleKeydownEnter
  9092. },
  9093. Escape: handleKeydownEsc
  9094. }
  9095. }, keyboardEnabledRef);
  9096. const {
  9097. mergedClsPrefixRef,
  9098. inlineThemeDisabled
  9099. } = useConfig(props);
  9100. const themeRef = useTheme("Dropdown", "-dropdown", style$1, dropdownLight, props, mergedClsPrefixRef);
  9101. vue.provide(dropdownInjectionKey, {
  9102. labelFieldRef: vue.toRef(props, "labelField"),
  9103. childrenFieldRef: vue.toRef(props, "childrenField"),
  9104. renderLabelRef: vue.toRef(props, "renderLabel"),
  9105. renderIconRef: vue.toRef(props, "renderIcon"),
  9106. hoverKeyRef,
  9107. keyboardKeyRef,
  9108. lastToggledSubmenuKeyRef,
  9109. pendingKeyPathRef,
  9110. activeKeyPathRef,
  9111. animatedRef: vue.toRef(props, "animated"),
  9112. mergedShowRef,
  9113. nodePropsRef: vue.toRef(props, "nodeProps"),
  9114. renderOptionRef: vue.toRef(props, "renderOption"),
  9115. menuPropsRef: vue.toRef(props, "menuProps"),
  9116. doSelect,
  9117. doUpdateShow
  9118. });
  9119. vue.watch(mergedShowRef, (value) => {
  9120. if (!props.animated && !value) {
  9121. clearPendingState();
  9122. }
  9123. });
  9124. function doSelect(key, node) {
  9125. const {
  9126. onSelect
  9127. } = props;
  9128. if (onSelect)
  9129. call(onSelect, key, node);
  9130. }
  9131. function doUpdateShow(value) {
  9132. const {
  9133. "onUpdate:show": _onUpdateShow,
  9134. onUpdateShow
  9135. } = props;
  9136. if (_onUpdateShow)
  9137. call(_onUpdateShow, value);
  9138. if (onUpdateShow)
  9139. call(onUpdateShow, value);
  9140. uncontrolledShowRef.value = value;
  9141. }
  9142. function clearPendingState() {
  9143. hoverKeyRef.value = null;
  9144. keyboardKeyRef.value = null;
  9145. lastToggledSubmenuKeyRef.value = null;
  9146. }
  9147. function handleKeydownEsc() {
  9148. doUpdateShow(false);
  9149. }
  9150. function handleKeydownLeft() {
  9151. handleKeydown("left");
  9152. }
  9153. function handleKeydownRight() {
  9154. handleKeydown("right");
  9155. }
  9156. function handleKeydownUp() {
  9157. handleKeydown("up");
  9158. }
  9159. function handleKeydownDown() {
  9160. handleKeydown("down");
  9161. }
  9162. function handleKeydownEnter() {
  9163. const pendingNode = getPendingNode();
  9164. if ((pendingNode === null || pendingNode === void 0 ? void 0 : pendingNode.isLeaf) && mergedShowRef.value) {
  9165. doSelect(pendingNode.key, pendingNode.rawNode);
  9166. doUpdateShow(false);
  9167. }
  9168. }
  9169. function getPendingNode() {
  9170. var _a;
  9171. const {
  9172. value: treeMate
  9173. } = treemateRef;
  9174. const {
  9175. value: pendingKey
  9176. } = pendingKeyRef;
  9177. if (!treeMate || pendingKey === null)
  9178. return null;
  9179. return (_a = treeMate.getNode(pendingKey)) !== null && _a !== void 0 ? _a : null;
  9180. }
  9181. function handleKeydown(direction) {
  9182. const {
  9183. value: pendingKey
  9184. } = pendingKeyRef;
  9185. const {
  9186. value: {
  9187. getFirstAvailableNode: getFirstAvailableNode2
  9188. }
  9189. } = treemateRef;
  9190. let nextKeyboardKey = null;
  9191. if (pendingKey === null) {
  9192. const firstNode = getFirstAvailableNode2();
  9193. if (firstNode !== null) {
  9194. nextKeyboardKey = firstNode.key;
  9195. }
  9196. } else {
  9197. const currentNode = getPendingNode();
  9198. if (currentNode) {
  9199. let nextNode;
  9200. switch (direction) {
  9201. case "down":
  9202. nextNode = currentNode.getNext();
  9203. break;
  9204. case "up":
  9205. nextNode = currentNode.getPrev();
  9206. break;
  9207. case "right":
  9208. nextNode = currentNode.getChild();
  9209. break;
  9210. case "left":
  9211. nextNode = currentNode.getParent();
  9212. break;
  9213. }
  9214. if (nextNode)
  9215. nextKeyboardKey = nextNode.key;
  9216. }
  9217. }
  9218. if (nextKeyboardKey !== null) {
  9219. hoverKeyRef.value = null;
  9220. keyboardKeyRef.value = nextKeyboardKey;
  9221. }
  9222. }
  9223. const cssVarsRef = vue.computed(() => {
  9224. const {
  9225. size: size2,
  9226. inverted
  9227. } = props;
  9228. const {
  9229. common: {
  9230. cubicBezierEaseInOut: cubicBezierEaseInOut2
  9231. },
  9232. self: self2
  9233. } = themeRef.value;
  9234. const {
  9235. padding,
  9236. dividerColor,
  9237. borderRadius,
  9238. optionOpacityDisabled,
  9239. [createKey("optionIconSuffixWidth", size2)]: optionIconSuffixWidth,
  9240. [createKey("optionSuffixWidth", size2)]: optionSuffixWidth,
  9241. [createKey("optionIconPrefixWidth", size2)]: optionIconPrefixWidth,
  9242. [createKey("optionPrefixWidth", size2)]: optionPrefixWidth,
  9243. [createKey("fontSize", size2)]: fontSize2,
  9244. [createKey("optionHeight", size2)]: optionHeight,
  9245. [createKey("optionIconSize", size2)]: optionIconSize
  9246. } = self2;
  9247. const vars = {
  9248. "--n-bezier": cubicBezierEaseInOut2,
  9249. "--n-font-size": fontSize2,
  9250. "--n-padding": padding,
  9251. "--n-border-radius": borderRadius,
  9252. "--n-option-height": optionHeight,
  9253. "--n-option-prefix-width": optionPrefixWidth,
  9254. "--n-option-icon-prefix-width": optionIconPrefixWidth,
  9255. "--n-option-suffix-width": optionSuffixWidth,
  9256. "--n-option-icon-suffix-width": optionIconSuffixWidth,
  9257. "--n-option-icon-size": optionIconSize,
  9258. "--n-divider-color": dividerColor,
  9259. "--n-option-opacity-disabled": optionOpacityDisabled
  9260. };
  9261. if (inverted) {
  9262. vars["--n-color"] = self2.colorInverted;
  9263. vars["--n-option-color-hover"] = self2.optionColorHoverInverted;
  9264. vars["--n-option-color-active"] = self2.optionColorActiveInverted;
  9265. vars["--n-option-text-color"] = self2.optionTextColorInverted;
  9266. vars["--n-option-text-color-hover"] = self2.optionTextColorHoverInverted;
  9267. vars["--n-option-text-color-active"] = self2.optionTextColorActiveInverted;
  9268. vars["--n-option-text-color-child-active"] = self2.optionTextColorChildActiveInverted;
  9269. vars["--n-prefix-color"] = self2.prefixColorInverted;
  9270. vars["--n-suffix-color"] = self2.suffixColorInverted;
  9271. vars["--n-group-header-text-color"] = self2.groupHeaderTextColorInverted;
  9272. } else {
  9273. vars["--n-color"] = self2.color;
  9274. vars["--n-option-color-hover"] = self2.optionColorHover;
  9275. vars["--n-option-color-active"] = self2.optionColorActive;
  9276. vars["--n-option-text-color"] = self2.optionTextColor;
  9277. vars["--n-option-text-color-hover"] = self2.optionTextColorHover;
  9278. vars["--n-option-text-color-active"] = self2.optionTextColorActive;
  9279. vars["--n-option-text-color-child-active"] = self2.optionTextColorChildActive;
  9280. vars["--n-prefix-color"] = self2.prefixColor;
  9281. vars["--n-suffix-color"] = self2.suffixColor;
  9282. vars["--n-group-header-text-color"] = self2.groupHeaderTextColor;
  9283. }
  9284. return vars;
  9285. });
  9286. const themeClassHandle = inlineThemeDisabled ? useThemeClass("dropdown", vue.computed(() => `${props.size[0]}${props.inverted ? "i" : ""}`), cssVarsRef, props) : void 0;
  9287. return {
  9288. mergedClsPrefix: mergedClsPrefixRef,
  9289. mergedTheme: themeRef,
  9290. // data
  9291. tmNodes: tmNodesRef,
  9292. // show
  9293. mergedShow: mergedShowRef,
  9294. // methods
  9295. handleAfterLeave: () => {
  9296. if (!props.animated)
  9297. return;
  9298. clearPendingState();
  9299. },
  9300. doUpdateShow,
  9301. cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
  9302. themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
  9303. onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
  9304. };
  9305. },
  9306. render() {
  9307. const renderPopoverBody = (className, ref2, style2, onMouseenter, onMouseleave) => {
  9308. var _a;
  9309. const {
  9310. mergedClsPrefix,
  9311. menuProps: menuProps2
  9312. } = this;
  9313. (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
  9314. const menuNodeProps = (menuProps2 === null || menuProps2 === void 0 ? void 0 : menuProps2(void 0, this.tmNodes.map((v) => v.rawNode))) || {};
  9315. const dropdownProps2 = {
  9316. ref: createRefSetter(ref2),
  9317. class: [className, `${mergedClsPrefix}-dropdown`, this.themeClass],
  9318. clsPrefix: mergedClsPrefix,
  9319. tmNodes: this.tmNodes,
  9320. style: [...style2, this.cssVars],
  9321. showArrow: this.showArrow,
  9322. arrowStyle: this.arrowStyle,
  9323. scrollable: this.scrollable,
  9324. onMouseenter,
  9325. onMouseleave
  9326. };
  9327. return vue.h(NDropdownMenu, vue.mergeProps(this.$attrs, dropdownProps2, menuNodeProps));
  9328. };
  9329. const {
  9330. mergedTheme
  9331. } = this;
  9332. const popoverProps2 = {
  9333. show: this.mergedShow,
  9334. theme: mergedTheme.peers.Popover,
  9335. themeOverrides: mergedTheme.peerOverrides.Popover,
  9336. internalOnAfterLeave: this.handleAfterLeave,
  9337. internalRenderBody: renderPopoverBody,
  9338. onUpdateShow: this.doUpdateShow,
  9339. "onUpdate:show": void 0
  9340. };
  9341. return vue.h(NPopover, Object.assign({}, keep(this.$props, popoverPropKeys), popoverProps2), {
  9342. trigger: () => {
  9343. var _a, _b;
  9344. return (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a);
  9345. }
  9346. });
  9347. }
  9348. });
  9349. function createPartialInvertedVars(color, activeItemColor, activeTextColor, groupTextColor) {
  9350. return {
  9351. itemColorHoverInverted: "#0000",
  9352. itemColorActiveInverted: activeItemColor,
  9353. itemColorActiveHoverInverted: activeItemColor,
  9354. itemColorActiveCollapsedInverted: activeItemColor,
  9355. itemTextColorInverted: color,
  9356. itemTextColorHoverInverted: activeTextColor,
  9357. itemTextColorChildActiveInverted: activeTextColor,
  9358. itemTextColorChildActiveHoverInverted: activeTextColor,
  9359. itemTextColorActiveInverted: activeTextColor,
  9360. itemTextColorActiveHoverInverted: activeTextColor,
  9361. itemTextColorHorizontalInverted: color,
  9362. itemTextColorHoverHorizontalInverted: activeTextColor,
  9363. itemTextColorChildActiveHorizontalInverted: activeTextColor,
  9364. itemTextColorChildActiveHoverHorizontalInverted: activeTextColor,
  9365. itemTextColorActiveHorizontalInverted: activeTextColor,
  9366. itemTextColorActiveHoverHorizontalInverted: activeTextColor,
  9367. itemIconColorInverted: color,
  9368. itemIconColorHoverInverted: activeTextColor,
  9369. itemIconColorActiveInverted: activeTextColor,
  9370. itemIconColorActiveHoverInverted: activeTextColor,
  9371. itemIconColorChildActiveInverted: activeTextColor,
  9372. itemIconColorChildActiveHoverInverted: activeTextColor,
  9373. itemIconColorCollapsedInverted: color,
  9374. itemIconColorHorizontalInverted: color,
  9375. itemIconColorHoverHorizontalInverted: activeTextColor,
  9376. itemIconColorActiveHorizontalInverted: activeTextColor,
  9377. itemIconColorActiveHoverHorizontalInverted: activeTextColor,
  9378. itemIconColorChildActiveHorizontalInverted: activeTextColor,
  9379. itemIconColorChildActiveHoverHorizontalInverted: activeTextColor,
  9380. arrowColorInverted: color,
  9381. arrowColorHoverInverted: activeTextColor,
  9382. arrowColorActiveInverted: activeTextColor,
  9383. arrowColorActiveHoverInverted: activeTextColor,
  9384. arrowColorChildActiveInverted: activeTextColor,
  9385. arrowColorChildActiveHoverInverted: activeTextColor,
  9386. groupTextColorInverted: groupTextColor
  9387. };
  9388. }
  9389. const self$1 = (vars) => {
  9390. const {
  9391. borderRadius,
  9392. textColor3,
  9393. primaryColor,
  9394. textColor2,
  9395. textColor1,
  9396. fontSize: fontSize2,
  9397. dividerColor,
  9398. hoverColor,
  9399. primaryColorHover
  9400. } = vars;
  9401. return Object.assign({
  9402. borderRadius,
  9403. color: "#0000",
  9404. groupTextColor: textColor3,
  9405. itemColorHover: hoverColor,
  9406. itemColorActive: changeColor(primaryColor, {
  9407. alpha: 0.1
  9408. }),
  9409. itemColorActiveHover: changeColor(primaryColor, {
  9410. alpha: 0.1
  9411. }),
  9412. itemColorActiveCollapsed: changeColor(primaryColor, {
  9413. alpha: 0.1
  9414. }),
  9415. itemTextColor: textColor2,
  9416. itemTextColorHover: textColor2,
  9417. itemTextColorActive: primaryColor,
  9418. itemTextColorActiveHover: primaryColor,
  9419. itemTextColorChildActive: primaryColor,
  9420. itemTextColorChildActiveHover: primaryColor,
  9421. itemTextColorHorizontal: textColor2,
  9422. itemTextColorHoverHorizontal: primaryColorHover,
  9423. itemTextColorActiveHorizontal: primaryColor,
  9424. itemTextColorActiveHoverHorizontal: primaryColor,
  9425. itemTextColorChildActiveHorizontal: primaryColor,
  9426. itemTextColorChildActiveHoverHorizontal: primaryColor,
  9427. itemIconColor: textColor1,
  9428. itemIconColorHover: textColor1,
  9429. itemIconColorActive: primaryColor,
  9430. itemIconColorActiveHover: primaryColor,
  9431. itemIconColorChildActive: primaryColor,
  9432. itemIconColorChildActiveHover: primaryColor,
  9433. itemIconColorCollapsed: textColor1,
  9434. itemIconColorHorizontal: textColor1,
  9435. itemIconColorHoverHorizontal: primaryColorHover,
  9436. itemIconColorActiveHorizontal: primaryColor,
  9437. itemIconColorActiveHoverHorizontal: primaryColor,
  9438. itemIconColorChildActiveHorizontal: primaryColor,
  9439. itemIconColorChildActiveHoverHorizontal: primaryColor,
  9440. itemHeight: "42px",
  9441. arrowColor: textColor2,
  9442. arrowColorHover: textColor2,
  9443. arrowColorActive: primaryColor,
  9444. arrowColorActiveHover: primaryColor,
  9445. arrowColorChildActive: primaryColor,
  9446. arrowColorChildActiveHover: primaryColor,
  9447. colorInverted: "#0000",
  9448. borderColorHorizontal: "#0000",
  9449. fontSize: fontSize2,
  9450. dividerColor
  9451. }, createPartialInvertedVars("#BBB", primaryColor, "#FFF", "#AAA"));
  9452. };
  9453. const menuLight = createTheme({
  9454. name: "Menu",
  9455. common: derived,
  9456. peers: {
  9457. Tooltip: tooltipLight,
  9458. Dropdown: dropdownLight
  9459. },
  9460. self: self$1
  9461. });
  9462. const layoutSiderInjectionKey = createInjectionKey("n-layout-sider");
  9463. const menuInjectionKey = createInjectionKey("n-menu");
  9464. const submenuInjectionKey = createInjectionKey("n-submenu");
  9465. const menuItemGroupInjectionKey = createInjectionKey("n-menu-item-group");
  9466. const ICON_MARGIN_RIGHT = 8;
  9467. function useMenuChild(props) {
  9468. const NMenu = vue.inject(menuInjectionKey);
  9469. const {
  9470. props: menuProps2,
  9471. mergedCollapsedRef
  9472. } = NMenu;
  9473. const NSubmenu2 = vue.inject(submenuInjectionKey, null);
  9474. const NMenuOptionGroup2 = vue.inject(menuItemGroupInjectionKey, null);
  9475. const horizontalRef = vue.computed(() => {
  9476. return menuProps2.mode === "horizontal";
  9477. });
  9478. const dropdownPlacementRef = vue.computed(() => {
  9479. if (horizontalRef.value) {
  9480. return menuProps2.dropdownPlacement;
  9481. }
  9482. if ("tmNodes" in props)
  9483. return "right-start";
  9484. return "right";
  9485. });
  9486. const maxIconSizeRef = vue.computed(() => {
  9487. var _a;
  9488. return Math.max((_a = menuProps2.collapsedIconSize) !== null && _a !== void 0 ? _a : menuProps2.iconSize, menuProps2.iconSize);
  9489. });
  9490. const activeIconSizeRef = vue.computed(() => {
  9491. var _a;
  9492. if (!horizontalRef.value && props.root && mergedCollapsedRef.value) {
  9493. return (_a = menuProps2.collapsedIconSize) !== null && _a !== void 0 ? _a : menuProps2.iconSize;
  9494. } else {
  9495. return menuProps2.iconSize;
  9496. }
  9497. });
  9498. const paddingLeftRef = vue.computed(() => {
  9499. if (horizontalRef.value)
  9500. return void 0;
  9501. const {
  9502. collapsedWidth,
  9503. indent,
  9504. rootIndent
  9505. } = menuProps2;
  9506. const {
  9507. root: root2,
  9508. isGroup: isGroup2
  9509. } = props;
  9510. const mergedRootIndent = rootIndent === void 0 ? indent : rootIndent;
  9511. if (root2) {
  9512. if (mergedCollapsedRef.value) {
  9513. return collapsedWidth / 2 - maxIconSizeRef.value / 2;
  9514. }
  9515. return mergedRootIndent;
  9516. }
  9517. if (NMenuOptionGroup2 && typeof NMenuOptionGroup2.paddingLeftRef.value === "number") {
  9518. return indent / 2 + NMenuOptionGroup2.paddingLeftRef.value;
  9519. }
  9520. if (NSubmenu2 && typeof NSubmenu2.paddingLeftRef.value === "number") {
  9521. return (isGroup2 ? indent / 2 : indent) + NSubmenu2.paddingLeftRef.value;
  9522. }
  9523. return 0;
  9524. });
  9525. const iconMarginRightRef = vue.computed(() => {
  9526. const {
  9527. collapsedWidth,
  9528. indent,
  9529. rootIndent
  9530. } = menuProps2;
  9531. const {
  9532. value: maxIconSize
  9533. } = maxIconSizeRef;
  9534. const {
  9535. root: root2
  9536. } = props;
  9537. if (horizontalRef.value)
  9538. return ICON_MARGIN_RIGHT;
  9539. if (!root2)
  9540. return ICON_MARGIN_RIGHT;
  9541. if (!mergedCollapsedRef.value)
  9542. return ICON_MARGIN_RIGHT;
  9543. const mergedRootIndent = rootIndent === void 0 ? indent : rootIndent;
  9544. return mergedRootIndent + maxIconSize + ICON_MARGIN_RIGHT - (collapsedWidth + maxIconSize) / 2;
  9545. });
  9546. return {
  9547. dropdownPlacement: dropdownPlacementRef,
  9548. activeIconSize: activeIconSizeRef,
  9549. maxIconSize: maxIconSizeRef,
  9550. paddingLeft: paddingLeftRef,
  9551. iconMarginRight: iconMarginRightRef,
  9552. NMenu,
  9553. NSubmenu: NSubmenu2
  9554. };
  9555. }
  9556. const useMenuChildProps = {
  9557. internalKey: {
  9558. type: [String, Number],
  9559. required: true
  9560. },
  9561. root: Boolean,
  9562. isGroup: Boolean,
  9563. level: {
  9564. type: Number,
  9565. required: true
  9566. },
  9567. title: [String, Function],
  9568. extra: [String, Function]
  9569. };
  9570. const menuItemGroupProps = Object.assign(Object.assign({}, useMenuChildProps), {
  9571. tmNode: {
  9572. type: Object,
  9573. required: true
  9574. },
  9575. tmNodes: {
  9576. type: Array,
  9577. required: true
  9578. }
  9579. });
  9580. const NMenuOptionGroup = vue.defineComponent({
  9581. name: "MenuOptionGroup",
  9582. props: menuItemGroupProps,
  9583. setup(props) {
  9584. vue.provide(submenuInjectionKey, null);
  9585. const MenuChild = useMenuChild(props);
  9586. vue.provide(menuItemGroupInjectionKey, {
  9587. paddingLeftRef: MenuChild.paddingLeft
  9588. });
  9589. const {
  9590. mergedClsPrefixRef,
  9591. props: menuProps2
  9592. } = vue.inject(menuInjectionKey);
  9593. return function() {
  9594. const {
  9595. value: mergedClsPrefix
  9596. } = mergedClsPrefixRef;
  9597. const paddingLeft = MenuChild.paddingLeft.value;
  9598. const {
  9599. nodeProps
  9600. } = menuProps2;
  9601. const attrs = nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(props.tmNode.rawNode);
  9602. return vue.h("div", {
  9603. class: `${mergedClsPrefix}-menu-item-group`,
  9604. role: "group"
  9605. }, vue.h("div", Object.assign({}, attrs, {
  9606. class: [`${mergedClsPrefix}-menu-item-group-title`, attrs === null || attrs === void 0 ? void 0 : attrs.class],
  9607. style: [(attrs === null || attrs === void 0 ? void 0 : attrs.style) || "", paddingLeft !== void 0 ? `padding-left: ${paddingLeft}px;` : ""]
  9608. }), render$1(props.title), props.extra ? vue.h(vue.Fragment, null, " ", render$1(props.extra)) : null), vue.h("div", null, props.tmNodes.map((tmNode) => itemRenderer(tmNode, menuProps2))));
  9609. };
  9610. }
  9611. });
  9612. const NMenuOptionContent = vue.defineComponent({
  9613. name: "MenuOptionContent",
  9614. props: {
  9615. collapsed: Boolean,
  9616. disabled: Boolean,
  9617. title: [String, Function],
  9618. icon: Function,
  9619. extra: [String, Function],
  9620. showArrow: Boolean,
  9621. childActive: Boolean,
  9622. hover: Boolean,
  9623. paddingLeft: Number,
  9624. selected: Boolean,
  9625. maxIconSize: {
  9626. type: Number,
  9627. required: true
  9628. },
  9629. activeIconSize: {
  9630. type: Number,
  9631. required: true
  9632. },
  9633. iconMarginRight: {
  9634. type: Number,
  9635. required: true
  9636. },
  9637. clsPrefix: {
  9638. type: String,
  9639. required: true
  9640. },
  9641. onClick: Function,
  9642. tmNode: {
  9643. type: Object,
  9644. required: true
  9645. },
  9646. isEllipsisPlaceholder: Boolean
  9647. },
  9648. setup(props) {
  9649. const {
  9650. props: menuProps2
  9651. } = vue.inject(menuInjectionKey);
  9652. return {
  9653. menuProps: menuProps2,
  9654. style: vue.computed(() => {
  9655. const {
  9656. paddingLeft
  9657. } = props;
  9658. return {
  9659. paddingLeft: paddingLeft && `${paddingLeft}px`
  9660. };
  9661. }),
  9662. iconStyle: vue.computed(() => {
  9663. const {
  9664. maxIconSize,
  9665. activeIconSize,
  9666. iconMarginRight
  9667. } = props;
  9668. return {
  9669. width: `${maxIconSize}px`,
  9670. height: `${maxIconSize}px`,
  9671. fontSize: `${activeIconSize}px`,
  9672. marginRight: `${iconMarginRight}px`
  9673. };
  9674. })
  9675. };
  9676. },
  9677. render() {
  9678. const {
  9679. clsPrefix,
  9680. tmNode,
  9681. menuProps: {
  9682. renderIcon,
  9683. renderLabel,
  9684. renderExtra,
  9685. expandIcon
  9686. }
  9687. } = this;
  9688. const icon = renderIcon ? renderIcon(tmNode.rawNode) : render$1(this.icon);
  9689. return vue.h("div", {
  9690. onClick: (e) => {
  9691. var _a;
  9692. (_a = this.onClick) === null || _a === void 0 ? void 0 : _a.call(this, e);
  9693. },
  9694. role: "none",
  9695. class: [`${clsPrefix}-menu-item-content`, {
  9696. [`${clsPrefix}-menu-item-content--selected`]: this.selected,
  9697. [`${clsPrefix}-menu-item-content--collapsed`]: this.collapsed,
  9698. [`${clsPrefix}-menu-item-content--child-active`]: this.childActive,
  9699. [`${clsPrefix}-menu-item-content--disabled`]: this.disabled,
  9700. [`${clsPrefix}-menu-item-content--hover`]: this.hover
  9701. }],
  9702. style: this.style
  9703. }, icon && vue.h("div", {
  9704. class: `${clsPrefix}-menu-item-content__icon`,
  9705. style: this.iconStyle,
  9706. role: "none"
  9707. }, [icon]), vue.h("div", {
  9708. class: `${clsPrefix}-menu-item-content-header`,
  9709. role: "none"
  9710. }, this.isEllipsisPlaceholder ? this.title : renderLabel ? renderLabel(tmNode.rawNode) : render$1(this.title), this.extra || renderExtra ? vue.h("span", {
  9711. class: `${clsPrefix}-menu-item-content-header__extra`
  9712. }, " ", renderExtra ? renderExtra(tmNode.rawNode) : render$1(this.extra)) : null), this.showArrow ? vue.h(NBaseIcon, {
  9713. ariaHidden: true,
  9714. class: `${clsPrefix}-menu-item-content__arrow`,
  9715. clsPrefix
  9716. }, {
  9717. default: () => expandIcon ? expandIcon(tmNode.rawNode) : vue.h(ChevronDownFilledIcon, null)
  9718. }) : null);
  9719. }
  9720. });
  9721. const submenuProps = Object.assign(Object.assign({}, useMenuChildProps), {
  9722. rawNodes: {
  9723. type: Array,
  9724. default: () => []
  9725. },
  9726. tmNodes: {
  9727. type: Array,
  9728. default: () => []
  9729. },
  9730. tmNode: {
  9731. type: Object,
  9732. required: true
  9733. },
  9734. disabled: Boolean,
  9735. icon: Function,
  9736. onClick: Function,
  9737. domId: String,
  9738. virtualChildActive: {
  9739. type: Boolean,
  9740. default: void 0
  9741. },
  9742. isEllipsisPlaceholder: Boolean
  9743. });
  9744. const NSubmenu = vue.defineComponent({
  9745. name: "Submenu",
  9746. props: submenuProps,
  9747. setup(props) {
  9748. const MenuChild = useMenuChild(props);
  9749. const {
  9750. NMenu,
  9751. NSubmenu: NSubmenu2
  9752. } = MenuChild;
  9753. const {
  9754. props: menuProps2,
  9755. mergedCollapsedRef,
  9756. mergedThemeRef
  9757. } = NMenu;
  9758. const mergedDisabledRef = vue.computed(() => {
  9759. const {
  9760. disabled
  9761. } = props;
  9762. if (NSubmenu2 === null || NSubmenu2 === void 0 ? void 0 : NSubmenu2.mergedDisabledRef.value)
  9763. return true;
  9764. if (menuProps2.disabled)
  9765. return true;
  9766. return disabled;
  9767. });
  9768. const dropdownShowRef = vue.ref(false);
  9769. vue.provide(submenuInjectionKey, {
  9770. paddingLeftRef: MenuChild.paddingLeft,
  9771. mergedDisabledRef
  9772. });
  9773. vue.provide(menuItemGroupInjectionKey, null);
  9774. function doClick() {
  9775. const {
  9776. onClick
  9777. } = props;
  9778. if (onClick)
  9779. onClick();
  9780. }
  9781. function handleClick() {
  9782. if (!mergedDisabledRef.value) {
  9783. if (!mergedCollapsedRef.value) {
  9784. NMenu.toggleExpand(props.internalKey);
  9785. }
  9786. doClick();
  9787. }
  9788. }
  9789. function handlePopoverShowChange(value) {
  9790. dropdownShowRef.value = value;
  9791. }
  9792. return {
  9793. menuProps: menuProps2,
  9794. mergedTheme: mergedThemeRef,
  9795. doSelect: NMenu.doSelect,
  9796. inverted: NMenu.invertedRef,
  9797. isHorizontal: NMenu.isHorizontalRef,
  9798. mergedClsPrefix: NMenu.mergedClsPrefixRef,
  9799. maxIconSize: MenuChild.maxIconSize,
  9800. activeIconSize: MenuChild.activeIconSize,
  9801. iconMarginRight: MenuChild.iconMarginRight,
  9802. dropdownPlacement: MenuChild.dropdownPlacement,
  9803. dropdownShow: dropdownShowRef,
  9804. paddingLeft: MenuChild.paddingLeft,
  9805. mergedDisabled: mergedDisabledRef,
  9806. mergedValue: NMenu.mergedValueRef,
  9807. childActive: useMemo(() => {
  9808. var _a;
  9809. return (_a = props.virtualChildActive) !== null && _a !== void 0 ? _a : NMenu.activePathRef.value.includes(props.internalKey);
  9810. }),
  9811. collapsed: vue.computed(() => {
  9812. if (menuProps2.mode === "horizontal")
  9813. return false;
  9814. if (mergedCollapsedRef.value) {
  9815. return true;
  9816. }
  9817. return !NMenu.mergedExpandedKeysRef.value.includes(props.internalKey);
  9818. }),
  9819. dropdownEnabled: vue.computed(() => {
  9820. return !mergedDisabledRef.value && (menuProps2.mode === "horizontal" || mergedCollapsedRef.value);
  9821. }),
  9822. handlePopoverShowChange,
  9823. handleClick
  9824. };
  9825. },
  9826. render() {
  9827. var _a;
  9828. const {
  9829. mergedClsPrefix,
  9830. menuProps: {
  9831. renderIcon,
  9832. renderLabel
  9833. }
  9834. } = this;
  9835. const createSubmenuItem = () => {
  9836. const {
  9837. isHorizontal,
  9838. paddingLeft,
  9839. collapsed,
  9840. mergedDisabled,
  9841. maxIconSize,
  9842. activeIconSize,
  9843. title,
  9844. childActive,
  9845. icon,
  9846. handleClick,
  9847. menuProps: {
  9848. nodeProps
  9849. },
  9850. dropdownShow,
  9851. iconMarginRight,
  9852. tmNode,
  9853. mergedClsPrefix: mergedClsPrefix2,
  9854. isEllipsisPlaceholder,
  9855. extra
  9856. } = this;
  9857. const attrs = nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(tmNode.rawNode);
  9858. return vue.h("div", Object.assign({}, attrs, {
  9859. class: [`${mergedClsPrefix2}-menu-item`, attrs === null || attrs === void 0 ? void 0 : attrs.class],
  9860. role: "menuitem"
  9861. }), vue.h(NMenuOptionContent, {
  9862. tmNode,
  9863. paddingLeft,
  9864. collapsed,
  9865. disabled: mergedDisabled,
  9866. iconMarginRight,
  9867. maxIconSize,
  9868. activeIconSize,
  9869. title,
  9870. extra,
  9871. showArrow: !isHorizontal,
  9872. childActive,
  9873. clsPrefix: mergedClsPrefix2,
  9874. icon,
  9875. hover: dropdownShow,
  9876. onClick: handleClick,
  9877. isEllipsisPlaceholder
  9878. }));
  9879. };
  9880. const createSubmenuChildren = () => {
  9881. return vue.h(NFadeInExpandTransition, null, {
  9882. default: () => {
  9883. const {
  9884. tmNodes,
  9885. collapsed
  9886. } = this;
  9887. return !collapsed ? vue.h("div", {
  9888. class: `${mergedClsPrefix}-submenu-children`,
  9889. role: "menu"
  9890. }, tmNodes.map((item) => itemRenderer(item, this.menuProps))) : null;
  9891. }
  9892. });
  9893. };
  9894. return this.root ? vue.h(NDropdown, Object.assign({
  9895. size: "large",
  9896. trigger: "hover"
  9897. }, (_a = this.menuProps) === null || _a === void 0 ? void 0 : _a.dropdownProps, {
  9898. themeOverrides: this.mergedTheme.peerOverrides.Dropdown,
  9899. theme: this.mergedTheme.peers.Dropdown,
  9900. builtinThemeOverrides: {
  9901. fontSizeLarge: "14px",
  9902. optionIconSizeLarge: "18px"
  9903. },
  9904. value: this.mergedValue,
  9905. disabled: !this.dropdownEnabled,
  9906. placement: this.dropdownPlacement,
  9907. keyField: this.menuProps.keyField,
  9908. labelField: this.menuProps.labelField,
  9909. childrenField: this.menuProps.childrenField,
  9910. onUpdateShow: this.handlePopoverShowChange,
  9911. options: this.rawNodes,
  9912. onSelect: this.doSelect,
  9913. inverted: this.inverted,
  9914. renderIcon,
  9915. renderLabel
  9916. }), {
  9917. default: () => vue.h("div", {
  9918. class: `${mergedClsPrefix}-submenu`,
  9919. role: "menu",
  9920. "aria-expanded": !this.collapsed,
  9921. id: this.domId
  9922. }, createSubmenuItem(), this.isHorizontal ? null : createSubmenuChildren())
  9923. }) : vue.h("div", {
  9924. class: `${mergedClsPrefix}-submenu`,
  9925. role: "menu",
  9926. "aria-expanded": !this.collapsed,
  9927. id: this.domId
  9928. }, createSubmenuItem(), createSubmenuChildren());
  9929. }
  9930. });
  9931. const menuItemProps = Object.assign(Object.assign({}, useMenuChildProps), {
  9932. tmNode: {
  9933. type: Object,
  9934. required: true
  9935. },
  9936. disabled: Boolean,
  9937. icon: Function,
  9938. onClick: Function
  9939. });
  9940. const NMenuOption = vue.defineComponent({
  9941. name: "MenuOption",
  9942. props: menuItemProps,
  9943. setup(props) {
  9944. const MenuChild = useMenuChild(props);
  9945. const {
  9946. NSubmenu: NSubmenu2,
  9947. NMenu
  9948. } = MenuChild;
  9949. const {
  9950. props: menuProps2,
  9951. mergedClsPrefixRef,
  9952. mergedCollapsedRef
  9953. } = NMenu;
  9954. const submenuDisabledRef = NSubmenu2 ? NSubmenu2.mergedDisabledRef : {
  9955. value: false
  9956. };
  9957. const mergedDisabledRef = vue.computed(() => {
  9958. return submenuDisabledRef.value || props.disabled;
  9959. });
  9960. function doClick(e) {
  9961. const {
  9962. onClick
  9963. } = props;
  9964. if (onClick)
  9965. onClick(e);
  9966. }
  9967. function handleClick(e) {
  9968. if (!mergedDisabledRef.value) {
  9969. NMenu.doSelect(props.internalKey, props.tmNode.rawNode);
  9970. doClick(e);
  9971. }
  9972. }
  9973. return {
  9974. mergedClsPrefix: mergedClsPrefixRef,
  9975. dropdownPlacement: MenuChild.dropdownPlacement,
  9976. paddingLeft: MenuChild.paddingLeft,
  9977. iconMarginRight: MenuChild.iconMarginRight,
  9978. maxIconSize: MenuChild.maxIconSize,
  9979. activeIconSize: MenuChild.activeIconSize,
  9980. mergedTheme: NMenu.mergedThemeRef,
  9981. menuProps: menuProps2,
  9982. dropdownEnabled: useMemo(() => {
  9983. return props.root && mergedCollapsedRef.value && menuProps2.mode !== "horizontal" && !mergedDisabledRef.value;
  9984. }),
  9985. selected: useMemo(() => {
  9986. if (NMenu.mergedValueRef.value === props.internalKey)
  9987. return true;
  9988. return false;
  9989. }),
  9990. mergedDisabled: mergedDisabledRef,
  9991. handleClick
  9992. };
  9993. },
  9994. render() {
  9995. const {
  9996. mergedClsPrefix,
  9997. mergedTheme,
  9998. tmNode,
  9999. menuProps: {
  10000. renderLabel,
  10001. nodeProps
  10002. }
  10003. } = this;
  10004. const attrs = nodeProps === null || nodeProps === void 0 ? void 0 : nodeProps(tmNode.rawNode);
  10005. return vue.h("div", Object.assign({}, attrs, {
  10006. role: "menuitem",
  10007. class: [`${mergedClsPrefix}-menu-item`, attrs === null || attrs === void 0 ? void 0 : attrs.class]
  10008. }), vue.h(NTooltip, {
  10009. theme: mergedTheme.peers.Tooltip,
  10010. themeOverrides: mergedTheme.peerOverrides.Tooltip,
  10011. trigger: "hover",
  10012. placement: this.dropdownPlacement,
  10013. disabled: !this.dropdownEnabled || this.title === void 0,
  10014. internalExtraClass: ["menu-tooltip"]
  10015. }, {
  10016. default: () => renderLabel ? renderLabel(tmNode.rawNode) : render$1(this.title),
  10017. trigger: () => vue.h(NMenuOptionContent, {
  10018. tmNode,
  10019. clsPrefix: mergedClsPrefix,
  10020. paddingLeft: this.paddingLeft,
  10021. iconMarginRight: this.iconMarginRight,
  10022. maxIconSize: this.maxIconSize,
  10023. activeIconSize: this.activeIconSize,
  10024. selected: this.selected,
  10025. title: this.title,
  10026. extra: this.extra,
  10027. disabled: this.mergedDisabled,
  10028. icon: this.icon,
  10029. onClick: this.handleClick
  10030. })
  10031. }));
  10032. }
  10033. });
  10034. const NMenuDivider = vue.defineComponent({
  10035. name: "MenuDivider",
  10036. setup() {
  10037. const NMenu = vue.inject(menuInjectionKey);
  10038. const {
  10039. mergedClsPrefixRef,
  10040. isHorizontalRef
  10041. } = NMenu;
  10042. return () => isHorizontalRef.value ? null : vue.h("div", {
  10043. class: `${mergedClsPrefixRef.value}-menu-divider`
  10044. });
  10045. }
  10046. });
  10047. const groupPropKeys = keysOf(menuItemGroupProps);
  10048. const itemPropKeys = keysOf(menuItemProps);
  10049. const submenuPropKeys = keysOf(submenuProps);
  10050. function isIgnoredNode(rawNode) {
  10051. return rawNode.type === "divider" || rawNode.type === "render";
  10052. }
  10053. function isDividerNode(rawNode) {
  10054. return rawNode.type === "divider";
  10055. }
  10056. function itemRenderer(tmNode, menuProps2) {
  10057. const {
  10058. rawNode
  10059. } = tmNode;
  10060. const {
  10061. show
  10062. } = rawNode;
  10063. if (show === false) {
  10064. return null;
  10065. }
  10066. if (isIgnoredNode(rawNode)) {
  10067. if (isDividerNode(rawNode)) {
  10068. return vue.h(NMenuDivider, Object.assign({
  10069. key: tmNode.key
  10070. }, rawNode.props));
  10071. }
  10072. return null;
  10073. }
  10074. const {
  10075. labelField
  10076. } = menuProps2;
  10077. const {
  10078. key,
  10079. level,
  10080. isGroup: isGroup2
  10081. } = tmNode;
  10082. const props = Object.assign(Object.assign({}, rawNode), {
  10083. title: rawNode.title || rawNode[labelField],
  10084. extra: rawNode.titleExtra || rawNode.extra,
  10085. key,
  10086. internalKey: key,
  10087. // since key can't be used as a prop
  10088. level,
  10089. root: level === 0,
  10090. isGroup: isGroup2
  10091. });
  10092. if (tmNode.children) {
  10093. if (tmNode.isGroup) {
  10094. return vue.h(NMenuOptionGroup, keep(props, groupPropKeys, {
  10095. tmNode,
  10096. tmNodes: tmNode.children,
  10097. key
  10098. }));
  10099. }
  10100. return vue.h(NSubmenu, keep(props, submenuPropKeys, {
  10101. key,
  10102. rawNodes: rawNode[menuProps2.childrenField],
  10103. tmNodes: tmNode.children,
  10104. tmNode
  10105. }));
  10106. } else {
  10107. return vue.h(NMenuOption, keep(props, itemPropKeys, {
  10108. key,
  10109. tmNode
  10110. }));
  10111. }
  10112. }
  10113. const hoverStyleChildren = [c$1("&::before", "background-color: var(--n-item-color-hover);"), cE("arrow", `
  10114. color: var(--n-arrow-color-hover);
  10115. `), cE("icon", `
  10116. color: var(--n-item-icon-color-hover);
  10117. `), cB("menu-item-content-header", `
  10118. color: var(--n-item-text-color-hover);
  10119. `, [c$1("a", `
  10120. color: var(--n-item-text-color-hover);
  10121. `), cE("extra", `
  10122. color: var(--n-item-text-color-hover);
  10123. `)])];
  10124. const horizontalHoverStyleChildren = [cE("icon", `
  10125. color: var(--n-item-icon-color-hover-horizontal);
  10126. `), cB("menu-item-content-header", `
  10127. color: var(--n-item-text-color-hover-horizontal);
  10128. `, [c$1("a", `
  10129. color: var(--n-item-text-color-hover-horizontal);
  10130. `), cE("extra", `
  10131. color: var(--n-item-text-color-hover-horizontal);
  10132. `)])];
  10133. const style = c$1([cB("menu", `
  10134. background-color: var(--n-color);
  10135. color: var(--n-item-text-color);
  10136. overflow: hidden;
  10137. transition: background-color .3s var(--n-bezier);
  10138. box-sizing: border-box;
  10139. font-size: var(--n-font-size);
  10140. padding-bottom: 6px;
  10141. `, [cM("horizontal", `
  10142. max-width: 100%;
  10143. width: 100%;
  10144. display: flex;
  10145. overflow: hidden;
  10146. padding-bottom: 0;
  10147. `, [cB("submenu", "margin: 0;"), cB("menu-item", "margin: 0;"), cB("menu-item-content", `
  10148. padding: 0 20px;
  10149. border-bottom: 2px solid #0000;
  10150. `, [c$1("&::before", "display: none;"), cM("selected", "border-bottom: 2px solid var(--n-border-color-horizontal)")]), cB("menu-item-content", [cM("selected", [cE("icon", "color: var(--n-item-icon-color-active-horizontal);"), cB("menu-item-content-header", `
  10151. color: var(--n-item-text-color-active-horizontal);
  10152. `, [c$1("a", "color: var(--n-item-text-color-active-horizontal);"), cE("extra", "color: var(--n-item-text-color-active-horizontal);")])]), cM("child-active", `
  10153. border-bottom: 2px solid var(--n-border-color-horizontal);
  10154. `, [cB("menu-item-content-header", `
  10155. color: var(--n-item-text-color-child-active-horizontal);
  10156. `, [c$1("a", `
  10157. color: var(--n-item-text-color-child-active-horizontal);
  10158. `), cE("extra", `
  10159. color: var(--n-item-text-color-child-active-horizontal);
  10160. `)]), cE("icon", `
  10161. color: var(--n-item-icon-color-child-active-horizontal);
  10162. `)]), cNotM("disabled", [cNotM("selected, child-active", [c$1("&:focus-within", horizontalHoverStyleChildren)]), cM("selected", [hoverStyle(null, [cE("icon", "color: var(--n-item-icon-color-active-hover-horizontal);"), cB("menu-item-content-header", `
  10163. color: var(--n-item-text-color-active-hover-horizontal);
  10164. `, [c$1("a", "color: var(--n-item-text-color-active-hover-horizontal);"), cE("extra", "color: var(--n-item-text-color-active-hover-horizontal);")])])]), cM("child-active", [hoverStyle(null, [cE("icon", "color: var(--n-item-icon-color-child-active-hover-horizontal);"), cB("menu-item-content-header", `
  10165. color: var(--n-item-text-color-child-active-hover-horizontal);
  10166. `, [c$1("a", "color: var(--n-item-text-color-child-active-hover-horizontal);"), cE("extra", "color: var(--n-item-text-color-child-active-hover-horizontal);")])])]), hoverStyle("border-bottom: 2px solid var(--n-border-color-horizontal);", horizontalHoverStyleChildren)]), cB("menu-item-content-header", [c$1("a", "color: var(--n-item-text-color-horizontal);")])])]), cNotM("responsive", [cB("menu-item-content-header", `
  10167. overflow: hidden;
  10168. text-overflow: ellipsis;
  10169. `)]), cM("collapsed", [cB("menu-item-content", [cM("selected", [c$1("&::before", `
  10170. background-color: var(--n-item-color-active-collapsed) !important;
  10171. `)]), cB("menu-item-content-header", "opacity: 0;"), cE("arrow", "opacity: 0;"), cE("icon", "color: var(--n-item-icon-color-collapsed);")])]), cB("menu-item", `
  10172. height: var(--n-item-height);
  10173. margin-top: 6px;
  10174. position: relative;
  10175. `), cB("menu-item-content", `
  10176. box-sizing: border-box;
  10177. line-height: 1.75;
  10178. height: 100%;
  10179. display: grid;
  10180. grid-template-areas: "icon content arrow";
  10181. grid-template-columns: auto 1fr auto;
  10182. align-items: center;
  10183. cursor: pointer;
  10184. position: relative;
  10185. padding-right: 18px;
  10186. transition:
  10187. background-color .3s var(--n-bezier),
  10188. padding-left .3s var(--n-bezier),
  10189. border-color .3s var(--n-bezier);
  10190. `, [c$1("> *", "z-index: 1;"), c$1("&::before", `
  10191. z-index: auto;
  10192. content: "";
  10193. background-color: #0000;
  10194. position: absolute;
  10195. left: 8px;
  10196. right: 8px;
  10197. top: 0;
  10198. bottom: 0;
  10199. pointer-events: none;
  10200. border-radius: var(--n-border-radius);
  10201. transition: background-color .3s var(--n-bezier);
  10202. `), cM("disabled", `
  10203. opacity: .45;
  10204. cursor: not-allowed;
  10205. `), cM("collapsed", [cE("arrow", "transform: rotate(0);")]), cM("selected", [c$1("&::before", "background-color: var(--n-item-color-active);"), cE("arrow", "color: var(--n-arrow-color-active);"), cE("icon", "color: var(--n-item-icon-color-active);"), cB("menu-item-content-header", `
  10206. color: var(--n-item-text-color-active);
  10207. `, [c$1("a", "color: var(--n-item-text-color-active);"), cE("extra", "color: var(--n-item-text-color-active);")])]), cM("child-active", [cB("menu-item-content-header", `
  10208. color: var(--n-item-text-color-child-active);
  10209. `, [c$1("a", `
  10210. color: var(--n-item-text-color-child-active);
  10211. `), cE("extra", `
  10212. color: var(--n-item-text-color-child-active);
  10213. `)]), cE("arrow", `
  10214. color: var(--n-arrow-color-child-active);
  10215. `), cE("icon", `
  10216. color: var(--n-item-icon-color-child-active);
  10217. `)]), cNotM("disabled", [cNotM("selected, child-active", [c$1("&:focus-within", hoverStyleChildren)]), cM("selected", [hoverStyle(null, [cE("arrow", "color: var(--n-arrow-color-active-hover);"), cE("icon", "color: var(--n-item-icon-color-active-hover);"), cB("menu-item-content-header", `
  10218. color: var(--n-item-text-color-active-hover);
  10219. `, [c$1("a", "color: var(--n-item-text-color-active-hover);"), cE("extra", "color: var(--n-item-text-color-active-hover);")])])]), cM("child-active", [hoverStyle(null, [cE("arrow", "color: var(--n-arrow-color-child-active-hover);"), cE("icon", "color: var(--n-item-icon-color-child-active-hover);"), cB("menu-item-content-header", `
  10220. color: var(--n-item-text-color-child-active-hover);
  10221. `, [c$1("a", "color: var(--n-item-text-color-child-active-hover);"), cE("extra", "color: var(--n-item-text-color-child-active-hover);")])])]), cM("selected", [hoverStyle(null, [c$1("&::before", "background-color: var(--n-item-color-active-hover);")])]), hoverStyle(null, hoverStyleChildren)]), cE("icon", `
  10222. grid-area: icon;
  10223. color: var(--n-item-icon-color);
  10224. transition:
  10225. color .3s var(--n-bezier),
  10226. font-size .3s var(--n-bezier),
  10227. margin-right .3s var(--n-bezier);
  10228. box-sizing: content-box;
  10229. display: inline-flex;
  10230. align-items: center;
  10231. justify-content: center;
  10232. `), cE("arrow", `
  10233. grid-area: arrow;
  10234. font-size: 16px;
  10235. color: var(--n-arrow-color);
  10236. transform: rotate(180deg);
  10237. opacity: 1;
  10238. transition:
  10239. color .3s var(--n-bezier),
  10240. transform 0.2s var(--n-bezier),
  10241. opacity 0.2s var(--n-bezier);
  10242. `), cB("menu-item-content-header", `
  10243. grid-area: content;
  10244. transition:
  10245. color .3s var(--n-bezier),
  10246. opacity .3s var(--n-bezier);
  10247. opacity: 1;
  10248. white-space: nowrap;
  10249. color: var(--n-item-text-color);
  10250. `, [c$1("a", `
  10251. outline: none;
  10252. text-decoration: none;
  10253. transition: color .3s var(--n-bezier);
  10254. color: var(--n-item-text-color);
  10255. `, [c$1("&::before", `
  10256. content: "";
  10257. position: absolute;
  10258. left: 0;
  10259. right: 0;
  10260. top: 0;
  10261. bottom: 0;
  10262. `)]), cE("extra", `
  10263. font-size: .93em;
  10264. color: var(--n-group-text-color);
  10265. transition: color .3s var(--n-bezier);
  10266. `)])]), cB("submenu", `
  10267. cursor: pointer;
  10268. position: relative;
  10269. margin-top: 6px;
  10270. `, [cB("menu-item-content", `
  10271. height: var(--n-item-height);
  10272. `), cB("submenu-children", `
  10273. overflow: hidden;
  10274. padding: 0;
  10275. `, [fadeInHeightExpandTransition({
  10276. duration: ".2s"
  10277. })])]), cB("menu-item-group", [cB("menu-item-group-title", `
  10278. margin-top: 6px;
  10279. color: var(--n-group-text-color);
  10280. cursor: default;
  10281. font-size: .93em;
  10282. height: 36px;
  10283. display: flex;
  10284. align-items: center;
  10285. transition:
  10286. padding-left .3s var(--n-bezier),
  10287. color .3s var(--n-bezier);
  10288. `)])]), cB("menu-tooltip", [c$1("a", `
  10289. color: inherit;
  10290. text-decoration: none;
  10291. `)]), cB("menu-divider", `
  10292. transition: background-color .3s var(--n-bezier);
  10293. background-color: var(--n-divider-color);
  10294. height: 1px;
  10295. margin: 6px 18px;
  10296. `)]);
  10297. function hoverStyle(props, children) {
  10298. return [cM("hover", props, children), c$1("&:hover", props, children)];
  10299. }
  10300. const menuProps = Object.assign(Object.assign({}, useTheme.props), {
  10301. options: {
  10302. type: Array,
  10303. default: () => []
  10304. },
  10305. collapsed: {
  10306. type: Boolean,
  10307. default: void 0
  10308. },
  10309. collapsedWidth: {
  10310. type: Number,
  10311. default: 48
  10312. },
  10313. iconSize: {
  10314. type: Number,
  10315. default: 20
  10316. },
  10317. collapsedIconSize: {
  10318. type: Number,
  10319. default: 24
  10320. },
  10321. rootIndent: Number,
  10322. indent: {
  10323. type: Number,
  10324. default: 32
  10325. },
  10326. labelField: {
  10327. type: String,
  10328. default: "label"
  10329. },
  10330. keyField: {
  10331. type: String,
  10332. default: "key"
  10333. },
  10334. childrenField: {
  10335. type: String,
  10336. default: "children"
  10337. },
  10338. disabledField: {
  10339. type: String,
  10340. default: "disabled"
  10341. },
  10342. defaultExpandAll: Boolean,
  10343. defaultExpandedKeys: Array,
  10344. expandedKeys: Array,
  10345. value: [String, Number],
  10346. defaultValue: {
  10347. type: [String, Number],
  10348. default: null
  10349. },
  10350. mode: {
  10351. type: String,
  10352. default: "vertical"
  10353. },
  10354. watchProps: {
  10355. type: Array,
  10356. default: void 0
  10357. },
  10358. disabled: Boolean,
  10359. show: {
  10360. type: Boolean,
  10361. default: true
  10362. },
  10363. inverted: Boolean,
  10364. "onUpdate:expandedKeys": [Function, Array],
  10365. onUpdateExpandedKeys: [Function, Array],
  10366. onUpdateValue: [Function, Array],
  10367. "onUpdate:value": [Function, Array],
  10368. expandIcon: Function,
  10369. renderIcon: Function,
  10370. renderLabel: Function,
  10371. renderExtra: Function,
  10372. dropdownProps: Object,
  10373. accordion: Boolean,
  10374. nodeProps: Function,
  10375. dropdownPlacement: {
  10376. type: String,
  10377. default: "bottom"
  10378. },
  10379. responsive: Boolean,
  10380. // deprecated
  10381. items: Array,
  10382. onOpenNamesChange: [Function, Array],
  10383. onSelect: [Function, Array],
  10384. onExpandedNamesChange: [Function, Array],
  10385. expandedNames: Array,
  10386. defaultExpandedNames: Array
  10387. });
  10388. const __unplugin_components_0 = vue.defineComponent({
  10389. name: "Menu",
  10390. props: menuProps,
  10391. setup(props) {
  10392. const {
  10393. mergedClsPrefixRef,
  10394. inlineThemeDisabled
  10395. } = useConfig(props);
  10396. const themeRef = useTheme("Menu", "-menu", style, menuLight, props, mergedClsPrefixRef);
  10397. const layoutSider = vue.inject(layoutSiderInjectionKey, null);
  10398. const mergedCollapsedRef = vue.computed(() => {
  10399. var _a;
  10400. const {
  10401. collapsed
  10402. } = props;
  10403. if (collapsed !== void 0)
  10404. return collapsed;
  10405. if (layoutSider) {
  10406. const {
  10407. collapseModeRef,
  10408. collapsedRef
  10409. } = layoutSider;
  10410. if (collapseModeRef.value === "width") {
  10411. return (_a = collapsedRef.value) !== null && _a !== void 0 ? _a : false;
  10412. }
  10413. }
  10414. return false;
  10415. });
  10416. const treeMateRef = vue.computed(() => {
  10417. const {
  10418. keyField,
  10419. childrenField,
  10420. disabledField
  10421. } = props;
  10422. return createTreeMate(props.items || props.options, {
  10423. getIgnored(node) {
  10424. return isIgnoredNode(node);
  10425. },
  10426. getChildren(node) {
  10427. return node[childrenField];
  10428. },
  10429. getDisabled(node) {
  10430. return node[disabledField];
  10431. },
  10432. getKey(node) {
  10433. var _a;
  10434. return (_a = node[keyField]) !== null && _a !== void 0 ? _a : node.name;
  10435. }
  10436. });
  10437. });
  10438. const treeKeysLevelOneRef = vue.computed(() => new Set(treeMateRef.value.treeNodes.map((e) => e.key)));
  10439. const {
  10440. watchProps
  10441. } = props;
  10442. const uncontrolledValueRef = vue.ref(null);
  10443. if (watchProps === null || watchProps === void 0 ? void 0 : watchProps.includes("defaultValue")) {
  10444. vue.watchEffect(() => {
  10445. uncontrolledValueRef.value = props.defaultValue;
  10446. });
  10447. } else {
  10448. uncontrolledValueRef.value = props.defaultValue;
  10449. }
  10450. const controlledValueRef = vue.toRef(props, "value");
  10451. const mergedValueRef = useMergedState(controlledValueRef, uncontrolledValueRef);
  10452. const uncontrolledExpandedKeysRef = vue.ref([]);
  10453. const initUncontrolledExpandedKeys = () => {
  10454. uncontrolledExpandedKeysRef.value = props.defaultExpandAll ? treeMateRef.value.getNonLeafKeys() : props.defaultExpandedNames || props.defaultExpandedKeys || treeMateRef.value.getPath(mergedValueRef.value, {
  10455. includeSelf: false
  10456. }).keyPath;
  10457. };
  10458. if (watchProps === null || watchProps === void 0 ? void 0 : watchProps.includes("defaultExpandedKeys")) {
  10459. vue.watchEffect(initUncontrolledExpandedKeys);
  10460. } else {
  10461. initUncontrolledExpandedKeys();
  10462. }
  10463. const controlledExpandedKeysRef = useCompitable(props, ["expandedNames", "expandedKeys"]);
  10464. const mergedExpandedKeysRef = useMergedState(controlledExpandedKeysRef, uncontrolledExpandedKeysRef);
  10465. const tmNodesRef = vue.computed(() => treeMateRef.value.treeNodes);
  10466. const activePathRef = vue.computed(() => {
  10467. return treeMateRef.value.getPath(mergedValueRef.value).keyPath;
  10468. });
  10469. vue.provide(menuInjectionKey, {
  10470. props,
  10471. mergedCollapsedRef,
  10472. mergedThemeRef: themeRef,
  10473. mergedValueRef,
  10474. mergedExpandedKeysRef,
  10475. activePathRef,
  10476. mergedClsPrefixRef,
  10477. isHorizontalRef: vue.computed(() => props.mode === "horizontal"),
  10478. invertedRef: vue.toRef(props, "inverted"),
  10479. doSelect,
  10480. toggleExpand
  10481. });
  10482. function doSelect(value, item) {
  10483. const {
  10484. "onUpdate:value": _onUpdateValue,
  10485. onUpdateValue,
  10486. onSelect
  10487. } = props;
  10488. if (onUpdateValue) {
  10489. call(onUpdateValue, value, item);
  10490. }
  10491. if (_onUpdateValue) {
  10492. call(_onUpdateValue, value, item);
  10493. }
  10494. if (onSelect) {
  10495. call(onSelect, value, item);
  10496. }
  10497. uncontrolledValueRef.value = value;
  10498. }
  10499. function doUpdateExpandedKeys(value) {
  10500. const {
  10501. "onUpdate:expandedKeys": _onUpdateExpandedKeys,
  10502. onUpdateExpandedKeys,
  10503. onExpandedNamesChange,
  10504. onOpenNamesChange
  10505. } = props;
  10506. if (_onUpdateExpandedKeys) {
  10507. call(_onUpdateExpandedKeys, value);
  10508. }
  10509. if (onUpdateExpandedKeys) {
  10510. call(onUpdateExpandedKeys, value);
  10511. }
  10512. if (onExpandedNamesChange) {
  10513. call(onExpandedNamesChange, value);
  10514. }
  10515. if (onOpenNamesChange) {
  10516. call(onOpenNamesChange, value);
  10517. }
  10518. uncontrolledExpandedKeysRef.value = value;
  10519. }
  10520. function toggleExpand(key) {
  10521. const currentExpandedKeys = Array.from(mergedExpandedKeysRef.value);
  10522. const index = currentExpandedKeys.findIndex((expanededKey) => expanededKey === key);
  10523. if (~index) {
  10524. currentExpandedKeys.splice(index, 1);
  10525. } else {
  10526. if (props.accordion) {
  10527. if (treeKeysLevelOneRef.value.has(key)) {
  10528. const closeKeyIndex = currentExpandedKeys.findIndex((e) => treeKeysLevelOneRef.value.has(e));
  10529. if (closeKeyIndex > -1) {
  10530. currentExpandedKeys.splice(closeKeyIndex, 1);
  10531. }
  10532. }
  10533. }
  10534. currentExpandedKeys.push(key);
  10535. }
  10536. doUpdateExpandedKeys(currentExpandedKeys);
  10537. }
  10538. const showOption = (key) => {
  10539. const selectedKeyPath = treeMateRef.value.getPath(key !== null && key !== void 0 ? key : mergedValueRef.value, {
  10540. includeSelf: false
  10541. }).keyPath;
  10542. if (!selectedKeyPath.length)
  10543. return;
  10544. const currentExpandedKeys = Array.from(mergedExpandedKeysRef.value);
  10545. const nextExpandedKeys = /* @__PURE__ */ new Set([...currentExpandedKeys, ...selectedKeyPath]);
  10546. if (props.accordion) {
  10547. treeKeysLevelOneRef.value.forEach((firstLevelKey) => {
  10548. if (nextExpandedKeys.has(firstLevelKey) && !selectedKeyPath.includes(firstLevelKey)) {
  10549. nextExpandedKeys.delete(firstLevelKey);
  10550. }
  10551. });
  10552. }
  10553. doUpdateExpandedKeys(Array.from(nextExpandedKeys));
  10554. };
  10555. const cssVarsRef = vue.computed(() => {
  10556. const {
  10557. inverted
  10558. } = props;
  10559. const {
  10560. common: {
  10561. cubicBezierEaseInOut: cubicBezierEaseInOut2
  10562. },
  10563. self: self2
  10564. } = themeRef.value;
  10565. const {
  10566. borderRadius,
  10567. borderColorHorizontal,
  10568. fontSize: fontSize2,
  10569. itemHeight,
  10570. dividerColor
  10571. } = self2;
  10572. const vars = {
  10573. "--n-divider-color": dividerColor,
  10574. "--n-bezier": cubicBezierEaseInOut2,
  10575. "--n-font-size": fontSize2,
  10576. "--n-border-color-horizontal": borderColorHorizontal,
  10577. "--n-border-radius": borderRadius,
  10578. "--n-item-height": itemHeight
  10579. };
  10580. if (inverted) {
  10581. vars["--n-group-text-color"] = self2.groupTextColorInverted;
  10582. vars["--n-color"] = self2.colorInverted;
  10583. vars["--n-item-text-color"] = self2.itemTextColorInverted;
  10584. vars["--n-item-text-color-hover"] = self2.itemTextColorHoverInverted;
  10585. vars["--n-item-text-color-active"] = self2.itemTextColorActiveInverted;
  10586. vars["--n-item-text-color-child-active"] = self2.itemTextColorChildActiveInverted;
  10587. vars["--n-item-text-color-child-active-hover"] = self2.itemTextColorChildActiveInverted;
  10588. vars["--n-item-text-color-active-hover"] = self2.itemTextColorActiveHoverInverted;
  10589. vars["--n-item-icon-color"] = self2.itemIconColorInverted;
  10590. vars["--n-item-icon-color-hover"] = self2.itemIconColorHoverInverted;
  10591. vars["--n-item-icon-color-active"] = self2.itemIconColorActiveInverted;
  10592. vars["--n-item-icon-color-active-hover"] = self2.itemIconColorActiveHoverInverted;
  10593. vars["--n-item-icon-color-child-active"] = self2.itemIconColorChildActiveInverted;
  10594. vars["--n-item-icon-color-child-active-hover"] = self2.itemIconColorChildActiveHoverInverted;
  10595. vars["--n-item-icon-color-collapsed"] = self2.itemIconColorCollapsedInverted;
  10596. vars["--n-item-text-color-horizontal"] = self2.itemTextColorHorizontalInverted;
  10597. vars["--n-item-text-color-hover-horizontal"] = self2.itemTextColorHoverHorizontalInverted;
  10598. vars["--n-item-text-color-active-horizontal"] = self2.itemTextColorActiveHorizontalInverted;
  10599. vars["--n-item-text-color-child-active-horizontal"] = self2.itemTextColorChildActiveHorizontalInverted;
  10600. vars["--n-item-text-color-child-active-hover-horizontal"] = self2.itemTextColorChildActiveHoverHorizontalInverted;
  10601. vars["--n-item-text-color-active-hover-horizontal"] = self2.itemTextColorActiveHoverHorizontalInverted;
  10602. vars["--n-item-icon-color-horizontal"] = self2.itemIconColorHorizontalInverted;
  10603. vars["--n-item-icon-color-hover-horizontal"] = self2.itemIconColorHoverHorizontalInverted;
  10604. vars["--n-item-icon-color-active-horizontal"] = self2.itemIconColorActiveHorizontalInverted;
  10605. vars["--n-item-icon-color-active-hover-horizontal"] = self2.itemIconColorActiveHoverHorizontalInverted;
  10606. vars["--n-item-icon-color-child-active-horizontal"] = self2.itemIconColorChildActiveHorizontalInverted;
  10607. vars["--n-item-icon-color-child-active-hover-horizontal"] = self2.itemIconColorChildActiveHoverHorizontalInverted;
  10608. vars["--n-arrow-color"] = self2.arrowColorInverted;
  10609. vars["--n-arrow-color-hover"] = self2.arrowColorHoverInverted;
  10610. vars["--n-arrow-color-active"] = self2.arrowColorActiveInverted;
  10611. vars["--n-arrow-color-active-hover"] = self2.arrowColorActiveHoverInverted;
  10612. vars["--n-arrow-color-child-active"] = self2.arrowColorChildActiveInverted;
  10613. vars["--n-arrow-color-child-active-hover"] = self2.arrowColorChildActiveHoverInverted;
  10614. vars["--n-item-color-hover"] = self2.itemColorHoverInverted;
  10615. vars["--n-item-color-active"] = self2.itemColorActiveInverted;
  10616. vars["--n-item-color-active-hover"] = self2.itemColorActiveHoverInverted;
  10617. vars["--n-item-color-active-collapsed"] = self2.itemColorActiveCollapsedInverted;
  10618. } else {
  10619. vars["--n-group-text-color"] = self2.groupTextColor;
  10620. vars["--n-color"] = self2.color;
  10621. vars["--n-item-text-color"] = self2.itemTextColor;
  10622. vars["--n-item-text-color-hover"] = self2.itemTextColorHover;
  10623. vars["--n-item-text-color-active"] = self2.itemTextColorActive;
  10624. vars["--n-item-text-color-child-active"] = self2.itemTextColorChildActive;
  10625. vars["--n-item-text-color-child-active-hover"] = self2.itemTextColorChildActiveHover;
  10626. vars["--n-item-text-color-active-hover"] = self2.itemTextColorActiveHover;
  10627. vars["--n-item-icon-color"] = self2.itemIconColor;
  10628. vars["--n-item-icon-color-hover"] = self2.itemIconColorHover;
  10629. vars["--n-item-icon-color-active"] = self2.itemIconColorActive;
  10630. vars["--n-item-icon-color-active-hover"] = self2.itemIconColorActiveHover;
  10631. vars["--n-item-icon-color-child-active"] = self2.itemIconColorChildActive;
  10632. vars["--n-item-icon-color-child-active-hover"] = self2.itemIconColorChildActiveHover;
  10633. vars["--n-item-icon-color-collapsed"] = self2.itemIconColorCollapsed;
  10634. vars["--n-item-text-color-horizontal"] = self2.itemTextColorHorizontal;
  10635. vars["--n-item-text-color-hover-horizontal"] = self2.itemTextColorHoverHorizontal;
  10636. vars["--n-item-text-color-active-horizontal"] = self2.itemTextColorActiveHorizontal;
  10637. vars["--n-item-text-color-child-active-horizontal"] = self2.itemTextColorChildActiveHorizontal;
  10638. vars["--n-item-text-color-child-active-hover-horizontal"] = self2.itemTextColorChildActiveHoverHorizontal;
  10639. vars["--n-item-text-color-active-hover-horizontal"] = self2.itemTextColorActiveHoverHorizontal;
  10640. vars["--n-item-icon-color-horizontal"] = self2.itemIconColorHorizontal;
  10641. vars["--n-item-icon-color-hover-horizontal"] = self2.itemIconColorHoverHorizontal;
  10642. vars["--n-item-icon-color-active-horizontal"] = self2.itemIconColorActiveHorizontal;
  10643. vars["--n-item-icon-color-active-hover-horizontal"] = self2.itemIconColorActiveHoverHorizontal;
  10644. vars["--n-item-icon-color-child-active-horizontal"] = self2.itemIconColorChildActiveHorizontal;
  10645. vars["--n-item-icon-color-child-active-hover-horizontal"] = self2.itemIconColorChildActiveHoverHorizontal;
  10646. vars["--n-arrow-color"] = self2.arrowColor;
  10647. vars["--n-arrow-color-hover"] = self2.arrowColorHover;
  10648. vars["--n-arrow-color-active"] = self2.arrowColorActive;
  10649. vars["--n-arrow-color-active-hover"] = self2.arrowColorActiveHover;
  10650. vars["--n-arrow-color-child-active"] = self2.arrowColorChildActive;
  10651. vars["--n-arrow-color-child-active-hover"] = self2.arrowColorChildActiveHover;
  10652. vars["--n-item-color-hover"] = self2.itemColorHover;
  10653. vars["--n-item-color-active"] = self2.itemColorActive;
  10654. vars["--n-item-color-active-hover"] = self2.itemColorActiveHover;
  10655. vars["--n-item-color-active-collapsed"] = self2.itemColorActiveCollapsed;
  10656. }
  10657. return vars;
  10658. });
  10659. const themeClassHandle = inlineThemeDisabled ? useThemeClass("menu", vue.computed(() => props.inverted ? "a" : "b"), cssVarsRef, props) : void 0;
  10660. const ellipsisNodeId = createId();
  10661. const overflowRef = vue.ref(null);
  10662. const counterRef = vue.ref(null);
  10663. let isFirstResize = true;
  10664. const onResize = () => {
  10665. var _a;
  10666. if (isFirstResize) {
  10667. isFirstResize = false;
  10668. } else {
  10669. (_a = overflowRef.value) === null || _a === void 0 ? void 0 : _a.sync({
  10670. showAllItemsBeforeCalculate: true
  10671. });
  10672. }
  10673. };
  10674. function getCounter() {
  10675. return document.getElementById(ellipsisNodeId);
  10676. }
  10677. const ellipsisFromIndexRef = vue.ref(-1);
  10678. function onUpdateCount(count) {
  10679. ellipsisFromIndexRef.value = props.options.length - count;
  10680. }
  10681. function onUpdateOverflow(overflow) {
  10682. if (!overflow) {
  10683. ellipsisFromIndexRef.value = -1;
  10684. }
  10685. }
  10686. const ellipsisOptionRef = vue.computed(() => {
  10687. const ellipsisFromIndex = ellipsisFromIndexRef.value;
  10688. const option = {
  10689. children: ellipsisFromIndex === -1 ? [] : props.options.slice(ellipsisFromIndex)
  10690. };
  10691. return option;
  10692. });
  10693. const ellipsisTreeMateRef = vue.computed(() => {
  10694. const {
  10695. childrenField,
  10696. disabledField,
  10697. keyField
  10698. } = props;
  10699. return createTreeMate([ellipsisOptionRef.value], {
  10700. getIgnored(node) {
  10701. return isIgnoredNode(node);
  10702. },
  10703. getChildren(node) {
  10704. return node[childrenField];
  10705. },
  10706. getDisabled(node) {
  10707. return node[disabledField];
  10708. },
  10709. getKey(node) {
  10710. var _a;
  10711. return (_a = node[keyField]) !== null && _a !== void 0 ? _a : node.name;
  10712. }
  10713. });
  10714. });
  10715. const emptyTmNodeRef = vue.computed(() => {
  10716. return createTreeMate([{}]).treeNodes[0];
  10717. });
  10718. function renderCounter() {
  10719. var _a;
  10720. if (ellipsisFromIndexRef.value === -1) {
  10721. return vue.h(NSubmenu, {
  10722. root: true,
  10723. level: 0,
  10724. key: "__ellpisisGroupPlaceholder__",
  10725. internalKey: "__ellpisisGroupPlaceholder__",
  10726. title: "···",
  10727. tmNode: emptyTmNodeRef.value,
  10728. domId: ellipsisNodeId,
  10729. isEllipsisPlaceholder: true
  10730. });
  10731. }
  10732. const tmNode = ellipsisTreeMateRef.value.treeNodes[0];
  10733. const activePath = activePathRef.value;
  10734. const childActive = !!((_a = tmNode.children) === null || _a === void 0 ? void 0 : _a.some((tmNode2) => {
  10735. return activePath.includes(tmNode2.key);
  10736. }));
  10737. return vue.h(NSubmenu, {
  10738. level: 0,
  10739. root: true,
  10740. key: "__ellpisisGroup__",
  10741. internalKey: "__ellpisisGroup__",
  10742. title: "···",
  10743. virtualChildActive: childActive,
  10744. tmNode,
  10745. domId: ellipsisNodeId,
  10746. rawNodes: tmNode.rawNode.children || [],
  10747. tmNodes: tmNode.children || [],
  10748. isEllipsisPlaceholder: true
  10749. });
  10750. }
  10751. return {
  10752. mergedClsPrefix: mergedClsPrefixRef,
  10753. controlledExpandedKeys: controlledExpandedKeysRef,
  10754. uncontrolledExpanededKeys: uncontrolledExpandedKeysRef,
  10755. mergedExpandedKeys: mergedExpandedKeysRef,
  10756. uncontrolledValue: uncontrolledValueRef,
  10757. mergedValue: mergedValueRef,
  10758. activePath: activePathRef,
  10759. tmNodes: tmNodesRef,
  10760. mergedTheme: themeRef,
  10761. mergedCollapsed: mergedCollapsedRef,
  10762. cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
  10763. themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
  10764. overflowRef,
  10765. counterRef,
  10766. updateCounter: () => {
  10767. },
  10768. onResize,
  10769. onUpdateOverflow,
  10770. onUpdateCount,
  10771. renderCounter,
  10772. getCounter,
  10773. onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender,
  10774. showOption,
  10775. deriveResponsiveState: onResize
  10776. };
  10777. },
  10778. render() {
  10779. const {
  10780. mergedClsPrefix,
  10781. mode,
  10782. themeClass,
  10783. onRender
  10784. } = this;
  10785. onRender === null || onRender === void 0 ? void 0 : onRender();
  10786. const renderMenuItemNodes = () => this.tmNodes.map((tmNode) => itemRenderer(tmNode, this.$props));
  10787. const horizontal = mode === "horizontal";
  10788. const finalResponsive = horizontal && this.responsive;
  10789. const renderMainNode = () => vue.h("div", {
  10790. role: mode === "horizontal" ? "menubar" : "menu",
  10791. class: [`${mergedClsPrefix}-menu`, themeClass, `${mergedClsPrefix}-menu--${mode}`, finalResponsive && `${mergedClsPrefix}-menu--responsive`, this.mergedCollapsed && `${mergedClsPrefix}-menu--collapsed`],
  10792. style: this.cssVars
  10793. }, finalResponsive ? vue.h(VOverflow, {
  10794. ref: "overflowRef",
  10795. onUpdateOverflow: this.onUpdateOverflow,
  10796. getCounter: this.getCounter,
  10797. onUpdateCount: this.onUpdateCount,
  10798. updateCounter: this.updateCounter,
  10799. style: {
  10800. width: "100%",
  10801. display: "flex",
  10802. overflow: "hidden"
  10803. }
  10804. }, {
  10805. default: renderMenuItemNodes,
  10806. counter: this.renderCounter
  10807. }) : renderMenuItemNodes());
  10808. return finalResponsive ? vue.h(VResizeObserver, {
  10809. onResize: this.onResize
  10810. }, {
  10811. default: renderMainNode
  10812. }) : renderMainNode();
  10813. }
  10814. });
  10815. const _hoisted_1 = {
  10816. class: "main"
  10817. };
  10818. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  10819. __name: "App",
  10820. setup(__props) {
  10821. const menuThemeOverrides = {
  10822. itemColorActive: "#EEF0FF",
  10823. itemColorActiveHover: "#EEF0FF",
  10824. itemTextColorActive: "#2777F8",
  10825. itemTextColorActiveHover: "#2777F8"
  10826. };
  10827. const menuOptions = [{
  10828. label: () => vue.createVNode("a", {
  10829. "href": "//115.com/?cid=0&offset=0&mode=wangpan"
  10830. }, [vue.createTextVNode("全部文件")]),
  10831. key: "all"
  10832. }, {
  10833. label: () => vue.createVNode("a", {
  10834. "href": "//115.com/?tab=upload&mode=wangpan"
  10835. }, [vue.createTextVNode("最近上传")]),
  10836. key: "upload"
  10837. }, {
  10838. label: () => vue.createVNode("a", {
  10839. "href": "//115.com/?tab=offline&mode=wangpan"
  10840. }, [vue.createTextVNode("云下载")]),
  10841. key: "offline"
  10842. }];
  10843. const menuValue = vue.ref("all");
  10844. const url = new URL(window.location.href);
  10845. if (url.searchParams.has("cid")) {
  10846. menuValue.value = "all";
  10847. } else if (url.searchParams.has("tab")) {
  10848. const tab = url.searchParams.get("tab");
  10849. if (tab === "upload") {
  10850. menuValue.value = "upload";
  10851. } else if (tab === "offline") {
  10852. menuValue.value = "offline";
  10853. }
  10854. }
  10855. return (_ctx, _cache) => {
  10856. const _component_NMenu = __unplugin_components_0;
  10857. return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [vue.createVNode(_component_NMenu, {
  10858. options: menuOptions,
  10859. value: vue.unref(menuValue),
  10860. "onUpdate:value": _cache[0] || (_cache[0] = ($event) => vue.isRef(menuValue) ? menuValue.value = $event : null),
  10861. "theme-overrides": menuThemeOverrides
  10862. }, null, 8, ["value"])]);
  10863. };
  10864. }
  10865. });
  10866. const _export_sfc = (sfc, props) => {
  10867. const target = sfc.__vccOpts || sfc;
  10868. for (const [key, val] of props) {
  10869. target[key] = val;
  10870. }
  10871. return target;
  10872. };
  10873. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8fb240a8"]]);
  10874. var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
  10875. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  10876. var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
  10877. vue.createApp(App).mount(
  10878. (() => {
  10879. const wrap_hflow = document.getElementsByClassName("wrap-hflow")[0];
  10880. const site_left_bar = document.getElementById("site_left_bar");
  10881. const app = document.createElement("div");
  10882. app.addEventListener("mousedown", (e) => {
  10883. e.stopPropagation();
  10884. });
  10885. if (site_left_bar && wrap_hflow) {
  10886. wrap_hflow.insertBefore(app, site_left_bar);
  10887. wrap_hflow.removeChild(site_left_bar);
  10888. }
  10889. return app;
  10890. })()
  10891. );
  10892. let delSource = _GM_getValue("delSource") ?? true;
  10893. _GM_setValue("delSource", delSource);
  10894. function toggleDelSource() {
  10895. delSource = !delSource;
  10896. _GM_setValue("delSource", delSource);
  10897. history.go(0);
  10898. }
  10899. _GM_registerMenuCommand(
  10900. `${delSource ? "✅" : "🚫"}默认删除源文件`,
  10901. toggleDelSource
  10902. );
  10903. const observer = new MutationObserver((mutationsList) => {
  10904. mutationsList.some((mutation) => {
  10905. if (mutation.type === "childList" && mutation.addedNodes.length > 0 && mutation.addedNodes[0].className === "dialog-box dialog-mini window-current" && delSource) {
  10906. const checkBox = document.querySelector(
  10907. "#js_del_task_source"
  10908. );
  10909. if (checkBox) {
  10910. checkBox.checked = true;
  10911. }
  10912. return true;
  10913. }
  10914. return false;
  10915. });
  10916. });
  10917. observer.observe(document.querySelector("body"), { childList: true });
  10918. }
  10919. });
  10920. require_main_001();
  10921.  
  10922. })(Vue);