{"version":3,"sources":["node_modules/@arcgis/core/core/support/UpdatingHandles.js"],"sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.31/esri/copyright.txt for details.\n*/\nimport { _ as s } from \"../../chunks/tslib.es6.js\";\nimport e from \"../Accessor.js\";\nimport { makeHandle as t } from \"../handleUtils.js\";\nimport { watch as i, when as n, on as d, sync as a } from \"../reactiveUtils.js\";\nimport { schedule as r } from \"../scheduling.js\";\nimport { property as o } from \"../accessorSupport/decorators/property.js\";\nimport { subclass as l } from \"../accessorSupport/decorators/subclass.js\";\nlet h = class extends e {\n constructor() {\n super(...arguments), this.updating = !1, this._handleId = 0, this._scheduleHandleId = 0, this._pendingPromises = new Set();\n }\n destroy() {\n this.removeAll();\n }\n add(s, e, t = {}) {\n return this._installWatch(s, e, t, i);\n }\n addWhen(s, e, t = {}) {\n return this._installWatch(s, e, t, n);\n }\n addOnCollectionChange(s, e, {\n initial: i = !1,\n final: n = !1\n } = {}) {\n const r = ++this._handleId;\n return this.addHandles([d(s, \"after-changes\", this._createSyncUpdatingCallback(), a), d(s, \"change\", e, {\n onListenerAdd: i ? s => e({\n added: s.toArray(),\n removed: []\n }) : void 0,\n onListenerRemove: n ? s => e({\n added: [],\n removed: s.toArray()\n }) : void 0\n })], r), t(() => this.removeHandles(r));\n }\n addPromise(s) {\n if (null == s) return s;\n const e = ++this._handleId;\n this.addHandles(t(() => {\n this._pendingPromises.delete(s) && (0 !== this._pendingPromises.size || this.hasHandles(c) || this._set(\"updating\", !1));\n }), e), this._pendingPromises.add(s), this._set(\"updating\", !0);\n const i = () => this.removeHandles(e);\n return s.then(i, i), s;\n }\n removeAll() {\n this._pendingPromises.clear(), this.removeAllHandles(), this._set(\"updating\", !1);\n }\n _installWatch(s, e, i = {}, n) {\n const d = ++this._handleId;\n i.sync || this._installSyncUpdatingWatch(s, d);\n const a = n(s, e, i);\n return this.addHandles(a, d), t(() => this.removeHandles(d));\n }\n _installSyncUpdatingWatch(s, e) {\n const t = this._createSyncUpdatingCallback(),\n n = i(s, t, {\n sync: !0,\n equals: () => !1\n });\n return this.addHandles(n, e), n;\n }\n _createSyncUpdatingCallback() {\n return () => {\n this.removeHandles(c), ++this._scheduleHandleId;\n const s = this._scheduleHandleId;\n this._get(\"updating\") || this._set(\"updating\", !0), this.addHandles(r(() => {\n s === this._scheduleHandleId && (this._set(\"updating\", this._pendingPromises.size > 0), this.removeHandles(c));\n }), c);\n };\n }\n};\ns([o({\n readOnly: !0\n})], h.prototype, \"updating\", void 0), h = s([l(\"esri.core.support.UpdatingHandles\")], h);\nconst c = -42;\nexport { h as UpdatingHandles };"],"mappings":"2OAWA,IAAIA,EAAI,cAAcC,CAAE,CACtB,aAAc,CACZ,MAAM,GAAG,SAAS,EAAG,KAAK,SAAW,GAAI,KAAK,UAAY,EAAG,KAAK,kBAAoB,EAAG,KAAK,iBAAmB,IAAI,GACvH,CACA,SAAU,CACR,KAAK,UAAU,CACjB,CACA,IAAIC,EAAGC,EAAGC,EAAI,CAAC,EAAG,CAChB,OAAO,KAAK,cAAcF,EAAGC,EAAGC,EAAGC,CAAC,CACtC,CACA,QAAQH,EAAGC,EAAGC,EAAI,CAAC,EAAG,CACpB,OAAO,KAAK,cAAcF,EAAGC,EAAGC,EAAGE,CAAC,CACtC,CACA,sBAAsBJ,EAAGC,EAAG,CAC1B,QAASI,EAAI,GACb,MAAO,EAAI,EACb,EAAI,CAAC,EAAG,CACN,IAAMC,EAAI,EAAE,KAAK,UACjB,OAAO,KAAK,WAAW,CAACC,EAAEP,EAAG,gBAAiB,KAAK,4BAA4B,EAAGQ,CAAC,EAAGD,EAAEP,EAAG,SAAUC,EAAG,CACtG,cAAeI,EAAIL,GAAKC,EAAE,CACxB,MAAOD,EAAE,QAAQ,EACjB,QAAS,CAAC,CACZ,CAAC,EAAI,OACL,iBAAkB,EAAIA,GAAKC,EAAE,CAC3B,MAAO,CAAC,EACR,QAASD,EAAE,QAAQ,CACrB,CA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