@valiantys/atlassian-app-frontend 1.0.0 → 2.0.0

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/index.mjs CHANGED
@@ -1,75 +1,76 @@
1
1
  import { jsx as n, jsxs as y } from "react/jsx-runtime";
2
- import { ButtonGroup as D } from "@atlaskit/button";
3
- import _ from "@atlaskit/button/new";
4
- import N, { FormHeader as J, FormSection as z, Field as V, FormFooter as G } from "@atlaskit/form";
5
- import { Flex as v, xcss as C, Box as R } from "@atlaskit/primitives";
6
- import B from "@atlaskit/section-message";
7
- import K from "@atlaskit/select";
8
- import { createContext as f, useContext as m, useState as p, useCallback as S, useEffect as g, lazy as X, useReducer as ke, useRef as U } from "react";
9
- import Y from "@atlaskit/heading";
10
- import xe from "@atlaskit/spinner";
11
- import { BrowserRouter as Ae, Routes as ye, Route as O, Navigate as Re } from "react-router-dom";
12
- import Ce, { FlagGroup as Se, AutoDismissFlag as Ee } from "@atlaskit/flag";
13
- import be from "@atlaskit/icon/glyph/check-circle";
14
- import Pe from "@atlaskit/icon/glyph/error";
15
- import Ie from "@atlaskit/icon/glyph/info";
16
- import Ue from "@atlaskit/icon/glyph/warning";
17
- import { token as E } from "@atlaskit/tokens";
18
- const T = class T {
2
+ import { ButtonGroup as Z } from "@atlaskit/button";
3
+ import L, { IconButton as Be } from "@atlaskit/button/new";
4
+ import ee, { FormHeader as te, FormSection as re, Field as ne, FormFooter as oe } from "@atlaskit/form";
5
+ import { Flex as x, xcss as I, Box as S } from "@atlaskit/primitives";
6
+ import j from "@atlaskit/section-message";
7
+ import se from "@atlaskit/select";
8
+ import { createContext as v, useContext as g, useState as f, useCallback as w, useEffect as A, useReducer as Fe, useRef as F, lazy as D } from "react";
9
+ import H from "@atlaskit/heading";
10
+ import Te from "@atlaskit/spinner";
11
+ import qe from "@atlaskit/app-provider";
12
+ import { BrowserRouter as Le, Routes as je, Route as T, Navigate as De } from "react-router-dom";
13
+ import He, { FlagGroup as Me, AutoDismissFlag as _e } from "@atlaskit/flag";
14
+ import Je from "@atlaskit/icon/glyph/check-circle";
15
+ import ze from "@atlaskit/icon/glyph/error";
16
+ import Ne from "@atlaskit/icon/glyph/info";
17
+ import Ge from "@atlaskit/icon/glyph/warning";
18
+ import { token as P } from "@atlaskit/tokens";
19
+ const z = class z {
19
20
  };
20
- T.getOauthToken = "get-token";
21
- let q = T;
22
- class Oe {
21
+ z.getOauthToken = "get-token";
22
+ let G = z;
23
+ class Ve {
23
24
  constructor(t) {
24
25
  this.message = t;
25
26
  }
26
27
  }
27
- function W(e, t) {
28
+ function M(e, t) {
28
29
  const r = {
29
30
  Authorization: e.startsWith("Bearer ") ? e : `Bearer ${e}`
30
31
  };
31
32
  return t ? { ...t, ...r } : r;
32
33
  }
33
- async function $e(e, t, r) {
34
- const i = W(
34
+ async function Ke(e, t, r) {
35
+ const c = M(
35
36
  e,
36
37
  r.headers || {}
37
38
  );
38
- return fetch(t, { ...r, headers: i });
39
+ return fetch(t, { ...r, headers: c });
39
40
  }
40
- async function P(e, t, r, i, o = "json", s = {}) {
41
- return Q(
41
+ async function $(e, t, r, c, o = "json", s = {}) {
42
+ return ce(
42
43
  t,
43
44
  r,
44
- W(e, s),
45
- i,
45
+ M(e, s),
46
+ c,
46
47
  o
47
48
  );
48
49
  }
49
- async function Q(e, t, r, i, o = "json") {
50
+ async function ce(e, t, r, c, o = "json") {
50
51
  const s = {
51
52
  ...r || {},
52
53
  Accept: o === "json" ? "application/json" : "text/html",
53
54
  "Content-Type": o === "json" ? "application/json" : "text/html"
54
- }, a = i ? JSON.stringify(i) : void 0, c = await fetch(e, {
55
+ }, i = c ? JSON.stringify(c) : void 0, a = await fetch(e, {
55
56
  method: t,
56
57
  headers: s,
57
- body: a
58
+ body: i
58
59
  });
59
- if (c.ok)
60
- return t === "DELETE" ? void 0 : o === "text" ? await c.text() : await c.json();
60
+ if (a.ok)
61
+ return t === "DELETE" || a.status === 204 ? void 0 : o === "text" ? await a.text() : await a.json();
61
62
  {
62
- let u = "";
63
+ let l = "";
63
64
  try {
64
- u = await c.text();
65
+ l = await a.text();
65
66
  } catch {
66
67
  }
67
- const d = `${c.status} ${c.statusText} - ${t} ${e}
68
- ${u}`;
69
- throw console.error(d), new Oe(d);
68
+ const h = `${a.status} ${a.statusText} - ${t} ${e}
69
+ ${l}`;
70
+ throw console.error(h), new Ve(h);
70
71
  }
71
72
  }
72
- class Z {
73
+ class ie {
73
74
  constructor(t) {
74
75
  this.value_ = t;
75
76
  }
@@ -80,96 +81,96 @@ class Z {
80
81
  return this.value_;
81
82
  }
82
83
  }
83
- function L(e) {
84
- return e instanceof Z;
84
+ function V(e) {
85
+ return e instanceof ie;
85
86
  }
86
- const Be = ["..", ".%2e", "%2e.", "%2e%2e", ".%2E", "%2E.", "%2E%2e"], We = ["/", "\\"], ee = ["?", "#"];
87
- function b(e, t) {
87
+ const Xe = ["..", ".%2e", "%2e.", "%2e%2e", ".%2E", "%2E.", "%2E%2e"], Ye = ["/", "\\"], ae = ["?", "#"];
88
+ function U(e, t) {
88
89
  return e.some((r) => t.includes(r));
89
90
  }
90
- function Fe(e, t) {
91
+ function Qe(e, t) {
91
92
  switch (t) {
92
93
  case "path":
93
- if (L(e))
94
+ if (V(e))
94
95
  return e.value;
95
- if (e = String(e), b(Be, e) || b(ee, e) || b(We, e))
96
+ if (e = String(e), U(Xe, e) || U(ae, e) || U(Ye, e))
96
97
  throw new Error(
97
98
  "Disallowing path manipulation attempt. For more information see: https://go.atlassian.com/product-fetch-api-route"
98
99
  );
99
100
  return e;
100
101
  case "query":
101
- return L(e) ? encodeURIComponent(e.value) : e instanceof URLSearchParams ? e.toString() : encodeURIComponent(e);
102
+ return V(e) ? encodeURIComponent(e.value) : e instanceof URLSearchParams ? e.toString() : encodeURIComponent(e);
102
103
  }
103
104
  }
104
- function Te(e, ...t) {
105
- let r = "path", i = "";
105
+ function Ze(e, ...t) {
106
+ let r = "path", c = "";
106
107
  for (let o = 0; o < e.length; o++) {
107
108
  const s = e[o];
108
- if (b(ee, s) && (r = "query"), i += s, o >= t.length)
109
+ if (U(ae, s) && (r = "query"), c += s, o >= t.length)
109
110
  break;
110
- i += Fe(t[o], r);
111
+ c += Qe(t[o], r);
111
112
  }
112
- return new Z(i);
113
+ return new ie(c);
113
114
  }
114
- function $(e, t) {
115
+ function q(e, t) {
115
116
  if (t) {
116
117
  const r = e.startsWith("/") ? e.slice(1) : e;
117
118
  return `${t}/${r}`;
118
119
  } else
119
120
  return e;
120
121
  }
121
- function F(e, t, r) {
122
+ function _(e, t, r) {
122
123
  return {
123
124
  productType: r,
124
- fetch: ({ url: i, method: o, responseType: s = "json", allowExperimental: a = !1 }, c) => P(
125
+ fetch: ({ url: c, method: o, responseType: s = "json", allowExperimental: i = !1 }, u) => $(
125
126
  e,
126
- $(i.value, t),
127
+ q(c.value, t),
127
128
  o,
128
- c,
129
+ u,
129
130
  s,
130
131
  {
131
- "X-ExperimentalApi": a ? "opt-in" : ""
132
+ "X-ExperimentalApi": i ? "opt-in" : ""
132
133
  }
133
134
  ),
134
- route: Te,
135
- rawFetch: (i, o) => $e(
135
+ route: Ze,
136
+ rawFetch: (c, o) => Ke(
136
137
  e,
137
- $(i.value, t),
138
+ q(c.value, t),
138
139
  o
139
140
  ),
140
- fullUrl: (i) => $(i, t)
141
+ fullUrl: (c) => q(c, t)
141
142
  };
142
143
  }
143
- function Ct(e, t) {
144
- return F(
144
+ function et(e, t) {
145
+ return _(
145
146
  e,
146
147
  `https://api.atlassian.com/ex/jira/${t}`,
147
148
  "jira"
148
149
  );
149
150
  }
150
- function St(e, t) {
151
- return F(
151
+ function tt(e, t) {
152
+ return _(
152
153
  e,
153
154
  `https://api.atlassian.com/ex/confluence/${t}`,
154
155
  "confluence"
155
156
  );
156
157
  }
157
- function Et(e) {
158
- return F(
158
+ function rt(e) {
159
+ return _(
159
160
  e,
160
161
  "https://api.bitbucket.org",
161
162
  "bitbucket"
162
163
  );
163
164
  }
164
- async function bt(e) {
165
- return P(
165
+ async function Qt(e) {
166
+ return $(
166
167
  e,
167
168
  "https://api.atlassian.com/me",
168
169
  "GET"
169
170
  );
170
171
  }
171
- async function Pt(e, t, r, i, o) {
172
- return Q(
172
+ async function Zt(e, t, r, c, o) {
173
+ return ce(
173
174
  "https://auth.atlassian.com/oauth/token",
174
175
  "POST",
175
176
  void 0,
@@ -177,22 +178,22 @@ async function Pt(e, t, r, i, o) {
177
178
  grant_type: e,
178
179
  client_id: t,
179
180
  client_secret: r,
180
- code: i,
181
+ code: c,
181
182
  redirect_uri: o
182
183
  }
183
184
  );
184
185
  }
185
- class te extends Error {
186
+ class ue extends Error {
186
187
  constructor(t) {
187
188
  super(t);
188
189
  }
189
190
  }
190
- class It {
191
+ class nt {
191
192
  constructor() {
192
193
  this.userResourcesUrl = "https://api.atlassian.com/oauth/token/accessible-resources";
193
194
  }
194
195
  async getAtlassianUserResources(t) {
195
- return await P(
196
+ return await $(
196
197
  t,
197
198
  this.userResourcesUrl,
198
199
  "GET"
@@ -200,7 +201,7 @@ class It {
200
201
  }
201
202
  async checkUserChosenResource(t, r) {
202
203
  const o = (await this.getAtlassianUserResources(t)).filter(
203
- (s, a, c) => c.findIndex((u) => u.id === s.id) === a
204
+ (s, i, u) => u.findIndex((a) => a.id === s.id) === i
204
205
  ).map((s) => ({
205
206
  name: s.name,
206
207
  id: s.id
@@ -208,7 +209,7 @@ class It {
208
209
  if (o.length > 1) {
209
210
  if (r) {
210
211
  const s = o.find(
211
- (a) => a.id === r
212
+ (i) => i.id === r
212
213
  );
213
214
  if (s)
214
215
  return { hasChosen: !0, resource: s };
@@ -220,29 +221,29 @@ class It {
220
221
  } else {
221
222
  if (o.length === 1)
222
223
  return { hasChosen: !0, resource: o[0] };
223
- throw new te(
224
+ throw new ue(
224
225
  "Provided token does not have permissions for any resources"
225
226
  );
226
227
  }
227
228
  }
228
229
  }
229
- class qe {
230
+ class ot {
230
231
  constructor(t) {
231
232
  this.fetchSvc = t, this.workspaceApiUrl = "/rest/servicedeskapi/assets/workspace";
232
233
  }
233
234
  async getAllUserWorkspaces() {
234
235
  const t = [];
235
236
  let r = !0;
236
- const i = 50;
237
+ const c = 50;
237
238
  let o = 0;
238
239
  for (; r; ) {
239
240
  const s = await this.fetchSvc.fetch(
240
241
  {
241
- url: this.fetchSvc.route`/rest/servicedeskapi/assets/workspace?start=${o}&limit=${i}`,
242
+ url: this.fetchSvc.route`/rest/servicedeskapi/assets/workspace?start=${o}&limit=${c}`,
242
243
  method: "GET"
243
244
  }
244
245
  );
245
- t.push(...s.values), o += i, s.isLastPage && (r = !1);
246
+ t.push(...s.values), o += c, s.isLastPage && (r = !1);
246
247
  }
247
248
  return t;
248
249
  }
@@ -250,13 +251,13 @@ class qe {
250
251
  const r = await this.getAllUserWorkspaces();
251
252
  if (r.length > 1) {
252
253
  if (t) {
253
- const i = r.find(
254
+ const c = r.find(
254
255
  (o) => o.workspaceId === t
255
256
  );
256
- if (i)
257
+ if (c)
257
258
  return {
258
259
  hasChosen: !0,
259
- workspace: i.workspaceId
260
+ workspace: c.workspaceId
260
261
  };
261
262
  }
262
263
  return {
@@ -266,150 +267,150 @@ class qe {
266
267
  } else {
267
268
  if (r.length === 1)
268
269
  return { hasChosen: !0, workspace: r[0].workspaceId };
269
- throw new te(
270
+ throw new ue(
270
271
  "Provided token does not have permissions for any workspaces"
271
272
  );
272
273
  }
273
274
  }
274
275
  }
275
- const re = f(null), Ut = () => {
276
- const e = m(re);
276
+ const le = v(null), er = () => {
277
+ const e = g(le);
277
278
  if (!e)
278
279
  throw new Error(
279
280
  "useRequestBitbucket must be used within a RequestBitbucketProvider"
280
281
  );
281
282
  return e;
282
283
  };
283
- function Le({
284
+ function de({
284
285
  children: e,
285
286
  requestBitbucketImplementation: t
286
287
  }) {
287
- return /* @__PURE__ */ n(re.Provider, { value: t, children: e });
288
+ return /* @__PURE__ */ n(le.Provider, { value: t, children: e });
288
289
  }
289
- const oe = f(null), Ot = () => {
290
- const e = m(oe);
290
+ const he = v(null), tr = () => {
291
+ const e = g(he);
291
292
  if (!e)
292
293
  throw new Error(
293
294
  "useRequestConfluence must be used within a RequestConfluenceProvider"
294
295
  );
295
296
  return e;
296
297
  };
297
- function je({
298
+ function pe({
298
299
  children: e,
299
300
  requestConfluenceImplementation: t
300
301
  }) {
301
- return /* @__PURE__ */ n(oe.Provider, { value: t, children: e });
302
+ return /* @__PURE__ */ n(he.Provider, { value: t, children: e });
302
303
  }
303
- const ne = f(null), Me = () => {
304
- const e = m(ne);
304
+ const fe = v(null), st = () => {
305
+ const e = g(fe);
305
306
  if (!e)
306
307
  throw new Error("useRequestJira must be used within a RequestJiraProvider");
307
308
  return e;
308
309
  };
309
- function He({
310
+ function me({
310
311
  children: e,
311
312
  requestJiraImplementation: t
312
313
  }) {
313
- return /* @__PURE__ */ n(ne.Provider, { value: t, children: e });
314
+ return /* @__PURE__ */ n(fe.Provider, { value: t, children: e });
314
315
  }
315
- function I({
316
+ function O({
316
317
  label: e,
317
318
  loadingError: t,
318
319
  labelSize: r
319
320
  }) {
320
- return /* @__PURE__ */ y(v, { direction: "column", children: [
321
- /* @__PURE__ */ n(Y, { size: r || "large", children: e }),
322
- t ? /* @__PURE__ */ n(B, { appearance: "error", children: t }) : /* @__PURE__ */ n(xe, { interactionName: "load" })
321
+ return /* @__PURE__ */ y(x, { direction: "column", children: [
322
+ /* @__PURE__ */ n(H, { size: r || "large", children: e }),
323
+ t ? /* @__PURE__ */ n(j, { appearance: "error", children: t }) : /* @__PURE__ */ n(Te, { interactionName: "load" })
323
324
  ] });
324
325
  }
325
- const se = f(void 0), $t = () => m(se);
326
- function ie({
326
+ const we = v(void 0), rr = () => g(we);
327
+ function ve({
327
328
  children: e,
328
329
  workspaceId: t
329
330
  }) {
330
- return /* @__PURE__ */ n(se.Provider, { value: t, children: e });
331
+ return /* @__PURE__ */ n(we.Provider, { value: t, children: e });
331
332
  }
332
- const j = C({
333
+ const K = I({
333
334
  maxWidth: "max-content",
334
335
  paddingBlockStart: "space.1000"
335
336
  });
336
- function Bt({
337
+ function ct({
337
338
  appName: e,
338
339
  children: t
339
340
  }) {
340
- const [r, i] = p(!1), [o, s] = p(
341
+ const [r, c] = f(!1), [o, s] = f(
341
342
  null
342
- ), [a, c] = p(""), [u, d] = p(), h = Me(), l = S(
343
- async (k) => {
343
+ ), [i, u] = f(""), [a, l] = f(), h = st(), d = w(
344
+ async (p) => {
344
345
  try {
345
- c("");
346
- const w = k ?? (e && localStorage.getItem(`${e}-user-workspace-id`)) ?? "", A = await new qe(
346
+ u("");
347
+ const k = p ?? (e && localStorage.getItem(`${e}-user-workspace-id`)) ?? "", R = await new ot(
347
348
  h
348
- ).checkUserChosenWorkspace(w);
349
- A.hasChosen ? (e && localStorage.setItem(
349
+ ).checkUserChosenWorkspace(k);
350
+ R.hasChosen ? (e && localStorage.setItem(
350
351
  `${e}-user-workspace-id`,
351
- A.workspace
352
- ), i(!0), d(A.workspace)) : s(A.workspaces);
353
- } catch (w) {
354
- w instanceof Error ? c(`Error Occurred: ${w.message}`) : c("Uncaught error occurred!");
352
+ R.workspace
353
+ ), c(!0), l(R.workspace)) : s(R.workspaces);
354
+ } catch (k) {
355
+ k instanceof Error ? u(`Error Occurred: ${k.message}`) : u("Uncaught error occurred!");
355
356
  }
356
357
  },
357
358
  [e, h]
358
359
  );
359
- g(() => {
360
- l();
361
- }, [l]);
362
- async function x({
363
- selectedWorkspace: k
360
+ A(() => {
361
+ d();
362
+ }, [d]);
363
+ async function C({
364
+ selectedWorkspace: p
364
365
  }) {
365
- return l(k.value);
366
+ return d(p.value);
366
367
  }
367
368
  if (r)
368
- return /* @__PURE__ */ n(ie, { workspaceId: u, children: t });
369
+ return /* @__PURE__ */ n(ve, { workspaceId: a, children: t });
369
370
  if (o) {
370
- const k = o.map((w) => ({
371
- label: w.workspaceId,
372
- value: w.workspaceId
371
+ const p = o.map((k) => ({
372
+ label: k.workspaceId,
373
+ value: k.workspaceId
373
374
  }));
374
- return /* @__PURE__ */ n(v, { justifyContent: "center", children: /* @__PURE__ */ n(R, { xcss: j, children: /* @__PURE__ */ n(N, { onSubmit: x, children: ({ formProps: w, submitting: A }) => /* @__PURE__ */ y("form", { ...w, children: [
375
- /* @__PURE__ */ n(J, { title: "Choose Workspace", children: a ? /* @__PURE__ */ n(B, { appearance: "error", children: a }) : null }),
376
- /* @__PURE__ */ n(z, { children: /* @__PURE__ */ n(
377
- V,
375
+ return /* @__PURE__ */ n(x, { justifyContent: "center", children: /* @__PURE__ */ n(S, { xcss: K, children: /* @__PURE__ */ n(ee, { onSubmit: C, children: ({ formProps: k, submitting: R }) => /* @__PURE__ */ y("form", { ...k, children: [
376
+ /* @__PURE__ */ n(te, { title: "Choose Workspace", children: i ? /* @__PURE__ */ n(j, { appearance: "error", children: i }) : null }),
377
+ /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(
378
+ ne,
378
379
  {
379
380
  "aria-required": !0,
380
381
  name: "selectedWorkspace",
381
382
  label: "Workspace",
382
383
  isRequired: !0,
383
- children: ({ fieldProps: ge }) => /* @__PURE__ */ n("div", { "data-testid": "workspace-select-component", children: /* @__PURE__ */ n(K, { ...ge, options: k }) })
384
+ children: ({ fieldProps: W }) => /* @__PURE__ */ n("div", { "data-testid": "workspace-select-component", children: /* @__PURE__ */ n(se, { ...W, options: p }) })
384
385
  }
385
386
  ) }),
386
- /* @__PURE__ */ n(G, { align: "start", children: /* @__PURE__ */ n(D, { label: "Form submit options", children: /* @__PURE__ */ n(
387
- _,
387
+ /* @__PURE__ */ n(oe, { align: "start", children: /* @__PURE__ */ n(Z, { label: "Form submit options", children: /* @__PURE__ */ n(
388
+ L,
388
389
  {
389
390
  type: "submit",
390
391
  appearance: "primary",
391
- isLoading: A,
392
+ isLoading: R,
392
393
  children: "Submit"
393
394
  }
394
395
  ) }) })
395
396
  ] }) }) }) });
396
397
  } else
397
- return /* @__PURE__ */ n(v, { justifyContent: "center", xcss: j, children: /* @__PURE__ */ n(I, { label: "", loadingError: a }) });
398
+ return /* @__PURE__ */ n(x, { justifyContent: "center", xcss: K, children: /* @__PURE__ */ n(O, { label: "", loadingError: i }) });
398
399
  }
399
- const ce = f(null), Wt = () => {
400
- const e = m(ce);
400
+ const ge = v(null), nr = () => {
401
+ const e = g(ge);
401
402
  if (!e)
402
403
  throw new Error(
403
404
  "useBackendAdapter must be used within a BackendAdapterProvider"
404
405
  );
405
406
  return e;
406
407
  };
407
- function De({
408
+ function ke({
408
409
  children: e,
409
410
  invokeImplementation: t
410
411
  }) {
411
412
  return /* @__PURE__ */ n(
412
- ce.Provider,
413
+ ge.Provider,
413
414
  {
414
415
  value: {
415
416
  invoke: t
@@ -418,10 +419,10 @@ function De({
418
419
  }
419
420
  );
420
421
  }
421
- function Ft(e, t, r) {
422
- return async (i, o) => P(
422
+ function it(e, t, r) {
423
+ return async (c, o) => $(
423
424
  t,
424
- e + i,
425
+ e + c,
425
426
  "POST",
426
427
  { ...o },
427
428
  "json",
@@ -430,7 +431,7 @@ function Ft(e, t, r) {
430
431
  }
431
432
  );
432
433
  }
433
- class Tt {
434
+ class at {
434
435
  navigate(t) {
435
436
  return window.location.href = t, Promise.resolve();
436
437
  }
@@ -441,32 +442,56 @@ class Tt {
441
442
  return window.location.reload(), Promise.resolve();
442
443
  }
443
444
  }
444
- const ae = f(null), qt = () => {
445
- const e = m(ae);
445
+ const Ae = v(null), ut = () => {
446
+ const e = g(Ae);
446
447
  if (!e)
447
448
  throw new Error("useHostRouter must be used within a HostRouterProvider");
448
449
  return e;
449
450
  };
450
- function _e({
451
+ function xe({
451
452
  children: e,
452
453
  hostRouter: t
453
454
  }) {
454
- return /* @__PURE__ */ n(ae.Provider, { value: t, children: e });
455
+ return /* @__PURE__ */ n(Ae.Provider, { value: t, children: e });
456
+ }
457
+ function or({
458
+ url: e,
459
+ action: t,
460
+ label: r,
461
+ linkStyle: c,
462
+ buttonIcon: o,
463
+ buttonAppearance: s
464
+ }) {
465
+ const i = ut(), u = w(
466
+ (a) => {
467
+ a.preventDefault(), t === "open" ? i.open(e) : i.navigate(e);
468
+ },
469
+ [t, i, e]
470
+ );
471
+ return c === "link" ? /* @__PURE__ */ n("a", { href: e, target: "_blank", rel: "noreferrer", onClick: u, children: r }) : o ? /* @__PURE__ */ n(
472
+ Be,
473
+ {
474
+ icon: o,
475
+ label: r,
476
+ appearance: s || "subtle",
477
+ onClick: u
478
+ }
479
+ ) : /* @__PURE__ */ n(L, { appearance: s || "subtle", onClick: u, children: r });
455
480
  }
456
- const ue = f(null), Lt = () => {
457
- const e = m(ue);
481
+ const Re = v(null), sr = () => {
482
+ const e = g(Re);
458
483
  if (!e)
459
484
  throw new Error(
460
485
  "useRemoteAdapter must be used within a RemoteAdapterProvider"
461
486
  );
462
487
  return e;
463
488
  };
464
- function Ne({
489
+ function ye({
465
490
  children: e,
466
491
  invokeRemoteImplementation: t
467
492
  }) {
468
493
  return /* @__PURE__ */ n(
469
- ue.Provider,
494
+ Re.Provider,
470
495
  {
471
496
  value: {
472
497
  invokeRemote: t
@@ -475,15 +500,15 @@ function Ne({
475
500
  }
476
501
  );
477
502
  }
478
- function jt(e, t) {
503
+ function lt(e, t) {
479
504
  return async (r) => {
480
- const i = `${e}${r.path}`, o = await fetch(i, {
505
+ const c = `${e}${r.path}`, o = await fetch(c, {
481
506
  method: r.method,
482
- headers: t ? W(t, r.headers || {}) : r.headers,
507
+ headers: t ? M(t, r.headers || {}) : r.headers,
483
508
  body: r.body ? JSON.stringify(r.body) : void 0
484
509
  }), s = {};
485
- return o.headers.forEach((c, u) => {
486
- s[u] = c;
510
+ return o.headers.forEach((u, a) => {
511
+ s[a] = u;
487
512
  }), {
488
513
  body: await o.json(),
489
514
  headers: s,
@@ -491,19 +516,19 @@ function jt(e, t) {
491
516
  };
492
517
  };
493
518
  }
494
- const le = f(null), Je = () => {
495
- const e = m(le);
519
+ const Se = v(null), dt = () => {
520
+ const e = g(Se);
496
521
  if (!e)
497
522
  throw new Error("useViewContext must be used within a ViewContextProvider");
498
523
  return e;
499
524
  };
500
- function ze({
525
+ function Ce({
501
526
  children: e,
502
527
  viewContext: t
503
528
  }) {
504
- return /* @__PURE__ */ n(le.Provider, { value: t, children: e });
529
+ return /* @__PURE__ */ n(Se.Provider, { value: t, children: e });
505
530
  }
506
- class de {
531
+ class J {
507
532
  constructor(t) {
508
533
  this.context = t, this.theme = {
509
534
  enable() {
@@ -527,32 +552,32 @@ class de {
527
552
  return Promise.resolve();
528
553
  }
529
554
  }
530
- function Mt({
555
+ function cr({
531
556
  mockContext: e,
532
557
  invoke: t,
533
558
  invokeRemote: r,
534
- jiraFetchService: i,
559
+ jiraFetchService: c,
535
560
  confluenceFetchService: o,
536
561
  bitbucketFetchService: s,
537
- hostRouter: a,
538
- children: c
562
+ hostRouter: i,
563
+ children: u
539
564
  }) {
540
- let u = /* @__PURE__ */ n(ie, { workspaceId: "test-workspace", children: /* @__PURE__ */ n(De, { invokeImplementation: t, children: /* @__PURE__ */ n(Ne, { invokeRemoteImplementation: r, children: /* @__PURE__ */ n(_e, { hostRouter: a, children: /* @__PURE__ */ n(ze, { viewContext: new de(e), children: c }) }) }) }) });
541
- return i && (u = /* @__PURE__ */ n(He, { requestJiraImplementation: i, children: u })), o && (u = /* @__PURE__ */ n(
542
- je,
565
+ let a = /* @__PURE__ */ n(ve, { workspaceId: "test-workspace", children: /* @__PURE__ */ n(ke, { invokeImplementation: t, children: /* @__PURE__ */ n(ye, { invokeRemoteImplementation: r, children: /* @__PURE__ */ n(xe, { hostRouter: i, children: /* @__PURE__ */ n(Ce, { viewContext: new J(e), children: u }) }) }) }) });
566
+ return c && (a = /* @__PURE__ */ n(me, { requestJiraImplementation: c, children: a })), o && (a = /* @__PURE__ */ n(
567
+ pe,
543
568
  {
544
569
  requestConfluenceImplementation: o,
545
- children: u
570
+ children: a
546
571
  }
547
- )), s && (u = /* @__PURE__ */ n(
548
- Le,
572
+ )), s && (a = /* @__PURE__ */ n(
573
+ de,
549
574
  {
550
575
  requestBitbucketImplementation: s,
551
- children: u
576
+ children: a
552
577
  }
553
- )), u;
578
+ )), a;
554
579
  }
555
- function Ht(e) {
580
+ function ir(e) {
556
581
  return {
557
582
  mockContext: {
558
583
  accountId: "testAccount",
@@ -576,11 +601,11 @@ function Ht(e) {
576
601
  }
577
602
  };
578
603
  }
579
- function Ve(e) {
604
+ function ht(e) {
580
605
  const r = new URLSearchParams(window.location.search).get("code");
581
- return g(() => {
606
+ return A(() => {
582
607
  r && (async () => {
583
- const i = await fetch(e.codeTokenExchangeUrl, {
608
+ const c = await fetch(e.codeTokenExchangeUrl, {
584
609
  method: "POST",
585
610
  headers: {
586
611
  Accept: "application/json",
@@ -591,205 +616,99 @@ function Ve(e) {
591
616
  redirect_uri: e.redirectUri
592
617
  })
593
618
  });
594
- if (i.ok) {
595
- const o = await i.json(), s = Date.now() + o.expires_in * 1e3;
619
+ if (c.ok) {
620
+ const o = await c.json(), s = Date.now() + o.expires_in * 1e3;
596
621
  e.setAuth({ token: o.access_token, expiresAt: s });
597
622
  }
598
623
  })();
599
- }), /* @__PURE__ */ n(I, { label: "Fetching auth token with provided code" });
624
+ }), /* @__PURE__ */ n(O, { label: "Fetching auth token with provided code" });
600
625
  }
601
- function he(e, t, r) {
602
- const i = new URLSearchParams({
626
+ function Ie(e, t, r) {
627
+ const c = new URLSearchParams({
603
628
  audience: "api.atlassian.com",
604
629
  client_id: e,
605
630
  scope: r.join(" "),
606
631
  redirect_uri: t,
607
- state: Ge(),
632
+ state: pt(),
608
633
  // The backend should potentially generate and validate this piece?
609
634
  response_type: "code",
610
635
  prompt: "consent"
611
636
  }).toString();
612
- window.location.href = `https://auth.atlassian.com/authorize?${i}`;
637
+ window.location.href = `https://auth.atlassian.com/authorize?${c}`;
613
638
  }
614
- function Ge() {
639
+ function pt() {
615
640
  return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
616
641
  }
617
- function Ke(e) {
618
- return he(e.clientId, e.redirectUri, e.oAuthScopes), /* @__PURE__ */ n(I, { label: "Redirecting to Atlassian Authentication System" });
642
+ function ft(e) {
643
+ return Ie(e.clientId, e.redirectUri, e.oAuthScopes), /* @__PURE__ */ n(O, { label: "Redirecting to Atlassian Authentication System" });
619
644
  }
620
- const Xe = C({
645
+ const mt = I({
621
646
  paddingBlockStart: "space.1000"
622
- }), pe = f(null), Dt = () => {
623
- const e = m(pe);
647
+ }), Ee = v(null), wt = () => {
648
+ const e = g(Ee);
624
649
  return e || (console.warn("No OAuth provider"), { getAuthToken: () => "" });
625
650
  };
626
- function Ye({
651
+ function vt({
627
652
  children: e,
628
653
  ...t
629
654
  }) {
630
- const [r, i] = p(
655
+ const [r, c] = f(
631
656
  localStorage.getItem(`${t.appName}-auth-token`)
632
657
  ), o = localStorage.getItem(
633
658
  `${t.appName}-auth-expires-at`
634
- ), [s, a] = p(
659
+ ), [s, i] = f(
635
660
  o ? Number(o) : null
636
- ), c = window.location.protocol + "//" + window.location.hostname + (window.location.port ? `:${window.location.port}` : ""), u = c + "/callback";
637
- function d() {
638
- return s && r && !M(s) ? r : (he(t.clientId, u, t.oAuthScopes), "");
661
+ ), u = window.location.protocol + "//" + window.location.hostname + (window.location.port ? `:${window.location.port}` : ""), a = u + "/callback";
662
+ function l() {
663
+ return s && r && !X(s) ? r : (Ie(t.clientId, a, t.oAuthScopes), "");
639
664
  }
640
- function h(l) {
641
- i(l.token), localStorage.setItem(`${t.appName}-auth-token`, l.token), a(l.expiresAt), localStorage.setItem(
665
+ function h(d) {
666
+ c(d.token), localStorage.setItem(`${t.appName}-auth-token`, d.token), i(d.expiresAt), localStorage.setItem(
642
667
  `${t.appName}-auth-expires-at`,
643
- l.expiresAt.toString()
644
- ), localStorage.removeItem(`${t.appName}-user-resource-id`), localStorage.removeItem(`${t.appName}-user-workspace-id`), window.location.href = c;
668
+ d.expiresAt.toString()
669
+ ), localStorage.removeItem(`${t.appName}-user-resource-id`), localStorage.removeItem(`${t.appName}-user-workspace-id`), window.location.href = u;
645
670
  }
646
- return !r || !s || M(s) ? /* @__PURE__ */ n(v, { justifyContent: "center", xcss: Xe, children: /* @__PURE__ */ n(Ae, { children: /* @__PURE__ */ y(ye, { children: [
671
+ return !r || !s || X(s) ? /* @__PURE__ */ n(x, { justifyContent: "center", xcss: mt, children: /* @__PURE__ */ n(Le, { children: /* @__PURE__ */ y(je, { children: [
647
672
  /* @__PURE__ */ n(
648
- O,
673
+ T,
649
674
  {
650
675
  path: "/",
651
676
  element: /* @__PURE__ */ n(
652
- Ke,
677
+ ft,
653
678
  {
654
679
  clientId: t.clientId,
655
- redirectUri: u,
680
+ redirectUri: a,
656
681
  oAuthScopes: t.oAuthScopes
657
682
  }
658
683
  )
659
684
  }
660
685
  ),
661
686
  /* @__PURE__ */ n(
662
- O,
687
+ T,
663
688
  {
664
689
  path: "/callback",
665
690
  element: /* @__PURE__ */ n(
666
- Ve,
691
+ ht,
667
692
  {
668
693
  setAuth: h,
669
- redirectUri: u,
694
+ redirectUri: a,
670
695
  codeTokenExchangeUrl: t.codeTokenExchangeUrl
671
696
  }
672
697
  )
673
698
  }
674
699
  ),
675
- /* @__PURE__ */ n(O, { path: "/*", element: /* @__PURE__ */ n(Re, { to: "/", replace: !0 }) })
676
- ] }) }) }) : /* @__PURE__ */ n(pe.Provider, { value: { getAuthToken: d }, children: e });
700
+ /* @__PURE__ */ n(T, { path: "/*", element: /* @__PURE__ */ n(De, { to: "/", replace: !0 }) })
701
+ ] }) }) }) : /* @__PURE__ */ n(Ee.Provider, { value: { getAuthToken: l }, children: e });
677
702
  }
678
- function M(e) {
703
+ function X(e) {
679
704
  return e < Date.now();
680
705
  }
681
- const Qe = X(() => import("./atlassian-app-forge-DdtDadi2.mjs")), Ze = X(() => import("./atlassian-app-standalone-DyyH6WPO.mjs")), et = window.self === window.top;
682
- function _t({
683
- children: e,
684
- appName: t,
685
- doCheckWorkspace: r,
686
- embeddedConfig: i,
687
- standaloneConfig: o
688
- }) {
689
- var s;
690
- if (et)
691
- if (o) {
692
- const a = /* @__PURE__ */ n(
693
- Ze,
694
- {
695
- appName: t,
696
- backendUrl: o.backendUrl,
697
- remoteUrl: o.remoteUrl,
698
- initialMockViewContext: o.initialMockViewContext,
699
- modalOpenerConfig: o.modalOpenerConfig,
700
- modalContextConfig: o.modalContextConfig,
701
- doCheckWorkspace: o.oauthConfig && r,
702
- doCheckResource: ((s = o.oauthConfig) == null ? void 0 : s.doCheckResource) !== !1,
703
- children: e
704
- }
705
- );
706
- return o.oauthConfig ? /* @__PURE__ */ n(
707
- Ye,
708
- {
709
- clientId: o.oauthConfig.clientId,
710
- codeTokenExchangeUrl: o.oauthConfig.codeTokenExchangeUrl,
711
- appName: t,
712
- oAuthScopes: o.oauthConfig.oAuthScopes,
713
- children: a
714
- }
715
- ) : a;
716
- } else
717
- return /* @__PURE__ */ n("div", { children: "Not configured for standalone mode." });
718
- else
719
- return /* @__PURE__ */ n(
720
- Qe,
721
- {
722
- appName: t,
723
- doCheckWorkspace: r,
724
- invokeRemoteImpl: i == null ? void 0 : i.invokeRemoteImpl,
725
- children: e
726
- }
727
- );
728
- }
729
- const H = C({
730
- maxWidth: "max-content",
731
- paddingBlockStart: "space.1000"
732
- });
733
- function Nt({
734
- checkResource: e,
735
- children: t
736
- }) {
737
- const [r, i] = p(!1), [o, s] = p(null), [a, c] = p(""), u = S(
738
- async (h) => {
739
- try {
740
- c("");
741
- const l = await e(h);
742
- l.hasChosen ? i(!0) : s(l.resources);
743
- } catch (l) {
744
- l instanceof Error ? c(`Error Occurred: ${l.message}`) : c("Uncaught error occurred!");
745
- }
746
- },
747
- [e]
748
- );
749
- g(() => {
750
- u();
751
- }, [u]);
752
- function d({ selectedResource: h }) {
753
- return u(h.value);
754
- }
755
- if (r)
756
- return t;
757
- if (o) {
758
- const h = o.map((l) => ({
759
- label: l.name,
760
- value: l.id
761
- }));
762
- return /* @__PURE__ */ n(v, { justifyContent: "center", children: /* @__PURE__ */ n(R, { xcss: H, children: /* @__PURE__ */ n(N, { onSubmit: d, children: ({ formProps: l, submitting: x }) => /* @__PURE__ */ y("form", { ...l, children: [
763
- /* @__PURE__ */ n(J, { title: "Choose Resource", children: a ? /* @__PURE__ */ n(B, { appearance: "error", children: a }) : null }),
764
- /* @__PURE__ */ n(z, { children: /* @__PURE__ */ n(
765
- V,
766
- {
767
- "aria-required": !0,
768
- name: "selectedResource",
769
- label: "Resource",
770
- isRequired: !0,
771
- children: ({ fieldProps: k }) => /* @__PURE__ */ n(K, { ...k, options: h })
772
- }
773
- ) }),
774
- /* @__PURE__ */ n(G, { align: "start", children: /* @__PURE__ */ n(D, { label: "Form submit options", children: /* @__PURE__ */ n(
775
- _,
776
- {
777
- type: "submit",
778
- appearance: "primary",
779
- isLoading: x,
780
- children: "Submit"
781
- }
782
- ) }) })
783
- ] }) }) }) });
784
- } else
785
- return /* @__PURE__ */ n(v, { justifyContent: "center", xcss: H, children: /* @__PURE__ */ n(I, { label: "", loadingError: a }) });
786
- }
787
- const fe = f(void 0);
788
- function tt() {
789
- return m(fe);
706
+ const be = v(void 0);
707
+ function gt() {
708
+ return g(be);
790
709
  }
791
- function Jt() {
792
- const e = tt();
710
+ function ar() {
711
+ const e = gt();
793
712
  function t(o) {
794
713
  e({
795
714
  type: "add",
@@ -803,27 +722,27 @@ function Jt() {
803
722
  id: o
804
723
  });
805
724
  }
806
- function i(o, s, a, c) {
725
+ function c(o, s, i, u) {
807
726
  t({
808
727
  id: o,
809
728
  isAutoDismiss: !1,
810
729
  type: "error",
811
730
  title: s,
812
- description: a instanceof Error ? a.message : typeof a == "string" ? a : "Uncaught error occurred!",
813
- actions: c
731
+ description: i instanceof Error ? i.message : typeof i == "string" ? i : "Uncaught error occurred!",
732
+ actions: u
814
733
  });
815
734
  }
816
735
  return {
817
736
  addFlag: t,
818
737
  removeFlag: r,
819
- addErrorFlag: i
738
+ addErrorFlag: c
820
739
  };
821
740
  }
822
- function zt({
741
+ function kt({
823
742
  children: e
824
743
  }) {
825
- const [t, r] = ke(ot, []);
826
- function i(s) {
744
+ const [t, r] = Fe(xt, []);
745
+ function c(s) {
827
746
  r({
828
747
  type: "remove",
829
748
  id: s
@@ -833,46 +752,46 @@ function zt({
833
752
  switch (s) {
834
753
  case "info":
835
754
  return /* @__PURE__ */ n(
836
- Ie,
755
+ Ne,
837
756
  {
838
757
  label: "Info",
839
- primaryColor: E("color.icon.information"),
758
+ primaryColor: P("color.icon.information"),
840
759
  size: "large"
841
760
  }
842
761
  );
843
762
  case "warning":
844
763
  return /* @__PURE__ */ n(
845
- Ue,
764
+ Ge,
846
765
  {
847
766
  label: "Warning",
848
- primaryColor: E("color.icon.warning"),
767
+ primaryColor: P("color.icon.warning"),
849
768
  size: "large"
850
769
  }
851
770
  );
852
771
  case "error":
853
772
  return /* @__PURE__ */ n(
854
- Pe,
773
+ ze,
855
774
  {
856
775
  label: "Error",
857
- primaryColor: E("color.icon.danger"),
776
+ primaryColor: P("color.icon.danger"),
858
777
  size: "large"
859
778
  }
860
779
  );
861
780
  case "success":
862
781
  return /* @__PURE__ */ n(
863
- be,
782
+ Je,
864
783
  {
865
- primaryColor: E("color.icon.success"),
784
+ primaryColor: P("color.icon.success"),
866
785
  label: "Success",
867
786
  size: "large"
868
787
  }
869
788
  );
870
789
  }
871
790
  }
872
- return /* @__PURE__ */ y(fe.Provider, { value: r, children: [
791
+ return /* @__PURE__ */ y(be.Provider, { value: r, children: [
873
792
  e,
874
- /* @__PURE__ */ n(Se, { onDismissed: i, children: t.map((s) => s.isAutoDismiss ? /* @__PURE__ */ n(
875
- Ee,
793
+ /* @__PURE__ */ n(Me, { onDismissed: c, children: t.map((s) => s.isAutoDismiss ? /* @__PURE__ */ n(
794
+ _e,
876
795
  {
877
796
  id: s.id,
878
797
  icon: o(s.type || "success"),
@@ -880,30 +799,30 @@ function zt({
880
799
  },
881
800
  s.id
882
801
  ) : /* @__PURE__ */ n(
883
- Ce,
802
+ He,
884
803
  {
885
804
  appearance: s.appearance || "normal",
886
805
  icon: o(s.type || "success"),
887
806
  id: s.id,
888
807
  title: s.title,
889
808
  description: s.description,
890
- actions: rt(s.actions)
809
+ actions: At(s.actions)
891
810
  },
892
811
  s.id
893
812
  )) })
894
813
  ] });
895
814
  }
896
- function rt(e) {
815
+ function At(e) {
897
816
  return e == null ? void 0 : e.map((t) => ({
898
817
  ...t,
899
818
  content: t.text
900
819
  }));
901
820
  }
902
- function ot(e, t) {
821
+ function xt(e, t) {
903
822
  switch (t.type) {
904
823
  case "add":
905
824
  if (t.props) {
906
- const r = e.filter((i) => i.id !== t.id);
825
+ const r = e.filter((c) => c.id !== t.id);
907
826
  return r.push(t.props), r;
908
827
  } else
909
828
  return console.error("invalid flag action: ", JSON.stringify(t)), e;
@@ -913,84 +832,123 @@ function ot(e, t) {
913
832
  throw Error("Unknown action: " + t.type);
914
833
  }
915
834
  }
916
- function me(e, t, r) {
917
- g(() => (window.addEventListener(e, t, r), () => {
835
+ function Pe(e, t, r) {
836
+ A(() => (window.addEventListener(e, t, r), () => {
918
837
  window.removeEventListener(e, t, r);
919
838
  }), [e, t, r]);
920
839
  }
921
- const we = f({
840
+ const Ue = v({
922
841
  close: () => {
923
842
  }
924
843
  });
925
- function nt() {
926
- return m(we);
844
+ function Rt() {
845
+ return g(
846
+ Ue
847
+ );
927
848
  }
928
- function Vt({ children: e }) {
929
- const [t, r] = p(), i = Je(), o = S(() => {
930
- i.close();
931
- }, [i]);
932
- return me("unload", o), g(() => {
849
+ function ur({ children: e }) {
850
+ const [t, r] = f(), c = dt(), o = w(() => {
851
+ c.close();
852
+ }, [c]);
853
+ return Pe("unload", o), A(() => {
933
854
  (async () => {
934
- const s = await i.getContext();
855
+ const s = await c.getContext();
935
856
  r(s.extension.modal);
936
857
  })();
937
- }, [i]), /* @__PURE__ */ n(
938
- we.Provider,
858
+ }, [c]), /* @__PURE__ */ n(
859
+ Ue.Provider,
939
860
  {
940
- value: { modalContextData: t, close: i.close },
861
+ value: { modalContextData: t, close: c.close },
941
862
  children: e
942
863
  }
943
864
  );
944
865
  }
945
- const st = {
946
- "modal-content-iframe-wrapper": "_modal-content-iframe-wrapper_9wuab_1"
866
+ const yt = {
867
+ "iframe-wrapper": "_iframe-wrapper_c8hdk_1"
947
868
  };
948
- function Gt({
949
- messageCallback: e,
950
- closeOnMouseOut: t
869
+ function St({
870
+ iframeProps: e,
871
+ messageCallback: t,
872
+ onMouseOut: r
951
873
  }) {
952
- const [r, i] = p(), o = U(!1), s = U(!1), a = U(null), { modalContextData: c, close: u } = nt(), d = S(
953
- (h) => {
954
- var l;
955
- if (h.source === ((l = a.current) == null ? void 0 : l.contentWindow) && e) {
956
- const x = e(h.data, c);
957
- x.newHeight && i(x.newHeight);
958
- }
874
+ const [c, o] = f(), s = F(!1), i = F(!1), u = F(null), a = w(
875
+ (l) => {
876
+ var h;
877
+ l.source === ((h = u.current) == null ? void 0 : h.contentWindow) && t && t(l.data);
959
878
  },
960
- [e, c]
879
+ [t]
961
880
  );
962
- return me("message", d), g(() => {
963
- (async () => c != null && c.height && i(c.height))();
964
- }, [c]), g(() => {
881
+ return Pe("message", a), A(() => {
882
+ (async () => e != null && e.height && o(e.height))();
883
+ }, [e]), A(() => {
965
884
  (async () => {
966
- var h;
967
- !s.current && ((h = a.current) != null && h.contentWindow) && (a.current.contentWindow.focus(), s.current = !0);
885
+ var l;
886
+ !i.current && ((l = u.current) != null && l.contentWindow) && (u.current.contentWindow.focus(), i.current = !0);
968
887
  })();
969
- }), /* @__PURE__ */ n("div", { className: st["modal-content-iframe-wrapper"], children: /* @__PURE__ */ n(
888
+ }), /* @__PURE__ */ n("div", { className: yt["iframe-wrapper"], children: /* @__PURE__ */ n(
970
889
  "iframe",
971
890
  {
972
- title: c == null ? void 0 : c.title,
973
- ref: a,
974
- width: c == null ? void 0 : c.width,
975
- height: r,
976
- src: c == null ? void 0 : c.link,
977
- onMouseEnter: () => o.current = !0,
891
+ title: e == null ? void 0 : e.title,
892
+ ref: u,
893
+ width: e == null ? void 0 : e.width,
894
+ height: c,
895
+ src: e == null ? void 0 : e.link,
896
+ onMouseEnter: () => s.current = !0,
978
897
  onMouseOut: () => {
979
- o.current && t && (u == null || u());
898
+ s.current && r && r();
980
899
  }
981
900
  }
982
901
  ) });
983
902
  }
984
- class Kt {
903
+ function lr({
904
+ messageCallback: e,
905
+ closeOnMouseOut: t
906
+ }) {
907
+ const { modalContextData: r, close: c } = Rt(), [o, s] = f();
908
+ A(() => {
909
+ r && s({
910
+ ...r.iframeProps
911
+ });
912
+ }, [r]);
913
+ const i = w(
914
+ (a) => {
915
+ if (e && o) {
916
+ const l = e(
917
+ a.data,
918
+ r == null ? void 0 : r.iframeProps
919
+ );
920
+ l.newHeight && s({ ...o, height: l.newHeight });
921
+ }
922
+ },
923
+ [o, e, r]
924
+ );
925
+ if (!o)
926
+ return /* @__PURE__ */ n("div", {});
927
+ const u = /* @__PURE__ */ n(
928
+ St,
929
+ {
930
+ messageCallback: i,
931
+ iframeProps: o,
932
+ onMouseOut: () => {
933
+ t && (c == null || c());
934
+ }
935
+ }
936
+ );
937
+ return r != null && r.modalHeader ? /* @__PURE__ */ y(x, { gap: "space.200", direction: "column", children: [
938
+ /* @__PURE__ */ n(S, { paddingInline: "space.200", children: /* @__PURE__ */ n(H, { size: "medium", children: r.modalHeader }) }),
939
+ u
940
+ ] }) : u;
941
+ }
942
+ class Ct {
985
943
  constructor(t, r = {}) {
986
944
  this.defaultUrl = t, this.resourceMap = r;
987
945
  }
988
946
  open(t) {
989
- const r = t.resource && this.resourceMap[t.resource] || this.defaultUrl, i = this.features(t.size || "small"), o = window.open(r, "_blank", i), s = (a) => {
990
- var c, u;
991
- if (a.source === o && (c = a.data) != null && c.closing) {
992
- const d = a.data;
993
- window.removeEventListener("message", s), (u = t.onClose) == null || u.call(t, d.payload);
947
+ const r = t.resource && this.resourceMap[t.resource] || this.defaultUrl, c = this.features(t.size || "small"), o = window.open(r, "_blank", c), s = (i) => {
948
+ var u, a;
949
+ if (i.source === o && (u = i.data) != null && u.closing) {
950
+ const l = i.data;
951
+ window.removeEventListener("message", s), (a = t.onClose) == null || a.call(t, l.payload);
994
952
  }
995
953
  };
996
954
  return window.addEventListener("message", s), Promise.resolve();
@@ -1016,130 +974,330 @@ class Kt {
1016
974
  }
1017
975
  }
1018
976
  }
1019
- const ve = f(null), Xt = () => {
1020
- const e = m(ve);
977
+ const $e = v(null), dr = () => {
978
+ const e = g($e);
1021
979
  if (!e)
1022
980
  throw new Error(
1023
981
  "useModalService must be used within a ModalServiceProvider"
1024
982
  );
1025
983
  return e;
1026
984
  };
1027
- function Yt({
985
+ function It({
1028
986
  children: e,
1029
987
  modalService: t
1030
988
  }) {
1031
- return /* @__PURE__ */ n(ve.Provider, { value: t, children: e });
989
+ return /* @__PURE__ */ n($e.Provider, { value: t, children: e });
1032
990
  }
1033
- class Qt extends de {
991
+ class Et extends J {
1034
992
  constructor(t, r = "http://localhost:4200") {
1035
- super(t), this.context = t, this.openerOrigin = r, this.close = (i) => {
993
+ super(t), this.context = t, this.openerOrigin = r, this.close = (c) => {
1036
994
  var s;
1037
- const o = { closing: !0, payload: i };
995
+ const o = { closing: !0, payload: c };
1038
996
  return (s = window.opener) == null || s.postMessage(o, this.openerOrigin), window.close(), Promise.resolve();
1039
997
  };
1040
998
  }
1041
999
  }
1042
- function Zt({
1000
+ function hr({
1043
1001
  title: e,
1044
1002
  buttonGroup: t,
1045
1003
  children: r
1046
1004
  }) {
1047
1005
  return /* @__PURE__ */ y(
1048
- v,
1006
+ x,
1049
1007
  {
1050
1008
  direction: "column",
1051
- xcss: C({ height: "100%", padding: "space.300" }),
1009
+ xcss: I({ height: "100%", padding: "space.300" }),
1052
1010
  children: [
1053
- /* @__PURE__ */ n(R, { children: /* @__PURE__ */ n(Y, { size: "medium", children: e }) }),
1054
- /* @__PURE__ */ n(R, { paddingBlockStart: "space.200", xcss: C({ flexGrow: 2 }), children: r }),
1055
- /* @__PURE__ */ n(R, { paddingBlockStart: "space.200", children: /* @__PURE__ */ n(v, { justifyContent: "end", alignItems: "center", children: t }) })
1011
+ e && /* @__PURE__ */ n(S, { paddingBlockEnd: "space.200", children: /* @__PURE__ */ n(H, { size: "medium", children: e }) }),
1012
+ /* @__PURE__ */ n(S, { xcss: I({ flexGrow: 2 }), children: r }),
1013
+ t && /* @__PURE__ */ n(S, { paddingBlockStart: "space.200", children: /* @__PURE__ */ n(x, { justifyContent: "end", alignItems: "center", children: t }) })
1056
1014
  ]
1057
1015
  }
1058
1016
  );
1059
1017
  }
1060
- function it(e) {
1018
+ const bt = D(
1019
+ () => import("./index-ZJX0bAUh.mjs")
1020
+ );
1021
+ function Y({
1022
+ initialMockViewContext: e,
1023
+ backendUrl: t,
1024
+ remoteUrl: r,
1025
+ doCheckWorkspace: c,
1026
+ appName: o,
1027
+ doCheckResource: s,
1028
+ modalOpenerConfig: i,
1029
+ modalContextConfig: u,
1030
+ children: a
1031
+ }) {
1032
+ const [l, h] = f(), [d, C] = f(), { getAuthToken: p } = wt(), k = w(() => et(p(), l ?? ""), [p, l]), R = w(() => tt(p(), l ?? ""), [p, l]), W = w(() => rt(p()), [p]), Oe = w(
1033
+ async (E) => {
1034
+ if (t && s) {
1035
+ const B = E ?? localStorage.getItem(`${o}-user-resource-id`) ?? "", b = await new nt().checkUserChosenResource(
1036
+ p(),
1037
+ B
1038
+ );
1039
+ return b.hasChosen && (localStorage.setItem(
1040
+ `${o}-user-resource-id`,
1041
+ b.resource.id
1042
+ ), h(b.resource.id)), b;
1043
+ } else
1044
+ return { hasChosen: !0 };
1045
+ },
1046
+ [t, p, o, s]
1047
+ );
1048
+ A(() => {
1049
+ const E = l ?? (e == null ? void 0 : e.cloudId) ?? "";
1050
+ if (!d || d.cloudId !== E) {
1051
+ const B = {
1052
+ ...d || e,
1053
+ cloudId: E
1054
+ };
1055
+ C(B);
1056
+ }
1057
+ }, [e, l, d]);
1058
+ const We = w(
1059
+ () => t ? it(t, p(), l ?? "") : void 0,
1060
+ [l, p, t]
1061
+ );
1062
+ let m = a;
1063
+ c && (m = /* @__PURE__ */ n(ct, { appName: o, children: m })), i && (m = /* @__PURE__ */ n(
1064
+ It,
1065
+ {
1066
+ modalService: new Ct(
1067
+ i.defaultUrl,
1068
+ i.resourceMap
1069
+ ),
1070
+ children: m
1071
+ }
1072
+ )), d && (m = /* @__PURE__ */ n(
1073
+ Ce,
1074
+ {
1075
+ viewContext: u ? new Et(d, u.openerOrigin) : new J(d),
1076
+ children: m
1077
+ }
1078
+ )), m = /* @__PURE__ */ n(xe, { hostRouter: new at(), children: /* @__PURE__ */ n(
1079
+ de,
1080
+ {
1081
+ requestBitbucketImplementation: W(),
1082
+ children: /* @__PURE__ */ n(
1083
+ pe,
1084
+ {
1085
+ requestConfluenceImplementation: R(),
1086
+ children: /* @__PURE__ */ n(
1087
+ me,
1088
+ {
1089
+ requestJiraImplementation: k(),
1090
+ children: m
1091
+ }
1092
+ )
1093
+ }
1094
+ )
1095
+ }
1096
+ ) });
1097
+ const N = We();
1098
+ return N && (m = /* @__PURE__ */ n(ke, { invokeImplementation: N, children: m })), r && (m = /* @__PURE__ */ n(
1099
+ ye,
1100
+ {
1101
+ invokeRemoteImplementation: lt(r),
1102
+ children: m
1103
+ }
1104
+ )), s && (m = /* @__PURE__ */ n(bt, { checkResource: Oe, children: m })), /* @__PURE__ */ n(qe, { children: /* @__PURE__ */ n(kt, { children: m }) });
1105
+ }
1106
+ const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1107
+ __proto__: null,
1108
+ AtlassianAppStandalone: Y,
1109
+ default: Y
1110
+ }, Symbol.toStringTag, { value: "Module" })), Ut = D(() => import("./atlassian-app-forge-DG01gNAI.mjs")), $t = D(() => Promise.resolve().then(() => Pt)), Ot = window.self === window.top;
1111
+ function pr({
1112
+ children: e,
1113
+ appName: t,
1114
+ doCheckWorkspace: r,
1115
+ embeddedConfig: c,
1116
+ standaloneConfig: o
1117
+ }) {
1118
+ var s;
1119
+ if (Ot)
1120
+ if (o) {
1121
+ const i = /* @__PURE__ */ n(
1122
+ $t,
1123
+ {
1124
+ appName: t,
1125
+ backendUrl: o.backendUrl,
1126
+ remoteUrl: o.remoteUrl,
1127
+ initialMockViewContext: o.initialMockViewContext,
1128
+ modalOpenerConfig: o.modalOpenerConfig,
1129
+ modalContextConfig: o.modalContextConfig,
1130
+ doCheckWorkspace: o.oauthConfig && r,
1131
+ doCheckResource: ((s = o.oauthConfig) == null ? void 0 : s.doCheckResource) !== !1,
1132
+ children: e
1133
+ }
1134
+ );
1135
+ return o.oauthConfig ? /* @__PURE__ */ n(
1136
+ vt,
1137
+ {
1138
+ clientId: o.oauthConfig.clientId,
1139
+ codeTokenExchangeUrl: o.oauthConfig.codeTokenExchangeUrl,
1140
+ appName: t,
1141
+ oAuthScopes: o.oauthConfig.oAuthScopes,
1142
+ children: i
1143
+ }
1144
+ ) : i;
1145
+ } else
1146
+ return /* @__PURE__ */ n("div", { children: "Not configured for standalone mode." });
1147
+ else
1148
+ return /* @__PURE__ */ n(
1149
+ Ut,
1150
+ {
1151
+ appName: t,
1152
+ doCheckWorkspace: r,
1153
+ invokeRemoteImpl: c == null ? void 0 : c.invokeRemoteImpl,
1154
+ children: e
1155
+ }
1156
+ );
1157
+ }
1158
+ const Q = I({
1159
+ maxWidth: "max-content",
1160
+ paddingBlockStart: "space.1000"
1161
+ });
1162
+ function fr({
1163
+ checkResource: e,
1164
+ children: t
1165
+ }) {
1166
+ const [r, c] = f(!1), [o, s] = f(null), [i, u] = f(""), a = w(
1167
+ async (h) => {
1168
+ try {
1169
+ u("");
1170
+ const d = await e(h);
1171
+ d.hasChosen ? c(!0) : s(d.resources);
1172
+ } catch (d) {
1173
+ d instanceof Error ? u(`Error Occurred: ${d.message}`) : u("Uncaught error occurred!");
1174
+ }
1175
+ },
1176
+ [e]
1177
+ );
1178
+ A(() => {
1179
+ a();
1180
+ }, [a]);
1181
+ function l({ selectedResource: h }) {
1182
+ return a(h.value);
1183
+ }
1184
+ if (r)
1185
+ return t;
1186
+ if (o) {
1187
+ const h = o.map((d) => ({
1188
+ label: d.name,
1189
+ value: d.id
1190
+ }));
1191
+ return /* @__PURE__ */ n(x, { justifyContent: "center", children: /* @__PURE__ */ n(S, { xcss: Q, children: /* @__PURE__ */ n(ee, { onSubmit: l, children: ({ formProps: d, submitting: C }) => /* @__PURE__ */ y("form", { ...d, children: [
1192
+ /* @__PURE__ */ n(te, { title: "Choose Resource", children: i ? /* @__PURE__ */ n(j, { appearance: "error", children: i }) : null }),
1193
+ /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(
1194
+ ne,
1195
+ {
1196
+ "aria-required": !0,
1197
+ name: "selectedResource",
1198
+ label: "Resource",
1199
+ isRequired: !0,
1200
+ children: ({ fieldProps: p }) => /* @__PURE__ */ n(se, { ...p, options: h })
1201
+ }
1202
+ ) }),
1203
+ /* @__PURE__ */ n(oe, { align: "start", children: /* @__PURE__ */ n(Z, { label: "Form submit options", children: /* @__PURE__ */ n(
1204
+ L,
1205
+ {
1206
+ type: "submit",
1207
+ appearance: "primary",
1208
+ isLoading: C,
1209
+ children: "Submit"
1210
+ }
1211
+ ) }) })
1212
+ ] }) }) }) });
1213
+ } else
1214
+ return /* @__PURE__ */ n(x, { justifyContent: "center", xcss: Q, children: /* @__PURE__ */ n(O, { label: "", loadingError: i }) });
1215
+ }
1216
+ function Wt(e) {
1061
1217
  return console.error(e), `Error Occurred: ${e.message || e}`;
1062
1218
  }
1063
- function er(e, t = it) {
1064
- const [r, i] = p(), [o, s] = p(!0), [a, c] = p(), u = S(async () => {
1219
+ function mr(e, t = Wt) {
1220
+ const [r, c] = f(), [o, s] = f(!0), [i, u] = f(), a = w(async () => {
1065
1221
  s(!0);
1066
1222
  try {
1067
- const d = await e();
1068
- return i(d), d;
1069
- } catch (d) {
1070
- c(t(d));
1223
+ const l = await e();
1224
+ return c(l), l;
1225
+ } catch (l) {
1226
+ u(t(l));
1071
1227
  } finally {
1072
1228
  s(!1);
1073
1229
  }
1074
1230
  }, [e, t]);
1075
- return g(() => {
1076
- u();
1077
- }, [u]), {
1231
+ return A(() => {
1232
+ a();
1233
+ }, [a]), {
1078
1234
  data: r,
1079
1235
  loading: o,
1080
- error: a,
1081
- setData: i,
1236
+ error: i,
1237
+ setData: c,
1082
1238
  setLoading: s,
1083
- setError: c,
1084
- manualTrigger: () => u()
1239
+ setError: u,
1240
+ manualTrigger: () => a()
1085
1241
  };
1086
1242
  }
1087
1243
  export {
1088
- fe as AppFlagsDispatchContext,
1089
- zt as AppFlagsProviderAtlasKit,
1090
- _t as AtlassianApp,
1091
- Mt as AtlassianAppTest,
1092
- It as AtlassianUserResourceService,
1093
- qe as AtlassianUserWorkspaceService,
1094
- De as BackendAdapterProvider,
1095
- q as CommonResolverPaths,
1096
- Nt as FeatureChosenResourceCheck,
1097
- Bt as FeatureChosenWorkspaceCheck,
1098
- Oe as FetchError,
1099
- _e as HostRouterProvider,
1100
- et as IS_STANDALONE,
1101
- ie as JiraWorkspaceProvider,
1102
- de as MockViewContext,
1103
- Vt as ModalContent,
1104
- Gt as ModalContentIframe,
1105
- Zt as ModalDialogLayout,
1106
- Yt as ModalServiceProvider,
1107
- Qt as ModalViewContext,
1108
- Ye as OAuthProvider,
1109
- I as PageLoadingView,
1110
- Ne as RemoteAdapterProvider,
1111
- Le as RequestBitbucketProvider,
1112
- je as RequestConfluenceProvider,
1113
- He as RequestJiraProvider,
1114
- ze as ViewContextProvider,
1115
- Tt as WindowHostRouter,
1116
- Kt as WindowModalService,
1117
- W as addAuthHeader,
1118
- Et as atlassianOAuthBitbucketFetch,
1119
- St as atlassianOAuthConfluenceFetch,
1120
- Ct as atlassianOAuthJiraFetch,
1121
- F as atlassianOAuthRawFetch,
1122
- P as bearerAuthFetch,
1123
- $e as bearerAuthFetchRaw,
1124
- Ht as defaultProps,
1125
- Pt as getAtlassianOAuthToken,
1126
- bt as getAtlassianUserDetails,
1127
- Ft as getOauthFetchInvokeImpl,
1128
- Q as jsonFetch,
1129
- jt as oauthFetchInvokeRemote,
1130
- Te as route,
1131
- tt as useAppFlagsDispatch,
1132
- Jt as useAppFlagsDispatchMethods,
1133
- Wt as useBackendAdapter,
1134
- qt as useHostRouter,
1135
- er as useLoadDataEffect,
1136
- nt as useModalContentService,
1137
- Xt as useModalService,
1138
- Dt as useOAuth,
1139
- Lt as useRemoteAdapter,
1140
- Ut as useRequestBitbucket,
1141
- Ot as useRequestConfluence,
1142
- Me as useRequestJira,
1143
- Je as useViewContext,
1144
- $t as useWorkspaceId
1244
+ be as AppFlagsDispatchContext,
1245
+ kt as AppFlagsProviderAtlasKit,
1246
+ pr as AtlassianApp,
1247
+ Y as AtlassianAppStandalone,
1248
+ cr as AtlassianAppTest,
1249
+ nt as AtlassianUserResourceService,
1250
+ ot as AtlassianUserWorkspaceService,
1251
+ ke as BackendAdapterProvider,
1252
+ G as CommonResolverPaths,
1253
+ fr as FeatureChosenResourceCheck,
1254
+ ct as FeatureChosenWorkspaceCheck,
1255
+ Ve as FetchError,
1256
+ or as HostRouterLink,
1257
+ xe as HostRouterProvider,
1258
+ Ot as IS_STANDALONE,
1259
+ ve as JiraWorkspaceProvider,
1260
+ J as MockViewContext,
1261
+ ur as ModalContent,
1262
+ lr as ModalContentIframe,
1263
+ hr as ModalDialogLayout,
1264
+ It as ModalServiceProvider,
1265
+ Et as ModalViewContext,
1266
+ vt as OAuthProvider,
1267
+ O as PageLoadingView,
1268
+ ye as RemoteAdapterProvider,
1269
+ de as RequestBitbucketProvider,
1270
+ pe as RequestConfluenceProvider,
1271
+ me as RequestJiraProvider,
1272
+ Ce as ViewContextProvider,
1273
+ at as WindowHostRouter,
1274
+ Ct as WindowModalService,
1275
+ M as addAuthHeader,
1276
+ rt as atlassianOAuthBitbucketFetch,
1277
+ tt as atlassianOAuthConfluenceFetch,
1278
+ et as atlassianOAuthJiraFetch,
1279
+ _ as atlassianOAuthRawFetch,
1280
+ $ as bearerAuthFetch,
1281
+ Ke as bearerAuthFetchRaw,
1282
+ ir as defaultProps,
1283
+ Zt as getAtlassianOAuthToken,
1284
+ Qt as getAtlassianUserDetails,
1285
+ it as getOauthFetchInvokeImpl,
1286
+ ce as jsonFetch,
1287
+ lt as oauthFetchInvokeRemote,
1288
+ Ze as route,
1289
+ gt as useAppFlagsDispatch,
1290
+ ar as useAppFlagsDispatchMethods,
1291
+ nr as useBackendAdapter,
1292
+ ut as useHostRouter,
1293
+ mr as useLoadDataEffect,
1294
+ Rt as useModalContentService,
1295
+ dr as useModalService,
1296
+ wt as useOAuth,
1297
+ sr as useRemoteAdapter,
1298
+ er as useRequestBitbucket,
1299
+ tr as useRequestConfluence,
1300
+ st as useRequestJira,
1301
+ dt as useViewContext,
1302
+ rr as useWorkspaceId
1145
1303
  };