pxengine 0.1.135 → 0.1.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -212,6 +212,7 @@ __export(index_exports, {
212
212
  InputWidget: () => InputWidget,
213
213
  InsightDigestCard: () => InsightDigestCard,
214
214
  InsightSummaryCard: () => InsightSummaryCard,
215
+ JOB_SIGNAL_EVENT: () => JOB_SIGNAL_EVENT,
215
216
  KPIStatsCard: () => KPIStatsCard,
216
217
  KbdAtom: () => KbdAtom,
217
218
  KeywordBundlesDisplay: () => KeywordBundlesDisplay,
@@ -272,6 +273,7 @@ __export(index_exports, {
272
273
  ResizablePanel: () => ResizablePanel,
273
274
  ResizablePanelGroup: () => ResizablePanelGroup,
274
275
  RiskSignalCard: () => RiskSignalCard,
276
+ SSE_FALLBACK_POLL_MS: () => SSE_FALLBACK_POLL_MS,
275
277
  ScoreBreakdownCard: () => ScoreBreakdownCard,
276
278
  ScrollArea: () => ScrollArea,
277
279
  ScrollAreaAtom: () => ScrollAreaAtom,
@@ -342,24 +344,28 @@ __export(index_exports, {
342
344
  defaultFetchSelections: () => defaultFetchSelections,
343
345
  defaultPersistSelection: () => defaultPersistSelection,
344
346
  elementToQAField: () => elementToQAField,
347
+ emitJobSignal: () => emitJobSignal,
345
348
  formatQAMessage: () => formatQAMessage,
346
349
  generateFieldsFromData: () => generateFieldsFromData,
347
350
  generateFieldsFromPropDefinitions: () => generateFieldsFromPropDefinitions,
348
351
  getPxAuthToken: () => getPxAuthToken,
349
352
  isInputAtom: () => isInputAtom,
350
353
  notifyPxUnauthorized: () => notifyPxUnauthorized,
354
+ refreshSharedPoll: () => refreshSharedPoll,
351
355
  setPxAuthTokenProvider: () => setPxAuthTokenProvider,
352
356
  setPxUnauthorizedHandler: () => setPxUnauthorizedHandler,
353
357
  submitWidgetToAgent: () => submitWidgetToAgent,
358
+ subscribeJobSignal: () => subscribeJobSignal,
354
359
  th: () => th,
355
360
  useCreatorWidgetPolling: () => useCreatorWidgetPolling,
361
+ useJobSignal: () => useJobSignal,
356
362
  useWidgetTheme: () => useWidgetTheme,
357
363
  withAlpha: () => withAlpha
358
364
  });
359
365
  module.exports = __toCommonJS(index_exports);
360
366
 
361
367
  // src/render/PXEngineRenderer.tsx
362
- var import_react99 = __toESM(require("react"), 1);
368
+ var import_react100 = __toESM(require("react"), 1);
363
369
 
364
370
  // src/atoms/index.ts
365
371
  var atoms_exports = {};
@@ -16119,10 +16125,11 @@ var NextStepCard = ({
16119
16125
  };
16120
16126
 
16121
16127
  // src/molecules/generic/PresentationJobCard/PresentationJobCard.tsx
16122
- var import_react80 = require("react");
16128
+ var import_react81 = require("react");
16123
16129
 
16124
16130
  // src/lib/shared-poll.ts
16125
16131
  var import_react79 = require("react");
16132
+ var SSE_FALLBACK_POLL_MS = 2e4;
16126
16133
  var MAX_RETAINED = 50;
16127
16134
  var RETAIN_TTL_MS = 30 * 60 * 1e3;
16128
16135
  var entries = /* @__PURE__ */ new Map();
@@ -16249,6 +16256,12 @@ function stopSharedPoll(key) {
16249
16256
  entry.stopped = true;
16250
16257
  clearTimer(entry);
16251
16258
  }
16259
+ function refreshSharedPoll(key) {
16260
+ if (!key) return;
16261
+ const entry = entries.get(key);
16262
+ if (!entry || entry.stopped) return;
16263
+ void runPoll(key);
16264
+ }
16252
16265
  function getSharedPollLastData(key) {
16253
16266
  if (!key) return void 0;
16254
16267
  const entry = entries.get(key);
@@ -16285,6 +16298,45 @@ function useSharedPoll(config, onData, onError) {
16285
16298
  }, [key, intervalMs]);
16286
16299
  }
16287
16300
 
16301
+ // src/lib/job-signal.ts
16302
+ var import_react80 = require("react");
16303
+ var JOB_SIGNAL_EVENT = "pxengine:job-signal";
16304
+ var listeners = /* @__PURE__ */ new Set();
16305
+ var windowBridgeInstalled = false;
16306
+ function fanout(jobId) {
16307
+ if (!jobId) return;
16308
+ for (const listener of Array.from(listeners)) {
16309
+ try {
16310
+ listener(jobId);
16311
+ } catch {
16312
+ }
16313
+ }
16314
+ }
16315
+ function ensureWindowBridge() {
16316
+ if (windowBridgeInstalled || typeof window === "undefined") return;
16317
+ windowBridgeInstalled = true;
16318
+ window.addEventListener(JOB_SIGNAL_EVENT, (event) => {
16319
+ const detail = event.detail;
16320
+ const jobId = detail?.jobId;
16321
+ if (typeof jobId === "string" && jobId) fanout(jobId);
16322
+ });
16323
+ }
16324
+ function emitJobSignal(jobId) {
16325
+ fanout(jobId);
16326
+ }
16327
+ function subscribeJobSignal(listener) {
16328
+ ensureWindowBridge();
16329
+ listeners.add(listener);
16330
+ return () => {
16331
+ listeners.delete(listener);
16332
+ };
16333
+ }
16334
+ function useJobSignal(onSignal) {
16335
+ const ref = (0, import_react80.useRef)(onSignal);
16336
+ ref.current = onSignal;
16337
+ (0, import_react80.useEffect)(() => subscribeJobSignal((jobId) => ref.current(jobId)), []);
16338
+ }
16339
+
16288
16340
  // src/molecules/generic/job-card-shared/Chip.tsx
16289
16341
  var import_jsx_runtime148 = require("react/jsx-runtime");
16290
16342
  var Chip = ({
@@ -16378,9 +16430,9 @@ function formatTemplateLabel(templateId) {
16378
16430
  }
16379
16431
  var DECK_CANVAS = { w: 1280, h: 720 };
16380
16432
  function useDeckFitScale(canvasW = DECK_CANVAS.w, canvasH = DECK_CANVAS.h) {
16381
- const containerRef = (0, import_react80.useRef)(null);
16382
- const [scale, setScale] = (0, import_react80.useState)(1);
16383
- (0, import_react80.useLayoutEffect)(() => {
16433
+ const containerRef = (0, import_react81.useRef)(null);
16434
+ const [scale, setScale] = (0, import_react81.useState)(1);
16435
+ (0, import_react81.useLayoutEffect)(() => {
16384
16436
  const el = containerRef.current;
16385
16437
  if (!el) return;
16386
16438
  const update = () => {
@@ -16443,7 +16495,7 @@ var FORMATS = [
16443
16495
  var ExportModal = ({ formats, title, onClose }) => {
16444
16496
  const available = FORMATS.filter((f) => (formats ?? {})[f.key]);
16445
16497
  const filename = (title ?? "").replace(/[^a-z0-9]/gi, "-").toLowerCase();
16446
- const [downloadingKey, setDownloadingKey] = (0, import_react80.useState)(null);
16498
+ const [downloadingKey, setDownloadingKey] = (0, import_react81.useState)(null);
16447
16499
  const handleDownload = async (fmtKey, url, ext) => {
16448
16500
  if (downloadingKey) return;
16449
16501
  const downloadName = `${filename}${ext}`;
@@ -16511,11 +16563,11 @@ var ExportModal = ({ formats, title, onClose }) => {
16511
16563
  ] });
16512
16564
  };
16513
16565
  var FullscreenModal = ({ url, title, slideCount, initialSlide = 1, onClose }) => {
16514
- const [currentSlide, setCurrentSlide] = (0, import_react80.useState)(initialSlide);
16515
- const [iframeReady, setIframeReady] = (0, import_react80.useState)(false);
16516
- const iframeRef = (0, import_react80.useRef)(null);
16566
+ const [currentSlide, setCurrentSlide] = (0, import_react81.useState)(initialSlide);
16567
+ const [iframeReady, setIframeReady] = (0, import_react81.useState)(false);
16568
+ const iframeRef = (0, import_react81.useRef)(null);
16517
16569
  const { containerRef, scale, canvasW, canvasH } = useDeckFitScale();
16518
- (0, import_react80.useEffect)(() => {
16570
+ (0, import_react81.useEffect)(() => {
16519
16571
  const onKey = (e) => {
16520
16572
  if (e.key === "Escape") onClose();
16521
16573
  };
@@ -16533,7 +16585,7 @@ var FullscreenModal = ({ url, title, slideCount, initialSlide = 1, onClose }) =>
16533
16585
  window.removeEventListener("message", onMsg);
16534
16586
  };
16535
16587
  }, [onClose, iframeReady]);
16536
- (0, import_react80.useEffect)(() => {
16588
+ (0, import_react81.useEffect)(() => {
16537
16589
  document.body.style.overflow = "hidden";
16538
16590
  return () => {
16539
16591
  document.body.style.overflow = "";
@@ -16659,74 +16711,74 @@ var PresentationJobCard = ({
16659
16711
  }) => {
16660
16712
  const t = th(theme);
16661
16713
  const accentGradient = theme?.gradient;
16662
- const [status, setStatus] = (0, import_react80.useState)(initialStatus);
16663
- const [title, setTitle] = (0, import_react80.useState)(initialTitle);
16664
- const [slideCount, setSlideCount] = (0, import_react80.useState)(initialSlideCount ?? 0);
16665
- const [formats, setFormats] = (0, import_react80.useState)(initialFormats);
16666
- const [error, setError] = (0, import_react80.useState)(initialError);
16667
- const [progress, setProgress] = (0, import_react80.useState)(initialProgress);
16668
- const [generationMode, setGenerationMode] = (0, import_react80.useState)(
16714
+ const [status, setStatus] = (0, import_react81.useState)(initialStatus);
16715
+ const [title, setTitle] = (0, import_react81.useState)(initialTitle);
16716
+ const [slideCount, setSlideCount] = (0, import_react81.useState)(initialSlideCount ?? 0);
16717
+ const [formats, setFormats] = (0, import_react81.useState)(initialFormats);
16718
+ const [error, setError] = (0, import_react81.useState)(initialError);
16719
+ const [progress, setProgress] = (0, import_react81.useState)(initialProgress);
16720
+ const [generationMode, setGenerationMode] = (0, import_react81.useState)(
16669
16721
  initialGenerationMode || (initialFormats?.html_url ? "template" : "")
16670
16722
  );
16671
- const [templateId, setTemplateId] = (0, import_react80.useState)(initialTemplateId || "");
16672
- const [, setTemplateVersionId] = (0, import_react80.useState)(initialTemplateVersionId || "");
16673
- const [reviewStatus, setReviewStatus] = (0, import_react80.useState)(initialReviewStatus || "");
16674
- const [outline, setOutline] = (0, import_react80.useState)(initialOutline);
16675
- const [slideTemplateOptions, setSlideTemplateOptions] = (0, import_react80.useState)(null);
16676
- const [showExport, setShowExport] = (0, import_react80.useState)(false);
16677
- const [showFullscreen, setShowFullscreen] = (0, import_react80.useState)(false);
16678
- const [copied, setCopied] = (0, import_react80.useState)(false);
16679
- const [approving, setApproving] = (0, import_react80.useState)(false);
16680
- const [regenerating, setRegenerating] = (0, import_react80.useState)(false);
16681
- const [approveError, setApproveError] = (0, import_react80.useState)(null);
16682
- const [messageEdits, setMessageEdits] = (0, import_react80.useState)({});
16683
- const [approvingOutline, setApprovingOutline] = (0, import_react80.useState)(false);
16684
- const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react80.useState)(null);
16685
- const [rowBusyIndex, setRowBusyIndex] = (0, import_react80.useState)(null);
16686
- const [rowError, setRowError] = (0, import_react80.useState)(null);
16687
- const [regenPollUrl, setRegenPollUrl] = (0, import_react80.useState)(null);
16688
- const [currentSlide, setCurrentSlide] = (0, import_react80.useState)(1);
16689
- const [iframeReady, setIframeReady] = (0, import_react80.useState)(false);
16690
- const iframeRef = (0, import_react80.useRef)(null);
16723
+ const [templateId, setTemplateId] = (0, import_react81.useState)(initialTemplateId || "");
16724
+ const [, setTemplateVersionId] = (0, import_react81.useState)(initialTemplateVersionId || "");
16725
+ const [reviewStatus, setReviewStatus] = (0, import_react81.useState)(initialReviewStatus || "");
16726
+ const [outline, setOutline] = (0, import_react81.useState)(initialOutline);
16727
+ const [slideTemplateOptions, setSlideTemplateOptions] = (0, import_react81.useState)(null);
16728
+ const [showExport, setShowExport] = (0, import_react81.useState)(false);
16729
+ const [showFullscreen, setShowFullscreen] = (0, import_react81.useState)(false);
16730
+ const [copied, setCopied] = (0, import_react81.useState)(false);
16731
+ const [approving, setApproving] = (0, import_react81.useState)(false);
16732
+ const [regenerating, setRegenerating] = (0, import_react81.useState)(false);
16733
+ const [approveError, setApproveError] = (0, import_react81.useState)(null);
16734
+ const [messageEdits, setMessageEdits] = (0, import_react81.useState)({});
16735
+ const [approvingOutline, setApprovingOutline] = (0, import_react81.useState)(false);
16736
+ const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react81.useState)(null);
16737
+ const [rowBusyIndex, setRowBusyIndex] = (0, import_react81.useState)(null);
16738
+ const [rowError, setRowError] = (0, import_react81.useState)(null);
16739
+ const [regenPollUrl, setRegenPollUrl] = (0, import_react81.useState)(null);
16740
+ const [currentSlide, setCurrentSlide] = (0, import_react81.useState)(1);
16741
+ const [iframeReady, setIframeReady] = (0, import_react81.useState)(false);
16742
+ const iframeRef = (0, import_react81.useRef)(null);
16691
16743
  const { containerRef: previewFitRef, scale: previewScale, canvasW, canvasH } = useDeckFitScale();
16692
- (0, import_react80.useEffect)(() => {
16744
+ (0, import_react81.useEffect)(() => {
16693
16745
  setStatus(initialStatus);
16694
16746
  }, [initialStatus]);
16695
16747
  const progressPct = initialProgress?.percentage;
16696
16748
  const progressStep = initialProgress?.current_step;
16697
- (0, import_react80.useEffect)(() => {
16749
+ (0, import_react81.useEffect)(() => {
16698
16750
  if (initialProgress) setProgress(initialProgress);
16699
16751
  }, [progressPct, progressStep]);
16700
- (0, import_react80.useEffect)(() => {
16752
+ (0, import_react81.useEffect)(() => {
16701
16753
  if (initialError) setError(initialError);
16702
16754
  }, [initialError]);
16703
- (0, import_react80.useEffect)(() => {
16755
+ (0, import_react81.useEffect)(() => {
16704
16756
  if (initialSlideCount !== void 0) setSlideCount(initialSlideCount);
16705
16757
  }, [initialSlideCount]);
16706
16758
  const htmlUrl = initialFormats?.html_url;
16707
- (0, import_react80.useEffect)(() => {
16759
+ (0, import_react81.useEffect)(() => {
16708
16760
  if (initialFormats) setFormats(initialFormats);
16709
16761
  }, [htmlUrl]);
16710
- (0, import_react80.useEffect)(() => {
16762
+ (0, import_react81.useEffect)(() => {
16711
16763
  if (initialTitle) setTitle(initialTitle);
16712
16764
  }, [initialTitle]);
16713
- (0, import_react80.useEffect)(() => {
16765
+ (0, import_react81.useEffect)(() => {
16714
16766
  if (initialGenerationMode) setGenerationMode(initialGenerationMode);
16715
16767
  }, [initialGenerationMode]);
16716
- (0, import_react80.useEffect)(() => {
16768
+ (0, import_react81.useEffect)(() => {
16717
16769
  if (initialTemplateId) setTemplateId(initialTemplateId);
16718
16770
  }, [initialTemplateId]);
16719
- (0, import_react80.useEffect)(() => {
16771
+ (0, import_react81.useEffect)(() => {
16720
16772
  if (initialTemplateVersionId) setTemplateVersionId(initialTemplateVersionId);
16721
16773
  }, [initialTemplateVersionId]);
16722
- (0, import_react80.useEffect)(() => {
16774
+ (0, import_react81.useEffect)(() => {
16723
16775
  if (initialReviewStatus) setReviewStatus(initialReviewStatus);
16724
16776
  }, [initialReviewStatus]);
16725
16777
  const initialOutlineSlideCount = initialOutline?.slides?.length;
16726
- (0, import_react80.useEffect)(() => {
16778
+ (0, import_react81.useEffect)(() => {
16727
16779
  if (initialOutline) setOutline(initialOutline);
16728
16780
  }, [initialOutlineSlideCount]);
16729
- (0, import_react80.useEffect)(() => {
16781
+ (0, import_react81.useEffect)(() => {
16730
16782
  if (reviewStatus !== "pending_outline_approval" || slideTemplateOptions !== null) return;
16731
16783
  let cancelled = false;
16732
16784
  (async () => {
@@ -16753,10 +16805,10 @@ var PresentationJobCard = ({
16753
16805
  cancelled = true;
16754
16806
  };
16755
16807
  }, [reviewStatus, slideTemplateOptions, templatesUrl, authToken]);
16756
- (0, import_react80.useEffect)(() => {
16808
+ (0, import_react81.useEffect)(() => {
16757
16809
  setIframeReady(false);
16758
16810
  }, [formats.html_url]);
16759
- (0, import_react80.useEffect)(() => {
16811
+ (0, import_react81.useEffect)(() => {
16760
16812
  const handler = (e) => {
16761
16813
  if (e.data?.type === "slideChanged") {
16762
16814
  setCurrentSlide(e.data.slide);
@@ -16782,15 +16834,15 @@ var PresentationJobCard = ({
16782
16834
  };
16783
16835
  const isTerminal = status === "complete" || status === "failed";
16784
16836
  const building = Boolean(outlineWritePollUrl) || approvingOutline;
16785
- const onCompleteRef = (0, import_react80.useRef)(onComplete);
16786
- const onFailedRef = (0, import_react80.useRef)(onFailed);
16787
- const hasNotifiedRef = (0, import_react80.useRef)(false);
16837
+ const onCompleteRef = (0, import_react81.useRef)(onComplete);
16838
+ const onFailedRef = (0, import_react81.useRef)(onFailed);
16839
+ const hasNotifiedRef = (0, import_react81.useRef)(false);
16788
16840
  onCompleteRef.current = onComplete;
16789
16841
  onFailedRef.current = onFailed;
16790
16842
  useSharedPoll(
16791
16843
  {
16792
16844
  key: !isTerminal && pollUrl ? pollUrl : null,
16793
- intervalMs: 3e3,
16845
+ intervalMs: SSE_FALLBACK_POLL_MS,
16794
16846
  fetcher: async () => {
16795
16847
  const headers = {};
16796
16848
  if (authToken) {
@@ -16850,7 +16902,7 @@ var PresentationJobCard = ({
16850
16902
  useSharedPoll(
16851
16903
  {
16852
16904
  key: building && pollUrl ? pollUrl : null,
16853
- intervalMs: 2e3,
16905
+ intervalMs: SSE_FALLBACK_POLL_MS,
16854
16906
  fetcher: async () => {
16855
16907
  const headers = {};
16856
16908
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -16864,7 +16916,7 @@ var PresentationJobCard = ({
16864
16916
  if (data.progress) setProgress(data.progress);
16865
16917
  }
16866
16918
  );
16867
- const applyDeckOutput = (0, import_react80.useCallback)((out, opts) => {
16919
+ const applyDeckOutput = (0, import_react81.useCallback)((out, opts) => {
16868
16920
  if (out.title) setTitle(out.title);
16869
16921
  if (out.slide_count !== void 0) setSlideCount(out.slide_count);
16870
16922
  if (out.formats) setFormats(out.formats);
@@ -16885,7 +16937,7 @@ var PresentationJobCard = ({
16885
16937
  });
16886
16938
  }
16887
16939
  }, [title, slideCount, formats, generationMode, templateId]);
16888
- const refetchSourceAndApply = (0, import_react80.useCallback)(async () => {
16940
+ const refetchSourceAndApply = (0, import_react81.useCallback)(async () => {
16889
16941
  if (!pollUrl) return;
16890
16942
  try {
16891
16943
  const headers = {};
@@ -16900,7 +16952,7 @@ var PresentationJobCard = ({
16900
16952
  useSharedPoll(
16901
16953
  {
16902
16954
  key: outlineWritePollUrl,
16903
- intervalMs: 3e3,
16955
+ intervalMs: SSE_FALLBACK_POLL_MS,
16904
16956
  fetcher: async () => {
16905
16957
  const headers = {};
16906
16958
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -16925,7 +16977,7 @@ var PresentationJobCard = ({
16925
16977
  useSharedPoll(
16926
16978
  {
16927
16979
  key: regenPollUrl,
16928
- intervalMs: 3e3,
16980
+ intervalMs: SSE_FALLBACK_POLL_MS,
16929
16981
  fetcher: async () => {
16930
16982
  const headers = {};
16931
16983
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -16947,6 +16999,16 @@ var PresentationJobCard = ({
16947
16999
  }
16948
17000
  }
16949
17001
  );
17002
+ useJobSignal(
17003
+ (0, import_react81.useCallback)(
17004
+ (completedJobId) => {
17005
+ for (const url of [pollUrl, outlineWritePollUrl, regenPollUrl]) {
17006
+ if (url && url.includes(completedJobId)) refreshSharedPoll(url);
17007
+ }
17008
+ },
17009
+ [pollUrl, outlineWritePollUrl, regenPollUrl]
17010
+ )
17011
+ );
16950
17012
  const buildEditedOutline = () => {
16951
17013
  if (!outline || !Array.isArray(outline.slides)) return void 0;
16952
17014
  let changed = false;
@@ -17639,7 +17701,7 @@ var PresentationJobCard = ({
17639
17701
  };
17640
17702
 
17641
17703
  // src/molecules/generic/ResearchReportJobCard/ResearchReportJobCard.tsx
17642
- var import_react81 = require("react");
17704
+ var import_react82 = require("react");
17643
17705
  var import_jsx_runtime152 = require("react/jsx-runtime");
17644
17706
  var DEFAULT_THEME = {
17645
17707
  primary: "#C0AE82",
@@ -17675,14 +17737,14 @@ function withPdfViewerParams(url) {
17675
17737
  return `${url}#toolbar=0&navpanes=0&scrollbar=0`;
17676
17738
  }
17677
17739
  var FullscreenPreviewModal = ({ url, title, onClose, isPdf }) => {
17678
- (0, import_react81.useEffect)(() => {
17740
+ (0, import_react82.useEffect)(() => {
17679
17741
  const onKey = (e) => {
17680
17742
  if (e.key === "Escape") onClose();
17681
17743
  };
17682
17744
  document.addEventListener("keydown", onKey);
17683
17745
  return () => document.removeEventListener("keydown", onKey);
17684
17746
  }, [onClose]);
17685
- (0, import_react81.useEffect)(() => {
17747
+ (0, import_react82.useEffect)(() => {
17686
17748
  document.body.style.overflow = "hidden";
17687
17749
  return () => {
17688
17750
  document.body.style.overflow = "";
@@ -17739,8 +17801,8 @@ var ReportExportModal = ({ htmlUrl, pdfUrl, title, onClose }) => {
17739
17801
  const urls = { pdf: pdfUrl, html: htmlUrl };
17740
17802
  const available = REPORT_FORMATS.filter((f) => urls[f.key]);
17741
17803
  const filename = (title ?? "").replace(/[^a-z0-9]/gi, "-").toLowerCase();
17742
- const [downloadingKey, setDownloadingKey] = (0, import_react81.useState)(null);
17743
- (0, import_react81.useEffect)(() => {
17804
+ const [downloadingKey, setDownloadingKey] = (0, import_react82.useState)(null);
17805
+ (0, import_react82.useEffect)(() => {
17744
17806
  const onKey = (e) => {
17745
17807
  if (e.key === "Escape") onClose();
17746
17808
  };
@@ -17853,95 +17915,95 @@ var ResearchReportJobCard = (props) => {
17853
17915
  compact = false
17854
17916
  } = props;
17855
17917
  const inferredStatus = initialStatus ?? (initialHtmlUrl ? "complete" : void 0);
17856
- const [status, setStatus] = (0, import_react81.useState)(inferredStatus);
17857
- const [title, setTitle] = (0, import_react81.useState)(initialTitle);
17858
- const [depth, setDepth] = (0, import_react81.useState)(initialDepth || "");
17859
- const [sectionCount, setSectionCount] = (0, import_react81.useState)(initialSectionCount ?? 0);
17860
- const [sourceCount, setSourceCount] = (0, import_react81.useState)(initialSourceCount ?? 0);
17861
- const [wordCount, setWordCount] = (0, import_react81.useState)(initialWordCount ?? 0);
17862
- const [summary, setSummary] = (0, import_react81.useState)(initialSummary || "");
17863
- const [htmlUrl, setHtmlUrl] = (0, import_react81.useState)(initialHtmlUrl || "");
17864
- const [pdfUrl, setPdfUrl] = (0, import_react81.useState)(initialPdfUrl || "");
17865
- const [generationMode, setGenerationMode] = (0, import_react81.useState)(
17918
+ const [status, setStatus] = (0, import_react82.useState)(inferredStatus);
17919
+ const [title, setTitle] = (0, import_react82.useState)(initialTitle);
17920
+ const [depth, setDepth] = (0, import_react82.useState)(initialDepth || "");
17921
+ const [sectionCount, setSectionCount] = (0, import_react82.useState)(initialSectionCount ?? 0);
17922
+ const [sourceCount, setSourceCount] = (0, import_react82.useState)(initialSourceCount ?? 0);
17923
+ const [wordCount, setWordCount] = (0, import_react82.useState)(initialWordCount ?? 0);
17924
+ const [summary, setSummary] = (0, import_react82.useState)(initialSummary || "");
17925
+ const [htmlUrl, setHtmlUrl] = (0, import_react82.useState)(initialHtmlUrl || "");
17926
+ const [pdfUrl, setPdfUrl] = (0, import_react82.useState)(initialPdfUrl || "");
17927
+ const [generationMode, setGenerationMode] = (0, import_react82.useState)(
17866
17928
  initialGenerationMode || (initialHtmlUrl ? "template" : "")
17867
17929
  );
17868
- const [templateId, setTemplateId] = (0, import_react81.useState)(initialTemplateId || "");
17869
- const [templateVersionId, setTemplateVersionId] = (0, import_react81.useState)(initialTemplateVersionId || "");
17870
- const [reviewStatus, setReviewStatus] = (0, import_react81.useState)(
17930
+ const [templateId, setTemplateId] = (0, import_react82.useState)(initialTemplateId || "");
17931
+ const [templateVersionId, setTemplateVersionId] = (0, import_react82.useState)(initialTemplateVersionId || "");
17932
+ const [reviewStatus, setReviewStatus] = (0, import_react82.useState)(
17871
17933
  initialReviewStatus || (initialHtmlUrl ? "pending_review" : "")
17872
17934
  );
17873
- const [outline, setOutline] = (0, import_react81.useState)(initialOutline);
17874
- const [theme, setTheme] = (0, import_react81.useState)(initialTheme || DEFAULT_THEME);
17875
- const [error, setError] = (0, import_react81.useState)(initialError);
17876
- const [progress, setProgress] = (0, import_react81.useState)(initialProgress);
17877
- const [showPreview, setShowPreview] = (0, import_react81.useState)(false);
17878
- const [showExport, setShowExport] = (0, import_react81.useState)(false);
17879
- const [copied, setCopied] = (0, import_react81.useState)(false);
17880
- const [approving, setApproving] = (0, import_react81.useState)(false);
17881
- const [regenerating, setRegenerating] = (0, import_react81.useState)(false);
17882
- const [approveError, setApproveError] = (0, import_react81.useState)(null);
17883
- const [headingEdits, setHeadingEdits] = (0, import_react81.useState)({});
17884
- const [approvingOutline, setApprovingOutline] = (0, import_react81.useState)(false);
17885
- const [rowBusyIndex, setRowBusyIndex] = (0, import_react81.useState)(null);
17886
- const [rowError, setRowError] = (0, import_react81.useState)(null);
17887
- const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react81.useState)(null);
17888
- const [regenPollUrl, setRegenPollUrl] = (0, import_react81.useState)(null);
17889
- const onCompleteRef = (0, import_react81.useRef)(onComplete);
17890
- const onFailedRef = (0, import_react81.useRef)(onFailed);
17891
- const hasNotifiedRef = (0, import_react81.useRef)(false);
17935
+ const [outline, setOutline] = (0, import_react82.useState)(initialOutline);
17936
+ const [theme, setTheme] = (0, import_react82.useState)(initialTheme || DEFAULT_THEME);
17937
+ const [error, setError] = (0, import_react82.useState)(initialError);
17938
+ const [progress, setProgress] = (0, import_react82.useState)(initialProgress);
17939
+ const [showPreview, setShowPreview] = (0, import_react82.useState)(false);
17940
+ const [showExport, setShowExport] = (0, import_react82.useState)(false);
17941
+ const [copied, setCopied] = (0, import_react82.useState)(false);
17942
+ const [approving, setApproving] = (0, import_react82.useState)(false);
17943
+ const [regenerating, setRegenerating] = (0, import_react82.useState)(false);
17944
+ const [approveError, setApproveError] = (0, import_react82.useState)(null);
17945
+ const [headingEdits, setHeadingEdits] = (0, import_react82.useState)({});
17946
+ const [approvingOutline, setApprovingOutline] = (0, import_react82.useState)(false);
17947
+ const [rowBusyIndex, setRowBusyIndex] = (0, import_react82.useState)(null);
17948
+ const [rowError, setRowError] = (0, import_react82.useState)(null);
17949
+ const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react82.useState)(null);
17950
+ const [regenPollUrl, setRegenPollUrl] = (0, import_react82.useState)(null);
17951
+ const onCompleteRef = (0, import_react82.useRef)(onComplete);
17952
+ const onFailedRef = (0, import_react82.useRef)(onFailed);
17953
+ const hasNotifiedRef = (0, import_react82.useRef)(false);
17892
17954
  onCompleteRef.current = onComplete;
17893
17955
  onFailedRef.current = onFailed;
17894
- (0, import_react81.useEffect)(() => {
17956
+ (0, import_react82.useEffect)(() => {
17895
17957
  const newStatus = initialStatus ?? (initialHtmlUrl ? "complete" : void 0);
17896
17958
  setStatus(newStatus);
17897
17959
  }, [initialStatus, initialHtmlUrl]);
17898
- (0, import_react81.useEffect)(() => {
17960
+ (0, import_react82.useEffect)(() => {
17899
17961
  if (initialTitle) setTitle(initialTitle);
17900
17962
  }, [initialTitle]);
17901
- (0, import_react81.useEffect)(() => {
17963
+ (0, import_react82.useEffect)(() => {
17902
17964
  if (initialHtmlUrl) setHtmlUrl(initialHtmlUrl);
17903
17965
  }, [initialHtmlUrl]);
17904
- (0, import_react81.useEffect)(() => {
17966
+ (0, import_react82.useEffect)(() => {
17905
17967
  if (initialGenerationMode) setGenerationMode(initialGenerationMode);
17906
17968
  }, [initialGenerationMode]);
17907
- (0, import_react81.useEffect)(() => {
17969
+ (0, import_react82.useEffect)(() => {
17908
17970
  if (initialTemplateId) setTemplateId(initialTemplateId);
17909
17971
  }, [initialTemplateId]);
17910
- (0, import_react81.useEffect)(() => {
17972
+ (0, import_react82.useEffect)(() => {
17911
17973
  if (initialTemplateVersionId) setTemplateVersionId(initialTemplateVersionId);
17912
17974
  }, [initialTemplateVersionId]);
17913
- (0, import_react81.useEffect)(() => {
17975
+ (0, import_react82.useEffect)(() => {
17914
17976
  if (initialReviewStatus) setReviewStatus(initialReviewStatus);
17915
17977
  }, [initialReviewStatus]);
17916
17978
  const initialOutlineSectionCount = initialOutline?.sections?.length;
17917
- (0, import_react81.useEffect)(() => {
17979
+ (0, import_react82.useEffect)(() => {
17918
17980
  if (initialOutline) setOutline(initialOutline);
17919
17981
  }, [initialOutlineSectionCount]);
17920
- (0, import_react81.useEffect)(() => {
17982
+ (0, import_react82.useEffect)(() => {
17921
17983
  if (initialDepth) setDepth(initialDepth);
17922
17984
  }, [initialDepth]);
17923
- (0, import_react81.useEffect)(() => {
17985
+ (0, import_react82.useEffect)(() => {
17924
17986
  if (initialSectionCount !== void 0) setSectionCount(initialSectionCount);
17925
17987
  }, [initialSectionCount]);
17926
- (0, import_react81.useEffect)(() => {
17988
+ (0, import_react82.useEffect)(() => {
17927
17989
  if (initialSourceCount !== void 0) setSourceCount(initialSourceCount);
17928
17990
  }, [initialSourceCount]);
17929
- (0, import_react81.useEffect)(() => {
17991
+ (0, import_react82.useEffect)(() => {
17930
17992
  if (initialWordCount !== void 0) setWordCount(initialWordCount);
17931
17993
  }, [initialWordCount]);
17932
- (0, import_react81.useEffect)(() => {
17994
+ (0, import_react82.useEffect)(() => {
17933
17995
  if (initialSummary) setSummary(initialSummary);
17934
17996
  }, [initialSummary]);
17935
17997
  const themePrimary = initialTheme?.primary;
17936
- (0, import_react81.useEffect)(() => {
17998
+ (0, import_react82.useEffect)(() => {
17937
17999
  if (initialTheme) setTheme(initialTheme);
17938
18000
  }, [themePrimary]);
17939
- (0, import_react81.useEffect)(() => {
18001
+ (0, import_react82.useEffect)(() => {
17940
18002
  if (initialError) setError(initialError);
17941
18003
  }, [initialError]);
17942
18004
  const progressPct = initialProgress?.percentage;
17943
18005
  const progressStep = initialProgress?.current_step;
17944
- (0, import_react81.useEffect)(() => {
18006
+ (0, import_react82.useEffect)(() => {
17945
18007
  if (initialProgress) setProgress(initialProgress);
17946
18008
  }, [progressPct, progressStep]);
17947
18009
  const isTerminal = status === "complete" || status === "failed";
@@ -17951,7 +18013,7 @@ var ResearchReportJobCard = (props) => {
17951
18013
  useSharedPoll(
17952
18014
  {
17953
18015
  key: !isTerminal && pollUrl ? pollUrl : null,
17954
- intervalMs: 3e3,
18016
+ intervalMs: SSE_FALLBACK_POLL_MS,
17955
18017
  fetcher: async () => {
17956
18018
  const headers = {};
17957
18019
  if (authToken) {
@@ -18007,7 +18069,7 @@ var ResearchReportJobCard = (props) => {
18007
18069
  useSharedPoll(
18008
18070
  {
18009
18071
  key: building && pollUrl ? pollUrl : null,
18010
- intervalMs: 2e3,
18072
+ intervalMs: SSE_FALLBACK_POLL_MS,
18011
18073
  fetcher: async () => {
18012
18074
  const headers = {};
18013
18075
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -18021,7 +18083,7 @@ var ResearchReportJobCard = (props) => {
18021
18083
  if (data.progress) setProgress(data.progress);
18022
18084
  }
18023
18085
  );
18024
- const applyRegeneratedOutput = (0, import_react81.useCallback)(
18086
+ const applyRegeneratedOutput = (0, import_react82.useCallback)(
18025
18087
  (out) => {
18026
18088
  if (out.html_url) setHtmlUrl(out.html_url);
18027
18089
  setPdfUrl(out.pdf_url || "");
@@ -18054,7 +18116,7 @@ var ResearchReportJobCard = (props) => {
18054
18116
  useSharedPoll(
18055
18117
  {
18056
18118
  key: regenPollUrl,
18057
- intervalMs: 3e3,
18119
+ intervalMs: SSE_FALLBACK_POLL_MS,
18058
18120
  fetcher: async () => {
18059
18121
  const headers = {};
18060
18122
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -18076,7 +18138,7 @@ var ResearchReportJobCard = (props) => {
18076
18138
  }
18077
18139
  }
18078
18140
  );
18079
- const refetchSourceAndApply = (0, import_react81.useCallback)(async () => {
18141
+ const refetchSourceAndApply = (0, import_react82.useCallback)(async () => {
18080
18142
  if (!pollUrl) return;
18081
18143
  try {
18082
18144
  const headers = {};
@@ -18109,7 +18171,7 @@ var ResearchReportJobCard = (props) => {
18109
18171
  useSharedPoll(
18110
18172
  {
18111
18173
  key: outlineWritePollUrl,
18112
- intervalMs: 3e3,
18174
+ intervalMs: SSE_FALLBACK_POLL_MS,
18113
18175
  fetcher: async () => {
18114
18176
  const headers = {};
18115
18177
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -18131,6 +18193,16 @@ var ResearchReportJobCard = (props) => {
18131
18193
  }
18132
18194
  }
18133
18195
  );
18196
+ useJobSignal(
18197
+ (0, import_react82.useCallback)(
18198
+ (completedJobId) => {
18199
+ for (const url of [pollUrl, outlineWritePollUrl, regenPollUrl]) {
18200
+ if (url && url.includes(completedJobId)) refreshSharedPoll(url);
18201
+ }
18202
+ },
18203
+ [pollUrl, outlineWritePollUrl, regenPollUrl]
18204
+ )
18205
+ );
18134
18206
  const buildEditedOutline = () => {
18135
18207
  if (!outline || !Array.isArray(outline.sections)) return void 0;
18136
18208
  let changed = false;
@@ -18804,7 +18876,7 @@ var ResearchReportJobCard = (props) => {
18804
18876
  };
18805
18877
 
18806
18878
  // src/molecules/generic/WebSearchJobCard/WebSearchJobCard.tsx
18807
- var import_react82 = require("react");
18879
+ var import_react83 = require("react");
18808
18880
  var import_jsx_runtime153 = require("react/jsx-runtime");
18809
18881
  var SearchIcon = () => /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
18810
18882
  /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("circle", { cx: "11", cy: "11", r: "8" }),
@@ -18833,46 +18905,46 @@ var WebSearchJobCard = ({
18833
18905
  onFailed,
18834
18906
  compact = false
18835
18907
  }) => {
18836
- const [status, setStatus] = (0, import_react82.useState)(initialStatus);
18837
- const [query, setQuery] = (0, import_react82.useState)(initialQuery || initialTitle || "");
18838
- const [resultCount, setResultCount] = (0, import_react82.useState)(initialResultCount ?? 0);
18839
- const [searchCount, setSearchCount] = (0, import_react82.useState)(initialSearchCount ?? 0);
18840
- const [summary, setSummary] = (0, import_react82.useState)(initialSummary || "");
18841
- const [results, setResults] = (0, import_react82.useState)(initialResults || []);
18842
- const [error, setError] = (0, import_react82.useState)(initialError);
18843
- const [progress, setProgress] = (0, import_react82.useState)(initialProgress);
18844
- const onCompleteRef = (0, import_react82.useRef)(onComplete);
18845
- const onFailedRef = (0, import_react82.useRef)(onFailed);
18846
- const hasNotifiedRef = (0, import_react82.useRef)(false);
18908
+ const [status, setStatus] = (0, import_react83.useState)(initialStatus);
18909
+ const [query, setQuery] = (0, import_react83.useState)(initialQuery || initialTitle || "");
18910
+ const [resultCount, setResultCount] = (0, import_react83.useState)(initialResultCount ?? 0);
18911
+ const [searchCount, setSearchCount] = (0, import_react83.useState)(initialSearchCount ?? 0);
18912
+ const [summary, setSummary] = (0, import_react83.useState)(initialSummary || "");
18913
+ const [results, setResults] = (0, import_react83.useState)(initialResults || []);
18914
+ const [error, setError] = (0, import_react83.useState)(initialError);
18915
+ const [progress, setProgress] = (0, import_react83.useState)(initialProgress);
18916
+ const onCompleteRef = (0, import_react83.useRef)(onComplete);
18917
+ const onFailedRef = (0, import_react83.useRef)(onFailed);
18918
+ const hasNotifiedRef = (0, import_react83.useRef)(false);
18847
18919
  onCompleteRef.current = onComplete;
18848
18920
  onFailedRef.current = onFailed;
18849
- (0, import_react82.useEffect)(() => {
18921
+ (0, import_react83.useEffect)(() => {
18850
18922
  setStatus(initialStatus);
18851
18923
  }, [initialStatus]);
18852
- (0, import_react82.useEffect)(() => {
18924
+ (0, import_react83.useEffect)(() => {
18853
18925
  if (initialQuery) setQuery(initialQuery);
18854
18926
  }, [initialQuery]);
18855
- (0, import_react82.useEffect)(() => {
18927
+ (0, import_react83.useEffect)(() => {
18856
18928
  if (initialTitle && !initialQuery) setQuery(initialTitle);
18857
18929
  }, [initialTitle, initialQuery]);
18858
- (0, import_react82.useEffect)(() => {
18930
+ (0, import_react83.useEffect)(() => {
18859
18931
  if (initialResultCount !== void 0) setResultCount(initialResultCount);
18860
18932
  }, [initialResultCount]);
18861
- (0, import_react82.useEffect)(() => {
18933
+ (0, import_react83.useEffect)(() => {
18862
18934
  if (initialSearchCount !== void 0) setSearchCount(initialSearchCount);
18863
18935
  }, [initialSearchCount]);
18864
- (0, import_react82.useEffect)(() => {
18936
+ (0, import_react83.useEffect)(() => {
18865
18937
  if (initialSummary) setSummary(initialSummary);
18866
18938
  }, [initialSummary]);
18867
- (0, import_react82.useEffect)(() => {
18939
+ (0, import_react83.useEffect)(() => {
18868
18940
  if (initialResults) setResults(initialResults);
18869
18941
  }, [initialResults]);
18870
- (0, import_react82.useEffect)(() => {
18942
+ (0, import_react83.useEffect)(() => {
18871
18943
  if (initialError) setError(initialError);
18872
18944
  }, [initialError]);
18873
18945
  const progressPct = initialProgress?.percentage;
18874
18946
  const progressStep = initialProgress?.current_step;
18875
- (0, import_react82.useEffect)(() => {
18947
+ (0, import_react83.useEffect)(() => {
18876
18948
  if (initialProgress) setProgress(initialProgress);
18877
18949
  }, [progressPct, progressStep]);
18878
18950
  const isTerminal = status === "complete" || status === "failed";
@@ -19057,10 +19129,10 @@ var WebSearchJobCard = ({
19057
19129
  };
19058
19130
 
19059
19131
  // src/molecules/creator-discovery/CampaignSeedCard/CampaignSeedCard.tsx
19060
- var import_react84 = __toESM(require("react"), 1);
19132
+ var import_react85 = __toESM(require("react"), 1);
19061
19133
 
19062
19134
  // src/molecules/creator-discovery/SearchSpecCard/CustomFieldRenderers.tsx
19063
- var import_react83 = require("react");
19135
+ var import_react84 = require("react");
19064
19136
 
19065
19137
  // src/lib/countries.ts
19066
19138
  var countries = [
@@ -19272,10 +19344,10 @@ var CountrySelectEdit = ({
19272
19344
  value,
19273
19345
  onChange
19274
19346
  }) => {
19275
- const [isDropdownOpen, setIsDropdownOpen] = (0, import_react83.useState)(false);
19276
- const [searchTerm, setSearchTerm] = (0, import_react83.useState)("");
19277
- const dropdownRef = (0, import_react83.useRef)(null);
19278
- (0, import_react83.useEffect)(() => {
19347
+ const [isDropdownOpen, setIsDropdownOpen] = (0, import_react84.useState)(false);
19348
+ const [searchTerm, setSearchTerm] = (0, import_react84.useState)("");
19349
+ const dropdownRef = (0, import_react84.useRef)(null);
19350
+ (0, import_react84.useEffect)(() => {
19279
19351
  const handleClickOutside = (event) => {
19280
19352
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
19281
19353
  setIsDropdownOpen(false);
@@ -19284,7 +19356,7 @@ var CountrySelectEdit = ({
19284
19356
  document.addEventListener("mousedown", handleClickOutside);
19285
19357
  return () => document.removeEventListener("mousedown", handleClickOutside);
19286
19358
  }, []);
19287
- const inputValue = (0, import_react83.useMemo)(() => {
19359
+ const inputValue = (0, import_react84.useMemo)(() => {
19288
19360
  if (Array.isArray(value)) return value;
19289
19361
  if (typeof value === "string" && value.trim() !== "") {
19290
19362
  const foundCountry = countries.find(
@@ -19385,7 +19457,7 @@ var CountrySelectEdit = ({
19385
19457
  ] });
19386
19458
  };
19387
19459
  var CountrySelectDisplay = ({ value }) => {
19388
- const displayValues = (0, import_react83.useMemo)(() => {
19460
+ const displayValues = (0, import_react84.useMemo)(() => {
19389
19461
  if (Array.isArray(value)) return value;
19390
19462
  if (typeof value === "string" && value.trim() !== "") return [value];
19391
19463
  return [];
@@ -19561,7 +19633,7 @@ var PlatformSelectEdit = ({
19561
19633
  value,
19562
19634
  onChange
19563
19635
  }) => {
19564
- const selectedPlatforms = (0, import_react83.useMemo)(() => {
19636
+ const selectedPlatforms = (0, import_react84.useMemo)(() => {
19565
19637
  if (Array.isArray(value)) return value;
19566
19638
  if (typeof value === "string" && value.trim() !== "") {
19567
19639
  return value.split(",").map((s) => s.trim()).filter(Boolean);
@@ -19580,7 +19652,7 @@ var PlatformSelectEdit = ({
19580
19652
  onChange([...selectedPlatforms, platform]);
19581
19653
  }
19582
19654
  };
19583
- const options = (0, import_react83.useMemo)(() => {
19655
+ const options = (0, import_react84.useMemo)(() => {
19584
19656
  return DEFAULT_PLATFORMS;
19585
19657
  }, []);
19586
19658
  return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("div", { className: "flex flex-wrap gap-4 py-2", children: options.map((platform) => /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(
@@ -19606,7 +19678,7 @@ var PlatformSelectEdit = ({
19606
19678
  )) });
19607
19679
  };
19608
19680
  var PlatformSelectDisplay = ({ value }) => {
19609
- const displayValues = (0, import_react83.useMemo)(() => {
19681
+ const displayValues = (0, import_react84.useMemo)(() => {
19610
19682
  if (Array.isArray(value)) return value;
19611
19683
  if (typeof value === "string" && value.trim() !== "") {
19612
19684
  return value.split(",").map((s) => s.trim()).filter(Boolean);
@@ -19766,7 +19838,7 @@ function buildCampaignSeedFields(data) {
19766
19838
  return generated;
19767
19839
  });
19768
19840
  }
19769
- var CampaignSeedCard = import_react84.default.memo(
19841
+ var CampaignSeedCard = import_react85.default.memo(
19770
19842
  ({
19771
19843
  selectionStatus,
19772
19844
  isLatestMessage = true,
@@ -19778,7 +19850,7 @@ var CampaignSeedCard = import_react84.default.memo(
19778
19850
  sendMessage,
19779
19851
  ...formCardProps
19780
19852
  }) => {
19781
- const fields = (0, import_react84.useMemo)(() => {
19853
+ const fields = (0, import_react85.useMemo)(() => {
19782
19854
  return providedFields || buildCampaignSeedFields(data);
19783
19855
  }, [providedFields, data]);
19784
19856
  const handleProceed = () => {
@@ -19812,7 +19884,7 @@ var CampaignSeedCard = import_react84.default.memo(
19812
19884
  CampaignSeedCard.displayName = "CampaignSeedCard";
19813
19885
 
19814
19886
  // src/molecules/creator-discovery/SearchSpecCard/SearchSpecCard.tsx
19815
- var import_react85 = __toESM(require("react"), 1);
19887
+ var import_react86 = __toESM(require("react"), 1);
19816
19888
  var import_jsx_runtime156 = require("react/jsx-runtime");
19817
19889
  var ObjectDisplay2 = ({ value }) => {
19818
19890
  if (!value || typeof value !== "object") return null;
@@ -19928,7 +20000,7 @@ function buildSearchSpecFields(data) {
19928
20000
  return generated;
19929
20001
  });
19930
20002
  }
19931
- var SearchSpecCard = import_react85.default.memo(
20003
+ var SearchSpecCard = import_react86.default.memo(
19932
20004
  ({
19933
20005
  selectionStatus,
19934
20006
  isLatestMessage = true,
@@ -19942,7 +20014,7 @@ var SearchSpecCard = import_react85.default.memo(
19942
20014
  ...formCardProps
19943
20015
  }) => {
19944
20016
  const resolvedData = data || specData;
19945
- const fields = (0, import_react85.useMemo)(() => {
20017
+ const fields = (0, import_react86.useMemo)(() => {
19946
20018
  return providedFields || buildSearchSpecFields(resolvedData ?? {});
19947
20019
  }, [providedFields, resolvedData]);
19948
20020
  const handleProceed = () => {
@@ -19978,7 +20050,7 @@ var SearchSpecCard = import_react85.default.memo(
19978
20050
  SearchSpecCard.displayName = "SearchSpecCard";
19979
20051
 
19980
20052
  // src/molecules/creator-discovery/MCQCard/MCQCard.tsx
19981
- var import_react86 = __toESM(require("react"), 1);
20053
+ var import_react87 = __toESM(require("react"), 1);
19982
20054
 
19983
20055
  // src/lib/auth-provider.ts
19984
20056
  var _provider = null;
@@ -20148,7 +20220,7 @@ function inferSelectionLimits(text, optionCount) {
20148
20220
  }
20149
20221
  return null;
20150
20222
  }
20151
- var MCQCard = import_react86.default.memo(
20223
+ var MCQCard = import_react87.default.memo(
20152
20224
  ({
20153
20225
  question,
20154
20226
  options,
@@ -20206,12 +20278,12 @@ var MCQCard = import_react86.default.memo(
20206
20278
  if (propsSelectedOption) return [propsSelectedOption];
20207
20279
  return [];
20208
20280
  };
20209
- const [selectedKeys, setSelectedKeys] = import_react86.default.useState(seedSelection);
20210
- const [isProceeded, setIsProceeded] = import_react86.default.useState(
20281
+ const [selectedKeys, setSelectedKeys] = import_react87.default.useState(seedSelection);
20282
+ const [isProceeded, setIsProceeded] = import_react87.default.useState(
20211
20283
  Boolean(propsSelectedOption || propsSelectedOptions && propsSelectedOptions.length)
20212
20284
  );
20213
- const fetchedSessionRef = import_react86.default.useRef("");
20214
- import_react86.default.useEffect(() => {
20285
+ const fetchedSessionRef = import_react87.default.useRef("");
20286
+ import_react87.default.useEffect(() => {
20215
20287
  if (propsSelectedOption) {
20216
20288
  setSelectedKeys([propsSelectedOption]);
20217
20289
  setIsProceeded(true);
@@ -20220,7 +20292,7 @@ var MCQCard = import_react86.default.memo(
20220
20292
  setIsProceeded(true);
20221
20293
  }
20222
20294
  }, [propsSelectedOption, propsSelectedOptions]);
20223
- const buildQuestionKey = import_react86.default.useCallback((sid, q) => {
20295
+ const buildQuestionKey = import_react87.default.useCallback((sid, q) => {
20224
20296
  let hash = 2166136261;
20225
20297
  for (let i = 0; i < q.length; i++) {
20226
20298
  hash ^= q.charCodeAt(i);
@@ -20228,7 +20300,7 @@ var MCQCard = import_react86.default.memo(
20228
20300
  }
20229
20301
  return `mcq_${sid}_${hash.toString(36)}`;
20230
20302
  }, []);
20231
- import_react86.default.useEffect(() => {
20303
+ import_react87.default.useEffect(() => {
20232
20304
  if (!sessionId || !resolvedQuestion) return;
20233
20305
  const fetchKey = `${sessionId}::${resolvedQuestion}`;
20234
20306
  if (fetchedSessionRef.current === fetchKey) return;
@@ -20900,9 +20972,9 @@ var CreatorActionHeader = ({
20900
20972
  };
20901
20973
 
20902
20974
  // src/molecules/creator-discovery/CreatorSearchBox/CreatorSearch.tsx
20903
- var import_react87 = __toESM(require("react"), 1);
20975
+ var import_react88 = __toESM(require("react"), 1);
20904
20976
  var import_jsx_runtime168 = require("react/jsx-runtime");
20905
- var CreatorSearch = import_react87.default.memo(
20977
+ var CreatorSearch = import_react88.default.memo(
20906
20978
  ({
20907
20979
  selectionStatus,
20908
20980
  isLatestMessage = true,
@@ -20911,7 +20983,7 @@ var CreatorSearch = import_react87.default.memo(
20911
20983
  data,
20912
20984
  ...formCardProps
20913
20985
  }) => {
20914
- const fields = (0, import_react87.useMemo)(() => {
20986
+ const fields = (0, import_react88.useMemo)(() => {
20915
20987
  const baseFields = providedFields || generateFieldsFromData(data);
20916
20988
  return baseFields.map((field) => {
20917
20989
  if (field.key === "platforms") {
@@ -20991,10 +21063,10 @@ var CreatorSearch = import_react87.default.memo(
20991
21063
  CreatorSearch.displayName = "CreatorSearch";
20992
21064
 
20993
21065
  // src/molecules/creator-discovery/CampaignConceptCard/CampaignConceptCard.tsx
20994
- var import_react88 = __toESM(require("react"), 1);
21066
+ var import_react89 = __toESM(require("react"), 1);
20995
21067
  var import_framer_motion = require("framer-motion");
20996
21068
  var import_jsx_runtime169 = require("react/jsx-runtime");
20997
- var CampaignConceptCard = import_react88.default.memo(
21069
+ var CampaignConceptCard = import_react89.default.memo(
20998
21070
  ({
20999
21071
  index,
21000
21072
  isRecommended,
@@ -21010,7 +21082,7 @@ var CampaignConceptCard = import_react88.default.memo(
21010
21082
  onAction,
21011
21083
  ...formCardProps
21012
21084
  }) => {
21013
- const [internalIsOpen, setInternalIsOpen] = (0, import_react88.useState)(false);
21085
+ const [internalIsOpen, setInternalIsOpen] = (0, import_react89.useState)(false);
21014
21086
  const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
21015
21087
  const handleToggle = () => {
21016
21088
  if (onToggle) {
@@ -21029,7 +21101,7 @@ var CampaignConceptCard = import_react88.default.memo(
21029
21101
  });
21030
21102
  };
21031
21103
  const effectiveIsLatest = isLatestMessage && !hasUserResponded;
21032
- const fields = (0, import_react88.useMemo)(() => {
21104
+ const fields = (0, import_react89.useMemo)(() => {
21033
21105
  const baseFields = providedFields || generateFieldsFromData(data);
21034
21106
  const FIELD_ORDER = [
21035
21107
  "description",
@@ -21341,14 +21413,14 @@ var CampaignConceptCard = import_react88.default.memo(
21341
21413
  CampaignConceptCard.displayName = "CampaignConceptCard";
21342
21414
 
21343
21415
  // src/molecules/creator-discovery/CreatorWidget/CreatorWidget.tsx
21344
- var import_react96 = require("react");
21416
+ var import_react97 = require("react");
21345
21417
 
21346
21418
  // src/molecules/creator-discovery/CreatorWidget/CreatorImageList.tsx
21347
- var import_react89 = require("react");
21419
+ var import_react90 = require("react");
21348
21420
  var import_jsx_runtime170 = require("react/jsx-runtime");
21349
21421
  function useMediaQuery(query) {
21350
- const [matches, setMatches] = (0, import_react89.useState)(false);
21351
- (0, import_react89.useEffect)(() => {
21422
+ const [matches, setMatches] = (0, import_react90.useState)(false);
21423
+ (0, import_react90.useEffect)(() => {
21352
21424
  const media = window.matchMedia(query);
21353
21425
  const listener = () => setMatches(media.matches);
21354
21426
  listener();
@@ -21431,7 +21503,7 @@ function CreatorImageList({
21431
21503
  }
21432
21504
 
21433
21505
  // src/molecules/creator-discovery/CreatorWidget/CreatorProgressBar.tsx
21434
- var import_react90 = require("react");
21506
+ var import_react91 = require("react");
21435
21507
  var import_framer_motion2 = require("framer-motion");
21436
21508
  var import_jsx_runtime171 = require("react/jsx-runtime");
21437
21509
  function truncateName(name, maxLength) {
@@ -21439,8 +21511,8 @@ function truncateName(name, maxLength) {
21439
21511
  return name.substring(0, maxLength) + "...";
21440
21512
  }
21441
21513
  function ProgressBar({ overallPercentage }) {
21442
- const [showTooltip, setShowTooltip] = (0, import_react90.useState)(true);
21443
- (0, import_react90.useEffect)(() => {
21514
+ const [showTooltip, setShowTooltip] = (0, import_react91.useState)(true);
21515
+ (0, import_react91.useEffect)(() => {
21444
21516
  if (overallPercentage && overallPercentage >= 100) {
21445
21517
  setShowTooltip(false);
21446
21518
  }
@@ -21601,7 +21673,7 @@ function CreatorCompactView({
21601
21673
  }
21602
21674
 
21603
21675
  // src/molecules/creator-discovery/CreatorWidget/CreatorExpandedPanel.tsx
21604
- var import_react94 = require("react");
21676
+ var import_react95 = require("react");
21605
21677
  var import_react_dom2 = __toESM(require("react-dom"), 1);
21606
21678
  var import_framer_motion5 = require("framer-motion");
21607
21679
 
@@ -22075,7 +22147,7 @@ function getPlatformIconColor(platform) {
22075
22147
  }
22076
22148
 
22077
22149
  // src/molecules/creator-discovery/CreatorWidget/PostCard.tsx
22078
- var import_react91 = require("react");
22150
+ var import_react92 = require("react");
22079
22151
  var import_jsx_runtime176 = require("react/jsx-runtime");
22080
22152
  var formatFollowerCount = (count) => {
22081
22153
  if (count >= 1e6) {
@@ -22089,8 +22161,8 @@ var formatFollowerCount = (count) => {
22089
22161
  return Math.floor(count).toString();
22090
22162
  };
22091
22163
  function PostCard({ post, platformUsername }) {
22092
- const [expanded, setExpanded] = (0, import_react91.useState)(false);
22093
- const [errored, setErrored] = (0, import_react91.useState)(false);
22164
+ const [expanded, setExpanded] = (0, import_react92.useState)(false);
22165
+ const [errored, setErrored] = (0, import_react92.useState)(false);
22094
22166
  const thumbnail = post.thumbnail_url || post.thumbnail || post.image || "";
22095
22167
  const likes = post.engagement?.likes ?? post.likes ?? null;
22096
22168
  const comments = post.engagement?.comments ?? post.comments ?? null;
@@ -22300,7 +22372,7 @@ function PlatformPostsSection({
22300
22372
  }
22301
22373
 
22302
22374
  // src/molecules/creator-discovery/CreatorWidget/BrandCollaborationsList.tsx
22303
- var import_react92 = require("react");
22375
+ var import_react93 = require("react");
22304
22376
  var import_react_dom = __toESM(require("react-dom"), 1);
22305
22377
  var import_framer_motion3 = require("framer-motion");
22306
22378
  var import_jsx_runtime178 = require("react/jsx-runtime");
@@ -22502,8 +22574,8 @@ function BrandMentionDetails({
22502
22574
  function BrandCollaborationsList({
22503
22575
  brandBreakdown
22504
22576
  }) {
22505
- const [openDetails, setOpenDetails] = (0, import_react92.useState)(false);
22506
- const [selectedBrand, setSelectedBrand] = (0, import_react92.useState)("");
22577
+ const [openDetails, setOpenDetails] = (0, import_react93.useState)(false);
22578
+ const [selectedBrand, setSelectedBrand] = (0, import_react93.useState)("");
22507
22579
  if (!brandBreakdown?.insights?.brandBreakdown || brandBreakdown.insights.brandBreakdown.length === 0) {
22508
22580
  return null;
22509
22581
  }
@@ -22562,7 +22634,7 @@ function BrandCollaborationsList({
22562
22634
  }
22563
22635
 
22564
22636
  // src/molecules/creator-discovery/CreatorWidget/CreatorGridView.tsx
22565
- var import_react93 = require("react");
22637
+ var import_react94 = require("react");
22566
22638
  var import_framer_motion4 = require("framer-motion");
22567
22639
  var import_jsx_runtime179 = require("react/jsx-runtime");
22568
22640
  var formatFollowerCount3 = (count) => {
@@ -22611,25 +22683,25 @@ var itemsExplanation = [
22611
22683
  { key: "brandSafety", label: "Brand Safety" }
22612
22684
  ];
22613
22685
  function CreatorGridViewCard({ creator }) {
22614
- const [isExpanded, setIsExpanded] = (0, import_react93.useState)(false);
22615
- const [showFullDescription, setShowFullDescription] = (0, import_react93.useState)(false);
22616
- const [isDescriptionOverflowing, setIsDescriptionOverflowing] = (0, import_react93.useState)(false);
22617
- const descriptionRef = (0, import_react93.useRef)(null);
22618
- const cardRef = (0, import_react93.useRef)(null);
22619
- const checkDescriptionOverflow = (0, import_react93.useCallback)(() => {
22686
+ const [isExpanded, setIsExpanded] = (0, import_react94.useState)(false);
22687
+ const [showFullDescription, setShowFullDescription] = (0, import_react94.useState)(false);
22688
+ const [isDescriptionOverflowing, setIsDescriptionOverflowing] = (0, import_react94.useState)(false);
22689
+ const descriptionRef = (0, import_react94.useRef)(null);
22690
+ const cardRef = (0, import_react94.useRef)(null);
22691
+ const checkDescriptionOverflow = (0, import_react94.useCallback)(() => {
22620
22692
  const el = descriptionRef.current;
22621
22693
  if (!el) return;
22622
22694
  setIsDescriptionOverflowing(el.scrollHeight > el.clientHeight + 1);
22623
22695
  }, []);
22624
- (0, import_react93.useEffect)(() => {
22696
+ (0, import_react94.useEffect)(() => {
22625
22697
  checkDescriptionOverflow();
22626
22698
  }, [checkDescriptionOverflow, isExpanded, showFullDescription]);
22627
- (0, import_react93.useEffect)(() => {
22699
+ (0, import_react94.useEffect)(() => {
22628
22700
  const onResize = () => checkDescriptionOverflow();
22629
22701
  window.addEventListener("resize", onResize);
22630
22702
  return () => window.removeEventListener("resize", onResize);
22631
22703
  }, [checkDescriptionOverflow]);
22632
- const platformStats = (0, import_react93.useMemo)(() => {
22704
+ const platformStats = (0, import_react94.useMemo)(() => {
22633
22705
  return [
22634
22706
  {
22635
22707
  platform: "instagram",
@@ -23058,7 +23130,7 @@ function BrandMentionPerformance({ creator }) {
23058
23130
  ] });
23059
23131
  }
23060
23132
  function CreatorFitSummary({ creator, showBrandPerformance }) {
23061
- const [contentExpanded, setContentExpanded] = (0, import_react94.useState)(false);
23133
+ const [contentExpanded, setContentExpanded] = (0, import_react95.useState)(false);
23062
23134
  const hasDeepAnalysis = creator?.sentiment?.deepAnalysis?.deepAnalysis;
23063
23135
  const title = hasDeepAnalysis ? "CREATOR DEEP ANALYSIS" : "CREATOR FIT SUMMARY";
23064
23136
  const content = hasDeepAnalysis ? creator.sentiment.deepAnalysis.deepAnalysis : creator?.sentiment?.aiReasoning || "No data available.";
@@ -23078,7 +23150,7 @@ function CreatorFitSummary({ creator, showBrandPerformance }) {
23078
23150
  ] });
23079
23151
  }
23080
23152
  function ProfileSection({ creator, isValidationComplete }) {
23081
- const [descriptionExpanded, setDescriptionExpanded] = (0, import_react94.useState)(false);
23153
+ const [descriptionExpanded, setDescriptionExpanded] = (0, import_react95.useState)(false);
23082
23154
  const username = creator.platformMetrics?.instagramMetrics?.username ? `@${creator.platformMetrics.instagramMetrics.username}` : creator.platformMetrics?.youtubeMetrics?.channelName ? `@${creator.platformMetrics.youtubeMetrics.channelName}` : creator.platformMetrics?.tiktokMetrics?.username ? `@${creator.platformMetrics.tiktokMetrics.username}` : "";
23083
23155
  const iso2 = normalizeToIso2(creator.country);
23084
23156
  const meta = codeToMeta[iso2];
@@ -23168,7 +23240,7 @@ function CreatorCard({
23168
23240
  creator,
23169
23241
  isValidationComplete
23170
23242
  }) {
23171
- const [detailsExpanded, setDetailsExpanded] = (0, import_react94.useState)(false);
23243
+ const [detailsExpanded, setDetailsExpanded] = (0, import_react95.useState)(false);
23172
23244
  const hasValidBrandMention = (() => {
23173
23245
  const insights = creator?.brandCollaborations?.insights;
23174
23246
  if (!insights) return false;
@@ -23210,7 +23282,7 @@ function CreatorDisplay({
23210
23282
  creators,
23211
23283
  isValidationComplete
23212
23284
  }) {
23213
- const [viewMode, setViewMode] = (0, import_react94.useState)("list");
23285
+ const [viewMode, setViewMode] = (0, import_react95.useState)("list");
23214
23286
  return /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "px-4", children: [
23215
23287
  /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "flex justify-end items-center my-3 gap-1", children: [
23216
23288
  /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("span", { className: "text-xs text-gray600 mr-2", children: [
@@ -23301,10 +23373,10 @@ function CreatorExpandedPanel({
23301
23373
  searchSpec,
23302
23374
  fetchCreatorDetails
23303
23375
  }) {
23304
- const [creators, setCreators] = (0, import_react94.useState)([]);
23305
- const [loading, setLoading] = (0, import_react94.useState)(false);
23376
+ const [creators, setCreators] = (0, import_react95.useState)([]);
23377
+ const [loading, setLoading] = (0, import_react95.useState)(false);
23306
23378
  const fetcher = fetchCreatorDetails ?? defaultFetchCreatorDetails;
23307
- const loadCreators = (0, import_react94.useCallback)(async () => {
23379
+ const loadCreators = (0, import_react95.useCallback)(async () => {
23308
23380
  if (!creatorIds.length) return;
23309
23381
  setLoading(true);
23310
23382
  try {
@@ -23316,7 +23388,7 @@ function CreatorExpandedPanel({
23316
23388
  setLoading(false);
23317
23389
  }
23318
23390
  }, [creatorIds, sessionId, version, fetcher]);
23319
- (0, import_react94.useEffect)(() => {
23391
+ (0, import_react95.useEffect)(() => {
23320
23392
  if (isOpen && creatorIds.length > 0) {
23321
23393
  loadCreators();
23322
23394
  }
@@ -23370,7 +23442,7 @@ function CreatorExpandedPanel({
23370
23442
  }
23371
23443
 
23372
23444
  // src/molecules/creator-discovery/CreatorWidget/useCreatorWidgetPolling.ts
23373
- var import_react95 = require("react");
23445
+ var import_react96 = require("react");
23374
23446
  var DEFAULT_POLLING_CONFIG = {
23375
23447
  pollInterval: 5e3,
23376
23448
  maxDuration: 15 * 60 * 1e3,
@@ -23401,11 +23473,11 @@ function useCreatorWidgetPolling({
23401
23473
  }) {
23402
23474
  const fetchVersions = fetchVersionsProp ?? defaultFetchVersions;
23403
23475
  const fetchStatus = fetchStatusProp ?? defaultFetchStatus;
23404
- const config = (0, import_react95.useMemo)(
23476
+ const config = (0, import_react96.useMemo)(
23405
23477
  () => ({ ...DEFAULT_POLLING_CONFIG, ...pollingConfig }),
23406
23478
  [pollingConfig]
23407
23479
  );
23408
- const hydrated = (0, import_react95.useMemo)(() => {
23480
+ const hydrated = (0, import_react96.useMemo)(() => {
23409
23481
  if (!sessionId) {
23410
23482
  return {
23411
23483
  versionData: null,
@@ -23427,33 +23499,33 @@ function useCreatorWidgetPolling({
23427
23499
  }, [sessionId, currentVersion]);
23428
23500
  const hydratedStatus = hydrated.statusPayload?.status?.status;
23429
23501
  const hydratedTerminal = isTerminalStatus(hydratedStatus);
23430
- const [versionData, setVersionData] = (0, import_react95.useState)(
23502
+ const [versionData, setVersionData] = (0, import_react96.useState)(
23431
23503
  hydrated.versionData
23432
23504
  );
23433
- const [totalVersions, setTotalVersions] = (0, import_react95.useState)(
23505
+ const [totalVersions, setTotalVersions] = (0, import_react96.useState)(
23434
23506
  hydrated.versionData?.totalVersions || 0
23435
23507
  );
23436
- const [selectedVersion, setSelectedVersion] = (0, import_react95.useState)();
23437
- const [isLoadingVersion, setIsLoadingVersion] = (0, import_react95.useState)(!hydrated.versionData);
23438
- const [isValidationComplete, setIsValidationComplete] = (0, import_react95.useState)(
23508
+ const [selectedVersion, setSelectedVersion] = (0, import_react96.useState)();
23509
+ const [isLoadingVersion, setIsLoadingVersion] = (0, import_react96.useState)(!hydrated.versionData);
23510
+ const [isValidationComplete, setIsValidationComplete] = (0, import_react96.useState)(
23439
23511
  hydratedTerminal && hydratedStatus !== "failed"
23440
23512
  );
23441
- const [versionStatus, setVersionStatus] = (0, import_react95.useState)(
23513
+ const [versionStatus, setVersionStatus] = (0, import_react96.useState)(
23442
23514
  hydratedStatus || (hydrated.versionData ? "in-progress" : "checking")
23443
23515
  );
23444
- const [statusDetails, setStatusDetails] = (0, import_react95.useState)(
23516
+ const [statusDetails, setStatusDetails] = (0, import_react96.useState)(
23445
23517
  hydrated.statusPayload?.status
23446
23518
  );
23447
- const [timeDisplay, setTimeDisplay] = (0, import_react95.useState)("");
23448
- const [loadingStatus, setLoadingStatus] = (0, import_react95.useState)(
23519
+ const [timeDisplay, setTimeDisplay] = (0, import_react96.useState)("");
23520
+ const [loadingStatus, setLoadingStatus] = (0, import_react96.useState)(
23449
23521
  !(hydrated.versionData && hydratedTerminal)
23450
23522
  );
23451
- const remainingTimeRef = (0, import_react95.useRef)(0);
23452
- const countdownRef = (0, import_react95.useRef)(null);
23453
- const versionDataRef = (0, import_react95.useRef)(versionData);
23523
+ const remainingTimeRef = (0, import_react96.useRef)(0);
23524
+ const countdownRef = (0, import_react96.useRef)(null);
23525
+ const versionDataRef = (0, import_react96.useRef)(versionData);
23454
23526
  versionDataRef.current = versionData;
23455
23527
  const requestedVersion = selectedVersion ?? currentVersion ?? versionData?.currentVersion;
23456
- const updateStatus = (0, import_react95.useCallback)(
23528
+ const updateStatus = (0, import_react96.useCallback)(
23457
23529
  (status) => {
23458
23530
  setVersionStatus(status);
23459
23531
  onStatusChange?.(status);
@@ -23491,17 +23563,17 @@ function useCreatorWidgetPolling({
23491
23563
  );
23492
23564
  const activeVersion = selectedVersion ?? requestedVersion;
23493
23565
  const statusKey = sessionId && activeVersion != null ? statusPollKey(sessionId, activeVersion) : null;
23494
- const errorCountRef = (0, import_react95.useRef)(0);
23495
- const deadlineRef = (0, import_react95.useRef)(0);
23496
- const doneRef = (0, import_react95.useRef)(hydratedTerminal);
23497
- const stopCountdown = (0, import_react95.useCallback)(() => {
23566
+ const errorCountRef = (0, import_react96.useRef)(0);
23567
+ const deadlineRef = (0, import_react96.useRef)(0);
23568
+ const doneRef = (0, import_react96.useRef)(hydratedTerminal);
23569
+ const stopCountdown = (0, import_react96.useCallback)(() => {
23498
23570
  if (countdownRef.current) {
23499
23571
  clearInterval(countdownRef.current);
23500
23572
  countdownRef.current = null;
23501
23573
  }
23502
23574
  setTimeDisplay("");
23503
23575
  }, []);
23504
- (0, import_react95.useEffect)(() => {
23576
+ (0, import_react96.useEffect)(() => {
23505
23577
  if (statusKey == null) return;
23506
23578
  const cached = getSharedPollLastData(statusKey);
23507
23579
  const cachedStatus = cached?.status?.status;
@@ -23582,7 +23654,7 @@ function useCreatorWidgetPolling({
23582
23654
  setLoadingStatus(false);
23583
23655
  }
23584
23656
  );
23585
- const versionNumbers = (0, import_react95.useMemo)(() => {
23657
+ const versionNumbers = (0, import_react96.useMemo)(() => {
23586
23658
  if (!totalVersions) return [];
23587
23659
  return Array.from({ length: totalVersions }, (_, i) => i + 1);
23588
23660
  }, [totalVersions]);
@@ -23622,7 +23694,7 @@ function CreatorWidgetInner({
23622
23694
  onAction,
23623
23695
  className
23624
23696
  }) {
23625
- const [isExpanded, setIsExpanded] = (0, import_react96.useState)(false);
23697
+ const [isExpanded, setIsExpanded] = (0, import_react97.useState)(false);
23626
23698
  const {
23627
23699
  versionNumbers,
23628
23700
  selectedVersion,
@@ -23643,11 +23715,11 @@ function CreatorWidgetInner({
23643
23715
  pollingConfig,
23644
23716
  onStatusChange
23645
23717
  });
23646
- const handleVersionSelect = (0, import_react96.useCallback)(
23718
+ const handleVersionSelect = (0, import_react97.useCallback)(
23647
23719
  (version) => setSelectedVersion(version),
23648
23720
  [setSelectedVersion]
23649
23721
  );
23650
- const handleViewCreators = (0, import_react96.useCallback)(() => {
23722
+ const handleViewCreators = (0, import_react97.useCallback)(() => {
23651
23723
  setIsExpanded(true);
23652
23724
  onAction?.({
23653
23725
  type: "view-creators",
@@ -23688,10 +23760,10 @@ function CreatorWidgetInner({
23688
23760
  )
23689
23761
  ] });
23690
23762
  }
23691
- var CreatorWidget = (0, import_react96.memo)(CreatorWidgetInner);
23763
+ var CreatorWidget = (0, import_react97.memo)(CreatorWidgetInner);
23692
23764
 
23693
23765
  // src/molecules/analytics/AnalyticsChart.tsx
23694
- var import_react97 = require("react");
23766
+ var import_react98 = require("react");
23695
23767
 
23696
23768
  // src/molecules/analytics/buildOptions.ts
23697
23769
  function deepMerge(base, override) {
@@ -24023,13 +24095,13 @@ function AnalyticsChart({
24023
24095
  loading: loadingProp,
24024
24096
  error: errorProp
24025
24097
  }) {
24026
- const [mounted, setMounted] = (0, import_react97.useState)(false);
24027
- const [fetchedConfig, setFetchedConfig] = (0, import_react97.useState)(null);
24028
- const [fetching, setFetching] = (0, import_react97.useState)(false);
24029
- const [fetchError, setFetchError] = (0, import_react97.useState)(null);
24030
- const containerRef = (0, import_react97.useRef)(null);
24031
- const chartRef = (0, import_react97.useRef)(null);
24032
- const declarative = (0, import_react97.useMemo)(
24098
+ const [mounted, setMounted] = (0, import_react98.useState)(false);
24099
+ const [fetchedConfig, setFetchedConfig] = (0, import_react98.useState)(null);
24100
+ const [fetching, setFetching] = (0, import_react98.useState)(false);
24101
+ const [fetchError, setFetchError] = (0, import_react98.useState)(null);
24102
+ const containerRef = (0, import_react98.useRef)(null);
24103
+ const chartRef = (0, import_react98.useRef)(null);
24104
+ const declarative = (0, import_react98.useMemo)(
24033
24105
  () => resolveDeclarativeConfig({
24034
24106
  chartConfig,
24035
24107
  chartType,
@@ -24063,16 +24135,16 @@ function AnalyticsChart({
24063
24135
  height
24064
24136
  ]
24065
24137
  );
24066
- const builtConfig = (0, import_react97.useMemo)(() => {
24138
+ const builtConfig = (0, import_react98.useMemo)(() => {
24067
24139
  if (!declarative) return null;
24068
24140
  const palette = buildChartPalette(theme, mode);
24069
24141
  const options = buildChartOptions(declarative, palette);
24070
24142
  return extraOptions ? deepMerge(options, extraOptions) : options;
24071
24143
  }, [declarative, theme, mode, extraOptions]);
24072
- (0, import_react97.useEffect)(() => {
24144
+ (0, import_react98.useEffect)(() => {
24073
24145
  setMounted(true);
24074
24146
  }, []);
24075
- (0, import_react97.useEffect)(() => {
24147
+ (0, import_react98.useEffect)(() => {
24076
24148
  if (!chartId || configProp || builtConfig) return;
24077
24149
  let cancelled = false;
24078
24150
  setFetching(true);
@@ -24094,7 +24166,7 @@ function AnalyticsChart({
24094
24166
  };
24095
24167
  }, [chartId, apiBase, authToken, configProp, builtConfig]);
24096
24168
  const activeConfig = configProp ?? builtConfig ?? fetchedConfig;
24097
- (0, import_react97.useEffect)(() => {
24169
+ (0, import_react98.useEffect)(() => {
24098
24170
  if (!mounted || !activeConfig || !containerRef.current) return;
24099
24171
  const container = containerRef.current;
24100
24172
  let cancelled = false;
@@ -24114,7 +24186,7 @@ function AnalyticsChart({
24114
24186
  cancelled = true;
24115
24187
  };
24116
24188
  }, [mounted, activeConfig]);
24117
- (0, import_react97.useEffect)(() => {
24189
+ (0, import_react98.useEffect)(() => {
24118
24190
  return () => {
24119
24191
  if (chartRef.current) {
24120
24192
  try {
@@ -24125,7 +24197,7 @@ function AnalyticsChart({
24125
24197
  }
24126
24198
  };
24127
24199
  }, []);
24128
- (0, import_react97.useEffect)(() => {
24200
+ (0, import_react98.useEffect)(() => {
24129
24201
  if (!mounted || !containerRef.current) return;
24130
24202
  const obs = new ResizeObserver(() => {
24131
24203
  try {
@@ -24607,7 +24679,7 @@ function EmptyContent({ className, ...props }) {
24607
24679
  }
24608
24680
 
24609
24681
  // src/components/ui/field.tsx
24610
- var import_react98 = require("react");
24682
+ var import_react99 = require("react");
24611
24683
  var import_class_variance_authority10 = require("class-variance-authority");
24612
24684
  var import_jsx_runtime185 = require("react/jsx-runtime");
24613
24685
  function FieldSet({ className, ...props }) {
@@ -24790,7 +24862,7 @@ function FieldError({
24790
24862
  errors,
24791
24863
  ...props
24792
24864
  }) {
24793
- const content = (0, import_react98.useMemo)(() => {
24865
+ const content = (0, import_react99.useMemo)(() => {
24794
24866
  if (children) {
24795
24867
  return children;
24796
24868
  }
@@ -26071,18 +26143,18 @@ var FORM_INPUT_ATOM_NAMES = /* @__PURE__ */ new Set([
26071
26143
  "InputOTPAtom",
26072
26144
  "ToggleAtom"
26073
26145
  ]);
26074
- var PXEngineRenderer = import_react99.default.memo(function PXEngineRenderer2({
26146
+ var PXEngineRenderer = import_react100.default.memo(function PXEngineRenderer2({
26075
26147
  schema,
26076
26148
  onAction,
26077
26149
  disabled,
26078
26150
  theme,
26079
26151
  onFormSubmit
26080
26152
  }) {
26081
- const contextTheme = import_react99.default.useContext(WidgetThemeContext);
26153
+ const contextTheme = import_react100.default.useContext(WidgetThemeContext);
26082
26154
  const effectiveTheme = theme ?? contextTheme;
26083
- const formValuesRef = import_react99.default.useRef({});
26084
- const [, forceUpdate] = import_react99.default.useReducer((x) => x + 1, 0);
26085
- const handleInputValueChange = import_react99.default.useCallback((key, value) => {
26155
+ const formValuesRef = import_react100.default.useRef({});
26156
+ const [, forceUpdate] = import_react100.default.useReducer((x) => x + 1, 0);
26157
+ const handleInputValueChange = import_react100.default.useCallback((key, value) => {
26086
26158
  formValuesRef.current[key] = value;
26087
26159
  forceUpdate();
26088
26160
  }, []);
@@ -26090,12 +26162,12 @@ var PXEngineRenderer = import_react99.default.memo(function PXEngineRenderer2({
26090
26162
  const root = schema.root || schema;
26091
26163
  const renderRecursive = (component, index) => {
26092
26164
  if (Array.isArray(component)) {
26093
- return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_react99.default.Fragment, { children: component.map((child, idx) => renderRecursive(child, idx)) }, index !== void 0 ? `array-${index}` : "array-root");
26165
+ return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_react100.default.Fragment, { children: component.map((child, idx) => renderRecursive(child, idx)) }, index !== void 0 ? `array-${index}` : "array-root");
26094
26166
  }
26095
26167
  if (typeof component === "string" || typeof component === "number") {
26096
26168
  return component;
26097
26169
  }
26098
- if (import_react99.default.isValidElement(component)) {
26170
+ if (import_react100.default.isValidElement(component)) {
26099
26171
  return component;
26100
26172
  }
26101
26173
  if (!component || typeof component !== "object") return null;
@@ -26402,6 +26474,7 @@ PXEngineRenderer.displayName = "PXEngineRenderer";
26402
26474
  InputWidget,
26403
26475
  InsightDigestCard,
26404
26476
  InsightSummaryCard,
26477
+ JOB_SIGNAL_EVENT,
26405
26478
  KPIStatsCard,
26406
26479
  KbdAtom,
26407
26480
  KeywordBundlesDisplay,
@@ -26462,6 +26535,7 @@ PXEngineRenderer.displayName = "PXEngineRenderer";
26462
26535
  ResizablePanel,
26463
26536
  ResizablePanelGroup,
26464
26537
  RiskSignalCard,
26538
+ SSE_FALLBACK_POLL_MS,
26465
26539
  ScoreBreakdownCard,
26466
26540
  ScrollArea,
26467
26541
  ScrollAreaAtom,
@@ -26532,17 +26606,21 @@ PXEngineRenderer.displayName = "PXEngineRenderer";
26532
26606
  defaultFetchSelections,
26533
26607
  defaultPersistSelection,
26534
26608
  elementToQAField,
26609
+ emitJobSignal,
26535
26610
  formatQAMessage,
26536
26611
  generateFieldsFromData,
26537
26612
  generateFieldsFromPropDefinitions,
26538
26613
  getPxAuthToken,
26539
26614
  isInputAtom,
26540
26615
  notifyPxUnauthorized,
26616
+ refreshSharedPoll,
26541
26617
  setPxAuthTokenProvider,
26542
26618
  setPxUnauthorizedHandler,
26543
26619
  submitWidgetToAgent,
26620
+ subscribeJobSignal,
26544
26621
  th,
26545
26622
  useCreatorWidgetPolling,
26623
+ useJobSignal,
26546
26624
  useWidgetTheme,
26547
26625
  withAlpha
26548
26626
  });