sunpeak 0.9.6 → 0.9.10

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.
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  var _a, _b;
5
5
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
6
6
  import * as React from "react";
7
- import React__default, { useSyncExternalStore, useState, useEffect, useCallback, useLayoutEffect, useRef, useId as useId$1, Children, isValidElement, cloneElement, createContext, useReducer, useMemo, use } from "react";
7
+ import React__default, { useSyncExternalStore, useState, useRef, useEffect, useCallback, useLayoutEffect, useId as useId$1, Children, isValidElement, cloneElement, createContext, useReducer, useMemo, use } from "react";
8
8
  import * as ReactDOM from "react-dom";
9
9
  import ReactDOM__default from "react-dom";
10
10
  const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
@@ -39,19 +39,38 @@ class OpenAiProvider {
39
39
  };
40
40
  }
41
41
  getAPI() {
42
- var _a2, _b2, _c, _d, _e, _f, _g;
43
42
  if (typeof window === "undefined" || !window.openai) {
44
43
  return null;
45
44
  }
46
- const api = window.openai;
47
45
  return {
48
- callTool: (_a2 = api.callTool) == null ? void 0 : _a2.bind(api),
49
- sendFollowUpMessage: (_b2 = api.sendFollowUpMessage) == null ? void 0 : _b2.bind(api),
50
- openExternal: (_c = api.openExternal) == null ? void 0 : _c.bind(api),
51
- requestDisplayMode: (_d = api.requestDisplayMode) == null ? void 0 : _d.bind(api),
52
- requestModal: (_e = api.requestModal) == null ? void 0 : _e.bind(api),
53
- notifyIntrinsicHeight: (_f = api.notifyIntrinsicHeight) == null ? void 0 : _f.bind(api),
54
- setWidgetState: (_g = api.setWidgetState) == null ? void 0 : _g.bind(api)
46
+ callTool: (...args) => {
47
+ var _a2, _b2;
48
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.callTool) == null ? void 0 : _b2.call(_a2, ...args);
49
+ },
50
+ sendFollowUpMessage: (...args) => {
51
+ var _a2, _b2;
52
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.sendFollowUpMessage) == null ? void 0 : _b2.call(_a2, ...args);
53
+ },
54
+ openExternal: (...args) => {
55
+ var _a2, _b2;
56
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.openExternal) == null ? void 0 : _b2.call(_a2, ...args);
57
+ },
58
+ requestDisplayMode: (...args) => {
59
+ var _a2, _b2;
60
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.requestDisplayMode) == null ? void 0 : _b2.call(_a2, ...args);
61
+ },
62
+ requestModal: (...args) => {
63
+ var _a2, _b2;
64
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.requestModal) == null ? void 0 : _b2.call(_a2, ...args);
65
+ },
66
+ notifyIntrinsicHeight: (...args) => {
67
+ var _a2, _b2;
68
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.notifyIntrinsicHeight) == null ? void 0 : _b2.call(_a2, ...args);
69
+ },
70
+ setWidgetState: (...args) => {
71
+ var _a2, _b2;
72
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.setWidgetState) == null ? void 0 : _b2.call(_a2, ...args);
73
+ }
55
74
  };
56
75
  }
57
76
  }
@@ -154,8 +173,17 @@ function useWidgetState(defaultState) {
154
173
  }
155
174
  return typeof defaultState === "function" ? defaultState() : defaultState ?? null;
156
175
  });
176
+ const hasSentInitialState = useRef(false);
157
177
  useEffect(() => {
158
- _setWidgetState(widgetStateFromProvider);
178
+ if (!hasSentInitialState.current && widgetStateFromProvider == null && widgetState != null && (api == null ? void 0 : api.setWidgetState)) {
179
+ hasSentInitialState.current = true;
180
+ api.setWidgetState(widgetState);
181
+ }
182
+ }, [api, widgetState, widgetStateFromProvider]);
183
+ useEffect(() => {
184
+ if (widgetStateFromProvider != null) {
185
+ _setWidgetState(widgetStateFromProvider);
186
+ }
159
187
  }, [widgetStateFromProvider]);
160
188
  const setWidgetState = useCallback(
161
189
  (state) => {
@@ -7351,9 +7379,34 @@ const Segment = ({ children, ...restProps }) => {
7351
7379
  return jsx(Item2, { className: s.SegmentedControlOption, ...restProps, onPointerEnter: handlePressableMouseEnter, children: jsx("span", { className: "relative", children }) });
7352
7380
  };
7353
7381
  SegmentedControl.Option = Segment;
7382
+ const DEFAULT_SIDEBAR_WIDTH = 224;
7354
7383
  function SimpleSidebar({ children, controls }) {
7355
7384
  const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);
7385
+ const [sidebarWidth, setSidebarWidth] = React.useState(DEFAULT_SIDEBAR_WIDTH);
7386
+ const [isResizing, setIsResizing] = React.useState(false);
7387
+ const handleMouseDown = React.useCallback((e) => {
7388
+ e.preventDefault();
7389
+ setIsResizing(true);
7390
+ }, []);
7391
+ React.useEffect(() => {
7392
+ if (!isResizing) return;
7393
+ const handleMouseMove = (e) => {
7394
+ const maxWidth = Math.floor(window.innerWidth / 3);
7395
+ const newWidth = Math.min(maxWidth, Math.max(DEFAULT_SIDEBAR_WIDTH, e.clientX));
7396
+ setSidebarWidth(newWidth);
7397
+ };
7398
+ const handleMouseUp = () => {
7399
+ setIsResizing(false);
7400
+ };
7401
+ document.addEventListener("mousemove", handleMouseMove);
7402
+ document.addEventListener("mouseup", handleMouseUp);
7403
+ return () => {
7404
+ document.removeEventListener("mousemove", handleMouseMove);
7405
+ document.removeEventListener("mouseup", handleMouseUp);
7406
+ };
7407
+ }, [isResizing]);
7356
7408
  return /* @__PURE__ */ jsxs("div", { className: "sunpeak-simulator-root flex h-screen w-full overflow-hidden relative", children: [
7409
+ isResizing && /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 cursor-col-resize" }),
7357
7410
  isDrawerOpen && /* @__PURE__ */ jsx(
7358
7411
  "div",
7359
7412
  {
@@ -7365,50 +7418,60 @@ function SimpleSidebar({ children, controls }) {
7365
7418
  }
7366
7419
  }
7367
7420
  ),
7368
- /* @__PURE__ */ jsx(
7421
+ /* @__PURE__ */ jsxs(
7369
7422
  "aside",
7370
7423
  {
7371
7424
  className: `
7372
- w-56 flex flex-col border-r border-subtle bg-sidebar
7373
- md:relative md:z-auto
7425
+ relative flex flex-col border-r border-subtle bg-sidebar
7426
+ md:z-auto
7374
7427
  max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-[100]
7375
- max-md:transition-transform max-md:duration-300
7428
+ max-md:transition-transform max-md:duration-300 max-md:!w-2/3
7376
7429
  ${isDrawerOpen ? "max-md:translate-x-0" : "max-md:-translate-x-full"}
7377
7430
  `,
7378
- children: /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs("div", { children: [
7379
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2", children: [
7380
- /* @__PURE__ */ jsx("h2", { className: "text-xs font-semibold", children: "Controls" }),
7381
- /* @__PURE__ */ jsx(
7382
- "button",
7383
- {
7384
- onClick: () => setIsDrawerOpen(false),
7385
- className: "md:hidden text-secondary hover:text-primary transition-colors p-1",
7386
- type: "button",
7387
- "aria-label": "Close sidebar",
7388
- children: /* @__PURE__ */ jsx(
7389
- "svg",
7390
- {
7391
- width: "16",
7392
- height: "16",
7393
- viewBox: "0 0 16 16",
7394
- fill: "none",
7395
- xmlns: "http://www.w3.org/2000/svg",
7396
- children: /* @__PURE__ */ jsx(
7397
- "path",
7398
- {
7399
- d: "M12 4L4 12M4 4L12 12",
7400
- stroke: "currentColor",
7401
- strokeWidth: "2",
7402
- strokeLinecap: "round"
7403
- }
7404
- )
7405
- }
7406
- )
7407
- }
7408
- )
7409
- ] }),
7410
- controls
7411
- ] }) }) })
7431
+ style: { width: sidebarWidth },
7432
+ children: [
7433
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs("div", { children: [
7434
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2", children: [
7435
+ /* @__PURE__ */ jsx("h2", { className: "text-xs font-semibold", children: "Controls" }),
7436
+ /* @__PURE__ */ jsx(
7437
+ "button",
7438
+ {
7439
+ onClick: () => setIsDrawerOpen(false),
7440
+ className: "md:hidden text-secondary hover:text-primary transition-colors p-1",
7441
+ type: "button",
7442
+ "aria-label": "Close sidebar",
7443
+ children: /* @__PURE__ */ jsx(
7444
+ "svg",
7445
+ {
7446
+ width: "16",
7447
+ height: "16",
7448
+ viewBox: "0 0 16 16",
7449
+ fill: "none",
7450
+ xmlns: "http://www.w3.org/2000/svg",
7451
+ children: /* @__PURE__ */ jsx(
7452
+ "path",
7453
+ {
7454
+ d: "M12 4L4 12M4 4L12 12",
7455
+ stroke: "currentColor",
7456
+ strokeWidth: "2",
7457
+ strokeLinecap: "round"
7458
+ }
7459
+ )
7460
+ }
7461
+ )
7462
+ }
7463
+ )
7464
+ ] }),
7465
+ controls
7466
+ ] }) }) }),
7467
+ /* @__PURE__ */ jsx(
7468
+ "div",
7469
+ {
7470
+ onMouseDown: handleMouseDown,
7471
+ className: "hidden md:block absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-primary/20 active:bg-primary/30 transition-colors"
7472
+ }
7473
+ )
7474
+ ]
7412
7475
  }
7413
7476
  ),
7414
7477
  /* @__PURE__ */ jsxs("main", { className: "flex-1 overflow-auto relative", children: [
@@ -7502,9 +7565,11 @@ function SidebarTextarea({
7502
7565
  onFocus,
7503
7566
  onBlur,
7504
7567
  placeholder,
7505
- rows = 2,
7568
+ maxRows = 8,
7506
7569
  error
7507
7570
  }) {
7571
+ const contentRows = (value == null ? void 0 : value.split("\n").length) ?? 1;
7572
+ const rows = Math.min(contentRows, maxRows);
7508
7573
  return /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
7509
7574
  /* @__PURE__ */ jsx(
7510
7575
  Textarea,
@@ -7516,7 +7581,8 @@ function SidebarTextarea({
7516
7581
  placeholder,
7517
7582
  rows,
7518
7583
  size: "2xs",
7519
- className: "text-[10px] font-mono",
7584
+ className: "text-[10px] font-mono resize-y [&>textarea]:!h-full [&>textarea]:!max-h-none [&>textarea]:!min-h-0",
7585
+ style: { whiteSpace: "pre", overflowX: "auto", overflowWrap: "normal" },
7520
7586
  invalid: !!error
7521
7587
  }
7522
7588
  ),
@@ -8358,8 +8424,8 @@ class MockOpenAI {
8358
8424
  console.log("Mock notifyIntrinsicHeight:", height);
8359
8425
  }
8360
8426
  async setWidgetState(state) {
8361
- this.widgetState = state;
8362
- this.emitUpdate({ widgetState: state });
8427
+ this.widgetState = { ...this.widgetState, ...state };
8428
+ this.emitUpdate({ widgetState: this.widgetState });
8363
8429
  }
8364
8430
  setTheme(theme) {
8365
8431
  this.theme = theme;
@@ -8570,11 +8636,17 @@ function ChatGPTSimulator({
8570
8636
  // eslint-disable-next-line react-hooks/exhaustive-deps -- only initialize once
8571
8637
  []
8572
8638
  );
8639
+ if (typeof window !== "undefined") {
8640
+ window.openai = mock;
8641
+ resetProviderCache();
8642
+ }
8573
8643
  useEffect(() => {
8574
8644
  var _a2, _b2;
8575
8645
  if (selectedSim) {
8576
8646
  mock.toolInput = ((_a2 = selectedSim.callToolRequestParams) == null ? void 0 : _a2.arguments) ?? {};
8577
- mock.widgetState = selectedSim.widgetState ?? null;
8647
+ if (selectedSim.widgetState !== void 0) {
8648
+ mock.setWidgetStateExternal(selectedSim.widgetState);
8649
+ }
8578
8650
  mock.toolOutput = ((_b2 = selectedSim.callToolResult) == null ? void 0 : _b2.structuredContent) ?? null;
8579
8651
  }
8580
8652
  }, [selectedSimulationName, selectedSim, mock]);
@@ -8586,7 +8658,7 @@ function ChatGPTSimulator({
8586
8658
  const safeArea = useSafeArea();
8587
8659
  const view = useView();
8588
8660
  const toolInput = useToolInput();
8589
- const [widgetState] = useWidgetState();
8661
+ const widgetState = useWidgetGlobal("widgetState");
8590
8662
  const toolResponseMetadata = useToolResponseMetadata();
8591
8663
  const toolOutput = useWidgetProps();
8592
8664
  const [toolInputJson, setToolInputJson] = useState(
@@ -8610,12 +8682,6 @@ function ChatGPTSimulator({
8610
8682
  const [toolResponseMetadataError, setToolResponseMetadataError] = useState("");
8611
8683
  const [widgetStateError, setWidgetStateError] = useState("");
8612
8684
  const [viewParamsError, setViewParamsError] = useState("");
8613
- useLayoutEffect(() => {
8614
- if (mock && typeof window !== "undefined") {
8615
- window.openai = mock;
8616
- resetProviderCache();
8617
- }
8618
- }, [mock]);
8619
8685
  useEffect(() => {
8620
8686
  if (mock) {
8621
8687
  mock.emitUpdate({
@@ -8704,11 +8770,15 @@ function ChatGPTSimulator({
8704
8770
  SimpleSidebar,
8705
8771
  {
8706
8772
  controls: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
8707
- simulationNames.length > 0 && /* @__PURE__ */ jsx(SidebarControl, { label: "Simulation", children: /* @__PURE__ */ jsx(
8773
+ simulationNames.length > 1 && /* @__PURE__ */ jsx(SidebarControl, { label: "Simulation", children: /* @__PURE__ */ jsx(
8708
8774
  SidebarSelect,
8709
8775
  {
8710
8776
  value: selectedSimulationName,
8711
- onChange: (value) => setSelectedSimulationName(value),
8777
+ onChange: (value) => {
8778
+ const newSim = simulations[value];
8779
+ mock.setWidgetStateExternal((newSim == null ? void 0 : newSim.widgetState) ?? null);
8780
+ setSelectedSimulationName(value);
8781
+ },
8712
8782
  options: simulationNames.map((name) => {
8713
8783
  const sim = simulations[name];
8714
8784
  const resourceTitle = sim.resource.title || sim.resource.name;
@@ -8733,237 +8803,254 @@ function ChatGPTSimulator({
8733
8803
  ]
8734
8804
  }
8735
8805
  ) }),
8736
- /* @__PURE__ */ jsx(SidebarControl, { label: "Theme", children: /* @__PURE__ */ jsx(
8737
- SidebarToggle,
8738
- {
8739
- value: theme,
8740
- onChange: (value) => mock.setTheme(value),
8741
- options: [
8742
- { value: "light", label: "Light" },
8743
- { value: "dark", label: "Dark" }
8744
- ]
8745
- }
8746
- ) }),
8747
- /* @__PURE__ */ jsx(SidebarControl, { label: "Display Mode", children: /* @__PURE__ */ jsx(
8748
- SidebarToggle,
8749
- {
8750
- value: displayMode,
8751
- onChange: (value) => {
8752
- const newMode = value;
8753
- if (isMobileWidth(screenWidth) && newMode === "pip") {
8754
- mock.setDisplayMode("fullscreen");
8755
- } else {
8756
- mock.setDisplayMode(newMode);
8757
- }
8758
- },
8759
- options: [
8760
- { value: "inline", label: "Inline" },
8761
- { value: "pip", label: "PiP" },
8762
- { value: "fullscreen", label: "Full" }
8763
- ]
8764
- }
8765
- ) }),
8766
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
8767
- /* @__PURE__ */ jsx(SidebarControl, { label: "Locale", children: /* @__PURE__ */ jsx(
8768
- SidebarInput,
8806
+ /* @__PURE__ */ jsx(SidebarCollapsibleControl, { label: "Runtime Globals", defaultCollapsed: false, children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
8807
+ /* @__PURE__ */ jsx(SidebarControl, { label: "Theme", children: /* @__PURE__ */ jsx(
8808
+ SidebarToggle,
8769
8809
  {
8770
- value: locale,
8771
- onChange: (value) => mock.setLocale(value),
8772
- placeholder: "e.g. en-US"
8810
+ value: theme,
8811
+ onChange: (value) => mock.setTheme(value),
8812
+ options: [
8813
+ { value: "light", label: "Light" },
8814
+ { value: "dark", label: "Dark" }
8815
+ ]
8773
8816
  }
8774
8817
  ) }),
8775
- /* @__PURE__ */ jsx(SidebarControl, { label: "Max Height (PiP)", children: /* @__PURE__ */ jsx(
8776
- SidebarInput,
8818
+ /* @__PURE__ */ jsx(SidebarControl, { label: "Display Mode", children: /* @__PURE__ */ jsx(
8819
+ SidebarToggle,
8777
8820
  {
8778
- type: "number",
8779
- value: displayMode === "pip" && maxHeight !== void 0 ? String(maxHeight) : "",
8821
+ value: displayMode,
8780
8822
  onChange: (value) => {
8781
- if (displayMode === "pip") {
8782
- mock.setMaxHeight(value ? Number(value) : 480);
8823
+ const newMode = value;
8824
+ if (isMobileWidth(screenWidth) && newMode === "pip") {
8825
+ mock.setDisplayMode("fullscreen");
8826
+ } else {
8827
+ mock.setDisplayMode(newMode);
8783
8828
  }
8784
8829
  },
8785
- placeholder: displayMode === "pip" ? "480" : "-",
8786
- disabled: displayMode !== "pip"
8787
- }
8788
- ) })
8789
- ] }),
8790
- /* @__PURE__ */ jsx(SidebarControl, { label: "User Agent - Device", children: /* @__PURE__ */ jsx(
8791
- SidebarSelect,
8792
- {
8793
- value: (userAgent == null ? void 0 : userAgent.device.type) ?? "desktop",
8794
- onChange: (value) => {
8795
- const deviceType = value;
8796
- let capabilities;
8797
- switch (deviceType) {
8798
- case "mobile":
8799
- capabilities = { hover: false, touch: true };
8800
- break;
8801
- case "tablet":
8802
- capabilities = { hover: false, touch: true };
8803
- break;
8804
- case "desktop":
8805
- capabilities = { hover: true, touch: false };
8806
- break;
8807
- case "unknown":
8808
- default:
8809
- capabilities = { hover: true, touch: false };
8810
- break;
8811
- }
8812
- mock.setUserAgent({
8813
- ...userAgent,
8814
- device: { type: deviceType },
8815
- capabilities
8816
- });
8817
- },
8818
- options: [
8819
- { value: "mobile", label: "Mobile" },
8820
- { value: "tablet", label: "Tablet" },
8821
- { value: "desktop", label: "Desktop" },
8822
- { value: "unknown", label: "Unknown" }
8823
- ]
8824
- }
8825
- ) }),
8826
- /* @__PURE__ */ jsx("div", { className: "pl-4", children: /* @__PURE__ */ jsx(SidebarControl, { label: "Capabilities", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
8827
- /* @__PURE__ */ jsx(
8828
- SidebarCheckbox,
8829
- {
8830
- checked: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8831
- onChange: (checked) => mock.setUserAgent({
8832
- ...userAgent,
8833
- device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8834
- capabilities: {
8835
- hover: checked,
8836
- touch: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false
8837
- }
8838
- }),
8839
- label: "Hover"
8840
- }
8841
- ),
8842
- /* @__PURE__ */ jsx(
8843
- SidebarCheckbox,
8844
- {
8845
- checked: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false,
8846
- onChange: (checked) => mock.setUserAgent({
8847
- ...userAgent,
8848
- device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8849
- capabilities: {
8850
- hover: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8851
- touch: checked
8852
- }
8853
- }),
8854
- label: "Touch"
8830
+ options: [
8831
+ { value: "inline", label: "Inline" },
8832
+ { value: "pip", label: "PiP" },
8833
+ { value: "fullscreen", label: "Full" }
8834
+ ]
8855
8835
  }
8856
- )
8857
- ] }) }) }),
8858
- /* @__PURE__ */ jsx(SidebarControl, { label: "Safe Area Insets", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-1", children: [
8859
- /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8860
- /* @__PURE__ */ jsx("label", { className: "text-[9px] text-secondary", children: "Top" }),
8861
- /* @__PURE__ */ jsx(
8836
+ ) }),
8837
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
8838
+ /* @__PURE__ */ jsx(SidebarControl, { label: "Locale", children: /* @__PURE__ */ jsx(
8862
8839
  SidebarInput,
8863
8840
  {
8864
- type: "number",
8865
- value: String((safeArea == null ? void 0 : safeArea.insets.top) ?? 0),
8866
- onChange: (value) => mock.setSafeArea({
8867
- insets: {
8868
- ...safeArea == null ? void 0 : safeArea.insets,
8869
- top: Number(value),
8870
- bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8871
- left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8872
- right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8873
- }
8874
- })
8841
+ value: locale,
8842
+ onChange: (value) => mock.setLocale(value),
8843
+ placeholder: "e.g. en-US"
8875
8844
  }
8876
- )
8877
- ] }),
8878
- /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8879
- /* @__PURE__ */ jsx("label", { className: "text-[9px] text-secondary", children: "Bottom" }),
8880
- /* @__PURE__ */ jsx(
8845
+ ) }),
8846
+ /* @__PURE__ */ jsx(SidebarControl, { label: "Max Height (PiP)", children: /* @__PURE__ */ jsx(
8881
8847
  SidebarInput,
8882
8848
  {
8883
8849
  type: "number",
8884
- value: String((safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0),
8885
- onChange: (value) => mock.setSafeArea({
8886
- insets: {
8887
- ...safeArea == null ? void 0 : safeArea.insets,
8888
- top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8889
- bottom: Number(value),
8890
- left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8891
- right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8850
+ value: displayMode === "pip" && maxHeight !== void 0 ? String(maxHeight) : "",
8851
+ onChange: (value) => {
8852
+ if (displayMode === "pip") {
8853
+ mock.setMaxHeight(value ? Number(value) : 480);
8892
8854
  }
8893
- })
8855
+ },
8856
+ placeholder: displayMode === "pip" ? "480" : "-",
8857
+ disabled: displayMode !== "pip"
8894
8858
  }
8895
- )
8859
+ ) })
8896
8860
  ] }),
8897
- /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8898
- /* @__PURE__ */ jsx("label", { className: "text-[9px] text-secondary", children: "Left" }),
8861
+ /* @__PURE__ */ jsx(SidebarControl, { label: "User Agent - Device", children: /* @__PURE__ */ jsx(
8862
+ SidebarSelect,
8863
+ {
8864
+ value: (userAgent == null ? void 0 : userAgent.device.type) ?? "desktop",
8865
+ onChange: (value) => {
8866
+ const deviceType = value;
8867
+ let capabilities;
8868
+ switch (deviceType) {
8869
+ case "mobile":
8870
+ capabilities = { hover: false, touch: true };
8871
+ break;
8872
+ case "tablet":
8873
+ capabilities = { hover: false, touch: true };
8874
+ break;
8875
+ case "desktop":
8876
+ capabilities = { hover: true, touch: false };
8877
+ break;
8878
+ case "unknown":
8879
+ default:
8880
+ capabilities = { hover: true, touch: false };
8881
+ break;
8882
+ }
8883
+ mock.setUserAgent({
8884
+ ...userAgent,
8885
+ device: { type: deviceType },
8886
+ capabilities
8887
+ });
8888
+ },
8889
+ options: [
8890
+ { value: "mobile", label: "Mobile" },
8891
+ { value: "tablet", label: "Tablet" },
8892
+ { value: "desktop", label: "Desktop" },
8893
+ { value: "unknown", label: "Unknown" }
8894
+ ]
8895
+ }
8896
+ ) }),
8897
+ /* @__PURE__ */ jsx("div", { className: "pl-4", children: /* @__PURE__ */ jsx(SidebarControl, { label: "Capabilities", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
8899
8898
  /* @__PURE__ */ jsx(
8900
- SidebarInput,
8899
+ SidebarCheckbox,
8901
8900
  {
8902
- type: "number",
8903
- value: String((safeArea == null ? void 0 : safeArea.insets.left) ?? 0),
8904
- onChange: (value) => mock.setSafeArea({
8905
- insets: {
8906
- ...safeArea == null ? void 0 : safeArea.insets,
8907
- top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8908
- bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8909
- left: Number(value),
8910
- right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8901
+ checked: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8902
+ onChange: (checked) => mock.setUserAgent({
8903
+ ...userAgent,
8904
+ device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8905
+ capabilities: {
8906
+ hover: checked,
8907
+ touch: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false
8911
8908
  }
8912
- })
8909
+ }),
8910
+ label: "Hover"
8913
8911
  }
8914
- )
8915
- ] }),
8916
- /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
8917
- /* @__PURE__ */ jsx("label", { className: "text-[9px] text-secondary", children: "Right" }),
8912
+ ),
8918
8913
  /* @__PURE__ */ jsx(
8919
- SidebarInput,
8914
+ SidebarCheckbox,
8920
8915
  {
8921
- type: "number",
8922
- value: String((safeArea == null ? void 0 : safeArea.insets.right) ?? 0),
8923
- onChange: (value) => mock.setSafeArea({
8924
- insets: {
8925
- ...safeArea == null ? void 0 : safeArea.insets,
8926
- top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8927
- bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8928
- left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8929
- right: Number(value)
8916
+ checked: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false,
8917
+ onChange: (checked) => mock.setUserAgent({
8918
+ ...userAgent,
8919
+ device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8920
+ capabilities: {
8921
+ hover: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8922
+ touch: checked
8930
8923
  }
8931
- })
8924
+ }),
8925
+ label: "Touch"
8932
8926
  }
8933
8927
  )
8934
- ] })
8928
+ ] }) }) }),
8929
+ /* @__PURE__ */ jsx(SidebarControl, { label: "Safe Area Insets", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 gap-1", children: [
8930
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", children: [
8931
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-secondary", children: "↑" }),
8932
+ /* @__PURE__ */ jsx(
8933
+ SidebarInput,
8934
+ {
8935
+ type: "number",
8936
+ value: String((safeArea == null ? void 0 : safeArea.insets.top) ?? 0),
8937
+ onChange: (value) => mock.setSafeArea({
8938
+ insets: {
8939
+ ...safeArea == null ? void 0 : safeArea.insets,
8940
+ top: Number(value),
8941
+ bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8942
+ left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8943
+ right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8944
+ }
8945
+ })
8946
+ }
8947
+ )
8948
+ ] }),
8949
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", children: [
8950
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-secondary", children: "↓" }),
8951
+ /* @__PURE__ */ jsx(
8952
+ SidebarInput,
8953
+ {
8954
+ type: "number",
8955
+ value: String((safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0),
8956
+ onChange: (value) => mock.setSafeArea({
8957
+ insets: {
8958
+ ...safeArea == null ? void 0 : safeArea.insets,
8959
+ top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8960
+ bottom: Number(value),
8961
+ left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8962
+ right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8963
+ }
8964
+ })
8965
+ }
8966
+ )
8967
+ ] }),
8968
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", children: [
8969
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-secondary", children: "←" }),
8970
+ /* @__PURE__ */ jsx(
8971
+ SidebarInput,
8972
+ {
8973
+ type: "number",
8974
+ value: String((safeArea == null ? void 0 : safeArea.insets.left) ?? 0),
8975
+ onChange: (value) => mock.setSafeArea({
8976
+ insets: {
8977
+ ...safeArea == null ? void 0 : safeArea.insets,
8978
+ top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8979
+ bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8980
+ left: Number(value),
8981
+ right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8982
+ }
8983
+ })
8984
+ }
8985
+ )
8986
+ ] }),
8987
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", children: [
8988
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-secondary", children: "→" }),
8989
+ /* @__PURE__ */ jsx(
8990
+ SidebarInput,
8991
+ {
8992
+ type: "number",
8993
+ value: String((safeArea == null ? void 0 : safeArea.insets.right) ?? 0),
8994
+ onChange: (value) => mock.setSafeArea({
8995
+ insets: {
8996
+ ...safeArea == null ? void 0 : safeArea.insets,
8997
+ top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8998
+ bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8999
+ left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
9000
+ right: Number(value)
9001
+ }
9002
+ })
9003
+ }
9004
+ )
9005
+ ] })
9006
+ ] }) }),
9007
+ /* @__PURE__ */ jsx(SidebarControl, { label: "View Mode", children: /* @__PURE__ */ jsx(
9008
+ SidebarSelect,
9009
+ {
9010
+ value: (view == null ? void 0 : view.mode) ?? "default",
9011
+ onChange: (value) => mock.setView(
9012
+ value === "default" ? null : {
9013
+ mode: value,
9014
+ params: view == null ? void 0 : view.params
9015
+ }
9016
+ ),
9017
+ options: [
9018
+ { value: "default", label: "Default (null)" },
9019
+ { value: "modal", label: "Modal" }
9020
+ ]
9021
+ }
9022
+ ) }),
9023
+ view && view.mode !== "default" && /* @__PURE__ */ jsx(SidebarControl, { label: "View Params (JSON)", children: /* @__PURE__ */ jsx(
9024
+ SidebarTextarea,
9025
+ {
9026
+ value: viewParamsJson,
9027
+ onChange: (json) => validateJSON(json, setViewParamsJson, setViewParamsError),
9028
+ onFocus: () => setEditingField("viewParams"),
9029
+ onBlur: () => commitJSON(viewParamsJson, setViewParamsError, (parsed) => {
9030
+ if (view) {
9031
+ mock.setView({ ...view, params: parsed ?? void 0 });
9032
+ }
9033
+ }),
9034
+ error: viewParamsError,
9035
+ maxRows: 2
9036
+ }
9037
+ ) }),
9038
+ /* @__PURE__ */ jsx(SidebarCollapsibleControl, { label: "Widget State (JSON)", defaultCollapsed: false, children: /* @__PURE__ */ jsx(
9039
+ SidebarTextarea,
9040
+ {
9041
+ value: widgetStateJson,
9042
+ onChange: (json) => validateJSON(json, setWidgetStateJson, setWidgetStateError),
9043
+ onFocus: () => setEditingField("widgetState"),
9044
+ onBlur: () => commitJSON(
9045
+ widgetStateJson,
9046
+ setWidgetStateError,
9047
+ (parsed) => mock.setWidgetStateExternal(parsed)
9048
+ ),
9049
+ error: widgetStateError,
9050
+ maxRows: 8
9051
+ }
9052
+ ) })
8935
9053
  ] }) }),
8936
- /* @__PURE__ */ jsx(SidebarControl, { label: "View Mode", children: /* @__PURE__ */ jsx(
8937
- SidebarSelect,
8938
- {
8939
- value: (view == null ? void 0 : view.mode) ?? "default",
8940
- onChange: (value) => mock.setView(
8941
- value === "default" ? null : {
8942
- mode: value,
8943
- params: view == null ? void 0 : view.params
8944
- }
8945
- ),
8946
- options: [
8947
- { value: "default", label: "Default (null)" },
8948
- { value: "modal", label: "Modal" }
8949
- ]
8950
- }
8951
- ) }),
8952
- view && view.mode !== "default" && /* @__PURE__ */ jsx(SidebarControl, { label: "View Params (JSON)", children: /* @__PURE__ */ jsx(
8953
- SidebarTextarea,
8954
- {
8955
- value: viewParamsJson,
8956
- onChange: (json) => validateJSON(json, setViewParamsJson, setViewParamsError),
8957
- onFocus: () => setEditingField("viewParams"),
8958
- onBlur: () => commitJSON(viewParamsJson, setViewParamsError, (parsed) => {
8959
- if (view) {
8960
- mock.setView({ ...view, params: parsed ?? void 0 });
8961
- }
8962
- }),
8963
- error: viewParamsError,
8964
- rows: 2
8965
- }
8966
- ) }),
8967
9054
  /* @__PURE__ */ jsx(SidebarCollapsibleControl, { label: "Tool Input (JSON)", children: /* @__PURE__ */ jsx(
8968
9055
  SidebarTextarea,
8969
9056
  {
@@ -8976,7 +9063,7 @@ function ChatGPTSimulator({
8976
9063
  (parsed) => mock.setToolInput(parsed ?? {})
8977
9064
  ),
8978
9065
  error: toolInputError,
8979
- rows: 8
9066
+ maxRows: 8
8980
9067
  }
8981
9068
  ) }),
8982
9069
  /* @__PURE__ */ jsx(SidebarCollapsibleControl, { label: "Tool Output (JSON)", children: /* @__PURE__ */ jsx(
@@ -8991,7 +9078,7 @@ function ChatGPTSimulator({
8991
9078
  (parsed) => mock.setToolOutput(parsed)
8992
9079
  ),
8993
9080
  error: toolOutputError,
8994
- rows: 8
9081
+ maxRows: 8
8995
9082
  }
8996
9083
  ) }),
8997
9084
  /* @__PURE__ */ jsx(SidebarCollapsibleControl, { label: "Tool Response Metadata (JSON)", children: /* @__PURE__ */ jsx(
@@ -9006,22 +9093,7 @@ function ChatGPTSimulator({
9006
9093
  (parsed) => mock.setToolResponseMetadata(parsed)
9007
9094
  ),
9008
9095
  error: toolResponseMetadataError,
9009
- rows: 8
9010
- }
9011
- ) }),
9012
- /* @__PURE__ */ jsx(SidebarCollapsibleControl, { label: "Widget State (JSON)", children: /* @__PURE__ */ jsx(
9013
- SidebarTextarea,
9014
- {
9015
- value: widgetStateJson,
9016
- onChange: (json) => validateJSON(json, setWidgetStateJson, setWidgetStateError),
9017
- onFocus: () => setEditingField("widgetState"),
9018
- onBlur: () => commitJSON(
9019
- widgetStateJson,
9020
- setWidgetStateError,
9021
- (parsed) => mock.setWidgetStateExternal(parsed)
9022
- ),
9023
- error: widgetStateError,
9024
- rows: 8
9096
+ maxRows: 8
9025
9097
  }
9026
9098
  ) })
9027
9099
  ] }),
@@ -9114,4 +9186,4 @@ export {
9114
9186
  getAPI as v,
9115
9187
  resetProviderCache as w
9116
9188
  };
9117
- //# sourceMappingURL=simulator-url-BOSS60NS.js.map
9189
+ //# sourceMappingURL=simulator-url-wBi-pko3.js.map