@waniwani/sdk 0.11.10 → 0.11.12
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/README.md +92 -93
- package/dist/chat/embed.js +51 -51
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/express-js/index.d.ts +8 -1
- package/dist/chat/express-js/index.js.map +1 -1
- package/dist/chat/index.d.ts +1 -22
- package/dist/chat/index.js +7 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/next-js/index.d.ts +5 -3
- package/dist/chat/next-js/index.js.map +1 -1
- package/dist/chat/server/index.js +1 -1
- package/dist/chat/server/index.js.map +1 -1
- package/dist/chat/styles.css +1 -1
- package/dist/{chunk-DGSC74SV.js → chunk-DP6SAQTK.js} +1 -1
- package/dist/chunk-DP6SAQTK.js.map +1 -0
- package/dist/{chunk-5OQXAEHG.js → chunk-RZKVTH7F.js} +1 -1
- package/dist/chunk-RZKVTH7F.js.map +1 -0
- package/dist/legacy/chat/express-js/index.d.ts +407 -0
- package/dist/legacy/chat/express-js/index.js +10 -0
- package/dist/legacy/chat/express-js/index.js.map +1 -0
- package/dist/legacy/chat/next-js/index.d.ts +368 -0
- package/dist/legacy/chat/next-js/index.js +10 -0
- package/dist/legacy/chat/next-js/index.js.map +1 -0
- package/dist/legacy/index.d.ts +335 -0
- package/dist/legacy/index.js +2 -0
- package/dist/legacy/index.js.map +1 -0
- package/dist/legacy/mcp/react.d.ts +573 -0
- package/dist/legacy/mcp/react.js +68 -0
- package/dist/legacy/mcp/react.js.map +1 -0
- package/dist/mcp/index.d.ts +1158 -1080
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/react.d.ts +170 -74
- package/dist/mcp/react.js +7 -7
- package/dist/mcp/react.js.map +1 -1
- package/dist/{mcp-apps-client-PUL4H54S.js → mcp-apps-client-OFYMQOI3.js} +1 -1
- package/dist/mcp-apps-client-OFYMQOI3.js.map +1 -0
- package/dist/{openai-client-QAC3ZD5W.js → openai-client-TZIOCMXP.js} +2 -2
- package/dist/openai-client-TZIOCMXP.js.map +1 -0
- package/dist/platform-LKQFC3AJ.js +3 -0
- package/package.json +34 -21
- package/dist/chunk-5OQXAEHG.js.map +0 -1
- package/dist/chunk-DGSC74SV.js.map +0 -1
- package/dist/evals/index.d.ts +0 -156
- package/dist/evals/index.js +0 -2
- package/dist/evals/index.js.map +0 -1
- package/dist/evals/scorers.d.ts +0 -92
- package/dist/evals/scorers.js +0 -8
- package/dist/evals/scorers.js.map +0 -1
- package/dist/mcp-apps-client-PUL4H54S.js.map +0 -1
- package/dist/openai-client-QAC3ZD5W.js.map +0 -1
- package/dist/platform-GKYYQBCS.js +0 -3
- /package/dist/{platform-GKYYQBCS.js.map → platform-LKQFC3AJ.js.map} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
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=`
|
|
3
|
+
@keyframes devPanelSlideIn {
|
|
4
|
+
0% {
|
|
5
|
+
opacity: 0;
|
|
6
|
+
transform: translateY(12px) scale(0.98);
|
|
7
|
+
}
|
|
8
|
+
100% {
|
|
9
|
+
opacity: 1;
|
|
10
|
+
transform: translateY(0) scale(1);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@keyframes devPanelSlideOut {
|
|
15
|
+
0% {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
transform: translateY(0) scale(1);
|
|
18
|
+
}
|
|
19
|
+
100% {
|
|
20
|
+
opacity: 0;
|
|
21
|
+
transform: translateY(8px) scale(0.98);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.dev-panel-enter {
|
|
26
|
+
animation: devPanelSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.dev-panel-exit {
|
|
30
|
+
animation: devPanelSlideOut 150ms cubic-bezier(0.4, 0, 1, 1) forwards;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dev-json-editor::-webkit-scrollbar {
|
|
34
|
+
width: 6px;
|
|
35
|
+
height: 6px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dev-json-editor::-webkit-scrollbar-track {
|
|
39
|
+
background: transparent;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.dev-json-editor::-webkit-scrollbar-thumb {
|
|
43
|
+
background: rgba(255, 255, 255, 0.1);
|
|
44
|
+
border-radius: 3px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dev-json-editor::-webkit-scrollbar-thumb:hover {
|
|
48
|
+
background: rgba(255, 255, 255, 0.15);
|
|
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:`
|
|
51
|
+
relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5
|
|
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:`
|
|
55
|
+
0 4px 12px rgba(0, 0, 0, 0.4),
|
|
56
|
+
0 0 0 1px rgba(255, 255, 255, 0.05),
|
|
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:`
|
|
59
|
+
0 25px 50px -12px rgba(0, 0, 0, 0.6),
|
|
60
|
+
0 0 0 1px rgba(255, 255, 255, 0.05),
|
|
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:`
|
|
63
|
+
@keyframes shimmer {
|
|
64
|
+
0% { background-position: 200% 0; }
|
|
65
|
+
100% { background-position: -200% 0; }
|
|
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};
|
|
68
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/legacy/mcp/react/components/initialize-next-in-iframe.tsx","../../../src/legacy/mcp/react/dev/dev-controls.tsx","../../../src/legacy/mcp/react/dev/mock-openai.ts","../../../src/legacy/mcp/react/hooks/use-call-tool.ts","../../../src/legacy/mcp/react/hooks/use-widget.ts","../../../src/mcp/react/context.ts","../../../src/legacy/mcp/react/widgets/widget-client.ts","../../../src/legacy/mcp/react/hooks/use-display-mode.ts","../../../src/legacy/mcp/react/hooks/use-tool-output.ts","../../../src/legacy/mcp/react/hooks/use-flow-action.ts","../../../src/legacy/mcp/react/hooks/use-is-chatgpt-app.ts","../../../src/legacy/mcp/react/hooks/use-locale.ts","../../../src/legacy/mcp/react/hooks/use-max-height.ts","../../../src/legacy/mcp/react/hooks/use-open-external.ts","../../../src/legacy/mcp/react/hooks/use-request-display-mode.ts","../../../src/legacy/mcp/react/hooks/use-safe-area.ts","../../../src/legacy/mcp/react/hooks/use-send-follow-up.ts","../../../src/legacy/mcp/react/hooks/use-theme.ts","../../../src/legacy/mcp/react/hooks/use-tool-response-metadata.ts","../../../src/legacy/mcp/react/hooks/use-update-model-context.ts","../../../src/legacy/mcp/react/hooks/use-widget-state.ts","../../../src/legacy/mcp/react/widgets/loading-widget.tsx"],"sourcesContent":["/**\n * Patches `history`, `<html>` mutations and `window.fetch` so a Next.js\n * widget can run inside a cross-origin iframe host. Reads its config from\n * `window.innerBaseUrl` and `window.__wwPassthroughOrigins`, which the\n * surrounding `<script>` tags set before this runs.\n *\n * Exported so tests can drive it directly. Production code never imports\n * it — the component below stringifies it into the SSR HTML.\n */\nexport function applyIframePatches(): void {\n\tconst baseUrl = window.innerBaseUrl;\n\tconst passthroughOrigins: string[] =\n\t\t(window as unknown as { __wwPassthroughOrigins: string[] })\n\t\t\t.__wwPassthroughOrigins ?? [];\n\tconst htmlElement = document.documentElement;\n\tconst observer = new MutationObserver((mutations) => {\n\t\tmutations.forEach((mutation) => {\n\t\t\tif (mutation.type === \"attributes\" && mutation.target === htmlElement) {\n\t\t\t\tconst attrName = mutation.attributeName;\n\t\t\t\t// Preserve class/style for theming (html.dark) and lang for i18n\n\t\t\t\tif (\n\t\t\t\t\tattrName &&\n\t\t\t\t\tattrName !== \"suppresshydrationwarning\" &&\n\t\t\t\t\tattrName !== \"lang\" &&\n\t\t\t\t\tattrName !== \"class\" &&\n\t\t\t\t\tattrName !== \"style\"\n\t\t\t\t) {\n\t\t\t\t\thtmlElement.removeAttribute(attrName);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n\tobserver.observe(htmlElement, {\n\t\tattributes: true,\n\t\tattributeOldValue: true,\n\t});\n\n\tconst originalReplaceState = history.replaceState.bind(history);\n\thistory.replaceState = (\n\t\t_s: unknown,\n\t\tunused: string,\n\t\turl?: string | URL | null,\n\t) => {\n\t\ttry {\n\t\t\tconst u = new URL(String(url ?? \"\"), window.location.href);\n\t\t\toriginalReplaceState(null, unused, u.pathname + u.search + u.hash);\n\t\t} catch {\n\t\t\t/* SecurityError in sandboxed iframe */\n\t\t}\n\t};\n\n\tconst originalPushState = history.pushState.bind(history);\n\thistory.pushState = (\n\t\t_s: unknown,\n\t\tunused: string,\n\t\turl?: string | URL | null,\n\t) => {\n\t\ttry {\n\t\t\tconst u = new URL(String(url ?? \"\"), window.location.href);\n\t\t\toriginalPushState(null, unused, u.pathname + u.search + u.hash);\n\t\t} catch {\n\t\t\t/* SecurityError in sandboxed iframe */\n\t\t}\n\t};\n\n\tconst appOrigin = new URL(baseUrl).origin;\n\tconst isInIframe = window.self !== window.top;\n\n\twindow.addEventListener(\n\t\t\"click\",\n\t\t(e) => {\n\t\t\tconst a = (e?.target as HTMLElement)?.closest(\"a\");\n\t\t\tif (!a || !a.href) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst url = new URL(a.href, window.location.href);\n\t\t\tif (url.origin !== window.location.origin && url.origin !== appOrigin) {\n\t\t\t\ttry {\n\t\t\t\t\tif (window.openai) {\n\t\t\t\t\t\twindow.openai?.openExternal({ href: a.href });\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\tconsole.warn(\"openExternal failed, likely not in OpenAI client\");\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\ttrue,\n\t);\n\n\tif (isInIframe && window.location.origin !== appOrigin) {\n\t\tconst originalFetch = window.fetch;\n\n\t\t(window as { fetch: typeof window.fetch }).fetch = ((\n\t\t\tinput: URL | RequestInfo,\n\t\t\tinit?: RequestInit,\n\t\t): Promise<Response> => {\n\t\t\t// Only string inputs without a scheme (or `//host`) are treated\n\t\t\t// as relative. URL/Request instances are always absolute, so\n\t\t\t// the caller already chose the target host.\n\t\t\tconst isRelativeString =\n\t\t\t\ttypeof input === \"string\" &&\n\t\t\t\t!/^[a-z][a-z0-9+.-]*:/i.test(input) &&\n\t\t\t\t!input.startsWith(\"//\");\n\n\t\t\tlet url: URL;\n\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\turl = new URL(input, window.location.href);\n\t\t\t} else {\n\t\t\t\turl = new URL(input.url, window.location.href);\n\t\t\t}\n\n\t\t\tif (url.origin === appOrigin) {\n\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\tinput = url.toString();\n\t\t\t\t} else {\n\t\t\t\t\tinput = new Request(url.toString(), input);\n\t\t\t\t}\n\n\t\t\t\treturn originalFetch.call(window, input, {\n\t\t\t\t\t...init,\n\t\t\t\t\tmode: \"cors\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (passthroughOrigins.indexOf(url.origin) !== -1) {\n\t\t\t\treturn originalFetch.call(window, input, init);\n\t\t\t}\n\n\t\t\t// Rewrite *relative* same-origin requests to the widget's real\n\t\t\t// `baseUrl`. Absolute URLs are left alone — they're the\n\t\t\t// caller's explicit target (e.g. SDK transport posting to the\n\t\t\t// WaniWani API on the same origin as the iframe).\n\t\t\tif (isRelativeString && url.origin === window.location.origin) {\n\t\t\t\tconst newUrl = new URL(baseUrl);\n\t\t\t\tnewUrl.pathname = url.pathname;\n\t\t\t\tnewUrl.search = url.search;\n\t\t\t\tnewUrl.hash = url.hash;\n\t\t\t\turl = newUrl;\n\t\t\t\tinput = url.toString();\n\n\t\t\t\treturn originalFetch.call(window, input, {\n\t\t\t\t\t...init,\n\t\t\t\t\tmode: \"cors\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn originalFetch.call(window, input, init);\n\t\t}) as typeof window.fetch;\n\n\t\tconst wsAppOrigin = appOrigin.replace(/^http/, \"ws\");\n\t\tconst OriginalWebSocket = window.WebSocket;\n\t\tconst PatchedWebSocket = ((\n\t\t\turl: string | URL,\n\t\t\tprotocols?: string | string[],\n\t\t) => {\n\t\t\tconst parsed = new URL(String(url), window.location.href);\n\t\t\tif (\n\t\t\t\tparsed.origin === window.location.origin ||\n\t\t\t\tparsed.origin === window.location.origin.replace(/^http/, \"ws\")\n\t\t\t) {\n\t\t\t\tconst rewritten = new URL(wsAppOrigin);\n\t\t\t\trewritten.pathname = parsed.pathname;\n\t\t\t\trewritten.search = parsed.search;\n\t\t\t\trewritten.hash = parsed.hash;\n\t\t\t\treturn new OriginalWebSocket(rewritten.toString(), protocols);\n\t\t\t}\n\t\t\treturn new OriginalWebSocket(url, protocols);\n\t\t}) as unknown as typeof WebSocket;\n\t\tPatchedWebSocket.prototype = OriginalWebSocket.prototype;\n\t\tObject.assign(PatchedWebSocket, {\n\t\t\tCONNECTING: OriginalWebSocket.CONNECTING,\n\t\t\tOPEN: OriginalWebSocket.OPEN,\n\t\t\tCLOSING: OriginalWebSocket.CLOSING,\n\t\t\tCLOSED: OriginalWebSocket.CLOSED,\n\t\t});\n\t\t(window as { WebSocket: typeof WebSocket }).WebSocket = PatchedWebSocket;\n\t}\n}\n\nconst PATCH_SCRIPT = `(${applyIframePatches.toString()})()`;\n\n/**\n * Initializes & patches Next.js functionality so an app can run as a\n * widget inside a cross-origin iframe. Used by every MCP widget host —\n * ChatGPT's sandbox, the embed's `/api/mcp/chat/resource` proxy, and any\n * future host that renders the widget on a domain other than its own\n * `baseUrl`.\n *\n * See `applyIframePatches` for the patch behavior.\n *\n * More background on the ChatGPT case:\n * https://vercel.com/blog/running-next-js-inside-chatgpt-a-deep-dive-into-native-app-integration\n *\n * @deprecated Legacy MCP-widget-in-host stack (used with `createResource`/`createTool`).\n * Preserved for back-compat; will move to `@waniwani/sdk/legacy/react` in a future minor\n * release.\n */\nexport function InitializeNextJsInIframe({\n\tbaseUrl,\n\tpassthroughOrigins,\n}: {\n\tbaseUrl: string;\n\t/**\n\t * Origins whose fetches should skip the relative same-origin → baseUrl\n\t * rewrite. Only needed for relative-URL calls that resolve to an\n\t * origin you do not want forwarded to `baseUrl` — absolute URLs are\n\t * never rewritten regardless of this list.\n\t */\n\tpassthroughOrigins?: string[];\n}) {\n\treturn (\n\t\t<>\n\t\t\t<base href={baseUrl}></base>\n\t\t\t<script>{`window.innerBaseUrl = ${JSON.stringify(baseUrl)}`}</script>\n\t\t\t<script>{`window.__wwPassthroughOrigins = ${JSON.stringify(passthroughOrigins ?? [])}`}</script>\n\t\t\t<script>{`window.__isChatGptApp = typeof window.openai !== \"undefined\";`}</script>\n\t\t\t<script>{PATCH_SCRIPT}</script>\n\t\t</>\n\t);\n}\n","\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { DisplayMode, Theme } from \"../hooks/@types\";\nimport { SetGlobalsEvent } from \"../hooks/@types\";\nimport {\n\tgetMockState,\n\tinitializeMockOpenAI,\n\tupdateMockDisplayMode,\n\tupdateMockTheme,\n\tupdateMockToolOutput,\n} from \"./mock-openai\";\n\nconst MOCK_SAFE_AREA_HEIGHT = 150;\n\n// ============================================================================\n// SVG Icons\n// ============================================================================\n\nfunction DevIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\trole=\"img\"\n\t\t\taria-label=\"Dev Controls\"\n\t\t>\n\t\t\t{/* Minimal: two stacked squares offset */}\n\t\t\t<rect\n\t\t\t\tx=\"4\"\n\t\t\t\ty=\"4\"\n\t\t\t\twidth=\"10\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"2\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t/>\n\t\t\t<rect\n\t\t\t\tx=\"10\"\n\t\t\t\ty=\"10\"\n\t\t\t\twidth=\"10\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"2\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\tfillOpacity=\"0.15\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction CloseIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t>\n\t\t\t<path d=\"M18 6L6 18M6 6l12 12\" />\n\t\t</svg>\n\t);\n}\n\nfunction InlineIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tx=\"2\"\n\t\t\t\ty=\"4\"\n\t\t\t\twidth=\"12\"\n\t\t\t\theight=\"8\"\n\t\t\t\trx=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction PipIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tx=\"1.5\"\n\t\t\t\ty=\"3\"\n\t\t\t\twidth=\"13\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t/>\n\t\t\t<rect x=\"8.5\" y=\"7\" width=\"5\" height=\"4\" rx=\"0.75\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\nfunction FullscreenIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"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\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction SunIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"2.5\" stroke=\"currentColor\" strokeWidth=\"1.25\" />\n\t\t\t<path\n\t\t\t\td=\"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\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction MoonIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction ResetIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\td=\"M12.5 2v3h-3M3.5 14v-3h3\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\n// ============================================================================\n// Styles\n// ============================================================================\n\nconst panelAnimationStyles = `\n @keyframes devPanelSlideIn {\n 0% {\n opacity: 0;\n transform: translateY(12px) scale(0.98);\n }\n 100% {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n\n @keyframes devPanelSlideOut {\n 0% {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n 100% {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n }\n\n .dev-panel-enter {\n animation: devPanelSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;\n }\n\n .dev-panel-exit {\n animation: devPanelSlideOut 150ms cubic-bezier(0.4, 0, 1, 1) forwards;\n }\n\n .dev-json-editor::-webkit-scrollbar {\n width: 6px;\n height: 6px;\n }\n\n .dev-json-editor::-webkit-scrollbar-track {\n background: transparent;\n }\n\n .dev-json-editor::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.1);\n border-radius: 3px;\n }\n\n .dev-json-editor::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n`;\n\n// ============================================================================\n// Components\n// ============================================================================\n\ninterface DevControlsProps {\n\tdefaultProps?: Record<string, unknown>;\n\twidgetPaths?: string[];\n}\n\n/**\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n */\nexport function DevModeProvider({\n\tdefaultProps,\n\twidgetPaths,\n\tchildren,\n}: DevControlsProps & { children: React.ReactNode }) {\n\tconst [isInitialized, setIsInitialized] = useState(false);\n\tconst [isWidgetPage, setIsWidgetPage] = useState(false);\n\n\tuseEffect(() => {\n\t\t// When loaded inside the MCP harness iframe, skip the OpenAI mock\n\t\t// so the real MCPAppsWidgetClient + App class is used instead.\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.get(\"platform\") === \"mcp-apps\") {\n\t\t\tsetIsInitialized(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if current path is a widget page\n\t\tif (widgetPaths && widgetPaths.length > 0) {\n\t\t\tconst currentPath = window.location.pathname;\n\t\t\tconst isWidget = widgetPaths.some(\n\t\t\t\t(path) => currentPath === path || currentPath.startsWith(`${path}/`),\n\t\t\t);\n\t\t\tsetIsWidgetPage(isWidget);\n\n\t\t\tif (isWidget) {\n\t\t\t\tinitializeMockOpenAI(defaultProps);\n\t\t\t}\n\t\t} else {\n\t\t\t// If no widgetPaths specified, treat all pages as widget pages (backwards compat)\n\t\t\tinitializeMockOpenAI(defaultProps);\n\t\t\tsetIsWidgetPage(true);\n\t\t}\n\t\tsetIsInitialized(true);\n\t}, [defaultProps, widgetPaths]);\n\n\tif (!isInitialized) {\n\t\treturn null;\n\t}\n\n\t// If not a widget page, just render children without the dev frame\n\tif (!isWidgetPage) {\n\t\treturn <>{children}</>;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<WidgetPreviewFrame>{children}</WidgetPreviewFrame>\n\t\t\t<DevControls defaultProps={defaultProps} />\n\t\t</>\n\t);\n}\n\nfunction WidgetPreviewFrame({ children }: { children: React.ReactNode }) {\n\treturn (\n\t\t<div className=\"min-h-screen bg-[#212121] flex items-center justify-center p-8\">\n\t\t\t<div\n\t\t\t\tclassName=\"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]\"\n\t\t\t\tstyle={{\n\t\t\t\t\tboxShadow: \"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)\",\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n// ============================================================================\n// Segmented Control\n// ============================================================================\n\ninterface SegmentOption<T extends string> {\n\tvalue: T;\n\tlabel: string;\n\ticon: React.ReactNode;\n}\n\ninterface SegmentedControlProps<T extends string> {\n\toptions: SegmentOption<T>[];\n\tvalue: T;\n\tonChange: (value: T) => void;\n}\n\nfunction SegmentedControl<T extends string>({\n\toptions,\n\tvalue,\n\tonChange,\n}: SegmentedControlProps<T>) {\n\tconst activeIndex = options.findIndex((opt) => opt.value === value);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"relative flex p-0.5 rounded-lg\"\n\t\t\tstyle={{\n\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t}}\n\t\t>\n\t\t\t{/* Sliding indicator */}\n\t\t\t<div\n\t\t\t\tclassName=\"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out\"\n\t\t\t\tstyle={{\n\t\t\t\t\twidth: `calc(${100 / options.length}% - 2px)`,\n\t\t\t\t\tleft: \"2px\",\n\t\t\t\t\ttransform: `translateX(calc(${activeIndex * 100}% + ${activeIndex * 2}px))`,\n\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.1)\",\n\t\t\t\t}}\n\t\t\t/>\n\n\t\t\t{options.map((option) => (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tkey={option.value}\n\t\t\t\t\tonClick={() => onChange(option.value)}\n\t\t\t\t\tclassName={`\n relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5\n text-xs font-medium rounded-md transition-colors duration-150\n ${value === option.value ? \"text-white\" : \"text-gray-400 hover:text-gray-300\"}\n `}\n\t\t\t\t>\n\t\t\t\t\t{option.icon}\n\t\t\t\t\t<span className=\"capitalize\">{option.label}</span>\n\t\t\t\t</button>\n\t\t\t))}\n\t\t</div>\n\t);\n}\n\n// ============================================================================\n// Main DevControls Component\n// ============================================================================\n\nfunction DevControls({ defaultProps }: DevControlsProps) {\n\tconst [isOpen, setIsOpen] = useState(() => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn false;\n\t\t}\n\t\treturn localStorage.getItem(\"dev-controls-open\") === \"true\";\n\t});\n\tconst [isAnimating, setIsAnimating] = useState(false);\n\tconst [shouldRender, setShouldRender] = useState(isOpen);\n\tconst [displayMode, setDisplayMode] = useState<DisplayMode>(\"inline\");\n\tconst [theme, setTheme] = useState<Theme>(\"dark\");\n\tconst [showSafeArea, setShowSafeArea] = useState(false);\n\tconst [propsJson, setPropsJson] = useState(() =>\n\t\tJSON.stringify(defaultProps ?? {}, null, 2),\n\t);\n\tconst [jsonError, setJsonError] = useState<string | null>(null);\n\tconst debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst panelRef = useRef<HTMLDivElement>(null);\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t// Initialize from mock state\n\tuseEffect(() => {\n\t\tconst state = getMockState();\n\t\tsetDisplayMode(state.displayMode);\n\t\tsetTheme(state.theme);\n\t}, []);\n\n\t// Update safeArea when toggled\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!window.openai) {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: window.openai may not exist yet\n\t\t\t(window as any).openai = {};\n\t\t}\n\t\twindow.openai.safeArea = {\n\t\t\tinsets: {\n\t\t\t\ttop: 0,\n\t\t\t\tbottom: showSafeArea ? MOCK_SAFE_AREA_HEIGHT : 0,\n\t\t\t\tleft: 0,\n\t\t\t\tright: 0,\n\t\t\t},\n\t\t};\n\t\twindow.dispatchEvent(\n\t\t\tnew SetGlobalsEvent({ globals: { safeArea: window.openai.safeArea } }),\n\t\t);\n\t}, [showSafeArea]);\n\n\t// Persist open state\n\tuseEffect(() => {\n\t\tlocalStorage.setItem(\"dev-controls-open\", String(isOpen));\n\t}, [isOpen]);\n\n\tconst openPanel = useCallback(() => {\n\t\tsetShouldRender(true);\n\t\t// Small delay to ensure DOM is ready for animation\n\t\trequestAnimationFrame(() => {\n\t\t\tsetIsOpen(true);\n\t\t});\n\t}, []);\n\n\tconst closePanel = useCallback(() => {\n\t\tsetIsAnimating(true);\n\t\tsetIsOpen(false);\n\t\t// Wait for exit animation\n\t\tsetTimeout(() => {\n\t\t\tsetShouldRender(false);\n\t\t\tsetIsAnimating(false);\n\t\t}, 150);\n\t}, []);\n\n\tconst togglePanel = useCallback(() => {\n\t\tif (isOpen) {\n\t\t\tclosePanel();\n\t\t} else {\n\t\t\topenPanel();\n\t\t}\n\t}, [isOpen, openPanel, closePanel]);\n\n\t// Keyboard shortcuts\n\tuseEffect(() => {\n\t\tconst handleKeyDown = (e: KeyboardEvent) => {\n\t\t\t// Cmd/Ctrl + Shift + D to toggle\n\t\t\tif ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === \"d\") {\n\t\t\t\te.preventDefault();\n\t\t\t\ttogglePanel();\n\t\t\t}\n\t\t\t// Escape to close\n\t\t\tif (e.key === \"Escape\" && isOpen) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"keydown\", handleKeyDown);\n\t\treturn () => window.removeEventListener(\"keydown\", handleKeyDown);\n\t}, [isOpen, togglePanel, closePanel]);\n\n\t// Click outside to close\n\tuseEffect(() => {\n\t\tif (!isOpen) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleClickOutside = (e: MouseEvent) => {\n\t\t\tif (\n\t\t\t\tcontainerRef.current &&\n\t\t\t\t!containerRef.current.contains(e.target as Node)\n\t\t\t) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener(\"mousedown\", handleClickOutside);\n\t\treturn () => document.removeEventListener(\"mousedown\", handleClickOutside);\n\t}, [isOpen, closePanel]);\n\n\tconst handleDisplayModeChange = useCallback((mode: DisplayMode) => {\n\t\tsetDisplayMode(mode);\n\t\tupdateMockDisplayMode(mode);\n\t}, []);\n\n\tconst handleThemeChange = useCallback((newTheme: Theme) => {\n\t\tsetTheme(newTheme);\n\t\tupdateMockTheme(newTheme);\n\t}, []);\n\n\tconst applyProps = useCallback((json: string) => {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(json);\n\t\t\tsetJsonError(null);\n\t\t\tupdateMockToolOutput(parsed);\n\t\t} catch {\n\t\t\tsetJsonError(\"Invalid JSON\");\n\t\t}\n\t}, []);\n\n\tconst handlePropsChange = useCallback(\n\t\t(json: string) => {\n\t\t\tsetPropsJson(json);\n\t\t\tif (debounceRef.current) {\n\t\t\t\tclearTimeout(debounceRef.current);\n\t\t\t}\n\t\t\tdebounceRef.current = setTimeout(() => {\n\t\t\t\tapplyProps(json);\n\t\t\t}, 500);\n\t\t},\n\t\t[applyProps],\n\t);\n\n\tconst handlePropsBlur = useCallback(() => {\n\t\tif (debounceRef.current) {\n\t\t\tclearTimeout(debounceRef.current);\n\t\t}\n\t\tapplyProps(propsJson);\n\t}, [applyProps, propsJson]);\n\n\tconst handleReset = useCallback(() => {\n\t\tconst defaultJson = JSON.stringify(defaultProps ?? {}, null, 2);\n\t\tsetPropsJson(defaultJson);\n\t\tsetJsonError(null);\n\t\tupdateMockToolOutput(defaultProps ?? {});\n\t\tsetDisplayMode(\"inline\");\n\t\tupdateMockDisplayMode(\"inline\");\n\t\tsetTheme(\"dark\");\n\t\tupdateMockTheme(\"dark\");\n\t}, [defaultProps]);\n\n\tconst displayModeOptions: SegmentOption<DisplayMode>[] = [\n\t\t{\n\t\t\tvalue: \"inline\",\n\t\t\tlabel: \"inline\",\n\t\t\ticon: <InlineIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t\t{ value: \"pip\", label: \"pip\", icon: <PipIcon className=\"w-3.5 h-3.5\" /> },\n\t\t{\n\t\t\tvalue: \"fullscreen\",\n\t\t\tlabel: \"full\",\n\t\t\ticon: <FullscreenIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t];\n\n\tconst themeOptions: SegmentOption<Theme>[] = [\n\t\t{\n\t\t\tvalue: \"light\",\n\t\t\tlabel: \"light\",\n\t\t\ticon: <SunIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t\t{\n\t\t\tvalue: \"dark\",\n\t\t\tlabel: \"dark\",\n\t\t\ticon: <MoonIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{/* Inject animation styles */}\n\t\t\t{/** biome-ignore lint/security/noDangerouslySetInnerHtml: we need to inject styles into the DOM */}\n\t\t\t<style dangerouslySetInnerHTML={{ __html: panelAnimationStyles }} />\n\n\t\t\t<div\n\t\t\t\tref={containerRef}\n\t\t\t\tclassName=\"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]\"\n\t\t\t>\n\t\t\t\t{/* Toggle Button */}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={togglePanel}\n\t\t\t\t\tclassName=\"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\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: \"rgba(14, 14, 16, 0.95)\",\n\t\t\t\t\t\tbackdropFilter: \"blur(16px)\",\n\t\t\t\t\t\tWebkitBackdropFilter: \"blur(16px)\",\n\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.08)\",\n\t\t\t\t\t\tboxShadow: `\n 0 4px 12px rgba(0, 0, 0, 0.4),\n 0 0 0 1px rgba(255, 255, 255, 0.05),\n inset 0 1px 0 rgba(255, 255, 255, 0.04)\n `,\n\t\t\t\t\t}}\n\t\t\t\t\taria-label=\"Toggle Dev Controls\"\n\t\t\t\t\taria-expanded={isOpen}\n\t\t\t\t>\n\t\t\t\t\t<DevIcon\n\t\t\t\t\t\tclassName={`w-5 h-5 transition-all duration-200 ${\n\t\t\t\t\t\t\tisOpen\n\t\t\t\t\t\t\t\t? \"text-indigo-400 scale-110\"\n\t\t\t\t\t\t\t\t: \"text-gray-300 group-hover:text-white\"\n\t\t\t\t\t\t}`}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{/* Subtle glow on hover */}\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none\"\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\t\"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</button>\n\n\t\t\t\t{/* Panel */}\n\t\t\t\t{shouldRender && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={panelRef}\n\t\t\t\t\t\tclassName={`absolute bottom-14 right-0 w-80 ${\n\t\t\t\t\t\t\tisOpen && !isAnimating ? \"dev-panel-enter\" : \"dev-panel-exit\"\n\t\t\t\t\t\t}`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tmaxHeight: \"calc(100vh - 120px)\",\n\t\t\t\t\t\t\tbackground: \"rgba(14, 14, 16, 0.92)\",\n\t\t\t\t\t\t\tbackdropFilter: \"blur(24px)\",\n\t\t\t\t\t\t\tWebkitBackdropFilter: \"blur(24px)\",\n\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\tborderRadius: \"16px\",\n\t\t\t\t\t\t\tboxShadow: `\n 0 25px 50px -12px rgba(0, 0, 0, 0.6),\n 0 0 0 1px rgba(255, 255, 255, 0.05),\n inset 0 1px 0 rgba(255, 255, 255, 0.04)\n `,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{/* Header */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"flex items-center justify-between px-4 py-3\"\n\t\t\t\t\t\t\tstyle={{ borderBottom: \"1px solid rgba(255, 255, 255, 0.06)\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<DevIcon className=\"w-4 h-4 text-gray-400\" />\n\t\t\t\t\t\t\t\t<span className=\"text-sm font-medium text-white\">\n\t\t\t\t\t\t\t\t\tDev Controls\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t{/* Keyboard shortcut badge */}\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded\"\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{typeof navigator !== \"undefined\" &&\n\t\t\t\t\t\t\t\t\tnavigator.platform?.includes(\"Mac\")\n\t\t\t\t\t\t\t\t\t\t? \"⌘⇧D\"\n\t\t\t\t\t\t\t\t\t\t: \"Ctrl+Shift+D\"}\n\t\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t\t{/* Close button */}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tonClick={closePanel}\n\t\t\t\t\t\t\t\t\tclassName=\"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CloseIcon className=\"w-4 h-4\" />\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t{/* Content */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"p-4 space-y-5 overflow-y-auto\"\n\t\t\t\t\t\t\tstyle={{ maxHeight: \"calc(100vh - 200px)\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/* Display Mode */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"display-mode\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tDisplay Mode\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<SegmentedControl\n\t\t\t\t\t\t\t\t\toptions={displayModeOptions}\n\t\t\t\t\t\t\t\t\tvalue={displayMode}\n\t\t\t\t\t\t\t\t\tonChange={handleDisplayModeChange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Theme */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"theme\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tTheme\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<SegmentedControl\n\t\t\t\t\t\t\t\t\toptions={themeOptions}\n\t\t\t\t\t\t\t\t\tvalue={theme}\n\t\t\t\t\t\t\t\t\tonChange={handleThemeChange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Safe Area Mock */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"safe-area\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tSafe Area (Chat Input)\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShowSafeArea(!showSafeArea)}\n\t\t\t\t\t\t\t\t\tclassName={`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${\n\t\t\t\t\t\t\t\t\t\tshowSafeArea ? \"text-emerald-400\" : \"text-gray-400\"\n\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: showSafeArea\n\t\t\t\t\t\t\t\t\t\t\t? \"rgba(34, 197, 94, 0.1)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\t\tborder: showSafeArea\n\t\t\t\t\t\t\t\t\t\t\t? \"1px solid rgba(34, 197, 94, 0.3)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>Mock ChatGPT Input Bar</span>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclassName={`px-2 py-0.5 rounded text-[10px] font-semibold ${\n\t\t\t\t\t\t\t\t\t\t\tshowSafeArea\n\t\t\t\t\t\t\t\t\t\t\t\t? \"bg-emerald-500/20 text-emerald-400\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"bg-gray-500/20 text-gray-500\"\n\t\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{showSafeArea ? \"ON\" : \"OFF\"}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t{showSafeArea && (\n\t\t\t\t\t\t\t\t\t<p className=\"text-[10px] text-gray-500 mt-1.5\">\n\t\t\t\t\t\t\t\t\t\tbottom: {MOCK_SAFE_AREA_HEIGHT}px\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Widget Props */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"widget-props\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tWidget Props\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\t\t\tvalue={propsJson}\n\t\t\t\t\t\t\t\t\tonChange={(e) => handlePropsChange(e.target.value)}\n\t\t\t\t\t\t\t\t\tonBlur={handlePropsBlur}\n\t\t\t\t\t\t\t\t\tclassName=\"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors\"\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: \"rgba(0, 0, 0, 0.3)\",\n\t\t\t\t\t\t\t\t\t\tborder: jsonError\n\t\t\t\t\t\t\t\t\t\t\t? \"1px solid rgba(239, 68, 68, 0.5)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t\tfontFamily:\n\t\t\t\t\t\t\t\t\t\t\t\"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace\",\n\t\t\t\t\t\t\t\t\t\tlineHeight: 1.6,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonFocus={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (!jsonError) {\n\t\t\t\t\t\t\t\t\t\t\te.target.style.borderColor = \"rgba(99, 102, 241, 0.5)\";\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonBlurCapture={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (!jsonError) {\n\t\t\t\t\t\t\t\t\t\t\te.target.style.borderColor = \"rgba(255, 255, 255, 0.06)\";\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tspellCheck={false}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{jsonError && (\n\t\t\t\t\t\t\t\t\t<p className=\"text-red-400 text-[11px] mt-1.5 flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Error\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"w-3 h-3\"\n\t\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<path d=\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z\" />\n\t\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t\t{jsonError}\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Reset Button */}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tonClick={handleReset}\n\t\t\t\t\t\t\t\tclassName=\"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\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonMouseEnter={(e) => {\n\t\t\t\t\t\t\t\t\te.currentTarget.style.background =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.08)\";\n\t\t\t\t\t\t\t\t\te.currentTarget.style.borderColor =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.1)\";\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonMouseLeave={(e) => {\n\t\t\t\t\t\t\t\t\te.currentTarget.style.background =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.04)\";\n\t\t\t\t\t\t\t\t\te.currentTarget.style.borderColor =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.06)\";\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ResetIcon className=\"w-3.5 h-3.5\" />\n\t\t\t\t\t\t\t\tReset to Defaults\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Mock ChatGPT Input Bar */}\n\t\t\t{showSafeArea && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\theight: `${MOCK_SAFE_AREA_HEIGHT}px`,\n\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)\",\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<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\">\n\t\t\t\t\t\t<div className=\"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center\">\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tclassName=\"w-4 h-4 text-gray-400\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeWidth={2}\n\t\t\t\t\t\t\t\t\td=\"M12 4v16m8-8H4\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"flex-1 text-gray-400 text-sm\">\n\t\t\t\t\t\t\tAsk me anything...\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center\">\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tclassName=\"w-4 h-4 text-gray-400\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeWidth={2}\n\t\t\t\t\t\t\t\t\td=\"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\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"absolute bottom-1 text-[10px] text-gray-600 font-mono\">\n\t\t\t\t\t\tMock SafeArea: bottom={MOCK_SAFE_AREA_HEIGHT}px\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</>\n\t);\n}\n","import {\n\ttype DisplayMode,\n\ttype OpenAIGlobals,\n\tSetGlobalsEvent,\n\ttype Theme,\n} from \"../hooks/@types\";\n\nconst DEFAULT_MOCK_CONFIG: Omit<OpenAIGlobals, \"setWidgetState\"> = {\n\ttheme: \"dark\",\n\tuserAgent: {\n\t\tdevice: { type: \"desktop\" },\n\t\tcapabilities: { hover: true, touch: false },\n\t},\n\tlocale: \"en\",\n\tmaxHeight: 800,\n\tdisplayMode: \"inline\",\n\tsafeArea: { insets: { top: 0, bottom: 0, left: 0, right: 0 } },\n\ttoolInput: {},\n\ttoolOutput: null,\n\ttoolResponseMetadata: null,\n\twidgetState: null,\n};\n\nlet mockState: Omit<OpenAIGlobals, \"setWidgetState\"> = {\n\t...DEFAULT_MOCK_CONFIG,\n};\n\nexport function initializeMockOpenAI(\n\tinitialToolOutput?: Record<string, unknown>,\n): void {\n\tif (typeof window === \"undefined\") {\n\t\treturn;\n\t}\n\tif (window.openai) {\n\t\treturn; // Already initialized (real ChatGPT or previous mock)\n\t}\n\n\tmockState = {\n\t\t...DEFAULT_MOCK_CONFIG,\n\t\ttoolOutput: initialToolOutput ?? null,\n\t};\n\n\twindow.openai = {\n\t\t...mockState,\n\t\t// Mock API functions\n\t\trequestDisplayMode: async ({ mode }) => {\n\t\t\tupdateMockGlobal(\"displayMode\", mode);\n\t\t\treturn { mode };\n\t\t},\n\t\tcallTool: async (name, args) => {\n\t\t\tconsole.log(`[DevMode] callTool: ${name}`, args);\n\t\t\treturn { result: JSON.stringify({ mock: true, tool: name, args }) };\n\t\t},\n\t\tsendFollowUpMessage: async ({ prompt }) => {\n\t\t\tconsole.log(`[DevMode] sendFollowUpMessage: ${prompt}`);\n\t\t},\n\t\topenExternal: ({ href }) => {\n\t\t\tconsole.log(`[DevMode] openExternal: ${href}`);\n\t\t\twindow.open(href, \"_blank\");\n\t\t},\n\t\tsetWidgetState: async (state) => {\n\t\t\tupdateMockGlobal(\"widgetState\", state);\n\t\t},\n\t};\n\n\t// Dispatch initial event so hooks pick up the values\n\twindow.dispatchEvent(new SetGlobalsEvent({ globals: mockState }));\n}\n\nexport function updateMockGlobal<K extends keyof OpenAIGlobals>(\n\tkey: K,\n\tvalue: OpenAIGlobals[K],\n): void {\n\tif (typeof window === \"undefined\" || !window.openai) {\n\t\treturn;\n\t}\n\n\t(mockState as Record<string, unknown>)[key] = value;\n\t(window.openai as Record<string, unknown>)[key] = value;\n\n\twindow.dispatchEvent(new SetGlobalsEvent({ globals: { [key]: value } }));\n}\n\nexport function getMockState(): typeof mockState {\n\treturn { ...mockState };\n}\n\nexport function updateMockToolOutput(props: Record<string, unknown>): void {\n\tupdateMockGlobal(\"toolOutput\", props);\n}\n\nexport function updateMockDisplayMode(mode: DisplayMode): void {\n\tupdateMockGlobal(\"displayMode\", mode);\n}\n\nexport function updateMockTheme(theme: Theme): void {\n\tupdateMockGlobal(\"theme\", theme);\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { ToolCallResult } from \"../widgets/widget-client\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to call other tools.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns A function to call tools with their name and arguments\n */\nexport function useCallTool(): (\n\tname: string,\n\targs: Record<string, unknown>,\n) => Promise<ToolCallResult> {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(name: string, args: Record<string, unknown>) =>\n\t\t\tclient.callTool(name, args),\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport React, {\n\ttype ReactNode,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseState,\n\tuseSyncExternalStore,\n} from \"react\";\nimport { WidgetClientContext } from \"../../../../mcp/react/context\";\nimport {\n\tcreateWidgetClient,\n\ttype UnifiedWidgetClient,\n} from \"../widgets/widget-client\";\nimport type { DisplayMode, SafeArea, Theme, UnknownObject } from \"./@types\";\n\n// `WidgetClientContext` lives in non-legacy at `src/mcp/react/context.ts` so\n// the non-legacy `useWaniwani` hook can read it without depending on legacy\n// runtime. Re-exported here for back-compat with any code that imported it\n// from this path.\nexport { WidgetClientContext };\n\n/**\n * Provider props\n */\ninterface WidgetProviderProps {\n\tchildren: ReactNode;\n\t/** Optional loading component while connecting */\n\tloading?: ReactNode;\n\t/** Optional error component */\n\tonError?: (error: Error) => ReactNode;\n}\n\n/**\n * Provider component that initializes the correct widget client based on platform.\n * Wrap your widget component with this provider.\n *\n * @deprecated Part of the legacy MCP-widget-in-host stack (used with `createResource` /\n * `createTool`). Preserved for back-compat; will move to `@waniwani/sdk/legacy/react` in\n * a future minor release. For new code, use `createFlow` from `@waniwani/sdk/mcp` and\n * `useWaniwani` from `@waniwani/sdk/mcp/react`.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <WidgetProvider loading={<Spinner />}>\n * <MyWidget />\n * </WidgetProvider>\n * );\n * }\n * ```\n */\nexport function WidgetProvider({\n\tchildren,\n\tloading = null,\n\tonError,\n}: WidgetProviderProps) {\n\tconst [client, setClient] = useState<UnifiedWidgetClient | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst [isConnecting, setIsConnecting] = useState(true);\n\n\tuseEffect(() => {\n\t\tlet mounted = true;\n\t\tlet activeClient: UnifiedWidgetClient | null = null;\n\n\t\tasync function initClient() {\n\t\t\ttry {\n\t\t\t\tconst widgetClient = await createWidgetClient();\n\n\t\t\t\tawait widgetClient.connect();\n\n\t\t\t\tif (mounted) {\n\t\t\t\t\tactiveClient = widgetClient;\n\t\t\t\t\tsetClient(widgetClient);\n\t\t\t\t\tsetIsConnecting(false);\n\t\t\t\t} else {\n\t\t\t\t\t// Component unmounted during connect — clean up\n\t\t\t\t\twidgetClient.close();\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tif (mounted) {\n\t\t\t\t\tconsole.error(\"error\", err);\n\t\t\t\t\tsetError(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t\tsetIsConnecting(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tinitClient();\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\t\t\tactiveClient?.close();\n\t\t};\n\t}, []);\n\n\t// Sync theme to <html> class so consumers can use html.dark { ... } or dark: variants\n\tuseEffect(() => {\n\t\tif (!client) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst syncTheme = (theme: Theme) => {\n\t\t\tdocument.documentElement.classList.toggle(\"dark\", theme === \"dark\");\n\t\t\tdocument.documentElement.style.colorScheme =\n\t\t\t\ttheme === \"dark\" ? \"dark\" : \"auto\";\n\t\t};\n\n\t\tsyncTheme(client.getTheme());\n\t\treturn client.onThemeChange(syncTheme);\n\t}, [client]);\n\n\tif (error && onError) {\n\t\treturn React.createElement(React.Fragment, null, onError(error));\n\t}\n\n\tif (isConnecting || !client) {\n\t\treturn React.createElement(React.Fragment, null, loading);\n\t}\n\n\treturn React.createElement(\n\t\tWidgetClientContext.Provider,\n\t\t{ value: client },\n\t\tchildren,\n\t);\n}\n\n/**\n * Keys that can be selected from the widget client.\n */\ntype WidgetKey =\n\t| \"toolOutput\"\n\t| \"theme\"\n\t| \"displayMode\"\n\t| \"locale\"\n\t| \"safeArea\"\n\t| \"maxHeight\"\n\t| \"toolResponseMetadata\"\n\t| \"widgetState\";\n\n/**\n * Value types for each widget key.\n */\ntype WidgetKeyValues = {\n\ttoolOutput: Record<string, unknown> | null;\n\ttheme: Theme;\n\tdisplayMode: DisplayMode;\n\tlocale: string;\n\tsafeArea: SafeArea | null;\n\tmaxHeight: number | null;\n\ttoolResponseMetadata: UnknownObject | null;\n\twidgetState: UnknownObject | null;\n};\n\n/**\n * Get the unified widget client instance.\n * Must be used within a WidgetProvider.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n *\n * @example\n * ```tsx\n * // Full client for actions\n * const client = useWidgetClient();\n * client.callTool(\"foo\", {});\n *\n * // Key selector for reactive values\n * const toolOutput = useWidgetClient(\"toolOutput\");\n * const theme = useWidgetClient(\"theme\");\n * ```\n */\nexport function useWidgetClient(): UnifiedWidgetClient;\nexport function useWidgetClient<K extends WidgetKey>(\n\tkey: K,\n): WidgetKeyValues[K];\nexport function useWidgetClient<K extends WidgetKey>(key?: K) {\n\tconst client = useContext(WidgetClientContext);\n\n\tif (!client) {\n\t\tthrow new Error(\"useWidgetClient must be used within a WidgetProvider\");\n\t}\n\n\t// Key selector - use useSyncExternalStore\n\tconst subscribe = useCallback(\n\t\t(onChange: () => void) => {\n\t\t\tif (key === \"toolOutput\") {\n\t\t\t\treturn client.onToolResult(() => onChange());\n\t\t\t}\n\t\t\tif (key === \"theme\") {\n\t\t\t\treturn client.onThemeChange(() => onChange());\n\t\t\t}\n\t\t\tif (key === \"displayMode\") {\n\t\t\t\treturn client.onDisplayModeChange(() => onChange());\n\t\t\t}\n\t\t\tif (key === \"safeArea\") {\n\t\t\t\treturn client.onSafeAreaChange(() => onChange());\n\t\t\t}\n\t\t\tif (key === \"maxHeight\") {\n\t\t\t\treturn client.onMaxHeightChange(() => onChange());\n\t\t\t}\n\t\t\tif (key === \"toolResponseMetadata\") {\n\t\t\t\treturn client.onToolResponseMetadataChange(() => onChange());\n\t\t\t}\n\t\t\tif (key === \"widgetState\") {\n\t\t\t\treturn client.onWidgetStateChange(() => onChange());\n\t\t\t}\n\t\t\treturn () => {};\n\t\t},\n\t\t[client, key],\n\t);\n\n\tconst getSnapshot = useCallback(() => {\n\t\tif (key === \"toolOutput\") {\n\t\t\treturn client.getToolOutput();\n\t\t}\n\t\tif (key === \"theme\") {\n\t\t\treturn client.getTheme();\n\t\t}\n\t\tif (key === \"displayMode\") {\n\t\t\treturn client.getDisplayMode();\n\t\t}\n\t\tif (key === \"locale\") {\n\t\t\treturn client.getLocale();\n\t\t}\n\t\tif (key === \"safeArea\") {\n\t\t\treturn client.getSafeArea();\n\t\t}\n\t\tif (key === \"maxHeight\") {\n\t\t\treturn client.getMaxHeight();\n\t\t}\n\t\tif (key === \"toolResponseMetadata\") {\n\t\t\treturn client.getToolResponseMetadata();\n\t\t}\n\t\tif (key === \"widgetState\") {\n\t\t\treturn client.getWidgetState();\n\t\t}\n\t\treturn null;\n\t}, [client, key]);\n\n\tconst store = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n\t// No key - return full client\n\tif (!key) {\n\t\treturn client;\n\t}\n\n\treturn store;\n}\n","\"use client\";\n\n/**\n * Shared widget-client context.\n *\n * The context value is owned by the legacy `WidgetProvider`\n * (`src/legacy/mcp/react/hooks/use-widget.ts`), but `useWaniwani` reads it\n * opportunistically to auto-discover its config when a widget is mounted\n * inside a legacy MCP-widget host. Outside that legacy host, the context\n * value is `null` and `useWaniwani` falls back to explicit options.\n *\n * Lives in non-legacy because non-legacy code (`useWaniwani`) reads it. Legacy\n * code crosses the boundary to import it, which is allowed.\n */\n\nimport { createContext } from \"react\";\nimport type { UnifiedWidgetClient } from \"../../legacy/mcp/react/widgets/widget-client\";\n\nexport const WidgetClientContext = createContext<UnifiedWidgetClient | null>(\n\tnull,\n);\n","import type { CallToolResult as McpCallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { ModelContextUpdate } from \"../../../../shared/model-context\";\nimport type {\n\tDisplayMode,\n\tSafeArea,\n\tTheme,\n\tUnknownObject,\n} from \"../hooks/@types\";\n\n/**\n * Result from calling a tool\n */\nexport type ToolCallResult = McpCallToolResult;\n\n/**\n * Tool result notification (what the host pushes to the widget)\n */\nexport type ToolResult = McpCallToolResult;\n\n/**\n * Host context - all values available from the host.\n */\nexport type HostContext = {\n\ttheme: Theme;\n\tlocale: string;\n\tdisplayMode: DisplayMode;\n\tmaxHeight: number | null;\n\tsafeArea: SafeArea | null;\n\ttoolOutput: UnknownObject | null;\n\ttoolResponseMetadata: UnknownObject | null;\n\twidgetState: UnknownObject | null;\n};\n\n/**\n * Store interface for useSyncExternalStore compatibility.\n */\nexport type HostContextStore<K extends keyof HostContext> = {\n\tsubscribe: (onStoreChange: () => void) => () => void;\n\tgetSnapshot: () => HostContext[K];\n};\n\n/**\n * Unified widget client interface that works on both OpenAI and MCP Apps.\n *\n * Platform-specific behavior:\n * - Display mode: OpenAI-only. MCP Apps returns \"inline\" and requestDisplayMode is a no-op.\n * - Follow-up messages: Unified API, different underlying implementations.\n */\nexport interface UnifiedWidgetClient {\n\t/**\n\t * Connect to the host. Must be called before using other methods.\n\t * On OpenAI, this is a no-op (already connected via window.openai).\n\t * On MCP Apps, this establishes the postMessage connection.\n\t */\n\tconnect(): Promise<void>;\n\n\t/**\n\t * Close the connection to the host and clean up resources.\n\t * On OpenAI, this is a no-op.\n\t * On MCP Apps, this closes the transport and removes event listeners.\n\t */\n\tclose(): Promise<void>;\n\n\t/**\n\t * Get the tool output (structured content returned by the tool handler).\n\t * This is the main data source for widget rendering.\n\t */\n\tgetToolOutput<T = Record<string, unknown>>(): T | null;\n\n\t/**\n\t * Register a callback for when tool results are received.\n\t * On OpenAI, this subscribes to toolOutput changes.\n\t * On MCP Apps, this sets app.ontoolresult.\n\t */\n\tonToolResult(callback: (result: ToolResult) => void): () => void;\n\n\t/**\n\t * Call another tool on the server.\n\t */\n\tcallTool(\n\t\tname: string,\n\t\targs: Record<string, unknown>,\n\t): Promise<ToolCallResult>;\n\n\t/**\n\t * Open an external URL.\n\t * On OpenAI: openai.openExternal({ href })\n\t * On MCP Apps: app.sendOpenLink(url)\n\t */\n\topenExternal(url: string): void;\n\n\t/**\n\t * Send a follow-up message to the AI.\n\t * On OpenAI: openai.sendFollowUpMessage({ prompt })\n\t * On MCP Apps: app.sendMessages([{ role: 'user', content: { type: 'text', text: prompt } }])\n\t */\n\tsendFollowUp(prompt: string): void | Promise<void>;\n\n\t/**\n\t * Update hidden model context for the next assistant turn.\n\t * On MCP Apps this uses the standard `ui/update-model-context` request.\n\t * On other hosts this may fall back to best-effort behavior.\n\t */\n\tupdateModelContext(context: ModelContextUpdate): Promise<void> | void;\n\n\t/**\n\t * Get the current theme.\n\t */\n\tgetTheme(): Theme;\n\n\t/**\n\t * Subscribe to theme changes.\n\t */\n\tonThemeChange(callback: (theme: Theme) => void): () => void;\n\n\t/**\n\t * Get the current locale.\n\t */\n\tgetLocale(): string;\n\n\t/**\n\t * Get the current display mode.\n\t * OpenAI-only: returns \"pip\" | \"inline\" | \"fullscreen\"\n\t * MCP Apps: always returns \"inline\"\n\t */\n\tgetDisplayMode(): DisplayMode;\n\n\t/**\n\t * Request a display mode change.\n\t * OpenAI-only: requests the mode from the host.\n\t * MCP Apps: no-op (returns current mode).\n\t */\n\trequestDisplayMode(mode: DisplayMode): Promise<DisplayMode>;\n\n\t/**\n\t * Subscribe to display mode changes.\n\t * OpenAI-only: subscribes to displayMode changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonDisplayModeChange(callback: (mode: DisplayMode) => void): () => void;\n\n\t/**\n\t * Get the safe area insets.\n\t * OpenAI-only: returns insets from window.openai.safeArea.\n\t * MCP Apps: returns null.\n\t */\n\tgetSafeArea(): SafeArea | null;\n\n\t/**\n\t * Subscribe to safe area changes.\n\t * OpenAI-only: subscribes to safeArea changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonSafeAreaChange(callback: (safeArea: SafeArea | null) => void): () => void;\n\n\t/**\n\t * Get the max height constraint.\n\t * OpenAI-only: returns maxHeight from window.openai.maxHeight.\n\t * MCP Apps: returns null.\n\t */\n\tgetMaxHeight(): number | null;\n\n\t/**\n\t * Subscribe to max height changes.\n\t * OpenAI-only: subscribes to maxHeight changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonMaxHeightChange(callback: (maxHeight: number | null) => void): () => void;\n\n\t/**\n\t * Get the tool response metadata.\n\t * OpenAI: returns metadata from window.openai.toolResponseMetadata.\n\t * MCP Apps: returns `_meta` from the latest `ui/notifications/tool-result`, if provided by host.\n\t */\n\tgetToolResponseMetadata(): UnknownObject | null;\n\n\t/**\n\t * Subscribe to tool response metadata changes.\n\t * OpenAI: subscribes to toolResponseMetadata changes.\n\t * MCP Apps: fires when tool result `_meta` changes.\n\t */\n\tonToolResponseMetadataChange(\n\t\tcallback: (metadata: UnknownObject | null) => void,\n\t): () => void;\n\n\t/**\n\t * Get the widget state.\n\t * OpenAI-only: returns state from window.openai.widgetState.\n\t * MCP Apps: returns null.\n\t */\n\tgetWidgetState(): UnknownObject | null;\n\n\t/**\n\t * Subscribe to widget state changes.\n\t * OpenAI-only: subscribes to widgetState changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonWidgetStateChange(\n\t\tcallback: (state: UnknownObject | null) => void,\n\t): () => void;\n}\n\n/**\n * Creates a unified widget client for the current platform.\n */\nexport async function createWidgetClient(): Promise<UnifiedWidgetClient> {\n\tconst { detectPlatform } = await import(\"./platform\");\n\tconst platform = detectPlatform();\n\n\tif (platform === \"openai\") {\n\t\tconst { OpenAIWidgetClient } = await import(\"./openai-client\");\n\t\treturn new OpenAIWidgetClient();\n\t} else {\n\t\tconst { MCPAppsWidgetClient } = await import(\"./mcp-apps-client\");\n\t\treturn new MCPAppsWidgetClient();\n\t}\n}\n","\"use client\";\n\nimport type { DisplayMode } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current display mode.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The current display mode (\"pip\" | \"inline\" | \"fullscreen\")\n */\nexport function useDisplayMode(): DisplayMode {\n\treturn useWidgetClient(\"displayMode\");\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the tool output (structured content returned by the tool handler).\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The tool output or null\n */\nexport function useToolOutput<T extends Record<string, unknown>>(): T | null {\n\treturn useWidgetClient(\"toolOutput\") as T | null;\n}\n","\"use client\";\n\nimport { useToolOutput } from \"./use-tool-output\";\n\n// ── Types ────────────────────────────────────────────────────\n\n/** Return type of the useFlowAction hook */\nexport type FlowActionResult<T> = {\n\t/** Current widget data from structuredContent. */\n\tdata: T | null;\n};\n\n// ── Hook ─────────────────────────────────────────────────────\n\n/**\n * Hook for reading flow widget data from structuredContent.\n * Lightweight wrapper over `useToolOutput` — will be extended\n * with flow-specific features in the future.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n *\n * @example\n * ```tsx\n * const { data } = useFlowAction<{ plans: string[] }>();\n * if (!data) return null;\n * return <PricingTable plans={data.plans} />;\n * ```\n */\nexport function useFlowAction<\n\tT extends Record<string, unknown>,\n>(): FlowActionResult<T> {\n\tconst data = useToolOutput<T>();\n\treturn { data };\n}\n","\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n/**\n * Check if running in ChatGPT app (OpenAI-only).\n * Returns false on MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns Whether the widget is running in ChatGPT app\n */\nexport function useIsChatGptApp(): boolean {\n\treturn useSyncExternalStore(\n\t\t() => () => {},\n\t\t() => {\n\t\t\tif (typeof window === \"undefined\") {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: __isChatGptApp is injected by ChatGPT\n\t\t\treturn (window as any).__isChatGptApp === true;\n\t\t},\n\t\t() => false,\n\t);\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current locale.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The current locale string (e.g., \"en-US\")\n */\nexport function useLocale(): string {\n\treturn useWidgetClient(\"locale\");\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the maximum height available for the widget (OpenAI-only).\n * Useful for responsive layouts that need to adapt to container constraints.\n * Returns null on MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The maximum height in pixels, or null if not available\n */\nexport function useMaxHeight(): number | null {\n\treturn useWidgetClient(\"maxHeight\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to open external URLs.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns A function that opens external URLs\n */\nexport function useOpenExternal(): (url: string) => void {\n\tconst client = useWidgetClient();\n\treturn useCallback((url: string) => client.openExternal(url), [client]);\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { DisplayMode } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to request display mode changes.\n * On MCP Apps, this may be a no-op depending on host support.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns A function to request a specific display mode\n */\nexport function useRequestDisplayMode(): (\n\tmode: DisplayMode,\n) => Promise<DisplayMode> {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(mode: DisplayMode) => client.requestDisplayMode(mode),\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport type { SafeArea } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get safe area insets (OpenAI-only).\n * Useful for ensuring UI elements don't get hidden behind the chat input.\n * Returns null on MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The safe area insets, or null if not available\n */\nexport function useSafeArea(): SafeArea | null {\n\treturn useWidgetClient(\"safeArea\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport {\n\thasModelContext,\n\ttype ModelContextUpdate,\n} from \"../../../../shared/model-context\";\nimport { useWidgetClient } from \"./use-widget\";\n\nexport interface SendFollowUpOptions {\n\tmodelContext?: ModelContextUpdate | null;\n}\n\n/**\n * Get a function to send follow-up messages to the AI.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns A function that sends a follow-up message\n */\nexport function useSendFollowUp(): (\n\tprompt: string,\n\toptions?: SendFollowUpOptions,\n) => void {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(prompt: string, options?: SendFollowUpOptions) => {\n\t\t\tvoid (async () => {\n\t\t\t\tif (hasModelContext(options?.modelContext)) {\n\t\t\t\t\tawait Promise.resolve(\n\t\t\t\t\t\tclient.updateModelContext(options.modelContext),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait Promise.resolve(client.sendFollowUp(prompt));\n\t\t\t})().catch((error) => {\n\t\t\t\tconsole.error(\"Failed to send follow-up message:\", error);\n\t\t\t});\n\t\t},\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport type { Theme } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current theme.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The current theme (\"light\" | \"dark\")\n */\nexport function useTheme(): Theme {\n\treturn useWidgetClient(\"theme\");\n}\n","\"use client\";\n\nimport type { UnknownObject } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get tool response metadata.\n * Contains host/tool metadata (for example identifiers like\n * `openai/widgetSessionId` and custom tool `_meta` fields).\n * Returns null when the host does not provide metadata.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @returns The tool response metadata object or null if not available\n */\nexport function useToolResponseMetadata(): UnknownObject | null {\n\treturn useWidgetClient(\"toolResponseMetadata\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { ModelContextUpdate } from \"../../../../shared/model-context\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to update hidden model context for the next assistant turn.\n * Uses the MCP Apps `ui/update-model-context` request when available.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n */\nexport function useUpdateModelContext(): (\n\tcontext: ModelContextUpdate,\n) => Promise<void> {\n\tconst client = useWidgetClient();\n\n\treturn useCallback(\n\t\tasync (context: ModelContextUpdate) => {\n\t\t\tawait Promise.resolve(client.updateModelContext(context));\n\t\t},\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport { type SetStateAction, useCallback, useEffect, useState } from \"react\";\nimport { detectPlatform } from \"../widgets/platform\";\nimport type { UnknownObject } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Widget state that persists across widget lifecycles (OpenAI-only).\n * State is synchronized with the ChatGPT parent window and survives widget minimize/restore.\n * On MCP Apps, returns [null, no-op].\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n * @param defaultState - Initial state value or function to compute it\n * @returns A tuple of [state, setState] similar to useState\n */\nexport function useWidgetState<T extends UnknownObject>(\n\tdefaultState?: T | (() => T | null) | null,\n): readonly [T | null, (state: SetStateAction<T | null>) => void] {\n\tconst widgetStateFromWindow = useWidgetClient(\"widgetState\") as T | null;\n\n\tconst [widgetState, _setWidgetState] = useState<T | null>(() => {\n\t\tif (widgetStateFromWindow != null) {\n\t\t\treturn widgetStateFromWindow;\n\t\t}\n\t\treturn typeof defaultState === \"function\"\n\t\t\t? defaultState()\n\t\t\t: (defaultState ?? null);\n\t});\n\n\tuseEffect(() => {\n\t\t_setWidgetState(widgetStateFromWindow);\n\t}, [widgetStateFromWindow]);\n\n\tconst setWidgetState = useCallback((state: SetStateAction<T | null>) => {\n\t\t_setWidgetState((prevState) => {\n\t\t\tconst newState = typeof state === \"function\" ? state(prevState) : state;\n\n\t\t\tif (detectPlatform() === \"openai\" && newState != null) {\n\t\t\t\twindow.openai?.setWidgetState(newState);\n\t\t\t}\n\n\t\t\treturn newState;\n\t\t});\n\t}, []);\n\n\treturn [widgetState, setWidgetState] as const;\n}\n","/**\n * Default loading fallback for legacy MCP widgets.\n *\n * @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to\n * `@waniwani/sdk/legacy/react` in a future minor release.\n */\nexport const LoadingWidget = () => {\n\treturn (\n\t\t<div className=\"flex flex-col items-center justify-center h-full min-h-[120px] gap-4\">\n\t\t\t{/* Animated dots */}\n\t\t\t<div className=\"flex gap-2\">\n\t\t\t\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]\" />\n\t\t\t\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]\" />\n\t\t\t\t<div className=\"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce\" />\n\t\t\t</div>\n\n\t\t\t{/* Shimmer text */}\n\t\t\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]\">\n\t\t\t\tLoading widget...\n\t\t\t</p>\n\n\t\t\t{/* Pulsing ring */}\n\t\t\t<div className=\"absolute inset-0 flex items-center justify-center pointer-events-none\">\n\t\t\t\t<div className=\"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping\" />\n\t\t\t</div>\n\n\t\t\t<style>{`\n @keyframes shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n }\n `}</style>\n\t\t</div>\n\t);\n};\n"],"mappings":";+GAoNE,mBAAAA,GACC,OAAAC,EADD,QAAAC,OAAA,oBA3MK,SAASC,IAA2B,CAC1C,IAAMC,EAAU,OAAO,aACjBC,EACJ,OACC,wBAA0B,CAAC,EACxBC,EAAc,SAAS,gBACZ,IAAI,iBAAkBC,GAAc,CACpDA,EAAU,QAASC,GAAa,CAC/B,GAAIA,EAAS,OAAS,cAAgBA,EAAS,SAAWF,EAAa,CACtE,IAAMG,EAAWD,EAAS,cAGzBC,GACAA,IAAa,4BACbA,IAAa,QACbA,IAAa,SACbA,IAAa,SAEbH,EAAY,gBAAgBG,CAAQ,C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E,UAAU,iLAAiL,6BAE9L,EAGAA,EAAC,OAAI,UAAU,wEACd,SAAAA,EAAC,OAAI,UAAU,kEAAkE,EAClF,EAEAA,EAAC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,QAKH,GACN","names":["Fragment","jsx","jsxs","applyIframePatches","baseUrl","passthroughOrigins","htmlElement","mutations","mutation","attrName","originalReplaceState","_s","unused","url","u","originalPushState","appOrigin","isInIframe","e","a","originalFetch","input","init","isRelativeString","newUrl","wsAppOrigin","OriginalWebSocket","PatchedWebSocket","protocols","parsed","rewritten","PATCH_SCRIPT","InitializeNextJsInIframe","useCallback","useEffect","useRef","useState","DEFAULT_MOCK_CONFIG","mockState","initializeMockOpenAI","initialToolOutput","mode","updateMockGlobal","name","args","prompt","href","state","SetGlobalsEvent","key","value","getMockState","updateMockToolOutput","props","updateMockDisplayMode","updateMockTheme","theme","Fragment","jsx","jsxs","MOCK_SAFE_AREA_HEIGHT","DevIcon","className","CloseIcon","InlineIcon","PipIcon","FullscreenIcon","SunIcon","MoonIcon","ResetIcon","panelAnimationStyles","DevModeProvider","defaultProps","widgetPaths","children","isInitialized","setIsInitialized","useState","isWidgetPage","setIsWidgetPage","useEffect","currentPath","isWidget","path","initializeMockOpenAI","WidgetPreviewFrame","DevControls","SegmentedControl","options","value","onChange","activeIndex","opt","option","isOpen","setIsOpen","isAnimating","setIsAnimating","shouldRender","setShouldRender","displayMode","setDisplayMode","theme","setTheme","showSafeArea","setShowSafeArea","propsJson","setPropsJson","jsonError","setJsonError","debounceRef","useRef","panelRef","containerRef","state","getMockState","SetGlobalsEvent","openPanel","useCallback","closePanel","togglePanel","handleKeyDown","e","handleClickOutside","handleDisplayModeChange","mode","updateMockDisplayMode","handleThemeChange","newTheme","updateMockTheme","applyProps","json","parsed","updateMockToolOutput","handlePropsChange","handlePropsBlur","handleReset","defaultJson","displayModeOptions","themeOptions","useCallback","React","useCallback","useContext","useEffect","useState","useSyncExternalStore","createContext","WidgetClientContext","createWidgetClient","detectPlatform","OpenAIWidgetClient","MCPAppsWidgetClient","WidgetProvider","children","loading","onError","client","setClient","useState","error","setError","isConnecting","setIsConnecting","useEffect","mounted","activeClient","initClient","widgetClient","createWidgetClient","err","syncTheme","theme","React","WidgetClientContext","useWidgetClient","key","useContext","subscribe","useCallback","onChange","getSnapshot","store","useSyncExternalStore","useCallTool","client","useWidgetClient","useCallback","name","args","useDisplayMode","useWidgetClient","useToolOutput","useWidgetClient","useFlowAction","useToolOutput","useSyncExternalStore","useIsChatGptApp","useLocale","useWidgetClient","useMaxHeight","useWidgetClient","useCallback","useOpenExternal","client","useWidgetClient","useCallback","url","useCallback","useRequestDisplayMode","client","useWidgetClient","useCallback","mode","useSafeArea","useWidgetClient","useCallback","useSendFollowUp","client","useWidgetClient","useCallback","prompt","options","hasModelContext","error","useTheme","useWidgetClient","useToolResponseMetadata","useWidgetClient","useCallback","useUpdateModelContext","client","useWidgetClient","useCallback","context","useCallback","useEffect","useState","useWidgetState","defaultState","widgetStateFromWindow","useWidgetClient","widgetState","_setWidgetState","useState","useEffect","setWidgetState","useCallback","state","prevState","newState","detectPlatform","jsx","jsxs","LoadingWidget"]}
|