lew-ui 2.7.46 → 2.7.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { h, defineComponent, computed, createBlock, openBlock, resolveDynamicComponent, normalizeStyle, normalizeClass, unref, createApp, mergeModels, useModel, provide, watch, toRaw, createElementBlock, renderSlot, ref, Transition, withCtx, inject, createVNode, Fragment, createCommentVNode, createElementVNode, renderList, createTextVNode, toDisplayString as toDisplayString$1, isVNode as isVNode$1, mergeProps, getCurrentInstance, resolveDirective, withDirectives, onMounted, nextTick, createSlots, reactive, getCurrentScope, onScopeDispose, shallowRef, shallowReadonly, toValue, isRef, readonly, resolveComponent, onUnmounted, withModifiers, normalizeProps, guardReactiveProps, vShow, markRaw, Teleport, onActivated, onDeactivated, onBeforeUnmount, shallowReactive, onBeforeMount, vModelText, useCssVars, watchEffect, vModelDynamic, TransitionGroup, useSlots, vModelCheckbox, render as render$1, effectScope, Text } from "vue";
1
+ import { h, defineComponent, computed, createBlock, openBlock, resolveDynamicComponent, normalizeStyle, normalizeClass, unref, createApp, mergeModels, useModel, provide, watch, toRaw, createElementBlock, renderSlot, ref, Transition, withCtx, inject, createVNode, Fragment, createCommentVNode, createElementVNode, renderList, createTextVNode, toDisplayString as toDisplayString$1, isVNode as isVNode$1, mergeProps, getCurrentInstance, resolveDirective, withDirectives, onMounted, nextTick, createSlots, reactive, getCurrentScope, onScopeDispose, shallowRef, shallowReadonly, toValue, isRef, readonly, resolveComponent, onUnmounted, withModifiers, normalizeProps, guardReactiveProps, vShow, markRaw, Teleport, onActivated, onDeactivated, onBeforeUnmount, shallowReactive, onBeforeMount, vModelText, useCssVars, vModelDynamic, TransitionGroup, useSlots, vModelCheckbox, watchEffect, render as render$1, effectScope, Text } from "vue";
2
2
  const collapseItemEmits = {
3
3
  change: (expanded, key) => ({ expanded, key })
4
4
  };
@@ -71,7 +71,7 @@ var symbolTag$3 = "[object Symbol]";
71
71
  function isSymbol(value) {
72
72
  return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$3;
73
73
  }
74
- function arrayMap(array2, iteratee) {
74
+ function arrayMap$1(array2, iteratee) {
75
75
  var index2 = -1, length = array2 == null ? 0 : array2.length, result = Array(length);
76
76
  while (++index2 < length) {
77
77
  result[index2] = iteratee(array2[index2], index2, array2);
@@ -85,7 +85,7 @@ function baseToString(value) {
85
85
  return value;
86
86
  }
87
87
  if (isArray$1(value)) {
88
- return arrayMap(value, baseToString) + "";
88
+ return arrayMap$1(value, baseToString) + "";
89
89
  }
90
90
  if (isSymbol(value)) {
91
91
  return symbolToString$1 ? symbolToString$1.call(value) : "";
@@ -791,7 +791,7 @@ function cloneBuffer(buffer, isDeep) {
791
791
  return buffer.slice();
792
792
  }
793
793
  }
794
- function arrayFilter(array2, predicate) {
794
+ function arrayFilter$1(array2, predicate) {
795
795
  var index2 = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
796
796
  while (++index2 < length) {
797
797
  var value = array2[index2];
@@ -807,12 +807,12 @@ function stubArray() {
807
807
  var objectProto$5 = Object.prototype;
808
808
  var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
809
809
  var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
810
- var getSymbols = !nativeGetSymbols$1 ? stubArray : function(object2) {
810
+ var getSymbols$1 = !nativeGetSymbols$1 ? stubArray : function(object2) {
811
811
  if (object2 == null) {
812
812
  return [];
813
813
  }
814
814
  object2 = Object(object2);
815
- return arrayFilter(nativeGetSymbols$1(object2), function(symbol) {
815
+ return arrayFilter$1(nativeGetSymbols$1(object2), function(symbol) {
816
816
  return propertyIsEnumerable.call(object2, symbol);
817
817
  });
818
818
  };
@@ -820,7 +820,7 @@ var nativeGetSymbols = Object.getOwnPropertySymbols;
820
820
  var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object2) {
821
821
  var result = [];
822
822
  while (object2) {
823
- arrayPush(result, getSymbols(object2));
823
+ arrayPush(result, getSymbols$1(object2));
824
824
  object2 = getPrototype(object2);
825
825
  }
826
826
  return result;
@@ -830,7 +830,7 @@ function baseGetAllKeys(object2, keysFunc, symbolsFunc) {
830
830
  return isArray$1(object2) ? result : arrayPush(result, symbolsFunc(object2));
831
831
  }
832
832
  function getAllKeys(object2) {
833
- return baseGetAllKeys(object2, keys, getSymbols);
833
+ return baseGetAllKeys(object2, keys, getSymbols$1);
834
834
  }
835
835
  function getAllKeysIn(object2) {
836
836
  return baseGetAllKeys(object2, keysIn, getSymbolsIn);
@@ -1629,7 +1629,7 @@ function pickBy(object2, predicate) {
1629
1629
  if (object2 == null) {
1630
1630
  return {};
1631
1631
  }
1632
- var props = arrayMap(getAllKeysIn(object2), function(prop) {
1632
+ var props = arrayMap$1(getAllKeysIn(object2), function(prop) {
1633
1633
  return [prop];
1634
1634
  });
1635
1635
  predicate = baseIteratee(predicate);
@@ -2528,7 +2528,7 @@ class Schema {
2528
2528
  let conditions = schema.conditions;
2529
2529
  schema = schema.clone();
2530
2530
  schema.conditions = [];
2531
- schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
2531
+ schema = conditions.reduce((prevSchema, condition2) => condition2.resolve(prevSchema, options), schema);
2532
2532
  schema = schema.resolve(options);
2533
2533
  }
2534
2534
  return schema;
@@ -6259,8 +6259,8 @@ const formItemProps = {
6259
6259
  })
6260
6260
  },
6261
6261
  visible: {
6262
- type: [Boolean, Function],
6263
- default: true,
6262
+ type: Function,
6263
+ default: () => true,
6264
6264
  validator: validators.boolean({
6265
6265
  componentName: "LewForm",
6266
6266
  propName: "visible"
@@ -6321,16 +6321,16 @@ const formItemProps = {
6321
6321
  })
6322
6322
  },
6323
6323
  disabled: {
6324
- type: [Boolean, Function],
6325
- default: false,
6324
+ type: Function,
6325
+ default: () => false,
6326
6326
  validator: validators.boolean({
6327
6327
  componentName: "LewFormItem",
6328
6328
  propName: "disabled"
6329
6329
  })
6330
6330
  },
6331
6331
  readonly: {
6332
- type: [Boolean, Function],
6333
- default: false,
6332
+ type: Function,
6333
+ default: () => false,
6334
6334
  validator: validators.boolean({
6335
6335
  componentName: "LewFormItem",
6336
6336
  propName: "readonly"
@@ -7028,7 +7028,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
7028
7028
  };
7029
7029
  }
7030
7030
  });
7031
- const LewDescItem = /* @__PURE__ */ _export_sfc(_sfc_main$15, [["__scopeId", "data-v-c41ccfe3"]]);
7031
+ const LewDescItem = /* @__PURE__ */ _export_sfc(_sfc_main$15, [["__scopeId", "data-v-67c52aba"]]);
7032
7032
  const _sfc_main$14 = /* @__PURE__ */ defineComponent({
7033
7033
  __name: "LewDesc",
7034
7034
  props: descProps,
@@ -7484,7 +7484,7 @@ const _sfc_main$12 = /* @__PURE__ */ defineComponent({
7484
7484
  };
7485
7485
  }
7486
7486
  });
7487
- const LewPagination = /* @__PURE__ */ _export_sfc(_sfc_main$12, [["__scopeId", "data-v-5caebf55"]]);
7487
+ const LewPagination = /* @__PURE__ */ _export_sfc(_sfc_main$12, [["__scopeId", "data-v-ed4ad664"]]);
7488
7488
  const tableEmits = {
7489
7489
  sortChange: (sortValue) => sortValue,
7490
7490
  selectChange: (selectedKeys) => selectedKeys,
@@ -7595,13 +7595,13 @@ function watchWithFilter(source, cb, options = {}) {
7595
7595
  );
7596
7596
  }
7597
7597
  function createUntil(r, isNot = false) {
7598
- function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
7598
+ function toMatch(condition2, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
7599
7599
  let stop = null;
7600
7600
  const watcher = new Promise((resolve) => {
7601
7601
  stop = watch(
7602
7602
  r,
7603
7603
  (v) => {
7604
- if (condition(v) !== isNot) {
7604
+ if (condition2(v) !== isNot) {
7605
7605
  if (stop)
7606
7606
  stop();
7607
7607
  else
@@ -11663,8 +11663,8 @@ const applyStyles$1 = {
11663
11663
  function getBasePlacement$1(placement) {
11664
11664
  return placement.split("-")[0];
11665
11665
  }
11666
- var max = Math.max;
11667
- var min = Math.min;
11666
+ var max$1 = Math.max;
11667
+ var min$1 = Math.min;
11668
11668
  var round = Math.round;
11669
11669
  function getUAString() {
11670
11670
  var uaData = navigator.userAgentData;
@@ -11726,7 +11726,7 @@ function getLayoutRect(element) {
11726
11726
  height
11727
11727
  };
11728
11728
  }
11729
- function contains(parent, child) {
11729
+ function contains$1(parent, child) {
11730
11730
  var rootNode = child.getRootNode && child.getRootNode();
11731
11731
  if (parent.contains(child)) {
11732
11732
  return true;
@@ -11812,8 +11812,8 @@ function getOffsetParent(element) {
11812
11812
  function getMainAxisFromPlacement(placement) {
11813
11813
  return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
11814
11814
  }
11815
- function within(min$1, value, max$1) {
11816
- return max(min$1, min(value, max$1));
11815
+ function within(min2, value, max2) {
11816
+ return max$1(min2, min$1(value, max2));
11817
11817
  }
11818
11818
  function withinMaxClamp(min2, value, max2) {
11819
11819
  var v = within(min2, value, max2);
@@ -11882,7 +11882,7 @@ function effect$1(_ref2) {
11882
11882
  return;
11883
11883
  }
11884
11884
  }
11885
- if (!contains(state.elements.popper, arrowElement)) {
11885
+ if (!contains$1(state.elements.popper, arrowElement)) {
11886
11886
  return;
11887
11887
  }
11888
11888
  state.elements.arrow = arrowElement;
@@ -12115,12 +12115,12 @@ function getDocumentRect(element) {
12115
12115
  var html = getDocumentElement(element);
12116
12116
  var winScroll = getWindowScroll(element);
12117
12117
  var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
12118
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
12119
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
12118
+ var width = max$1(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
12119
+ var height = max$1(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
12120
12120
  var x2 = -winScroll.scrollLeft + getWindowScrollBarX(element);
12121
12121
  var y2 = -winScroll.scrollTop;
12122
12122
  if (getComputedStyle$1(body || html).direction === "rtl") {
12123
- x2 += max(html.clientWidth, body ? body.clientWidth : 0) - width;
12123
+ x2 += max$1(html.clientWidth, body ? body.clientWidth : 0) - width;
12124
12124
  }
12125
12125
  return {
12126
12126
  width,
@@ -12188,7 +12188,7 @@ function getClippingParents(element) {
12188
12188
  return [];
12189
12189
  }
12190
12190
  return clippingParents2.filter(function(clippingParent) {
12191
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
12191
+ return isElement$1(clippingParent) && contains$1(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
12192
12192
  });
12193
12193
  }
12194
12194
  function getClippingRect(element, boundary, rootBoundary, strategy) {
@@ -12197,10 +12197,10 @@ function getClippingRect(element, boundary, rootBoundary, strategy) {
12197
12197
  var firstClippingParent = clippingParents2[0];
12198
12198
  var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
12199
12199
  var rect = getClientRectFromMixedType(element, clippingParent, strategy);
12200
- accRect.top = max(rect.top, accRect.top);
12201
- accRect.right = min(rect.right, accRect.right);
12202
- accRect.bottom = min(rect.bottom, accRect.bottom);
12203
- accRect.left = max(rect.left, accRect.left);
12200
+ accRect.top = max$1(rect.top, accRect.top);
12201
+ accRect.right = min$1(rect.right, accRect.right);
12202
+ accRect.bottom = min$1(rect.bottom, accRect.bottom);
12203
+ accRect.left = max$1(rect.left, accRect.left);
12204
12204
  return accRect;
12205
12205
  }, getClientRectFromMixedType(element, firstClippingParent, strategy));
12206
12206
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -12575,8 +12575,8 @@ function preventOverflow(_ref) {
12575
12575
  var altSide = mainAxis === "y" ? bottom : right;
12576
12576
  var len = mainAxis === "y" ? "height" : "width";
12577
12577
  var offset2 = popperOffsets2[mainAxis];
12578
- var min$1 = offset2 + overflow[mainSide];
12579
- var max$1 = offset2 - overflow[altSide];
12578
+ var min2 = offset2 + overflow[mainSide];
12579
+ var max2 = offset2 - overflow[altSide];
12580
12580
  var additive = tether ? -popperRect[len] / 2 : 0;
12581
12581
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
12582
12582
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
@@ -12596,7 +12596,7 @@ function preventOverflow(_ref) {
12596
12596
  var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
12597
12597
  var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
12598
12598
  var tetherMax = offset2 + maxOffset - offsetModifierValue;
12599
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset2, tether ? max(max$1, tetherMax) : max$1);
12599
+ var preventedOffset = within(tether ? min$1(min2, tetherMin) : min2, offset2, tether ? max$1(max2, tetherMax) : max2);
12600
12600
  popperOffsets2[mainAxis] = preventedOffset;
12601
12601
  data[mainAxis] = preventedOffset - offset2;
12602
12602
  }
@@ -12963,7 +12963,7 @@ function removeUndefinedProps(obj) {
12963
12963
  return acc;
12964
12964
  }, {});
12965
12965
  }
12966
- function div() {
12966
+ function div$1() {
12967
12967
  return document.createElement("div");
12968
12968
  }
12969
12969
  function isElement(value) {
@@ -13118,15 +13118,15 @@ if (process.env.NODE_ENV !== "production") {
13118
13118
  function resetVisitedMessages() {
13119
13119
  visitedMessages = /* @__PURE__ */ new Set();
13120
13120
  }
13121
- function warnWhen(condition, message) {
13122
- if (condition && !visitedMessages.has(message)) {
13121
+ function warnWhen(condition2, message) {
13122
+ if (condition2 && !visitedMessages.has(message)) {
13123
13123
  var _console;
13124
13124
  visitedMessages.add(message);
13125
13125
  (_console = console).warn.apply(_console, getFormattedMessage(message));
13126
13126
  }
13127
13127
  }
13128
- function errorWhen(condition, message) {
13129
- if (condition && !visitedMessages.has(message)) {
13128
+ function errorWhen(condition2, message) {
13129
+ if (condition2 && !visitedMessages.has(message)) {
13130
13130
  var _console2;
13131
13131
  visitedMessages.add(message);
13132
13132
  (_console2 = console).error.apply(_console2, getFormattedMessage(message));
@@ -13285,7 +13285,7 @@ function dangerouslySetInnerHTML(element, html) {
13285
13285
  element[innerHTML()] = html;
13286
13286
  }
13287
13287
  function createArrowElement(value) {
13288
- var arrow2 = div();
13288
+ var arrow2 = div$1();
13289
13289
  if (value === true) {
13290
13290
  arrow2.className = ARROW_CLASS;
13291
13291
  } else {
@@ -13327,12 +13327,12 @@ function getChildren(popper2) {
13327
13327
  };
13328
13328
  }
13329
13329
  function render(instance) {
13330
- var popper2 = div();
13331
- var box = div();
13330
+ var popper2 = div$1();
13331
+ var box = div$1();
13332
13332
  box.className = BOX_CLASS;
13333
13333
  box.setAttribute("data-state", "hidden");
13334
13334
  box.setAttribute("tabindex", "-1");
13335
- var content = div();
13335
+ var content = div$1();
13336
13336
  content.className = CONTENT_CLASS;
13337
13337
  content.setAttribute("data-state", "hidden");
13338
13338
  setContent(content, instance.props);
@@ -13419,7 +13419,7 @@ function createTippy(reference2, passedProps) {
13419
13419
  // properties
13420
13420
  id,
13421
13421
  reference: reference2,
13422
- popper: div(),
13422
+ popper: div$1(),
13423
13423
  popperInstance,
13424
13424
  props,
13425
13425
  state,
@@ -19563,6 +19563,1610 @@ const formEmits = {
19563
19563
  const formItemEmits = {
19564
19564
  change: (value) => value
19565
19565
  };
19566
+ var INUMBER = "INUMBER";
19567
+ var IOP1 = "IOP1";
19568
+ var IOP2 = "IOP2";
19569
+ var IOP3 = "IOP3";
19570
+ var IVAR = "IVAR";
19571
+ var IVARNAME = "IVARNAME";
19572
+ var IFUNCALL = "IFUNCALL";
19573
+ var IFUNDEF = "IFUNDEF";
19574
+ var IEXPR = "IEXPR";
19575
+ var IEXPREVAL = "IEXPREVAL";
19576
+ var IMEMBER = "IMEMBER";
19577
+ var IENDSTATEMENT = "IENDSTATEMENT";
19578
+ var IARRAY = "IARRAY";
19579
+ function Instruction(type, value) {
19580
+ this.type = type;
19581
+ this.value = value !== void 0 && value !== null ? value : 0;
19582
+ }
19583
+ Instruction.prototype.toString = function() {
19584
+ switch (this.type) {
19585
+ case INUMBER:
19586
+ case IOP1:
19587
+ case IOP2:
19588
+ case IOP3:
19589
+ case IVAR:
19590
+ case IVARNAME:
19591
+ case IENDSTATEMENT:
19592
+ return this.value;
19593
+ case IFUNCALL:
19594
+ return "CALL " + this.value;
19595
+ case IFUNDEF:
19596
+ return "DEF " + this.value;
19597
+ case IARRAY:
19598
+ return "ARRAY " + this.value;
19599
+ case IMEMBER:
19600
+ return "." + this.value;
19601
+ default:
19602
+ return "Invalid Instruction";
19603
+ }
19604
+ };
19605
+ function unaryInstruction(value) {
19606
+ return new Instruction(IOP1, value);
19607
+ }
19608
+ function binaryInstruction(value) {
19609
+ return new Instruction(IOP2, value);
19610
+ }
19611
+ function ternaryInstruction(value) {
19612
+ return new Instruction(IOP3, value);
19613
+ }
19614
+ function simplify(tokens, unaryOps, binaryOps, ternaryOps, values) {
19615
+ var nstack = [];
19616
+ var newexpression = [];
19617
+ var n1, n2, n3;
19618
+ var f;
19619
+ for (var i = 0; i < tokens.length; i++) {
19620
+ var item = tokens[i];
19621
+ var type = item.type;
19622
+ if (type === INUMBER || type === IVARNAME) {
19623
+ if (Array.isArray(item.value)) {
19624
+ nstack.push.apply(nstack, simplify(item.value.map(function(x2) {
19625
+ return new Instruction(INUMBER, x2);
19626
+ }).concat(new Instruction(IARRAY, item.value.length)), unaryOps, binaryOps, ternaryOps, values));
19627
+ } else {
19628
+ nstack.push(item);
19629
+ }
19630
+ } else if (type === IVAR && values.hasOwnProperty(item.value)) {
19631
+ item = new Instruction(INUMBER, values[item.value]);
19632
+ nstack.push(item);
19633
+ } else if (type === IOP2 && nstack.length > 1) {
19634
+ n2 = nstack.pop();
19635
+ n1 = nstack.pop();
19636
+ f = binaryOps[item.value];
19637
+ item = new Instruction(INUMBER, f(n1.value, n2.value));
19638
+ nstack.push(item);
19639
+ } else if (type === IOP3 && nstack.length > 2) {
19640
+ n3 = nstack.pop();
19641
+ n2 = nstack.pop();
19642
+ n1 = nstack.pop();
19643
+ if (item.value === "?") {
19644
+ nstack.push(n1.value ? n2.value : n3.value);
19645
+ } else {
19646
+ f = ternaryOps[item.value];
19647
+ item = new Instruction(INUMBER, f(n1.value, n2.value, n3.value));
19648
+ nstack.push(item);
19649
+ }
19650
+ } else if (type === IOP1 && nstack.length > 0) {
19651
+ n1 = nstack.pop();
19652
+ f = unaryOps[item.value];
19653
+ item = new Instruction(INUMBER, f(n1.value));
19654
+ nstack.push(item);
19655
+ } else if (type === IEXPR) {
19656
+ while (nstack.length > 0) {
19657
+ newexpression.push(nstack.shift());
19658
+ }
19659
+ newexpression.push(new Instruction(IEXPR, simplify(item.value, unaryOps, binaryOps, ternaryOps, values)));
19660
+ } else if (type === IMEMBER && nstack.length > 0) {
19661
+ n1 = nstack.pop();
19662
+ nstack.push(new Instruction(INUMBER, n1.value[item.value]));
19663
+ } else {
19664
+ while (nstack.length > 0) {
19665
+ newexpression.push(nstack.shift());
19666
+ }
19667
+ newexpression.push(item);
19668
+ }
19669
+ }
19670
+ while (nstack.length > 0) {
19671
+ newexpression.push(nstack.shift());
19672
+ }
19673
+ return newexpression;
19674
+ }
19675
+ function substitute(tokens, variable, expr) {
19676
+ var newexpression = [];
19677
+ for (var i = 0; i < tokens.length; i++) {
19678
+ var item = tokens[i];
19679
+ var type = item.type;
19680
+ if (type === IVAR && item.value === variable) {
19681
+ for (var j = 0; j < expr.tokens.length; j++) {
19682
+ var expritem = expr.tokens[j];
19683
+ var replitem;
19684
+ if (expritem.type === IOP1) {
19685
+ replitem = unaryInstruction(expritem.value);
19686
+ } else if (expritem.type === IOP2) {
19687
+ replitem = binaryInstruction(expritem.value);
19688
+ } else if (expritem.type === IOP3) {
19689
+ replitem = ternaryInstruction(expritem.value);
19690
+ } else {
19691
+ replitem = new Instruction(expritem.type, expritem.value);
19692
+ }
19693
+ newexpression.push(replitem);
19694
+ }
19695
+ } else if (type === IEXPR) {
19696
+ newexpression.push(new Instruction(IEXPR, substitute(item.value, variable, expr)));
19697
+ } else {
19698
+ newexpression.push(item);
19699
+ }
19700
+ }
19701
+ return newexpression;
19702
+ }
19703
+ function evaluate(tokens, expr, values) {
19704
+ var nstack = [];
19705
+ var n1, n2, n3;
19706
+ var f, args, argCount;
19707
+ if (isExpressionEvaluator(tokens)) {
19708
+ return resolveExpression(tokens, values);
19709
+ }
19710
+ var numTokens = tokens.length;
19711
+ for (var i = 0; i < numTokens; i++) {
19712
+ var item = tokens[i];
19713
+ var type = item.type;
19714
+ if (type === INUMBER || type === IVARNAME) {
19715
+ nstack.push(item.value);
19716
+ } else if (type === IOP2) {
19717
+ n2 = nstack.pop();
19718
+ n1 = nstack.pop();
19719
+ if (item.value === "and") {
19720
+ nstack.push(n1 ? !!evaluate(n2, expr, values) : false);
19721
+ } else if (item.value === "or") {
19722
+ nstack.push(n1 ? true : !!evaluate(n2, expr, values));
19723
+ } else if (item.value === "=") {
19724
+ f = expr.binaryOps[item.value];
19725
+ nstack.push(f(n1, evaluate(n2, expr, values), values));
19726
+ } else {
19727
+ f = expr.binaryOps[item.value];
19728
+ nstack.push(f(resolveExpression(n1, values), resolveExpression(n2, values)));
19729
+ }
19730
+ } else if (type === IOP3) {
19731
+ n3 = nstack.pop();
19732
+ n2 = nstack.pop();
19733
+ n1 = nstack.pop();
19734
+ if (item.value === "?") {
19735
+ nstack.push(evaluate(n1 ? n2 : n3, expr, values));
19736
+ } else {
19737
+ f = expr.ternaryOps[item.value];
19738
+ nstack.push(f(resolveExpression(n1, values), resolveExpression(n2, values), resolveExpression(n3, values)));
19739
+ }
19740
+ } else if (type === IVAR) {
19741
+ if (item.value in expr.functions) {
19742
+ nstack.push(expr.functions[item.value]);
19743
+ } else if (item.value in expr.unaryOps && expr.parser.isOperatorEnabled(item.value)) {
19744
+ nstack.push(expr.unaryOps[item.value]);
19745
+ } else {
19746
+ var v = values[item.value];
19747
+ if (v !== void 0) {
19748
+ nstack.push(v);
19749
+ } else {
19750
+ throw new Error("undefined variable: " + item.value);
19751
+ }
19752
+ }
19753
+ } else if (type === IOP1) {
19754
+ n1 = nstack.pop();
19755
+ f = expr.unaryOps[item.value];
19756
+ nstack.push(f(resolveExpression(n1, values)));
19757
+ } else if (type === IFUNCALL) {
19758
+ argCount = item.value;
19759
+ args = [];
19760
+ while (argCount-- > 0) {
19761
+ args.unshift(resolveExpression(nstack.pop(), values));
19762
+ }
19763
+ f = nstack.pop();
19764
+ if (f.apply && f.call) {
19765
+ nstack.push(f.apply(void 0, args));
19766
+ } else {
19767
+ throw new Error(f + " is not a function");
19768
+ }
19769
+ } else if (type === IFUNDEF) {
19770
+ nstack.push((function() {
19771
+ var n22 = nstack.pop();
19772
+ var args2 = [];
19773
+ var argCount2 = item.value;
19774
+ while (argCount2-- > 0) {
19775
+ args2.unshift(nstack.pop());
19776
+ }
19777
+ var n12 = nstack.pop();
19778
+ var f2 = function() {
19779
+ var scope = Object.assign({}, values);
19780
+ for (var i2 = 0, len = args2.length; i2 < len; i2++) {
19781
+ scope[args2[i2]] = arguments[i2];
19782
+ }
19783
+ return evaluate(n22, expr, scope);
19784
+ };
19785
+ Object.defineProperty(f2, "name", {
19786
+ value: n12,
19787
+ writable: false
19788
+ });
19789
+ values[n12] = f2;
19790
+ return f2;
19791
+ })());
19792
+ } else if (type === IEXPR) {
19793
+ nstack.push(createExpressionEvaluator(item, expr));
19794
+ } else if (type === IEXPREVAL) {
19795
+ nstack.push(item);
19796
+ } else if (type === IMEMBER) {
19797
+ n1 = nstack.pop();
19798
+ nstack.push(n1[item.value]);
19799
+ } else if (type === IENDSTATEMENT) {
19800
+ nstack.pop();
19801
+ } else if (type === IARRAY) {
19802
+ argCount = item.value;
19803
+ args = [];
19804
+ while (argCount-- > 0) {
19805
+ args.unshift(nstack.pop());
19806
+ }
19807
+ nstack.push(args);
19808
+ } else {
19809
+ throw new Error("invalid Expression");
19810
+ }
19811
+ }
19812
+ if (nstack.length > 1) {
19813
+ throw new Error("invalid Expression (parity)");
19814
+ }
19815
+ return nstack[0] === 0 ? 0 : resolveExpression(nstack[0], values);
19816
+ }
19817
+ function createExpressionEvaluator(token, expr, values) {
19818
+ if (isExpressionEvaluator(token)) return token;
19819
+ return {
19820
+ type: IEXPREVAL,
19821
+ value: function(scope) {
19822
+ return evaluate(token.value, expr, scope);
19823
+ }
19824
+ };
19825
+ }
19826
+ function isExpressionEvaluator(n) {
19827
+ return n && n.type === IEXPREVAL;
19828
+ }
19829
+ function resolveExpression(n, values) {
19830
+ return isExpressionEvaluator(n) ? n.value(values) : n;
19831
+ }
19832
+ function expressionToString(tokens, toJS) {
19833
+ var nstack = [];
19834
+ var n1, n2, n3;
19835
+ var f, args, argCount;
19836
+ for (var i = 0; i < tokens.length; i++) {
19837
+ var item = tokens[i];
19838
+ var type = item.type;
19839
+ if (type === INUMBER) {
19840
+ if (typeof item.value === "number" && item.value < 0) {
19841
+ nstack.push("(" + item.value + ")");
19842
+ } else if (Array.isArray(item.value)) {
19843
+ nstack.push("[" + item.value.map(escapeValue).join(", ") + "]");
19844
+ } else {
19845
+ nstack.push(escapeValue(item.value));
19846
+ }
19847
+ } else if (type === IOP2) {
19848
+ n2 = nstack.pop();
19849
+ n1 = nstack.pop();
19850
+ f = item.value;
19851
+ if (toJS) {
19852
+ if (f === "^") {
19853
+ nstack.push("Math.pow(" + n1 + ", " + n2 + ")");
19854
+ } else if (f === "and") {
19855
+ nstack.push("(!!" + n1 + " && !!" + n2 + ")");
19856
+ } else if (f === "or") {
19857
+ nstack.push("(!!" + n1 + " || !!" + n2 + ")");
19858
+ } else if (f === "||") {
19859
+ nstack.push("(function(a,b){ return Array.isArray(a) && Array.isArray(b) ? a.concat(b) : String(a) + String(b); }((" + n1 + "),(" + n2 + ")))");
19860
+ } else if (f === "==") {
19861
+ nstack.push("(" + n1 + " === " + n2 + ")");
19862
+ } else if (f === "!=") {
19863
+ nstack.push("(" + n1 + " !== " + n2 + ")");
19864
+ } else if (f === "[") {
19865
+ nstack.push(n1 + "[(" + n2 + ") | 0]");
19866
+ } else {
19867
+ nstack.push("(" + n1 + " " + f + " " + n2 + ")");
19868
+ }
19869
+ } else {
19870
+ if (f === "[") {
19871
+ nstack.push(n1 + "[" + n2 + "]");
19872
+ } else {
19873
+ nstack.push("(" + n1 + " " + f + " " + n2 + ")");
19874
+ }
19875
+ }
19876
+ } else if (type === IOP3) {
19877
+ n3 = nstack.pop();
19878
+ n2 = nstack.pop();
19879
+ n1 = nstack.pop();
19880
+ f = item.value;
19881
+ if (f === "?") {
19882
+ nstack.push("(" + n1 + " ? " + n2 + " : " + n3 + ")");
19883
+ } else {
19884
+ throw new Error("invalid Expression");
19885
+ }
19886
+ } else if (type === IVAR || type === IVARNAME) {
19887
+ nstack.push(item.value);
19888
+ } else if (type === IOP1) {
19889
+ n1 = nstack.pop();
19890
+ f = item.value;
19891
+ if (f === "-" || f === "+") {
19892
+ nstack.push("(" + f + n1 + ")");
19893
+ } else if (toJS) {
19894
+ if (f === "not") {
19895
+ nstack.push("(!" + n1 + ")");
19896
+ } else if (f === "!") {
19897
+ nstack.push("fac(" + n1 + ")");
19898
+ } else {
19899
+ nstack.push(f + "(" + n1 + ")");
19900
+ }
19901
+ } else if (f === "!") {
19902
+ nstack.push("(" + n1 + "!)");
19903
+ } else {
19904
+ nstack.push("(" + f + " " + n1 + ")");
19905
+ }
19906
+ } else if (type === IFUNCALL) {
19907
+ argCount = item.value;
19908
+ args = [];
19909
+ while (argCount-- > 0) {
19910
+ args.unshift(nstack.pop());
19911
+ }
19912
+ f = nstack.pop();
19913
+ nstack.push(f + "(" + args.join(", ") + ")");
19914
+ } else if (type === IFUNDEF) {
19915
+ n2 = nstack.pop();
19916
+ argCount = item.value;
19917
+ args = [];
19918
+ while (argCount-- > 0) {
19919
+ args.unshift(nstack.pop());
19920
+ }
19921
+ n1 = nstack.pop();
19922
+ if (toJS) {
19923
+ nstack.push("(" + n1 + " = function(" + args.join(", ") + ") { return " + n2 + " })");
19924
+ } else {
19925
+ nstack.push("(" + n1 + "(" + args.join(", ") + ") = " + n2 + ")");
19926
+ }
19927
+ } else if (type === IMEMBER) {
19928
+ n1 = nstack.pop();
19929
+ nstack.push(n1 + "." + item.value);
19930
+ } else if (type === IARRAY) {
19931
+ argCount = item.value;
19932
+ args = [];
19933
+ while (argCount-- > 0) {
19934
+ args.unshift(nstack.pop());
19935
+ }
19936
+ nstack.push("[" + args.join(", ") + "]");
19937
+ } else if (type === IEXPR) {
19938
+ nstack.push("(" + expressionToString(item.value, toJS) + ")");
19939
+ } else if (type === IENDSTATEMENT) ;
19940
+ else {
19941
+ throw new Error("invalid Expression");
19942
+ }
19943
+ }
19944
+ if (nstack.length > 1) {
19945
+ if (toJS) {
19946
+ nstack = [nstack.join(",")];
19947
+ } else {
19948
+ nstack = [nstack.join(";")];
19949
+ }
19950
+ }
19951
+ return String(nstack[0]);
19952
+ }
19953
+ function escapeValue(v) {
19954
+ if (typeof v === "string") {
19955
+ return JSON.stringify(v).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
19956
+ }
19957
+ return v;
19958
+ }
19959
+ function contains(array2, obj) {
19960
+ for (var i = 0; i < array2.length; i++) {
19961
+ if (array2[i] === obj) {
19962
+ return true;
19963
+ }
19964
+ }
19965
+ return false;
19966
+ }
19967
+ function getSymbols(tokens, symbols, options) {
19968
+ options = options || {};
19969
+ var withMembers = !!options.withMembers;
19970
+ var prevVar = null;
19971
+ for (var i = 0; i < tokens.length; i++) {
19972
+ var item = tokens[i];
19973
+ if (item.type === IVAR || item.type === IVARNAME) {
19974
+ if (!withMembers && !contains(symbols, item.value)) {
19975
+ symbols.push(item.value);
19976
+ } else if (prevVar !== null) {
19977
+ if (!contains(symbols, prevVar)) {
19978
+ symbols.push(prevVar);
19979
+ }
19980
+ prevVar = item.value;
19981
+ } else {
19982
+ prevVar = item.value;
19983
+ }
19984
+ } else if (item.type === IMEMBER && withMembers && prevVar !== null) {
19985
+ prevVar += "." + item.value;
19986
+ } else if (item.type === IEXPR) {
19987
+ getSymbols(item.value, symbols, options);
19988
+ } else if (prevVar !== null) {
19989
+ if (!contains(symbols, prevVar)) {
19990
+ symbols.push(prevVar);
19991
+ }
19992
+ prevVar = null;
19993
+ }
19994
+ }
19995
+ if (prevVar !== null && !contains(symbols, prevVar)) {
19996
+ symbols.push(prevVar);
19997
+ }
19998
+ }
19999
+ function Expression(tokens, parser) {
20000
+ this.tokens = tokens;
20001
+ this.parser = parser;
20002
+ this.unaryOps = parser.unaryOps;
20003
+ this.binaryOps = parser.binaryOps;
20004
+ this.ternaryOps = parser.ternaryOps;
20005
+ this.functions = parser.functions;
20006
+ }
20007
+ Expression.prototype.simplify = function(values) {
20008
+ values = values || {};
20009
+ return new Expression(simplify(this.tokens, this.unaryOps, this.binaryOps, this.ternaryOps, values), this.parser);
20010
+ };
20011
+ Expression.prototype.substitute = function(variable, expr) {
20012
+ if (!(expr instanceof Expression)) {
20013
+ expr = this.parser.parse(String(expr));
20014
+ }
20015
+ return new Expression(substitute(this.tokens, variable, expr), this.parser);
20016
+ };
20017
+ Expression.prototype.evaluate = function(values) {
20018
+ values = values || {};
20019
+ return evaluate(this.tokens, this, values);
20020
+ };
20021
+ Expression.prototype.toString = function() {
20022
+ return expressionToString(this.tokens, false);
20023
+ };
20024
+ Expression.prototype.symbols = function(options) {
20025
+ options = options || {};
20026
+ var vars = [];
20027
+ getSymbols(this.tokens, vars, options);
20028
+ return vars;
20029
+ };
20030
+ Expression.prototype.variables = function(options) {
20031
+ options = options || {};
20032
+ var vars = [];
20033
+ getSymbols(this.tokens, vars, options);
20034
+ var functions = this.functions;
20035
+ return vars.filter(function(name) {
20036
+ return !(name in functions);
20037
+ });
20038
+ };
20039
+ Expression.prototype.toJSFunction = function(param, variables) {
20040
+ var expr = this;
20041
+ var f = new Function(param, "with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return " + expressionToString(this.simplify(variables).tokens, true) + "; }");
20042
+ return function() {
20043
+ return f.apply(expr, arguments);
20044
+ };
20045
+ };
20046
+ var TEOF = "TEOF";
20047
+ var TOP = "TOP";
20048
+ var TNUMBER = "TNUMBER";
20049
+ var TSTRING = "TSTRING";
20050
+ var TPAREN = "TPAREN";
20051
+ var TBRACKET = "TBRACKET";
20052
+ var TCOMMA = "TCOMMA";
20053
+ var TNAME = "TNAME";
20054
+ var TSEMICOLON = "TSEMICOLON";
20055
+ function Token(type, value, index2) {
20056
+ this.type = type;
20057
+ this.value = value;
20058
+ this.index = index2;
20059
+ }
20060
+ Token.prototype.toString = function() {
20061
+ return this.type + ": " + this.value;
20062
+ };
20063
+ function TokenStream(parser, expression) {
20064
+ this.pos = 0;
20065
+ this.current = null;
20066
+ this.unaryOps = parser.unaryOps;
20067
+ this.binaryOps = parser.binaryOps;
20068
+ this.ternaryOps = parser.ternaryOps;
20069
+ this.consts = parser.consts;
20070
+ this.expression = expression;
20071
+ this.savedPosition = 0;
20072
+ this.savedCurrent = null;
20073
+ this.options = parser.options;
20074
+ this.parser = parser;
20075
+ }
20076
+ TokenStream.prototype.newToken = function(type, value, pos) {
20077
+ return new Token(type, value, pos != null ? pos : this.pos);
20078
+ };
20079
+ TokenStream.prototype.save = function() {
20080
+ this.savedPosition = this.pos;
20081
+ this.savedCurrent = this.current;
20082
+ };
20083
+ TokenStream.prototype.restore = function() {
20084
+ this.pos = this.savedPosition;
20085
+ this.current = this.savedCurrent;
20086
+ };
20087
+ TokenStream.prototype.next = function() {
20088
+ if (this.pos >= this.expression.length) {
20089
+ return this.newToken(TEOF, "EOF");
20090
+ }
20091
+ if (this.isWhitespace() || this.isComment()) {
20092
+ return this.next();
20093
+ } else if (this.isRadixInteger() || this.isNumber() || this.isOperator() || this.isString() || this.isParen() || this.isBracket() || this.isComma() || this.isSemicolon() || this.isNamedOp() || this.isConst() || this.isName()) {
20094
+ return this.current;
20095
+ } else {
20096
+ this.parseError('Unknown character "' + this.expression.charAt(this.pos) + '"');
20097
+ }
20098
+ };
20099
+ TokenStream.prototype.isString = function() {
20100
+ var r = false;
20101
+ var startPos = this.pos;
20102
+ var quote = this.expression.charAt(startPos);
20103
+ if (quote === "'" || quote === '"') {
20104
+ var index2 = this.expression.indexOf(quote, startPos + 1);
20105
+ while (index2 >= 0 && this.pos < this.expression.length) {
20106
+ this.pos = index2 + 1;
20107
+ if (this.expression.charAt(index2 - 1) !== "\\") {
20108
+ var rawString = this.expression.substring(startPos + 1, index2);
20109
+ this.current = this.newToken(TSTRING, this.unescape(rawString), startPos);
20110
+ r = true;
20111
+ break;
20112
+ }
20113
+ index2 = this.expression.indexOf(quote, index2 + 1);
20114
+ }
20115
+ }
20116
+ return r;
20117
+ };
20118
+ TokenStream.prototype.isParen = function() {
20119
+ var c = this.expression.charAt(this.pos);
20120
+ if (c === "(" || c === ")") {
20121
+ this.current = this.newToken(TPAREN, c);
20122
+ this.pos++;
20123
+ return true;
20124
+ }
20125
+ return false;
20126
+ };
20127
+ TokenStream.prototype.isBracket = function() {
20128
+ var c = this.expression.charAt(this.pos);
20129
+ if ((c === "[" || c === "]") && this.isOperatorEnabled("[")) {
20130
+ this.current = this.newToken(TBRACKET, c);
20131
+ this.pos++;
20132
+ return true;
20133
+ }
20134
+ return false;
20135
+ };
20136
+ TokenStream.prototype.isComma = function() {
20137
+ var c = this.expression.charAt(this.pos);
20138
+ if (c === ",") {
20139
+ this.current = this.newToken(TCOMMA, ",");
20140
+ this.pos++;
20141
+ return true;
20142
+ }
20143
+ return false;
20144
+ };
20145
+ TokenStream.prototype.isSemicolon = function() {
20146
+ var c = this.expression.charAt(this.pos);
20147
+ if (c === ";") {
20148
+ this.current = this.newToken(TSEMICOLON, ";");
20149
+ this.pos++;
20150
+ return true;
20151
+ }
20152
+ return false;
20153
+ };
20154
+ TokenStream.prototype.isConst = function() {
20155
+ var startPos = this.pos;
20156
+ var i = startPos;
20157
+ for (; i < this.expression.length; i++) {
20158
+ var c = this.expression.charAt(i);
20159
+ if (c.toUpperCase() === c.toLowerCase()) {
20160
+ if (i === this.pos || c !== "_" && c !== "." && (c < "0" || c > "9")) {
20161
+ break;
20162
+ }
20163
+ }
20164
+ }
20165
+ if (i > startPos) {
20166
+ var str = this.expression.substring(startPos, i);
20167
+ if (str in this.consts) {
20168
+ this.current = this.newToken(TNUMBER, this.consts[str]);
20169
+ this.pos += str.length;
20170
+ return true;
20171
+ }
20172
+ }
20173
+ return false;
20174
+ };
20175
+ TokenStream.prototype.isNamedOp = function() {
20176
+ var startPos = this.pos;
20177
+ var i = startPos;
20178
+ for (; i < this.expression.length; i++) {
20179
+ var c = this.expression.charAt(i);
20180
+ if (c.toUpperCase() === c.toLowerCase()) {
20181
+ if (i === this.pos || c !== "_" && (c < "0" || c > "9")) {
20182
+ break;
20183
+ }
20184
+ }
20185
+ }
20186
+ if (i > startPos) {
20187
+ var str = this.expression.substring(startPos, i);
20188
+ if (this.isOperatorEnabled(str) && (str in this.binaryOps || str in this.unaryOps || str in this.ternaryOps)) {
20189
+ this.current = this.newToken(TOP, str);
20190
+ this.pos += str.length;
20191
+ return true;
20192
+ }
20193
+ }
20194
+ return false;
20195
+ };
20196
+ TokenStream.prototype.isName = function() {
20197
+ var startPos = this.pos;
20198
+ var i = startPos;
20199
+ var hasLetter = false;
20200
+ for (; i < this.expression.length; i++) {
20201
+ var c = this.expression.charAt(i);
20202
+ if (c.toUpperCase() === c.toLowerCase()) {
20203
+ if (i === this.pos && (c === "$" || c === "_")) {
20204
+ if (c === "_") {
20205
+ hasLetter = true;
20206
+ }
20207
+ continue;
20208
+ } else if (i === this.pos || !hasLetter || c !== "_" && (c < "0" || c > "9")) {
20209
+ break;
20210
+ }
20211
+ } else {
20212
+ hasLetter = true;
20213
+ }
20214
+ }
20215
+ if (hasLetter) {
20216
+ var str = this.expression.substring(startPos, i);
20217
+ this.current = this.newToken(TNAME, str);
20218
+ this.pos += str.length;
20219
+ return true;
20220
+ }
20221
+ return false;
20222
+ };
20223
+ TokenStream.prototype.isWhitespace = function() {
20224
+ var r = false;
20225
+ var c = this.expression.charAt(this.pos);
20226
+ while (c === " " || c === " " || c === "\n" || c === "\r") {
20227
+ r = true;
20228
+ this.pos++;
20229
+ if (this.pos >= this.expression.length) {
20230
+ break;
20231
+ }
20232
+ c = this.expression.charAt(this.pos);
20233
+ }
20234
+ return r;
20235
+ };
20236
+ var codePointPattern = /^[0-9a-f]{4}$/i;
20237
+ TokenStream.prototype.unescape = function(v) {
20238
+ var index2 = v.indexOf("\\");
20239
+ if (index2 < 0) {
20240
+ return v;
20241
+ }
20242
+ var buffer = v.substring(0, index2);
20243
+ while (index2 >= 0) {
20244
+ var c = v.charAt(++index2);
20245
+ switch (c) {
20246
+ case "'":
20247
+ buffer += "'";
20248
+ break;
20249
+ case '"':
20250
+ buffer += '"';
20251
+ break;
20252
+ case "\\":
20253
+ buffer += "\\";
20254
+ break;
20255
+ case "/":
20256
+ buffer += "/";
20257
+ break;
20258
+ case "b":
20259
+ buffer += "\b";
20260
+ break;
20261
+ case "f":
20262
+ buffer += "\f";
20263
+ break;
20264
+ case "n":
20265
+ buffer += "\n";
20266
+ break;
20267
+ case "r":
20268
+ buffer += "\r";
20269
+ break;
20270
+ case "t":
20271
+ buffer += " ";
20272
+ break;
20273
+ case "u":
20274
+ var codePoint = v.substring(index2 + 1, index2 + 5);
20275
+ if (!codePointPattern.test(codePoint)) {
20276
+ this.parseError("Illegal escape sequence: \\u" + codePoint);
20277
+ }
20278
+ buffer += String.fromCharCode(parseInt(codePoint, 16));
20279
+ index2 += 4;
20280
+ break;
20281
+ default:
20282
+ throw this.parseError('Illegal escape sequence: "\\' + c + '"');
20283
+ }
20284
+ ++index2;
20285
+ var backslash = v.indexOf("\\", index2);
20286
+ buffer += v.substring(index2, backslash < 0 ? v.length : backslash);
20287
+ index2 = backslash;
20288
+ }
20289
+ return buffer;
20290
+ };
20291
+ TokenStream.prototype.isComment = function() {
20292
+ var c = this.expression.charAt(this.pos);
20293
+ if (c === "/" && this.expression.charAt(this.pos + 1) === "*") {
20294
+ this.pos = this.expression.indexOf("*/", this.pos) + 2;
20295
+ if (this.pos === 1) {
20296
+ this.pos = this.expression.length;
20297
+ }
20298
+ return true;
20299
+ }
20300
+ return false;
20301
+ };
20302
+ TokenStream.prototype.isRadixInteger = function() {
20303
+ var pos = this.pos;
20304
+ if (pos >= this.expression.length - 2 || this.expression.charAt(pos) !== "0") {
20305
+ return false;
20306
+ }
20307
+ ++pos;
20308
+ var radix;
20309
+ var validDigit;
20310
+ if (this.expression.charAt(pos) === "x") {
20311
+ radix = 16;
20312
+ validDigit = /^[0-9a-f]$/i;
20313
+ ++pos;
20314
+ } else if (this.expression.charAt(pos) === "b") {
20315
+ radix = 2;
20316
+ validDigit = /^[01]$/i;
20317
+ ++pos;
20318
+ } else {
20319
+ return false;
20320
+ }
20321
+ var valid = false;
20322
+ var startPos = pos;
20323
+ while (pos < this.expression.length) {
20324
+ var c = this.expression.charAt(pos);
20325
+ if (validDigit.test(c)) {
20326
+ pos++;
20327
+ valid = true;
20328
+ } else {
20329
+ break;
20330
+ }
20331
+ }
20332
+ if (valid) {
20333
+ this.current = this.newToken(TNUMBER, parseInt(this.expression.substring(startPos, pos), radix));
20334
+ this.pos = pos;
20335
+ }
20336
+ return valid;
20337
+ };
20338
+ TokenStream.prototype.isNumber = function() {
20339
+ var valid = false;
20340
+ var pos = this.pos;
20341
+ var startPos = pos;
20342
+ var resetPos = pos;
20343
+ var foundDot = false;
20344
+ var foundDigits = false;
20345
+ var c;
20346
+ while (pos < this.expression.length) {
20347
+ c = this.expression.charAt(pos);
20348
+ if (c >= "0" && c <= "9" || !foundDot && c === ".") {
20349
+ if (c === ".") {
20350
+ foundDot = true;
20351
+ } else {
20352
+ foundDigits = true;
20353
+ }
20354
+ pos++;
20355
+ valid = foundDigits;
20356
+ } else {
20357
+ break;
20358
+ }
20359
+ }
20360
+ if (valid) {
20361
+ resetPos = pos;
20362
+ }
20363
+ if (c === "e" || c === "E") {
20364
+ pos++;
20365
+ var acceptSign = true;
20366
+ var validExponent = false;
20367
+ while (pos < this.expression.length) {
20368
+ c = this.expression.charAt(pos);
20369
+ if (acceptSign && (c === "+" || c === "-")) {
20370
+ acceptSign = false;
20371
+ } else if (c >= "0" && c <= "9") {
20372
+ validExponent = true;
20373
+ acceptSign = false;
20374
+ } else {
20375
+ break;
20376
+ }
20377
+ pos++;
20378
+ }
20379
+ if (!validExponent) {
20380
+ pos = resetPos;
20381
+ }
20382
+ }
20383
+ if (valid) {
20384
+ this.current = this.newToken(TNUMBER, parseFloat(this.expression.substring(startPos, pos)));
20385
+ this.pos = pos;
20386
+ } else {
20387
+ this.pos = resetPos;
20388
+ }
20389
+ return valid;
20390
+ };
20391
+ TokenStream.prototype.isOperator = function() {
20392
+ var startPos = this.pos;
20393
+ var c = this.expression.charAt(this.pos);
20394
+ if (c === "+" || c === "-" || c === "*" || c === "/" || c === "%" || c === "^" || c === "?" || c === ":" || c === ".") {
20395
+ this.current = this.newToken(TOP, c);
20396
+ } else if (c === "∙" || c === "•") {
20397
+ this.current = this.newToken(TOP, "*");
20398
+ } else if (c === ">") {
20399
+ if (this.expression.charAt(this.pos + 1) === "=") {
20400
+ this.current = this.newToken(TOP, ">=");
20401
+ this.pos++;
20402
+ } else {
20403
+ this.current = this.newToken(TOP, ">");
20404
+ }
20405
+ } else if (c === "<") {
20406
+ if (this.expression.charAt(this.pos + 1) === "=") {
20407
+ this.current = this.newToken(TOP, "<=");
20408
+ this.pos++;
20409
+ } else {
20410
+ this.current = this.newToken(TOP, "<");
20411
+ }
20412
+ } else if (c === "|") {
20413
+ if (this.expression.charAt(this.pos + 1) === "|") {
20414
+ this.current = this.newToken(TOP, "||");
20415
+ this.pos++;
20416
+ } else {
20417
+ return false;
20418
+ }
20419
+ } else if (c === "=") {
20420
+ if (this.expression.charAt(this.pos + 1) === "=") {
20421
+ this.current = this.newToken(TOP, "==");
20422
+ this.pos++;
20423
+ } else {
20424
+ this.current = this.newToken(TOP, c);
20425
+ }
20426
+ } else if (c === "!") {
20427
+ if (this.expression.charAt(this.pos + 1) === "=") {
20428
+ this.current = this.newToken(TOP, "!=");
20429
+ this.pos++;
20430
+ } else {
20431
+ this.current = this.newToken(TOP, c);
20432
+ }
20433
+ } else {
20434
+ return false;
20435
+ }
20436
+ this.pos++;
20437
+ if (this.isOperatorEnabled(this.current.value)) {
20438
+ return true;
20439
+ } else {
20440
+ this.pos = startPos;
20441
+ return false;
20442
+ }
20443
+ };
20444
+ TokenStream.prototype.isOperatorEnabled = function(op) {
20445
+ return this.parser.isOperatorEnabled(op);
20446
+ };
20447
+ TokenStream.prototype.getCoordinates = function() {
20448
+ var line = 0;
20449
+ var column;
20450
+ var newline = -1;
20451
+ do {
20452
+ line++;
20453
+ column = this.pos - newline;
20454
+ newline = this.expression.indexOf("\n", newline + 1);
20455
+ } while (newline >= 0 && newline < this.pos);
20456
+ return {
20457
+ line,
20458
+ column
20459
+ };
20460
+ };
20461
+ TokenStream.prototype.parseError = function(msg) {
20462
+ var coords = this.getCoordinates();
20463
+ throw new Error("parse error [" + coords.line + ":" + coords.column + "]: " + msg);
20464
+ };
20465
+ function ParserState(parser, tokenStream, options) {
20466
+ this.parser = parser;
20467
+ this.tokens = tokenStream;
20468
+ this.current = null;
20469
+ this.nextToken = null;
20470
+ this.next();
20471
+ this.savedCurrent = null;
20472
+ this.savedNextToken = null;
20473
+ this.allowMemberAccess = options.allowMemberAccess !== false;
20474
+ }
20475
+ ParserState.prototype.next = function() {
20476
+ this.current = this.nextToken;
20477
+ return this.nextToken = this.tokens.next();
20478
+ };
20479
+ ParserState.prototype.tokenMatches = function(token, value) {
20480
+ if (typeof value === "undefined") {
20481
+ return true;
20482
+ } else if (Array.isArray(value)) {
20483
+ return contains(value, token.value);
20484
+ } else if (typeof value === "function") {
20485
+ return value(token);
20486
+ } else {
20487
+ return token.value === value;
20488
+ }
20489
+ };
20490
+ ParserState.prototype.save = function() {
20491
+ this.savedCurrent = this.current;
20492
+ this.savedNextToken = this.nextToken;
20493
+ this.tokens.save();
20494
+ };
20495
+ ParserState.prototype.restore = function() {
20496
+ this.tokens.restore();
20497
+ this.current = this.savedCurrent;
20498
+ this.nextToken = this.savedNextToken;
20499
+ };
20500
+ ParserState.prototype.accept = function(type, value) {
20501
+ if (this.nextToken.type === type && this.tokenMatches(this.nextToken, value)) {
20502
+ this.next();
20503
+ return true;
20504
+ }
20505
+ return false;
20506
+ };
20507
+ ParserState.prototype.expect = function(type, value) {
20508
+ if (!this.accept(type, value)) {
20509
+ var coords = this.tokens.getCoordinates();
20510
+ throw new Error("parse error [" + coords.line + ":" + coords.column + "]: Expected " + (value || type));
20511
+ }
20512
+ };
20513
+ ParserState.prototype.parseAtom = function(instr) {
20514
+ var unaryOps = this.tokens.unaryOps;
20515
+ function isPrefixOperator(token) {
20516
+ return token.value in unaryOps;
20517
+ }
20518
+ if (this.accept(TNAME) || this.accept(TOP, isPrefixOperator)) {
20519
+ instr.push(new Instruction(IVAR, this.current.value));
20520
+ } else if (this.accept(TNUMBER)) {
20521
+ instr.push(new Instruction(INUMBER, this.current.value));
20522
+ } else if (this.accept(TSTRING)) {
20523
+ instr.push(new Instruction(INUMBER, this.current.value));
20524
+ } else if (this.accept(TPAREN, "(")) {
20525
+ this.parseExpression(instr);
20526
+ this.expect(TPAREN, ")");
20527
+ } else if (this.accept(TBRACKET, "[")) {
20528
+ if (this.accept(TBRACKET, "]")) {
20529
+ instr.push(new Instruction(IARRAY, 0));
20530
+ } else {
20531
+ var argCount = this.parseArrayList(instr);
20532
+ instr.push(new Instruction(IARRAY, argCount));
20533
+ }
20534
+ } else {
20535
+ throw new Error("unexpected " + this.nextToken);
20536
+ }
20537
+ };
20538
+ ParserState.prototype.parseExpression = function(instr) {
20539
+ var exprInstr = [];
20540
+ if (this.parseUntilEndStatement(instr, exprInstr)) {
20541
+ return;
20542
+ }
20543
+ this.parseVariableAssignmentExpression(exprInstr);
20544
+ if (this.parseUntilEndStatement(instr, exprInstr)) {
20545
+ return;
20546
+ }
20547
+ this.pushExpression(instr, exprInstr);
20548
+ };
20549
+ ParserState.prototype.pushExpression = function(instr, exprInstr) {
20550
+ for (var i = 0, len = exprInstr.length; i < len; i++) {
20551
+ instr.push(exprInstr[i]);
20552
+ }
20553
+ };
20554
+ ParserState.prototype.parseUntilEndStatement = function(instr, exprInstr) {
20555
+ if (!this.accept(TSEMICOLON)) return false;
20556
+ if (this.nextToken && this.nextToken.type !== TEOF && !(this.nextToken.type === TPAREN && this.nextToken.value === ")")) {
20557
+ exprInstr.push(new Instruction(IENDSTATEMENT));
20558
+ }
20559
+ if (this.nextToken.type !== TEOF) {
20560
+ this.parseExpression(exprInstr);
20561
+ }
20562
+ instr.push(new Instruction(IEXPR, exprInstr));
20563
+ return true;
20564
+ };
20565
+ ParserState.prototype.parseArrayList = function(instr) {
20566
+ var argCount = 0;
20567
+ while (!this.accept(TBRACKET, "]")) {
20568
+ this.parseExpression(instr);
20569
+ ++argCount;
20570
+ while (this.accept(TCOMMA)) {
20571
+ this.parseExpression(instr);
20572
+ ++argCount;
20573
+ }
20574
+ }
20575
+ return argCount;
20576
+ };
20577
+ ParserState.prototype.parseVariableAssignmentExpression = function(instr) {
20578
+ this.parseConditionalExpression(instr);
20579
+ while (this.accept(TOP, "=")) {
20580
+ var varName = instr.pop();
20581
+ var varValue = [];
20582
+ var lastInstrIndex = instr.length - 1;
20583
+ if (varName.type === IFUNCALL) {
20584
+ if (!this.tokens.isOperatorEnabled("()=")) {
20585
+ throw new Error("function definition is not permitted");
20586
+ }
20587
+ for (var i = 0, len = varName.value + 1; i < len; i++) {
20588
+ var index2 = lastInstrIndex - i;
20589
+ if (instr[index2].type === IVAR) {
20590
+ instr[index2] = new Instruction(IVARNAME, instr[index2].value);
20591
+ }
20592
+ }
20593
+ this.parseVariableAssignmentExpression(varValue);
20594
+ instr.push(new Instruction(IEXPR, varValue));
20595
+ instr.push(new Instruction(IFUNDEF, varName.value));
20596
+ continue;
20597
+ }
20598
+ if (varName.type !== IVAR && varName.type !== IMEMBER) {
20599
+ throw new Error("expected variable for assignment");
20600
+ }
20601
+ this.parseVariableAssignmentExpression(varValue);
20602
+ instr.push(new Instruction(IVARNAME, varName.value));
20603
+ instr.push(new Instruction(IEXPR, varValue));
20604
+ instr.push(binaryInstruction("="));
20605
+ }
20606
+ };
20607
+ ParserState.prototype.parseConditionalExpression = function(instr) {
20608
+ this.parseOrExpression(instr);
20609
+ while (this.accept(TOP, "?")) {
20610
+ var trueBranch = [];
20611
+ var falseBranch = [];
20612
+ this.parseConditionalExpression(trueBranch);
20613
+ this.expect(TOP, ":");
20614
+ this.parseConditionalExpression(falseBranch);
20615
+ instr.push(new Instruction(IEXPR, trueBranch));
20616
+ instr.push(new Instruction(IEXPR, falseBranch));
20617
+ instr.push(ternaryInstruction("?"));
20618
+ }
20619
+ };
20620
+ ParserState.prototype.parseOrExpression = function(instr) {
20621
+ this.parseAndExpression(instr);
20622
+ while (this.accept(TOP, "or")) {
20623
+ var falseBranch = [];
20624
+ this.parseAndExpression(falseBranch);
20625
+ instr.push(new Instruction(IEXPR, falseBranch));
20626
+ instr.push(binaryInstruction("or"));
20627
+ }
20628
+ };
20629
+ ParserState.prototype.parseAndExpression = function(instr) {
20630
+ this.parseComparison(instr);
20631
+ while (this.accept(TOP, "and")) {
20632
+ var trueBranch = [];
20633
+ this.parseComparison(trueBranch);
20634
+ instr.push(new Instruction(IEXPR, trueBranch));
20635
+ instr.push(binaryInstruction("and"));
20636
+ }
20637
+ };
20638
+ var COMPARISON_OPERATORS = ["==", "!=", "<", "<=", ">=", ">", "in"];
20639
+ ParserState.prototype.parseComparison = function(instr) {
20640
+ this.parseAddSub(instr);
20641
+ while (this.accept(TOP, COMPARISON_OPERATORS)) {
20642
+ var op = this.current;
20643
+ this.parseAddSub(instr);
20644
+ instr.push(binaryInstruction(op.value));
20645
+ }
20646
+ };
20647
+ var ADD_SUB_OPERATORS = ["+", "-", "||"];
20648
+ ParserState.prototype.parseAddSub = function(instr) {
20649
+ this.parseTerm(instr);
20650
+ while (this.accept(TOP, ADD_SUB_OPERATORS)) {
20651
+ var op = this.current;
20652
+ this.parseTerm(instr);
20653
+ instr.push(binaryInstruction(op.value));
20654
+ }
20655
+ };
20656
+ var TERM_OPERATORS = ["*", "/", "%"];
20657
+ ParserState.prototype.parseTerm = function(instr) {
20658
+ this.parseFactor(instr);
20659
+ while (this.accept(TOP, TERM_OPERATORS)) {
20660
+ var op = this.current;
20661
+ this.parseFactor(instr);
20662
+ instr.push(binaryInstruction(op.value));
20663
+ }
20664
+ };
20665
+ ParserState.prototype.parseFactor = function(instr) {
20666
+ var unaryOps = this.tokens.unaryOps;
20667
+ function isPrefixOperator(token) {
20668
+ return token.value in unaryOps;
20669
+ }
20670
+ this.save();
20671
+ if (this.accept(TOP, isPrefixOperator)) {
20672
+ if (this.current.value !== "-" && this.current.value !== "+") {
20673
+ if (this.nextToken.type === TPAREN && this.nextToken.value === "(") {
20674
+ this.restore();
20675
+ this.parseExponential(instr);
20676
+ return;
20677
+ } else if (this.nextToken.type === TSEMICOLON || this.nextToken.type === TCOMMA || this.nextToken.type === TEOF || this.nextToken.type === TPAREN && this.nextToken.value === ")") {
20678
+ this.restore();
20679
+ this.parseAtom(instr);
20680
+ return;
20681
+ }
20682
+ }
20683
+ var op = this.current;
20684
+ this.parseFactor(instr);
20685
+ instr.push(unaryInstruction(op.value));
20686
+ } else {
20687
+ this.parseExponential(instr);
20688
+ }
20689
+ };
20690
+ ParserState.prototype.parseExponential = function(instr) {
20691
+ this.parsePostfixExpression(instr);
20692
+ while (this.accept(TOP, "^")) {
20693
+ this.parseFactor(instr);
20694
+ instr.push(binaryInstruction("^"));
20695
+ }
20696
+ };
20697
+ ParserState.prototype.parsePostfixExpression = function(instr) {
20698
+ this.parseFunctionCall(instr);
20699
+ while (this.accept(TOP, "!")) {
20700
+ instr.push(unaryInstruction("!"));
20701
+ }
20702
+ };
20703
+ ParserState.prototype.parseFunctionCall = function(instr) {
20704
+ var unaryOps = this.tokens.unaryOps;
20705
+ function isPrefixOperator(token) {
20706
+ return token.value in unaryOps;
20707
+ }
20708
+ if (this.accept(TOP, isPrefixOperator)) {
20709
+ var op = this.current;
20710
+ this.parseAtom(instr);
20711
+ instr.push(unaryInstruction(op.value));
20712
+ } else {
20713
+ this.parseMemberExpression(instr);
20714
+ while (this.accept(TPAREN, "(")) {
20715
+ if (this.accept(TPAREN, ")")) {
20716
+ instr.push(new Instruction(IFUNCALL, 0));
20717
+ } else {
20718
+ var argCount = this.parseArgumentList(instr);
20719
+ instr.push(new Instruction(IFUNCALL, argCount));
20720
+ }
20721
+ }
20722
+ }
20723
+ };
20724
+ ParserState.prototype.parseArgumentList = function(instr) {
20725
+ var argCount = 0;
20726
+ while (!this.accept(TPAREN, ")")) {
20727
+ this.parseExpression(instr);
20728
+ ++argCount;
20729
+ while (this.accept(TCOMMA)) {
20730
+ this.parseExpression(instr);
20731
+ ++argCount;
20732
+ }
20733
+ }
20734
+ return argCount;
20735
+ };
20736
+ ParserState.prototype.parseMemberExpression = function(instr) {
20737
+ this.parseAtom(instr);
20738
+ while (this.accept(TOP, ".") || this.accept(TBRACKET, "[")) {
20739
+ var op = this.current;
20740
+ if (op.value === ".") {
20741
+ if (!this.allowMemberAccess) {
20742
+ throw new Error('unexpected ".", member access is not permitted');
20743
+ }
20744
+ this.expect(TNAME);
20745
+ instr.push(new Instruction(IMEMBER, this.current.value));
20746
+ } else if (op.value === "[") {
20747
+ if (!this.tokens.isOperatorEnabled("[")) {
20748
+ throw new Error('unexpected "[]", arrays are disabled');
20749
+ }
20750
+ this.parseExpression(instr);
20751
+ this.expect(TBRACKET, "]");
20752
+ instr.push(binaryInstruction("["));
20753
+ } else {
20754
+ throw new Error("unexpected symbol: " + op.value);
20755
+ }
20756
+ }
20757
+ };
20758
+ function add(a, b) {
20759
+ return Number(a) + Number(b);
20760
+ }
20761
+ function sub(a, b) {
20762
+ return a - b;
20763
+ }
20764
+ function mul(a, b) {
20765
+ return a * b;
20766
+ }
20767
+ function div(a, b) {
20768
+ return a / b;
20769
+ }
20770
+ function mod(a, b) {
20771
+ return a % b;
20772
+ }
20773
+ function concat(a, b) {
20774
+ if (Array.isArray(a) && Array.isArray(b)) {
20775
+ return a.concat(b);
20776
+ }
20777
+ return "" + a + b;
20778
+ }
20779
+ function equal(a, b) {
20780
+ return a === b;
20781
+ }
20782
+ function notEqual(a, b) {
20783
+ return a !== b;
20784
+ }
20785
+ function greaterThan(a, b) {
20786
+ return a > b;
20787
+ }
20788
+ function lessThan(a, b) {
20789
+ return a < b;
20790
+ }
20791
+ function greaterThanEqual(a, b) {
20792
+ return a >= b;
20793
+ }
20794
+ function lessThanEqual(a, b) {
20795
+ return a <= b;
20796
+ }
20797
+ function andOperator(a, b) {
20798
+ return Boolean(a && b);
20799
+ }
20800
+ function orOperator(a, b) {
20801
+ return Boolean(a || b);
20802
+ }
20803
+ function inOperator(a, b) {
20804
+ return contains(b, a);
20805
+ }
20806
+ function sinh(a) {
20807
+ return (Math.exp(a) - Math.exp(-a)) / 2;
20808
+ }
20809
+ function cosh(a) {
20810
+ return (Math.exp(a) + Math.exp(-a)) / 2;
20811
+ }
20812
+ function tanh(a) {
20813
+ if (a === Infinity) return 1;
20814
+ if (a === -Infinity) return -1;
20815
+ return (Math.exp(a) - Math.exp(-a)) / (Math.exp(a) + Math.exp(-a));
20816
+ }
20817
+ function asinh(a) {
20818
+ if (a === -Infinity) return a;
20819
+ return Math.log(a + Math.sqrt(a * a + 1));
20820
+ }
20821
+ function acosh(a) {
20822
+ return Math.log(a + Math.sqrt(a * a - 1));
20823
+ }
20824
+ function atanh(a) {
20825
+ return Math.log((1 + a) / (1 - a)) / 2;
20826
+ }
20827
+ function log10(a) {
20828
+ return Math.log(a) * Math.LOG10E;
20829
+ }
20830
+ function neg(a) {
20831
+ return -a;
20832
+ }
20833
+ function not(a) {
20834
+ return !a;
20835
+ }
20836
+ function trunc(a) {
20837
+ return a < 0 ? Math.ceil(a) : Math.floor(a);
20838
+ }
20839
+ function random(a) {
20840
+ return Math.random() * (a || 1);
20841
+ }
20842
+ function factorial(a) {
20843
+ return gamma(a + 1);
20844
+ }
20845
+ function isInteger(value) {
20846
+ return isFinite(value) && value === Math.round(value);
20847
+ }
20848
+ var GAMMA_G = 4.7421875;
20849
+ var GAMMA_P = [
20850
+ 0.9999999999999971,
20851
+ 57.15623566586292,
20852
+ -59.59796035547549,
20853
+ 14.136097974741746,
20854
+ -0.4919138160976202,
20855
+ 3399464998481189e-20,
20856
+ 4652362892704858e-20,
20857
+ -9837447530487956e-20,
20858
+ 1580887032249125e-19,
20859
+ -21026444172410488e-20,
20860
+ 21743961811521265e-20,
20861
+ -1643181065367639e-19,
20862
+ 8441822398385275e-20,
20863
+ -26190838401581408e-21,
20864
+ 36899182659531625e-22
20865
+ ];
20866
+ function gamma(n) {
20867
+ var t, x2;
20868
+ if (isInteger(n)) {
20869
+ if (n <= 0) {
20870
+ return isFinite(n) ? Infinity : NaN;
20871
+ }
20872
+ if (n > 171) {
20873
+ return Infinity;
20874
+ }
20875
+ var value = n - 2;
20876
+ var res = n - 1;
20877
+ while (value > 1) {
20878
+ res *= value;
20879
+ value--;
20880
+ }
20881
+ if (res === 0) {
20882
+ res = 1;
20883
+ }
20884
+ return res;
20885
+ }
20886
+ if (n < 0.5) {
20887
+ return Math.PI / (Math.sin(Math.PI * n) * gamma(1 - n));
20888
+ }
20889
+ if (n >= 171.35) {
20890
+ return Infinity;
20891
+ }
20892
+ if (n > 85) {
20893
+ var twoN = n * n;
20894
+ var threeN = twoN * n;
20895
+ var fourN = threeN * n;
20896
+ var fiveN = fourN * n;
20897
+ return Math.sqrt(2 * Math.PI / n) * Math.pow(n / Math.E, n) * (1 + 1 / (12 * n) + 1 / (288 * twoN) - 139 / (51840 * threeN) - 571 / (2488320 * fourN) + 163879 / (209018880 * fiveN) + 5246819 / (75246796800 * fiveN * n));
20898
+ }
20899
+ --n;
20900
+ x2 = GAMMA_P[0];
20901
+ for (var i = 1; i < GAMMA_P.length; ++i) {
20902
+ x2 += GAMMA_P[i] / (n + i);
20903
+ }
20904
+ t = n + GAMMA_G + 0.5;
20905
+ return Math.sqrt(2 * Math.PI) * Math.pow(t, n + 0.5) * Math.exp(-t) * x2;
20906
+ }
20907
+ function stringOrArrayLength(s) {
20908
+ if (Array.isArray(s)) {
20909
+ return s.length;
20910
+ }
20911
+ return String(s).length;
20912
+ }
20913
+ function hypot() {
20914
+ var sum = 0;
20915
+ var larg = 0;
20916
+ for (var i = 0; i < arguments.length; i++) {
20917
+ var arg = Math.abs(arguments[i]);
20918
+ var div2;
20919
+ if (larg < arg) {
20920
+ div2 = larg / arg;
20921
+ sum = sum * div2 * div2 + 1;
20922
+ larg = arg;
20923
+ } else if (arg > 0) {
20924
+ div2 = arg / larg;
20925
+ sum += div2 * div2;
20926
+ } else {
20927
+ sum += arg;
20928
+ }
20929
+ }
20930
+ return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
20931
+ }
20932
+ function condition(cond, yep, nope) {
20933
+ return cond ? yep : nope;
20934
+ }
20935
+ function roundTo(value, exp) {
20936
+ if (typeof exp === "undefined" || +exp === 0) {
20937
+ return Math.round(value);
20938
+ }
20939
+ value = +value;
20940
+ exp = -+exp;
20941
+ if (isNaN(value) || !(typeof exp === "number" && exp % 1 === 0)) {
20942
+ return NaN;
20943
+ }
20944
+ value = value.toString().split("e");
20945
+ value = Math.round(+(value[0] + "e" + (value[1] ? +value[1] - exp : -exp)));
20946
+ value = value.toString().split("e");
20947
+ return +(value[0] + "e" + (value[1] ? +value[1] + exp : exp));
20948
+ }
20949
+ function setVar(name, value, variables) {
20950
+ if (variables) variables[name] = value;
20951
+ return value;
20952
+ }
20953
+ function arrayIndex(array2, index2) {
20954
+ return array2[index2 | 0];
20955
+ }
20956
+ function max(array2) {
20957
+ if (arguments.length === 1 && Array.isArray(array2)) {
20958
+ return Math.max.apply(Math, array2);
20959
+ } else {
20960
+ return Math.max.apply(Math, arguments);
20961
+ }
20962
+ }
20963
+ function min(array2) {
20964
+ if (arguments.length === 1 && Array.isArray(array2)) {
20965
+ return Math.min.apply(Math, array2);
20966
+ } else {
20967
+ return Math.min.apply(Math, arguments);
20968
+ }
20969
+ }
20970
+ function arrayMap(f, a) {
20971
+ if (typeof f !== "function") {
20972
+ throw new Error("First argument to map is not a function");
20973
+ }
20974
+ if (!Array.isArray(a)) {
20975
+ throw new Error("Second argument to map is not an array");
20976
+ }
20977
+ return a.map(function(x2, i) {
20978
+ return f(x2, i);
20979
+ });
20980
+ }
20981
+ function arrayFold(f, init, a) {
20982
+ if (typeof f !== "function") {
20983
+ throw new Error("First argument to fold is not a function");
20984
+ }
20985
+ if (!Array.isArray(a)) {
20986
+ throw new Error("Second argument to fold is not an array");
20987
+ }
20988
+ return a.reduce(function(acc, x2, i) {
20989
+ return f(acc, x2, i);
20990
+ }, init);
20991
+ }
20992
+ function arrayFilter(f, a) {
20993
+ if (typeof f !== "function") {
20994
+ throw new Error("First argument to filter is not a function");
20995
+ }
20996
+ if (!Array.isArray(a)) {
20997
+ throw new Error("Second argument to filter is not an array");
20998
+ }
20999
+ return a.filter(function(x2, i) {
21000
+ return f(x2, i);
21001
+ });
21002
+ }
21003
+ function stringOrArrayIndexOf(target, s) {
21004
+ if (!(Array.isArray(s) || typeof s === "string")) {
21005
+ throw new Error("Second argument to indexOf is not a string or array");
21006
+ }
21007
+ return s.indexOf(target);
21008
+ }
21009
+ function arrayJoin(sep, a) {
21010
+ if (!Array.isArray(a)) {
21011
+ throw new Error("Second argument to join is not an array");
21012
+ }
21013
+ return a.join(sep);
21014
+ }
21015
+ function sign(x2) {
21016
+ return (x2 > 0) - (x2 < 0) || +x2;
21017
+ }
21018
+ var ONE_THIRD = 1 / 3;
21019
+ function cbrt(x2) {
21020
+ return x2 < 0 ? -Math.pow(-x2, ONE_THIRD) : Math.pow(x2, ONE_THIRD);
21021
+ }
21022
+ function expm1(x2) {
21023
+ return Math.exp(x2) - 1;
21024
+ }
21025
+ function log1p(x2) {
21026
+ return Math.log(1 + x2);
21027
+ }
21028
+ function log2(x2) {
21029
+ return Math.log(x2) / Math.LN2;
21030
+ }
21031
+ function Parser(options) {
21032
+ this.options = options || {};
21033
+ this.unaryOps = {
21034
+ sin: Math.sin,
21035
+ cos: Math.cos,
21036
+ tan: Math.tan,
21037
+ asin: Math.asin,
21038
+ acos: Math.acos,
21039
+ atan: Math.atan,
21040
+ sinh: Math.sinh || sinh,
21041
+ cosh: Math.cosh || cosh,
21042
+ tanh: Math.tanh || tanh,
21043
+ asinh: Math.asinh || asinh,
21044
+ acosh: Math.acosh || acosh,
21045
+ atanh: Math.atanh || atanh,
21046
+ sqrt: Math.sqrt,
21047
+ cbrt: Math.cbrt || cbrt,
21048
+ log: Math.log,
21049
+ log2: Math.log2 || log2,
21050
+ ln: Math.log,
21051
+ lg: Math.log10 || log10,
21052
+ log10: Math.log10 || log10,
21053
+ expm1: Math.expm1 || expm1,
21054
+ log1p: Math.log1p || log1p,
21055
+ abs: Math.abs,
21056
+ ceil: Math.ceil,
21057
+ floor: Math.floor,
21058
+ round: Math.round,
21059
+ trunc: Math.trunc || trunc,
21060
+ "-": neg,
21061
+ "+": Number,
21062
+ exp: Math.exp,
21063
+ not,
21064
+ length: stringOrArrayLength,
21065
+ "!": factorial,
21066
+ sign: Math.sign || sign
21067
+ };
21068
+ this.binaryOps = {
21069
+ "+": add,
21070
+ "-": sub,
21071
+ "*": mul,
21072
+ "/": div,
21073
+ "%": mod,
21074
+ "^": Math.pow,
21075
+ "||": concat,
21076
+ "==": equal,
21077
+ "!=": notEqual,
21078
+ ">": greaterThan,
21079
+ "<": lessThan,
21080
+ ">=": greaterThanEqual,
21081
+ "<=": lessThanEqual,
21082
+ and: andOperator,
21083
+ or: orOperator,
21084
+ "in": inOperator,
21085
+ "=": setVar,
21086
+ "[": arrayIndex
21087
+ };
21088
+ this.ternaryOps = {
21089
+ "?": condition
21090
+ };
21091
+ this.functions = {
21092
+ random,
21093
+ fac: factorial,
21094
+ min,
21095
+ max,
21096
+ hypot: Math.hypot || hypot,
21097
+ pyt: Math.hypot || hypot,
21098
+ // backward compat
21099
+ pow: Math.pow,
21100
+ atan2: Math.atan2,
21101
+ "if": condition,
21102
+ gamma,
21103
+ roundTo,
21104
+ map: arrayMap,
21105
+ fold: arrayFold,
21106
+ filter: arrayFilter,
21107
+ indexOf: stringOrArrayIndexOf,
21108
+ join: arrayJoin
21109
+ };
21110
+ this.consts = {
21111
+ E: Math.E,
21112
+ PI: Math.PI,
21113
+ "true": true,
21114
+ "false": false
21115
+ };
21116
+ }
21117
+ Parser.prototype.parse = function(expr) {
21118
+ var instr = [];
21119
+ var parserState = new ParserState(
21120
+ this,
21121
+ new TokenStream(this, expr),
21122
+ { allowMemberAccess: this.options.allowMemberAccess }
21123
+ );
21124
+ parserState.parseExpression(instr);
21125
+ parserState.expect(TEOF, "EOF");
21126
+ return new Expression(instr, this);
21127
+ };
21128
+ Parser.prototype.evaluate = function(expr, variables) {
21129
+ return this.parse(expr).evaluate(variables);
21130
+ };
21131
+ var sharedParser = new Parser();
21132
+ Parser.parse = function(expr) {
21133
+ return sharedParser.parse(expr);
21134
+ };
21135
+ Parser.evaluate = function(expr, variables) {
21136
+ return sharedParser.parse(expr).evaluate(variables);
21137
+ };
21138
+ var optionNameMap = {
21139
+ "+": "add",
21140
+ "-": "subtract",
21141
+ "*": "multiply",
21142
+ "/": "divide",
21143
+ "%": "remainder",
21144
+ "^": "power",
21145
+ "!": "factorial",
21146
+ "<": "comparison",
21147
+ ">": "comparison",
21148
+ "<=": "comparison",
21149
+ ">=": "comparison",
21150
+ "==": "comparison",
21151
+ "!=": "comparison",
21152
+ "||": "concatenate",
21153
+ "and": "logical",
21154
+ "or": "logical",
21155
+ "not": "logical",
21156
+ "?": "conditional",
21157
+ ":": "conditional",
21158
+ "=": "assignment",
21159
+ "[": "array",
21160
+ "()=": "fndef"
21161
+ };
21162
+ function getOptionName(op) {
21163
+ return optionNameMap.hasOwnProperty(op) ? optionNameMap[op] : op;
21164
+ }
21165
+ Parser.prototype.isOperatorEnabled = function(op) {
21166
+ var optionName = getOptionName(op);
21167
+ var operators = this.options.operators || {};
21168
+ return !(optionName in operators) || !!operators[optionName];
21169
+ };
19566
21170
  const _hoisted_1$t = {
19567
21171
  key: 0,
19568
21172
  class: "lew-label-box"
@@ -19579,7 +21183,6 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
19579
21183
  const emit = __emit;
19580
21184
  const formSchema = inject("formSchema", ref(null));
19581
21185
  const formData = inject("formData", ref({}));
19582
- const formUpdateKey = inject("formUpdateKey", ref(0));
19583
21186
  const asMap = {
19584
21187
  "input": LewInput,
19585
21188
  "textarea": LewTextarea,
@@ -19676,38 +21279,22 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
19676
21279
  justifyContent: direction === "x" && between ? "flex-end" : "flex-start"
19677
21280
  };
19678
21281
  });
19679
- const getVisible = computed(() => {
19680
- if (typeof props.visible === "function") {
19681
- return props.visible(formData.value);
19682
- }
19683
- return props.visible;
19684
- });
19685
- const getDisabled = computed(() => {
19686
- if (typeof props.disabled === "function") {
19687
- return props.disabled(formData.value);
19688
- }
19689
- return props.disabled;
19690
- });
19691
- const getReadonly = computed(() => {
19692
- if (typeof props.readonly === "function") {
19693
- return props.readonly(formData.value);
19694
- }
19695
- return props.readonly;
19696
- });
19697
21282
  const getDynamicProps = computed(() => {
19698
21283
  if (typeof props.props === "function") {
19699
21284
  return props.props(formData.value);
19700
21285
  }
19701
21286
  return props.props;
19702
21287
  });
19703
- watchEffect(() => {
19704
- formUpdateKey.value;
19705
- formData.value;
19706
- });
21288
+ function runFunc(func) {
21289
+ if (typeof func === "function") {
21290
+ return func(formData.value);
21291
+ }
21292
+ return func;
21293
+ }
19707
21294
  __expose({ validate, setError, setIgnoreValidate });
19708
21295
  return (_ctx, _cache) => {
19709
21296
  const _directive_tooltip = resolveDirective("tooltip");
19710
- return unref(getVisible) ? (openBlock(), createElementBlock("div", {
21297
+ return runFunc(_ctx.visible) ? (openBlock(), createElementBlock("div", {
19711
21298
  key: 0,
19712
21299
  ref_key: "formItemRef",
19713
21300
  ref: formItemRef,
@@ -19747,8 +21334,8 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
19747
21334
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event)
19748
21335
  }, {
19749
21336
  size: _ctx.size,
19750
- readonly: unref(getReadonly),
19751
- disabled: unref(getDisabled),
21337
+ readonly: runFunc(_ctx.readonly),
21338
+ disabled: runFunc(_ctx.disabled),
19752
21339
  ...unref(getDynamicProps),
19753
21340
  width: _ctx.as && ["input-number", "tabs", "button"].includes(_ctx.as) ? unref(getDynamicProps).width : "100%",
19754
21341
  popoverWidth: _ctx.as && ["select"].includes(_ctx.as) ? "100%" : void 0
@@ -19769,7 +21356,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
19769
21356
  };
19770
21357
  }
19771
21358
  });
19772
- const LewFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-83ae1c96"]]);
21359
+ const LewFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-32907163"]]);
19773
21360
  const _sfc_main$E = /* @__PURE__ */ defineComponent({
19774
21361
  __name: "LewForm",
19775
21362
  props: formProps,
@@ -19780,11 +21367,27 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19780
21367
  const formMap = ref({});
19781
21368
  const formLabelRef = ref();
19782
21369
  const autoLabelWidth = ref(0);
19783
- const componentOptions = cloneDeep(props.options) || [];
21370
+ const componentOptions = ref(props.options);
19784
21371
  const formItemRefMap = ref({});
19785
- const formUpdateKey = ref(0);
21372
+ const parser = new Parser();
21373
+ function normalizeProp(value) {
21374
+ return (formData) => {
21375
+ if (typeof value === "function") {
21376
+ return value(formData);
21377
+ }
21378
+ if (typeof value === "string") {
21379
+ try {
21380
+ console.log(formData);
21381
+ return Boolean(parser.evaluate(value, formData));
21382
+ } catch {
21383
+ return false;
21384
+ }
21385
+ }
21386
+ return Boolean(value);
21387
+ };
21388
+ }
19786
21389
  const formSchema = computed(() => {
19787
- const schemaMap = componentOptions.reduce((acc, item) => {
21390
+ const schemaMap = componentOptions.value.reduce((acc, item) => {
19788
21391
  if (item.field && item.rule) {
19789
21392
  acc[item.field] = typeof item.rule === "string" ? new Function("Yup", `return ${item.rule}`)(Yup) : item.rule;
19790
21393
  }
@@ -19798,7 +21401,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19798
21401
  }));
19799
21402
  function getForm() {
19800
21403
  let formData = formatFormByMap(toRaw(formMap.value));
19801
- componentOptions.forEach((item) => {
21404
+ componentOptions.value.forEach((item) => {
19802
21405
  if (item.outputFormat && item.field && formData[item.field]) {
19803
21406
  const _value = item.outputFormat({ item, value: formData[item.field] });
19804
21407
  if (typeof _value === "object" && !Array.isArray(_value)) {
@@ -19812,7 +21415,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19812
21415
  return formData;
19813
21416
  }
19814
21417
  function setForm(value = {}) {
19815
- componentOptions.forEach((item) => {
21418
+ componentOptions.value.forEach((item) => {
19816
21419
  if (!item.field)
19817
21420
  return;
19818
21421
  let v = retrieveNestedFieldValue(value, item.field);
@@ -19824,7 +21427,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19824
21427
  });
19825
21428
  }
19826
21429
  function resetError() {
19827
- componentOptions.forEach((item) => item.field && resetFieldError(item.field));
21430
+ componentOptions.value.forEach((item) => item.field && resetFieldError(item.field));
19828
21431
  }
19829
21432
  function resetFieldError(field, ignore = false) {
19830
21433
  const ref2 = formItemRefMap.value[field];
@@ -19852,18 +21455,10 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19852
21455
  provide("formMethods", props.formMethods);
19853
21456
  provide("formSchema", formSchema);
19854
21457
  provide("formData", formMap);
19855
- provide("formUpdateKey", formUpdateKey);
19856
21458
  watch(
19857
21459
  () => props.size,
19858
21460
  () => nextTick(() => autoLabelWidth.value = formLabelRef.value?.getWidth())
19859
21461
  );
19860
- watch(
19861
- () => formMap.value,
19862
- () => {
19863
- formUpdateKey.value++;
19864
- },
19865
- { deep: true }
19866
- );
19867
21462
  const GAP_MAP = {
19868
21463
  small: "24px",
19869
21464
  medium: "26px",
@@ -19906,9 +21501,10 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19906
21501
  direction: _ctx.direction,
19907
21502
  size: _ctx.size,
19908
21503
  labelWidth: unref(getLabelWidth),
19909
- disabled: _ctx.disabled,
19910
- readonly: _ctx.readonly,
19911
21504
  ...item,
21505
+ disabled: item.disabled ? normalizeProp(item.disabled) : () => Boolean(_ctx.disabled),
21506
+ readonly: item.readonly ? normalizeProp(item.readonly) : () => Boolean(_ctx.readonly),
21507
+ visible: item.visible === void 0 ? () => true : normalizeProp(item.visible),
19912
21508
  required: unref(getFormItemRequired)(item)
19913
21509
  }, {
19914
21510
  onChange: _cache[0] || (_cache[0] = () => emit("change", getForm()))
@@ -19918,7 +21514,7 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
19918
21514
  };
19919
21515
  }
19920
21516
  });
19921
- const LewForm = /* @__PURE__ */ _export_sfc(_sfc_main$E, [["__scopeId", "data-v-2eb97031"]]);
21517
+ const LewForm = /* @__PURE__ */ _export_sfc(_sfc_main$E, [["__scopeId", "data-v-2babc77a"]]);
19922
21518
  const inputEmits = {
19923
21519
  change: (value) => value,
19924
21520
  input: (value) => value,
@@ -20693,11 +22289,11 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
20693
22289
  }
20694
22290
  function plus() {
20695
22291
  lewInputRef.value.stepUp();
20696
- modelValue.value = lewInputRef.value.value;
22292
+ modelValue.value = Number(lewInputRef.value.value);
20697
22293
  longClickTimer.value = setTimeout(() => {
20698
22294
  longClickTimer.value = setInterval(() => {
20699
22295
  lewInputRef.value.stepUp();
20700
- modelValue.value = lewInputRef.value.value;
22296
+ modelValue.value = Number(lewInputRef.value.value);
20701
22297
  emit("change", cloneDeep(modelValue.value));
20702
22298
  if (props.max !== void 0 && lewInputRef.value.value >= Number(props.max || 0)) {
20703
22299
  clearTimer();
@@ -20707,11 +22303,11 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
20707
22303
  }
20708
22304
  function minus() {
20709
22305
  lewInputRef.value.stepDown();
20710
- modelValue.value = lewInputRef.value.value;
22306
+ modelValue.value = Number(lewInputRef.value.value);
20711
22307
  longClickTimer.value = setTimeout(() => {
20712
22308
  longClickTimer.value = setInterval(() => {
20713
22309
  lewInputRef.value.stepDown();
20714
- modelValue.value = lewInputRef.value.value;
22310
+ modelValue.value = Number(lewInputRef.value.value);
20715
22311
  emit("change", cloneDeep(modelValue.value));
20716
22312
  if (props.min !== void 0 && lewInputRef.value.value <= Number(props.min || 0)) {
20717
22313
  clearTimer();
@@ -20791,7 +22387,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
20791
22387
  };
20792
22388
  }
20793
22389
  });
20794
- const LewInputNumber = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-a92b8be3"]]);
22390
+ const LewInputNumber = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-3760ac9e"]]);
20795
22391
  const inputTableEmits = {
20796
22392
  change: (value) => value
20797
22393
  };
@@ -21162,7 +22758,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
21162
22758
  }
21163
22759
  });
21164
22760
  }
21165
- function add() {
22761
+ function add2() {
21166
22762
  if ((modelValue.value || []).length >= props.maxRows) {
21167
22763
  LewMessage.warning(locale.t("inputTable.maxRows"));
21168
22764
  return;
@@ -21260,7 +22856,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
21260
22856
  y: "center",
21261
22857
  class: normalizeClass(["add-btn", { disabled: unref(isMaxRowsReached) }]),
21262
22858
  style: normalizeStyle(unref(styleConfig).addButtonStyle),
21263
- onClick: add
22859
+ onClick: add2
21264
22860
  }, {
21265
22861
  default: withCtx(() => [
21266
22862
  createVNode(CommonIcon, {
@@ -21443,9 +23039,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
21443
23039
  return;
21444
23040
  try {
21445
23041
  if (props.maxLength > 0 && Array.isArray(modelValue.value) && modelValue.value.length >= props.maxLength) {
21446
- LewMessage.warning(
21447
- locale.t("inputTag.maxLength", { maxLength: props.maxLength })
21448
- );
23042
+ LewMessage.warning(locale.t("inputTag.maxLength", { maxLength: props.maxLength }));
21449
23043
  return;
21450
23044
  }
21451
23045
  isInputActive.value = true;
@@ -21526,9 +23120,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
21526
23120
  if (props.maxLength > 0 && _value.length >= props.maxLength) {
21527
23121
  inputValue.value = "";
21528
23122
  isInputActive.value = false;
21529
- LewMessage.warning(
21530
- locale.t("inputTag.maxLength", { maxLength: props.maxLength })
21531
- );
23123
+ LewMessage.warning(locale.t("inputTag.maxLength", { maxLength: props.maxLength }));
21532
23124
  return;
21533
23125
  }
21534
23126
  _value.push(inputValue.value);
@@ -21597,6 +23189,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
21597
23189
  }
21598
23190
  function onBlur() {
21599
23191
  isInputActive.value = false;
23192
+ isTagMarkedForDeletion.value = false;
21600
23193
  if (inputValue.value) {
21601
23194
  addTag();
21602
23195
  }
@@ -21610,8 +23203,8 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
21610
23203
  const getTagStyle = computed(() => (index2) => {
21611
23204
  return {
21612
23205
  maxWidth: "100%",
21613
- backgroundColor: isInputActive.value && isTagMarkedForDeletion.value && index2 === (modelValue.value || []).length - 1 ? "var(--lew-color-red-light)" : "",
21614
- color: isInputActive.value && isTagMarkedForDeletion.value && index2 === (modelValue.value || []).length - 1 ? "var(--lew-color-red-dark)" : "var(--lew-color-primary-dark)"
23206
+ backgroundColor: isTagMarkedForDeletion.value && index2 === (modelValue.value || []).length - 1 ? "var(--lew-color-red-light)" : "",
23207
+ color: isTagMarkedForDeletion.value && index2 === (modelValue.value || []).length - 1 ? "var(--lew-color-red-dark)" : "var(--lew-color-primary-dark)"
21615
23208
  };
21616
23209
  });
21617
23210
  return (_ctx, _cache) => {
@@ -21687,7 +23280,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
21687
23280
  };
21688
23281
  }
21689
23282
  });
21690
- const LewInputTag = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-bafe25d6"]]);
23283
+ const LewInputTag = /* @__PURE__ */ _export_sfc(_sfc_main$z, [["__scopeId", "data-v-3efd3712"]]);
21691
23284
  const radioEmits = {
21692
23285
  change: () => true
21693
23286
  };
@@ -26909,12 +28502,6 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
26909
28502
  }
26910
28503
  });
26911
28504
  const LewUpload = /* @__PURE__ */ _export_sfc(_sfc_main$l, [["__scopeId", "data-v-741ec8ee"]]);
26912
- const avatarEmits = {
26913
- load: () => {
26914
- },
26915
- error: () => {
26916
- }
26917
- };
26918
28505
  const statusValues = ["online", "processing", "away", "offline", "busy"];
26919
28506
  const placementValues = ["top-left", "top-right", "bottom-left", "bottom-right"];
26920
28507
  const shapeValues = ["circle", "square", "sharp"];
@@ -26947,6 +28534,7 @@ const avatarProps = {
26947
28534
  },
26948
28535
  src: {
26949
28536
  type: String,
28537
+ default: "",
26950
28538
  validator: validators.string({
26951
28539
  componentName: "LewAvatar",
26952
28540
  propName: "src"
@@ -27007,10 +28595,8 @@ const _hoisted_2$a = ["alt", "src"];
27007
28595
  const _sfc_main$k = /* @__PURE__ */ defineComponent({
27008
28596
  __name: "LewAvatar",
27009
28597
  props: avatarProps,
27010
- emits: avatarEmits,
27011
- setup(__props, { emit: __emit }) {
28598
+ setup(__props) {
27012
28599
  const props = __props;
27013
- const emit = __emit;
27014
28600
  const BORDER_RADIUS_MAP = {
27015
28601
  circle: "50%",
27016
28602
  sharp: "0",
@@ -27075,11 +28661,16 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
27075
28661
  processing: "var(--lew-color-info)",
27076
28662
  away: "var(--lew-color-warning)"
27077
28663
  };
27078
- const { isLoading, error } = useImage({
27079
- src: props.src,
27080
- onLoaded: () => emit("load"),
27081
- onError: () => emit("error")
28664
+ const imageOptions = ref({
28665
+ src: props.src
27082
28666
  });
28667
+ watch(
28668
+ () => props.src,
28669
+ (newVal) => {
28670
+ imageOptions.value.src = newVal;
28671
+ }
28672
+ );
28673
+ const { isLoading, error } = useImage(imageOptions);
27083
28674
  const avatarStyleObject = computed(() => ({
27084
28675
  width: any2px(props.size),
27085
28676
  height: any2px(props.size)
@@ -27102,15 +28693,13 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
27102
28693
  };
27103
28694
  });
27104
28695
  const altText = computed(() => {
27105
- if (!props.alt)
27106
- return "";
28696
+ if (!props.alt) return "";
27107
28697
  const result = props.alt.split(" ").map((word) => word.charAt(0)).join("").toUpperCase();
27108
28698
  return result.length > 2 ? result.charAt(0) : result;
27109
28699
  });
27110
28700
  const dotStyleObject = computed(() => {
27111
28701
  const { status, statusPlacement, shape, size } = props;
27112
- if (!status)
27113
- return {};
28702
+ if (!status) return {};
27114
28703
  const statusPlacementConfig = shape === "circle" ? STATUS_PLACEMENT_CONFIG_CIRCLE : STATUS_PLACEMENT_CONFIG_SQUARE;
27115
28704
  return {
27116
28705
  ...statusPlacementConfig[statusPlacement],
@@ -27137,29 +28726,29 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
27137
28726
  class: "lew-avatar-box",
27138
28727
  style: normalizeStyle(avatarBoxStyleObject.value)
27139
28728
  }, [
27140
- _ctx.src ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
27141
- unref(isLoading) || _ctx.loading ? (openBlock(), createElementBlock("div", _hoisted_1$c)) : !unref(error) ? (openBlock(), createElementBlock("img", {
27142
- key: 1,
28729
+ unref(isLoading) || _ctx.loading ? (openBlock(), createElementBlock("div", _hoisted_1$c)) : _ctx.src ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
28730
+ !unref(error) ? (openBlock(), createElementBlock("img", {
28731
+ key: 0,
27143
28732
  alt: _ctx.alt,
27144
28733
  src: _ctx.src,
27145
28734
  lazy: "",
27146
28735
  style: normalizeStyle(imageStyleObject.value)
27147
28736
  }, null, 12, _hoisted_2$a)) : _ctx.alt ? (openBlock(), createElementBlock("div", {
27148
- key: 2,
28737
+ key: 1,
27149
28738
  class: "lew-avatar-text",
27150
28739
  style: normalizeStyle(textStyleObject.value)
27151
28740
  }, toDisplayString$1(altText.value), 5)) : (openBlock(), createBlock(CommonIcon, {
27152
- key: 3,
28741
+ key: 2,
27153
28742
  class: "lew-avatar-user-icon",
27154
28743
  size: getIconSize.value,
27155
28744
  type: "user"
27156
28745
  }, null, 8, ["size"]))
27157
28746
  ], 64)) : _ctx.alt ? (openBlock(), createElementBlock("div", {
27158
- key: 1,
28747
+ key: 2,
27159
28748
  class: "lew-avatar-text",
27160
28749
  style: normalizeStyle(textStyleObject.value)
27161
28750
  }, toDisplayString$1(altText.value), 5)) : (openBlock(), createBlock(CommonIcon, {
27162
- key: 2,
28751
+ key: 3,
27163
28752
  class: "lew-avatar-user-icon",
27164
28753
  size: getIconSize.value,
27165
28754
  type: "user"
@@ -27173,7 +28762,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
27173
28762
  };
27174
28763
  }
27175
28764
  });
27176
- const LewAvatar = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-d0850c9b"]]);
28765
+ const LewAvatar = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-c104afd2"]]);
27177
28766
  const badgeProps = {
27178
28767
  text: {
27179
28768
  type: String,
@@ -27566,11 +29155,6 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
27566
29155
  }
27567
29156
  });
27568
29157
  const LewFlex = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-8faad083"]]);
27569
- const imageEmits = {
27570
- load: (event) => event,
27571
- error: (event) => event,
27572
- click: (event) => event
27573
- };
27574
29158
  const _imports_0 = "data:image/svg+xml,%3csvg%20t='1726823972943'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6153'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M692.712%20172.458h-43.443l-21.561%2037.727-120.367%20210.648%20170.073%20170.092-118.896%20222.89-20.127%2037.727H926.996V172.458H692.712z%20m-21.561%2037.727h218.118v312.869L758.998%20392.783l-129.346%2097.015-75.265-75.265%20116.764-204.348z%20m218.118%20603.63h-287.97l122.575-229.832-67.267-67.267%2098.863-74.133L889.269%20576.4v237.415z'%20fill='%23DBDBDB'%20p-id='6154'%3e%3c/path%3e%3cpath%20d='M441.206%20414.533L557.97%20210.185l21.561-37.727H97.004v679.083H467.991l20.127-37.727%20122.575-229.832-169.487-169.449zM134.731%20210.185h379.796L394.16%20420.833l170.073%20170.092-12.488%2023.409L282.47%20528.92%20134.731%20632.33V210.185z%20m310.624%20603.63H134.731V678.394l154.077-107.861%20244.866%2077.661-88.319%20165.621z'%20fill='%23DBDBDB'%20p-id='6155'%3e%3c/path%3e%3cpath%20d='M361.093%20370.524c0-36.463-29.559-66.022-66.022-66.022s-66.022%2029.559-66.022%2066.022%2029.559%2066.022%2066.022%2066.022%2066.022-29.559%2066.022-66.022z%20m-94.318%200c0-15.6%2012.695-28.295%2028.295-28.295%2015.6%200%2028.295%2012.695%2028.295%2028.295%200%2015.6-12.695%2028.295-28.295%2028.295-15.6%200-28.295-12.695-28.295-28.295z'%20fill='%23DBDBDB'%20p-id='6156'%3e%3c/path%3e%3c/svg%3e";
27575
29159
  const imageProps = {
27576
29160
  src: {
@@ -27676,9 +29260,14 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
27676
29260
  height: any2px(height)
27677
29261
  };
27678
29262
  });
27679
- const { isLoading, error } = useImage({
27680
- src: props.src
27681
- });
29263
+ const imageOptions = ref({ src: props.src });
29264
+ watch(
29265
+ () => props.src,
29266
+ (newVal) => {
29267
+ imageOptions.value.src = newVal;
29268
+ }
29269
+ );
29270
+ const { isLoading, error } = useImage(imageOptions);
27682
29271
  return (_ctx, _cache) => {
27683
29272
  const _directive_tooltip = resolveDirective("tooltip");
27684
29273
  return openBlock(), createBlock(unref(LewFlex), {
@@ -27719,7 +29308,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
27719
29308
  };
27720
29309
  }
27721
29310
  });
27722
- const LewImage = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-95fcf03f"]]);
29311
+ const LewImage = /* @__PURE__ */ _export_sfc(_sfc_main$g, [["__scopeId", "data-v-eb70b553"]]);
27723
29312
  const markProps = {
27724
29313
  color: {
27725
29314
  type: String,
@@ -29930,7 +31519,6 @@ const components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
29930
31519
  actionBoxProps,
29931
31520
  alertEmits,
29932
31521
  alertProps,
29933
- avatarEmits,
29934
31522
  avatarProps,
29935
31523
  backTopProps,
29936
31524
  badgeProps,
@@ -29983,7 +31571,6 @@ const components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
29983
31571
  formModalProps,
29984
31572
  formProps,
29985
31573
  formTypeAsMap,
29986
- imageEmits,
29987
31574
  imageProps,
29988
31575
  inputEmits,
29989
31576
  inputModel,
@@ -30770,7 +32357,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
30770
32357
  0
30771
32358
  );
30772
32359
  }
30773
- function add(type, title, content, duration, showProgress, width2) {
32360
+ function add2(type, title, content, duration, showProgress, width2) {
30774
32361
  const id = getUniqueId();
30775
32362
  document.getElementById("lew-notification")?.classList.remove("notification-hidden");
30776
32363
  notifications.value.unshift({
@@ -30811,7 +32398,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
30811
32398
  }
30812
32399
  }
30813
32400
  __expose({
30814
- add,
32401
+ add: add2,
30815
32402
  handleClose
30816
32403
  });
30817
32404
  return (_ctx, _cache) => {
@@ -37395,7 +38982,6 @@ export {
37395
38982
  actionBoxProps,
37396
38983
  alertEmits,
37397
38984
  alertProps,
37398
- avatarEmits,
37399
38985
  avatarProps,
37400
38986
  backTopProps,
37401
38987
  badgeProps,
@@ -37457,7 +39043,6 @@ export {
37457
39043
  formTypeAsMap,
37458
39044
  fr,
37459
39045
  getLocale,
37460
- imageEmits,
37461
39046
  imageProps,
37462
39047
  initLewContextMenu,
37463
39048
  inputEmits,