sanity-plugin-mux-input 2.0.6-debug.0 → 2.0.6-debug.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks/Input-63bcfbf4.cjs +3543 -0
- package/lib/_chunks/Input-63bcfbf4.cjs.map +1 -0
- package/lib/_chunks/Input-97c1d2de.js +3543 -0
- package/lib/_chunks/Input-97c1d2de.js.map +1 -0
- package/lib/_chunks/{Preview-c090d878.js → Preview-28bff96a.cjs} +2 -2
- package/lib/_chunks/Preview-28bff96a.cjs.map +1 -0
- package/lib/_chunks/{Preview-63d97f42.js → Preview-5d0896e2.js} +2 -2
- package/lib/_chunks/{Preview-63d97f42.js.map → Preview-5d0896e2.js.map} +1 -1
- package/lib/_chunks/{VideoSource.styled-5aa3e3e6.js → VideoSource.styled-3c581658.js} +2 -2
- package/lib/_chunks/{VideoSource.styled-5aa3e3e6.js.map → VideoSource.styled-3c581658.js.map} +1 -1
- package/lib/_chunks/{VideoSource.styled-1a8b1b24.js → VideoSource.styled-a794bf69.cjs} +2 -2
- package/lib/_chunks/VideoSource.styled-a794bf69.cjs.map +1 -0
- package/lib/_chunks/{index-748efd6b.js → index-08de2a62.cjs} +3 -3
- package/lib/_chunks/index-08de2a62.cjs.map +1 -0
- package/lib/_chunks/{index-e2c54741.js → index-d592bb71.js} +3 -3
- package/lib/_chunks/{index-e2c54741.js.map → index-d592bb71.js.map} +1 -1
- package/lib/index.cjs +10 -0
- package/lib/index.cjs.js +6 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.js +2 -9
- package/lib/index.js.map +1 -1
- package/package.json +12 -7
- package/src/components/Player.tsx +0 -1
- package/lib/_chunks/Input-080b5b98.js +0 -2648
- package/lib/_chunks/Input-080b5b98.js.map +0 -1
- package/lib/_chunks/Input-0c9eb69e.js +0 -2679
- package/lib/_chunks/Input-0c9eb69e.js.map +0 -1
- package/lib/_chunks/Preview-c090d878.js.map +0 -1
- package/lib/_chunks/VideoSource.styled-1a8b1b24.js.map +0 -1
- package/lib/_chunks/index-748efd6b.js.map +0 -1
- package/lib/index.esm.js +0 -3
- package/lib/index.esm.js.map +0 -1
|
@@ -1,2679 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
|
|
4
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var VideoSource_styled = require('./VideoSource.styled-1a8b1b24.js');
|
|
8
|
-
var sanity = require('sanity');
|
|
9
|
-
var useSWR = require('swr');
|
|
10
|
-
var index = require('./index-748efd6b.js');
|
|
11
|
-
var rxjs = require('rxjs');
|
|
12
|
-
var operators = require('rxjs/operators');
|
|
13
|
-
var uuid = require('@sanity/uuid');
|
|
14
|
-
var UpChunk = require('@mux/upchunk');
|
|
15
|
-
var ui = require('@sanity/ui');
|
|
16
|
-
var icons = require('@sanity/icons');
|
|
17
|
-
var motion = require('motion');
|
|
18
|
-
var styled = require('styled-components');
|
|
19
|
-
var useDevicePixelRatio = require('use-device-pixel-ratio');
|
|
20
|
-
var MuxVideo = require('@mux/mux-video-react');
|
|
21
|
-
var react = require('media-chrome/dist/react');
|
|
22
|
-
var reactIs = require('react-is');
|
|
23
|
-
var suspendReact = require('suspend-react');
|
|
24
|
-
function _interopDefaultCompat(e) {
|
|
25
|
-
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
26
|
-
default: e
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function _interopNamespaceCompat(e) {
|
|
30
|
-
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
31
|
-
var n = Object.create(null);
|
|
32
|
-
if (e) {
|
|
33
|
-
Object.keys(e).forEach(function (k) {
|
|
34
|
-
if (k !== 'default') {
|
|
35
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
36
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return e[k];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
n.default = e;
|
|
46
|
-
return Object.freeze(n);
|
|
47
|
-
}
|
|
48
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
49
|
-
var useSWR__default = /*#__PURE__*/_interopDefaultCompat(useSWR);
|
|
50
|
-
var UpChunk__namespace = /*#__PURE__*/_interopNamespaceCompat(UpChunk);
|
|
51
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
52
|
-
var MuxVideo__default = /*#__PURE__*/_interopDefaultCompat(MuxVideo);
|
|
53
|
-
function useDialogState() {
|
|
54
|
-
return React.useState(false);
|
|
55
|
-
}
|
|
56
|
-
const useMuxPolling = asset => {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
const client = VideoSource_styled.useClient();
|
|
59
|
-
const projectId = sanity.useProjectId();
|
|
60
|
-
const dataset = sanity.useDataset();
|
|
61
|
-
const shouldFetch = React.useMemo(() => {
|
|
62
|
-
var _a2, _b2;
|
|
63
|
-
return !!(asset == null ? void 0 : asset.assetId) && ((asset == null ? void 0 : asset.status) === "preparing" || ((_b2 = (_a2 = asset == null ? void 0 : asset.data) == null ? void 0 : _a2.static_renditions) == null ? void 0 : _b2.status) === "preparing");
|
|
64
|
-
}, [asset == null ? void 0 : asset.assetId, (_b = (_a = asset == null ? void 0 : asset.data) == null ? void 0 : _a.static_renditions) == null ? void 0 : _b.status, asset == null ? void 0 : asset.status]);
|
|
65
|
-
return useSWR__default.default(shouldFetch ? "/".concat(projectId, "/addons/mux/assets/").concat(dataset, "/data/").concat(asset == null ? void 0 : asset.assetId) : null, async () => {
|
|
66
|
-
const {
|
|
67
|
-
data
|
|
68
|
-
} = await client.request({
|
|
69
|
-
url: "/addons/mux/assets/".concat(dataset, "/data/").concat(asset.assetId),
|
|
70
|
-
withCredentials: true,
|
|
71
|
-
method: "GET"
|
|
72
|
-
});
|
|
73
|
-
client.patch(asset._id).set({
|
|
74
|
-
status: data.status,
|
|
75
|
-
data
|
|
76
|
-
}).commit({
|
|
77
|
-
returnDocuments: false
|
|
78
|
-
});
|
|
79
|
-
}, {
|
|
80
|
-
refreshInterval: 2e3,
|
|
81
|
-
refreshWhenHidden: true,
|
|
82
|
-
dedupingInterval: 1e3
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const path = ["token", "secretKey", "enableSignedUrls", "signingKeyId", "signingKeyPrivate"];
|
|
86
|
-
const useSecretsDocumentValues = () => {
|
|
87
|
-
const {
|
|
88
|
-
error,
|
|
89
|
-
isLoading,
|
|
90
|
-
value
|
|
91
|
-
} = sanity.useDocumentValues(index.muxSecretsDocumentId, path);
|
|
92
|
-
const cache = React.useMemo(() => {
|
|
93
|
-
const exists = Boolean(value);
|
|
94
|
-
const secrets = {
|
|
95
|
-
token: (value == null ? void 0 : value.token) || null,
|
|
96
|
-
secretKey: (value == null ? void 0 : value.secretKey) || null,
|
|
97
|
-
enableSignedUrls: (value == null ? void 0 : value.enableSignedUrls) || false,
|
|
98
|
-
signingKeyId: (value == null ? void 0 : value.signingKeyId) || null,
|
|
99
|
-
signingKeyPrivate: (value == null ? void 0 : value.signingKeyPrivate) || null
|
|
100
|
-
};
|
|
101
|
-
return {
|
|
102
|
-
isInitialSetup: !exists,
|
|
103
|
-
needsSetup: !(secrets == null ? void 0 : secrets.token) || !(secrets == null ? void 0 : secrets.secretKey),
|
|
104
|
-
secrets
|
|
105
|
-
};
|
|
106
|
-
}, [value]);
|
|
107
|
-
return {
|
|
108
|
-
error,
|
|
109
|
-
isLoading,
|
|
110
|
-
value: cache
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
function createUpChunkObservable(uuid, uploadUrl, source) {
|
|
114
|
-
return new rxjs.Observable(subscriber => {
|
|
115
|
-
const upchunk = UpChunk__namespace.createUpload({
|
|
116
|
-
endpoint: uploadUrl,
|
|
117
|
-
file: source,
|
|
118
|
-
dynamicChunkSize: true
|
|
119
|
-
// changes the chunk size based on network speeds
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const successHandler = () => {
|
|
123
|
-
subscriber.next({
|
|
124
|
-
type: "success",
|
|
125
|
-
id: uuid
|
|
126
|
-
});
|
|
127
|
-
subscriber.complete();
|
|
128
|
-
};
|
|
129
|
-
const errorHandler = data => subscriber.error(new Error(data.detail.message));
|
|
130
|
-
const progressHandler = data => {
|
|
131
|
-
return subscriber.next({
|
|
132
|
-
type: "progress",
|
|
133
|
-
percent: data.detail
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
const offlineHandler = () => {
|
|
137
|
-
upchunk.pause();
|
|
138
|
-
subscriber.next({
|
|
139
|
-
type: "pause",
|
|
140
|
-
id: uuid
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
const onlineHandler = () => {
|
|
144
|
-
upchunk.resume();
|
|
145
|
-
subscriber.next({
|
|
146
|
-
type: "resume",
|
|
147
|
-
id: uuid
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
upchunk.on("success", successHandler);
|
|
151
|
-
upchunk.on("error", errorHandler);
|
|
152
|
-
upchunk.on("progress", progressHandler);
|
|
153
|
-
upchunk.on("offline", offlineHandler);
|
|
154
|
-
upchunk.on("online", onlineHandler);
|
|
155
|
-
return () => upchunk.abort();
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function deleteAsset(client, assetId) {
|
|
159
|
-
const {
|
|
160
|
-
dataset
|
|
161
|
-
} = client.config();
|
|
162
|
-
return client.request({
|
|
163
|
-
url: "/addons/mux/assets/".concat(dataset, "/").concat(assetId),
|
|
164
|
-
withCredentials: true,
|
|
165
|
-
method: "DELETE"
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
function getAsset(client, assetId) {
|
|
169
|
-
const {
|
|
170
|
-
dataset
|
|
171
|
-
} = client.config();
|
|
172
|
-
return client.request({
|
|
173
|
-
url: "/addons/mux/assets/".concat(dataset, "/data/").concat(assetId),
|
|
174
|
-
withCredentials: true,
|
|
175
|
-
method: "GET"
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate) {
|
|
179
|
-
const doc = {
|
|
180
|
-
_id: "secrets.mux",
|
|
181
|
-
_type: "mux.apiKey",
|
|
182
|
-
token,
|
|
183
|
-
secretKey,
|
|
184
|
-
enableSignedUrls,
|
|
185
|
-
signingKeyId,
|
|
186
|
-
signingKeyPrivate
|
|
187
|
-
};
|
|
188
|
-
return client.createOrReplace(doc);
|
|
189
|
-
}
|
|
190
|
-
function createSigningKeys(client) {
|
|
191
|
-
const {
|
|
192
|
-
dataset
|
|
193
|
-
} = client.config();
|
|
194
|
-
return client.request({
|
|
195
|
-
url: "/addons/mux/signing-keys/".concat(dataset),
|
|
196
|
-
withCredentials: true,
|
|
197
|
-
method: "POST"
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
function testSecrets(client) {
|
|
201
|
-
const {
|
|
202
|
-
dataset
|
|
203
|
-
} = client.config();
|
|
204
|
-
return client.request({
|
|
205
|
-
url: "/addons/mux/secrets/".concat(dataset, "/test"),
|
|
206
|
-
withCredentials: true,
|
|
207
|
-
method: "GET"
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
async function haveValidSigningKeys(client, signingKeyId, signingKeyPrivate) {
|
|
211
|
-
if (!(signingKeyId && signingKeyPrivate)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
const {
|
|
215
|
-
dataset
|
|
216
|
-
} = client.config();
|
|
217
|
-
try {
|
|
218
|
-
const res = await client.request({
|
|
219
|
-
url: "/addons/mux/signing-keys/".concat(dataset, "/").concat(signingKeyId),
|
|
220
|
-
withCredentials: true,
|
|
221
|
-
method: "GET"
|
|
222
|
-
});
|
|
223
|
-
return !!(res.data && res.data.id);
|
|
224
|
-
} catch (e) {
|
|
225
|
-
console.error("Error fetching signingKeyId", signingKeyId, "assuming it is not valid");
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function testSecretsObservable(client) {
|
|
230
|
-
const {
|
|
231
|
-
dataset
|
|
232
|
-
} = client.config();
|
|
233
|
-
return rxjs.defer(() => client.observable.request({
|
|
234
|
-
url: "/addons/mux/secrets/".concat(dataset, "/test"),
|
|
235
|
-
withCredentials: true,
|
|
236
|
-
method: "GET"
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
function cancelUpload(client, uuid) {
|
|
240
|
-
return client.observable.request({
|
|
241
|
-
url: "/addons/mux/uploads/".concat(client.clientConfig.dataset, "/").concat(uuid),
|
|
242
|
-
withCredentials: true,
|
|
243
|
-
method: "DELETE"
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
function uploadUrl(config, client, url) {
|
|
247
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
248
|
-
return testUrl(url).pipe(operators.switchMap(validUrl => {
|
|
249
|
-
return rxjs.concat(rxjs.of({
|
|
250
|
-
type: "url",
|
|
251
|
-
url: validUrl
|
|
252
|
-
}), testSecretsObservable(client).pipe(operators.switchMap(json => {
|
|
253
|
-
if (!json || !json.status) {
|
|
254
|
-
return rxjs.throwError(new Error("Invalid credentials"));
|
|
255
|
-
}
|
|
256
|
-
const uuid$1 = uuid.uuid();
|
|
257
|
-
const {
|
|
258
|
-
enableSignedUrls
|
|
259
|
-
} = options;
|
|
260
|
-
const muxBody = {
|
|
261
|
-
input: validUrl,
|
|
262
|
-
playback_policy: [enableSignedUrls ? "signed" : "public"],
|
|
263
|
-
mp4_support: config.mp4_support
|
|
264
|
-
};
|
|
265
|
-
const query = {
|
|
266
|
-
muxBody: JSON.stringify(muxBody),
|
|
267
|
-
filename: validUrl.split("/").slice(-1)[0]
|
|
268
|
-
};
|
|
269
|
-
const dataset = client.clientConfig.dataset;
|
|
270
|
-
return rxjs.defer(() => client.observable.request({
|
|
271
|
-
url: "/addons/mux/assets/".concat(dataset),
|
|
272
|
-
withCredentials: true,
|
|
273
|
-
method: "POST",
|
|
274
|
-
headers: {
|
|
275
|
-
"MUX-Proxy-UUID": uuid$1,
|
|
276
|
-
"Content-Type": "application/json"
|
|
277
|
-
},
|
|
278
|
-
query
|
|
279
|
-
})).pipe(operators.mergeMap(result => {
|
|
280
|
-
const asset = result && result.results && result.results[0] && result.results[0].document || null;
|
|
281
|
-
if (!asset) {
|
|
282
|
-
return rxjs.throwError(new Error("No asset document returned"));
|
|
283
|
-
}
|
|
284
|
-
return rxjs.of({
|
|
285
|
-
type: "success",
|
|
286
|
-
id: uuid$1,
|
|
287
|
-
asset
|
|
288
|
-
});
|
|
289
|
-
}));
|
|
290
|
-
})));
|
|
291
|
-
}));
|
|
292
|
-
}
|
|
293
|
-
function uploadFile(config, client, file) {
|
|
294
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
295
|
-
return testFile(file).pipe(operators.switchMap(fileOptions => {
|
|
296
|
-
return rxjs.concat(rxjs.of({
|
|
297
|
-
type: "file",
|
|
298
|
-
file: fileOptions
|
|
299
|
-
}), testSecretsObservable(client).pipe(operators.switchMap(json => {
|
|
300
|
-
if (!json || !json.status) {
|
|
301
|
-
return rxjs.throwError(new Error("Invalid credentials"));
|
|
302
|
-
}
|
|
303
|
-
const uuid$1 = uuid.uuid();
|
|
304
|
-
const {
|
|
305
|
-
enableSignedUrls
|
|
306
|
-
} = options;
|
|
307
|
-
const body = {
|
|
308
|
-
mp4_support: config.mp4_support,
|
|
309
|
-
playback_policy: [enableSignedUrls ? "signed" : "public"]
|
|
310
|
-
};
|
|
311
|
-
return rxjs.concat(rxjs.of({
|
|
312
|
-
type: "uuid",
|
|
313
|
-
uuid: uuid$1
|
|
314
|
-
}), rxjs.defer(() => client.observable.request({
|
|
315
|
-
url: "/addons/mux/uploads/".concat(client.clientConfig.dataset),
|
|
316
|
-
withCredentials: true,
|
|
317
|
-
method: "POST",
|
|
318
|
-
headers: {
|
|
319
|
-
"MUX-Proxy-UUID": uuid$1,
|
|
320
|
-
"Content-Type": "application/json"
|
|
321
|
-
},
|
|
322
|
-
body
|
|
323
|
-
})).pipe(operators.mergeMap(result => {
|
|
324
|
-
return createUpChunkObservable(uuid$1, result.upload.url, file).pipe(
|
|
325
|
-
// eslint-disable-next-line no-warning-comments
|
|
326
|
-
// @TODO type the observable events
|
|
327
|
-
// eslint-disable-next-line max-nested-callbacks
|
|
328
|
-
operators.mergeMap(event => {
|
|
329
|
-
if (event.type !== "success") {
|
|
330
|
-
return rxjs.of(event);
|
|
331
|
-
}
|
|
332
|
-
return rxjs.from(updateAssetDocumentFromUpload(client, uuid$1)).pipe(
|
|
333
|
-
// eslint-disable-next-line max-nested-callbacks
|
|
334
|
-
operators.mergeMap(doc => rxjs.of({
|
|
335
|
-
...event,
|
|
336
|
-
asset: doc
|
|
337
|
-
})));
|
|
338
|
-
}),
|
|
339
|
-
// eslint-disable-next-line max-nested-callbacks
|
|
340
|
-
operators.catchError(err => {
|
|
341
|
-
return cancelUpload(client, uuid$1).pipe(operators.mergeMapTo(rxjs.throwError(err)));
|
|
342
|
-
}));
|
|
343
|
-
})));
|
|
344
|
-
})));
|
|
345
|
-
}));
|
|
346
|
-
}
|
|
347
|
-
function getUpload(client, assetId) {
|
|
348
|
-
const {
|
|
349
|
-
dataset
|
|
350
|
-
} = client.config();
|
|
351
|
-
return client.request({
|
|
352
|
-
url: "/addons/mux/uploads/".concat(dataset, "/").concat(assetId),
|
|
353
|
-
withCredentials: true,
|
|
354
|
-
method: "GET"
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
function pollUpload(client, uuid) {
|
|
358
|
-
const maxTries = 10;
|
|
359
|
-
let pollInterval;
|
|
360
|
-
let tries = 0;
|
|
361
|
-
let assetId;
|
|
362
|
-
let upload;
|
|
363
|
-
return new Promise((resolve, reject) => {
|
|
364
|
-
pollInterval = setInterval(async () => {
|
|
365
|
-
try {
|
|
366
|
-
upload = await getUpload(client, uuid);
|
|
367
|
-
} catch (err) {
|
|
368
|
-
reject(err);
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
assetId = upload && upload.data && upload.data.asset_id;
|
|
372
|
-
if (assetId) {
|
|
373
|
-
clearInterval(pollInterval);
|
|
374
|
-
resolve(upload);
|
|
375
|
-
}
|
|
376
|
-
if (tries > maxTries) {
|
|
377
|
-
clearInterval(pollInterval);
|
|
378
|
-
reject(new Error("Upload did not finish"));
|
|
379
|
-
}
|
|
380
|
-
tries++;
|
|
381
|
-
}, 2e3);
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
async function updateAssetDocumentFromUpload(client, uuid) {
|
|
385
|
-
let upload;
|
|
386
|
-
let asset;
|
|
387
|
-
try {
|
|
388
|
-
upload = await pollUpload(client, uuid);
|
|
389
|
-
} catch (err) {
|
|
390
|
-
return Promise.reject(err);
|
|
391
|
-
}
|
|
392
|
-
try {
|
|
393
|
-
asset = await getAsset(client, upload.data.asset_id);
|
|
394
|
-
} catch (err) {
|
|
395
|
-
return Promise.reject(err);
|
|
396
|
-
}
|
|
397
|
-
const doc = {
|
|
398
|
-
_id: uuid,
|
|
399
|
-
_type: "mux.videoAsset",
|
|
400
|
-
status: asset.data.status,
|
|
401
|
-
data: asset.data,
|
|
402
|
-
assetId: asset.data.id,
|
|
403
|
-
playbackId: asset.data.playback_ids[0].id,
|
|
404
|
-
uploadId: upload.data.id
|
|
405
|
-
};
|
|
406
|
-
return client.createOrReplace(doc).then(() => {
|
|
407
|
-
return doc;
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
function testFile(file) {
|
|
411
|
-
if (typeof window !== "undefined" && file instanceof window.File) {
|
|
412
|
-
const fileOptions = optionsFromFile({}, file);
|
|
413
|
-
return rxjs.of(fileOptions);
|
|
414
|
-
}
|
|
415
|
-
return rxjs.throwError(new Error("Invalid file"));
|
|
416
|
-
}
|
|
417
|
-
function testUrl(url) {
|
|
418
|
-
const error = new Error("Invalid URL");
|
|
419
|
-
if (typeof url !== "string") {
|
|
420
|
-
return rxjs.throwError(error);
|
|
421
|
-
}
|
|
422
|
-
let parsed;
|
|
423
|
-
try {
|
|
424
|
-
parsed = new URL(url);
|
|
425
|
-
} catch (err) {
|
|
426
|
-
return rxjs.throwError(error);
|
|
427
|
-
}
|
|
428
|
-
if (parsed && !parsed.protocol.match(/http:|https:/)) {
|
|
429
|
-
return rxjs.throwError(error);
|
|
430
|
-
}
|
|
431
|
-
return rxjs.of(url);
|
|
432
|
-
}
|
|
433
|
-
function optionsFromFile(opts, file) {
|
|
434
|
-
if (typeof window === "undefined" || !(file instanceof window.File)) {
|
|
435
|
-
return opts;
|
|
436
|
-
}
|
|
437
|
-
return {
|
|
438
|
-
name: opts.preserveFilename === false ? void 0 : file.name,
|
|
439
|
-
type: file.type
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
function extractDroppedFiles(dataTransfer) {
|
|
443
|
-
const files = Array.from(dataTransfer.files || []);
|
|
444
|
-
const items = Array.from(dataTransfer.items || []);
|
|
445
|
-
if (files && files.length > 0) {
|
|
446
|
-
return Promise.resolve(files);
|
|
447
|
-
}
|
|
448
|
-
return normalizeItems(items).then(arr => arr.flat());
|
|
449
|
-
}
|
|
450
|
-
function normalizeItems(items) {
|
|
451
|
-
return Promise.all(items.map(item => {
|
|
452
|
-
if (item.kind === "file" && item.webkitGetAsEntry) {
|
|
453
|
-
let entry;
|
|
454
|
-
try {
|
|
455
|
-
entry = item.webkitGetAsEntry();
|
|
456
|
-
} catch (err) {
|
|
457
|
-
return [item.getAsFile()];
|
|
458
|
-
}
|
|
459
|
-
if (!entry) {
|
|
460
|
-
return [];
|
|
461
|
-
}
|
|
462
|
-
return entry.isDirectory ? walk(entry) : [item.getAsFile()];
|
|
463
|
-
}
|
|
464
|
-
if (item.kind === "file") {
|
|
465
|
-
const file = item.getAsFile();
|
|
466
|
-
return Promise.resolve(file ? [file] : []);
|
|
467
|
-
}
|
|
468
|
-
return new Promise(resolve => item.getAsString(resolve)).then(str => str ? [new File([str], "unknown.txt", {
|
|
469
|
-
type: item.type
|
|
470
|
-
})] : []);
|
|
471
|
-
}));
|
|
472
|
-
}
|
|
473
|
-
function isFile(entry) {
|
|
474
|
-
return entry.isFile;
|
|
475
|
-
}
|
|
476
|
-
function isDirectory(entry) {
|
|
477
|
-
return entry.isDirectory;
|
|
478
|
-
}
|
|
479
|
-
function walk(entry) {
|
|
480
|
-
if (isFile(entry)) {
|
|
481
|
-
return new Promise(resolve => entry.file(resolve)).then(file => [file]);
|
|
482
|
-
}
|
|
483
|
-
if (isDirectory(entry)) {
|
|
484
|
-
const dir = entry.createReader();
|
|
485
|
-
return new Promise(resolve => dir.readEntries(resolve)).then(entries => entries.filter(entr => !entr.name.startsWith("."))).then(entries => Promise.all(entries.map(walk)).then(arr => arr.flat()));
|
|
486
|
-
}
|
|
487
|
-
return Promise.resolve([]);
|
|
488
|
-
}
|
|
489
|
-
function AssetActionsMenu(props) {
|
|
490
|
-
const {
|
|
491
|
-
asset
|
|
492
|
-
} = props;
|
|
493
|
-
const id = React.useId();
|
|
494
|
-
const [dialogState, setDialogState] = React.useState();
|
|
495
|
-
const [open, setOpen] = React.useState(false);
|
|
496
|
-
const [menuElement, setMenuRef] = React.useState(null);
|
|
497
|
-
const handleDelete = React.useCallback(() => setDialogState("confirm-delete"), []);
|
|
498
|
-
const handleClick = React.useCallback(() => {
|
|
499
|
-
setDialogState(false);
|
|
500
|
-
setOpen(true);
|
|
501
|
-
}, [setDialogState]);
|
|
502
|
-
const handleClose = React.useCallback(() => {
|
|
503
|
-
setDialogState(false);
|
|
504
|
-
setOpen(false);
|
|
505
|
-
}, [setDialogState]);
|
|
506
|
-
React.useEffect(() => {
|
|
507
|
-
if (open && dialogState) {
|
|
508
|
-
setOpen(false);
|
|
509
|
-
}
|
|
510
|
-
}, [dialogState, open]);
|
|
511
|
-
ui.useClickOutside(React.useCallback(() => setOpen(false), []), [menuElement]);
|
|
512
|
-
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
513
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.MenuButton, {
|
|
514
|
-
id: "".concat(id, "-asset-menu"),
|
|
515
|
-
button: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
516
|
-
icon: icons.EllipsisVerticalIcon,
|
|
517
|
-
mode: "ghost",
|
|
518
|
-
onClick: handleClick,
|
|
519
|
-
padding: 2
|
|
520
|
-
}),
|
|
521
|
-
menu: /* @__PURE__ */jsxRuntime.jsx(ui.Menu, {
|
|
522
|
-
ref: setMenuRef,
|
|
523
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.MenuItem, {
|
|
524
|
-
tone: "critical",
|
|
525
|
-
icon: icons.TrashIcon,
|
|
526
|
-
text: "Delete",
|
|
527
|
-
onClick: handleDelete
|
|
528
|
-
})
|
|
529
|
-
}),
|
|
530
|
-
portal: true,
|
|
531
|
-
placement: "right"
|
|
532
|
-
}), dialogState === "confirm-delete" && /* @__PURE__ */jsxRuntime.jsx(DeleteDialog, {
|
|
533
|
-
asset,
|
|
534
|
-
onClose: handleClose
|
|
535
|
-
})]
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
function DeleteDialog(props) {
|
|
539
|
-
const {
|
|
540
|
-
asset,
|
|
541
|
-
onClose
|
|
542
|
-
} = props;
|
|
543
|
-
const client = VideoSource_styled.useClient();
|
|
544
|
-
const {
|
|
545
|
-
push: pushToast
|
|
546
|
-
} = ui.useToast();
|
|
547
|
-
const [deleting, setDeleting] = React.useState(false);
|
|
548
|
-
const [deleteOnMux, setDeleteOnMux] = React.useState(false);
|
|
549
|
-
const id = React.useId();
|
|
550
|
-
const width = 200 * useDevicePixelRatio.getDevicePixelRatio({
|
|
551
|
-
maxDpr: 2
|
|
552
|
-
});
|
|
553
|
-
const handleDelete = React.useCallback(async () => {
|
|
554
|
-
var _a, _b, _c;
|
|
555
|
-
setDeleting(true);
|
|
556
|
-
try {
|
|
557
|
-
if (asset == null ? void 0 : asset._id) {
|
|
558
|
-
await client.delete(asset._id);
|
|
559
|
-
}
|
|
560
|
-
if (deleteOnMux && (asset == null ? void 0 : asset.assetId)) {
|
|
561
|
-
await deleteAsset(client, asset.assetId);
|
|
562
|
-
}
|
|
563
|
-
(_c = (_b = (_a = document.querySelector("[data-id=\"".concat(asset._id, "\"]"))) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.setAttribute) == null ? void 0 : _c.call(_b, "hidden", "true");
|
|
564
|
-
} catch (err) {
|
|
565
|
-
console.error("Failed during delete", err);
|
|
566
|
-
pushToast({
|
|
567
|
-
closable: true,
|
|
568
|
-
description: err == null ? void 0 : err.message,
|
|
569
|
-
duration: 5e3,
|
|
570
|
-
title: "Uncaught error",
|
|
571
|
-
status: "error"
|
|
572
|
-
});
|
|
573
|
-
} finally {
|
|
574
|
-
setDeleting(false);
|
|
575
|
-
onClose();
|
|
576
|
-
}
|
|
577
|
-
}, [asset._id, asset.assetId, client, deleteOnMux, onClose, pushToast]);
|
|
578
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
579
|
-
onClose,
|
|
580
|
-
id: "".concat(id, "-confirm-delete"),
|
|
581
|
-
header: "Delete video",
|
|
582
|
-
footer: /* @__PURE__ */jsxRuntime.jsxs(ui.Grid, {
|
|
583
|
-
padding: 2,
|
|
584
|
-
gap: 2,
|
|
585
|
-
columns: 2,
|
|
586
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
587
|
-
mode: "bleed",
|
|
588
|
-
text: "Cancel",
|
|
589
|
-
onClick: onClose
|
|
590
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
591
|
-
text: "Delete",
|
|
592
|
-
tone: "critical",
|
|
593
|
-
icon: icons.TrashIcon,
|
|
594
|
-
onClick: handleDelete,
|
|
595
|
-
loading: deleting
|
|
596
|
-
})]
|
|
597
|
-
}),
|
|
598
|
-
width: 1,
|
|
599
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
600
|
-
paddingX: 0,
|
|
601
|
-
paddingY: 0,
|
|
602
|
-
space: 1,
|
|
603
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
604
|
-
paddingX: [2, 3, 4],
|
|
605
|
-
paddingY: [3, 3, 3, 4],
|
|
606
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Grid, {
|
|
607
|
-
columns: 3,
|
|
608
|
-
gap: 3,
|
|
609
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
610
|
-
style: {
|
|
611
|
-
gridColumn: "span 2"
|
|
612
|
-
},
|
|
613
|
-
align: "center",
|
|
614
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
615
|
-
padding: 4,
|
|
616
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
617
|
-
space: 4,
|
|
618
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
619
|
-
align: "center",
|
|
620
|
-
as: "label",
|
|
621
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
|
|
622
|
-
checked: deleteOnMux,
|
|
623
|
-
onChange: () => setDeleteOnMux(prev => !prev)
|
|
624
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
625
|
-
style: {
|
|
626
|
-
margin: "0 10px"
|
|
627
|
-
},
|
|
628
|
-
children: "Delete asset on Mux"
|
|
629
|
-
})]
|
|
630
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
631
|
-
align: "center",
|
|
632
|
-
as: "label",
|
|
633
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
|
|
634
|
-
disabled: true,
|
|
635
|
-
checked: true
|
|
636
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
637
|
-
style: {
|
|
638
|
-
margin: "0 10px"
|
|
639
|
-
},
|
|
640
|
-
children: "Delete video from dataset"
|
|
641
|
-
})]
|
|
642
|
-
})]
|
|
643
|
-
})
|
|
644
|
-
})
|
|
645
|
-
}), /* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.VideoThumbnail, {
|
|
646
|
-
asset,
|
|
647
|
-
width,
|
|
648
|
-
showTip: true
|
|
649
|
-
})]
|
|
650
|
-
})
|
|
651
|
-
})
|
|
652
|
-
})
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
function VideoSource(_ref) {
|
|
656
|
-
let {
|
|
657
|
-
assets,
|
|
658
|
-
isLoading,
|
|
659
|
-
isLastPage,
|
|
660
|
-
onSelect,
|
|
661
|
-
onLoadMore
|
|
662
|
-
} = _ref;
|
|
663
|
-
const handleClick = React.useCallback(event => onSelect(event.currentTarget.dataset.id), [onSelect]);
|
|
664
|
-
const handleKeyPress = React.useCallback(event => {
|
|
665
|
-
if (event.key === "Enter") {
|
|
666
|
-
onSelect(event.currentTarget.dataset.id);
|
|
667
|
-
}
|
|
668
|
-
}, [onSelect]);
|
|
669
|
-
const width = 200 * useDevicePixelRatio.getDevicePixelRatio({
|
|
670
|
-
maxDpr: 2
|
|
671
|
-
});
|
|
672
|
-
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
673
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Box, {
|
|
674
|
-
padding: 4,
|
|
675
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.ThumbGrid, {
|
|
676
|
-
gap: 2,
|
|
677
|
-
children: assets.map(asset => /* @__PURE__ */jsxRuntime.jsx(VideoSourceItem, {
|
|
678
|
-
asset,
|
|
679
|
-
onClick: handleClick,
|
|
680
|
-
onKeyPress: handleKeyPress,
|
|
681
|
-
width
|
|
682
|
-
}, asset._id))
|
|
683
|
-
}), isLoading && assets.length === 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
684
|
-
justify: "center",
|
|
685
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {
|
|
686
|
-
muted: true
|
|
687
|
-
})
|
|
688
|
-
}), !isLoading && assets.length === 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
689
|
-
align: "center",
|
|
690
|
-
muted: true,
|
|
691
|
-
children: "No videos"
|
|
692
|
-
})]
|
|
693
|
-
}), assets.length > 0 && !isLastPage && /* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.CardLoadMore, {
|
|
694
|
-
tone: "default",
|
|
695
|
-
padding: 4,
|
|
696
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
697
|
-
direction: "column",
|
|
698
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
699
|
-
type: "button",
|
|
700
|
-
icon: icons.DownloadIcon,
|
|
701
|
-
loading: isLoading,
|
|
702
|
-
onClick: onLoadMore,
|
|
703
|
-
text: "Load more",
|
|
704
|
-
tone: "primary"
|
|
705
|
-
})
|
|
706
|
-
})
|
|
707
|
-
})]
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
const _VideoSourceItem = _ref2 => {
|
|
711
|
-
let {
|
|
712
|
-
asset,
|
|
713
|
-
onClick,
|
|
714
|
-
onKeyPress,
|
|
715
|
-
width
|
|
716
|
-
} = _ref2;
|
|
717
|
-
const [hover, setHover] = React.useState(null);
|
|
718
|
-
const ref = React.useRef(null);
|
|
719
|
-
React.useLayoutEffect(() => {
|
|
720
|
-
if (!ref.current || hover === null) {
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
if (hover) {
|
|
724
|
-
motion.animate(ref.current, {
|
|
725
|
-
opacity: 1
|
|
726
|
-
});
|
|
727
|
-
} else {
|
|
728
|
-
motion.animate(ref.current, {
|
|
729
|
-
opacity: 0
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
}, [hover]);
|
|
733
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Box, {
|
|
734
|
-
height: "fill",
|
|
735
|
-
style: {
|
|
736
|
-
position: "relative"
|
|
737
|
-
},
|
|
738
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Card, {
|
|
739
|
-
as: "button",
|
|
740
|
-
"data-id": asset._id,
|
|
741
|
-
onClick,
|
|
742
|
-
onKeyPress,
|
|
743
|
-
tabIndex: 0,
|
|
744
|
-
radius: 2,
|
|
745
|
-
padding: 1,
|
|
746
|
-
style: {
|
|
747
|
-
lineHeight: 0,
|
|
748
|
-
position: "relative"
|
|
749
|
-
},
|
|
750
|
-
__unstable_focusRing: true,
|
|
751
|
-
onMouseEnter: () => setHover(true),
|
|
752
|
-
onMouseLeave: () => setHover(false),
|
|
753
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.VideoThumbnail, {
|
|
754
|
-
asset,
|
|
755
|
-
width,
|
|
756
|
-
showTip: true
|
|
757
|
-
}), (asset == null ? void 0 : asset.playbackId) && /* @__PURE__ */jsxRuntime.jsx(AnimateWrapper, {
|
|
758
|
-
tone: "transparent",
|
|
759
|
-
ref,
|
|
760
|
-
margin: 1,
|
|
761
|
-
radius: 1,
|
|
762
|
-
children: hover !== null && /* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.AnimatedVideoThumbnail, {
|
|
763
|
-
asset,
|
|
764
|
-
width
|
|
765
|
-
})
|
|
766
|
-
})]
|
|
767
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ActionsAssetsContainer, {
|
|
768
|
-
children: /* @__PURE__ */jsxRuntime.jsx(AssetActionsMenu, {
|
|
769
|
-
asset
|
|
770
|
-
})
|
|
771
|
-
})]
|
|
772
|
-
});
|
|
773
|
-
};
|
|
774
|
-
const VideoSourceItem = React.memo(_VideoSourceItem);
|
|
775
|
-
const AnimateWrapper = styled__default.default(ui.Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n will-change: opacity;\n background: transparent;\n background-color: hsl(0deg 0% 0% / 33%);\n opacity: 0;\n pointer-events: none;\n"])));
|
|
776
|
-
const ActionsAssetsContainer = styled__default.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n box-sizing: border-box;\n position: absolute;\n z-index: 300;\n opacity: 0;\n top: 7px;\n right: 7px;\n\n button:hover + &,\n button:focus-visible + &,\n &:hover,\n &:focus-visible {\n opacity: 1;\n }\n"])));
|
|
777
|
-
const PER_PAGE = 200;
|
|
778
|
-
function createQuery() {
|
|
779
|
-
let start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
780
|
-
let end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PER_PAGE;
|
|
781
|
-
return (/* groq */"*[_type == \"mux.videoAsset\"] | order(_updatedAt desc) [".concat(start, "...").concat(end, "]")
|
|
782
|
-
);
|
|
783
|
-
}
|
|
784
|
-
function SelectAssets(_ref3) {
|
|
785
|
-
let {
|
|
786
|
-
asset,
|
|
787
|
-
onChange,
|
|
788
|
-
setDialogState
|
|
789
|
-
} = _ref3;
|
|
790
|
-
const client = VideoSource_styled.useClient();
|
|
791
|
-
const pageNoRef = React.useRef(0);
|
|
792
|
-
const [isLastPage, setLastPage] = React.useState(false);
|
|
793
|
-
const [isLoading, setLoading] = React.useState(false);
|
|
794
|
-
const [assets, setAssets] = React.useState([]);
|
|
795
|
-
const fetchPage = React.useCallback(pageNo => {
|
|
796
|
-
const start = pageNo * PER_PAGE;
|
|
797
|
-
const end = start + PER_PAGE;
|
|
798
|
-
setLoading(true);
|
|
799
|
-
return client.fetch(createQuery(start, end)).then(result => {
|
|
800
|
-
setLastPage(result.length < PER_PAGE);
|
|
801
|
-
setAssets(prev => prev.concat(result));
|
|
802
|
-
}).finally(() => setLoading(false));
|
|
803
|
-
}, [client]);
|
|
804
|
-
const handleSelect = React.useCallback(id => {
|
|
805
|
-
const selected = assets.find(doc => doc._id === id);
|
|
806
|
-
if (!selected) {
|
|
807
|
-
throw new TypeError("Failed to find video asset with id: ".concat(id));
|
|
808
|
-
}
|
|
809
|
-
onChange(sanity.PatchEvent.from([sanity.setIfMissing({
|
|
810
|
-
asset: {}
|
|
811
|
-
}), sanity.set({
|
|
812
|
-
_type: "reference",
|
|
813
|
-
_weak: true,
|
|
814
|
-
_ref: selected._id
|
|
815
|
-
}, ["asset"])]));
|
|
816
|
-
setDialogState(false);
|
|
817
|
-
}, [assets, onChange, setDialogState]);
|
|
818
|
-
const handleLoadMore = React.useCallback(() => {
|
|
819
|
-
fetchPage(++pageNoRef.current);
|
|
820
|
-
}, [fetchPage]);
|
|
821
|
-
React.useEffect(() => void fetchPage(pageNoRef.current), [fetchPage]);
|
|
822
|
-
return /* @__PURE__ */jsxRuntime.jsx(VideoSource, {
|
|
823
|
-
onSelect: handleSelect,
|
|
824
|
-
assets,
|
|
825
|
-
isLastPage,
|
|
826
|
-
isLoading,
|
|
827
|
-
onLoadMore: handleLoadMore
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
function InputBrowser(_ref4) {
|
|
831
|
-
let {
|
|
832
|
-
setDialogState,
|
|
833
|
-
asset,
|
|
834
|
-
onChange
|
|
835
|
-
} = _ref4;
|
|
836
|
-
const id = "InputBrowser".concat(React.useId());
|
|
837
|
-
const handleClose = React.useCallback(() => setDialogState(false), [setDialogState]);
|
|
838
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
839
|
-
scheme: "dark",
|
|
840
|
-
__unstable_autoFocus: true,
|
|
841
|
-
header: "Select video",
|
|
842
|
-
id,
|
|
843
|
-
onClose: handleClose,
|
|
844
|
-
width: 2,
|
|
845
|
-
children: /* @__PURE__ */jsxRuntime.jsx(SelectAssets, {
|
|
846
|
-
asset,
|
|
847
|
-
onChange,
|
|
848
|
-
setDialogState
|
|
849
|
-
})
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
|
-
const useCancelUpload = (asset, onChange) => {
|
|
853
|
-
const client = VideoSource_styled.useClient();
|
|
854
|
-
return React.useCallback(() => {
|
|
855
|
-
if (!asset) {
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
onChange(sanity.PatchEvent.from(sanity.unset()));
|
|
859
|
-
if (asset.assetId) {
|
|
860
|
-
deleteAsset(client, asset.assetId);
|
|
861
|
-
}
|
|
862
|
-
if (asset._id) {
|
|
863
|
-
client.delete(asset._id);
|
|
864
|
-
}
|
|
865
|
-
}, [asset, client, onChange]);
|
|
866
|
-
};
|
|
867
|
-
function getVideoSrc(_ref5) {
|
|
868
|
-
let {
|
|
869
|
-
asset,
|
|
870
|
-
client
|
|
871
|
-
} = _ref5;
|
|
872
|
-
const playbackId = VideoSource_styled.getPlaybackId(asset);
|
|
873
|
-
const searchParams = new URLSearchParams();
|
|
874
|
-
if (VideoSource_styled.getPlaybackPolicy(asset) === "signed") {
|
|
875
|
-
const token = VideoSource_styled.generateJwt(client, playbackId, "v");
|
|
876
|
-
searchParams.set("token", token);
|
|
877
|
-
}
|
|
878
|
-
return "https://stream.mux.com/".concat(playbackId, ".m3u8?").concat(searchParams);
|
|
879
|
-
}
|
|
880
|
-
function EditThumbnailDialog(_ref6) {
|
|
881
|
-
let {
|
|
882
|
-
asset,
|
|
883
|
-
getCurrentTime,
|
|
884
|
-
setDialogState
|
|
885
|
-
} = _ref6;
|
|
886
|
-
const client = VideoSource_styled.useClient();
|
|
887
|
-
const dialogId = "EditThumbnailDialog".concat(React.useId());
|
|
888
|
-
const nextTime = React.useMemo(() => getCurrentTime(), [getCurrentTime]);
|
|
889
|
-
const assetWithNewThumbnail = React.useMemo(() => ({
|
|
890
|
-
...asset,
|
|
891
|
-
thumbTime: nextTime
|
|
892
|
-
}), [asset, nextTime]);
|
|
893
|
-
const [saving, setSaving] = React.useState(false);
|
|
894
|
-
const [error, setError] = React.useState(null);
|
|
895
|
-
const handleSave = React.useCallback(() => {
|
|
896
|
-
setSaving(true);
|
|
897
|
-
client.patch(asset._id).set({
|
|
898
|
-
thumbTime: nextTime
|
|
899
|
-
}).commit({
|
|
900
|
-
returnDocuments: false
|
|
901
|
-
}).then(() => void setDialogState(false)).catch(setError).finally(() => void setSaving(false));
|
|
902
|
-
}, [client, asset._id, nextTime, setDialogState]);
|
|
903
|
-
const width = 300 * useDevicePixelRatio.getDevicePixelRatio({
|
|
904
|
-
maxDpr: 2
|
|
905
|
-
});
|
|
906
|
-
if (error) {
|
|
907
|
-
throw error;
|
|
908
|
-
}
|
|
909
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
910
|
-
id: dialogId,
|
|
911
|
-
header: "Edit thumbnail",
|
|
912
|
-
onClose: () => setDialogState(false),
|
|
913
|
-
footer: /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
914
|
-
padding: 3,
|
|
915
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
916
|
-
mode: "ghost",
|
|
917
|
-
tone: "primary",
|
|
918
|
-
loading: saving,
|
|
919
|
-
onClick: handleSave,
|
|
920
|
-
text: "Set new thumbnail"
|
|
921
|
-
}, "thumbnail")
|
|
922
|
-
}),
|
|
923
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
924
|
-
space: 3,
|
|
925
|
-
padding: 3,
|
|
926
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
927
|
-
space: 2,
|
|
928
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
929
|
-
size: 1,
|
|
930
|
-
weight: "semibold",
|
|
931
|
-
children: "Current:"
|
|
932
|
-
}), /* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.VideoThumbnail, {
|
|
933
|
-
asset,
|
|
934
|
-
width
|
|
935
|
-
})]
|
|
936
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
937
|
-
space: 2,
|
|
938
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
939
|
-
size: 1,
|
|
940
|
-
weight: "semibold",
|
|
941
|
-
children: "New:"
|
|
942
|
-
}), /* @__PURE__ */jsxRuntime.jsx(VideoSource_styled.VideoThumbnail, {
|
|
943
|
-
asset: assetWithNewThumbnail,
|
|
944
|
-
width
|
|
945
|
-
})]
|
|
946
|
-
})]
|
|
947
|
-
})
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
function getStoryboardSrc(_ref7) {
|
|
951
|
-
let {
|
|
952
|
-
asset,
|
|
953
|
-
client
|
|
954
|
-
} = _ref7;
|
|
955
|
-
const playbackId = VideoSource_styled.getPlaybackId(asset);
|
|
956
|
-
const searchParams = new URLSearchParams();
|
|
957
|
-
if (VideoSource_styled.getPlaybackPolicy(asset) === "signed") {
|
|
958
|
-
const token = VideoSource_styled.generateJwt(client, playbackId, "s");
|
|
959
|
-
searchParams.set("token", token);
|
|
960
|
-
}
|
|
961
|
-
return "https://image.mux.com/".concat(playbackId, "/storyboard.vtt?").concat(searchParams);
|
|
962
|
-
}
|
|
963
|
-
const VideoContainer = styled__default.default(ui.Card)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n min-height: 150px;\n aspect-ratio: 16 / 9;\n overflow: hidden;\n border-radius: 1px;\n media-airplay-button[media-airplay-unavailable] {\n display: none;\n }\n media-volume-range[media-volume-unavailable] {\n display: none;\n }\n media-pip-button[media-pip-unavailable] {\n display: none;\n }\n media-controller {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n --media-range-track-background-color: rgba(255, 255, 255, 0.5);\n --media-range-track-border-radius: 3px;\n width: 100%;\n height: 100%;\n background-color: transparent;\n }\n media-control-bar {\n --media-button-icon-width: 18px;\n --media-preview-time-margin: 0px;\n }\n media-control-bar:not([slot]) :is([role='button'], [role='switch'], button) {\n height: 44px;\n }\n .size-extra-small media-control-bar [role='button'],\n .size-extra-small media-control-bar [role='switch'] {\n height: auto;\n padding: 4.4% 3.2%;\n }\n .mxp-spacer {\n flex-grow: 1;\n height: 100%;\n background-color: var(--media-control-background, rgba(20, 20, 30, 0.7));\n }\n media-controller::part(vertical-layer) {\n transition: background-color 1s;\n }\n media-controller:is([media-paused], :not([user-inactive]))::part(vertical-layer) {\n background-color: rgba(0, 0, 0, 0.6);\n transition: background-color 0.25s;\n }\n .mxp-center-controls {\n --media-background-color: transparent;\n --media-button-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n width: 100%;\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n }\n .mxp-center-controls media-play-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n width: max(27px, min(9%, 90px));\n }\n .mxp-center-controls media-seek-backward-button,\n .mxp-center-controls media-seek-forward-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n margin: 0 10%;\n width: min(7%, 70px);\n }\n media-loading-indicator {\n --media-loading-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n position: absolute;\n width: min(15%, 150px);\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n }\n /* Intentionally don't target the div for transition but the children\n of the div. Prevents messing with media-chrome's autohide feature. */\n media-loading-indicator + div * {\n transition: opacity 0.15s;\n opacity: 1;\n }\n media-loading-indicator[media-loading]:not([media-paused]) ~ div > * {\n opacity: 0;\n transition-delay: 400ms;\n }\n media-volume-range {\n width: min(100%, 100px);\n }\n media-time-display {\n white-space: nowrap;\n }\n :is(media-time-display, media-text-display, media-playback-rate-button) {\n color: inherit;\n }\n media-controller:fullscreen media-control-bar[slot='top-chrome'] {\n /* Hide menus and buttons that trigger modals when in full-screen */\n display: none;\n }\n video {\n background: transparent;\n }\n media-controller:not(:fullscreen) video {\n aspect-ratio: 16 / 9;\n }\n media-controller:not(:-webkit-full-screen) video {\n aspect-ratio: 16 / 9;\n }\n"])));
|
|
964
|
-
const StyledCenterControls = styled__default.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n && {\n --media-background-color: transparent;\n --media-button-icon-width: 100%;\n --media-button-icon-height: auto;\n pointer-events: none;\n width: 100%;\n display: flex;\n flex-flow: row;\n align-items: center;\n justify-content: center;\n media-play-button {\n --media-control-background: transparent;\n --media-control-hover-background: transparent;\n padding: 0;\n width: max(27px, min(9%, 90px));\n }\n }\n"])));
|
|
965
|
-
const TopControls = styled__default.default(react.MediaControlBar)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n justify-content: flex-end;\n button {\n height: auto;\n }\n"])));
|
|
966
|
-
function PosterImage(_ref8) {
|
|
967
|
-
let {
|
|
968
|
-
asset
|
|
969
|
-
} = _ref8;
|
|
970
|
-
const client = VideoSource_styled.useClient();
|
|
971
|
-
const ref = React.useRef(null);
|
|
972
|
-
const src = React.useMemo(() => VideoSource_styled.getPosterSrc({
|
|
973
|
-
client,
|
|
974
|
-
asset,
|
|
975
|
-
width: 1920,
|
|
976
|
-
height: 1080
|
|
977
|
-
}), [client, asset]);
|
|
978
|
-
React.useEffect(() => {
|
|
979
|
-
var _a;
|
|
980
|
-
if (ref.current) {
|
|
981
|
-
const style = document.createElement("style");
|
|
982
|
-
style.innerHTML = "img { object-fit: contain; }";
|
|
983
|
-
if ((_a = ref.current) == null ? void 0 : _a.shadowRoot) {
|
|
984
|
-
ref.current.shadowRoot.appendChild(style);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}, []);
|
|
988
|
-
return /* @__PURE__ */jsxRuntime.jsx(react.MediaPosterImage, {
|
|
989
|
-
ref,
|
|
990
|
-
slot: "poster",
|
|
991
|
-
src
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
function ThumbnailsMetadataTrack(_ref9) {
|
|
995
|
-
let {
|
|
996
|
-
asset
|
|
997
|
-
} = _ref9;
|
|
998
|
-
const client = VideoSource_styled.useClient();
|
|
999
|
-
const [src] = React.useState(() => getStoryboardSrc({
|
|
1000
|
-
asset,
|
|
1001
|
-
client
|
|
1002
|
-
}));
|
|
1003
|
-
return /* @__PURE__ */jsxRuntime.jsx("track", {
|
|
1004
|
-
label: "thumbnails",
|
|
1005
|
-
default: true,
|
|
1006
|
-
kind: "metadata",
|
|
1007
|
-
src
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
const CardWrapper = styled__default.default(ui.Card)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n min-height: 82px;\n box-sizing: border-box;\n"])));
|
|
1011
|
-
const FlexWrapper = styled__default.default(ui.Flex)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n text-overflow: ellipsis;\n overflow: hidden;\n"])));
|
|
1012
|
-
const LeftSection = styled__default.default(ui.Stack)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: relative;\n width: 60%;\n"])));
|
|
1013
|
-
const CodeWrapper = styled__default.default(ui.Code)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n\n code {\n overflow: hidden;\n text-overflow: ellipsis;\n position: relative;\n max-width: 200px;\n }\n"])));
|
|
1014
|
-
const UploadProgress = _ref10 => {
|
|
1015
|
-
let {
|
|
1016
|
-
progress = 100,
|
|
1017
|
-
onCancel,
|
|
1018
|
-
filename,
|
|
1019
|
-
text = "Uploading"
|
|
1020
|
-
} = _ref10;
|
|
1021
|
-
return /* @__PURE__ */jsxRuntime.jsx(CardWrapper, {
|
|
1022
|
-
tone: "primary",
|
|
1023
|
-
padding: 4,
|
|
1024
|
-
border: true,
|
|
1025
|
-
height: "fill",
|
|
1026
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(FlexWrapper, {
|
|
1027
|
-
align: "center",
|
|
1028
|
-
justify: "space-between",
|
|
1029
|
-
height: "fill",
|
|
1030
|
-
direction: "row",
|
|
1031
|
-
gap: 2,
|
|
1032
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(LeftSection, {
|
|
1033
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
1034
|
-
justify: "center",
|
|
1035
|
-
gap: [3, 3, 2, 2],
|
|
1036
|
-
direction: ["column", "column", "row"],
|
|
1037
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
1038
|
-
size: 1,
|
|
1039
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Inline, {
|
|
1040
|
-
space: 2,
|
|
1041
|
-
children: [text, /* @__PURE__ */jsxRuntime.jsx(CodeWrapper, {
|
|
1042
|
-
size: 1,
|
|
1043
|
-
children: filename ? filename : "..."
|
|
1044
|
-
})]
|
|
1045
|
-
})
|
|
1046
|
-
})
|
|
1047
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
1048
|
-
marginTop: 3,
|
|
1049
|
-
radius: 5,
|
|
1050
|
-
shadow: 1,
|
|
1051
|
-
children: /* @__PURE__ */jsxRuntime.jsx(sanity.LinearProgress, {
|
|
1052
|
-
value: progress
|
|
1053
|
-
})
|
|
1054
|
-
})]
|
|
1055
|
-
}), onCancel ? /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
1056
|
-
fontSize: 2,
|
|
1057
|
-
text: "Cancel upload",
|
|
1058
|
-
mode: "ghost",
|
|
1059
|
-
tone: "critical",
|
|
1060
|
-
onClick: onCancel
|
|
1061
|
-
}) : null]
|
|
1062
|
-
})
|
|
1063
|
-
});
|
|
1064
|
-
};
|
|
1065
|
-
const MuxVideoOld = _ref11 => {
|
|
1066
|
-
let {
|
|
1067
|
-
asset,
|
|
1068
|
-
buttons,
|
|
1069
|
-
readOnly,
|
|
1070
|
-
onChange,
|
|
1071
|
-
dialogState,
|
|
1072
|
-
setDialogState
|
|
1073
|
-
} = _ref11;
|
|
1074
|
-
var _a, _b, _c, _d;
|
|
1075
|
-
const client = VideoSource_styled.useClient();
|
|
1076
|
-
const isLoading = React.useMemo(() => {
|
|
1077
|
-
if ((asset == null ? void 0 : asset.status) === "preparing") {
|
|
1078
|
-
return "Preparing the video";
|
|
1079
|
-
}
|
|
1080
|
-
if ((asset == null ? void 0 : asset.status) === "waiting_for_upload") {
|
|
1081
|
-
return "Waiting for upload to start";
|
|
1082
|
-
}
|
|
1083
|
-
if ((asset == null ? void 0 : asset.status) === "waiting") {
|
|
1084
|
-
return "Processing upload";
|
|
1085
|
-
}
|
|
1086
|
-
if ((asset == null ? void 0 : asset.status) === "ready") {
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
if (typeof (asset == null ? void 0 : asset.status) === "undefined") {
|
|
1090
|
-
return false;
|
|
1091
|
-
}
|
|
1092
|
-
return true;
|
|
1093
|
-
}, [asset]);
|
|
1094
|
-
const isPreparingStaticRenditions = React.useMemo(() => {
|
|
1095
|
-
var _a2, _b2, _c2, _d2;
|
|
1096
|
-
if (((_b2 = (_a2 = asset == null ? void 0 : asset.data) == null ? void 0 : _a2.static_renditions) == null ? void 0 : _b2.status) === "preparing") {
|
|
1097
|
-
return true;
|
|
1098
|
-
}
|
|
1099
|
-
if (((_d2 = (_c2 = asset == null ? void 0 : asset.data) == null ? void 0 : _c2.static_renditions) == null ? void 0 : _d2.status) === "ready") {
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
|
-
return false;
|
|
1103
|
-
}, [(_b = (_a = asset == null ? void 0 : asset.data) == null ? void 0 : _a.static_renditions) == null ? void 0 : _b.status]);
|
|
1104
|
-
const videoSrc = React.useMemo(() => asset.playbackId && getVideoSrc({
|
|
1105
|
-
client,
|
|
1106
|
-
asset
|
|
1107
|
-
}), [asset, client]);
|
|
1108
|
-
const [error, setError] = React.useState(null);
|
|
1109
|
-
const handleError = React.useCallback(event => setError(event.currentTarget.error), []);
|
|
1110
|
-
const playRef = React.useRef(null);
|
|
1111
|
-
const muteRef = React.useRef(null);
|
|
1112
|
-
const video = React.useRef(null);
|
|
1113
|
-
const getCurrentTime = React.useCallback(() => {
|
|
1114
|
-
var _a2, _b2;
|
|
1115
|
-
return (_b2 = (_a2 = video.current) == null ? void 0 : _a2.currentTime) != null ? _b2 : 0;
|
|
1116
|
-
}, [video]);
|
|
1117
|
-
const handleCancelUpload = useCancelUpload(asset, onChange);
|
|
1118
|
-
React.useEffect(() => {
|
|
1119
|
-
var _a2, _b2;
|
|
1120
|
-
const style = document.createElement("style");
|
|
1121
|
-
style.innerHTML = "button svg { vertical-align: middle; }";
|
|
1122
|
-
if ((_a2 = playRef.current) == null ? void 0 : _a2.shadowRoot) {
|
|
1123
|
-
playRef.current.shadowRoot.appendChild(style);
|
|
1124
|
-
}
|
|
1125
|
-
if ((_b2 = muteRef == null ? void 0 : muteRef.current) == null ? void 0 : _b2.shadowRoot) {
|
|
1126
|
-
muteRef.current.shadowRoot.appendChild(style.cloneNode(true));
|
|
1127
|
-
}
|
|
1128
|
-
}, []);
|
|
1129
|
-
React.useEffect(() => {
|
|
1130
|
-
var _a2, _b2, _c2;
|
|
1131
|
-
if ((asset == null ? void 0 : asset.status) === "errored") {
|
|
1132
|
-
handleCancelUpload();
|
|
1133
|
-
throw new Error((_c2 = (_b2 = (_a2 = asset.data) == null ? void 0 : _a2.errors) == null ? void 0 : _b2.messages) == null ? void 0 : _c2.join(" "));
|
|
1134
|
-
}
|
|
1135
|
-
}, [(_d = (_c = asset.data) == null ? void 0 : _c.errors) == null ? void 0 : _d.messages, asset == null ? void 0 : asset.status, handleCancelUpload]);
|
|
1136
|
-
const signedToken = React.useMemo(() => {
|
|
1137
|
-
try {
|
|
1138
|
-
const url = new URL(videoSrc);
|
|
1139
|
-
return url.searchParams.get("token");
|
|
1140
|
-
} catch {
|
|
1141
|
-
return false;
|
|
1142
|
-
}
|
|
1143
|
-
}, [videoSrc]);
|
|
1144
|
-
if (error) {
|
|
1145
|
-
throw error;
|
|
1146
|
-
}
|
|
1147
|
-
if (!asset || !asset.status) {
|
|
1148
|
-
return null;
|
|
1149
|
-
}
|
|
1150
|
-
if (isLoading) {
|
|
1151
|
-
return /* @__PURE__ */jsxRuntime.jsx(UploadProgress, {
|
|
1152
|
-
progress: 100,
|
|
1153
|
-
filename: asset == null ? void 0 : asset.filename,
|
|
1154
|
-
text: isLoading !== true && isLoading || "Waiting for Mux to complete the file",
|
|
1155
|
-
onCancel: readOnly ? void 0 : () => handleCancelUpload()
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1159
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(VideoContainer, {
|
|
1160
|
-
shadow: 1,
|
|
1161
|
-
tone: "transparent",
|
|
1162
|
-
scheme: "dark",
|
|
1163
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(react.MediaController, {
|
|
1164
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(MuxVideo__default.default, {
|
|
1165
|
-
playsInline: true,
|
|
1166
|
-
ref: video,
|
|
1167
|
-
playbackId: "".concat(asset.playbackId).concat(signedToken ? "?token=".concat(signedToken) : ""),
|
|
1168
|
-
onError: handleError,
|
|
1169
|
-
slot: "media",
|
|
1170
|
-
preload: "metadata",
|
|
1171
|
-
crossOrigin: "anonomous",
|
|
1172
|
-
debug: true,
|
|
1173
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ThumbnailsMetadataTrack, {
|
|
1174
|
-
asset
|
|
1175
|
-
})
|
|
1176
|
-
}), /* @__PURE__ */jsxRuntime.jsx(PosterImage, {
|
|
1177
|
-
asset
|
|
1178
|
-
}), /* @__PURE__ */jsxRuntime.jsx(react.MediaLoadingIndicator, {
|
|
1179
|
-
slot: "centered-chrome",
|
|
1180
|
-
noAutoHide: true
|
|
1181
|
-
}), /* @__PURE__ */jsxRuntime.jsx(StyledCenterControls, {
|
|
1182
|
-
slot: "centered-chrome",
|
|
1183
|
-
children: /* @__PURE__ */jsxRuntime.jsx(react.MediaPlayButton, {})
|
|
1184
|
-
}), buttons && /* @__PURE__ */jsxRuntime.jsx(TopControls, {
|
|
1185
|
-
slot: "top-chrome",
|
|
1186
|
-
children: buttons
|
|
1187
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(react.MediaControlBar, {
|
|
1188
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(react.MediaMuteButton, {}), /* @__PURE__ */jsxRuntime.jsx(react.MediaTimeDisplay, {}), /* @__PURE__ */jsxRuntime.jsx(react.MediaTimeRange, {}), /* @__PURE__ */jsxRuntime.jsx(react.MediaDurationDisplay, {}), /* @__PURE__ */jsxRuntime.jsx(react.MediaFullscreenButton, {})]
|
|
1189
|
-
})]
|
|
1190
|
-
}), isPreparingStaticRenditions && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
1191
|
-
padding: 2,
|
|
1192
|
-
radius: 1,
|
|
1193
|
-
style: {
|
|
1194
|
-
background: "var(--card-fg-color)",
|
|
1195
|
-
position: "absolute",
|
|
1196
|
-
top: "0.5em",
|
|
1197
|
-
left: "0.5em"
|
|
1198
|
-
},
|
|
1199
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
1200
|
-
size: 1,
|
|
1201
|
-
style: {
|
|
1202
|
-
color: "var(--card-bg-color)"
|
|
1203
|
-
},
|
|
1204
|
-
children: "MUX is preparing static renditions, please stand by"
|
|
1205
|
-
})
|
|
1206
|
-
})]
|
|
1207
|
-
}), dialogState === "edit-thumbnail" && /* @__PURE__ */jsxRuntime.jsx(EditThumbnailDialog, {
|
|
1208
|
-
asset,
|
|
1209
|
-
getCurrentTime,
|
|
1210
|
-
setDialogState
|
|
1211
|
-
})]
|
|
1212
|
-
});
|
|
1213
|
-
};
|
|
1214
|
-
function focusRingBorderStyle(border) {
|
|
1215
|
-
return "inset 0 0 0 ".concat(border.width, "px ").concat(border.color);
|
|
1216
|
-
}
|
|
1217
|
-
function focusRingStyle(opts) {
|
|
1218
|
-
const {
|
|
1219
|
-
base,
|
|
1220
|
-
border,
|
|
1221
|
-
focusRing
|
|
1222
|
-
} = opts;
|
|
1223
|
-
const focusRingOutsetWidth = focusRing.offset + focusRing.width;
|
|
1224
|
-
const focusRingInsetWidth = 0 - focusRing.offset;
|
|
1225
|
-
const bgColor = base ? base.bg : "var(--card-bg-color)";
|
|
1226
|
-
return [focusRingInsetWidth > 0 && "inset 0 0 0 ".concat(focusRingInsetWidth, "px var(--card-focus-ring-color)"), border && focusRingBorderStyle(border), focusRingInsetWidth < 0 && "0 0 0 ".concat(0 - focusRingInsetWidth, "px ").concat(bgColor), focusRingOutsetWidth > 0 && "0 0 0 ".concat(focusRingOutsetWidth, "px var(--card-focus-ring-color)")].filter(Boolean).join(",");
|
|
1227
|
-
}
|
|
1228
|
-
const FileButton = styled__default.default(ui.MenuItem)(_ref12 => {
|
|
1229
|
-
let {
|
|
1230
|
-
theme
|
|
1231
|
-
} = _ref12;
|
|
1232
|
-
const {
|
|
1233
|
-
focusRing
|
|
1234
|
-
} = theme.sanity;
|
|
1235
|
-
const base = theme.sanity.color.base;
|
|
1236
|
-
const border = {
|
|
1237
|
-
width: 1,
|
|
1238
|
-
color: "var(--card-border-color)"
|
|
1239
|
-
};
|
|
1240
|
-
return styled.css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n\n &:not([data-disabled='true']) {\n &:focus-within {\n box-shadow: ", ";\n }\n }\n\n & input {\n overflow: hidden;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n min-width: 0;\n display: block;\n appearance: none;\n padding: 0;\n margin: 0;\n border: 0;\n opacity: 0;\n }\n "])), focusRingStyle({
|
|
1241
|
-
base,
|
|
1242
|
-
border,
|
|
1243
|
-
focusRing
|
|
1244
|
-
}));
|
|
1245
|
-
});
|
|
1246
|
-
const FileInputMenuItem = React__default.default.forwardRef(function FileInputMenuItem2(props, forwardedRef) {
|
|
1247
|
-
const {
|
|
1248
|
-
icon,
|
|
1249
|
-
id: idProp,
|
|
1250
|
-
accept,
|
|
1251
|
-
capture,
|
|
1252
|
-
fontSize,
|
|
1253
|
-
multiple,
|
|
1254
|
-
onSelect,
|
|
1255
|
-
padding = 3,
|
|
1256
|
-
space = 3,
|
|
1257
|
-
textAlign,
|
|
1258
|
-
text,
|
|
1259
|
-
disabled,
|
|
1260
|
-
...rest
|
|
1261
|
-
} = props;
|
|
1262
|
-
const idHook = React.useId();
|
|
1263
|
-
const id = idProp || idHook;
|
|
1264
|
-
const handleChange = React__default.default.useCallback(event => {
|
|
1265
|
-
if (onSelect && event.target.files) {
|
|
1266
|
-
onSelect(Array.from(event.target.files));
|
|
1267
|
-
}
|
|
1268
|
-
}, [onSelect]);
|
|
1269
|
-
const content = /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
1270
|
-
align: "center",
|
|
1271
|
-
justify: "flex-start",
|
|
1272
|
-
padding,
|
|
1273
|
-
children: [icon && /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
1274
|
-
marginRight: text ? space : void 0,
|
|
1275
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
1276
|
-
size: fontSize,
|
|
1277
|
-
children: [React.isValidElement(icon) && icon, reactIs.isValidElementType(icon) && React.createElement(icon)]
|
|
1278
|
-
})
|
|
1279
|
-
}), text && /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
1280
|
-
align: textAlign,
|
|
1281
|
-
size: fontSize,
|
|
1282
|
-
textOverflow: "ellipsis",
|
|
1283
|
-
children: text
|
|
1284
|
-
})]
|
|
1285
|
-
});
|
|
1286
|
-
return /* @__PURE__ */jsxRuntime.jsxs(FileButton, {
|
|
1287
|
-
...rest,
|
|
1288
|
-
htmlFor: id,
|
|
1289
|
-
padding: 0,
|
|
1290
|
-
fontSize: 2,
|
|
1291
|
-
disabled,
|
|
1292
|
-
ref: forwardedRef,
|
|
1293
|
-
children: [content, /* @__PURE__ */jsxRuntime.jsx("input", {
|
|
1294
|
-
"data-testid": "file-button-input",
|
|
1295
|
-
accept,
|
|
1296
|
-
capture,
|
|
1297
|
-
id,
|
|
1298
|
-
multiple,
|
|
1299
|
-
onChange: handleChange,
|
|
1300
|
-
type: "file",
|
|
1301
|
-
value: "",
|
|
1302
|
-
disabled
|
|
1303
|
-
})]
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1306
|
-
const LockCard = styled__default.default(ui.Card)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0.6;\n mix-blend-mode: screen;\n background: transparent;\n"])));
|
|
1307
|
-
const LockButton = styled__default.default(ui.Button)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n background: transparent;\n color: white;\n"])));
|
|
1308
|
-
function PlayerActionsMenu(props) {
|
|
1309
|
-
const {
|
|
1310
|
-
asset,
|
|
1311
|
-
readOnly,
|
|
1312
|
-
dialogState,
|
|
1313
|
-
setDialogState,
|
|
1314
|
-
onChange,
|
|
1315
|
-
onUpload
|
|
1316
|
-
} = props;
|
|
1317
|
-
const [open, setOpen] = React.useState(false);
|
|
1318
|
-
const [menuElement, setMenuRef] = React.useState(null);
|
|
1319
|
-
const isSigned = React.useMemo(() => VideoSource_styled.getPlaybackPolicy(asset) === "signed", [asset]);
|
|
1320
|
-
const onReset = React.useCallback(() => onChange(sanity.PatchEvent.from(sanity.unset([]))), [onChange]);
|
|
1321
|
-
React.useEffect(() => {
|
|
1322
|
-
if (open && dialogState) {
|
|
1323
|
-
setOpen(false);
|
|
1324
|
-
}
|
|
1325
|
-
}, [dialogState, open]);
|
|
1326
|
-
ui.useClickOutside(React.useCallback(() => setOpen(false), []), [menuElement]);
|
|
1327
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Inline, {
|
|
1328
|
-
space: 1,
|
|
1329
|
-
padding: 2,
|
|
1330
|
-
children: [isSigned && /* @__PURE__ */jsxRuntime.jsx(ui.Tooltip, {
|
|
1331
|
-
content: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
1332
|
-
padding: 2,
|
|
1333
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
1334
|
-
muted: true,
|
|
1335
|
-
size: 1,
|
|
1336
|
-
children: "Signed playback policy"
|
|
1337
|
-
})
|
|
1338
|
-
}),
|
|
1339
|
-
placement: "right",
|
|
1340
|
-
portal: true,
|
|
1341
|
-
children: /* @__PURE__ */jsxRuntime.jsx(LockCard, {
|
|
1342
|
-
radius: 2,
|
|
1343
|
-
margin: 2,
|
|
1344
|
-
scheme: "dark",
|
|
1345
|
-
tone: "positive",
|
|
1346
|
-
children: /* @__PURE__ */jsxRuntime.jsx(LockButton, {
|
|
1347
|
-
icon: icons.LockIcon,
|
|
1348
|
-
mode: "bleed",
|
|
1349
|
-
tone: "positive"
|
|
1350
|
-
})
|
|
1351
|
-
})
|
|
1352
|
-
}), !readOnly && /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
1353
|
-
icon: icons.EditIcon,
|
|
1354
|
-
mode: "ghost",
|
|
1355
|
-
onClick: () => setDialogState("edit-thumbnail")
|
|
1356
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Popover, {
|
|
1357
|
-
content: /* @__PURE__ */jsxRuntime.jsxs(ui.Menu, {
|
|
1358
|
-
ref: setMenuRef,
|
|
1359
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
1360
|
-
padding: 2,
|
|
1361
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
|
|
1362
|
-
muted: true,
|
|
1363
|
-
size: 1,
|
|
1364
|
-
children: "Replace"
|
|
1365
|
-
})
|
|
1366
|
-
}), /* @__PURE__ */jsxRuntime.jsx(FileInputMenuItem, {
|
|
1367
|
-
accept: "video/*",
|
|
1368
|
-
icon: icons.UploadIcon,
|
|
1369
|
-
mode: "bleed",
|
|
1370
|
-
onSelect: onUpload,
|
|
1371
|
-
text: "Upload",
|
|
1372
|
-
disabled: readOnly,
|
|
1373
|
-
fontSize: 2
|
|
1374
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.MenuItem, {
|
|
1375
|
-
icon: icons.SearchIcon,
|
|
1376
|
-
text: "Browse",
|
|
1377
|
-
onClick: () => setDialogState("select-video")
|
|
1378
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.MenuDivider, {}), /* @__PURE__ */jsxRuntime.jsx(ui.MenuItem, {
|
|
1379
|
-
icon: icons.PlugIcon,
|
|
1380
|
-
text: "Configure API",
|
|
1381
|
-
onClick: () => setDialogState("secrets")
|
|
1382
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.MenuDivider, {}), /* @__PURE__ */jsxRuntime.jsx(ui.MenuItem, {
|
|
1383
|
-
tone: "critical",
|
|
1384
|
-
icon: icons.ResetIcon,
|
|
1385
|
-
text: "Clear field",
|
|
1386
|
-
onClick: onReset,
|
|
1387
|
-
disabled: readOnly
|
|
1388
|
-
})]
|
|
1389
|
-
}),
|
|
1390
|
-
portal: true,
|
|
1391
|
-
open,
|
|
1392
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
1393
|
-
icon: icons.EllipsisVerticalIcon,
|
|
1394
|
-
mode: "ghost",
|
|
1395
|
-
onClick: () => {
|
|
1396
|
-
setDialogState(false);
|
|
1397
|
-
setOpen(true);
|
|
1398
|
-
}
|
|
1399
|
-
})
|
|
1400
|
-
})]
|
|
1401
|
-
});
|
|
1402
|
-
}
|
|
1403
|
-
var PlayerActionsMenu$1 = React.memo(PlayerActionsMenu);
|
|
1404
|
-
function withFocusRing(component) {
|
|
1405
|
-
return styled__default.default(component)(props => {
|
|
1406
|
-
const border = {
|
|
1407
|
-
width: props.$border ? 1 : 0,
|
|
1408
|
-
color: "var(--card-border-color)"
|
|
1409
|
-
};
|
|
1410
|
-
return styled.css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n --card-focus-box-shadow: ", ";\n\n border-radius: ", ";\n outline: none;\n box-shadow: var(--card-focus-box-shadow);\n\n &:focus {\n --card-focus-box-shadow: ", ";\n }\n "])), focusRingBorderStyle(border), ui.rem(props.theme.sanity.radius[1]), focusRingStyle({
|
|
1411
|
-
base: props.theme.sanity.color.base,
|
|
1412
|
-
border,
|
|
1413
|
-
focusRing: props.theme.sanity.focusRing
|
|
1414
|
-
}));
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
const ctrlKey = 17;
|
|
1418
|
-
const cmdKey = 91;
|
|
1419
|
-
const UploadCardWithFocusRing = withFocusRing(ui.Card);
|
|
1420
|
-
const UploadCard$1 = React.forwardRef((_ref13, forwardedRef) => {
|
|
1421
|
-
let {
|
|
1422
|
-
children,
|
|
1423
|
-
tone,
|
|
1424
|
-
onPaste,
|
|
1425
|
-
onDrop,
|
|
1426
|
-
onDragEnter,
|
|
1427
|
-
onDragLeave,
|
|
1428
|
-
onDragOver
|
|
1429
|
-
} = _ref13;
|
|
1430
|
-
const ctrlDown = React.useRef(false);
|
|
1431
|
-
const inputRef = React.useRef(null);
|
|
1432
|
-
const handleKeyDown = React.useCallback(event => {
|
|
1433
|
-
if (event.keyCode == ctrlKey || event.keyCode == cmdKey) {
|
|
1434
|
-
ctrlDown.current = true;
|
|
1435
|
-
}
|
|
1436
|
-
const vKey = 86;
|
|
1437
|
-
if (ctrlDown.current && event.keyCode == vKey) {
|
|
1438
|
-
inputRef.current.focus();
|
|
1439
|
-
}
|
|
1440
|
-
}, []);
|
|
1441
|
-
const handleKeyUp = React.useCallback(event => {
|
|
1442
|
-
if (event.keyCode == ctrlKey || event.keyCode == cmdKey) {
|
|
1443
|
-
ctrlDown.current = false;
|
|
1444
|
-
}
|
|
1445
|
-
}, []);
|
|
1446
|
-
return /* @__PURE__ */jsxRuntime.jsxs(UploadCardWithFocusRing, {
|
|
1447
|
-
tone,
|
|
1448
|
-
height: "fill",
|
|
1449
|
-
ref: forwardedRef,
|
|
1450
|
-
padding: 0,
|
|
1451
|
-
radius: 2,
|
|
1452
|
-
shadow: 0,
|
|
1453
|
-
tabIndex: 0,
|
|
1454
|
-
onKeyDown: handleKeyDown,
|
|
1455
|
-
onKeyUp: handleKeyUp,
|
|
1456
|
-
onPaste,
|
|
1457
|
-
onDrop,
|
|
1458
|
-
onDragEnter,
|
|
1459
|
-
onDragLeave,
|
|
1460
|
-
onDragOver,
|
|
1461
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(HiddenInput$1, {
|
|
1462
|
-
ref: inputRef,
|
|
1463
|
-
onPaste
|
|
1464
|
-
}), children]
|
|
1465
|
-
});
|
|
1466
|
-
});
|
|
1467
|
-
const HiddenInput$1 = styled__default.default.input.attrs({
|
|
1468
|
-
type: "text"
|
|
1469
|
-
})(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: absolute;\n border: 0;\n color: white;\n opacity: 0;\n\n &:focus {\n outline: none;\n }\n"])));
|
|
1470
|
-
const HiddenInput = styled__default.default.input(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n overflow: hidden;\n width: 0.1px;\n height: 0.1px;\n opacity: 0;\n position: absolute;\n z-index: -1;\n"])));
|
|
1471
|
-
const Label = styled__default.default.label(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
1472
|
-
const FileInputButton = _ref14 => {
|
|
1473
|
-
let {
|
|
1474
|
-
onSelect,
|
|
1475
|
-
...props
|
|
1476
|
-
} = _ref14;
|
|
1477
|
-
const inputId = "FileSelect".concat(React.useId());
|
|
1478
|
-
const inputRef = React.useRef(null);
|
|
1479
|
-
const handleSelect = React.useCallback(event => {
|
|
1480
|
-
if (onSelect) {
|
|
1481
|
-
onSelect(event.target.files);
|
|
1482
|
-
}
|
|
1483
|
-
}, [onSelect]);
|
|
1484
|
-
const handleButtonClick = React.useCallback(() => {
|
|
1485
|
-
var _a;
|
|
1486
|
-
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
1487
|
-
}, []);
|
|
1488
|
-
return /* @__PURE__ */jsxRuntime.jsxs(Label, {
|
|
1489
|
-
htmlFor: inputId,
|
|
1490
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(HiddenInput, {
|
|
1491
|
-
accept: "video/*",
|
|
1492
|
-
ref: inputRef,
|
|
1493
|
-
tabIndex: 0,
|
|
1494
|
-
type: "file",
|
|
1495
|
-
id: inputId,
|
|
1496
|
-
onChange: handleSelect,
|
|
1497
|
-
value: ""
|
|
1498
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
1499
|
-
onClick: handleButtonClick,
|
|
1500
|
-
mode: "default",
|
|
1501
|
-
tone: "primary",
|
|
1502
|
-
style: {
|
|
1503
|
-
width: "100%"
|
|
1504
|
-
},
|
|
1505
|
-
...props
|
|
1506
|
-
})]
|
|
1507
|
-
});
|
|
1508
|
-
};
|
|
1509
|
-
const UploadCard = styled__default.default(ui.Card)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n && {\n border-style: dashed;\n }\n"])));
|
|
1510
|
-
const ConfigureApiBox = styled__default.default(ui.Box)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n right: 0;\n"])));
|
|
1511
|
-
function UploadPlaceholder(props) {
|
|
1512
|
-
const {
|
|
1513
|
-
setDialogState,
|
|
1514
|
-
readOnly,
|
|
1515
|
-
onSelect,
|
|
1516
|
-
hovering,
|
|
1517
|
-
needsSetup
|
|
1518
|
-
} = props;
|
|
1519
|
-
const handleBrowse = React.useCallback(() => setDialogState("select-video"), [setDialogState]);
|
|
1520
|
-
const handleConfigureApi = React.useCallback(() => setDialogState("secrets"), [setDialogState]);
|
|
1521
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
1522
|
-
style: {
|
|
1523
|
-
padding: 1,
|
|
1524
|
-
position: "relative"
|
|
1525
|
-
},
|
|
1526
|
-
height: "stretch",
|
|
1527
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(UploadCard, {
|
|
1528
|
-
sizing: "border",
|
|
1529
|
-
height: "fill",
|
|
1530
|
-
tone: readOnly ? "transparent" : "inherit",
|
|
1531
|
-
border: true,
|
|
1532
|
-
padding: 3,
|
|
1533
|
-
style: hovering ? {
|
|
1534
|
-
borderColor: "transparent"
|
|
1535
|
-
} : void 0,
|
|
1536
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ConfigureApiBox, {
|
|
1537
|
-
padding: 3,
|
|
1538
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
1539
|
-
padding: 3,
|
|
1540
|
-
radius: 3,
|
|
1541
|
-
tone: needsSetup ? "critical" : void 0,
|
|
1542
|
-
onClick: handleConfigureApi,
|
|
1543
|
-
icon: icons.PlugIcon,
|
|
1544
|
-
mode: "bleed"
|
|
1545
|
-
})
|
|
1546
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
1547
|
-
align: "center",
|
|
1548
|
-
justify: "space-between",
|
|
1549
|
-
gap: 4,
|
|
1550
|
-
direction: ["column", "column", "row"],
|
|
1551
|
-
paddingY: [2, 2, 0],
|
|
1552
|
-
sizing: "border",
|
|
1553
|
-
height: "fill",
|
|
1554
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
1555
|
-
align: "center",
|
|
1556
|
-
justify: "center",
|
|
1557
|
-
gap: 2,
|
|
1558
|
-
flex: 1,
|
|
1559
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
1560
|
-
justify: "center",
|
|
1561
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
1562
|
-
muted: true,
|
|
1563
|
-
children: /* @__PURE__ */jsxRuntime.jsx(icons.DocumentVideoIcon, {})
|
|
1564
|
-
})
|
|
1565
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
1566
|
-
justify: "center",
|
|
1567
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
1568
|
-
size: 1,
|
|
1569
|
-
muted: true,
|
|
1570
|
-
children: "Drag video or paste URL here"
|
|
1571
|
-
})
|
|
1572
|
-
})]
|
|
1573
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Inline, {
|
|
1574
|
-
space: 2,
|
|
1575
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(FileInputButton, {
|
|
1576
|
-
mode: "ghost",
|
|
1577
|
-
tone: "default",
|
|
1578
|
-
icon: icons.UploadIcon,
|
|
1579
|
-
text: "Upload",
|
|
1580
|
-
onSelect
|
|
1581
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
1582
|
-
mode: "ghost",
|
|
1583
|
-
icon: icons.SearchIcon,
|
|
1584
|
-
text: "Select",
|
|
1585
|
-
onClick: handleBrowse
|
|
1586
|
-
})]
|
|
1587
|
-
})]
|
|
1588
|
-
})]
|
|
1589
|
-
})
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
class MuxVideoInputUploader extends React.Component {
|
|
1593
|
-
constructor() {
|
|
1594
|
-
super(...arguments);
|
|
1595
|
-
this.state = {
|
|
1596
|
-
isDraggingOver: false,
|
|
1597
|
-
invalidPaste: false,
|
|
1598
|
-
invalidFile: false,
|
|
1599
|
-
uploadProgress: null,
|
|
1600
|
-
fileInfo: null,
|
|
1601
|
-
uuid: null,
|
|
1602
|
-
error: null,
|
|
1603
|
-
url: null
|
|
1604
|
-
};
|
|
1605
|
-
this.dragEnteredEls = [];
|
|
1606
|
-
this.ctrlDown = false;
|
|
1607
|
-
// eslint-disable-next-line no-warning-comments
|
|
1608
|
-
// @TODO add proper typings for the return values of uploadFile and uploadUrl
|
|
1609
|
-
this.upload = null;
|
|
1610
|
-
this.container = React__default.default.createRef();
|
|
1611
|
-
this.handleProgress = evt => {
|
|
1612
|
-
this.setState({
|
|
1613
|
-
uploadProgress: evt.percent
|
|
1614
|
-
});
|
|
1615
|
-
};
|
|
1616
|
-
this.onUpload = files => {
|
|
1617
|
-
this.setState({
|
|
1618
|
-
uploadProgress: 0,
|
|
1619
|
-
fileInfo: null,
|
|
1620
|
-
uuid: null
|
|
1621
|
-
});
|
|
1622
|
-
this.upload = uploadFile(this.props.config, this.props.client, files[0], {
|
|
1623
|
-
enableSignedUrls: this.props.secrets.enableSignedUrls
|
|
1624
|
-
}).pipe(operators.takeUntil(this.onCancelUploadButtonClick$.pipe(operators.tap(() => {
|
|
1625
|
-
if (this.state.uuid) {
|
|
1626
|
-
this.props.client.delete(this.state.uuid);
|
|
1627
|
-
}
|
|
1628
|
-
})))).subscribe({
|
|
1629
|
-
complete: () => {
|
|
1630
|
-
this.setState({
|
|
1631
|
-
error: null,
|
|
1632
|
-
uploadProgress: null,
|
|
1633
|
-
uuid: null
|
|
1634
|
-
});
|
|
1635
|
-
},
|
|
1636
|
-
next: event => {
|
|
1637
|
-
this.handleUploadEvent(event);
|
|
1638
|
-
},
|
|
1639
|
-
error: err => {
|
|
1640
|
-
this.setState({
|
|
1641
|
-
error: err,
|
|
1642
|
-
uploadProgress: null,
|
|
1643
|
-
uuid: null
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
});
|
|
1647
|
-
};
|
|
1648
|
-
// eslint-disable-next-line no-warning-comments
|
|
1649
|
-
// @TODO add proper typings for the Observable events
|
|
1650
|
-
this.handleUploadEvent = event => {
|
|
1651
|
-
switch (event.type) {
|
|
1652
|
-
case "success":
|
|
1653
|
-
return this.handleUploadSuccess(event.asset);
|
|
1654
|
-
case "progress":
|
|
1655
|
-
return this.handleProgress(event);
|
|
1656
|
-
case "file":
|
|
1657
|
-
return this.setState({
|
|
1658
|
-
fileInfo: event.file
|
|
1659
|
-
});
|
|
1660
|
-
case "uuid":
|
|
1661
|
-
return this.setState({
|
|
1662
|
-
uuid: event.uuid
|
|
1663
|
-
});
|
|
1664
|
-
case "url":
|
|
1665
|
-
return this.setState({
|
|
1666
|
-
url: event.url,
|
|
1667
|
-
uploadProgress: 100
|
|
1668
|
-
});
|
|
1669
|
-
default:
|
|
1670
|
-
return null;
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
this.handleUploadSuccess = asset => {
|
|
1674
|
-
this.setState({
|
|
1675
|
-
uploadProgress: 100
|
|
1676
|
-
});
|
|
1677
|
-
this.props.onChange(sanity.PatchEvent.from([sanity.setIfMissing({
|
|
1678
|
-
asset: {}
|
|
1679
|
-
}), sanity.set({
|
|
1680
|
-
_type: "reference",
|
|
1681
|
-
_weak: true,
|
|
1682
|
-
_ref: asset._id
|
|
1683
|
-
}, ["asset"])]));
|
|
1684
|
-
};
|
|
1685
|
-
this.handlePaste = event => {
|
|
1686
|
-
const clipboardData = event.clipboardData || window.clipboardData;
|
|
1687
|
-
const url = clipboardData.getData("text");
|
|
1688
|
-
const options = {
|
|
1689
|
-
enableSignedUrls: this.props.secrets.enableSignedUrls
|
|
1690
|
-
};
|
|
1691
|
-
this.upload = uploadUrl(this.props.config, this.props.client, url, options).subscribe({
|
|
1692
|
-
complete: () => {
|
|
1693
|
-
this.setState({
|
|
1694
|
-
error: null,
|
|
1695
|
-
uploadProgress: null,
|
|
1696
|
-
url: null
|
|
1697
|
-
});
|
|
1698
|
-
},
|
|
1699
|
-
next: sEvent => {
|
|
1700
|
-
this.handleUploadEvent(sEvent);
|
|
1701
|
-
},
|
|
1702
|
-
error: err => {
|
|
1703
|
-
let error;
|
|
1704
|
-
if (!err.message.toLowerCase().match("invalid url")) {
|
|
1705
|
-
error = err;
|
|
1706
|
-
}
|
|
1707
|
-
this.setState({
|
|
1708
|
-
invalidPaste: true,
|
|
1709
|
-
error
|
|
1710
|
-
}, () => {
|
|
1711
|
-
setTimeout(() => {
|
|
1712
|
-
this.setState({
|
|
1713
|
-
invalidPaste: false,
|
|
1714
|
-
uploadProgress: null
|
|
1715
|
-
});
|
|
1716
|
-
}, 2e3);
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1719
|
-
});
|
|
1720
|
-
};
|
|
1721
|
-
this.handleDrop = event => {
|
|
1722
|
-
this.setState({
|
|
1723
|
-
isDraggingOver: false
|
|
1724
|
-
});
|
|
1725
|
-
event.preventDefault();
|
|
1726
|
-
event.stopPropagation();
|
|
1727
|
-
extractDroppedFiles(event.nativeEvent.dataTransfer).then(files => {
|
|
1728
|
-
if (files) {
|
|
1729
|
-
this.onUpload(files);
|
|
1730
|
-
}
|
|
1731
|
-
});
|
|
1732
|
-
};
|
|
1733
|
-
this.handleDragOver = event => {
|
|
1734
|
-
event.preventDefault();
|
|
1735
|
-
event.stopPropagation();
|
|
1736
|
-
};
|
|
1737
|
-
this.handleDragEnter = event => {
|
|
1738
|
-
var _a, _b;
|
|
1739
|
-
event.stopPropagation();
|
|
1740
|
-
this.dragEnteredEls.push(event.target);
|
|
1741
|
-
this.setState({
|
|
1742
|
-
isDraggingOver: true
|
|
1743
|
-
});
|
|
1744
|
-
const type = (_b = (_a = event.dataTransfer.items) == null ? void 0 : _a[0]) == null ? void 0 : _b.type;
|
|
1745
|
-
this.setState({
|
|
1746
|
-
invalidFile: !type.startsWith("video/")
|
|
1747
|
-
});
|
|
1748
|
-
};
|
|
1749
|
-
this.handleDragLeave = event => {
|
|
1750
|
-
event.stopPropagation();
|
|
1751
|
-
const idx = this.dragEnteredEls.indexOf(event.target);
|
|
1752
|
-
if (idx > -1) {
|
|
1753
|
-
this.dragEnteredEls.splice(idx, 1);
|
|
1754
|
-
}
|
|
1755
|
-
if (this.dragEnteredEls.length === 0) {
|
|
1756
|
-
this.setState({
|
|
1757
|
-
isDraggingOver: false
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1761
|
-
}
|
|
1762
|
-
componentWillUnmount() {
|
|
1763
|
-
this.unSubscribeToUpload();
|
|
1764
|
-
}
|
|
1765
|
-
componentDidMount() {
|
|
1766
|
-
const events$ = new rxjs.Subject();
|
|
1767
|
-
this.onCancelUploadButtonClick$ = events$.asObservable();
|
|
1768
|
-
this.handleCancelUploadButtonClick = event => events$.next(event);
|
|
1769
|
-
}
|
|
1770
|
-
unSubscribeToUpload() {
|
|
1771
|
-
if (this.upload && !this.upload.closed) {
|
|
1772
|
-
this.upload.unsubscribe();
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
render() {
|
|
1776
|
-
var _a;
|
|
1777
|
-
if (this.state.uploadProgress !== null) {
|
|
1778
|
-
return /* @__PURE__ */jsxRuntime.jsx(UploadProgress, {
|
|
1779
|
-
onCancel: this.handleCancelUploadButtonClick,
|
|
1780
|
-
progress: this.state.uploadProgress,
|
|
1781
|
-
filename: ((_a = this.state.fileInfo) == null ? void 0 : _a.name) || this.state.url
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
|
-
if (this.state.error) {
|
|
1785
|
-
throw this.state.error;
|
|
1786
|
-
}
|
|
1787
|
-
return /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1788
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(UploadCard$1, {
|
|
1789
|
-
tone: this.state.isDraggingOver && (this.state.invalidPaste || this.state.invalidFile) ? "critical" : this.state.isDraggingOver ? "positive" : void 0,
|
|
1790
|
-
onDrop: this.handleDrop,
|
|
1791
|
-
onDragOver: this.handleDragOver,
|
|
1792
|
-
onDragLeave: this.handleDragLeave,
|
|
1793
|
-
onDragEnter: this.handleDragEnter,
|
|
1794
|
-
onPaste: this.handlePaste,
|
|
1795
|
-
ref: this.container,
|
|
1796
|
-
children: this.props.asset ? /* @__PURE__ */jsxRuntime.jsx(MuxVideoOld, {
|
|
1797
|
-
readOnly: this.props.readOnly,
|
|
1798
|
-
asset: this.props.asset,
|
|
1799
|
-
onChange: this.props.onChange,
|
|
1800
|
-
dialogState: this.props.dialogState,
|
|
1801
|
-
setDialogState: this.props.setDialogState,
|
|
1802
|
-
buttons: /* @__PURE__ */jsxRuntime.jsx(PlayerActionsMenu$1, {
|
|
1803
|
-
asset: this.props.asset,
|
|
1804
|
-
dialogState: this.props.dialogState,
|
|
1805
|
-
setDialogState: this.props.setDialogState,
|
|
1806
|
-
onChange: this.props.onChange,
|
|
1807
|
-
onUpload: this.onUpload,
|
|
1808
|
-
readOnly: this.props.readOnly
|
|
1809
|
-
})
|
|
1810
|
-
}) : /* @__PURE__ */jsxRuntime.jsx(UploadPlaceholder, {
|
|
1811
|
-
hovering: this.state.isDraggingOver,
|
|
1812
|
-
onSelect: this.onUpload,
|
|
1813
|
-
readOnly: this.props.readOnly,
|
|
1814
|
-
setDialogState: this.props.setDialogState,
|
|
1815
|
-
needsSetup: this.props.needsSetup
|
|
1816
|
-
})
|
|
1817
|
-
}), this.props.dialogState === "select-video" && /* @__PURE__ */jsxRuntime.jsx(InputBrowser, {
|
|
1818
|
-
asset: this.props.asset,
|
|
1819
|
-
onChange: this.props.onChange,
|
|
1820
|
-
setDialogState: this.props.setDialogState
|
|
1821
|
-
})]
|
|
1822
|
-
});
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
const useSaveSecrets = (client, secrets) => {
|
|
1826
|
-
return React.useCallback(async _ref15 => {
|
|
1827
|
-
let {
|
|
1828
|
-
token,
|
|
1829
|
-
secretKey,
|
|
1830
|
-
enableSignedUrls
|
|
1831
|
-
} = _ref15;
|
|
1832
|
-
let {
|
|
1833
|
-
signingKeyId,
|
|
1834
|
-
signingKeyPrivate
|
|
1835
|
-
} = secrets;
|
|
1836
|
-
try {
|
|
1837
|
-
await saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate);
|
|
1838
|
-
const valid = await testSecrets(client);
|
|
1839
|
-
if (!(valid == null ? void 0 : valid.status) && token && secretKey) {
|
|
1840
|
-
throw new Error("Invalid secrets");
|
|
1841
|
-
}
|
|
1842
|
-
} catch (err) {
|
|
1843
|
-
console.error("Error while trying to save secrets:", err);
|
|
1844
|
-
throw err;
|
|
1845
|
-
}
|
|
1846
|
-
if (enableSignedUrls) {
|
|
1847
|
-
const hasValidSigningKeys = await haveValidSigningKeys(client, signingKeyId, signingKeyPrivate);
|
|
1848
|
-
if (!hasValidSigningKeys) {
|
|
1849
|
-
try {
|
|
1850
|
-
const {
|
|
1851
|
-
data
|
|
1852
|
-
} = await createSigningKeys(client);
|
|
1853
|
-
signingKeyId = data.id;
|
|
1854
|
-
signingKeyPrivate = data.private_key;
|
|
1855
|
-
await saveSecrets(client, token, secretKey, enableSignedUrls, signingKeyId, signingKeyPrivate);
|
|
1856
|
-
} catch (err) {
|
|
1857
|
-
console.log("Error while creating and saving signing key:", err == null ? void 0 : err.message);
|
|
1858
|
-
throw err;
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
return {
|
|
1863
|
-
token,
|
|
1864
|
-
secretKey,
|
|
1865
|
-
enableSignedUrls,
|
|
1866
|
-
signingKeyId,
|
|
1867
|
-
signingKeyPrivate
|
|
1868
|
-
};
|
|
1869
|
-
}, [client, secrets]);
|
|
1870
|
-
};
|
|
1871
|
-
function init(_ref16) {
|
|
1872
|
-
let {
|
|
1873
|
-
token,
|
|
1874
|
-
secretKey,
|
|
1875
|
-
enableSignedUrls
|
|
1876
|
-
} = _ref16;
|
|
1877
|
-
return {
|
|
1878
|
-
submitting: false,
|
|
1879
|
-
error: null,
|
|
1880
|
-
// Form inputs don't set the state back to null when clearing a field, but uses empty strings
|
|
1881
|
-
// This ensures the `dirty` check works correctly
|
|
1882
|
-
token: token != null ? token : "",
|
|
1883
|
-
secretKey: secretKey != null ? secretKey : "",
|
|
1884
|
-
enableSignedUrls: enableSignedUrls != null ? enableSignedUrls : false
|
|
1885
|
-
};
|
|
1886
|
-
}
|
|
1887
|
-
function reducer(state, action) {
|
|
1888
|
-
switch (action == null ? void 0 : action.type) {
|
|
1889
|
-
case "submit":
|
|
1890
|
-
return {
|
|
1891
|
-
...state,
|
|
1892
|
-
submitting: true,
|
|
1893
|
-
error: null
|
|
1894
|
-
};
|
|
1895
|
-
case "error":
|
|
1896
|
-
return {
|
|
1897
|
-
...state,
|
|
1898
|
-
submitting: false,
|
|
1899
|
-
error: action.payload
|
|
1900
|
-
};
|
|
1901
|
-
case "reset":
|
|
1902
|
-
return init(action.payload);
|
|
1903
|
-
case "change":
|
|
1904
|
-
return {
|
|
1905
|
-
...state,
|
|
1906
|
-
[action.payload.name]: action.payload.value
|
|
1907
|
-
};
|
|
1908
|
-
default:
|
|
1909
|
-
throw new Error("Unknown action type: ".concat(action == null ? void 0 : action.type));
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
const useSecretsFormState = secrets => React.useReducer(reducer, secrets, init);
|
|
1913
|
-
const ids = ["title", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r"];
|
|
1914
|
-
function MuxLogo(_ref17) {
|
|
1915
|
-
let {
|
|
1916
|
-
height = 26
|
|
1917
|
-
} = _ref17;
|
|
1918
|
-
const id = React.useId();
|
|
1919
|
-
const [titleId, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = React.useMemo(() => ids.map(field => "".concat(id, "-").concat(field)), [id]);
|
|
1920
|
-
return /* @__PURE__ */jsxRuntime.jsxs("svg", {
|
|
1921
|
-
"aria-labelledby": titleId,
|
|
1922
|
-
role: "img",
|
|
1923
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1924
|
-
xmlSpace: "preserve",
|
|
1925
|
-
viewBox: "92.08878326416016 102.66712188720703 692.76123046875 219.99948120117188",
|
|
1926
|
-
style: {
|
|
1927
|
-
height: "".concat(height, "px")
|
|
1928
|
-
},
|
|
1929
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("title", {
|
|
1930
|
-
id: titleId,
|
|
1931
|
-
children: "Mux Logo"
|
|
1932
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("defs", {
|
|
1933
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
1934
|
-
id: c,
|
|
1935
|
-
spreadMethod: "pad",
|
|
1936
|
-
gradientTransform: "matrix(528.38055 0 0 -528.38055 63.801 159.5)",
|
|
1937
|
-
gradientUnits: "userSpaceOnUse",
|
|
1938
|
-
y2: 0,
|
|
1939
|
-
x2: 1,
|
|
1940
|
-
y1: 0,
|
|
1941
|
-
x1: 0,
|
|
1942
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
1943
|
-
offset: 0,
|
|
1944
|
-
style: {
|
|
1945
|
-
stopOpacity: 1,
|
|
1946
|
-
stopColor: "#ff4e00"
|
|
1947
|
-
}
|
|
1948
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
1949
|
-
offset: 1,
|
|
1950
|
-
style: {
|
|
1951
|
-
stopOpacity: 1,
|
|
1952
|
-
stopColor: "#ff1791"
|
|
1953
|
-
}
|
|
1954
|
-
})]
|
|
1955
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
1956
|
-
id: d,
|
|
1957
|
-
spreadMethod: "pad",
|
|
1958
|
-
gradientTransform: "matrix(523.66766 0 0 -523.66766 67.897 159.5)",
|
|
1959
|
-
gradientUnits: "userSpaceOnUse",
|
|
1960
|
-
y2: 0,
|
|
1961
|
-
x2: 1,
|
|
1962
|
-
y1: 0,
|
|
1963
|
-
x1: 0,
|
|
1964
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
1965
|
-
offset: 0,
|
|
1966
|
-
style: {
|
|
1967
|
-
stopOpacity: 1,
|
|
1968
|
-
stopColor: "#ff4e00"
|
|
1969
|
-
}
|
|
1970
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
1971
|
-
offset: 1,
|
|
1972
|
-
style: {
|
|
1973
|
-
stopOpacity: 1,
|
|
1974
|
-
stopColor: "#ff1791"
|
|
1975
|
-
}
|
|
1976
|
-
})]
|
|
1977
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
1978
|
-
id: g,
|
|
1979
|
-
spreadMethod: "pad",
|
|
1980
|
-
gradientTransform: "rotate(180 296.075 79.75) scale(524.84045)",
|
|
1981
|
-
gradientUnits: "userSpaceOnUse",
|
|
1982
|
-
y2: 0,
|
|
1983
|
-
x2: 1,
|
|
1984
|
-
y1: 0,
|
|
1985
|
-
x1: 0,
|
|
1986
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
1987
|
-
offset: 0,
|
|
1988
|
-
style: {
|
|
1989
|
-
stopOpacity: 1,
|
|
1990
|
-
stopColor: "#ff4e00"
|
|
1991
|
-
}
|
|
1992
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
1993
|
-
offset: 1,
|
|
1994
|
-
style: {
|
|
1995
|
-
stopOpacity: 1,
|
|
1996
|
-
stopColor: "#ff1791"
|
|
1997
|
-
}
|
|
1998
|
-
})]
|
|
1999
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2000
|
-
id: i,
|
|
2001
|
-
spreadMethod: "pad",
|
|
2002
|
-
gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
|
|
2003
|
-
gradientUnits: "userSpaceOnUse",
|
|
2004
|
-
y2: 0,
|
|
2005
|
-
x2: 1,
|
|
2006
|
-
y1: 0,
|
|
2007
|
-
x1: 0,
|
|
2008
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2009
|
-
offset: 0,
|
|
2010
|
-
style: {
|
|
2011
|
-
stopOpacity: 1,
|
|
2012
|
-
stopColor: "#ff4e00"
|
|
2013
|
-
}
|
|
2014
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2015
|
-
offset: 1,
|
|
2016
|
-
style: {
|
|
2017
|
-
stopOpacity: 1,
|
|
2018
|
-
stopColor: "#ff1791"
|
|
2019
|
-
}
|
|
2020
|
-
})]
|
|
2021
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2022
|
-
id: j,
|
|
2023
|
-
spreadMethod: "pad",
|
|
2024
|
-
gradientTransform: "matrix(523.08514 0 0 -523.08514 67.897 224.446)",
|
|
2025
|
-
gradientUnits: "userSpaceOnUse",
|
|
2026
|
-
y2: 0,
|
|
2027
|
-
x2: 1,
|
|
2028
|
-
y1: 0,
|
|
2029
|
-
x1: 0,
|
|
2030
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2031
|
-
offset: 0,
|
|
2032
|
-
style: {
|
|
2033
|
-
stopOpacity: 1,
|
|
2034
|
-
stopColor: "#ff4e00"
|
|
2035
|
-
}
|
|
2036
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2037
|
-
offset: 1,
|
|
2038
|
-
style: {
|
|
2039
|
-
stopOpacity: 1,
|
|
2040
|
-
stopColor: "#ff1791"
|
|
2041
|
-
}
|
|
2042
|
-
})]
|
|
2043
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2044
|
-
id: k,
|
|
2045
|
-
spreadMethod: "pad",
|
|
2046
|
-
gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.553)",
|
|
2047
|
-
gradientUnits: "userSpaceOnUse",
|
|
2048
|
-
y2: 0,
|
|
2049
|
-
x2: 1,
|
|
2050
|
-
y1: 0,
|
|
2051
|
-
x1: 0,
|
|
2052
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2053
|
-
offset: 0,
|
|
2054
|
-
style: {
|
|
2055
|
-
stopOpacity: 1,
|
|
2056
|
-
stopColor: "#ff4e00"
|
|
2057
|
-
}
|
|
2058
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2059
|
-
offset: 1,
|
|
2060
|
-
style: {
|
|
2061
|
-
stopOpacity: 1,
|
|
2062
|
-
stopColor: "#ff1791"
|
|
2063
|
-
}
|
|
2064
|
-
})]
|
|
2065
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2066
|
-
id: l,
|
|
2067
|
-
spreadMethod: "pad",
|
|
2068
|
-
gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
|
|
2069
|
-
gradientUnits: "userSpaceOnUse",
|
|
2070
|
-
y2: 0,
|
|
2071
|
-
x2: 1,
|
|
2072
|
-
y1: 0,
|
|
2073
|
-
x1: 0,
|
|
2074
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2075
|
-
offset: 0,
|
|
2076
|
-
style: {
|
|
2077
|
-
stopOpacity: 1,
|
|
2078
|
-
stopColor: "#ff4e00"
|
|
2079
|
-
}
|
|
2080
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2081
|
-
offset: 1,
|
|
2082
|
-
style: {
|
|
2083
|
-
stopOpacity: 1,
|
|
2084
|
-
stopColor: "#ff1791"
|
|
2085
|
-
}
|
|
2086
|
-
})]
|
|
2087
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2088
|
-
id: m,
|
|
2089
|
-
spreadMethod: "pad",
|
|
2090
|
-
gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 94.554)",
|
|
2091
|
-
gradientUnits: "userSpaceOnUse",
|
|
2092
|
-
y2: 0,
|
|
2093
|
-
x2: 1,
|
|
2094
|
-
y1: 0,
|
|
2095
|
-
x1: 0,
|
|
2096
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2097
|
-
offset: 0,
|
|
2098
|
-
style: {
|
|
2099
|
-
stopOpacity: 1,
|
|
2100
|
-
stopColor: "#ff4e00"
|
|
2101
|
-
}
|
|
2102
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2103
|
-
offset: 1,
|
|
2104
|
-
style: {
|
|
2105
|
-
stopOpacity: 1,
|
|
2106
|
-
stopColor: "#ff1791"
|
|
2107
|
-
}
|
|
2108
|
-
})]
|
|
2109
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2110
|
-
id: p,
|
|
2111
|
-
spreadMethod: "pad",
|
|
2112
|
-
gradientTransform: "matrix(521.97632 0 0 -521.97632 69.067 191.973)",
|
|
2113
|
-
gradientUnits: "userSpaceOnUse",
|
|
2114
|
-
y2: 0,
|
|
2115
|
-
x2: 1,
|
|
2116
|
-
y1: 0,
|
|
2117
|
-
x1: 0,
|
|
2118
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2119
|
-
offset: 0,
|
|
2120
|
-
style: {
|
|
2121
|
-
stopOpacity: 1,
|
|
2122
|
-
stopColor: "#ff4e00"
|
|
2123
|
-
}
|
|
2124
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2125
|
-
offset: 1,
|
|
2126
|
-
style: {
|
|
2127
|
-
stopOpacity: 1,
|
|
2128
|
-
stopColor: "#ff1791"
|
|
2129
|
-
}
|
|
2130
|
-
})]
|
|
2131
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2132
|
-
id: q,
|
|
2133
|
-
spreadMethod: "pad",
|
|
2134
|
-
gradientTransform: "matrix(523.09039 0 0 -523.09039 67.312 191.973)",
|
|
2135
|
-
gradientUnits: "userSpaceOnUse",
|
|
2136
|
-
y2: 0,
|
|
2137
|
-
x2: 1,
|
|
2138
|
-
y1: 0,
|
|
2139
|
-
x1: 0,
|
|
2140
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2141
|
-
offset: 0,
|
|
2142
|
-
style: {
|
|
2143
|
-
stopOpacity: 1,
|
|
2144
|
-
stopColor: "#ff4e00"
|
|
2145
|
-
}
|
|
2146
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2147
|
-
offset: 1,
|
|
2148
|
-
style: {
|
|
2149
|
-
stopOpacity: 1,
|
|
2150
|
-
stopColor: "#ff1791"
|
|
2151
|
-
}
|
|
2152
|
-
})]
|
|
2153
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("linearGradient", {
|
|
2154
|
-
id: r,
|
|
2155
|
-
spreadMethod: "pad",
|
|
2156
|
-
gradientTransform: "matrix(524.84045 0 0 -524.84045 63.801 159.5)",
|
|
2157
|
-
gradientUnits: "userSpaceOnUse",
|
|
2158
|
-
y2: 0,
|
|
2159
|
-
x2: 1,
|
|
2160
|
-
y1: 0,
|
|
2161
|
-
x1: 0,
|
|
2162
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2163
|
-
offset: 0,
|
|
2164
|
-
style: {
|
|
2165
|
-
stopOpacity: 1,
|
|
2166
|
-
stopColor: "#ff4e00"
|
|
2167
|
-
}
|
|
2168
|
-
}), /* @__PURE__ */jsxRuntime.jsx("stop", {
|
|
2169
|
-
offset: 1,
|
|
2170
|
-
style: {
|
|
2171
|
-
stopOpacity: 1,
|
|
2172
|
-
stopColor: "#ff1791"
|
|
2173
|
-
}
|
|
2174
|
-
})]
|
|
2175
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2176
|
-
id: a,
|
|
2177
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2178
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2179
|
-
d: "M0 319h657.706V0H0Z"
|
|
2180
|
-
})
|
|
2181
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2182
|
-
id: b,
|
|
2183
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2184
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2185
|
-
d: "M423.64 242h164.999V77H423.64Z"
|
|
2186
|
-
})
|
|
2187
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2188
|
-
id: e,
|
|
2189
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2190
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2191
|
-
d: "M0 319h657.706V0H0Z"
|
|
2192
|
-
})
|
|
2193
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2194
|
-
id: f,
|
|
2195
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2196
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2197
|
-
d: "M311.3 242h93.031V77H311.3Z"
|
|
2198
|
-
})
|
|
2199
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2200
|
-
id: h,
|
|
2201
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2202
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2203
|
-
d: "M198.96 242h35.106V77H198.96Z"
|
|
2204
|
-
})
|
|
2205
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2206
|
-
id: n,
|
|
2207
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2208
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2209
|
-
d: "M0 319h657.706V0H0Z"
|
|
2210
|
-
})
|
|
2211
|
-
}), /* @__PURE__ */jsxRuntime.jsx("clipPath", {
|
|
2212
|
-
id: o,
|
|
2213
|
-
clipPathUnits: "userSpaceOnUse",
|
|
2214
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2215
|
-
d: "M69.067 242H169.12V141.947H69.067Z"
|
|
2216
|
-
})
|
|
2217
|
-
})]
|
|
2218
|
-
}), /* @__PURE__ */jsxRuntime.jsx("g", {
|
|
2219
|
-
clipPath: "url(#".concat(a, ")"),
|
|
2220
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)",
|
|
2221
|
-
children: /* @__PURE__ */jsxRuntime.jsx("g", {
|
|
2222
|
-
style: {
|
|
2223
|
-
opacity: 0.69999701
|
|
2224
|
-
},
|
|
2225
|
-
clipPath: "url(#".concat(b, ")"),
|
|
2226
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2227
|
-
style: {
|
|
2228
|
-
fill: "url(#".concat(c, ")"),
|
|
2229
|
-
stroke: "none"
|
|
2230
|
-
},
|
|
2231
|
-
d: "M558.674 82.142c6.855-6.855 17.969-6.855 24.824 0 6.854 6.855 6.854 17.969 0 24.823L453.605 236.858c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
|
|
2232
|
-
})
|
|
2233
|
-
})
|
|
2234
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2235
|
-
style: {
|
|
2236
|
-
fill: "url(#".concat(d, ")"),
|
|
2237
|
-
stroke: "none"
|
|
2238
|
-
},
|
|
2239
|
-
d: "M558.674 236.858 428.781 106.966c-6.855-6.855-6.855-17.969 0-24.825 6.855-6.854 17.969-6.854 24.823 0l129.894 129.894c6.854 6.855 6.854 17.968 0 24.823A17.498 17.498 0 0 1 571.086 242a17.495 17.495 0 0 1-12.412-5.142",
|
|
2240
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2241
|
-
}), /* @__PURE__ */jsxRuntime.jsxs("g", {
|
|
2242
|
-
clipPath: "url(#".concat(e, ")"),
|
|
2243
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)",
|
|
2244
|
-
children: [/* @__PURE__ */jsxRuntime.jsx("g", {
|
|
2245
|
-
style: {
|
|
2246
|
-
opacity: 0.69999701
|
|
2247
|
-
},
|
|
2248
|
-
clipPath: "url(#".concat(f, ")"),
|
|
2249
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2250
|
-
style: {
|
|
2251
|
-
fill: "url(#".concat(g, ")"),
|
|
2252
|
-
stroke: "none"
|
|
2253
|
-
},
|
|
2254
|
-
d: "M328.853 112.107c22.297 0 40.372 18.075 40.372 40.372v71.315c0 10.054 7.505 18.206 17.554 18.206 10.048 0 17.552-8.152 17.552-18.206v-71.315c0-41.686-33.793-75.479-75.478-75.479-9.694 0-17.553 7.859-17.553 17.554 0 9.694 7.859 17.553 17.553 17.553"
|
|
2255
|
-
})
|
|
2256
|
-
}), /* @__PURE__ */jsxRuntime.jsx("g", {
|
|
2257
|
-
style: {
|
|
2258
|
-
opacity: 0.69999701
|
|
2259
|
-
},
|
|
2260
|
-
clipPath: "url(#".concat(h, ")"),
|
|
2261
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2262
|
-
style: {
|
|
2263
|
-
fill: "url(#".concat(i, ")"),
|
|
2264
|
-
stroke: "none"
|
|
2265
|
-
},
|
|
2266
|
-
d: "M216.513 242c-10.049 0-17.553-8.152-17.553-18.206V95.206c0-10.054 7.504-18.206 17.553-18.206 10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.054-7.505 18.206-17.553 18.206"
|
|
2267
|
-
})
|
|
2268
|
-
})]
|
|
2269
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2270
|
-
style: {
|
|
2271
|
-
fill: "url(#".concat(j, ")"),
|
|
2272
|
-
stroke: "none"
|
|
2273
|
-
},
|
|
2274
|
-
d: "M369.225 224.447c0-9.694 7.859-17.553 17.553-17.553 9.695 0 17.553 7.859 17.553 17.553s-7.858 17.552-17.553 17.552c-9.694 0-17.553-7.858-17.553-17.552",
|
|
2275
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2276
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2277
|
-
style: {
|
|
2278
|
-
fill: "url(#".concat(k, ")"),
|
|
2279
|
-
stroke: "none"
|
|
2280
|
-
},
|
|
2281
|
-
d: "M553.532 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.552-17.554 17.552-9.694 0-17.553-7.858-17.553-17.552",
|
|
2282
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2283
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2284
|
-
style: {
|
|
2285
|
-
fill: "url(#".concat(l, ")"),
|
|
2286
|
-
stroke: "none"
|
|
2287
|
-
},
|
|
2288
|
-
d: "M69.067 223.794V95.206C69.067 85.152 76.571 77 86.62 77c10.048 0 17.553 8.152 17.553 18.206v128.588c0 10.055-7.505 18.205-17.553 18.205-10.049 0-17.553-8.15-17.553-18.205",
|
|
2289
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2290
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2291
|
-
style: {
|
|
2292
|
-
fill: "url(#".concat(m, ")"),
|
|
2293
|
-
stroke: "none"
|
|
2294
|
-
},
|
|
2295
|
-
d: "M198.96 94.554c0-9.695 7.859-17.554 17.553-17.554 9.695 0 17.554 7.859 17.554 17.554 0 9.694-7.859 17.553-17.554 17.553-9.694 0-17.553-7.859-17.553-17.553",
|
|
2296
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2297
|
-
}), /* @__PURE__ */jsxRuntime.jsx("g", {
|
|
2298
|
-
clipPath: "url(#".concat(n, ")"),
|
|
2299
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)",
|
|
2300
|
-
children: /* @__PURE__ */jsxRuntime.jsx("g", {
|
|
2301
|
-
style: {
|
|
2302
|
-
opacity: 0.69999701
|
|
2303
|
-
},
|
|
2304
|
-
clipPath: "url(#".concat(o, ")"),
|
|
2305
|
-
children: /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2306
|
-
style: {
|
|
2307
|
-
fill: "url(#".concat(p, ")"),
|
|
2308
|
-
stroke: "none"
|
|
2309
|
-
},
|
|
2310
|
-
d: "M139.155 147.088c6.855-6.855 17.969-6.855 24.824 0s6.855 17.969 0 24.824l-64.947 64.946c-6.855 6.855-17.969 6.855-24.824 0s-6.855-17.969 0-24.823z"
|
|
2311
|
-
})
|
|
2312
|
-
})
|
|
2313
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2314
|
-
style: {
|
|
2315
|
-
fill: "url(#".concat(q, ")"),
|
|
2316
|
-
stroke: "none"
|
|
2317
|
-
},
|
|
2318
|
-
d: "m204.101 236.858-64.947-64.946c-6.854-6.855-6.854-17.969 0-24.824 6.856-6.855 17.97-6.855 24.824 0l64.947 64.947c6.855 6.855 6.855 17.968 0 24.823A17.495 17.495 0 0 1 216.513 242a17.498 17.498 0 0 1-12.412-5.142",
|
|
2319
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2320
|
-
}), /* @__PURE__ */jsxRuntime.jsx("path", {
|
|
2321
|
-
style: {
|
|
2322
|
-
fill: "url(#".concat(r, ")"),
|
|
2323
|
-
stroke: "none"
|
|
2324
|
-
},
|
|
2325
|
-
d: "M253.374 223.794v-71.315c0-41.685 33.793-75.479 75.479-75.479 9.695 0 17.553 7.859 17.553 17.554 0 9.694-7.858 17.553-17.553 17.553-22.297 0-40.372 18.075-40.372 40.372v71.315c0 10.055-7.505 18.205-17.554 18.205s-17.553-8.15-17.553-18.205",
|
|
2326
|
-
transform: "matrix(1.33333 0 0 -1.33333 0 425.333)"
|
|
2327
|
-
})]
|
|
2328
|
-
});
|
|
2329
|
-
}
|
|
2330
|
-
const Logo = styled__default.default.span(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n display: inline-block;\n height: 0.8em;\n margin-right: 1em;\n transform: translate(0.3em, -0.2em);\n"])));
|
|
2331
|
-
const Header = () => /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2332
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(Logo, {
|
|
2333
|
-
children: /* @__PURE__ */jsxRuntime.jsx(MuxLogo, {
|
|
2334
|
-
height: 13
|
|
2335
|
-
})
|
|
2336
|
-
}), "API Credentials"]
|
|
2337
|
-
});
|
|
2338
|
-
function FormField(props) {
|
|
2339
|
-
const {
|
|
2340
|
-
children,
|
|
2341
|
-
title,
|
|
2342
|
-
description,
|
|
2343
|
-
inputId
|
|
2344
|
-
} = props;
|
|
2345
|
-
return /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2346
|
-
space: 1,
|
|
2347
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
2348
|
-
align: "flex-end",
|
|
2349
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2350
|
-
flex: 1,
|
|
2351
|
-
paddingY: 2,
|
|
2352
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
|
|
2353
|
-
space: 2,
|
|
2354
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2355
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2356
|
-
as: "label",
|
|
2357
|
-
htmlFor: inputId,
|
|
2358
|
-
weight: "semibold",
|
|
2359
|
-
size: 1,
|
|
2360
|
-
children: title || /* @__PURE__ */jsxRuntime.jsx("em", {
|
|
2361
|
-
children: "Untitled"
|
|
2362
|
-
})
|
|
2363
|
-
}), description && /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2364
|
-
muted: true,
|
|
2365
|
-
size: 1,
|
|
2366
|
-
children: description
|
|
2367
|
-
})]
|
|
2368
|
-
})
|
|
2369
|
-
})
|
|
2370
|
-
})
|
|
2371
|
-
}), /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
2372
|
-
children
|
|
2373
|
-
})]
|
|
2374
|
-
});
|
|
2375
|
-
}
|
|
2376
|
-
var FormField$1 = React.memo(FormField);
|
|
2377
|
-
const fieldNames = ["token", "secretKey", "enableSignedUrls"];
|
|
2378
|
-
function ConfigureApi(_ref18) {
|
|
2379
|
-
let {
|
|
2380
|
-
secrets,
|
|
2381
|
-
setDialogState
|
|
2382
|
-
} = _ref18;
|
|
2383
|
-
var _a, _b;
|
|
2384
|
-
const client = VideoSource_styled.useClient();
|
|
2385
|
-
const [state, dispatch] = useSecretsFormState(secrets);
|
|
2386
|
-
const hasSecretsInitially = React.useMemo(() => secrets.token && secrets.secretKey, [secrets]);
|
|
2387
|
-
const handleClose = React.useCallback(() => setDialogState(false), [setDialogState]);
|
|
2388
|
-
const dirty = React.useMemo(() => secrets.token !== state.token || secrets.secretKey !== state.secretKey || secrets.enableSignedUrls !== state.enableSignedUrls, [secrets, state]);
|
|
2389
|
-
const id = "ConfigureApi".concat(React.useId());
|
|
2390
|
-
const [tokenId, secretKeyId, enableSignedUrlsId] = React.useMemo(() => fieldNames.map(field => "".concat(id, "-").concat(field)), [id]);
|
|
2391
|
-
const firstField = React.useRef(null);
|
|
2392
|
-
const handleSaveSecrets = useSaveSecrets(client, secrets);
|
|
2393
|
-
const saving = React.useRef(false);
|
|
2394
|
-
const handleSubmit = React.useCallback(event => {
|
|
2395
|
-
event.preventDefault();
|
|
2396
|
-
if (!saving.current && event.currentTarget.reportValidity()) {
|
|
2397
|
-
saving.current = true;
|
|
2398
|
-
dispatch({
|
|
2399
|
-
type: "submit"
|
|
2400
|
-
});
|
|
2401
|
-
const {
|
|
2402
|
-
token,
|
|
2403
|
-
secretKey,
|
|
2404
|
-
enableSignedUrls
|
|
2405
|
-
} = state;
|
|
2406
|
-
handleSaveSecrets({
|
|
2407
|
-
token,
|
|
2408
|
-
secretKey,
|
|
2409
|
-
enableSignedUrls
|
|
2410
|
-
}).then(savedSecrets => {
|
|
2411
|
-
const {
|
|
2412
|
-
projectId,
|
|
2413
|
-
dataset
|
|
2414
|
-
} = client.config();
|
|
2415
|
-
suspendReact.clear([index.cacheNs, VideoSource_styled._id, projectId, dataset]);
|
|
2416
|
-
suspendReact.preload(() => Promise.resolve(savedSecrets), [index.cacheNs, VideoSource_styled._id, projectId, dataset]);
|
|
2417
|
-
setDialogState(false);
|
|
2418
|
-
}).catch(err => dispatch({
|
|
2419
|
-
type: "error",
|
|
2420
|
-
payload: err.message
|
|
2421
|
-
})).finally(() => {
|
|
2422
|
-
saving.current = false;
|
|
2423
|
-
});
|
|
2424
|
-
}
|
|
2425
|
-
}, [client, dispatch, handleSaveSecrets, setDialogState, state]);
|
|
2426
|
-
const handleChangeToken = React.useCallback(event => {
|
|
2427
|
-
dispatch({
|
|
2428
|
-
type: "change",
|
|
2429
|
-
payload: {
|
|
2430
|
-
name: "token",
|
|
2431
|
-
value: event.currentTarget.value
|
|
2432
|
-
}
|
|
2433
|
-
});
|
|
2434
|
-
}, [dispatch]);
|
|
2435
|
-
const handleChangeSecretKey = React.useCallback(event => {
|
|
2436
|
-
dispatch({
|
|
2437
|
-
type: "change",
|
|
2438
|
-
payload: {
|
|
2439
|
-
name: "secretKey",
|
|
2440
|
-
value: event.currentTarget.value
|
|
2441
|
-
}
|
|
2442
|
-
});
|
|
2443
|
-
}, [dispatch]);
|
|
2444
|
-
const handleChangeEnableSignedUrls = React.useCallback(event => {
|
|
2445
|
-
dispatch({
|
|
2446
|
-
type: "change",
|
|
2447
|
-
payload: {
|
|
2448
|
-
name: "enableSignedUrls",
|
|
2449
|
-
value: event.currentTarget.checked
|
|
2450
|
-
}
|
|
2451
|
-
});
|
|
2452
|
-
}, [dispatch]);
|
|
2453
|
-
React.useEffect(() => {
|
|
2454
|
-
if (firstField.current) {
|
|
2455
|
-
firstField.current.focus();
|
|
2456
|
-
}
|
|
2457
|
-
}, [firstField]);
|
|
2458
|
-
return /* @__PURE__ */jsxRuntime.jsx(ui.Dialog, {
|
|
2459
|
-
id,
|
|
2460
|
-
onClose: handleClose,
|
|
2461
|
-
header: /* @__PURE__ */jsxRuntime.jsx(Header, {}),
|
|
2462
|
-
width: 0,
|
|
2463
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2464
|
-
padding: 4,
|
|
2465
|
-
style: {
|
|
2466
|
-
position: "relative"
|
|
2467
|
-
},
|
|
2468
|
-
children: /* @__PURE__ */jsxRuntime.jsx("form", {
|
|
2469
|
-
onSubmit: handleSubmit,
|
|
2470
|
-
noValidate: true,
|
|
2471
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2472
|
-
space: 4,
|
|
2473
|
-
children: [!hasSecretsInitially && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2474
|
-
padding: [3, 3, 3],
|
|
2475
|
-
radius: 2,
|
|
2476
|
-
shadow: 1,
|
|
2477
|
-
tone: "primary",
|
|
2478
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2479
|
-
space: 3,
|
|
2480
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
2481
|
-
size: 1,
|
|
2482
|
-
children: ["To set up a new access token, go to your", " ", /* @__PURE__ */jsxRuntime.jsx("a", {
|
|
2483
|
-
href: "https://dashboard.mux.com/settings/access-tokens",
|
|
2484
|
-
target: "_blank",
|
|
2485
|
-
rel: "noreferrer noopener",
|
|
2486
|
-
children: "account on mux.com"
|
|
2487
|
-
}), "."]
|
|
2488
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
2489
|
-
size: 1,
|
|
2490
|
-
children: ["The access token needs permissions: ", /* @__PURE__ */jsxRuntime.jsx("strong", {
|
|
2491
|
-
children: "Mux Video "
|
|
2492
|
-
}), "(Full Access) and ", /* @__PURE__ */jsxRuntime.jsx("strong", {
|
|
2493
|
-
children: "Mux Data"
|
|
2494
|
-
}), " (Read)", /* @__PURE__ */jsxRuntime.jsx("br", {}), "The credentials will be stored safely in a hidden document only available to editors."]
|
|
2495
|
-
})]
|
|
2496
|
-
})
|
|
2497
|
-
}), /* @__PURE__ */jsxRuntime.jsx(FormField$1, {
|
|
2498
|
-
title: "Access Token",
|
|
2499
|
-
inputId: tokenId,
|
|
2500
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.TextInput, {
|
|
2501
|
-
id: tokenId,
|
|
2502
|
-
ref: firstField,
|
|
2503
|
-
onChange: handleChangeToken,
|
|
2504
|
-
type: "text",
|
|
2505
|
-
value: (_a = state.token) != null ? _a : "",
|
|
2506
|
-
required: !!state.secretKey || state.enableSignedUrls
|
|
2507
|
-
})
|
|
2508
|
-
}), /* @__PURE__ */jsxRuntime.jsx(FormField$1, {
|
|
2509
|
-
title: "Secret Key",
|
|
2510
|
-
inputId: secretKeyId,
|
|
2511
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.TextInput, {
|
|
2512
|
-
id: secretKeyId,
|
|
2513
|
-
onChange: handleChangeSecretKey,
|
|
2514
|
-
type: "text",
|
|
2515
|
-
value: (_b = state.secretKey) != null ? _b : "",
|
|
2516
|
-
required: !!state.token || state.enableSignedUrls
|
|
2517
|
-
})
|
|
2518
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2519
|
-
space: 4,
|
|
2520
|
-
children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2521
|
-
align: "center",
|
|
2522
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
|
|
2523
|
-
id: enableSignedUrlsId,
|
|
2524
|
-
onChange: handleChangeEnableSignedUrls,
|
|
2525
|
-
checked: state.enableSignedUrls,
|
|
2526
|
-
style: {
|
|
2527
|
-
display: "block"
|
|
2528
|
-
}
|
|
2529
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2530
|
-
flex: 1,
|
|
2531
|
-
paddingLeft: 3,
|
|
2532
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2533
|
-
children: /* @__PURE__ */jsxRuntime.jsx("label", {
|
|
2534
|
-
htmlFor: enableSignedUrlsId,
|
|
2535
|
-
children: "Enable Signed Urls"
|
|
2536
|
-
})
|
|
2537
|
-
})
|
|
2538
|
-
})]
|
|
2539
|
-
}), secrets.signingKeyId && state.enableSignedUrls ? /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2540
|
-
padding: [3, 3, 3],
|
|
2541
|
-
radius: 2,
|
|
2542
|
-
shadow: 1,
|
|
2543
|
-
tone: "caution",
|
|
2544
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
|
|
2545
|
-
space: 3,
|
|
2546
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2547
|
-
size: 1,
|
|
2548
|
-
children: "The signing key ID that Sanity will use is:"
|
|
2549
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Code, {
|
|
2550
|
-
size: 1,
|
|
2551
|
-
children: secrets.signingKeyId
|
|
2552
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
2553
|
-
size: 1,
|
|
2554
|
-
children: ["This key is only used for previewing content in the Sanity UI.", /* @__PURE__ */jsxRuntime.jsx("br", {}), "You should generate a different key to use in your application server."]
|
|
2555
|
-
})]
|
|
2556
|
-
})
|
|
2557
|
-
}) : null]
|
|
2558
|
-
}), /* @__PURE__ */jsxRuntime.jsxs(ui.Inline, {
|
|
2559
|
-
space: 2,
|
|
2560
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2561
|
-
text: "Save",
|
|
2562
|
-
disabled: !dirty,
|
|
2563
|
-
loading: state.submitting,
|
|
2564
|
-
tone: "primary",
|
|
2565
|
-
mode: "default",
|
|
2566
|
-
type: "submit"
|
|
2567
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2568
|
-
disabled: state.submitting,
|
|
2569
|
-
text: "Cancel",
|
|
2570
|
-
mode: "bleed",
|
|
2571
|
-
onClick: handleClose
|
|
2572
|
-
})]
|
|
2573
|
-
}), state.error && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2574
|
-
padding: [3, 3, 3],
|
|
2575
|
-
radius: 2,
|
|
2576
|
-
shadow: 1,
|
|
2577
|
-
tone: "critical",
|
|
2578
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
|
|
2579
|
-
children: state.error
|
|
2580
|
-
})
|
|
2581
|
-
})]
|
|
2582
|
-
})
|
|
2583
|
-
})
|
|
2584
|
-
})
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
var ConfigureApi$1 = React.memo(ConfigureApi);
|
|
2588
|
-
function Onboard(props) {
|
|
2589
|
-
const {
|
|
2590
|
-
setDialogState
|
|
2591
|
-
} = props;
|
|
2592
|
-
const handleOpen = React.useCallback(() => setDialogState("secrets"), [setDialogState]);
|
|
2593
|
-
return /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2594
|
-
children: /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
2595
|
-
style: {
|
|
2596
|
-
padding: 2
|
|
2597
|
-
},
|
|
2598
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2599
|
-
display: "flex",
|
|
2600
|
-
sizing: "border",
|
|
2601
|
-
style: {
|
|
2602
|
-
aspectRatio: "16/9",
|
|
2603
|
-
width: "100%",
|
|
2604
|
-
boxShadow: "var(--card-bg-color) 0 0 0 2px"
|
|
2605
|
-
},
|
|
2606
|
-
paddingX: [2, 3, 4, 4],
|
|
2607
|
-
radius: 1,
|
|
2608
|
-
tone: "transparent",
|
|
2609
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
|
|
2610
|
-
justify: "flex-start",
|
|
2611
|
-
align: "center",
|
|
2612
|
-
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Grid, {
|
|
2613
|
-
columns: 1,
|
|
2614
|
-
gap: [2, 3, 4, 4],
|
|
2615
|
-
children: [/* @__PURE__ */jsxRuntime.jsx(ui.Inline, {
|
|
2616
|
-
paddingY: 1,
|
|
2617
|
-
children: /* @__PURE__ */jsxRuntime.jsx("div", {
|
|
2618
|
-
style: {
|
|
2619
|
-
height: "32px"
|
|
2620
|
-
},
|
|
2621
|
-
children: /* @__PURE__ */jsxRuntime.jsx(MuxLogo, {})
|
|
2622
|
-
})
|
|
2623
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Inline, {
|
|
2624
|
-
paddingY: 1,
|
|
2625
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Heading, {
|
|
2626
|
-
size: [0, 1, 2, 2],
|
|
2627
|
-
children: "Upload and preview videos directly from your studio."
|
|
2628
|
-
})
|
|
2629
|
-
}), /* @__PURE__ */jsxRuntime.jsx(ui.Inline, {
|
|
2630
|
-
paddingY: 1,
|
|
2631
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
|
|
2632
|
-
mode: "ghost",
|
|
2633
|
-
icon: icons.PlugIcon,
|
|
2634
|
-
text: "Configure API",
|
|
2635
|
-
onClick: handleOpen
|
|
2636
|
-
})
|
|
2637
|
-
})]
|
|
2638
|
-
})
|
|
2639
|
-
})
|
|
2640
|
-
})
|
|
2641
|
-
})
|
|
2642
|
-
});
|
|
2643
|
-
}
|
|
2644
|
-
const Input = props => {
|
|
2645
|
-
var _a;
|
|
2646
|
-
const client = VideoSource_styled.useClient();
|
|
2647
|
-
const secretDocumentValues = useSecretsDocumentValues();
|
|
2648
|
-
const assetDocumentValues = VideoSource_styled.useAssetDocumentValues((_a = props.value) == null ? void 0 : _a.asset);
|
|
2649
|
-
const poll = useMuxPolling(props.readOnly ? void 0 : (assetDocumentValues == null ? void 0 : assetDocumentValues.value) || void 0);
|
|
2650
|
-
const [dialogState, setDialogState] = useDialogState();
|
|
2651
|
-
const error = secretDocumentValues.error || assetDocumentValues.error || poll.error;
|
|
2652
|
-
if (error) {
|
|
2653
|
-
throw error;
|
|
2654
|
-
}
|
|
2655
|
-
const isLoading = secretDocumentValues.isLoading || assetDocumentValues.isLoading;
|
|
2656
|
-
return /* @__PURE__ */jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2657
|
-
children: isLoading ? /* @__PURE__ */jsxRuntime.jsx(index.InputFallback, {}) : /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2658
|
-
children: [secretDocumentValues.value.needsSetup && !assetDocumentValues.value ? /* @__PURE__ */jsxRuntime.jsx(Onboard, {
|
|
2659
|
-
setDialogState
|
|
2660
|
-
}) : /* @__PURE__ */jsxRuntime.jsx(MuxVideoInputUploader, {
|
|
2661
|
-
...props,
|
|
2662
|
-
config: props.config,
|
|
2663
|
-
onChange: props.onChange,
|
|
2664
|
-
client,
|
|
2665
|
-
secrets: secretDocumentValues.value.secrets,
|
|
2666
|
-
asset: assetDocumentValues.value,
|
|
2667
|
-
dialogState,
|
|
2668
|
-
setDialogState,
|
|
2669
|
-
needsSetup: secretDocumentValues.value.needsSetup
|
|
2670
|
-
}), dialogState === "secrets" && /* @__PURE__ */jsxRuntime.jsx(ConfigureApi$1, {
|
|
2671
|
-
setDialogState,
|
|
2672
|
-
secrets: secretDocumentValues.value.secrets
|
|
2673
|
-
})]
|
|
2674
|
-
})
|
|
2675
|
-
});
|
|
2676
|
-
};
|
|
2677
|
-
var Input$1 = React.memo(Input);
|
|
2678
|
-
exports.default = Input$1;
|
|
2679
|
-
//# sourceMappingURL=Input-0c9eb69e.js.map
|