@gui-chat-plugin/sequence 0.7.0 → 0.7.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.
@@ -200,32 +200,32 @@ var x = [
200
200
  "polarArea",
201
201
  "scatter",
202
202
  "bubble"
203
- ], oe = "https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.min.js", se = "sha384-jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ", ce = "\n(() => {\n const fail = (why) => {\n document.getElementById(\"chart-error\").textContent = why;\n document.documentElement.classList.add(\"failed\");\n };\n addEventListener(\"DOMContentLoaded\", () => {\n if (!window.Chart) return fail(\"The chart couldn't be drawn: Chart.js didn't load.\");\n let config;\n try {\n config = JSON.parse(document.getElementById(\"chart-config\").textContent);\n } catch {\n return fail(\"The chart couldn't be drawn: its configuration isn't valid.\");\n }\n Chart.defaults.font.size = 22;\n Chart.defaults.color = \"#334155\";\n Chart.defaults.animation.duration = 1200;\n config.options = { ...config.options, responsive: true, maintainAspectRatio: false };\n try {\n new Chart(document.getElementById(\"chart\"), config);\n } catch (error) {\n fail(\"The chart couldn't be drawn: \" + (error && error.message ? error.message : error));\n }\n });\n})();", le = [
203
+ ], S = "https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.min.js", oe = "sha384-jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ", se = "\n(() => {\n const fail = (why) => {\n document.getElementById(\"chart-error\").textContent = why;\n document.documentElement.classList.add(\"failed\");\n };\n addEventListener(\"DOMContentLoaded\", () => {\n if (!window.Chart) return fail(\"The chart couldn't be drawn: Chart.js didn't load.\");\n let config;\n try {\n config = JSON.parse(document.getElementById(\"chart-config\").textContent);\n } catch {\n return fail(\"The chart couldn't be drawn: its configuration isn't valid.\");\n }\n Chart.defaults.font.size = 22;\n Chart.defaults.color = \"#334155\";\n Chart.defaults.animation.duration = 1200;\n config.options = { ...config.options, responsive: true, maintainAspectRatio: false };\n try {\n new Chart(document.getElementById(\"chart\"), config);\n } catch (error) {\n fail(\"The chart couldn't be drawn: \" + (error && error.message ? error.message : error));\n }\n });\n})();", ce = [
204
204
  "default-src 'none'",
205
- `script-src 'sha256-TfZZxJX+yWgzYLy7zqsMa85OJEaC+zNLIpKLDZVnUqA=' ${oe}`,
205
+ `script-src 'sha256-TfZZxJX+yWgzYLy7zqsMa85OJEaC+zNLIpKLDZVnUqA=' ${S}`,
206
206
  "style-src 'unsafe-inline'",
207
207
  "img-src data: blob:",
208
208
  "connect-src 'none'",
209
209
  "form-action 'none'",
210
210
  "base-uri 'none'"
211
- ].join("; "), ue = `
211
+ ].join("; "), le = `
212
212
  html, body { margin: 0; width: ${t}px; height: 720px; overflow: hidden; background: #ffffff; color: #0f172a; font-family: ui-sans-serif, system-ui, sans-serif; }
213
213
  body { box-sizing: border-box; padding: 40px 64px 48px; display: flex; flex-direction: column; gap: 24px; }
214
214
  h1 { margin: 0; font-size: 52px; font-weight: 800; color: #1e3a8a; line-height: 1.15; text-align: center; }
215
215
  .chart { position: relative; flex: 1; min-height: 0; }
216
216
  #chart-error { display: none; margin: auto; font-size: 28px; color: #b91c1c; }
217
217
  .failed .chart { display: none; }
218
- .failed #chart-error { display: block; }`, de = (e) => JSON.stringify(e).replace(/</g, "\\u003c");
219
- function fe(e, t) {
218
+ .failed #chart-error { display: block; }`, ue = (e) => JSON.stringify(e).replace(/</g, "\\u003c");
219
+ function de(e, t) {
220
220
  return `<!doctype html>
221
221
  <html lang="en">
222
222
  <head>
223
223
  <meta charset="utf-8">
224
- <meta http-equiv="Content-Security-Policy" content="${le}">
225
- <style>${ue}</style>
226
- <script>${ce}<\/script>
227
- <script defer src="${oe}" integrity="${se}" crossorigin="anonymous"><\/script>
228
- <script type="application/json" id="chart-config">${de(t)}<\/script>
224
+ <meta http-equiv="Content-Security-Policy" content="${ce}">
225
+ <style>${le}</style>
226
+ <script>${se}<\/script>
227
+ <script defer src="${S}" integrity="${oe}" crossorigin="anonymous"><\/script>
228
+ <script type="application/json" id="chart-config">${ue(t)}<\/script>
229
229
  </head>
230
230
  <body>
231
231
  ${e ? `<h1>${p(e)}</h1>` : ""}
@@ -236,7 +236,7 @@ ${e ? `<h1>${p(e)}</h1>` : ""}
236
236
  }
237
237
  //#endregion
238
238
  //#region src/core/definitions.ts
239
- var pe = "presentSlide", me = "defineStoryboard", he = "presentPanel", ge = 4, _e = 12, ve = 3, S = /^[0-9a-f]{12}$/, C = (e) => typeof e == "object" && !!e && !Array.isArray(e), w = (e) => typeof e == "string" ? e.trim() : "", T = (e, t) => e.toLowerCase() === t.toLowerCase(), E = (e) => typeof e == "number" && Number.isInteger(e), D = "presentSlide needs slide and totalSlides (whole numbers, slide from 1 to totalSlides), and one of imagePrompt, imageUrl, html, markdown or chart", O = `presentSlide's slide is too long: keep its html, markdown or chart under ${r} characters`, k = `presentSlide's chart must be a Chart.js configuration: an object with type (${x.join(", ")}), data ({ labels, datasets }) and optionally options`;
239
+ var C = "presentSlide", w = "defineStoryboard", fe = "presentPanel", pe = 4, me = 12, he = 3, T = /^[0-9a-f]{12}$/, E = (e) => typeof e == "object" && !!e && !Array.isArray(e), D = (e) => typeof e == "string" ? e.trim() : "", O = (e, t) => e.toLowerCase() === t.toLowerCase(), k = (e) => typeof e == "number" && Number.isInteger(e), ge = "presentSlide needs slide and totalSlides (whole numbers, slide from 1 to totalSlides), and one of imagePrompt, imageUrl, html, markdown or chart", _e = `presentSlide's slide is too long: keep its html, markdown or chart under ${r} characters`, ve = `presentSlide's chart must be a Chart.js configuration: an object with type (${x.join(", ")}), data ({ labels, datasets }) and optionally options`;
240
240
  function ye(e) {
241
241
  let t = e;
242
242
  if (typeof t == "string") try {
@@ -244,45 +244,46 @@ function ye(e) {
244
244
  } catch {
245
245
  return null;
246
246
  }
247
- if (!C(t) || !C(t.data)) return null;
247
+ if (!E(t) || !E(t.data)) return null;
248
248
  let n = t.type;
249
- return !x.some((e) => e === n) || t.options !== void 0 && !C(t.options) ? null : t;
249
+ return !x.some((e) => e === n) || t.options !== void 0 && !E(t.options) ? null : t;
250
250
  }
251
- function A(e) {
252
- let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a = w(e.imageUrl), o = w(e.html), s = o ? "" : w(e.markdown), c = !o && !s && e.chart !== void 0 && e.chart !== null;
253
- if (!E(t) || !E(n) || t < 1 || n < t || !o && !s && !c && !w(i) && !a) return D;
251
+ function be(e) {
252
+ let { slide: t, totalSlides: n, title: r, imagePrompt: i } = e, a = D(e.imageUrl), o = D(e.html), s = o ? "" : D(e.markdown), c = !o && !s && e.chart !== void 0 && e.chart !== null;
253
+ if (!k(t) || !k(n) || t < 1 || n < t || !o && !s && !c && !D(i) && !a) return ge;
254
254
  let l = c ? ye(e.chart) : null;
255
- if (c && !l) return k;
256
- if (Math.max(o.length, s.length, l ? JSON.stringify(l).length : 0) > 6e4) return O;
255
+ if (c && !l) return ve;
256
+ if (Math.max(o.length, s.length, l ? JSON.stringify(l).length : 0) > 6e4) return _e;
257
257
  let u = !o && !s && !l, d = !!o && b(o), f = u || d || !!s;
258
258
  return {
259
259
  slide: t,
260
260
  totalSlides: n,
261
261
  title: typeof r == "string" ? r : "",
262
- imagePrompt: u ? typeof i == "string" ? i : "" : f ? w(i) : "",
262
+ imagePrompt: u ? typeof i == "string" ? i : "" : f ? D(i) : "",
263
263
  ...f && a && { imageUrl: a },
264
+ ...!f && a && { unplacedImageUrl: a },
264
265
  ...o && { html: o },
265
266
  ...s && { markdown: s },
266
267
  ...l && { chart: l },
267
268
  mode: e.mode === "steps" ? "steps" : "presentation"
268
269
  };
269
270
  }
270
- var j = "teach its subject as a presenter speaking to the audience, and cover everything on it: every section, point and number, in order, each in a sentence or more. The slide is replaced by the next one as soon as you stop talking, so a point you leave out is never explained. Begin with the content itself, never with the slide or your plan: no \"This slide is about…\", \"The first slide shows…\", \"Let's unpack this one\", \"Next, I'll…\". A line about the slide is not an explanation.", M = ({ slide: e, totalSlides: t, title: n, mode: r }) => {
271
+ var xe = "teach its subject as a presenter speaking to the audience, and cover everything on it: every section, point and number, in order, each in a sentence or more. The slide is replaced by the next one as soon as you stop talking, so a point you leave out is never explained. Begin with the content itself, never with the slide or your plan: no \"This slide is about…\", \"The first slide shows…\", \"Let's unpack this one\", \"Next, I'll…\". A line about the slide is not an explanation.", A = ({ slide: e, totalSlides: t, title: n, mode: r }) => {
271
272
  let i = n ? ` ("${n}")` : "";
272
273
  if (r === "steps") {
273
274
  let n = `Step ${e} of ${t}${i}`;
274
275
  return e < t ? `${n} is now on the screen. Say what to do in this step, directly ("Crack two eggs into a bowl…", not "This step is about eggs"), then stop and wait while the user does it. When they say they're ready (next, done, go on), call presentSlide for step ${e + 1} with mode "steps". If they ask to go back or to see a step again, call presentSlide for that step.` : `${n}, the last one, is now on the screen. Say what to do, directly, then wrap up the guide once the user is done.`;
275
276
  }
276
277
  let a = `Slide ${e} of ${t}${i}`;
277
- return e < t ? `${a} is now on the screen. Explain it: ${j} This reply is only the explanation: don't call presentSlide in it. When you have finished, you will be asked for slide ${e + 1}. If the user has asked you to stop, or asked something else, since the slideshow began, answer them instead of going on.` : `${a}, the last one, is now on the screen. Explain it: ${j} Then wrap up the slideshow.`;
278
- }, be = [
278
+ return e < t ? `${a} is now on the screen. Explain it: ${xe} This reply is only the explanation: don't call presentSlide in it. When you have finished, you will be asked for slide ${e + 1}. If the user has asked you to stop, or asked something else, since the slideshow began, answer them instead of going on.` : `${a}, the last one, is now on the screen. Explain it: ${xe} Then wrap up the slideshow.`;
279
+ }, Se = [
279
280
  `For an HTML slide: the slide's content, the inside of <body> only (no <html>, <head> or <body> tags), for a ${t}x720 px canvas, which it should fill (start with a <div class="w-full h-full ...">). Style it with Tailwind CSS v4 classes, which are loaded for you: a clear layout, a large title (text-6xl or so), few words in large type, a color scheme, and inline SVG or emoji for icons and diagrams. There is no network: no <img> from URLs, no links to follow. For one picture on the slide (a photo, a scene, an object beside the text), give imagePrompt (a generated picture) or imageUrl (a picture from the web) too and put <img src="${_}" alt="..." class="..."> where it goes, sized by its classes (for example class="w-1/2 h-full object-cover rounded-2xl").`,
280
281
  "Animate it so it builds up as you explain it, with MulmoCast's data-animation attributes (the same ones make it move in a movie of the slideshow): data-animation=\"animate\" with data-opacity=\"0,1\", data-translate-x, data-translate-y (px), data-scale, data-rotate (deg), data-width or data-height (\"0,80,%\"), each \"from,to\"; data-animation=\"counter\" with data-from, data-to, data-decimals, data-prefix, data-suffix; data-animation=\"typewriter\" (its text, or data-text). Give every one data-start and data-end in seconds, and optionally data-easing (linear, easeIn, easeOut, easeInOut); stagger the parts with later data-start values so they appear one after another over a few seconds (for example 0, 0.6, 1.2). Set the first frame inline too (style=\"opacity:0\" on an element that fades in).",
281
282
  "CSS animations, transitions and scripts don't play: animate only with data-animation. A <style> for layout is allowed (and Google Fonts by @import)."
282
- ].join(" "), xe = `For a Markdown slide: the slide in Markdown (GitHub's: headings, lists, bold, tables, code), with math in TeX between $...$ inline or $$...$$ for a displayed equation (on lines of its own). Start with a # heading, and keep it to what fits on one slide: a heading and a few lines, a list or an equation or two. Write a dollar sign that isn't math as \\$, and & % # inside \\text{} as \\& \\% \\#. For one picture on the slide, give imagePrompt (a generated picture) or imageUrl (a picture from the web) too and put ![what it shows](${_}) on a line of its own: the slide is then two columns, the text on the left and the picture on the right. Without imagePrompt, the alt text is what is drawn.`, Se = `For a chart slide, instead of imagePrompt (for numbers: real figures you have, never a picture of a chart): a Chart.js configuration as JSON text, {"type": ..., "data": ...}: { type, data: { labels, datasets: [{ label, data, backgroundColor }] }, options }. type is one of ${x.join(", ")}. It is drawn under the slide's title, so leave out options.plugins.title; give the datasets colors, and the axes titles (options.scales.x.title) when their units aren't obvious. JSON values only: no functions.`, N = "When the user asks for a slideshow (or to explain something with slides), plan four to six slides (more when the subject or your instructions need them), then show them one at a time with presentSlide: slide 1 first, and each next slide only after you have explained the one on the screen. Explain the subject, not the slides: say what the slide teaches, not that a slide is about it, and explain everything on a slide before showing the next; put on a slide only what you will explain. Go on to the last slide without asking whether to continue. A slide is a generated picture (imagePrompt), a chart (chart), a text slide in Markdown (markdown) or a designed slide in HTML (html): use a picture for a scene, an object or a place; a chart for numbers to compare, a trend or proportions; Markdown for equations and formulas (TeX math), definitions, short lists and small tables; and HTML for designed layouts, comparisons, timelines and diagrams. A picture model draws words, numbers and math badly, so they go on the other kinds; a slideshow can mix them. When a picture helps the text (the thing being explained, beside its key points), make an HTML or Markdown slide with one picture on it: imagePrompt for the picture, and {{image}} where it goes. When the slide is about a real, particular thing (a person, a building, a product, an artwork) and you have the address of a picture of it (an image file, from a search or the user), give that as imageUrl instead of imagePrompt: it is shown as it is. Numbers go on a chart slide: when you have figures (from a search, a document or the user: revenue, market share, growth, prices, counts over time), show them in a chart with those exact values, labelled with their units and the year or period, and say where they come from. Figures over time, shares of a whole or values side by side are a chart, not a list or table on a Markdown or HTML slide. Never make a chart, graph or table a picture (imagePrompt): a picture of a chart has made-up bars and no real numbers. A slideshow about a business, a market or a comparison of companies has its figures on chart slides, not only in text. Never invent figures; with none to show, leave the chart out. A slide holds only its subject, never notes about your work (what you searched for, that a search succeeded). When the user asks for HTML slides (slides in HTML, an HTML presentation), this is the tool: make them HTML slides with presentSlide, one call per slide, not one HTML page. When the user wants to be shown how to do something they will do along with you (cooking, folding, fixing, an exercise), make it a step-by-step guide instead: mode \"steps\", one slide per step, and after each step wait for the user to say they are ready. Use generateImage for a single picture, not for slides.", P = {
283
+ ].join(" "), Ce = `For a Markdown slide: the slide in Markdown (GitHub's: headings, lists, bold, tables, code), with math in TeX between $...$ inline or $$...$$ for a displayed equation (on lines of its own). Start with a # heading, and keep it to what fits on one slide: a heading and a few lines, a list or an equation or two. Write a dollar sign that isn't math as \\$, and & % # inside \\text{} as \\& \\% \\#. For one picture on the slide, give imagePrompt (a generated picture) or imageUrl (a picture from the web) too and put ![what it shows](${_}) on a line of its own: the slide is then two columns, the text on the left and the picture on the right. Without imagePrompt, the alt text is what is drawn.`, we = `For a chart slide, instead of imagePrompt (for numbers: real figures you have, never a picture of a chart): a Chart.js configuration as JSON text, {"type": ..., "data": ...}: { type, data: { labels, datasets: [{ label, data, backgroundColor }] }, options }. type is one of ${x.join(", ")}. It is drawn under the slide's title, so leave out options.plugins.title; give the datasets colors, and the axes titles (options.scales.x.title) when their units aren't obvious. JSON values only: no functions.`, Te = "When the user asks for a slideshow (or to explain something with slides), plan four to six slides (more when the subject or your instructions need them), then show them one at a time with presentSlide: slide 1 first, and each next slide only after you have explained the one on the screen. Explain the subject, not the slides: say what the slide teaches, not that a slide is about it, and explain everything on a slide before showing the next; put on a slide only what you will explain. Go on to the last slide without asking whether to continue. A slide is a generated picture (imagePrompt), a chart (chart), a text slide in Markdown (markdown) or a designed slide in HTML (html): use a picture for a scene, an object or a place; a chart for numbers to compare, a trend or proportions; Markdown for equations and formulas (TeX math), definitions, short lists and small tables; and HTML for designed layouts, comparisons, timelines and diagrams. A picture model draws words, numbers and math badly, so they go on the other kinds; a slideshow can mix them. When a picture helps the text (the thing being explained, beside its key points), make an HTML or Markdown slide with one picture on it: imagePrompt for the picture, and {{image}} where it goes. When the slide is about a real, particular thing (a person, a building, a product, an artwork) and you have the address of a picture of it or of a page about it (an image file, or an article from a search), give that as imageUrl instead of imagePrompt: the picture, or the preview picture of the page, is shown as it is. Numbers go on a chart slide: when you have figures (from a search, a document or the user: revenue, market share, growth, prices, counts over time), show them in a chart with those exact values, labelled with their units and the year or period, and say where they come from. Figures over time, shares of a whole or values side by side are a chart, not a list or table on a Markdown or HTML slide. Never make a chart, graph or table a picture (imagePrompt): a picture of a chart has made-up bars and no real numbers. A slideshow about a business, a market or a comparison of companies has its figures on chart slides, not only in text. Never invent figures; with none to show, leave the chart out. A slide holds only its subject, never notes about your work (what you searched for, that a search succeeded). When the user asks for HTML slides (slides in HTML, an HTML presentation), this is the tool: make them HTML slides with presentSlide, one call per slide, not one HTML page. When the user wants to be shown how to do something they will do along with you (cooking, folding, fixing, an exercise), make it a step-by-step guide instead: mode \"steps\", one slide per step, and after each step wait for the user to say they are ready. Use generateImage for a single picture, not for slides.", Ee = {
283
284
  type: "function",
284
- name: pe,
285
- prompt: N,
285
+ name: C,
286
+ prompt: Te,
286
287
  description: "Show one slide of a slideshow, full screen: a picture generated from imagePrompt or from the web (imageUrl), a chart (chart), a slide written in Markdown with TeX math (markdown), or a slide written in HTML (html). Give one of them; an HTML or Markdown slide can also hold one picture (imagePrompt or imageUrl, placed at {{image}}). Call it once per slide, in order, starting with slide 1. With mode \"steps\" it is a step-by-step guide: one slide per step, and the next step waits for the user.",
287
288
  parameters: {
288
289
  type: "object",
@@ -305,19 +306,19 @@ var j = "teach its subject as a presenter speaking to the audience, and cover ev
305
306
  },
306
307
  imageUrl: {
307
308
  type: "string",
308
- description: "A picture from the web, shown instead of a generated one: the https address of an image file (PNG, JPEG, GIF or WebP) of a real, particular thing, from a search or the user. Never an address you made up, or a web page's. With imagePrompt too, the picture is drawn from imagePrompt if the address can't be fetched. With html or markdown, it is the one picture placed where the slide has {{image}}."
309
+ description: "A picture from the web, shown instead of a generated one, of a real, particular thing: the https address of an image file (PNG, JPEG, GIF or WebP), or of a web page about it (an article from a search), whose preview picture is shown. Never an address you made up. With imagePrompt too, the picture is drawn from imagePrompt if the address can't be fetched. With html or markdown, it is the one picture placed where the slide has {{image}}, which the slide must have: without it, the picture isn't shown."
309
310
  },
310
311
  html: {
311
312
  type: "string",
312
- description: be
313
+ description: Se
313
314
  },
314
315
  markdown: {
315
316
  type: "string",
316
- description: xe
317
+ description: Ce
317
318
  },
318
319
  chart: {
319
320
  type: "string",
320
- description: Se
321
+ description: we
321
322
  },
322
323
  mode: {
323
324
  type: "string",
@@ -332,49 +333,49 @@ var j = "teach its subject as a presenter speaking to the audience, and cover ev
332
333
  ]
333
334
  }
334
335
  };
335
- function F(e) {
336
+ function De(e) {
336
337
  let { totalPanels: t } = e;
337
- if (!E(t) || t < 1 || t > 12) return "totalPanels must be a whole number from 1 to 12";
338
+ if (!k(t) || t < 1 || t > 12) return "totalPanels must be a whole number from 1 to 12";
338
339
  let n = [];
339
340
  for (let t of Array.isArray(e.characters) ? e.characters : []) {
340
- let e = C(t) ? w(t.name) : "", r = C(t) ? w(t.description) : "";
341
+ let e = E(t) ? D(t.name) : "", r = E(t) ? D(t.description) : "";
341
342
  if (!e || !r) return "every character needs a name and a description";
342
- if (n.some((t) => T(t.name, e))) return `two characters are named ${e}`;
343
+ if (n.some((t) => O(t.name, e))) return `two characters are named ${e}`;
343
344
  n.push({
344
345
  name: e,
345
346
  description: r
346
347
  });
347
348
  }
348
349
  return n.length < 1 || n.length > 4 ? "a storyboard has 1 to 4 characters" : {
349
- title: w(e.title),
350
- style: w(e.style),
350
+ title: D(e.title),
351
+ style: D(e.style),
351
352
  totalPanels: t,
352
353
  characters: n,
353
354
  interactive: e.interactive === !0
354
355
  };
355
356
  }
356
- var I = ({ title: e }) => `The cast of "${e}" is now on the screen. Introduce the characters briefly. This reply is only the introduction: don't call presentPanel in it. When you have finished, you will be asked for panel 1. If the user has asked you to stop, or asked something else, answer them instead of going on.`, L = "presentPanel needs a storyboardId, a panel number (from 1) and an imagePrompt";
357
- function R(e) {
358
- let { panel: t } = e, n = w(e.storyboardId), r = w(e.imagePrompt);
359
- if (!n || !r || !E(t) || t < 1) return null;
360
- let i = (e) => (Array.isArray(e) ? e : []).map(w).filter(Boolean);
357
+ var Oe = ({ title: e }) => `The cast of "${e}" is now on the screen. Introduce the characters briefly. This reply is only the introduction: don't call presentPanel in it. When you have finished, you will be asked for panel 1. If the user has asked you to stop, or asked something else, answer them instead of going on.`, j = "presentPanel needs a storyboardId, a panel number (from 1) and an imagePrompt";
358
+ function M(e) {
359
+ let { panel: t } = e, n = D(e.storyboardId), r = D(e.imagePrompt);
360
+ if (!n || !r || !k(t) || t < 1) return null;
361
+ let i = (e) => (Array.isArray(e) ? e : []).map(D).filter(Boolean);
361
362
  return {
362
363
  storyboardId: n,
363
364
  panel: t,
364
365
  characters: i(e.characters),
365
366
  imagePrompt: r,
366
- caption: w(e.caption),
367
+ caption: D(e.caption),
367
368
  choices: i(e.choices).slice(0, 3)
368
369
  };
369
370
  }
370
- function z(e, t, n) {
371
+ function N(e, t, n) {
371
372
  let { id: r, totalPanels: i } = e;
372
373
  return n.length ? `Panel ${t} of ${i} is now on the screen, with the user's choices: ${n.map((e, t) => `${t + 1}. ${e}`).join(" ")} Tell this part of the story, then read the choices out and ask the user which one they pick, and wait for their answer. Then call presentPanel for panel ${t + 1} with storyboardId "${r}", going on the way they chose.` : t < i ? `Panel ${t} of ${i} is now on the screen. Tell this part of the story, aloud, as a storyteller. This reply is only the telling: don't call presentPanel in it. When you have finished, you will be asked for panel ${t + 1}. If the user has asked you to stop, or asked something else, since the story began, answer them instead of going on.` : `Panel ${t} of ${i}, the last one, is now on the screen. Tell this part of the story, then bring it to an end.`;
373
374
  }
374
- var B = "When the user asks for a story, a picture book, a comic or a storyboard, tell it in pictures: first call defineStoryboard with the art style and the characters who appear more than once (it draws a reference sheet for each, so they look the same in every panel), then show the panels one at a time with presentPanel, naming the characters in each, and tell each part of the story when its panel appears. Go on to the last panel without asking whether to continue, unless the story is interactive. When the user wants to decide what happens (an adventure, a story for a child who wants to choose), set interactive, and give two or three choices on two or three of the panels: the story waits there for the user's pick and goes on their way; it still ends at the last panel whichever way it goes. Use presentSlide to explain a topic, not to tell a story.", Ce = {
375
+ var P = "When the user asks for a story, a picture book, a comic or a storyboard, tell it in pictures: first call defineStoryboard with the art style and the characters who appear more than once (it draws a reference sheet for each, so they look the same in every panel), then show the panels one at a time with presentPanel, naming the characters in each, and tell each part of the story when its panel appears. Go on to the last panel without asking whether to continue, unless the story is interactive. When the user wants to decide what happens (an adventure, a story for a child who wants to choose), set interactive, and give two or three choices on two or three of the panels: the story waits there for the user's pick and goes on their way; it still ends at the last panel whichever way it goes. Use presentSlide to explain a topic, not to tell a story.", F = {
375
376
  type: "function",
376
- name: me,
377
- prompt: B,
377
+ name: w,
378
+ prompt: P,
378
379
  description: "Start a story told in pictures: set its art style and draw a reference sheet for each recurring character, shown as the cast. Then call presentPanel for each panel, in order.",
379
380
  parameters: {
380
381
  type: "object",
@@ -421,9 +422,9 @@ var B = "When the user asks for a story, a picture book, a comic or a storyboard
421
422
  "characters"
422
423
  ]
423
424
  }
424
- }, we = {
425
+ }, I = {
425
426
  type: "function",
426
- name: he,
427
+ name: fe,
427
428
  description: "Show one panel of a storyboard made with defineStoryboard: a picture of the scene with its characters drawn as in their reference sheets, and a caption. Call it once per panel, in order, starting with panel 1.",
428
429
  parameters: {
429
430
  type: "object",
@@ -462,60 +463,60 @@ var B = "When the user asks for a story, a picture book, a comic or a storyboard
462
463
  "imagePrompt"
463
464
  ]
464
465
  }
465
- }, V = (e) => typeof e == "object" && !!e && !Array.isArray(e), Te = (e) => V(e) && typeof e.message == "string";
466
- function H(e) {
467
- let t = V(e?.data) ? e.data : {};
466
+ }, L = (e) => typeof e == "object" && !!e && !Array.isArray(e), ke = (e) => L(e) && typeof e.message == "string";
467
+ function R(e) {
468
+ let t = L(e?.data) ? e.data : {};
468
469
  return {
469
470
  ...typeof t.imageData == "string" && { imageData: t.imageData },
470
471
  ...typeof t.imagePath == "string" && { imagePath: t.imagePath }
471
472
  };
472
473
  }
473
- function U(e) {
474
- let t = V(e?.data) ? e.data : {};
474
+ function z(e) {
475
+ let t = L(e?.data) ? e.data : {};
475
476
  return typeof t.html == "string" ? t.html : "";
476
477
  }
477
- function W(e) {
478
- let t = V(e?.data) ? e.data : {};
479
- return V(t.chart) ? JSON.stringify(t.chart) : "";
478
+ function B(e) {
479
+ let t = L(e?.data) ? e.data : {};
480
+ return L(t.chart) ? JSON.stringify(t.chart) : "";
480
481
  }
481
- var Ee = (e) => !!H(e).imageData || !!U(e) || !!W(e);
482
- function De(e, t) {
483
- let n = H(e), r = H(t);
482
+ var Ae = (e) => !!R(e).imageData || !!z(e) || !!B(e);
483
+ function je(e, t) {
484
+ let n = R(e), r = R(t);
484
485
  if (n.imagePath && r.imagePath) return n.imagePath === r.imagePath;
485
486
  if (n.imageData) return n.imageData === r.imageData;
486
- let i = U(e);
487
- if (i) return i === U(t);
488
- let a = W(e);
489
- return !!a && a === W(t);
487
+ let i = z(e);
488
+ if (i) return i === z(t);
489
+ let a = B(e);
490
+ return !!a && a === B(t);
490
491
  }
491
- var Oe = (e, t) => e.userSpokeAt === void 0 || e.userSpokeAt > t, ke = () => crypto.randomUUID().replace(/-/g, "").slice(0, 12), Ae = "artifacts/";
492
- async function je(e, t) {
492
+ var V = (e, t) => e.userSpokeAt === void 0 || e.userSpokeAt > t, H = () => crypto.randomUUID().replace(/-/g, "").slice(0, 12), Me = "artifacts/";
493
+ async function U(e, t) {
493
494
  let n = e.files?.artifacts;
494
495
  if (!e.app?.editImages || !n) return [];
495
496
  let r = [];
496
- for (let e of t) if (e.startsWith(Ae)) try {
497
+ for (let e of t) if (e.startsWith(Me)) try {
497
498
  await n.exists(e.slice(10)) && r.push(e);
498
499
  } catch {}
499
500
  return r;
500
501
  }
501
- async function G(e, t, n = []) {
502
+ async function W(e, t, n = []) {
502
503
  let r = e.app, i = r?.editImages, a = r?.generateImage;
503
504
  try {
504
505
  let e;
505
506
  if (n.length && i) e = await i(t, [...n]);
506
507
  else if (a) e = await a(t);
507
508
  else return { message: "image generation isn't available" };
508
- return Te(e) ? e : { message: "image generation returned an unrecognized result" };
509
+ return ke(e) ? e : { message: "image generation returned an unrecognized result" };
509
510
  } catch (e) {
510
511
  return { message: `image generation failed: ${e instanceof Error ? e.message : String(e)}` };
511
512
  }
512
513
  }
513
- var Me = 50;
514
- function Ne(e) {
514
+ var Ne = 50;
515
+ function G(e) {
515
516
  let t = /* @__PURE__ */ new Map();
516
517
  return (n) => {
517
518
  let r = n.conversationId ?? "", i = t.get(r);
518
- if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size > Me) {
519
+ if (i === void 0 ? i = e() : t.delete(r), t.set(r, i), t.size > Ne) {
519
520
  let e = t.keys().next().value;
520
521
  e !== void 0 && t.delete(e);
521
522
  }
@@ -557,12 +558,12 @@ var K = "slide-md", Pe = "slide-md-split", q = "slide-md-text", Fe = "slide-md-p
557
558
  .${K} mtd:first-child { padding-left: 0; }
558
559
  .${K} mtd:last-child { padding-right: 0; }
559
560
  .${K} .math-error { color: #b91c1c; font-family: ui-monospace, monospace; }`;
560
- function J(e) {
561
+ function Re(e) {
561
562
  let t = e.split("\n").filter((e) => e.trim()).length, n = e.length;
562
563
  return t <= 5 && n <= 250 ? 40 : t <= 8 && n <= 450 ? 34 : t <= 12 && n <= 700 ? 28 : 24;
563
564
  }
564
- var Re = /^[ \t]*(?:\$\$([\s\S]+?)\$\$|\\\[([\s\S]+?)\\\])[ \t]*(?:\n|$)/, ze = /^(?:\$\$(.+?)\$\$|\$(?!\s)((?:\\.|[^\\$\n])+?)(?<!\s)\$(?!\d)|\\\((.+?)\\\))/;
565
- function Be(e) {
565
+ var ze = /^[ \t]*(?:\$\$([\s\S]+?)\$\$|\\\[([\s\S]+?)\\\])[ \t]*(?:\n|$)/, Be = /^(?:\$\$(.+?)\$\$|\$(?!\s)((?:\\.|[^\\$\n])+?)(?<!\s)\$(?!\d)|\\\((.+?)\\\))/;
566
+ function Ve(e) {
566
567
  return [{
567
568
  name: "blockMath",
568
569
  level: "block",
@@ -571,7 +572,7 @@ function Be(e) {
571
572
  return t ? t.index + (t[1] ?? "").length : void 0;
572
573
  },
573
574
  tokenizer(e) {
574
- let t = Re.exec(e);
575
+ let t = ze.exec(e);
575
576
  if (t) return {
576
577
  type: "blockMath",
577
578
  raw: t[0],
@@ -584,7 +585,7 @@ function Be(e) {
584
585
  level: "inline",
585
586
  start: (e) => e.match(/(?<!\\)\$|\\\(/)?.index,
586
587
  tokenizer(e) {
587
- let t = ze.exec(e);
588
+ let t = Be.exec(e);
588
589
  if (t) return {
589
590
  type: "inlineMath",
590
591
  raw: t[0],
@@ -595,9 +596,9 @@ function Be(e) {
595
596
  renderer: (t) => e(String(t.text), t.display === !0)
596
597
  }];
597
598
  }
598
- var Ve = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="normal")?>[A-Za-z]{2,}<\/mi>)<mo>\u2061<\/mo>/g, He = "<mspace width=\"0.1667em\"></mspace>", Ue = (e) => e.replace(Ve, (e, t, n) => `${t ? t + He : ""}${n}<mo lspace="0" rspace="0.1667em">\u2061</mo>`), We = /\\(?:text(?:bf|it|rm|sf|tt|normal)?|mbox)\s*\{/g, Ge = (e) => {
599
+ var He = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="normal")?>[A-Za-z]{2,}<\/mi>)<mo>\u2061<\/mo>/g, Ue = "<mspace width=\"0.1667em\"></mspace>", We = (e) => e.replace(He, (e, t, n) => `${t ? t + Ue : ""}${n}<mo lspace="0" rspace="0.1667em">\u2061</mo>`), Ge = /\\(?:text(?:bf|it|rm|sf|tt|normal)?|mbox)\s*\{/g, Ke = (e) => {
599
600
  let t = "", n = 0;
600
- for (let r of e.matchAll(We)) {
601
+ for (let r of e.matchAll(Ge)) {
601
602
  let i = r.index + r[0].length;
602
603
  if (i <= n) continue;
603
604
  let a = 1, o = i;
@@ -606,10 +607,10 @@ var Ve = /(<\/mi>|<\/mn>|<\/mrow>|<mo[^>]*>[)\]]<\/mo>)?(<mi(?: mathvariant="nor
606
607
  }
607
608
  return t + e.slice(n);
608
609
  };
609
- async function Ke(e) {
610
+ async function qe(e) {
610
611
  let [{ Marked: t }, { default: n }] = await Promise.all([import("marked"), import("katex")]), r = (e, t) => {
611
612
  try {
612
- return Ue(n.renderToString(Ge(e), {
613
+ return We(n.renderToString(Ke(e), {
613
614
  output: "mathml",
614
615
  displayMode: t,
615
616
  throwOnError: !0
@@ -621,7 +622,7 @@ async function Ke(e) {
621
622
  gfm: !0,
622
623
  breaks: !1
623
624
  });
624
- i.use({ extensions: Be(r) });
625
+ i.use({ extensions: Ve(r) });
625
626
  let a = i.lexer(e), o = a.findIndex((e) => {
626
627
  if (e.type !== "paragraph" || e.tokens?.length !== 1) return !1;
627
628
  let t = e.tokens[0];
@@ -630,7 +631,7 @@ async function Ke(e) {
630
631
  if (o >= 0) {
631
632
  let [t] = a.splice(o, 1), n = t?.type === "paragraph" ? t.tokens?.[0] : void 0, r = n?.type === "image" ? n.text : "", s = i.parser(a), c = e.replace(t?.raw ?? "", "");
632
633
  return `<style>${Le}</style>
633
- <div class="${K} ${Pe}" data-fit style="font-size: ${Math.round(J(c) * Ie)}px">
634
+ <div class="${K} ${Pe}" data-fit style="font-size: ${Math.round(Re(c) * Ie)}px">
634
635
  <div class="${q}">
635
636
  ${s}</div>
636
637
  <img class="${Fe}" src="${_}" alt="${p(r)}">
@@ -638,25 +639,25 @@ ${s}</div>
638
639
  }
639
640
  let s = await i.parse(e);
640
641
  return `<style>${Le}</style>
641
- <div class="${K}" data-fit style="font-size: ${J(e)}px">
642
+ <div class="${K}" data-fit style="font-size: ${Re(e)}px">
642
643
  ${s}</div>`;
643
644
  }
644
645
  //#endregion
645
646
  //#region src/core/records.ts
646
- var qe = "slideshows", Y = "storyboards", Je = {}, Ye = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap();
647
- function Ze(e) {
648
- let t = Ye.get(e);
649
- return t || Ye.set(e, t = /* @__PURE__ */ new Map()), t;
647
+ var Je = "slideshows", J = "storyboards", Ye = {}, Xe = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap();
648
+ function Qe(e) {
649
+ let t = Xe.get(e);
650
+ return t || Xe.set(e, t = /* @__PURE__ */ new Map()), t;
650
651
  }
651
- function Qe(t, n) {
652
- let r = Xe.get(t);
653
- r || Xe.set(t, r = /* @__PURE__ */ new Map());
652
+ function $e(t, n) {
653
+ let r = Ze.get(t);
654
+ r || Ze.set(t, r = /* @__PURE__ */ new Map());
654
655
  let i = r.get(n);
655
656
  return i || r.set(n, i = e()), i;
656
657
  }
657
- var $e = (e, t) => `${e}/${t}.json`;
658
- async function et(e, t) {
659
- let n = Ze(e ?? Je), r = n.get(t);
658
+ var et = (e, t) => `${e}/${t}.json`;
659
+ async function tt(e, t) {
660
+ let n = Qe(e ?? Ye), r = n.get(t);
660
661
  if (r) return r;
661
662
  if (!e) return null;
662
663
  try {
@@ -666,14 +667,14 @@ async function et(e, t) {
666
667
  return null;
667
668
  }
668
669
  }
669
- async function tt(e, t, n) {
670
- return S.test(n) ? et(e, $e(t, n)) : null;
670
+ async function nt(e, t, n) {
671
+ return T.test(n) ? tt(e, et(t, n)) : null;
671
672
  }
672
- async function X(e, t, n, r) {
673
- let i = $e(t, n), a = e ?? Je;
674
- return Qe(a, i)(async () => {
675
- let t = r(await et(e, i));
676
- if (Ze(a).set(i, t), !e) return !1;
673
+ async function Y(e, t, n, r) {
674
+ let i = et(t, n), a = e ?? Ye;
675
+ return $e(a, i)(async () => {
676
+ let t = r(await tt(e, i));
677
+ if (Qe(a).set(i, t), !e) return !1;
677
678
  try {
678
679
  return await e.write(i, JSON.stringify(t, null, 2)), !0;
679
680
  } catch (e) {
@@ -681,12 +682,12 @@ async function X(e, t, n, r) {
681
682
  }
682
683
  });
683
684
  }
684
- var Z = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`, nt = 6e4;
685
- function rt() {
685
+ var X = (e) => `the ${e} could not be saved, so it lasts only until the app or server restarts`, rt = 6e4;
686
+ function it() {
686
687
  let e = /* @__PURE__ */ new Map();
687
688
  return { claim: (t) => {
688
689
  let n = Date.now();
689
- for (let [t, r] of e) n - r.at > nt && e.delete(t);
690
+ for (let [t, r] of e) n - r.at > rt && e.delete(t);
690
691
  let r = e.get(t);
691
692
  if (r) return { earlier: r.shown };
692
693
  let i = () => void 0, a = new Promise((e) => i = e);
@@ -700,16 +701,16 @@ function rt() {
700
701
  }
701
702
  //#endregion
702
703
  //#region src/core/webImage.ts
703
- var it = 1e4, at = 5242880, ot = 3, st = "images", ct = "artifacts/";
704
- function lt(e) {
704
+ var at = 1e4, ot = 5242880, st = 3, ct = "images", lt = "artifacts/";
705
+ function ut(e) {
705
706
  if (e.protocol !== "https:") return "only https URLs are fetched";
706
707
  if (e.username || e.password) return "a URL with a password isn't fetched";
707
708
  let t = e.hostname.toLowerCase().replace(/\.$/, "");
708
709
  return t.startsWith("[") || /^\d+\.\d+\.\d+\.\d+$/.test(t) ? "a URL with an IP address isn't fetched" : !t.includes(".") || /\.(localhost|local|internal|lan|home\.arpa)$/.test(t) ? "a URL on a local network isn't fetched" : null;
709
710
  }
710
- var Q = (e, t, n = 0) => t.every((t, r) => e[n + r] === t);
711
- function ut(e) {
712
- return Q(e, [
711
+ var Z = (e, t, n = 0) => t.every((t, r) => e[n + r] === t);
712
+ function dt(e) {
713
+ return Z(e, [
713
714
  137,
714
715
  80,
715
716
  78,
@@ -721,14 +722,14 @@ function ut(e) {
721
722
  ]) ? {
722
723
  mime: "image/png",
723
724
  extension: "png"
724
- } : Q(e, [
725
+ } : Z(e, [
725
726
  255,
726
727
  216,
727
728
  255
728
729
  ]) ? {
729
730
  mime: "image/jpeg",
730
731
  extension: "jpg"
731
- } : Q(e, [
732
+ } : Z(e, [
732
733
  71,
733
734
  73,
734
735
  70,
@@ -736,12 +737,12 @@ function ut(e) {
736
737
  ]) ? {
737
738
  mime: "image/gif",
738
739
  extension: "gif"
739
- } : Q(e, [
740
+ } : Z(e, [
740
741
  82,
741
742
  73,
742
743
  70,
743
744
  70
744
- ]) && Q(e, [
745
+ ]) && Z(e, [
745
746
  87,
746
747
  69,
747
748
  66,
@@ -751,14 +752,14 @@ function ut(e) {
751
752
  extension: "webp"
752
753
  } : null;
753
754
  }
754
- function dt(e) {
755
+ function ft(e) {
755
756
  let t = "", n = 32768;
756
757
  for (let r = 0; r < e.length; r += n) t += String.fromCharCode(...e.subarray(r, r + n));
757
758
  return btoa(t);
758
759
  }
759
- var $ = (e) => e.body?.cancel().catch(() => void 0) ?? Promise.resolve();
760
- async function ft(e) {
761
- if (Number(e.headers.get("content-length")) > 5242880) return await $(e), null;
760
+ var Q = (e) => e.body?.cancel().catch(() => void 0) ?? Promise.resolve();
761
+ async function pt(e) {
762
+ if (Number(e.headers.get("content-length")) > 5242880) return await Q(e), null;
762
763
  if (!e.body) {
763
764
  let t = new Uint8Array(await e.arrayBuffer());
764
765
  return t.length > 5242880 ? null : t;
@@ -774,7 +775,30 @@ async function ft(e) {
774
775
  for (let e of n) i.set(e, a), a += e.length;
775
776
  return i;
776
777
  }
777
- async function pt(e, t) {
778
+ var mt = [
779
+ "og:image:secure_url",
780
+ "og:image:url",
781
+ "og:image",
782
+ "twitter:image",
783
+ "twitter:image:src"
784
+ ], ht = /([a-z:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/gi, gt = (e, t) => t <= 1114111 ? String.fromCodePoint(t) : e, _t = (e) => e.replace(/&#x([0-9a-f]+);/gi, (e, t) => gt(e, parseInt(t, 16))).replace(/&#(\d+);/g, (e, t) => gt(e, Number(t))).replace(/&quot;/g, "\"").replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
785
+ function vt(e, t) {
786
+ let n = /* @__PURE__ */ new Map();
787
+ for (let [t] of e.matchAll(/<meta\b[^>]*>/gi)) {
788
+ let e = /* @__PURE__ */ new Map();
789
+ for (let [, n, r, i, a] of t.matchAll(ht)) n && e.set(n.toLowerCase(), r ?? i ?? a ?? "");
790
+ let r = (e.get("property") ?? e.get("name") ?? "").toLowerCase(), i = _t(e.get("content") ?? "").trim();
791
+ i && !n.has(r) && n.set(r, i);
792
+ }
793
+ for (let e of mt) {
794
+ let r = n.get(e);
795
+ if (r) try {
796
+ return new URL(r, t).href;
797
+ } catch {}
798
+ }
799
+ return null;
800
+ }
801
+ async function yt(e, t) {
778
802
  let n;
779
803
  try {
780
804
  n = new URL(e);
@@ -782,7 +806,7 @@ async function pt(e, t) {
782
806
  return "it isn't a URL";
783
807
  }
784
808
  for (let e = 0;; e++) {
785
- let r = lt(n);
809
+ let r = ut(n);
786
810
  if (r) return r;
787
811
  let i = await fetch(n, {
788
812
  redirect: "manual",
@@ -790,45 +814,64 @@ async function pt(e, t) {
790
814
  credentials: "omit",
791
815
  referrerPolicy: "no-referrer"
792
816
  });
793
- if (i.type === "opaqueredirect") return fetch(n, {
794
- signal: t,
795
- credentials: "omit",
796
- referrerPolicy: "no-referrer"
797
- });
817
+ if (i.type === "opaqueredirect") {
818
+ let e = await fetch(n, {
819
+ signal: t,
820
+ credentials: "omit",
821
+ referrerPolicy: "no-referrer"
822
+ });
823
+ return {
824
+ response: e,
825
+ url: e.url || n.href
826
+ };
827
+ }
798
828
  let a = i.headers.get("location");
799
- if (i.status < 300 || i.status >= 400 || !a) return i;
800
- if (await $(i), e >= ot) return "it redirects too many times";
829
+ if (i.status < 300 || i.status >= 400 || !a) return {
830
+ response: i,
831
+ url: n.href
832
+ };
833
+ if (await Q(i), e >= st) return "it redirects too many times";
801
834
  n = new URL(a, n);
802
835
  }
803
836
  }
804
- async function mt(e, t) {
805
- let n;
837
+ async function $(e, t, n = !1) {
838
+ let r, i;
806
839
  try {
807
- let t = await pt(e, AbortSignal.timeout(it));
840
+ let t = await yt(e, AbortSignal.timeout(at));
808
841
  if (typeof t == "string") return { error: t };
809
- if (!t.ok) return await $(t), { error: `the site answered ${t.status}` };
810
- n = await ft(t);
842
+ let { response: n } = t;
843
+ if (i = t.url, !n.ok) return await Q(n), { error: `the site answered ${n.status}` };
844
+ r = await pt(n);
811
845
  } catch (e) {
812
846
  return { error: `it couldn't be fetched (${e instanceof Error ? e.message : String(e)})` };
813
847
  }
814
- if (!n) return { error: `it is larger than ${at / 1024 / 1024} MB` };
815
- let r = ut(n);
816
- if (!r) return { error: "it isn't a PNG, JPEG, GIF or WebP picture" };
817
- let i = `data:${r.mime};base64,${dt(n)}`;
818
- if (!t) return { imageData: i };
819
- let a = /* @__PURE__ */ new Date(), o = String(a.getUTCMonth() + 1).padStart(2, "0"), s = crypto.randomUUID().replace(/-/g, "").slice(0, 16), c = `${st}/${a.getUTCFullYear()}/${o}/${s}.${r.extension}`;
848
+ if (!r) return { error: `it is larger than ${ot / 1024 / 1024} MB` };
849
+ let a = dt(r);
850
+ if (!a) {
851
+ if (n) return { error: "it isn't a PNG, JPEG, GIF or WebP picture" };
852
+ let e = vt(new TextDecoder().decode(r), i);
853
+ if (!e) return { error: "it isn't a PNG, JPEG, GIF or WebP picture, or a web page with a preview picture (og:image)" };
854
+ let a = await $(e, t, !0);
855
+ return "error" in a ? { error: `its page's preview picture, ${e}: ${a.error}` } : {
856
+ ...a,
857
+ source: e
858
+ };
859
+ }
860
+ let o = `data:${a.mime};base64,${ft(r)}`;
861
+ if (!t) return { imageData: o };
862
+ let s = /* @__PURE__ */ new Date(), c = String(s.getUTCMonth() + 1).padStart(2, "0"), l = crypto.randomUUID().replace(/-/g, "").slice(0, 16), u = `${ct}/${s.getUTCFullYear()}/${c}/${l}.${a.extension}`;
820
863
  try {
821
- return await t.write(c, n), {
822
- imageData: i,
823
- imagePath: `${ct}${c}`
864
+ return await t.write(u, r), {
865
+ imageData: o,
866
+ imagePath: `${lt}${u}`
824
867
  };
825
868
  } catch {
826
- return { imageData: i };
869
+ return { imageData: o };
827
870
  }
828
871
  }
829
872
  //#endregion
830
873
  //#region src/core/presentSlide.ts
831
- function ht({ slide: e, totalSlides: t, mode: n }) {
874
+ function bt({ slide: e, totalSlides: t, mode: n }) {
832
875
  return n === "steps" ? {
833
876
  step: e,
834
877
  total: t,
@@ -846,7 +889,7 @@ function ht({ slide: e, totalSlides: t, mode: n }) {
846
889
  nextCall: `call presentSlide for slide ${e + 1} of ${t}`
847
890
  };
848
891
  }
849
- var gt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, imageUrl: a, html: o, markdown: s, chart: c }) => JSON.stringify([
892
+ var xt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, imageUrl: a, html: o, markdown: s, chart: c }) => JSON.stringify([
850
893
  e,
851
894
  t,
852
895
  n,
@@ -856,19 +899,19 @@ var gt = (e, { slide: t, totalSlides: n, title: r, imagePrompt: i, imageUrl: a,
856
899
  o,
857
900
  s,
858
901
  c
859
- ]), _t = Ne(() => ({
902
+ ]), St = G(() => ({
860
903
  latest: {
861
904
  presentation: null,
862
905
  steps: null
863
906
  },
864
907
  lastShown: null,
865
- repeats: rt()
908
+ repeats: it()
866
909
  }));
867
- function vt(e, t) {
910
+ function Ct(e, t) {
868
911
  let n = e.latest[t.mode], r = n?.totalSlides === t.totalSlides && (t.slide !== 1 || n.firstTitle === t.title);
869
912
  if (n && r) return n;
870
913
  let i = {
871
- id: ke(),
914
+ id: H(),
872
915
  mode: t.mode,
873
916
  totalSlides: t.totalSlides,
874
917
  firstTitle: t.slide === 1 ? t.title : "",
@@ -878,50 +921,50 @@ function vt(e, t) {
878
921
  };
879
922
  return e.latest[t.mode] = i, i;
880
923
  }
881
- function yt(e, t, n, r) {
924
+ function wt(e, t, n, r) {
882
925
  t.current = n.slide, t.shownAt = Date.now(), e.lastShown = t;
883
926
  let i = n.mode === "steps" ? "step" : "slide", { uuid: a, ...o } = r;
884
927
  return {
885
928
  ...o,
886
929
  message: `${i} ${n.slide} of ${n.totalSlides} is on the screen again, as it was`,
887
- instructions: M(n),
930
+ instructions: A(n),
888
931
  instructionsRequired: !0,
889
- sequence: ht(n)
932
+ sequence: bt(n)
890
933
  };
891
934
  }
892
- function bt(e, t) {
935
+ function Tt(e, t) {
893
936
  if (e.mode !== "steps") return e.title ? `A presentation slide titled "${e.title}". ${e.imagePrompt}` : e.imagePrompt;
894
937
  let n = e.title ? `, "${e.title}"` : "";
895
938
  return [
896
939
  `An instructional illustration of step ${e.slide} of ${e.totalSlides}${n}. ${e.imagePrompt}`,
897
- t ? xt : "",
940
+ t ? Et : "",
898
941
  "Show the action clearly, with little or no text."
899
942
  ].filter(Boolean).join(" ");
900
943
  }
901
- var xt = "The reference image is the previous step: keep the same objects, hands, tools and setting, and show what this step changes.";
902
- async function St(e, t, n) {
944
+ var Et = "The reference image is the previous step: keep the same objects, hands, tools and setting, and show what this step changes.";
945
+ async function Dt(e, t, n) {
903
946
  if (n.mode !== "steps") return [];
904
- let r = H(t.slides.get(n.slide - 1)).imagePath;
905
- return r ? await je(e, [r]) : [];
947
+ let r = R(t.slides.get(n.slide - 1)).imagePath;
948
+ return r ? await U(e, [r]) : [];
906
949
  }
907
- var Ct = (e, t) => [
950
+ var Ot = (e, t) => [
908
951
  e.mode === "steps" ? `An instructional illustration for step ${e.slide} of ${e.totalSlides}${e.title ? `, "${e.title}"` : ""}. ${e.imagePrompt}` : `A picture for a presentation slide${e.title ? ` titled "${e.title}"` : ""}. ${e.imagePrompt}`,
909
- t ? xt : "",
952
+ t ? Et : "",
910
953
  e.markdown ? "Keep the subject in the middle: the picture is cropped to a tall frame." : "",
911
954
  "No text, letters or numbers in the picture."
912
955
  ].filter(Boolean).join(" ");
913
- async function wt(e, t) {
914
- let n = await mt(t, e.files?.artifacts);
956
+ async function kt(e, t) {
957
+ let n = await $(t, e.files?.artifacts);
915
958
  return "error" in n && console.info(`[sequence] picture at ${t} not shown: ${n.error}`), n;
916
959
  }
917
- async function Tt(e, t, n) {
960
+ async function At(e, t, n) {
918
961
  if (n.chart) return {
919
962
  chart: n.chart,
920
963
  prompt: ""
921
964
  };
922
965
  if (n.html || n.markdown) {
923
966
  let r = n.html ? { html: n.html } : {
924
- html: await Ke(n.markdown ?? ""),
967
+ html: await qe(n.markdown ?? ""),
925
968
  markdown: n.markdown ?? ""
926
969
  };
927
970
  if (!b(r.html)) return {
@@ -930,7 +973,7 @@ async function Tt(e, t, n) {
930
973
  };
931
974
  let i = n.imagePrompt || re(r.html) || n.title, a;
932
975
  if (n.imageUrl) {
933
- let t = await wt(e, n.imageUrl);
976
+ let t = await kt(e, n.imageUrl);
934
977
  if (!("error" in t)) return {
935
978
  ...r,
936
979
  ...t,
@@ -943,7 +986,7 @@ async function Tt(e, t, n) {
943
986
  let o = {
944
987
  ...n,
945
988
  imagePrompt: i
946
- }, s = await St(e, t, o), c = Ct(o, s.length > 0), l = await G(e, c, s), { imageData: u, imagePath: d } = H(l), f = a !== void 0 && { urlFailed: a };
989
+ }, s = await Dt(e, t, o), c = Ot(o, s.length > 0), l = await W(e, c, s), { imageData: u, imagePath: d } = R(l), f = a !== void 0 && { urlFailed: a };
947
990
  return u ? {
948
991
  ...r,
949
992
  imageData: u,
@@ -961,7 +1004,7 @@ async function Tt(e, t, n) {
961
1004
  }
962
1005
  let r;
963
1006
  if (n.imageUrl) {
964
- let t = await wt(e, n.imageUrl);
1007
+ let t = await kt(e, n.imageUrl);
965
1008
  if (!("error" in t)) return {
966
1009
  ...t,
967
1010
  imageUrl: n.imageUrl,
@@ -973,7 +1016,7 @@ async function Tt(e, t, n) {
973
1016
  } };
974
1017
  r = t.error;
975
1018
  }
976
- let i = await St(e, t, n), a = bt(n, i.length > 0), o = await G(e, a, i), { imageData: s, imagePath: c } = H(o);
1019
+ let i = await Dt(e, t, n), a = Tt(n, i.length > 0), o = await W(e, a, i), { imageData: s, imagePath: c } = R(o);
977
1020
  return s ? {
978
1021
  imageData: s,
979
1022
  ...c && { imagePath: c },
@@ -984,12 +1027,12 @@ async function Tt(e, t, n) {
984
1027
  sequence: null
985
1028
  } };
986
1029
  }
987
- async function Et(e, t, n) {
988
- let r = await Tt(e, t, n);
1030
+ async function jt(e, t, n) {
1031
+ let r = await At(e, t, n);
989
1032
  if ("failed" in r) return r.failed;
990
- let { imageData: i, imagePath: a, imageUrl: o, html: s, markdown: c, chart: l, prompt: u, pictureFailed: d, urlFailed: f } = r, p = t.id, m = await X(e.files?.artifacts, qe, p, (e) => {
1033
+ let { imageData: i, imagePath: a, imageUrl: o, html: s, markdown: c, chart: l, prompt: u, pictureFailed: d, urlFailed: f, source: p } = r, m = t.id, h = await Y(e.files?.artifacts, Je, m, (e) => {
991
1034
  let t = e ?? {
992
- id: p,
1035
+ id: m,
993
1036
  title: "",
994
1037
  mode: n.mode,
995
1038
  totalSlides: n.totalSlides,
@@ -1004,7 +1047,7 @@ async function Et(e, t, n) {
1004
1047
  ...c && { markdown: c },
1005
1048
  ...l && { chart: l }
1006
1049
  }, t;
1007
- }), h = {
1050
+ }), g = {
1008
1051
  ...i && { imageData: i },
1009
1052
  ...a && { imagePath: a },
1010
1053
  ...o && { imageUrl: o },
@@ -1012,36 +1055,37 @@ async function Et(e, t, n) {
1012
1055
  ...c && { markdown: c },
1013
1056
  ...l && { chart: l },
1014
1057
  prompt: u,
1015
- slideshowId: p,
1058
+ slideshowId: m,
1016
1059
  slide: n.slide,
1017
1060
  totalSlides: n.totalSlides,
1018
1061
  title: n.title,
1019
1062
  mode: n.mode
1020
- }, g = n.mode === "steps" ? "step" : "slide";
1063
+ }, v = n.mode === "steps" ? "step" : "slide";
1021
1064
  return {
1022
- data: h,
1065
+ data: g,
1023
1066
  title: n.title || `Slide ${n.slide}`,
1024
1067
  message: [
1025
- `${g} ${n.slide} of ${n.totalSlides} of slideshow "${p}" is on the screen`,
1026
- o ? `its picture is from ${o}` : "",
1068
+ `${v} ${n.slide} of ${n.totalSlides} of slideshow "${m}" is on the screen`,
1069
+ o ? p ? `its picture is the preview picture of ${o} (${p})` : `its picture is from ${o}` : "",
1027
1070
  a ? `saved to ${a}` : "",
1071
+ n.unplacedImageUrl ? `the picture at ${n.unplacedImageUrl} isn't shown: ${n.chart ? "a chart slide has no picture" : `the slide has no ${_} for it (<img src="${_}" alt="..." class="..."> where it goes)`}` : "",
1028
1072
  f === void 0 ? "" : `the picture at ${n.imageUrl} couldn't be shown (${f}), so it was drawn instead`,
1029
1073
  d ? `its picture couldn't be drawn (${d}), so the slide is shown without it` : "",
1030
- m ? "" : Z("slideshow")
1074
+ h ? "" : X("slideshow")
1031
1075
  ].filter(Boolean).join("; "),
1032
- instructions: M(n),
1076
+ instructions: A(n),
1033
1077
  instructionsRequired: !0,
1034
- sequence: ht(n)
1078
+ sequence: bt(n)
1035
1079
  };
1036
1080
  }
1037
- async function Dt(e, t) {
1038
- let n = A(t);
1081
+ async function Mt(e, t) {
1082
+ let n = be(t);
1039
1083
  if (typeof n == "string") return {
1040
1084
  message: n,
1041
1085
  sequence: null
1042
1086
  };
1043
- let r = _t(e), i = vt(r, n), a = n.mode === "steps";
1044
- if (a && n.slide > i.current && i.current > 0 && !Oe(e, i.shownAt)) {
1087
+ let r = St(e), i = Ct(r, n), a = n.mode === "steps";
1088
+ if (a && n.slide > i.current && i.current > 0 && !V(e, i.shownAt)) {
1045
1089
  console.info(`[sequence] holding step ${n.slide} for the user`);
1046
1090
  let e = i.shownAt === Infinity ? "is still being drawn" : "is still on the screen";
1047
1091
  return {
@@ -1050,15 +1094,15 @@ async function Dt(e, t) {
1050
1094
  };
1051
1095
  }
1052
1096
  let o = a ? i.slides.get(n.slide) : void 0;
1053
- if (o) return De(e.currentResult, o) ? {
1097
+ if (o) return je(e.currentResult, o) ? {
1054
1098
  message: `step ${n.slide} of ${n.totalSlides} is already on the screen`,
1055
1099
  cancelled: !0
1056
- } : yt(r, i, n, o);
1057
- let s = r.repeats.claim(gt(i.id, n));
1100
+ } : wt(r, i, n, o);
1101
+ let s = r.repeats.claim(xt(i.id, n));
1058
1102
  if ("earlier" in s) {
1059
- if (!await s.earlier) return Dt(e, t);
1103
+ if (!await s.earlier) return Mt(e, t);
1060
1104
  let a = i.slides.get(n.slide);
1061
- return a && r.lastShown !== i ? yt(r, i, n, a) : {
1105
+ return a && r.lastShown !== i ? wt(r, i, n, a) : {
1062
1106
  message: `slide ${n.slide} of ${n.totalSlides} is already on the screen`,
1063
1107
  cancelled: !0
1064
1108
  };
@@ -1070,22 +1114,22 @@ async function Dt(e, t) {
1070
1114
  i.current = n.slide, i.shownAt = Infinity;
1071
1115
  let u = !1;
1072
1116
  try {
1073
- let t = await Et(e, i, n);
1074
- return u = Ee(t), u && (i.slides.set(n.slide, t), i.current = n.slide, i.shownAt = Date.now(), r.lastShown = i), t;
1117
+ let t = await jt(e, i, n);
1118
+ return u = Ae(t), u && (i.slides.set(n.slide, t), i.current = n.slide, i.shownAt = Date.now(), r.lastShown = i), t;
1075
1119
  } finally {
1076
1120
  c(u), !u && i.current === n.slide && (i.current = l.current, i.shownAt = l.shownAt);
1077
1121
  }
1078
1122
  }
1079
1123
  //#endregion
1080
1124
  //#region src/core/storyboard.ts
1081
- var Ot = ({ id: e, title: t, totalPanels: n }) => ({
1125
+ var Nt = ({ id: e, title: t, totalPanels: n }) => ({
1082
1126
  step: 0,
1083
1127
  total: n,
1084
1128
  kind: "story",
1085
1129
  label: `The cast of "${t}"`,
1086
1130
  onShown: "introduce the characters",
1087
1131
  nextCall: `call presentPanel for panel 1 of ${n} with storyboardId "${e}"`
1088
- }), kt = ({ id: e, totalPanels: t }, n, r) => ({
1132
+ }), Pt = ({ id: e, totalPanels: t }, n, r) => ({
1089
1133
  step: n,
1090
1134
  total: t,
1091
1135
  kind: "story",
@@ -1093,21 +1137,21 @@ var Ot = ({ id: e, title: t, totalPanels: n }) => ({
1093
1137
  onShown: "tell that part of the story",
1094
1138
  nextCall: `call presentPanel for panel ${n + 1} of ${t} with storyboardId "${e}"`,
1095
1139
  ...r.length > 0 && { waitsForUser: !0 }
1096
- }), At = (e, t) => e ? `${e}. ${t}` : t, jt = (e, { name: t, description: n }) => At(e, `Character reference sheet of ${t}: ${n}. Full body, front, side and back views, on a plain white background. No text or labels.`);
1097
- async function Mt(e, t) {
1098
- let n = F(t);
1140
+ }), Ft = (e, t) => e ? `${e}. ${t}` : t, It = (e, { name: t, description: n }) => Ft(e, `Character reference sheet of ${t}: ${n}. Full body, front, side and back views, on a plain white background. No text or labels.`);
1141
+ async function Lt(e, t) {
1142
+ let n = De(t);
1099
1143
  if (typeof n == "string") return {
1100
1144
  message: n,
1101
1145
  sequence: null
1102
1146
  };
1103
- let r = await Promise.all(n.characters.map((t) => G(e, jt(n.style, t)))), i = r.map(H), a = r.find((e, t) => !i[t]?.imageData);
1147
+ let r = await Promise.all(n.characters.map((t) => W(e, It(n.style, t)))), i = r.map(R), a = r.find((e, t) => !i[t]?.imageData);
1104
1148
  if (i.every(({ imageData: e }) => !e) && a) return {
1105
1149
  ...a,
1106
1150
  message: `the character sheets couldn't be made: ${a.message}`,
1107
1151
  sequence: null
1108
1152
  };
1109
1153
  let o = {
1110
- id: ke(),
1154
+ id: H(),
1111
1155
  ...n,
1112
1156
  characters: n.characters.map((e, t) => {
1113
1157
  let n = i[t]?.imagePath;
@@ -1117,7 +1161,7 @@ async function Mt(e, t) {
1117
1161
  };
1118
1162
  }),
1119
1163
  panels: {}
1120
- }, s = await X(e.files?.artifacts, Y, o.id, () => o), c = o.characters.filter((e) => e.imagePath).map((e) => `${e.name}: ${e.imagePath}`), l = n.characters.map(({ name: e }, t) => i[t]?.imageData ? null : `${e} (${r[t]?.message ?? ""})`).filter((e) => !!e), u = i.find((e) => e.imageData)?.imageData;
1164
+ }, s = await Y(e.files?.artifacts, J, o.id, () => o), c = o.characters.filter((e) => e.imagePath).map((e) => `${e.name}: ${e.imagePath}`), l = n.characters.map(({ name: e }, t) => i[t]?.imageData ? null : `${e} (${r[t]?.message ?? ""})`).filter((e) => !!e), u = i.find((e) => e.imageData)?.imageData;
1121
1165
  return {
1122
1166
  data: {
1123
1167
  storyboardId: o.id,
@@ -1138,39 +1182,39 @@ async function Mt(e, t) {
1138
1182
  `storyboard "${o.id}" is ready with ${o.totalPanels} panels; the cast is on the screen`,
1139
1183
  c.length ? `character sheets saved to ${c.join(", ")}` : "",
1140
1184
  l.length ? `no sheet for ${l.join("; ")}: they will be drawn from their description` : "",
1141
- s ? "" : Z("storyboard")
1185
+ s ? "" : X("storyboard")
1142
1186
  ].filter(Boolean).join("; "),
1143
- instructions: I(o),
1187
+ instructions: Oe(o),
1144
1188
  instructionsRequired: !0,
1145
- sequence: Ot(o)
1189
+ sequence: Nt(o)
1146
1190
  };
1147
1191
  }
1148
- function Nt(e, t, n) {
1149
- let r = [At(e.style, `Panel ${t.panel} of ${e.totalPanels} of the illustrated story "${e.title}". ${t.imagePrompt}`)], i = 0, a = n.map(({ character: e, hasSheet: t }) => t ? `${e.name} is the character in reference image ${++i}` : `${e.name}: ${e.description}`);
1192
+ function Rt(e, t, n) {
1193
+ let r = [Ft(e.style, `Panel ${t.panel} of ${e.totalPanels} of the illustrated story "${e.title}". ${t.imagePrompt}`)], i = 0, a = n.map(({ character: e, hasSheet: t }) => t ? `${e.name} is the character in reference image ${++i}` : `${e.name}: ${e.description}`);
1150
1194
  return a.length && r.push(`${a.join(". ")}.`), i && r.push("Draw each character exactly as in their reference image: the same face, hair, clothes and colors. Use the reference images only for how the characters look, not for their pose or the background."), r.push("No captions, speech bubbles or other text in the picture."), r.join(" ");
1151
1195
  }
1152
- async function Pt(e, t, n) {
1196
+ async function zt(e, t, n) {
1153
1197
  let r = [], i = [];
1154
1198
  for (let a of n.characters) {
1155
- let n = t.characters.find((e) => T(e.name, a));
1199
+ let n = t.characters.find((e) => O(e.name, a));
1156
1200
  if (!n) r.push(a);
1157
1201
  else if (!i.some((e) => e.character === n)) {
1158
- let [t] = n.imagePath ? await je(e, [n.imagePath]) : [];
1202
+ let [t] = n.imagePath ? await U(e, [n.imagePath]) : [];
1159
1203
  i.push({
1160
1204
  character: n,
1161
1205
  sheet: t ?? null
1162
1206
  });
1163
1207
  }
1164
1208
  }
1165
- let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o = Nt(t, n, i.map(({ character: e, sheet: t }) => ({
1209
+ let a = i.map(({ sheet: e }) => e).filter((e) => !!e), o = Rt(t, n, i.map(({ character: e, sheet: t }) => ({
1166
1210
  character: e,
1167
1211
  hasSheet: !!t
1168
- }))), s = await G(e, o, a), { imageData: c, imagePath: l } = H(s);
1212
+ }))), s = await W(e, o, a), { imageData: c, imagePath: l } = R(s);
1169
1213
  if (!c) return {
1170
1214
  ...s,
1171
1215
  sequence: null
1172
1216
  };
1173
- let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await X(e.files?.artifacts, Y, t.id, (e) => {
1217
+ let u = n.panel < t.totalPanels && n.choices.length >= 2 ? n.choices : [], d = await Y(e.files?.artifacts, J, t.id, (e) => {
1174
1218
  let r = e ?? t;
1175
1219
  return u.length && (r.interactive = !0), r.panels[String(n.panel)] = {
1176
1220
  caption: n.caption,
@@ -1196,25 +1240,25 @@ async function Pt(e, t, n) {
1196
1240
  `panel ${n.panel} of ${t.totalPanels} is on the screen`,
1197
1241
  l ? `saved to ${l}` : "",
1198
1242
  r.length ? `not in the cast, so drawn from the prompt alone: ${r.join(", ")}` : "",
1199
- d ? "" : Z("storyboard")
1243
+ d ? "" : X("storyboard")
1200
1244
  ].filter(Boolean).join("; "),
1201
- instructions: z(t, n.panel, u),
1245
+ instructions: N(t, n.panel, u),
1202
1246
  instructionsRequired: !0,
1203
- sequence: kt(t, n.panel, u)
1247
+ sequence: Pt(t, n.panel, u)
1204
1248
  };
1205
1249
  }
1206
- var Ft = Ne(() => ({
1207
- repeats: rt(),
1250
+ var Bt = G(() => ({
1251
+ repeats: it(),
1208
1252
  awaitingChoice: /* @__PURE__ */ new Map()
1209
1253
  }));
1210
- async function It(e, t) {
1211
- let n = R(t);
1254
+ async function Vt(e, t) {
1255
+ let n = M(t);
1212
1256
  if (!n) return {
1213
- message: L,
1257
+ message: j,
1214
1258
  sequence: null
1215
1259
  };
1216
- let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } = Ft(e), s = o.get(r);
1217
- if (s && i > s.panel && !Oe(e, s.shownAt)) return console.info(`[sequence] holding panel ${i} for the user`), {
1260
+ let { storyboardId: r, panel: i } = n, { repeats: a, awaitingChoice: o } = Bt(e), s = o.get(r);
1261
+ if (s && i > s.panel && !V(e, s.shownAt)) return console.info(`[sequence] holding panel ${i} for the user`), {
1218
1262
  message: s.shownAt === Infinity ? `panel ${i} was not shown: panel ${s.panel} is still being drawn. Wait for it before going on.` : `panel ${i} was not shown: the user hasn't picked a choice yet, and panel ${s.panel} is still on the screen. Wait for their answer.`,
1219
1263
  cancelled: !0
1220
1264
  };
@@ -1222,7 +1266,7 @@ async function It(e, t) {
1222
1266
  if ("earlier" in c) return await c.earlier ? {
1223
1267
  message: `panel ${i} is already on the screen`,
1224
1268
  cancelled: !0
1225
- } : It(e, t);
1269
+ } : Vt(e, t);
1226
1270
  let { settle: l } = c, u = {
1227
1271
  panel: i,
1228
1272
  shownAt: Infinity
@@ -1230,7 +1274,7 @@ async function It(e, t) {
1230
1274
  o.set(r, u);
1231
1275
  let f = () => o.get(r) === u, p = !1;
1232
1276
  try {
1233
- let t = await tt(e.files?.artifacts, Y, r);
1277
+ let t = await nt(e.files?.artifacts, J, r);
1234
1278
  if (!t) return {
1235
1279
  message: `there is no storyboard "${r}"; call defineStoryboard first`,
1236
1280
  sequence: null
@@ -1239,8 +1283,8 @@ async function It(e, t) {
1239
1283
  message: `storyboard "${t.id}" has ${t.totalPanels} panels`,
1240
1284
  sequence: null
1241
1285
  };
1242
- let a = await Pt(e, t, n);
1243
- p = !!H(a).imageData;
1286
+ let a = await zt(e, t, n);
1287
+ p = !!R(a).imageData;
1244
1288
  let s = a.data;
1245
1289
  return p && f() && (s?.choices?.length ? o.set(r, {
1246
1290
  panel: i,
@@ -1252,21 +1296,21 @@ async function It(e, t) {
1252
1296
  }
1253
1297
  //#endregion
1254
1298
  //#region src/core/index.ts
1255
- var Lt = {
1256
- toolDefinition: P,
1299
+ var Ht = {
1300
+ toolDefinition: Ee,
1257
1301
  generatingMessage: "Making the slide...",
1258
1302
  isEnabled: () => !0,
1259
- execute: (e, t) => Dt(e, t)
1260
- }, Rt = {
1261
- toolDefinition: Ce,
1303
+ execute: (e, t) => Mt(e, t)
1304
+ }, Ut = {
1305
+ toolDefinition: F,
1262
1306
  generatingMessage: "Drawing the characters...",
1263
1307
  isEnabled: () => !0,
1264
- execute: (e, t) => Mt(e, t)
1265
- }, zt = {
1266
- toolDefinition: we,
1308
+ execute: (e, t) => Lt(e, t)
1309
+ }, Wt = {
1310
+ toolDefinition: I,
1267
1311
  generatingMessage: "Drawing the panel...",
1268
1312
  isEnabled: () => !0,
1269
- execute: (e, t) => It(e, t)
1313
+ execute: (e, t) => Vt(e, t)
1270
1314
  };
1271
1315
  //#endregion
1272
- export { M as A, t as B, B as C, A as D, R as E, s as F, ae as H, h as I, l as L, fe as M, r as N, F as O, o as P, n as R, O as S, z as T, ie as U, b as V, P as _, Y as a, D as b, me as c, ve as d, _e as f, pe as g, we as h, qe as i, x as j, T as k, Ce as l, he as m, zt as n, tt as o, L as p, Lt as r, Ke as s, Rt as t, ge as u, N as v, I as w, k as x, S as y, _ as z };
1316
+ export { A, t as B, P as C, be as D, M as E, s as F, ae as H, h as I, l as L, de as M, r as N, De as O, o as P, n as R, _e as S, N as T, ie as U, b as V, Ee as _, J as a, ge as b, w as c, he as d, me as f, C as g, I as h, Je as i, x as j, O as k, F as l, fe as m, Wt as n, nt as o, j as p, Ht as r, qe as s, Ut as t, pe as u, Te as v, Oe as w, ve as x, T as y, _ as z };