@link-loom/cloud-sdk 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4961 @@
1
+ import axios from 'axios';
2
+ import React$1, { useState, useRef, useCallback, useEffect, useMemo, useContext, createContext } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import Box from '@mui/material/Box';
5
+ import Typography from '@mui/material/Typography';
6
+ import CircularProgress from '@mui/material/CircularProgress';
7
+ import { createRoot } from 'react-dom/client';
8
+ import Button from '@mui/material/Button';
9
+ import IconButton from '@mui/material/IconButton';
10
+ import Chip from '@mui/material/Chip';
11
+ import SaveIcon from '@mui/icons-material/Save';
12
+ import BuildIcon from '@mui/icons-material/Build';
13
+ import PublishIcon from '@mui/icons-material/Publish';
14
+ import PlayArrowIcon from '@mui/icons-material/PlayArrow';
15
+ import VisibilityIcon from '@mui/icons-material/Visibility';
16
+ import ViewSidebarIcon from '@mui/icons-material/ViewSidebar';
17
+ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
18
+ import FolderIcon from '@mui/icons-material/Folder';
19
+ import FolderOpenIcon from '@mui/icons-material/FolderOpen';
20
+ import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
21
+ import NoteAddIcon from '@mui/icons-material/NoteAdd';
22
+ import CreateNewFolderIcon from '@mui/icons-material/CreateNewFolder';
23
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
24
+ import ChevronRightIcon from '@mui/icons-material/ChevronRight';
25
+ import Tabs from '@mui/material/Tabs';
26
+ import Tab from '@mui/material/Tab';
27
+ import CloseIcon from '@mui/icons-material/Close';
28
+ import Editor from '@monaco-editor/react';
29
+ import TextField from '@mui/material/TextField';
30
+ import Switch from '@mui/material/Switch';
31
+ import Select from '@mui/material/Select';
32
+ import MenuItem from '@mui/material/MenuItem';
33
+ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
34
+ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
35
+ import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
36
+ import InputAdornment from '@mui/material/InputAdornment';
37
+ import SearchIcon from '@mui/icons-material/Search';
38
+ import AddIcon from '@mui/icons-material/Add';
39
+ import MoreVertIcon from '@mui/icons-material/MoreVert';
40
+ import PushPinIcon from '@mui/icons-material/PushPin';
41
+ import StarIcon from '@mui/icons-material/Star';
42
+ import Menu from '@mui/material/Menu';
43
+
44
+ function _arrayLikeToArray(r, a) {
45
+ (null == a || a > r.length) && (a = r.length);
46
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
47
+ return n;
48
+ }
49
+ function _arrayWithHoles(r) {
50
+ if (Array.isArray(r)) return r;
51
+ }
52
+ function _arrayWithoutHoles(r) {
53
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
54
+ }
55
+ function _assertClassBrand(e, t, n) {
56
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
57
+ throw new TypeError("Private element is not present on this object");
58
+ }
59
+ function _assertThisInitialized(e) {
60
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
61
+ return e;
62
+ }
63
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
64
+ try {
65
+ var i = n[a](c),
66
+ u = i.value;
67
+ } catch (n) {
68
+ return void e(n);
69
+ }
70
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
71
+ }
72
+ function _asyncToGenerator(n) {
73
+ return function () {
74
+ var t = this,
75
+ e = arguments;
76
+ return new Promise(function (r, o) {
77
+ var a = n.apply(t, e);
78
+ function _next(n) {
79
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
80
+ }
81
+ function _throw(n) {
82
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
83
+ }
84
+ _next(void 0);
85
+ });
86
+ };
87
+ }
88
+ function _callSuper(t, o, e) {
89
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
90
+ }
91
+ function _checkPrivateRedeclaration(e, t) {
92
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
93
+ }
94
+ function _classCallCheck(a, n) {
95
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
96
+ }
97
+ function _classPrivateMethodInitSpec(e, a) {
98
+ _checkPrivateRedeclaration(e, a), a.add(e);
99
+ }
100
+ function _defineProperties(e, r) {
101
+ for (var t = 0; t < r.length; t++) {
102
+ var o = r[t];
103
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
104
+ }
105
+ }
106
+ function _createClass(e, r, t) {
107
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
108
+ writable: false
109
+ }), e;
110
+ }
111
+ function _createForOfIteratorHelper(r, e) {
112
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
113
+ if (!t) {
114
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
115
+ t && (r = t);
116
+ var n = 0,
117
+ F = function () {};
118
+ return {
119
+ s: F,
120
+ n: function () {
121
+ return n >= r.length ? {
122
+ done: true
123
+ } : {
124
+ done: false,
125
+ value: r[n++]
126
+ };
127
+ },
128
+ e: function (r) {
129
+ throw r;
130
+ },
131
+ f: F
132
+ };
133
+ }
134
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
135
+ }
136
+ var o,
137
+ a = true,
138
+ u = false;
139
+ return {
140
+ s: function () {
141
+ t = t.call(r);
142
+ },
143
+ n: function () {
144
+ var r = t.next();
145
+ return a = r.done, r;
146
+ },
147
+ e: function (r) {
148
+ u = true, o = r;
149
+ },
150
+ f: function () {
151
+ try {
152
+ a || null == t.return || t.return();
153
+ } finally {
154
+ if (u) throw o;
155
+ }
156
+ }
157
+ };
158
+ }
159
+ function _defineProperty(e, r, t) {
160
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
161
+ value: t,
162
+ enumerable: true,
163
+ configurable: true,
164
+ writable: true
165
+ }) : e[r] = t, e;
166
+ }
167
+ function _get$1() {
168
+ return _get$1 = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
169
+ var p = _superPropBase(e, t);
170
+ if (p) {
171
+ var n = Object.getOwnPropertyDescriptor(p, t);
172
+ return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
173
+ }
174
+ }, _get$1.apply(null, arguments);
175
+ }
176
+ function _getPrototypeOf(t) {
177
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
178
+ return t.__proto__ || Object.getPrototypeOf(t);
179
+ }, _getPrototypeOf(t);
180
+ }
181
+ function _inherits(t, e) {
182
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
183
+ t.prototype = Object.create(e && e.prototype, {
184
+ constructor: {
185
+ value: t,
186
+ writable: true,
187
+ configurable: true
188
+ }
189
+ }), Object.defineProperty(t, "prototype", {
190
+ writable: false
191
+ }), e && _setPrototypeOf(t, e);
192
+ }
193
+ function _isNativeReflectConstruct() {
194
+ try {
195
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
196
+ } catch (t) {}
197
+ return (_isNativeReflectConstruct = function () {
198
+ return !!t;
199
+ })();
200
+ }
201
+ function _iterableToArray(r) {
202
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
203
+ }
204
+ function _iterableToArrayLimit(r, l) {
205
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
206
+ if (null != t) {
207
+ var e,
208
+ n,
209
+ i,
210
+ u,
211
+ a = [],
212
+ f = true,
213
+ o = false;
214
+ try {
215
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
216
+ } catch (r) {
217
+ o = true, n = r;
218
+ } finally {
219
+ try {
220
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
221
+ } finally {
222
+ if (o) throw n;
223
+ }
224
+ }
225
+ return a;
226
+ }
227
+ }
228
+ function _nonIterableRest() {
229
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
230
+ }
231
+ function _nonIterableSpread() {
232
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
233
+ }
234
+ function ownKeys(e, r) {
235
+ var t = Object.keys(e);
236
+ if (Object.getOwnPropertySymbols) {
237
+ var o = Object.getOwnPropertySymbols(e);
238
+ r && (o = o.filter(function (r) {
239
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
240
+ })), t.push.apply(t, o);
241
+ }
242
+ return t;
243
+ }
244
+ function _objectSpread2(e) {
245
+ for (var r = 1; r < arguments.length; r++) {
246
+ var t = null != arguments[r] ? arguments[r] : {};
247
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
248
+ _defineProperty(e, r, t[r]);
249
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
250
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
251
+ });
252
+ }
253
+ return e;
254
+ }
255
+ function _possibleConstructorReturn(t, e) {
256
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
257
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
258
+ return _assertThisInitialized(t);
259
+ }
260
+ function _regenerator() {
261
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
262
+ var e,
263
+ t,
264
+ r = "function" == typeof Symbol ? Symbol : {},
265
+ n = r.iterator || "@@iterator",
266
+ o = r.toStringTag || "@@toStringTag";
267
+ function i(r, n, o, i) {
268
+ var c = n && n.prototype instanceof Generator ? n : Generator,
269
+ u = Object.create(c.prototype);
270
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
271
+ var i,
272
+ c,
273
+ u,
274
+ f = 0,
275
+ p = o || [],
276
+ y = false,
277
+ G = {
278
+ p: 0,
279
+ n: 0,
280
+ v: e,
281
+ a: d,
282
+ f: d.bind(e, 4),
283
+ d: function (t, r) {
284
+ return i = t, c = 0, u = e, G.n = r, a;
285
+ }
286
+ };
287
+ function d(r, n) {
288
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
289
+ var o,
290
+ i = p[t],
291
+ d = G.p,
292
+ l = i[2];
293
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
294
+ }
295
+ if (o || r > 1) return a;
296
+ throw y = true, n;
297
+ }
298
+ return function (o, p, l) {
299
+ if (f > 1) throw TypeError("Generator is already running");
300
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
301
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
302
+ try {
303
+ if (f = 2, i) {
304
+ if (c || (o = "next"), t = i[o]) {
305
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
306
+ if (!t.done) return t;
307
+ u = t.value, c < 2 && (c = 0);
308
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
309
+ i = e;
310
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
311
+ } catch (t) {
312
+ i = e, c = 1, u = t;
313
+ } finally {
314
+ f = 1;
315
+ }
316
+ }
317
+ return {
318
+ value: t,
319
+ done: y
320
+ };
321
+ };
322
+ }(r, o, i), true), u;
323
+ }
324
+ var a = {};
325
+ function Generator() {}
326
+ function GeneratorFunction() {}
327
+ function GeneratorFunctionPrototype() {}
328
+ t = Object.getPrototypeOf;
329
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
330
+ return this;
331
+ }), t),
332
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
333
+ function f(e) {
334
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
335
+ }
336
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
337
+ return this;
338
+ }), _regeneratorDefine(u, "toString", function () {
339
+ return "[object Generator]";
340
+ }), (_regenerator = function () {
341
+ return {
342
+ w: i,
343
+ m: f
344
+ };
345
+ })();
346
+ }
347
+ function _regeneratorDefine(e, r, n, t) {
348
+ var i = Object.defineProperty;
349
+ try {
350
+ i({}, "", {});
351
+ } catch (e) {
352
+ i = 0;
353
+ }
354
+ _regeneratorDefine = function (e, r, n, t) {
355
+ function o(r, n) {
356
+ _regeneratorDefine(e, r, function (e) {
357
+ return this._invoke(r, n, e);
358
+ });
359
+ }
360
+ r ? i ? i(e, r, {
361
+ value: n,
362
+ enumerable: !t,
363
+ configurable: !t,
364
+ writable: !t
365
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
366
+ }, _regeneratorDefine(e, r, n, t);
367
+ }
368
+ function _setPrototypeOf(t, e) {
369
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
370
+ return t.__proto__ = e, t;
371
+ }, _setPrototypeOf(t, e);
372
+ }
373
+ function _slicedToArray(r, e) {
374
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
375
+ }
376
+ function _superPropBase(t, o) {
377
+ for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
378
+ return t;
379
+ }
380
+ function _superPropGet(t, o, e, r) {
381
+ var p = _get$1(_getPrototypeOf(t.prototype ), o, e);
382
+ return 2 & r && "function" == typeof p ? function (t) {
383
+ return p.apply(e, t);
384
+ } : p;
385
+ }
386
+ function _toConsumableArray(r) {
387
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
388
+ }
389
+ function _toPrimitive(t, r) {
390
+ if ("object" != typeof t || !t) return t;
391
+ var e = t[Symbol.toPrimitive];
392
+ if (void 0 !== e) {
393
+ var i = e.call(t, r);
394
+ if ("object" != typeof i) return i;
395
+ throw new TypeError("@@toPrimitive must return a primitive value.");
396
+ }
397
+ return ("string" === r ? String : Number)(t);
398
+ }
399
+ function _toPropertyKey(t) {
400
+ var i = _toPrimitive(t, "string");
401
+ return "symbol" == typeof i ? i : i + "";
402
+ }
403
+ function _typeof(o) {
404
+ "@babel/helpers - typeof";
405
+
406
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
407
+ return typeof o;
408
+ } : function (o) {
409
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
410
+ }, _typeof(o);
411
+ }
412
+ function _unsupportedIterableToArray(r, a) {
413
+ if (r) {
414
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
415
+ var t = {}.toString.call(r).slice(8, -1);
416
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
417
+ }
418
+ }
419
+
420
+ var _AppEngineClient_brand = /*#__PURE__*/new WeakSet();
421
+ var AppEngineClient = /*#__PURE__*/function () {
422
+ function AppEngineClient(_ref) {
423
+ var baseUrl = _ref.baseUrl,
424
+ _ref$timeout = _ref.timeout,
425
+ timeout = _ref$timeout === void 0 ? 30000 : _ref$timeout;
426
+ _classCallCheck(this, AppEngineClient);
427
+ // ─── HTTP helpers ────────────────────────────────────────
428
+ _classPrivateMethodInitSpec(this, _AppEngineClient_brand);
429
+ if (!baseUrl) {
430
+ throw new Error('AppEngineClient requires a baseUrl');
431
+ }
432
+ this._baseUrl = baseUrl.replace(/\/$/, '');
433
+ this._http = axios.create({
434
+ baseURL: this._baseUrl,
435
+ timeout: timeout,
436
+ headers: {
437
+ 'Content-Type': 'application/json'
438
+ }
439
+ });
440
+ }
441
+
442
+ // ─── App Definition ──────────────────────────────────────
443
+ return _createClass(AppEngineClient, [{
444
+ key: "getAppDefinition",
445
+ value: function () {
446
+ var _getAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2) {
447
+ var queryselector, search, page, pageSize, exclude_status, params;
448
+ return _regenerator().w(function (_context) {
449
+ while (1) switch (_context.n) {
450
+ case 0:
451
+ queryselector = _ref2.queryselector, search = _ref2.search, page = _ref2.page, pageSize = _ref2.pageSize, exclude_status = _ref2.exclude_status;
452
+ params = {
453
+ search: search,
454
+ page: page,
455
+ pageSize: pageSize,
456
+ exclude_status: exclude_status
457
+ };
458
+ return _context.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, "/app/definition/".concat(queryselector), params));
459
+ }
460
+ }, _callee, this);
461
+ }));
462
+ function getAppDefinition(_x) {
463
+ return _getAppDefinition.apply(this, arguments);
464
+ }
465
+ return getAppDefinition;
466
+ }()
467
+ }, {
468
+ key: "getAppsCatalog",
469
+ value: function () {
470
+ var _getAppsCatalog = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
471
+ var _ref3,
472
+ owning_product,
473
+ page,
474
+ pageSize,
475
+ params,
476
+ _args2 = arguments;
477
+ return _regenerator().w(function (_context2) {
478
+ while (1) switch (_context2.n) {
479
+ case 0:
480
+ _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, owning_product = _ref3.owning_product, page = _ref3.page, pageSize = _ref3.pageSize;
481
+ params = {
482
+ owning_product: owning_product,
483
+ page: page,
484
+ pageSize: pageSize
485
+ };
486
+ return _context2.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/definition/catalog/', params));
487
+ }
488
+ }, _callee2, this);
489
+ }));
490
+ function getAppsCatalog() {
491
+ return _getAppsCatalog.apply(this, arguments);
492
+ }
493
+ return getAppsCatalog;
494
+ }()
495
+ }, {
496
+ key: "getFullApp",
497
+ value: function () {
498
+ var _getFullApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref4) {
499
+ var slug;
500
+ return _regenerator().w(function (_context3) {
501
+ while (1) switch (_context3.n) {
502
+ case 0:
503
+ slug = _ref4.slug;
504
+ return _context3.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/definition/full/', {
505
+ slug: slug
506
+ }));
507
+ }
508
+ }, _callee3, this);
509
+ }));
510
+ function getFullApp(_x2) {
511
+ return _getFullApp.apply(this, arguments);
512
+ }
513
+ return getFullApp;
514
+ }()
515
+ }, {
516
+ key: "getStudioPayload",
517
+ value: function () {
518
+ var _getStudioPayload = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref5) {
519
+ var search;
520
+ return _regenerator().w(function (_context4) {
521
+ while (1) switch (_context4.n) {
522
+ case 0:
523
+ search = _ref5.search;
524
+ return _context4.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/definition/studio/', {
525
+ search: search
526
+ }));
527
+ }
528
+ }, _callee4, this);
529
+ }));
530
+ function getStudioPayload(_x3) {
531
+ return _getStudioPayload.apply(this, arguments);
532
+ }
533
+ return getStudioPayload;
534
+ }()
535
+ }, {
536
+ key: "createAppDefinition",
537
+ value: function () {
538
+ var _createAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(data) {
539
+ return _regenerator().w(function (_context5) {
540
+ while (1) switch (_context5.n) {
541
+ case 0:
542
+ return _context5.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/definition/', data));
543
+ }
544
+ }, _callee5, this);
545
+ }));
546
+ function createAppDefinition(_x4) {
547
+ return _createAppDefinition.apply(this, arguments);
548
+ }
549
+ return createAppDefinition;
550
+ }()
551
+ }, {
552
+ key: "createAppWithScaffold",
553
+ value: function () {
554
+ var _createAppWithScaffold = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(data) {
555
+ return _regenerator().w(function (_context6) {
556
+ while (1) switch (_context6.n) {
557
+ case 0:
558
+ return _context6.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/definition/scaffold/', data));
559
+ }
560
+ }, _callee6, this);
561
+ }));
562
+ function createAppWithScaffold(_x5) {
563
+ return _createAppWithScaffold.apply(this, arguments);
564
+ }
565
+ return createAppWithScaffold;
566
+ }()
567
+ }, {
568
+ key: "updateAppDefinition",
569
+ value: function () {
570
+ var _updateAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(data) {
571
+ return _regenerator().w(function (_context7) {
572
+ while (1) switch (_context7.n) {
573
+ case 0:
574
+ return _context7.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/definition/', data));
575
+ }
576
+ }, _callee7, this);
577
+ }));
578
+ function updateAppDefinition(_x6) {
579
+ return _updateAppDefinition.apply(this, arguments);
580
+ }
581
+ return updateAppDefinition;
582
+ }()
583
+ }, {
584
+ key: "deleteAppDefinition",
585
+ value: function () {
586
+ var _deleteAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref6) {
587
+ var id;
588
+ return _regenerator().w(function (_context8) {
589
+ while (1) switch (_context8.n) {
590
+ case 0:
591
+ id = _ref6.id;
592
+ return _context8.a(2, _assertClassBrand(_AppEngineClient_brand, this, _delete).call(this, '/app/definition/', {
593
+ id: id
594
+ }));
595
+ }
596
+ }, _callee8, this);
597
+ }));
598
+ function deleteAppDefinition(_x7) {
599
+ return _deleteAppDefinition.apply(this, arguments);
600
+ }
601
+ return deleteAppDefinition;
602
+ }() // ─── App Version ─────────────────────────────────────────
603
+ }, {
604
+ key: "getAppVersion",
605
+ value: function () {
606
+ var _getAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref7) {
607
+ var queryselector, search, page, pageSize, params;
608
+ return _regenerator().w(function (_context9) {
609
+ while (1) switch (_context9.n) {
610
+ case 0:
611
+ queryselector = _ref7.queryselector, search = _ref7.search, page = _ref7.page, pageSize = _ref7.pageSize;
612
+ params = {
613
+ search: search,
614
+ page: page,
615
+ pageSize: pageSize
616
+ };
617
+ return _context9.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, "/app/version/".concat(queryselector), params));
618
+ }
619
+ }, _callee9, this);
620
+ }));
621
+ function getAppVersion(_x8) {
622
+ return _getAppVersion.apply(this, arguments);
623
+ }
624
+ return getAppVersion;
625
+ }()
626
+ }, {
627
+ key: "createAppVersion",
628
+ value: function () {
629
+ var _createAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(data) {
630
+ return _regenerator().w(function (_context0) {
631
+ while (1) switch (_context0.n) {
632
+ case 0:
633
+ return _context0.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/version/', data));
634
+ }
635
+ }, _callee0, this);
636
+ }));
637
+ function createAppVersion(_x9) {
638
+ return _createAppVersion.apply(this, arguments);
639
+ }
640
+ return createAppVersion;
641
+ }()
642
+ }, {
643
+ key: "updateAppVersion",
644
+ value: function () {
645
+ var _updateAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(data) {
646
+ return _regenerator().w(function (_context1) {
647
+ while (1) switch (_context1.n) {
648
+ case 0:
649
+ return _context1.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/version/', data));
650
+ }
651
+ }, _callee1, this);
652
+ }));
653
+ function updateAppVersion(_x0) {
654
+ return _updateAppVersion.apply(this, arguments);
655
+ }
656
+ return updateAppVersion;
657
+ }()
658
+ }, {
659
+ key: "publishVersion",
660
+ value: function () {
661
+ var _publishVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(_ref8) {
662
+ var app_definition_id, changelog, published_by;
663
+ return _regenerator().w(function (_context10) {
664
+ while (1) switch (_context10.n) {
665
+ case 0:
666
+ app_definition_id = _ref8.app_definition_id, changelog = _ref8.changelog, published_by = _ref8.published_by;
667
+ return _context10.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/version/publish/', {
668
+ app_definition_id: app_definition_id,
669
+ changelog: changelog,
670
+ published_by: published_by
671
+ }));
672
+ }
673
+ }, _callee10, this);
674
+ }));
675
+ function publishVersion(_x1) {
676
+ return _publishVersion.apply(this, arguments);
677
+ }
678
+ return publishVersion;
679
+ }()
680
+ }, {
681
+ key: "activateVersion",
682
+ value: function () {
683
+ var _activateVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(_ref9) {
684
+ var id;
685
+ return _regenerator().w(function (_context11) {
686
+ while (1) switch (_context11.n) {
687
+ case 0:
688
+ id = _ref9.id;
689
+ return _context11.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/version/activate/', {
690
+ id: id
691
+ }));
692
+ }
693
+ }, _callee11, this);
694
+ }));
695
+ function activateVersion(_x10) {
696
+ return _activateVersion.apply(this, arguments);
697
+ }
698
+ return activateVersion;
699
+ }()
700
+ }, {
701
+ key: "deleteAppVersion",
702
+ value: function () {
703
+ var _deleteAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(_ref0) {
704
+ var id;
705
+ return _regenerator().w(function (_context12) {
706
+ while (1) switch (_context12.n) {
707
+ case 0:
708
+ id = _ref0.id;
709
+ return _context12.a(2, _assertClassBrand(_AppEngineClient_brand, this, _delete).call(this, '/app/version/', {
710
+ id: id
711
+ }));
712
+ }
713
+ }, _callee12, this);
714
+ }));
715
+ function deleteAppVersion(_x11) {
716
+ return _deleteAppVersion.apply(this, arguments);
717
+ }
718
+ return deleteAppVersion;
719
+ }() // ─── App File ────────────────────────────────────────────
720
+ }, {
721
+ key: "getAppFile",
722
+ value: function () {
723
+ var _getAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref1) {
724
+ var queryselector, search, page, pageSize, params;
725
+ return _regenerator().w(function (_context13) {
726
+ while (1) switch (_context13.n) {
727
+ case 0:
728
+ queryselector = _ref1.queryselector, search = _ref1.search, page = _ref1.page, pageSize = _ref1.pageSize;
729
+ params = {
730
+ search: search,
731
+ page: page,
732
+ pageSize: pageSize
733
+ };
734
+ return _context13.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, "/app/file/".concat(queryselector), params));
735
+ }
736
+ }, _callee13, this);
737
+ }));
738
+ function getAppFile(_x12) {
739
+ return _getAppFile.apply(this, arguments);
740
+ }
741
+ return getAppFile;
742
+ }()
743
+ }, {
744
+ key: "getFileTree",
745
+ value: function () {
746
+ var _getFileTree = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref10) {
747
+ var search;
748
+ return _regenerator().w(function (_context14) {
749
+ while (1) switch (_context14.n) {
750
+ case 0:
751
+ search = _ref10.search;
752
+ return _context14.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/file/tree/', {
753
+ search: search
754
+ }));
755
+ }
756
+ }, _callee14, this);
757
+ }));
758
+ function getFileTree(_x13) {
759
+ return _getFileTree.apply(this, arguments);
760
+ }
761
+ return getFileTree;
762
+ }()
763
+ }, {
764
+ key: "getFileContent",
765
+ value: function () {
766
+ var _getFileContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref11) {
767
+ var search;
768
+ return _regenerator().w(function (_context15) {
769
+ while (1) switch (_context15.n) {
770
+ case 0:
771
+ search = _ref11.search;
772
+ return _context15.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/file/content/', {
773
+ search: search
774
+ }));
775
+ }
776
+ }, _callee15, this);
777
+ }));
778
+ function getFileContent(_x14) {
779
+ return _getFileContent.apply(this, arguments);
780
+ }
781
+ return getFileContent;
782
+ }()
783
+ }, {
784
+ key: "createAppFile",
785
+ value: function () {
786
+ var _createAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(data) {
787
+ return _regenerator().w(function (_context16) {
788
+ while (1) switch (_context16.n) {
789
+ case 0:
790
+ return _context16.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/file/', data));
791
+ }
792
+ }, _callee16, this);
793
+ }));
794
+ function createAppFile(_x15) {
795
+ return _createAppFile.apply(this, arguments);
796
+ }
797
+ return createAppFile;
798
+ }()
799
+ }, {
800
+ key: "updateAppFile",
801
+ value: function () {
802
+ var _updateAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(data) {
803
+ return _regenerator().w(function (_context17) {
804
+ while (1) switch (_context17.n) {
805
+ case 0:
806
+ return _context17.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/file/', data));
807
+ }
808
+ }, _callee17, this);
809
+ }));
810
+ function updateAppFile(_x16) {
811
+ return _updateAppFile.apply(this, arguments);
812
+ }
813
+ return updateAppFile;
814
+ }()
815
+ }, {
816
+ key: "deleteAppFile",
817
+ value: function () {
818
+ var _deleteAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref12) {
819
+ var id;
820
+ return _regenerator().w(function (_context18) {
821
+ while (1) switch (_context18.n) {
822
+ case 0:
823
+ id = _ref12.id;
824
+ return _context18.a(2, _assertClassBrand(_AppEngineClient_brand, this, _delete).call(this, '/app/file/', {
825
+ id: id
826
+ }));
827
+ }
828
+ }, _callee18, this);
829
+ }));
830
+ function deleteAppFile(_x17) {
831
+ return _deleteAppFile.apply(this, arguments);
832
+ }
833
+ return deleteAppFile;
834
+ }()
835
+ }, {
836
+ key: "applyFileChanges",
837
+ value: function () {
838
+ var _applyFileChanges = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref13) {
839
+ var app_definition_id, organization_id, changes;
840
+ return _regenerator().w(function (_context19) {
841
+ while (1) switch (_context19.n) {
842
+ case 0:
843
+ app_definition_id = _ref13.app_definition_id, organization_id = _ref13.organization_id, changes = _ref13.changes;
844
+ return _context19.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/file/apply-changes/', {
845
+ app_definition_id: app_definition_id,
846
+ organization_id: organization_id,
847
+ changes: changes
848
+ }));
849
+ }
850
+ }, _callee19, this);
851
+ }));
852
+ function applyFileChanges(_x18) {
853
+ return _applyFileChanges.apply(this, arguments);
854
+ }
855
+ return applyFileChanges;
856
+ }() // ─── App Build ───────────────────────────────────────────
857
+ }, {
858
+ key: "buildApp",
859
+ value: function () {
860
+ var _buildApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(_ref14) {
861
+ var slug, app_definition_id;
862
+ return _regenerator().w(function (_context20) {
863
+ while (1) switch (_context20.n) {
864
+ case 0:
865
+ slug = _ref14.slug, app_definition_id = _ref14.app_definition_id;
866
+ return _context20.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/build/single/', {
867
+ slug: slug,
868
+ app_definition_id: app_definition_id
869
+ }));
870
+ }
871
+ }, _callee20, this);
872
+ }));
873
+ function buildApp(_x19) {
874
+ return _buildApp.apply(this, arguments);
875
+ }
876
+ return buildApp;
877
+ }()
878
+ }, {
879
+ key: "buildAllApps",
880
+ value: function () {
881
+ var _buildAllApps = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
882
+ var _ref15,
883
+ owning_product,
884
+ _args21 = arguments;
885
+ return _regenerator().w(function (_context21) {
886
+ while (1) switch (_context21.n) {
887
+ case 0:
888
+ _ref15 = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {}, owning_product = _ref15.owning_product;
889
+ return _context21.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/build/all/', {
890
+ owning_product: owning_product
891
+ }));
892
+ }
893
+ }, _callee21, this);
894
+ }));
895
+ function buildAllApps() {
896
+ return _buildAllApps.apply(this, arguments);
897
+ }
898
+ return buildAllApps;
899
+ }()
900
+ }, {
901
+ key: "buildAndPublish",
902
+ value: function () {
903
+ var _buildAndPublish = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(_ref16) {
904
+ var slug, app_definition_id, changelog, published_by;
905
+ return _regenerator().w(function (_context22) {
906
+ while (1) switch (_context22.n) {
907
+ case 0:
908
+ slug = _ref16.slug, app_definition_id = _ref16.app_definition_id, changelog = _ref16.changelog, published_by = _ref16.published_by;
909
+ return _context22.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/build/publish/', {
910
+ slug: slug,
911
+ app_definition_id: app_definition_id,
912
+ changelog: changelog,
913
+ published_by: published_by
914
+ }));
915
+ }
916
+ }, _callee22, this);
917
+ }));
918
+ function buildAndPublish(_x20) {
919
+ return _buildAndPublish.apply(this, arguments);
920
+ }
921
+ return buildAndPublish;
922
+ }()
923
+ }]);
924
+ }();
925
+ function _get(_x21) {
926
+ return _get2.apply(this, arguments);
927
+ }
928
+ function _get2() {
929
+ _get2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(path) {
930
+ var params,
931
+ cleanParams,
932
+ response,
933
+ _args23 = arguments,
934
+ _t;
935
+ return _regenerator().w(function (_context23) {
936
+ while (1) switch (_context23.p = _context23.n) {
937
+ case 0:
938
+ params = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {};
939
+ _context23.p = 1;
940
+ cleanParams = _assertClassBrand(_AppEngineClient_brand, this, _cleanParams).call(this, params);
941
+ _context23.n = 2;
942
+ return this._http.get(path, {
943
+ params: cleanParams
944
+ });
945
+ case 2:
946
+ response = _context23.v;
947
+ return _context23.a(2, response.data);
948
+ case 3:
949
+ _context23.p = 3;
950
+ _t = _context23.v;
951
+ return _context23.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t));
952
+ }
953
+ }, _callee23, this, [[1, 3]]);
954
+ }));
955
+ return _get2.apply(this, arguments);
956
+ }
957
+ function _post(_x22) {
958
+ return _post2.apply(this, arguments);
959
+ }
960
+ function _post2() {
961
+ _post2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(path) {
962
+ var data,
963
+ response,
964
+ _args24 = arguments,
965
+ _t2;
966
+ return _regenerator().w(function (_context24) {
967
+ while (1) switch (_context24.p = _context24.n) {
968
+ case 0:
969
+ data = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {};
970
+ _context24.p = 1;
971
+ _context24.n = 2;
972
+ return this._http.post(path, data);
973
+ case 2:
974
+ response = _context24.v;
975
+ return _context24.a(2, response.data);
976
+ case 3:
977
+ _context24.p = 3;
978
+ _t2 = _context24.v;
979
+ return _context24.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t2));
980
+ }
981
+ }, _callee24, this, [[1, 3]]);
982
+ }));
983
+ return _post2.apply(this, arguments);
984
+ }
985
+ function _patch(_x23) {
986
+ return _patch2.apply(this, arguments);
987
+ }
988
+ function _patch2() {
989
+ _patch2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(path) {
990
+ var data,
991
+ response,
992
+ _args25 = arguments,
993
+ _t3;
994
+ return _regenerator().w(function (_context25) {
995
+ while (1) switch (_context25.p = _context25.n) {
996
+ case 0:
997
+ data = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
998
+ _context25.p = 1;
999
+ _context25.n = 2;
1000
+ return this._http.patch(path, data);
1001
+ case 2:
1002
+ response = _context25.v;
1003
+ return _context25.a(2, response.data);
1004
+ case 3:
1005
+ _context25.p = 3;
1006
+ _t3 = _context25.v;
1007
+ return _context25.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t3));
1008
+ }
1009
+ }, _callee25, this, [[1, 3]]);
1010
+ }));
1011
+ return _patch2.apply(this, arguments);
1012
+ }
1013
+ function _delete(_x24) {
1014
+ return _delete2.apply(this, arguments);
1015
+ }
1016
+ function _delete2() {
1017
+ _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(path) {
1018
+ var data,
1019
+ response,
1020
+ _args26 = arguments,
1021
+ _t4;
1022
+ return _regenerator().w(function (_context26) {
1023
+ while (1) switch (_context26.p = _context26.n) {
1024
+ case 0:
1025
+ data = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
1026
+ _context26.p = 1;
1027
+ _context26.n = 2;
1028
+ return this._http["delete"](path, {
1029
+ data: data
1030
+ });
1031
+ case 2:
1032
+ response = _context26.v;
1033
+ return _context26.a(2, response.data);
1034
+ case 3:
1035
+ _context26.p = 3;
1036
+ _t4 = _context26.v;
1037
+ return _context26.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t4));
1038
+ }
1039
+ }, _callee26, this, [[1, 3]]);
1040
+ }));
1041
+ return _delete2.apply(this, arguments);
1042
+ }
1043
+ function _cleanParams(params) {
1044
+ var clean = {};
1045
+ for (var _i = 0, _Object$entries = Object.entries(params); _i < _Object$entries.length; _i++) {
1046
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1047
+ key = _Object$entries$_i[0],
1048
+ value = _Object$entries$_i[1];
1049
+ if (value !== undefined && value !== null) {
1050
+ clean[key] = value;
1051
+ }
1052
+ }
1053
+ return clean;
1054
+ }
1055
+ function _handleError(error) {
1056
+ if (error.response) {
1057
+ return error.response.data || {
1058
+ success: false,
1059
+ status: error.response.status,
1060
+ message: error.response.statusText
1061
+ };
1062
+ }
1063
+ return {
1064
+ success: false,
1065
+ status: 500,
1066
+ message: error.message || 'Network error'
1067
+ };
1068
+ }
1069
+
1070
+ var RuntimeContainer = styled('div')(function (_ref) {
1071
+ var $launchMode = _ref.$launchMode;
1072
+ return {
1073
+ width: '100%',
1074
+ height: '100%',
1075
+ flex: $launchMode === 'fullscreen' ? 1 : 'none',
1076
+ minHeight: $launchMode === 'fullscreen' ? 0 : '400px',
1077
+ backgroundColor: '#2B2A33',
1078
+ position: 'relative',
1079
+ display: 'flex',
1080
+ flexDirection: 'column'
1081
+ };
1082
+ });
1083
+ var LoadingState = styled('div')({
1084
+ display: 'flex',
1085
+ flexDirection: 'column',
1086
+ alignItems: 'center',
1087
+ justifyContent: 'center',
1088
+ height: '100%',
1089
+ minHeight: '400px',
1090
+ gap: '16px',
1091
+ color: '#9CA3AF'
1092
+ });
1093
+ var ErrorState = styled('div')({
1094
+ display: 'flex',
1095
+ flexDirection: 'column',
1096
+ alignItems: 'center',
1097
+ justifyContent: 'center',
1098
+ height: '100%',
1099
+ minHeight: '400px',
1100
+ gap: '12px',
1101
+ color: '#EF4444',
1102
+ padding: '24px'
1103
+ });
1104
+ var AppRuntimeHost = function AppRuntimeHost(_ref2) {
1105
+ var appSlug = _ref2.appSlug,
1106
+ routePath = _ref2.routePath,
1107
+ _ref2$launchMode = _ref2.launchMode,
1108
+ launchMode = _ref2$launchMode === void 0 ? 'fullscreen' : _ref2$launchMode,
1109
+ _ref2$inputPayload = _ref2.inputPayload,
1110
+ inputPayload = _ref2$inputPayload === void 0 ? {} : _ref2$inputPayload,
1111
+ appSessionService = _ref2.appSessionService,
1112
+ _ref2$apiBaseUrl = _ref2.apiBaseUrl,
1113
+ apiBaseUrl = _ref2$apiBaseUrl === void 0 ? '' : _ref2$apiBaseUrl,
1114
+ onClose = _ref2.onClose,
1115
+ onSubmitOutput = _ref2.onSubmitOutput,
1116
+ onNavigate = _ref2.onNavigate;
1117
+ var _useState = useState('loading'),
1118
+ _useState2 = _slicedToArray(_useState, 2),
1119
+ status = _useState2[0],
1120
+ setStatus = _useState2[1];
1121
+ var _useState3 = useState(null),
1122
+ _useState4 = _slicedToArray(_useState3, 2),
1123
+ error = _useState4[0],
1124
+ setError = _useState4[1];
1125
+ var _useState5 = useState(null),
1126
+ _useState6 = _slicedToArray(_useState5, 2);
1127
+ _useState6[0];
1128
+ var setSession = _useState6[1];
1129
+ var mountRef = useRef(null);
1130
+ var rootRef = useRef(null);
1131
+ var blobUrlRef = useRef(null);
1132
+ var openSession = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1133
+ var response, _response$result, sessionData, version, _t;
1134
+ return _regenerator().w(function (_context) {
1135
+ while (1) switch (_context.p = _context.n) {
1136
+ case 0:
1137
+ if (!(!appSessionService || !appSlug)) {
1138
+ _context.n = 1;
1139
+ break;
1140
+ }
1141
+ return _context.a(2);
1142
+ case 1:
1143
+ setStatus('loading');
1144
+ setError(null);
1145
+ _context.p = 2;
1146
+ _context.n = 3;
1147
+ return appSessionService.open({
1148
+ app_slug: appSlug,
1149
+ route_path: routePath || '/',
1150
+ launch_mode: launchMode,
1151
+ input_payload: inputPayload
1152
+ });
1153
+ case 3:
1154
+ response = _context.v;
1155
+ if (response !== null && response !== void 0 && response.result) {
1156
+ _context.n = 4;
1157
+ break;
1158
+ }
1159
+ throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Failed to open session');
1160
+ case 4:
1161
+ _response$result = response.result, sessionData = _response$result.session, version = _response$result.app_version;
1162
+ setSession(sessionData);
1163
+ if (version !== null && version !== void 0 && version.build_artifact) {
1164
+ _context.n = 5;
1165
+ break;
1166
+ }
1167
+ throw new Error('No build artifact available. Build and publish the app first.');
1168
+ case 5:
1169
+ _context.n = 6;
1170
+ return loadAndMount(version.build_artifact, sessionData, response.result);
1171
+ case 6:
1172
+ _context.n = 8;
1173
+ break;
1174
+ case 7:
1175
+ _context.p = 7;
1176
+ _t = _context.v;
1177
+ setError(_t.message);
1178
+ setStatus('error');
1179
+ case 8:
1180
+ return _context.a(2);
1181
+ }
1182
+ }, _callee, null, [[2, 7]]);
1183
+ })), [appSessionService, appSlug, routePath, launchMode, inputPayload]);
1184
+ var loadAndMount = /*#__PURE__*/function () {
1185
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(buildArtifact, sessionData, fullPayload) {
1186
+ var _buildArtifact$entryF, entryFile, code, blob, blobUrl, module, AppComponent, inputData, sdk, _t2;
1187
+ return _regenerator().w(function (_context9) {
1188
+ while (1) switch (_context9.p = _context9.n) {
1189
+ case 0:
1190
+ _context9.p = 0;
1191
+ entryFile = Object.keys(buildArtifact).find(function (key) {
1192
+ return key.endsWith('.js') || key.endsWith('.mjs');
1193
+ });
1194
+ if (!(!entryFile || !((_buildArtifact$entryF = buildArtifact[entryFile]) !== null && _buildArtifact$entryF !== void 0 && _buildArtifact$entryF.content))) {
1195
+ _context9.n = 1;
1196
+ break;
1197
+ }
1198
+ throw new Error('No entry file found in build artifacts');
1199
+ case 1:
1200
+ code = buildArtifact[entryFile].content;
1201
+ blob = new Blob([code], {
1202
+ type: 'application/javascript'
1203
+ });
1204
+ blobUrl = URL.createObjectURL(blob);
1205
+ blobUrlRef.current = blobUrl;
1206
+ _context9.n = 2;
1207
+ return import(/* @vite-ignore */blobUrl);
1208
+ case 2:
1209
+ module = _context9.v;
1210
+ AppComponent = module["default"];
1211
+ if (AppComponent) {
1212
+ _context9.n = 3;
1213
+ break;
1214
+ }
1215
+ throw new Error('App module does not export a default component');
1216
+ case 3:
1217
+ inputData = sessionData.input_payload || inputPayload;
1218
+ sdk = {
1219
+ session: {
1220
+ id: sessionData.id,
1221
+ appId: sessionData.app_definition_id,
1222
+ appSlug: sessionData.app_slug,
1223
+ appVersionId: sessionData.app_version_id,
1224
+ launchMode: sessionData.launch_mode,
1225
+ routePath: sessionData.route_path
1226
+ },
1227
+ input: inputData,
1228
+ context: {
1229
+ appDefinition: fullPayload.app_definition || {},
1230
+ appVersion: fullPayload.app_version || {},
1231
+ task: (inputData === null || inputData === void 0 ? void 0 : inputData.task) || null,
1232
+ data: inputData
1233
+ },
1234
+ api: {
1235
+ get: function () {
1236
+ var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(path) {
1237
+ var params,
1238
+ qs,
1239
+ url,
1240
+ res,
1241
+ _args2 = arguments;
1242
+ return _regenerator().w(function (_context2) {
1243
+ while (1) switch (_context2.n) {
1244
+ case 0:
1245
+ params = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
1246
+ qs = new URLSearchParams(params).toString();
1247
+ url = "".concat(apiBaseUrl).concat(path).concat(qs ? '?' + qs : '');
1248
+ _context2.n = 1;
1249
+ return fetch(url, {
1250
+ headers: {
1251
+ 'Content-Type': 'application/json'
1252
+ }
1253
+ });
1254
+ case 1:
1255
+ res = _context2.v;
1256
+ return _context2.a(2, res.json());
1257
+ }
1258
+ }, _callee2);
1259
+ }));
1260
+ function get(_x4) {
1261
+ return _get.apply(this, arguments);
1262
+ }
1263
+ return get;
1264
+ }(),
1265
+ post: function () {
1266
+ var _post = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(path) {
1267
+ var body,
1268
+ res,
1269
+ _args3 = arguments;
1270
+ return _regenerator().w(function (_context3) {
1271
+ while (1) switch (_context3.n) {
1272
+ case 0:
1273
+ body = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
1274
+ _context3.n = 1;
1275
+ return fetch("".concat(apiBaseUrl).concat(path), {
1276
+ method: 'POST',
1277
+ headers: {
1278
+ 'Content-Type': 'application/json'
1279
+ },
1280
+ body: JSON.stringify(body)
1281
+ });
1282
+ case 1:
1283
+ res = _context3.v;
1284
+ return _context3.a(2, res.json());
1285
+ }
1286
+ }, _callee3);
1287
+ }));
1288
+ function post(_x5) {
1289
+ return _post.apply(this, arguments);
1290
+ }
1291
+ return post;
1292
+ }(),
1293
+ patch: function () {
1294
+ var _patch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(path) {
1295
+ var body,
1296
+ res,
1297
+ _args4 = arguments;
1298
+ return _regenerator().w(function (_context4) {
1299
+ while (1) switch (_context4.n) {
1300
+ case 0:
1301
+ body = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
1302
+ _context4.n = 1;
1303
+ return fetch("".concat(apiBaseUrl).concat(path), {
1304
+ method: 'PATCH',
1305
+ headers: {
1306
+ 'Content-Type': 'application/json'
1307
+ },
1308
+ body: JSON.stringify(body)
1309
+ });
1310
+ case 1:
1311
+ res = _context4.v;
1312
+ return _context4.a(2, res.json());
1313
+ }
1314
+ }, _callee4);
1315
+ }));
1316
+ function patch(_x6) {
1317
+ return _patch.apply(this, arguments);
1318
+ }
1319
+ return patch;
1320
+ }(),
1321
+ "delete": function () {
1322
+ var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(path) {
1323
+ var res;
1324
+ return _regenerator().w(function (_context5) {
1325
+ while (1) switch (_context5.n) {
1326
+ case 0:
1327
+ _context5.n = 1;
1328
+ return fetch("".concat(apiBaseUrl).concat(path), {
1329
+ method: 'DELETE',
1330
+ headers: {
1331
+ 'Content-Type': 'application/json'
1332
+ }
1333
+ });
1334
+ case 1:
1335
+ res = _context5.v;
1336
+ return _context5.a(2, res.json());
1337
+ }
1338
+ }, _callee5);
1339
+ }));
1340
+ function _delete(_x7) {
1341
+ return _delete2.apply(this, arguments);
1342
+ }
1343
+ return _delete;
1344
+ }()
1345
+ },
1346
+ navigate: function navigate(path) {
1347
+ if (onNavigate) onNavigate(path);
1348
+ },
1349
+ saveDraft: function () {
1350
+ var _saveDraft = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(payload) {
1351
+ return _regenerator().w(function (_context6) {
1352
+ while (1) switch (_context6.n) {
1353
+ case 0:
1354
+ if (!appSessionService) {
1355
+ _context6.n = 1;
1356
+ break;
1357
+ }
1358
+ return _context6.a(2, appSessionService.saveDraft({
1359
+ id: sessionData.id,
1360
+ draft_payload: payload
1361
+ }));
1362
+ case 1:
1363
+ return _context6.a(2);
1364
+ }
1365
+ }, _callee6);
1366
+ }));
1367
+ function saveDraft(_x8) {
1368
+ return _saveDraft.apply(this, arguments);
1369
+ }
1370
+ return saveDraft;
1371
+ }(),
1372
+ submitOutput: function () {
1373
+ var _submitOutput = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(payload) {
1374
+ return _regenerator().w(function (_context7) {
1375
+ while (1) switch (_context7.n) {
1376
+ case 0:
1377
+ if (!appSessionService) {
1378
+ _context7.n = 1;
1379
+ break;
1380
+ }
1381
+ _context7.n = 1;
1382
+ return appSessionService.submitOutput({
1383
+ id: sessionData.id,
1384
+ output_payload: payload
1385
+ });
1386
+ case 1:
1387
+ if (onSubmitOutput) onSubmitOutput(payload);
1388
+ case 2:
1389
+ return _context7.a(2);
1390
+ }
1391
+ }, _callee7);
1392
+ }));
1393
+ function submitOutput(_x9) {
1394
+ return _submitOutput.apply(this, arguments);
1395
+ }
1396
+ return submitOutput;
1397
+ }(),
1398
+ close: function close() {
1399
+ if (onClose) onClose();
1400
+ },
1401
+ cancel: function () {
1402
+ var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(reason) {
1403
+ return _regenerator().w(function (_context8) {
1404
+ while (1) switch (_context8.n) {
1405
+ case 0:
1406
+ if (!appSessionService) {
1407
+ _context8.n = 1;
1408
+ break;
1409
+ }
1410
+ _context8.n = 1;
1411
+ return appSessionService.cancel({
1412
+ id: sessionData.id
1413
+ });
1414
+ case 1:
1415
+ if (onClose) onClose();
1416
+ case 2:
1417
+ return _context8.a(2);
1418
+ }
1419
+ }, _callee8);
1420
+ }));
1421
+ function cancel(_x0) {
1422
+ return _cancel.apply(this, arguments);
1423
+ }
1424
+ return cancel;
1425
+ }()
1426
+ };
1427
+ if (mountRef.current) {
1428
+ rootRef.current = createRoot(mountRef.current);
1429
+ rootRef.current.render(/*#__PURE__*/React$1.createElement(AppComponent, {
1430
+ sdk: sdk
1431
+ }));
1432
+ setStatus('running');
1433
+ }
1434
+ _context9.n = 5;
1435
+ break;
1436
+ case 4:
1437
+ _context9.p = 4;
1438
+ _t2 = _context9.v;
1439
+ setError(_t2.message);
1440
+ setStatus('error');
1441
+ case 5:
1442
+ return _context9.a(2);
1443
+ }
1444
+ }, _callee9, null, [[0, 4]]);
1445
+ }));
1446
+ return function loadAndMount(_x, _x2, _x3) {
1447
+ return _ref4.apply(this, arguments);
1448
+ };
1449
+ }();
1450
+ useEffect(function () {
1451
+ openSession();
1452
+ return function () {
1453
+ if (rootRef.current) {
1454
+ rootRef.current.unmount();
1455
+ rootRef.current = null;
1456
+ }
1457
+ if (blobUrlRef.current) {
1458
+ URL.revokeObjectURL(blobUrlRef.current);
1459
+ blobUrlRef.current = null;
1460
+ }
1461
+ };
1462
+ }, [openSession]);
1463
+ if (status === 'loading') {
1464
+ return /*#__PURE__*/React$1.createElement(RuntimeContainer, {
1465
+ $launchMode: launchMode
1466
+ }, /*#__PURE__*/React$1.createElement(LoadingState, null, /*#__PURE__*/React$1.createElement(CircularProgress, {
1467
+ sx: {
1468
+ color: '#7C3AED'
1469
+ }
1470
+ }), /*#__PURE__*/React$1.createElement(Typography, {
1471
+ sx: {
1472
+ fontSize: '14px'
1473
+ }
1474
+ }, "Loading app...")));
1475
+ }
1476
+ if (status === 'error') {
1477
+ return /*#__PURE__*/React$1.createElement(RuntimeContainer, {
1478
+ $launchMode: launchMode
1479
+ }, /*#__PURE__*/React$1.createElement(ErrorState, null, /*#__PURE__*/React$1.createElement(Typography, {
1480
+ sx: {
1481
+ fontSize: '16px',
1482
+ fontWeight: 500
1483
+ }
1484
+ }, "Failed to load app"), /*#__PURE__*/React$1.createElement(Typography, {
1485
+ sx: {
1486
+ fontSize: '13px',
1487
+ color: '#9CA3AF',
1488
+ textAlign: 'center',
1489
+ maxWidth: '400px'
1490
+ }
1491
+ }, error)));
1492
+ }
1493
+ return /*#__PURE__*/React$1.createElement(RuntimeContainer, {
1494
+ $launchMode: launchMode
1495
+ }, /*#__PURE__*/React$1.createElement("div", {
1496
+ ref: mountRef,
1497
+ style: {
1498
+ width: '100%',
1499
+ height: '100%'
1500
+ }
1501
+ }));
1502
+ };
1503
+
1504
+ var ToolbarContainer = styled('div')({
1505
+ display: 'flex',
1506
+ justifyContent: 'space-between',
1507
+ alignItems: 'center',
1508
+ padding: '8px 16px',
1509
+ backgroundColor: '#1F1E26',
1510
+ borderBottom: '1px solid #6B728040',
1511
+ minHeight: '48px',
1512
+ gap: '12px'
1513
+ });
1514
+ var ActionButton = styled(Button)({
1515
+ textTransform: 'none',
1516
+ fontSize: '12px',
1517
+ borderRadius: '6px',
1518
+ padding: '4px 12px',
1519
+ minWidth: 'auto'
1520
+ });
1521
+ var StudioToolbar = function StudioToolbar(_ref) {
1522
+ var appName = _ref.appName,
1523
+ isSaving = _ref.isSaving,
1524
+ isDirty = _ref.isDirty,
1525
+ buildStatus = _ref.buildStatus,
1526
+ onBack = _ref.onBack,
1527
+ onSave = _ref.onSave,
1528
+ onBuild = _ref.onBuild,
1529
+ onPublish = _ref.onPublish,
1530
+ onPreview = _ref.onPreview,
1531
+ onRun = _ref.onRun,
1532
+ onToggleProperties = _ref.onToggleProperties,
1533
+ isPropertiesOpen = _ref.isPropertiesOpen;
1534
+ return /*#__PURE__*/React$1.createElement(ToolbarContainer, null, /*#__PURE__*/React$1.createElement(Box, {
1535
+ sx: {
1536
+ display: 'flex',
1537
+ alignItems: 'center',
1538
+ gap: '12px'
1539
+ }
1540
+ }, onBack && /*#__PURE__*/React$1.createElement(IconButton, {
1541
+ size: "small",
1542
+ onClick: onBack,
1543
+ sx: {
1544
+ color: '#9CA3AF'
1545
+ }
1546
+ }, /*#__PURE__*/React$1.createElement(ArrowBackIcon, {
1547
+ fontSize: "small"
1548
+ })), /*#__PURE__*/React$1.createElement(Typography, {
1549
+ sx: {
1550
+ color: '#EAEAF0',
1551
+ fontSize: '14px',
1552
+ fontWeight: 600
1553
+ }
1554
+ }, appName || 'Untitled App'), isDirty && /*#__PURE__*/React$1.createElement(Chip, {
1555
+ label: "Unsaved",
1556
+ size: "small",
1557
+ sx: {
1558
+ backgroundColor: '#F59E0B20',
1559
+ color: '#F59E0B',
1560
+ fontSize: '10px',
1561
+ height: '20px'
1562
+ }
1563
+ }), buildStatus && /*#__PURE__*/React$1.createElement(Chip, {
1564
+ label: buildStatus,
1565
+ size: "small",
1566
+ sx: {
1567
+ backgroundColor: buildStatus === 'success' ? '#10B98120' : buildStatus === 'building' ? '#7C3AED20' : buildStatus === 'failed' ? '#EF444420' : '#6B728020',
1568
+ color: buildStatus === 'success' ? '#10B981' : buildStatus === 'building' ? '#7C3AED' : buildStatus === 'failed' ? '#EF4444' : '#6B7280',
1569
+ fontSize: '10px',
1570
+ height: '20px'
1571
+ }
1572
+ })), /*#__PURE__*/React$1.createElement(Box, {
1573
+ sx: {
1574
+ display: 'flex',
1575
+ alignItems: 'center',
1576
+ gap: '8px'
1577
+ }
1578
+ }, onToggleProperties && /*#__PURE__*/React$1.createElement(IconButton, {
1579
+ size: "small",
1580
+ onClick: onToggleProperties,
1581
+ sx: {
1582
+ color: isPropertiesOpen ? '#7C3AED' : '#6B7280'
1583
+ }
1584
+ }, /*#__PURE__*/React$1.createElement(ViewSidebarIcon, {
1585
+ fontSize: "small"
1586
+ })), onSave && /*#__PURE__*/React$1.createElement(ActionButton, {
1587
+ variant: "outlined",
1588
+ startIcon: isSaving ? /*#__PURE__*/React$1.createElement(CircularProgress, {
1589
+ size: 14,
1590
+ sx: {
1591
+ color: '#7C3AED'
1592
+ }
1593
+ }) : /*#__PURE__*/React$1.createElement(SaveIcon, {
1594
+ sx: {
1595
+ fontSize: 14
1596
+ }
1597
+ }),
1598
+ onClick: onSave,
1599
+ disabled: isSaving || !isDirty,
1600
+ sx: {
1601
+ borderColor: '#6B728040',
1602
+ color: '#EAEAF0',
1603
+ '&:hover': {
1604
+ borderColor: '#7C3AED',
1605
+ backgroundColor: '#7C3AED10'
1606
+ },
1607
+ '&.Mui-disabled': {
1608
+ borderColor: '#6B728020',
1609
+ color: '#6B7280'
1610
+ }
1611
+ }
1612
+ }, "Save"), onBuild && /*#__PURE__*/React$1.createElement(ActionButton, {
1613
+ variant: "outlined",
1614
+ startIcon: buildStatus === 'building' ? /*#__PURE__*/React$1.createElement(CircularProgress, {
1615
+ size: 14,
1616
+ sx: {
1617
+ color: '#7C3AED'
1618
+ }
1619
+ }) : /*#__PURE__*/React$1.createElement(BuildIcon, {
1620
+ sx: {
1621
+ fontSize: 14
1622
+ }
1623
+ }),
1624
+ onClick: onBuild,
1625
+ disabled: buildStatus === 'building',
1626
+ sx: {
1627
+ borderColor: '#6B728040',
1628
+ color: '#EAEAF0',
1629
+ '&:hover': {
1630
+ borderColor: '#7C3AED',
1631
+ backgroundColor: '#7C3AED10'
1632
+ },
1633
+ '&.Mui-disabled': {
1634
+ borderColor: '#6B728020',
1635
+ color: '#6B7280'
1636
+ }
1637
+ }
1638
+ }, "Build"), onPreview && /*#__PURE__*/React$1.createElement(ActionButton, {
1639
+ variant: "outlined",
1640
+ startIcon: /*#__PURE__*/React$1.createElement(VisibilityIcon, {
1641
+ sx: {
1642
+ fontSize: 14
1643
+ }
1644
+ }),
1645
+ onClick: onPreview,
1646
+ sx: {
1647
+ borderColor: '#6B728040',
1648
+ color: '#EAEAF0',
1649
+ '&:hover': {
1650
+ borderColor: '#7C3AED',
1651
+ backgroundColor: '#7C3AED10'
1652
+ }
1653
+ }
1654
+ }, "Preview"), onPublish && /*#__PURE__*/React$1.createElement(ActionButton, {
1655
+ variant: "contained",
1656
+ startIcon: /*#__PURE__*/React$1.createElement(PublishIcon, {
1657
+ sx: {
1658
+ fontSize: 14
1659
+ }
1660
+ }),
1661
+ onClick: onPublish,
1662
+ sx: {
1663
+ backgroundColor: '#7C3AED',
1664
+ '&:hover': {
1665
+ backgroundColor: '#6D28D9'
1666
+ }
1667
+ }
1668
+ }, "Publish"), onRun && /*#__PURE__*/React$1.createElement(ActionButton, {
1669
+ variant: "contained",
1670
+ startIcon: /*#__PURE__*/React$1.createElement(PlayArrowIcon, {
1671
+ sx: {
1672
+ fontSize: 14
1673
+ }
1674
+ }),
1675
+ onClick: onRun,
1676
+ sx: {
1677
+ backgroundColor: '#10B981',
1678
+ '&:hover': {
1679
+ backgroundColor: '#059669'
1680
+ }
1681
+ }
1682
+ }, "Run")));
1683
+ };
1684
+
1685
+ var PanelContainer$2 = styled('div')({
1686
+ height: '100%',
1687
+ backgroundColor: '#1F1E26',
1688
+ borderRight: '1px solid #6B728040',
1689
+ display: 'flex',
1690
+ flexDirection: 'column',
1691
+ overflow: 'hidden'
1692
+ });
1693
+ var PanelHeader$2 = styled('div')({
1694
+ display: 'flex',
1695
+ justifyContent: 'space-between',
1696
+ alignItems: 'center',
1697
+ padding: '8px 12px',
1698
+ borderBottom: '1px solid #6B728040',
1699
+ minHeight: '36px'
1700
+ });
1701
+ var TreeContainer = styled('div')({
1702
+ flex: 1,
1703
+ overflowY: 'auto',
1704
+ padding: '4px 0'
1705
+ });
1706
+ var TreeItem = styled('div')(function (_ref) {
1707
+ var $depth = _ref.$depth,
1708
+ $isActive = _ref.$isActive;
1709
+ return {
1710
+ display: 'flex',
1711
+ alignItems: 'center',
1712
+ gap: '4px',
1713
+ padding: "3px 8px 3px ".concat(8 + $depth * 16, "px"),
1714
+ cursor: 'pointer',
1715
+ fontSize: '12px',
1716
+ color: $isActive ? '#EAEAF0' : '#9CA3AF',
1717
+ backgroundColor: $isActive ? '#7C3AED20' : 'transparent',
1718
+ '&:hover': {
1719
+ backgroundColor: $isActive ? '#7C3AED20' : '#2B2A33'
1720
+ }
1721
+ };
1722
+ });
1723
+ var FileExplorer = function FileExplorer(_ref2) {
1724
+ var _ref2$fileTree = _ref2.fileTree,
1725
+ fileTree = _ref2$fileTree === void 0 ? [] : _ref2$fileTree,
1726
+ activeFilePath = _ref2.activeFilePath,
1727
+ onFileSelect = _ref2.onFileSelect,
1728
+ onCreateFile = _ref2.onCreateFile,
1729
+ onCreateFolder = _ref2.onCreateFolder;
1730
+ var _useState = useState(new Set(['/src', '/src/components', '/src/views'])),
1731
+ _useState2 = _slicedToArray(_useState, 2),
1732
+ expandedFolders = _useState2[0],
1733
+ setExpandedFolders = _useState2[1];
1734
+ var tree = useMemo(function () {
1735
+ return buildTree(fileTree);
1736
+ }, [fileTree]);
1737
+ var toggleFolder = function toggleFolder(path) {
1738
+ setExpandedFolders(function (prev) {
1739
+ var next = new Set(prev);
1740
+ if (next.has(path)) {
1741
+ next["delete"](path);
1742
+ } else {
1743
+ next.add(path);
1744
+ }
1745
+ return next;
1746
+ });
1747
+ };
1748
+ var handleItemClick = function handleItemClick(item) {
1749
+ if (item.kind === 'folder') {
1750
+ toggleFolder(item.path);
1751
+ } else if (onFileSelect) {
1752
+ onFileSelect(item);
1753
+ }
1754
+ };
1755
+ var _renderTree = function renderTree(nodes) {
1756
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1757
+ return nodes.map(function (node) {
1758
+ var _node$children;
1759
+ var isFolder = node.kind === 'folder';
1760
+ var isExpanded = expandedFolders.has(node.path);
1761
+ var isActive = node.path === activeFilePath;
1762
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, {
1763
+ key: node.path
1764
+ }, /*#__PURE__*/React$1.createElement(TreeItem, {
1765
+ $depth: depth,
1766
+ $isActive: isActive,
1767
+ onClick: function onClick() {
1768
+ return handleItemClick(node);
1769
+ }
1770
+ }, isFolder ? isExpanded ? /*#__PURE__*/React$1.createElement(ExpandMoreIcon, {
1771
+ sx: {
1772
+ fontSize: 14,
1773
+ color: '#6B7280'
1774
+ }
1775
+ }) : /*#__PURE__*/React$1.createElement(ChevronRightIcon, {
1776
+ sx: {
1777
+ fontSize: 14,
1778
+ color: '#6B7280'
1779
+ }
1780
+ }) : /*#__PURE__*/React$1.createElement("span", {
1781
+ style: {
1782
+ width: 14
1783
+ }
1784
+ }), isFolder ? isExpanded ? /*#__PURE__*/React$1.createElement(FolderOpenIcon, {
1785
+ sx: {
1786
+ fontSize: 14,
1787
+ color: '#F59E0B'
1788
+ }
1789
+ }) : /*#__PURE__*/React$1.createElement(FolderIcon, {
1790
+ sx: {
1791
+ fontSize: 14,
1792
+ color: '#F59E0B'
1793
+ }
1794
+ }) : /*#__PURE__*/React$1.createElement(InsertDriveFileIcon, {
1795
+ sx: {
1796
+ fontSize: 14,
1797
+ color: getFileColor(node.language)
1798
+ }
1799
+ }), /*#__PURE__*/React$1.createElement(Typography, {
1800
+ sx: {
1801
+ fontSize: '12px',
1802
+ color: 'inherit',
1803
+ whiteSpace: 'nowrap',
1804
+ overflow: 'hidden',
1805
+ textOverflow: 'ellipsis'
1806
+ }
1807
+ }, node.name)), isFolder && isExpanded && ((_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.length) > 0 && _renderTree(node.children, depth + 1));
1808
+ });
1809
+ };
1810
+ return /*#__PURE__*/React$1.createElement(PanelContainer$2, null, /*#__PURE__*/React$1.createElement(PanelHeader$2, null, /*#__PURE__*/React$1.createElement(Typography, {
1811
+ sx: {
1812
+ color: '#9CA3AF',
1813
+ fontSize: '11px',
1814
+ fontWeight: 600,
1815
+ textTransform: 'uppercase',
1816
+ letterSpacing: '0.5px'
1817
+ }
1818
+ }, "Explorer"), /*#__PURE__*/React$1.createElement(Box, {
1819
+ sx: {
1820
+ display: 'flex',
1821
+ gap: '2px'
1822
+ }
1823
+ }, onCreateFile && /*#__PURE__*/React$1.createElement(IconButton, {
1824
+ size: "small",
1825
+ onClick: onCreateFile,
1826
+ sx: {
1827
+ color: '#6B7280',
1828
+ padding: '2px'
1829
+ }
1830
+ }, /*#__PURE__*/React$1.createElement(NoteAddIcon, {
1831
+ sx: {
1832
+ fontSize: 16
1833
+ }
1834
+ })), onCreateFolder && /*#__PURE__*/React$1.createElement(IconButton, {
1835
+ size: "small",
1836
+ onClick: onCreateFolder,
1837
+ sx: {
1838
+ color: '#6B7280',
1839
+ padding: '2px'
1840
+ }
1841
+ }, /*#__PURE__*/React$1.createElement(CreateNewFolderIcon, {
1842
+ sx: {
1843
+ fontSize: 16
1844
+ }
1845
+ })))), /*#__PURE__*/React$1.createElement(TreeContainer, null, _renderTree(tree)));
1846
+ };
1847
+ function buildTree(files) {
1848
+ var root = [];
1849
+ var folderMap = {};
1850
+ var folders = files.filter(function (f) {
1851
+ return f.kind === 'folder';
1852
+ }).sort(function (a, b) {
1853
+ return a.path.localeCompare(b.path);
1854
+ });
1855
+ var fileItems = files.filter(function (f) {
1856
+ return f.kind !== 'folder';
1857
+ }).sort(function (a, b) {
1858
+ return a.path.localeCompare(b.path);
1859
+ });
1860
+ var _iterator = _createForOfIteratorHelper(folders),
1861
+ _step;
1862
+ try {
1863
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1864
+ var folder = _step.value;
1865
+ folderMap[folder.path] = _objectSpread2(_objectSpread2({}, folder), {}, {
1866
+ children: []
1867
+ });
1868
+ }
1869
+ } catch (err) {
1870
+ _iterator.e(err);
1871
+ } finally {
1872
+ _iterator.f();
1873
+ }
1874
+ var _iterator2 = _createForOfIteratorHelper(fileItems),
1875
+ _step2;
1876
+ try {
1877
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1878
+ var file = _step2.value;
1879
+ var parentPath = file.parent_path || '/';
1880
+ if (folderMap[parentPath]) {
1881
+ folderMap[parentPath].children.push(file);
1882
+ }
1883
+ }
1884
+ } catch (err) {
1885
+ _iterator2.e(err);
1886
+ } finally {
1887
+ _iterator2.f();
1888
+ }
1889
+ var _iterator3 = _createForOfIteratorHelper(folders),
1890
+ _step3;
1891
+ try {
1892
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1893
+ var _folder = _step3.value;
1894
+ var _parentPath = _folder.parent_path || null;
1895
+ if (_parentPath && folderMap[_parentPath]) {
1896
+ folderMap[_parentPath].children.unshift(folderMap[_folder.path]);
1897
+ } else {
1898
+ root.push(folderMap[_folder.path]);
1899
+ }
1900
+ }
1901
+ } catch (err) {
1902
+ _iterator3.e(err);
1903
+ } finally {
1904
+ _iterator3.f();
1905
+ }
1906
+ var orphanFiles = fileItems.filter(function (f) {
1907
+ return !f.parent_path || f.parent_path === '/';
1908
+ });
1909
+ root.push.apply(root, _toConsumableArray(orphanFiles));
1910
+ return root;
1911
+ }
1912
+ function getFileColor(language) {
1913
+ var colors = {
1914
+ jsx: '#61DAFB',
1915
+ js: '#F7DF1E',
1916
+ css: '#264DE4',
1917
+ json: '#6B7280',
1918
+ html: '#E34F26'
1919
+ };
1920
+ return colors[language] || '#6B7280';
1921
+ }
1922
+
1923
+ var EditorContainer = styled('div')({
1924
+ height: '100%',
1925
+ display: 'flex',
1926
+ flexDirection: 'column',
1927
+ backgroundColor: '#1E1E1E',
1928
+ overflow: 'hidden'
1929
+ });
1930
+ var TabsContainer = styled('div')({
1931
+ backgroundColor: '#252526',
1932
+ borderBottom: '1px solid #6B728040',
1933
+ minHeight: '35px'
1934
+ });
1935
+ var EditorWrapper = styled('div')({
1936
+ flex: 1,
1937
+ overflow: 'hidden'
1938
+ });
1939
+ var EmptyEditor = styled('div')({
1940
+ display: 'flex',
1941
+ alignItems: 'center',
1942
+ justifyContent: 'center',
1943
+ height: '100%',
1944
+ color: '#6B7280'
1945
+ });
1946
+ var StyledTab = styled(Tab)(function (_ref) {
1947
+ var $isDirty = _ref.$isDirty;
1948
+ return {
1949
+ minHeight: '35px',
1950
+ padding: '0 12px',
1951
+ textTransform: 'none',
1952
+ fontSize: '12px',
1953
+ color: '#9CA3AF',
1954
+ '&.Mui-selected': {
1955
+ color: '#EAEAF0',
1956
+ backgroundColor: '#1E1E1E'
1957
+ },
1958
+ '& .tab-label': {
1959
+ display: 'flex',
1960
+ alignItems: 'center',
1961
+ gap: '4px'
1962
+ },
1963
+ '& .dirty-indicator': {
1964
+ display: $isDirty ? 'inline-block' : 'none',
1965
+ width: '6px',
1966
+ height: '6px',
1967
+ borderRadius: '50%',
1968
+ backgroundColor: '#EAEAF0'
1969
+ }
1970
+ };
1971
+ });
1972
+ var EditorArea = function EditorArea(_ref2) {
1973
+ var _ref2$openFiles = _ref2.openFiles,
1974
+ openFiles = _ref2$openFiles === void 0 ? [] : _ref2$openFiles,
1975
+ activeFilePath = _ref2.activeFilePath,
1976
+ onTabChange = _ref2.onTabChange,
1977
+ onTabClose = _ref2.onTabClose,
1978
+ onContentChange = _ref2.onContentChange;
1979
+ var activeFile = openFiles.find(function (f) {
1980
+ return f.path === activeFilePath;
1981
+ });
1982
+ var activeIndex = openFiles.findIndex(function (f) {
1983
+ return f.path === activeFilePath;
1984
+ });
1985
+ var handleTabChange = function handleTabChange(event, newIndex) {
1986
+ if (onTabChange && openFiles[newIndex]) {
1987
+ onTabChange(openFiles[newIndex].path);
1988
+ }
1989
+ };
1990
+ var handleTabClose = function handleTabClose(event, filePath) {
1991
+ event.stopPropagation();
1992
+ if (onTabClose) {
1993
+ onTabClose(filePath);
1994
+ }
1995
+ };
1996
+ var handleEditorChange = useCallback(function (value) {
1997
+ if (onContentChange && activeFilePath) {
1998
+ onContentChange(activeFilePath, value);
1999
+ }
2000
+ }, [onContentChange, activeFilePath]);
2001
+ var getLanguage = function getLanguage(filePath) {
2002
+ if (!filePath) return 'javascript';
2003
+ if (filePath.endsWith('.jsx') || filePath.endsWith('.tsx')) return 'javascript';
2004
+ if (filePath.endsWith('.js') || filePath.endsWith('.ts')) return 'javascript';
2005
+ if (filePath.endsWith('.css')) return 'css';
2006
+ if (filePath.endsWith('.json')) return 'json';
2007
+ if (filePath.endsWith('.html')) return 'html';
2008
+ return 'plaintext';
2009
+ };
2010
+ return /*#__PURE__*/React$1.createElement(EditorContainer, null, openFiles.length > 0 ? /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(TabsContainer, null, /*#__PURE__*/React$1.createElement(Tabs, {
2011
+ value: activeIndex >= 0 ? activeIndex : 0,
2012
+ onChange: handleTabChange,
2013
+ variant: "scrollable",
2014
+ scrollButtons: "auto",
2015
+ sx: {
2016
+ minHeight: '35px',
2017
+ '& .MuiTabs-indicator': {
2018
+ backgroundColor: '#7C3AED',
2019
+ height: '2px'
2020
+ },
2021
+ '& .MuiTabs-scrollButtons': {
2022
+ color: '#6B7280'
2023
+ }
2024
+ }
2025
+ }, openFiles.map(function (file) {
2026
+ return /*#__PURE__*/React$1.createElement(StyledTab, {
2027
+ key: file.path,
2028
+ $isDirty: file.isDirty,
2029
+ label: /*#__PURE__*/React$1.createElement("span", {
2030
+ className: "tab-label"
2031
+ }, /*#__PURE__*/React$1.createElement("span", {
2032
+ className: "dirty-indicator"
2033
+ }), file.name || file.path.split('/').pop(), /*#__PURE__*/React$1.createElement(IconButton, {
2034
+ size: "small",
2035
+ onClick: function onClick(e) {
2036
+ return handleTabClose(e, file.path);
2037
+ },
2038
+ sx: {
2039
+ color: '#6B7280',
2040
+ padding: '1px',
2041
+ ml: '4px',
2042
+ '&:hover': {
2043
+ color: '#EAEAF0'
2044
+ }
2045
+ }
2046
+ }, /*#__PURE__*/React$1.createElement(CloseIcon, {
2047
+ sx: {
2048
+ fontSize: 12
2049
+ }
2050
+ })))
2051
+ });
2052
+ }))), /*#__PURE__*/React$1.createElement(EditorWrapper, null, activeFile && /*#__PURE__*/React$1.createElement(Editor, {
2053
+ height: "100%",
2054
+ language: getLanguage(activeFile.path),
2055
+ value: activeFile.content || '',
2056
+ onChange: handleEditorChange,
2057
+ theme: "vs-dark",
2058
+ options: {
2059
+ minimap: {
2060
+ enabled: true
2061
+ },
2062
+ fontSize: 13,
2063
+ lineNumbers: 'on',
2064
+ scrollBeyondLastLine: false,
2065
+ wordWrap: 'on',
2066
+ tabSize: 2,
2067
+ automaticLayout: true,
2068
+ padding: {
2069
+ top: 8
2070
+ }
2071
+ }
2072
+ }))) : /*#__PURE__*/React$1.createElement(EmptyEditor, null, /*#__PURE__*/React$1.createElement(Box, {
2073
+ sx: {
2074
+ textAlign: 'center'
2075
+ }
2076
+ }, /*#__PURE__*/React$1.createElement(Typography, {
2077
+ sx: {
2078
+ fontSize: '14px',
2079
+ mb: 1
2080
+ }
2081
+ }, "No file open"), /*#__PURE__*/React$1.createElement(Typography, {
2082
+ sx: {
2083
+ fontSize: '12px'
2084
+ }
2085
+ }, "Select a file from the explorer to start editing"))));
2086
+ };
2087
+
2088
+ var PanelContainer$1 = styled('div')(function (_ref) {
2089
+ var $isOpen = _ref.$isOpen;
2090
+ return {
2091
+ height: '100%',
2092
+ width: $isOpen ? '300px' : '0px',
2093
+ minWidth: $isOpen ? '300px' : '0px',
2094
+ backgroundColor: '#1F1E26',
2095
+ borderLeft: $isOpen ? '1px solid #6B728040' : 'none',
2096
+ display: 'flex',
2097
+ flexDirection: 'column',
2098
+ overflow: 'hidden',
2099
+ transition: 'width 0.2s, min-width 0.2s'
2100
+ };
2101
+ });
2102
+ var PanelHeader$1 = styled('div')({
2103
+ display: 'flex',
2104
+ justifyContent: 'space-between',
2105
+ alignItems: 'center',
2106
+ padding: '8px 12px',
2107
+ borderBottom: '1px solid #6B728040',
2108
+ minHeight: '36px'
2109
+ });
2110
+ var PanelContent$1 = styled('div')({
2111
+ flex: 1,
2112
+ overflowY: 'auto',
2113
+ padding: '12px'
2114
+ });
2115
+ var FieldGroup = styled('div')({
2116
+ marginBottom: '16px'
2117
+ });
2118
+ var FieldLabel = styled(Typography)({
2119
+ color: '#9CA3AF',
2120
+ fontSize: '11px',
2121
+ fontWeight: 600,
2122
+ textTransform: 'uppercase',
2123
+ letterSpacing: '0.5px',
2124
+ marginBottom: '6px'
2125
+ });
2126
+ var inputSx = {
2127
+ '& .MuiOutlinedInput-root': {
2128
+ backgroundColor: '#2B2A33',
2129
+ color: '#EAEAF0',
2130
+ fontSize: '13px',
2131
+ '& fieldset': {
2132
+ borderColor: '#6B728040'
2133
+ },
2134
+ '&:hover fieldset': {
2135
+ borderColor: '#7C3AED'
2136
+ },
2137
+ '&.Mui-focused fieldset': {
2138
+ borderColor: '#7C3AED'
2139
+ }
2140
+ }
2141
+ };
2142
+ var selectSx = {
2143
+ backgroundColor: '#2B2A33',
2144
+ color: '#EAEAF0',
2145
+ fontSize: '13px',
2146
+ '& fieldset': {
2147
+ borderColor: '#6B728040'
2148
+ },
2149
+ '&:hover fieldset': {
2150
+ borderColor: '#7C3AED'
2151
+ },
2152
+ '&.Mui-focused fieldset': {
2153
+ borderColor: '#7C3AED'
2154
+ },
2155
+ '& .MuiSelect-icon': {
2156
+ color: '#6B7280'
2157
+ }
2158
+ };
2159
+ var PropertiesPanel = function PropertiesPanel(_ref2) {
2160
+ var _appDefinition$tags, _appDefinition$manife, _appDefinition$manife2, _appDefinition$manife3, _appDefinition$manife4, _appDefinition$manife5, _appDefinition$manife6, _appDefinition$routes;
2161
+ var _ref2$isOpen = _ref2.isOpen,
2162
+ isOpen = _ref2$isOpen === void 0 ? true : _ref2$isOpen,
2163
+ onClose = _ref2.onClose,
2164
+ appDefinition = _ref2.appDefinition,
2165
+ onUpdateDefinition = _ref2.onUpdateDefinition;
2166
+ var _useState = useState(0),
2167
+ _useState2 = _slicedToArray(_useState, 2),
2168
+ activeTab = _useState2[0],
2169
+ setActiveTab = _useState2[1];
2170
+ var handleFieldChange = function handleFieldChange(field, value) {
2171
+ if (onUpdateDefinition) {
2172
+ onUpdateDefinition(_objectSpread2(_objectSpread2({}, appDefinition), {}, _defineProperty({}, field, value)));
2173
+ }
2174
+ };
2175
+ var handleManifestFieldChange = function handleManifestFieldChange(field, value) {
2176
+ if (!onUpdateDefinition) return;
2177
+ var updatedManifest = _objectSpread2(_objectSpread2({}, (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.manifest) || {}), {}, _defineProperty({}, field, value));
2178
+ if (field === 'launcher_visibility') {
2179
+ updatedManifest.launcher_visible = value === 'visible';
2180
+ }
2181
+ onUpdateDefinition(_objectSpread2(_objectSpread2({}, appDefinition), {}, {
2182
+ manifest: updatedManifest
2183
+ }));
2184
+ };
2185
+ return /*#__PURE__*/React$1.createElement(PanelContainer$1, {
2186
+ $isOpen: isOpen
2187
+ }, /*#__PURE__*/React$1.createElement(PanelHeader$1, null, /*#__PURE__*/React$1.createElement(Typography, {
2188
+ sx: {
2189
+ color: '#9CA3AF',
2190
+ fontSize: '11px',
2191
+ fontWeight: 600,
2192
+ textTransform: 'uppercase',
2193
+ letterSpacing: '0.5px'
2194
+ }
2195
+ }, "Properties"), onClose && /*#__PURE__*/React$1.createElement(IconButton, {
2196
+ size: "small",
2197
+ onClick: onClose,
2198
+ sx: {
2199
+ color: '#6B7280',
2200
+ padding: '2px'
2201
+ }
2202
+ }, /*#__PURE__*/React$1.createElement(ChevronLeftIcon, {
2203
+ sx: {
2204
+ fontSize: 16,
2205
+ transform: 'rotate(180deg)'
2206
+ }
2207
+ }))), /*#__PURE__*/React$1.createElement(Tabs, {
2208
+ value: activeTab,
2209
+ onChange: function onChange(e, v) {
2210
+ return setActiveTab(v);
2211
+ },
2212
+ variant: "fullWidth",
2213
+ sx: {
2214
+ minHeight: '32px',
2215
+ borderBottom: '1px solid #6B728040',
2216
+ '& .MuiTab-root': {
2217
+ minHeight: '32px',
2218
+ fontSize: '11px',
2219
+ textTransform: 'none',
2220
+ color: '#9CA3AF'
2221
+ },
2222
+ '& .Mui-selected': {
2223
+ color: '#EAEAF0'
2224
+ },
2225
+ '& .MuiTabs-indicator': {
2226
+ backgroundColor: '#7C3AED'
2227
+ }
2228
+ }
2229
+ }, /*#__PURE__*/React$1.createElement(Tab, {
2230
+ label: "General"
2231
+ }), /*#__PURE__*/React$1.createElement(Tab, {
2232
+ label: "Manifest"
2233
+ }), /*#__PURE__*/React$1.createElement(Tab, {
2234
+ label: "Routes"
2235
+ })), /*#__PURE__*/React$1.createElement(PanelContent$1, null, activeTab === 0 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Name"), /*#__PURE__*/React$1.createElement(TextField, {
2236
+ fullWidth: true,
2237
+ size: "small",
2238
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.name) || '',
2239
+ onChange: function onChange(e) {
2240
+ return handleFieldChange('name', e.target.value);
2241
+ },
2242
+ sx: inputSx
2243
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Slug"), /*#__PURE__*/React$1.createElement(TextField, {
2244
+ fullWidth: true,
2245
+ size: "small",
2246
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.slug) || '',
2247
+ onChange: function onChange(e) {
2248
+ return handleFieldChange('slug', e.target.value);
2249
+ },
2250
+ sx: inputSx
2251
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Description"), /*#__PURE__*/React$1.createElement(TextField, {
2252
+ fullWidth: true,
2253
+ size: "small",
2254
+ multiline: true,
2255
+ rows: 3,
2256
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.description) || '',
2257
+ onChange: function onChange(e) {
2258
+ return handleFieldChange('description', e.target.value);
2259
+ },
2260
+ sx: inputSx
2261
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Category"), /*#__PURE__*/React$1.createElement(TextField, {
2262
+ fullWidth: true,
2263
+ size: "small",
2264
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.category) || '',
2265
+ onChange: function onChange(e) {
2266
+ return handleFieldChange('category', e.target.value);
2267
+ },
2268
+ sx: inputSx
2269
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Icon"), /*#__PURE__*/React$1.createElement(TextField, {
2270
+ fullWidth: true,
2271
+ size: "small",
2272
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.icon) || '',
2273
+ onChange: function onChange(e) {
2274
+ return handleFieldChange('icon', e.target.value);
2275
+ },
2276
+ sx: inputSx
2277
+ })), (appDefinition === null || appDefinition === void 0 || (_appDefinition$tags = appDefinition.tags) === null || _appDefinition$tags === void 0 ? void 0 : _appDefinition$tags.length) > 0 && /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Tags"), /*#__PURE__*/React$1.createElement(Box, {
2278
+ sx: {
2279
+ display: 'flex',
2280
+ flexWrap: 'wrap',
2281
+ gap: '4px'
2282
+ }
2283
+ }, appDefinition.tags.map(function (tag, i) {
2284
+ return /*#__PURE__*/React$1.createElement(Chip, {
2285
+ key: i,
2286
+ label: tag,
2287
+ size: "small",
2288
+ sx: {
2289
+ backgroundColor: '#7C3AED20',
2290
+ color: '#A78BFA',
2291
+ fontSize: '11px',
2292
+ height: '22px'
2293
+ }
2294
+ });
2295
+ })))), activeTab === 1 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Kind"), /*#__PURE__*/React$1.createElement(Select, {
2296
+ fullWidth: true,
2297
+ size: "small",
2298
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife = appDefinition.manifest) === null || _appDefinition$manife === void 0 ? void 0 : _appDefinition$manife.kind) || 'workspace',
2299
+ onChange: function onChange(e) {
2300
+ return handleManifestFieldChange('kind', e.target.value);
2301
+ },
2302
+ sx: selectSx
2303
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
2304
+ value: "workspace"
2305
+ }, "Workspace"), /*#__PURE__*/React$1.createElement(MenuItem, {
2306
+ value: "utility"
2307
+ }, "Utility"))), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Launcher Visibility"), /*#__PURE__*/React$1.createElement(Select, {
2308
+ fullWidth: true,
2309
+ size: "small",
2310
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife2 = appDefinition.manifest) === null || _appDefinition$manife2 === void 0 ? void 0 : _appDefinition$manife2.launcher_visibility) || 'visible',
2311
+ onChange: function onChange(e) {
2312
+ return handleManifestFieldChange('launcher_visibility', e.target.value);
2313
+ },
2314
+ sx: selectSx
2315
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
2316
+ value: "visible"
2317
+ }, "Visible"), /*#__PURE__*/React$1.createElement(MenuItem, {
2318
+ value: "hidden"
2319
+ }, "Hidden"), /*#__PURE__*/React$1.createElement(MenuItem, {
2320
+ value: "system"
2321
+ }, "System"))), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Entry Behavior"), /*#__PURE__*/React$1.createElement(Select, {
2322
+ fullWidth: true,
2323
+ size: "small",
2324
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife3 = appDefinition.manifest) === null || _appDefinition$manife3 === void 0 ? void 0 : _appDefinition$manife3.entry_behavior) || 'home',
2325
+ onChange: function onChange(e) {
2326
+ return handleManifestFieldChange('entry_behavior', e.target.value);
2327
+ },
2328
+ sx: selectSx
2329
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
2330
+ value: "home"
2331
+ }, "Home"), /*#__PURE__*/React$1.createElement(MenuItem, {
2332
+ value: "context-required"
2333
+ }, "Context Required"), /*#__PURE__*/React$1.createElement(MenuItem, {
2334
+ value: "route-only"
2335
+ }, "Route Only"))), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Pinnable"), /*#__PURE__*/React$1.createElement(Switch, {
2336
+ checked: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife4 = appDefinition.manifest) === null || _appDefinition$manife4 === void 0 ? void 0 : _appDefinition$manife4.pinnable) !== false,
2337
+ onChange: function onChange(e) {
2338
+ return handleManifestFieldChange('pinnable', e.target.checked);
2339
+ },
2340
+ size: "small",
2341
+ sx: {
2342
+ '& .Mui-checked': {
2343
+ color: '#7C3AED'
2344
+ },
2345
+ '& .Mui-checked + .MuiSwitch-track': {
2346
+ backgroundColor: '#7C3AED'
2347
+ }
2348
+ }
2349
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Requires Context"), /*#__PURE__*/React$1.createElement(Switch, {
2350
+ checked: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife5 = appDefinition.manifest) === null || _appDefinition$manife5 === void 0 ? void 0 : _appDefinition$manife5.requires_context) || false,
2351
+ onChange: function onChange(e) {
2352
+ return handleManifestFieldChange('requires_context', e.target.checked);
2353
+ },
2354
+ size: "small",
2355
+ sx: {
2356
+ '& .Mui-checked': {
2357
+ color: '#7C3AED'
2358
+ },
2359
+ '& .Mui-checked + .MuiSwitch-track': {
2360
+ backgroundColor: '#7C3AED'
2361
+ }
2362
+ }
2363
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Entry Route"), /*#__PURE__*/React$1.createElement(TextField, {
2364
+ fullWidth: true,
2365
+ size: "small",
2366
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife6 = appDefinition.manifest) === null || _appDefinition$manife6 === void 0 ? void 0 : _appDefinition$manife6.entry_route) || '/',
2367
+ onChange: function onChange(e) {
2368
+ return handleManifestFieldChange('entry_route', e.target.value);
2369
+ },
2370
+ sx: inputSx
2371
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Advanced (JSON)"), /*#__PURE__*/React$1.createElement(TextField, {
2372
+ fullWidth: true,
2373
+ size: "small",
2374
+ multiline: true,
2375
+ rows: 6,
2376
+ value: appDefinition !== null && appDefinition !== void 0 && appDefinition.manifest ? JSON.stringify(appDefinition.manifest, null, 2) : '{}',
2377
+ onChange: function onChange(e) {
2378
+ try {
2379
+ handleFieldChange('manifest', JSON.parse(e.target.value));
2380
+ } catch (_) {/* ignore parse errors during typing */}
2381
+ },
2382
+ sx: _objectSpread2(_objectSpread2({}, inputSx), {}, {
2383
+ '& .MuiOutlinedInput-root': _objectSpread2(_objectSpread2({}, inputSx['& .MuiOutlinedInput-root']), {}, {
2384
+ fontFamily: 'monospace',
2385
+ fontSize: '12px'
2386
+ })
2387
+ })
2388
+ }))), activeTab === 2 && /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Routes"), (appDefinition === null || appDefinition === void 0 || (_appDefinition$routes = appDefinition.routes) === null || _appDefinition$routes === void 0 ? void 0 : _appDefinition$routes.length) > 0 ? appDefinition.routes.map(function (route, i) {
2389
+ return /*#__PURE__*/React$1.createElement(Box, {
2390
+ key: i,
2391
+ sx: {
2392
+ mb: 1,
2393
+ p: 1,
2394
+ backgroundColor: '#2B2A33',
2395
+ borderRadius: '6px'
2396
+ }
2397
+ }, /*#__PURE__*/React$1.createElement(Typography, {
2398
+ sx: {
2399
+ color: '#EAEAF0',
2400
+ fontSize: '12px',
2401
+ fontWeight: 500
2402
+ }
2403
+ }, route.path || '/'), /*#__PURE__*/React$1.createElement(Typography, {
2404
+ sx: {
2405
+ color: '#9CA3AF',
2406
+ fontSize: '11px'
2407
+ }
2408
+ }, route.name || 'Unnamed route'));
2409
+ }) : /*#__PURE__*/React$1.createElement(Typography, {
2410
+ sx: {
2411
+ color: '#6B7280',
2412
+ fontSize: '12px'
2413
+ }
2414
+ }, "No routes defined"))));
2415
+ };
2416
+
2417
+ var PanelContainer = styled('div')(function (_ref) {
2418
+ var $isOpen = _ref.$isOpen,
2419
+ $height = _ref.$height;
2420
+ return {
2421
+ height: $isOpen ? "".concat($height, "px") : '35px',
2422
+ backgroundColor: '#1F1E26',
2423
+ borderTop: '1px solid #6B728040',
2424
+ display: 'flex',
2425
+ flexDirection: 'column',
2426
+ overflow: 'hidden',
2427
+ transition: 'height 0.2s'
2428
+ };
2429
+ });
2430
+ var PanelHeader = styled('div')({
2431
+ display: 'flex',
2432
+ justifyContent: 'space-between',
2433
+ alignItems: 'center',
2434
+ minHeight: '35px',
2435
+ borderBottom: '1px solid #6B728040'
2436
+ });
2437
+ var PanelContent = styled('div')({
2438
+ flex: 1,
2439
+ overflowY: 'auto',
2440
+ padding: '8px 12px',
2441
+ fontFamily: "'JetBrains Mono', 'Fira Code', monospace",
2442
+ fontSize: '12px',
2443
+ lineHeight: 1.6
2444
+ });
2445
+ var LogLine = styled('div')(function (_ref2) {
2446
+ var $level = _ref2.$level;
2447
+ return {
2448
+ color: $level === 'error' ? '#EF4444' : $level === 'warning' ? '#F59E0B' : $level === 'success' ? '#10B981' : '#9CA3AF',
2449
+ whiteSpace: 'pre-wrap',
2450
+ wordBreak: 'break-all'
2451
+ };
2452
+ });
2453
+ var BottomPanel = function BottomPanel(_ref3) {
2454
+ var _ref3$buildLog = _ref3.buildLog,
2455
+ buildLog = _ref3$buildLog === void 0 ? '' : _ref3$buildLog,
2456
+ _ref3$buildErrors = _ref3.buildErrors,
2457
+ buildErrors = _ref3$buildErrors === void 0 ? [] : _ref3$buildErrors,
2458
+ controlledIsOpen = _ref3.isOpen,
2459
+ onToggle = _ref3.onToggle,
2460
+ _ref3$height = _ref3.height,
2461
+ height = _ref3$height === void 0 ? 200 : _ref3$height;
2462
+ var _useState = useState(false),
2463
+ _useState2 = _slicedToArray(_useState, 2),
2464
+ internalIsOpen = _useState2[0],
2465
+ setInternalIsOpen = _useState2[1];
2466
+ var _useState3 = useState(0),
2467
+ _useState4 = _slicedToArray(_useState3, 2),
2468
+ activeTab = _useState4[0],
2469
+ setActiveTab = _useState4[1];
2470
+ var isOpen = controlledIsOpen !== undefined ? controlledIsOpen : internalIsOpen;
2471
+ var handleToggle = function handleToggle() {
2472
+ if (onToggle) {
2473
+ onToggle(!isOpen);
2474
+ } else {
2475
+ setInternalIsOpen(!internalIsOpen);
2476
+ }
2477
+ };
2478
+ var logLines = buildLog ? buildLog.split('\n').filter(Boolean) : [];
2479
+ return /*#__PURE__*/React$1.createElement(PanelContainer, {
2480
+ $isOpen: isOpen,
2481
+ $height: height
2482
+ }, /*#__PURE__*/React$1.createElement(PanelHeader, null, /*#__PURE__*/React$1.createElement(Tabs, {
2483
+ value: activeTab,
2484
+ onChange: function onChange(e, v) {
2485
+ return setActiveTab(v);
2486
+ },
2487
+ sx: {
2488
+ minHeight: '35px',
2489
+ '& .MuiTab-root': {
2490
+ minHeight: '35px',
2491
+ fontSize: '11px',
2492
+ textTransform: 'none',
2493
+ color: '#9CA3AF',
2494
+ padding: '0 16px'
2495
+ },
2496
+ '& .Mui-selected': {
2497
+ color: '#EAEAF0'
2498
+ },
2499
+ '& .MuiTabs-indicator': {
2500
+ backgroundColor: '#7C3AED'
2501
+ }
2502
+ }
2503
+ }, /*#__PURE__*/React$1.createElement(Tab, {
2504
+ label: "Build Output".concat(logLines.length ? " (".concat(logLines.length, ")") : '')
2505
+ }), /*#__PURE__*/React$1.createElement(Tab, {
2506
+ label: "Problems".concat(buildErrors.length ? " (".concat(buildErrors.length, ")") : '')
2507
+ })), /*#__PURE__*/React$1.createElement(IconButton, {
2508
+ size: "small",
2509
+ onClick: handleToggle,
2510
+ sx: {
2511
+ color: '#6B7280',
2512
+ mr: 1
2513
+ }
2514
+ }, isOpen ? /*#__PURE__*/React$1.createElement(KeyboardArrowDownIcon, {
2515
+ fontSize: "small"
2516
+ }) : /*#__PURE__*/React$1.createElement(KeyboardArrowUpIcon, {
2517
+ fontSize: "small"
2518
+ }))), /*#__PURE__*/React$1.createElement(PanelContent, null, activeTab === 0 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, logLines.length > 0 ? logLines.map(function (line, index) {
2519
+ var level = 'info';
2520
+ if (line.toLowerCase().includes('error')) level = 'error';else if (line.toLowerCase().includes('warn')) level = 'warning';else if (line.toLowerCase().includes('success') || line.toLowerCase().includes('built')) level = 'success';
2521
+ return /*#__PURE__*/React$1.createElement(LogLine, {
2522
+ key: index,
2523
+ $level: level
2524
+ }, line);
2525
+ }) : /*#__PURE__*/React$1.createElement(LogLine, {
2526
+ $level: "info"
2527
+ }, "No build output yet. Click \"Build\" to compile the app.")), activeTab === 1 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, buildErrors.length > 0 ? buildErrors.map(function (error, index) {
2528
+ return /*#__PURE__*/React$1.createElement(LogLine, {
2529
+ key: index,
2530
+ $level: "error"
2531
+ }, error);
2532
+ }) : /*#__PURE__*/React$1.createElement(LogLine, {
2533
+ $level: "success"
2534
+ }, "No problems detected."))));
2535
+ };
2536
+
2537
+ var StudioContainer = styled('div')({
2538
+ height: '100%',
2539
+ display: 'flex',
2540
+ flexDirection: 'column',
2541
+ backgroundColor: '#1E1E1E',
2542
+ overflow: 'hidden'
2543
+ });
2544
+ var MainContent = styled('div')({
2545
+ flex: 1,
2546
+ display: 'flex',
2547
+ overflow: 'hidden'
2548
+ });
2549
+ var FileExplorerWrapper = styled('div')({
2550
+ width: '240px',
2551
+ minWidth: '240px',
2552
+ height: '100%'
2553
+ });
2554
+ var CenterArea = styled('div')({
2555
+ flex: 1,
2556
+ display: 'flex',
2557
+ flexDirection: 'column',
2558
+ overflow: 'hidden'
2559
+ });
2560
+ var AppStudio = function AppStudio(_ref) {
2561
+ var appDefinitionId = _ref.appDefinitionId,
2562
+ appDefinitionService = _ref.appDefinitionService,
2563
+ appFileService = _ref.appFileService,
2564
+ appVersionService = _ref.appVersionService,
2565
+ appBuildService = _ref.appBuildService,
2566
+ onBack = _ref.onBack,
2567
+ onRun = _ref.onRun;
2568
+ _ref.onNavigateToRuntime;
2569
+ var _useState = useState(null),
2570
+ _useState2 = _slicedToArray(_useState, 2),
2571
+ appDefinition = _useState2[0],
2572
+ setAppDefinition = _useState2[1];
2573
+ var _useState3 = useState([]),
2574
+ _useState4 = _slicedToArray(_useState3, 2),
2575
+ fileTree = _useState4[0],
2576
+ setFileTree = _useState4[1];
2577
+ var _useState5 = useState([]),
2578
+ _useState6 = _slicedToArray(_useState5, 2),
2579
+ openFiles = _useState6[0],
2580
+ setOpenFiles = _useState6[1];
2581
+ var _useState7 = useState(null),
2582
+ _useState8 = _slicedToArray(_useState7, 2),
2583
+ activeFilePath = _useState8[0],
2584
+ setActiveFilePath = _useState8[1];
2585
+ var _useState9 = useState(false),
2586
+ _useState0 = _slicedToArray(_useState9, 2),
2587
+ isSaving = _useState0[0],
2588
+ setIsSaving = _useState0[1];
2589
+ var _useState1 = useState(null),
2590
+ _useState10 = _slicedToArray(_useState1, 2),
2591
+ buildStatus = _useState10[0],
2592
+ setBuildStatus = _useState10[1];
2593
+ var _useState11 = useState(''),
2594
+ _useState12 = _slicedToArray(_useState11, 2),
2595
+ buildLog = _useState12[0],
2596
+ setBuildLog = _useState12[1];
2597
+ var _useState13 = useState([]),
2598
+ _useState14 = _slicedToArray(_useState13, 2),
2599
+ buildErrors = _useState14[0],
2600
+ setBuildErrors = _useState14[1];
2601
+ var _useState15 = useState(true),
2602
+ _useState16 = _slicedToArray(_useState15, 2),
2603
+ isPropertiesOpen = _useState16[0],
2604
+ setIsPropertiesOpen = _useState16[1];
2605
+ var _useState17 = useState(false),
2606
+ _useState18 = _slicedToArray(_useState17, 2),
2607
+ isBottomPanelOpen = _useState18[0],
2608
+ setIsBottomPanelOpen = _useState18[1];
2609
+ var isDirty = openFiles.some(function (f) {
2610
+ return f.isDirty;
2611
+ });
2612
+ var definitionDirtyRef = useRef(false);
2613
+ var loadStudioPayload = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2614
+ var response, _t;
2615
+ return _regenerator().w(function (_context) {
2616
+ while (1) switch (_context.p = _context.n) {
2617
+ case 0:
2618
+ if (!(!appDefinitionService || !appDefinitionId)) {
2619
+ _context.n = 1;
2620
+ break;
2621
+ }
2622
+ return _context.a(2);
2623
+ case 1:
2624
+ _context.p = 1;
2625
+ _context.n = 2;
2626
+ return appDefinitionService.getStudioPayload({
2627
+ id: appDefinitionId
2628
+ });
2629
+ case 2:
2630
+ response = _context.v;
2631
+ if (response !== null && response !== void 0 && response.result) {
2632
+ setAppDefinition(response.result.definition);
2633
+ setFileTree(response.result.file_tree || []);
2634
+ }
2635
+ _context.n = 4;
2636
+ break;
2637
+ case 3:
2638
+ _context.p = 3;
2639
+ _t = _context.v;
2640
+ console.error('Failed to load studio payload:', _t);
2641
+ case 4:
2642
+ return _context.a(2);
2643
+ }
2644
+ }, _callee, null, [[1, 3]]);
2645
+ })), [appDefinitionService, appDefinitionId]);
2646
+ useEffect(function () {
2647
+ loadStudioPayload();
2648
+ }, [loadStudioPayload]);
2649
+ var handleFileSelect = useCallback(/*#__PURE__*/function () {
2650
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(file) {
2651
+ var existing, content, response, _t2;
2652
+ return _regenerator().w(function (_context2) {
2653
+ while (1) switch (_context2.p = _context2.n) {
2654
+ case 0:
2655
+ if (!(file.kind === 'folder')) {
2656
+ _context2.n = 1;
2657
+ break;
2658
+ }
2659
+ return _context2.a(2);
2660
+ case 1:
2661
+ existing = openFiles.find(function (f) {
2662
+ return f.path === file.path;
2663
+ });
2664
+ if (!existing) {
2665
+ _context2.n = 2;
2666
+ break;
2667
+ }
2668
+ setActiveFilePath(file.path);
2669
+ return _context2.a(2);
2670
+ case 2:
2671
+ content = file.content;
2672
+ if (!(content === undefined || content === null)) {
2673
+ _context2.n = 6;
2674
+ break;
2675
+ }
2676
+ _context2.p = 3;
2677
+ _context2.n = 4;
2678
+ return appFileService.getFileContent({
2679
+ search: file.id
2680
+ });
2681
+ case 4:
2682
+ response = _context2.v;
2683
+ if (response !== null && response !== void 0 && response.result) {
2684
+ content = response.result.content || '';
2685
+ }
2686
+ _context2.n = 6;
2687
+ break;
2688
+ case 5:
2689
+ _context2.p = 5;
2690
+ _t2 = _context2.v;
2691
+ console.error('Failed to load file content:', _t2);
2692
+ content = '';
2693
+ case 6:
2694
+ setOpenFiles(function (prev) {
2695
+ return [].concat(_toConsumableArray(prev), [_objectSpread2(_objectSpread2({}, file), {}, {
2696
+ content: content,
2697
+ isDirty: false,
2698
+ originalContent: content
2699
+ })]);
2700
+ });
2701
+ setActiveFilePath(file.path);
2702
+ case 7:
2703
+ return _context2.a(2);
2704
+ }
2705
+ }, _callee2, null, [[3, 5]]);
2706
+ }));
2707
+ return function (_x) {
2708
+ return _ref3.apply(this, arguments);
2709
+ };
2710
+ }(), [openFiles, appFileService]);
2711
+ var handleContentChange = useCallback(function (filePath, newContent) {
2712
+ setOpenFiles(function (prev) {
2713
+ return prev.map(function (f) {
2714
+ if (f.path !== filePath) return f;
2715
+ return _objectSpread2(_objectSpread2({}, f), {}, {
2716
+ content: newContent,
2717
+ isDirty: newContent !== f.originalContent
2718
+ });
2719
+ });
2720
+ });
2721
+ }, []);
2722
+ var handleTabChange = useCallback(function (filePath) {
2723
+ setActiveFilePath(filePath);
2724
+ }, []);
2725
+ var handleTabClose = useCallback(function (filePath) {
2726
+ setOpenFiles(function (prev) {
2727
+ var next = prev.filter(function (f) {
2728
+ return f.path !== filePath;
2729
+ });
2730
+ if (filePath === activeFilePath) {
2731
+ var _next$Math$min;
2732
+ var closedIndex = prev.findIndex(function (f) {
2733
+ return f.path === filePath;
2734
+ });
2735
+ var newActive = ((_next$Math$min = next[Math.min(closedIndex, next.length - 1)]) === null || _next$Math$min === void 0 ? void 0 : _next$Math$min.path) || null;
2736
+ setActiveFilePath(newActive);
2737
+ }
2738
+ return next;
2739
+ });
2740
+ }, [activeFilePath]);
2741
+ var handleSave = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
2742
+ var dirtyFiles, changes, _t3;
2743
+ return _regenerator().w(function (_context3) {
2744
+ while (1) switch (_context3.p = _context3.n) {
2745
+ case 0:
2746
+ if (appFileService) {
2747
+ _context3.n = 1;
2748
+ break;
2749
+ }
2750
+ return _context3.a(2);
2751
+ case 1:
2752
+ setIsSaving(true);
2753
+ _context3.p = 2;
2754
+ dirtyFiles = openFiles.filter(function (f) {
2755
+ return f.isDirty;
2756
+ });
2757
+ changes = dirtyFiles.map(function (f) {
2758
+ return {
2759
+ operation: 'update',
2760
+ id: f.id,
2761
+ path: f.path,
2762
+ content: f.content
2763
+ };
2764
+ });
2765
+ if (!(changes.length > 0)) {
2766
+ _context3.n = 4;
2767
+ break;
2768
+ }
2769
+ _context3.n = 3;
2770
+ return appFileService.applyChanges({
2771
+ app_definition_id: appDefinitionId,
2772
+ changes: changes
2773
+ });
2774
+ case 3:
2775
+ setOpenFiles(function (prev) {
2776
+ return prev.map(function (f) {
2777
+ return f.isDirty ? _objectSpread2(_objectSpread2({}, f), {}, {
2778
+ isDirty: false,
2779
+ originalContent: f.content
2780
+ }) : f;
2781
+ });
2782
+ });
2783
+ case 4:
2784
+ if (!(definitionDirtyRef.current && appDefinitionService)) {
2785
+ _context3.n = 6;
2786
+ break;
2787
+ }
2788
+ _context3.n = 5;
2789
+ return appDefinitionService.update(appDefinition);
2790
+ case 5:
2791
+ definitionDirtyRef.current = false;
2792
+ case 6:
2793
+ _context3.n = 8;
2794
+ break;
2795
+ case 7:
2796
+ _context3.p = 7;
2797
+ _t3 = _context3.v;
2798
+ console.error('Failed to save:', _t3);
2799
+ case 8:
2800
+ _context3.p = 8;
2801
+ setIsSaving(false);
2802
+ return _context3.f(8);
2803
+ case 9:
2804
+ return _context3.a(2);
2805
+ }
2806
+ }, _callee3, null, [[2, 7, 8, 9]]);
2807
+ })), [openFiles, appFileService, appDefinitionId, appDefinitionService, appDefinition]);
2808
+ var handleBuild = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
2809
+ var response, _t4;
2810
+ return _regenerator().w(function (_context4) {
2811
+ while (1) switch (_context4.p = _context4.n) {
2812
+ case 0:
2813
+ if (appBuildService) {
2814
+ _context4.n = 1;
2815
+ break;
2816
+ }
2817
+ return _context4.a(2);
2818
+ case 1:
2819
+ setBuildStatus('building');
2820
+ setBuildLog('');
2821
+ setBuildErrors([]);
2822
+ setIsBottomPanelOpen(true);
2823
+ _context4.p = 2;
2824
+ _context4.n = 3;
2825
+ return appBuildService.build({
2826
+ app_definition_id: appDefinitionId,
2827
+ organization_id: appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.organization_id
2828
+ });
2829
+ case 3:
2830
+ response = _context4.v;
2831
+ if (response !== null && response !== void 0 && response.result) {
2832
+ setBuildStatus(response.result.build_status || 'success');
2833
+ setBuildLog(response.result.build_log || 'Build completed successfully');
2834
+ } else {
2835
+ setBuildStatus('failed');
2836
+ setBuildErrors([(response === null || response === void 0 ? void 0 : response.message) || 'Build failed']);
2837
+ }
2838
+ _context4.n = 5;
2839
+ break;
2840
+ case 4:
2841
+ _context4.p = 4;
2842
+ _t4 = _context4.v;
2843
+ setBuildStatus('failed');
2844
+ setBuildErrors([_t4.message || 'Build failed']);
2845
+ case 5:
2846
+ return _context4.a(2);
2847
+ }
2848
+ }, _callee4, null, [[2, 4]]);
2849
+ })), [appBuildService, appDefinitionId, appDefinition]);
2850
+ var handlePublish = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
2851
+ var response, _t5;
2852
+ return _regenerator().w(function (_context5) {
2853
+ while (1) switch (_context5.p = _context5.n) {
2854
+ case 0:
2855
+ if (appVersionService) {
2856
+ _context5.n = 1;
2857
+ break;
2858
+ }
2859
+ return _context5.a(2);
2860
+ case 1:
2861
+ _context5.p = 1;
2862
+ _context5.n = 2;
2863
+ return appVersionService.publish({
2864
+ app_definition_id: appDefinitionId
2865
+ });
2866
+ case 2:
2867
+ response = _context5.v;
2868
+ if (response !== null && response !== void 0 && response.result) {
2869
+ setBuildLog(function (prev) {
2870
+ return prev + '\nVersion published successfully: ' + (response.result.version || '');
2871
+ });
2872
+ }
2873
+ _context5.n = 4;
2874
+ break;
2875
+ case 3:
2876
+ _context5.p = 3;
2877
+ _t5 = _context5.v;
2878
+ console.error('Failed to publish:', _t5);
2879
+ case 4:
2880
+ return _context5.a(2);
2881
+ }
2882
+ }, _callee5, null, [[1, 3]]);
2883
+ })), [appVersionService, appDefinitionId]);
2884
+ var handleUpdateDefinition = useCallback(function (updated) {
2885
+ setAppDefinition(updated);
2886
+ definitionDirtyRef.current = true;
2887
+ }, []);
2888
+ return /*#__PURE__*/React$1.createElement(StudioContainer, null, /*#__PURE__*/React$1.createElement(StudioToolbar, {
2889
+ appName: appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.name,
2890
+ isSaving: isSaving,
2891
+ isDirty: isDirty || definitionDirtyRef.current,
2892
+ buildStatus: buildStatus,
2893
+ onBack: onBack,
2894
+ onSave: handleSave,
2895
+ onBuild: handleBuild,
2896
+ onPublish: handlePublish,
2897
+ onRun: onRun,
2898
+ onToggleProperties: function onToggleProperties() {
2899
+ return setIsPropertiesOpen(!isPropertiesOpen);
2900
+ },
2901
+ isPropertiesOpen: isPropertiesOpen
2902
+ }), /*#__PURE__*/React$1.createElement(MainContent, null, /*#__PURE__*/React$1.createElement(FileExplorerWrapper, null, /*#__PURE__*/React$1.createElement(FileExplorer, {
2903
+ fileTree: fileTree,
2904
+ activeFilePath: activeFilePath,
2905
+ onFileSelect: handleFileSelect
2906
+ })), /*#__PURE__*/React$1.createElement(CenterArea, null, /*#__PURE__*/React$1.createElement(Box, {
2907
+ sx: {
2908
+ flex: 1,
2909
+ overflow: 'hidden'
2910
+ }
2911
+ }, /*#__PURE__*/React$1.createElement(EditorArea, {
2912
+ openFiles: openFiles,
2913
+ activeFilePath: activeFilePath,
2914
+ onTabChange: handleTabChange,
2915
+ onTabClose: handleTabClose,
2916
+ onContentChange: handleContentChange
2917
+ })), /*#__PURE__*/React$1.createElement(BottomPanel, {
2918
+ buildLog: buildLog,
2919
+ buildErrors: buildErrors,
2920
+ isOpen: isBottomPanelOpen,
2921
+ onToggle: setIsBottomPanelOpen
2922
+ })), /*#__PURE__*/React$1.createElement(PropertiesPanel, {
2923
+ isOpen: isPropertiesOpen,
2924
+ onClose: function onClose() {
2925
+ return setIsPropertiesOpen(false);
2926
+ },
2927
+ appDefinition: appDefinition,
2928
+ onUpdateDefinition: handleUpdateDefinition
2929
+ })));
2930
+ };
2931
+
2932
+ var CardContainer = styled('div')(function (_ref) {
2933
+ _ref.theme;
2934
+ return {
2935
+ backgroundColor: '#2B2A33',
2936
+ border: '1px solid #6B728040',
2937
+ borderRadius: '12px',
2938
+ padding: '20px',
2939
+ cursor: 'pointer',
2940
+ transition: 'border-color 0.2s, box-shadow 0.2s',
2941
+ display: 'flex',
2942
+ flexDirection: 'column',
2943
+ gap: '12px',
2944
+ minHeight: '160px',
2945
+ '&:hover': {
2946
+ borderColor: '#7C3AED',
2947
+ boxShadow: '0 0 0 1px #7C3AED40'
2948
+ }
2949
+ };
2950
+ });
2951
+ var AppIcon = styled('div')(function (_ref2) {
2952
+ var $color = _ref2.$color;
2953
+ return {
2954
+ width: '40px',
2955
+ height: '40px',
2956
+ borderRadius: '10px',
2957
+ backgroundColor: $color || '#7C3AED20',
2958
+ display: 'flex',
2959
+ alignItems: 'center',
2960
+ justifyContent: 'center',
2961
+ fontSize: '20px'
2962
+ };
2963
+ });
2964
+ var AppCatalogCard = function AppCatalogCard(_ref3) {
2965
+ var _app$manifest;
2966
+ var app = _ref3.app,
2967
+ onOpen = _ref3.onOpen,
2968
+ onEdit = _ref3.onEdit,
2969
+ onDelete = _ref3.onDelete,
2970
+ onPin = _ref3.onPin,
2971
+ onFavorite = _ref3.onFavorite,
2972
+ preference = _ref3.preference;
2973
+ var _useState = useState(null),
2974
+ _useState2 = _slicedToArray(_useState, 2),
2975
+ anchorEl = _useState2[0],
2976
+ setAnchorEl = _useState2[1];
2977
+ var handleMenuOpen = function handleMenuOpen(event) {
2978
+ event.stopPropagation();
2979
+ setAnchorEl(event.currentTarget);
2980
+ };
2981
+ var handleMenuClose = function handleMenuClose() {
2982
+ setAnchorEl(null);
2983
+ };
2984
+ var handleOpen = function handleOpen() {
2985
+ if (onOpen) {
2986
+ onOpen(app);
2987
+ }
2988
+ };
2989
+ var handleEdit = function handleEdit() {
2990
+ handleMenuClose();
2991
+ if (onEdit) {
2992
+ onEdit(app);
2993
+ }
2994
+ };
2995
+ var handleDelete = function handleDelete() {
2996
+ handleMenuClose();
2997
+ if (onDelete) {
2998
+ onDelete(app);
2999
+ }
3000
+ };
3001
+ var isPinnable = (app === null || app === void 0 || (_app$manifest = app.manifest) === null || _app$manifest === void 0 ? void 0 : _app$manifest.pinnable) !== false;
3002
+ var handlePin = function handlePin(event) {
3003
+ event.stopPropagation();
3004
+ if (onPin && isPinnable) {
3005
+ onPin(app, !(preference !== null && preference !== void 0 && preference.is_pinned));
3006
+ }
3007
+ };
3008
+ var handleFavorite = function handleFavorite(event) {
3009
+ event.stopPropagation();
3010
+ if (onFavorite) {
3011
+ onFavorite(app, !(preference !== null && preference !== void 0 && preference.is_favorite));
3012
+ }
3013
+ };
3014
+ return /*#__PURE__*/React$1.createElement(CardContainer, {
3015
+ onClick: handleOpen
3016
+ }, /*#__PURE__*/React$1.createElement(Box, {
3017
+ sx: {
3018
+ display: 'flex',
3019
+ justifyContent: 'space-between',
3020
+ alignItems: 'flex-start'
3021
+ }
3022
+ }, /*#__PURE__*/React$1.createElement(AppIcon, {
3023
+ $color: app !== null && app !== void 0 && app.icon ? undefined : '#7C3AED20'
3024
+ }, (app === null || app === void 0 ? void 0 : app.icon) || '📱'), /*#__PURE__*/React$1.createElement(Box, {
3025
+ sx: {
3026
+ display: 'flex',
3027
+ gap: '4px'
3028
+ }
3029
+ }, onFavorite && /*#__PURE__*/React$1.createElement(IconButton, {
3030
+ size: "small",
3031
+ onClick: handleFavorite,
3032
+ sx: {
3033
+ color: preference !== null && preference !== void 0 && preference.is_favorite ? '#F59E0B' : '#6B7280'
3034
+ }
3035
+ }, /*#__PURE__*/React$1.createElement(StarIcon, {
3036
+ fontSize: "small"
3037
+ })), onPin && isPinnable && /*#__PURE__*/React$1.createElement(IconButton, {
3038
+ size: "small",
3039
+ onClick: handlePin,
3040
+ sx: {
3041
+ color: preference !== null && preference !== void 0 && preference.is_pinned ? '#7C3AED' : '#6B7280'
3042
+ }
3043
+ }, /*#__PURE__*/React$1.createElement(PushPinIcon, {
3044
+ fontSize: "small"
3045
+ })), /*#__PURE__*/React$1.createElement(IconButton, {
3046
+ size: "small",
3047
+ onClick: handleMenuOpen,
3048
+ sx: {
3049
+ color: '#6B7280'
3050
+ }
3051
+ }, /*#__PURE__*/React$1.createElement(MoreVertIcon, {
3052
+ fontSize: "small"
3053
+ })))), /*#__PURE__*/React$1.createElement(Box, {
3054
+ sx: {
3055
+ flex: 1
3056
+ }
3057
+ }, /*#__PURE__*/React$1.createElement(Typography, {
3058
+ sx: {
3059
+ color: '#EAEAF0',
3060
+ fontWeight: 600,
3061
+ fontSize: '14px',
3062
+ mb: '4px'
3063
+ }
3064
+ }, (app === null || app === void 0 ? void 0 : app.name) || 'Untitled App'), /*#__PURE__*/React$1.createElement(Typography, {
3065
+ sx: {
3066
+ color: '#9CA3AF',
3067
+ fontSize: '12px',
3068
+ lineHeight: 1.4,
3069
+ display: '-webkit-box',
3070
+ WebkitLineClamp: 2,
3071
+ WebkitBoxOrient: 'vertical',
3072
+ overflow: 'hidden'
3073
+ }
3074
+ }, (app === null || app === void 0 ? void 0 : app.description) || 'No description')), (app === null || app === void 0 ? void 0 : app.category) && /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Chip, {
3075
+ label: app.category,
3076
+ size: "small",
3077
+ sx: {
3078
+ backgroundColor: '#7C3AED20',
3079
+ color: '#A78BFA',
3080
+ fontSize: '11px',
3081
+ height: '22px'
3082
+ }
3083
+ })), /*#__PURE__*/React$1.createElement(Menu, {
3084
+ anchorEl: anchorEl,
3085
+ open: Boolean(anchorEl),
3086
+ onClose: handleMenuClose
3087
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
3088
+ onClick: handleOpen
3089
+ }, "Open"), /*#__PURE__*/React$1.createElement(MenuItem, {
3090
+ onClick: handleEdit
3091
+ }, "Edit in Studio"), /*#__PURE__*/React$1.createElement(MenuItem, {
3092
+ onClick: handleDelete,
3093
+ sx: {
3094
+ color: '#EF4444'
3095
+ }
3096
+ }, "Delete")));
3097
+ };
3098
+
3099
+ var GridContainer = styled('div')({
3100
+ display: 'grid',
3101
+ gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
3102
+ gap: '16px'
3103
+ });
3104
+ var EmptyState = styled('div')({
3105
+ display: 'flex',
3106
+ flexDirection: 'column',
3107
+ alignItems: 'center',
3108
+ justifyContent: 'center',
3109
+ padding: '64px 24px',
3110
+ color: '#9CA3AF',
3111
+ gap: '16px'
3112
+ });
3113
+ var AppCatalogGrid = function AppCatalogGrid(_ref) {
3114
+ var appDefinitionService = _ref.appDefinitionService,
3115
+ appPreferenceService = _ref.appPreferenceService,
3116
+ onOpenApp = _ref.onOpenApp,
3117
+ onEditApp = _ref.onEditApp,
3118
+ onCreateApp = _ref.onCreateApp,
3119
+ onDeleteApp = _ref.onDeleteApp,
3120
+ onPinApp = _ref.onPinApp,
3121
+ onFavoriteApp = _ref.onFavoriteApp,
3122
+ onPreferencesLoaded = _ref.onPreferencesLoaded,
3123
+ organizationId = _ref.organizationId;
3124
+ var _useState = useState([]),
3125
+ _useState2 = _slicedToArray(_useState, 2),
3126
+ apps = _useState2[0],
3127
+ setApps = _useState2[1];
3128
+ var _useState3 = useState({}),
3129
+ _useState4 = _slicedToArray(_useState3, 2),
3130
+ preferences = _useState4[0],
3131
+ setPreferences = _useState4[1];
3132
+ var _useState5 = useState(''),
3133
+ _useState6 = _slicedToArray(_useState5, 2),
3134
+ searchQuery = _useState6[0],
3135
+ setSearchQuery = _useState6[1];
3136
+ var _useState7 = useState('all'),
3137
+ _useState8 = _slicedToArray(_useState7, 2),
3138
+ kindFilter = _useState8[0],
3139
+ setKindFilter = _useState8[1];
3140
+ var _useState9 = useState(true),
3141
+ _useState0 = _slicedToArray(_useState9, 2),
3142
+ isLoading = _useState0[0],
3143
+ setIsLoading = _useState0[1];
3144
+ var loadApps = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
3145
+ var _response$result, queryParams, response, _t;
3146
+ return _regenerator().w(function (_context) {
3147
+ while (1) switch (_context.p = _context.n) {
3148
+ case 0:
3149
+ if (appDefinitionService) {
3150
+ _context.n = 1;
3151
+ break;
3152
+ }
3153
+ return _context.a(2);
3154
+ case 1:
3155
+ setIsLoading(true);
3156
+ _context.p = 2;
3157
+ queryParams = {
3158
+ queryselector: 'all',
3159
+ exclude_status: 'deleted'
3160
+ };
3161
+ if (organizationId) {
3162
+ queryParams.queryselector = 'organization-id';
3163
+ queryParams.search = organizationId;
3164
+ }
3165
+ _context.n = 3;
3166
+ return appDefinitionService.get(queryParams);
3167
+ case 3:
3168
+ response = _context.v;
3169
+ if (response !== null && response !== void 0 && (_response$result = response.result) !== null && _response$result !== void 0 && _response$result.items) {
3170
+ setApps(response.result.items);
3171
+ }
3172
+ _context.n = 5;
3173
+ break;
3174
+ case 4:
3175
+ _context.p = 4;
3176
+ _t = _context.v;
3177
+ console.error('Failed to load apps:', _t);
3178
+ case 5:
3179
+ _context.p = 5;
3180
+ setIsLoading(false);
3181
+ return _context.f(5);
3182
+ case 6:
3183
+ return _context.a(2);
3184
+ }
3185
+ }, _callee, null, [[2, 4, 5, 6]]);
3186
+ })), [appDefinitionService, organizationId]);
3187
+ var loadPreferences = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
3188
+ var _response$result2, response, prefsMap, _iterator, _step, pref, _t2;
3189
+ return _regenerator().w(function (_context2) {
3190
+ while (1) switch (_context2.p = _context2.n) {
3191
+ case 0:
3192
+ if (appPreferenceService) {
3193
+ _context2.n = 1;
3194
+ break;
3195
+ }
3196
+ return _context2.a(2);
3197
+ case 1:
3198
+ _context2.p = 1;
3199
+ _context2.n = 2;
3200
+ return appPreferenceService.get({
3201
+ queryselector: 'all',
3202
+ exclude_status: 'deleted'
3203
+ });
3204
+ case 2:
3205
+ response = _context2.v;
3206
+ if (response !== null && response !== void 0 && (_response$result2 = response.result) !== null && _response$result2 !== void 0 && _response$result2.items) {
3207
+ prefsMap = {};
3208
+ _iterator = _createForOfIteratorHelper(response.result.items);
3209
+ try {
3210
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3211
+ pref = _step.value;
3212
+ prefsMap[pref.app_definition_id] = pref;
3213
+ }
3214
+ } catch (err) {
3215
+ _iterator.e(err);
3216
+ } finally {
3217
+ _iterator.f();
3218
+ }
3219
+ setPreferences(prefsMap);
3220
+ if (onPreferencesLoaded) {
3221
+ onPreferencesLoaded(prefsMap);
3222
+ }
3223
+ }
3224
+ _context2.n = 4;
3225
+ break;
3226
+ case 3:
3227
+ _context2.p = 3;
3228
+ _t2 = _context2.v;
3229
+ console.error('Failed to load preferences:', _t2);
3230
+ case 4:
3231
+ return _context2.a(2);
3232
+ }
3233
+ }, _callee2, null, [[1, 3]]);
3234
+ })), [appPreferenceService, onPreferencesLoaded]);
3235
+ useEffect(function () {
3236
+ loadApps();
3237
+ loadPreferences();
3238
+ }, [loadApps, loadPreferences]);
3239
+ var filteredApps = apps.filter(function (app) {
3240
+ var _app$manifest, _app$manifest2, _app$name, _app$description, _app$category, _app$slug;
3241
+ var appKind = ((_app$manifest = app.manifest) === null || _app$manifest === void 0 ? void 0 : _app$manifest.kind) || 'workspace';
3242
+ var launcherVisibility = ((_app$manifest2 = app.manifest) === null || _app$manifest2 === void 0 ? void 0 : _app$manifest2.launcher_visibility) || 'visible';
3243
+ if (kindFilter === 'workspace' && appKind !== 'workspace') return false;
3244
+ if (kindFilter === 'utility' && appKind !== 'utility') return false;
3245
+ if (kindFilter === 'all' && launcherVisibility === 'system') return false;
3246
+ if (!searchQuery) return true;
3247
+ var query = searchQuery.toLowerCase();
3248
+ return ((_app$name = app.name) === null || _app$name === void 0 ? void 0 : _app$name.toLowerCase().includes(query)) || ((_app$description = app.description) === null || _app$description === void 0 ? void 0 : _app$description.toLowerCase().includes(query)) || ((_app$category = app.category) === null || _app$category === void 0 ? void 0 : _app$category.toLowerCase().includes(query)) || ((_app$slug = app.slug) === null || _app$slug === void 0 ? void 0 : _app$slug.toLowerCase().includes(query));
3249
+ });
3250
+ var handleCreateApp = /*#__PURE__*/function () {
3251
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
3252
+ return _regenerator().w(function (_context3) {
3253
+ while (1) switch (_context3.n) {
3254
+ case 0:
3255
+ if (!onCreateApp) {
3256
+ _context3.n = 2;
3257
+ break;
3258
+ }
3259
+ _context3.n = 1;
3260
+ return onCreateApp();
3261
+ case 1:
3262
+ loadApps();
3263
+ case 2:
3264
+ return _context3.a(2);
3265
+ }
3266
+ }, _callee3);
3267
+ }));
3268
+ return function handleCreateApp() {
3269
+ return _ref4.apply(this, arguments);
3270
+ };
3271
+ }();
3272
+ var handleDeleteApp = /*#__PURE__*/function () {
3273
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(app) {
3274
+ return _regenerator().w(function (_context4) {
3275
+ while (1) switch (_context4.n) {
3276
+ case 0:
3277
+ if (!onDeleteApp) {
3278
+ _context4.n = 2;
3279
+ break;
3280
+ }
3281
+ _context4.n = 1;
3282
+ return onDeleteApp(app);
3283
+ case 1:
3284
+ loadApps();
3285
+ case 2:
3286
+ return _context4.a(2);
3287
+ }
3288
+ }, _callee4);
3289
+ }));
3290
+ return function handleDeleteApp(_x) {
3291
+ return _ref5.apply(this, arguments);
3292
+ };
3293
+ }();
3294
+ var handlePinApp = /*#__PURE__*/function () {
3295
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(app, isPinned) {
3296
+ return _regenerator().w(function (_context5) {
3297
+ while (1) switch (_context5.n) {
3298
+ case 0:
3299
+ if (!onPinApp) {
3300
+ _context5.n = 2;
3301
+ break;
3302
+ }
3303
+ _context5.n = 1;
3304
+ return onPinApp(app, isPinned);
3305
+ case 1:
3306
+ loadPreferences();
3307
+ case 2:
3308
+ return _context5.a(2);
3309
+ }
3310
+ }, _callee5);
3311
+ }));
3312
+ return function handlePinApp(_x2, _x3) {
3313
+ return _ref6.apply(this, arguments);
3314
+ };
3315
+ }();
3316
+ var handleFavoriteApp = /*#__PURE__*/function () {
3317
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(app, isFavorite) {
3318
+ return _regenerator().w(function (_context6) {
3319
+ while (1) switch (_context6.n) {
3320
+ case 0:
3321
+ if (!onFavoriteApp) {
3322
+ _context6.n = 2;
3323
+ break;
3324
+ }
3325
+ _context6.n = 1;
3326
+ return onFavoriteApp(app, isFavorite);
3327
+ case 1:
3328
+ loadPreferences();
3329
+ case 2:
3330
+ return _context6.a(2);
3331
+ }
3332
+ }, _callee6);
3333
+ }));
3334
+ return function handleFavoriteApp(_x4, _x5) {
3335
+ return _ref7.apply(this, arguments);
3336
+ };
3337
+ }();
3338
+ return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Tabs, {
3339
+ value: kindFilter,
3340
+ onChange: function onChange(e, value) {
3341
+ return setKindFilter(value);
3342
+ },
3343
+ sx: {
3344
+ mb: 2,
3345
+ minHeight: '36px',
3346
+ '& .MuiTab-root': {
3347
+ minHeight: '36px',
3348
+ textTransform: 'none',
3349
+ color: '#9CA3AF',
3350
+ fontSize: '13px',
3351
+ '&.Mui-selected': {
3352
+ color: '#A78BFA'
3353
+ }
3354
+ },
3355
+ '& .MuiTabs-indicator': {
3356
+ backgroundColor: '#7C3AED'
3357
+ }
3358
+ }
3359
+ }, /*#__PURE__*/React$1.createElement(Tab, {
3360
+ label: "All Apps",
3361
+ value: "all"
3362
+ }), /*#__PURE__*/React$1.createElement(Tab, {
3363
+ label: "Workspaces",
3364
+ value: "workspace"
3365
+ }), /*#__PURE__*/React$1.createElement(Tab, {
3366
+ label: "Utilities",
3367
+ value: "utility"
3368
+ })), /*#__PURE__*/React$1.createElement(Box, {
3369
+ sx: {
3370
+ display: 'flex',
3371
+ justifyContent: 'space-between',
3372
+ alignItems: 'center',
3373
+ mb: 3
3374
+ }
3375
+ }, /*#__PURE__*/React$1.createElement(TextField, {
3376
+ placeholder: "Search apps...",
3377
+ size: "small",
3378
+ value: searchQuery,
3379
+ onChange: function onChange(e) {
3380
+ return setSearchQuery(e.target.value);
3381
+ },
3382
+ InputProps: {
3383
+ startAdornment: /*#__PURE__*/React$1.createElement(InputAdornment, {
3384
+ position: "start"
3385
+ }, /*#__PURE__*/React$1.createElement(SearchIcon, {
3386
+ sx: {
3387
+ color: '#6B7280'
3388
+ }
3389
+ }))
3390
+ },
3391
+ sx: {
3392
+ width: '320px',
3393
+ '& .MuiOutlinedInput-root': {
3394
+ backgroundColor: '#1F1E26',
3395
+ color: '#EAEAF0',
3396
+ borderRadius: '8px',
3397
+ '& fieldset': {
3398
+ borderColor: '#6B728040'
3399
+ },
3400
+ '&:hover fieldset': {
3401
+ borderColor: '#7C3AED'
3402
+ },
3403
+ '&.Mui-focused fieldset': {
3404
+ borderColor: '#7C3AED'
3405
+ }
3406
+ }
3407
+ }
3408
+ }), onCreateApp && /*#__PURE__*/React$1.createElement(Button, {
3409
+ variant: "contained",
3410
+ startIcon: /*#__PURE__*/React$1.createElement(AddIcon, null),
3411
+ onClick: handleCreateApp,
3412
+ sx: {
3413
+ backgroundColor: '#7C3AED',
3414
+ '&:hover': {
3415
+ backgroundColor: '#6D28D9'
3416
+ },
3417
+ textTransform: 'none',
3418
+ borderRadius: '8px'
3419
+ }
3420
+ }, "New App")), isLoading ? /*#__PURE__*/React$1.createElement(Box, {
3421
+ sx: {
3422
+ display: 'flex',
3423
+ justifyContent: 'center',
3424
+ py: 8
3425
+ }
3426
+ }, /*#__PURE__*/React$1.createElement(CircularProgress, {
3427
+ sx: {
3428
+ color: '#7C3AED'
3429
+ }
3430
+ })) : filteredApps.length === 0 ? /*#__PURE__*/React$1.createElement(EmptyState, null, /*#__PURE__*/React$1.createElement(Typography, {
3431
+ sx: {
3432
+ fontSize: '16px',
3433
+ fontWeight: 500
3434
+ }
3435
+ }, searchQuery ? 'No apps match your search' : 'No apps yet'), /*#__PURE__*/React$1.createElement(Typography, {
3436
+ sx: {
3437
+ fontSize: '13px'
3438
+ }
3439
+ }, searchQuery ? 'Try a different search term' : 'Create your first app to get started'), !searchQuery && onCreateApp && /*#__PURE__*/React$1.createElement(Button, {
3440
+ variant: "outlined",
3441
+ startIcon: /*#__PURE__*/React$1.createElement(AddIcon, null),
3442
+ onClick: handleCreateApp,
3443
+ sx: {
3444
+ borderColor: '#7C3AED',
3445
+ color: '#7C3AED',
3446
+ '&:hover': {
3447
+ borderColor: '#6D28D9',
3448
+ backgroundColor: '#7C3AED10'
3449
+ },
3450
+ textTransform: 'none',
3451
+ mt: 1
3452
+ }
3453
+ }, "Create App")) : /*#__PURE__*/React$1.createElement(GridContainer, null, filteredApps.map(function (app) {
3454
+ return /*#__PURE__*/React$1.createElement(AppCatalogCard, {
3455
+ key: app.id,
3456
+ app: app,
3457
+ preference: preferences[app.id],
3458
+ onOpen: onOpenApp,
3459
+ onEdit: onEditApp,
3460
+ onDelete: handleDeleteApp,
3461
+ onPin: onPinApp ? handlePinApp : undefined,
3462
+ onFavorite: onFavoriteApp ? handleFavoriteApp : undefined
3463
+ });
3464
+ })));
3465
+ };
3466
+
3467
+ var BaseApi = /*#__PURE__*/function () {
3468
+ function BaseApi() {
3469
+ _classCallCheck(this, BaseApi);
3470
+ this.api_key = null;
3471
+ this.client = null;
3472
+ this.serviceEndpoints = {
3473
+ baseUrlProduction: process.env.VERIPASS_PRODUCTION_SERVICE_URL,
3474
+ baseUrlDevelopment: process.env.VERIPASS_DEVELOPMENT_SERVICE_URL,
3475
+ baseUrlLocal: process.env.VERIPASS_LOCAL_SERVICE_URL,
3476
+ get: '',
3477
+ create: '',
3478
+ update: '',
3479
+ "delete": '',
3480
+ patch: '',
3481
+ put: ''
3482
+ };
3483
+ this.settings = {};
3484
+ }
3485
+
3486
+ /**
3487
+ * Initializes and returns an Axios client instance with the necessary headers and configurations.
3488
+ *
3489
+ * @returns {Object} Axios client instance.
3490
+ */
3491
+ return _createClass(BaseApi, [{
3492
+ key: "request",
3493
+ value: function request() {
3494
+ var headers = {
3495
+ Accept: 'application/json'
3496
+ };
3497
+ if (this.api_key) {
3498
+ headers['api-key'] = this.api_key;
3499
+ }
3500
+ this.client = axios.create({
3501
+ baseURL: this.api_url,
3502
+ timeout: 31000,
3503
+ headers: headers
3504
+ });
3505
+ return this.client;
3506
+ }
3507
+ }, {
3508
+ key: "urlBuilder",
3509
+ value: function urlBuilder(_ref) {
3510
+ var _this$settings;
3511
+ var endpoint = _ref.endpoint;
3512
+ var environment = ((_this$settings = this.settings) === null || _this$settings === void 0 ? void 0 : _this$settings.environment) || 'production';
3513
+ var baseUrl = '';
3514
+ switch (environment) {
3515
+ case 'local':
3516
+ baseUrl = this.serviceEndpoints.baseUrlLocal;
3517
+ break;
3518
+ case 'development':
3519
+ baseUrl = this.serviceEndpoints.baseUrlDevelopment;
3520
+ break;
3521
+ case 'production':
3522
+ default:
3523
+ baseUrl = this.serviceEndpoints.baseUrlProduction;
3524
+ break;
3525
+ }
3526
+ return "".concat(baseUrl).concat(endpoint);
3527
+ }
3528
+
3529
+ /**
3530
+ * Serializes a nested object into a query string format.
3531
+ *
3532
+ * @param {Object} obj The object to be serialized.
3533
+ * @param {string} [prefix] Prefix for nested properties in the object.
3534
+ * @returns {string} Serialized query string.
3535
+ */
3536
+ }, {
3537
+ key: "serializerOjectToQueryString",
3538
+ value: function serializerOjectToQueryString(obj, prefix) {
3539
+ if (obj && _typeof(obj) === 'object') {
3540
+ var serializedArr = [];
3541
+ var key = {};
3542
+ for (key in obj) {
3543
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
3544
+ var k = prefix ? prefix + '[' + key + ']' : key;
3545
+ var value = obj[key] || null;
3546
+ serializedArr.push(value !== null && _typeof(value) === 'object' ? this.serializerOjectToQueryString(value, k) : encodeURIComponent(k) + '=' + encodeURIComponent(value));
3547
+ }
3548
+ }
3549
+ return serializedArr.join('&');
3550
+ }
3551
+ }
3552
+
3553
+ /**
3554
+ * Converts an object into a query string format.
3555
+ *
3556
+ * @param {Object} obj The object to be converted.
3557
+ * @returns {string} Query string starting with '?' or an empty string if the object is not valid.
3558
+ */
3559
+ }, {
3560
+ key: "objectToQueryString",
3561
+ value: function objectToQueryString(obj) {
3562
+ if (obj && _typeof(obj) === 'object') {
3563
+ var result = this.serializerOjectToQueryString(obj);
3564
+ return "?".concat(result);
3565
+ } else {
3566
+ return '';
3567
+ }
3568
+ }
3569
+
3570
+ /**
3571
+ * Execute a query to filter by parameters
3572
+ * @param {Object} payload Provides all information to get an entity by parameters
3573
+ * @param {string} payload.queryselector Is the selector of filter
3574
+ * @param {*} settings Configuration settings for the request
3575
+ * @returns an object to be processed
3576
+ */
3577
+ }, {
3578
+ key: "getByParameters",
3579
+ value: (function () {
3580
+ var _getByParameters = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload, settings) {
3581
+ var parameters, endpoint, url, result, _t;
3582
+ return _regenerator().w(function (_context) {
3583
+ while (1) switch (_context.p = _context.n) {
3584
+ case 0:
3585
+ _context.p = 0;
3586
+ if (payload) {
3587
+ _context.n = 1;
3588
+ break;
3589
+ }
3590
+ return _context.a(2, null);
3591
+ case 1:
3592
+ if (payload.queryselector) {
3593
+ _context.n = 2;
3594
+ break;
3595
+ }
3596
+ console.error('Provide a query selector to query');
3597
+ return _context.a(2, null);
3598
+ case 2:
3599
+ parameters = this.objectToQueryString(payload);
3600
+ endpoint = this.urlBuilder({
3601
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.get
3602
+ });
3603
+ url = "".concat(endpoint).concat(payload.queryselector).concat(parameters);
3604
+ _context.n = 3;
3605
+ return this.request().get(url);
3606
+ case 3:
3607
+ result = _context.v;
3608
+ return _context.a(2, result.data);
3609
+ case 4:
3610
+ _context.p = 4;
3611
+ _t = _context.v;
3612
+ console.error(_t);
3613
+ return _context.a(2, _t === null || _t === void 0 ? void 0 : _t.body);
3614
+ }
3615
+ }, _callee, this, [[0, 4]]);
3616
+ }));
3617
+ function getByParameters(_x, _x2) {
3618
+ return _getByParameters.apply(this, arguments);
3619
+ }
3620
+ return getByParameters;
3621
+ }()
3622
+ /**
3623
+ * Execute a create query into backend service
3624
+ * @param {*} payload
3625
+ * @param {*} settings Configuration settings for the request
3626
+ * @returns
3627
+ */
3628
+ )
3629
+ }, {
3630
+ key: "create",
3631
+ value: (function () {
3632
+ var _create = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload, settings) {
3633
+ var endpoint, result, _error$response, _t2;
3634
+ return _regenerator().w(function (_context2) {
3635
+ while (1) switch (_context2.p = _context2.n) {
3636
+ case 0:
3637
+ _context2.p = 0;
3638
+ if (payload) {
3639
+ _context2.n = 1;
3640
+ break;
3641
+ }
3642
+ return _context2.a(2, null);
3643
+ case 1:
3644
+ endpoint = this.urlBuilder({
3645
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.create
3646
+ });
3647
+ _context2.n = 2;
3648
+ return this.request().post(endpoint, payload);
3649
+ case 2:
3650
+ result = _context2.v;
3651
+ return _context2.a(2, result.data);
3652
+ case 3:
3653
+ _context2.p = 3;
3654
+ _t2 = _context2.v;
3655
+ console.error(_t2);
3656
+ return _context2.a(2, (_t2 === null || _t2 === void 0 || (_error$response = _t2.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || null);
3657
+ }
3658
+ }, _callee2, this, [[0, 3]]);
3659
+ }));
3660
+ function create(_x3, _x4) {
3661
+ return _create.apply(this, arguments);
3662
+ }
3663
+ return create;
3664
+ }()
3665
+ /**
3666
+ * Execute an update query into backend service
3667
+ * @param {*} payload
3668
+ * @param {*} settings Configuration settings for the request
3669
+ * @returns
3670
+ */
3671
+ )
3672
+ }, {
3673
+ key: "update",
3674
+ value: (function () {
3675
+ var _update = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload, settings) {
3676
+ var endpoint, result, _t3;
3677
+ return _regenerator().w(function (_context3) {
3678
+ while (1) switch (_context3.p = _context3.n) {
3679
+ case 0:
3680
+ _context3.p = 0;
3681
+ if (payload) {
3682
+ _context3.n = 1;
3683
+ break;
3684
+ }
3685
+ return _context3.a(2, null);
3686
+ case 1:
3687
+ endpoint = this.urlBuilder({
3688
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.update
3689
+ });
3690
+ _context3.n = 2;
3691
+ return this.request().patch(endpoint, payload);
3692
+ case 2:
3693
+ result = _context3.v;
3694
+ return _context3.a(2, result.data);
3695
+ case 3:
3696
+ _context3.p = 3;
3697
+ _t3 = _context3.v;
3698
+ console.error(_t3);
3699
+ return _context3.a(2, _t3 === null || _t3 === void 0 ? void 0 : _t3.body);
3700
+ }
3701
+ }, _callee3, this, [[0, 3]]);
3702
+ }));
3703
+ function update(_x5, _x6) {
3704
+ return _update.apply(this, arguments);
3705
+ }
3706
+ return update;
3707
+ }()
3708
+ /**
3709
+ * Execute a delete query into backend service
3710
+ * @param {*} payload
3711
+ * @param {*} settings Configuration settings for the request
3712
+ * @returns
3713
+ */
3714
+ )
3715
+ }, {
3716
+ key: "delete",
3717
+ value: (function () {
3718
+ var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload, settings) {
3719
+ var endpoint, result, _t4;
3720
+ return _regenerator().w(function (_context4) {
3721
+ while (1) switch (_context4.p = _context4.n) {
3722
+ case 0:
3723
+ _context4.p = 0;
3724
+ if (payload) {
3725
+ _context4.n = 1;
3726
+ break;
3727
+ }
3728
+ return _context4.a(2, null);
3729
+ case 1:
3730
+ endpoint = this.urlBuilder({
3731
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints["delete"]
3732
+ });
3733
+ _context4.n = 2;
3734
+ return this.request()["delete"](endpoint, {
3735
+ data: payload
3736
+ });
3737
+ case 2:
3738
+ result = _context4.v;
3739
+ return _context4.a(2, result.data);
3740
+ case 3:
3741
+ _context4.p = 3;
3742
+ _t4 = _context4.v;
3743
+ console.error(_t4);
3744
+ return _context4.a(2, _t4 === null || _t4 === void 0 ? void 0 : _t4.body);
3745
+ }
3746
+ }, _callee4, this, [[0, 3]]);
3747
+ }));
3748
+ function _delete(_x7, _x8) {
3749
+ return _delete2.apply(this, arguments);
3750
+ }
3751
+ return _delete;
3752
+ }()
3753
+ /**
3754
+ * Execute a post query
3755
+ * @param {*} payload Define what data need to be posted
3756
+ * @param {*} settings Configuration settings for the request
3757
+ * @returns
3758
+ */
3759
+ )
3760
+ }, {
3761
+ key: "post",
3762
+ value: (function () {
3763
+ var _post = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(payload, settings) {
3764
+ var endpoint, result, _error$response2, _t5;
3765
+ return _regenerator().w(function (_context5) {
3766
+ while (1) switch (_context5.p = _context5.n) {
3767
+ case 0:
3768
+ _context5.p = 0;
3769
+ if (payload) {
3770
+ _context5.n = 1;
3771
+ break;
3772
+ }
3773
+ return _context5.a(2, null);
3774
+ case 1:
3775
+ endpoint = this.urlBuilder({
3776
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.post
3777
+ });
3778
+ _context5.n = 2;
3779
+ return this.request().post(endpoint, payload);
3780
+ case 2:
3781
+ result = _context5.v;
3782
+ return _context5.a(2, result.data);
3783
+ case 3:
3784
+ _context5.p = 3;
3785
+ _t5 = _context5.v;
3786
+ console.error(_t5);
3787
+ return _context5.a(2, _t5 === null || _t5 === void 0 || (_error$response2 = _t5.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3788
+ }
3789
+ }, _callee5, this, [[0, 3]]);
3790
+ }));
3791
+ function post(_x9, _x0) {
3792
+ return _post.apply(this, arguments);
3793
+ }
3794
+ return post;
3795
+ }()
3796
+ /**
3797
+ * Execute a put query
3798
+ * @param {*} payload Define what data need to be posted
3799
+ * @param {*} settings Configuration settings for the request
3800
+ * @returns
3801
+ */
3802
+ )
3803
+ }, {
3804
+ key: "put",
3805
+ value: (function () {
3806
+ var _put = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(payload, settings) {
3807
+ var endpoint, result, _error$response3, _t6;
3808
+ return _regenerator().w(function (_context6) {
3809
+ while (1) switch (_context6.p = _context6.n) {
3810
+ case 0:
3811
+ _context6.p = 0;
3812
+ if (payload) {
3813
+ _context6.n = 1;
3814
+ break;
3815
+ }
3816
+ return _context6.a(2, null);
3817
+ case 1:
3818
+ endpoint = this.urlBuilder({
3819
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.put
3820
+ });
3821
+ _context6.n = 2;
3822
+ return this.request().put(endpoint, payload);
3823
+ case 2:
3824
+ result = _context6.v;
3825
+ return _context6.a(2, result.data);
3826
+ case 3:
3827
+ _context6.p = 3;
3828
+ _t6 = _context6.v;
3829
+ console.error(_t6);
3830
+ return _context6.a(2, _t6 === null || _t6 === void 0 || (_error$response3 = _t6.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data);
3831
+ }
3832
+ }, _callee6, this, [[0, 3]]);
3833
+ }));
3834
+ function put(_x1, _x10) {
3835
+ return _put.apply(this, arguments);
3836
+ }
3837
+ return put;
3838
+ }()
3839
+ /**
3840
+ * Execute a patch query
3841
+ * @param {*} payload Define what data need to be posted
3842
+ * @param {*} settings Configuration settings for the request
3843
+ * @returns
3844
+ */
3845
+ )
3846
+ }, {
3847
+ key: "patch",
3848
+ value: (function () {
3849
+ var _patch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(payload, settings) {
3850
+ var endpoint, result, _error$response4, _t7;
3851
+ return _regenerator().w(function (_context7) {
3852
+ while (1) switch (_context7.p = _context7.n) {
3853
+ case 0:
3854
+ _context7.p = 0;
3855
+ if (payload) {
3856
+ _context7.n = 1;
3857
+ break;
3858
+ }
3859
+ return _context7.a(2, null);
3860
+ case 1:
3861
+ endpoint = this.urlBuilder({
3862
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.patch
3863
+ });
3864
+ _context7.n = 2;
3865
+ return this.request().patch(endpoint, payload);
3866
+ case 2:
3867
+ result = _context7.v;
3868
+ return _context7.a(2, result.data);
3869
+ case 3:
3870
+ _context7.p = 3;
3871
+ _t7 = _context7.v;
3872
+ console.error(_t7);
3873
+ return _context7.a(2, _t7 === null || _t7 === void 0 || (_error$response4 = _t7.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data);
3874
+ }
3875
+ }, _callee7, this, [[0, 3]]);
3876
+ }));
3877
+ function patch(_x11, _x12) {
3878
+ return _patch.apply(this, arguments);
3879
+ }
3880
+ return patch;
3881
+ }()
3882
+ /**
3883
+ * Execute a query get query
3884
+ * @param {*} payload
3885
+ * @param {*} endpoint
3886
+ * @returns
3887
+ */
3888
+ )
3889
+ }, {
3890
+ key: "get",
3891
+ value: (function () {
3892
+ var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(payload, settings) {
3893
+ var parameters, endpoint, result, _t8;
3894
+ return _regenerator().w(function (_context8) {
3895
+ while (1) switch (_context8.p = _context8.n) {
3896
+ case 0:
3897
+ _context8.p = 0;
3898
+ if (payload) {
3899
+ _context8.n = 1;
3900
+ break;
3901
+ }
3902
+ return _context8.a(2, null);
3903
+ case 1:
3904
+ parameters = this.objectToQueryString(payload);
3905
+ endpoint = this.urlBuilder({
3906
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.post
3907
+ });
3908
+ _context8.n = 2;
3909
+ return this.request().get("".concat(endpoint).concat(parameters));
3910
+ case 2:
3911
+ result = _context8.v;
3912
+ return _context8.a(2, result.data);
3913
+ case 3:
3914
+ _context8.p = 3;
3915
+ _t8 = _context8.v;
3916
+ console.error(_t8);
3917
+ return _context8.a(2, _t8 === null || _t8 === void 0 ? void 0 : _t8.body);
3918
+ }
3919
+ }, _callee8, this, [[0, 3]]);
3920
+ }));
3921
+ function get(_x13, _x14) {
3922
+ return _get.apply(this, arguments);
3923
+ }
3924
+ return get;
3925
+ }())
3926
+ }]);
3927
+ }();
3928
+
3929
+ var AppEngineAppDefinitionService = /*#__PURE__*/function (_BaseApi) {
3930
+ function AppEngineAppDefinitionService(args) {
3931
+ var _this;
3932
+ _classCallCheck(this, AppEngineAppDefinitionService);
3933
+ _this = _callSuper(this, AppEngineAppDefinitionService, [args]);
3934
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
3935
+ _this.service_uri = {
3936
+ get: '/app-engine/definition',
3937
+ create: '/app-engine/definition',
3938
+ update: '/app-engine/definition',
3939
+ "delete": '/app-engine/definition',
3940
+ createWithScaffold: '/app-engine/definition/scaffold',
3941
+ studioPayload: '/app-engine/definition/studio',
3942
+ catalog: '/app-engine/definition/catalog',
3943
+ fullApp: '/app-engine/definition/full',
3944
+ provision: '/app-engine/definition/provision'
3945
+ };
3946
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
3947
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || import.meta.env.VITE_LOOM_CLOUD_BACKEND_URL || '';
3948
+ if (baseUrl) {
3949
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
3950
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
3951
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
3952
+ }
3953
+ return _this;
3954
+ }
3955
+ _inherits(AppEngineAppDefinitionService, _BaseApi);
3956
+ return _createClass(AppEngineAppDefinitionService, [{
3957
+ key: "createWithScaffold",
3958
+ value: function () {
3959
+ var _createWithScaffold = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
3960
+ return _regenerator().w(function (_context) {
3961
+ while (1) switch (_context.n) {
3962
+ case 0:
3963
+ return _context.a(2, _superPropGet(AppEngineAppDefinitionService, "post", this, 3)([payload, {
3964
+ endpoint: this.service_uri.createWithScaffold
3965
+ }]));
3966
+ }
3967
+ }, _callee, this);
3968
+ }));
3969
+ function createWithScaffold(_x) {
3970
+ return _createWithScaffold.apply(this, arguments);
3971
+ }
3972
+ return createWithScaffold;
3973
+ }()
3974
+ }, {
3975
+ key: "getStudioPayload",
3976
+ value: function () {
3977
+ var _getStudioPayload = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
3978
+ return _regenerator().w(function (_context2) {
3979
+ while (1) switch (_context2.n) {
3980
+ case 0:
3981
+ return _context2.a(2, _superPropGet(AppEngineAppDefinitionService, "get", this, 3)([payload, {
3982
+ endpoint: this.service_uri.studioPayload
3983
+ }]));
3984
+ }
3985
+ }, _callee2, this);
3986
+ }));
3987
+ function getStudioPayload(_x2) {
3988
+ return _getStudioPayload.apply(this, arguments);
3989
+ }
3990
+ return getStudioPayload;
3991
+ }()
3992
+ }, {
3993
+ key: "getCatalog",
3994
+ value: function () {
3995
+ var _getCatalog = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
3996
+ return _regenerator().w(function (_context3) {
3997
+ while (1) switch (_context3.n) {
3998
+ case 0:
3999
+ return _context3.a(2, _superPropGet(AppEngineAppDefinitionService, "get", this, 3)([payload, {
4000
+ endpoint: this.service_uri.catalog
4001
+ }]));
4002
+ }
4003
+ }, _callee3, this);
4004
+ }));
4005
+ function getCatalog(_x3) {
4006
+ return _getCatalog.apply(this, arguments);
4007
+ }
4008
+ return getCatalog;
4009
+ }()
4010
+ }, {
4011
+ key: "getFullApp",
4012
+ value: function () {
4013
+ var _getFullApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload) {
4014
+ return _regenerator().w(function (_context4) {
4015
+ while (1) switch (_context4.n) {
4016
+ case 0:
4017
+ return _context4.a(2, _superPropGet(AppEngineAppDefinitionService, "get", this, 3)([payload, {
4018
+ endpoint: this.service_uri.fullApp
4019
+ }]));
4020
+ }
4021
+ }, _callee4, this);
4022
+ }));
4023
+ function getFullApp(_x4) {
4024
+ return _getFullApp.apply(this, arguments);
4025
+ }
4026
+ return getFullApp;
4027
+ }()
4028
+ }, {
4029
+ key: "provision",
4030
+ value: function () {
4031
+ var _provision = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(payload) {
4032
+ return _regenerator().w(function (_context5) {
4033
+ while (1) switch (_context5.n) {
4034
+ case 0:
4035
+ return _context5.a(2, _superPropGet(AppEngineAppDefinitionService, "post", this, 3)([payload, {
4036
+ endpoint: this.service_uri.provision
4037
+ }]));
4038
+ }
4039
+ }, _callee5, this);
4040
+ }));
4041
+ function provision(_x5) {
4042
+ return _provision.apply(this, arguments);
4043
+ }
4044
+ return provision;
4045
+ }()
4046
+ }]);
4047
+ }(BaseApi);
4048
+
4049
+ var AppEngineAppVersionService = /*#__PURE__*/function (_BaseApi) {
4050
+ function AppEngineAppVersionService(args) {
4051
+ var _this;
4052
+ _classCallCheck(this, AppEngineAppVersionService);
4053
+ _this = _callSuper(this, AppEngineAppVersionService, [args]);
4054
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4055
+ _this.service_uri = {
4056
+ get: '/app-engine/version',
4057
+ create: '/app-engine/version',
4058
+ update: '/app-engine/version',
4059
+ "delete": '/app-engine/version',
4060
+ publish: '/app-engine/version/publish',
4061
+ activate: '/app-engine/version/activate'
4062
+ };
4063
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4064
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || import.meta.env.VITE_LOOM_CLOUD_BACKEND_URL || '';
4065
+ if (baseUrl) {
4066
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4067
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4068
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4069
+ }
4070
+ return _this;
4071
+ }
4072
+ _inherits(AppEngineAppVersionService, _BaseApi);
4073
+ return _createClass(AppEngineAppVersionService, [{
4074
+ key: "publish",
4075
+ value: function () {
4076
+ var _publish = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4077
+ return _regenerator().w(function (_context) {
4078
+ while (1) switch (_context.n) {
4079
+ case 0:
4080
+ return _context.a(2, _superPropGet(AppEngineAppVersionService, "post", this, 3)([payload, {
4081
+ endpoint: this.service_uri.publish
4082
+ }]));
4083
+ }
4084
+ }, _callee, this);
4085
+ }));
4086
+ function publish(_x) {
4087
+ return _publish.apply(this, arguments);
4088
+ }
4089
+ return publish;
4090
+ }()
4091
+ }, {
4092
+ key: "activate",
4093
+ value: function () {
4094
+ var _activate = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4095
+ return _regenerator().w(function (_context2) {
4096
+ while (1) switch (_context2.n) {
4097
+ case 0:
4098
+ return _context2.a(2, _superPropGet(AppEngineAppVersionService, "patch", this, 3)([payload, {
4099
+ endpoint: this.service_uri.activate
4100
+ }]));
4101
+ }
4102
+ }, _callee2, this);
4103
+ }));
4104
+ function activate(_x2) {
4105
+ return _activate.apply(this, arguments);
4106
+ }
4107
+ return activate;
4108
+ }()
4109
+ }]);
4110
+ }(BaseApi);
4111
+
4112
+ var AppEngineAppFileService = /*#__PURE__*/function (_BaseApi) {
4113
+ function AppEngineAppFileService(args) {
4114
+ var _this;
4115
+ _classCallCheck(this, AppEngineAppFileService);
4116
+ _this = _callSuper(this, AppEngineAppFileService, [args]);
4117
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4118
+ _this.service_uri = {
4119
+ get: '/app-engine/file',
4120
+ create: '/app-engine/file',
4121
+ update: '/app-engine/file',
4122
+ "delete": '/app-engine/file',
4123
+ content: '/app-engine/file/content',
4124
+ tree: '/app-engine/file/tree',
4125
+ applyChanges: '/app-engine/file/apply-changes'
4126
+ };
4127
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4128
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || import.meta.env.VITE_LOOM_CLOUD_BACKEND_URL || '';
4129
+ if (baseUrl) {
4130
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4131
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4132
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4133
+ }
4134
+ return _this;
4135
+ }
4136
+ _inherits(AppEngineAppFileService, _BaseApi);
4137
+ return _createClass(AppEngineAppFileService, [{
4138
+ key: "getFileContent",
4139
+ value: function () {
4140
+ var _getFileContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4141
+ return _regenerator().w(function (_context) {
4142
+ while (1) switch (_context.n) {
4143
+ case 0:
4144
+ return _context.a(2, _superPropGet(AppEngineAppFileService, "get", this, 3)([payload, {
4145
+ endpoint: this.service_uri.content
4146
+ }]));
4147
+ }
4148
+ }, _callee, this);
4149
+ }));
4150
+ function getFileContent(_x) {
4151
+ return _getFileContent.apply(this, arguments);
4152
+ }
4153
+ return getFileContent;
4154
+ }()
4155
+ }, {
4156
+ key: "getFileTree",
4157
+ value: function () {
4158
+ var _getFileTree = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4159
+ return _regenerator().w(function (_context2) {
4160
+ while (1) switch (_context2.n) {
4161
+ case 0:
4162
+ return _context2.a(2, _superPropGet(AppEngineAppFileService, "get", this, 3)([payload, {
4163
+ endpoint: this.service_uri.tree
4164
+ }]));
4165
+ }
4166
+ }, _callee2, this);
4167
+ }));
4168
+ function getFileTree(_x2) {
4169
+ return _getFileTree.apply(this, arguments);
4170
+ }
4171
+ return getFileTree;
4172
+ }()
4173
+ }, {
4174
+ key: "applyChanges",
4175
+ value: function () {
4176
+ var _applyChanges = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
4177
+ return _regenerator().w(function (_context3) {
4178
+ while (1) switch (_context3.n) {
4179
+ case 0:
4180
+ return _context3.a(2, _superPropGet(AppEngineAppFileService, "post", this, 3)([payload, {
4181
+ endpoint: this.service_uri.applyChanges
4182
+ }]));
4183
+ }
4184
+ }, _callee3, this);
4185
+ }));
4186
+ function applyChanges(_x3) {
4187
+ return _applyChanges.apply(this, arguments);
4188
+ }
4189
+ return applyChanges;
4190
+ }()
4191
+ }]);
4192
+ }(BaseApi);
4193
+
4194
+ var AppEngineAppBuildService = /*#__PURE__*/function (_BaseApi) {
4195
+ function AppEngineAppBuildService(args) {
4196
+ var _this;
4197
+ _classCallCheck(this, AppEngineAppBuildService);
4198
+ _this = _callSuper(this, AppEngineAppBuildService, [args]);
4199
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4200
+ _this.service_uri = {
4201
+ buildSingle: '/app-engine/build/single',
4202
+ buildAll: '/app-engine/build/all',
4203
+ buildAndPublish: '/app-engine/build/publish'
4204
+ };
4205
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4206
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || import.meta.env.VITE_LOOM_CLOUD_BACKEND_URL || '';
4207
+ if (baseUrl) {
4208
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4209
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4210
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4211
+ }
4212
+ return _this;
4213
+ }
4214
+ _inherits(AppEngineAppBuildService, _BaseApi);
4215
+ return _createClass(AppEngineAppBuildService, [{
4216
+ key: "buildSingle",
4217
+ value: function () {
4218
+ var _buildSingle = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4219
+ return _regenerator().w(function (_context) {
4220
+ while (1) switch (_context.n) {
4221
+ case 0:
4222
+ return _context.a(2, _superPropGet(AppEngineAppBuildService, "post", this, 3)([payload, {
4223
+ endpoint: this.service_uri.buildSingle
4224
+ }]));
4225
+ }
4226
+ }, _callee, this);
4227
+ }));
4228
+ function buildSingle(_x) {
4229
+ return _buildSingle.apply(this, arguments);
4230
+ }
4231
+ return buildSingle;
4232
+ }()
4233
+ }, {
4234
+ key: "buildAll",
4235
+ value: function () {
4236
+ var _buildAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4237
+ return _regenerator().w(function (_context2) {
4238
+ while (1) switch (_context2.n) {
4239
+ case 0:
4240
+ return _context2.a(2, _superPropGet(AppEngineAppBuildService, "post", this, 3)([payload, {
4241
+ endpoint: this.service_uri.buildAll
4242
+ }]));
4243
+ }
4244
+ }, _callee2, this);
4245
+ }));
4246
+ function buildAll(_x2) {
4247
+ return _buildAll.apply(this, arguments);
4248
+ }
4249
+ return buildAll;
4250
+ }()
4251
+ }, {
4252
+ key: "buildAndPublish",
4253
+ value: function () {
4254
+ var _buildAndPublish = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
4255
+ return _regenerator().w(function (_context3) {
4256
+ while (1) switch (_context3.n) {
4257
+ case 0:
4258
+ return _context3.a(2, _superPropGet(AppEngineAppBuildService, "post", this, 3)([payload, {
4259
+ endpoint: this.service_uri.buildAndPublish
4260
+ }]));
4261
+ }
4262
+ }, _callee3, this);
4263
+ }));
4264
+ function buildAndPublish(_x3) {
4265
+ return _buildAndPublish.apply(this, arguments);
4266
+ }
4267
+ return buildAndPublish;
4268
+ }()
4269
+ }]);
4270
+ }(BaseApi);
4271
+
4272
+ var AppEngineAppSessionService = /*#__PURE__*/function (_BaseApi) {
4273
+ function AppEngineAppSessionService(args) {
4274
+ var _this;
4275
+ _classCallCheck(this, AppEngineAppSessionService);
4276
+ _this = _callSuper(this, AppEngineAppSessionService, [args]);
4277
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4278
+ _this.service_uri = {
4279
+ get: '/app-engine/session',
4280
+ create: '/app-engine/session',
4281
+ update: '/app-engine/session',
4282
+ "delete": '/app-engine/session',
4283
+ open: '/app-engine/session/open',
4284
+ saveDraft: '/app-engine/session/save-draft',
4285
+ submitOutput: '/app-engine/session/submit-output',
4286
+ cancel: '/app-engine/session/cancel'
4287
+ };
4288
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4289
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || import.meta.env.VITE_LOOM_CLOUD_BACKEND_URL || '';
4290
+ if (baseUrl) {
4291
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4292
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4293
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4294
+ }
4295
+ return _this;
4296
+ }
4297
+ _inherits(AppEngineAppSessionService, _BaseApi);
4298
+ return _createClass(AppEngineAppSessionService, [{
4299
+ key: "open",
4300
+ value: function () {
4301
+ var _open = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4302
+ return _regenerator().w(function (_context) {
4303
+ while (1) switch (_context.n) {
4304
+ case 0:
4305
+ return _context.a(2, _superPropGet(AppEngineAppSessionService, "post", this, 3)([payload, {
4306
+ endpoint: this.service_uri.open
4307
+ }]));
4308
+ }
4309
+ }, _callee, this);
4310
+ }));
4311
+ function open(_x) {
4312
+ return _open.apply(this, arguments);
4313
+ }
4314
+ return open;
4315
+ }()
4316
+ }, {
4317
+ key: "saveDraft",
4318
+ value: function () {
4319
+ var _saveDraft = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4320
+ return _regenerator().w(function (_context2) {
4321
+ while (1) switch (_context2.n) {
4322
+ case 0:
4323
+ return _context2.a(2, _superPropGet(AppEngineAppSessionService, "patch", this, 3)([payload, {
4324
+ endpoint: this.service_uri.saveDraft
4325
+ }]));
4326
+ }
4327
+ }, _callee2, this);
4328
+ }));
4329
+ function saveDraft(_x2) {
4330
+ return _saveDraft.apply(this, arguments);
4331
+ }
4332
+ return saveDraft;
4333
+ }()
4334
+ }, {
4335
+ key: "submitOutput",
4336
+ value: function () {
4337
+ var _submitOutput = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
4338
+ return _regenerator().w(function (_context3) {
4339
+ while (1) switch (_context3.n) {
4340
+ case 0:
4341
+ return _context3.a(2, _superPropGet(AppEngineAppSessionService, "patch", this, 3)([payload, {
4342
+ endpoint: this.service_uri.submitOutput
4343
+ }]));
4344
+ }
4345
+ }, _callee3, this);
4346
+ }));
4347
+ function submitOutput(_x3) {
4348
+ return _submitOutput.apply(this, arguments);
4349
+ }
4350
+ return submitOutput;
4351
+ }()
4352
+ }, {
4353
+ key: "cancel",
4354
+ value: function () {
4355
+ var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload) {
4356
+ return _regenerator().w(function (_context4) {
4357
+ while (1) switch (_context4.n) {
4358
+ case 0:
4359
+ return _context4.a(2, _superPropGet(AppEngineAppSessionService, "patch", this, 3)([payload, {
4360
+ endpoint: this.service_uri.cancel
4361
+ }]));
4362
+ }
4363
+ }, _callee4, this);
4364
+ }));
4365
+ function cancel(_x4) {
4366
+ return _cancel.apply(this, arguments);
4367
+ }
4368
+ return cancel;
4369
+ }()
4370
+ }]);
4371
+ }(BaseApi);
4372
+
4373
+ var AppEngineAppPreferenceService = /*#__PURE__*/function (_BaseApi) {
4374
+ function AppEngineAppPreferenceService(args) {
4375
+ var _this;
4376
+ _classCallCheck(this, AppEngineAppPreferenceService);
4377
+ _this = _callSuper(this, AppEngineAppPreferenceService, [args]);
4378
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4379
+ _this.service_uri = {
4380
+ get: '/app-engine/preference',
4381
+ create: '/app-engine/preference',
4382
+ update: '/app-engine/preference',
4383
+ "delete": '/app-engine/preference'
4384
+ };
4385
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4386
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || import.meta.env.VITE_LOOM_CLOUD_BACKEND_URL || '';
4387
+ if (baseUrl) {
4388
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4389
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4390
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4391
+ }
4392
+ return _this;
4393
+ }
4394
+ _inherits(AppEngineAppPreferenceService, _BaseApi);
4395
+ return _createClass(AppEngineAppPreferenceService);
4396
+ }(BaseApi);
4397
+
4398
+ var AppEngineSDKContext = /*#__PURE__*/createContext(null);
4399
+ var AppEngineSDKProvider = function AppEngineSDKProvider(_ref) {
4400
+ var baseUrl = _ref.baseUrl,
4401
+ children = _ref.children;
4402
+ var services = useMemo(function () {
4403
+ var config = baseUrl ? {
4404
+ baseUrl: baseUrl
4405
+ } : {};
4406
+ return {
4407
+ appDefinitionService: new AppEngineAppDefinitionService(config),
4408
+ appVersionService: new AppEngineAppVersionService(config),
4409
+ appFileService: new AppEngineAppFileService(config),
4410
+ appBuildService: new AppEngineAppBuildService(config),
4411
+ appSessionService: new AppEngineAppSessionService(config),
4412
+ appPreferenceService: new AppEngineAppPreferenceService(config)
4413
+ };
4414
+ }, [baseUrl]);
4415
+ return /*#__PURE__*/React$1.createElement(AppEngineSDKContext.Provider, {
4416
+ value: services
4417
+ }, children);
4418
+ };
4419
+ var useAppEngineSDK = function useAppEngineSDK() {
4420
+ var context = useContext(AppEngineSDKContext);
4421
+ if (!context) {
4422
+ throw new Error('useAppEngineSDK must be used within an AppEngineSDKProvider');
4423
+ }
4424
+ return context;
4425
+ };
4426
+
4427
+ function useAppStudio(_ref) {
4428
+ var appDefinitionService = _ref.appDefinitionService,
4429
+ appFileService = _ref.appFileService,
4430
+ appVersionService = _ref.appVersionService,
4431
+ appBuildService = _ref.appBuildService;
4432
+ var _useState = useState(null),
4433
+ _useState2 = _slicedToArray(_useState, 2),
4434
+ appDefinition = _useState2[0],
4435
+ setAppDefinition = _useState2[1];
4436
+ var _useState3 = useState([]),
4437
+ _useState4 = _slicedToArray(_useState3, 2),
4438
+ fileTree = _useState4[0],
4439
+ setFileTree = _useState4[1];
4440
+ var _useState5 = useState([]),
4441
+ _useState6 = _slicedToArray(_useState5, 2),
4442
+ openFiles = _useState6[0],
4443
+ setOpenFiles = _useState6[1];
4444
+ var _useState7 = useState(null),
4445
+ _useState8 = _slicedToArray(_useState7, 2),
4446
+ activeFilePath = _useState8[0],
4447
+ setActiveFilePath = _useState8[1];
4448
+ var _useState9 = useState(false),
4449
+ _useState0 = _slicedToArray(_useState9, 2),
4450
+ isSaving = _useState0[0],
4451
+ setIsSaving = _useState0[1];
4452
+ var _useState1 = useState(null),
4453
+ _useState10 = _slicedToArray(_useState1, 2),
4454
+ buildStatus = _useState10[0],
4455
+ setBuildStatus = _useState10[1];
4456
+ var _useState11 = useState(''),
4457
+ _useState12 = _slicedToArray(_useState11, 2),
4458
+ buildLog = _useState12[0],
4459
+ setBuildLog = _useState12[1];
4460
+ var _useState13 = useState([]),
4461
+ _useState14 = _slicedToArray(_useState13, 2),
4462
+ buildErrors = _useState14[0],
4463
+ setBuildErrors = _useState14[1];
4464
+ var definitionDirtyRef = useRef(false);
4465
+ var isDirty = openFiles.some(function (f) {
4466
+ return f.isDirty;
4467
+ }) || definitionDirtyRef.current;
4468
+ var loadStudioPayload = useCallback(/*#__PURE__*/function () {
4469
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(appDefinitionId) {
4470
+ var response, _t;
4471
+ return _regenerator().w(function (_context) {
4472
+ while (1) switch (_context.p = _context.n) {
4473
+ case 0:
4474
+ if (!(!appDefinitionService || !appDefinitionId)) {
4475
+ _context.n = 1;
4476
+ break;
4477
+ }
4478
+ return _context.a(2);
4479
+ case 1:
4480
+ _context.p = 1;
4481
+ _context.n = 2;
4482
+ return appDefinitionService.getStudioPayload({
4483
+ id: appDefinitionId
4484
+ });
4485
+ case 2:
4486
+ response = _context.v;
4487
+ if (response !== null && response !== void 0 && response.result) {
4488
+ setAppDefinition(response.result.definition);
4489
+ setFileTree(response.result.file_tree || []);
4490
+ }
4491
+ _context.n = 4;
4492
+ break;
4493
+ case 3:
4494
+ _context.p = 3;
4495
+ _t = _context.v;
4496
+ console.error('Failed to load studio payload:', _t);
4497
+ case 4:
4498
+ return _context.a(2);
4499
+ }
4500
+ }, _callee, null, [[1, 3]]);
4501
+ }));
4502
+ return function (_x) {
4503
+ return _ref2.apply(this, arguments);
4504
+ };
4505
+ }(), [appDefinitionService]);
4506
+ var openFile = useCallback(/*#__PURE__*/function () {
4507
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(file) {
4508
+ var existing, content, _response$result, response, _t2;
4509
+ return _regenerator().w(function (_context2) {
4510
+ while (1) switch (_context2.p = _context2.n) {
4511
+ case 0:
4512
+ if (!(file.kind === 'folder')) {
4513
+ _context2.n = 1;
4514
+ break;
4515
+ }
4516
+ return _context2.a(2);
4517
+ case 1:
4518
+ existing = openFiles.find(function (f) {
4519
+ return f.path === file.path;
4520
+ });
4521
+ if (!existing) {
4522
+ _context2.n = 2;
4523
+ break;
4524
+ }
4525
+ setActiveFilePath(file.path);
4526
+ return _context2.a(2);
4527
+ case 2:
4528
+ content = file.content;
4529
+ if (!(content === undefined || content === null)) {
4530
+ _context2.n = 6;
4531
+ break;
4532
+ }
4533
+ _context2.p = 3;
4534
+ _context2.n = 4;
4535
+ return appFileService === null || appFileService === void 0 ? void 0 : appFileService.getFileContent({
4536
+ search: file.id
4537
+ });
4538
+ case 4:
4539
+ response = _context2.v;
4540
+ content = (response === null || response === void 0 || (_response$result = response.result) === null || _response$result === void 0 ? void 0 : _response$result.content) || '';
4541
+ _context2.n = 6;
4542
+ break;
4543
+ case 5:
4544
+ _context2.p = 5;
4545
+ _t2 = _context2.v;
4546
+ console.error('Failed to load file content:', _t2);
4547
+ content = '';
4548
+ case 6:
4549
+ setOpenFiles(function (prev) {
4550
+ return [].concat(_toConsumableArray(prev), [_objectSpread2(_objectSpread2({}, file), {}, {
4551
+ content: content,
4552
+ isDirty: false,
4553
+ originalContent: content
4554
+ })]);
4555
+ });
4556
+ setActiveFilePath(file.path);
4557
+ case 7:
4558
+ return _context2.a(2);
4559
+ }
4560
+ }, _callee2, null, [[3, 5]]);
4561
+ }));
4562
+ return function (_x2) {
4563
+ return _ref3.apply(this, arguments);
4564
+ };
4565
+ }(), [openFiles, appFileService]);
4566
+ var updateFileContent = useCallback(function (filePath, newContent) {
4567
+ setOpenFiles(function (prev) {
4568
+ return prev.map(function (f) {
4569
+ if (f.path !== filePath) return f;
4570
+ return _objectSpread2(_objectSpread2({}, f), {}, {
4571
+ content: newContent,
4572
+ isDirty: newContent !== f.originalContent
4573
+ });
4574
+ });
4575
+ });
4576
+ }, []);
4577
+ var closeFile = useCallback(function (filePath) {
4578
+ setOpenFiles(function (prev) {
4579
+ var next = prev.filter(function (f) {
4580
+ return f.path !== filePath;
4581
+ });
4582
+ if (filePath === activeFilePath) {
4583
+ var _next$Math$min;
4584
+ var closedIndex = prev.findIndex(function (f) {
4585
+ return f.path === filePath;
4586
+ });
4587
+ setActiveFilePath(((_next$Math$min = next[Math.min(closedIndex, next.length - 1)]) === null || _next$Math$min === void 0 ? void 0 : _next$Math$min.path) || null);
4588
+ }
4589
+ return next;
4590
+ });
4591
+ }, [activeFilePath]);
4592
+ var save = useCallback(/*#__PURE__*/function () {
4593
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(appDefinitionId) {
4594
+ var dirtyFiles, _t3;
4595
+ return _regenerator().w(function (_context3) {
4596
+ while (1) switch (_context3.p = _context3.n) {
4597
+ case 0:
4598
+ if (appFileService) {
4599
+ _context3.n = 1;
4600
+ break;
4601
+ }
4602
+ return _context3.a(2);
4603
+ case 1:
4604
+ setIsSaving(true);
4605
+ _context3.p = 2;
4606
+ dirtyFiles = openFiles.filter(function (f) {
4607
+ return f.isDirty;
4608
+ });
4609
+ if (!(dirtyFiles.length > 0)) {
4610
+ _context3.n = 4;
4611
+ break;
4612
+ }
4613
+ _context3.n = 3;
4614
+ return appFileService.applyChanges({
4615
+ app_definition_id: appDefinitionId,
4616
+ changes: dirtyFiles.map(function (f) {
4617
+ return {
4618
+ operation: 'update',
4619
+ id: f.id,
4620
+ path: f.path,
4621
+ content: f.content
4622
+ };
4623
+ })
4624
+ });
4625
+ case 3:
4626
+ setOpenFiles(function (prev) {
4627
+ return prev.map(function (f) {
4628
+ return f.isDirty ? _objectSpread2(_objectSpread2({}, f), {}, {
4629
+ isDirty: false,
4630
+ originalContent: f.content
4631
+ }) : f;
4632
+ });
4633
+ });
4634
+ case 4:
4635
+ if (!(definitionDirtyRef.current && appDefinitionService)) {
4636
+ _context3.n = 6;
4637
+ break;
4638
+ }
4639
+ _context3.n = 5;
4640
+ return appDefinitionService.update(appDefinition);
4641
+ case 5:
4642
+ definitionDirtyRef.current = false;
4643
+ case 6:
4644
+ _context3.n = 8;
4645
+ break;
4646
+ case 7:
4647
+ _context3.p = 7;
4648
+ _t3 = _context3.v;
4649
+ console.error('Failed to save:', _t3);
4650
+ case 8:
4651
+ _context3.p = 8;
4652
+ setIsSaving(false);
4653
+ return _context3.f(8);
4654
+ case 9:
4655
+ return _context3.a(2);
4656
+ }
4657
+ }, _callee3, null, [[2, 7, 8, 9]]);
4658
+ }));
4659
+ return function (_x3) {
4660
+ return _ref4.apply(this, arguments);
4661
+ };
4662
+ }(), [openFiles, appFileService, appDefinitionService, appDefinition]);
4663
+ var build = useCallback(/*#__PURE__*/function () {
4664
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(appDefinitionId) {
4665
+ var _response$result2, response, _t4;
4666
+ return _regenerator().w(function (_context4) {
4667
+ while (1) switch (_context4.p = _context4.n) {
4668
+ case 0:
4669
+ if (appBuildService) {
4670
+ _context4.n = 1;
4671
+ break;
4672
+ }
4673
+ return _context4.a(2);
4674
+ case 1:
4675
+ setBuildStatus('building');
4676
+ setBuildLog('');
4677
+ setBuildErrors([]);
4678
+ _context4.p = 2;
4679
+ _context4.n = 3;
4680
+ return appBuildService.build({
4681
+ app_definition_id: appDefinitionId,
4682
+ organization_id: appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.organization_id
4683
+ });
4684
+ case 3:
4685
+ response = _context4.v;
4686
+ setBuildStatus(response !== null && response !== void 0 && response.result ? 'success' : 'failed');
4687
+ setBuildLog((response === null || response === void 0 || (_response$result2 = response.result) === null || _response$result2 === void 0 ? void 0 : _response$result2.build_log) || '');
4688
+ _context4.n = 5;
4689
+ break;
4690
+ case 4:
4691
+ _context4.p = 4;
4692
+ _t4 = _context4.v;
4693
+ setBuildStatus('failed');
4694
+ setBuildErrors([_t4.message]);
4695
+ case 5:
4696
+ return _context4.a(2);
4697
+ }
4698
+ }, _callee4, null, [[2, 4]]);
4699
+ }));
4700
+ return function (_x4) {
4701
+ return _ref5.apply(this, arguments);
4702
+ };
4703
+ }(), [appBuildService, appDefinition]);
4704
+ var publish = useCallback(/*#__PURE__*/function () {
4705
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(appDefinitionId) {
4706
+ var _t5;
4707
+ return _regenerator().w(function (_context5) {
4708
+ while (1) switch (_context5.p = _context5.n) {
4709
+ case 0:
4710
+ if (appVersionService) {
4711
+ _context5.n = 1;
4712
+ break;
4713
+ }
4714
+ return _context5.a(2);
4715
+ case 1:
4716
+ _context5.p = 1;
4717
+ _context5.n = 2;
4718
+ return appVersionService.publish({
4719
+ app_definition_id: appDefinitionId
4720
+ });
4721
+ case 2:
4722
+ _context5.n = 4;
4723
+ break;
4724
+ case 3:
4725
+ _context5.p = 3;
4726
+ _t5 = _context5.v;
4727
+ console.error('Failed to publish:', _t5);
4728
+ case 4:
4729
+ return _context5.a(2);
4730
+ }
4731
+ }, _callee5, null, [[1, 3]]);
4732
+ }));
4733
+ return function (_x5) {
4734
+ return _ref6.apply(this, arguments);
4735
+ };
4736
+ }(), [appVersionService]);
4737
+ var updateDefinition = useCallback(function (updated) {
4738
+ setAppDefinition(updated);
4739
+ definitionDirtyRef.current = true;
4740
+ }, []);
4741
+ return {
4742
+ appDefinition: appDefinition,
4743
+ fileTree: fileTree,
4744
+ openFiles: openFiles,
4745
+ activeFilePath: activeFilePath,
4746
+ isSaving: isSaving,
4747
+ isDirty: isDirty,
4748
+ buildStatus: buildStatus,
4749
+ buildLog: buildLog,
4750
+ buildErrors: buildErrors,
4751
+ setActiveFilePath: setActiveFilePath,
4752
+ loadStudioPayload: loadStudioPayload,
4753
+ openFile: openFile,
4754
+ updateFileContent: updateFileContent,
4755
+ closeFile: closeFile,
4756
+ save: save,
4757
+ build: build,
4758
+ publish: publish,
4759
+ updateDefinition: updateDefinition
4760
+ };
4761
+ }
4762
+
4763
+ function useAppRuntime(_ref) {
4764
+ var appSessionService = _ref.appSessionService;
4765
+ var _useState = useState('idle'),
4766
+ _useState2 = _slicedToArray(_useState, 2),
4767
+ status = _useState2[0],
4768
+ setStatus = _useState2[1];
4769
+ var _useState3 = useState(null),
4770
+ _useState4 = _slicedToArray(_useState3, 2),
4771
+ error = _useState4[0],
4772
+ setError = _useState4[1];
4773
+ var _useState5 = useState(null),
4774
+ _useState6 = _slicedToArray(_useState5, 2),
4775
+ session = _useState6[0],
4776
+ setSession = _useState6[1];
4777
+ var mountRef = useRef(null);
4778
+ var rootRef = useRef(null);
4779
+ var blobUrlRef = useRef(null);
4780
+ var cleanup = useCallback(function () {
4781
+ if (rootRef.current) {
4782
+ rootRef.current.unmount();
4783
+ rootRef.current = null;
4784
+ }
4785
+ if (blobUrlRef.current) {
4786
+ URL.revokeObjectURL(blobUrlRef.current);
4787
+ blobUrlRef.current = null;
4788
+ }
4789
+ }, []);
4790
+ var openApp = useCallback(/*#__PURE__*/function () {
4791
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref2) {
4792
+ var appSlug, routePath, launchMode, inputPayload, onSubmitOutput, onClose, onNavigate, _version$build_artifa, response, _response$result, sessionData, version, entryFile, blob, module, AppComponent, sdk, _t;
4793
+ return _regenerator().w(function (_context3) {
4794
+ while (1) switch (_context3.p = _context3.n) {
4795
+ case 0:
4796
+ appSlug = _ref2.appSlug, routePath = _ref2.routePath, launchMode = _ref2.launchMode, inputPayload = _ref2.inputPayload, onSubmitOutput = _ref2.onSubmitOutput, onClose = _ref2.onClose, onNavigate = _ref2.onNavigate;
4797
+ if (!(!appSessionService || !appSlug)) {
4798
+ _context3.n = 1;
4799
+ break;
4800
+ }
4801
+ return _context3.a(2);
4802
+ case 1:
4803
+ cleanup();
4804
+ setStatus('loading');
4805
+ setError(null);
4806
+ _context3.p = 2;
4807
+ _context3.n = 3;
4808
+ return appSessionService.open({
4809
+ app_slug: appSlug,
4810
+ route_path: routePath || '/',
4811
+ launch_mode: launchMode || 'fullscreen',
4812
+ input_payload: inputPayload || {}
4813
+ });
4814
+ case 3:
4815
+ response = _context3.v;
4816
+ if (response !== null && response !== void 0 && response.result) {
4817
+ _context3.n = 4;
4818
+ break;
4819
+ }
4820
+ throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Failed to open session');
4821
+ case 4:
4822
+ _response$result = response.result, sessionData = _response$result.session, version = _response$result.app_version;
4823
+ setSession(sessionData);
4824
+ if (version !== null && version !== void 0 && version.build_artifact) {
4825
+ _context3.n = 5;
4826
+ break;
4827
+ }
4828
+ throw new Error('No build artifact available');
4829
+ case 5:
4830
+ entryFile = Object.keys(version.build_artifact).find(function (key) {
4831
+ return key.endsWith('.js') || key.endsWith('.mjs');
4832
+ });
4833
+ if (!(!entryFile || !((_version$build_artifa = version.build_artifact[entryFile]) !== null && _version$build_artifa !== void 0 && _version$build_artifa.content))) {
4834
+ _context3.n = 6;
4835
+ break;
4836
+ }
4837
+ throw new Error('No entry file found in build artifacts');
4838
+ case 6:
4839
+ blob = new Blob([version.build_artifact[entryFile].content], {
4840
+ type: 'application/javascript'
4841
+ });
4842
+ blobUrlRef.current = URL.createObjectURL(blob);
4843
+ _context3.n = 7;
4844
+ return import(/* @vite-ignore */blobUrlRef.current);
4845
+ case 7:
4846
+ module = _context3.v;
4847
+ AppComponent = module["default"];
4848
+ if (AppComponent) {
4849
+ _context3.n = 8;
4850
+ break;
4851
+ }
4852
+ throw new Error('App module does not export a default component');
4853
+ case 8:
4854
+ sdk = {
4855
+ session: {
4856
+ id: sessionData.id,
4857
+ appId: sessionData.app_definition_id,
4858
+ appSlug: sessionData.app_slug,
4859
+ appVersionId: sessionData.app_version_id,
4860
+ launchMode: sessionData.launch_mode,
4861
+ routePath: sessionData.route_path
4862
+ },
4863
+ input: sessionData.input_payload || inputPayload || {},
4864
+ navigate: function navigate(path) {
4865
+ return onNavigate === null || onNavigate === void 0 ? void 0 : onNavigate(path);
4866
+ },
4867
+ saveDraft: function saveDraft(payload) {
4868
+ return appSessionService === null || appSessionService === void 0 ? void 0 : appSessionService.saveDraft({
4869
+ id: sessionData.id,
4870
+ draft_payload: payload
4871
+ });
4872
+ },
4873
+ submitOutput: function () {
4874
+ var _submitOutput = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4875
+ return _regenerator().w(function (_context) {
4876
+ while (1) switch (_context.n) {
4877
+ case 0:
4878
+ _context.n = 1;
4879
+ return appSessionService === null || appSessionService === void 0 ? void 0 : appSessionService.submitOutput({
4880
+ id: sessionData.id,
4881
+ output_payload: payload
4882
+ });
4883
+ case 1:
4884
+ onSubmitOutput === null || onSubmitOutput === void 0 || onSubmitOutput(payload);
4885
+ case 2:
4886
+ return _context.a(2);
4887
+ }
4888
+ }, _callee);
4889
+ }));
4890
+ function submitOutput(_x2) {
4891
+ return _submitOutput.apply(this, arguments);
4892
+ }
4893
+ return submitOutput;
4894
+ }(),
4895
+ close: function close() {
4896
+ return onClose === null || onClose === void 0 ? void 0 : onClose();
4897
+ },
4898
+ cancel: function () {
4899
+ var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
4900
+ return _regenerator().w(function (_context2) {
4901
+ while (1) switch (_context2.n) {
4902
+ case 0:
4903
+ _context2.n = 1;
4904
+ return appSessionService === null || appSessionService === void 0 ? void 0 : appSessionService.cancel({
4905
+ id: sessionData.id
4906
+ });
4907
+ case 1:
4908
+ onClose === null || onClose === void 0 || onClose();
4909
+ case 2:
4910
+ return _context2.a(2);
4911
+ }
4912
+ }, _callee2);
4913
+ }));
4914
+ function cancel() {
4915
+ return _cancel.apply(this, arguments);
4916
+ }
4917
+ return cancel;
4918
+ }()
4919
+ };
4920
+ return _context3.a(2, {
4921
+ AppComponent: AppComponent,
4922
+ sdk: sdk
4923
+ });
4924
+ case 9:
4925
+ _context3.p = 9;
4926
+ _t = _context3.v;
4927
+ setError(_t.message);
4928
+ setStatus('error');
4929
+ return _context3.a(2, null);
4930
+ }
4931
+ }, _callee3, null, [[2, 9]]);
4932
+ }));
4933
+ return function (_x) {
4934
+ return _ref3.apply(this, arguments);
4935
+ };
4936
+ }(), [appSessionService, cleanup]);
4937
+ var mountApp = useCallback(function (containerRef, AppComponent, sdk) {
4938
+ if (!(containerRef !== null && containerRef !== void 0 && containerRef.current) || !AppComponent) return;
4939
+ cleanup();
4940
+ mountRef.current = containerRef.current;
4941
+ rootRef.current = createRoot(containerRef.current);
4942
+ rootRef.current.render(/*#__PURE__*/React.createElement(AppComponent, {
4943
+ sdk: sdk
4944
+ }));
4945
+ setStatus('running');
4946
+ }, [cleanup]);
4947
+ useEffect(function () {
4948
+ return cleanup;
4949
+ }, [cleanup]);
4950
+ return {
4951
+ status: status,
4952
+ error: error,
4953
+ session: session,
4954
+ openApp: openApp,
4955
+ mountApp: mountApp,
4956
+ cleanup: cleanup
4957
+ };
4958
+ }
4959
+
4960
+ export { AppCatalogCard as AppCatalogCardComponent, AppCatalogGrid as AppCatalogGridComponent, AppEngineAppBuildService, AppEngineAppDefinitionService, AppEngineAppFileService, AppEngineAppPreferenceService, AppEngineAppSessionService, AppEngineAppVersionService, AppEngineClient, AppEngineSDKProvider, AppRuntimeHost as AppRuntimeHostComponent, AppStudio as AppStudioComponent, useAppEngineSDK, useAppRuntime, useAppStudio };
4961
+ //# sourceMappingURL=cloud-sdk.esm.js.map