@newview/file-ui 1.1.13 → 1.1.15

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/file-ui.js CHANGED
@@ -5,11 +5,12 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { BaseInstance } from "@newview/base-vue";
8
- import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx, createElementVNode, reactive, renderList, createBlock, createSlots, normalizeClass, withModifiers, createCommentVNode, toDisplayString, createTextVNode, pushScopeId, popScopeId, onMounted, onBeforeUnmount, nextTick, h, watchEffect, normalizeStyle } from "vue";
9
- import { QueryWrapper } from "@newview/infrastructure";
8
+ import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx, createElementVNode, reactive, renderList, createBlock, createSlots, normalizeClass, withModifiers, createCommentVNode, toDisplayString, createTextVNode, pushScopeId, popScopeId, onMounted, onBeforeUnmount, nextTick, h, watchEffect, normalizeStyle, withDirectives, vShow, vModelText } from "vue";
9
+ import { QueryWrapper, storageInfo } from "@newview/infrastructure";
10
10
  import { OSSFileApi, FileApi, UploadApi, FileInfoApi } from "@newview/fileservice-api";
11
- import { NvDicSelect, NvStructureTypeSelect, NvStructureSelect } from "@newview/basics-ui";
12
- const propDefine$3 = {
11
+ import { DictionaryDetailApi, DataStructureApi, StructureInstanceApi } from "@newview/basics-api";
12
+ import { utilities } from "@newview/tools";
13
+ const propDefine$6 = {
13
14
  modelValue: {
14
15
  // 是否显示
15
16
  type: Boolean,
@@ -32,12 +33,12 @@ const propDefine$3 = {
32
33
  default: 0
33
34
  }
34
35
  };
35
- const _sfc_main$3 = defineComponent({
36
+ const _sfc_main$6 = defineComponent({
36
37
  name: "FilePreview",
37
38
  components: {},
38
39
  emits: ["update:modelValue"],
39
40
  // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
40
- props: propDefine$3,
41
+ props: propDefine$6,
41
42
  setup(props, ctx) {
42
43
  return new FilePreviewInstance(props, ctx);
43
44
  }
@@ -149,9 +150,9 @@ const _export_sfc = (sfc, props) => {
149
150
  }
150
151
  return target;
151
152
  };
152
- const _hoisted_1$1 = { class: "ifr-container" };
153
- const _hoisted_2$1 = ["src", "title"];
154
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
153
+ const _hoisted_1$3 = { class: "ifr-container" };
154
+ const _hoisted_2$3 = ["src", "title"];
155
+ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
155
156
  const _component_ImagePreview = resolveComponent("ImagePreview");
156
157
  const _component_Modal = resolveComponent("Modal");
157
158
  return openBlock(), createElementBlock(Fragment, null, [
@@ -174,20 +175,20 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
174
175
  onOnVisibleChange: _ctx.doClose
175
176
  }, {
176
177
  default: withCtx(() => [
177
- createElementVNode("div", _hoisted_1$1, [
178
+ createElementVNode("div", _hoisted_1$3, [
178
179
  createElementVNode("iframe", {
179
180
  src: _ctx.ifrUrl,
180
181
  class: "ifr-content",
181
182
  title: _ctx.fileInfo.fileInfo
182
- }, " ", 8, _hoisted_2$1)
183
+ }, " ", 8, _hoisted_2$3)
183
184
  ])
184
185
  ]),
185
186
  _: 1
186
187
  }, 8, ["modelValue", "title", "onOnVisibleChange"])
187
188
  ], 64);
188
189
  }
189
- const filePreview = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-071f536d"]]);
190
- const propDefine$2 = {
190
+ const filePreview = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-071f536d"]]);
191
+ const propDefine$5 = {
191
192
  linkParam: {
192
193
  // 带入的参数
193
194
  type: String,
@@ -254,12 +255,12 @@ const propDefine$2 = {
254
255
  default: "暂无附件"
255
256
  }
256
257
  };
257
- const _sfc_main$2 = defineComponent({
258
+ const _sfc_main$5 = defineComponent({
258
259
  name: "UploadFile",
259
260
  components: { filePreview },
260
261
  emits: ["success", "returnFileList"],
261
262
  // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
262
- props: propDefine$2,
263
+ props: propDefine$5,
263
264
  setup(props, ctx) {
264
265
  return new UploadFileInstance(props, ctx);
265
266
  }
@@ -600,21 +601,21 @@ class UploadFileInstance extends BaseInstance {
600
601
  //#endregion 业务逻辑 文件预览 END
601
602
  }
602
603
  const UploadFile_vue_vue_type_style_index_0_scoped_d6b14e55_lang = "";
603
- const _withScopeId = (n) => (pushScopeId("data-v-d6b14e55"), n = n(), popScopeId(), n);
604
- const _hoisted_1 = { class: "uploadFile" };
605
- const _hoisted_2 = ["onClick", "title"];
606
- const _hoisted_3 = { class: "file-upload-list-cover" };
607
- const _hoisted_4 = { class: "file-upload-btn" };
608
- const _hoisted_5 = {
604
+ const _withScopeId$1 = (n) => (pushScopeId("data-v-d6b14e55"), n = n(), popScopeId(), n);
605
+ const _hoisted_1$2 = { class: "uploadFile" };
606
+ const _hoisted_2$2 = ["onClick", "title"];
607
+ const _hoisted_3$2 = { class: "file-upload-list-cover" };
608
+ const _hoisted_4$2 = { class: "file-upload-btn" };
609
+ const _hoisted_5$2 = {
609
610
  key: 1,
610
611
  class: "nv-flex",
611
612
  style: { "color": "#949494", "border": "1px dashed #dcdee2", "height": "60px", "padding": "0 20px", "font-size": "16px", "justify-content": "center" }
612
613
  };
613
- const _hoisted_6 = {
614
+ const _hoisted_6$2 = {
614
615
  class: "nv-flex",
615
616
  style: { "width": "40px", "margin-right": "6px" }
616
617
  };
617
- const _hoisted_7 = {
618
+ const _hoisted_7$2 = {
618
619
  t: "1706683071705",
619
620
  class: "icon",
620
621
  viewBox: "0 0 1566 1024",
@@ -623,16 +624,16 @@ const _hoisted_7 = {
623
624
  "p-id": "4559",
624
625
  style: { "fill": "currentColor" }
625
626
  };
626
- const _hoisted_8 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("path", {
627
+ const _hoisted_8$2 = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ createElementVNode("path", {
627
628
  d: "M156.661991 699.757959h21.096999a10.443999 10.443999 0 0 1 10.235999 10.443999c0 5.765-4.491 10.443999-10.235999 10.444h-21.096999v21.097999a10.443999 10.443999 0 0 1-10.444 10.234999 10.276999 10.276999 0 0 1-10.443999-10.234999v-21.097999h-21.096999a10.443999 10.443999 0 0 1-10.234999-10.444c0-5.765 4.49-10.443999 10.234999-10.443999h21.096999v-21.096999a10.443999 10.443999 0 0 1 10.443999-10.234999c5.765 0 10.443999 4.49 10.444 10.234999v21.096999z m1378.627919-83.552995v-21.096999a10.276999 10.276999 0 0 0-10.443999-10.234999 10.443999 10.443999 0 0 0-10.444 10.234999v21.096999h-21.096998a10.276999 10.276999 0 0 0-10.235 10.443999c0 5.598 4.595 10.443999 10.235 10.444h21.096998v21.096998c0 5.745 4.679 10.235999 10.444 10.236a10.443999 10.443999 0 0 0 10.443999-10.236v-21.096998h21.097999c5.744 0 10.234999-4.679 10.234999-10.444a10.443999 10.443999 0 0 0-10.234999-10.443999h-21.097999zM776.459955 960.861944H250.596985a20.804999 20.804999 0 0 1-20.825998-20.887999c0-11.529999 9.462999-20.888999 20.825998-20.888999h94.727995a83.009995 83.009995 0 0 1-11.112-41.671997v-605.969965a83.489995 83.489995 0 0 1 83.636996-83.447995h62.580996v-20.992999a83.489995 83.489995 0 0 1 83.636995-83.448995h501.151971a83.448995 83.448995 0 0 1 83.636995 83.448995v605.969965c0 15.184999-4.053 29.409998-11.134 41.671997h115.553994c11.551999 0 20.909999 9.273999 20.909998 20.887999 0 11.529999-9.295999 20.887999-20.888998 20.887999h-250.659986v20.992999c0 15.185999-4.052 29.409998-11.132999 41.671997h11.195999c11.488999 0 20.825999 9.274999 20.825999 20.888999 0 11.529999-9.462999 20.887999-20.825999 20.887999H892.807948a41.657998 41.657998 0 0 1-6.413 50.862997 41.671998 41.671998 0 0 1-59.071996 0l-50.862997-50.862997z m76.367995-41.776998h66.423996c22.977999 0 41.609998-18.589999 41.609998-41.879997V270.460984c0-22.559999-18.047999-40.689998-40.313998-40.689997H416.303976c-22.266999 0-40.314998 18.213999-40.314998 40.689997v606.741965c0 23.123999 18.799999 41.880998 41.589998 41.880997h317.083981l-10.736999-10.756999a41.692998 41.692998 0 0 1-10.862-40.376998l-19.718999-19.739999a146.259991 146.259991 0 0 1-190.980988-220.516987 146.217991 146.217991 0 0 1 220.517987 190.980989l19.738998 19.739999a41.629998 41.629998 0 0 1 40.376998 10.839999l69.829996 69.829996z m149.809991-104.440994h62.852997a41.796998 41.796998 0 0 0 41.589997-41.776997v-605.759965c0-23.144999-18.632999-41.776998-41.589997-41.776997H563.774967a41.796998 41.796998 0 0 0-41.566998 41.775997v20.888999h396.793977a83.448995 83.448995 0 0 1 83.636995 83.448995v543.199968zM266.326984 46.998997h31.122999c8.773999 0 15.875999 6.955 15.875999 15.665999 0 8.647999-7.102 15.665999-15.875999 15.665999h-31.122999v31.123999c0 8.772999-6.956 15.874999-15.665999 15.874999a15.769999 15.769999 0 0 1-15.666999-15.874999V78.329995H203.869988a15.728999 15.728999 0 0 1-15.874999-15.665999c0-8.647999 7.102-15.665999 15.874999-15.665999h31.122998V15.874999C234.992986 7.102 241.949986 0 250.659985 0c8.646999 0 15.665999 7.102 15.665999 15.874999V46.999997zM20.887999 939.973945c0-11.529999 9.462999-20.888999 20.825999-20.888999h125.454992c11.488999 0 20.825999 9.274999 20.825999 20.888999 0 11.529999-9.462999 20.887999-20.825999 20.887999H41.713998a20.804999 20.804999 0 0 1-20.825999-20.887999z m658.733961-135.021992A104.441994 104.441994 0 1 0 531.899969 657.229961a104.441994 104.441994 0 0 0 147.721991 147.721992z m-220.079987-491.626971a20.887999 20.887999 0 0 1 20.867999-20.888999h229.791986a20.887999 20.887999 0 1 1 0 41.776997H480.430972a20.825999 20.825999 0 0 1-20.887999-20.887998z m0 104.440994c0-11.529999 9.295999-20.887999 20.742999-20.887999H814.789952c11.446999 0 20.741999 9.273999 20.741999 20.887999 0 11.529999-9.294999 20.887999-20.741999 20.887998H480.284972a20.762999 20.762999 0 0 1-20.741999-20.887998z m0 104.441993c0-11.529999 9.316999-20.888999 20.846999-20.888998h146.301991c11.509999 0 20.845999 9.274999 20.845999 20.888998 0 11.529999-9.315999 20.887999-20.845999 20.887999H480.388972a20.804999 20.804999 0 0 1-20.845999-20.887999zM62.665996 396.877977a62.664996 62.664996 0 1 1 0-125.329993 62.664996 62.664996 0 0 1 0 125.329993z m0-31.332998a31.331998 31.331998 0 1 0 0-62.664997 31.331998 31.331998 0 0 0 0 62.664997z m1295.074924-93.996995a62.664996 62.664996 0 1 1 0-125.329993 62.664996 62.664996 0 0 1 0 125.329993z m0-31.332998a31.331998 31.331998 0 1 0 0-62.663996 31.331998 31.331998 0 0 0 0 62.663996z",
628
629
  "p-id": "4560"
629
630
  }, null, -1));
630
- const _hoisted_9 = [
631
- _hoisted_8
631
+ const _hoisted_9$2 = [
632
+ _hoisted_8$2
632
633
  ];
633
- const _hoisted_10 = { class: "file-upload-list-cover" };
634
- const _hoisted_11 = { class: "file-upload-btn" };
635
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
634
+ const _hoisted_10$2 = { class: "file-upload-list-cover" };
635
+ const _hoisted_11$2 = { class: "file-upload-btn" };
636
+ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
636
637
  const _component_Image = resolveComponent("Image");
637
638
  const _component_Icon = resolveComponent("Icon");
638
639
  const _component_Space = resolveComponent("Space");
@@ -640,7 +641,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
640
641
  const _component_Card = resolveComponent("Card");
641
642
  const _component_Spin = resolveComponent("Spin");
642
643
  const _component_filePreview = resolveComponent("filePreview");
643
- return openBlock(), createElementBlock("div", _hoisted_1, [
644
+ return openBlock(), createElementBlock("div", _hoisted_1$2, [
644
645
  !_ctx.single ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.groups, (groupName) => {
645
646
  return openBlock(), createBlock(_component_Card, {
646
647
  "dis-hover": "",
@@ -664,7 +665,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
664
665
  width: "100%",
665
666
  height: "100%"
666
667
  }, null, 8, ["src"]),
667
- createElementVNode("div", _hoisted_3, [
668
+ createElementVNode("div", _hoisted_3$2, [
668
669
  createVNode(_component_Space, null, {
669
670
  default: withCtx(() => [
670
671
  createVNode(_component_Icon, {
@@ -682,7 +683,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
682
683
  _: 2
683
684
  }, 1024)
684
685
  ])
685
- ], 8, _hoisted_2)
686
+ ], 8, _hoisted_2$2)
686
687
  ], 2);
687
688
  }), 256)),
688
689
  !_ctx.readonly ? (openBlock(), createBlock(_component_Upload, {
@@ -705,7 +706,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
705
706
  style: { "display": "inline-block", "width": "78px" }
706
707
  }, {
707
708
  default: withCtx(() => [
708
- createElementVNode("div", _hoisted_4, [
709
+ createElementVNode("div", _hoisted_4$2, [
709
710
  createVNode(_component_Icon, {
710
711
  type: "ios-camera",
711
712
  size: "20"
@@ -714,9 +715,9 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
714
715
  ]),
715
716
  _: 2
716
717
  }, 1032, ["multiple", "format", "max-size", "action", "headers", "data", "on-success", "on-format-error", "on-exceeded-size", "before-upload"])) : createCommentVNode("", true),
717
- _ctx.readonly && _ctx.fileList.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [
718
- createElementVNode("i", _hoisted_6, [
719
- (openBlock(), createElementBlock("svg", _hoisted_7, _hoisted_9))
718
+ _ctx.readonly && _ctx.fileList.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_5$2, [
719
+ createElementVNode("i", _hoisted_6$2, [
720
+ (openBlock(), createElementBlock("svg", _hoisted_7$2, _hoisted_9$2))
720
721
  ]),
721
722
  createElementVNode("div", null, toDisplayString(_ctx.nullMsg), 1)
722
723
  ])) : createCommentVNode("", true)
@@ -744,7 +745,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
744
745
  width: "100%",
745
746
  height: "100%"
746
747
  }, null, 8, ["src"]),
747
- createElementVNode("div", _hoisted_10, [
748
+ createElementVNode("div", _hoisted_10$2, [
748
749
  createVNode(_component_Space, null, {
749
750
  default: withCtx(() => [
750
751
  createVNode(_component_Icon, {
@@ -787,7 +788,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
787
788
  style: { "display": "inline-block", "width": "78px" }
788
789
  }, {
789
790
  default: withCtx(() => [
790
- createElementVNode("div", _hoisted_11, [
791
+ createElementVNode("div", _hoisted_11$2, [
791
792
  createVNode(_component_Icon, {
792
793
  type: "ios-camera",
793
794
  size: "20"
@@ -813,7 +814,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
813
814
  }, null, 8, ["modelValue", "preview-list", "preview-index", "file-info"])
814
815
  ]);
815
816
  }
816
- const UploadFile = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-d6b14e55"]]);
817
+ const UploadFile = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5], ["__scopeId", "data-v-d6b14e55"]]);
817
818
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
818
819
  function getDefaultExportFromCjs(x) {
819
820
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -15145,7 +15146,7 @@ const QuillEditor = defineComponent({
15145
15146
  });
15146
15147
  const vueQuill_snow = "";
15147
15148
  const vueQuill_bubble = "";
15148
- const propDefine$1 = {
15149
+ const propDefine$4 = {
15149
15150
  modelValue: {
15150
15151
  default: "",
15151
15152
  type: String
@@ -15163,14 +15164,14 @@ const propDefine$1 = {
15163
15164
  default: true
15164
15165
  }
15165
15166
  };
15166
- const _sfc_main$1 = defineComponent({
15167
+ const _sfc_main$4 = defineComponent({
15167
15168
  name: "TextEditor",
15168
15169
  components: {
15169
15170
  QuillEditor
15170
15171
  },
15171
15172
  emits: ["update:modelValue", "textChange"],
15172
15173
  // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
15173
- props: propDefine$1,
15174
+ props: propDefine$4,
15174
15175
  setup(props, ctx) {
15175
15176
  return new TextEditor$1(props, ctx);
15176
15177
  }
@@ -15289,7 +15290,7 @@ let TextEditor$1 = class TextEditor extends BaseInstance {
15289
15290
  //#endregion 业务逻辑 END
15290
15291
  };
15291
15292
  const TextEditor_vue_vue_type_style_index_0_scoped_5812cc0f_lang = "";
15292
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
15293
+ function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
15293
15294
  const _component_QuillEditor = resolveComponent("QuillEditor");
15294
15295
  return openBlock(), createElementBlock("div", {
15295
15296
  style: { "height": "100%" },
@@ -15308,8 +15309,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
15308
15309
  }, null, 8, ["content", "readOnly", "theme", "onTextChange", "options"])) : createCommentVNode("", true)
15309
15310
  ], 2);
15310
15311
  }
15311
- const TextEditor2 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-5812cc0f"]]);
15312
- const propDefine = {
15312
+ const TextEditor2 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4], ["__scopeId", "data-v-5812cc0f"]]);
15313
+ const propDefine$3 = {
15313
15314
  onlyView: {
15314
15315
  // 是否只读
15315
15316
  type: Boolean,
@@ -15327,11 +15328,11 @@ const propDefine = {
15327
15328
  }
15328
15329
  }
15329
15330
  };
15330
- const _sfc_main = defineComponent({
15331
+ const _sfc_main$3 = defineComponent({
15331
15332
  name: "NvComFormUp",
15332
15333
  components: { UploadFile, TextEditor: TextEditor2, NvDicSelect, NvStructureTypeSelect, NvStructureSelect },
15333
15334
  emits: ["textChange", "TokenChange"],
15334
- props: propDefine,
15335
+ props: propDefine$3,
15335
15336
  setup(props, ctx) {
15336
15337
  return new ComFormInstance(props, ctx);
15337
15338
  }
@@ -15410,7 +15411,7 @@ class ComFormInstance extends BaseInstance {
15410
15411
  this.ctx = ctx;
15411
15412
  }
15412
15413
  }
15413
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
15414
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
15414
15415
  const _component_UploadFile = resolveComponent("UploadFile");
15415
15416
  const _component_TextEditor = resolveComponent("TextEditor");
15416
15417
  const _component_NvDicSelect = resolveComponent("NvDicSelect");
@@ -15465,10 +15466,3610 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
15465
15466
  _: 1
15466
15467
  }, 8, ["onlyView", "formItems", "formModel"]);
15467
15468
  }
15468
- const ComFormUp = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
15469
+ const ComFormUp = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
15470
+ const dictionaryDetailApi = new DictionaryDetailApi();
15471
+ const loadDictionaryData = async (optionCode, source, iViewOptions, platformId) => {
15472
+ if (!source) {
15473
+ source = [];
15474
+ }
15475
+ if (utilities.isNull(platformId)) {
15476
+ platformId = storageInfo.getCurrentPlatform().Id;
15477
+ }
15478
+ const res = utilities.parseApiResult(await dictionaryDetailApi.getOptions(platformId, optionCode));
15479
+ if (iViewOptions) {
15480
+ source.splice(0, 0, ...utilities.arrayHelper.parseIViewOptions(res, "DetailInfor", "DetailValue"));
15481
+ return source;
15482
+ }
15483
+ return res;
15484
+ };
15485
+ const propDefine$2 = {
15486
+ code: {
15487
+ // 字典码
15488
+ type: String,
15489
+ default: ""
15490
+ },
15491
+ platformId: {
15492
+ // 平台Id
15493
+ type: Number,
15494
+ default: null
15495
+ },
15496
+ value: {
15497
+ // 平台Id
15498
+ type: String,
15499
+ default: ""
15500
+ },
15501
+ readonly: {
15502
+ // 只读
15503
+ type: Boolean,
15504
+ default: false
15505
+ }
15506
+ };
15507
+ const _sfc_main$2 = defineComponent({
15508
+ name: "NvDicSelect",
15509
+ components: {},
15510
+ emits: ["input", "change"],
15511
+ // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
15512
+ props: propDefine$2,
15513
+ setup(props, ctx) {
15514
+ return new DicSelectInstance(props, ctx);
15515
+ }
15516
+ });
15517
+ class DicSelectInstance extends BaseInstance {
15518
+ constructor(props, ctx) {
15519
+ super();
15520
+ __publicField(this, "props");
15521
+ __publicField(this, "ctx");
15522
+ // 全局属性
15523
+ __publicField(this, "DicValue", ref(""));
15524
+ __publicField(this, "dicOptions", ref([]));
15525
+ __publicField(this, "DicSelectChange", () => {
15526
+ this.ctx.emit("input", this.DicValue.value);
15527
+ this.ctx.emit("change", this.DicValue.value);
15528
+ });
15529
+ this.props = props;
15530
+ this.ctx = ctx;
15531
+ this.loadDicData();
15532
+ }
15533
+ async loadDicData() {
15534
+ this.dicOptions.value = await loadDictionaryData(this.props.code, [], true, this.props.platformId);
15535
+ }
15536
+ }
15537
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
15538
+ const _component_Option = resolveComponent("Option");
15539
+ const _component_Select = resolveComponent("Select");
15540
+ return openBlock(), createBlock(_component_Select, {
15541
+ disabled: _ctx.readonly,
15542
+ modelValue: _ctx.DicValue,
15543
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.DicValue = $event),
15544
+ transfer: "",
15545
+ onOnChange: _ctx.DicSelectChange
15546
+ }, {
15547
+ default: withCtx(() => [
15548
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.dicOptions, (item) => {
15549
+ return openBlock(), createBlock(_component_Option, {
15550
+ value: item.value,
15551
+ key: item.value
15552
+ }, {
15553
+ default: withCtx(() => [
15554
+ createTextVNode(toDisplayString(item.text), 1)
15555
+ ]),
15556
+ _: 2
15557
+ }, 1032, ["value"]);
15558
+ }), 128))
15559
+ ]),
15560
+ _: 1
15561
+ }, 8, ["disabled", "modelValue", "onOnChange"]);
15562
+ }
15563
+ const NvDicSelect = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
15564
+ var Functions = {
15565
+ Identity: function(x) {
15566
+ return x;
15567
+ },
15568
+ True: function() {
15569
+ return true;
15570
+ },
15571
+ Blank: function() {
15572
+ }
15573
+ };
15574
+ var Types = {
15575
+ Boolean: "boolean",
15576
+ Number: "number",
15577
+ String: "string",
15578
+ Object: typeof {},
15579
+ Undefined: "undefined",
15580
+ Function: "function"
15581
+ };
15582
+ var funcCache = { "": Functions.Identity };
15583
+ var Utils = {
15584
+ createLambda: function(expression) {
15585
+ if (expression == null)
15586
+ return Functions.Identity;
15587
+ if (typeof expression === Types.String) {
15588
+ let f = funcCache[expression];
15589
+ if (f != null) {
15590
+ return f;
15591
+ }
15592
+ if (expression.indexOf("=>") === -1) {
15593
+ const regexp = new RegExp("[$]+", "g");
15594
+ let maxLength = 0;
15595
+ let match;
15596
+ while ((match = regexp.exec(expression)) != null) {
15597
+ if (match[0].length > maxLength) {
15598
+ maxLength = match[0].length;
15599
+ }
15600
+ }
15601
+ const argArray = [];
15602
+ for (let i = 1; i <= maxLength; i++) {
15603
+ let dollar = "";
15604
+ for (let j = 0; j < i; j++) {
15605
+ dollar += "$";
15606
+ }
15607
+ argArray.push(dollar);
15608
+ }
15609
+ const args = argArray.join(",");
15610
+ f = new Function(args, "return " + expression);
15611
+ funcCache[expression] = f;
15612
+ return f;
15613
+ } else {
15614
+ const expr = expression.match(/^[(\s]*([^()]*?)[)\s]*=>(.*)/);
15615
+ f = new Function(expr[1], expr[2].match(/\breturn\b/) ? expr[2] : "return " + expr[2]);
15616
+ funcCache[expression] = f;
15617
+ return f;
15618
+ }
15619
+ }
15620
+ return expression;
15621
+ },
15622
+ defineProperty: function(target, methodName, value) {
15623
+ Object.defineProperty(target, methodName, {
15624
+ enumerable: false,
15625
+ configurable: true,
15626
+ writable: true,
15627
+ value
15628
+ });
15629
+ },
15630
+ compare: function(a, b) {
15631
+ return a === b ? 0 : a > b ? 1 : -1;
15632
+ },
15633
+ dispose: function(obj) {
15634
+ if (obj != null)
15635
+ obj.dispose();
15636
+ },
15637
+ hasNativeIteratorSupport: function() {
15638
+ return typeof Symbol !== "undefined" && typeof Symbol.iterator !== "undefined";
15639
+ }
15640
+ };
15641
+ var State = { Before: 0, Running: 1, After: 2 };
15642
+ var IEnumerator = function(initialize, tryGetNext, dispose) {
15643
+ var yielder = new Yielder();
15644
+ var state = State.Before;
15645
+ this.current = yielder.current;
15646
+ this.moveNext = function() {
15647
+ try {
15648
+ switch (state) {
15649
+ case State.Before:
15650
+ state = State.Running;
15651
+ initialize();
15652
+ case State.Running:
15653
+ if (tryGetNext.apply(yielder)) {
15654
+ return true;
15655
+ } else {
15656
+ this.dispose();
15657
+ return false;
15658
+ }
15659
+ case State.After:
15660
+ return false;
15661
+ }
15662
+ } catch (e) {
15663
+ this.dispose();
15664
+ throw e;
15665
+ }
15666
+ };
15667
+ this.dispose = function() {
15668
+ if (state != State.Running)
15669
+ return;
15670
+ try {
15671
+ dispose();
15672
+ } finally {
15673
+ state = State.After;
15674
+ }
15675
+ };
15676
+ };
15677
+ var Yielder = function() {
15678
+ var current = null;
15679
+ this.current = function() {
15680
+ return current;
15681
+ };
15682
+ this.yieldReturn = function(value) {
15683
+ current = value;
15684
+ return true;
15685
+ };
15686
+ this.yieldBreak = function() {
15687
+ return false;
15688
+ };
15689
+ };
15690
+ var Enumerable = function(getEnumerator) {
15691
+ this.getEnumerator = getEnumerator;
15692
+ };
15693
+ Enumerable.Utils = {};
15694
+ Enumerable.Utils.createLambda = function(expression) {
15695
+ return Utils.createLambda(expression);
15696
+ };
15697
+ Enumerable.Utils.createEnumerable = function(getEnumerator) {
15698
+ return new Enumerable(getEnumerator);
15699
+ };
15700
+ Enumerable.Utils.createEnumerator = function(initialize, tryGetNext, dispose) {
15701
+ return new IEnumerator(initialize, tryGetNext, dispose);
15702
+ };
15703
+ Enumerable.Utils.extendTo = function(type) {
15704
+ var typeProto = type.prototype;
15705
+ var enumerableProto;
15706
+ if (type === Array) {
15707
+ enumerableProto = ArrayEnumerable.prototype;
15708
+ Utils.defineProperty(typeProto, "getSource", function() {
15709
+ return this;
15710
+ });
15711
+ } else {
15712
+ enumerableProto = Enumerable.prototype;
15713
+ Utils.defineProperty(typeProto, "getEnumerator", function() {
15714
+ return Enumerable.from(this).getEnumerator();
15715
+ });
15716
+ }
15717
+ for (let methodName in enumerableProto) {
15718
+ const func = enumerableProto[methodName];
15719
+ if (typeProto[methodName] == func)
15720
+ continue;
15721
+ if (typeProto[methodName] != null) {
15722
+ methodName = methodName + "ByLinq";
15723
+ if (typeProto[methodName] == func)
15724
+ continue;
15725
+ }
15726
+ if (func instanceof Function) {
15727
+ Utils.defineProperty(typeProto, methodName, func);
15728
+ }
15729
+ }
15730
+ };
15731
+ Enumerable.Utils.recallFrom = function(type) {
15732
+ var typeProto = type.prototype;
15733
+ var enumerableProto;
15734
+ if (type === Array) {
15735
+ enumerableProto = ArrayEnumerable.prototype;
15736
+ delete typeProto.getSource;
15737
+ } else {
15738
+ enumerableProto = Enumerable.prototype;
15739
+ delete typeProto.getEnumerator;
15740
+ }
15741
+ for (const methodName in enumerableProto) {
15742
+ const func = enumerableProto[methodName];
15743
+ if (typeProto[methodName + "ByLinq"]) {
15744
+ delete typeProto[methodName + "ByLinq"];
15745
+ } else if (typeProto[methodName] == func && func instanceof Function) {
15746
+ delete typeProto[methodName];
15747
+ }
15748
+ }
15749
+ };
15750
+ Enumerable.choice = function() {
15751
+ var args = arguments;
15752
+ return new Enumerable(function() {
15753
+ return new IEnumerator(
15754
+ function() {
15755
+ args = args[0] instanceof Array ? args[0] : args[0].getEnumerator != null ? args[0].toArray() : args;
15756
+ },
15757
+ function() {
15758
+ return this.yieldReturn(args[Math.floor(Math.random() * args.length)]);
15759
+ },
15760
+ Functions.Blank
15761
+ );
15762
+ });
15763
+ };
15764
+ Enumerable.cycle = function() {
15765
+ var args = arguments;
15766
+ return new Enumerable(function() {
15767
+ var index = 0;
15768
+ return new IEnumerator(
15769
+ function() {
15770
+ args = args[0] instanceof Array ? args[0] : args[0].getEnumerator != null ? args[0].toArray() : args;
15771
+ },
15772
+ function() {
15773
+ if (index >= args.length)
15774
+ index = 0;
15775
+ return this.yieldReturn(args[index++]);
15776
+ },
15777
+ Functions.Blank
15778
+ );
15779
+ });
15780
+ };
15781
+ Enumerable.empty = function() {
15782
+ return new Enumerable(function() {
15783
+ return new IEnumerator(
15784
+ Functions.Blank,
15785
+ function() {
15786
+ return false;
15787
+ },
15788
+ Functions.Blank
15789
+ );
15790
+ });
15791
+ };
15792
+ Enumerable.from = function(obj) {
15793
+ if (obj == null) {
15794
+ return Enumerable.empty();
15795
+ }
15796
+ if (obj instanceof Enumerable) {
15797
+ return obj;
15798
+ }
15799
+ if (typeof obj == Types.Number || typeof obj == Types.Boolean) {
15800
+ return Enumerable.repeat(obj, 1);
15801
+ }
15802
+ if (typeof obj == Types.String) {
15803
+ return new Enumerable(function() {
15804
+ var index = 0;
15805
+ return new IEnumerator(
15806
+ Functions.Blank,
15807
+ function() {
15808
+ return index < obj.length ? this.yieldReturn(obj.charAt(index++)) : false;
15809
+ },
15810
+ Functions.Blank
15811
+ );
15812
+ });
15813
+ }
15814
+ if (typeof obj != Types.Function) {
15815
+ if (typeof obj.length == Types.Number) {
15816
+ return new ArrayEnumerable(obj);
15817
+ }
15818
+ if (typeof Symbol !== "undefined" && typeof obj[Symbol.iterator] !== "undefined") {
15819
+ return new Enumerable(function() {
15820
+ return new IEnumerator(
15821
+ Functions.Blank,
15822
+ function() {
15823
+ var next = obj.next();
15824
+ return next.done ? false : this.yieldReturn(next.value);
15825
+ },
15826
+ Functions.Blank
15827
+ );
15828
+ });
15829
+ }
15830
+ }
15831
+ return new Enumerable(function() {
15832
+ var array = [];
15833
+ var index = 0;
15834
+ return new IEnumerator(
15835
+ function() {
15836
+ for (const key in obj) {
15837
+ const value = obj[key];
15838
+ if (!(value instanceof Function) && Object.prototype.hasOwnProperty.call(obj, key)) {
15839
+ array.push({ key, value });
15840
+ }
15841
+ }
15842
+ },
15843
+ function() {
15844
+ return index < array.length ? this.yieldReturn(array[index++]) : false;
15845
+ },
15846
+ Functions.Blank
15847
+ );
15848
+ });
15849
+ }, Enumerable.make = function(element) {
15850
+ return Enumerable.repeat(element, 1);
15851
+ };
15852
+ Enumerable.matches = function(input, pattern, flags) {
15853
+ if (flags == null)
15854
+ flags = "";
15855
+ if (pattern instanceof RegExp) {
15856
+ flags += pattern.ignoreCase ? "i" : "";
15857
+ flags += pattern.multiline ? "m" : "";
15858
+ pattern = pattern.source;
15859
+ }
15860
+ if (flags.indexOf("g") === -1)
15861
+ flags += "g";
15862
+ return new Enumerable(function() {
15863
+ var regex;
15864
+ return new IEnumerator(
15865
+ function() {
15866
+ regex = new RegExp(pattern, flags);
15867
+ },
15868
+ function() {
15869
+ var match = regex.exec(input);
15870
+ return match ? this.yieldReturn(match) : false;
15871
+ },
15872
+ Functions.Blank
15873
+ );
15874
+ });
15875
+ };
15876
+ Enumerable.range = function(start, count, step) {
15877
+ if (step == null)
15878
+ step = 1;
15879
+ return new Enumerable(function() {
15880
+ var value;
15881
+ var index = 0;
15882
+ return new IEnumerator(
15883
+ function() {
15884
+ value = start - step;
15885
+ },
15886
+ function() {
15887
+ return index++ < count ? this.yieldReturn(value += step) : this.yieldBreak();
15888
+ },
15889
+ Functions.Blank
15890
+ );
15891
+ });
15892
+ };
15893
+ Enumerable.rangeDown = function(start, count, step) {
15894
+ if (step == null)
15895
+ step = 1;
15896
+ return new Enumerable(function() {
15897
+ var value;
15898
+ var index = 0;
15899
+ return new IEnumerator(
15900
+ function() {
15901
+ value = start + step;
15902
+ },
15903
+ function() {
15904
+ return index++ < count ? this.yieldReturn(value -= step) : this.yieldBreak();
15905
+ },
15906
+ Functions.Blank
15907
+ );
15908
+ });
15909
+ };
15910
+ Enumerable.rangeTo = function(start, to, step) {
15911
+ if (step == null)
15912
+ step = 1;
15913
+ if (start < to) {
15914
+ return new Enumerable(function() {
15915
+ var value;
15916
+ return new IEnumerator(
15917
+ function() {
15918
+ value = start - step;
15919
+ },
15920
+ function() {
15921
+ var next = value += step;
15922
+ return next <= to ? this.yieldReturn(next) : this.yieldBreak();
15923
+ },
15924
+ Functions.Blank
15925
+ );
15926
+ });
15927
+ } else {
15928
+ return new Enumerable(function() {
15929
+ var value;
15930
+ return new IEnumerator(
15931
+ function() {
15932
+ value = start + step;
15933
+ },
15934
+ function() {
15935
+ var next = value -= step;
15936
+ return next >= to ? this.yieldReturn(next) : this.yieldBreak();
15937
+ },
15938
+ Functions.Blank
15939
+ );
15940
+ });
15941
+ }
15942
+ };
15943
+ Enumerable.repeat = function(element, count) {
15944
+ if (count != null)
15945
+ return Enumerable.repeat(element).take(count);
15946
+ return new Enumerable(function() {
15947
+ return new IEnumerator(
15948
+ Functions.Blank,
15949
+ function() {
15950
+ return this.yieldReturn(element);
15951
+ },
15952
+ Functions.Blank
15953
+ );
15954
+ });
15955
+ };
15956
+ Enumerable.repeatWithFinalize = function(initializer, finalizer) {
15957
+ initializer = Utils.createLambda(initializer);
15958
+ finalizer = Utils.createLambda(finalizer);
15959
+ return new Enumerable(function() {
15960
+ var element;
15961
+ return new IEnumerator(
15962
+ function() {
15963
+ element = initializer();
15964
+ },
15965
+ function() {
15966
+ return this.yieldReturn(element);
15967
+ },
15968
+ function() {
15969
+ if (element != null) {
15970
+ finalizer(element);
15971
+ element = null;
15972
+ }
15973
+ }
15974
+ );
15975
+ });
15976
+ };
15977
+ Enumerable.generate = function(func, count) {
15978
+ if (count != null)
15979
+ return Enumerable.generate(func).take(count);
15980
+ func = Utils.createLambda(func);
15981
+ return new Enumerable(function() {
15982
+ return new IEnumerator(
15983
+ Functions.Blank,
15984
+ function() {
15985
+ return this.yieldReturn(func());
15986
+ },
15987
+ Functions.Blank
15988
+ );
15989
+ });
15990
+ };
15991
+ Enumerable.toInfinity = function(start, step) {
15992
+ if (start == null)
15993
+ start = 0;
15994
+ if (step == null)
15995
+ step = 1;
15996
+ return new Enumerable(function() {
15997
+ var value;
15998
+ return new IEnumerator(
15999
+ function() {
16000
+ value = start - step;
16001
+ },
16002
+ function() {
16003
+ return this.yieldReturn(value += step);
16004
+ },
16005
+ Functions.Blank
16006
+ );
16007
+ });
16008
+ };
16009
+ Enumerable.toNegativeInfinity = function(start, step) {
16010
+ if (start == null)
16011
+ start = 0;
16012
+ if (step == null)
16013
+ step = 1;
16014
+ return new Enumerable(function() {
16015
+ var value;
16016
+ return new IEnumerator(
16017
+ function() {
16018
+ value = start + step;
16019
+ },
16020
+ function() {
16021
+ return this.yieldReturn(value -= step);
16022
+ },
16023
+ Functions.Blank
16024
+ );
16025
+ });
16026
+ };
16027
+ Enumerable.unfold = function(seed, func) {
16028
+ func = Utils.createLambda(func);
16029
+ return new Enumerable(function() {
16030
+ var isFirst = true;
16031
+ var value;
16032
+ return new IEnumerator(
16033
+ Functions.Blank,
16034
+ function() {
16035
+ if (isFirst) {
16036
+ isFirst = false;
16037
+ value = seed;
16038
+ return this.yieldReturn(value);
16039
+ }
16040
+ value = func(value);
16041
+ return this.yieldReturn(value);
16042
+ },
16043
+ Functions.Blank
16044
+ );
16045
+ });
16046
+ };
16047
+ Enumerable.defer = function(enumerableFactory) {
16048
+ return new Enumerable(function() {
16049
+ var enumerator;
16050
+ return new IEnumerator(
16051
+ function() {
16052
+ enumerator = Enumerable.from(enumerableFactory()).getEnumerator();
16053
+ },
16054
+ function() {
16055
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : this.yieldBreak();
16056
+ },
16057
+ function() {
16058
+ Utils.dispose(enumerator);
16059
+ }
16060
+ );
16061
+ });
16062
+ };
16063
+ Enumerable.prototype.traverseBreadthFirst = function(func, resultSelector) {
16064
+ var source = this;
16065
+ func = Utils.createLambda(func);
16066
+ resultSelector = Utils.createLambda(resultSelector);
16067
+ return new Enumerable(function() {
16068
+ var enumerator;
16069
+ var nestLevel = 0;
16070
+ var buffer = [];
16071
+ return new IEnumerator(
16072
+ function() {
16073
+ enumerator = source.getEnumerator();
16074
+ },
16075
+ function() {
16076
+ while (true) {
16077
+ if (enumerator.moveNext()) {
16078
+ buffer.push(enumerator.current());
16079
+ return this.yieldReturn(resultSelector(enumerator.current(), nestLevel));
16080
+ }
16081
+ const next = Enumerable.from(buffer).selectMany(function(x) {
16082
+ return func(x);
16083
+ });
16084
+ if (!next.any()) {
16085
+ return false;
16086
+ } else {
16087
+ nestLevel++;
16088
+ buffer = [];
16089
+ Utils.dispose(enumerator);
16090
+ enumerator = next.getEnumerator();
16091
+ }
16092
+ }
16093
+ },
16094
+ function() {
16095
+ Utils.dispose(enumerator);
16096
+ }
16097
+ );
16098
+ });
16099
+ };
16100
+ Enumerable.prototype.traverseDepthFirst = function(func, resultSelector) {
16101
+ var source = this;
16102
+ func = Utils.createLambda(func);
16103
+ resultSelector = Utils.createLambda(resultSelector);
16104
+ return new Enumerable(function() {
16105
+ var enumeratorStack = [];
16106
+ var enumerator;
16107
+ return new IEnumerator(
16108
+ function() {
16109
+ enumerator = source.getEnumerator();
16110
+ },
16111
+ function() {
16112
+ while (true) {
16113
+ if (enumerator.moveNext()) {
16114
+ const value = resultSelector(enumerator.current(), enumeratorStack.length);
16115
+ enumeratorStack.push(enumerator);
16116
+ enumerator = Enumerable.from(func(enumerator.current())).getEnumerator();
16117
+ return this.yieldReturn(value);
16118
+ }
16119
+ if (enumeratorStack.length <= 0)
16120
+ return false;
16121
+ Utils.dispose(enumerator);
16122
+ enumerator = enumeratorStack.pop();
16123
+ }
16124
+ },
16125
+ function() {
16126
+ try {
16127
+ Utils.dispose(enumerator);
16128
+ } finally {
16129
+ Enumerable.from(enumeratorStack).forEach(function(s) {
16130
+ s.dispose();
16131
+ });
16132
+ }
16133
+ }
16134
+ );
16135
+ });
16136
+ };
16137
+ Enumerable.prototype.flatten = function() {
16138
+ var source = this;
16139
+ return new Enumerable(function() {
16140
+ var enumerator;
16141
+ var middleEnumerator = null;
16142
+ return new IEnumerator(
16143
+ function() {
16144
+ enumerator = source.getEnumerator();
16145
+ },
16146
+ function() {
16147
+ while (true) {
16148
+ if (middleEnumerator != null) {
16149
+ if (middleEnumerator.moveNext()) {
16150
+ return this.yieldReturn(middleEnumerator.current());
16151
+ } else {
16152
+ middleEnumerator = null;
16153
+ }
16154
+ }
16155
+ if (enumerator.moveNext()) {
16156
+ if (enumerator.current() instanceof Array) {
16157
+ Utils.dispose(middleEnumerator);
16158
+ middleEnumerator = Enumerable.from(enumerator.current()).selectMany(Functions.Identity).flatten().getEnumerator();
16159
+ continue;
16160
+ } else {
16161
+ return this.yieldReturn(enumerator.current());
16162
+ }
16163
+ }
16164
+ return false;
16165
+ }
16166
+ },
16167
+ function() {
16168
+ try {
16169
+ Utils.dispose(enumerator);
16170
+ } finally {
16171
+ Utils.dispose(middleEnumerator);
16172
+ }
16173
+ }
16174
+ );
16175
+ });
16176
+ };
16177
+ Enumerable.prototype.pairwise = function(selector) {
16178
+ var source = this;
16179
+ selector = Utils.createLambda(selector);
16180
+ return new Enumerable(function() {
16181
+ var enumerator;
16182
+ return new IEnumerator(
16183
+ function() {
16184
+ enumerator = source.getEnumerator();
16185
+ enumerator.moveNext();
16186
+ },
16187
+ function() {
16188
+ var prev = enumerator.current();
16189
+ return enumerator.moveNext() ? this.yieldReturn(selector(prev, enumerator.current())) : false;
16190
+ },
16191
+ function() {
16192
+ Utils.dispose(enumerator);
16193
+ }
16194
+ );
16195
+ });
16196
+ };
16197
+ Enumerable.prototype.scan = function(seed, func) {
16198
+ var isUseSeed;
16199
+ if (func == null) {
16200
+ func = Utils.createLambda(seed);
16201
+ isUseSeed = false;
16202
+ } else {
16203
+ func = Utils.createLambda(func);
16204
+ isUseSeed = true;
16205
+ }
16206
+ var source = this;
16207
+ return new Enumerable(function() {
16208
+ var enumerator;
16209
+ var value;
16210
+ var isFirst = true;
16211
+ return new IEnumerator(
16212
+ function() {
16213
+ enumerator = source.getEnumerator();
16214
+ },
16215
+ function() {
16216
+ if (isFirst) {
16217
+ isFirst = false;
16218
+ if (!isUseSeed) {
16219
+ if (enumerator.moveNext()) {
16220
+ return this.yieldReturn(value = enumerator.current());
16221
+ }
16222
+ } else {
16223
+ return this.yieldReturn(value = seed);
16224
+ }
16225
+ }
16226
+ return enumerator.moveNext() ? this.yieldReturn(value = func(value, enumerator.current())) : false;
16227
+ },
16228
+ function() {
16229
+ Utils.dispose(enumerator);
16230
+ }
16231
+ );
16232
+ });
16233
+ };
16234
+ Enumerable.prototype.select = function(selector) {
16235
+ selector = Utils.createLambda(selector);
16236
+ if (selector.length <= 1) {
16237
+ return new WhereSelectEnumerable(this, null, selector);
16238
+ } else {
16239
+ var source = this;
16240
+ return new Enumerable(function() {
16241
+ var enumerator;
16242
+ var index = 0;
16243
+ return new IEnumerator(
16244
+ function() {
16245
+ enumerator = source.getEnumerator();
16246
+ },
16247
+ function() {
16248
+ return enumerator.moveNext() ? this.yieldReturn(selector(enumerator.current(), index++)) : false;
16249
+ },
16250
+ function() {
16251
+ Utils.dispose(enumerator);
16252
+ }
16253
+ );
16254
+ });
16255
+ }
16256
+ };
16257
+ Enumerable.prototype.selectMany = function(collectionSelector, resultSelector) {
16258
+ var source = this;
16259
+ collectionSelector = Utils.createLambda(collectionSelector);
16260
+ if (resultSelector == null)
16261
+ resultSelector = function(a, b) {
16262
+ return b;
16263
+ };
16264
+ resultSelector = Utils.createLambda(resultSelector);
16265
+ return new Enumerable(function() {
16266
+ var enumerator;
16267
+ var middleEnumerator = void 0;
16268
+ var index = 0;
16269
+ return new IEnumerator(
16270
+ function() {
16271
+ enumerator = source.getEnumerator();
16272
+ },
16273
+ function() {
16274
+ if (middleEnumerator === void 0) {
16275
+ if (!enumerator.moveNext())
16276
+ return false;
16277
+ }
16278
+ do {
16279
+ if (middleEnumerator == null) {
16280
+ const middleSeq = collectionSelector(enumerator.current(), index++);
16281
+ middleEnumerator = Enumerable.from(middleSeq).getEnumerator();
16282
+ }
16283
+ if (middleEnumerator.moveNext()) {
16284
+ return this.yieldReturn(resultSelector(enumerator.current(), middleEnumerator.current()));
16285
+ }
16286
+ Utils.dispose(middleEnumerator);
16287
+ middleEnumerator = null;
16288
+ } while (enumerator.moveNext());
16289
+ return false;
16290
+ },
16291
+ function() {
16292
+ try {
16293
+ Utils.dispose(enumerator);
16294
+ } finally {
16295
+ Utils.dispose(middleEnumerator);
16296
+ }
16297
+ }
16298
+ );
16299
+ });
16300
+ };
16301
+ Enumerable.prototype.where = function(predicate) {
16302
+ predicate = Utils.createLambda(predicate);
16303
+ if (predicate.length <= 1) {
16304
+ return new WhereEnumerable(this, predicate);
16305
+ } else {
16306
+ var source = this;
16307
+ return new Enumerable(function() {
16308
+ var enumerator;
16309
+ var index = 0;
16310
+ return new IEnumerator(
16311
+ function() {
16312
+ enumerator = source.getEnumerator();
16313
+ },
16314
+ function() {
16315
+ while (enumerator.moveNext()) {
16316
+ if (predicate(enumerator.current(), index++)) {
16317
+ return this.yieldReturn(enumerator.current());
16318
+ }
16319
+ }
16320
+ return false;
16321
+ },
16322
+ function() {
16323
+ Utils.dispose(enumerator);
16324
+ }
16325
+ );
16326
+ });
16327
+ }
16328
+ };
16329
+ Enumerable.prototype.choose = function(selector) {
16330
+ selector = Utils.createLambda(selector);
16331
+ var source = this;
16332
+ return new Enumerable(function() {
16333
+ var enumerator;
16334
+ var index = 0;
16335
+ return new IEnumerator(
16336
+ function() {
16337
+ enumerator = source.getEnumerator();
16338
+ },
16339
+ function() {
16340
+ while (enumerator.moveNext()) {
16341
+ const result = selector(enumerator.current(), index++);
16342
+ if (result != null) {
16343
+ return this.yieldReturn(result);
16344
+ }
16345
+ }
16346
+ return this.yieldBreak();
16347
+ },
16348
+ function() {
16349
+ Utils.dispose(enumerator);
16350
+ }
16351
+ );
16352
+ });
16353
+ };
16354
+ Enumerable.prototype.ofType = function(type) {
16355
+ var typeName;
16356
+ switch (type) {
16357
+ case Number:
16358
+ typeName = Types.Number;
16359
+ break;
16360
+ case String:
16361
+ typeName = Types.String;
16362
+ break;
16363
+ case Boolean:
16364
+ typeName = Types.Boolean;
16365
+ break;
16366
+ case Function:
16367
+ typeName = Types.Function;
16368
+ break;
16369
+ default:
16370
+ typeName = null;
16371
+ break;
16372
+ }
16373
+ return typeName === null ? this.where(function(x) {
16374
+ return x instanceof type;
16375
+ }) : this.where(function(x) {
16376
+ return typeof x === typeName;
16377
+ });
16378
+ };
16379
+ Enumerable.prototype.zip = function() {
16380
+ var args = arguments;
16381
+ var selector = Utils.createLambda(arguments[arguments.length - 1]);
16382
+ var source = this;
16383
+ if (arguments.length == 2) {
16384
+ const second = arguments[0];
16385
+ return new Enumerable(function() {
16386
+ var firstEnumerator;
16387
+ var secondEnumerator;
16388
+ var index = 0;
16389
+ return new IEnumerator(
16390
+ function() {
16391
+ firstEnumerator = source.getEnumerator();
16392
+ secondEnumerator = Enumerable.from(second).getEnumerator();
16393
+ },
16394
+ function() {
16395
+ if (firstEnumerator.moveNext() && secondEnumerator.moveNext()) {
16396
+ return this.yieldReturn(selector(firstEnumerator.current(), secondEnumerator.current(), index++));
16397
+ }
16398
+ return false;
16399
+ },
16400
+ function() {
16401
+ try {
16402
+ Utils.dispose(firstEnumerator);
16403
+ } finally {
16404
+ Utils.dispose(secondEnumerator);
16405
+ }
16406
+ }
16407
+ );
16408
+ });
16409
+ } else {
16410
+ return new Enumerable(function() {
16411
+ var enumerators;
16412
+ var index = 0;
16413
+ return new IEnumerator(
16414
+ function() {
16415
+ var array = Enumerable.make(source).concat(Enumerable.from(args).takeExceptLast().select(Enumerable.from)).select(function(x) {
16416
+ return x.getEnumerator();
16417
+ }).toArray();
16418
+ enumerators = Enumerable.from(array);
16419
+ },
16420
+ function() {
16421
+ if (enumerators.all(function(x) {
16422
+ return x.moveNext();
16423
+ })) {
16424
+ const array = enumerators.select(function(x) {
16425
+ return x.current();
16426
+ }).toArray();
16427
+ array.push(index++);
16428
+ return this.yieldReturn(selector.apply(null, array));
16429
+ } else {
16430
+ return this.yieldBreak();
16431
+ }
16432
+ },
16433
+ function() {
16434
+ Enumerable.from(enumerators).forEach(Utils.dispose);
16435
+ }
16436
+ );
16437
+ });
16438
+ }
16439
+ };
16440
+ Enumerable.prototype.merge = function() {
16441
+ var args = arguments;
16442
+ var source = this;
16443
+ return new Enumerable(function() {
16444
+ var enumerators;
16445
+ var index = -1;
16446
+ return new IEnumerator(
16447
+ function() {
16448
+ enumerators = Enumerable.make(source).concat(Enumerable.from(args).select(Enumerable.from)).select(function(x) {
16449
+ return x.getEnumerator();
16450
+ }).toArray();
16451
+ },
16452
+ function() {
16453
+ while (enumerators.length > 0) {
16454
+ index = index >= enumerators.length - 1 ? 0 : index + 1;
16455
+ const enumerator = enumerators[index];
16456
+ if (enumerator.moveNext()) {
16457
+ return this.yieldReturn(enumerator.current());
16458
+ } else {
16459
+ enumerator.dispose();
16460
+ enumerators.splice(index--, 1);
16461
+ }
16462
+ }
16463
+ return this.yieldBreak();
16464
+ },
16465
+ function() {
16466
+ Enumerable.from(enumerators).forEach(Utils.dispose);
16467
+ }
16468
+ );
16469
+ });
16470
+ };
16471
+ Enumerable.prototype.join = function(inner, outerKeySelector, innerKeySelector, resultSelector, compareSelector) {
16472
+ outerKeySelector = Utils.createLambda(outerKeySelector);
16473
+ innerKeySelector = Utils.createLambda(innerKeySelector);
16474
+ resultSelector = Utils.createLambda(resultSelector);
16475
+ compareSelector = Utils.createLambda(compareSelector);
16476
+ var source = this;
16477
+ return new Enumerable(function() {
16478
+ var outerEnumerator;
16479
+ var lookup;
16480
+ var innerElements = null;
16481
+ var innerCount = 0;
16482
+ return new IEnumerator(
16483
+ function() {
16484
+ outerEnumerator = source.getEnumerator();
16485
+ lookup = Enumerable.from(inner).toLookup(innerKeySelector, Functions.Identity, compareSelector);
16486
+ },
16487
+ function() {
16488
+ while (true) {
16489
+ if (innerElements != null) {
16490
+ let innerElement = innerElements[innerCount++];
16491
+ if (innerElement !== void 0) {
16492
+ return this.yieldReturn(resultSelector(outerEnumerator.current(), innerElement));
16493
+ }
16494
+ innerElement = null;
16495
+ innerCount = 0;
16496
+ }
16497
+ if (outerEnumerator.moveNext()) {
16498
+ const key = outerKeySelector(outerEnumerator.current());
16499
+ innerElements = lookup.get(key).toArray();
16500
+ } else {
16501
+ return false;
16502
+ }
16503
+ }
16504
+ },
16505
+ function() {
16506
+ Utils.dispose(outerEnumerator);
16507
+ }
16508
+ );
16509
+ });
16510
+ };
16511
+ Enumerable.prototype.leftJoin = function(inner, outerKeySelector, innerKeySelector, resultSelector, compareSelector) {
16512
+ outerKeySelector = Utils.createLambda(outerKeySelector);
16513
+ innerKeySelector = Utils.createLambda(innerKeySelector);
16514
+ resultSelector = Utils.createLambda(resultSelector);
16515
+ compareSelector = Utils.createLambda(compareSelector);
16516
+ var source = this;
16517
+ return new Enumerable(function() {
16518
+ var outerEnumerator;
16519
+ var lookup;
16520
+ var innerElements = null;
16521
+ var innerCount = 0;
16522
+ return new IEnumerator(
16523
+ function() {
16524
+ outerEnumerator = source.getEnumerator();
16525
+ lookup = Enumerable.from(inner).toLookup(innerKeySelector, Functions.Identity, compareSelector);
16526
+ },
16527
+ function() {
16528
+ while (true) {
16529
+ if (innerElements != null) {
16530
+ let innerElement = innerElements[innerCount++];
16531
+ if (innerElement !== void 0) {
16532
+ return this.yieldReturn(resultSelector(outerEnumerator.current(), innerElement));
16533
+ }
16534
+ innerElement = null;
16535
+ innerCount = 0;
16536
+ }
16537
+ if (outerEnumerator.moveNext()) {
16538
+ const key = outerKeySelector(outerEnumerator.current());
16539
+ innerElements = lookup.get(key).toArray();
16540
+ if (innerElements == null || innerElements.length == 0) {
16541
+ return this.yieldReturn(resultSelector(outerEnumerator.current(), null));
16542
+ }
16543
+ } else {
16544
+ return false;
16545
+ }
16546
+ }
16547
+ },
16548
+ function() {
16549
+ Utils.dispose(outerEnumerator);
16550
+ }
16551
+ );
16552
+ });
16553
+ };
16554
+ Enumerable.prototype.groupJoin = function(inner, outerKeySelector, innerKeySelector, resultSelector, compareSelector) {
16555
+ outerKeySelector = Utils.createLambda(outerKeySelector);
16556
+ innerKeySelector = Utils.createLambda(innerKeySelector);
16557
+ resultSelector = Utils.createLambda(resultSelector);
16558
+ compareSelector = Utils.createLambda(compareSelector);
16559
+ var source = this;
16560
+ return new Enumerable(function() {
16561
+ var enumerator = source.getEnumerator();
16562
+ var lookup = null;
16563
+ return new IEnumerator(
16564
+ function() {
16565
+ enumerator = source.getEnumerator();
16566
+ lookup = Enumerable.from(inner).toLookup(innerKeySelector, Functions.Identity, compareSelector);
16567
+ },
16568
+ function() {
16569
+ if (enumerator.moveNext()) {
16570
+ const innerElement = lookup.get(outerKeySelector(enumerator.current()));
16571
+ return this.yieldReturn(resultSelector(enumerator.current(), innerElement));
16572
+ }
16573
+ return false;
16574
+ },
16575
+ function() {
16576
+ Utils.dispose(enumerator);
16577
+ }
16578
+ );
16579
+ });
16580
+ };
16581
+ Enumerable.prototype.all = function(predicate) {
16582
+ predicate = Utils.createLambda(predicate);
16583
+ var result = true;
16584
+ this.forEach(function(x) {
16585
+ if (!predicate(x)) {
16586
+ result = false;
16587
+ return false;
16588
+ }
16589
+ });
16590
+ return result;
16591
+ };
16592
+ Enumerable.prototype.any = function(predicate) {
16593
+ predicate = Utils.createLambda(predicate);
16594
+ var enumerator = this.getEnumerator();
16595
+ try {
16596
+ if (arguments.length == 0)
16597
+ return enumerator.moveNext();
16598
+ while (enumerator.moveNext()) {
16599
+ if (predicate(enumerator.current()))
16600
+ return true;
16601
+ }
16602
+ return false;
16603
+ } finally {
16604
+ Utils.dispose(enumerator);
16605
+ }
16606
+ };
16607
+ Enumerable.prototype.isEmpty = function() {
16608
+ return !this.any();
16609
+ };
16610
+ Enumerable.prototype.concat = function() {
16611
+ var source = this;
16612
+ if (arguments.length == 1) {
16613
+ const second = arguments[0];
16614
+ return new Enumerable(function() {
16615
+ var firstEnumerator;
16616
+ var secondEnumerator;
16617
+ return new IEnumerator(
16618
+ function() {
16619
+ firstEnumerator = source.getEnumerator();
16620
+ },
16621
+ function() {
16622
+ if (secondEnumerator == null) {
16623
+ if (firstEnumerator.moveNext())
16624
+ return this.yieldReturn(firstEnumerator.current());
16625
+ secondEnumerator = Enumerable.from(second).getEnumerator();
16626
+ }
16627
+ if (secondEnumerator.moveNext())
16628
+ return this.yieldReturn(secondEnumerator.current());
16629
+ return false;
16630
+ },
16631
+ function() {
16632
+ try {
16633
+ Utils.dispose(firstEnumerator);
16634
+ } finally {
16635
+ Utils.dispose(secondEnumerator);
16636
+ }
16637
+ }
16638
+ );
16639
+ });
16640
+ } else {
16641
+ const args = arguments;
16642
+ return new Enumerable(function() {
16643
+ var enumerators;
16644
+ return new IEnumerator(
16645
+ function() {
16646
+ enumerators = Enumerable.make(source).concat(Enumerable.from(args).select(Enumerable.from)).select(function(x) {
16647
+ return x.getEnumerator();
16648
+ }).toArray();
16649
+ },
16650
+ function() {
16651
+ while (enumerators.length > 0) {
16652
+ const enumerator = enumerators[0];
16653
+ if (enumerator.moveNext()) {
16654
+ return this.yieldReturn(enumerator.current());
16655
+ } else {
16656
+ enumerator.dispose();
16657
+ enumerators.splice(0, 1);
16658
+ }
16659
+ }
16660
+ return this.yieldBreak();
16661
+ },
16662
+ function() {
16663
+ Enumerable.from(enumerators).forEach(Utils.dispose);
16664
+ }
16665
+ );
16666
+ });
16667
+ }
16668
+ };
16669
+ Enumerable.prototype.insert = function(index, second) {
16670
+ var source = this;
16671
+ return new Enumerable(function() {
16672
+ var firstEnumerator;
16673
+ var secondEnumerator;
16674
+ var count = 0;
16675
+ var isEnumerated = false;
16676
+ return new IEnumerator(
16677
+ function() {
16678
+ firstEnumerator = source.getEnumerator();
16679
+ secondEnumerator = Enumerable.from(second).getEnumerator();
16680
+ },
16681
+ function() {
16682
+ if (count == index && secondEnumerator.moveNext()) {
16683
+ isEnumerated = true;
16684
+ return this.yieldReturn(secondEnumerator.current());
16685
+ }
16686
+ if (firstEnumerator.moveNext()) {
16687
+ count++;
16688
+ return this.yieldReturn(firstEnumerator.current());
16689
+ }
16690
+ if (!isEnumerated && secondEnumerator.moveNext()) {
16691
+ return this.yieldReturn(secondEnumerator.current());
16692
+ }
16693
+ return false;
16694
+ },
16695
+ function() {
16696
+ try {
16697
+ Utils.dispose(firstEnumerator);
16698
+ } finally {
16699
+ Utils.dispose(secondEnumerator);
16700
+ }
16701
+ }
16702
+ );
16703
+ });
16704
+ };
16705
+ Enumerable.prototype.alternate = function(alternateValueOrSequence) {
16706
+ var source = this;
16707
+ return new Enumerable(function() {
16708
+ var buffer;
16709
+ var enumerator;
16710
+ var alternateSequence;
16711
+ var alternateEnumerator;
16712
+ return new IEnumerator(
16713
+ function() {
16714
+ if (alternateValueOrSequence instanceof Array || alternateValueOrSequence.getEnumerator != null) {
16715
+ alternateSequence = Enumerable.from(Enumerable.from(alternateValueOrSequence).toArray());
16716
+ } else {
16717
+ alternateSequence = Enumerable.make(alternateValueOrSequence);
16718
+ }
16719
+ enumerator = source.getEnumerator();
16720
+ if (enumerator.moveNext())
16721
+ buffer = enumerator.current();
16722
+ },
16723
+ function() {
16724
+ while (true) {
16725
+ if (alternateEnumerator != null) {
16726
+ if (alternateEnumerator.moveNext()) {
16727
+ return this.yieldReturn(alternateEnumerator.current());
16728
+ } else {
16729
+ alternateEnumerator = null;
16730
+ }
16731
+ }
16732
+ if (buffer == null && enumerator.moveNext()) {
16733
+ buffer = enumerator.current();
16734
+ alternateEnumerator = alternateSequence.getEnumerator();
16735
+ continue;
16736
+ } else if (buffer != null) {
16737
+ const retVal = buffer;
16738
+ buffer = null;
16739
+ return this.yieldReturn(retVal);
16740
+ }
16741
+ return this.yieldBreak();
16742
+ }
16743
+ },
16744
+ function() {
16745
+ try {
16746
+ Utils.dispose(enumerator);
16747
+ } finally {
16748
+ Utils.dispose(alternateEnumerator);
16749
+ }
16750
+ }
16751
+ );
16752
+ });
16753
+ };
16754
+ Enumerable.prototype.contains = function(value, compareSelector) {
16755
+ compareSelector = Utils.createLambda(compareSelector);
16756
+ var enumerator = this.getEnumerator();
16757
+ try {
16758
+ while (enumerator.moveNext()) {
16759
+ if (compareSelector(enumerator.current()) === value)
16760
+ return true;
16761
+ }
16762
+ return false;
16763
+ } finally {
16764
+ Utils.dispose(enumerator);
16765
+ }
16766
+ };
16767
+ Enumerable.prototype.defaultIfEmpty = function(defaultValue) {
16768
+ var source = this;
16769
+ if (defaultValue === void 0)
16770
+ defaultValue = null;
16771
+ return new Enumerable(function() {
16772
+ var enumerator;
16773
+ var isFirst = true;
16774
+ return new IEnumerator(
16775
+ function() {
16776
+ enumerator = source.getEnumerator();
16777
+ },
16778
+ function() {
16779
+ if (enumerator.moveNext()) {
16780
+ isFirst = false;
16781
+ return this.yieldReturn(enumerator.current());
16782
+ } else if (isFirst) {
16783
+ isFirst = false;
16784
+ return this.yieldReturn(defaultValue);
16785
+ }
16786
+ return false;
16787
+ },
16788
+ function() {
16789
+ Utils.dispose(enumerator);
16790
+ }
16791
+ );
16792
+ });
16793
+ };
16794
+ Enumerable.prototype.distinct = function(compareSelector) {
16795
+ return this.except(Enumerable.empty(), compareSelector);
16796
+ };
16797
+ Enumerable.prototype.distinctUntilChanged = function(compareSelector) {
16798
+ compareSelector = Utils.createLambda(compareSelector);
16799
+ var source = this;
16800
+ return new Enumerable(function() {
16801
+ var enumerator;
16802
+ var compareKey;
16803
+ return new IEnumerator(
16804
+ function() {
16805
+ enumerator = source.getEnumerator();
16806
+ },
16807
+ function() {
16808
+ while (enumerator.moveNext()) {
16809
+ const key = compareSelector(enumerator.current());
16810
+ if (compareKey === key) {
16811
+ continue;
16812
+ }
16813
+ compareKey = key;
16814
+ return this.yieldReturn(enumerator.current());
16815
+ }
16816
+ return this.yieldBreak();
16817
+ },
16818
+ function() {
16819
+ Utils.dispose(enumerator);
16820
+ }
16821
+ );
16822
+ });
16823
+ };
16824
+ Enumerable.prototype.except = function(second, compareSelector) {
16825
+ compareSelector = Utils.createLambda(compareSelector);
16826
+ var source = this;
16827
+ return new Enumerable(function() {
16828
+ var enumerator;
16829
+ var keys;
16830
+ return new IEnumerator(
16831
+ function() {
16832
+ enumerator = source.getEnumerator();
16833
+ keys = new Dictionary(compareSelector);
16834
+ Enumerable.from(second).forEach(function(key) {
16835
+ keys.add(key);
16836
+ });
16837
+ },
16838
+ function() {
16839
+ while (enumerator.moveNext()) {
16840
+ const current = enumerator.current();
16841
+ if (!keys.contains(current)) {
16842
+ keys.add(current);
16843
+ return this.yieldReturn(current);
16844
+ }
16845
+ }
16846
+ return false;
16847
+ },
16848
+ function() {
16849
+ Utils.dispose(enumerator);
16850
+ }
16851
+ );
16852
+ });
16853
+ };
16854
+ Enumerable.prototype.intersect = function(second, compareSelector) {
16855
+ compareSelector = Utils.createLambda(compareSelector);
16856
+ var source = this;
16857
+ return new Enumerable(function() {
16858
+ var enumerator;
16859
+ var keys;
16860
+ var outs;
16861
+ return new IEnumerator(
16862
+ function() {
16863
+ enumerator = source.getEnumerator();
16864
+ keys = new Dictionary(compareSelector);
16865
+ Enumerable.from(second).forEach(function(key) {
16866
+ keys.add(key);
16867
+ });
16868
+ outs = new Dictionary(compareSelector);
16869
+ },
16870
+ function() {
16871
+ while (enumerator.moveNext()) {
16872
+ const current = enumerator.current();
16873
+ if (!outs.contains(current) && keys.contains(current)) {
16874
+ outs.add(current);
16875
+ return this.yieldReturn(current);
16876
+ }
16877
+ }
16878
+ return false;
16879
+ },
16880
+ function() {
16881
+ Utils.dispose(enumerator);
16882
+ }
16883
+ );
16884
+ });
16885
+ };
16886
+ Enumerable.prototype.sequenceEqual = function(second, compareSelector) {
16887
+ compareSelector = Utils.createLambda(compareSelector);
16888
+ var firstEnumerator = this.getEnumerator();
16889
+ try {
16890
+ const secondEnumerator = Enumerable.from(second).getEnumerator();
16891
+ try {
16892
+ while (firstEnumerator.moveNext()) {
16893
+ if (!secondEnumerator.moveNext() || compareSelector(firstEnumerator.current()) !== compareSelector(secondEnumerator.current())) {
16894
+ return false;
16895
+ }
16896
+ }
16897
+ if (secondEnumerator.moveNext())
16898
+ return false;
16899
+ return true;
16900
+ } finally {
16901
+ Utils.dispose(secondEnumerator);
16902
+ }
16903
+ } finally {
16904
+ Utils.dispose(firstEnumerator);
16905
+ }
16906
+ };
16907
+ Enumerable.prototype.union = function(second, compareSelector) {
16908
+ compareSelector = Utils.createLambda(compareSelector);
16909
+ var source = this;
16910
+ return new Enumerable(function() {
16911
+ var firstEnumerator;
16912
+ var secondEnumerator;
16913
+ var keys;
16914
+ return new IEnumerator(
16915
+ function() {
16916
+ firstEnumerator = source.getEnumerator();
16917
+ keys = new Dictionary(compareSelector);
16918
+ },
16919
+ function() {
16920
+ var current;
16921
+ if (secondEnumerator === void 0) {
16922
+ while (firstEnumerator.moveNext()) {
16923
+ current = firstEnumerator.current();
16924
+ if (!keys.contains(current)) {
16925
+ keys.add(current);
16926
+ return this.yieldReturn(current);
16927
+ }
16928
+ }
16929
+ secondEnumerator = Enumerable.from(second).getEnumerator();
16930
+ }
16931
+ while (secondEnumerator.moveNext()) {
16932
+ current = secondEnumerator.current();
16933
+ if (!keys.contains(current)) {
16934
+ keys.add(current);
16935
+ return this.yieldReturn(current);
16936
+ }
16937
+ }
16938
+ return false;
16939
+ },
16940
+ function() {
16941
+ try {
16942
+ Utils.dispose(firstEnumerator);
16943
+ } finally {
16944
+ Utils.dispose(secondEnumerator);
16945
+ }
16946
+ }
16947
+ );
16948
+ });
16949
+ };
16950
+ Enumerable.prototype.orderBy = function(keySelector, comparer) {
16951
+ return new OrderedEnumerable(this, keySelector, comparer, false);
16952
+ };
16953
+ Enumerable.prototype.orderByDescending = function(keySelector, comparer) {
16954
+ return new OrderedEnumerable(this, keySelector, comparer, true);
16955
+ };
16956
+ Enumerable.prototype.reverse = function() {
16957
+ var source = this;
16958
+ return new Enumerable(function() {
16959
+ var buffer;
16960
+ var index;
16961
+ return new IEnumerator(
16962
+ function() {
16963
+ buffer = source.toArray();
16964
+ index = buffer.length;
16965
+ },
16966
+ function() {
16967
+ return index > 0 ? this.yieldReturn(buffer[--index]) : false;
16968
+ },
16969
+ Functions.Blank
16970
+ );
16971
+ });
16972
+ };
16973
+ Enumerable.prototype.shuffle = function() {
16974
+ var source = this;
16975
+ return new Enumerable(function() {
16976
+ var buffer;
16977
+ return new IEnumerator(
16978
+ function() {
16979
+ buffer = source.toArray();
16980
+ },
16981
+ function() {
16982
+ if (buffer.length > 0) {
16983
+ const i = Math.floor(Math.random() * buffer.length);
16984
+ return this.yieldReturn(buffer.splice(i, 1)[0]);
16985
+ }
16986
+ return false;
16987
+ },
16988
+ Functions.Blank
16989
+ );
16990
+ });
16991
+ };
16992
+ Enumerable.prototype.weightedSample = function(weightSelector) {
16993
+ weightSelector = Utils.createLambda(weightSelector);
16994
+ var source = this;
16995
+ return new Enumerable(function() {
16996
+ var sortedByBound;
16997
+ var totalWeight = 0;
16998
+ return new IEnumerator(
16999
+ function() {
17000
+ sortedByBound = source.choose(function(x) {
17001
+ var weight = weightSelector(x);
17002
+ if (weight <= 0)
17003
+ return null;
17004
+ totalWeight += weight;
17005
+ return { value: x, bound: totalWeight };
17006
+ }).toArray();
17007
+ },
17008
+ function() {
17009
+ if (sortedByBound.length > 0) {
17010
+ const draw = Math.floor(Math.random() * totalWeight) + 1;
17011
+ let lower = -1;
17012
+ let upper = sortedByBound.length;
17013
+ while (upper - lower > 1) {
17014
+ const index = Math.floor((lower + upper) / 2);
17015
+ if (sortedByBound[index].bound >= draw) {
17016
+ upper = index;
17017
+ } else {
17018
+ lower = index;
17019
+ }
17020
+ }
17021
+ return this.yieldReturn(sortedByBound[upper].value);
17022
+ }
17023
+ return this.yieldBreak();
17024
+ },
17025
+ Functions.Blank
17026
+ );
17027
+ });
17028
+ };
17029
+ Enumerable.prototype.groupBy = function(keySelector, elementSelector, resultSelector, compareSelector) {
17030
+ var source = this;
17031
+ keySelector = Utils.createLambda(keySelector);
17032
+ elementSelector = Utils.createLambda(elementSelector);
17033
+ if (resultSelector != null)
17034
+ resultSelector = Utils.createLambda(resultSelector);
17035
+ compareSelector = Utils.createLambda(compareSelector);
17036
+ return new Enumerable(function() {
17037
+ var enumerator;
17038
+ return new IEnumerator(
17039
+ function() {
17040
+ enumerator = source.toLookup(keySelector, elementSelector, compareSelector).toEnumerable().getEnumerator();
17041
+ },
17042
+ function() {
17043
+ while (enumerator.moveNext()) {
17044
+ return resultSelector == null ? this.yieldReturn(enumerator.current()) : this.yieldReturn(resultSelector(enumerator.current().key(), enumerator.current()));
17045
+ }
17046
+ return false;
17047
+ },
17048
+ function() {
17049
+ Utils.dispose(enumerator);
17050
+ }
17051
+ );
17052
+ });
17053
+ };
17054
+ Enumerable.prototype.partitionBy = function(keySelector, elementSelector, resultSelector, compareSelector) {
17055
+ var source = this;
17056
+ keySelector = Utils.createLambda(keySelector);
17057
+ elementSelector = Utils.createLambda(elementSelector);
17058
+ compareSelector = Utils.createLambda(compareSelector);
17059
+ var hasResultSelector;
17060
+ if (resultSelector == null) {
17061
+ hasResultSelector = false;
17062
+ resultSelector = function(key, group) {
17063
+ return new Grouping(key, group);
17064
+ };
17065
+ } else {
17066
+ hasResultSelector = true;
17067
+ resultSelector = Utils.createLambda(resultSelector);
17068
+ }
17069
+ return new Enumerable(function() {
17070
+ var enumerator;
17071
+ var key;
17072
+ var compareKey;
17073
+ var group = [];
17074
+ return new IEnumerator(
17075
+ function() {
17076
+ enumerator = source.getEnumerator();
17077
+ if (enumerator.moveNext()) {
17078
+ key = keySelector(enumerator.current());
17079
+ compareKey = compareSelector(key);
17080
+ group.push(elementSelector(enumerator.current()));
17081
+ }
17082
+ },
17083
+ function() {
17084
+ var hasNext;
17085
+ while ((hasNext = enumerator.moveNext()) == true) {
17086
+ if (compareKey === compareSelector(keySelector(enumerator.current()))) {
17087
+ group.push(elementSelector(enumerator.current()));
17088
+ } else
17089
+ break;
17090
+ }
17091
+ if (group.length > 0) {
17092
+ const result = hasResultSelector ? resultSelector(key, Enumerable.from(group)) : resultSelector(key, group);
17093
+ if (hasNext) {
17094
+ key = keySelector(enumerator.current());
17095
+ compareKey = compareSelector(key);
17096
+ group = [elementSelector(enumerator.current())];
17097
+ } else
17098
+ group = [];
17099
+ return this.yieldReturn(result);
17100
+ }
17101
+ return false;
17102
+ },
17103
+ function() {
17104
+ Utils.dispose(enumerator);
17105
+ }
17106
+ );
17107
+ });
17108
+ };
17109
+ Enumerable.prototype.buffer = function(count) {
17110
+ var source = this;
17111
+ return new Enumerable(function() {
17112
+ var enumerator;
17113
+ return new IEnumerator(
17114
+ function() {
17115
+ enumerator = source.getEnumerator();
17116
+ },
17117
+ function() {
17118
+ var array = [];
17119
+ var index = 0;
17120
+ while (enumerator.moveNext()) {
17121
+ array.push(enumerator.current());
17122
+ if (++index >= count)
17123
+ return this.yieldReturn(array);
17124
+ }
17125
+ if (array.length > 0)
17126
+ return this.yieldReturn(array);
17127
+ return false;
17128
+ },
17129
+ function() {
17130
+ Utils.dispose(enumerator);
17131
+ }
17132
+ );
17133
+ });
17134
+ };
17135
+ Enumerable.prototype.aggregate = function(seed, func, resultSelector) {
17136
+ resultSelector = Utils.createLambda(resultSelector);
17137
+ return resultSelector(this.scan(seed, func, resultSelector).last());
17138
+ };
17139
+ Enumerable.prototype.average = function(selector) {
17140
+ selector = Utils.createLambda(selector);
17141
+ var sum = 0;
17142
+ var count = 0;
17143
+ this.forEach(function(x) {
17144
+ sum += selector(x);
17145
+ ++count;
17146
+ });
17147
+ return sum / count;
17148
+ };
17149
+ Enumerable.prototype.count = function(predicate) {
17150
+ predicate = predicate == null ? Functions.True : Utils.createLambda(predicate);
17151
+ var count = 0;
17152
+ this.forEach(function(x, i) {
17153
+ if (predicate(x, i))
17154
+ ++count;
17155
+ });
17156
+ return count;
17157
+ };
17158
+ Enumerable.prototype.max = function(selector) {
17159
+ if (selector == null)
17160
+ selector = Functions.Identity;
17161
+ return this.select(selector).aggregate(function(a, b) {
17162
+ return a > b ? a : b;
17163
+ });
17164
+ };
17165
+ Enumerable.prototype.min = function(selector) {
17166
+ if (selector == null)
17167
+ selector = Functions.Identity;
17168
+ return this.select(selector).aggregate(function(a, b) {
17169
+ return a < b ? a : b;
17170
+ });
17171
+ };
17172
+ Enumerable.prototype.maxBy = function(keySelector) {
17173
+ keySelector = Utils.createLambda(keySelector);
17174
+ return this.aggregate(function(a, b) {
17175
+ return keySelector(a) > keySelector(b) ? a : b;
17176
+ });
17177
+ };
17178
+ Enumerable.prototype.minBy = function(keySelector) {
17179
+ keySelector = Utils.createLambda(keySelector);
17180
+ return this.aggregate(function(a, b) {
17181
+ return keySelector(a) < keySelector(b) ? a : b;
17182
+ });
17183
+ };
17184
+ Enumerable.prototype.sum = function(selector) {
17185
+ if (selector == null)
17186
+ selector = Functions.Identity;
17187
+ return this.select(selector).aggregate(0, function(a, b) {
17188
+ return a + b;
17189
+ });
17190
+ };
17191
+ Enumerable.prototype.elementAt = function(index) {
17192
+ var value;
17193
+ var found = false;
17194
+ this.forEach(function(x, i) {
17195
+ if (i == index) {
17196
+ value = x;
17197
+ found = true;
17198
+ return false;
17199
+ }
17200
+ });
17201
+ if (!found)
17202
+ throw new Error("index is less than 0 or greater than or equal to the number of elements in source.");
17203
+ return value;
17204
+ };
17205
+ Enumerable.prototype.elementAtOrDefault = function(index, defaultValue) {
17206
+ if (defaultValue === void 0)
17207
+ defaultValue = null;
17208
+ var value;
17209
+ var found = false;
17210
+ this.forEach(function(x, i) {
17211
+ if (i == index) {
17212
+ value = x;
17213
+ found = true;
17214
+ return false;
17215
+ }
17216
+ });
17217
+ return !found ? defaultValue : value;
17218
+ };
17219
+ Enumerable.prototype.first = function(predicate) {
17220
+ if (predicate != null)
17221
+ return this.where(predicate).first();
17222
+ var value;
17223
+ var found = false;
17224
+ this.forEach(function(x) {
17225
+ value = x;
17226
+ found = true;
17227
+ return false;
17228
+ });
17229
+ if (!found)
17230
+ throw new Error("first:No element satisfies the condition.");
17231
+ return value;
17232
+ };
17233
+ Enumerable.prototype.firstOrDefault = function(predicate, defaultValue) {
17234
+ if (predicate !== void 0) {
17235
+ if (typeof predicate === Types.Function || typeof Utils.createLambda(predicate) === Types.Function) {
17236
+ return this.where(predicate).firstOrDefault(void 0, defaultValue);
17237
+ }
17238
+ defaultValue = predicate;
17239
+ }
17240
+ var value;
17241
+ var found = false;
17242
+ this.forEach(function(x) {
17243
+ value = x;
17244
+ found = true;
17245
+ return false;
17246
+ });
17247
+ return !found ? defaultValue : value;
17248
+ };
17249
+ Enumerable.prototype.last = function(predicate) {
17250
+ if (predicate != null)
17251
+ return this.where(predicate).last();
17252
+ var value;
17253
+ var found = false;
17254
+ this.forEach(function(x) {
17255
+ found = true;
17256
+ value = x;
17257
+ });
17258
+ if (!found)
17259
+ throw new Error("last:No element satisfies the condition.");
17260
+ return value;
17261
+ };
17262
+ Enumerable.prototype.lastOrDefault = function(predicate, defaultValue) {
17263
+ if (predicate !== void 0) {
17264
+ if (typeof predicate === Types.Function || typeof Utils.createLambda(predicate) === Types.Function) {
17265
+ return this.where(predicate).lastOrDefault(void 0, defaultValue);
17266
+ }
17267
+ defaultValue = predicate;
17268
+ }
17269
+ var value;
17270
+ var found = false;
17271
+ this.forEach(function(x) {
17272
+ found = true;
17273
+ value = x;
17274
+ });
17275
+ return !found ? defaultValue : value;
17276
+ };
17277
+ Enumerable.prototype.single = function(predicate) {
17278
+ if (predicate != null)
17279
+ return this.where(predicate).single();
17280
+ var value;
17281
+ var found = false;
17282
+ this.forEach(function(x) {
17283
+ if (!found) {
17284
+ found = true;
17285
+ value = x;
17286
+ } else
17287
+ throw new Error("single:sequence contains more than one element.");
17288
+ });
17289
+ if (!found)
17290
+ throw new Error("single:No element satisfies the condition.");
17291
+ return value;
17292
+ };
17293
+ Enumerable.prototype.singleOrDefault = function(predicate, defaultValue) {
17294
+ if (defaultValue === void 0)
17295
+ defaultValue = null;
17296
+ if (predicate != null)
17297
+ return this.where(predicate).singleOrDefault(null, defaultValue);
17298
+ var value;
17299
+ var found = false;
17300
+ this.forEach(function(x) {
17301
+ if (!found) {
17302
+ found = true;
17303
+ value = x;
17304
+ } else
17305
+ throw new Error("single:sequence contains more than one element.");
17306
+ });
17307
+ return !found ? defaultValue : value;
17308
+ };
17309
+ Enumerable.prototype.skip = function(count) {
17310
+ var source = this;
17311
+ return new Enumerable(function() {
17312
+ var enumerator;
17313
+ var index = 0;
17314
+ return new IEnumerator(
17315
+ function() {
17316
+ enumerator = source.getEnumerator();
17317
+ while (index++ < count && enumerator.moveNext()) {
17318
+ }
17319
+ },
17320
+ function() {
17321
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17322
+ },
17323
+ function() {
17324
+ Utils.dispose(enumerator);
17325
+ }
17326
+ );
17327
+ });
17328
+ };
17329
+ Enumerable.prototype.skipWhile = function(predicate) {
17330
+ predicate = Utils.createLambda(predicate);
17331
+ var source = this;
17332
+ return new Enumerable(function() {
17333
+ var enumerator;
17334
+ var index = 0;
17335
+ var isSkipEnd = false;
17336
+ return new IEnumerator(
17337
+ function() {
17338
+ enumerator = source.getEnumerator();
17339
+ },
17340
+ function() {
17341
+ while (!isSkipEnd) {
17342
+ if (enumerator.moveNext()) {
17343
+ if (!predicate(enumerator.current(), index++)) {
17344
+ isSkipEnd = true;
17345
+ return this.yieldReturn(enumerator.current());
17346
+ }
17347
+ continue;
17348
+ } else
17349
+ return false;
17350
+ }
17351
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17352
+ },
17353
+ function() {
17354
+ Utils.dispose(enumerator);
17355
+ }
17356
+ );
17357
+ });
17358
+ };
17359
+ Enumerable.prototype.take = function(count) {
17360
+ var source = this;
17361
+ return new Enumerable(function() {
17362
+ var enumerator;
17363
+ var index = 0;
17364
+ return new IEnumerator(
17365
+ function() {
17366
+ enumerator = source.getEnumerator();
17367
+ },
17368
+ function() {
17369
+ return index++ < count && enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17370
+ },
17371
+ function() {
17372
+ Utils.dispose(enumerator);
17373
+ }
17374
+ );
17375
+ });
17376
+ };
17377
+ Enumerable.prototype.takeWhile = function(predicate) {
17378
+ predicate = Utils.createLambda(predicate);
17379
+ var source = this;
17380
+ return new Enumerable(function() {
17381
+ var enumerator;
17382
+ var index = 0;
17383
+ return new IEnumerator(
17384
+ function() {
17385
+ enumerator = source.getEnumerator();
17386
+ },
17387
+ function() {
17388
+ return enumerator.moveNext() && predicate(enumerator.current(), index++) ? this.yieldReturn(enumerator.current()) : false;
17389
+ },
17390
+ function() {
17391
+ Utils.dispose(enumerator);
17392
+ }
17393
+ );
17394
+ });
17395
+ };
17396
+ Enumerable.prototype.takeExceptLast = function(count) {
17397
+ if (count == null)
17398
+ count = 1;
17399
+ var source = this;
17400
+ return new Enumerable(function() {
17401
+ if (count <= 0)
17402
+ return source.getEnumerator();
17403
+ var enumerator;
17404
+ var q = [];
17405
+ return new IEnumerator(
17406
+ function() {
17407
+ enumerator = source.getEnumerator();
17408
+ },
17409
+ function() {
17410
+ while (enumerator.moveNext()) {
17411
+ if (q.length == count) {
17412
+ q.push(enumerator.current());
17413
+ return this.yieldReturn(q.shift());
17414
+ }
17415
+ q.push(enumerator.current());
17416
+ }
17417
+ return false;
17418
+ },
17419
+ function() {
17420
+ Utils.dispose(enumerator);
17421
+ }
17422
+ );
17423
+ });
17424
+ };
17425
+ Enumerable.prototype.takeFromLast = function(count) {
17426
+ if (count <= 0 || count == null)
17427
+ return Enumerable.empty();
17428
+ var source = this;
17429
+ return new Enumerable(function() {
17430
+ var sourceEnumerator;
17431
+ var enumerator;
17432
+ var q = [];
17433
+ return new IEnumerator(
17434
+ function() {
17435
+ sourceEnumerator = source.getEnumerator();
17436
+ },
17437
+ function() {
17438
+ while (sourceEnumerator.moveNext()) {
17439
+ if (q.length == count)
17440
+ q.shift();
17441
+ q.push(sourceEnumerator.current());
17442
+ }
17443
+ if (enumerator == null) {
17444
+ enumerator = Enumerable.from(q).getEnumerator();
17445
+ }
17446
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17447
+ },
17448
+ function() {
17449
+ Utils.dispose(enumerator);
17450
+ }
17451
+ );
17452
+ });
17453
+ };
17454
+ Enumerable.prototype.indexOf = function(item) {
17455
+ var found = null;
17456
+ if (typeof item === Types.Function) {
17457
+ this.forEach(function(x, i) {
17458
+ if (item(x, i)) {
17459
+ found = i;
17460
+ return false;
17461
+ }
17462
+ });
17463
+ } else {
17464
+ this.forEach(function(x, i) {
17465
+ if (x === item) {
17466
+ found = i;
17467
+ return false;
17468
+ }
17469
+ });
17470
+ }
17471
+ return found !== null ? found : -1;
17472
+ };
17473
+ Enumerable.prototype.lastIndexOf = function(item) {
17474
+ var result = -1;
17475
+ if (typeof item === Types.Function) {
17476
+ this.forEach(function(x, i) {
17477
+ if (item(x, i))
17478
+ result = i;
17479
+ });
17480
+ } else {
17481
+ this.forEach(function(x, i) {
17482
+ if (x === item)
17483
+ result = i;
17484
+ });
17485
+ }
17486
+ return result;
17487
+ };
17488
+ Enumerable.prototype.cast = function() {
17489
+ return this;
17490
+ };
17491
+ Enumerable.prototype.asEnumerable = function() {
17492
+ return Enumerable.from(this);
17493
+ };
17494
+ Enumerable.prototype.toArray = function() {
17495
+ var array = [];
17496
+ this.forEach(function(x) {
17497
+ array.push(x);
17498
+ });
17499
+ return array;
17500
+ };
17501
+ Enumerable.prototype.toLookup = function(keySelector, elementSelector, compareSelector) {
17502
+ keySelector = Utils.createLambda(keySelector);
17503
+ elementSelector = Utils.createLambda(elementSelector);
17504
+ compareSelector = Utils.createLambda(compareSelector);
17505
+ var dict = new Dictionary(compareSelector);
17506
+ this.forEach(function(x) {
17507
+ var key = keySelector(x);
17508
+ var element = elementSelector(x);
17509
+ var array = dict.get(key);
17510
+ if (array !== void 0)
17511
+ array.push(element);
17512
+ else
17513
+ dict.add(key, [element]);
17514
+ });
17515
+ return new Lookup(dict);
17516
+ };
17517
+ Enumerable.prototype.toObject = function(keySelector, elementSelector) {
17518
+ keySelector = Utils.createLambda(keySelector);
17519
+ elementSelector = Utils.createLambda(elementSelector);
17520
+ var obj = {};
17521
+ this.forEach(function(x) {
17522
+ obj[keySelector(x)] = elementSelector(x);
17523
+ });
17524
+ return obj;
17525
+ };
17526
+ Enumerable.prototype.toDictionary = function(keySelector, elementSelector, compareSelector) {
17527
+ keySelector = Utils.createLambda(keySelector);
17528
+ elementSelector = Utils.createLambda(elementSelector);
17529
+ compareSelector = Utils.createLambda(compareSelector);
17530
+ var dict = new Dictionary(compareSelector);
17531
+ this.forEach(function(x) {
17532
+ dict.add(keySelector(x), elementSelector(x));
17533
+ });
17534
+ return dict;
17535
+ };
17536
+ Enumerable.prototype.toJSONString = function(replacer, space) {
17537
+ if (typeof JSON === Types.Undefined || JSON.stringify == null) {
17538
+ throw new Error("toJSONString can't find JSON.stringify. This works native JSON support Browser or include json2.js");
17539
+ }
17540
+ return JSON.stringify(this.toArray(), replacer, space);
17541
+ };
17542
+ Enumerable.prototype.toJoinedString = function(separator, selector) {
17543
+ if (separator == null)
17544
+ separator = "";
17545
+ if (selector == null)
17546
+ selector = Functions.Identity;
17547
+ return this.select(selector).toArray().join(separator);
17548
+ };
17549
+ Enumerable.prototype.doAction = function(action) {
17550
+ var source = this;
17551
+ action = Utils.createLambda(action);
17552
+ return new Enumerable(function() {
17553
+ var enumerator;
17554
+ var index = 0;
17555
+ return new IEnumerator(
17556
+ function() {
17557
+ enumerator = source.getEnumerator();
17558
+ },
17559
+ function() {
17560
+ if (enumerator.moveNext()) {
17561
+ action(enumerator.current(), index++);
17562
+ return this.yieldReturn(enumerator.current());
17563
+ }
17564
+ return false;
17565
+ },
17566
+ function() {
17567
+ Utils.dispose(enumerator);
17568
+ }
17569
+ );
17570
+ });
17571
+ };
17572
+ Enumerable.prototype.forEach = function(action) {
17573
+ action = Utils.createLambda(action);
17574
+ var index = 0;
17575
+ var enumerator = this.getEnumerator();
17576
+ try {
17577
+ while (enumerator.moveNext()) {
17578
+ if (action(enumerator.current(), index++) === false)
17579
+ break;
17580
+ }
17581
+ } finally {
17582
+ Utils.dispose(enumerator);
17583
+ }
17584
+ };
17585
+ Enumerable.prototype.force = function() {
17586
+ var enumerator = this.getEnumerator();
17587
+ try {
17588
+ while (enumerator.moveNext()) {
17589
+ }
17590
+ } finally {
17591
+ Utils.dispose(enumerator);
17592
+ }
17593
+ };
17594
+ Enumerable.prototype.letBind = function(func) {
17595
+ func = Utils.createLambda(func);
17596
+ var source = this;
17597
+ return new Enumerable(function() {
17598
+ var enumerator;
17599
+ return new IEnumerator(
17600
+ function() {
17601
+ enumerator = Enumerable.from(func(source)).getEnumerator();
17602
+ },
17603
+ function() {
17604
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17605
+ },
17606
+ function() {
17607
+ Utils.dispose(enumerator);
17608
+ }
17609
+ );
17610
+ });
17611
+ };
17612
+ Enumerable.prototype.share = function() {
17613
+ var source = this;
17614
+ var sharedEnumerator;
17615
+ var disposed = false;
17616
+ return new DisposableEnumerable(function() {
17617
+ return new IEnumerator(
17618
+ function() {
17619
+ if (sharedEnumerator == null) {
17620
+ sharedEnumerator = source.getEnumerator();
17621
+ }
17622
+ },
17623
+ function() {
17624
+ if (disposed)
17625
+ throw new Error("enumerator is disposed");
17626
+ return sharedEnumerator.moveNext() ? this.yieldReturn(sharedEnumerator.current()) : false;
17627
+ },
17628
+ Functions.Blank
17629
+ );
17630
+ }, function() {
17631
+ disposed = true;
17632
+ Utils.dispose(sharedEnumerator);
17633
+ });
17634
+ };
17635
+ Enumerable.prototype.memoize = function() {
17636
+ var source = this;
17637
+ var cache;
17638
+ var enumerator;
17639
+ var disposed = false;
17640
+ return new DisposableEnumerable(function() {
17641
+ var index = -1;
17642
+ return new IEnumerator(
17643
+ function() {
17644
+ if (enumerator == null) {
17645
+ enumerator = source.getEnumerator();
17646
+ cache = [];
17647
+ }
17648
+ },
17649
+ function() {
17650
+ if (disposed)
17651
+ throw new Error("enumerator is disposed");
17652
+ index++;
17653
+ if (cache.length <= index) {
17654
+ return enumerator.moveNext() ? this.yieldReturn(cache[index] = enumerator.current()) : false;
17655
+ }
17656
+ return this.yieldReturn(cache[index]);
17657
+ },
17658
+ Functions.Blank
17659
+ );
17660
+ }, function() {
17661
+ disposed = true;
17662
+ Utils.dispose(enumerator);
17663
+ cache = null;
17664
+ });
17665
+ };
17666
+ if (Utils.hasNativeIteratorSupport()) {
17667
+ Enumerable.prototype[Symbol.iterator] = function() {
17668
+ return {
17669
+ enumerator: this.getEnumerator(),
17670
+ next: function() {
17671
+ if (this.enumerator.moveNext()) {
17672
+ return {
17673
+ done: false,
17674
+ value: this.enumerator.current()
17675
+ };
17676
+ } else {
17677
+ return { done: true };
17678
+ }
17679
+ }
17680
+ };
17681
+ };
17682
+ }
17683
+ Enumerable.prototype.catchError = function(handler) {
17684
+ handler = Utils.createLambda(handler);
17685
+ var source = this;
17686
+ return new Enumerable(function() {
17687
+ var enumerator;
17688
+ return new IEnumerator(
17689
+ function() {
17690
+ enumerator = source.getEnumerator();
17691
+ },
17692
+ function() {
17693
+ try {
17694
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17695
+ } catch (e) {
17696
+ handler(e);
17697
+ return false;
17698
+ }
17699
+ },
17700
+ function() {
17701
+ Utils.dispose(enumerator);
17702
+ }
17703
+ );
17704
+ });
17705
+ };
17706
+ Enumerable.prototype.finallyAction = function(finallyAction) {
17707
+ finallyAction = Utils.createLambda(finallyAction);
17708
+ var source = this;
17709
+ return new Enumerable(function() {
17710
+ var enumerator;
17711
+ return new IEnumerator(
17712
+ function() {
17713
+ enumerator = source.getEnumerator();
17714
+ },
17715
+ function() {
17716
+ return enumerator.moveNext() ? this.yieldReturn(enumerator.current()) : false;
17717
+ },
17718
+ function() {
17719
+ try {
17720
+ Utils.dispose(enumerator);
17721
+ } finally {
17722
+ finallyAction();
17723
+ }
17724
+ }
17725
+ );
17726
+ });
17727
+ };
17728
+ Enumerable.prototype.log = function(selector) {
17729
+ selector = Utils.createLambda(selector);
17730
+ return this.doAction(function(item) {
17731
+ if (typeof console !== Types.Undefined) {
17732
+ console.log(selector(item));
17733
+ }
17734
+ });
17735
+ };
17736
+ Enumerable.prototype.trace = function(message, selector) {
17737
+ if (message == null)
17738
+ message = "Trace";
17739
+ selector = Utils.createLambda(selector);
17740
+ return this.doAction(function(item) {
17741
+ if (typeof console !== Types.Undefined) {
17742
+ console.log(message, selector(item));
17743
+ }
17744
+ });
17745
+ };
17746
+ var OrderedEnumerable = function(source, keySelector, comparer, descending, parent) {
17747
+ this.source = source;
17748
+ this.keySelector = Utils.createLambda(keySelector);
17749
+ this.descending = descending;
17750
+ this.parent = parent;
17751
+ if (comparer)
17752
+ this.comparer = Utils.createLambda(comparer);
17753
+ };
17754
+ OrderedEnumerable.prototype = new Enumerable();
17755
+ OrderedEnumerable.prototype.createOrderedEnumerable = function(keySelector, comparer, descending) {
17756
+ return new OrderedEnumerable(this.source, keySelector, comparer, descending, this);
17757
+ };
17758
+ OrderedEnumerable.prototype.thenBy = function(keySelector, comparer) {
17759
+ return this.createOrderedEnumerable(keySelector, comparer, false);
17760
+ };
17761
+ OrderedEnumerable.prototype.thenByDescending = function(keySelector, comparer) {
17762
+ return this.createOrderedEnumerable(keySelector, comparer, true);
17763
+ };
17764
+ OrderedEnumerable.prototype.getEnumerator = function() {
17765
+ var self2 = this;
17766
+ var buffer;
17767
+ var indexes;
17768
+ var index = 0;
17769
+ return new IEnumerator(
17770
+ function() {
17771
+ buffer = [];
17772
+ indexes = [];
17773
+ self2.source.forEach(function(item, index2) {
17774
+ buffer.push(item);
17775
+ indexes.push(index2);
17776
+ });
17777
+ var sortContext = SortContext.create(self2, null);
17778
+ sortContext.GenerateKeys(buffer);
17779
+ indexes.sort(function(a, b) {
17780
+ return sortContext.compare(a, b);
17781
+ });
17782
+ },
17783
+ function() {
17784
+ return index < indexes.length ? this.yieldReturn(buffer[indexes[index++]]) : false;
17785
+ },
17786
+ Functions.Blank
17787
+ );
17788
+ };
17789
+ var SortContext = function(keySelector, comparer, descending, child) {
17790
+ this.keySelector = keySelector;
17791
+ this.descending = descending;
17792
+ this.child = child;
17793
+ this.comparer = comparer;
17794
+ this.keys = null;
17795
+ };
17796
+ SortContext.create = function(orderedEnumerable, currentContext) {
17797
+ var context = new SortContext(
17798
+ orderedEnumerable.keySelector,
17799
+ orderedEnumerable.comparer,
17800
+ orderedEnumerable.descending,
17801
+ currentContext
17802
+ );
17803
+ if (orderedEnumerable.parent != null)
17804
+ return SortContext.create(orderedEnumerable.parent, context);
17805
+ return context;
17806
+ };
17807
+ SortContext.prototype.GenerateKeys = function(source) {
17808
+ var len = source.length;
17809
+ var keySelector = this.keySelector;
17810
+ var keys = new Array(len);
17811
+ for (let i = 0; i < len; i++)
17812
+ keys[i] = keySelector(source[i]);
17813
+ this.keys = keys;
17814
+ if (this.child != null)
17815
+ this.child.GenerateKeys(source);
17816
+ };
17817
+ SortContext.prototype.compare = function(index1, index2) {
17818
+ var comparison = this.comparer ? this.comparer(this.keys[index1], this.keys[index2]) : Utils.compare(this.keys[index1], this.keys[index2]);
17819
+ if (comparison == 0) {
17820
+ if (this.child != null)
17821
+ return this.child.compare(index1, index2);
17822
+ return Utils.compare(index1, index2);
17823
+ }
17824
+ return this.descending ? -comparison : comparison;
17825
+ };
17826
+ var DisposableEnumerable = function(getEnumerator, dispose) {
17827
+ this.dispose = dispose;
17828
+ Enumerable.call(this, getEnumerator);
17829
+ };
17830
+ DisposableEnumerable.prototype = new Enumerable();
17831
+ var ArrayEnumerable = function(source) {
17832
+ this.getSource = function() {
17833
+ return source;
17834
+ };
17835
+ };
17836
+ ArrayEnumerable.prototype = new Enumerable();
17837
+ ArrayEnumerable.prototype.any = function(predicate) {
17838
+ return predicate == null ? this.getSource().length > 0 : Enumerable.prototype.any.apply(this, arguments);
17839
+ };
17840
+ ArrayEnumerable.prototype.count = function(predicate) {
17841
+ return predicate == null ? this.getSource().length : Enumerable.prototype.count.apply(this, arguments);
17842
+ };
17843
+ ArrayEnumerable.prototype.elementAt = function(index) {
17844
+ var source = this.getSource();
17845
+ return 0 <= index && index < source.length ? source[index] : Enumerable.prototype.elementAt.apply(this, arguments);
17846
+ };
17847
+ ArrayEnumerable.prototype.elementAtOrDefault = function(index, defaultValue) {
17848
+ if (defaultValue === void 0)
17849
+ defaultValue = null;
17850
+ var source = this.getSource();
17851
+ return 0 <= index && index < source.length ? source[index] : defaultValue;
17852
+ };
17853
+ ArrayEnumerable.prototype.first = function(predicate) {
17854
+ var source = this.getSource();
17855
+ return predicate == null && source.length > 0 ? source[0] : Enumerable.prototype.first.apply(this, arguments);
17856
+ };
17857
+ ArrayEnumerable.prototype.firstOrDefault = function(predicate, defaultValue) {
17858
+ if (predicate !== void 0) {
17859
+ return Enumerable.prototype.firstOrDefault.apply(this, arguments);
17860
+ }
17861
+ defaultValue = predicate;
17862
+ var source = this.getSource();
17863
+ return source.length > 0 ? source[0] : defaultValue;
17864
+ };
17865
+ ArrayEnumerable.prototype.last = function(predicate) {
17866
+ var source = this.getSource();
17867
+ return predicate == null && source.length > 0 ? source[source.length - 1] : Enumerable.prototype.last.apply(this, arguments);
17868
+ };
17869
+ ArrayEnumerable.prototype.lastOrDefault = function(predicate, defaultValue) {
17870
+ if (predicate !== void 0) {
17871
+ return Enumerable.prototype.lastOrDefault.apply(this, arguments);
17872
+ }
17873
+ defaultValue = predicate;
17874
+ var source = this.getSource();
17875
+ return source.length > 0 ? source[source.length - 1] : defaultValue;
17876
+ };
17877
+ ArrayEnumerable.prototype.skip = function(count) {
17878
+ var source = this.getSource();
17879
+ return new Enumerable(function() {
17880
+ var index;
17881
+ return new IEnumerator(
17882
+ function() {
17883
+ index = count < 0 ? 0 : count;
17884
+ },
17885
+ function() {
17886
+ return index < source.length ? this.yieldReturn(source[index++]) : false;
17887
+ },
17888
+ Functions.Blank
17889
+ );
17890
+ });
17891
+ };
17892
+ ArrayEnumerable.prototype.takeExceptLast = function(count) {
17893
+ if (count == null)
17894
+ count = 1;
17895
+ return this.take(this.getSource().length - count);
17896
+ };
17897
+ ArrayEnumerable.prototype.takeFromLast = function(count) {
17898
+ return this.skip(this.getSource().length - count);
17899
+ };
17900
+ ArrayEnumerable.prototype.reverse = function() {
17901
+ var source = this.getSource();
17902
+ return new Enumerable(function() {
17903
+ var index;
17904
+ return new IEnumerator(
17905
+ function() {
17906
+ index = source.length;
17907
+ },
17908
+ function() {
17909
+ return index > 0 ? this.yieldReturn(source[--index]) : false;
17910
+ },
17911
+ Functions.Blank
17912
+ );
17913
+ });
17914
+ };
17915
+ ArrayEnumerable.prototype.sequenceEqual = function(second, compareSelector) {
17916
+ if ((second instanceof ArrayEnumerable || second instanceof Array) && compareSelector == null && Enumerable.from(second).count() != this.count()) {
17917
+ return false;
17918
+ }
17919
+ return Enumerable.prototype.sequenceEqual.apply(this, arguments);
17920
+ };
17921
+ ArrayEnumerable.prototype.toJoinedString = function(separator, selector) {
17922
+ var source = this.getSource();
17923
+ if (selector != null || !(source instanceof Array)) {
17924
+ return Enumerable.prototype.toJoinedString.apply(this, arguments);
17925
+ }
17926
+ if (separator == null)
17927
+ separator = "";
17928
+ return source.join(separator);
17929
+ };
17930
+ ArrayEnumerable.prototype.getEnumerator = function() {
17931
+ var source = this.getSource();
17932
+ var index = -1;
17933
+ return {
17934
+ current: function() {
17935
+ return source[index];
17936
+ },
17937
+ moveNext: function() {
17938
+ return ++index < source.length;
17939
+ },
17940
+ dispose: Functions.Blank
17941
+ };
17942
+ };
17943
+ var WhereEnumerable = function(source, predicate) {
17944
+ this.prevSource = source;
17945
+ this.prevPredicate = predicate;
17946
+ };
17947
+ WhereEnumerable.prototype = new Enumerable();
17948
+ WhereEnumerable.prototype.where = function(predicate) {
17949
+ predicate = Utils.createLambda(predicate);
17950
+ if (predicate.length <= 1) {
17951
+ const prevPredicate = this.prevPredicate;
17952
+ const composedPredicate = function(x) {
17953
+ return prevPredicate(x) && predicate(x);
17954
+ };
17955
+ return new WhereEnumerable(this.prevSource, composedPredicate);
17956
+ } else {
17957
+ return Enumerable.prototype.where.call(this, predicate);
17958
+ }
17959
+ };
17960
+ WhereEnumerable.prototype.select = function(selector) {
17961
+ selector = Utils.createLambda(selector);
17962
+ return selector.length <= 1 ? new WhereSelectEnumerable(this.prevSource, this.prevPredicate, selector) : Enumerable.prototype.select.call(this, selector);
17963
+ };
17964
+ WhereEnumerable.prototype.getEnumerator = function() {
17965
+ var predicate = this.prevPredicate;
17966
+ var source = this.prevSource;
17967
+ var enumerator;
17968
+ return new IEnumerator(
17969
+ function() {
17970
+ enumerator = source.getEnumerator();
17971
+ },
17972
+ function() {
17973
+ while (enumerator.moveNext()) {
17974
+ if (predicate(enumerator.current())) {
17975
+ return this.yieldReturn(enumerator.current());
17976
+ }
17977
+ }
17978
+ return false;
17979
+ },
17980
+ function() {
17981
+ Utils.dispose(enumerator);
17982
+ }
17983
+ );
17984
+ };
17985
+ var WhereSelectEnumerable = function(source, predicate, selector) {
17986
+ this.prevSource = source;
17987
+ this.prevPredicate = predicate;
17988
+ this.prevSelector = selector;
17989
+ };
17990
+ WhereSelectEnumerable.prototype = new Enumerable();
17991
+ WhereSelectEnumerable.prototype.where = function(predicate) {
17992
+ predicate = Utils.createLambda(predicate);
17993
+ return predicate.length <= 1 ? new WhereEnumerable(this, predicate) : Enumerable.prototype.where.call(this, predicate);
17994
+ };
17995
+ WhereSelectEnumerable.prototype.select = function(selector) {
17996
+ selector = Utils.createLambda(selector);
17997
+ if (selector.length <= 1) {
17998
+ const prevSelector = this.prevSelector;
17999
+ const composedSelector = function(x) {
18000
+ return selector(prevSelector(x));
18001
+ };
18002
+ return new WhereSelectEnumerable(this.prevSource, this.prevPredicate, composedSelector);
18003
+ } else {
18004
+ return Enumerable.prototype.select.call(this, selector);
18005
+ }
18006
+ };
18007
+ WhereSelectEnumerable.prototype.getEnumerator = function() {
18008
+ var predicate = this.prevPredicate;
18009
+ var selector = this.prevSelector;
18010
+ var source = this.prevSource;
18011
+ var enumerator;
18012
+ return new IEnumerator(
18013
+ function() {
18014
+ enumerator = source.getEnumerator();
18015
+ },
18016
+ function() {
18017
+ while (enumerator.moveNext()) {
18018
+ if (predicate == null || predicate(enumerator.current())) {
18019
+ return this.yieldReturn(selector(enumerator.current()));
18020
+ }
18021
+ }
18022
+ return false;
18023
+ },
18024
+ function() {
18025
+ Utils.dispose(enumerator);
18026
+ }
18027
+ );
18028
+ };
18029
+ var Dictionary = function() {
18030
+ var callHasOwnProperty = function(target, key) {
18031
+ return Object.prototype.hasOwnProperty.call(target, key);
18032
+ };
18033
+ var computeHashCode = function(obj) {
18034
+ if (obj === null)
18035
+ return "null";
18036
+ if (obj === void 0)
18037
+ return "undefined";
18038
+ return typeof obj.toString === Types.Function ? obj.toString() : Object.prototype.toString.call(obj);
18039
+ };
18040
+ var HashEntry = function(key, value) {
18041
+ this.key = key;
18042
+ this.value = value;
18043
+ this.prev = null;
18044
+ this.next = null;
18045
+ };
18046
+ var EntryList = function() {
18047
+ this.first = null;
18048
+ this.last = null;
18049
+ };
18050
+ EntryList.prototype = {
18051
+ addLast: function(entry) {
18052
+ if (this.last != null) {
18053
+ this.last.next = entry;
18054
+ entry.prev = this.last;
18055
+ this.last = entry;
18056
+ } else
18057
+ this.first = this.last = entry;
18058
+ },
18059
+ replace: function(entry, newEntry) {
18060
+ if (entry.prev != null) {
18061
+ entry.prev.next = newEntry;
18062
+ newEntry.prev = entry.prev;
18063
+ } else
18064
+ this.first = newEntry;
18065
+ if (entry.next != null) {
18066
+ entry.next.prev = newEntry;
18067
+ newEntry.next = entry.next;
18068
+ } else
18069
+ this.last = newEntry;
18070
+ },
18071
+ remove: function(entry) {
18072
+ if (entry.prev != null)
18073
+ entry.prev.next = entry.next;
18074
+ else
18075
+ this.first = entry.next;
18076
+ if (entry.next != null)
18077
+ entry.next.prev = entry.prev;
18078
+ else
18079
+ this.last = entry.prev;
18080
+ }
18081
+ };
18082
+ var Dictionary2 = function(compareSelector) {
18083
+ this.countField = 0;
18084
+ this.entryList = new EntryList();
18085
+ this.buckets = {};
18086
+ this.compareSelector = compareSelector == null ? Functions.Identity : compareSelector;
18087
+ };
18088
+ Dictionary2.prototype = {
18089
+ add: function(key, value) {
18090
+ var compareKey = this.compareSelector(key);
18091
+ var hash = computeHashCode(compareKey);
18092
+ var entry = new HashEntry(key, value);
18093
+ if (callHasOwnProperty(this.buckets, hash)) {
18094
+ const array = this.buckets[hash];
18095
+ for (let i = 0; i < array.length; i++) {
18096
+ if (this.compareSelector(array[i].key) === compareKey) {
18097
+ this.entryList.replace(array[i], entry);
18098
+ array[i] = entry;
18099
+ return;
18100
+ }
18101
+ }
18102
+ array.push(entry);
18103
+ } else {
18104
+ this.buckets[hash] = [entry];
18105
+ }
18106
+ this.countField++;
18107
+ this.entryList.addLast(entry);
18108
+ },
18109
+ get: function(key) {
18110
+ var compareKey = this.compareSelector(key);
18111
+ var hash = computeHashCode(compareKey);
18112
+ if (!callHasOwnProperty(this.buckets, hash))
18113
+ return void 0;
18114
+ var array = this.buckets[hash];
18115
+ for (let i = 0; i < array.length; i++) {
18116
+ const entry = array[i];
18117
+ if (this.compareSelector(entry.key) === compareKey)
18118
+ return entry.value;
18119
+ }
18120
+ return void 0;
18121
+ },
18122
+ set: function(key, value) {
18123
+ var compareKey = this.compareSelector(key);
18124
+ var hash = computeHashCode(compareKey);
18125
+ if (callHasOwnProperty(this.buckets, hash)) {
18126
+ const array = this.buckets[hash];
18127
+ for (let i = 0; i < array.length; i++) {
18128
+ if (this.compareSelector(array[i].key) === compareKey) {
18129
+ const newEntry = new HashEntry(key, value);
18130
+ this.entryList.replace(array[i], newEntry);
18131
+ array[i] = newEntry;
18132
+ return true;
18133
+ }
18134
+ }
18135
+ }
18136
+ return false;
18137
+ },
18138
+ contains: function(key) {
18139
+ var compareKey = this.compareSelector(key);
18140
+ var hash = computeHashCode(compareKey);
18141
+ if (!callHasOwnProperty(this.buckets, hash))
18142
+ return false;
18143
+ var array = this.buckets[hash];
18144
+ for (let i = 0; i < array.length; i++) {
18145
+ if (this.compareSelector(array[i].key) === compareKey)
18146
+ return true;
18147
+ }
18148
+ return false;
18149
+ },
18150
+ clear: function() {
18151
+ this.countField = 0;
18152
+ this.buckets = {};
18153
+ this.entryList = new EntryList();
18154
+ },
18155
+ remove: function(key) {
18156
+ var compareKey = this.compareSelector(key);
18157
+ var hash = computeHashCode(compareKey);
18158
+ if (!callHasOwnProperty(this.buckets, hash))
18159
+ return;
18160
+ var array = this.buckets[hash];
18161
+ for (let i = 0; i < array.length; i++) {
18162
+ if (this.compareSelector(array[i].key) === compareKey) {
18163
+ this.entryList.remove(array[i]);
18164
+ array.splice(i, 1);
18165
+ if (array.length == 0)
18166
+ delete this.buckets[hash];
18167
+ this.countField--;
18168
+ return;
18169
+ }
18170
+ }
18171
+ },
18172
+ count: function() {
18173
+ return this.countField;
18174
+ },
18175
+ toEnumerable: function() {
18176
+ var self2 = this;
18177
+ return new Enumerable(function() {
18178
+ var currentEntry;
18179
+ return new IEnumerator(
18180
+ function() {
18181
+ currentEntry = self2.entryList.first;
18182
+ },
18183
+ function() {
18184
+ if (currentEntry != null) {
18185
+ const result = { key: currentEntry.key, value: currentEntry.value };
18186
+ currentEntry = currentEntry.next;
18187
+ return this.yieldReturn(result);
18188
+ }
18189
+ return false;
18190
+ },
18191
+ Functions.Blank
18192
+ );
18193
+ });
18194
+ }
18195
+ };
18196
+ return Dictionary2;
18197
+ }();
18198
+ var Lookup = function(dictionary) {
18199
+ this.count = function() {
18200
+ return dictionary.count();
18201
+ };
18202
+ this.get = function(key) {
18203
+ return Enumerable.from(dictionary.get(key));
18204
+ };
18205
+ this.contains = function(key) {
18206
+ return dictionary.contains(key);
18207
+ };
18208
+ this.toEnumerable = function() {
18209
+ return dictionary.toEnumerable().select(function(kvp) {
18210
+ return new Grouping(kvp.key, kvp.value);
18211
+ });
18212
+ };
18213
+ };
18214
+ var Grouping = function(groupKey, elements) {
18215
+ this.key = function() {
18216
+ return groupKey;
18217
+ };
18218
+ ArrayEnumerable.call(this, elements);
18219
+ };
18220
+ Grouping.prototype = new ArrayEnumerable();
18221
+ const propDefine$1 = {
18222
+ // modelValue:{
18223
+ // // 平台Id
18224
+ // type: Array,
18225
+ // default: []
18226
+ // },
18227
+ readonly: {
18228
+ // 只读
18229
+ type: Boolean,
18230
+ default: false
18231
+ },
18232
+ multiple: {
18233
+ // 是否多选
18234
+ type: Boolean,
18235
+ default: false
18236
+ },
18237
+ dataValue: {
18238
+ // 值
18239
+ type: Array || Number,
18240
+ default: true
18241
+ }
18242
+ };
18243
+ const _sfc_main$1 = defineComponent({
18244
+ name: "NvStructureTypeSelect",
18245
+ components: {},
18246
+ emits: ["update", "on-change"],
18247
+ // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
18248
+ props: propDefine$1,
18249
+ setup(props, ctx) {
18250
+ return new StructureTypeSelectInstance(props, ctx);
18251
+ }
18252
+ });
18253
+ class StructureTypeSelectInstance extends BaseInstance {
18254
+ constructor(props, ctx) {
18255
+ super();
18256
+ __publicField(this, "props");
18257
+ __publicField(this, "ctx");
18258
+ // 全局属性
18259
+ __publicField(this, "selWidth", ref(100));
18260
+ __publicField(this, "StructureTypeSel", ref());
18261
+ __publicField(this, "TypeValue", ref([]));
18262
+ __publicField(this, "StructureTypeDataAll", []);
18263
+ __publicField(this, "StructureTypeData", ref([]));
18264
+ __publicField(this, "StructureTypeCheckData", ref([]));
18265
+ __publicField(this, "searchView", ref(false));
18266
+ __publicField(this, "searchValue", ref(""));
18267
+ /**
18268
+ * 获取构件类别列表数据
18269
+ */
18270
+ __publicField(this, "dataStructureApi", new DataStructureApi());
18271
+ __publicField(this, "structrueTypeLevGroup", ref([]));
18272
+ __publicField(this, "activeTypeItem", ref({}));
18273
+ __publicField(this, "TypeTextValue", ref(""));
18274
+ __publicField(this, "typeItemClick", (item, level) => {
18275
+ item.level = level;
18276
+ if (level == 1) {
18277
+ this.activeTypeItem.value = item;
18278
+ }
18279
+ if (this.structrueTypeLevGroup.value.find((e) => e["level"] == level)) {
18280
+ let index = Enumerable.from(this.structrueTypeLevGroup.value).indexOf((e) => e["level"] == level);
18281
+ this.structrueTypeLevGroup.value[index] = item;
18282
+ this.structrueTypeLevGroup.value.splice(index + 1, this.structrueTypeLevGroup.value.length);
18283
+ } else {
18284
+ this.structrueTypeLevGroup.value.push(item);
18285
+ }
18286
+ nextTick(() => {
18287
+ if (this.StructureTypeSel.value) {
18288
+ let boxWidth = this.StructureTypeSel.value.clientWidth;
18289
+ this.selWidth.value = parseFloat(boxWidth);
18290
+ }
18291
+ });
18292
+ this.TypeValue.value = [this.activeTypeItem.value.value].concat(this.structrueTypeLevGroup.value.map((e) => e["value"]));
18293
+ if (!this.props.multiple) {
18294
+ this.StructureTypeCheckData.value = [item];
18295
+ this.doSelectedAfterFun();
18296
+ }
18297
+ });
18298
+ __publicField(this, "typeCheckFun", (item, state) => {
18299
+ if (state) {
18300
+ this.StructureTypeCheckData.value.push(item);
18301
+ } else {
18302
+ let index = Enumerable.from(this.StructureTypeCheckData.value).indexOf((e) => e["value"] == item.value);
18303
+ this.StructureTypeCheckData.value.splice(index, 1);
18304
+ }
18305
+ this.doSelectedAfterFun();
18306
+ });
18307
+ __publicField(this, "removeStructureType", (item) => {
18308
+ this.changeTreeItem(this.StructureTypeData.value, item.value, "checked", false);
18309
+ let index = Enumerable.from(this.StructureTypeCheckData.value).indexOf((e) => e["value"] == item.value);
18310
+ this.StructureTypeCheckData.value.splice(index, 1);
18311
+ });
18312
+ __publicField(this, "poptipVisChange", () => {
18313
+ nextTick(() => {
18314
+ if (this.StructureTypeSel.value) {
18315
+ let boxWidth = this.StructureTypeSel.value.clientWidth;
18316
+ this.selWidth.value = parseFloat(boxWidth);
18317
+ }
18318
+ });
18319
+ });
18320
+ __publicField(this, "poptipHideFun", () => {
18321
+ if (this.searchValue.value && this.searchTypeList.value.length == 0) {
18322
+ this.searchView.value = false;
18323
+ this.searchValue.value = "";
18324
+ }
18325
+ });
18326
+ __publicField(this, "searchTypeList", ref([]));
18327
+ __publicField(this, "searchTypeFun", () => {
18328
+ let res = this.StructureTypeDataAll.filter((e) => e["NodeName"].indexOf(this.searchValue.value) >= 0);
18329
+ this.searchTypeList.value = res.map((e) => {
18330
+ e.checked = this.StructureTypeCheckData.value.find((x) => x["value"] == e.Id) ? true : false;
18331
+ return e;
18332
+ });
18333
+ nextTick(() => {
18334
+ if (this.StructureTypeSel.value) {
18335
+ let boxWidth = this.StructureTypeSel.value.clientWidth;
18336
+ this.selWidth.value = parseFloat(boxWidth) + 16;
18337
+ }
18338
+ });
18339
+ });
18340
+ __publicField(this, "toSelectSearchType", (item) => {
18341
+ this.TypeValue.value = item.parentPath.concat([item.Id]);
18342
+ this.StructureTypeCheckData.value = [{ value: item.Id, label: item.NodeName, parentPath: item.parentPath }];
18343
+ this.doSelectedAfterFun();
18344
+ this.structrueTypeLevGroup.value = [];
18345
+ this.loadTypeLevGroupData(this.StructureTypeData.value);
18346
+ this.poptipVisChange();
18347
+ this.searchValue.value = "";
18348
+ this.searchView.value = false;
18349
+ this.searchTypeList.value = [];
18350
+ });
18351
+ __publicField(this, "toCheckSearchType", (item, state) => {
18352
+ let index = Enumerable.from(this.StructureTypeCheckData.value).indexOf((e) => e["value"] == item.value);
18353
+ if (state || index >= 0) {
18354
+ this.StructureTypeCheckData.value.push({ value: item.Id, label: item.NodeName, parentPath: item.parentPath });
18355
+ this.changeTreeItem(this.StructureTypeData.value, item.Id, "checked", true);
18356
+ } else {
18357
+ this.StructureTypeCheckData.value.splice(index, 1);
18358
+ this.changeTreeItem(this.StructureTypeData.value, item.Id, "checked", false);
18359
+ }
18360
+ });
18361
+ __publicField(this, "confirmSearchTypeData", () => {
18362
+ this.doSelectedAfterFun();
18363
+ this.searchValue.value = "";
18364
+ this.searchView.value = false;
18365
+ this.structrueTypeLevGroup.value = [];
18366
+ this.searchTypeList.value = [];
18367
+ this.poptipVisChange();
18368
+ });
18369
+ this.props = props;
18370
+ this.ctx = ctx;
18371
+ this.loadSelectData();
18372
+ }
18373
+ async loadSelectData() {
18374
+ let res = window["G_StructureTypeData"];
18375
+ if (!res || res.length == 0) {
18376
+ res = this.utilities.parseApiResult(await this.dataStructureApi.getEntities(new QueryWrapper().select(["Id", "PId", "NodeName"]).orderBy(["OrderNo"])));
18377
+ window["G_StructureTypeData"] = res;
18378
+ }
18379
+ this.StructureTypeDataAll = res;
18380
+ this.StructureTypeData.value = this.formatToIViewCascaderData(res, 0, "Id", "NodeName");
18381
+ if (!this.props.multiple) {
18382
+ this.loadTypeLevGroupData(this.StructureTypeData.value);
18383
+ }
18384
+ watch(() => this.props.dataValue, (newValue, oldValue) => {
18385
+ this.setStructureTypeCheckData(this.StructureTypeData.value);
18386
+ if (!this.props.multiple) {
18387
+ this.structrueTypeLevGroup.value = [];
18388
+ this.loadTypeLevGroupData(this.StructureTypeData.value);
18389
+ }
18390
+ }, { immediate: true });
18391
+ }
18392
+ /**
18393
+ * 展开选中值所在的列表
18394
+ * @param data
18395
+ */
18396
+ loadTypeLevGroupData(data) {
18397
+ data.map((e) => {
18398
+ if (this.StructureTypeCheckData.value[0]) {
18399
+ let parentPath = this.StructureTypeCheckData.value[0].parentPath;
18400
+ if (parentPath.includes(e.value)) {
18401
+ this.structrueTypeLevGroup.value.push(e);
18402
+ }
18403
+ if (e.children && e.children.length > 0) {
18404
+ this.loadTypeLevGroupData(e.children);
18405
+ }
18406
+ }
18407
+ });
18408
+ }
18409
+ /**
18410
+ * 执行选择项发生改变后事件
18411
+ */
18412
+ doSelectedAfterFun() {
18413
+ if (this.props.multiple) {
18414
+ this.ctx.emit("on-change", this.StructureTypeCheckData.value.map((e) => e["value"]));
18415
+ } else {
18416
+ this.ctx.emit("on-change", this.StructureTypeCheckData.value[0].value);
18417
+ }
18418
+ }
18419
+ /**
18420
+ * 转换为iview级联菜单所需数据
18421
+ * @param data 原始数据
18422
+ * @param PId
18423
+ * @param value
18424
+ * @param label
18425
+ * @returns
18426
+ */
18427
+ formatToIViewCascaderData(data, PId = 0, value, label, parentPath = []) {
18428
+ let arr1 = data.filter((e) => e["PId"] == PId);
18429
+ let parentPath2 = JSON.parse(JSON.stringify(parentPath));
18430
+ if (PId > 0) {
18431
+ parentPath2.push(PId);
18432
+ }
18433
+ arr1 = arr1.map((e) => {
18434
+ let obj = {};
18435
+ obj.value = e[value];
18436
+ obj.label = e[label];
18437
+ obj.parentPath = JSON.parse(JSON.stringify(parentPath2));
18438
+ let index = Enumerable.from(this.StructureTypeDataAll).indexOf((x) => x["Id"] == obj.value);
18439
+ this.StructureTypeDataAll[index].parentPath = obj.parentPath;
18440
+ obj.level = obj.parentPath.length + 1;
18441
+ if (this.props.multiple) {
18442
+ obj.checked = this.props.dataValue.find((x) => x == obj.value) ? true : false;
18443
+ if (obj.checked) {
18444
+ this.StructureTypeCheckData.value.push(obj);
18445
+ }
18446
+ } else {
18447
+ if (this.props.dataValue == obj.value) {
18448
+ this.TypeValue.value = JSON.parse(JSON.stringify(parentPath2)).concat([obj.value]);
18449
+ this.StructureTypeCheckData.value = [obj];
18450
+ }
18451
+ }
18452
+ let data2 = data.filter((x) => x["PId"] == e.Id);
18453
+ if (data2.length > 0) {
18454
+ obj.children = this.formatToIViewCascaderData(data, e.Id, value, label, parentPath2);
18455
+ } else {
18456
+ obj.children = [];
18457
+ }
18458
+ return obj;
18459
+ });
18460
+ return arr1;
18461
+ }
18462
+ setStructureTypeCheckData(data) {
18463
+ data.map((e) => {
18464
+ if (this.props.multiple) {
18465
+ e.checked = this.props.dataValue.find((x) => x == e.value) ? true : false;
18466
+ if (e.checked) {
18467
+ this.StructureTypeCheckData.value.push(e);
18468
+ }
18469
+ } else {
18470
+ if (this.props.dataValue == e.value) {
18471
+ this.TypeValue.value = JSON.parse(JSON.stringify(e.parentPath)).concat([e.value]);
18472
+ this.StructureTypeCheckData.value = [e];
18473
+ }
18474
+ }
18475
+ if (e.children && e.children.length > 0) {
18476
+ this.setStructureTypeCheckData(e.children);
18477
+ }
18478
+ });
18479
+ }
18480
+ changeTreeItem(data, Id, key, value) {
18481
+ data.map((e) => {
18482
+ if (e.value == Id) {
18483
+ e[key] = value;
18484
+ return;
18485
+ }
18486
+ if (e.children && e.children.length > 0) {
18487
+ this.changeTreeItem(e.children, Id, key, value);
18488
+ }
18489
+ });
18490
+ }
18491
+ }
18492
+ const StructureTypeSelect_vue_vue_type_style_index_0_scoped_c07822d5_lang = "";
18493
+ const StructureTypeSelect_vue_vue_type_style_index_1_lang = "";
18494
+ const _hoisted_1$1 = { key: 0 };
18495
+ const _hoisted_2$1 = {
18496
+ key: 0,
18497
+ ref: "StructureTypeSel",
18498
+ style: { "height": "220px", "display": "inline-block" }
18499
+ };
18500
+ const _hoisted_3$1 = { class: "nv-cascader-box nv-overflow-auto" };
18501
+ const _hoisted_4$1 = ["onClick"];
18502
+ const _hoisted_5$1 = {
18503
+ key: 0,
18504
+ class: "nv-cascader-box nv-overflow-auto"
18505
+ };
18506
+ const _hoisted_6$1 = ["onClick"];
18507
+ const _hoisted_7$1 = {
18508
+ key: 1,
18509
+ ref: "StructureTypeSel",
18510
+ style: { "display": "inline-block" }
18511
+ };
18512
+ const _hoisted_8$1 = {
18513
+ key: 0,
18514
+ style: { "padding": "5px 10px", "color": "#c5c8ce", "text-align": "center", "width": "150px" }
18515
+ };
18516
+ const _hoisted_9$1 = { key: 1 };
18517
+ const _hoisted_10$1 = {
18518
+ class: "nv-overflow-auto",
18519
+ style: { "max-height": "220px" }
18520
+ };
18521
+ const _hoisted_11$1 = ["onClick"];
18522
+ const _hoisted_12$1 = {
18523
+ key: 0,
18524
+ class: "nv-text-r",
18525
+ style: { "padding-right": "10px" }
18526
+ };
18527
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
18528
+ const _component_Tag = resolveComponent("Tag");
18529
+ const _component_Checkbox = resolveComponent("Checkbox");
18530
+ const _component_Icon = resolveComponent("Icon");
18531
+ const _component_Button = resolveComponent("Button");
18532
+ const _component_Poptip = resolveComponent("Poptip");
18533
+ return openBlock(), createElementBlock("div", null, [
18534
+ createVNode(_component_Poptip, {
18535
+ placement: "bottom-start",
18536
+ "transfer-class-name": "nvstructuretype-sel-box",
18537
+ width: _ctx.selWidth,
18538
+ transfer: "",
18539
+ disabled: _ctx.readonly,
18540
+ onOnPopperShow: _cache[6] || (_cache[6] = ($event) => _ctx.poptipVisChange()),
18541
+ onOnPopperHide: _ctx.poptipHideFun
18542
+ }, {
18543
+ content: withCtx(() => [
18544
+ !_ctx.searchValue ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
18545
+ createElementVNode("div", _hoisted_3$1, [
18546
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.StructureTypeData, (item) => {
18547
+ return openBlock(), createElementBlock("div", {
18548
+ class: normalizeClass(["nv-c-p nv-cascader-item", { active: _ctx.TypeValue.includes(item.value) }]),
18549
+ key: item.value,
18550
+ onClick: ($event) => _ctx.typeItemClick(item, 1)
18551
+ }, [
18552
+ _ctx.multiple ? (openBlock(), createBlock(_component_Checkbox, {
18553
+ key: 0,
18554
+ modelValue: item.checked,
18555
+ "onUpdate:modelValue": ($event) => item.checked = $event,
18556
+ onClick: _cache[3] || (_cache[3] = withModifiers(() => {
18557
+ }, ["stop"])),
18558
+ onOnChange: ($event) => _ctx.typeCheckFun(item, $event)
18559
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onOnChange"])) : createCommentVNode("", true),
18560
+ createTextVNode(" " + toDisplayString(item.label) + " ", 1),
18561
+ item.children && item.children.length > 0 ? (openBlock(), createBlock(_component_Icon, {
18562
+ key: 1,
18563
+ class: "arrow-right",
18564
+ type: "ios-arrow-forward"
18565
+ })) : createCommentVNode("", true)
18566
+ ], 10, _hoisted_4$1);
18567
+ }), 128))
18568
+ ]),
18569
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.structrueTypeLevGroup, (item1) => {
18570
+ return openBlock(), createElementBlock(Fragment, null, [
18571
+ item1 && item1.children && item1.children.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_5$1, [
18572
+ (openBlock(true), createElementBlock(Fragment, null, renderList(item1.children, (item2) => {
18573
+ return openBlock(), createElementBlock("div", {
18574
+ class: normalizeClass(["nv-c-p nv-cascader-item", { active: _ctx.TypeValue.includes(item2.value) }]),
18575
+ key: item2.value,
18576
+ onClick: ($event) => _ctx.typeItemClick(item2, item1.level + 1)
18577
+ }, [
18578
+ _ctx.multiple ? (openBlock(), createBlock(_component_Checkbox, {
18579
+ key: 0,
18580
+ modelValue: item2.checked,
18581
+ "onUpdate:modelValue": ($event) => item2.checked = $event,
18582
+ onClick: _cache[4] || (_cache[4] = withModifiers(() => {
18583
+ }, ["stop"])),
18584
+ onOnChange: ($event) => _ctx.typeCheckFun(item2, $event)
18585
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onOnChange"])) : createCommentVNode("", true),
18586
+ createTextVNode(" " + toDisplayString(item2.label) + " ", 1),
18587
+ item2.children && item2.children.length > 0 ? (openBlock(), createBlock(_component_Icon, {
18588
+ key: 1,
18589
+ class: "arrow-right",
18590
+ type: "ios-arrow-forward"
18591
+ })) : createCommentVNode("", true)
18592
+ ], 10, _hoisted_6$1);
18593
+ }), 128))
18594
+ ])) : createCommentVNode("", true)
18595
+ ], 64);
18596
+ }), 256))
18597
+ ], 512)) : (openBlock(), createElementBlock("div", _hoisted_7$1, [
18598
+ _ctx.searchTypeList.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_8$1, "无匹配数据")) : (openBlock(), createElementBlock("div", _hoisted_9$1, [
18599
+ createElementVNode("div", _hoisted_10$1, [
18600
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.searchTypeList, (item, index) => {
18601
+ return openBlock(), createElementBlock("div", {
18602
+ class: "nv-cascader-item nv-c-p",
18603
+ onClick: ($event) => _ctx.multiple ? null : _ctx.toSelectSearchType(item)
18604
+ }, [
18605
+ _ctx.multiple ? (openBlock(), createBlock(_component_Checkbox, {
18606
+ key: 0,
18607
+ modelValue: item.checked,
18608
+ "onUpdate:modelValue": ($event) => item.checked = $event,
18609
+ onClick: _cache[5] || (_cache[5] = withModifiers(() => {
18610
+ }, ["stop"])),
18611
+ onOnChange: ($event) => _ctx.toCheckSearchType(item, $event)
18612
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onOnChange"])) : createCommentVNode("", true),
18613
+ createTextVNode(" " + toDisplayString(item.NodeName), 1)
18614
+ ], 8, _hoisted_11$1);
18615
+ }), 256))
18616
+ ]),
18617
+ _ctx.multiple ? (openBlock(), createElementBlock("div", _hoisted_12$1, [
18618
+ createVNode(_component_Button, {
18619
+ type: "primary",
18620
+ size: "small",
18621
+ onClick: _ctx.confirmSearchTypeData
18622
+ }, {
18623
+ default: withCtx(() => [
18624
+ createTextVNode("确认")
18625
+ ]),
18626
+ _: 1
18627
+ }, 8, ["onClick"])
18628
+ ])) : createCommentVNode("", true)
18629
+ ]))
18630
+ ], 512))
18631
+ ]),
18632
+ default: withCtx(() => [
18633
+ createElementVNode("div", {
18634
+ class: "nv-c-p structuretype-sel-box",
18635
+ onClick: _cache[2] || (_cache[2] = ($event) => _ctx.readonly ? null : _ctx.searchView = true)
18636
+ }, [
18637
+ _ctx.StructureTypeCheckData.length == 0 && !_ctx.searchValue ? (openBlock(), createElementBlock("div", _hoisted_1$1, "选择构件类别")) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
18638
+ _ctx.multiple ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.StructureTypeCheckData, (item, index) => {
18639
+ return withDirectives((openBlock(), createBlock(_component_Tag, {
18640
+ style: { "position": "relative", "z-index": "5" },
18641
+ closable: !_ctx.readonly,
18642
+ key: index,
18643
+ onOnClose: ($event) => _ctx.removeStructureType(item)
18644
+ }, {
18645
+ default: withCtx(() => [
18646
+ createTextVNode(toDisplayString(item.label), 1)
18647
+ ]),
18648
+ _: 2
18649
+ }, 1032, ["closable", "onOnClose"])), [
18650
+ [vShow, !_ctx.searchValue]
18651
+ ]);
18652
+ }), 128)) : (openBlock(), createElementBlock("div", {
18653
+ key: 1,
18654
+ style: normalizeStyle({ visibility: _ctx.searchValue ? "hidden" : "visible" }),
18655
+ class: "nv-text-nowrap"
18656
+ }, toDisplayString(_ctx.StructureTypeCheckData[0] ? _ctx.StructureTypeCheckData[0].label : ""), 5))
18657
+ ], 64)),
18658
+ _ctx.searchView ? withDirectives((openBlock(), createElementBlock("input", {
18659
+ key: 2,
18660
+ class: "nv-pos-a searchinput",
18661
+ style: { "top": "0", "left": "0", "width": "100%" },
18662
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.searchValue = $event),
18663
+ onInput: _cache[1] || (_cache[1] = (...args) => _ctx.searchTypeFun && _ctx.searchTypeFun(...args))
18664
+ }, null, 544)), [
18665
+ [vModelText, _ctx.searchValue]
18666
+ ]) : createCommentVNode("", true)
18667
+ ])
18668
+ ]),
18669
+ _: 1
18670
+ }, 8, ["width", "disabled", "onOnPopperHide"])
18671
+ ]);
18672
+ }
18673
+ const NvStructureTypeSelect = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-c07822d5"]]);
18674
+ const propDefine = {
18675
+ readonly: {
18676
+ // 只读
18677
+ type: Boolean,
18678
+ default: false
18679
+ },
18680
+ selType: {
18681
+ // 选择类别
18682
+ type: Number,
18683
+ default: 1
18684
+ },
18685
+ multiple: {
18686
+ // 是否多选
18687
+ type: Boolean,
18688
+ default: true
18689
+ },
18690
+ dataValue: {
18691
+ // 值
18692
+ type: Array || Number,
18693
+ default: true
18694
+ }
18695
+ };
18696
+ const _sfc_main = defineComponent({
18697
+ name: "NvStructureSelect",
18698
+ components: {},
18699
+ emits: ["update", "on-change"],
18700
+ // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
18701
+ props: propDefine,
18702
+ setup(props, ctx) {
18703
+ return new StructureSelectInstance(props, ctx);
18704
+ }
18705
+ });
18706
+ class StructureSelectInstance extends BaseInstance {
18707
+ constructor(props, ctx) {
18708
+ super();
18709
+ __publicField(this, "props");
18710
+ __publicField(this, "ctx");
18711
+ // 全局属性
18712
+ __publicField(this, "TypeValue", ref([]));
18713
+ __publicField(this, "StructureTypeData", ref([]));
18714
+ /**
18715
+ * 获取构件类别列表数据
18716
+ */
18717
+ __publicField(this, "dataStructureApi", new DataStructureApi());
18718
+ __publicField(this, "structureInstanceApi", new StructureInstanceApi());
18719
+ /** 单位工程下拉列表值 */
18720
+ __publicField(this, "UnitValue", ref());
18721
+ __publicField(this, "TypeGroupData", ref([]));
18722
+ __publicField(this, "activeNodeType", ref(""));
18723
+ //#region 构件选择--单位工程列表相关
18724
+ __publicField(this, "activeUnit", ref(0));
18725
+ __publicField(this, "activeUnitName", "");
18726
+ __publicField(this, "unitData", ref([]));
18727
+ /**
18728
+ * 顶级构件类别选择事件
18729
+ */
18730
+ __publicField(this, "NodeTypeSelect", () => {
18731
+ this.unitData.value = this.TypeGroupData.value.find((e) => e["NodeTypeName"] == this.activeNodeType.value).UnitData;
18732
+ if (this.props.selType == 1 && this.props.multiple) {
18733
+ return;
18734
+ }
18735
+ if (this.unitData.value[0]) {
18736
+ this.activeUnit.value = this.unitData.value[0].Id;
18737
+ this.activeUnitName = this.unitData.value[0].NodeName;
18738
+ this.unitSelected(this.activeUnit.value);
18739
+ }
18740
+ });
18741
+ //#endregion
18742
+ //#region 构件选择--构件树列表数据相关
18743
+ __publicField(this, "StructureInstanceLoading", ref(false));
18744
+ __publicField(this, "StructureInstanceData", ref([]));
18745
+ /**
18746
+ * 构件树根节点数据获取
18747
+ * @param value 单位工程Id
18748
+ */
18749
+ __publicField(this, "unitSelected", async (value) => {
18750
+ this.activeUnitName = this.unitData.value.find((e) => e["Id"] == value).NodeName;
18751
+ this.StructureInstanceLoading.value = true;
18752
+ this.StructureInstanceData.value = [];
18753
+ let res = this.utilities.parseApiResult(await this.structureInstanceApi.getEntities(new QueryWrapper().select(["Id", "NodeTypeName", "NodeType", "NodeName"]).eq("PId", value)));
18754
+ this.StructureInstanceData.value = res.map((e) => {
18755
+ e.title = e.NodeName;
18756
+ e.UnitName = this.activeUnitName;
18757
+ e.loading = false;
18758
+ e.checked = this.StructureInstanceCheckData.value.find((x) => x["Id"] == e.Id) ? true : false;
18759
+ e.children = [];
18760
+ return e;
18761
+ });
18762
+ this.StructureInstanceLoading.value = false;
18763
+ });
18764
+ /**
18765
+ * 构件树子级数据获取
18766
+ * @param item
18767
+ * @param callback
18768
+ * @returns
18769
+ */
18770
+ __publicField(this, "loadStructureInstance", async (item, callback) => {
18771
+ let res = this.utilities.parseApiResult(await this.structureInstanceApi.getEntities(new QueryWrapper().select(["Id", "NodeTypeName", "NodeType", "NodeName"]).eq("PId", item.Id)));
18772
+ if (res.length == 0) {
18773
+ item.children = void 0;
18774
+ callback([]);
18775
+ return;
18776
+ }
18777
+ res = res.map((e) => {
18778
+ e.title = e.NodeName;
18779
+ e.loading = false;
18780
+ e.checked = this.StructureInstanceCheckData.value.find((x) => x["Id"] == e.Id) ? true : false;
18781
+ e.children = [];
18782
+ return e;
18783
+ });
18784
+ callback(res);
18785
+ });
18786
+ /** 已选择构件数据 */
18787
+ __publicField(this, "StructureInstanceCheckData", ref([]));
18788
+ /**
18789
+ * 构件复选框选中
18790
+ * @param nodes
18791
+ * @param item
18792
+ */
18793
+ __publicField(this, "StructureInstanceCheckFun", (nodes, item) => {
18794
+ if (item.checked) {
18795
+ this.StructureInstanceCheckData.value.push(item);
18796
+ } else {
18797
+ this.removeStructureInstance(item);
18798
+ }
18799
+ this.doSelectedAfterFun();
18800
+ });
18801
+ __publicField(this, "StructureInstanceSelectFun", (nodes, item) => {
18802
+ if (!this.props.multiple) {
18803
+ this.StructureInstanceCheckData.value = [item];
18804
+ this.doSelectedAfterFun();
18805
+ }
18806
+ });
18807
+ /**
18808
+ * 移除选中构件
18809
+ * @param item
18810
+ */
18811
+ __publicField(this, "removeStructureInstance", (item) => {
18812
+ item.checked = false;
18813
+ let index = Enumerable.from(this.StructureInstanceCheckData.value).indexOf((e) => e["Id"] == item.Id);
18814
+ this.StructureInstanceCheckData.value.splice(index, 1);
18815
+ this.treeChStateChange(this.StructureInstanceData.value);
18816
+ this.doSelectedAfterFun();
18817
+ });
18818
+ this.props = props;
18819
+ this.ctx = ctx;
18820
+ this.loadNodeTypeAndUnitData();
18821
+ }
18822
+ /**
18823
+ * 获取构件类别大类及单位工程数据
18824
+ */
18825
+ async loadNodeTypeAndUnitData() {
18826
+ let res = this.utilities.parseApiResult(await this.structureInstanceApi.getEntities(new QueryWrapper().select(["Id", "NodeTypeName", "NodeType", "NodeName"]).eq("PId", 0)));
18827
+ this.TypeGroupData.value = Enumerable.from(res).groupBy((e) => e["NodeTypeName"]).select((e) => {
18828
+ return {
18829
+ NodeTypeName: e.key(),
18830
+ UnitData: e.getSource()
18831
+ };
18832
+ }).toArray();
18833
+ if (this.props.selType == 1) {
18834
+ this.UnitValue.value = this.props.dataValue;
18835
+ return;
18836
+ }
18837
+ if (this.TypeGroupData.value[0]) {
18838
+ this.activeNodeType.value = this.TypeGroupData.value[0].NodeTypeName;
18839
+ this.NodeTypeSelect();
18840
+ if (this.props.dataValue) {
18841
+ let ids = typeof this.props.dataValue == "object" ? this.props.dataValue : [this.props.dataValue];
18842
+ this.StructureInstanceCheckData.value = this.utilities.parseApiResult(await this.structureInstanceApi.getEntities(new QueryWrapper().select(["Id", "NodeTypeName", "NodeType", "NodeName", "RootId"]).in("Id", ids)));
18843
+ this.StructureInstanceCheckData.value = this.StructureInstanceCheckData.value.map((e) => {
18844
+ let unitInfo = this.unitData.value.find((x) => x["Id"] == e.RootId);
18845
+ e.UnitName = unitInfo ? unitInfo.NodeName : "";
18846
+ return e;
18847
+ });
18848
+ }
18849
+ }
18850
+ }
18851
+ /**
18852
+ * 单位工程选择项改变事件
18853
+ */
18854
+ unitSelectChange() {
18855
+ this.doSelectedAfterFun();
18856
+ }
18857
+ /**
18858
+ * 变更树组件选中状态
18859
+ * @param data
18860
+ */
18861
+ treeChStateChange(data) {
18862
+ data.map((e) => {
18863
+ e.checked = this.StructureInstanceCheckData.value.find((x) => x["Id"] == e.Id) ? true : false;
18864
+ if (e.children && e.children.length > 0) {
18865
+ this.treeChStateChange(e.children);
18866
+ }
18867
+ });
18868
+ }
18869
+ //#endregion
18870
+ /**
18871
+ * 执行选择项发生改变后事件
18872
+ */
18873
+ doSelectedAfterFun() {
18874
+ if (this.props.selType == 1) {
18875
+ this.ctx.emit("on-change", this.UnitValue.value);
18876
+ } else {
18877
+ this.ctx.emit("on-change", this.StructureInstanceCheckData.value.map((e) => e["Id"]));
18878
+ }
18879
+ }
18880
+ }
18881
+ const StructureSelect_vue_vue_type_style_index_0_scoped_502883e6_lang = "";
18882
+ const _withScopeId = (n) => (pushScopeId("data-v-502883e6"), n = n(), popScopeId(), n);
18883
+ const _hoisted_1 = { key: 1 };
18884
+ const _hoisted_2 = { class: "nv-pos-r" };
18885
+ const _hoisted_3 = { class: "nv-c-p structure-sel-box" };
18886
+ const _hoisted_4 = { key: 0 };
18887
+ const _hoisted_5 = {
18888
+ key: 0,
18889
+ class: "nv-text-nowrap"
18890
+ };
18891
+ const _hoisted_6 = { key: 1 };
18892
+ const _hoisted_7 = { key: 0 };
18893
+ const _hoisted_8 = { key: 1 };
18894
+ const _hoisted_9 = {
18895
+ key: 0,
18896
+ style: { "margin-bottom": "10px" }
18897
+ };
18898
+ const _hoisted_10 = {
18899
+ class: "nv-flex",
18900
+ style: { "height": "280px" }
18901
+ };
18902
+ const _hoisted_11 = { class: "nv-flex-1 nv-flex-col nv-full-h" };
18903
+ const _hoisted_12 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", null, "单位工程:", -1));
18904
+ const _hoisted_13 = { class: "nv-flex-1 nv-overflow-auto" };
18905
+ const _hoisted_14 = {
18906
+ key: 0,
18907
+ class: "nv-flex-1 nv-full-h nv-overflow-auto nv-pos-r"
18908
+ };
18909
+ const _hoisted_15 = { key: 0 };
18910
+ const _hoisted_16 = {
18911
+ class: "nv-flex-1 nv-text-nowrap",
18912
+ style: { "margin-left": "7px" }
18913
+ };
18914
+ const _hoisted_17 = { key: 0 };
18915
+ const _hoisted_18 = { key: 1 };
18916
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
18917
+ const _component_Option = resolveComponent("Option");
18918
+ const _component_OptionGroup = resolveComponent("OptionGroup");
18919
+ const _component_Select = resolveComponent("Select");
18920
+ const _component_Radio = resolveComponent("Radio");
18921
+ const _component_RadioGroup = resolveComponent("RadioGroup");
18922
+ const _component_nvLoading = resolveComponent("nvLoading");
18923
+ const _component_Tree = resolveComponent("Tree");
18924
+ const _component_Poptip = resolveComponent("Poptip");
18925
+ const _component_Icon = resolveComponent("Icon");
18926
+ return _ctx.selType == 1 ? (openBlock(), createBlock(_component_Select, {
18927
+ key: 0,
18928
+ modelValue: _ctx.UnitValue,
18929
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.UnitValue = $event),
18930
+ multiple: _ctx.multiple,
18931
+ transfer: "",
18932
+ filterable: "",
18933
+ clearable: "",
18934
+ onOnChange: _ctx.unitSelectChange,
18935
+ disabled: _ctx.readonly
18936
+ }, {
18937
+ default: withCtx(() => [
18938
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.TypeGroupData, (item, index) => {
18939
+ return openBlock(), createBlock(_component_OptionGroup, {
18940
+ label: item.NodeTypeName
18941
+ }, {
18942
+ default: withCtx(() => [
18943
+ (openBlock(true), createElementBlock(Fragment, null, renderList(item.UnitData, (item2) => {
18944
+ return openBlock(), createBlock(_component_Option, {
18945
+ value: item2.Id,
18946
+ key: item2.Id
18947
+ }, {
18948
+ default: withCtx(() => [
18949
+ createTextVNode(toDisplayString(item2.NodeName), 1)
18950
+ ]),
18951
+ _: 2
18952
+ }, 1032, ["value"]);
18953
+ }), 128))
18954
+ ]),
18955
+ _: 2
18956
+ }, 1032, ["label"]);
18957
+ }), 256))
18958
+ ]),
18959
+ _: 1
18960
+ }, 8, ["modelValue", "multiple", "onOnChange", "disabled"])) : (openBlock(), createElementBlock("div", _hoisted_1, [
18961
+ createVNode(_component_Poptip, {
18962
+ placement: "bottom-start",
18963
+ width: 700,
18964
+ transfer: ""
18965
+ }, {
18966
+ content: withCtx(() => [
18967
+ _ctx.TypeGroupData.length > 1 ? (openBlock(), createElementBlock("div", _hoisted_9, [
18968
+ createVNode(_component_RadioGroup, {
18969
+ modelValue: _ctx.activeNodeType,
18970
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.activeNodeType = $event),
18971
+ type: "button",
18972
+ size: "small",
18973
+ "button-style": "solid",
18974
+ onOnChange: _ctx.NodeTypeSelect
18975
+ }, {
18976
+ default: withCtx(() => [
18977
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.TypeGroupData, (item, index) => {
18978
+ return openBlock(), createBlock(_component_Radio, {
18979
+ key: index,
18980
+ label: item.NodeTypeName
18981
+ }, null, 8, ["label"]);
18982
+ }), 128))
18983
+ ]),
18984
+ _: 1
18985
+ }, 8, ["modelValue", "onOnChange"])
18986
+ ])) : createCommentVNode("", true),
18987
+ createElementVNode("div", _hoisted_10, [
18988
+ createElementVNode("div", _hoisted_11, [
18989
+ _hoisted_12,
18990
+ createElementVNode("div", _hoisted_13, [
18991
+ createVNode(_component_RadioGroup, {
18992
+ modelValue: _ctx.activeUnit,
18993
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.activeUnit = $event),
18994
+ vertical: "",
18995
+ onOnChange: _ctx.unitSelected
18996
+ }, {
18997
+ default: withCtx(() => [
18998
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.unitData, (item, index) => {
18999
+ return openBlock(), createBlock(_component_Radio, {
19000
+ label: item.Id
19001
+ }, {
19002
+ default: withCtx(() => [
19003
+ createElementVNode("span", null, toDisplayString(item.NodeName), 1)
19004
+ ]),
19005
+ _: 2
19006
+ }, 1032, ["label"]);
19007
+ }), 256))
19008
+ ]),
19009
+ _: 1
19010
+ }, 8, ["modelValue", "onOnChange"])
19011
+ ])
19012
+ ]),
19013
+ _ctx.selType == 2 ? (openBlock(), createElementBlock("div", _hoisted_14, [
19014
+ _ctx.StructureInstanceLoading ? (openBlock(), createBlock(_component_nvLoading, { key: 0 })) : (openBlock(), createBlock(_component_Tree, {
19015
+ key: 1,
19016
+ style: { "width": "calc(100% - 30px)" },
19017
+ data: _ctx.StructureInstanceData,
19018
+ "load-data": _ctx.loadStructureInstance,
19019
+ "check-strictly": true,
19020
+ "show-checkbox": _ctx.multiple,
19021
+ onOnCheckChange: _ctx.StructureInstanceCheckFun,
19022
+ onOnSelectChange: _ctx.StructureInstanceSelectFun
19023
+ }, null, 8, ["data", "load-data", "show-checkbox", "onOnCheckChange", "onOnSelectChange"]))
19024
+ ])) : createCommentVNode("", true)
19025
+ ])
19026
+ ]),
19027
+ default: withCtx(() => [
19028
+ createElementVNode("div", _hoisted_2, [
19029
+ createElementVNode("div", _hoisted_3, [
19030
+ _ctx.StructureInstanceCheckData.length == 0 ? (openBlock(), createElementBlock("div", _hoisted_4, "点击选择构件")) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
19031
+ _ctx.multiple ? (openBlock(), createElementBlock("div", _hoisted_5, " 已选择" + toDisplayString(_ctx.StructureInstanceCheckData.length) + "个构件(" + toDisplayString(_ctx.StructureInstanceCheckData.map((e) => e["NodeName"]).toString()) + ") ", 1)) : (openBlock(), createElementBlock("div", _hoisted_6, [
19032
+ createTextVNode(toDisplayString(_ctx.StructureInstanceCheckData[0].NodeName) + " ", 1),
19033
+ _ctx.StructureInstanceCheckData[0].NodeTypeName ? (openBlock(), createElementBlock("span", _hoisted_7, "[" + toDisplayString(_ctx.StructureInstanceCheckData[0].NodeTypeName) + "]", 1)) : createCommentVNode("", true),
19034
+ _ctx.StructureInstanceCheckData[0].UnitName ? (openBlock(), createElementBlock("span", _hoisted_8, "[" + toDisplayString(_ctx.StructureInstanceCheckData[0].UnitName) + "]", 1)) : createCommentVNode("", true)
19035
+ ]))
19036
+ ], 64))
19037
+ ])
19038
+ ])
19039
+ ]),
19040
+ _: 1
19041
+ }),
19042
+ _ctx.multiple ? (openBlock(), createElementBlock("div", _hoisted_15, [
19043
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.StructureInstanceCheckData, (item, index) => {
19044
+ return openBlock(), createElementBlock("div", {
19045
+ class: "nv-flex",
19046
+ key: index
19047
+ }, [
19048
+ !_ctx.readonly ? (openBlock(), createBlock(_component_Icon, {
19049
+ key: 0,
19050
+ class: "nv-c-p",
19051
+ type: "md-trash",
19052
+ onClick: withModifiers(($event) => _ctx.removeStructureInstance(item), ["stop"]),
19053
+ size: 20,
19054
+ color: "#ae5d55"
19055
+ }, null, 8, ["onClick"])) : createCommentVNode("", true),
19056
+ createElementVNode("div", _hoisted_16, [
19057
+ createTextVNode(toDisplayString(item.NodeName) + " ", 1),
19058
+ item.NodeTypeName ? (openBlock(), createElementBlock("span", _hoisted_17, "[" + toDisplayString(item.NodeTypeName) + "]", 1)) : createCommentVNode("", true),
19059
+ item.UnitName ? (openBlock(), createElementBlock("span", _hoisted_18, "[" + toDisplayString(item.UnitName) + "]", 1)) : createCommentVNode("", true)
19060
+ ])
19061
+ ]);
19062
+ }), 128))
19063
+ ])) : createCommentVNode("", true)
19064
+ ]));
19065
+ }
19066
+ const NvStructureSelect = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-502883e6"]]);
15469
19067
  export {
15470
19068
  filePreview as FilePreview,
15471
19069
  ComFormUp as NvComFormUp,
19070
+ NvDicSelect,
19071
+ NvStructureSelect,
19072
+ NvStructureTypeSelect,
15472
19073
  TextEditor2 as TextEditor,
15473
19074
  UploadFile
15474
19075
  };