UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

68 lines (67 loc) 1.88 kB
import { unwrap as a, assertReflexAction as x } from "./helpers.js"; import { UnknownRefError as w } from "./errors.js"; import { REF as v } from "./constants.js"; import { struct as m } from "../../../utils/struct/main.js"; import { enumerable as p } from "../../../utils/struct/property.js"; import { isFunction as z } from "../../../utils/value/is.js"; import { sameValue as k } from "../../../utils/value/compare.js"; const A = /* @__PURE__ */ (() => { const l = (r, s) => { const n = r.get(s); if (!n) throw new w(); return n; }, b = (r, s, n) => { let o, e; const t = a(s); try { o = l(r, t); } catch { x(n); } if (o) [, e] = o; else { const f = z(t), g = f ? (c) => { t(i = c); } : (c) => { t && (t.current = c, i = t.current); }, u = (c) => { if (e.size === 0) return; const d = i; if (g(c), !k(i, d)) for (const [_] of e) _(i, d); }; let i = f ? null : t.current; r.set(t, o = [u, e = /* @__PURE__ */ new Map()]), Object.defineProperties(u, { [v]: { value: t }, actions: { value: m({ get: { value: e.get.bind(e) }, size: { get: () => e.size } }) }, current: { get: () => i, set: f ? void 0 : u } }); } return n && e.set(n, 1 + (e.get(n) || 0)), o[0]; }, R = (r, s, n) => { const o = a(s), [, e] = l(r, o), t = e.get(n) || 0; t === 1 ? e.delete(n) : t > 1 && e.set(n, t - 1), e.size === 0 && o && r.delete(o); }; return () => { const r = /* @__PURE__ */ new WeakMap(); return m({ bind: p(b.bind(void 0, r)), unbind: p(R.bind(void 0, r)) }); }; })(), I = A(); export { I as $globalReflexRegister, A as createReflexRegister, I as default };