@bobfrankston/rmfmail 1.2.162 → 1.2.164

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.
@@ -5605,6 +5605,7 @@ function openNewEventDialog() {
5605
5605
  createBtn.click();
5606
5606
  }
5607
5607
  });
5608
+ let asTextMode = false;
5608
5609
  createBtn.addEventListener("click", async () => {
5609
5610
  const text = ta.value.trim();
5610
5611
  if (!text) {
@@ -5614,26 +5615,39 @@ function openNewEventDialog() {
5614
5615
  createBtn.disabled = true;
5615
5616
  cancelBtn.disabled = true;
5616
5617
  status.textContent = "Parsing\u2026";
5617
- let event = null;
5618
- try {
5619
- const { aiTransform: aiTransform2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
5620
- const r = await aiTransform2({
5621
- action: "extractEvent",
5622
- text,
5623
- nowISO: (/* @__PURE__ */ new Date()).toISOString()
5624
- });
5625
- event = r?.event || null;
5626
- if (!event && r?.reason)
5627
- status.textContent = `AI: ${r.reason} \u2014 using raw text as title.`;
5628
- } catch (e) {
5629
- status.textContent = `AI call failed: ${e.message} \u2014 using raw text as title.`;
5618
+ let events = [];
5619
+ if (!asTextMode) {
5620
+ try {
5621
+ const { aiTransform: aiTransform2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
5622
+ const r = await aiTransform2({
5623
+ action: "extractEvent",
5624
+ text,
5625
+ nowISO: (/* @__PURE__ */ new Date()).toISOString()
5626
+ });
5627
+ events = r?.events || (r?.event ? [r.event] : []);
5628
+ if (events.length === 0) {
5629
+ status.textContent = `AI parse failed${r?.reason ? `: ${r.reason}` : ""}.`;
5630
+ }
5631
+ } catch (e) {
5632
+ status.textContent = `AI call failed: ${e.message}`;
5633
+ }
5634
+ if (events.length === 0) {
5635
+ createBtn.textContent = "Create as text";
5636
+ createBtn.disabled = false;
5637
+ cancelBtn.disabled = false;
5638
+ asTextMode = true;
5639
+ return;
5640
+ }
5630
5641
  }
5631
- const url = buildGoogleEventUrl(event, text);
5632
5642
  const api = window.mailxapi;
5633
- if (api?.openExternal)
5634
- api.openExternal(url);
5635
- else
5636
- window.open(url, "_blank");
5643
+ const targets = events.length ? events : [null];
5644
+ for (const ev of targets) {
5645
+ const url = buildGoogleEventUrl(ev, text);
5646
+ if (api?.openExternal)
5647
+ api.openExternal(url);
5648
+ else
5649
+ window.open(url, "_blank");
5650
+ }
5637
5651
  close();
5638
5652
  });
5639
5653
  }
@@ -5670,6 +5684,8 @@ function buildGoogleEventUrl(event, fallbackText) {
5670
5684
  params.push(`location=${encodeURIComponent(event.location)}`);
5671
5685
  if (event?.notes)
5672
5686
  params.push(`details=${encodeURIComponent(event.notes)}`);
5687
+ if (event?.timeZone)
5688
+ params.push(`ctz=${encodeURIComponent(event.timeZone)}`);
5673
5689
  return `${base}&${params.join("&")}`;
5674
5690
  }
5675
5691
  async function showCalendarSidebar() {