sanity-plugin-dashboard-widget-vercel 3.1.6 → 4.0.1

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.
Files changed (42) hide show
  1. package/README.md +8 -36
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1380 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +42 -85
  7. package/lib/index.d.mts +0 -6
  8. package/lib/index.d.ts +0 -6
  9. package/lib/index.js +0 -1007
  10. package/lib/index.js.map +0 -1
  11. package/lib/index.mjs +0 -1005
  12. package/lib/index.mjs.map +0 -1
  13. package/sanity.json +0 -8
  14. package/src/app.tsx +0 -135
  15. package/src/client.ts +0 -7
  16. package/src/components/DeployButton/index.tsx +0 -86
  17. package/src/components/Deployment/index.tsx +0 -126
  18. package/src/components/DeploymentPlaceholder/index.tsx +0 -41
  19. package/src/components/DeploymentTarget/index.tsx +0 -51
  20. package/src/components/DeploymentTargets/index.tsx +0 -24
  21. package/src/components/Deployments/index.tsx +0 -187
  22. package/src/components/DialogForm/index.tsx +0 -220
  23. package/src/components/FormFieldInputLabel/index.tsx +0 -65
  24. package/src/components/FormFieldInputText/index.tsx +0 -43
  25. package/src/components/PlaceholderAvatar/index.tsx +0 -20
  26. package/src/components/PlaceholderText/index.tsx +0 -32
  27. package/src/components/StateDebug/index.tsx +0 -46
  28. package/src/components/StatusDot/index.tsx +0 -22
  29. package/src/components/TableCell/index.tsx +0 -81
  30. package/src/constants.ts +0 -26
  31. package/src/hooks/useDeployments.ts +0 -89
  32. package/src/index.ts +0 -16
  33. package/src/machines/deploy.ts +0 -117
  34. package/src/machines/deploymentTargetList.ts +0 -149
  35. package/src/machines/dialog.ts +0 -62
  36. package/src/machines/form.ts +0 -155
  37. package/src/machines/refresh.ts +0 -47
  38. package/src/types/index.ts +0 -49
  39. package/src/utils/fetcher.ts +0 -37
  40. package/src/utils/sanitizeFormData.ts +0 -26
  41. package/src/utils/useCardColor.ts +0 -5
  42. package/v2-incompatible.js +0 -11
package/dist/index.js ADDED
@@ -0,0 +1,1380 @@
1
+ import TimeAgo from "javascript-time-ago";
2
+ import en from "javascript-time-ago/locale/en";
3
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
4
+ import { c } from "react/compiler-runtime";
5
+ import { UploadIcon, LinkIcon, EditIcon, ErrorOutlineIcon, AddIcon } from "@sanity/icons";
6
+ import { useTheme_v2, useToast, Box, Button, Label, Text, Flex, Stack, Tooltip, Inline, TextInput, Dialog, ToastProvider, Card } from "@sanity/ui";
7
+ import { useQuery, QueryClient, QueryClientProvider } from "@tanstack/react-query";
8
+ import { useMachine, useActor } from "@xstate/react";
9
+ import { useClient } from "sanity";
10
+ import { useEffect, useRef, forwardRef } from "react";
11
+ import useDeepCompareEffect from "use-deep-compare-effect";
12
+ import hash from "object-hash";
13
+ import { setup, fromPromise, assign, assertEvent, toPromise } from "xstate";
14
+ import ReactTimeAgo from "react-time-ago";
15
+ import { yupResolver } from "@hookform/resolvers/yup";
16
+ import { useForm } from "react-hook-form";
17
+ import * as yup from "yup";
18
+ import { uuid } from "@sanity/uuid";
19
+ import { red } from "@sanity/color";
20
+ const API_ENDPOINT_DEPLOYMENTS = "https://api.vercel.com/v5/now/deployments", API_ENDPOINT_ALIASES = "https://api.vercel.com/v3/now/aliases", API_VERSION = "1", DEPLOYMENT_TARGET_DOCUMENT_TYPE = "vercel.deploymentTarget", VERCEL_STATUS_COLORS = {
21
+ BUILDING: "#f5a623",
22
+ CANCELED: "#ff0000",
23
+ ERROR: "#ff0000",
24
+ READY: "#50e3c2",
25
+ QUEUED: "#333"
26
+ }, WIDGET_NAME = "Vercel (dashboard)", Z_INDEX_DIALOG = 600001, Z_INDEX_TOAST_PROVIDER = 600002;
27
+ function useSanityClient() {
28
+ const $ = c(1);
29
+ let t0;
30
+ return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
31
+ apiVersion: API_VERSION
32
+ }, $[0] = t0) : t0 = $[0], useClient(t0);
33
+ }
34
+ const fetcher = (deploymentTarget) => async (url, extraParams) => {
35
+ const params = new URLSearchParams();
36
+ if (params.set("projectId", deploymentTarget.projectId), deploymentTarget.teamId && params.set("teamId", deploymentTarget.teamId), extraParams)
37
+ for (const [k, v] of extraParams.entries())
38
+ params.append(k, v);
39
+ const response = await fetch(`${url}?${params.toString()}`, {
40
+ headers: {
41
+ Authorization: `Bearer ${deploymentTarget.token}`
42
+ }
43
+ });
44
+ if (!response.ok)
45
+ throw new Error("Response not OK");
46
+ try {
47
+ return await response.json();
48
+ } catch (err) {
49
+ throw new Error("Unable to parse response as JSON", {
50
+ cause: err
51
+ });
52
+ }
53
+ }, useDeployments = (deploymentTarget, options) => {
54
+ const $ = c(35);
55
+ let t0;
56
+ $[0] !== deploymentTarget ? (t0 = fetcher(deploymentTarget), $[0] = deploymentTarget, $[1] = t0) : t0 = $[1];
57
+ const fetchUrl = t0;
58
+ let deployParams;
59
+ $[2] !== deploymentTarget?.deployLimit ? (deployParams = new URLSearchParams(), deployParams.set("limit", String(deploymentTarget?.deployLimit)), $[2] = deploymentTarget?.deployLimit, $[3] = deployParams) : deployParams = $[3];
60
+ let t1;
61
+ $[4] !== deploymentTarget ? (t1 = hash(deploymentTarget), $[4] = deploymentTarget, $[5] = t1) : t1 = $[5];
62
+ let t2;
63
+ $[6] !== t1 ? (t2 = [t1], $[6] = t1, $[7] = t2) : t2 = $[7];
64
+ let t3;
65
+ $[8] !== deployParams || $[9] !== fetchUrl ? (t3 = () => fetchUrl(API_ENDPOINT_DEPLOYMENTS, deployParams), $[8] = deployParams, $[9] = fetchUrl, $[10] = t3) : t3 = $[10];
66
+ const t4 = options?.enabled ?? !0;
67
+ let t5;
68
+ $[11] !== t2 || $[12] !== t3 || $[13] !== t4 ? (t5 = {
69
+ queryKey: t2,
70
+ queryFn: t3,
71
+ enabled: t4,
72
+ refetchInterval: 2e4,
73
+ refetchIntervalInBackground: !1,
74
+ refetchOnMount: !0,
75
+ refetchOnReconnect: "always",
76
+ refetchOnWindowFocus: !1,
77
+ retry: !1
78
+ }, $[11] = t2, $[12] = t3, $[13] = t4, $[14] = t5) : t5 = $[14];
79
+ const {
80
+ data: deploymentsData,
81
+ isFetching: deploymentsIsFetching,
82
+ isSuccess: deploymentsIsSuccess,
83
+ error: deploymentsError,
84
+ refetch
85
+ } = useQuery(t5);
86
+ let aliasParams;
87
+ $[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (aliasParams = new URLSearchParams(), aliasParams.set("limit", "20"), $[15] = aliasParams) : aliasParams = $[15];
88
+ let t6;
89
+ $[16] !== deploymentTarget ? (t6 = hash(deploymentTarget), $[16] = deploymentTarget, $[17] = t6) : t6 = $[17];
90
+ let t7;
91
+ $[18] !== t6 ? (t7 = [t6, "aliases"], $[18] = t6, $[19] = t7) : t7 = $[19];
92
+ let t8;
93
+ $[20] !== fetchUrl ? (t8 = () => fetchUrl(API_ENDPOINT_ALIASES, aliasParams), $[20] = fetchUrl, $[21] = t8) : t8 = $[21];
94
+ const t9 = !!deploymentsData;
95
+ let t10;
96
+ $[22] !== t7 || $[23] !== t8 || $[24] !== t9 ? (t10 = {
97
+ queryKey: t7,
98
+ queryFn: t8,
99
+ enabled: t9,
100
+ refetchOnMount: !1,
101
+ refetchOnReconnect: !1,
102
+ refetchOnWindowFocus: !1,
103
+ retry: !1
104
+ }, $[22] = t7, $[23] = t8, $[24] = t9, $[25] = t10) : t10 = $[25];
105
+ const {
106
+ data: aliasesData,
107
+ isFetching: aliasesIsFetching,
108
+ isSuccess: aliasesIsSuccess,
109
+ error: aliasesError
110
+ } = useQuery(t10), aliases = aliasesData?.aliases;
111
+ let deploymentsWithAlias;
112
+ if (aliases) {
113
+ let t112;
114
+ $[26] !== aliases || $[27] !== deploymentsData?.deployments ? (t112 = deploymentsData?.deployments?.map((val) => {
115
+ const alias = aliases.find((a) => a.deploymentId === val.uid);
116
+ return Object.assign(val, {
117
+ alias: alias?.alias
118
+ });
119
+ }), $[26] = aliases, $[27] = deploymentsData?.deployments, $[28] = t112) : t112 = $[28], deploymentsWithAlias = t112;
120
+ }
121
+ const t11 = aliasesError || deploymentsError, t12 = aliasesIsFetching || deploymentsIsFetching, t13 = aliasesIsSuccess && deploymentsIsSuccess;
122
+ let t14;
123
+ return $[29] !== deploymentsWithAlias || $[30] !== refetch || $[31] !== t11 || $[32] !== t12 || $[33] !== t13 ? (t14 = {
124
+ deployments: deploymentsWithAlias,
125
+ error: t11,
126
+ isFetching: t12,
127
+ isSuccess: t13,
128
+ refetch
129
+ }, $[29] = deploymentsWithAlias, $[30] = refetch, $[31] = t11, $[32] = t12, $[33] = t13, $[34] = t14) : t14 = $[34], t14;
130
+ }, refreshMachine = setup({
131
+ types: {
132
+ events: {}
133
+ }
134
+ }).createMachine({
135
+ /** @xstate-layout N4IgpgJg5mDOIC5QAoC2BDAxgCwJYDswBKAOlwgBswBiAJQFEAxBgZQAkBtABgF1FQADgHtYuAC64h+fiAAeiAIwAmAGwkuGrkoAsAZhVKlAVm0KAHABoQAT0QBOJSRN27XFXaMmz2twF9fVmhYeISkAE5gAGYRsCFQ1PS0tADytNx8SCDCohJSMvIIPnYkxhpKXGZ22kY6xla2CAq6CiQudgDsRnYqKroVfe3+gRg4BMQkEdFwcXRMrGz0ACLpMtniktKZBUUlRmUVVTXadTaISrqObUY97QodvWa6QyBBo6ETUTHYkLPM9OwrTJrXKbUDbJTFLjtMzmWraOx3doqeqKMyOeHdXp3BTHXTVZ6vELjMBhMJCMK-eaAwQidZ5LaIY6Q6Gw47wxHI04IGEkDFma5NbTtY7ufwBED4IQQOAyQljIirWkg-KIAC0nIa6oJIyJpHIVEVOQ2KsKShRCDsunUGLcHi8PhU2uC8o+U1iBCghrpoLkZ2uTk0XCq7SRRl0Zg19itXHhIZ85lMEaUTre40mX0gXuVDIQnmKRhZKk6PmaVXN2PUaLsZhj2hUOJU-JTupIJLJYSzxpzeacheLXFL2nNrkrfW8SKFnhDYt8QA */
136
+ initial: "idle",
137
+ states: {
138
+ idle: {
139
+ on: {
140
+ REFRESH: {
141
+ target: "refreshing"
142
+ }
143
+ }
144
+ },
145
+ refreshing: {
146
+ on: {
147
+ ERROR: {
148
+ target: "error"
149
+ },
150
+ REFRESHED: {
151
+ target: "refreshed"
152
+ }
153
+ }
154
+ },
155
+ refreshed: {
156
+ on: {
157
+ REFRESH: {
158
+ target: "refreshing"
159
+ }
160
+ }
161
+ },
162
+ error: {
163
+ on: {
164
+ REFRESH: {
165
+ target: "refreshing"
166
+ }
167
+ }
168
+ }
169
+ }
170
+ });
171
+ function useCardColor() {
172
+ const $ = c(2), {
173
+ color
174
+ } = useTheme_v2();
175
+ let t0;
176
+ return $[0] !== color.border ? (t0 = {
177
+ border: color.border
178
+ }, $[0] = color.border, $[1] = t0) : t0 = $[1], t0;
179
+ }
180
+ const deployMachine = setup({
181
+ types: {
182
+ context: {},
183
+ events: {},
184
+ input: {}
185
+ },
186
+ actors: {
187
+ deploy: fromPromise(async ({
188
+ input,
189
+ signal
190
+ }) => {
191
+ try {
192
+ if (!input.deployHook)
193
+ throw new Error("No deployHook URL defined");
194
+ const res = await fetch(input.deployHook, {
195
+ method: "POST",
196
+ signal
197
+ }), data = await res.json();
198
+ if (!res.ok)
199
+ throw data?.error?.message || res.statusText;
200
+ } catch (err) {
201
+ throw typeof err == "string" ? err : (console.error("Unable to deploy with error:", err), new Error("Please check the developer console for more information", {
202
+ cause: err
203
+ }));
204
+ }
205
+ })
206
+ }
207
+ }).createMachine({
208
+ /** @xstate-layout N4IgpgJg5mDOIC5QTABwDYHsCeA6AlhOmAMQAiAogAoAyA8gJoDaADALqKiqaz4Au+TADtOIAB6IATCxa4AnADYAHAHYArArUslAZjksNAGhDZEARk3yVmhSxVyHC-QBYAvq+MoMOXF6zZ8ISgSCGEwAiEAN0wAa3C-HwSAoIRA6IBjAEMBYVY2PNFuXhyRJHFENTMzXElFJSUzNTVnWx0FY1MESXVcZzUdM2k1OTUVBoV3TzR-X2mcQOCwACclzCXcDGyAMzWAW1nvPCSF1KjMLJK8grKi-kFS0AkESura5QamlpY2jvMB+QcDkqLH0wxYEw8ICSuFgAFd0uk4LByNR6Mx2IUeHdhKIns1ZN9BtYQVpRnJfl1JM55P1BnY1Ep9CpGpMoXM8MtVksUbRGNcuFiSriKs4CQNurYRgZ7BSGr1ASNupIzEo+kp3JChJgUPAyklMcV7sKEABadomRAmtQAhW2wE6VnQwjEA3Yh7lBDOSQUsxeqyaPoWYbWFSO9kHfwLV1CspPHSSHQ1ZyA1UKJzJlQ+iz+5oKewKWrfNyQ6FwhFI6NG2OINOSXDiypKAxtMyZi1dEE1Qk6L0FpTSUMl8OctaVnHVhC1+uDRvNhStin6XDaHQ9liSXTJiUa1xAA */
209
+ id: "deploy",
210
+ initial: "idle",
211
+ context: ({
212
+ input
213
+ }) => ({
214
+ disabled: !1,
215
+ feedback: void 0,
216
+ label: void 0,
217
+ error: void 0,
218
+ deployHook: input.deployHook
219
+ }),
220
+ states: {
221
+ idle: {
222
+ entry: assign({
223
+ feedback: () => {
224
+ },
225
+ label: () => "Deploy"
226
+ }),
227
+ on: {
228
+ DEPLOY: {
229
+ target: "deploying"
230
+ }
231
+ }
232
+ },
233
+ deploying: {
234
+ entry: assign({
235
+ disabled: () => !0,
236
+ label: () => "Deploying"
237
+ }),
238
+ exit: assign({
239
+ disabled: () => !1,
240
+ label: () => "Deploy"
241
+ }),
242
+ invoke: {
243
+ src: "deploy",
244
+ input: ({
245
+ context
246
+ }) => ({
247
+ deployHook: context.deployHook
248
+ }),
249
+ onDone: {
250
+ target: "success"
251
+ },
252
+ onError: {
253
+ target: "error",
254
+ actions: assign({
255
+ error: ({
256
+ event
257
+ }) => {
258
+ if ("error" in event) {
259
+ const {
260
+ error
261
+ } = event;
262
+ if (typeof error == "string")
263
+ return error;
264
+ if (error instanceof Error)
265
+ return error.message;
266
+ }
267
+ return "Unknown error";
268
+ }
269
+ })
270
+ }
271
+ }
272
+ },
273
+ success: {
274
+ entry: assign({
275
+ feedback: () => "Successfully started!"
276
+ }),
277
+ exit: assign({
278
+ feedback: () => {
279
+ }
280
+ }),
281
+ on: {
282
+ DEPLOY: {
283
+ target: "deploying"
284
+ }
285
+ }
286
+ },
287
+ error: {
288
+ on: {
289
+ DEPLOY: {
290
+ target: "deploying"
291
+ }
292
+ }
293
+ }
294
+ }
295
+ }), StateDebug = (props) => (c(10), null), DeployButton = (props) => {
296
+ const $ = c(29), {
297
+ deployHook,
298
+ onDeploySuccess,
299
+ targetName
300
+ } = props;
301
+ let t0;
302
+ $[0] !== deployHook ? (t0 = {
303
+ input: {
304
+ deployHook
305
+ }
306
+ }, $[0] = deployHook, $[1] = t0) : t0 = $[1];
307
+ const [deployState, deployStateTransition, deployStateInterpreter] = useMachine(deployMachine, t0), toast = useToast();
308
+ let t1;
309
+ $[2] !== deployState ? (t1 = deployState.matches("error"), $[2] = deployState, $[3] = t1) : t1 = $[3];
310
+ const isError = t1;
311
+ let t2;
312
+ $[4] !== deployState ? (t2 = deployState.matches("success"), $[4] = deployState, $[5] = t2) : t2 = $[5];
313
+ const isSuccess = t2;
314
+ let t3;
315
+ $[6] !== deployStateTransition ? (t3 = () => {
316
+ deployStateTransition({
317
+ type: "DEPLOY"
318
+ });
319
+ }, $[6] = deployStateTransition, $[7] = t3) : t3 = $[7];
320
+ const handleDeploy = t3;
321
+ let t4, t5;
322
+ $[8] !== deployState.context.error || $[9] !== isError || $[10] !== isSuccess || $[11] !== targetName || $[12] !== toast ? (t4 = () => {
323
+ isError && toast.push({
324
+ closable: !0,
325
+ description: `Unable to queue deploy for ${targetName}: ${deployState.context.error}`,
326
+ duration: 8e3,
327
+ status: "error",
328
+ title: WIDGET_NAME
329
+ }), isSuccess && toast.push({
330
+ closable: !0,
331
+ description: `Deploy queued for ${targetName}`,
332
+ duration: 8e3,
333
+ status: "success",
334
+ title: WIDGET_NAME
335
+ });
336
+ }, t5 = [isError, isSuccess, toast, targetName, deployState.context.error], $[8] = deployState.context.error, $[9] = isError, $[10] = isSuccess, $[11] = targetName, $[12] = toast, $[13] = t4, $[14] = t5) : (t4 = $[13], t5 = $[14]), useEffect(t4, t5);
337
+ let t6, t7;
338
+ $[15] !== deployStateInterpreter || $[16] !== onDeploySuccess ? (t6 = () => {
339
+ const subscription = deployStateInterpreter.subscribe((state) => {
340
+ state.value === "success" && onDeploySuccess && onDeploySuccess();
341
+ });
342
+ return () => subscription.unsubscribe();
343
+ }, t7 = [deployStateInterpreter, onDeploySuccess], $[15] = deployStateInterpreter, $[16] = onDeploySuccess, $[17] = t6, $[18] = t7) : (t6 = $[17], t7 = $[18]), useEffect(t6, t7);
344
+ let t8;
345
+ $[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = {
346
+ position: "relative"
347
+ }, $[19] = t8) : t8 = $[19];
348
+ let t9;
349
+ $[20] !== deployState ? (t9 = /* @__PURE__ */ jsx(StateDebug, { name: "Deploy", state: deployState }), $[20] = deployState, $[21] = t9) : t9 = $[21];
350
+ const t10 = `${deployState.context.label} ${targetName}`;
351
+ let t11;
352
+ $[22] !== deployState.context.disabled || $[23] !== handleDeploy || $[24] !== t10 ? (t11 = /* @__PURE__ */ jsx(Button, { disabled: deployState.context.disabled, fontSize: 1, icon: UploadIcon, mode: "ghost", onClick: handleDeploy, padding: 3, text: t10, tone: "default" }), $[22] = deployState.context.disabled, $[23] = handleDeploy, $[24] = t10, $[25] = t11) : t11 = $[25];
353
+ let t12;
354
+ return $[26] !== t11 || $[27] !== t9 ? (t12 = /* @__PURE__ */ jsxs(Box, { padding: 3, style: t8, children: [
355
+ t9,
356
+ t11
357
+ ] }), $[26] = t11, $[27] = t9, $[28] = t12) : t12 = $[28], t12;
358
+ }, StatusDot = (t0) => {
359
+ const $ = c(2), {
360
+ state
361
+ } = t0, t1 = VERCEL_STATUS_COLORS[state];
362
+ let t2;
363
+ return $[0] !== t1 ? (t2 = /* @__PURE__ */ jsx(Box, { style: {
364
+ backgroundColor: t1,
365
+ borderRadius: "20px",
366
+ height: "9px",
367
+ width: "9px"
368
+ } }), $[0] = t1, $[1] = t2) : t2 = $[1], t2;
369
+ }, TableCell = (props) => {
370
+ const $ = c(20), {
371
+ children,
372
+ colSpan,
373
+ header,
374
+ variant
375
+ } = props;
376
+ let display = "table-cell", cellWidth = "auto";
377
+ bb0: switch (variant) {
378
+ case "age": {
379
+ cellWidth = "50px";
380
+ break bb0;
381
+ }
382
+ case "branch": {
383
+ cellWidth = "300px";
384
+ let t02;
385
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t02 = ["none", "none", "none", "table-cell"], $[0] = t02) : t02 = $[0], display = t02;
386
+ break bb0;
387
+ }
388
+ case "creator": {
389
+ cellWidth = "80px";
390
+ break bb0;
391
+ }
392
+ case "state": {
393
+ cellWidth = "110px";
394
+ let t02;
395
+ $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t02 = ["none", "none", "none", "none", "table-cell"], $[1] = t02) : t02 = $[1], display = t02;
396
+ break bb0;
397
+ }
398
+ }
399
+ const {
400
+ border
401
+ } = useCardColor();
402
+ if (header) {
403
+ let t02;
404
+ $[2] !== cellWidth ? (t02 = {
405
+ maxWidth: cellWidth,
406
+ position: "relative",
407
+ textAlign: "left",
408
+ width: cellWidth
409
+ }, $[2] = cellWidth, $[3] = t02) : t02 = $[3];
410
+ let t12;
411
+ $[4] !== children ? (t12 = /* @__PURE__ */ jsx(Label, { size: 0, children }), $[4] = children, $[5] = t12) : t12 = $[5];
412
+ let t22;
413
+ return $[6] !== colSpan || $[7] !== display || $[8] !== t02 || $[9] !== t12 ? (t22 = /* @__PURE__ */ jsx(Box, { as: "th", colSpan, display, paddingX: 3, paddingY: 2, style: t02, children: t12 }), $[6] = colSpan, $[7] = display, $[8] = t02, $[9] = t12, $[10] = t22) : t22 = $[10], t22;
414
+ }
415
+ let t0;
416
+ $[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = [2, 2, 3], $[11] = t0) : t0 = $[11];
417
+ const t1 = `1px solid ${border}`;
418
+ let t2;
419
+ $[12] !== cellWidth || $[13] !== t1 ? (t2 = {
420
+ borderTop: t1,
421
+ maxWidth: cellWidth,
422
+ position: "relative",
423
+ textAlign: "left",
424
+ width: cellWidth
425
+ }, $[12] = cellWidth, $[13] = t1, $[14] = t2) : t2 = $[14];
426
+ let t3;
427
+ return $[15] !== children || $[16] !== colSpan || $[17] !== display || $[18] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { as: "td", colSpan, display, paddingX: 3, paddingY: t0, style: t2, children }), $[15] = children, $[16] = colSpan, $[17] = display, $[18] = t2, $[19] = t3) : t3 = $[19], t3;
428
+ }, Deployment = (props) => {
429
+ const $ = c(42), {
430
+ deployment
431
+ } = props;
432
+ let t0;
433
+ $[0] !== deployment.created ? (t0 = new Date(deployment.created), $[0] = deployment.created, $[1] = t0) : t0 = $[1];
434
+ const date = t0, commitMessage = deployment?.meta?.githubCommitMessage, commitRef = deployment?.meta?.githubCommitRef, targetUrl = deployment.alias ?? deployment.url;
435
+ let t1;
436
+ $[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = ["block", "block", "block", "block", "none"], $[2] = t1) : t1 = $[2];
437
+ let t2;
438
+ $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
439
+ flexShrink: 0
440
+ }, $[3] = t2) : t2 = $[3];
441
+ let t3;
442
+ $[4] !== deployment.state ? (t3 = /* @__PURE__ */ jsx(Box, { display: t1, marginRight: 3, style: t2, children: /* @__PURE__ */ jsx(StatusDot, { state: deployment.state }) }), $[4] = deployment.state, $[5] = t3) : t3 = $[5];
443
+ let t4;
444
+ $[6] !== deployment.alias || $[7] !== deployment.state || $[8] !== targetUrl ? (t4 = targetUrl ? /* @__PURE__ */ jsxs(Fragment, { children: [
445
+ deployment.alias && /* @__PURE__ */ jsx(LinkIcon, {}),
446
+ /* @__PURE__ */ jsx(Box, { marginLeft: deployment.alias ? 1 : 0, children: /* @__PURE__ */ jsx(Text, { muted: deployment.state !== "READY", size: 1, style: {
447
+ textDecoration: deployment.state === "CANCELED" || deployment.state === "ERROR" ? "line-through" : "normal"
448
+ }, textOverflow: "ellipsis", children: deployment.state === "READY" ? /* @__PURE__ */ jsx("a", { href: `https://${targetUrl}`, rel: "noopener noreferrer", target: "_blank", children: targetUrl }) : targetUrl }) })
449
+ ] }) : /* @__PURE__ */ jsx(Text, { size: 1, children: "Uploading..." }), $[6] = deployment.alias, $[7] = deployment.state, $[8] = targetUrl, $[9] = t4) : t4 = $[9];
450
+ let t5;
451
+ $[10] !== t3 || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", children: [
452
+ t3,
453
+ t4
454
+ ] }) }), $[10] = t3, $[11] = t4, $[12] = t5) : t5 = $[12];
455
+ let t6;
456
+ $[13] !== deployment.state ? (t6 = /* @__PURE__ */ jsx(StatusDot, { state: deployment.state }), $[13] = deployment.state, $[14] = t6) : t6 = $[14];
457
+ let t7;
458
+ if ($[15] !== deployment.state) {
459
+ let t82;
460
+ $[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t82 = /^[a-z]/i, $[17] = t82) : t82 = $[17], t7 = deployment.state.trim().toLowerCase().replace(t82, _temp$2), $[15] = deployment.state, $[16] = t7;
461
+ } else
462
+ t7 = $[16];
463
+ let t8;
464
+ $[18] !== t7 ? (t8 = /* @__PURE__ */ jsx(Box, { marginLeft: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, children: t7 }) }), $[18] = t7, $[19] = t8) : t8 = $[19];
465
+ let t9;
466
+ $[20] !== t6 || $[21] !== t8 ? (t9 = /* @__PURE__ */ jsx(TableCell, { variant: "state", children: /* @__PURE__ */ jsxs(Flex, { align: "center", children: [
467
+ t6,
468
+ t8
469
+ ] }) }), $[20] = t6, $[21] = t8, $[22] = t9) : t9 = $[22];
470
+ let t10;
471
+ $[23] !== commitRef ? (t10 = /* @__PURE__ */ jsx(Text, { size: 1, textOverflow: "ellipsis", children: commitRef }), $[23] = commitRef, $[24] = t10) : t10 = $[24];
472
+ let t11;
473
+ $[25] !== commitMessage ? (t11 = commitMessage && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, textOverflow: "ellipsis", children: commitMessage }), $[25] = commitMessage, $[26] = t11) : t11 = $[26];
474
+ let t12;
475
+ $[27] !== t10 || $[28] !== t11 ? (t12 = /* @__PURE__ */ jsx(TableCell, { variant: "branch", children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
476
+ t10,
477
+ t11
478
+ ] }) }), $[27] = t10, $[28] = t11, $[29] = t12) : t12 = $[29];
479
+ let t13;
480
+ $[30] !== date ? (t13 = /* @__PURE__ */ jsx(TableCell, { variant: "age", children: /* @__PURE__ */ jsx(Flex, { align: "center", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(ReactTimeAgo, { date, locale: "en-US", timeStyle: "mini" }) }) }) }), $[30] = date, $[31] = t13) : t13 = $[31];
481
+ const t14 = deployment?.creator?.username || "Deployment creator avatar", t15 = `https://vercel.com/api/www/avatar/${deployment?.creator?.uid}?&s=48`;
482
+ let t16;
483
+ $[32] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t16 = {
484
+ borderRadius: "20px",
485
+ height: "20px",
486
+ width: "20px"
487
+ }, $[32] = t16) : t16 = $[32];
488
+ let t17;
489
+ $[33] !== t14 || $[34] !== t15 ? (t17 = /* @__PURE__ */ jsx(TableCell, { variant: "creator", children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", children: /* @__PURE__ */ jsx("img", { alt: t14, draggable: !1, src: t15, style: t16 }) }) }), $[33] = t14, $[34] = t15, $[35] = t17) : t17 = $[35];
490
+ let t18;
491
+ return $[36] !== t12 || $[37] !== t13 || $[38] !== t17 || $[39] !== t5 || $[40] !== t9 ? (t18 = /* @__PURE__ */ jsxs("tr", { children: [
492
+ t5,
493
+ t9,
494
+ t12,
495
+ t13,
496
+ t17
497
+ ] }), $[36] = t12, $[37] = t13, $[38] = t17, $[39] = t5, $[40] = t9, $[41] = t18) : t18 = $[41], t18;
498
+ };
499
+ function _temp$2(t) {
500
+ return t.toUpperCase();
501
+ }
502
+ const PlaceholderAvatar = () => {
503
+ const $ = c(2), {
504
+ border
505
+ } = useCardColor();
506
+ let t0;
507
+ return $[0] !== border ? (t0 = /* @__PURE__ */ jsx(Box, { style: {
508
+ backgroundColor: border,
509
+ borderRadius: "20px",
510
+ height: "20px",
511
+ userSelect: "none",
512
+ width: "20px"
513
+ } }), $[0] = border, $[1] = t0) : t0 = $[1], t0;
514
+ }, PlaceholderText = (props) => {
515
+ const $ = c(7), {
516
+ rows
517
+ } = props, {
518
+ border
519
+ } = useCardColor();
520
+ let t0;
521
+ $[0] !== border ? (t0 = {
522
+ backgroundColor: border,
523
+ borderRadius: "3px",
524
+ userSelect: "none",
525
+ width: "100%"
526
+ }, $[0] = border, $[1] = t0) : t0 = $[1];
527
+ let t1;
528
+ $[2] !== rows ? (t1 = /* @__PURE__ */ jsx(Stack, { gap: 2, children: Array.from({
529
+ length: rows
530
+ }, _temp$1) }), $[2] = rows, $[3] = t1) : t1 = $[3];
531
+ let t2;
532
+ return $[4] !== t0 || $[5] !== t1 ? (t2 = /* @__PURE__ */ jsx(Box, { style: t0, children: t1 }), $[4] = t0, $[5] = t1, $[6] = t2) : t2 = $[6], t2;
533
+ };
534
+ function _temp$1(_, index) {
535
+ return /* @__PURE__ */ jsx(Text, { size: 1, children: "\xA0" }, index);
536
+ }
537
+ const DeploymentPlaceholder = () => {
538
+ const $ = c(5);
539
+ let t0;
540
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(PlaceholderText, { rows: 1 }) }), $[0] = t0) : t0 = $[0];
541
+ let t1;
542
+ $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx(TableCell, { variant: "state", children: /* @__PURE__ */ jsx(PlaceholderText, { rows: 1 }) }), $[1] = t1) : t1 = $[1];
543
+ let t2;
544
+ $[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(TableCell, { variant: "branch", children: /* @__PURE__ */ jsx(PlaceholderText, { rows: 2 }) }), $[2] = t2) : t2 = $[2];
545
+ let t3;
546
+ $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(TableCell, { variant: "age", children: /* @__PURE__ */ jsx(PlaceholderText, { rows: 1 }) }), $[3] = t3) : t3 = $[3];
547
+ let t4;
548
+ return $[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsxs("tr", { children: [
549
+ t0,
550
+ t1,
551
+ t2,
552
+ t3,
553
+ /* @__PURE__ */ jsx(TableCell, { variant: "creator", children: /* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(PlaceholderAvatar, {}) }) })
554
+ ] }), $[4] = t4) : t4 = $[4], t4;
555
+ }, Deployments = (props) => {
556
+ const $ = c(49), {
557
+ deploymentTarget
558
+ } = props, refTimeout = useRef(null), [refreshState, refreshStateTransition] = useMachine(refreshMachine);
559
+ let t0;
560
+ $[0] !== refreshState ? (t0 = refreshState.matches("error"), $[0] = refreshState, $[1] = t0) : t0 = $[1];
561
+ const t1 = !t0;
562
+ let t2;
563
+ $[2] !== t1 ? (t2 = {
564
+ enabled: t1
565
+ }, $[2] = t1, $[3] = t2) : t2 = $[3];
566
+ const {
567
+ deployments,
568
+ error,
569
+ isFetching,
570
+ isSuccess,
571
+ refetch
572
+ } = useDeployments(deploymentTarget, t2), toast = useToast();
573
+ let t3;
574
+ $[4] !== refreshState ? (t3 = refreshState.matches("error"), $[4] = refreshState, $[5] = t3) : t3 = $[5];
575
+ const isError = t3;
576
+ let t4;
577
+ $[6] !== refetch ? (t4 = () => {
578
+ refTimeout.current && clearTimeout(refTimeout.current), refTimeout.current = setTimeout(() => {
579
+ refetch({
580
+ cancelRefetch: !0,
581
+ throwOnError: !0
582
+ });
583
+ }, 4e3);
584
+ }, $[6] = refetch, $[7] = t4) : t4 = $[7];
585
+ const handleDeploySuccess = t4;
586
+ let t5, t6;
587
+ $[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = () => () => {
588
+ refTimeout.current && clearTimeout(refTimeout.current);
589
+ }, t6 = [], $[8] = t5, $[9] = t6) : (t5 = $[8], t6 = $[9]), useEffect(t5, t6);
590
+ let t7, t8;
591
+ $[10] !== error || $[11] !== isFetching || $[12] !== isSuccess || $[13] !== refreshStateTransition ? (t7 = () => {
592
+ error && refreshStateTransition({
593
+ type: "ERROR"
594
+ }), isFetching && refreshStateTransition({
595
+ type: "REFRESH"
596
+ }), !isFetching && isSuccess && refreshStateTransition({
597
+ type: "REFRESHED"
598
+ });
599
+ }, t8 = [error, isFetching, isSuccess, refreshStateTransition], $[10] = error, $[11] = isFetching, $[12] = isSuccess, $[13] = refreshStateTransition, $[14] = t7, $[15] = t8) : (t7 = $[14], t8 = $[15]), useEffect(t7, t8);
600
+ let t9;
601
+ $[16] !== refreshState || $[17] !== refreshStateTransition ? (t9 = () => {
602
+ refreshState.matches("refreshing") || refreshStateTransition({
603
+ type: "REFRESH"
604
+ });
605
+ }, $[16] = refreshState, $[17] = refreshStateTransition, $[18] = t9) : t9 = $[18];
606
+ let t10;
607
+ $[19] !== deploymentTarget ? (t10 = [deploymentTarget], $[19] = deploymentTarget, $[20] = t10) : t10 = $[20], useDeepCompareEffect(t9, t10);
608
+ let t11;
609
+ $[21] !== deploymentTarget || $[22] !== isError || $[23] !== toast ? (t11 = () => {
610
+ isError && toast.push({
611
+ closable: !0,
612
+ description: `Unable to fetch deployments for ${deploymentTarget.name}`,
613
+ duration: 8e3,
614
+ status: "error",
615
+ title: WIDGET_NAME
616
+ });
617
+ }, $[21] = deploymentTarget, $[22] = isError, $[23] = toast, $[24] = t11) : t11 = $[24];
618
+ let t12;
619
+ $[25] !== deploymentTarget || $[26] !== isError ? (t12 = [deploymentTarget, isError], $[25] = deploymentTarget, $[26] = isError, $[27] = t12) : t12 = $[27], useDeepCompareEffect(t11, t12);
620
+ const hasFetched = typeof deployments < "u", hasDeployments = deployments && deployments.length > 0, {
621
+ border
622
+ } = useCardColor();
623
+ let t13;
624
+ $[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = {
625
+ position: "relative"
626
+ }, $[28] = t13) : t13 = $[28];
627
+ let t14;
628
+ $[29] !== refreshState ? (t14 = /* @__PURE__ */ jsx(StateDebug, { name: "Refresh", state: refreshState }), $[29] = refreshState, $[30] = t14) : t14 = $[30];
629
+ let t15;
630
+ $[31] !== border || $[32] !== deploymentTarget || $[33] !== deployments || $[34] !== hasDeployments || $[35] !== hasFetched || $[36] !== refreshState ? (t15 = !refreshState.matches("error") && /* @__PURE__ */ jsxs(Fragment, { children: [
631
+ /* @__PURE__ */ jsxs(Box, { as: "table", style: {
632
+ borderBottom: `1px solid ${border}`,
633
+ borderCollapse: "collapse",
634
+ display: "table",
635
+ tableLayout: "fixed",
636
+ width: "100%"
637
+ }, children: [
638
+ /* @__PURE__ */ jsx(Box, { as: "thead", style: {
639
+ display: "table-header-group"
640
+ }, children: /* @__PURE__ */ jsxs("tr", { children: [
641
+ /* @__PURE__ */ jsx(TableCell, { header: !0, children: "Deployment" }),
642
+ /* @__PURE__ */ jsx(TableCell, { header: !0, variant: "state", children: "State" }),
643
+ /* @__PURE__ */ jsx(TableCell, { header: !0, variant: "branch", children: "Branch" }),
644
+ /* @__PURE__ */ jsx(TableCell, { header: !0, variant: "age", children: "Age" }),
645
+ /* @__PURE__ */ jsx(TableCell, { header: !0, variant: "creator", children: "Creator" })
646
+ ] }) }),
647
+ /* @__PURE__ */ jsxs(Box, { as: "tbody", style: {
648
+ display: "table-row-group"
649
+ }, children: [
650
+ !deployments && Array.from({
651
+ length: deploymentTarget.deployLimit
652
+ }, _temp),
653
+ hasDeployments && deployments?.map(_temp2)
654
+ ] })
655
+ ] }),
656
+ hasFetched && !hasDeployments && /* @__PURE__ */ jsx(Box, { padding: 3, style: {
657
+ width: "100%"
658
+ }, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "No deployments found. Don't forget to specify a valid team ID if your project belongs to a team." }) })
659
+ ] }), $[31] = border, $[32] = deploymentTarget, $[33] = deployments, $[34] = hasDeployments, $[35] = hasFetched, $[36] = refreshState, $[37] = t15) : t15 = $[37];
660
+ let t16;
661
+ $[38] !== refreshState ? (t16 = refreshState.matches("error") && /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "Unable to fetch recent deployments. Please check your network and deployment settings." }) }), $[38] = refreshState, $[39] = t16) : t16 = $[39];
662
+ let t17;
663
+ $[40] !== deploymentTarget || $[41] !== handleDeploySuccess || $[42] !== refreshState ? (t17 = !refreshState.matches("error") && deploymentTarget.deployHook && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(DeployButton, { deployHook: deploymentTarget.deployHook, onDeploySuccess: handleDeploySuccess, targetName: deploymentTarget.name }) }), $[40] = deploymentTarget, $[41] = handleDeploySuccess, $[42] = refreshState, $[43] = t17) : t17 = $[43];
664
+ let t18;
665
+ return $[44] !== t14 || $[45] !== t15 || $[46] !== t16 || $[47] !== t17 ? (t18 = /* @__PURE__ */ jsxs(Box, { marginTop: 3, style: t13, children: [
666
+ t14,
667
+ t15,
668
+ t16,
669
+ t17
670
+ ] }), $[44] = t14, $[45] = t15, $[46] = t16, $[47] = t17, $[48] = t18) : t18 = $[48], t18;
671
+ };
672
+ function _temp(_, index) {
673
+ return /* @__PURE__ */ jsx(DeploymentPlaceholder, {}, index);
674
+ }
675
+ function _temp2(deployment) {
676
+ return /* @__PURE__ */ jsx(Deployment, { deployment }, deployment.uid);
677
+ }
678
+ const DeploymentTarget = (props) => {
679
+ const $ = c(22), {
680
+ item,
681
+ onDialogEdit
682
+ } = props;
683
+ let t0;
684
+ $[0] !== item.deployHook || $[1] !== item.deployLimit || $[2] !== item.name || $[3] !== item.projectId || $[4] !== item.teamId || $[5] !== item.token ? (t0 = {
685
+ deployHook: item.deployHook,
686
+ deployLimit: item.deployLimit,
687
+ name: item.name,
688
+ projectId: item.projectId,
689
+ teamId: item.teamId,
690
+ token: item.token
691
+ }, $[0] = item.deployHook, $[1] = item.deployLimit, $[2] = item.name, $[3] = item.projectId, $[4] = item.teamId, $[5] = item.token, $[6] = t0) : t0 = $[6];
692
+ const deploymentTarget = t0;
693
+ let t1;
694
+ $[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = {
695
+ position: "relative"
696
+ }, $[7] = t1) : t1 = $[7];
697
+ let t2;
698
+ $[8] !== item.name ? (t2 = /* @__PURE__ */ jsx(Text, { size: 2, children: item.name }), $[8] = item.name, $[9] = t2) : t2 = $[9];
699
+ let t3;
700
+ $[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "Edit deployment target" }) }), $[10] = t3) : t3 = $[10];
701
+ let t4;
702
+ $[11] !== item || $[12] !== onDialogEdit ? (t4 = /* @__PURE__ */ jsx(Tooltip, { content: t3, placement: "left", children: /* @__PURE__ */ jsx(Button, { fontSize: 1, icon: EditIcon, mode: "bleed", onClick: () => onDialogEdit(item) }) }), $[11] = item, $[12] = onDialogEdit, $[13] = t4) : t4 = $[13];
703
+ let t5;
704
+ $[14] !== t2 || $[15] !== t4 ? (t5 = /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", marginTop: 2, paddingX: 3, children: [
705
+ t2,
706
+ t4
707
+ ] }), $[14] = t2, $[15] = t4, $[16] = t5) : t5 = $[16];
708
+ let t6;
709
+ $[17] !== deploymentTarget ? (t6 = /* @__PURE__ */ jsx(Deployments, { deploymentTarget }), $[17] = deploymentTarget, $[18] = t6) : t6 = $[18];
710
+ let t7;
711
+ return $[19] !== t5 || $[20] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Box, { style: t1, children: [
712
+ t5,
713
+ t6
714
+ ] }), $[19] = t5, $[20] = t6, $[21] = t7) : t7 = $[21], t7;
715
+ }, DeploymentTargets = (props) => {
716
+ const $ = c(5), {
717
+ items,
718
+ onDialogEdit
719
+ } = props;
720
+ let t0;
721
+ $[0] !== items || $[1] !== onDialogEdit ? (t0 = items?.map((item) => /* @__PURE__ */ jsx(DeploymentTarget, { item, onDialogEdit }, item._id)), $[0] = items, $[1] = onDialogEdit, $[2] = t0) : t0 = $[2];
722
+ let t1;
723
+ return $[3] !== t0 ? (t1 = /* @__PURE__ */ jsx(Stack, { gap: 5, children: t0 }), $[3] = t0, $[4] = t1) : t1 = $[4], t1;
724
+ }, formMachine = setup({
725
+ types: {},
726
+ actions: {
727
+ setId: assign({
728
+ id: ({
729
+ event
730
+ }) => (assertEvent(event, ["UPDATE", "DELETE"]), event.id)
731
+ }),
732
+ setFormData: assign({
733
+ formData: ({
734
+ event
735
+ }) => (assertEvent(event, ["CREATE", "UPDATE"]), event.formData)
736
+ }),
737
+ setMessage: assign({
738
+ message: ({
739
+ event
740
+ }) => "data" in event && event.data && typeof event.data == "object" && "details" in event.data && event.data.details && typeof event.data.details == "object" && "description" in event.data.details ? event.data.details.description : "An error occurred"
741
+ }),
742
+ setDocument: assign({
743
+ document: ({
744
+ event
745
+ }) => event.output
746
+ })
747
+ },
748
+ actors: {
749
+ "create document": fromPromise(({
750
+ input
751
+ }) => input.client.create({
752
+ _id: `vercel.${uuid()}`,
753
+ _type: DEPLOYMENT_TARGET_DOCUMENT_TYPE,
754
+ ...input.formData
755
+ })),
756
+ "update document": fromPromise(({
757
+ input
758
+ }) => input.client.patch(input.id).set(input.formData).commit()),
759
+ "delete document": fromPromise(({
760
+ input
761
+ }) => input.client.delete(input.id))
762
+ }
763
+ }).createMachine({
764
+ /** @xstate-layout N4IgpgJg5mDOIC5QAoC2BDAxgCwJYDswBKAOlwgBswBiAYQCUBRAQQBVGBtABgF1FQADgHtYuAC64h+fiAAeiAIwBmAGwkuGjQFYALAE4AHACYdWgwYA0IAJ6IjKgOwkdXFUYVa9h-Ua5KAvv5WaFh4hKTkVNQAqgAKACJsnLwywqISUjLyCMpqmtr6xqbmVrYIBgokWvlGWkpaCgZeKoHBGDgExGSUNPGMADKM7Nx8SCBp4pLSY9m56vm6hiZmljaIOipqdXpcDk1aWiYqBlqtICEd4SSYAE5g6BL4UNQQUmBk+ABuQgDW77f3MRgeJCTAAV1QYHwYmYmDEQhuI1SIkmmRmiGOShIDiUOh0SiaCgUegcDj0pTsjhI5iMewUpPsTSMZwuYS6AIeBGeYBuNwRJAEFAeADMEahrncHsDQRCoTC4QikWMJhlpqBspjsbj8YTiaTyWsEKouNT6noiX5zUpiQEgud2mzSGCBBBOU8Xm8Pt8-iRna6gSDwZDobD4YiUsqUaqshiDFicXiCea9WSKeVKiSVIclEYlIY-BUWQ7Ok6XW7ubz+YKRWLfWWAzLg-Kw0rBFGpjGEJqEzrkyTU4b6ToSHojHos7VXEc6kXQiWSBAwFRHs9XoQvb93ovl9Kg3LQ4qI230h30V241rE7r+wayro1A4dO4VHotA5fPTTnbWfPt2AV9QPJ8jcApCmIoo3OKf4NnuIYKuGozHqiapyLG8bakmRI3mmpjxk0XAuEoXAHI+DgtGc+BCIu8BjD+4TIieaLqogAC0Khpmxs6XF0kRgAxyGdk+aYKLSVR7Fweg6A4IkGFwChcY6EqAly-HRmeY7DnSY5GHGL4qFwRhpjpJpmriDjVMRLgGAp84ckCECqaezEIHoObUuZuwKH4xGPgoRnmCQpmOAcqhmPJ37Flcfrlo5TGoQgY4mgYHkeAS+iqH5hqSc4dSuCo+I6SoSjvjZUX1pAsUodkrlGO51TSd5b46JlZRebVuG7IcjRmA05FtHOVzQSpkaMVVdivs4CibHGxg6biSg4ZsJD2AccaFEVGwOKVXTQRVI0CWeNV1Z5jW+WmujDj4HjmMRnhEttpBAQilWdkdyX1V5RFNS1iAEpU1pHER9JWjogSBEAA */
765
+ context: ({
766
+ input
767
+ }) => ({
768
+ client: input.client,
769
+ formData: {},
770
+ message: ""
771
+ }),
772
+ initial: "idle",
773
+ states: {
774
+ idle: {
775
+ on: {
776
+ CREATE: {
777
+ actions: ["setFormData"],
778
+ target: "creating"
779
+ },
780
+ UPDATE: {
781
+ actions: ["setId", "setFormData"],
782
+ target: "updating"
783
+ },
784
+ DELETE: {
785
+ actions: "setId",
786
+ target: "deleting"
787
+ }
788
+ }
789
+ },
790
+ creating: {
791
+ tags: ["busy"],
792
+ invoke: {
793
+ src: "create document",
794
+ id: "createDocumentActor",
795
+ input: ({
796
+ context
797
+ }) => ({
798
+ client: context.client,
799
+ formData: context.formData
800
+ }),
801
+ onDone: {
802
+ actions: "setDocument",
803
+ target: "created"
804
+ },
805
+ onError: {
806
+ actions: "setMessage",
807
+ target: "error"
808
+ }
809
+ }
810
+ },
811
+ created: {
812
+ type: "final"
813
+ },
814
+ updating: {
815
+ tags: ["busy"],
816
+ invoke: {
817
+ src: "update document",
818
+ id: "updateDocumentActor",
819
+ input: ({
820
+ context
821
+ }) => ({
822
+ client: context.client,
823
+ id: context.id,
824
+ formData: context.formData
825
+ }),
826
+ onDone: {
827
+ actions: "setDocument",
828
+ target: "updated"
829
+ },
830
+ onError: {
831
+ actions: "setMessage",
832
+ target: "error"
833
+ }
834
+ }
835
+ },
836
+ updated: {
837
+ type: "final"
838
+ },
839
+ deleting: {
840
+ tags: ["busy"],
841
+ invoke: {
842
+ src: "delete document",
843
+ id: "deleteDocumentActor",
844
+ input: ({
845
+ context
846
+ }) => ({
847
+ client: context.client,
848
+ id: context.id
849
+ }),
850
+ onDone: {
851
+ target: "deleted"
852
+ },
853
+ onError: {
854
+ actions: "setMessage",
855
+ target: "error"
856
+ }
857
+ }
858
+ },
859
+ deleted: {
860
+ type: "final"
861
+ },
862
+ error: {
863
+ type: "final"
864
+ }
865
+ }
866
+ }), sanitizeFormData = (formData) => Object.keys(formData).reduce((acc, key) => {
867
+ const val = formData[key];
868
+ return typeof val == "object" && val !== null && val.constructor !== Array ? acc[key] = sanitizeFormData(val) : val === "" || typeof val > "u" || val?.length === 0 ? acc[key] = null : typeof val == "string" && val ? acc[key] = formData[key].trim() : acc[key] = formData[key], acc;
869
+ }, {}), errorIconStyle = {
870
+ color: red[500].hex
871
+ }, FormFieldInputLabel = (props) => {
872
+ const $ = c(13), {
873
+ description,
874
+ error,
875
+ label,
876
+ name
877
+ } = props;
878
+ let t0;
879
+ $[0] !== label || $[1] !== name ? (t0 = /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: name, size: 1, weight: "semibold", children: label }), $[0] = label, $[1] = name, $[2] = t0) : t0 = $[2];
880
+ let t1;
881
+ $[3] !== error ? (t1 = error && /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsxs(Text, { muted: !0, size: 1, children: [
882
+ /* @__PURE__ */ jsx(ErrorOutlineIcon, { style: {
883
+ ...errorIconStyle,
884
+ marginRight: "0.1em"
885
+ } }),
886
+ error.message
887
+ ] }) }), fallbackPlacements: ["top", "left"], placement: "right", portal: !0, children: /* @__PURE__ */ jsx(ErrorOutlineIcon, { style: errorIconStyle }) }) }), $[3] = error, $[4] = t1) : t1 = $[4];
888
+ let t2;
889
+ $[5] !== t0 || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsxs(Inline, { gap: 2, children: [
890
+ t0,
891
+ t1
892
+ ] }), $[5] = t0, $[6] = t1, $[7] = t2) : t2 = $[7];
893
+ let t3;
894
+ $[8] !== description ? (t3 = description && /* @__PURE__ */ jsx(Box, { marginY: 3, children: /* @__PURE__ */ jsx(Text, { as: "p", muted: !0, size: 1, children: description }) }), $[8] = description, $[9] = t3) : t3 = $[9];
895
+ let t4;
896
+ return $[10] !== t2 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Box, { marginBottom: 3, children: [
897
+ t2,
898
+ t3
899
+ ] }), $[10] = t2, $[11] = t3, $[12] = t4) : t4 = $[12], t4;
900
+ }, FormFieldInputText = forwardRef((props, ref) => {
901
+ const $ = c(16), {
902
+ description,
903
+ disabled,
904
+ error,
905
+ label,
906
+ name,
907
+ placeholder,
908
+ value,
909
+ onChange,
910
+ onBlur
911
+ } = props;
912
+ let t0;
913
+ $[0] !== description || $[1] !== error || $[2] !== label || $[3] !== name ? (t0 = /* @__PURE__ */ jsx(FormFieldInputLabel, { description, error, label, name }), $[0] = description, $[1] = error, $[2] = label, $[3] = name, $[4] = t0) : t0 = $[4];
914
+ let t1;
915
+ $[5] !== disabled || $[6] !== name || $[7] !== onBlur || $[8] !== onChange || $[9] !== placeholder || $[10] !== ref || $[11] !== value ? (t1 = /* @__PURE__ */ jsx(TextInput, { autoComplete: "off", autoFocus: !0, defaultValue: value, disabled, id: name, name, placeholder, onChange, onBlur, ref }), $[5] = disabled, $[6] = name, $[7] = onBlur, $[8] = onChange, $[9] = placeholder, $[10] = ref, $[11] = value, $[12] = t1) : t1 = $[12];
916
+ let t2;
917
+ return $[13] !== t0 || $[14] !== t1 ? (t2 = /* @__PURE__ */ jsxs(Box, { children: [
918
+ t0,
919
+ t1
920
+ ] }), $[13] = t0, $[14] = t1, $[15] = t2) : t2 = $[15], t2;
921
+ }), formSchema = yup.object().shape({
922
+ deployHook: yup.string().url("Deploy hook must be a valid URL"),
923
+ deployLimit: yup.number().positive().integer().min(1, "Deploy limit must no less than 1").max(15, "Deploy limit must no higher than 15").typeError("Deploy limit must be a number").required("Deploy limit must be a positive integer between 1 and 15"),
924
+ name: yup.string().required("Name cannot be empty"),
925
+ projectId: yup.string().required("Vercel Project ID cannot be empty"),
926
+ teamId: yup.string(),
927
+ token: yup.string().required("Vercel Account Token cannot be empty")
928
+ }), DialogForm = (props) => {
929
+ const $ = c(104), {
930
+ deploymentTarget,
931
+ onClose,
932
+ onCreate,
933
+ onDelete,
934
+ onUpdate
935
+ } = props, client = useSanityClient(), toast = useToast();
936
+ let t0;
937
+ $[0] !== client ? (t0 = {
938
+ input: {
939
+ client
940
+ }
941
+ }, $[0] = client, $[1] = t0) : t0 = $[1];
942
+ const [formState, formStateTransition, formStateActorRef] = useActor(formMachine, t0);
943
+ let t1;
944
+ $[2] !== formState ? (t1 = formState.hasTag("busy"), $[2] = formState, $[3] = t1) : t1 = $[3];
945
+ const formUpdating = t1, t2 = deploymentTarget?.deployHook || "", t3 = deploymentTarget?.deployLimit || 5, t4 = deploymentTarget?.name || "", t5 = deploymentTarget?.projectId || "", t6 = deploymentTarget?.teamId || "", t7 = deploymentTarget?.token || "";
946
+ let t8;
947
+ $[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== t5 || $[8] !== t6 || $[9] !== t7 ? (t8 = {
948
+ deployHook: t2,
949
+ deployLimit: t3,
950
+ name: t4,
951
+ projectId: t5,
952
+ teamId: t6,
953
+ token: t7
954
+ }, $[4] = t2, $[5] = t3, $[6] = t4, $[7] = t5, $[8] = t6, $[9] = t7, $[10] = t8) : t8 = $[10];
955
+ let t9;
956
+ $[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = yupResolver(formSchema), $[11] = t9) : t9 = $[11];
957
+ let t10;
958
+ $[12] !== t8 ? (t10 = {
959
+ defaultValues: t8,
960
+ mode: "onChange",
961
+ resolver: t9
962
+ }, $[12] = t8, $[13] = t10) : t10 = $[13];
963
+ const {
964
+ formState: t11,
965
+ handleSubmit,
966
+ register
967
+ } = useForm(t10), {
968
+ errors,
969
+ isDirty,
970
+ isValid
971
+ } = t11;
972
+ let t12, t13;
973
+ $[14] !== formState || $[15] !== onClose || $[16] !== toast ? (t12 = () => {
974
+ formState.matches("error") && toast.push({
975
+ status: "error",
976
+ title: formState.context.message || "An error occurred"
977
+ }), formState.status === "done" && onClose();
978
+ }, t13 = [formState, onClose, toast], $[14] = formState, $[15] = onClose, $[16] = toast, $[17] = t12, $[18] = t13) : (t12 = $[17], t13 = $[18]), useEffect(t12, t13);
979
+ let t14;
980
+ $[19] !== deploymentTarget || $[20] !== formStateActorRef || $[21] !== formStateTransition || $[22] !== onCreate || $[23] !== onUpdate ? (t14 = async (formData) => {
981
+ const sanitizedFormData = sanitizeFormData(formData);
982
+ formStateTransition(deploymentTarget ? {
983
+ type: "UPDATE",
984
+ id: deploymentTarget._id,
985
+ formData: sanitizedFormData
986
+ } : {
987
+ type: "CREATE",
988
+ formData: sanitizedFormData
989
+ }), await toPromise(formStateActorRef);
990
+ const snapshot = formStateActorRef.getSnapshot(), {
991
+ document
992
+ } = snapshot.context;
993
+ document && (snapshot.matches("created") ? onCreate?.(document) : snapshot.matches("updated") && onUpdate?.(document));
994
+ }, $[19] = deploymentTarget, $[20] = formStateActorRef, $[21] = formStateTransition, $[22] = onCreate, $[23] = onUpdate, $[24] = t14) : t14 = $[24];
995
+ const onSubmit = t14;
996
+ let t15;
997
+ $[25] !== deploymentTarget || $[26] !== formStateActorRef || $[27] !== formStateTransition || $[28] !== onDelete ? (t15 = async () => {
998
+ if (!deploymentTarget)
999
+ return;
1000
+ const id = deploymentTarget._id;
1001
+ formStateTransition({
1002
+ type: "DELETE",
1003
+ id
1004
+ }), await toPromise(formStateActorRef), formStateActorRef.getSnapshot().matches("deleted") && onDelete?.(id);
1005
+ }, $[25] = deploymentTarget, $[26] = formStateActorRef, $[27] = formStateTransition, $[28] = onDelete, $[29] = t15) : t15 = $[29];
1006
+ const handleDelete = t15, t16 = deploymentTarget ? "space-between" : "flex-end";
1007
+ let t17;
1008
+ $[30] !== deploymentTarget || $[31] !== formState || $[32] !== formUpdating || $[33] !== handleDelete ? (t17 = deploymentTarget && /* @__PURE__ */ jsx(Button, { loading: formState.matches("deleting"), disabled: formUpdating, fontSize: 1, mode: "bleed", onClick: handleDelete, text: "Delete", tone: "critical" }), $[30] = deploymentTarget, $[31] = formState, $[32] = formUpdating, $[33] = handleDelete, $[34] = t17) : t17 = $[34];
1009
+ let t18;
1010
+ $[35] !== formState ? (t18 = formState.matches("creating") || formState.matches("updating"), $[35] = formState, $[36] = t18) : t18 = $[36];
1011
+ const t19 = !isDirty || !isValid;
1012
+ let t20;
1013
+ $[37] !== handleSubmit || $[38] !== onSubmit ? (t20 = handleSubmit(onSubmit), $[37] = handleSubmit, $[38] = onSubmit, $[39] = t20) : t20 = $[39];
1014
+ const t21 = deploymentTarget ? "Update and close" : "Create";
1015
+ let t22;
1016
+ $[40] !== t18 || $[41] !== t19 || $[42] !== t20 || $[43] !== t21 ? (t22 = /* @__PURE__ */ jsx(Button, { loading: t18, disabled: t19, fontSize: 1, onClick: t20, text: t21, tone: "primary" }), $[40] = t18, $[41] = t19, $[42] = t20, $[43] = t21, $[44] = t22) : t22 = $[44];
1017
+ let t23;
1018
+ $[45] !== t16 || $[46] !== t17 || $[47] !== t22 ? (t23 = /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsxs(Flex, { justify: t16, children: [
1019
+ t17,
1020
+ t22
1021
+ ] }) }), $[45] = t16, $[46] = t17, $[47] = t22, $[48] = t23) : t23 = $[48];
1022
+ const t24 = `${deploymentTarget ? "Edit" : "Create"} deployment target`;
1023
+ let t25;
1024
+ $[49] !== handleSubmit || $[50] !== onSubmit ? (t25 = handleSubmit(onSubmit), $[49] = handleSubmit, $[50] = onSubmit, $[51] = t25) : t25 = $[51];
1025
+ let t26;
1026
+ $[52] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t26 = /* @__PURE__ */ jsx("button", { "aria-label": "Submit", style: {
1027
+ display: "none"
1028
+ }, tabIndex: -1, type: "submit" }), $[52] = t26) : t26 = $[52];
1029
+ const t27 = errors?.name;
1030
+ let t28;
1031
+ $[53] !== register ? (t28 = register("name"), $[53] = register, $[54] = t28) : t28 = $[54];
1032
+ let t29;
1033
+ $[55] !== formUpdating || $[56] !== t27 || $[57] !== t28 ? (t29 = /* @__PURE__ */ jsx(FormFieldInputText, { disabled: formUpdating, description: "Name displayed in this plugin (e.g. production, staging)", error: t27, label: "Name", ...t28 }), $[55] = formUpdating, $[56] = t27, $[57] = t28, $[58] = t29) : t29 = $[58];
1034
+ const t30 = errors?.token;
1035
+ let t31;
1036
+ $[59] !== register ? (t31 = register("token"), $[59] = register, $[60] = t31) : t31 = $[60];
1037
+ let t32;
1038
+ $[61] !== formUpdating || $[62] !== t30 || $[63] !== t31 ? (t32 = /* @__PURE__ */ jsx(FormFieldInputText, { disabled: formUpdating, error: t30, label: "Vercel Account Token", ...t31 }), $[61] = formUpdating, $[62] = t30, $[63] = t31, $[64] = t32) : t32 = $[64];
1039
+ const t33 = errors?.projectId;
1040
+ let t34;
1041
+ $[65] !== register ? (t34 = register("projectId"), $[65] = register, $[66] = t34) : t34 = $[66];
1042
+ let t35;
1043
+ $[67] !== formUpdating || $[68] !== t33 || $[69] !== t34 ? (t35 = /* @__PURE__ */ jsx(FormFieldInputText, { disabled: formUpdating, error: t33, label: "Vercel Project ID", ...t34 }), $[67] = formUpdating, $[68] = t33, $[69] = t34, $[70] = t35) : t35 = $[70];
1044
+ const t36 = errors?.teamId;
1045
+ let t37;
1046
+ $[71] !== register ? (t37 = register("teamId"), $[71] = register, $[72] = t37) : t37 = $[72];
1047
+ let t38;
1048
+ $[73] !== formUpdating || $[74] !== t36 || $[75] !== t37 ? (t38 = /* @__PURE__ */ jsx(FormFieldInputText, { description: "Required only if your project is owned by a team account", disabled: formUpdating, error: t36, label: "Vercel Team ID (optional)", ...t37 }), $[73] = formUpdating, $[74] = t36, $[75] = t37, $[76] = t38) : t38 = $[76];
1049
+ const t39 = errors?.deployHook;
1050
+ let t40;
1051
+ $[77] !== register ? (t40 = register("deployHook"), $[77] = register, $[78] = t40) : t40 = $[78];
1052
+ let t41;
1053
+ $[79] !== formUpdating || $[80] !== t39 || $[81] !== t40 ? (t41 = /* @__PURE__ */ jsx(FormFieldInputText, { description: "Enter a valid deploy hook URL to enable manual deploys", disabled: formUpdating, error: t39, label: "Vercel Deploy Hook (optional)", ...t40 }), $[79] = formUpdating, $[80] = t39, $[81] = t40, $[82] = t41) : t41 = $[82];
1054
+ const t42 = errors?.deployLimit;
1055
+ let t43;
1056
+ $[83] !== register ? (t43 = register("deployLimit", {
1057
+ valueAsNumber: !0
1058
+ }), $[83] = register, $[84] = t43) : t43 = $[84];
1059
+ let t44;
1060
+ $[85] !== formUpdating || $[86] !== t42 || $[87] !== t43 ? (t44 = /* @__PURE__ */ jsx(FormFieldInputText, { disabled: formUpdating, error: t42, label: "Number of deploys to display", ...t43 }), $[85] = formUpdating, $[86] = t42, $[87] = t43, $[88] = t44) : t44 = $[88];
1061
+ let t45;
1062
+ $[89] !== t29 || $[90] !== t32 || $[91] !== t35 || $[92] !== t38 || $[93] !== t41 || $[94] !== t44 ? (t45 = /* @__PURE__ */ jsxs(Stack, { gap: 5, children: [
1063
+ t29,
1064
+ t32,
1065
+ t35,
1066
+ t38,
1067
+ t41,
1068
+ t44
1069
+ ] }), $[89] = t29, $[90] = t32, $[91] = t35, $[92] = t38, $[93] = t41, $[94] = t44, $[95] = t45) : t45 = $[95];
1070
+ let t46;
1071
+ $[96] !== t25 || $[97] !== t45 ? (t46 = /* @__PURE__ */ jsxs(Box, { as: "form", padding: 4, onSubmit: t25, children: [
1072
+ t26,
1073
+ t45
1074
+ ] }), $[96] = t25, $[97] = t45, $[98] = t46) : t46 = $[98];
1075
+ let t47;
1076
+ return $[99] !== onClose || $[100] !== t23 || $[101] !== t24 || $[102] !== t46 ? (t47 = /* @__PURE__ */ jsx(Dialog, { footer: t23, header: t24, id: "create", onClose, width: 1, zOffset: Z_INDEX_DIALOG, children: t46 }), $[99] = onClose, $[100] = t23, $[101] = t24, $[102] = t46, $[103] = t47) : t47 = $[103], t47;
1077
+ }, sortByTargetName = (items) => items.sort((a, b) => a.name > b.name ? 1 : a.name < b.name ? -1 : 0), deploymentTargetListMachine = setup({
1078
+ types: {},
1079
+ actions: {
1080
+ targetCreate: assign({
1081
+ results: ({
1082
+ context,
1083
+ event
1084
+ }) => (assertEvent(event, "CREATE"), sortByTargetName([...context.results, event.deploymentTarget]))
1085
+ }),
1086
+ targetDelete: assign({
1087
+ results: ({
1088
+ context,
1089
+ event
1090
+ }) => (assertEvent(event, "DELETE"), context.results.filter((target) => target._id !== event.id))
1091
+ }),
1092
+ targetUpdate: assign({
1093
+ results: ({
1094
+ context,
1095
+ event
1096
+ }) => {
1097
+ assertEvent(event, "UPDATE");
1098
+ const {
1099
+ deploymentTarget
1100
+ } = event, index = context.results.findIndex((target) => target._id === deploymentTarget._id), updatedResults = Object.assign([], context.results, {
1101
+ [index]: deploymentTarget
1102
+ });
1103
+ return sortByTargetName(updatedResults);
1104
+ }
1105
+ })
1106
+ },
1107
+ guards: {
1108
+ hasData: ({
1109
+ context
1110
+ }) => context?.results?.length > 0,
1111
+ hasNoData: ({
1112
+ context
1113
+ }) => context?.results?.length === 0
1114
+ },
1115
+ actors: {
1116
+ "fetch data": fromPromise(({
1117
+ input,
1118
+ signal
1119
+ }) => input.client.fetch("*[_type == $type] | order(name asc)", {
1120
+ type: DEPLOYMENT_TARGET_DOCUMENT_TYPE
1121
+ }, {
1122
+ signal
1123
+ }).catch((error) => {
1124
+ if (error instanceof Error && error.name === "AbortError")
1125
+ return [];
1126
+ throw console.error("Failed to fetch deployment targets", error), error;
1127
+ }))
1128
+ }
1129
+ }).createMachine({
1130
+ /** @xstate-layout N4IgpgJg5mDOIC5QAoC2BDAxgCwJYDswBKAOgAcx8ICoBiCAe0JIIDcGBrMEgMzABccAEXT90AbQAMAXUSgyDWLn64mckAA9EAZkkBOEgHYAjAA5DAFgBsFgEwnJAVkMAaEAE9Ep4yUeT-klbGesbaoYaGAL6RbmhYeISkFFQ0tGAATukM6eQANqI82ai8AsKiEjLqCkoqakiaOvpGZpY29sZOrh6IxpYkFo5h2oaOpnqOxraSFtGxGDgExCTpYOgQ7rQAwgBKAKIAggAqu1Ky9dXKqvjqWggWHSS9eoaS9ibao6aObp4IVh8kL56OzGII2PT-WYgOILRLLVbrWhCXYAGV2x1OVUUlzqoFu90kRm8tlM2gsL1eJJ+iEGBj0gVsFm0YWmVkctihMISSxWaw2AFUAApCI4nSrnbG1a71fGSUz9WzBezTFWvb7dO5MkjjMITZykwxjTnzbmkXnrEgAV3wHHwDAA7vhaJiJTUrjces9fFZGc9TLYrGqA9SEM9CcT7sznH5HHpjfFFmaEe4rTa7Y7ncYzvJJe6ZZ7DN7fYaA0GrCHvD4xs4S+yPnGYtCTYn4XySPblNgRGJneKc27cQ0EI4BiQ2T77noAzXyxrTIESGFGd4rP9DONTPHYTzk+3OwxLfxu+he9mQBcpR7h6Px4ylWyIrPfl9bIvJhZJIYA-7zFZoo27QgOB1C5RMsQHaU8UQABaYIQ2gv9G1AuFkmofAoHAnFIKHOwQz0bRtUMcd-j8WwpnuLdTVbdZMMvfMEFsPQQxMeViQmZkLC+f0oiQ5s4XNFNrVtB1sIvPMoIQCIK1BIsmXXWxtFJcZKJbAS934Ltylo8ShysfDHl9PRxjlekrC6Z9BhIBk5MkXpzFBFT+N3DsNIPI8tNdLCr20L0Wmscw5V0e5pMJYwBiI8kwrDRC5gTOEeHQXBckgbTB1uZwQw6RwrEBd9bEcQZYzsRDoiAA */
1131
+ context: ({
1132
+ input
1133
+ }) => ({
1134
+ client: input.client,
1135
+ results: []
1136
+ }),
1137
+ initial: "pending",
1138
+ states: {
1139
+ pending: {
1140
+ invoke: {
1141
+ src: "fetch data",
1142
+ id: "fetchData",
1143
+ input: ({
1144
+ context
1145
+ }) => ({
1146
+ client: context.client
1147
+ }),
1148
+ onDone: {
1149
+ actions: assign({
1150
+ results: ({
1151
+ event
1152
+ }) => event.output
1153
+ }),
1154
+ target: "ready"
1155
+ },
1156
+ onError: {
1157
+ target: "failed"
1158
+ }
1159
+ }
1160
+ },
1161
+ ready: {
1162
+ initial: "unknown",
1163
+ on: {
1164
+ CREATE: {
1165
+ actions: "targetCreate"
1166
+ },
1167
+ DELETE: {
1168
+ actions: "targetDelete"
1169
+ },
1170
+ UPDATE: {
1171
+ actions: "targetUpdate"
1172
+ }
1173
+ },
1174
+ states: {
1175
+ unknown: {
1176
+ always: [{
1177
+ target: "withData",
1178
+ guard: "hasData"
1179
+ }, {
1180
+ target: "withoutData",
1181
+ guard: "hasNoData"
1182
+ }]
1183
+ },
1184
+ withData: {
1185
+ always: [{
1186
+ target: "withoutData",
1187
+ guard: "hasNoData"
1188
+ }]
1189
+ },
1190
+ withoutData: {
1191
+ always: [{
1192
+ target: "withData",
1193
+ guard: "hasData"
1194
+ }]
1195
+ }
1196
+ }
1197
+ },
1198
+ failed: {
1199
+ type: "final"
1200
+ }
1201
+ }
1202
+ }), dialogMachine = setup({
1203
+ types: {
1204
+ context: {},
1205
+ events: {}
1206
+ },
1207
+ actions: {
1208
+ setEditDeploymentTarget: assign({
1209
+ editDeploymentTarget: ({
1210
+ event
1211
+ }) => (assertEvent(event, "EDIT"), event.deploymentTarget)
1212
+ })
1213
+ }
1214
+ }).createMachine({
1215
+ /** @xstate-layout N4IgpgJg5mDOIC5QAoC2BDAxgCwJYDswBKAOlwgBswBiAYQCUBRAQQBVGBtABgF1FQADgHtYuAC64h+fiAAeiAEwKArCQCcANgAcAdmUbNOhVx0BGLQBoQAT0SmAzApJcXXexoAsW5fbWaFAL4BVmhYeISk5FTUjAAiAJKs3HxIIMKiElIy8ghKqpq6+obGZpY2ivb2zq4e5moeXKZc3kEhGDgExCSQ4nQAMgDyAMqcvDLp4pLSqTn2DSQefn7uyq5aWvZWtgjmTqsuvnU6XMoK9q0goR0RJJgATmDoYjS0gyPJ4yKTWTOIc1wLJZqFZrDZbRBaUwkfZuew6SFcepuILBED4IQQOAyK7hYifDJTbKIAC0GnBCFJFxxnUilDA+O+01AOQ8CnJGxIGn29lMpjUxhcCh0VPauNIPTEDMyTLkiA8PhIxh5Cg8DS8pgM5L5UOalSMah0cP05hFYRptweT3pqQm0qJCHlVSVphVashmvKCDUAN17j0XNMqrUyhRASAA */
1216
+ context: {
1217
+ editDeploymentTarget: void 0
1218
+ },
1219
+ initial: "idle",
1220
+ states: {
1221
+ idle: {
1222
+ entry: assign({
1223
+ editDeploymentTarget: () => {
1224
+ }
1225
+ }),
1226
+ on: {
1227
+ CREATE: {
1228
+ target: "create"
1229
+ },
1230
+ EDIT: {
1231
+ actions: "setEditDeploymentTarget",
1232
+ target: "edit"
1233
+ }
1234
+ }
1235
+ },
1236
+ edit: {
1237
+ on: {
1238
+ CLOSE: {
1239
+ target: "idle"
1240
+ }
1241
+ }
1242
+ },
1243
+ create: {
1244
+ on: {
1245
+ CLOSE: {
1246
+ target: "idle"
1247
+ }
1248
+ }
1249
+ }
1250
+ }
1251
+ }), queryClient = new QueryClient({
1252
+ defaultOptions: {
1253
+ queries: {
1254
+ gcTime: 0,
1255
+ staleTime: 0
1256
+ }
1257
+ }
1258
+ }), Widget = () => {
1259
+ const $ = c(53), client = useSanityClient();
1260
+ let t0;
1261
+ $[0] !== client ? (t0 = {
1262
+ input: {
1263
+ client
1264
+ }
1265
+ }, $[0] = client, $[1] = t0) : t0 = $[1];
1266
+ const [deploymentTargetListState, deploymentTargetListStateTransition] = useMachine(deploymentTargetListMachine, t0), [dialogState, dialogStateTransition] = useMachine(dialogMachine);
1267
+ let t1;
1268
+ $[2] !== dialogStateTransition ? (t1 = () => {
1269
+ dialogStateTransition({
1270
+ type: "CLOSE"
1271
+ });
1272
+ }, $[2] = dialogStateTransition, $[3] = t1) : t1 = $[3];
1273
+ const handleDialogClose = t1;
1274
+ let t2;
1275
+ $[4] !== dialogStateTransition ? (t2 = () => {
1276
+ dialogStateTransition({
1277
+ type: "CREATE"
1278
+ });
1279
+ }, $[4] = dialogStateTransition, $[5] = t2) : t2 = $[5];
1280
+ const handleDialogShowCreate = t2;
1281
+ let t3;
1282
+ $[6] !== dialogStateTransition ? (t3 = (deploymentTarget) => {
1283
+ dialogStateTransition({
1284
+ type: "EDIT",
1285
+ deploymentTarget
1286
+ });
1287
+ }, $[6] = dialogStateTransition, $[7] = t3) : t3 = $[7];
1288
+ const handleDialogShowEdit = t3;
1289
+ let t4;
1290
+ $[8] !== deploymentTargetListStateTransition ? (t4 = (deploymentTarget_0) => {
1291
+ deploymentTargetListStateTransition({
1292
+ type: "CREATE",
1293
+ deploymentTarget: deploymentTarget_0
1294
+ });
1295
+ }, $[8] = deploymentTargetListStateTransition, $[9] = t4) : t4 = $[9];
1296
+ const handleTargetCreate = t4;
1297
+ let t5;
1298
+ $[10] !== deploymentTargetListStateTransition ? (t5 = (id) => {
1299
+ deploymentTargetListStateTransition({
1300
+ type: "DELETE",
1301
+ id
1302
+ });
1303
+ }, $[10] = deploymentTargetListStateTransition, $[11] = t5) : t5 = $[11];
1304
+ const handleTargetDelete = t5;
1305
+ let t6;
1306
+ $[12] !== deploymentTargetListStateTransition ? (t6 = (deploymentTarget_1) => {
1307
+ deploymentTargetListStateTransition({
1308
+ type: "UPDATE",
1309
+ deploymentTarget: deploymentTarget_1
1310
+ });
1311
+ }, $[12] = deploymentTargetListStateTransition, $[13] = t6) : t6 = $[13];
1312
+ const handleTargetUpdate = t6;
1313
+ let t7;
1314
+ $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t7 = {
1315
+ overflow: "hidden "
1316
+ }, $[14] = t7) : t7 = $[14];
1317
+ let t8;
1318
+ $[15] !== deploymentTargetListState ? (t8 = /* @__PURE__ */ jsx(StateDebug, { name: "List", state: deploymentTargetListState }), $[15] = deploymentTargetListState, $[16] = t8) : t8 = $[16];
1319
+ let t9;
1320
+ $[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx(Text, { size: 5, weight: "semibold", children: "Vercel deployments" }), $[17] = t9) : t9 = $[17];
1321
+ let t10;
1322
+ $[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "Create new deployment target" }) }), $[18] = t10) : t10 = $[18];
1323
+ let t11;
1324
+ $[19] !== handleDialogShowCreate ? (t11 = /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", paddingX: 3, paddingY: 2, children: [
1325
+ t9,
1326
+ /* @__PURE__ */ jsx(Tooltip, { content: t10, placement: "left", children: /* @__PURE__ */ jsx(Button, { fontSize: 1, icon: AddIcon, onClick: handleDialogShowCreate, mode: "bleed" }) })
1327
+ ] }), $[19] = handleDialogShowCreate, $[20] = t11) : t11 = $[20];
1328
+ let t12;
1329
+ $[21] !== deploymentTargetListState ? (t12 = deploymentTargetListState.matches("pending") && /* @__PURE__ */ jsx(Box, { paddingX: 3, paddingY: 4, children: /* @__PURE__ */ jsx(Text, { children: "Loading..." }) }), $[21] = deploymentTargetListState, $[22] = t12) : t12 = $[22];
1330
+ let t13;
1331
+ $[23] !== deploymentTargetListState || $[24] !== handleDialogShowCreate ? (t13 = deploymentTargetListState.matches({
1332
+ ready: "withoutData"
1333
+ }) && /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, paddingX: 3, paddingY: 4, children: [
1334
+ /* @__PURE__ */ jsx(Text, { children: "No deployment targets found." }),
1335
+ /* @__PURE__ */ jsx(Button, { fontSize: 1, mode: "ghost", onClick: handleDialogShowCreate, text: "Create a new target" })
1336
+ ] }), $[23] = deploymentTargetListState, $[24] = handleDialogShowCreate, $[25] = t13) : t13 = $[25];
1337
+ let t14;
1338
+ $[26] !== deploymentTargetListState || $[27] !== handleDialogShowEdit ? (t14 = deploymentTargetListState.matches({
1339
+ ready: "withData"
1340
+ }) && /* @__PURE__ */ jsx(DeploymentTargets, { items: deploymentTargetListState.context.results, onDialogEdit: handleDialogShowEdit }), $[26] = deploymentTargetListState, $[27] = handleDialogShowEdit, $[28] = t14) : t14 = $[28];
1341
+ let t15;
1342
+ $[29] !== deploymentTargetListState ? (t15 = deploymentTargetListState.matches("failed") && /* @__PURE__ */ jsx(Box, { paddingX: 3, paddingY: 4, children: /* @__PURE__ */ jsx(Text, { children: "Failed to retrieve deployment targets. Please check the developer console log for more information." }) }), $[29] = deploymentTargetListState, $[30] = t15) : t15 = $[30];
1343
+ let t16;
1344
+ $[31] !== t12 || $[32] !== t13 || $[33] !== t14 || $[34] !== t15 ? (t16 = /* @__PURE__ */ jsxs(Box, { children: [
1345
+ t12,
1346
+ t13,
1347
+ t14,
1348
+ t15
1349
+ ] }), $[31] = t12, $[32] = t13, $[33] = t14, $[34] = t15, $[35] = t16) : t16 = $[35];
1350
+ let t17;
1351
+ $[36] !== t11 || $[37] !== t16 || $[38] !== t8 ? (t17 = /* @__PURE__ */ jsxs(Card, { radius: 2, style: t7, children: [
1352
+ t8,
1353
+ t11,
1354
+ t16
1355
+ ] }), $[36] = t11, $[37] = t16, $[38] = t8, $[39] = t17) : t17 = $[39];
1356
+ let t18;
1357
+ $[40] !== dialogState || $[41] !== handleDialogClose || $[42] !== handleTargetCreate ? (t18 = dialogState.matches("create") && /* @__PURE__ */ jsx(DialogForm, { onClose: handleDialogClose, onCreate: handleTargetCreate }), $[40] = dialogState, $[41] = handleDialogClose, $[42] = handleTargetCreate, $[43] = t18) : t18 = $[43];
1358
+ let t19;
1359
+ $[44] !== dialogState || $[45] !== handleDialogClose || $[46] !== handleTargetDelete || $[47] !== handleTargetUpdate ? (t19 = dialogState.matches("edit") && /* @__PURE__ */ jsx(DialogForm, { deploymentTarget: dialogState.context.editDeploymentTarget, onClose: handleDialogClose, onDelete: handleTargetDelete, onUpdate: handleTargetUpdate }), $[44] = dialogState, $[45] = handleDialogClose, $[46] = handleTargetDelete, $[47] = handleTargetUpdate, $[48] = t19) : t19 = $[48];
1360
+ let t20;
1361
+ return $[49] !== t17 || $[50] !== t18 || $[51] !== t19 ? (t20 = /* @__PURE__ */ jsx(ToastProvider, { zOffset: Z_INDEX_TOAST_PROVIDER, children: /* @__PURE__ */ jsxs(QueryClientProvider, { client: queryClient, children: [
1362
+ t17,
1363
+ t18,
1364
+ t19
1365
+ ] }) }), $[49] = t17, $[50] = t18, $[51] = t19, $[52] = t20) : t20 = $[52], t20;
1366
+ };
1367
+ TimeAgo.addDefaultLocale(en);
1368
+ function vercelWidget(config = {}) {
1369
+ return {
1370
+ name: "vercel",
1371
+ component: Widget,
1372
+ layout: config.layout ?? {
1373
+ width: "full"
1374
+ }
1375
+ };
1376
+ }
1377
+ export {
1378
+ vercelWidget
1379
+ };
1380
+ //# sourceMappingURL=index.js.map