@templatical/editor 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/{AiChatSidebar-Br9dhkIB.js → AiChatSidebar-B3SJIKG_.js} +1 -1
  2. package/dist/{AiFeatureMenu-Ceewb3uB.js → AiFeatureMenu-BLLKoOos.js} +1 -1
  3. package/dist/{CloudEditor-D_flODpm.js → CloudEditor-BIaM8Gux.js} +36 -30
  4. package/dist/{CollaboratorBar-BcSxXVY-.js → CollaboratorBar-DuPYW5iF.js} +1 -1
  5. package/dist/{CommentsSidebar-DceMRyIS.js → CommentsSidebar-B1pvJdqF.js} +1 -1
  6. package/dist/{DesignReferenceSidebar-50qFipmW.js → DesignReferenceSidebar-B8V_F2yF.js} +69 -67
  7. package/dist/{ModuleBrowserModal-BnSdG4DE.js → ModuleBrowserModal-DrUFMTDx.js} +4 -4
  8. package/dist/{ModulePreviewCanvas-B78PuZdk.js → ModulePreviewCanvas-CHdOwV_4.js} +1 -1
  9. package/dist/{ParagraphEditor-CPBYk2m3.js → ParagraphEditor-D75wl3BX.js} +1 -1
  10. package/dist/{SaveModuleDialog-Df__VToK.js → SaveModuleDialog-FZ9lxY7_.js} +2 -2
  11. package/dist/{SnapshotHistory-QBTbVrEK.js → SnapshotHistory-BR3eV120.js} +2 -2
  12. package/dist/{TestEmailModal-DaDMACHY.js → TestEmailModal--ue5w9fT.js} +2 -2
  13. package/dist/{TitleEditor-PHShl4tS.js → TitleEditor-fStSADI-.js} +1 -1
  14. package/dist/{TplModal-DzlNkBYQ.js → TplModal-BwSfxIHf.js} +1 -1
  15. package/dist/{blockTypeIcons-D0wkSpP9.js → blockTypeIcons-BcTrDjmH.js} +1 -1
  16. package/dist/bundle-stats.json +6 -6
  17. package/dist/cdn/chunks/{AccessibilityPanel-fjNLcnxu.js → AccessibilityPanel-B6DOjojm.js} +3 -3
  18. package/dist/cdn/chunks/{AccessibilityPanel-fjNLcnxu.js.map → AccessibilityPanel-B6DOjojm.js.map} +1 -1
  19. package/dist/cdn/chunks/{AiFeatureMenu-DSamZ3ve.js → AiFeatureMenu-qEdB2fZJ.js} +2 -2
  20. package/dist/cdn/chunks/{AiFeatureMenu-DSamZ3ve.js.map → AiFeatureMenu-qEdB2fZJ.js.map} +1 -1
  21. package/dist/cdn/chunks/{BlockA11yBadge-D73PKVS8.js → BlockA11yBadge-DcEZftf6.js} +2 -2
  22. package/dist/cdn/chunks/{BlockA11yBadge-D73PKVS8.js.map → BlockA11yBadge-DcEZftf6.js.map} +1 -1
  23. package/dist/cdn/chunks/{CloudEditor-BGfliRFn.js → CloudEditor-fSfLEuDT.js} +41 -35
  24. package/dist/cdn/chunks/CloudEditor-fSfLEuDT.js.map +1 -0
  25. package/dist/cdn/chunks/{CollaboratorBar-BRvF0m5t.js → CollaboratorBar--nO7TX6b.js} +3 -3
  26. package/dist/cdn/chunks/{CollaboratorBar-BRvF0m5t.js.map → CollaboratorBar--nO7TX6b.js.map} +1 -1
  27. package/dist/cdn/chunks/{CountdownBlock-IIZk8uja.js → CountdownBlock-5YdT1uUu.js} +2 -2
  28. package/dist/cdn/chunks/{CountdownBlock-IIZk8uja.js.map → CountdownBlock-5YdT1uUu.js.map} +1 -1
  29. package/dist/cdn/chunks/{CountdownToolbar-mXM3YITU.js → CountdownToolbar-DXPXrbAA.js} +3 -3
  30. package/dist/cdn/chunks/{CountdownToolbar-mXM3YITU.js.map → CountdownToolbar-DXPXrbAA.js.map} +1 -1
  31. package/dist/cdn/chunks/{ModuleBrowserModal-BgIdqEyV.js → ModuleBrowserModal-DxoPp81s.js} +5 -5
  32. package/dist/cdn/chunks/{ModuleBrowserModal-BgIdqEyV.js.map → ModuleBrowserModal-DxoPp81s.js.map} +1 -1
  33. package/dist/cdn/chunks/{ModulePreviewCanvas-BOFLwREg.js → ModulePreviewCanvas-CoLdb4ar.js} +2 -2
  34. package/dist/cdn/chunks/{ModulePreviewCanvas-BOFLwREg.js.map → ModulePreviewCanvas-CoLdb4ar.js.map} +1 -1
  35. package/dist/cdn/chunks/{NumberWithSuffix-Cxe5sPC2.js → NumberWithSuffix-CE3NrZhH.js} +2 -2
  36. package/dist/cdn/chunks/{NumberWithSuffix-Cxe5sPC2.js.map → NumberWithSuffix-CE3NrZhH.js.map} +1 -1
  37. package/dist/cdn/chunks/{ParagraphEditor-7Wycs4gM.js → ParagraphEditor-B6Ygu-Mq.js} +16 -16
  38. package/dist/cdn/chunks/{ParagraphEditor-7Wycs4gM.js.map → ParagraphEditor-B6Ygu-Mq.js.map} +1 -1
  39. package/dist/cdn/chunks/{RichTextEditorContent-DVw5mwEA.js → RichTextEditorContent-DL_y2SrR.js} +2 -2
  40. package/dist/cdn/chunks/{RichTextEditorContent-DVw5mwEA.js.map → RichTextEditorContent-DL_y2SrR.js.map} +1 -1
  41. package/dist/cdn/chunks/{SaveModuleDialog-Cz1xEjJG.js → SaveModuleDialog-B0TnO_o9.js} +2 -2
  42. package/dist/cdn/chunks/{SaveModuleDialog-Cz1xEjJG.js.map → SaveModuleDialog-B0TnO_o9.js.map} +1 -1
  43. package/dist/cdn/chunks/{TitleEditor-DTF4hRB6.js → TitleEditor-BHpfxvwy.js} +8 -8
  44. package/dist/cdn/chunks/{TitleEditor-DTF4hRB6.js.map → TitleEditor-BHpfxvwy.js.map} +1 -1
  45. package/dist/cdn/chunks/{blockTypeIcons-C5tZU4ot.js → blockTypeIcons-BzzY9_kA.js} +3 -3
  46. package/dist/cdn/chunks/{blockTypeIcons-C5tZU4ot.js.map → blockTypeIcons-BzzY9_kA.js.map} +1 -1
  47. package/dist/cdn/chunks/{extensions-BrVEX2vQ.js → extensions-DIxF31tA.js} +3 -3
  48. package/dist/cdn/chunks/{extensions-BrVEX2vQ.js.map → extensions-DIxF31tA.js.map} +1 -1
  49. package/dist/cdn/chunks/{features-BdkV7kQP.js → features-DEMb13KS.js} +419 -380
  50. package/dist/cdn/chunks/features-DEMb13KS.js.map +1 -0
  51. package/dist/cdn/chunks/{icons-oRXtYgc3.js → icons-CsLTcirh.js} +2 -2
  52. package/dist/cdn/chunks/{icons-oRXtYgc3.js.map → icons-CsLTcirh.js.map} +1 -1
  53. package/dist/cdn/chunks/{media-library-C7uyFrMO.js → media-library-CVaNvhpM.js} +3 -3
  54. package/dist/cdn/chunks/{media-library-C7uyFrMO.js.map → media-library-CVaNvhpM.js.map} +1 -1
  55. package/dist/cdn/chunks/{quality-C5gsx_Tw.js → quality-BaBfc54_.js} +2 -2
  56. package/dist/cdn/chunks/{quality-C5gsx_Tw.js.map → quality-BaBfc54_.js.map} +1 -1
  57. package/dist/cdn/chunks/{renderer-DM2gdPmx.js → renderer-CUxvx7ro.js} +11 -11
  58. package/dist/cdn/chunks/renderer-CUxvx7ro.js.map +1 -0
  59. package/dist/cdn/chunks/{src-BAAwLL7q.js → src-CRaqN-p8.js} +4 -4
  60. package/dist/cdn/chunks/{src-BAAwLL7q.js.map → src-CRaqN-p8.js.map} +1 -1
  61. package/dist/cdn/chunks/{styles-iDn0uW8_.js → styles-DlM2koDM.js} +8 -8
  62. package/dist/cdn/chunks/{styles-iDn0uW8_.js.map → styles-DlM2koDM.js.map} +1 -1
  63. package/dist/cdn/chunks/{tiptap-ClLEM7Xz.js → tiptap-ZhwKyFp7.js} +2 -2
  64. package/dist/cdn/chunks/{tiptap-ClLEM7Xz.js.map → tiptap-ZhwKyFp7.js.map} +1 -1
  65. package/dist/cdn/editor.css +1 -1
  66. package/dist/cdn/editor.js +5 -5
  67. package/dist/{cloud-WfWdqZVK.js → cloud-DEk_b4CR.js} +321 -293
  68. package/dist/{formatRelativeTime-WvH3Au71.js → formatRelativeTime-BOEf47hq.js} +3 -1
  69. package/dist/index.d.ts +6 -6
  70. package/dist/style.css +1 -1
  71. package/dist/{styles-B58wYIn4.js → styles-CMX4BeKs.js} +2 -2
  72. package/dist/templatical-editor.js +3 -3
  73. package/dist/{useEditorCore-Dz-qbVXX.js → useEditorCore-C6ost42Q.js} +71 -64
  74. package/package.json +7 -7
  75. package/dist/cdn/chunks/CloudEditor-BGfliRFn.js.map +0 -1
  76. package/dist/cdn/chunks/features-BdkV7kQP.js.map +0 -1
  77. package/dist/cdn/chunks/renderer-DM2gdPmx.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { Q as e, X as t, Z as n, p as r, z as i } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
2
- import { r as a, u as o } from "./dist-DJmnUmW9.js";
1
+ import { Q as e, X as t, Y as n, Z as r, p as i, z as a } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
2
+ import { r as o, u as s } from "./dist-DJmnUmW9.js";
3
3
  //#region ../core/dist/cloud/index.js
4
- var s = class e {
4
+ var c = class e {
5
5
  static DEFAULT_BASE_URL = "https://templatical.com";
6
6
  accessToken = null;
7
7
  expiresAt = null;
@@ -75,7 +75,7 @@ var s = class e {
75
75
  };
76
76
  e === "POST" && this.requestOptions.body && (t["Content-Type"] = "application/json", n.body = JSON.stringify(this.requestOptions.body));
77
77
  let r = await fetch(this.url, n);
78
- if (!r.ok) throw new a(`Token refresh failed: ${r.status}`, r.status);
78
+ if (!r.ok) throw new o(`Token refresh failed: ${r.status}`, r.status);
79
79
  let i = await r.json();
80
80
  if (!i.token || !i.expires_at || !i.project_id || !i.tenant) throw Error("Invalid token response: missing token, expires_at, project_id, or tenant");
81
81
  return this.accessToken = i.token, this.expiresAt = /* @__PURE__ */ new Date(i.expires_at * 1e3), this._projectId = i.project_id, this._tenantSlug = i.tenant, i.test_email?.allowed_emails && i.test_email?.signature ? this._testEmailConfig = {
@@ -102,54 +102,54 @@ var s = class e {
102
102
  return a.status === 401 && (a = await i(await this.refreshToken())), a;
103
103
  }
104
104
  };
105
- function c(e, t) {
105
+ function l(e, t) {
106
106
  return e.replace(/\{(\w+)\}/g, (e, n) => encodeURIComponent(t[n] ?? ""));
107
107
  }
108
- var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{template}`, d = `${u}/ai`, f = `${l}/media`, p = `${f}/folders`, m = `${l}/saved-modules`, h = {
108
+ var u = "/api/v1/projects/{project}/tenants/{tenant}", d = `${u}/templates/{template}`, f = `${d}/ai`, p = `${u}/media`, m = `${p}/folders`, h = `${u}/saved-modules`, g = {
109
109
  health: "/api/v1/health",
110
- "projects.config": `${l}/config`,
111
- "broadcasting.auth": `${l}/broadcasting/auth`,
112
- "templates.store": `${l}/templates`,
113
- "templates.show": `${u}`,
114
- "templates.update": `${u}`,
115
- "templates.destroy": `${u}`,
116
- "templates.export": `${u}/export`,
117
- "templates.importFromBeefree": `${l}/templates/import/from-beefree`,
118
- "templates.sendTestEmail": `${u}/send-test-email`,
119
- "snapshots.index": `${u}/snapshots`,
120
- "snapshots.store": `${u}/snapshots`,
121
- "snapshots.show": `${u}/snapshots/{snapshot}`,
122
- "snapshots.restore": `${u}/snapshots/{snapshot}/restore`,
123
- "comments.index": `${u}/comments`,
124
- "comments.store": `${u}/comments`,
125
- "comments.update": `${u}/comments/{comment}`,
126
- "comments.destroy": `${u}/comments/{comment}`,
127
- "comments.resolve": `${u}/comments/{comment}/resolve`,
128
- "ai.generate": `${d}/generate`,
129
- "ai.conversationMessages": `${d}/conversation-messages`,
130
- "ai.suggestions": `${d}/suggestions`,
131
- "ai.rewriteText": `${d}/rewrite-text`,
132
- "ai.score": `${d}/score`,
133
- "ai.fixFinding": `${d}/fix-finding`,
134
- "ai.generateFromDesign": `${d}/generate-from-design`,
135
- "media.upload": `${f}/upload`,
136
- "media.browse": `${f}/browse`,
137
- "media.delete": `${f}/delete`,
138
- "media.move": `${f}/move`,
139
- "media.update": `${f}/{media}`,
140
- "media.replace": `${f}/{media}/replace`,
141
- "media.checkUsage": `${f}/check-usage`,
142
- "media.frequentlyUsed": `${f}/frequently-used`,
143
- "media.importFromUrl": `${f}/import-from-url`,
144
- "folders.index": `${p}`,
145
- "folders.store": `${p}`,
146
- "folders.update": `${p}/{mediaFolder}`,
147
- "folders.destroy": `${p}/{mediaFolder}`,
148
- "savedModules.index": `${m}`,
149
- "savedModules.store": `${m}`,
150
- "savedModules.update": `${m}/{savedModule}`,
151
- "savedModules.destroy": `${m}/{savedModule}`
152
- }, g = class {
110
+ "projects.config": `${u}/config`,
111
+ "broadcasting.auth": `${u}/broadcasting/auth`,
112
+ "templates.store": `${u}/templates`,
113
+ "templates.show": `${d}`,
114
+ "templates.update": `${d}`,
115
+ "templates.destroy": `${d}`,
116
+ "templates.export": `${d}/export`,
117
+ "templates.importFromBeefree": `${u}/templates/import/from-beefree`,
118
+ "templates.sendTestEmail": `${d}/send-test-email`,
119
+ "snapshots.index": `${d}/snapshots`,
120
+ "snapshots.store": `${d}/snapshots`,
121
+ "snapshots.show": `${d}/snapshots/{snapshot}`,
122
+ "snapshots.restore": `${d}/snapshots/{snapshot}/restore`,
123
+ "comments.index": `${d}/comments`,
124
+ "comments.store": `${d}/comments`,
125
+ "comments.update": `${d}/comments/{comment}`,
126
+ "comments.destroy": `${d}/comments/{comment}`,
127
+ "comments.resolve": `${d}/comments/{comment}/resolve`,
128
+ "ai.generate": `${f}/generate`,
129
+ "ai.conversationMessages": `${f}/conversation-messages`,
130
+ "ai.suggestions": `${f}/suggestions`,
131
+ "ai.rewriteText": `${f}/rewrite-text`,
132
+ "ai.score": `${f}/score`,
133
+ "ai.fixFinding": `${f}/fix-finding`,
134
+ "ai.generateFromDesign": `${f}/generate-from-design`,
135
+ "media.upload": `${p}/upload`,
136
+ "media.browse": `${p}/browse`,
137
+ "media.delete": `${p}/delete`,
138
+ "media.move": `${p}/move`,
139
+ "media.update": `${p}/{media}`,
140
+ "media.replace": `${p}/{media}/replace`,
141
+ "media.checkUsage": `${p}/check-usage`,
142
+ "media.frequentlyUsed": `${p}/frequently-used`,
143
+ "media.importFromUrl": `${p}/import-from-url`,
144
+ "folders.index": `${m}`,
145
+ "folders.store": `${m}`,
146
+ "folders.update": `${m}/{mediaFolder}`,
147
+ "folders.destroy": `${m}/{mediaFolder}`,
148
+ "savedModules.index": `${h}`,
149
+ "savedModules.store": `${h}`,
150
+ "savedModules.update": `${h}/{savedModule}`,
151
+ "savedModules.destroy": `${h}/{savedModule}`
152
+ }, _ = class {
153
153
  constructor(e) {
154
154
  this.authManager = e;
155
155
  }
@@ -177,7 +177,7 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
177
177
  });
178
178
  if (!n.ok) {
179
179
  let e = await n.json().catch(() => ({ message: `HTTP error ${n.status}` }));
180
- throw new a(this.extractFirstValidationError(e), n.status);
180
+ throw new o(this.extractFirstValidationError(e), n.status);
181
181
  }
182
182
  if (n.status !== 204) return (await n.json()).data;
183
183
  }
@@ -189,19 +189,19 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
189
189
  return e.message;
190
190
  }
191
191
  async createTemplate(e) {
192
- return this.request(c(h["templates.store"], this.baseParams), {
192
+ return this.request(l(g["templates.store"], this.baseParams), {
193
193
  method: "POST",
194
194
  body: JSON.stringify({ content: e })
195
195
  });
196
196
  }
197
197
  async getTemplate(e) {
198
- return this.request(c(h["templates.show"], {
198
+ return this.request(l(g["templates.show"], {
199
199
  ...this.baseParams,
200
200
  template: e
201
201
  }));
202
202
  }
203
203
  async updateTemplate(e, t) {
204
- return this.request(c(h["templates.update"], {
204
+ return this.request(l(g["templates.update"], {
205
205
  ...this.baseParams,
206
206
  template: e
207
207
  }), {
@@ -210,7 +210,7 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
210
210
  });
211
211
  }
212
212
  async createSnapshot(e, t) {
213
- return this.request(c(h["snapshots.store"], {
213
+ return this.request(l(g["snapshots.store"], {
214
214
  ...this.baseParams,
215
215
  template: e
216
216
  }), {
@@ -219,19 +219,19 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
219
219
  });
220
220
  }
221
221
  async deleteTemplate(e) {
222
- return this.request(c(h["templates.destroy"], {
222
+ return this.request(l(g["templates.destroy"], {
223
223
  ...this.baseParams,
224
224
  template: e
225
225
  }), { method: "DELETE" });
226
226
  }
227
227
  async getSnapshots(e) {
228
- return this.request(c(h["snapshots.index"], {
228
+ return this.request(l(g["snapshots.index"], {
229
229
  ...this.baseParams,
230
230
  template: e
231
231
  }));
232
232
  }
233
233
  async restoreSnapshot(e, t) {
234
- return this.request(c(h["snapshots.restore"], {
234
+ return this.request(l(g["snapshots.restore"], {
235
235
  ...this.baseParams,
236
236
  template: e,
237
237
  snapshot: t
@@ -242,7 +242,7 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
242
242
  custom_fonts: t.customFonts,
243
243
  default_fallback: t.defaultFallback
244
244
  }) : void 0;
245
- return this.request(c(h["templates.export"], {
245
+ return this.request(l(g["templates.export"], {
246
246
  ...this.baseParams,
247
247
  template: e
248
248
  }), {
@@ -251,7 +251,7 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
251
251
  });
252
252
  }
253
253
  async sendTestEmail(e, t) {
254
- await this.request(c(h["templates.sendTestEmail"], {
254
+ await this.request(l(g["templates.sendTestEmail"], {
255
255
  ...this.baseParams,
256
256
  template: e
257
257
  }), {
@@ -260,11 +260,11 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
260
260
  });
261
261
  }
262
262
  commentsUrl(e, t) {
263
- return t ? c(h["comments.update"], {
263
+ return t ? l(g["comments.update"], {
264
264
  ...this.baseParams,
265
265
  template: e,
266
266
  comment: t
267
- }) : c(h["comments.index"], {
267
+ }) : l(g["comments.index"], {
268
268
  ...this.baseParams,
269
269
  template: e
270
270
  });
@@ -294,7 +294,7 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
294
294
  });
295
295
  }
296
296
  async resolveComment(e, t, n, r) {
297
- return this.request(c(h["comments.resolve"], {
297
+ return this.request(l(g["comments.resolve"], {
298
298
  ...this.baseParams,
299
299
  template: e,
300
300
  comment: t
@@ -305,20 +305,20 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
305
305
  });
306
306
  }
307
307
  async fetchConfig() {
308
- return this.request(c(h["projects.config"], this.baseParams));
308
+ return this.request(l(g["projects.config"], this.baseParams));
309
309
  }
310
310
  async listModules(e) {
311
- let t = c(h["savedModules.index"], this.baseParams), n = e ? `?search=${encodeURIComponent(e)}` : "";
311
+ let t = l(g["savedModules.index"], this.baseParams), n = e ? `?search=${encodeURIComponent(e)}` : "";
312
312
  return this.request(`${t}${n}`);
313
313
  }
314
314
  async createModule(e) {
315
- return this.request(c(h["savedModules.store"], this.baseParams), {
315
+ return this.request(l(g["savedModules.store"], this.baseParams), {
316
316
  method: "POST",
317
317
  body: JSON.stringify(e)
318
318
  });
319
319
  }
320
320
  async updateModule(e, t) {
321
- return this.request(c(h["savedModules.update"], {
321
+ return this.request(l(g["savedModules.update"], {
322
322
  ...this.baseParams,
323
323
  savedModule: e
324
324
  }), {
@@ -327,20 +327,20 @@ var l = "/api/v1/projects/{project}/tenants/{tenant}", u = `${l}/templates/{temp
327
327
  });
328
328
  }
329
329
  async deleteModule(e) {
330
- return this.request(c(h["savedModules.destroy"], {
330
+ return this.request(l(g["savedModules.destroy"], {
331
331
  ...this.baseParams,
332
332
  savedModule: e
333
333
  }), { method: "DELETE" });
334
334
  }
335
335
  };
336
- function _(e) {
336
+ function v(e) {
337
337
  return {
338
338
  host: e.host,
339
339
  port: e.port,
340
340
  appKey: e.app_key
341
341
  };
342
342
  }
343
- var v = class {
343
+ var y = class {
344
344
  pusher = null;
345
345
  authManager;
346
346
  config;
@@ -356,7 +356,7 @@ var v = class {
356
356
  } catch {
357
357
  throw Error("Cloud features require the optional peer dependency 'pusher-js'. Install it with: npm install pusher-js");
358
358
  }
359
- let { host: t, port: n, appKey: r } = this.config, i = this.authManager.resolveUrl(c(h["broadcasting.auth"], {
359
+ let { host: t, port: n, appKey: r } = this.config, i = this.authManager.resolveUrl(l(g["broadcasting.auth"], {
360
360
  project: this.authManager.projectId,
361
361
  tenant: this.authManager.tenantSlug
362
362
  }));
@@ -405,7 +405,7 @@ var v = class {
405
405
  return this.pusher?.connection.state === "connected";
406
406
  }
407
407
  };
408
- function y(e, t) {
408
+ function b(e, t) {
409
409
  let { operation: n, data: r } = t;
410
410
  switch (n) {
411
411
  case "add_block":
@@ -431,10 +431,10 @@ function y(e, t) {
431
431
  break;
432
432
  }
433
433
  }
434
- function b(e) {
435
- let i = new g(e.authManager), s = t({
434
+ function x(e) {
435
+ let n = new _(e.authManager), a = t({
436
436
  template: null,
437
- content: o(e.defaultFontFamily, e.templateDefaults),
437
+ content: s(e.defaultFontFamily, e.templateDefaults),
438
438
  selectedBlockId: null,
439
439
  viewport: "desktop",
440
440
  darkMode: !1,
@@ -443,13 +443,13 @@ function b(e) {
443
443
  isSaving: !1,
444
444
  isLoading: !1,
445
445
  uiTheme: "auto"
446
- }), c = r({
447
- get: () => s.content,
446
+ }), c = i({
447
+ get: () => a.content,
448
448
  set: (e) => {
449
- s.content = e, s.isDirty = !0;
449
+ a.content = e, a.isDirty = !0;
450
450
  }
451
- }), l = r(() => s.selectedBlockId ? d(s.content.blocks, s.selectedBlockId) : null), u = r(() => {
452
- let e = /* @__PURE__ */ new Set(), t = s.template?.content?.blocks;
451
+ }), l = i(() => a.selectedBlockId ? d(a.content.blocks, a.selectedBlockId) : null), u = i(() => {
452
+ let e = /* @__PURE__ */ new Set(), t = a.template?.content?.blocks;
453
453
  if (!t) return e;
454
454
  for (let n of t) if (e.add(n.id), n.type === "section") for (let t of n.children) for (let n of t) e.add(n.id);
455
455
  return e;
@@ -483,122 +483,122 @@ function b(e) {
483
483
  return e.lockedBlocks?.value.has(t) ?? !1;
484
484
  }
485
485
  function m(e, t = !0) {
486
- s.content = e, t && (s.isDirty = !0);
486
+ a.content = e, t && (a.isDirty = !0);
487
487
  }
488
488
  function h(e) {
489
- e && p(e) || (s.selectedBlockId = e);
489
+ e && p(e) || (a.selectedBlockId = e);
490
490
  }
491
- function _(e) {
492
- s.viewport = e;
491
+ function g(e) {
492
+ a.viewport = e;
493
493
  }
494
494
  function v(e) {
495
- s.darkMode = e;
495
+ a.darkMode = e;
496
496
  }
497
497
  function y(e) {
498
- s.uiTheme = e;
498
+ a.uiTheme = e;
499
499
  }
500
500
  function b(e) {
501
- s.previewMode = e, e && (s.selectedBlockId = null);
501
+ a.previewMode = e, e && (a.selectedBlockId = null);
502
502
  }
503
503
  function x(e, t) {
504
504
  if (p(e)) return;
505
- let n = d(s.content.blocks, e);
506
- n && (Object.assign(n, t), s.isDirty = !0);
505
+ let n = d(a.content.blocks, e);
506
+ n && (Object.assign(n, t), a.isDirty = !0);
507
507
  }
508
508
  function S(e) {
509
- s.content.settings = {
510
- ...s.content.settings,
509
+ a.content.settings = {
510
+ ...a.content.settings,
511
511
  ...e
512
- }, s.isDirty = !0;
512
+ }, a.isDirty = !0;
513
513
  }
514
514
  function C(e, t, n = 0, r) {
515
515
  if (t) {
516
- let i = d(s.content.blocks, t);
516
+ let i = d(a.content.blocks, t);
517
517
  if (i && i.type === "section") {
518
518
  i.children[n] = i.children[n] || [];
519
519
  let t = i.children[n];
520
520
  r !== void 0 && r < t.length ? t.splice(r, 0, e) : t.push(e);
521
521
  }
522
- } else r !== void 0 && r < s.content.blocks.length ? s.content.blocks.splice(r, 0, e) : s.content.blocks.push(e);
523
- s.isDirty = !0;
522
+ } else r !== void 0 && r < a.content.blocks.length ? a.content.blocks.splice(r, 0, e) : a.content.blocks.push(e);
523
+ a.isDirty = !0;
524
524
  }
525
525
  function w(e) {
526
526
  if (p(e)) return;
527
- let t = f(s.content.blocks, e);
527
+ let t = f(a.content.blocks, e);
528
528
  if (t) {
529
529
  let n = t.blocks.findIndex((t) => t.id === e);
530
- n !== -1 && (t.blocks.splice(n, 1), s.selectedBlockId === e && (s.selectedBlockId = null), s.isDirty = !0);
530
+ n !== -1 && (t.blocks.splice(n, 1), a.selectedBlockId === e && (a.selectedBlockId = null), a.isDirty = !0);
531
531
  }
532
532
  }
533
533
  function T(e, t, n, r = 0) {
534
- let i = f(s.content.blocks, e);
534
+ let i = f(a.content.blocks, e);
535
535
  if (!i) return;
536
- let a = i.blocks.findIndex((t) => t.id === e);
537
- if (a === -1) return;
538
- let [o] = i.blocks.splice(a, 1);
536
+ let o = i.blocks.findIndex((t) => t.id === e);
537
+ if (o === -1) return;
538
+ let [s] = i.blocks.splice(o, 1);
539
539
  if (n) {
540
- let e = d(s.content.blocks, n);
541
- e && e.type === "section" && (e.children[r] = e.children[r] || [], e.children[r].splice(t, 0, o));
542
- } else s.content.blocks.splice(t, 0, o);
543
- s.isDirty = !0;
540
+ let e = d(a.content.blocks, n);
541
+ e && e.type === "section" && (e.children[r] = e.children[r] || [], e.children[r].splice(t, 0, s));
542
+ } else a.content.blocks.splice(t, 0, s);
543
+ a.isDirty = !0;
544
544
  }
545
545
  async function E(t) {
546
- s.isLoading = !0;
546
+ a.isLoading = !0;
547
547
  try {
548
- t && (s.content = t);
549
- let e = await i.createTemplate(s.content);
550
- return s.template = e, s.isDirty = !1, e;
548
+ t && (a.content = t);
549
+ let e = await n.createTemplate(a.content);
550
+ return a.template = e, a.isDirty = !1, e;
551
551
  } catch (t) {
552
552
  throw e.onError?.(t), t;
553
553
  } finally {
554
- s.isLoading = !1;
554
+ a.isLoading = !1;
555
555
  }
556
556
  }
557
557
  async function D(t) {
558
- s.isLoading = !0;
558
+ a.isLoading = !0;
559
559
  try {
560
- let e = await i.getTemplate(t);
561
- return s.template = e, s.content = e.content, s.isDirty = !1, e;
560
+ let e = await n.getTemplate(t);
561
+ return a.template = e, a.content = e.content, a.isDirty = !1, e;
562
562
  } catch (t) {
563
563
  throw e.onError?.(t), t;
564
564
  } finally {
565
- s.isLoading = !1;
565
+ a.isLoading = !1;
566
566
  }
567
567
  }
568
568
  async function O() {
569
- if (!s.template?.id) throw new a("No template loaded. Call create() or load() before saving.");
570
- s.isSaving = !0;
569
+ if (!a.template?.id) throw new o("No template loaded. Call create() or load() before saving.");
570
+ a.isSaving = !0;
571
571
  try {
572
- let e = await i.updateTemplate(s.template.id, s.content);
573
- return s.template = e, s.isDirty = !1, e;
572
+ let e = await n.updateTemplate(a.template.id, a.content);
573
+ return a.template = e, a.isDirty = !1, e;
574
574
  } catch (t) {
575
575
  throw e.onError?.(t), t;
576
576
  } finally {
577
- s.isSaving = !1;
577
+ a.isSaving = !1;
578
578
  }
579
579
  }
580
580
  async function k() {
581
- if (s.template?.id) try {
582
- await i.createSnapshot(s.template.id, s.content);
581
+ if (a.template?.id) try {
582
+ await n.createSnapshot(a.template.id, a.content);
583
583
  } catch (t) {
584
584
  throw e.onError?.(t), t;
585
585
  }
586
586
  }
587
587
  function A() {
588
- return s.template?.id !== void 0;
588
+ return a.template?.id !== void 0;
589
589
  }
590
590
  function j() {
591
- s.isDirty = !0;
591
+ a.isDirty = !0;
592
592
  }
593
593
  return {
594
- state: n(s),
594
+ state: r(a),
595
595
  content: c,
596
596
  selectedBlock: l,
597
597
  savedBlockIds: u,
598
598
  isBlockLocked: p,
599
599
  setContent: m,
600
600
  selectBlock: h,
601
- setViewport: _,
601
+ setViewport: g,
602
602
  setDarkMode: v,
603
603
  setUiTheme: y,
604
604
  setPreviewMode: b,
@@ -615,12 +615,12 @@ function b(e) {
615
615
  markDirty: j
616
616
  };
617
617
  }
618
- var x = 0;
619
- function S() {
620
- return `msg_${Date.now()}_${++x}`;
618
+ var S = 0;
619
+ function C() {
620
+ return `msg_${Date.now()}_${++S}`;
621
621
  }
622
- function C(t) {
623
- let { authManager: n, getTemplateId: r, onApply: i, onError: a } = t, o = e([]), s = e(!1), l = e(!1), u = e(null), d = e(null), f = e(null), p = e(null), m = e(null), g = e(null), _ = e(!1), v = e([]), y = e(!1);
622
+ function w(t) {
623
+ let { authManager: n, getTemplateId: r, onApply: i, onError: a } = t, o = e([]), s = e(!1), c = e(!1), u = e(null), d = e(null), f = e(null), p = e(null), m = e(null), h = e(null), _ = e(!1), v = e([]), y = e(!1);
624
624
  function b(e, t) {
625
625
  let n = o.value.findIndex((t) => t.id === e);
626
626
  if (n === -1) return;
@@ -637,9 +637,9 @@ function C(t) {
637
637
  async function x() {
638
638
  let e = r();
639
639
  if (e) {
640
- l.value = !0;
640
+ c.value = !0;
641
641
  try {
642
- let t = c(h["ai.conversationMessages"], {
642
+ let t = l(g["ai.conversationMessages"], {
643
643
  project: n.projectId,
644
644
  tenant: n.tenantSlug,
645
645
  template: e
@@ -656,16 +656,16 @@ function C(t) {
656
656
  timestamp: new Date(e.created_at).getTime()
657
657
  })));
658
658
  } catch {} finally {
659
- l.value = !1;
659
+ c.value = !1;
660
660
  }
661
661
  }
662
662
  }
663
- async function C(e, t) {
663
+ async function S(e, t) {
664
664
  let i = r();
665
665
  if (i) {
666
666
  y.value = !0;
667
667
  try {
668
- let r = c(h["ai.suggestions"], {
668
+ let r = l(g["ai.suggestions"], {
669
669
  project: n.projectId,
670
670
  tenant: n.tenantSlug,
671
671
  template: i
@@ -686,13 +686,13 @@ function C(t) {
686
686
  if (!a.ok) return;
687
687
  let o = a.body?.getReader();
688
688
  if (!o) return;
689
- let s = new TextDecoder(), l = "";
689
+ let s = new TextDecoder(), c = "";
690
690
  for (;;) {
691
691
  let { done: e, value: t } = await o.read();
692
692
  if (e) break;
693
- l += s.decode(t, { stream: !0 });
694
- let n = l.split("\n");
695
- l = n.pop() ?? "";
693
+ c += s.decode(t, { stream: !0 });
694
+ let n = c.split("\n");
695
+ c = n.pop() ?? "";
696
696
  for (let e of n) {
697
697
  if (!e.startsWith("data: ")) continue;
698
698
  let t;
@@ -709,26 +709,26 @@ function C(t) {
709
709
  }
710
710
  }
711
711
  }
712
- async function w(e, t, l) {
712
+ async function w(e, t, c) {
713
713
  let y = r();
714
714
  if (!y) throw Error("Template must be saved before using AI generation");
715
715
  s.value = !0, u.value = null, d.value = null, v.value = [];
716
- let x = S();
716
+ let x = C();
717
717
  o.value = [...o.value, {
718
718
  id: x,
719
719
  role: "user",
720
720
  content: e,
721
721
  timestamp: Date.now()
722
722
  }];
723
- let C = S();
723
+ let S = C();
724
724
  o.value = [...o.value, {
725
- id: C,
725
+ id: S,
726
726
  role: "assistant",
727
727
  content: "",
728
728
  timestamp: Date.now()
729
729
  }];
730
730
  try {
731
- let r = c(h["ai.generate"], {
731
+ let r = l(g["ai.generate"], {
732
732
  project: n.projectId,
733
733
  tenant: n.tenantSlug,
734
734
  template: y
@@ -741,7 +741,7 @@ function C(t) {
741
741
  body: JSON.stringify({
742
742
  prompt: e,
743
743
  current_content: t,
744
- merge_tags: l.map((e) => ({
744
+ merge_tags: c.map((e) => ({
745
745
  label: e.label,
746
746
  value: e.value
747
747
  })),
@@ -755,43 +755,47 @@ function C(t) {
755
755
  let s = a.body?.getReader();
756
756
  if (!s) throw Error("Failed to read stream");
757
757
  let d = new TextDecoder(), v = "", x = null;
758
- for (;;) {
759
- let { done: e, value: n } = await s.read();
760
- if (e) break;
761
- v += d.decode(n, { stream: !0 });
762
- let r = v.split("\n");
763
- v = r.pop() ?? "";
764
- for (let e of r) {
765
- if (!e.startsWith("data: ")) continue;
766
- let n = e.slice(6), r;
767
- try {
768
- r = JSON.parse(n);
769
- } catch {
770
- continue;
758
+ try {
759
+ for (;;) {
760
+ let { done: e, value: n } = await s.read();
761
+ if (e) break;
762
+ v += d.decode(n, { stream: !0 });
763
+ let r = v.split("\n");
764
+ v = r.pop() ?? "";
765
+ for (let e of r) {
766
+ if (!e.startsWith("data: ")) continue;
767
+ let n = e.slice(6), r;
768
+ try {
769
+ r = JSON.parse(n);
770
+ } catch {
771
+ continue;
772
+ }
773
+ if (r.type === "text") b(S, { content: (o.value.find((e) => e.id === S)?.content ?? "") + r.text });
774
+ else if (r.type === "error") throw Error(r.message || "Failed to generate template");
775
+ else r.type === "done" && (r.conversation_id && (f.value = r.conversation_id), b(S, { content: r.text }), x = r.content ?? null, x ? (m.value = t, h.value = x, p.value = S, _.value = !1, i?.(x)) : u.value = "ai_apply_failed");
771
776
  }
772
- if (r.type === "text") b(C, { content: (o.value.find((e) => e.id === C)?.content ?? "") + r.text });
773
- else if (r.type === "error") throw Error(r.message || "Failed to generate template");
774
- else r.type === "done" && (r.conversation_id && (f.value = r.conversation_id), b(C, { content: r.text }), x = r.content ?? null, x ? (m.value = t, g.value = x, p.value = C, _.value = !1, i?.(x)) : u.value = "ai_apply_failed");
775
777
  }
778
+ } finally {
779
+ s.cancel().catch(() => {});
776
780
  }
777
781
  return x;
778
782
  } catch (t) {
779
783
  let n = t instanceof Error ? t : Error("Failed to generate template", { cause: t });
780
- return u.value = n.message, d.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== x && e.id !== C), null;
784
+ return u.value = n.message, d.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== x && e.id !== S), null;
781
785
  } finally {
782
786
  s.value = !1;
783
787
  }
784
788
  }
785
789
  function T() {
786
- _.value ? (g.value && i?.(g.value), _.value = !1) : (m.value && i?.(m.value), _.value = !0);
790
+ _.value ? (h.value && i?.(h.value), _.value = !1) : (m.value && i?.(m.value), _.value = !0);
787
791
  }
788
792
  function E() {
789
- o.value = [], f.value = null, u.value = null, p.value = null, m.value = null, g.value = null, _.value = !1;
793
+ o.value = [], f.value = null, u.value = null, p.value = null, m.value = null, h.value = null, _.value = !1;
790
794
  }
791
795
  return {
792
796
  messages: o,
793
797
  isGenerating: s,
794
- isLoadingHistory: l,
798
+ isLoadingHistory: c,
795
799
  isLastChangeReverted: _,
796
800
  lastApplyMessageId: p,
797
801
  error: u,
@@ -801,27 +805,27 @@ function C(t) {
801
805
  sendPrompt: w,
802
806
  toggleLastRevert: T,
803
807
  loadConversation: x,
804
- loadSuggestions: C,
808
+ loadSuggestions: S,
805
809
  clearChat: E
806
810
  };
807
811
  }
808
- function w(e) {
812
+ function T(e) {
809
813
  function t(t) {
810
814
  return e === !1 ? !1 : e?.[t] !== !1;
811
815
  }
812
816
  return {
813
817
  isFeatureEnabled: t,
814
- hasAnyMenuFeature: r(() => t("chat") || t("scoring") || t("designToTemplate"))
818
+ hasAnyMenuFeature: i(() => t("chat") || t("scoring") || t("designToTemplate"))
815
819
  };
816
820
  }
817
- function T(t) {
818
- let { authManager: n, getTemplateId: r } = t, i = e(!1), a = e(null), o = e(null), s = e(null), l = e(""), u = e(null);
821
+ function E(t) {
822
+ let { authManager: n, getTemplateId: r } = t, i = e(!1), a = e(null), o = e(null), s = e(null), c = e(""), u = e(null);
819
823
  async function d(e, t) {
820
824
  let s = r();
821
825
  if (!s) return null;
822
826
  i.value = !0, o.value = null, a.value = null;
823
827
  try {
824
- let r = c(h["ai.score"], {
828
+ let r = l(g["ai.score"], {
825
829
  project: n.projectId,
826
830
  tenant: n.tenantSlug,
827
831
  template: s
@@ -846,11 +850,11 @@ function T(t) {
846
850
  }
847
851
  let o = i.body?.getReader();
848
852
  if (!o) throw Error("Failed to read stream");
849
- let l = new TextDecoder(), u = "", d = null;
853
+ let c = new TextDecoder(), u = "", d = null;
850
854
  for (;;) {
851
855
  let { done: e, value: t } = await o.read();
852
856
  if (e) break;
853
- u += l.decode(t, { stream: !0 });
857
+ u += c.decode(t, { stream: !0 });
854
858
  let n = u.split("\n");
855
859
  u = n.pop() ?? "";
856
860
  for (let e of n) {
@@ -876,9 +880,9 @@ function T(t) {
876
880
  async function f(e, t, i) {
877
881
  let a = r();
878
882
  if (!a) return null;
879
- s.value = t.id, l.value = "", u.value = null;
883
+ s.value = t.id, c.value = "", u.value = null;
880
884
  try {
881
- let r = c(h["ai.fixFinding"], {
885
+ let r = l(g["ai.fixFinding"], {
882
886
  project: n.projectId,
883
887
  tenant: n.tenantSlug,
884
888
  template: a
@@ -924,7 +928,7 @@ function T(t) {
924
928
  } catch {
925
929
  continue;
926
930
  }
927
- if (t.type === "text") l.value += t.text;
931
+ if (t.type === "text") c.value += t.text;
928
932
  else if (t.type === "error") throw Error(t.message || "Failed to fix finding");
929
933
  else t.type === "done" && (f = t.content ?? null);
930
934
  }
@@ -942,14 +946,14 @@ function T(t) {
942
946
  n && (n.findings = n.findings.filter((e) => e.id !== t));
943
947
  }
944
948
  function m() {
945
- i.value = !1, a.value = null, o.value = null, s.value = null, l.value = "", u.value = null;
949
+ i.value = !1, a.value = null, o.value = null, s.value = null, c.value = "", u.value = null;
946
950
  }
947
951
  return {
948
952
  isScoring: i,
949
953
  scoringResult: a,
950
954
  error: o,
951
955
  fixingFindingId: s,
952
- fixStreamingText: l,
956
+ fixStreamingText: c,
953
957
  fixError: u,
954
958
  score: d,
955
959
  fixFinding: f,
@@ -957,16 +961,16 @@ function T(t) {
957
961
  reset: m
958
962
  };
959
963
  }
960
- function E(t) {
964
+ function D(t) {
961
965
  let { authManager: n, getTemplateId: r, onApply: i, onError: a } = t, o = e(!1), s = e(null);
962
- async function l(e) {
966
+ async function c(e) {
963
967
  let t = r();
964
968
  if (!t) throw Error("Template must be saved before using design reference");
965
969
  o.value = !0, s.value = null;
966
970
  try {
967
971
  let r = new FormData();
968
972
  e.prompt && r.append("prompt", e.prompt), e.imageUpload && r.append("image_upload", e.imageUpload), e.pdfUpload && r.append("pdf_upload", e.pdfUpload);
969
- let a = c(h["ai.generateFromDesign"], {
973
+ let a = l(g["ai.generateFromDesign"], {
970
974
  project: n.projectId,
971
975
  tenant: n.tenantSlug,
972
976
  template: t
@@ -981,11 +985,11 @@ function E(t) {
981
985
  }
982
986
  let s = o.body?.getReader();
983
987
  if (!s) throw Error("Failed to read stream");
984
- let l = new TextDecoder(), u = "", d = null;
988
+ let c = new TextDecoder(), u = "", d = null;
985
989
  for (;;) {
986
990
  let { done: e, value: t } = await s.read();
987
991
  if (e) break;
988
- u += l.decode(t, { stream: !0 });
992
+ u += c.decode(t, { stream: !0 });
989
993
  let n = u.split("\n");
990
994
  u = n.pop() ?? "";
991
995
  for (let e of n) {
@@ -1014,16 +1018,16 @@ function E(t) {
1014
1018
  return {
1015
1019
  isGenerating: o,
1016
1020
  error: s,
1017
- generate: l,
1021
+ generate: c,
1018
1022
  reset: u
1019
1023
  };
1020
1024
  }
1021
- function D(t) {
1022
- let { authManager: n, getTemplateId: i, getSocketId: a, onComment: o, onError: s, hasCommentingFeature: c } = t, l = new g(n), u = e([]), d = e(!1), f = e(!1), p = r(() => (c?.() ?? !1) && n.userConfig !== null), m = r(() => {
1025
+ function O(t) {
1026
+ let { authManager: n, getTemplateId: r, getSocketId: a, onComment: o, onError: s, hasCommentingFeature: c } = t, l = new _(n), u = e([]), d = e(!1), f = e(!1), p = i(() => (c?.() ?? !1) && n.userConfig !== null), m = i(() => {
1023
1027
  let e = 0;
1024
1028
  for (let t of u.value) e += 1 + (t.replies?.length ?? 0);
1025
1029
  return e;
1026
- }), h = r(() => u.value.filter((e) => !e.resolved_at).length), _ = r(() => {
1030
+ }), h = i(() => u.value.filter((e) => !e.resolved_at).length), g = i(() => {
1027
1031
  let e = /* @__PURE__ */ new Map();
1028
1032
  for (let t of u.value) t.block_id && e.set(t.block_id, (e.get(t.block_id) ?? 0) + 1 + (t.replies?.length ?? 0));
1029
1033
  return e;
@@ -1055,7 +1059,7 @@ function D(t) {
1055
1059
  return null;
1056
1060
  }
1057
1061
  async function S() {
1058
- let e = i();
1062
+ let e = r();
1059
1063
  if (e) {
1060
1064
  d.value = !0;
1061
1065
  try {
@@ -1069,11 +1073,11 @@ function D(t) {
1069
1073
  }
1070
1074
  }
1071
1075
  async function C(e, t, n) {
1072
- let r = i();
1073
- if (!r) return null;
1076
+ let i = r();
1077
+ if (!i) return null;
1074
1078
  f.value = !0;
1075
1079
  try {
1076
- let i = await l.createComment(r, {
1080
+ let r = await l.createComment(i, {
1077
1081
  body: e,
1078
1082
  block_id: t,
1079
1083
  parent_id: n,
@@ -1081,9 +1085,9 @@ function D(t) {
1081
1085
  }, y());
1082
1086
  if (n) {
1083
1087
  let e = x(n);
1084
- e && (e.replies = [...e.replies ?? [], i]);
1085
- } else u.value = [...u.value, i];
1086
- return b("created", i), i;
1088
+ e && (e.replies = [...e.replies ?? [], r]);
1089
+ } else u.value = [...u.value, r];
1090
+ return b("created", r), r;
1087
1091
  } catch (e) {
1088
1092
  let t = e instanceof Error ? e : Error("Failed to create comment", { cause: e });
1089
1093
  return s?.(t), null;
@@ -1092,7 +1096,7 @@ function D(t) {
1092
1096
  }
1093
1097
  }
1094
1098
  async function w(e, t) {
1095
- let n = i();
1099
+ let n = r();
1096
1100
  if (!n) return null;
1097
1101
  f.value = !0;
1098
1102
  try {
@@ -1109,11 +1113,11 @@ function D(t) {
1109
1113
  }
1110
1114
  }
1111
1115
  async function T(e) {
1112
- let t = i();
1116
+ let t = r();
1113
1117
  if (!t) return !1;
1114
1118
  let n = x(e);
1115
1119
  if (!n) return !1;
1116
- let r = {
1120
+ let i = {
1117
1121
  ...n,
1118
1122
  replies: [...n.replies ?? []]
1119
1123
  };
@@ -1123,7 +1127,7 @@ function D(t) {
1123
1127
  let t = x(n.parent_id);
1124
1128
  t && (t.replies = (t.replies ?? []).filter((t) => t.id !== e));
1125
1129
  } else u.value = u.value.filter((t) => t.id !== e);
1126
- return b("deleted", r), !0;
1130
+ return b("deleted", i), !0;
1127
1131
  } catch (e) {
1128
1132
  let t = e instanceof Error ? e : Error("Failed to delete comment", { cause: e });
1129
1133
  return s?.(t), !1;
@@ -1132,7 +1136,7 @@ function D(t) {
1132
1136
  }
1133
1137
  }
1134
1138
  async function E(e) {
1135
- let t = i();
1139
+ let t = r();
1136
1140
  if (!t) return null;
1137
1141
  f.value = !0;
1138
1142
  try {
@@ -1203,7 +1207,7 @@ function D(t) {
1203
1207
  isLoading: d,
1204
1208
  isSubmitting: f,
1205
1209
  isEnabled: p,
1206
- commentCountByBlock: _,
1210
+ commentCountByBlock: g,
1207
1211
  totalCount: m,
1208
1212
  unresolvedCount: h,
1209
1213
  loadComments: S,
@@ -1216,15 +1220,17 @@ function D(t) {
1216
1220
  applyRemoteDelete: k
1217
1221
  };
1218
1222
  }
1219
- function O(e) {
1220
- let { comments: t, channel: n } = e;
1221
- i(n, (e, n) => {
1223
+ function k(e) {
1224
+ let { comments: t, channel: r } = e;
1225
+ a(r, (e, n) => {
1222
1226
  n && n.unbind("comment-broadcast"), e && e.bind("comment-broadcast", (e) => {
1223
- k(t, e);
1227
+ A(t, e);
1224
1228
  });
1229
+ }), n(() => {
1230
+ r.value?.unbind("comment-broadcast");
1225
1231
  });
1226
1232
  }
1227
- function k(e, t) {
1233
+ function A(e, t) {
1228
1234
  switch (t.action) {
1229
1235
  case "comment_created":
1230
1236
  e.applyRemoteCreate(t.comment);
@@ -1241,7 +1247,18 @@ function k(e, t) {
1241
1247
  break;
1242
1248
  }
1243
1249
  }
1244
- var A = [
1250
+ var j = [
1251
+ "pusher:member_added",
1252
+ "pusher:member_removed",
1253
+ "client-block_locked",
1254
+ "client-block_unlocked",
1255
+ "client-operation",
1256
+ "mcp-operation"
1257
+ ];
1258
+ function M(e) {
1259
+ for (let t of j) e.unbind(t);
1260
+ }
1261
+ var N = [
1245
1262
  "#3b82f6",
1246
1263
  "#ef4444",
1247
1264
  "#10b981",
@@ -1253,110 +1270,112 @@ var A = [
1253
1270
  "#6366f1",
1254
1271
  "#14b8a6"
1255
1272
  ];
1256
- function j(t) {
1257
- let { authManager: n, editor: a, channel: o } = t, s = e([]), c = e(/* @__PURE__ */ new Map()), l = 0, u = !1, d = r(() => n.userConfig?.id ?? "");
1258
- function f() {
1259
- let e = A[l % A.length];
1260
- return l++, e;
1261
- }
1262
- function p(e) {
1263
- if (e.id === d.value || s.value.some((t) => t.id === e.id)) return;
1273
+ function P(t) {
1274
+ let { authManager: r, editor: o, channel: s } = t, c = e([]), l = e(/* @__PURE__ */ new Map()), u = 0, d = !1, f = i(() => r.userConfig?.id ?? "");
1275
+ function p() {
1276
+ let e = N[u % N.length];
1277
+ return u++, e;
1278
+ }
1279
+ function m(e) {
1280
+ if (e.id === f.value || c.value.some((t) => t.id === e.id)) return;
1264
1281
  let t = {
1265
1282
  id: e.id,
1266
1283
  name: e.name,
1267
- color: f(),
1284
+ color: p(),
1268
1285
  selectedBlockId: null
1269
1286
  };
1270
- return s.value = [...s.value, t], t;
1287
+ return c.value = [...c.value, t], t;
1271
1288
  }
1272
- function m(e) {
1273
- let t = new Map(c.value);
1289
+ function h(e) {
1290
+ let t = new Map(l.value);
1274
1291
  for (let [n, r] of t) r.id === e && t.delete(n);
1275
- c.value = t, s.value = s.value.filter((t) => t.id !== e);
1292
+ l.value = t, c.value = c.value.filter((t) => t.id !== e);
1276
1293
  }
1277
- function h(e) {
1278
- let t = s.value.find((t) => t.id === e.userId);
1294
+ function g(e) {
1295
+ let t = c.value.find((t) => t.id === e.userId);
1279
1296
  if (!t) return;
1280
- s.value = s.value.map((t) => t.id === e.userId ? {
1297
+ c.value = c.value.map((t) => t.id === e.userId ? {
1281
1298
  ...t,
1282
1299
  selectedBlockId: e.blockId
1283
1300
  } : t);
1284
- let n = new Map(c.value);
1301
+ let n = new Map(l.value);
1285
1302
  for (let [t, r] of n) r.id === e.userId && n.delete(t);
1286
1303
  n.set(e.blockId, {
1287
1304
  ...t,
1288
1305
  selectedBlockId: e.blockId
1289
- }), c.value = n, a.state.selectedBlockId === e.blockId && a.selectBlock(null);
1306
+ }), l.value = n, o.state.selectedBlockId === e.blockId && o.selectBlock(null);
1290
1307
  }
1291
- function g(e) {
1292
- let t = new Map(c.value), n = t.get(e.blockId);
1293
- t.delete(e.blockId), c.value = t, n && (s.value = s.value.map((e) => e.id === n.id ? {
1308
+ function _(e) {
1309
+ let t = new Map(l.value), n = t.get(e.blockId);
1310
+ t.delete(e.blockId), l.value = t, n && (c.value = c.value.map((e) => e.id === n.id ? {
1294
1311
  ...e,
1295
1312
  selectedBlockId: null
1296
1313
  } : e));
1297
1314
  }
1298
- function _(e) {
1299
- u = !0;
1315
+ function v(e) {
1316
+ d = !0;
1300
1317
  try {
1301
- y(a, e);
1318
+ b(o, e);
1302
1319
  } finally {
1303
- u = !1;
1320
+ d = !1;
1304
1321
  }
1305
1322
  }
1306
- function v(e) {
1307
- !o.value || u || o.value.trigger("client-operation", e);
1323
+ function y(e) {
1324
+ !s.value || d || s.value.trigger("client-operation", e);
1308
1325
  }
1309
- function b(e) {
1310
- o.value && o.value.trigger("client-block_locked", {
1326
+ function x(e) {
1327
+ s.value && s.value.trigger("client-block_locked", {
1311
1328
  blockId: e,
1312
- userId: d.value
1329
+ userId: f.value
1313
1330
  });
1314
1331
  }
1315
- function x(e) {
1316
- o.value && o.value.trigger("client-block_unlocked", { blockId: e });
1332
+ function S(e) {
1333
+ s.value && s.value.trigger("client-block_unlocked", { blockId: e });
1317
1334
  }
1318
- return i(() => a.state.selectedBlockId, (e, t) => {
1319
- u || (t && x(t), e && b(e));
1320
- }), i(o, (e, n) => {
1321
- if (n && (n.unbind("pusher:member_added"), n.unbind("pusher:member_removed"), n.unbind("client-block_locked"), n.unbind("client-block_unlocked"), n.unbind("client-operation"), n.unbind("mcp-operation")), !e) {
1322
- s.value = [], c.value = /* @__PURE__ */ new Map(), l = 0;
1335
+ return a(() => o.state.selectedBlockId, (e, t) => {
1336
+ d || (t && S(t), e && x(e));
1337
+ }), a(s, (e, n) => {
1338
+ if (n && M(n), !e) {
1339
+ c.value = [], l.value = /* @__PURE__ */ new Map(), u = 0;
1323
1340
  return;
1324
1341
  }
1325
1342
  let r = e.members;
1326
1343
  r && r.each((e) => {
1327
- p(e.info);
1344
+ m(e.info);
1328
1345
  }), e.bind("pusher:member_added", (e) => {
1329
- let n = p(e.info);
1346
+ let n = m(e.info);
1330
1347
  n && t.onCollaboratorJoined?.(n);
1331
1348
  }), e.bind("pusher:member_removed", (e) => {
1332
- let n = s.value.find((t) => t.id === e.id);
1333
- m(e.id), n && t.onCollaboratorLeft?.(n);
1349
+ let n = c.value.find((t) => t.id === e.id);
1350
+ h(e.id), n && t.onCollaboratorLeft?.(n);
1334
1351
  }), e.bind("client-block_locked", (e) => {
1335
- h(e);
1336
- let n = s.value.find((t) => t.id === e.userId);
1352
+ g(e);
1353
+ let n = c.value.find((t) => t.id === e.userId);
1337
1354
  n && t.onBlockLocked?.({
1338
1355
  blockId: e.blockId,
1339
1356
  collaborator: n
1340
1357
  });
1341
1358
  }), e.bind("client-block_unlocked", (e) => {
1342
- let n = c.value.get(e.blockId);
1343
- g(e), n && t.onBlockUnlocked?.({
1359
+ let n = l.value.get(e.blockId);
1360
+ _(e), n && t.onBlockUnlocked?.({
1344
1361
  blockId: e.blockId,
1345
1362
  collaborator: n
1346
1363
  });
1347
1364
  }), e.bind("client-operation", (e) => {
1348
- _(e);
1365
+ v(e);
1349
1366
  }), e.bind("mcp-operation", (e) => {
1350
- _(e);
1367
+ v(e);
1351
1368
  });
1369
+ }), n(() => {
1370
+ s.value && M(s.value);
1352
1371
  }), {
1353
- collaborators: s,
1354
- lockedBlocks: c,
1355
- _broadcastOperation: v,
1356
- _isProcessingRemoteOperation: () => u
1372
+ collaborators: c,
1373
+ lockedBlocks: l,
1374
+ _broadcastOperation: y,
1375
+ _isProcessingRemoteOperation: () => d
1357
1376
  };
1358
1377
  }
1359
- function M(e, t) {
1378
+ function F(e, t) {
1360
1379
  let n = e.addBlock, r = e.updateBlock, i = e.removeBlock, a = e.moveBlock, o = e.updateSettings, s = e.setContent;
1361
1380
  e.addBlock = (e, r, i) => {
1362
1381
  n(e, r, i), t._broadcastOperation({
@@ -1408,11 +1427,11 @@ function M(e, t) {
1408
1427
  });
1409
1428
  };
1410
1429
  }
1411
- function N(t) {
1430
+ function I(t) {
1412
1431
  let { authManager: n, onError: r } = t, i = e(null), a = e(!1), o = null, s = null;
1413
1432
  async function c(e, t) {
1414
1433
  if (o) return;
1415
- o = new v({
1434
+ o = new y({
1416
1435
  authManager: n,
1417
1436
  config: t,
1418
1437
  onError: r
@@ -1438,8 +1457,8 @@ function N(t) {
1438
1457
  getSocketId: u
1439
1458
  };
1440
1459
  }
1441
- function P(t) {
1442
- let n = new g(t.authManager), r = e([]), i = e(!1);
1460
+ function L(t) {
1461
+ let n = new _(t.authManager), r = e([]), i = e(!1);
1443
1462
  async function a(e) {
1444
1463
  i.value = !0;
1445
1464
  try {
@@ -1485,8 +1504,8 @@ function P(t) {
1485
1504
  deleteModule: c
1486
1505
  };
1487
1506
  }
1488
- function F(t) {
1489
- let n = new g(t.authManager), r = e([]), i = e(!1), a = e(!1);
1507
+ function R(t) {
1508
+ let n = new _(t.authManager), r = e([]), i = e(!1), a = e(!1);
1490
1509
  async function o() {
1491
1510
  i.value = !0;
1492
1511
  try {
@@ -1516,15 +1535,15 @@ function F(t) {
1516
1535
  restoreSnapshot: s
1517
1536
  };
1518
1537
  }
1519
- function I(t) {
1520
- let { authManager: n, getTemplateId: a, save: o, exportHtml: s, onError: c, isAuthReady: l, onBeforeTestEmail: u } = t, d = new g(n), f = e(!1), p = e(null), m = e(null);
1521
- l && i(l, (e) => {
1538
+ function z(t) {
1539
+ let { authManager: n, getTemplateId: r, save: o, exportHtml: s, onError: c, isAuthReady: l, onBeforeTestEmail: u } = t, d = new _(n), f = e(!1), p = e(null), m = e(null);
1540
+ l && a(l, (e) => {
1522
1541
  e && (m.value = n.testEmailConfig);
1523
1542
  }, { immediate: !0 });
1524
- let h = r(() => m.value !== null), _ = r(() => m.value?.allowedEmails ?? []);
1543
+ let h = i(() => m.value !== null), g = i(() => m.value?.allowedEmails ?? []);
1525
1544
  async function v(e) {
1526
1545
  if (!m.value) throw Error("Test email is not enabled for this project");
1527
- let t = a();
1546
+ let t = r();
1528
1547
  if (!t) throw Error("Template must be saved before sending a test email");
1529
1548
  f.value = !0, p.value = null;
1530
1549
  try {
@@ -1545,14 +1564,14 @@ function I(t) {
1545
1564
  }
1546
1565
  return {
1547
1566
  isEnabled: h,
1548
- allowedEmails: _,
1567
+ allowedEmails: g,
1549
1568
  isSending: f,
1550
1569
  error: p,
1551
1570
  sendTestEmail: v
1552
1571
  };
1553
1572
  }
1554
- function L(e) {
1555
- let { authManager: t, getFontsConfig: n, canUseCustomFonts: r } = e, i = new g(t);
1573
+ function B(e) {
1574
+ let { authManager: t, getFontsConfig: n, canUseCustomFonts: r } = e, i = new _(t);
1556
1575
  function a() {
1557
1576
  let e = n?.();
1558
1577
  return {
@@ -1576,8 +1595,8 @@ function L(e) {
1576
1595
  getMjmlSource: s
1577
1596
  };
1578
1597
  }
1579
- function R(t) {
1580
- let { authManager: n, onError: i } = t, a = e(null), o = e(!1), s = new g(n), c = r(() => a.value?.features ?? null);
1598
+ function V(t) {
1599
+ let { authManager: n, onError: r } = t, a = e(null), o = e(!1), s = new _(n), c = i(() => a.value?.features ?? null);
1581
1600
  function l(e) {
1582
1601
  return a.value?.features[e] ?? !1;
1583
1602
  }
@@ -1587,7 +1606,7 @@ function R(t) {
1587
1606
  try {
1588
1607
  a.value = await s.fetchConfig();
1589
1608
  } catch (e) {
1590
- i?.(e instanceof Error ? e : Error("Failed to fetch config", { cause: e }));
1609
+ r?.(e instanceof Error ? e : Error("Failed to fetch config", { cause: e }));
1591
1610
  } finally {
1592
1611
  o.value = !1;
1593
1612
  }
@@ -1601,14 +1620,14 @@ function R(t) {
1601
1620
  fetchConfig: u
1602
1621
  };
1603
1622
  }
1604
- var z = 5e3;
1605
- function B(e) {
1606
- return e.authManager ? e.authManager.resolveUrl(h.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${h.health}`;
1623
+ var H = 5e3;
1624
+ function U(e) {
1625
+ return e.authManager ? e.authManager.resolveUrl(g.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${g.health}`;
1607
1626
  }
1608
- async function V(e, t) {
1627
+ async function W(e, t) {
1609
1628
  let n = performance.now();
1610
1629
  try {
1611
- let r = t ? await t.authenticatedFetch(h.health, {
1630
+ let r = t ? await t.authenticatedFetch(g.health, {
1612
1631
  method: "GET",
1613
1632
  headers: { Accept: "application/json" }
1614
1633
  }) : await fetch(e, {
@@ -1657,7 +1676,7 @@ async function V(e, t) {
1657
1676
  };
1658
1677
  }
1659
1678
  }
1660
- async function H(e) {
1679
+ async function G(e) {
1661
1680
  if (!e?.host || !e?.app_key) return {
1662
1681
  ok: !1,
1663
1682
  error: "WebSocket configuration not available"
@@ -1668,24 +1687,33 @@ async function H(e) {
1668
1687
  };
1669
1688
  let t = `${e.port === 443 ? "wss" : "ws"}://${e.host}:${e.port}/app/${e.app_key}?protocol=7&client=js&version=8.4.0-rc2&flash=false`;
1670
1689
  return new Promise((e) => {
1671
- let n = setTimeout(() => {
1672
- r.close(), e({
1690
+ let n = null, r = setTimeout(() => {
1691
+ n?.close(), e({
1673
1692
  ok: !1,
1674
1693
  error: "WebSocket connection timed out"
1675
1694
  });
1676
- }, z), r = new WebSocket(t);
1677
- r.onopen = () => {
1678
- clearTimeout(n), r.close(), e({ ok: !0 });
1679
- }, r.onerror = () => {
1680
- clearTimeout(n), e({
1695
+ }, H);
1696
+ try {
1697
+ n = new WebSocket(t);
1698
+ } catch (t) {
1699
+ clearTimeout(r), e({
1700
+ ok: !1,
1701
+ error: t instanceof Error ? t.message : "WebSocket connection failed"
1702
+ });
1703
+ return;
1704
+ }
1705
+ n.onopen = () => {
1706
+ clearTimeout(r), n?.close(), e({ ok: !0 });
1707
+ }, n.onerror = () => {
1708
+ clearTimeout(r), e({
1681
1709
  ok: !1,
1682
1710
  error: "WebSocket connection failed"
1683
1711
  });
1684
1712
  };
1685
1713
  });
1686
1714
  }
1687
- async function U(e = {}) {
1688
- let t = await V(B(e), e.authManager), n = await H(t.wsConfig);
1715
+ async function K(e = {}) {
1716
+ let t = await W(U(e), e.authManager), n = await G(t.wsConfig);
1689
1717
  return {
1690
1718
  api: t.api,
1691
1719
  websocket: n,
@@ -1693,13 +1721,13 @@ async function U(e = {}) {
1693
1721
  overall: t.api.ok && t.auth.ok
1694
1722
  };
1695
1723
  }
1696
- function W(e) {
1724
+ function q(e) {
1697
1725
  let { editor: t, channel: n, onOperation: r } = e;
1698
- i(n, (e, n) => {
1726
+ a(n, (e, n) => {
1699
1727
  n && n.unbind("mcp-operation"), e && e.bind("mcp-operation", (e) => {
1700
- y(t, e), r?.(e);
1728
+ b(t, e), r?.(e);
1701
1729
  });
1702
1730
  });
1703
1731
  }
1704
1732
  //#endregion
1705
- export { T as _, w as a, O as c, b as d, L as f, F as g, P as h, C as i, D as l, R as m, U as n, j as o, W as p, _ as r, M as s, s as t, E as u, I as v, N as y };
1733
+ export { E as _, T as a, k as c, x as d, B as f, R as g, L as h, w as i, O as l, V as m, K as n, P as o, q as p, v as r, F as s, c as t, D as u, z as v, I as y };