chunk-JLSNMUQJ.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {
  2. M,
  3. ie,
  4. p
  5. } from "./chunk-CRGY2SDS.js";
  6. // node_modules/@arcgis/core/layers/support/FieldsIndex.js
  7. function s(e) {
  8. return "date" === e.type || "esriFieldTypeDate" === e.type;
  9. }
  10. function l(e) {
  11. return "oid" === e.type || "esriFieldTypeOID" === e.type;
  12. }
  13. function d(e) {
  14. return "global-id" === e.type || "esriFieldTypeGlobalID" === e.type;
  15. }
  16. var r = class {
  17. constructor(i = []) {
  18. if (this.fields = [], this._fieldsMap = /* @__PURE__ */ new Map(), this._normalizedFieldsMap = /* @__PURE__ */ new Map(), this._dateFieldsSet = /* @__PURE__ */ new Set(), this._numericFieldsSet = /* @__PURE__ */ new Set(), this.dateFields = [], this.numericFields = [], this._requiredFields = null, !i)
  19. return;
  20. this.fields = i;
  21. const t = [];
  22. for (const r2 of i) {
  23. const i2 = r2 && r2.name;
  24. if (i2) {
  25. const u = n(i2), h = a(i2);
  26. this._fieldsMap.set(i2, r2), this._fieldsMap.set(u, r2), this._normalizedFieldsMap.set(h, r2), t.push(u), s(r2) ? (this.dateFields.push(r2), this._dateFieldsSet.add(r2)) : ie(r2) && (this._numericFieldsSet.add(r2), this.numericFields.push(r2)), l(r2) || d(r2) || (r2.editable = null == r2.editable || !!r2.editable, r2.nullable = null == r2.nullable || !!r2.nullable);
  27. }
  28. }
  29. t.sort(), this.uid = t.join(",");
  30. }
  31. destroy() {
  32. this._fieldsMap.clear();
  33. }
  34. get requiredFields() {
  35. if (!this._requiredFields) {
  36. this._requiredFields = [];
  37. for (const e of this.fields)
  38. l(e) || d(e) || e.nullable || void 0 !== M(e) || this._requiredFields.push(e);
  39. }
  40. return this._requiredFields;
  41. }
  42. has(e) {
  43. return null != this.get(e);
  44. }
  45. get(e) {
  46. var _a;
  47. if (!e)
  48. return;
  49. let i = this._fieldsMap.get(e);
  50. return i || (i = (_a = this._fieldsMap.get(n(e))) != null ? _a : this._normalizedFieldsMap.get(a(e)), i && this._fieldsMap.set(e, i), i);
  51. }
  52. isDateField(e) {
  53. return this._dateFieldsSet.has(this.get(e));
  54. }
  55. isNumericField(e) {
  56. return this._numericFieldsSet.has(this.get(e));
  57. }
  58. normalizeFieldName(e) {
  59. var _a;
  60. const i = this.get(e);
  61. if (i)
  62. return (_a = i.name) != null ? _a : void 0;
  63. }
  64. };
  65. function n(e) {
  66. return e.trim().toLowerCase();
  67. }
  68. function a(e) {
  69. return p(e).toLowerCase();
  70. }
  71. export {
  72. r
  73. };
  74. //# sourceMappingURL=chunk-JLSNMUQJ.js.map