@waniwani/sdk 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ContentBlock, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
3
- import React$1, { ReactNode, SetStateAction } from 'react';
3
+ import React$1, { ReactNode, JSX, SetStateAction } from 'react';
4
4
 
5
5
  /**
6
6
  * Initializes & patches Next.js functionality so an app can run as a
@@ -140,6 +140,91 @@ type ModelContextUpdate = {
140
140
  structuredContent?: Record<string, unknown>;
141
141
  };
142
142
 
143
+ interface SendFollowUpOptions {
144
+ modelContext?: ModelContextUpdate | null;
145
+ }
146
+ /**
147
+ * Get a function to send follow-up messages to the AI.
148
+ * Works on both OpenAI widgets and MCP Apps.
149
+ *
150
+ * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to
151
+ * `@waniwani/sdk/legacy/react` in a future minor release.
152
+ * @returns A function that sends a follow-up message
153
+ */
154
+ declare function useSendFollowUp(): (prompt: string, options?: SendFollowUpOptions) => void;
155
+
156
+ interface UnstableSendFollowUpWithGhostGuardResult {
157
+ /** Wrapped `sendFollowUp`. Same signature as the one you passed in. */
158
+ sendFollowUp: (prompt: string, options?: SendFollowUpOptions) => void;
159
+ /**
160
+ * Wrap your widget's root render with this so the suppression can take
161
+ * effect. On non-ChatGPT hosts it is a transparent pass-through.
162
+ */
163
+ Guard: (props: {
164
+ children: ReactNode;
165
+ }) => JSX.Element | null;
166
+ }
167
+ /**
168
+ * ⚠️ EXPERIMENTAL — DO NOT USE UNLESS YOU UNDERSTAND THE TRADE-OFFS ⚠️
169
+ *
170
+ * Wraps an existing `sendFollowUp` with ghost-guard suppression specific
171
+ * to ChatGPT. ChatGPT renders the source widget a SECOND time alongside
172
+ * the new user message a widget emits via `sendFollowUpMessage`. The
173
+ * second iframe is a brand-new React tree with no link to the original;
174
+ * skybridge's `useViewState` persistence does not survive across them.
175
+ * The result is a visible duplicate widget for ~1s before ChatGPT
176
+ * collapses one of them.
177
+ *
178
+ * On ChatGPT the hook adds a per-`viewUUID` `localStorage` write before
179
+ * each `sendFollowUp` call, and the returned `Guard` checks that record
180
+ * on mount — if it sees a record set by a different `mountId` within
181
+ * `ADVANCED_WINDOW_MS`, it collapses the iframe to 0×0.
182
+ *
183
+ * On every other host (WaniWani embed, MCP Apps, etc.) the hook is a
184
+ * pure pass-through: `sendFollowUp` is your function unchanged and
185
+ * `Guard` is a transparent fragment.
186
+ *
187
+ * The hook does NOT require `WidgetProvider`. It reads the widget's
188
+ * `viewUUID` from `WidgetClientContext` when one is available and falls
189
+ * back to `window.openai.toolResponseMetadata.viewUUID` otherwise.
190
+ *
191
+ * Caveats:
192
+ * - Relies on ChatGPT's widget iframes sharing a single `localStorage`
193
+ * scope — verified at the time of writing but not guaranteed.
194
+ * - 10s suppression window per `viewUUID`. Two unrelated `sendFollowUp`
195
+ * calls inside 10s with the same viewUUID could mistakenly suppress one.
196
+ * - The `Guard` MUST wrap the widget's root render. If you forget it,
197
+ * the localStorage write happens but nothing is suppressed.
198
+ *
199
+ * @param sendFollowUp - The underlying `sendFollowUp` to wrap. On ChatGPT the
200
+ * hook adds the per-`viewUUID` localStorage write before delegating; on any
201
+ * other host the hook is a pure pass-through. Typically the value of
202
+ * `useSendFollowUpMessage()` from `skybridge/web` or `useSendFollowUp()`
203
+ * from this module.
204
+ *
205
+ * @example
206
+ * function MyWidget() {
207
+ * const sendFollowUpMessage = useSendFollowUpMessage(); // skybridge/web
208
+ * const { sendFollowUp, Guard } =
209
+ * unstable_useSendFollowUpWithGhostGuard(sendFollowUpMessage);
210
+ *
211
+ * // The Guard MUST wrap the widget's root render, otherwise the ghost
212
+ * // iframe will not be suppressed.
213
+ * return (
214
+ * <Guard>
215
+ * <div className="my-widget">
216
+ * <button onClick={() => sendFollowUp("I uploaded my bill")}>
217
+ * Continue
218
+ * </button>
219
+ * </div>
220
+ * </Guard>
221
+ * );
222
+ * }
223
+ *
224
+ * @experimental Subject to change or removal without notice.
225
+ */
226
+ declare function unstable_useSendFollowUpWithGhostGuard(sendFollowUp: (prompt: string) => void | Promise<void>): UnstableSendFollowUpWithGhostGuardResult;
227
+
143
228
  /**
144
229
  * Result from calling a tool
145
230
  */
@@ -398,19 +483,6 @@ declare function useRequestDisplayMode(): (mode: DisplayMode) => Promise<Display
398
483
  */
399
484
  declare function useSafeArea(): SafeArea | null;
400
485
 
401
- interface SendFollowUpOptions {
402
- modelContext?: ModelContextUpdate | null;
403
- }
404
- /**
405
- * Get a function to send follow-up messages to the AI.
406
- * Works on both OpenAI widgets and MCP Apps.
407
- *
408
- * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to
409
- * `@waniwani/sdk/legacy/react` in a future minor release.
410
- * @returns A function that sends a follow-up message
411
- */
412
- declare function useSendFollowUp(): (prompt: string, options?: SendFollowUpOptions) => void;
413
-
414
486
  /**
415
487
  * Get the current theme.
416
488
  * Works on both OpenAI widgets and MCP Apps.
@@ -570,4 +642,4 @@ declare function isOpenAI(): boolean;
570
642
  */
571
643
  declare function isMCPApps(): boolean;
572
644
 
573
- export { DevModeProvider, type DeviceType, type DisplayMode, type FlowActionResult, type HostContext, InitializeNextJsInIframe, LoadingWidget, type ModelContextContentBlock, type ModelContextUpdate, type SafeArea, type SafeAreaInsets, type SendFollowUpOptions, type Theme, type ToolCallResult, type ToolResult, type UnifiedWidgetClient, type UnknownObject, type UserAgent, type WidgetPlatform, WidgetProvider, detectPlatform, getMockState, initializeMockOpenAI, isMCPApps, isOpenAI, updateMockDisplayMode, updateMockGlobal, updateMockTheme, updateMockToolOutput, useCallTool, useDisplayMode, useFlowAction, useIsChatGptApp, useLocale, useMaxHeight, useOpenExternal, useRequestDisplayMode, useSafeArea, useSendFollowUp, useTheme, useToolOutput, useToolResponseMetadata, useUpdateModelContext, useWidgetClient, useWidgetState };
645
+ export { DevModeProvider, type DeviceType, type DisplayMode, type FlowActionResult, type HostContext, InitializeNextJsInIframe, LoadingWidget, type ModelContextContentBlock, type ModelContextUpdate, type SafeArea, type SafeAreaInsets, type SendFollowUpOptions, type Theme, type ToolCallResult, type ToolResult, type UnifiedWidgetClient, type UnknownObject, type UnstableSendFollowUpWithGhostGuardResult, type UserAgent, type WidgetPlatform, WidgetProvider, detectPlatform, getMockState, initializeMockOpenAI, isMCPApps, isOpenAI, unstable_useSendFollowUpWithGhostGuard, updateMockDisplayMode, updateMockGlobal, updateMockTheme, updateMockToolOutput, useCallTool, useDisplayMode, useFlowAction, useIsChatGptApp, useLocale, useMaxHeight, useOpenExternal, useRequestDisplayMode, useSafeArea, useSendFollowUp, useTheme, useToolOutput, useToolResponseMetadata, useUpdateModelContext, useWidgetClient, useWidgetState };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import{a as z,b as Oe,c as Ne}from"../../chunk-DP6SAQTK.js";import{b as R,c as V}from"../../chunk-RZKVTH7F.js";import{Fragment as Ue,jsx as W,jsxs as De}from"react/jsx-runtime";function Re(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(g=>{g.forEach(l=>{if(l.type==="attributes"&&l.target===a){let n=l.attributeName;n&&n!=="suppresshydrationwarning"&&n!=="lang"&&n!=="class"&&n!=="style"&&a.removeAttribute(n)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let m=history.replaceState.bind(history);history.replaceState=(g,l,n)=>{try{let c=new URL(String(n??""),window.location.href);m(null,l,c.pathname+c.search+c.hash)}catch{}};let f=history.pushState.bind(history);history.pushState=(g,l,n)=>{try{let c=new URL(String(n??""),window.location.href);f(null,l,c.pathname+c.search+c.hash)}catch{}};let x=new URL(e).origin,w=window.self!==window.top;if(window.addEventListener("click",g=>{let l=g?.target?.closest("a");if(!l||!l.href)return;let n=new URL(l.href,window.location.href);if(n.origin!==window.location.origin&&n.origin!==x)try{window.openai&&(window.openai?.openExternal({href:l.href}),g.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),w&&window.location.origin!==x){let g=window.fetch;window.fetch=((i,h)=>{let y=typeof i=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(i)&&!i.startsWith("//"),u;if(typeof i=="string"||i instanceof URL?u=new URL(i,window.location.href):u=new URL(i.url,window.location.href),u.origin===x)return typeof i=="string"||i instanceof URL?i=u.toString():i=new Request(u.toString(),i),g.call(window,i,{...h,mode:"cors"});if(t.indexOf(u.origin)!==-1)return g.call(window,i,h);if(y&&u.origin===window.location.origin){let C=new URL(e);return C.pathname=u.pathname,C.search=u.search,C.hash=u.hash,u=C,i=u.toString(),g.call(window,i,{...h,mode:"cors"})}return g.call(window,i,h)});let l=x.replace(/^http/,"ws"),n=window.WebSocket,c=((i,h)=>{let y=new URL(String(i),window.location.href);if(y.origin===window.location.origin||y.origin===window.location.origin.replace(/^http/,"ws")){let u=new URL(l);return u.pathname=y.pathname,u.search=y.search,u.hash=y.hash,new n(u.toString(),h)}return new n(i,h)});c.prototype=n.prototype,Object.assign(c,{CONNECTING:n.CONNECTING,OPEN:n.OPEN,CLOSING:n.CLOSING,CLOSED:n.CLOSED}),window.WebSocket=c}}var We=`(${Re.toString()})()`;function Ae({baseUrl:e,passthroughOrigins:t}){return De(Ue,{children:[W("base",{href:e}),W("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),W("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),W("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),W("script",{children:We})]})}import{useCallback as k,useEffect as O,useRef as G,useState as v}from"react";var Y={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},A={...Y};function U(e){typeof window>"u"||window.openai||(A={...Y,toolOutput:e??null},window.openai={...A,requestDisplayMode:async({mode:t})=>(S("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{S("widgetState",t)}},window.dispatchEvent(new R({globals:A})))}function S(e,t){typeof window>"u"||!window.openai||(A[e]=t,window.openai[e]=t,window.dispatchEvent(new R({globals:{[e]:t}})))}function F(){return{...A}}function D(e){S("toolOutput",e)}function I(e){S("displayMode",e)}function P(e){S("theme",e)}import{Fragment as K,jsx as o,jsxs as d}from"react/jsx-runtime";var H=150;function X({className:e}){return d("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[o("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),o("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Ie({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("path",{d:"M18 6L6 18M6 6l12 12"})})}function Pe({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function Ee({className:e}){return d("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),o("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Le({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Fe({className:e}){return d("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),o("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function He({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function je({className:e}){return d("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),o("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var _e=`
2
+ import{a as K,b as De,c as Ie}from"../../chunk-DP6SAQTK.js";import{b as O,c as Y}from"../../chunk-RZKVTH7F.js";import{Fragment as Le,jsx as U,jsxs as Ge}from"react/jsx-runtime";function Pe(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],n=document.documentElement;new MutationObserver(g=>{g.forEach(s=>{if(s.type==="attributes"&&s.target===n){let i=s.attributeName;i&&i!=="suppresshydrationwarning"&&i!=="lang"&&i!=="class"&&i!=="style"&&n.removeAttribute(i)}})}).observe(n,{attributes:!0,attributeOldValue:!0});let u=history.replaceState.bind(history);history.replaceState=(g,s,i)=>{try{let c=new URL(String(i??""),window.location.href);u(null,s,c.pathname+c.search+c.hash)}catch{}};let m=history.pushState.bind(history);history.pushState=(g,s,i)=>{try{let c=new URL(String(i??""),window.location.href);m(null,s,c.pathname+c.search+c.hash)}catch{}};let h=new URL(e).origin,w=window.self!==window.top;if(window.addEventListener("click",g=>{let s=g?.target?.closest("a");if(!s||!s.href)return;let i=new URL(s.href,window.location.href);if(i.origin!==window.location.origin&&i.origin!==h)try{window.openai&&(window.openai?.openExternal({href:s.href}),g.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),w&&window.location.origin!==h){let g=window.fetch;window.fetch=((r,x)=>{let y=typeof r=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(r)&&!r.startsWith("//"),f;if(typeof r=="string"||r instanceof URL?f=new URL(r,window.location.href):f=new URL(r.url,window.location.href),f.origin===h)return typeof r=="string"||r instanceof URL?r=f.toString():r=new Request(f.toString(),r),g.call(window,r,{...x,mode:"cors"});if(t.indexOf(f.origin)!==-1)return g.call(window,r,x);if(y&&f.origin===window.location.origin){let C=new URL(e);return C.pathname=f.pathname,C.search=f.search,C.hash=f.hash,f=C,r=f.toString(),g.call(window,r,{...x,mode:"cors"})}return g.call(window,r,x)});let s=h.replace(/^http/,"ws"),i=window.WebSocket,c=((r,x)=>{let y=new URL(String(r),window.location.href);if(y.origin===window.location.origin||y.origin===window.location.origin.replace(/^http/,"ws")){let f=new URL(s);return f.pathname=y.pathname,f.search=y.search,f.hash=y.hash,new i(f.toString(),x)}return new i(r,x)});c.prototype=i.prototype,Object.assign(c,{CONNECTING:i.CONNECTING,OPEN:i.OPEN,CLOSING:i.CLOSING,CLOSED:i.CLOSED}),window.WebSocket=c}}var Ee=`(${Pe.toString()})()`;function Fe({baseUrl:e,passthroughOrigins:t}){return Ge(Le,{children:[U("base",{href:e}),U("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),U("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),U("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),U("script",{children:Ee})]})}import{useCallback as k,useEffect as R,useRef as z,useState as v}from"react";var Q={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},W={...Q};function A(e){typeof window>"u"||window.openai||(W={...Q,toolOutput:e??null},window.openai={...W,requestDisplayMode:async({mode:t})=>(S("displayMode",t),{mode:t}),callTool:async(t,n)=>(console.log(`[DevMode] callTool: ${t}`,n),{result:JSON.stringify({mock:!0,tool:t,args:n})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{S("widgetState",t)}},window.dispatchEvent(new O({globals:W})))}function S(e,t){typeof window>"u"||!window.openai||(W[e]=t,window.openai[e]=t,window.dispatchEvent(new O({globals:{[e]:t}})))}function G(){return{...W}}function D(e){S("toolOutput",e)}function I(e){S("displayMode",e)}function P(e){S("theme",e)}import{Fragment as J,jsx as o,jsxs as p}from"react/jsx-runtime";var H=150;function Z({className:e}){return p("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[o("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),o("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function He({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("path",{d:"M18 6L6 18M6 6l12 12"})})}function _e({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function je({className:e}){return p("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),o("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Be({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ke({className:e}){return p("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),o("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function ze({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Je({className:e}){return p("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),o("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var $e=`
3
3
  @keyframes devPanelSlideIn {
4
4
  0% {
5
5
  opacity: 0;
@@ -47,22 +47,22 @@ import{a as z,b as Oe,c as Ne}from"../../chunk-DP6SAQTK.js";import{b as R,c as V
47
47
  .dev-json-editor::-webkit-scrollbar-thumb:hover {
48
48
  background: rgba(255, 255, 255, 0.15);
49
49
  }
50
- `;function Z({defaultProps:e,widgetPaths:t,children:a}){let[p,m]=v(!1),[f,x]=v(!1);return O(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){m(!0);return}if(t&&t.length>0){let g=window.location.pathname,l=t.some(n=>g===n||g.startsWith(`${n}/`));x(l),l&&U(e)}else U(e),x(!0);m(!0)},[e,t]),p?f?d(K,{children:[o(Be,{children:a}),o(ze,{defaultProps:e})]}):o(K,{children:a}):null}function Be({children:e}){return o("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:o("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function Q({options:e,value:t,onChange:a}){let p=e.findIndex(m=>m.value===t);return d("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[o("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${p*100}% + ${p*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(m=>d("button",{type:"button",onClick:()=>a(m.value),className:`
50
+ `;function te({defaultProps:e,widgetPaths:t,children:n}){let[d,u]=v(!1),[m,h]=v(!1);return R(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){u(!0);return}if(t&&t.length>0){let g=window.location.pathname,s=t.some(i=>g===i||g.startsWith(`${i}/`));h(s),s&&A(e)}else A(e),h(!0);u(!0)},[e,t]),d?m?p(J,{children:[o(Ve,{children:n}),o(qe,{defaultProps:e})]}):o(J,{children:n}):null}function Ve({children:e}){return o("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:o("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function ee({options:e,value:t,onChange:n}){let d=e.findIndex(u=>u.value===t);return p("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[o("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${d*100}% + ${d*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(u=>p("button",{type:"button",onClick:()=>n(u.value),className:`
51
51
  relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5
52
52
  text-xs font-medium rounded-md transition-colors duration-150
53
- ${t===m.value?"text-white":"text-gray-400 hover:text-gray-300"}
54
- `,children:[m.icon,o("span",{className:"capitalize",children:m.label})]},m.value))]})}function ze({defaultProps:e}){let[t,a]=v(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[p,m]=v(!1),[f,x]=v(t),[w,g]=v("inline"),[l,n]=v("dark"),[c,i]=v(!1),[h,y]=v(()=>JSON.stringify(e??{},null,2)),[u,C]=v(null),N=G(null),ye=G(null),_=G(null);O(()=>{let r=F();g(r.displayMode),n(r.theme)},[]),O(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:c?H:0,left:0,right:0}},window.dispatchEvent(new R({globals:{safeArea:window.openai.safeArea}})))},[c]),O(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let q=k(()=>{x(!0),requestAnimationFrame(()=>{a(!0)})},[]),M=k(()=>{m(!0),a(!1),setTimeout(()=>{x(!1),m(!1)},150)},[]),B=k(()=>{t?M():q()},[t,q,M]);O(()=>{let r=b=>{(b.metaKey||b.ctrlKey)&&b.shiftKey&&b.key==="d"&&(b.preventDefault(),B()),b.key==="Escape"&&t&&M()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,B,M]),O(()=>{if(!t)return;let r=b=>{_.current&&!_.current.contains(b.target)&&M()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[t,M]);let be=k(r=>{g(r),I(r)},[]),ve=k(r=>{n(r),P(r)},[]),L=k(r=>{try{let b=JSON.parse(r);C(null),D(b)}catch{C("Invalid JSON")}},[]),ke=k(r=>{y(r),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{L(r)},500)},[L]),Ce=k(()=>{N.current&&clearTimeout(N.current),L(h)},[L,h]),Me=k(()=>{let r=JSON.stringify(e??{},null,2);y(r),C(null),D(e??{}),g("inline"),I("inline"),n("dark"),P("dark")},[e]),Se=[{value:"inline",label:"inline",icon:o(Pe,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:o(Ee,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:o(Le,{className:"w-3.5 h-3.5"})}],Te=[{value:"light",label:"light",icon:o(Fe,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:o(He,{className:"w-3.5 h-3.5"})}];return d(K,{children:[o("style",{dangerouslySetInnerHTML:{__html:_e}}),d("div",{ref:_,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[d("button",{type:"button",onClick:B,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
53
+ ${t===u.value?"text-white":"text-gray-400 hover:text-gray-300"}
54
+ `,children:[u.icon,o("span",{className:"capitalize",children:u.label})]},u.value))]})}function qe({defaultProps:e}){let[t,n]=v(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[d,u]=v(!1),[m,h]=v(t),[w,g]=v("inline"),[s,i]=v("dark"),[c,r]=v(!1),[x,y]=v(()=>JSON.stringify(e??{},null,2)),[f,C]=v(null),N=z(null),Se=z(null),j=z(null);R(()=>{let a=G();g(a.displayMode),i(a.theme)},[]),R(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:c?H:0,left:0,right:0}},window.dispatchEvent(new O({globals:{safeArea:window.openai.safeArea}})))},[c]),R(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let X=k(()=>{h(!0),requestAnimationFrame(()=>{n(!0)})},[]),M=k(()=>{u(!0),n(!1),setTimeout(()=>{h(!1),u(!1)},150)},[]),B=k(()=>{t?M():X()},[t,X,M]);R(()=>{let a=b=>{(b.metaKey||b.ctrlKey)&&b.shiftKey&&b.key==="d"&&(b.preventDefault(),B()),b.key==="Escape"&&t&&M()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,B,M]),R(()=>{if(!t)return;let a=b=>{j.current&&!j.current.contains(b.target)&&M()};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[t,M]);let Te=k(a=>{g(a),I(a)},[]),Re=k(a=>{i(a),P(a)},[]),L=k(a=>{try{let b=JSON.parse(a);C(null),D(b)}catch{C("Invalid JSON")}},[]),Ne=k(a=>{y(a),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{L(a)},500)},[L]),Oe=k(()=>{N.current&&clearTimeout(N.current),L(x)},[L,x]),Ue=k(()=>{let a=JSON.stringify(e??{},null,2);y(a),C(null),D(e??{}),g("inline"),I("inline"),i("dark"),P("dark")},[e]),We=[{value:"inline",label:"inline",icon:o(_e,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:o(je,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:o(Be,{className:"w-3.5 h-3.5"})}],Ae=[{value:"light",label:"light",icon:o(Ke,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:o(ze,{className:"w-3.5 h-3.5"})}];return p(J,{children:[o("style",{dangerouslySetInnerHTML:{__html:$e}}),p("div",{ref:j,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[p("button",{type:"button",onClick:B,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
55
55
  0 4px 12px rgba(0, 0, 0, 0.4),
56
56
  0 0 0 1px rgba(255, 255, 255, 0.05),
57
57
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
58
- `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[o(X,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),o("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),f&&d("div",{ref:ye,className:`absolute bottom-14 right-0 w-80 ${t&&!p?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
58
+ `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[o(Z,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),o("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),m&&p("div",{ref:Se,className:`absolute bottom-14 right-0 w-80 ${t&&!d?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
59
59
  0 25px 50px -12px rgba(0, 0, 0, 0.6),
60
60
  0 0 0 1px rgba(255, 255, 255, 0.05),
61
61
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
62
- `},children:[d("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[d("div",{className:"flex items-center gap-2",children:[o(X,{className:"w-4 h-4 text-gray-400"}),o("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),d("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),o("button",{type:"button",onClick:M,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:o(Ie,{className:"w-4 h-4"})})]})]}),d("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[d("div",{children:[o("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),o(Q,{options:Se,value:w,onChange:be})]}),d("div",{children:[o("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),o(Q,{options:Te,value:l,onChange:ve})]}),d("div",{children:[o("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),d("button",{type:"button",onClick:()=>i(!c),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${c?"text-emerald-400":"text-gray-400"}`,style:{background:c?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:c?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[o("span",{children:"Mock ChatGPT Input Bar"}),o("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${c?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:c?"ON":"OFF"})]}),c&&d("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",H,"px"]})]}),d("div",{children:[o("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),o("textarea",{value:h,onChange:r=>ke(r.target.value),onBlur:Ce,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:u?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:r=>{u||(r.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:r=>{u||(r.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),u&&d("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[o("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:o("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),u]})]}),d("button",{type:"button",onClick:Me,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:r=>{r.currentTarget.style.background="rgba(255, 255, 255, 0.08)",r.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:r=>{r.currentTarget.style.background="rgba(255, 255, 255, 0.04)",r.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[o(je,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),c&&d("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${H}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[d("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),d("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",H,"px"]})]})]})}import{useCallback as Je}from"react";import E,{useCallback as te,useContext as Ke,useEffect as oe,useState as J,useSyncExternalStore as $e}from"react";import{createContext as Ge}from"react";var $=Ge(null);async function ee(){let{detectPlatform:e}=await import("../../platform-LKQFC3AJ.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../../openai-client-TZIOCMXP.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../../mcp-apps-client-OFYMQOI3.js");return new a}}function ne({children:e,loading:t=null,onError:a}){let[p,m]=J(null),[f,x]=J(null),[w,g]=J(!0);return oe(()=>{let l=!0,n=null;async function c(){try{let i=await ee();await i.connect(),l?(n=i,m(i),g(!1)):i.close()}catch(i){l&&(console.error("error",i),x(i instanceof Error?i:new Error(String(i))),g(!1))}}return c(),()=>{l=!1,n?.close()}},[]),oe(()=>{if(!p)return;let l=n=>{document.documentElement.classList.toggle("dark",n==="dark"),document.documentElement.style.colorScheme=n==="dark"?"dark":"auto"};return l(p.getTheme()),p.onThemeChange(l)},[p]),f&&a?E.createElement(E.Fragment,null,a(f)):w||!p?E.createElement(E.Fragment,null,t):E.createElement($.Provider,{value:p},e)}function s(e){let t=Ke($);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=te(f=>e==="toolOutput"?t.onToolResult(()=>f()):e==="theme"?t.onThemeChange(()=>f()):e==="displayMode"?t.onDisplayModeChange(()=>f()):e==="safeArea"?t.onSafeAreaChange(()=>f()):e==="maxHeight"?t.onMaxHeightChange(()=>f()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>f()):e==="widgetState"?t.onWidgetStateChange(()=>f()):()=>{},[t,e]),p=te(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),m=$e(a,p,p);return e?m:t}function re(){let e=s();return Je((t,a)=>e.callTool(t,a),[e])}function ie(){return s("displayMode")}function j(){return s("toolOutput")}function ae(){return{data:j()}}import{useSyncExternalStore as qe}from"react";function se(){return qe(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}function le(){return s("locale")}function de(){return s("maxHeight")}import{useCallback as Ve}from"react";function ce(){let e=s();return Ve(t=>e.openExternal(t),[e])}import{useCallback as Ye}from"react";function ue(){let e=s();return Ye(t=>e.requestDisplayMode(t),[e])}function pe(){return s("safeArea")}import{useCallback as Xe}from"react";function me(){let e=s();return Xe((t,a)=>{(async()=>{V(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(p=>{console.error("Failed to send follow-up message:",p)})},[e])}function ge(){return s("theme")}function fe(){return s("toolResponseMetadata")}import{useCallback as Qe}from"react";function xe(){let e=s();return Qe(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}import{useCallback as Ze,useEffect as et,useState as tt}from"react";function he(e){let t=s("widgetState"),[a,p]=tt(()=>t??(typeof e=="function"?e():e??null));et(()=>{p(t)},[t]);let m=Ze(f=>{p(x=>{let w=typeof f=="function"?f(x):f;return z()==="openai"&&w!=null&&window.openai?.setWidgetState(w),w})},[]);return[a,m]}import{jsx as T,jsxs as we}from"react/jsx-runtime";var ot=()=>we("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[we("div",{className:"flex gap-2",children:[T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),T("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),T("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:T("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),T("style",{children:`
62
+ `},children:[p("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[p("div",{className:"flex items-center gap-2",children:[o(Z,{className:"w-4 h-4 text-gray-400"}),o("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),p("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),o("button",{type:"button",onClick:M,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:o(He,{className:"w-4 h-4"})})]})]}),p("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[p("div",{children:[o("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),o(ee,{options:We,value:w,onChange:Te})]}),p("div",{children:[o("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),o(ee,{options:Ae,value:s,onChange:Re})]}),p("div",{children:[o("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),p("button",{type:"button",onClick:()=>r(!c),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${c?"text-emerald-400":"text-gray-400"}`,style:{background:c?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:c?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[o("span",{children:"Mock ChatGPT Input Bar"}),o("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${c?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:c?"ON":"OFF"})]}),c&&p("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",H,"px"]})]}),p("div",{children:[o("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),o("textarea",{value:x,onChange:a=>Ne(a.target.value),onBlur:Oe,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:f?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:a=>{f||(a.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:a=>{f||(a.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),f&&p("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[o("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:o("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),f]})]}),p("button",{type:"button",onClick:Ue,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.08)",a.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.04)",a.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[o(Je,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),c&&p("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${H}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[p("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),p("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",H,"px"]})]})]})}import{useCallback as Ye,useContext as Qe,useLayoutEffect as Ze,useMemo as et,useRef as oe}from"react";import{createContext as Xe}from"react";var E=Xe(null);import{Fragment as ne,jsx as $}from"react/jsx-runtime";var tt="waniwani:send-follow-up:advanced:",ot=1e4;function re(e){return`${tt}${e??"default"}`}function nt(e){try{let t=globalThis.localStorage?.getItem(re(e));if(!t)return null;let n=JSON.parse(t);return typeof n?.at!="number"||typeof n?.byMountId!="string"?null:n}catch{return null}}function rt(e,t){try{globalThis.localStorage?.setItem(re(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function V(){return typeof window>"u"?!1:typeof window.openai=="object"}function it(){return V()?window.openai:null}function at(){return Ze(()=>{let e=document.documentElement,t=document.body,n=e.getAttribute("style"),d=t.getAttribute("style"),u="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",u),t.setAttribute("style",u),()=>{n===null?e.removeAttribute("style"):e.setAttribute("style",n),d===null?t.removeAttribute("style"):t.setAttribute("style",d)}},[]),null}function ie(e){let t=Qe(E),n=oe(e);n.current=e;let d=t?.getToolResponseMetadata?.()??null,u=it()?.toolResponseMetadata??null,m=d??u,h=m&&typeof m.viewUUID=="string"?m.viewUUID:void 0,w=oe("");w.current===""&&(w.current=crypto.randomUUID());let g=Ye((i,c)=>{V()&&rt(h,w.current);try{Promise.resolve(n.current(i)).catch(r=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",r)})}catch(r){console.error("[unstable_useSendFollowUpWithGhostGuard]",r)}},[h]),s=et(()=>{let i=w.current;return function({children:r}){if(!V())return $(ne,{children:r});let x=nt(h);return x&&x.byMountId!==i&&Date.now()-x.at<ot?$(at,{}):$(ne,{children:r})}},[h]);return{sendFollowUp:g,Guard:s}}import{useCallback as dt}from"react";import F,{useCallback as se,useContext as st,useEffect as le,useState as q,useSyncExternalStore as lt}from"react";async function ae(){let{detectPlatform:e}=await import("../../platform-LKQFC3AJ.js");if(e()==="openai"){let{OpenAIWidgetClient:n}=await import("../../openai-client-TZIOCMXP.js");return new n}else{let{MCPAppsWidgetClient:n}=await import("../../mcp-apps-client-OFYMQOI3.js");return new n}}function de({children:e,loading:t=null,onError:n}){let[d,u]=q(null),[m,h]=q(null),[w,g]=q(!0);return le(()=>{let s=!0,i=null;async function c(){try{let r=await ae();await r.connect(),s?(i=r,u(r),g(!1)):r.close()}catch(r){s&&(console.error("error",r),h(r instanceof Error?r:new Error(String(r))),g(!1))}}return c(),()=>{s=!1,i?.close()}},[]),le(()=>{if(!d)return;let s=i=>{document.documentElement.classList.toggle("dark",i==="dark"),document.documentElement.style.colorScheme=i==="dark"?"dark":"auto"};return s(d.getTheme()),d.onThemeChange(s)},[d]),m&&n?F.createElement(F.Fragment,null,n(m)):w||!d?F.createElement(F.Fragment,null,t):F.createElement(E.Provider,{value:d},e)}function l(e){let t=st(E);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let n=se(m=>e==="toolOutput"?t.onToolResult(()=>m()):e==="theme"?t.onThemeChange(()=>m()):e==="displayMode"?t.onDisplayModeChange(()=>m()):e==="safeArea"?t.onSafeAreaChange(()=>m()):e==="maxHeight"?t.onMaxHeightChange(()=>m()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>m()):e==="widgetState"?t.onWidgetStateChange(()=>m()):()=>{},[t,e]),d=se(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),u=lt(n,d,d);return e?u:t}function ue(){let e=l();return dt((t,n)=>e.callTool(t,n),[e])}function ce(){return l("displayMode")}function _(){return l("toolOutput")}function pe(){return{data:_()}}import{useSyncExternalStore as ut}from"react";function me(){return ut(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}function ge(){return l("locale")}function fe(){return l("maxHeight")}import{useCallback as ct}from"react";function he(){let e=l();return ct(t=>e.openExternal(t),[e])}import{useCallback as pt}from"react";function we(){let e=l();return pt(t=>e.requestDisplayMode(t),[e])}function xe(){return l("safeArea")}import{useCallback as mt}from"react";function ye(){let e=l();return mt((t,n)=>{(async()=>{Y(n?.modelContext)&&await Promise.resolve(e.updateModelContext(n.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(d=>{console.error("Failed to send follow-up message:",d)})},[e])}function be(){return l("theme")}function ve(){return l("toolResponseMetadata")}import{useCallback as gt}from"react";function ke(){let e=l();return gt(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}import{useCallback as ft,useEffect as ht,useState as wt}from"react";function Ce(e){let t=l("widgetState"),[n,d]=wt(()=>t??(typeof e=="function"?e():e??null));ht(()=>{d(t)},[t]);let u=ft(m=>{d(h=>{let w=typeof m=="function"?m(h):m;return K()==="openai"&&w!=null&&window.openai?.setWidgetState(w),w})},[]);return[n,u]}import{jsx as T,jsxs as Me}from"react/jsx-runtime";var xt=()=>Me("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[Me("div",{className:"flex gap-2",children:[T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),T("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),T("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:T("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),T("style",{children:`
63
63
  @keyframes shimmer {
64
64
  0% { background-position: 200% 0; }
65
65
  100% { background-position: -200% 0; }
66
66
  }
67
- `})]});export{Z as DevModeProvider,Ae as InitializeNextJsInIframe,ot as LoadingWidget,ne as WidgetProvider,z as detectPlatform,F as getMockState,U as initializeMockOpenAI,Ne as isMCPApps,Oe as isOpenAI,I as updateMockDisplayMode,S as updateMockGlobal,P as updateMockTheme,D as updateMockToolOutput,re as useCallTool,ie as useDisplayMode,ae as useFlowAction,se as useIsChatGptApp,le as useLocale,de as useMaxHeight,ce as useOpenExternal,ue as useRequestDisplayMode,pe as useSafeArea,me as useSendFollowUp,ge as useTheme,j as useToolOutput,fe as useToolResponseMetadata,xe as useUpdateModelContext,s as useWidgetClient,he as useWidgetState};
67
+ `})]});export{te as DevModeProvider,Fe as InitializeNextJsInIframe,xt as LoadingWidget,de as WidgetProvider,K as detectPlatform,G as getMockState,A as initializeMockOpenAI,Ie as isMCPApps,De as isOpenAI,ie as unstable_useSendFollowUpWithGhostGuard,I as updateMockDisplayMode,S as updateMockGlobal,P as updateMockTheme,D as updateMockToolOutput,ue as useCallTool,ce as useDisplayMode,pe as useFlowAction,me as useIsChatGptApp,ge as useLocale,fe as useMaxHeight,he as useOpenExternal,we as useRequestDisplayMode,xe as useSafeArea,ye as useSendFollowUp,be as useTheme,_ as useToolOutput,ve as useToolResponseMetadata,ke as useUpdateModelContext,l as useWidgetClient,Ce as useWidgetState};
68
68
  //# sourceMappingURL=react.js.map