@hellocoop/vue 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
- import { provide as oe, inject as le, defineComponent as C, onMounted as Q, ref as X, openBlock as E, createElementBlock as M, normalizeClass as se, unref as Y, normalizeStyle as ue, createElementVNode as ce, createBlock as j, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as me, renderSlot as Z, createCommentVNode as ee } from "vue";
2
- const w = {
1
+ import { provide as ae, inject as le, defineComponent as L, onMounted as Q, ref as X, openBlock as k, createElementBlock as U, normalizeClass as se, normalizeStyle as ue, createElementVNode as ce, createBlock as q, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as pe, renderSlot as Z, createCommentVNode as ee } from "vue";
2
+ const m = {
3
3
  login: "/api/hellocoop?login=true",
4
4
  auth: "/api/hellocoop?auth=true",
5
5
  logout: "/api/hellocoop?logout=true"
6
- }, te = "HelloAuth", ye = () => le(te), Be = {
6
+ }, te = "HelloAuth", _e = () => le(te), Ke = {
7
7
  props: ["auth", "config"],
8
8
  setup(t) {
9
- var n, e, i;
10
- (n = t == null ? void 0 : t.config) != null && n.login && (w.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (w.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (w.logout = t.config.logout), oe(te, t.auth);
9
+ var r, e, i;
10
+ (r = t == null ? void 0 : t.config) != null && r.login && (m.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (m.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (m.logout = t.config.logout), ae(te, t.auth);
11
11
  },
12
12
  render() {
13
13
  return this.$slots.default();
14
14
  }
15
15
  };
16
- var A;
16
+ var P;
17
17
  ((t) => {
18
18
  t.STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css", t.HOVER_MAPPING = {
19
19
  pop: "",
@@ -34,260 +34,292 @@ var A;
34
34
  "aware-static": "hello-btn-white-and-static"
35
35
  }
36
36
  };
37
- })(A || (A = {}));
38
- const be = ["disabled"], pe = ["innerHTML"], U = /* @__PURE__ */ C({
37
+ })(P || (P = {}));
38
+ const ye = /* @__PURE__ */ L({
39
39
  __name: "BaseButton",
40
40
  props: {
41
- label: { default: "ō   Continue with Hellō" },
42
- style: {},
43
- color: { default: "black" },
44
- theme: { default: "ignore-light" },
45
- hover: { default: "pop" },
46
- scope: {},
47
- update: { type: Boolean },
48
- targetURI: {},
49
- providerHint: {},
50
- showLoader: { type: Boolean, default: !1 },
51
- disabled: { type: Boolean, default: !1 },
52
- promptLogin: { type: Boolean, default: !1 },
53
- promptConsent: { type: Boolean, default: !1 },
54
- loginHint: { default: "" },
55
- domainHint: { default: "" }
41
+ label: { type: String, required: !1, default: "ō   Continue with Hellō" },
42
+ style: { type: null, required: !1 },
43
+ color: { type: String, required: !1, default: "black" },
44
+ theme: { type: String, required: !1, default: "ignore-light" },
45
+ hover: { type: String, required: !1, default: "pop" },
46
+ scope: { type: Array, required: !1 },
47
+ update: { type: Boolean, required: !1 },
48
+ targetURI: { type: String, required: !1 },
49
+ providerHint: { type: Array, required: !1 },
50
+ showLoader: { type: Boolean, required: !1, default: !1 },
51
+ disabled: { type: Boolean, required: !1, default: !1 },
52
+ promptLogin: { type: Boolean, required: !1, default: !1 },
53
+ promptConsent: { type: Boolean, required: !1, default: !1 },
54
+ loginHint: { type: String, required: !1, default: "" },
55
+ domainHint: { type: String, required: !1, default: "" }
56
56
  },
57
- setup(t) {
58
- let n = !1;
57
+ setup(t, { expose: r }) {
58
+ r();
59
+ let e = !1;
59
60
  Q(() => {
60
- typeof window < "u" && !n && (Array.from(document.head.getElementsByTagName("link")).find(
61
- (f) => {
61
+ typeof window < "u" && !e && (Array.from(document.head.getElementsByTagName("link")).find(
62
+ (a) => {
62
63
  var s;
63
- return f.getAttribute("rel") === "stylesheet" && ((s = f.getAttribute("href")) == null ? void 0 : s.startsWith(A.STYLES_URL));
64
+ return a.getAttribute("rel") === "stylesheet" && ((s = a.getAttribute("href")) == null ? void 0 : s.startsWith(P.STYLES_URL));
64
65
  }
65
- ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), n = !0);
66
+ ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), e = !0);
66
67
  });
67
- const e = X(!1), i = t, a = new URL(w.login, window.location.origin);
68
- i.scope && a.searchParams.set("scope", i.scope.join(" ")), a.searchParams.set("target_uri", i.targetURI || window.location.pathname), i.update && a.searchParams.set("prompt", "consent"), i.promptLogin && i.promptConsent ? a.searchParams.set("prompt", "login consent") : i.promptLogin ? a.searchParams.set("prompt", "login") : i.promptConsent && a.searchParams.set("prompt", "consent"), i.loginHint && a.searchParams.set("login_hint", i.loginHint), i.domainHint && a.searchParams.set("login_hint", i.domainHint), i.providerHint && a.searchParams.set("provider_hint", i.providerHint.join(" "));
69
- const r = () => {
70
- e.value = !0, window.location.href = a.href;
71
- };
72
- return (l, f) => {
73
- var s;
74
- return E(), M("button", {
75
- onClick: r,
76
- class: se(["hello-btn", (s = Y(A).CLASS_MAPPING[i.color]) == null ? void 0 : s[i.theme], Y(A).HOVER_MAPPING[l.hover], (l.showLoader || e.value) && "hello-btn-loader"]),
77
- disabled: i.disabled || e.value,
78
- style: ue(l.style)
79
- }, [
80
- ce("span", { innerHTML: l.label }, null, 8, pe)
81
- ], 14, be);
82
- };
68
+ const i = X(!1), o = t, n = new URL(m.login, window.location.origin);
69
+ o.scope && n.searchParams.set("scope", o.scope.join(" ")), n.searchParams.set("target_uri", o.targetURI || window.location.pathname), o.update && n.searchParams.set("prompt", "consent"), o.promptLogin && o.promptConsent ? n.searchParams.set("prompt", "login consent") : o.promptLogin ? n.searchParams.set("prompt", "login") : o.promptConsent && n.searchParams.set("prompt", "consent"), o.loginHint && n.searchParams.set("login_hint", o.loginHint), o.domainHint && n.searchParams.set("login_hint", o.domainHint), o.providerHint && n.searchParams.set("provider_hint", o.providerHint.join(" "));
70
+ const c = { get checkedForStylesheet() {
71
+ return e;
72
+ }, set checkedForStylesheet(f) {
73
+ e = f;
74
+ }, clicked: i, props: o, loginRoute: n, onClickHandler: () => {
75
+ i.value = !0, window.location.href = n.href;
76
+ }, get Button() {
77
+ return P;
78
+ } };
79
+ return Object.defineProperty(c, "__isScriptSetup", { enumerable: !1, value: !0 }), c;
83
80
  }
84
- }), De = /* @__PURE__ */ C({
81
+ }), R = (t, r) => {
82
+ const e = t.__vccOpts || t;
83
+ for (const [i, o] of r)
84
+ e[i] = o;
85
+ return e;
86
+ }, be = ["disabled"], me = ["innerHTML"];
87
+ function we(t, r, e, i, o, n) {
88
+ var l;
89
+ return k(), U("button", {
90
+ onClick: i.onClickHandler,
91
+ class: se(["hello-btn", (l = i.Button.CLASS_MAPPING[i.props.color]) == null ? void 0 : l[i.props.theme], i.Button.HOVER_MAPPING[e.hover], (e.showLoader || i.clicked) && "hello-btn-loader"]),
92
+ disabled: i.props.disabled || i.clicked,
93
+ style: ue(e.style)
94
+ }, [
95
+ ce("span", { innerHTML: e.label }, null, 8, me)
96
+ ], 14, be);
97
+ }
98
+ const M = /* @__PURE__ */ R(ye, [["render", we], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/BaseButton.vue"]]), Se = /* @__PURE__ */ L({
85
99
  __name: "ContinueButton",
86
- setup(t) {
87
- return (n, e) => (E(), j(U));
100
+ setup(t, { expose: r }) {
101
+ r();
102
+ const e = { BaseButton: M };
103
+ return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
88
104
  }
89
- }), xe = /* @__PURE__ */ C({
105
+ });
106
+ function Ce(t, r, e, i, o, n) {
107
+ return k(), q(i.BaseButton);
108
+ }
109
+ const We = /* @__PURE__ */ R(Se, [["render", Ce], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/ContinueButton.vue"]]), Le = /* @__PURE__ */ L({
90
110
  __name: "LoginButton",
91
- setup(t) {
92
- return (n, e) => (E(), j(U, { label: "ō   Login with Hellō" }));
111
+ setup(t, { expose: r }) {
112
+ r();
113
+ const e = { BaseButton: M };
114
+ return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
93
115
  }
94
- }), $e = /* @__PURE__ */ C({
116
+ });
117
+ function ke(t, r, e, i, o, n) {
118
+ return k(), q(i.BaseButton, { label: "ō   Login with Hellō" });
119
+ }
120
+ const Ye = /* @__PURE__ */ R(Le, [["render", ke], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/LoginButton.vue"]]), Re = /* @__PURE__ */ L({
95
121
  __name: "UpdateProfileButton",
96
- setup(t) {
97
- return (n, e) => (E(), j(U, {
98
- label: "ō   Update Profile with Hellō",
99
- update: !0
100
- }));
122
+ setup(t, { expose: r }) {
123
+ r();
124
+ const e = { BaseButton: M };
125
+ return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
101
126
  }
102
127
  });
103
- var D = /* @__PURE__ */ new WeakMap(), q = 0;
104
- function we(t) {
128
+ function Ae(t, r, e, i, o, n) {
129
+ return k(), q(i.BaseButton, {
130
+ label: "ō   Update Profile with Hellō",
131
+ update: !0
132
+ });
133
+ }
134
+ const Je = /* @__PURE__ */ R(Re, [["render", Ae], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/UpdateProfileButton.vue"]]);
135
+ var $ = /* @__PURE__ */ new WeakMap(), Y = 0;
136
+ function Ie(t) {
105
137
  if (!t.length)
106
138
  return "";
107
- for (var n = "arg", e = 0; e < t.length; ++e) {
139
+ for (var r = "arg", e = 0; e < t.length; ++e) {
108
140
  var i = void 0;
109
- t[e] === null || typeof t[e] != "object" && typeof t[e] != "function" ? typeof t[e] == "string" ? i = '"' + t[e] + '"' : i = String(t[e]) : D.has(t[e]) ? i = D.get(t[e]) : (i = q, D.set(t[e], q++)), n += "@" + i;
141
+ t[e] === null || typeof t[e] != "object" && typeof t[e] != "function" ? typeof t[e] == "string" ? i = '"' + t[e] + '"' : i = String(t[e]) : $.has(t[e]) ? i = $.get(t[e]) : (i = Y, $.set(t[e], Y++)), r += "@" + i;
110
142
  }
111
- return n;
143
+ return r;
112
144
  }
113
- function _e(t) {
145
+ function Be(t) {
114
146
  if (typeof t == "function")
115
147
  try {
116
148
  t = t();
117
149
  } catch {
118
150
  t = "";
119
151
  }
120
- return Array.isArray(t) ? t = we(t) : t = String(t || ""), t;
152
+ return Array.isArray(t) ? t = Ie(t) : t = String(t || ""), t;
121
153
  }
122
154
  var F = (
123
155
  /** @class */
124
156
  function() {
125
- function t(n) {
126
- n === void 0 && (n = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = n;
157
+ function t(r) {
158
+ r === void 0 && (r = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = r;
127
159
  }
128
- return t.prototype.serializeKey = function(n) {
129
- return _e(n);
130
- }, t.prototype.get = function(n) {
131
- var e = this.serializeKey(n);
160
+ return t.prototype.serializeKey = function(r) {
161
+ return Be(r);
162
+ }, t.prototype.get = function(r) {
163
+ var e = this.serializeKey(r);
132
164
  return this.items.get(e);
133
- }, t.prototype.set = function(n, e, i) {
134
- var a = this.serializeKey(n), r = i || this.ttl, l = Date.now(), f = {
165
+ }, t.prototype.set = function(r, e, i) {
166
+ var o = this.serializeKey(r), n = i || this.ttl, l = Date.now(), c = {
135
167
  data: e,
136
168
  createdAt: l,
137
- expiresAt: r ? l + r : 1 / 0
169
+ expiresAt: n ? l + n : 1 / 0
138
170
  };
139
- this.dispatchExpire(r, f, a), this.items.set(a, f);
140
- }, t.prototype.dispatchExpire = function(n, e, i) {
141
- var a = this;
142
- n && setTimeout(function() {
143
- var r = Date.now(), l = r >= e.expiresAt;
144
- l && a.delete(i);
145
- }, n);
146
- }, t.prototype.delete = function(n) {
147
- this.items.delete(n);
171
+ this.dispatchExpire(n, c, o), this.items.set(o, c);
172
+ }, t.prototype.dispatchExpire = function(r, e, i) {
173
+ var o = this;
174
+ r && setTimeout(function() {
175
+ var n = Date.now(), l = n >= e.expiresAt;
176
+ l && o.delete(i);
177
+ }, r);
178
+ }, t.prototype.delete = function(r) {
179
+ this.items.delete(r);
148
180
  }, t;
149
181
  }()
150
182
  );
151
- function Re() {
183
+ function He() {
152
184
  return typeof navigator.onLine < "u" ? navigator.onLine : !0;
153
185
  }
154
- function Le() {
186
+ function Pe() {
155
187
  return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
156
188
  }
157
- var Ce = function(t) {
158
- return fetch(t).then(function(n) {
159
- return n.json();
189
+ var Oe = function(t) {
190
+ return fetch(t).then(function(r) {
191
+ return r.json();
160
192
  });
161
193
  };
162
- const x = {
163
- isOnline: Re,
164
- isDocumentVisible: Le,
165
- fetcher: Ce
194
+ const j = {
195
+ isOnline: He,
196
+ isDocumentVisible: Pe,
197
+ fetcher: Oe
166
198
  };
167
- var y = globalThis && globalThis.__assign || function() {
168
- return y = Object.assign || function(t) {
169
- for (var n, e = 1, i = arguments.length; e < i; e++) {
170
- n = arguments[e];
171
- for (var a in n)
172
- Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
199
+ var _ = globalThis && globalThis.__assign || function() {
200
+ return _ = Object.assign || function(t) {
201
+ for (var r, e = 1, i = arguments.length; e < i; e++) {
202
+ r = arguments[e];
203
+ for (var o in r)
204
+ Object.prototype.hasOwnProperty.call(r, o) && (t[o] = r[o]);
173
205
  }
174
206
  return t;
175
- }, y.apply(this, arguments);
176
- }, R = globalThis && globalThis.__awaiter || function(t, n, e, i) {
177
- function a(r) {
178
- return r instanceof e ? r : new e(function(l) {
179
- l(r);
207
+ }, _.apply(this, arguments);
208
+ }, S = globalThis && globalThis.__awaiter || function(t, r, e, i) {
209
+ function o(n) {
210
+ return n instanceof e ? n : new e(function(l) {
211
+ l(n);
180
212
  });
181
213
  }
182
- return new (e || (e = Promise))(function(r, l) {
183
- function f(u) {
214
+ return new (e || (e = Promise))(function(n, l) {
215
+ function c(s) {
184
216
  try {
185
- o(i.next(u));
217
+ a(i.next(s));
186
218
  } catch (g) {
187
219
  l(g);
188
220
  }
189
221
  }
190
- function s(u) {
222
+ function f(s) {
191
223
  try {
192
- o(i.throw(u));
224
+ a(i.throw(s));
193
225
  } catch (g) {
194
226
  l(g);
195
227
  }
196
228
  }
197
- function o(u) {
198
- u.done ? r(u.value) : a(u.value).then(f, s);
229
+ function a(s) {
230
+ s.done ? n(s.value) : o(s.value).then(c, f);
199
231
  }
200
- o((i = i.apply(t, n || [])).next());
232
+ a((i = i.apply(t, r || [])).next());
201
233
  });
202
- }, L = globalThis && globalThis.__generator || function(t, n) {
234
+ }, C = globalThis && globalThis.__generator || function(t, r) {
203
235
  var e = { label: 0, sent: function() {
204
- if (r[0] & 1)
205
- throw r[1];
206
- return r[1];
207
- }, trys: [], ops: [] }, i, a, r, l;
208
- return l = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
236
+ if (n[0] & 1)
237
+ throw n[1];
238
+ return n[1];
239
+ }, trys: [], ops: [] }, i, o, n, l;
240
+ return l = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
209
241
  return this;
210
242
  }), l;
211
- function f(o) {
212
- return function(u) {
213
- return s([o, u]);
243
+ function c(a) {
244
+ return function(s) {
245
+ return f([a, s]);
214
246
  };
215
247
  }
216
- function s(o) {
248
+ function f(a) {
217
249
  if (i)
218
250
  throw new TypeError("Generator is already executing.");
219
251
  for (; e; )
220
252
  try {
221
- if (i = 1, a && (r = o[0] & 2 ? a.return : o[0] ? a.throw || ((r = a.return) && r.call(a), 0) : a.next) && !(r = r.call(a, o[1])).done)
222
- return r;
223
- switch (a = 0, r && (o = [o[0] & 2, r.value]), o[0]) {
253
+ if (i = 1, o && (n = a[0] & 2 ? o.return : a[0] ? o.throw || ((n = o.return) && n.call(o), 0) : o.next) && !(n = n.call(o, a[1])).done)
254
+ return n;
255
+ switch (o = 0, n && (a = [a[0] & 2, n.value]), a[0]) {
224
256
  case 0:
225
257
  case 1:
226
- r = o;
258
+ n = a;
227
259
  break;
228
260
  case 4:
229
- return e.label++, { value: o[1], done: !1 };
261
+ return e.label++, { value: a[1], done: !1 };
230
262
  case 5:
231
- e.label++, a = o[1], o = [0];
263
+ e.label++, o = a[1], a = [0];
232
264
  continue;
233
265
  case 7:
234
- o = e.ops.pop(), e.trys.pop();
266
+ a = e.ops.pop(), e.trys.pop();
235
267
  continue;
236
268
  default:
237
- if (r = e.trys, !(r = r.length > 0 && r[r.length - 1]) && (o[0] === 6 || o[0] === 2)) {
269
+ if (n = e.trys, !(n = n.length > 0 && n[n.length - 1]) && (a[0] === 6 || a[0] === 2)) {
238
270
  e = 0;
239
271
  continue;
240
272
  }
241
- if (o[0] === 3 && (!r || o[1] > r[0] && o[1] < r[3])) {
242
- e.label = o[1];
273
+ if (a[0] === 3 && (!n || a[1] > n[0] && a[1] < n[3])) {
274
+ e.label = a[1];
243
275
  break;
244
276
  }
245
- if (o[0] === 6 && e.label < r[1]) {
246
- e.label = r[1], r = o;
277
+ if (a[0] === 6 && e.label < n[1]) {
278
+ e.label = n[1], n = a;
247
279
  break;
248
280
  }
249
- if (r && e.label < r[2]) {
250
- e.label = r[2], e.ops.push(o);
281
+ if (n && e.label < n[2]) {
282
+ e.label = n[2], e.ops.push(a);
251
283
  break;
252
284
  }
253
- r[2] && e.ops.pop(), e.trys.pop();
285
+ n[2] && e.ops.pop(), e.trys.pop();
254
286
  continue;
255
287
  }
256
- o = n.call(t, e);
257
- } catch (u) {
258
- o = [6, u], a = 0;
288
+ a = r.call(t, e);
289
+ } catch (s) {
290
+ a = [6, s], o = 0;
259
291
  } finally {
260
- i = r = 0;
292
+ i = n = 0;
261
293
  }
262
- if (o[0] & 5)
263
- throw o[1];
264
- return { value: o[0] ? o[1] : void 0, done: !0 };
294
+ if (a[0] & 5)
295
+ throw a[1];
296
+ return { value: a[0] ? a[1] : void 0, done: !0 };
265
297
  }
266
- }, Ee = globalThis && globalThis.__read || function(t, n) {
298
+ }, Ee = globalThis && globalThis.__read || function(t, r) {
267
299
  var e = typeof Symbol == "function" && t[Symbol.iterator];
268
300
  if (!e)
269
301
  return t;
270
- var i = e.call(t), a, r = [], l;
302
+ var i = e.call(t), o, n = [], l;
271
303
  try {
272
- for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; )
273
- r.push(a.value);
274
- } catch (f) {
275
- l = { error: f };
304
+ for (; (r === void 0 || r-- > 0) && !(o = i.next()).done; )
305
+ n.push(o.value);
306
+ } catch (c) {
307
+ l = { error: c };
276
308
  } finally {
277
309
  try {
278
- a && !a.done && (e = i.return) && e.call(i);
310
+ o && !o.done && (e = i.return) && e.call(i);
279
311
  } finally {
280
312
  if (l)
281
313
  throw l.error;
282
314
  }
283
315
  }
284
- return r;
285
- }, Ie = globalThis && globalThis.__spreadArray || function(t, n, e) {
316
+ return n;
317
+ }, xe = globalThis && globalThis.__spreadArray || function(t, r, e) {
286
318
  if (e || arguments.length === 2)
287
- for (var i = 0, a = n.length, r; i < a; i++)
288
- (r || !(i in n)) && (r || (r = Array.prototype.slice.call(n, 0, i)), r[i] = n[i]);
289
- return t.concat(r || Array.prototype.slice.call(n));
290
- }, ne = new F(), V = new F(), $ = new F(), re = {
319
+ for (var i = 0, o = r.length, n; i < o; i++)
320
+ (n || !(i in r)) && (n || (n = Array.prototype.slice.call(r, 0, i)), n[i] = r[i]);
321
+ return t.concat(n || Array.prototype.slice.call(r));
322
+ }, ne = new F(), O = new F(), D = new F(), re = {
291
323
  cache: ne,
292
324
  refreshInterval: 0,
293
325
  ttl: 0,
@@ -298,74 +330,74 @@ var y = globalThis && globalThis.__assign || function() {
298
330
  shouldRetryOnError: !0,
299
331
  errorRetryInterval: 5e3,
300
332
  errorRetryCount: 5,
301
- fetcher: x.fetcher,
302
- isOnline: x.isOnline,
303
- isDocumentVisible: x.isDocumentVisible
333
+ fetcher: j.fetcher,
334
+ isOnline: j.isOnline,
335
+ isDocumentVisible: j.isDocumentVisible
304
336
  };
305
- function Se(t, n, e) {
306
- var i = V.get(t);
337
+ function Te(t, r, e) {
338
+ var i = O.get(t);
307
339
  if (i)
308
- i.data.push(n);
340
+ i.data.push(r);
309
341
  else {
310
- var a = 5e3;
311
- V.set(t, [n], e > 0 ? e + a : e);
342
+ var o = 5e3;
343
+ O.set(t, [r], e > 0 ? e + o : e);
312
344
  }
313
345
  }
314
- function Ae(t, n, e) {
315
- if (e.isDocumentVisible() && !(e.errorRetryCount !== void 0 && n > e.errorRetryCount)) {
316
- var i = Math.min(n || 0, e.errorRetryCount), a = i * e.errorRetryInterval;
346
+ function Ve(t, r, e) {
347
+ if (e.isDocumentVisible() && !(e.errorRetryCount !== void 0 && r > e.errorRetryCount)) {
348
+ var i = Math.min(r || 0, e.errorRetryCount), o = i * e.errorRetryInterval;
317
349
  setTimeout(function() {
318
350
  t(null, { errorRetryCount: i + 1, shouldRetryOnError: !0 });
319
- }, a);
351
+ }, o);
320
352
  }
321
353
  }
322
- var J = function(t, n, e, i) {
323
- return e === void 0 && (e = ne), i === void 0 && (i = re.ttl), R(void 0, void 0, void 0, function() {
324
- var a, r, l, f, s, o, u;
325
- return L(this, function(g) {
354
+ var J = function(t, r, e, i) {
355
+ return e === void 0 && (e = ne), i === void 0 && (i = re.ttl), S(void 0, void 0, void 0, function() {
356
+ var o, n, l, c, f, a, s;
357
+ return C(this, function(g) {
326
358
  switch (g.label) {
327
359
  case 0:
328
- if (!Pe(n))
360
+ if (!je(r))
329
361
  return [3, 5];
330
362
  g.label = 1;
331
363
  case 1:
332
- return g.trys.push([1, 3, , 4]), [4, n];
364
+ return g.trys.push([1, 3, , 4]), [4, r];
333
365
  case 2:
334
- return a = g.sent(), [3, 4];
366
+ return o = g.sent(), [3, 4];
335
367
  case 3:
336
- return f = g.sent(), r = f, [3, 4];
368
+ return c = g.sent(), n = c, [3, 4];
337
369
  case 4:
338
370
  return [3, 6];
339
371
  case 5:
340
- a = n, g.label = 6;
372
+ o = r, g.label = 6;
341
373
  case 6:
342
- if (l = !1, s = { data: a, error: r, isValidating: l }, typeof a < "u")
374
+ if (l = !1, f = { data: o, error: n, isValidating: l }, typeof o < "u")
343
375
  try {
344
- e.set(t, s, i);
376
+ e.set(t, f, i);
345
377
  } catch (v) {
346
378
  console.error("swrv(mutate): failed to set cache", v);
347
379
  }
348
- return o = V.get(t), o && o.data.length && (u = o.data.filter(function(v) {
380
+ return a = O.get(t), a && a.data.length && (s = a.data.filter(function(v) {
349
381
  return v.key === t;
350
- }), u.forEach(function(v, d) {
351
- typeof s.data < "u" && (v.data = s.data), v.error = s.error, v.isValidating = s.isValidating;
352
- var b = d === u.length - 1;
353
- b || delete u[d];
354
- }), u = u.filter(Boolean)), [2, s];
382
+ }), s.forEach(function(v, d) {
383
+ typeof f.data < "u" && (v.data = f.data), v.error = f.error, v.isValidating = f.isValidating;
384
+ var y = d === s.length - 1;
385
+ y || delete s[d];
386
+ }), s = s.filter(Boolean)), [2, f];
355
387
  }
356
388
  });
357
389
  });
358
390
  };
359
- function Te() {
360
- for (var t = this, n = [], e = 0; e < arguments.length; e++)
361
- n[e] = arguments[e];
362
- var i, a, r = y({}, re), l = !1, f = !1, s = fe(), o = (s == null ? void 0 : s.proxy) || s;
363
- if (!o)
391
+ function $e() {
392
+ for (var t = this, r = [], e = 0; e < arguments.length; e++)
393
+ r[e] = arguments[e];
394
+ var i, o, n = _({}, re), l = !1, c = !1, f = fe(), a = (f == null ? void 0 : f.proxy) || f;
395
+ if (!a)
364
396
  return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
365
- var u = (o == null ? void 0 : o.$isServer) || !1;
366
- n.length >= 1 && (i = n[0]), n.length >= 2 && (a = n[1]), n.length > 2 && (r = y(y({}, r), n[2]));
367
- var g = u ? r.serverTTL : r.ttl, v = typeof i == "function" ? i : X(i);
368
- typeof a > "u" && (a = r.fetcher);
397
+ var s = (a == null ? void 0 : a.$isServer) || !1;
398
+ r.length >= 1 && (i = r[0]), r.length >= 2 && (o = r[1]), r.length > 2 && (n = _(_({}, n), r[2]));
399
+ var g = s ? n.serverTTL : n.ttl, v = typeof i == "function" ? i : X(i);
400
+ typeof o > "u" && (o = n.fetcher);
369
401
  var d = null;
370
402
  d || (d = de({
371
403
  data: void 0,
@@ -373,47 +405,47 @@ function Te() {
373
405
  isValidating: !0,
374
406
  key: null
375
407
  }));
376
- var b = function(h, c) {
377
- return R(t, void 0, void 0, function() {
378
- var N, m, I, S, H, z, O, G = this;
379
- return L(this, function(k) {
380
- switch (k.label) {
408
+ var y = function(h, u) {
409
+ return S(t, void 0, void 0, function() {
410
+ var N, p, A, I, E, z, x, G = this;
411
+ return C(this, function(T) {
412
+ switch (T.label) {
381
413
  case 0:
382
- return N = d.data === void 0, m = v.value, m ? (I = r.cache.get(m), S = I && I.data, d.isValidating = !0, S && (d.data = S.data, d.error = S.error), H = h || a, !H || !r.isDocumentVisible() && !N || (c == null ? void 0 : c.forceRevalidate) !== void 0 && !(c != null && c.forceRevalidate) ? (d.isValidating = !1, [
414
+ return N = d.data === void 0, p = v.value, p ? (A = n.cache.get(p), I = A && A.data, d.isValidating = !0, I && (d.data = I.data, d.error = I.error), E = h || o, !E || !n.isDocumentVisible() && !N || (u == null ? void 0 : u.forceRevalidate) !== void 0 && !(u != null && u.forceRevalidate) ? (d.isValidating = !1, [
383
415
  2
384
416
  /*return*/
385
- ]) : I && (z = !!(Date.now() - I.createdAt >= r.dedupingInterval || c != null && c.forceRevalidate), !z) ? (d.isValidating = !1, [
417
+ ]) : A && (z = !!(Date.now() - A.createdAt >= n.dedupingInterval || u != null && u.forceRevalidate), !z) ? (d.isValidating = !1, [
386
418
  2
387
419
  /*return*/
388
- ]) : (O = function() {
389
- return R(G, void 0, void 0, function() {
390
- var p, K, B, W;
391
- return L(this, function(P) {
392
- switch (P.label) {
420
+ ]) : (x = function() {
421
+ return S(G, void 0, void 0, function() {
422
+ var b, K, V, W;
423
+ return C(this, function(H) {
424
+ switch (H.label) {
393
425
  case 0:
394
- return p = $.get(m), p ? [3, 2] : (K = Array.isArray(m) ? m : [m], B = H.apply(void 0, Ie([], Ee(K), !1)), $.set(m, B, r.dedupingInterval), [4, J(m, B, r.cache, g)]);
426
+ return b = D.get(p), b ? [3, 2] : (K = Array.isArray(p) ? p : [p], V = E.apply(void 0, xe([], Ee(K), !1)), D.set(p, V, n.dedupingInterval), [4, J(p, V, n.cache, g)]);
395
427
  case 1:
396
- return P.sent(), [3, 4];
428
+ return H.sent(), [3, 4];
397
429
  case 2:
398
- return [4, J(m, p.data, r.cache, g)];
430
+ return [4, J(p, b.data, n.cache, g)];
399
431
  case 3:
400
- P.sent(), P.label = 4;
432
+ H.sent(), H.label = 4;
401
433
  case 4:
402
- return d.isValidating = !1, $.delete(m), d.error !== void 0 && (W = !l && r.shouldRetryOnError && (c ? c.shouldRetryOnError : !0), W && Ae(b, c ? c.errorRetryCount : 1, r)), [
434
+ return d.isValidating = !1, D.delete(p), d.error !== void 0 && (W = !l && n.shouldRetryOnError && (u ? u.shouldRetryOnError : !0), W && Ve(y, u ? u.errorRetryCount : 1, n)), [
403
435
  2
404
436
  /*return*/
405
437
  ];
406
438
  }
407
439
  });
408
440
  });
409
- }, S && r.revalidateDebounce ? (setTimeout(function() {
410
- return R(G, void 0, void 0, function() {
411
- return L(this, function(p) {
412
- switch (p.label) {
441
+ }, I && n.revalidateDebounce ? (setTimeout(function() {
442
+ return S(G, void 0, void 0, function() {
443
+ return C(this, function(b) {
444
+ switch (b.label) {
413
445
  case 0:
414
- return l ? [3, 2] : [4, O()];
446
+ return l ? [3, 2] : [4, x()];
415
447
  case 1:
416
- p.sent(), p.label = 2;
448
+ b.sent(), b.label = 2;
417
449
  case 2:
418
450
  return [
419
451
  2
@@ -422,14 +454,14 @@ function Te() {
422
454
  }
423
455
  });
424
456
  });
425
- }, r.revalidateDebounce), [3, 3]) : [3, 1])) : [
457
+ }, n.revalidateDebounce), [3, 3]) : [3, 1])) : [
426
458
  2
427
459
  /*return*/
428
460
  ];
429
461
  case 1:
430
- return [4, O()];
462
+ return [4, x()];
431
463
  case 2:
432
- k.sent(), k.label = 3;
464
+ T.sent(), T.label = 3;
433
465
  case 3:
434
466
  return [
435
467
  2
@@ -438,26 +470,26 @@ function Te() {
438
470
  }
439
471
  });
440
472
  });
441
- }, T = function() {
442
- return R(t, void 0, void 0, function() {
443
- return L(this, function(h) {
444
- return [2, b(null, { shouldRetryOnError: !1 })];
473
+ }, B = function() {
474
+ return S(t, void 0, void 0, function() {
475
+ return C(this, function(h) {
476
+ return [2, y(null, { shouldRetryOnError: !1 })];
445
477
  });
446
478
  });
447
- }, _ = null;
479
+ }, w = null;
448
480
  Q(function() {
449
481
  var h = function() {
450
- return R(t, void 0, void 0, function() {
451
- return L(this, function(c) {
452
- switch (c.label) {
482
+ return S(t, void 0, void 0, function() {
483
+ return C(this, function(u) {
484
+ switch (u.label) {
453
485
  case 0:
454
- return !d.error && r.isOnline() ? [4, b()] : [3, 2];
486
+ return !d.error && n.isOnline() ? [4, y()] : [3, 2];
455
487
  case 1:
456
- return c.sent(), [3, 3];
488
+ return u.sent(), [3, 3];
457
489
  case 2:
458
- _ && clearTimeout(_), c.label = 3;
490
+ w && clearTimeout(w), u.label = 3;
459
491
  case 3:
460
- return r.refreshInterval && !l && (_ = setTimeout(h, r.refreshInterval)), [
492
+ return n.refreshInterval && !l && (w = setTimeout(h, n.refreshInterval)), [
461
493
  2
462
494
  /*return*/
463
495
  ];
@@ -465,82 +497,92 @@ function Te() {
465
497
  });
466
498
  });
467
499
  };
468
- r.refreshInterval && (_ = setTimeout(h, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", T, !1), window.addEventListener("focus", T, !1));
500
+ n.refreshInterval && (w = setTimeout(h, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", B, !1), window.addEventListener("focus", B, !1));
469
501
  }), he(function() {
470
- l = !0, _ && clearTimeout(_), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", T, !1), window.removeEventListener("focus", T, !1));
471
- var h = V.get(v.value);
472
- h && (h.data = h.data.filter(function(c) {
473
- return c !== d;
502
+ l = !0, w && clearTimeout(w), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", B, !1), window.removeEventListener("focus", B, !1));
503
+ var h = O.get(v.value);
504
+ h && (h.data = h.data.filter(function(u) {
505
+ return u !== d;
474
506
  }));
475
507
  });
476
508
  try {
477
509
  ve(v, function(h) {
478
- ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Se(v.value, d, g), !u && !f && v.value && b(), f = !1;
510
+ ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Te(v.value, d, g), !s && !c && v.value && y(), c = !1;
479
511
  }, {
480
512
  immediate: !0
481
513
  });
482
514
  } catch {
483
515
  }
484
- var ae = y(y({}, me(d)), { mutate: function(h, c) {
485
- return b(h, y(y({}, c), { forceRevalidate: !0 }));
516
+ var oe = _(_({}, pe(d)), { mutate: function(h, u) {
517
+ return y(h, _(_({}, u), { forceRevalidate: !0 }));
486
518
  } });
487
- return ae;
519
+ return oe;
488
520
  }
489
- function Pe(t) {
521
+ function je(t) {
490
522
  return t !== null && typeof t == "object" && typeof t.then == "function";
491
523
  }
492
- const Ve = async (t) => {
524
+ const De = async (t) => {
493
525
  try {
494
526
  return await (await fetch(t)).json();
495
- } catch (n) {
496
- console.error(n);
527
+ } catch (r) {
528
+ console.error(r);
497
529
  return;
498
530
  }
499
531
  }, ie = () => {
500
- const t = ye(), { data: n = t, isValidating: e } = Te(w.auth, Ve);
532
+ const t = _e(), { data: r = t, isValidating: e } = $e(m.auth, De);
501
533
  return {
502
- auth: n || {},
534
+ auth: r || {},
503
535
  // @ts-ignore //TBD
504
536
  isLoading: e,
505
537
  // @ts-ignore
506
- isLoggedIn: n == null ? void 0 : n.isLoggedIn
538
+ isLoggedIn: r == null ? void 0 : r.isLoggedIn
507
539
  };
508
- }, He = { key: 0 }, Me = /* @__PURE__ */ C({
540
+ }, Ue = /* @__PURE__ */ L({
509
541
  __name: "LoggedIn",
510
- setup(t) {
511
- const n = () => {
512
- var e;
513
- return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
514
- };
515
- return (e, i) => n() ? (E(), M("div", He, [
516
- Z(e.$slots, "default")
517
- ])) : ee("", !0);
542
+ setup(t, { expose: r }) {
543
+ r();
544
+ const i = { isLoggedIn: () => {
545
+ var o;
546
+ return ((o = ie()) == null ? void 0 : o.isLoggedIn) || !1;
547
+ } };
548
+ return Object.defineProperty(i, "__isScriptSetup", { enumerable: !1, value: !0 }), i;
518
549
  }
519
- }), Oe = { key: 0 }, je = /* @__PURE__ */ C({
550
+ }), qe = { key: 0 };
551
+ function Me(t, r, e, i, o, n) {
552
+ return i.isLoggedIn() ? (k(), U("div", qe, [
553
+ Z(t.$slots, "default")
554
+ ])) : ee("v-if", !0);
555
+ }
556
+ const Qe = /* @__PURE__ */ R(Ue, [["render", Me], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedIn.vue"]]), Fe = /* @__PURE__ */ L({
520
557
  __name: "LoggedOut",
521
- setup(t) {
522
- const n = () => {
523
- var e;
524
- return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
525
- };
526
- return (e, i) => n() ? ee("", !0) : (E(), M("div", Oe, [
527
- Z(e.$slots, "default")
528
- ]));
558
+ setup(t, { expose: r }) {
559
+ r();
560
+ const i = { isLoggedIn: () => {
561
+ var o;
562
+ return ((o = ie()) == null ? void 0 : o.isLoggedIn) || !1;
563
+ } };
564
+ return Object.defineProperty(i, "__isScriptSetup", { enumerable: !1, value: !0 }), i;
529
565
  }
530
- }), Ue = () => w.logout;
531
- function Fe() {
532
- window.location.href = w.logout;
566
+ }), Ne = { key: 0 };
567
+ function ze(t, r, e, i, o, n) {
568
+ return i.isLoggedIn() ? ee("v-if", !0) : (k(), U("div", Ne, [
569
+ Z(t.$slots, "default")
570
+ ]));
571
+ }
572
+ const Xe = /* @__PURE__ */ R(Fe, [["render", ze], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedOut.vue"]]), Ze = () => m.logout;
573
+ function et() {
574
+ window.location.href = m.logout;
533
575
  }
534
576
  export {
535
- De as ContinueButton,
536
- Be as HelloProvider,
537
- Me as LoggedIn,
538
- je as LoggedOut,
539
- xe as LoginButton,
540
- $e as UpdateProfileButton,
541
- Ue as getLogOutRoute,
542
- Fe as logOut,
543
- w as routeConfig,
577
+ We as ContinueButton,
578
+ Ke as HelloProvider,
579
+ Qe as LoggedIn,
580
+ Xe as LoggedOut,
581
+ Ye as LoginButton,
582
+ Je as UpdateProfileButton,
583
+ Ze as getLogOutRoute,
584
+ et as logOut,
585
+ m as routeConfig,
544
586
  ie as useAuth,
545
- ye as useHelloProviderContext
587
+ _e as useHelloProviderContext
546
588
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(g,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g["@hellocoop/vue"]={},g.Vue))})(this,function(g,a){"use strict";const w={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},N="HelloAuth",z=()=>a.inject(N),Z={props:["auth","config"],setup(t){var n,e,i;(n=t==null?void 0:t.config)!=null&&n.login&&(w.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(w.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(w.logout=t.config.logout),a.provide(N,t.auth)},render(){return this.$slots.default()}};var S;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(S||(S={}));const ee=["disabled"],te=["innerHTML"],V=a.defineComponent({__name:"BaseButton",props:{label:{default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},update:{type:Boolean},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},promptLogin:{type:Boolean,default:!1},promptConsent:{type:Boolean,default:!1},loginHint:{default:""},domainHint:{default:""}},setup(t){let n=!1;a.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(d=>{var u;return d.getAttribute("rel")==="stylesheet"&&((u=d.getAttribute("href"))==null?void 0:u.startsWith(S.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const e=a.ref(!1),i=t,o=new URL(w.login,window.location.origin);i.scope&&o.searchParams.set("scope",i.scope.join(" ")),o.searchParams.set("target_uri",i.targetURI||window.location.pathname),i.update&&o.searchParams.set("prompt","consent"),i.promptLogin&&i.promptConsent?o.searchParams.set("prompt","login consent"):i.promptLogin?o.searchParams.set("prompt","login"):i.promptConsent&&o.searchParams.set("prompt","consent"),i.loginHint&&o.searchParams.set("login_hint",i.loginHint),i.domainHint&&o.searchParams.set("login_hint",i.domainHint),i.providerHint&&o.searchParams.set("provider_hint",i.providerHint.join(" "));const r=()=>{e.value=!0,window.location.href=o.href};return(s,d)=>{var u;return a.openBlock(),a.createElementBlock("button",{onClick:r,class:a.normalizeClass(["hello-btn",(u=a.unref(S).CLASS_MAPPING[i.color])==null?void 0:u[i.theme],a.unref(S).HOVER_MAPPING[s.hover],(s.showLoader||e.value)&&"hello-btn-loader"]),disabled:i.disabled||e.value,style:a.normalizeStyle(s.style)},[a.createElementVNode("span",{innerHTML:s.label},null,8,te)],14,ee)}}}),ne=a.defineComponent({__name:"ContinueButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V))}}),re=a.defineComponent({__name:"LoginButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V,{label:"ō   Login with Hellō"}))}}),ie=a.defineComponent({__name:"UpdateProfileButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V,{label:"ō   Update Profile with Hellō",update:!0}))}});var B=new WeakMap,x=0;function oe(t){if(!t.length)return"";for(var n="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):B.has(t[e])?i=B.get(t[e]):(i=x,B.set(t[e],x++)),n+="@"+i}return n}function ae(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=oe(t):t=String(t||""),t}var O=function(){function t(n){n===void 0&&(n=0),this.items=new Map,this.ttl=n}return t.prototype.serializeKey=function(n){return ae(n)},t.prototype.get=function(n){var e=this.serializeKey(n);return this.items.get(e)},t.prototype.set=function(n,e,i){var o=this.serializeKey(n),r=i||this.ttl,s=Date.now(),d={data:e,createdAt:s,expiresAt:r?s+r:1/0};this.dispatchExpire(r,d,o),this.items.set(o,d)},t.prototype.dispatchExpire=function(n,e,i){var o=this;n&&setTimeout(function(){var r=Date.now(),s=r>=e.expiresAt;s&&o.delete(i)},n)},t.prototype.delete=function(n){this.items.delete(n)},t}();function le(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function se(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ue=function(t){return fetch(t).then(function(n){return n.json()})};const H={isOnline:le,isDocumentVisible:se,fetcher:ue};var b=globalThis&&globalThis.__assign||function(){return b=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},b.apply(this,arguments)},R=globalThis&&globalThis.__awaiter||function(t,n,e,i){function o(r){return r instanceof e?r:new e(function(s){s(r)})}return new(e||(e=Promise))(function(r,s){function d(c){try{l(i.next(c))}catch(y){s(y)}}function u(c){try{l(i.throw(c))}catch(y){s(y)}}function l(c){c.done?r(c.value):o(c.value).then(d,u)}l((i=i.apply(t,n||[])).next())})},L=globalThis&&globalThis.__generator||function(t,n){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s;return s={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function d(l){return function(c){return u([l,c])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(r=l[0]&2?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,o=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){e.label=l[1];break}if(l[0]===6&&e.label<r[1]){e.label=r[1],r=l;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(l);break}r[2]&&e.ops.pop(),e.trys.pop();continue}l=n.call(t,e)}catch(c){l=[6,c],o=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ce=globalThis&&globalThis.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,r=[],s;try{for(;(n===void 0||n-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(d){s={error:d}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(s)throw s.error}}return r},fe=globalThis&&globalThis.__spreadArray||function(t,n,e){if(e||arguments.length===2)for(var i=0,o=n.length,r;i<o;i++)(r||!(i in n))&&(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))},G=new O,T=new O,D=new O,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:H.fetcher,isOnline:H.isOnline,isDocumentVisible:H.isDocumentVisible};function de(t,n,e){var i=T.get(t);if(i)i.data.push(n);else{var o=5e3;T.set(t,[n],e>0?e+o:e)}}function he(t,n,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&n>e.errorRetryCount)){var i=Math.min(n||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,n,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),R(void 0,void 0,void 0,function(){var o,r,s,d,u,l,c;return L(this,function(y){switch(y.label){case 0:if(!ve(n))return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,n];case 2:return o=y.sent(),[3,4];case 3:return d=y.sent(),r=d,[3,4];case 4:return[3,6];case 5:o=n,y.label=6;case 6:if(s=!1,u={data:o,error:r,isValidating:s},typeof o<"u")try{e.set(t,u,i)}catch(m){console.error("swrv(mutate): failed to set cache",m)}return l=T.get(t),l&&l.data.length&&(c=l.data.filter(function(m){return m.key===t}),c.forEach(function(m,h){typeof u.data<"u"&&(m.data=u.data),m.error=u.error,m.isValidating=u.isValidating;var _=h===c.length-1;_||delete c[h]}),c=c.filter(Boolean)),[2,u]}})})};function ge(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var i,o,r=b({},K),s=!1,d=!1,u=a.getCurrentInstance(),l=(u==null?void 0:u.proxy)||u;if(!l)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var c=(l==null?void 0:l.$isServer)||!1;n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]),n.length>2&&(r=b(b({},r),n[2]));var y=c?r.serverTTL:r.ttl,m=typeof i=="function"?i:a.ref(i);typeof o>"u"&&(o=r.fetcher);var h=null;h||(h=a.reactive({data:void 0,error:void 0,isValidating:!0,key:null}));var _=function(v,f){return R(t,void 0,void 0,function(){var Y,p,k,I,$,q,j,J=this;return L(this,function(U){switch(U.label){case 0:return Y=h.data===void 0,p=m.value,p?(k=r.cache.get(p),I=k&&k.data,h.isValidating=!0,I&&(h.data=I.data,h.error=I.error),$=v||o,!$||!r.isDocumentVisible()&&!Y||(f==null?void 0:f.forceRevalidate)!==void 0&&!(f!=null&&f.forceRevalidate)?(h.isValidating=!1,[2]):k&&(q=!!(Date.now()-k.createdAt>=r.dedupingInterval||f!=null&&f.forceRevalidate),!q)?(h.isValidating=!1,[2]):(j=function(){return R(J,void 0,void 0,function(){var C,Q,F,X;return L(this,function(P){switch(P.label){case 0:return C=D.get(p),C?[3,2]:(Q=Array.isArray(p)?p:[p],F=$.apply(void 0,fe([],ce(Q),!1)),D.set(p,F,r.dedupingInterval),[4,W(p,F,r.cache,y)]);case 1:return P.sent(),[3,4];case 2:return[4,W(p,C.data,r.cache,y)];case 3:P.sent(),P.label=4;case 4:return h.isValidating=!1,D.delete(p),h.error!==void 0&&(X=!s&&r.shouldRetryOnError&&(f?f.shouldRetryOnError:!0),X&&he(_,f?f.errorRetryCount:1,r)),[2]}})})},I&&r.revalidateDebounce?(setTimeout(function(){return R(J,void 0,void 0,function(){return L(this,function(C){switch(C.label){case 0:return s?[3,2]:[4,j()];case 1:C.sent(),C.label=2;case 2:return[2]}})})},r.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,j()];case 2:U.sent(),U.label=3;case 3:return[2]}})})},A=function(){return R(t,void 0,void 0,function(){return L(this,function(v){return[2,_(null,{shouldRetryOnError:!1})]})})},E=null;a.onMounted(function(){var v=function(){return R(t,void 0,void 0,function(){return L(this,function(f){switch(f.label){case 0:return!h.error&&r.isOnline()?[4,_()]:[3,2];case 1:return f.sent(),[3,3];case 2:E&&clearTimeout(E),f.label=3;case 3:return r.refreshInterval&&!s&&(E=setTimeout(v,r.refreshInterval)),[2]}})})};r.refreshInterval&&(E=setTimeout(v,r.refreshInterval)),r.revalidateOnFocus&&(document.addEventListener("visibilitychange",A,!1),window.addEventListener("focus",A,!1))}),a.onUnmounted(function(){s=!0,E&&clearTimeout(E),r.revalidateOnFocus&&(document.removeEventListener("visibilitychange",A,!1),window.removeEventListener("focus",A,!1));var v=T.get(m.value);v&&(v.data=v.data.filter(function(f){return f!==h}))});try{a.watch(m,function(v){a.isReadonly(m)||(m.value=v),h.key=v,h.isValidating=!!v,de(m.value,h,y),!c&&!d&&m.value&&_(),d=!1},{immediate:!0})}catch{}var Re=b(b({},a.toRefs(h)),{mutate:function(v,f){return _(v,b(b({},f),{forceRevalidate:!0}))}});return Re}function ve(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const me=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},M=()=>{const t=z(),{data:n=t,isValidating:e}=ge(w.auth,me);return{auth:n||{},isLoading:e,isLoggedIn:n==null?void 0:n.isLoggedIn}},ye={key:0},pe=a.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?(a.openBlock(),a.createElementBlock("div",ye,[a.renderSlot(e.$slots,"default")])):a.createCommentVNode("",!0)}}),be={key:0},we=a.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",be,[a.renderSlot(e.$slots,"default")]))}}),_e=()=>w.logout;function Ce(){window.location.href=w.logout}g.ContinueButton=ne,g.HelloProvider=Z,g.LoggedIn=pe,g.LoggedOut=we,g.LoginButton=re,g.UpdateProfileButton=ie,g.getLogOutRoute=_e,g.logOut=Ce,g.routeConfig=w,g.useAuth=M,g.useHelloProviderContext=z,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
1
+ (function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g["@hellocoop/vue"]={},g.Vue))})(this,function(g,l){"use strict";const m={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},F="HelloAuth",N=()=>l.inject(F),ee={props:["auth","config"],setup(t){var r,e,i;(r=t==null?void 0:t.config)!=null&&r.login&&(m.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(m.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(m.logout=t.config.logout),l.provide(F,t.auth)},render(){return this.$slots.default()}};var I;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(I||(I={}));const te=l.defineComponent({__name:"BaseButton",props:{label:{type:String,required:!1,default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{type:null,required:!1},color:{type:String,required:!1,default:"black"},theme:{type:String,required:!1,default:"ignore-light"},hover:{type:String,required:!1,default:"pop"},scope:{type:Array,required:!1},update:{type:Boolean,required:!1},targetURI:{type:String,required:!1},providerHint:{type:Array,required:!1},showLoader:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},promptLogin:{type:Boolean,required:!1,default:!1},promptConsent:{type:Boolean,required:!1,default:!1},loginHint:{type:String,required:!1,default:""},domainHint:{type:String,required:!1,default:""}},setup(t,{expose:r}){r();let e=!1;l.onMounted(()=>{typeof window<"u"&&!e&&(Array.from(document.head.getElementsByTagName("link")).find(a=>{var u;return a.getAttribute("rel")==="stylesheet"&&((u=a.getAttribute("href"))==null?void 0:u.startsWith(I.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),e=!0)});const i=l.ref(!1),o=t,n=new URL(m.login,window.location.origin);o.scope&&n.searchParams.set("scope",o.scope.join(" ")),n.searchParams.set("target_uri",o.targetURI||window.location.pathname),o.update&&n.searchParams.set("prompt","consent"),o.promptLogin&&o.promptConsent?n.searchParams.set("prompt","login consent"):o.promptLogin?n.searchParams.set("prompt","login"):o.promptConsent&&n.searchParams.set("prompt","consent"),o.loginHint&&n.searchParams.set("login_hint",o.loginHint),o.domainHint&&n.searchParams.set("login_hint",o.domainHint),o.providerHint&&n.searchParams.set("provider_hint",o.providerHint.join(" "));const f={get checkedForStylesheet(){return e},set checkedForStylesheet(d){e=d},clicked:i,props:o,loginRoute:n,onClickHandler:()=>{i.value=!0,window.location.href=n.href},get Button(){return I}};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),S=(t,r)=>{const e=t.__vccOpts||t;for(const[i,o]of r)e[i]=o;return e},ne=["disabled"],re=["innerHTML"];function ie(t,r,e,i,o,n){var s;return l.openBlock(),l.createElementBlock("button",{onClick:i.onClickHandler,class:l.normalizeClass(["hello-btn",(s=i.Button.CLASS_MAPPING[i.props.color])==null?void 0:s[i.props.theme],i.Button.HOVER_MAPPING[e.hover],(e.showLoader||i.clicked)&&"hello-btn-loader"]),disabled:i.props.disabled||i.clicked,style:l.normalizeStyle(e.style)},[l.createElementVNode("span",{innerHTML:e.label},null,8,re)],14,ne)}const E=S(te,[["render",ie],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/BaseButton.vue"]]),oe=l.defineComponent({__name:"ContinueButton",setup(t,{expose:r}){r();const e={BaseButton:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function ae(t,r,e,i,o,n){return l.openBlock(),l.createBlock(i.BaseButton)}const le=S(oe,[["render",ae],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/ContinueButton.vue"]]),se=l.defineComponent({__name:"LoginButton",setup(t,{expose:r}){r();const e={BaseButton:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function ue(t,r,e,i,o,n){return l.openBlock(),l.createBlock(i.BaseButton,{label:"ō   Login with Hellō"})}const ce=S(se,[["render",ue],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/LoginButton.vue"]]),fe=l.defineComponent({__name:"UpdateProfileButton",setup(t,{expose:r}){r();const e={BaseButton:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function de(t,r,e,i,o,n){return l.openBlock(),l.createBlock(i.BaseButton,{label:"ō   Update Profile with Hellō",update:!0})}const he=S(fe,[["render",de],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/UpdateProfileButton.vue"]]);var T=new WeakMap,z=0;function ge(t){if(!t.length)return"";for(var r="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):T.has(t[e])?i=T.get(t[e]):(i=z,T.set(t[e],z++)),r+="@"+i}return r}function ve(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=ge(t):t=String(t||""),t}var V=function(){function t(r){r===void 0&&(r=0),this.items=new Map,this.ttl=r}return t.prototype.serializeKey=function(r){return ve(r)},t.prototype.get=function(r){var e=this.serializeKey(r);return this.items.get(e)},t.prototype.set=function(r,e,i){var o=this.serializeKey(r),n=i||this.ttl,s=Date.now(),f={data:e,createdAt:s,expiresAt:n?s+n:1/0};this.dispatchExpire(n,f,o),this.items.set(o,f)},t.prototype.dispatchExpire=function(r,e,i){var o=this;r&&setTimeout(function(){var n=Date.now(),s=n>=e.expiresAt;s&&o.delete(i)},r)},t.prototype.delete=function(r){this.items.delete(r)},t}();function pe(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function _e(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ye=function(t){return fetch(t).then(function(r){return r.json()})};const $={isOnline:pe,isDocumentVisible:_e,fetcher:ye};var b=globalThis&&globalThis.__assign||function(){return b=Object.assign||function(t){for(var r,e=1,i=arguments.length;e<i;e++){r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},b.apply(this,arguments)},k=globalThis&&globalThis.__awaiter||function(t,r,e,i){function o(n){return n instanceof e?n:new e(function(s){s(n)})}return new(e||(e=Promise))(function(n,s){function f(u){try{a(i.next(u))}catch(_){s(_)}}function d(u){try{a(i.throw(u))}catch(_){s(_)}}function a(u){u.done?n(u.value):o(u.value).then(f,d)}a((i=i.apply(t,r||[])).next())})},L=globalThis&&globalThis.__generator||function(t,r){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,o,n,s;return s={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function f(a){return function(u){return d([a,u])}}function d(a){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(n=a[0]&2?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[a[0]&2,n.value]),a[0]){case 0:case 1:n=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,o=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(n=e.trys,!(n=n.length>0&&n[n.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]<n[3])){e.label=a[1];break}if(a[0]===6&&e.label<n[1]){e.label=n[1],n=a;break}if(n&&e.label<n[2]){e.label=n[2],e.ops.push(a);break}n[2]&&e.ops.pop(),e.trys.pop();continue}a=r.call(t,e)}catch(u){a=[6,u],o=0}finally{i=n=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},be=globalThis&&globalThis.__read||function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,n=[],s;try{for(;(r===void 0||r-- >0)&&!(o=i.next()).done;)n.push(o.value)}catch(f){s={error:f}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(s)throw s.error}}return n},me=globalThis&&globalThis.__spreadArray||function(t,r,e){if(e||arguments.length===2)for(var i=0,o=r.length,n;i<o;i++)(n||!(i in r))&&(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return t.concat(n||Array.prototype.slice.call(r))},G=new V,O=new V,j=new V,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:$.fetcher,isOnline:$.isOnline,isDocumentVisible:$.isDocumentVisible};function we(t,r,e){var i=O.get(t);if(i)i.data.push(r);else{var o=5e3;O.set(t,[r],e>0?e+o:e)}}function Ce(t,r,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&r>e.errorRetryCount)){var i=Math.min(r||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,r,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),k(void 0,void 0,void 0,function(){var o,n,s,f,d,a,u;return L(this,function(_){switch(_.label){case 0:if(!ke(r))return[3,5];_.label=1;case 1:return _.trys.push([1,3,,4]),[4,r];case 2:return o=_.sent(),[3,4];case 3:return f=_.sent(),n=f,[3,4];case 4:return[3,6];case 5:o=r,_.label=6;case 6:if(s=!1,d={data:o,error:n,isValidating:s},typeof o<"u")try{e.set(t,d,i)}catch(p){console.error("swrv(mutate): failed to set cache",p)}return a=O.get(t),a&&a.data.length&&(u=a.data.filter(function(p){return p.key===t}),u.forEach(function(p,h){typeof d.data<"u"&&(p.data=d.data),p.error=d.error,p.isValidating=d.isValidating;var w=h===u.length-1;w||delete u[h]}),u=u.filter(Boolean)),[2,d]}})})};function Se(){for(var t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var i,o,n=b({},K),s=!1,f=!1,d=l.getCurrentInstance(),a=(d==null?void 0:d.proxy)||d;if(!a)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var u=(a==null?void 0:a.$isServer)||!1;r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]),r.length>2&&(n=b(b({},n),r[2]));var _=u?n.serverTTL:n.ttl,p=typeof i=="function"?i:l.ref(i);typeof o>"u"&&(o=n.fetcher);var h=null;h||(h=l.reactive({data:void 0,error:void 0,isValidating:!0,key:null}));var w=function(v,c){return k(t,void 0,void 0,function(){var Y,y,R,A,D,J,U,Q=this;return L(this,function(q){switch(q.label){case 0:return Y=h.data===void 0,y=p.value,y?(R=n.cache.get(y),A=R&&R.data,h.isValidating=!0,A&&(h.data=A.data,h.error=A.error),D=v||o,!D||!n.isDocumentVisible()&&!Y||(c==null?void 0:c.forceRevalidate)!==void 0&&!(c!=null&&c.forceRevalidate)?(h.isValidating=!1,[2]):R&&(J=!!(Date.now()-R.createdAt>=n.dedupingInterval||c!=null&&c.forceRevalidate),!J)?(h.isValidating=!1,[2]):(U=function(){return k(Q,void 0,void 0,function(){var C,X,M,Z;return L(this,function(H){switch(H.label){case 0:return C=j.get(y),C?[3,2]:(X=Array.isArray(y)?y:[y],M=D.apply(void 0,me([],be(X),!1)),j.set(y,M,n.dedupingInterval),[4,W(y,M,n.cache,_)]);case 1:return H.sent(),[3,4];case 2:return[4,W(y,C.data,n.cache,_)];case 3:H.sent(),H.label=4;case 4:return h.isValidating=!1,j.delete(y),h.error!==void 0&&(Z=!s&&n.shouldRetryOnError&&(c?c.shouldRetryOnError:!0),Z&&Ce(w,c?c.errorRetryCount:1,n)),[2]}})})},A&&n.revalidateDebounce?(setTimeout(function(){return k(Q,void 0,void 0,function(){return L(this,function(C){switch(C.label){case 0:return s?[3,2]:[4,U()];case 1:C.sent(),C.label=2;case 2:return[2]}})})},n.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,U()];case 2:q.sent(),q.label=3;case 3:return[2]}})})},P=function(){return k(t,void 0,void 0,function(){return L(this,function(v){return[2,w(null,{shouldRetryOnError:!1})]})})},B=null;l.onMounted(function(){var v=function(){return k(t,void 0,void 0,function(){return L(this,function(c){switch(c.label){case 0:return!h.error&&n.isOnline()?[4,w()]:[3,2];case 1:return c.sent(),[3,3];case 2:B&&clearTimeout(B),c.label=3;case 3:return n.refreshInterval&&!s&&(B=setTimeout(v,n.refreshInterval)),[2]}})})};n.refreshInterval&&(B=setTimeout(v,n.refreshInterval)),n.revalidateOnFocus&&(document.addEventListener("visibilitychange",P,!1),window.addEventListener("focus",P,!1))}),l.onUnmounted(function(){s=!0,B&&clearTimeout(B),n.revalidateOnFocus&&(document.removeEventListener("visibilitychange",P,!1),window.removeEventListener("focus",P,!1));var v=O.get(p.value);v&&(v.data=v.data.filter(function(c){return c!==h}))});try{l.watch(p,function(v){l.isReadonly(p)||(p.value=v),h.key=v,h.isValidating=!!v,we(p.value,h,_),!u&&!f&&p.value&&w(),f=!1},{immediate:!0})}catch{}var $e=b(b({},l.toRefs(h)),{mutate:function(v,c){return w(v,b(b({},c),{forceRevalidate:!0}))}});return $e}function ke(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const Le=async t=>{try{return await(await fetch(t)).json()}catch(r){console.error(r);return}},x=()=>{const t=N(),{data:r=t,isValidating:e}=Se(m.auth,Le);return{auth:r||{},isLoading:e,isLoggedIn:r==null?void 0:r.isLoggedIn}},Be=l.defineComponent({__name:"LoggedIn",setup(t,{expose:r}){r();const i={isLoggedIn:()=>{var o;return((o=x())==null?void 0:o.isLoggedIn)||!1}};return Object.defineProperty(i,"__isScriptSetup",{enumerable:!1,value:!0}),i}}),Re={key:0};function Ae(t,r,e,i,o,n){return i.isLoggedIn()?(l.openBlock(),l.createElementBlock("div",Re,[l.renderSlot(t.$slots,"default")])):l.createCommentVNode("v-if",!0)}const Ie=S(Be,[["render",Ae],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedIn.vue"]]),Oe=l.defineComponent({__name:"LoggedOut",setup(t,{expose:r}){r();const i={isLoggedIn:()=>{var o;return((o=x())==null?void 0:o.isLoggedIn)||!1}};return Object.defineProperty(i,"__isScriptSetup",{enumerable:!1,value:!0}),i}}),Pe={key:0};function He(t,r,e,i,o,n){return i.isLoggedIn()?l.createCommentVNode("v-if",!0):(l.openBlock(),l.createElementBlock("div",Pe,[l.renderSlot(t.$slots,"default")]))}const Ee=S(Oe,[["render",He],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedOut.vue"]]),Te=()=>m.logout;function Ve(){window.location.href=m.logout}g.ContinueButton=le,g.HelloProvider=ee,g.LoggedIn=Ie,g.LoggedOut=Ee,g.LoginButton=ce,g.UpdateProfileButton=he,g.getLogOutRoute=Te,g.logOut=Ve,g.routeConfig=m,g.useAuth=x,g.useHelloProviderContext=N,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellocoop/vue",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Svelte SDK for Hellō https://hello.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,5 +51,5 @@
51
51
  "typescript": "^5.2.2",
52
52
  "vite-plugin-dts": "^3.6.3"
53
53
  },
54
- "gitHead": "b418b4e249a7fe7025d467688e52132848b465a2"
54
+ "gitHead": "2890e885168a5a0333b7ef610536fb8ad15703a5"
55
55
  }