@weppy/roblox-mcp 2.17.19 → 2.17.21

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dashboard/dist/assets/{AiPromptExamples-DXXVTOxG.js → AiPromptExamples-v7F0ZqtA.js} +1 -1
  3. package/dashboard/dist/assets/{AssetsPage-BoAbY8Q0.js → AssetsPage-BiFlajKz.js} +1 -1
  4. package/dashboard/dist/assets/{ChangelogPage-CSI3TeN9.js → ChangelogPage-CZ4M3zvA.js} +1 -1
  5. package/dashboard/dist/assets/{ConfirmModal-CuAwM71W.js → ConfirmModal-EJt_S9vY.js} +1 -1
  6. package/dashboard/dist/assets/{ConnectionPage-BvLuu2YZ.js → ConnectionPage-n7saIQzt.js} +1 -1
  7. package/dashboard/dist/assets/{ContentScopedDialog-zNvUtPLn.js → ContentScopedDialog-BcNAWEg1.js} +1 -1
  8. package/dashboard/dist/assets/{ControlsPage-Cs0i8umY.js → ControlsPage-BtjiFRSB.js} +1 -1
  9. package/dashboard/dist/assets/{DialogHeader-Fw_6GdLF.js → DialogHeader-BMv5alOx.js} +1 -1
  10. package/dashboard/dist/assets/{GameChangeDetail-CbawnSBl.js → GameChangeDetail-BNoyNyoe.js} +1 -1
  11. package/dashboard/dist/assets/{InfoLabel-CTdrBoDi.js → InfoLabel-xpwjU19F.js} +1 -1
  12. package/dashboard/dist/assets/{OverviewPage-Cff7bDt-.js → OverviewPage-gmgRY2nN.js} +1 -1
  13. package/dashboard/dist/assets/{PageHeader-DSDD3OAG.js → PageHeader-C7zSPJ0K.js} +1 -1
  14. package/dashboard/dist/assets/{PlaceSelectOptions-DI0uxHVw.js → PlaceSelectOptions-e39l4_SC.js} +1 -1
  15. package/dashboard/dist/assets/{PlaytestAiPromptExamples-DHdi8UDH.js → PlaytestAiPromptExamples-DNcOx55_.js} +1 -1
  16. package/dashboard/dist/assets/{PlaytestPage-BWCweSgO.js → PlaytestPage-C1cvi3ce.js} +17 -22
  17. package/dashboard/dist/assets/SettingsPage-BMmYemqI.js +23 -0
  18. package/dashboard/dist/assets/{SyncPage-B_UiR6Gv.js → SyncPage-C1xj3Vtj.js} +1 -1
  19. package/dashboard/dist/assets/{Tabs-Bo5GNqZZ.js → Tabs-CJSfllHd.js} +1 -1
  20. package/dashboard/dist/assets/{TierPromoPanel-XqwiWCl0.js → TierPromoPanel-Cj3f7idb.js} +1 -1
  21. package/dashboard/dist/assets/{ToolsPage-CxFhnaRc.js → ToolsPage-DxgcVWzx.js} +1 -1
  22. package/dashboard/dist/assets/{TooltipText-CUT7j-Zf.js → TooltipText-CKbtCUcM.js} +1 -1
  23. package/dashboard/dist/assets/{UiStudioPage-CZzeyb88.js → UiStudioPage-Ch9n11Rs.js} +1 -1
  24. package/dashboard/dist/assets/WhatsNewPage-C4uGwv-a.css +1 -0
  25. package/dashboard/dist/assets/WhatsNewPage-D91VijNf.js +1 -0
  26. package/dashboard/dist/assets/{bot-DK0pVEDR.js → bot-DBgSRd9L.js} +1 -1
  27. package/dashboard/dist/assets/{check-YRZbUfe_.js → check-BGgW005M.js} +1 -1
  28. package/dashboard/dist/assets/{copy-D0YbyaTR.js → copy-B53fec-q.js} +1 -1
  29. package/dashboard/dist/assets/index-B-46k2zD.js +868 -0
  30. package/dashboard/dist/assets/{index-VXvX8jPK.css → index-CrljkNgf.css} +1 -1
  31. package/dashboard/dist/assets/{rotate-ccw-BYZocyYl.js → rotate-ccw-C68bQzOX.js} +1 -1
  32. package/dashboard/dist/assets/{sample-requests-CMFXz8Sb.js → sample-requests-Cb8_d2yO.js} +1 -1
  33. package/dashboard/dist/assets/{trash-2-D_U7ZRs9.js → trash-2-DMaFDTK8.js} +1 -1
  34. package/dashboard/dist/assets/{useLiveUptime-BKKC36H5.js → useLiveUptime-Dd5RwIEz.js} +1 -1
  35. package/dashboard/dist/assets/useSettings-DpFpA827.js +2 -0
  36. package/dashboard/dist/index.html +2 -2
  37. package/dist/index.js +151 -151
  38. package/package.json +1 -1
  39. package/roblox-plugin/WeppyRobloxMCP.rbxm +0 -0
  40. package/dashboard/dist/assets/SettingsPage-BkTRExil.js +0 -23
  41. package/dashboard/dist/assets/WhatsNewPage-BbrAlXRG.js +0 -1
  42. package/dashboard/dist/assets/WhatsNewPage-WMbbAUsL.css +0 -1
  43. package/dashboard/dist/assets/index-CLRRkgqc.js +0 -746
  44. package/dashboard/dist/assets/useSettings-CWO5gtUr.js +0 -2
@@ -1,64 +1,59 @@
1
- import{c as Te,r as o,d as De,u as ue,j as t,D as Ut,y as Kt,X as zt,h as Wt,l as Jt,e as Yt,x as Qt,b as Xt,f as Zt,a as ea,k as ta,T as aa}from"./index-CLRRkgqc.js";import{T as sa}from"./TierPromoPanel-XqwiWCl0.js";import{P as na,a as ia}from"./PageHeader-DSDD3OAG.js";import{I as la}from"./InfoLabel-CTdrBoDi.js";import{T as ra,C as oa}from"./Tabs-Bo5GNqZZ.js";import{T as it}from"./TooltipText-CUT7j-Zf.js";import{C as ft}from"./ConfirmModal-CuAwM71W.js";import{C as Ke}from"./ContentScopedDialog-zNvUtPLn.js";import{D as ze}from"./DialogHeader-Fw_6GdLF.js";import{P as xt}from"./PlaytestAiPromptExamples-DHdi8UDH.js";import{B as ca}from"./bot-DK0pVEDR.js";import{R as da}from"./rotate-ccw-BYZocyYl.js";import{T as jt}from"./trash-2-D_U7ZRs9.js";import{C as ua}from"./check-YRZbUfe_.js";import"./PlaceSelectOptions-DI0uxHVw.js";import"./ConfirmModal.module-DJksQHBd.js";import"./AiPromptExamples-DXXVTOxG.js";import"./copy-D0YbyaTR.js";/**
1
+ import{c as Te,r as o,d as De,u as ue,j as t,D as Ut,y as Kt,z as zt,X as Wt,h as Jt,l as Yt,e as Qt,x as Xt,b as Zt,f as ea,a as ta,k as aa,T as sa}from"./index-B-46k2zD.js";import{T as na}from"./TierPromoPanel-Cj3f7idb.js";import{P as ia,a as la}from"./PageHeader-C7zSPJ0K.js";import{I as ra}from"./InfoLabel-xpwjU19F.js";import{T as oa,C as ca}from"./Tabs-CJSfllHd.js";import{T as it}from"./TooltipText-CKbtCUcM.js";import{C as ft}from"./ConfirmModal-EJt_S9vY.js";import{C as Ke}from"./ContentScopedDialog-BcNAWEg1.js";import{D as ze}from"./DialogHeader-BMv5alOx.js";import{P as xt}from"./PlaytestAiPromptExamples-DNcOx55_.js";import{B as da}from"./bot-DBgSRd9L.js";import{R as ua}from"./rotate-ccw-C68bQzOX.js";import{T as jt}from"./trash-2-DMaFDTK8.js";import{C as pa}from"./check-BGgW005M.js";import"./PlaceSelectOptions-e39l4_SC.js";import"./ConfirmModal.module-DJksQHBd.js";import"./AiPromptExamples-v7F0ZqtA.js";import"./copy-B53fec-q.js";/**
2
2
  * @license lucide-react v1.8.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const pa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],fa=Te("arrow-down",pa);/**
6
+ */const fa=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ma=Te("arrow-down",fa);/**
7
7
  * @license lucide-react v1.8.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const ma=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ha=Te("arrow-up",ma);/**
11
+ */const ha=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ya=Te("arrow-up",ha);/**
12
12
  * @license lucide-react v1.8.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ya=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],mt=Te("chevron-down",ya);/**
16
+ */const va=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],mt=Te("chevron-down",va);/**
17
17
  * @license lucide-react v1.8.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const va=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],St=Te("chevron-up",va);/**
21
+ */const ga=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],St=Te("chevron-up",ga);/**
22
22
  * @license lucide-react v1.8.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const ga=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ba=Te("circle-dot",ga);/**
26
+ */const ba=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],_a=Te("circle-dot",ba);/**
27
27
  * @license lucide-react v1.8.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const _a=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],wt=Te("grip-vertical",_a);/**
31
+ */const xa=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],wt=Te("grip-vertical",xa);/**
32
32
  * @license lucide-react v1.8.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const xa=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],ja=Te("list-plus",xa);/**
36
+ */const ja=[["path",{d:"M16 5H3",key:"m91uny"}],["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 19H3",key:"zzsher"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]],Sa=Te("list-plus",ja);/**
37
37
  * @license lucide-react v1.8.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const Sa=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],wa=Te("lock-keyhole",Sa);/**
41
+ */const wa=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],Na=Te("lock-keyhole",wa);/**
42
42
  * @license lucide-react v1.8.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const Na=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Ca=Te("mouse-pointer-click",Na);/**
46
+ */const Ca=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Ra=Te("mouse-pointer-click",Ca);/**
47
47
  * @license lucide-react v1.8.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const Ra=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Pa=Te("pencil",Ra);/**
51
+ */const Pa=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ka=Te("pencil",Pa);/**
52
52
  * @license lucide-react v1.8.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const ka=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],$t=Te("plus",ka);/**
57
- * @license lucide-react v1.8.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const Aa=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ea=Te("triangle-alert",Aa),Da=5e3;function Nt(e){return typeof e=="number"?{placeId:String(e)}:void 0}function Ia(e,a){return typeof a=="number"?`${e}?placeId=${encodeURIComponent(String(a))}`:e}function Ta(e){const a=e.context;return{...e,...typeof(a==null?void 0:a.contextId)=="string"?{contextId:a.contextId}:{},...a!=null&&a.contextSummary&&typeof a.contextSummary=="object"?{contextSummary:a.contextSummary}:{},...a!=null&&a.replayMetadata&&typeof a.replayMetadata=="object"?{replayMetadata:a.replayMetadata}:{}}}function Ct(e){return e instanceof Error?e.message:String(e)}function La(e){const a=(e==null?void 0:e.enabled)??!0,n=(e==null?void 0:e.placeId)??null,[i,d]=o.useState([]),[c,u]=o.useState(a?"loading":"idle"),[y,m]=o.useState(null),[_,C]=o.useState(null),[k,x]=o.useState(a),[f,V]=o.useState(!1),[R,M]=o.useState(null),w=o.useRef(null),B=o.useRef(0),P=o.useRef(null),E=o.useCallback(async()=>{try{const z=Nt(n),U=z?await De.get("/api/dashboard/playtest/history",z):await De.get("/api/dashboard/playtest/history");d(U.entries??[]),u("ready"),m(null)}catch(z){u("error"),m(Ct(z))}},[n]),W=o.useCallback(async()=>{if(!a){x(!1);return}await E(),x(!1)},[a,E]),$=o.useCallback(()=>{B.current+=1,P.current=null,C(null),V(!1),M(null)},[]);o.useEffect(()=>{$()},[$,a,n]);const ee=o.useCallback(async z=>{if(!a)return;P.current=z;const U=++B.current;C(null),V(!0),M(null);try{const L=Nt(n),ae=`/api/dashboard/playtest/detail/${encodeURIComponent(z)}`,J=L?await De.get(ae,L):await De.get(ae);U===B.current&&C(Ta(J))}catch(L){U===B.current&&M(Ct(L))}finally{U===B.current&&V(!1)}},[a,n]),te=o.useCallback(async()=>{const z=P.current;z&&await ee(z)},[ee]),q=o.useCallback(async()=>{a&&(u("loading"),m(null),await E())},[a,E]),O=o.useCallback(async()=>{a&&(await De.post(Ia("/api/dashboard/playtest/history/clear",n)),d([]),u("ready"),m(null),$())},[$,a,n]);return o.useEffect(()=>{if(!a){x(!1),u("idle"),m(null);return}return u("loading"),m(null),W(),w.current=setInterval(W,Da),()=>{w.current&&clearInterval(w.current)}},[a,W]),{history:i,historyLoadState:c,historyError:y,selectedReport:_,loading:k,detailLoading:f,detailError:R,loadReport:ee,retryReport:te,retryHistory:q,clearSelectedReport:$,clearHistory:O}}function Ma(e){const a="2026-03-27T15:26:00.000Z",n={testScenario:e("playtest.sample.context.why","Spawn into the arena, survive the opener, and verify the HUD responds immediately."),expectedBehavior:e("playtest.sample.context.expected","The player spawns safely, the countdown UI appears within one second, and the first wave starts without errors."),observedBehavior:e("playtest.sample.context.observed","Spawn protection held, the HUD updated on time, and wave one completed with no gameplay regressions.")};return{history:[{recordId:"sample_playtest_preview",directoryName:"sample-playtest-preview",recordKind:"structured",timestamp:a,testName:e("playtest.sample.history.name","Sample Arena Smoke Test"),mode:"play",executionKind:"structured_session",overallStatus:"passed",status:"passed",durationMs:4820,contextId:"sample_playtest_preview",contextSummary:n,evidenceSummary:{server:{required:!0,status:"passed",stepIds:["wave-started"]},clientUi:{required:!0,status:"passed",stepIds:["hud-visible"]},interaction:{required:!0,status:"passed",provider:"virtual_input",stepIds:["start-click"]},visual:{required:!1,status:"not_requested",reason:"not_requested",stepIds:[]}},agentCounts:{server:1,client:1},limitation:{code:"play_screenshot_unsupported",message:e("playtest.sample.limit.visual","Play screenshot evidence is unavailable in structured session v1")}}],report:{recordId:"sample_playtest_preview",directoryName:"sample-playtest-preview",recordKind:"structured",markdown:e("playtest.sample.report.markdown",`# Sample Arena Smoke Test
56
+ */const Aa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],$t=Te("plus",Aa),Ea=5e3;function Nt(e){return typeof e=="number"?{placeId:String(e)}:void 0}function Da(e,a){return typeof a=="number"?`${e}?placeId=${encodeURIComponent(String(a))}`:e}function Ia(e){const a=e.context;return{...e,...typeof(a==null?void 0:a.contextId)=="string"?{contextId:a.contextId}:{},...a!=null&&a.contextSummary&&typeof a.contextSummary=="object"?{contextSummary:a.contextSummary}:{},...a!=null&&a.replayMetadata&&typeof a.replayMetadata=="object"?{replayMetadata:a.replayMetadata}:{}}}function Ct(e){return e instanceof Error?e.message:String(e)}function Ta(e){const a=(e==null?void 0:e.enabled)??!0,n=(e==null?void 0:e.placeId)??null,[i,d]=o.useState([]),[c,u]=o.useState(a?"loading":"idle"),[y,m]=o.useState(null),[_,C]=o.useState(null),[k,x]=o.useState(a),[f,V]=o.useState(!1),[R,M]=o.useState(null),w=o.useRef(null),B=o.useRef(0),P=o.useRef(null),E=o.useCallback(async()=>{try{const z=Nt(n),U=z?await De.get("/api/dashboard/playtest/history",z):await De.get("/api/dashboard/playtest/history");d(U.entries??[]),u("ready"),m(null)}catch(z){u("error"),m(Ct(z))}},[n]),W=o.useCallback(async()=>{if(!a){x(!1);return}await E(),x(!1)},[a,E]),$=o.useCallback(()=>{B.current+=1,P.current=null,C(null),V(!1),M(null)},[]);o.useEffect(()=>{$()},[$,a,n]);const ee=o.useCallback(async z=>{if(!a)return;P.current=z;const U=++B.current;C(null),V(!0),M(null);try{const L=Nt(n),ae=`/api/dashboard/playtest/detail/${encodeURIComponent(z)}`,J=L?await De.get(ae,L):await De.get(ae);U===B.current&&C(Ia(J))}catch(L){U===B.current&&M(Ct(L))}finally{U===B.current&&V(!1)}},[a,n]),te=o.useCallback(async()=>{const z=P.current;z&&await ee(z)},[ee]),H=o.useCallback(async()=>{a&&(u("loading"),m(null),await E())},[a,E]),O=o.useCallback(async()=>{a&&(await De.post(Da("/api/dashboard/playtest/history/clear",n)),d([]),u("ready"),m(null),$())},[$,a,n]);return o.useEffect(()=>{if(!a){x(!1),u("idle"),m(null);return}return u("loading"),m(null),W(),w.current=setInterval(W,Ea),()=>{w.current&&clearInterval(w.current)}},[a,W]),{history:i,historyLoadState:c,historyError:y,selectedReport:_,loading:k,detailLoading:f,detailError:R,loadReport:ee,retryReport:te,retryHistory:H,clearSelectedReport:$,clearHistory:O}}function La(e){const a="2026-03-27T15:26:00.000Z",n={testScenario:e("playtest.sample.context.why","Spawn into the arena, survive the opener, and verify the HUD responds immediately."),expectedBehavior:e("playtest.sample.context.expected","The player spawns safely, the countdown UI appears within one second, and the first wave starts without errors."),observedBehavior:e("playtest.sample.context.observed","Spawn protection held, the HUD updated on time, and wave one completed with no gameplay regressions.")};return{history:[{recordId:"sample_playtest_preview",directoryName:"sample-playtest-preview",recordKind:"structured",timestamp:a,testName:e("playtest.sample.history.name","Sample Arena Smoke Test"),mode:"play",executionKind:"structured_session",overallStatus:"passed",status:"passed",durationMs:4820,contextId:"sample_playtest_preview",contextSummary:n,evidenceSummary:{server:{required:!0,status:"passed",stepIds:["wave-started"]},clientUi:{required:!0,status:"passed",stepIds:["hud-visible"]},interaction:{required:!0,status:"passed",provider:"virtual_input",stepIds:["start-click"]},visual:{required:!1,status:"not_requested",reason:"not_requested",stepIds:[]}},agentCounts:{server:1,client:1},limitation:{code:"play_screenshot_unsupported",message:e("playtest.sample.limit.visual","Play screenshot evidence is unavailable in structured session v1")}}],report:{recordId:"sample_playtest_preview",directoryName:"sample-playtest-preview",recordKind:"structured",markdown:e("playtest.sample.report.markdown",`# Sample Arena Smoke Test
62
57
 
63
58
  - Spawn flow: PASS
64
59
  - HUD countdown: PASS
@@ -68,7 +63,7 @@ This is a sample preview. Live playtests and real reports are available with Pro
68
63
  [sample] spawn protection active
69
64
  [sample] hud countdown rendered
70
65
  [sample] wave one completed
71
- [sample] preview report finished`),contextId:"sample_playtest_preview",contextSummary:n,artifactErrors:[],result:{schemaVersion:1,sessionId:"sample-session",recordId:"sample_playtest_preview",testName:e("playtest.sample.history.name","Sample Arena Smoke Test"),executionKind:"structured_session",overallStatus:"passed",overallPassed:!0,terminalReason:{code:"all_required_evidence_passed",message:e("playtest.sample.terminal","All required evidence passed")},mode:"play",place:{placeName:e("playtest.sample.place","Sample Arena")},startedAt:a,endedAt:"2026-03-27T15:26:04.820Z",durationMs:4820,agents:[{agentId:"sample-server-agent",role:"server"},{agentId:"sample-client-agent",role:"client",clientId:"client-1"}],capabilities:{semanticUiSnapshot:!0,virtualInput:!0,fixedBootstrap:!0,projectTestAdapter:!1},requiredEvidence:{server:!0,clientUi:!0,interaction:!0,visual:!1},dimensions:{server:{required:!0,status:"passed",stepIds:["wave-started"]},clientUi:{required:!0,status:"passed",stepIds:["hud-visible"]},interaction:{required:!0,status:"passed",provider:"virtual_input",stepIds:["start-click"]},visual:{required:!1,status:"not_requested",reason:"not_requested",stepIds:[]}},limitations:[{code:"play_screenshot_unsupported",message:e("playtest.sample.limit.visual","Play screenshot evidence is unavailable in structured session v1")}],steps:[{index:0,stepId:"start-click",target:{role:"client",clientId:"client-1"},action:"input_click",dimension:"interaction",required:!0,status:"passed",startedAt:a,endedAt:"2026-03-27T15:26:00.120Z",durationMs:120,expected:{activated:!0},observed:{activated:!0},evidence:{delivery:"VirtualInput",observation:"GuiButton.Activated"}}],cleanup:{status:"passed",errors:[]},artifacts:{status:"complete",files:["test-result.json","test-report.md","test-log.txt","test-context.json"]}}}}}function Ve(e,a){switch(a){case"passed":return e("playtest.result.status.passed","Passed");case"failed":return e("playtest.result.status.failed","Failed");case"timed_out":return e("playtest.result.status.timedOut","Timed out");case"cancelled":return e("playtest.result.status.cancelled","Cancelled");case"insufficient_evidence":return e("playtest.result.status.insufficientEvidence","Insufficient evidence");case"unavailable":return e("playtest.result.status.unavailable","Unavailable");case"skipped":return e("playtest.result.status.skipped","Skipped");case"not_requested":return e("playtest.result.status.notRequested","Not requested");default:return e("playtest.result.status.unknown","Unknown")}}function vt(e){return e==="passed"?"✓":e==="failed"||e==="timed_out"?"×":e==="cancelled"||e==="insufficient_evidence"||e==="unavailable"?"!":"–"}function Vt(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function at(e){return JSON.stringify(e,null,2)}function Ot(e,a,n){return a==="play_screenshot_unsupported"?e("playtest.limitations.visualUnsupported","Visual evidence unavailable — Play screenshots are not supported in structured session v1."):a==="virtual_input_unavailable"?e("playtest.limitations.virtualInputUnavailable","Virtual input is unavailable for this session."):n}function $a(e,a){return a==="play_screenshot_unsupported"?e("playtest.limitations.visualUnsupportedReason","Play screenshots are not supported in structured session v1."):a==="not_requested"?e("playtest.result.status.notRequested","Not requested"):a==="required_evidence_missing"?e("playtest.dimension.reason.missing","Required evidence is missing."):a==="required_capability_unavailable"?e("playtest.dimension.reason.capability","The required capability is unavailable."):a}const Va="_page_14ipf_2",Oa="_sampleBanner_14ipf_10",Ba="_sampleBannerRow_14ipf_22",Fa="_sampleBannerMain_14ipf_29",Ga="_sampleBadge_14ipf_36",qa="_sampleTitle_14ipf_51",Ha="_sampleMessage_14ipf_58",Ua="_sampleActions_14ipf_65",Ka="_primaryAction_14ipf_73",za="_secondaryAction_14ipf_74",Wa="_resetAction_14ipf_75",Ja="_card_14ipf_124",Ya="_cardHeader_14ipf_131",Qa="_clearButton_14ipf_144",Xa="_statusRow_14ipf_173",Za="_statusIndicator_14ipf_180",es="_statusRunning_14ipf_188",ts="_statusPaused_14ipf_193",as="_statusNotRunning_14ipf_197",ss="_statusLabel_14ipf_201",ns="_statusMeta_14ipf_208",is="_controlButtons_14ipf_214",ls="_btn_14ipf_221",rs="_btnPrimary_14ipf_243",os="_btnDanger_14ipf_253",cs="_historyList_14ipf_265",ds="_historyItem_14ipf_271",us="_stepDisclosure_14ipf_291",ps="_historyItemSelected_14ipf_296",fs="_historyItemHeader_14ipf_301",ms="_historyIcon_14ipf_307",hs="_historyTimestamp_14ipf_312",ys="_historyName_14ipf_319",vs="_recordKind_14ipf_330",gs="_historyItemMeta_14ipf_344",bs="_historyMode_14ipf_354",_s="_historyDuration_14ipf_358",xs="_historyStatus_14ipf_362",js="_status_passed_14ipf_369",Ss="_status_failed_14ipf_373",ws="_status_running_14ipf_377",Ns="_status_timed_out_14ipf_381",Cs="_status_cancelled_14ipf_385",Rs="_status_insufficient_evidence_14ipf_386",Ps="_historyError_14ipf_390",ks="_historyEvidence_14ipf_400",As="_historyLimitation_14ipf_410",Es="_detailShell_14ipf_421",Ds="_detailHeader_14ipf_429",Is="_detailHeading_14ipf_440",Ts="_detailRecordName_14ipf_451",Ls="_detailCloseButton_14ipf_460",Ms="_detailRetryButton_14ipf_480",$s="_detailBody_14ipf_485",Vs="_detailState_14ipf_494",Os="_detailErrorTitle_14ipf_505",Bs="_detailErrorMessage_14ipf_512",Fs="_reportContainer_14ipf_534",Gs="_runSummary_14ipf_540",qs="_viewerSection_14ipf_541",Hs="_summaryLead_14ipf_554",Us="_summaryStatusMark_14ipf_560",Ks="_viewerHeading_14ipf_573",zs="_summaryName_14ipf_583",Ws="_summaryReason_14ipf_594",Js="_summaryFacts_14ipf_601",Ys="_subsectionLabel_14ipf_614",Qs="_sectionHeadingRow_14ipf_629",Xs="_sectionHint_14ipf_637",Zs="_dimensionGrid_14ipf_642",en="_dimensionCard_14ipf_649",tn="_dimensionHeader_14ipf_657",an="_statusMark_14ipf_663",sn="_dimensionName_14ipf_676",nn="_requirementBadge_14ipf_686",ln="_dimensionStatus_14ipf_694",rn="_dimensionMeta_14ipf_701",on="_tone_passed_14ipf_709",cn="_tone_failed_14ipf_710",dn="_tone_timed_out_14ipf_711",un="_tone_cancelled_14ipf_712",pn="_tone_insufficient_evidence_14ipf_713",fn="_tone_unavailable_14ipf_714",mn="_tone_skipped_14ipf_715",hn="_tone_not_requested_14ipf_716",yn="_stepList_14ipf_718",vn="_stepItem_14ipf_725",gn="_stepIndex_14ipf_749",bn="_stepIdentity_14ipf_756",_n="_stepName_14ipf_763",xn="_stepMeta_14ipf_773",jn="_stepStatus_14ipf_774",Sn="_chevron_14ipf_782",wn="_chevronOpen_14ipf_788",Nn="_stepDetails_14ipf_790",Cn="_evidenceBlock_14ipf_799",Rn="_evidenceLabel_14ipf_803",Pn="_stepError_14ipf_830",kn="_recordProblem_14ipf_831",An="_capabilityGrid_14ipf_846",En="_capabilityItem_14ipf_853",Dn="_capabilityYes_14ipf_866",In="_capabilityNo_14ipf_867",Tn="_capabilityState_14ipf_868",Ln="_limitations_14ipf_870",Mn="_artifactList_14ipf_871",$n="_agentList_14ipf_872",Vn="_artifactDisclosures_14ipf_889",On="_artifactDisclosure_14ipf_889",Bn="_artifactButton_14ipf_903",Fn="_artifactContent_14ipf_928",Gn="_limitationItem_14ipf_948",qn="_reportContextPanel_14ipf_965",Hn="_reportContextRow_14ipf_975",Un="_reportContextLabel_14ipf_983",Kn="_reportSection_14ipf_991",zn="_reportSectionHeader_14ipf_997",Wn="_reportMarkdown_14ipf_1009",Jn="_reportLogs_14ipf_1022",Yn="_emptyState_14ipf_1037",Qn="_emptyStateTitle_14ipf_1044",Xn="_emptyStateMessage_14ipf_1052",Zn="_upgradePanel_14ipf_1061",ei="_upgradePanelIcon_14ipf_1069",ti="_upgradePanelTitle_14ipf_1074",ai="_upgradePanelDesc_14ipf_1082",si="_benefitList_14ipf_1092",ni="_benefitItem_14ipf_1103",ii="_upgradeActions_14ipf_1118",li="_workspaceTabs_14ipf_1124",ri="_sessionHelp_14ipf_1137",oi="_stopAction_14ipf_1143",ci="_controlEditor_14ipf_1144",di="_profileToolbar_14ipf_1146",ui="_profileDialog_14ipf_1147",pi="_sessionBar_14ipf_1152",fi="_sessionIdentity_14ipf_1165",mi="_sessionActions_14ipf_1195",hi="_profileActions_14ipf_1196",yi="_profileDialogActions_14ipf_1197",vi="_liveWorkspace_14ipf_1238",gi="_profileLabelRow_14ipf_1254",bi="_profileHint_14ipf_1262",_i="_actualValue_14ipf_1271",xi="_watchReading_14ipf_1272",ji="_liveGrid_14ipf_1308",Si="_livePanel_14ipf_1315",wi="_panelEmpty_14ipf_1352",Ni="_controlAvailability_14ipf_1358",Ci="_controlGate_14ipf_1361",Ri="_controlGateTrigger_14ipf_1364",Pi="_controlGateHint_14ipf_1366",ki="_editorLabel_14ipf_1367",Ai="_editorHeading_14ipf_1368",Ei="_savedValueState_14ipf_1369",Di="_valueToolbar_14ipf_1373",Ii="_valueFilters_14ipf_1383",Ti="_valuePagination_14ipf_1390",Li="_valueListStatus_14ipf_1391",Mi="_valueCount_14ipf_1392",$i="_layoutHint_14ipf_1394",Vi="_srOnly_14ipf_1395",Oi="_unifiedValueRows_14ipf_1396",Bi="_liveRows_14ipf_1397",Fi="_watchRows_14ipf_1397",Gi="_valueGroup_14ipf_1398",qi="_valueGroupToggle_14ipf_1400",Hi="_valueGroupRows_14ipf_1406",Ui="_controlRow_14ipf_1406",Ki="_watchRow_14ipf_1397",zi="_actionRow_14ipf_1408",Wi="_historyBrowser_14ipf_1412",Ji="_historyToolbar_14ipf_1413",Yi="_rowIdentity_14ipf_1437",Qi="_freshness_14ipf_1440",Xi="_presentationMeta_14ipf_1461",Zi="_rowFeedback_14ipf_1462",el="_controlEditorRow_14ipf_1468",tl="_controlActions_14ipf_1469",al="_applyOnStartOption_14ipf_1472",sl="_valueDetails_14ipf_1474",nl="_valueDetailButton_14ipf_1480",il="_valueDetailShell_14ipf_1483",ll="_valueDetailBody_14ipf_1484",rl="_valueDetailList_14ipf_1485",ol="_valueDetailActions_14ipf_1489",cl="_valueDetailFeedback_14ipf_1490",dl="_defaultValueEditor_14ipf_1493",ul="_defaultBooleanEditor_14ipf_1497",pl="_booleanEditor_14ipf_1500",fl="_rangeEditor_14ipf_1509",ml="_valueWorkspacePanel_14ipf_1524",hl="_valueWorkspaceHeader_14ipf_1525",yl="_valueSections_14ipf_1526",vl="_valueSection_14ipf_1526",gl="_valueSectionHeader_14ipf_1528",bl="_valueSectionHeading_14ipf_1529",_l="_valueSectionCount_14ipf_1531",xl="_valueSectionHeaderActions_14ipf_1532",jl="_sectionDragHandle_14ipf_1533",Sl="_sectionMoveButton_14ipf_1534",wl="_valueReorderControls_14ipf_1535",Nl="_dragHandle_14ipf_1537",Cl="_runtimeSettings_14ipf_1549",Rl="_runtimeSettingSwitch_14ipf_1550",Pl="_runtimeSettingSwitchInput_14ipf_1553",kl="_runtimeSettingSwitchTrack_14ipf_1554",Al="_runtimeSettingSwitchThumb_14ipf_1555",El="_layoutError_14ipf_1559",Dl="_controlValueList_14ipf_1560",Il="_watchValueGrid_14ipf_1561",Tl="_actionValueList_14ipf_1562",Ll="_valueEntryShell_14ipf_1563",Ml="_watchCardMain_14ipf_1576",$l="_watchDetails_14ipf_1583",Vl="_actionSummary_14ipf_1592",Ol="_actionExecution_14ipf_1592",Bl="_actionParameter_14ipf_1593",Fl="_actionInactiveReason_14ipf_1597",Gl="_actionParameterGrid_14ipf_1602",ql="_actionParameterError_14ipf_1608",Hl="_deploymentGuide_14ipf_1634",Ul="_deploymentScope_14ipf_1646",Kl="_deploymentLifecycle_14ipf_1649",zl="_deploymentNotice_14ipf_1650",Wl="_deploymentChecklist_14ipf_1652",Jl="_deploymentDescription_14ipf_1656",Yl="_deploymentDetails_14ipf_1659",Ql="_inlineError_14ipf_1679",Xl="_profileEditorDialog_14ipf_1682",Zl="_profileDialogBody_14ipf_1683",er="_profileDeleteAction_14ipf_1686",tr="_profileDeleteReason_14ipf_1687",ar="_bindingTabs_14ipf_1688",sr="_bindingList_14ipf_1692",nr="_bindingEmpty_14ipf_1693",ir="_bindingItem_14ipf_1694",lr="_bindingItemCopy_14ipf_1699",rr="_bindingPresentation_14ipf_1700",or="_bindingPin_14ipf_1703",cr="_bindingItemActions_14ipf_1705",dr="_bindingDelete_14ipf_1709",ur="_addBindingButton_14ipf_1711",pr="_bindingForm_14ipf_1712",fr="_bindingFormGrid_14ipf_1713",mr="_bindingBooleanDefault_14ipf_1716",hr="_bindingPathField_14ipf_1718",yr="_rangeFields_14ipf_1719",vr="_selectionButton_14ipf_1720",gr="_bindingFormActions_14ipf_1721",br="_bindingError_14ipf_1722",_r="_valueManagerShell_14ipf_1723",xr="_valueSourceTabs_14ipf_1724",jr="_valueManagerBody_14ipf_1728",Sr="_valueSourcePanel_14ipf_1729",wr="_registeredIntro_14ipf_1730",Nr="_registeredEmpty_14ipf_1734",Cr="_registeredSteps_14ipf_1737",Rr="_registeredEmptyActions_14ipf_1740",Pr="_adapterSetupList_14ipf_1745",kr="_adapterSetupRow_14ipf_1749",Ar="_adapterMethods_14ipf_1756",Er="_connectionGuide_14ipf_1757",Dr="_registrationGuide_14ipf_1760",Ir="_adapterSetupContext_14ipf_1761",Tr="_valueSearch_14ipf_1762",Lr="_firstProfileName_14ipf_1763",Mr="_sourceIntro_14ipf_1767",$r="_catalogGroups_14ipf_1771",Vr="_catalogRow_14ipf_1772",Or="_candidateActions_14ipf_1780",Br="_candidateEntry_14ipf_1782",Fr="_propertySelection_14ipf_1783",Gr="_propertySelectionHeader_14ipf_1784",qr="_selectedInstance_14ipf_1785",Hr="_propertyPickerLabel_14ipf_1786",Ur="_propertyPicker_14ipf_1786",Kr="_propertyPickerTrigger_14ipf_1792",zr="_propertyPickerPanel_14ipf_1794",Wr="_propertyPickerSearchRow_14ipf_1796",Jr="_propertyPickerList_14ipf_1800",Yr="_propertyPickerGroup_14ipf_1802",Qr="_propertyPickerOption_14ipf_1805",Xr="_compoundEditor_14ipf_1811",Zr="_compoundCoordinates_14ipf_1812",eo="_colorSwatch_14ipf_1819",to="_candidateAction_14ipf_1780",ao="_candidateActionSizer_14ipf_1836",so="_candidateError_14ipf_1840",no="_valueManagerFooter_14ipf_1842",io="_catalogDetails_14ipf_1843",lo="_inlineNotice_14ipf_1852",ro="_subscriptionUsage_14ipf_1853",oo="_pendingProfileAction_14ipf_1854",co="_registrationExample_14ipf_1859",uo="_registrationActions_14ipf_1862",s={page:Va,sampleBanner:Oa,sampleBannerRow:Ba,sampleBannerMain:Fa,sampleBadge:Ga,sampleTitle:qa,sampleMessage:Ha,sampleActions:Ua,primaryAction:Ka,secondaryAction:za,resetAction:Wa,card:Ja,cardHeader:Ya,clearButton:Qa,statusRow:Xa,statusIndicator:Za,statusRunning:es,statusPaused:ts,statusNotRunning:as,statusLabel:ss,statusMeta:ns,controlButtons:is,btn:ls,btnPrimary:rs,btnDanger:os,historyList:cs,historyItem:ds,stepDisclosure:us,historyItemSelected:ps,historyItemHeader:fs,historyIcon:ms,historyTimestamp:hs,historyName:ys,recordKind:vs,historyItemMeta:gs,historyMode:bs,historyDuration:_s,historyStatus:xs,status_passed:js,status_failed:Ss,status_running:ws,status_timed_out:Ns,status_cancelled:Cs,status_insufficient_evidence:Rs,historyError:Ps,historyEvidence:ks,historyLimitation:As,detailShell:Es,detailHeader:Ds,detailHeading:Is,detailRecordName:Ts,detailCloseButton:Ls,detailRetryButton:Ms,detailBody:$s,detailState:Vs,detailErrorTitle:Os,detailErrorMessage:Bs,reportContainer:Fs,runSummary:Gs,viewerSection:qs,summaryLead:Hs,summaryStatusMark:Us,viewerHeading:Ks,summaryName:zs,summaryReason:Ws,summaryFacts:Js,subsectionLabel:Ys,sectionHeadingRow:Qs,sectionHint:Xs,dimensionGrid:Zs,dimensionCard:en,dimensionHeader:tn,statusMark:an,dimensionName:sn,requirementBadge:nn,dimensionStatus:ln,dimensionMeta:rn,tone_passed:on,tone_failed:cn,tone_timed_out:dn,tone_cancelled:un,tone_insufficient_evidence:pn,tone_unavailable:fn,tone_skipped:mn,tone_not_requested:hn,stepList:yn,stepItem:vn,stepIndex:gn,stepIdentity:bn,stepName:_n,stepMeta:xn,stepStatus:jn,chevron:Sn,chevronOpen:wn,stepDetails:Nn,evidenceBlock:Cn,evidenceLabel:Rn,stepError:Pn,recordProblem:kn,capabilityGrid:An,capabilityItem:En,capabilityYes:Dn,capabilityNo:In,capabilityState:Tn,limitations:Ln,artifactList:Mn,agentList:$n,artifactDisclosures:Vn,artifactDisclosure:On,artifactButton:Bn,artifactContent:Fn,limitationItem:Gn,reportContextPanel:qn,reportContextRow:Hn,reportContextLabel:Un,reportSection:Kn,reportSectionHeader:zn,reportMarkdown:Wn,reportLogs:Jn,emptyState:Yn,emptyStateTitle:Qn,emptyStateMessage:Xn,upgradePanel:Zn,upgradePanelIcon:ei,upgradePanelTitle:ti,upgradePanelDesc:ai,benefitList:si,benefitItem:ni,upgradeActions:ii,workspaceTabs:li,sessionHelp:ri,stopAction:oi,controlEditor:ci,profileToolbar:di,profileDialog:ui,sessionBar:pi,sessionIdentity:fi,sessionActions:mi,profileActions:hi,profileDialogActions:yi,liveWorkspace:vi,profileLabelRow:gi,profileHint:bi,actualValue:_i,watchReading:xi,liveGrid:ji,livePanel:Si,panelEmpty:wi,controlAvailability:Ni,controlGate:Ci,controlGateTrigger:Ri,controlGateHint:Pi,editorLabel:ki,editorHeading:Ai,savedValueState:Ei,valueToolbar:Di,valueFilters:Ii,valuePagination:Ti,valueListStatus:Li,valueCount:Mi,layoutHint:$i,srOnly:Vi,unifiedValueRows:Oi,liveRows:Bi,watchRows:Fi,valueGroup:Gi,valueGroupToggle:qi,valueGroupRows:Hi,controlRow:Ui,watchRow:Ki,actionRow:zi,historyBrowser:Wi,historyToolbar:Ji,rowIdentity:Yi,freshness:Qi,presentationMeta:Xi,rowFeedback:Zi,controlEditorRow:el,controlActions:tl,applyOnStartOption:al,valueDetails:sl,valueDetailButton:nl,valueDetailShell:il,valueDetailBody:ll,valueDetailList:rl,valueDetailActions:ol,valueDetailFeedback:cl,defaultValueEditor:dl,defaultBooleanEditor:ul,booleanEditor:pl,rangeEditor:fl,valueWorkspacePanel:ml,valueWorkspaceHeader:hl,valueSections:yl,valueSection:vl,valueSectionHeader:gl,valueSectionHeading:bl,valueSectionCount:_l,valueSectionHeaderActions:xl,sectionDragHandle:jl,sectionMoveButton:Sl,valueReorderControls:wl,dragHandle:Nl,runtimeSettings:Cl,runtimeSettingSwitch:Rl,runtimeSettingSwitchInput:Pl,runtimeSettingSwitchTrack:kl,runtimeSettingSwitchThumb:Al,layoutError:El,controlValueList:Dl,watchValueGrid:Il,actionValueList:Tl,valueEntryShell:Ll,watchCardMain:Ml,watchDetails:$l,actionSummary:Vl,actionExecution:Ol,actionParameter:Bl,actionInactiveReason:Fl,actionParameterGrid:Gl,actionParameterError:ql,deploymentGuide:Hl,deploymentScope:Ul,deploymentLifecycle:Kl,deploymentNotice:zl,deploymentChecklist:Wl,deploymentDescription:Jl,deploymentDetails:Yl,inlineError:Ql,profileEditorDialog:Xl,profileDialogBody:Zl,profileDeleteAction:er,profileDeleteReason:tr,bindingTabs:ar,bindingList:sr,bindingEmpty:nr,bindingItem:ir,bindingItemCopy:lr,bindingPresentation:rr,bindingPin:or,bindingItemActions:cr,bindingDelete:dr,addBindingButton:ur,bindingForm:pr,bindingFormGrid:fr,bindingBooleanDefault:mr,bindingPathField:hr,rangeFields:yr,selectionButton:vr,bindingFormActions:gr,bindingError:br,valueManagerShell:_r,valueSourceTabs:xr,valueManagerBody:jr,valueSourcePanel:Sr,registeredIntro:wr,registeredEmpty:Nr,registeredSteps:Cr,registeredEmptyActions:Rr,adapterSetupList:Pr,adapterSetupRow:kr,adapterMethods:Ar,connectionGuide:Er,registrationGuide:Dr,adapterSetupContext:Ir,valueSearch:Tr,firstProfileName:Lr,sourceIntro:Mr,catalogGroups:$r,catalogRow:Vr,candidateActions:Or,candidateEntry:Br,propertySelection:Fr,propertySelectionHeader:Gr,selectedInstance:qr,propertyPickerLabel:Hr,propertyPicker:Ur,propertyPickerTrigger:Kr,propertyPickerPanel:zr,propertyPickerSearchRow:Wr,propertyPickerList:Jr,propertyPickerGroup:Yr,propertyPickerOption:Qr,compoundEditor:Xr,compoundCoordinates:Zr,colorSwatch:eo,candidateAction:to,candidateActionSizer:ao,candidateError:so,valueManagerFooter:no,catalogDetails:io,inlineNotice:lo,subscriptionUsage:ro,pendingProfileAction:oo,registrationExample:co,registrationActions:uo};function We(e){return e.trim().toLowerCase()}function po(e){switch(We(e)){case"passed":return"✓";case"failed":case"timed_out":return"×";case"running":return"◔";case"cancelled":case"insufficient_evidence":return"!";default:return"–"}}function fo(e,a){switch(We(a)){case"run":return e("playtest.status.mode.run","Run");case"server":return e("playtest.status.mode.server","Server");case"edit":return e("playtest.status.mode.edit","Edit");case"play":return e("playtest.status.mode.play","Play");default:return a}}function mo(e,a){const n=We(a);return n==="running"?e("playtest.history.status.running","Running"):Ve(e,n)}function ho(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function yo(e){const a=/^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})$/.exec(e);if(a){const[,i,d,c,u,y,m]=a,_=new Date(Date.UTC(Number(i),Number(d)-1,Number(c),Number(u),Number(y),Number(m)));return _.getUTCFullYear()===Number(i)&&_.getUTCMonth()===Number(d)-1&&_.getUTCDate()===Number(c)&&_.getUTCHours()===Number(u)&&_.getUTCMinutes()===Number(y)&&_.getUTCSeconds()===Number(m)?_:null}const n=Date.parse(e);return Number.isNaN(n)?null:new Date(n)}function vo(e,a){const n=yo(e);return n?new Intl.DateTimeFormat(a,{dateStyle:"medium",timeStyle:"short"}).format(n):e}function go({entries:e,onSelect:a,selectedRecordId:n}){const{t:i,locale:d}=ue(),[c,u]=o.useState(""),[y,m]=o.useState("all"),[_,C]=o.useState(0),k=o.useMemo(()=>{const R=c.trim().toLocaleLowerCase();return e.filter(M=>(y==="all"||We(M.status)===y)&&(!R||[M.testName,M.status,M.mode,M.recordKind].join(" ").toLocaleLowerCase().includes(R)))},[e,c,y]),x=Math.max(1,Math.ceil(k.length/50)),f=Math.min(_,x-1),V=k.slice(f*50,(f+1)*50);return e.length===0?t.jsx("div",{className:s.emptyState,children:i("playtest.history.empty","No test results yet")}):t.jsxs("div",{className:s.historyBrowser,children:[t.jsxs("div",{className:s.historyToolbar,children:[t.jsxs("label",{children:[t.jsx("span",{children:i("playtest.history.search","Search test results")}),t.jsx("input",{type:"search",value:c,onChange:R=>{u(R.target.value),C(0)}})]}),t.jsxs("label",{children:[t.jsx("span",{children:i("playtest.history.filter","Result")}),t.jsxs("select",{value:y,onChange:R=>{m(R.target.value),C(0)},children:[t.jsx("option",{value:"all",children:i("playtest.history.filterAll","All results")}),t.jsx("option",{value:"passed",children:i("playtest.result.status.passed","Passed")}),t.jsx("option",{value:"failed",children:i("playtest.result.status.failed","Failed")}),t.jsx("option",{value:"insufficient_evidence",children:i("playtest.result.status.insufficientEvidence","Insufficient evidence")}),t.jsx("option",{value:"timed_out",children:i("playtest.result.status.timedOut","Timed out")})]})]})]}),t.jsx("div",{className:s.valueCount,role:"status",children:i("playtest.history.filteredCount","{{visible}} of {{total}} results").replace("{{visible}}",String(k.length)).replace("{{total}}",String(e.length))}),t.jsx("div",{className:s.historyList,children:V.map(R=>{const M=R.recordId===n;return t.jsxs("button",{className:`${s.historyItem} ${M?s.historyItemSelected:""}`,onClick:w=>a(R.recordId,w.currentTarget),"aria-current":M?"true":void 0,"aria-haspopup":"dialog",children:[t.jsxs("div",{className:s.historyItemHeader,children:[t.jsx("span",{className:s.historyIcon,children:po(R.status)}),t.jsx("span",{className:s.historyTimestamp,children:vo(R.timestamp,d)}),t.jsx("span",{className:s.historyName,children:R.testName}),t.jsx("span",{className:s.recordKind,children:R.recordKind==="structured"?i("playtest.history.kind.structured","Structured"):R.recordKind==="legacy"?i("playtest.history.kind.legacy","Legacy"):i("playtest.history.kind.attention","Needs attention")})]}),t.jsxs("div",{className:s.historyItemMeta,children:[t.jsx(it,{text:i("playtest.history.mode.tooltip","Playtest mode used for this recorded test run."),children:t.jsxs("span",{className:s.historyMode,children:[i("playtest.history.mode","Mode"),": ",fo(i,R.mode)]})}),t.jsx("span",{className:s.historyDuration,children:ho(R.durationMs)}),t.jsx(it,{text:i("playtest.history.status.tooltip","Recorded result state for this automated playtest run."),children:t.jsx("span",{className:`${s.historyStatus} ${s[`status_${We(R.status)}`]??""}`,children:mo(i,R.status)})})]}),R.evidenceSummary&&t.jsxs("div",{className:s.historyEvidence,children:[t.jsxs("span",{children:[i("playtest.dimension.server","Server"),": ",Ve(i,R.evidenceSummary.server.status)]}),t.jsxs("span",{children:[i("playtest.dimension.clientUi","Client UI"),": ",Ve(i,R.evidenceSummary.clientUi.status)]}),R.agentCounts&&t.jsx("span",{children:i("playtest.history.agentCounts","Server {server} · Client {client}").replace("{server}",String(R.agentCounts.server)).replace("{client}",String(R.agentCounts.client))})]}),R.errorMessage&&t.jsx("div",{className:s.historyError,children:R.errorMessage}),!R.errorMessage&&R.limitation&&t.jsx("div",{className:s.historyLimitation,children:Ot(i,R.limitation.code,R.limitation.message)})]},R.recordId)})}),x>1&&t.jsxs("div",{className:s.valuePagination,children:[t.jsx("button",{type:"button",disabled:f===0,onClick:()=>C(R=>R-1),children:i("playtest.values.previous","Previous")}),t.jsxs("span",{children:[f+1," / ",x]}),t.jsx("button",{type:"button",disabled:f+1>=x,onClick:()=>C(R=>R+1),children:i("playtest.values.next","Next")})]})]})}function rt({label:e,open:a,onToggle:n,children:i,tooltip:d}){const c=o.useId();return t.jsxs("div",{className:s.artifactDisclosure,children:[t.jsxs("button",{className:s.artifactButton,onClick:n,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),n())},"aria-expanded":a,"aria-controls":c,children:[d?t.jsx(it,{text:d,children:t.jsx("span",{children:e})}):t.jsx("span",{children:e}),t.jsx("span",{"aria-hidden":"true",className:`${s.chevron} ${a?s.chevronOpen:""}`,children:"⌄"})]}),a&&t.jsx("div",{className:s.artifactContent,id:c,children:i})]})}function bo({detail:e}){const{t:a}=ue(),[n,i]=o.useState(()=>new Set(e.recordKind==="legacy"?["report","logs"]:[])),d=y=>i(m=>{const _=new Set(m);return _.has(y)?_.delete(y):_.add(y),_}),c=e.result?{schemaVersion:e.result.schemaVersion,sessionId:e.result.sessionId,recordId:e.result.recordId,startedAt:e.result.startedAt,endedAt:e.result.endedAt,files:e.result.artifacts.files}:null,u=e.artifactErrors??[];return!c&&!e.markdown&&!e.logs&&u.length===0?null:t.jsxs("section",{className:s.viewerSection,"aria-labelledby":"playtest-artifacts-heading",children:[t.jsx("h3",{id:"playtest-artifacts-heading",className:s.viewerHeading,children:a("playtest.artifacts.title","Artifacts")}),t.jsxs("div",{className:s.artifactDisclosures,children:[c&&t.jsx(rt,{label:a("playtest.artifacts.metadata","Result metadata"),open:n.has("metadata"),onToggle:()=>d("metadata"),children:t.jsx("pre",{children:at(c)})}),e.markdown&&t.jsx(rt,{label:a("playtest.report.content","Report"),tooltip:a("playtest.report.content.tooltip","Markdown summary for the selected automated playtest run."),open:n.has("report"),onToggle:()=>d("report"),children:t.jsx("pre",{children:e.markdown})}),e.logs&&t.jsx(rt,{label:a("playtest.report.logs","Logs"),tooltip:a("playtest.report.logs.tooltip","Execution logs captured for the selected automated playtest run."),open:n.has("logs"),onToggle:()=>d("logs"),children:t.jsx("pre",{children:e.logs})})]}),u.map(y=>t.jsx("div",{className:s.stepError,children:y.message},`${y.code}-${y.message}`))]})}function _o({result:e}){const{t:a}=ue(),n=[[a("playtest.capability.semanticUi","Semantic UI snapshot"),e.capabilities.semanticUiSnapshot],[a("playtest.capability.virtualInput","Virtual input"),e.capabilities.virtualInput],[a("playtest.capability.fixedBootstrap","Fixed agent bootstrap"),e.capabilities.fixedBootstrap],[a("playtest.capability.projectAdapter","Project test adapter"),e.capabilities.projectTestAdapter]];return t.jsxs("section",{className:s.viewerSection,"aria-labelledby":"playtest-capabilities-heading",children:[t.jsx("h3",{id:"playtest-capabilities-heading",className:s.viewerHeading,children:a("playtest.capability.title","Capabilities and limits")}),t.jsx("div",{className:s.capabilityGrid,children:n.map(([i,d])=>t.jsxs("div",{className:s.capabilityItem,children:[t.jsx("span",{className:d?s.capabilityYes:s.capabilityNo,"aria-hidden":"true",children:d?"✓":"–"}),t.jsx("span",{children:i}),t.jsx("span",{className:s.capabilityState,children:d?a("playtest.capability.available","Available"):a("playtest.capability.unavailable","Unavailable")})]},i))}),e.agents.length>0&&t.jsxs("div",{className:s.agentList,children:[t.jsx("span",{className:s.subsectionLabel,children:a("playtest.agents.title","Test agents")}),e.agents.map((i,d)=>{const c=typeof i.agentId=="string"?i.agentId:`${a("playtest.agents.unknown","Agent")} ${d+1}`,u=typeof i.role=="string"?i.role:"unknown",y=typeof i.clientId=="string"?` · ${i.clientId}`:"";return t.jsxs("code",{children:[c," · ",u,y]},`${c}-${d}`)})]}),e.limitations.length>0&&t.jsxs("div",{className:s.limitations,children:[t.jsx("div",{className:s.subsectionLabel,children:a("playtest.limitations.title","Limitations")}),e.limitations.map(i=>t.jsxs("div",{className:s.limitationItem,children:["! ",Ot(a,i.code,i.message)]},i.code))]})]})}const xo=["server","clientUi","interaction","visual"];function jo({result:e}){const{t:a}=ue(),n={server:a("playtest.dimension.server","Server"),clientUi:a("playtest.dimension.clientUi","Client UI"),interaction:a("playtest.dimension.interaction","Interaction"),visual:a("playtest.dimension.visual","Visual")};return t.jsxs("section",{className:s.viewerSection,"aria-labelledby":"playtest-dimensions-heading",children:[t.jsxs("div",{className:s.sectionHeadingRow,children:[t.jsx("h3",{id:"playtest-dimensions-heading",className:s.viewerHeading,children:a("playtest.dimension.title","Evidence dimensions")}),t.jsx("span",{className:s.sectionHint,children:a("playtest.dimension.hint","Required evidence is marked below.")})]}),t.jsx("div",{className:s.dimensionGrid,children:xo.map(i=>{const d=e.dimensions[i];return t.jsxs("div",{className:s.dimensionCard,children:[t.jsxs("div",{className:s.dimensionHeader,children:[t.jsx("span",{className:`${s.statusMark} ${s[`tone_${d.status}`]??""}`,"aria-hidden":"true",children:vt(d.status)}),t.jsx("span",{className:s.dimensionName,children:n[i]}),t.jsx("span",{className:s.requirementBadge,children:d.required?a("playtest.dimension.required","Required"):a("playtest.dimension.optional","Optional")})]}),t.jsx("div",{className:s.dimensionStatus,children:Ve(a,d.status)}),d.provider&&t.jsx("div",{className:s.dimensionMeta,children:d.provider}),d.reason&&t.jsx("div",{className:s.dimensionMeta,children:$a(a,d.reason)}),t.jsxs("div",{className:s.dimensionMeta,children:[a("playtest.dimension.steps","Steps"),": ",d.stepIds.length]})]},i)})})]})}function So({result:e}){const{t:a}=ue(),n=o.useId(),[i,d]=o.useState(()=>new Set),c=u=>{d(y=>{const m=new Set(y);return m.has(u)?m.delete(u):m.add(u),m})};return t.jsxs("section",{className:s.viewerSection,"aria-labelledby":`${n}-heading`,children:[t.jsx("h3",{id:`${n}-heading`,className:s.viewerHeading,children:a("playtest.steps.title","Step timeline")}),t.jsx("div",{className:s.stepList,children:e.steps.map(u=>{const y=i.has(u.stepId),m=`${n}-${u.index}-details`,_=u.target.role==="server"?a("playtest.steps.server","Server"):u.target.clientId;return t.jsxs("div",{className:s.stepItem,children:[t.jsxs("button",{className:s.stepDisclosure,onClick:()=>c(u.stepId),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),c(u.stepId))},"aria-expanded":y,"aria-controls":m,children:[t.jsx("span",{className:`${s.statusMark} ${s[`tone_${u.status}`]??""}`,"aria-hidden":"true",children:vt(u.status)}),t.jsx("span",{className:s.stepIndex,children:u.index+1}),t.jsxs("span",{className:s.stepIdentity,children:[t.jsx("span",{className:s.stepName,children:u.stepId}),t.jsxs("span",{className:s.stepMeta,children:[_," · ",u.action," · ",Vt(u.durationMs)]})]}),t.jsx("span",{className:s.stepStatus,children:Ve(a,u.status)}),t.jsx("span",{className:`${s.chevron} ${y?s.chevronOpen:""}`,"aria-hidden":"true",children:"⌄"})]}),y&&t.jsxs("div",{className:s.stepDetails,id:m,role:"region","aria-label":`${u.stepId} ${a("playtest.steps.details","details")}`,children:[u.expected!==void 0&&t.jsxs("div",{className:s.evidenceBlock,children:[t.jsx("div",{className:s.evidenceLabel,children:a("playtest.steps.expected","Expected")}),t.jsx("pre",{children:at(u.expected)})]}),u.observed!==void 0&&t.jsxs("div",{className:s.evidenceBlock,children:[t.jsx("div",{className:s.evidenceLabel,children:a("playtest.steps.observed","Observed")}),t.jsx("pre",{children:at(u.observed)})]}),u.evidence!==void 0&&t.jsxs("div",{className:s.evidenceBlock,children:[t.jsx("div",{className:s.evidenceLabel,children:a("playtest.steps.evidence","Evidence")}),t.jsx("pre",{children:at(u.evidence)})]}),u.error&&t.jsxs("div",{className:s.stepError,children:[t.jsx("strong",{children:u.error.code})," — ",u.error.message]})]})]},u.stepId)})})]})}function wo({report:e}){var i;const{t:a}=ue(),n=e.recordKind==="incomplete_structured"?a("playtest.record.incomplete","Structured result is incomplete"):e.recordKind==="corrupt_structured"?a("playtest.record.corrupt","Structured result is damaged"):a("playtest.record.unsupported","Structured result version is unsupported");return t.jsxs("div",{className:s.recordProblem,role:"status",children:[t.jsx("strong",{children:n}),t.jsx("span",{children:((i=e.error)==null?void 0:i.message)??a("playtest.record.unavailable","Result details are unavailable.")})]})}function No({report:e}){var d,c,u,y,m,_;const{t:a}=ue(),n=!!((d=e.contextSummary)!=null&&d.testScenario||(c=e.contextSummary)!=null&&c.expectedBehavior||(u=e.contextSummary)!=null&&u.observedBehavior),i=e.recordKind==="structured"?e.result:void 0;return t.jsxs("div",{className:s.reportContainer,children:[i&&t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:s.runSummary,"aria-labelledby":"playtest-summary-heading",children:[t.jsxs("div",{className:s.summaryLead,children:[t.jsx("span",{className:`${s.summaryStatusMark} ${s[`tone_${i.overallStatus}`]??""}`,"aria-hidden":"true",children:vt(i.overallStatus)}),t.jsxs("div",{children:[t.jsx("h3",{id:"playtest-summary-heading",className:s.viewerHeading,children:a("playtest.summary.title","Run summary")}),t.jsx("div",{className:s.summaryName,children:i.testName}),t.jsx("div",{className:s.summaryReason,children:i.terminalReason.message})]})]}),t.jsxs("div",{className:s.summaryFacts,children:[t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.status","Status")}),t.jsx("strong",{children:Ve(a,i.overallStatus)})]}),t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.mode","Mode")}),t.jsx("strong",{children:i.mode==="play"?a("playtest.status.mode.play","Play"):a("playtest.status.mode.run","Run")})]}),t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.duration","Duration")}),t.jsx("strong",{children:Vt(i.durationMs)})]}),t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.cleanup","Cleanup")}),t.jsx("strong",{children:Ve(a,i.cleanup.status)})]})]})]}),t.jsx(jo,{result:i}),t.jsx(So,{result:i}),t.jsx(_o,{result:i})]}),e.recordKind!=="structured"&&e.recordKind!=="legacy"&&t.jsx(wo,{report:e}),n&&t.jsxs("div",{className:s.reportContextPanel,children:[((y=e.contextSummary)==null?void 0:y.testScenario)&&t.jsxs("div",{className:s.reportContextRow,children:[t.jsx("span",{className:s.reportContextLabel,children:a("playtest.context.why","Why this test ran")}),t.jsx("span",{children:e.contextSummary.testScenario})]}),((m=e.contextSummary)==null?void 0:m.expectedBehavior)&&t.jsxs("div",{className:s.reportContextRow,children:[t.jsx("span",{className:s.reportContextLabel,children:a("playtest.context.expected","Expected")}),t.jsx("span",{children:e.contextSummary.expectedBehavior})]}),((_=e.contextSummary)==null?void 0:_.observedBehavior)&&t.jsxs("div",{className:s.reportContextRow,children:[t.jsx("span",{className:s.reportContextLabel,children:a("playtest.context.observed","Observed")}),t.jsx("span",{children:e.contextSummary.observedBehavior})]})]}),t.jsx(bo,{detail:e},e.recordId),!i&&!e.markdown&&!e.logs&&e.recordKind==="legacy"&&t.jsx("div",{className:s.emptyState,children:a("playtest.report.empty","No report content available")})]})}function Rt(e){return typeof e=="number"?{placeId:String(e)}:void 0}const me={listProfiles:async e=>De.get("/api/dashboard/playtest/control-profiles",Rt(e)),liveStatus:async(e,a)=>De.get("/api/dashboard/playtest/live",{...Rt(e)??{},...a?{leaseId:a}:{}}),liveAction:async e=>De.post("/api/dashboard/playtest/live",e),bindingDraft:async(e,a)=>De.post("/api/dashboard/playtest/binding-draft",{...e,...typeof a=="number"?{placeId:a}:{}}),bindingCandidates:async e=>De.post("/api/dashboard/playtest/binding-candidates",{...typeof e=="number"?{placeId:e}:{}}),saveProfile:async(e,a,n)=>De.put(`/api/dashboard/playtest/control-profiles/${encodeURIComponent(e.id)}`,{profile:e,expectedRevision:a,...typeof n=="number"?{placeId:n}:{}}),saveProfileMetadata:async(e,a,n,i)=>De.patch(`/api/dashboard/playtest/control-profiles/${encodeURIComponent(e)}/metadata`,{expectedRevision:a,...n,...typeof i=="number"?{placeId:i}:{}}),deleteProfile:async(e,a,n)=>{const i=new URLSearchParams({expectedRevision:String(a)});return n.placeId!==void 0&&i.set("placeId",String(n.placeId)),De.delete(`/api/dashboard/playtest/control-profiles/${encodeURIComponent(e)}?${i.toString()}`,n.clientId?{clientId:n.clientId}:void 0)}},Bt="weppy-playtest-workspace-v1",Co="weppy-playtest-profile-v1:";function Je(){try{return window.localStorage}catch{return null}}function Ro(){var e;try{const a=(e=Je())==null?void 0:e.getItem(Bt);return a==="live"||a==="results"?a:"live"}catch{return"live"}}function Po(e){var a;try{(a=Je())==null||a.setItem(Bt,e)}catch{}}function gt(e){return`${Co}${e}`}function ko(e){var a;if(e===null)return null;try{return((a=Je())==null?void 0:a.getItem(gt(e)))||null}catch{return null}}function Ye(e,a){var n;if(e!==null)try{(n=Je())==null||n.setItem(gt(e),a)}catch{}}function Pt(e){var a;if(e!==null)try{(a=Je())==null||a.removeItem(gt(e))}catch{}}const Qe={entries:[],diagnostics:[]},Xe={hasManagedAdapterWithoutStudioGuard:!1};function qe(e){return typeof e=="object"&&e!==null&&"error"in e&&typeof e.error=="string"?e.error:e instanceof Error?e.message:String(e)}function Ao(e){if(typeof e!="object"||e===null||!("payload"in e))return!1;const a=e.payload;return(a==null?void 0:a.errorCode)==="lease_agents_unavailable"}function Eo(e){const{enabled:a,canMutate:n,placeId:i,studioSnapshot:d}=e,[c,u]=o.useState([]),[y,m]=o.useState(!1),[_,C]=o.useState(null),[k,x]=o.useState(null),[f,V]=o.useState(Qe),[R,M]=o.useState(Xe),[w,B]=o.useState({}),[P,E]=o.useState({}),[W,$]=o.useState({}),[ee,te]=o.useState(!0),[q,O]=o.useState(null),[z,U]=o.useState(null),L=o.useRef(null),ae=o.useRef(null),J=o.useRef([]),le=o.useRef(!1),Q=o.useRef(Promise.resolve()),K=o.useRef(0),Z=o.useRef(0),X=o.useRef(null),he=o.useRef(Promise.resolve()),re=o.useRef(null),oe=o.useRef(i);oe.current=i;const[ye,we]=o.useState(0);L.current=k;const H=o.useMemo(()=>c.find(v=>v.id===_)??null,[c,_]);ae.current=H,J.current=c;const se=o.useCallback(()=>{E(v=>Object.fromEntries(Object.entries(v).map(([S,A])=>{const{observed:N,...G}=A;return[S,{...G,status:"unavailable",fresh:!1,...N!==void 0?{lastObserved:N}:{},reason:"session_ended"}]})))},[]),ne=o.useCallback(async()=>{X.current&&(clearTimeout(X.current),X.current=null),Z.current=0;const v=L.current;if(v){L.current=null,x(null),B({}),$({}),se();try{await me.liveAction({action:"close",leaseId:v.leaseId,...typeof i=="number"?{placeId:i}:{}})}catch{}}},[se,i]),ce=o.useCallback(async()=>{if(!(L.current||le.current)){le.current=!0;try{let v=ae.current,S=oe.current,A=await me.liveAction({action:v?"observe":"discover",...v?{profileId:v.id}:{},...typeof S=="number"?{placeId:S}:{}});const N=ae.current,G=oe.current,l=(N==null?void 0:N.id)??"__weppy_catalog__";(A.lease.profileId!==l||G!==S)&&(v=N,S=G,A=await me.liveAction({action:v?"observe":"discover",...v?{profileId:v.id}:{},...typeof S=="number"?{placeId:S}:{}})),L.current=A.lease,x(A.lease),A.lease.catalog&&V(A.lease.catalog),B({});const r=await me.liveStatus(S,A.lease.leaseId);E(Object.fromEntries(r.watches.map(g=>[g.subscriptionId,g]))),X.current&&clearTimeout(X.current),X.current=null,Z.current=0,U(null)}catch(v){if(U(qe(v)),Ao(v)&&!X.current){const S=Z.current;Z.current+=1;const A=Math.min(2e3,250*2**Math.min(S,3));X.current=setTimeout(()=>{X.current=null,we(N=>N+1)},A)}}finally{le.current=!1}}},[]);o.useEffect(()=>{a||ne()},[ne,a]),o.useEffect(()=>{let v=!1;return te(!0),m(!1),u([]),C(null),re.current=null,x(null),B({}),E({}),$({}),V(Qe),M(Xe),(async()=>{const A=me.listProfiles(i).then(N=>{var r,g;if(v)return;u(N.profiles),re.current=(r=N.scope)!=null&&r.placeId?{placeId:N.scope.placeId}:N.targetClientId?{clientId:N.targetClientId}:typeof i=="number"?{placeId:i}:null,V(N.catalog??Qe),M(N.releaseGuidance??Xe);const G=ko(i),l=N.profiles.some(D=>D.id===G)?G:((g=N.profiles[0])==null?void 0:g.id)??null;C(l),l&&Ye(i,l),m(!0)}).catch(N=>{v||(U(qe(N)),m(!0))});try{await A}finally{v||te(!1)}})(),()=>{v=!0}},[a,i]),o.useEffect(()=>{const v=++K.current,S=a&&y&&d.targetClientId!==null&&(d.state==="Running"||d.state==="Paused");!S&&X.current&&(clearTimeout(X.current),X.current=null,Z.current=0),Q.current=Q.current.catch(()=>{}).then(async()=>{if(v!==K.current)return;const A=L.current;A&&(!S||A.target.clientId!==d.targetClientId)&&await ne(),v===K.current&&S&&!L.current&&await ce()})},[ne,a,ce,ye,y,d.state,d.mode,d.targetClientId]),o.useEffect(()=>{if(!a)return;const v=new Ut,S=v.on("playtest_watch",A=>{var G,l;const N=A;!(N!=null&&N.subscriptionId)||N.leaseId!==((G=L.current)==null?void 0:G.leaseId)||(N.profileGeneration??1)===(((l=L.current)==null?void 0:l.profileGeneration)??1)&&E(r=>{const g=r[N.subscriptionId];if(g&&N.sequence<=g.sequence&&N.sequence!==0)return r;const h=g&&N.sequence>0&&g.sequence>0&&N.sequence!==g.sequence+1?(()=>{const{observed:b,...T}=N;return{...T,status:"stale",fresh:!1,...b!==void 0?{lastObserved:b}:{},reason:"sequence_gap"}})():N;return{...r,[N.subscriptionId]:h}})});return v.connect(),()=>{S(),v.disconnect()}},[a]);const ie=o.useCallback(async v=>{var N;const S=J.current.find(G=>G.id===v);if(!S)return;const A=L.current;if(!A){C(v),Ye(i,v);return}if(A.profileId===S.id&&A.profileRevision===S.revision){C(v),Ye(i,v);return}O(v),U(null);try{const G=A.profileGeneration??1,l=await me.liveAction({action:"observe",profileId:v,...typeof i=="number"?{placeId:i}:{}});L.current=l.lease,x(l.lease),C(v),Ye(i,v),(l.lease.profileGeneration??1)!==G&&(B({}),$({}));const r=await me.liveStatus(i,l.lease.leaseId);(((N=L.current)==null?void 0:N.profileGeneration)??1)===(l.lease.profileGeneration??1)&&E(Object.fromEntries(r.watches.map(g=>[g.subscriptionId,g])))}catch(G){U(qe(G))}finally{O(null)}},[i]),Ne=o.useCallback(async(v,S)=>{var G;const A=L.current;if(!A||!n)return;const N=A.profileGeneration??1;B(l=>({...l,[v]:{...l[v],status:"applying",draft:S}}));try{const l=await me.liveAction({action:"apply",leaseId:A.leaseId,expectedRevision:A.revision,values:{[v]:S},...typeof i=="number"?{placeId:i}:{}}),r=l.result.bindings.find(g=>g.bindingId===v);if((((G=L.current)==null?void 0:G.profileGeneration)??1)!==N)return;x(g=>g&&(g.profileGeneration??1)===N?{...g,revision:l.result.revision}:g),B(g=>{var D,h;return{...g,[v]:l.result.status==="applied"?{status:"applied",draft:S,requested:(r==null?void 0:r.requested)??S,observed:r==null?void 0:r.observed,original:r==null?void 0:r.original}:{...g[v],status:((D=l.result.error)==null?void 0:D.code)==="requires_adapter"?"requires_adapter":"error",draft:S,message:(h=l.result.error)==null?void 0:h.message}}})}catch(l){const r=typeof l=="object"&&l!==null&&"status"in l&&l.status===409;B(g=>({...g,[v]:{...g[v],status:r?"conflict":"error",draft:S,message:qe(l)}}))}},[n,i]),ve=o.useCallback(async()=>{const v=L.current;if(!v||!n)return;const S=await me.liveAction({action:"reset",leaseId:v.leaseId,...typeof i=="number"?{placeId:i}:{}});x(S.lease),B({})},[n,i]),_e=o.useCallback(async(v,S,A)=>{var g,D;const N=L.current,G=ae.current;if(!N||!G||!n||d.state!=="Running")return;const l=structuredClone(S),r=N.profileGeneration??1;$(h=>({...h,[v]:{status:"running",requestId:A,actionId:v,arguments:l,executedAtMs:Date.now()}}));try{const h=await me.liveAction({action:"execute_action",leaseId:N.leaseId,profileId:G.id,actionId:v,requestId:A,expectedProfileRevision:G.revision,expectedRevision:N.revision,arguments:l,...typeof i=="number"?{placeId:i}:{}});(((g=L.current)==null?void 0:g.profileGeneration)??1)===r&&$(b=>({...b,[v]:h.result}))}catch(h){const b=typeof h=="object"&&h!==null&&"payload"in h?h.payload:void 0,T=(b==null?void 0:b.errorCode)==="action_result_unknown"||(b==null?void 0:b.errorCode)==="plugin_disconnected"||(b==null?void 0:b.errorCode)==="command_timeout";if((((D=L.current)==null?void 0:D.profileGeneration)??1)!==r)return;$(I=>({...I,[v]:{status:T?"unknown":"failed",requestId:A,actionId:v,arguments:l,executedAtMs:Date.now(),error:{code:(b==null?void 0:b.errorCode)??"action_failed",message:qe(h)}}}))}},[n,i,d.state]),xe=o.useCallback(async v=>{const S=v.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||`profile-${Date.now()}`,A=await me.saveProfile({schemaVersion:4,id:S,name:v.trim(),controls:[],watches:[],actions:[],presentation:{},settings:{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"},sectionOrder:["watches","controls","actions"]},0,i);return u(N=>[...N,A.profile]),J.current=[...J.current,A.profile],await ie(A.profile.id),A.profile},[i,ie]),Ce=o.useCallback(async v=>{var G;const{revision:S,...A}=v,N=await me.saveProfile(A,S,i);u(l=>l.map(r=>r.id===N.profile.id?N.profile:r)),J.current=J.current.map(l=>l.id===N.profile.id?N.profile:l),((G=L.current)==null?void 0:G.profileId)===N.profile.id&&await ie(N.profile.id)},[i,ie]),be=o.useCallback(async(v,S,A)=>{const N=ae.current;if(!N)throw new Error("Select a test profile before saving a value.");const G=N.id;await new Promise((l,r)=>{he.current=he.current.catch(()=>{}).then(async()=>{var h,b;const g=J.current.find(T=>T.id===G);if(!g)throw new Error("The selected test profile is no longer available.");const D=await me.saveProfileMetadata(g.id,g.revision,{defaults:{[v]:S}},i);((h=ae.current)==null?void 0:h.id)===D.profile.id&&(ae.current=D.profile),J.current=J.current.map(T=>T.id===D.profile.id?D.profile:T),u(J.current),((b=L.current)==null?void 0:b.profileId)===D.profile.id&&await ie(D.profile.id)}),he.current.then(l,r)})},[i,ie]),fe=o.useCallback(async v=>{var A;const S=(A=ae.current)==null?void 0:A.id;if(!S)throw new Error("Select a test profile before saving display settings.");await new Promise((N,G)=>{he.current=he.current.catch(()=>{}).then(async()=>{var g,D;const l=J.current.find(h=>h.id===S);if(!l)throw new Error("The selected test profile is no longer available.");const r=await me.saveProfileMetadata(l.id,l.revision,v,i);((g=ae.current)==null?void 0:g.id)===r.profile.id&&(ae.current=r.profile),J.current=J.current.map(h=>h.id===r.profile.id?r.profile:h),u(J.current),((D=L.current)==null?void 0:D.profileId)===r.profile.id&&await ie(r.profile.id)}),he.current.then(N,G)})},[i,ie]),Re=o.useCallback(async(v,S)=>{await fe({actionDefaults:{[v]:S}})},[fe]),p=o.useCallback(async v=>({path:(await me.bindingDraft(v,i)).binding.path}),[i]),j=o.useCallback(async()=>await me.bindingCandidates(i),[i]),F=o.useCallback(async(v,S)=>{var r,g,D,h;const A=re.current,N=i;if(!A)throw Object.assign(new Error("profile_scope_unavailable"),{code:"profile_scope_unavailable"});if(((r=L.current)==null?void 0:r.profileId)===v){const b=J.current.find(T=>T.id!==v);if(b){if(await ie(b.id),((g=L.current)==null?void 0:g.profileId)!==b.id)throw new Error("Could not switch away from the active profile before deleting it.")}else{const T=await me.liveAction({action:"discover",...typeof N=="number"?{placeId:N}:{}});L.current=T.lease,x(T.lease),B({}),E({}),$({})}}await me.deleteProfile(v,S,A);let G;try{G=await me.listProfiles(N)}catch{if(oe.current!==N)return{refreshFailed:!0};const b=J.current.filter(I=>I.id!==v);J.current=b;const T=((D=b[0])==null?void 0:D.id)??null;if(u(b),B({}),E({}),$({}),T)await ie(T);else if(C(null),Pt(N),L.current&&L.current.profileId!=="__weppy_catalog__"){const I=await me.liveAction({action:"discover",...typeof N=="number"?{placeId:N}:{}});L.current=I.lease,x(I.lease)}return{refreshFailed:!0}}if(oe.current!==N)return{refreshFailed:!1};u(G.profiles),J.current=G.profiles,V(G.catalog??Qe),M(G.releaseGuidance??Xe);const l=((h=G.profiles[0])==null?void 0:h.id)??null;if(B({}),E({}),$({}),l)await ie(l);else if(C(null),Pt(N),L.current&&L.current.profileId!=="__weppy_catalog__"){const b=await me.liveAction({action:"discover",...typeof N=="number"?{placeId:N}:{}});L.current=b.lease,x(b.lease)}return{refreshFailed:!1}},[i,ie]);return{profiles:c,selectedProfileId:_,profile:H,catalog:f,releaseGuidance:R,lease:k,controls:w,watches:P,actions:W,studioState:d.state,studioMode:d.mode,canMutate:n,loading:ee,switchingProfileId:q,error:z,selectProfile:ie,apply:Ne,executeAction:_e,resetAll:ve,createProfile:xe,saveProfile:Ce,saveControlValue:be,saveActionDefaults:Re,saveProfileMetadata:fe,resolveSelection:p,resolveSelectionCandidates:j,deleteProfile:F}}function Do(e){const{t:a}=ue(),n=[{key:"live",label:a("playtest.view.liveSession","Test Values")},{key:"results",label:a("playtest.view.testResults","Automated Test Results")}];return t.jsx(ra,{items:n,value:e.value,onChange:e.onChange,ariaLabel:a("playtest.view.workspaceLabel","Playtest workspace"),className:s.workspaceTabs})}function Io(e){const{t:a}=ue(),n=e.studioState==="Running"&&e.studioMode==="run"?a("playtest.session.state.runRunning","Run running"):e.studioState==="Running"&&e.studioMode==="play"?a("playtest.session.state.playRunning","Play running"):a(`playtest.session.state.${e.studioState.toLowerCase()}`,e.studioState),i=e.studioState==="Disconnected"?a("playtest.session.disconnectedDescription","Connect Roblox Studio and WEPPY Plugin to observe Playtest values."):e.studioState==="Edit"?null:e.studioState==="Paused"?a("playtest.session.pausedDescription","Studio Play is paused. Observations remain connected, and Pro value changes stay available."):e.lease?`${e.profileName??e.lease.profileId} · ${e.lease.target.targetAlias??e.lease.target.clientId}`:a("playtest.session.connectingDescription","Studio is playing. Connecting runtime observations…");return t.jsx("section",{className:s.sessionBar,"aria-label":a("playtest.session.label","Playtest session"),children:t.jsxs("div",{className:s.sessionIdentity,children:[t.jsx(ba,{size:16,"aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("strong",{children:n}),i&&t.jsx("span",{children:i})]})]})})}function Oe(e){const{t:a}=ue(),[n,i]=o.useState(!1),d=o.useRef(null),c=o.useRef(null),u=o.useRef(null),[y,m]=o.useState({top:0,left:0});return o.useLayoutEffect(()=>{var R;if(!n||e.active||!c.current||!u.current)return;const C=(((R=d.current)==null?void 0:R.querySelector("input, select, button"))??c.current).getBoundingClientRect(),k=u.current.getBoundingClientRect(),x=C.top-k.height-6,f=C.bottom+6,V=x<8&&f+k.height<=window.innerHeight-8?f:x;m({top:Math.max(8,Math.min(V,window.innerHeight-k.height-8)),left:Math.max(8,Math.min(C.left+C.width/2-k.width/2,window.innerWidth-k.width-8))})},[n,e.active,e.reason]),o.useEffect(()=>{if(!n)return;const _=()=>i(!1);return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[n]),t.jsxs("div",{ref:d,className:s.controlGate,children:[e.children,!e.active&&t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c,type:"button",className:s.controlGateTrigger,"aria-label":a("playtest.controls.lockedHelp","Why is {{label}} unavailable?").replace("{{label}}",e.label),"aria-describedby":"playtest-controls-availability","aria-expanded":n,onClick:()=>i(!0),onFocus:()=>i(!0),onBlur:()=>i(!1),onKeyDown:_=>{_.key==="Escape"&&i(!1)}}),n&&Kt.createPortal(t.jsx("span",{ref:u,className:s.controlGateHint,style:y,role:"status",children:e.reason}),document.body)]})]})}function bt(e){var a,n,i;return t.jsx(Ke,{open:e.open,ariaLabel:e.ariaLabel,onClose:e.onClose,returnFocusTo:e.returnFocusTo,testId:"playtest-value-detail-layer",children:t.jsxs("div",{className:s.valueDetailShell,children:[t.jsx(ze,{title:e.title,description:e.description,closeLabel:e.closeLabel,onRequestClose:e.onClose}),t.jsxs("div",{className:s.valueDetailBody,children:[t.jsx("dl",{className:s.valueDetailList,children:e.items.map(d=>t.jsxs("div",{children:[t.jsx("dt",{children:d.label}),t.jsx("dd",{children:d.value})]},d.label))}),t.jsx("div",{className:s.valueDetailFeedback,"data-state":e.error?"error":((a=e.feedback)==null?void 0:a.state)??"idle",role:e.error||((n=e.feedback)==null?void 0:n.state)==="error"?"alert":"status","aria-live":"polite",children:e.error??((i=e.feedback)==null?void 0:i.message)??" "}),e.actions&&e.actions.length>0&&t.jsx("div",{className:s.valueDetailActions,children:e.actions.map(d=>{var c,u,y;return t.jsx(Oe,{active:((c=d.gate)==null?void 0:c.active)??!0,label:((u=d.gate)==null?void 0:u.label)??d.label,reason:((y=d.gate)==null?void 0:y.reason)??"",children:t.jsx("button",{type:"button",className:d.variant==="secondary"?s.secondaryAction:s.primaryAction,"aria-label":d.accessibleLabel,disabled:d.disabled,onClick:d.onClick,children:d.label})},d.accessibleLabel)})})]})]})})}function Ge(e){return e==="vector3"||e==="color3"||e==="cframe"}function Ft(e){return e==="vector3"?["x","y","z"]:e==="color3"?["r","g","b"]:["X","Y","Z","R00","R01","R02","R10","R11","R12","R20","R21","R22"]}function _t(e,a){try{const n=JSON.parse(a),i=Ft(e);if(e==="cframe"?!Array.isArray(n)||n.length!==12:!n||Array.isArray(n)||typeof n!="object"||Object.keys(n).length!==3)return;const d=i.map((c,u)=>e==="cframe"?n[u]:n[c]);if(!d.every(c=>typeof c=="number"&&Number.isFinite(c))||e==="color3"&&d.some(c=>c<0||c>1))return;if(e==="cframe"){const c=d,u=(m,_)=>c[m]*c[_]+c[m+1]*c[_+1]+c[m+2]*c[_+2],y=c[3]*(c[7]*c[11]-c[8]*c[10])-c[4]*(c[6]*c[11]-c[8]*c[9])+c[5]*(c[6]*c[10]-c[7]*c[9]);if([3,6,9].some(m=>Math.abs(u(m,m)-1)>1e-5)||[[3,6],[3,9],[6,9]].some(([m,_])=>Math.abs(u(m,_))>1e-5)||Math.abs(y-1)>1e-5)return}return n}catch{return}}function st(e){if(e===void 0)return"—";if(typeof e=="string")return e.replace(/^Enum\.[^.]+\./,"");if(e&&typeof e=="object"&&!Array.isArray(e)){const a="x"in e?["x","y","z"]:"r"in e?["r","g","b"]:[];if(a.length===3&&a.every(n=>typeof e[n]=="number"))return a.map(n=>`${n.toUpperCase()} ${Number(e[n].toPrecision(6))}`).join(" · ")}return JSON.stringify(e)}function ht(e){const a=o.useRef(!1),n=Ft(e.type);let i={};try{i=JSON.parse(e.draft)??{}}catch{}const d=n.map((m,_)=>{const C=e.type==="cframe"?i[_]:i[m];return C==null?"":String(C)}),c=(m,_)=>{const k=d.map((x,f)=>f===m?_:x).map(x=>x.trim()!==""&&!/[.eE+-]$/.test(x)&&Number.isFinite(Number(x))?Number(x):x);e.onChange(JSON.stringify(e.type==="cframe"?k:Object.fromEntries(n.map((x,f)=>[x,k[f]]))))},u=_t(e.type,e.draft),y=u&&!Array.isArray(u)&&typeof u=="object"?`#${["r","g","b"].map(m=>Math.round(Number(u[m])*255).toString(16).padStart(2,"0")).join("")}`:"#000000";return t.jsxs("div",{className:s.compoundEditor,role:"group","aria-label":e.label,onFocus:()=>{var m;return(m=e.onFocusChange)==null?void 0:m.call(e,!0)},onBlur:m=>{var _,C;m.currentTarget.contains(m.relatedTarget)||((_=e.onFocusChange)==null||_.call(e,!1),a.current||(C=e.onCommit)==null||C.call(e))},onCompositionStart:()=>{a.current=!0},onCompositionEnd:()=>{a.current=!1},onKeyDown:m=>{var _;m.key==="Enter"&&!m.nativeEvent.isComposing&&!a.current&&((_=e.onCommit)==null||_.call(e))},children:[e.type==="color3"&&t.jsx("input",{className:s.colorSwatch,type:"color",value:y,disabled:e.disabled,"aria-label":`${e.label} RGB`,"aria-describedby":e.describedBy,onChange:m=>{const _=m.target.value.slice(1);e.onChange(JSON.stringify({r:parseInt(_.slice(0,2),16)/255,g:parseInt(_.slice(2,4),16)/255,b:parseInt(_.slice(4,6),16)/255}))}}),t.jsx("div",{className:s.compoundCoordinates,children:n.map((m,_)=>t.jsxs("label",{children:[t.jsxs("span",{children:[m.toUpperCase(),e.type==="color3"?" (0–1)":""]}),t.jsx("input",{inputMode:"decimal",value:d[_],disabled:e.disabled,"aria-label":`${e.label} ${m.toUpperCase()}`,"aria-describedby":e.describedBy,"aria-invalid":e.draft!==""&&u===void 0||void 0,onChange:C=>c(_,C.target.value)})]},m))})]})}function Ae(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function To(e,a,n){const i=n!=null&&n.fresh?n.observed:n==null?void 0:n.lastObserved,d=(a==null?void 0:a.draft)??i??e.value;return d===void 0?"":Ae(d)}function He(e,a){var n;if(Ge(e.valueType))return _t(e.valueType,a);if(e.valueType==="number"){if(a.trim()==="")return;const i=Number(a);return Number.isFinite(i)?i:void 0}return e.valueType==="boolean"?a==="true":e.valueType==="enum"?((n=e.enumValues)==null?void 0:n.find(i=>Ae(i)===a))??a:a}function Be(e){return e&&typeof e=="object"&&!Array.isArray(e)?`object:${Object.keys(e).sort().map(a=>`${JSON.stringify(a)}:${Be(e[a])}`).join(",")}`:`${typeof e}:${JSON.stringify(e)}`}function Ue(e){var a;return e.value!==void 0?Ae(e.value):e.valueType==="boolean"?"false":e.valueType==="enum"?Ae((a=e.enumValues)==null?void 0:a[0]):""}function Lo(e){var i;const{t:a}=ue();if(!e.profile||e.profile.controls.length===0)return t.jsx("div",{className:s.panelEmpty,children:a("playtest.controls.empty","No test controls in this profile yet.")});const n=((i=e.profile.settings)==null?void 0:i.runtimeApplyMode)??"manual";return t.jsx("div",{className:s.liveRows,children:e.profile.controls.map(d=>{var c,u,y;return t.jsx(Mo,{control:d,active:e.active,inactiveReason:e.inactiveReason,profileSaveLocked:e.profileSaveLocked,runtimeApplyMode:n,state:e.states[d.id],watch:e.watches[`control:${d.id}`],presentation:(u=(c=e.profile)==null?void 0:c.presentation)==null?void 0:u[d.id],draftState:(y=e.drafts)==null?void 0:y[d.id],onDraftChange:e.onDraftChange,onApply:e.onApply,onSaveValue:e.onSaveValue,onRemoveValue:e.onRemoveValue},`${e.draftScope??"profile"}:${d.id}`)})})}function Mo(e){var ie,Ne,ve,_e,xe,Ce,be,fe,Re,p,j,F,v,S,A,N,G,l,r,g,D;const{t:a}=ue(),n=To(e.control,e.state,e.watch),[i,d]=o.useState(n),[c,u]=o.useState(!1),[y,m]=o.useState("idle"),[_,C]=o.useState(null),[k,x]=o.useState(()=>Ue(e.control)),[f,V]=o.useState(e.control.value),[R,M]=o.useState(null),[w,B]=o.useState(!1),P=o.useRef(null),E=o.useRef(!1),W=o.useRef(!1),$=o.useRef(null),ee=((ie=e.draftState)==null?void 0:ie.value)??i,te=((Ne=e.draftState)==null?void 0:Ne.dirty)??c;o.useEffect(()=>{d(n),u(!1),x(Ue(e.control)),V(e.control.value),M(null),C(null),$.current=null},[e.control.id]),o.useEffect(()=>{x(Ue(e.control)),V(e.control.value)},[e.control.value]),o.useEffect(()=>{!e.draftState&&!te&&!E.current&&d(n)},[te,n,e.draftState]),o.useEffect(()=>{var h,b,T;(((h=e.state)==null?void 0:h.status)==="error"||((b=e.state)==null?void 0:b.status)==="conflict"||((T=e.state)==null?void 0:T.status)==="requires_adapter")&&($.current=null)},[(ve=e.state)==null?void 0:ve.status]);const q=()=>He(e.control,ee),O=h=>{if(!e.active||W.current)return;const b=h??q();if(b===void 0)return;const T=Be(b);$.current!==T&&($.current=T,e.onApply(e.control.id,b))},z=h=>{var T;d(h),u(!0),(T=e.onDraftChange)==null||T.call(e,e.control.id,h,!0);const b=He(e.control,h);(b===void 0||Be(b)!==$.current)&&($.current=null)},U=async()=>{const h=He(e.control,k);if(!(h===void 0||!e.onSaveValue||e.profileSaveLocked||y!=="idle")){m("saving"),C(null),M(null);try{await e.onSaveValue(e.control.id,h,e.control.applyOnStart??!1),V(h),M({state:"saved",value:Ae(h)})}catch(b){C(b instanceof Error?b.message:String(b))}finally{m("idle")}}},L=async()=>{if(!(f===void 0||!e.onRemoveValue||e.profileSaveLocked||y!=="idle")){m("removing"),C(null),M(null);try{await e.onRemoveValue(e.control.id),x(Ue({...e.control,value:void 0})),V(void 0),M({state:"removed"})}catch(h){C(h instanceof Error?h.message:String(h))}finally{m("idle")}}},ae=a("playtest.controls.inputLabel","Input value for {{label}}").replace("{{label}}",e.control.label),J=e.active?void 0:"playtest-controls-availability",le=e.inactiveReason??a("playtest.values.playRequired","Start Play in Studio to change test values."),Q=e.control.valueType==="number"&&((_e=e.control.constraints)==null?void 0:_e.minimum)!==void 0&&((xe=e.control.constraints)==null?void 0:xe.maximum)!==void 0,K=(Ce=e.watch)!=null&&Ce.fresh?e.watch.observed:(be=e.watch)==null?void 0:be.lastObserved,Z=(fe=e.watch)!=null&&fe.fresh?a("playtest.controls.currentObserved","Current value"):K!==void 0?a("playtest.watch.lastObserved","Last observed"):a("playtest.watch.notObserved","Not observed yet"),X=((Re=e.state)==null?void 0:Re.status)??"idle",he=e.control.origin?`ServerStorage.WeppyTestAdapters.${e.control.origin.adapter}`:e.control.path?[e.control.path.root,...e.control.path.segments].join("."):"adapter",re=e.runtimeApplyMode==="auto",oe=q(),ye=X==="applying"||X==="pending_resume",we=!re&&e.active&&te&&oe!==void 0&&K!==void 0&&Be(oe)!==Be(K)&&Be(oe)!==$.current&&!ye,H=f===void 0?a("playtest.controls.noSavedValue","No saved default"):Ae(f),se=a("playtest.controls.defaultInputLabel","Saved default for {{label}}").replace("{{label}}",e.control.label);let ne;Ge(e.control.valueType)?ne=t.jsx(ht,{type:e.control.valueType,draft:ee,label:ae,disabled:!e.active,describedBy:J,onChange:z,onFocusChange:h=>{E.current=h},onCommit:()=>{re&&O()}}):e.control.valueType==="boolean"?ne=t.jsxs("label",{className:s.booleanEditor,children:[t.jsx("input",{type:"checkbox",checked:ee==="true",disabled:!e.active,"aria-label":ae,"aria-describedby":J,onFocus:()=>{E.current=!0},onBlur:()=>{E.current=!1},onChange:h=>{const b=h.target.checked;z(String(b)),re&&O(b)}}),t.jsx("span",{children:ee==="true"?a("common.true","True"):a("common.false","False")})]}):e.control.valueType==="enum"?ne=t.jsx("select",{"aria-label":ae,"aria-describedby":J,value:ee,disabled:!e.active,onFocus:()=>{E.current=!0},onBlur:()=>{E.current=!1},onChange:h=>{z(h.target.value);const b=He(e.control,h.target.value);re&&b!==void 0&&O(b)},children:(e.control.enumValues??[]).map(h=>t.jsx("option",{value:Ae(h),children:st(h)},Ae(h)))}):Q?ne=t.jsxs("div",{className:s.rangeEditor,children:[t.jsx("input",{type:"range",value:ee||String(((p=e.control.constraints)==null?void 0:p.minimum)??0),min:(j=e.control.constraints)==null?void 0:j.minimum,max:(F=e.control.constraints)==null?void 0:F.maximum,step:((v=e.control.constraints)==null?void 0:v.step)??1,disabled:!e.active,"aria-label":ae,"aria-describedby":J,onFocus:()=>{E.current=!0},onBlur:()=>{E.current=!1},onChange:h=>z(h.target.value),onPointerUp:()=>{re&&O()},onKeyUp:h=>{re&&(h.key.startsWith("Arrow")||h.key==="Home"||h.key==="End")&&O()}}),t.jsx("output",{children:ee||"—"})]}):ne=t.jsx("input",{value:ee,disabled:!e.active,inputMode:e.control.valueType==="number"?"decimal":void 0,onFocus:()=>{E.current=!0},onChange:h=>z(h.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:h=>{re&&h.key==="Enter"&&!h.nativeEvent.isComposing&&O()},onBlur:()=>{E.current=!1,re&&O()},"aria-label":ae,"aria-describedby":J});let ce;return Ge(e.control.valueType)?ce=t.jsx(ht,{type:e.control.valueType,draft:k,label:se,disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle",onChange:h=>{x(h),M(null),C(null)}}):e.control.valueType==="boolean"?ce=t.jsxs("label",{className:s.defaultBooleanEditor,children:[t.jsx("input",{type:"checkbox",checked:k==="true",disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle","aria-label":se,onChange:h=>{x(String(h.target.checked)),M(null),C(null)}}),t.jsx("span",{children:k==="true"?a("common.true","True"):a("common.false","False")})]}):e.control.valueType==="enum"?ce=t.jsx("select",{value:k,disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle","aria-label":se,onChange:h=>{x(h.target.value),M(null),C(null)},children:(e.control.enumValues??[]).map(h=>t.jsx("option",{value:Ae(h),children:st(h)},Ae(h)))}):ce=t.jsx("input",{type:e.control.valueType==="number"?"number":"text",value:k,min:(S=e.control.constraints)==null?void 0:S.minimum,max:(A=e.control.constraints)==null?void 0:A.maximum,step:(N=e.control.constraints)==null?void 0:N.step,disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle","aria-label":se,onChange:h=>{x(h.target.value),M(null),C(null)}}),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.controlRow,children:[t.jsxs("div",{className:s.rowIdentity,children:[t.jsx("strong",{children:e.control.label}),(((G=e.presentation)==null?void 0:G.pinned)||((l=e.presentation)==null?void 0:l.group))&&t.jsxs("span",{className:s.presentationMeta,children:[e.presentation.pinned?a("playtest.values.pinned","Pinned"):"",e.presentation.pinned&&e.presentation.group?" · ":"",e.presentation.group??""]}),t.jsx("button",{ref:P,type:"button",className:s.valueDetailButton,"aria-label":a("playtest.values.detailsFor","Value details for {{label}}").replace("{{label}}",e.control.label),onClick:()=>{x(Ue({...e.control,value:f})),M(null),C(null),B(!0)},children:a("playtest.values.viewDetails","View details")})]}),t.jsxs("div",{className:s.actualValue,"aria-label":`${Z} ${Ae(K)}`,children:[t.jsx("span",{children:Z}),t.jsx("strong",{children:st(K)})]}),t.jsxs("div",{className:s.controlEditor,children:[t.jsxs("div",{className:s.editorHeading,children:[t.jsx("span",{className:s.editorLabel,children:a("playtest.controls.inputValue","Input value")}),t.jsxs("span",{className:s.savedValueState,title:H,"aria-label":a("playtest.controls.savedDefaultState","Saved default for {{label}}: {{value}}").replace("{{label}}",e.control.label).replace("{{value}}",H),children:[a("playtest.controls.defaultValue","Saved default")," ",t.jsx("strong",{children:H})]})]}),t.jsxs("div",{className:s.controlEditorRow,children:[t.jsx(Oe,{active:e.active,label:`${e.control.label} input`,reason:le,children:ne}),t.jsx("div",{className:s.controlActions,children:t.jsx(Oe,{active:e.active,label:`${e.control.label} apply`,reason:le,children:t.jsx("button",{type:"button",className:s.secondaryAction,disabled:!we,"aria-label":a("playtest.controls.applyLabel","Apply the input value for {{label}}").replace("{{label}}",e.control.label),onClick:()=>O(),children:a("playtest.controls.applyRuntime","Apply manually")})})})]}),t.jsx("span",{className:s.rowFeedback,"data-state":_?"error":X,"aria-live":"polite",children:_??(X==="applying"?a("playtest.controls.applying","Applying…"):X==="pending_resume"?a("playtest.controls.pendingResume","Apply on resume"):X==="applied"?a("playtest.controls.applied","Applied · readback {{value}}").replace("{{value}}",Ae((r=e.state)==null?void 0:r.observed)):X==="conflict"?a("playtest.controls.conflict","Conflict · reload the current revision"):X==="requires_adapter"?a("playtest.controls.requiresAdapter","Requires reviewed adapter"):X==="error"?((g=e.state)==null?void 0:g.message)??a("playtest.controls.applyFailed","Apply failed"):e.active?re?a("playtest.controls.autoApplyReady","Changes apply automatically when the input is confirmed"):a("playtest.controls.readyToApply","Input value is ready to apply or save as the default"):" ")})]})]}),t.jsx(bt,{open:w,title:e.control.label,description:a("playtest.controls.details","Value details"),ariaLabel:a("playtest.values.detailsDialog","{{label}} value details").replace("{{label}}",e.control.label),closeLabel:a("common.close","Close"),returnFocusTo:P.current,onClose:()=>B(!1),items:[{label:Z,value:Ae(K)},{label:a("playtest.controls.defaultValue","Saved default"),value:t.jsx("div",{className:s.defaultValueEditor,children:ce})},{label:a("playtest.controls.originalValue","Original runtime value"),value:Ae((D=e.state)==null?void 0:D.original)},{label:a("playtest.controls.registration","Registration"),value:`${e.control.target.role} · ${e.control.access.kind}`},{label:a("playtest.values.location","Location"),value:he},{label:a("playtest.values.valueType","Value type"),value:e.control.valueType}],error:_,feedback:(R==null?void 0:R.state)==="saved"?{state:"success",message:a("playtest.controls.defaultSavedFeedback","Saved default {{value}} · Saved").replace("{{value}}",R.value??"")}:(R==null?void 0:R.state)==="removed"?{state:"success",message:a("playtest.controls.defaultRemovedFeedback","No saved default · Removed")}:null,actions:[{label:y==="removing"?a("playtest.controls.removingDefault","Removing…"):a("playtest.controls.removeDefault","Remove default"),accessibleLabel:a("playtest.controls.removeDefaultLabel","Remove saved default for {{label}}").replace("{{label}}",e.control.label),disabled:f===void 0||!e.onRemoveValue||e.profileSaveLocked||y!=="idle",variant:"secondary",onClick:()=>void L()},{label:y==="saving"?a("playtest.profile.saving","Saving…"):a("playtest.controls.saveDefault","Save default"),accessibleLabel:a("playtest.controls.saveLabel","Save default for {{label}}").replace("{{label}}",e.control.label),disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle"||He(e.control,k)===void 0,onClick:()=>void U()}]})]})}function Ze(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function $o(e){var C;const{t:a}=ue(),n=[...((C=e.profile)==null?void 0:C.watches.map(k=>({...k,subscriptionId:`watch:${k.id}`})))??[]],[i,d]=o.useState(null),c=o.useRef(null);if(n.length===0)return t.jsx("div",{className:s.panelEmpty,children:a("playtest.watch.empty","Observed values appear here during Play.")});const u=n.find(k=>k.id===i),y=u?e.watches[u.subscriptionId]:void 0,m=y!=null&&y.fresh?y.observed:y==null?void 0:y.lastObserved,_=u!=null&&u.path?[u.path.root,...u.path.segments].join("."):(u==null?void 0:u.access.adapter)??"adapter";return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:s.watchRows,children:n.map(k=>{var M,w;const x=e.watches[k.subscriptionId],f=(w=(M=e.profile)==null?void 0:M.presentation)==null?void 0:w[k.id],V=x!=null&&x.fresh?x.observed:x==null?void 0:x.lastObserved,R=x!=null&&x.fresh?a("playtest.watch.currentValue","Current value"):V!==void 0?a("playtest.watch.lastObserved","Last observed"):a("playtest.watch.notObserved","Not observed yet");return t.jsxs("div",{className:s.watchRow,"data-value-type":k.valueType,children:[t.jsxs("div",{className:s.watchCardMain,children:[t.jsx("strong",{children:k.label}),((f==null?void 0:f.pinned)||(f==null?void 0:f.group))&&t.jsxs("span",{className:s.presentationMeta,children:[f.pinned?a("playtest.values.pinned","Pinned"):"",f.pinned&&f.group?" · ":"",f.group??""]}),t.jsx("button",{type:"button",className:s.valueDetailButton,"aria-label":a("playtest.values.detailsFor","Value details for {{label}}").replace("{{label}}",k.label),onClick:B=>{c.current=B.currentTarget,d(k.id)},children:a("playtest.values.viewDetails","View details")})]}),t.jsxs("div",{className:s.watchReading,children:[!(x!=null&&x.fresh)&&t.jsx("span",{children:R}),t.jsx("strong",{title:Ze(V),"aria-label":`${R} ${Ze(V)}`,children:Ze(V)})]}),x&&x.status!=="fresh"&&t.jsx("span",{className:s.freshness,"data-status":x.status,children:(x==null?void 0:x.status)==="stale"?a("playtest.watch.stale","Stale"):a("playtest.watch.unavailable","Unavailable")})]},k.subscriptionId)})}),u&&t.jsx(bt,{open:i!==null,title:u.label,description:a("playtest.watch.details","Observation details"),ariaLabel:a("playtest.values.detailsDialog","{{label}} value details").replace("{{label}}",u.label),closeLabel:a("common.close","Close"),returnFocusTo:c.current,onClose:()=>d(null),items:[{label:a("playtest.watch.registration","Registration"),value:`${u.target.role} · ${u.access.kind}`},{label:a("playtest.values.location","Location"),value:_},{label:a("playtest.values.valueType","Value type"),value:u.valueType},{label:y!=null&&y.fresh?a("playtest.watch.currentValue","Current value"):m!==void 0?a("playtest.watch.lastObserved","Last observed"):a("playtest.watch.notObserved","Not observed yet"),value:Ze(m)},...y!=null&&y.observedAtMs?[{label:a("playtest.watch.observedAt","Observed at"),value:t.jsx("time",{children:new Date(y.observedAtMs).toLocaleTimeString()})}]:[]]})]})}function nt(e,a){return Object.prototype.hasOwnProperty.call(e,a)}function Vo(e,a){var n;if(e.type==="string")return typeof a=="string"?a:void 0;if(e.type==="boolean")return typeof a=="boolean"?a:void 0;if(e.type==="number"||e.type==="integer"){const i=typeof a=="number"?a:typeof a=="string"&&a.trim()!==""?Number(a):NaN;return Number.isFinite(i)?i:void 0}return(n=e.enumValues)==null?void 0:n.find(i=>i===a)}function Oo(e,a){if(e.type==="integer"&&!Number.isInteger(a))return"Enter a whole number.";if(typeof a=="number"){if(e.minimum!==void 0&&a<e.minimum)return`Enter ${e.minimum} or more.`;if(e.maximum!==void 0&&a>e.maximum)return`Enter ${e.maximum} or less.`}if(typeof a=="string"){if(e.minLength!==void 0&&a.length<e.minLength)return`Enter at least ${e.minLength} characters.`;if(e.maxLength!==void 0&&a.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}return null}function Gt(e){return Object.fromEntries(e.parameters.map(a=>[a.name,e.defaultArguments&&nt(e.defaultArguments,a.name)?e.defaultArguments[a.name]:a.defaultValue]))}function kt(e,a){const n={},i=new Set(e.parameters.map(c=>c.name));for(const c of Object.keys(a))nt(e.fixedArguments,c)?n[c]="This argument is fixed and cannot be changed.":i.has(c)||(n[c]="This argument is not declared.");const d=structuredClone(e.fixedArguments);for(const c of[...e.parameters].sort((u,y)=>u.order-y.order)){const u=nt(a,c.name)?a[c.name]:e.defaultArguments&&nt(e.defaultArguments,c.name)?e.defaultArguments[c.name]:c.defaultValue;if(u===void 0){c.required&&(n[c.name]="This value is required.");continue}const y=Vo(c,u);if(y===void 0){n[c.name]=c.type==="enum"?"Choose one of the available values.":"Enter a valid value.";continue}const m=Oo(c,y);m?n[c.name]=m:d[c.name]=y}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,arguments:d}}function At(e){const{t:a}=ue();return t.jsx("div",{className:s.actionParameterGrid,children:[...e.action.parameters].sort((n,i)=>n.order-i.order).map(n=>{var m,_;const i=(m=e.errors)==null?void 0:m[n.name],d=`playtest-action-${e.action.id}-${n.name}-error`,c=e.draft[n.name],u=`${n.label}${n.unit?` (${n.unit})`:""}`;let y;if(n.type==="boolean")y=t.jsx("input",{type:"checkbox","aria-label":u,checked:c===!0,disabled:e.disabled,"aria-invalid":!!i,"aria-describedby":i?d:void 0,onChange:C=>e.onChange(n.name,C.target.checked)});else if(n.type==="enum"){const C=((_=n.enumValues)==null?void 0:_.findIndex(k=>k===c))??-1;y=t.jsxs("select",{"aria-label":u,value:C<0?"":String(C),disabled:e.disabled,"aria-invalid":!!i,"aria-describedby":i?d:void 0,onChange:k=>{var f;const x=Number(k.target.value);e.onChange(n.name,Number.isInteger(x)?(f=n.enumValues)==null?void 0:f[x]:void 0)},children:[t.jsx("option",{value:"",children:n.required?a("playtest.actions.chooseValue","Choose a value"):a("playtest.actions.omitValue","Do not use")}),(n.enumValues??[]).map((k,x)=>t.jsx("option",{value:x,children:String(k)},`${x}:${String(k)}`))]})}else y=t.jsx("input",{type:n.type==="string"?"text":"number",inputMode:n.type==="string"?void 0:"decimal",step:n.type==="integer"?1:"any",min:n.minimum,max:n.maximum,minLength:n.minLength,maxLength:n.maxLength,"aria-label":u,"aria-invalid":!!i,"aria-describedby":i?d:void 0,disabled:e.disabled,value:typeof c=="string"||typeof c=="number"?String(c):"",onChange:C=>e.onChange(n.name,C.target.value)});return t.jsxs("label",{className:s.actionParameter,children:[t.jsxs("span",{children:[u,n.required?" *":""]}),y,n.description&&t.jsx("small",{children:n.description}),i&&t.jsx("small",{id:d,className:s.actionParameterError,role:"alert",children:i})]},n.name)})})}function ot(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function Bo(e){var P,E,W,$,ee,te;const{t:a}=ue(),[n,i]=o.useState(!1),[d,c]=o.useState({}),u=o.useRef(null),y=e.draft??Gt(e.action),m=o.useMemo(()=>[...e.action.parameters].sort((q,O)=>q.order-O.order),[e.action.parameters]),_=kt(e.action,y),C=((P=e.state)==null?void 0:P.status)??"idle",k=C==="running",x=e.inactiveReason??a("playtest.actions.playRequired","Start Studio Play before running this action."),f=m.length===0?a("playtest.actions.noParameters","No input required"):m.map(q=>`${q.label}: ${ot(y[q.name])}`).join(" · "),V=Object.entries(e.action.fixedArguments).map(([q,O])=>`${q}: ${ot(O)}`).join(" · "),R=C==="running"?a("playtest.actions.running","Running…"):C==="succeeded"?a("playtest.actions.succeeded","Succeeded"):C==="failed"?((W=(E=e.state)==null?void 0:E.error)==null?void 0:W.message)??a("playtest.actions.failed","Failed"):C==="unknown"?a("playtest.actions.unknown","Result unknown"):" ",M=(q,O)=>{const z={...y,[q]:O};c(U=>{const L={...U};return delete L[q],L}),e.onDraftChange(e.action.id,z)},w=()=>{const q=kt(e.action,y);if(!q.ok){c(q.errors);return}e.onExecute(e.action.id,structuredClone(q.arguments))},B=()=>{if(!_.ok){c(_.errors);return}const q=new Set(e.action.parameters.map(O=>O.name));e.onSaveDefaults(e.action.id,Object.fromEntries(Object.entries(_.arguments).filter(([O])=>q.has(O))))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.actionRow,"data-state":C,children:[t.jsxs("div",{className:s.rowIdentity,children:[t.jsx("strong",{children:e.action.label}),e.action.description&&t.jsx("span",{children:e.action.description}),((($=e.presentation)==null?void 0:$.pinned)||((ee=e.presentation)==null?void 0:ee.group))&&t.jsxs("span",{className:s.presentationMeta,children:[e.presentation.pinned?a("playtest.values.pinned","Pinned"):"",e.presentation.pinned&&e.presentation.group?" · ":"",e.presentation.group??""]}),m.length>1&&t.jsx("button",{ref:u,type:"button",className:s.valueDetailButton,"aria-label":a("playtest.actions.settingsFor","Execution settings for {{label}}").replace("{{label}}",e.action.label),onClick:()=>i(!0),children:a("playtest.actions.settings","Execution settings")})]}),t.jsxs("div",{className:s.actionSummary,children:[t.jsx("span",{children:a("playtest.actions.parameters","Parameters")}),t.jsx("strong",{children:f})]}),t.jsxs("div",{className:s.actionExecution,children:[m.length===1&&t.jsx(At,{action:e.action,draft:y,errors:d,disabled:k,onChange:M}),t.jsx(Oe,{active:e.active,label:e.action.label,reason:x,children:t.jsx("button",{type:"button",className:s.primaryAction,"aria-label":a("playtest.actions.runLabel","Run {{label}}").replace("{{label}}",e.action.label),disabled:!e.active||k,onClick:w,children:k?a("playtest.actions.running","Running…"):a("playtest.actions.run","Run")})}),t.jsx("span",{className:s.rowFeedback,"data-state":C,"aria-live":"polite",children:R}),!e.active&&t.jsx("span",{className:s.actionInactiveReason,children:x})]})]}),t.jsx(bt,{open:n,title:e.action.label,description:a("playtest.actions.settings","Execution settings"),ariaLabel:a("playtest.actions.settingsDialog","{{label}} execution settings").replace("{{label}}",e.action.label),closeLabel:a("common.close","Close"),returnFocusTo:u.current,onClose:()=>i(!1),items:[{label:a("playtest.actions.parameters","Parameters"),value:t.jsx(At,{action:e.action,draft:y,errors:d,disabled:k,onChange:M})},{label:a("playtest.actions.fixedArguments","Fixed arguments"),value:V||"—"},{label:a("playtest.actions.lastResult","Last result"),value:((te=e.state)==null?void 0:te.result)===void 0?R.trim()||"—":ot(e.state.result)}],actions:[{label:a("playtest.actions.saveDefaults","Save default inputs"),accessibleLabel:a("playtest.actions.saveDefaultsFor","Save default inputs for {{label}}").replace("{{label}}",e.action.label),variant:"secondary",disabled:k||!_.ok,onClick:B}]})]})}function Fo(e,a,n,i){const d=e.indexOf(a),c=e.indexOf(n);if(d<0||c<0||a===n)return[...e];const u=e.filter(_=>_!==a),y=u.indexOf(n),m=i==="after"?y+1:y;return u.splice(m,0,a),u}const Et=["watches","controls","actions"];function Go(e,a){const n="path"in e&&e.path?[e.path.root,...e.path.segments].join("."):"",i="access"in e?e.access.adapter:e.executor.kind==="adapter"?e.executor.adapter:"",d="access"in e?e.access.name:e.executor.kind;return[e.id,e.label,a,n,i,d].filter(Boolean).join(" ").toLocaleLowerCase()}function qo(e,a){if(a.kind==="action")return"unobserved";const n=e.watches[`${a.kind}:${a.binding.id}`];return(n==null?void 0:n.status)??"unobserved"}function Ho(e){var j,F,v,S,A,N,G,l;const{t:a}=ue(),[n,i]=o.useState(""),[d,c]=o.useState("all"),[u,y]=o.useState("all"),[m,_]=o.useState("all"),[C,k]=o.useState(new Set),[x,f]=o.useState(0),[V,R]=o.useState(50),[M,w]=o.useState(!1),[B,P]=o.useState(((F=(j=e.live.profile)==null?void 0:j.sectionOrder)==null?void 0:F.length)===3?e.live.profile.sectionOrder:Et),[E,W]=o.useState(null),[$,ee]=o.useState(null),[te,q]=o.useState(null),[O,z]=o.useState(!1),[U,L]=o.useState(!1),[ae,J]=o.useState(""),[le,Q]=o.useState(null),[K,Z]=o.useState(()=>{var r;return((r=e.live.profile)==null?void 0:r.presentation)??{}}),[X,he]=o.useState({}),[re,oe]=o.useState({}),[ye,we]=o.useState(()=>{var r;return((r=e.live.profile)==null?void 0:r.settings)??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"}}),H=e.live.profile,se=a("playtest.values.ungrouped","Ungrouped");o.useEffect(()=>{var r,g,D;P(((g=(r=e.live.profile)==null?void 0:r.sectionOrder)==null?void 0:g.length)===3?e.live.profile.sectionOrder:Et),Z(((D=e.live.profile)==null?void 0:D.presentation)??{}),z(!1)},[(v=e.live.profile)==null?void 0:v.id,(S=e.live.profile)==null?void 0:S.presentation,(A=e.live.profile)==null?void 0:A.sectionOrder]),o.useEffect(()=>{var r;we(((r=e.live.profile)==null?void 0:r.settings)??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"})},[(N=e.live.profile)==null?void 0:N.id,(G=e.live.profile)==null?void 0:G.settings]);const ne=o.useMemo(()=>{if(!H)return{entries:[],total:0,pages:1,safePage:0,groups:[]};const r=[...H.controls.map((I,Y)=>({kind:"control",binding:I,sourceOrder:Y})),...H.watches.map((I,Y)=>({kind:"watch",binding:I,sourceOrder:H.controls.length+Y})),...(H.actions??[]).map((I,Y)=>({kind:"action",binding:I,sourceOrder:H.controls.length+H.watches.length+Y}))],g=Array.from(new Set(r.map(I=>{var Y;return((Y=K[I.binding.id])==null?void 0:Y.group)??se}))).sort((I,Y)=>I.localeCompare(Y)),D=n.trim().toLocaleLowerCase(),h=r.filter(I=>{var de;const Y=((de=K[I.binding.id])==null?void 0:de.group)??se;return(d==="all"||I.kind===d)&&(m==="all"||Y===m)&&(u==="all"||I.kind==="action"||qo(e.live,I)===u)&&(!D||Go(I.binding,Y).includes(D))}).sort((I,Y)=>{if(I.kind!==Y.kind){const Pe=Ie=>Ie==="watch"?"watches":Ie==="control"?"controls":"actions";return B.indexOf(Pe(I.kind))-B.indexOf(Pe(Y.kind))}const de=K[I.binding.id],je=K[Y.binding.id];return!!(de!=null&&de.pinned)!=!!(je!=null&&je.pinned)?de!=null&&de.pinned?-1:1:((de==null?void 0:de.order)??I.sourceOrder)-((je==null?void 0:je.order)??Y.sourceOrder)}),b=Math.max(1,Math.ceil(h.length/V)),T=Math.min(x,b-1);return{entries:h.slice(T*V,(T+1)*V),total:h.length,pages:b,safePage:T,groups:g}},[m,d,u,x,V,K,H,e.live,n,B,se]),ce=((H==null?void 0:H.controls.length)??0)+((H==null?void 0:H.watches.length)??0)+(((l=H==null?void 0:H.actions)==null?void 0:l.length)??0),ie=n.trim()!==""||d!=="all"||u!=="all"||m!=="all",Ne={watches:a("playtest.values.observedSection","Observed values"),controls:a("playtest.values.changeSection","Change values"),actions:a("playtest.actions.section","Actions")},ve=async r=>{q(null);try{await e.live.saveProfileMetadata(r)}catch(g){throw q(g instanceof Error?g.message:a("playtest.values.layoutSaveFailed","Could not save the display order")),g}},_e=r=>{we(r),ve({settings:r}).catch(()=>we((H==null?void 0:H.settings)??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"}))},xe=r=>{if(!O||U||!B.includes(r))return;const g=B,D=B.indexOf(r),h=D===0?1:D-1,b=[...B];[b[D],b[h]]=[b[h],b[D]];const T=b;P(T),L(!0),ve({sectionOrder:T}).then(()=>J(a("playtest.values.layoutSaved","Display order saved"))).catch(()=>P(g)).finally(()=>L(!1))},Ce=r=>ne.entries.filter(g=>g.kind===r),be=(r,g,D,h)=>{var Pe,Ie,Me;if(!H||!O||U)return;const b=K,T=g.map(Se=>Se.binding.id),I=Fo(T,r.binding.id,D,h);if(T.every((Se,ke)=>Se===I[ke]))return;const Y={...K},de=g.map(Se=>{var ke;return((ke=K[Se.binding.id])==null?void 0:ke.order)??Se.sourceOrder}).sort((Se,ke)=>Se-ke);for(const[Se,ke]of I.entries())Y[ke]={order:de[Se],pinned:((Pe=K[ke])==null?void 0:Pe.pinned)??!1,...(Ie=K[ke])!=null&&Ie.group?{group:(Me=K[ke])==null?void 0:Me.group}:{}};Z(Y),L(!0);const je=I.indexOf(r.binding.id)+1;ve({presentation:Y}).then(()=>J(a("playtest.values.movedTo","{{label}} moved to position {{position}}").replace("{{label}}",r.binding.label).replace("{{position}}",String(je)))).catch(()=>Z(b)).finally(()=>L(!1))},fe=r=>k(g=>{const D=new Set(g);return D.has(r)?D.delete(r):D.add(r),D}),Re=(r,g)=>{var Ie,Me,Se,ke;const D=((Ie=K[r.binding.id])==null?void 0:Ie.group)??se,h=((Me=K[r.binding.id])==null?void 0:Me.pinned)??!1,b=g.filter(pe=>{var ge,Le;return(((ge=K[pe.binding.id])==null?void 0:ge.group)??se)===D&&(((Le=K[pe.binding.id])==null?void 0:Le.pinned)??!1)===h}),T=b.findIndex(pe=>pe.binding.id===r.binding.id),I=pe=>a(pe==="previous"?"playtest.values.movePrevious":"playtest.values.moveNext",`Move {{label}} ${pe}`).replace("{{label}}",r.binding.label),Y=a("playtest.values.drag","Drag {{label}} to reorder").replace("{{label}}",r.binding.label),de=e.active&&(e.live.studioMode!=="run"||r.binding.target.role==="server"),je=e.live.studioMode==="run"&&r.binding.target.role==="client"?a("playtest.controls.playModeRequired","Client test values are available in Play."):e.inactiveReason,Pe=`${H.id}:${((Se=e.live.lease)==null?void 0:Se.leaseId)??"edit"}:${r.binding.id}`;return t.jsxs("div",{className:s.valueEntryShell,"data-layout-editing":O,"data-drop-position":(le==null?void 0:le.id)===r.binding.id?le.placement:void 0,onDragOver:pe=>{if((E==null?void 0:E.kind)!==r.kind||!b.some(Ht=>Ht.binding.id===E.id))return;pe.preventDefault();const ge=pe.currentTarget.getBoundingClientRect(),lt=r.kind==="watch"?pe.clientX>=ge.left+ge.width/2?"after":"before":pe.clientY>=ge.top+ge.height/2?"after":"before";Q({id:r.binding.id,placement:lt})},onDrop:pe=>{if(pe.preventDefault(),(E==null?void 0:E.kind)===r.kind&&E.id!==r.binding.id&&(le==null?void 0:le.id)===r.binding.id){const ge=b.find(Le=>Le.binding.id===E.id);ge&&be(ge,b,r.binding.id,le.placement)}W(null),Q(null)},children:[O&&t.jsxs("div",{className:s.valueReorderControls,children:[t.jsx("button",{type:"button",className:s.dragHandle,draggable:!0,"aria-label":Y,disabled:U,onDragStart:()=>W({kind:r.kind,id:r.binding.id}),onDragEnd:()=>{W(null),Q(null)},children:t.jsx(wt,{size:14,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":I("previous"),"aria-describedby":T<=0?"playtest-layout-boundary":void 0,disabled:U||T<=0,onClick:()=>be(r,b,b[T-1].binding.id,"before"),children:t.jsx(St,{size:13,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":I("next"),"aria-describedby":T===b.length-1?"playtest-layout-boundary":void 0,disabled:U||T<0||T===b.length-1,onClick:()=>be(r,b,b[T+1].binding.id,"after"),children:t.jsx(mt,{size:13,"aria-hidden":"true"})})]}),r.kind==="control"?t.jsx(Lo,{profile:{...H,controls:[r.binding],watches:[],settings:ye},active:de,inactiveReason:je,states:e.live.controls,watches:e.live.watches,draftScope:`${H.id}:${((ke=e.live.lease)==null?void 0:ke.leaseId)??"edit"}`,drafts:X[Pe]?{[r.binding.id]:X[Pe]}:void 0,onDraftChange:(pe,ge,Le)=>he(lt=>({...lt,[Pe]:{value:ge,dirty:Le}})),profileSaveLocked:!1,onApply:(pe,ge)=>void e.live.apply(pe,ge),onSaveValue:e.live.saveControlValue,onRemoveValue:pe=>e.live.saveProfileMetadata({removeDefaults:[pe]})}):r.kind==="watch"?t.jsx($o,{profile:{...H,controls:[],watches:[r.binding]},watches:e.live.watches}):t.jsx(Bo,{action:r.binding,state:e.live.actions[r.binding.id],draft:re[`${H.id}:${r.binding.id}`]??Gt(r.binding),active:e.active&&e.live.studioState==="Running"&&(e.live.studioMode!=="run"||r.binding.target.role==="server"),inactiveReason:e.live.studioState==="Paused"?a("playtest.actions.resumeRequired","Resume Studio before running this action."):e.live.studioMode==="run"&&r.binding.target.role==="client"?a("playtest.actions.playModeRequired","This action is available in Play."):e.inactiveReason,presentation:K[r.binding.id],onDraftChange:(pe,ge)=>oe(Le=>({...Le,[`${H.id}:${r.binding.id}`]:ge})),onExecute:(pe,ge)=>void e.live.executeAction(pe,ge,crypto.randomUUID()),onSaveDefaults:e.live.saveActionDefaults})]},`${r.kind}:${r.binding.id}`)},p=r=>{var T;const D=Ce(r==="watches"?"watch":r==="controls"?"control":"action"),h=new Map;for(const I of D){const Y=((T=K[I.binding.id])==null?void 0:T.group)??se;h.set(Y,[...h.get(Y)??[],I])}const b=Ne[r];return t.jsxs("section",{className:s.valueSection,"aria-label":b,onDragOver:I=>{$&&$!==r&&I.preventDefault()},onDrop:I=>{!$||$===r||(I.preventDefault(),xe($),ee(null))},children:[t.jsxs("header",{className:s.valueSectionHeader,children:[t.jsxs("div",{className:s.valueSectionHeading,children:[O&&t.jsx("button",{type:"button",className:s.sectionDragHandle,draggable:!0,"aria-label":a("playtest.values.drag","Drag {{label}} to reorder").replace("{{label}}",b),disabled:U,onDragStart:()=>ee(r),onDragEnd:()=>ee(null),children:t.jsx(wt,{size:15,"aria-hidden":"true"})}),t.jsx("h3",{children:b}),t.jsx("span",{className:s.valueSectionCount,children:D.length})]}),t.jsxs("div",{className:s.valueSectionHeaderActions,children:[r==="controls"&&H&&t.jsxs("div",{className:s.runtimeSettings,children:[t.jsx(Oe,{active:e.live.canMutate,label:a("playtest.settings.applyChangesAutomatically","Apply changes automatically"),reason:e.inactiveReason??a("playtest.controls.proRequired","Real-time value editing and Reset all are available with Pro."),children:t.jsxs("label",{className:s.runtimeSettingSwitch,children:[t.jsx("span",{children:a("playtest.settings.applyChangesAutomatically","Apply changes automatically")}),t.jsx("input",{className:s.runtimeSettingSwitchInput,type:"checkbox",role:"switch",checked:ye.runtimeApplyMode==="auto",disabled:!e.live.canMutate,onChange:I=>{_e({...ye,runtimeApplyMode:I.target.checked?"auto":"manual"})}}),t.jsx("span",{className:s.runtimeSettingSwitchTrack,"aria-hidden":"true",children:t.jsx("span",{className:s.runtimeSettingSwitchThumb})})]})}),t.jsx(Oe,{active:e.live.canMutate,label:a("playtest.settings.applyDefaultsOnPlayStart","Apply saved defaults when Play starts"),reason:e.inactiveReason??a("playtest.controls.proRequired","Real-time value editing and Reset all are available with Pro."),children:t.jsxs("label",{className:s.runtimeSettingSwitch,children:[t.jsx("span",{children:a("playtest.settings.applyDefaultsOnPlayStart","Apply saved defaults when Play starts")}),t.jsx("input",{className:s.runtimeSettingSwitchInput,type:"checkbox",role:"switch",checked:ye.applyDefaultsOnManualPlayStart,disabled:!e.live.canMutate,onChange:I=>_e({...ye,applyDefaultsOnManualPlayStart:I.target.checked})}),t.jsx("span",{className:s.runtimeSettingSwitchTrack,"aria-hidden":"true",children:t.jsx("span",{className:s.runtimeSettingSwitchThumb})})]})})]}),O&&t.jsx("button",{type:"button",className:s.sectionMoveButton,disabled:U,"aria-label":a(B[0]===r?"playtest.values.moveDown":"playtest.values.moveUp",B[0]===r?"Move {{label}} down":"Move {{label}} up").replace("{{label}}",b),onClick:()=>xe(r),children:B[0]===r?t.jsx(mt,{size:14,"aria-hidden":"true"}):t.jsx(St,{size:14,"aria-hidden":"true"})})]})]}),D.length===0?t.jsx("div",{className:s.panelEmpty,children:r==="watches"?a("playtest.watch.empty","Observed values appear here during Play."):r==="controls"?a("playtest.controls.empty","No test controls in this profile yet."):a("playtest.actions.empty","No actions in this profile yet.")}):t.jsx("div",{className:r==="watches"?s.watchValueGrid:r==="controls"?s.controlValueList:s.actionValueList,children:Array.from(h.entries()).map(([I,Y])=>{const de=C.has(`${r}:${I}`),je=t.jsx("div",{className:s.valueGroupRows,children:Y.map(Pe=>Re(Pe,D))});return h.size===1&&I===se?t.jsx("div",{className:s.valueGroup,children:je},`${r}:${I}`):t.jsxs("section",{className:s.valueGroup,children:[t.jsxs("button",{type:"button",className:s.valueGroupToggle,"aria-expanded":!de,"aria-label":`${de?a("playtest.values.expandGroup","Expand"):a("playtest.values.collapseGroup","Collapse")} ${I}`,onClick:()=>fe(`${r}:${I}`),children:[t.jsx("span",{children:I}),t.jsx("span",{children:Y.length})]}),!de&&je]},`${r}:${I}`)})})]},r)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.valueToolbar,children:[t.jsxs("label",{className:s.valueSearch,children:[t.jsx("span",{className:s.srOnly,children:a("playtest.values.search","Search test values")}),t.jsx("input",{type:"search","aria-label":a("playtest.values.search","Search test values"),value:n,onChange:r=>{i(r.target.value),f(0)},placeholder:a("playtest.values.searchPlaceholder","Name, group, source, or path")})]}),t.jsxs("button",{type:"button",className:s.secondaryAction,"aria-expanded":M,"aria-controls":"playtest-value-filters",onClick:()=>w(r=>!r),children:[a("playtest.values.filters","Filters"),ie?` (${[n.trim()!=="",d!=="all",u!=="all",m!=="all"].filter(Boolean).length})`:""]})]}),M&&t.jsxs("div",{className:s.valueFilters,id:"playtest-value-filters",children:[t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.kind","Value type")}),t.jsxs("select",{"aria-label":a("playtest.values.kind","Value type"),value:d,onChange:r=>{c(r.target.value),f(0)},children:[t.jsx("option",{value:"all",children:a("playtest.values.all","All values")}),t.jsx("option",{value:"control",children:a("playtest.values.controls","Controls")}),t.jsx("option",{value:"watch",children:a("playtest.values.watches","Watch Values")}),t.jsx("option",{value:"action",children:a("playtest.actions.section","Actions")})]})]}),t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.status","Observation status")}),t.jsxs("select",{"aria-label":a("playtest.values.status","Observation status"),value:u,onChange:r=>{y(r.target.value),f(0)},children:[t.jsx("option",{value:"all",children:a("playtest.values.statusAll","All statuses")}),t.jsx("option",{value:"fresh",children:a("playtest.watch.fresh","Fresh")}),t.jsx("option",{value:"stale",children:a("playtest.watch.stale","Stale")}),t.jsx("option",{value:"unavailable",children:a("playtest.watch.unavailable","Unavailable")}),t.jsx("option",{value:"unobserved",children:a("playtest.watch.notObserved","Not observed yet")})]})]}),t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.group","Group")}),t.jsxs("select",{"aria-label":a("playtest.values.group","Group"),value:m,onChange:r=>{_(r.target.value),f(0)},children:[t.jsx("option",{value:"all",children:a("playtest.values.allGroups","All groups")}),ne.groups.map(r=>t.jsx("option",{value:r,children:r},r))]})]}),t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.pageSize","Rows")}),t.jsxs("select",{"aria-label":a("playtest.values.pageSize","Rows"),value:V,onChange:r=>{R(Number(r.target.value)),f(0)},children:[t.jsx("option",{value:"25",children:"25"}),t.jsx("option",{value:"50",children:"50"}),t.jsx("option",{value:"100",children:"100"})]})]})]}),t.jsxs("div",{className:s.valueListStatus,children:[t.jsx("div",{className:s.valueCount,role:"status",children:a("playtest.values.count","{{visible}} of {{total}} values").replace("{{visible}}",String(ne.total)).replace("{{total}}",String(ce))}),t.jsx("button",{type:"button",className:s.secondaryAction,disabled:U||ce===0,onClick:()=>{if(O){z(!1);return}ie&&(i(""),c("all"),y("all"),_("all"),f(0)),z(!0)},children:O?a("playtest.values.doneLayout","Done editing layout"):ie?a("playtest.values.editFullList","Edit full list"):a("playtest.values.editLayout","Edit layout")})]}),O&&t.jsx("div",{className:s.layoutHint,id:"playtest-layout-boundary",children:a("playtest.values.layoutBoundary","Move items within the current group and pinned section.")}),t.jsx("span",{className:s.srOnly,"aria-live":"polite",children:ae}),te&&t.jsx("div",{className:s.layoutError,role:"alert",children:te}),ne.total===0&&ce>0?t.jsx("div",{className:s.panelEmpty,children:a("playtest.values.noResults","No values match these filters.")}):t.jsx("div",{className:s.valueSections,children:B.map(p)}),ne.pages>1&&t.jsxs("div",{className:s.valuePagination,children:[t.jsx("button",{type:"button",disabled:ne.safePage===0,onClick:()=>f(r=>r-1),children:a("playtest.values.previous","Previous")}),t.jsxs("span",{children:[ne.safePage+1," / ",ne.pages]}),t.jsx("button",{type:"button",disabled:ne.safePage+1>=ne.pages,onClick:()=>f(r=>r+1),children:a("playtest.values.next","Next")})]})]})}const Uo="_emptyState_10pjf_1",Ko="_header_10pjf_11",zo="_method_10pjf_12",Wo="_methods_10pjf_39",Jo="_singleMethod_10pjf_45",Yo="_methodTitle_10pjf_57",Qo="_moreExamples_10pjf_70",Xo="_hint_10pjf_88",Zo="_tierNote_10pjf_89",ec="_disabledReason_10pjf_90",tc="_primaryAction_10pjf_102",Ee={emptyState:Uo,header:Ko,method:zo,methods:Wo,singleMethod:Jo,methodTitle:Yo,moreExamples:Qo,hint:Xo,tierNote:Zo,disabledReason:ec,primaryAction:tc};function qt(e){const{t:a}=ue(),n=e.kind==="no-results",i=e.kind==="no-profile",d=n?a("playtest.emptyResults.title","Ask AI to check your game"):i?a("playtest.emptyValues.noProfileTitle","Prepare values and actions to test"):a("playtest.emptyValues.noValuesTitle","Add test values and actions to this profile"),c=n?a("playtest.emptyResults.description","When AI finishes the test, you can review pass, failure, and the reason here."):i?a("playtest.emptyValues.noProfileDescription","Ask AI to prepare values to observe or change and actions to run during Play, or select an object in Studio and add one directly."):a("playtest.emptyValues.noValuesDescription","Use the selected profile, {{name}}, to collect values to observe or change and actions to run during Play.").replace("{{name}}",e.profileName??"");return t.jsxs("section",{className:Ee.emptyState,children:[t.jsxs("header",{className:Ee.header,children:[t.jsx("h3",{children:d}),t.jsx("p",{children:c})]}),t.jsxs("div",{className:`${Ee.methods} ${n?Ee.singleMethod:""}`,children:[t.jsxs("section",{className:Ee.method,children:[t.jsxs("div",{className:Ee.methodTitle,children:[t.jsx(ca,{size:16,"aria-hidden":"true"}),t.jsx("h4",{children:a("playtest.emptyValues.aiTitle","Ask AI")})]}),!n&&t.jsx("p",{children:a("playtest.emptyValues.aiDescription","Copy a request and paste it into an AI chat connected to WEPPY.")}),t.jsx(xt,{exampleIds:n?["automated-check"]:["character"]}),!n&&t.jsxs("details",{className:Ee.moreExamples,children:[t.jsx("summary",{children:a("playtest.ai.otherExamples","Other request examples")}),t.jsx(xt,{exampleIds:["selection","game-state","action"]})]}),n&&e.isBasic&&t.jsx("p",{className:Ee.tierNote,children:a("playtest.emptyResults.proDescription","Automated test runs and actual saved results are available with Pro.")})]}),!n&&t.jsxs("section",{className:Ee.method,children:[t.jsxs("div",{className:Ee.methodTitle,children:[t.jsx(Ca,{size:16,"aria-hidden":"true"}),t.jsx("h4",{children:a("playtest.emptyValues.directTitle","Select and add it yourself")})]}),t.jsx("p",{children:a("playtest.emptyValues.directDescription","Select an object in Studio, then choose a supported value to observe or change, or an available action.")}),i&&t.jsx("p",{className:Ee.hint,children:a("playtest.emptyValues.firstProfileHint","When you add the first item, enter a profile name to keep related test settings together.")}),t.jsx("button",{type:"button",className:Ee.primaryAction,disabled:!!e.directAddDisabledReason,"aria-describedby":e.directAddDisabledReason?"playtest-empty-direct-reason":void 0,onClick:e.onAddFromSelection,children:a("playtest.emptyValues.directAction","Add selected Studio value")}),e.directAddDisabledReason&&t.jsx("p",{className:Ee.disabledReason,id:"playtest-empty-direct-reason",children:e.directAddDisabledReason})]})]})]})}function ac(e){var m,_,C,k,x,f,V;const{live:a}=e,{t:n}=ue(),i=((m=a.lease)==null?void 0:m.state)==="active"&&(a.studioState==="Running"||a.studioState==="Paused"),d=i&&a.canMutate,c=d&&(a.studioMode!=="run"||!!((_=a.profile)!=null&&_.controls.some(R=>R.target.role==="server"))),u=e.inactiveReason??n("playtest.values.playRequired","Start Play in Studio to change test values."),y=(((C=a.profile)==null?void 0:C.controls.length)??0)+(((k=a.profile)==null?void 0:k.watches.length)??0)+(((f=(x=a.profile)==null?void 0:x.actions)==null?void 0:f.length)??0);return t.jsxs("div",{className:s.liveWorkspace,role:"tabpanel","aria-label":n("playtest.view.liveSession","Test Values"),children:[t.jsxs("section",{className:s.profileToolbar,children:[t.jsxs("div",{children:[t.jsxs("div",{className:s.profileLabelRow,children:[t.jsx("label",{htmlFor:"playtest-profile",children:n("playtest.profile.label","Test profiles")}),t.jsx("span",{children:n("playtest.profile.savedCount","{{count}} profiles saved").replace("{{count}}",String(a.profiles.length))})]}),t.jsxs("select",{id:"playtest-profile",value:a.selectedProfileId??"",disabled:!!a.switchingProfileId,"aria-busy":!!a.switchingProfileId,onChange:R=>void a.selectProfile(R.target.value),children:[a.profiles.length===0&&t.jsx("option",{value:"",children:n("playtest.profile.empty","No profiles yet")}),a.profiles.map(R=>t.jsx("option",{value:R.id,children:R.name},R.id))]})]}),t.jsxs("div",{className:s.profileActions,children:[t.jsxs("button",{type:"button",className:s.primaryAction,onClick:e.onManageValues,children:[t.jsx(ja,{size:14,"aria-hidden":"true"})," ",n("playtest.values.addValue","Add value")]}),t.jsxs("button",{type:"button",className:s.secondaryAction,disabled:!a.profile||!!a.switchingProfileId,onClick:e.onEditProfile,children:[t.jsx(Pa,{size:14,"aria-hidden":"true"})," ",n("playtest.profile.edit","Edit profile")]}),t.jsxs("button",{type:"button",className:s.secondaryAction,disabled:!!a.switchingProfileId,onClick:e.onNewProfile,children:[t.jsx($t,{size:14,"aria-hidden":"true"})," ",n("playtest.profile.new","New profile")]})]})]}),a.switchingProfileId&&t.jsx("div",{className:s.controlAvailability,role:"status","aria-live":"polite",children:n("playtest.profile.switching","Switching test profile…")}),a.loading?t.jsx("div",{className:s.panelEmpty,children:n("common.loading","Loading...")}):y===0?t.jsx(qt,{kind:a.profile?"no-values":"no-profile",profileName:(V=a.profile)==null?void 0:V.name,onAddFromSelection:e.onManageValues,directAddDisabledReason:e.directAddDisabledReason}):t.jsx("div",{className:s.liveGrid,children:t.jsxs("section",{className:`${s.livePanel} ${s.valueWorkspacePanel}`,"data-runtime-state":i?"active":"inactive",children:[t.jsxs("header",{className:s.valueWorkspaceHeader,children:[t.jsxs("div",{children:[t.jsx("strong",{children:n("playtest.values.title","Test values")}),!d&&t.jsxs("span",{className:s.controlAvailability,"data-warning":a.studioState==="Edit",id:"playtest-controls-availability",role:"status",children:[a.studioState==="Edit"&&t.jsx(Ea,{size:14,"aria-hidden":"true"}),u]})]}),t.jsx(Oe,{active:c,label:n("playtest.session.reset","Reset all"),reason:u,children:t.jsxs("button",{type:"button",className:s.resetAction,disabled:!c,"aria-describedby":c?void 0:"playtest-controls-availability",onClick:()=>void a.resetAll(),children:[a.canMutate?t.jsx(da,{size:14,"aria-hidden":"true"}):t.jsx(wa,{size:14,"aria-hidden":"true"}),n("playtest.session.reset","Reset all")]})})]}),t.jsx(Ho,{live:a,active:d,inactiveReason:u})]})})]})}const ct={label:"",role:"server",path:"Workspace",accessKind:"attribute",fieldName:"",editorType:"number",defaultValue:"0",minimum:"0",maximum:"100",step:"1"};function sc(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"binding"}function Dt(e){const a=e.split(".").map(n=>n.trim()).filter(Boolean);return a.length>0?{root:a[0],segments:a.slice(1)}:null}function $e(e){return e==="range"?"number":e}function nc(e){var n;if(Ge($e(e.editorType)))return _t($e(e.editorType),e.defaultValue)??null;if(e.editorType==="enum")return((n=e.enumValues)==null?void 0:n.find(i=>String(i)===e.defaultValue))??null;if(e.editorType==="boolean")return e.defaultValue==="true";if(e.editorType==="string")return e.defaultValue;const a=Number(e.defaultValue);return Number.isFinite(a)?a:null}function It(e){return e.accessKind==="value"?{kind:"value"}:{kind:e.accessKind,name:e.fieldName.trim()}}function ic(e){var d,c;if("executor"in e)return`${e.target.role} · ${e.executor.kind} · ${e.parameters.length} parameters`;const a=e.path?[e.path.root,...e.path.segments].join("."):"adapter",n=e.access.kind==="value"?"Value":e.access.name??e.access.kind,i="constraints"in e&&((d=e.constraints)==null?void 0:d.minimum)!==void 0&&((c=e.constraints)==null?void 0:c.maximum)!==void 0;return`${e.target.role} · ${a} · ${n} · ${i?"range":e.valueType}`}function lc(e){var _e,xe,Ce,be,fe,Re;const{t:a}=ue(),n=!!e.profile,[i,d]=o.useState(""),[c,u]=o.useState([]),[y,m]=o.useState([]),[_,C]=o.useState([]),[k,x]=o.useState({}),[f,V]=o.useState("controls"),[R,M]=o.useState(!1),[w,B]=o.useState(ct),[P,E]=o.useState(!1),[W,$]=o.useState(!1),[ee,te]=o.useState(!1),[q,O]=o.useState(!1),[z,U]=o.useState(null),[L,ae]=o.useState(null),J=o.useRef(null);o.useEffect(()=>{var p,j,F,v,S;e.open&&(d(((p=e.profile)==null?void 0:p.name)??""),u(((j=e.profile)==null?void 0:j.controls)??[]),m(((F=e.profile)==null?void 0:F.watches)??[]),C(((v=e.profile)==null?void 0:v.actions)??[]),x(((S=e.profile)==null?void 0:S.presentation)??{}),V("controls"),M(!1),B(ct),$(!1),te(!1),O(!1),ae(null),U(null))},[e.open,e.profile]);const le=f==="controls"?c:f==="watches"?y:_,Q=i!==(((_e=e.profile)==null?void 0:_e.name)??"")||JSON.stringify(c)!==JSON.stringify(((xe=e.profile)==null?void 0:xe.controls)??[])||JSON.stringify(y)!==JSON.stringify(((Ce=e.profile)==null?void 0:Ce.watches)??[])||JSON.stringify(_)!==JSON.stringify(((be=e.profile)==null?void 0:be.actions)??[])||JSON.stringify(k)!==JSON.stringify(((fe=e.profile)==null?void 0:fe.presentation)??{})||R,K=o.useMemo(()=>new Set([...c,...y,..._].map(p=>p.id)),[_,c,y]),Z=(p,j)=>{B(F=>({...F,[p]:j})),U(null)},X=()=>{const p=sc(w.label);let j=p,F=2;for(;K.has(j);)j=`${p}-${F}`,F+=1;return j},he=(p,j)=>k[p]??{order:j,pinned:!1},re=(p,j,F)=>x(v=>({...v,[p]:{...he(p,j),...F}})),oe=le.map((p,j)=>({binding:p,sourceOrder:j,entry:he(p.id,j)})).sort((p,j)=>p.entry.order-j.entry.order),ye=(p,j)=>{const F=oe.findIndex(A=>A.binding.id===p),v=oe[F+j],S=oe[F];!S||!v||x(A=>({...A,[S.binding.id]:{...S.entry,order:v.entry.order},[v.binding.id]:{...v.entry,order:S.entry.order}}))},we=()=>{const p=Dt(w.path),j=nc(w);if(!w.label.trim()||!p||w.accessKind!=="value"&&!w.fieldName.trim()||j===null)return null;const F=w.editorType==="range",v=Number(w.minimum),S=Number(w.maximum),A=Number(w.step);return F&&(typeof j!="number"||!Number.isFinite(v)||!Number.isFinite(S)||!Number.isFinite(A)||v>=S||A<=0||j<v||j>S)?null:{id:X(),label:w.label.trim(),target:{role:w.role},path:p,access:It(w),valueType:$e(w.editorType),value:j,...w.editorType==="enum"?{enumValues:w.enumValues}:{},applyTiming:"after_agents_ready",restorePolicy:"session_end",...F?{constraints:{minimum:v,maximum:S,step:A}}:{}}},H=()=>{const p=Dt(w.path);return!w.label.trim()||!p||w.accessKind!=="value"&&!w.fieldName.trim()?null:{id:X(),label:w.label.trim(),target:{role:w.role},path:p,access:It(w),valueType:$e(w.editorType)}},se=()=>{const p=f==="controls"?we():H();if(!p){U(a("playtest.profile.binding.invalid","Complete the label, path, field, and type values."));return}f==="controls"?u(j=>[...j,p]):m(j=>[...j,p]),x(j=>({...j,[p.id]:{order:c.length+y.length,pinned:!1}})),M(!1),B(ct)},ne=async()=>{if(e.onResolveSelectionCandidates){try{const j=await e.onResolveSelectionCandidates();if(!j.selected.path||j.candidates.length===0){U(a("playtest.profile.binding.selectionEmpty","The selected instance has no supported fields."));return}ae(j),ce(j,0)}catch(j){U(j instanceof Error?j.message:String(j))}return}if(!e.onResolveSelection)return;const p=f==="controls"?we():H();if(!p){U(a("playtest.profile.binding.selectionNeedsFields","Enter the label, field, and type before using the Studio selection."));return}try{const j=await e.onResolveSelection({kind:f==="controls"?"control":"watch",id:p.id,label:p.label,role:p.target.role,access:p.access,valueType:p.valueType,..."value"in p?{value:p.value}:{},..."constraints"in p&&p.constraints?{constraints:p.constraints}:{},..."enumValues"in p&&p.enumValues?{enumValues:p.enumValues}:{}});j.path&&Z("path",[j.path.root,...j.path.segments].join("."))}catch(j){U(j instanceof Error?j.message:String(j))}},ce=(p,j)=>{const F=p.candidates[j];if(!F||!p.selected.path)return;const v=F.fieldName??"Value";B(S=>({...S,label:`${p.selected.name??"Selected"} ${v}`,path:[p.selected.path.root,...p.selected.path.segments].join("."),accessKind:F.accessKind,fieldName:F.fieldName??"",editorType:F.valueType,defaultValue:typeof F.value=="object"?JSON.stringify(F.value):String(F.value),enumValues:F.enumValues})),U(null)},ie=async()=>{if(!(!e.profile||!e.onSave||!i.trim())){E(!0),U(null);try{await e.onSave({...e.profile,schemaVersion:4,name:i.trim(),controls:c,watches:y,actions:_,presentation:k}),e.onClose()}catch(p){U(p instanceof Error?p.message:String(p))}finally{E(!1)}}},Ne=()=>{if(!(P||q)){if(Q){$(!0);return}e.onClose()}},ve=async()=>{var p;if(!(!e.profile||!e.onDelete||q||e.deleteDisabledReason)){O(!0),U(null);try{await e.onDelete(e.profile.id,e.profile.revision),te(!1),e.onClose()}catch(j){const F=j&&typeof j=="object"?String("payload"in j&&((p=j.payload)==null?void 0:p.errorCode)||"error"in j&&j.error||"code"in j&&j.code||""):"";U(a(F==="profile_active"?"playtest.profile.deleteActive":F==="profile_revision_conflict"?"playtest.profile.deleteConflict":F==="profile_not_found"?"playtest.profile.deleteNotFound":F==="profile_scope_unavailable"?"playtest.profile.deleteScopeUnavailable":"playtest.profile.deleteFailed",j instanceof Error?j.message:"Could not delete the profile."))}finally{O(!1)}}};return t.jsxs(Ke,{open:e.open,onClose:Ne,dismissDisabled:P||q,initialFocusRef:J,ariaLabel:n?a("playtest.profile.editTitle","Edit test profile"):a("playtest.profile.createTitle","Create test profile"),children:[t.jsxs("div",{className:`${s.profileDialog} ${n?s.profileEditorDialog:""}`,children:[t.jsx(ze,{title:n?a("playtest.profile.editTitle","Edit test profile"):a("playtest.profile.createTitle","Create test profile"),description:n?a("playtest.profile.editDescription","Add controls you can change during Play and Watch Values you only want to observe."):a("playtest.profile.createDescription","Profiles are stored locally for the selected Place. Add controls after creating it."),closeLabel:a("common.close","Close"),closeDisabled:P||q,onRequestClose:Ne}),t.jsxs("div",{className:s.profileDialogBody,children:[t.jsxs("label",{children:[a("playtest.profile.name","Profile name"),t.jsx("input",{ref:J,value:i,onChange:p=>d(p.target.value)})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.bindingTabs,role:"tablist","aria-label":a("playtest.profile.bindingTabs","Profile values"),children:[t.jsxs("button",{type:"button",role:"tab","aria-selected":f==="controls",onClick:()=>{V("controls"),M(!1)},children:[a("playtest.profile.controlsTab","Controls")," ",t.jsx("span",{children:c.length})]}),t.jsxs("button",{type:"button",role:"tab","aria-selected":f==="watches",onClick:()=>{V("watches"),M(!1)},children:[a("playtest.profile.watchesTab","Watch Values")," ",t.jsx("span",{children:y.length})]}),t.jsxs("button",{type:"button",role:"tab","aria-selected":f==="actions",onClick:()=>{V("actions"),M(!1)},children:[a("playtest.actions.section","Actions")," ",t.jsx("span",{children:_.length})]})]}),t.jsx("div",{className:s.bindingList,children:le.length===0?t.jsx("div",{className:s.bindingEmpty,children:f==="controls"?a("playtest.profile.controlsEmpty","No controls added yet."):f==="watches"?a("playtest.profile.watchesEmpty","No Watch Values added yet."):a("playtest.actions.empty","No actions in this profile yet.")}):oe.map(({binding:p,entry:j,sourceOrder:F},v)=>t.jsxs("div",{className:s.bindingItem,children:[t.jsxs("div",{className:s.bindingItemCopy,children:[t.jsx("strong",{children:p.label}),t.jsx("span",{children:ic(p)}),t.jsxs("div",{className:s.bindingPresentation,children:[t.jsxs("label",{children:[a("playtest.profile.group","Group"),t.jsx("input",{"aria-label":a("playtest.profile.groupFor","Group for {{label}}").replace("{{label}}",p.label),value:j.group??"",onChange:S=>re(p.id,F,{group:S.target.value||void 0})})]}),t.jsxs("label",{className:s.bindingPin,children:[t.jsx("input",{type:"checkbox","aria-label":a("playtest.profile.pinLabel","Pin {{label}}").replace("{{label}}",p.label),checked:j.pinned,onChange:S=>re(p.id,F,{pinned:S.target.checked})}),a("playtest.profile.pin","Pin")]})]})]}),t.jsxs("div",{className:s.bindingItemActions,children:[t.jsx("button",{type:"button","aria-label":a("playtest.profile.moveUp","Move {{label}} up").replace("{{label}}",p.label),disabled:v===0,onClick:()=>ye(p.id,-1),children:t.jsx(ha,{size:13,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":a("playtest.profile.moveDown","Move {{label}} down").replace("{{label}}",p.label),disabled:v===oe.length-1,onClick:()=>ye(p.id,1),children:t.jsx(fa,{size:13,"aria-hidden":"true"})}),t.jsx("button",{type:"button",className:s.bindingDelete,"aria-label":a("playtest.profile.removeBinding","Remove {{label}}").replace("{{label}}",p.label),onClick:()=>{f==="controls"?u(S=>S.filter(A=>A.id!==p.id)):f==="watches"?m(S=>S.filter(A=>A.id!==p.id)):C(S=>S.filter(A=>A.id!==p.id)),x(S=>Object.fromEntries(Object.entries(S).filter(([A])=>A!==p.id)))},children:t.jsx(jt,{size:14,"aria-hidden":"true"})})]})]},p.id))}),f!=="actions"&&(R?t.jsxs("fieldset",{className:s.bindingForm,"aria-label":f==="controls"?a("playtest.profile.newControl","New control"):a("playtest.profile.newWatch","New watch"),children:[(e.onResolveSelectionCandidates||e.onResolveSelection)&&t.jsx("button",{type:"button",className:s.selectionButton,onClick:()=>void ne(),children:a("playtest.profile.binding.useSelection","Use current Studio selection")}),L&&L.candidates.length>1&&t.jsxs("label",{children:[a("playtest.profile.binding.selectedField","Selected field"),t.jsx("select",{onChange:p=>ce(L,Number(p.target.value)),children:L.candidates.map((p,j)=>t.jsx("option",{value:j,children:p.accessKind==="value"?"ValueBase.Value":`${p.accessKind} · ${p.fieldName}`},`${p.accessKind}:${p.fieldName??"Value"}`))})]}),t.jsxs("div",{className:s.bindingFormGrid,children:[t.jsxs("label",{children:[a("playtest.profile.binding.label","Label"),t.jsx("input",{value:w.label,onChange:p=>Z("label",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.role","Target"),t.jsxs("select",{value:w.role,onChange:p=>Z("role",p.target.value),children:[t.jsx("option",{value:"server",children:a("playtest.profile.binding.server","Server")}),t.jsx("option",{value:"client",children:a("playtest.profile.binding.client","Client")})]})]}),t.jsxs("label",{className:s.bindingPathField,children:[a("playtest.profile.binding.path","Runtime path"),t.jsx("input",{value:w.path,placeholder:a("playtest.profile.binding.pathPlaceholder","Workspace.Config"),onChange:p=>Z("path",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.access","Access"),t.jsxs("select",{value:w.accessKind,onChange:p=>Z("accessKind",p.target.value),children:[t.jsx("option",{value:"attribute",children:a("playtest.profile.binding.attribute","Attribute")}),t.jsx("option",{value:"value",children:a("playtest.profile.binding.valueBase","ValueBase.Value")}),t.jsx("option",{value:"property",children:a("playtest.profile.binding.property","Property")})]})]}),w.accessKind!=="value"&&t.jsxs("label",{children:[a("playtest.profile.binding.field","Field name"),t.jsx("input",{value:w.fieldName,onChange:p=>Z("fieldName",p.target.value)})]}),t.jsxs("label",{children:[f==="controls"?a("playtest.profile.binding.inputType","Input type"):a("playtest.profile.binding.valueType","Value type"),t.jsxs("select",{value:w.editorType,onChange:p=>Z("editorType",p.target.value),children:[t.jsx("option",{value:"number",children:a("playtest.profile.binding.number","Number")}),f==="controls"&&t.jsx("option",{value:"range",children:a("playtest.profile.binding.range","Range")}),t.jsx("option",{value:"string",children:a("playtest.profile.binding.string","String")}),t.jsx("option",{value:"boolean",children:a("playtest.profile.binding.boolean","Boolean")}),t.jsx("option",{value:"vector3",children:a("playtest.profile.binding.vector3","Vector3")}),t.jsx("option",{value:"color3",children:a("playtest.profile.binding.color3","Color3")}),t.jsx("option",{value:"cframe",children:a("playtest.profile.binding.cframe","CFrame")}),w.enumValues&&t.jsx("option",{value:"enum",children:a("playtest.profile.binding.enum","Enum")})]})]}),f==="controls"&&Ge($e(w.editorType))&&t.jsx(ht,{type:$e(w.editorType),draft:w.defaultValue,label:a("playtest.profile.binding.defaultValue","Default value"),onChange:p=>Z("defaultValue",p)}),f==="controls"&&w.editorType==="enum"&&t.jsxs("label",{children:[a("playtest.profile.binding.defaultValue","Default value"),t.jsx("select",{value:w.defaultValue,onChange:p=>Z("defaultValue",p.target.value),children:(Re=w.enumValues)==null?void 0:Re.map(p=>t.jsx("option",{value:String(p),children:String(p)},String(p)))})]}),f==="controls"&&!Ge($e(w.editorType))&&w.editorType!=="boolean"&&w.editorType!=="enum"&&t.jsxs("label",{children:[a("playtest.profile.binding.defaultValue","Default value"),t.jsx("input",{type:w.editorType==="string"?"text":"number",value:w.defaultValue,onChange:p=>Z("defaultValue",p.target.value)})]}),f==="controls"&&w.editorType==="boolean"&&t.jsxs("label",{className:s.bindingBooleanDefault,children:[t.jsx("input",{type:"checkbox","aria-label":a("playtest.profile.binding.defaultValue","Default value"),checked:w.defaultValue==="true",onChange:p=>Z("defaultValue",String(p.target.checked))}),t.jsx("span",{children:a("playtest.profile.binding.defaultValue","Default value")})]}),f==="controls"&&w.editorType==="range"&&t.jsxs("div",{className:s.rangeFields,children:[t.jsxs("label",{children:[a("playtest.profile.binding.minimum","Minimum"),t.jsx("input",{type:"number",value:w.minimum,onChange:p=>Z("minimum",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.maximum","Maximum"),t.jsx("input",{type:"number",value:w.maximum,onChange:p=>Z("maximum",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.step","Step"),t.jsx("input",{type:"number",value:w.step,onChange:p=>Z("step",p.target.value)})]})]})]}),z&&t.jsx("div",{className:s.bindingError,role:"alert",children:z}),t.jsxs("div",{className:s.bindingFormActions,children:[t.jsx("button",{type:"button",className:s.secondaryAction,onClick:()=>{M(!1),U(null)},children:a("common.cancel","Cancel")}),t.jsx("button",{type:"button",className:s.primaryAction,onClick:se,children:a("playtest.profile.binding.add","Add to profile")})]})]}):t.jsxs("button",{type:"button",className:s.addBindingButton,onClick:()=>M(!0),children:[t.jsx($t,{size:14,"aria-hidden":"true"})," ",f==="controls"?a("playtest.profile.addControl","Add control"):a("playtest.profile.addWatch","Add watch")]}))]}),z&&!R&&t.jsx("div",{className:s.bindingError,role:"alert",children:z})]}),t.jsxs("div",{className:s.profileDialogActions,children:[n&&e.onDelete&&t.jsxs("button",{type:"button",className:`${s.stopAction} ${s.profileDeleteAction}`,disabled:P||q||!!e.deleteDisabledReason,title:e.deleteDisabledReason,onClick:()=>te(!0),children:[t.jsx(jt,{size:14,"aria-hidden":"true"})," ",a("playtest.profile.delete","Delete profile")]}),n&&e.deleteDisabledReason&&t.jsx("span",{className:s.profileDeleteReason,role:"status",children:e.deleteDisabledReason}),t.jsx("button",{type:"button",className:s.secondaryAction,disabled:P||q,onClick:Ne,children:a("common.cancel","Cancel")}),n?t.jsx("button",{type:"button",className:s.primaryAction,disabled:!i.trim()||P,onClick:()=>void ie(),children:P?a("playtest.profile.saving","Saving…"):a("playtest.profile.save","Save profile")}):t.jsx("button",{type:"button",className:s.primaryAction,disabled:!i.trim()||P,onClick:async()=>{E(!0);try{await e.onCreate(i),d(""),e.onClose()}finally{E(!1)}},children:P?a("playtest.profile.creating","Creating…"):a("playtest.profile.createTitle","Create test profile")})]})]}),t.jsx(ft,{open:W,title:a("playtest.profile.discardTitle","Discard profile changes?"),message:a("playtest.profile.discardMessage","Your unsaved profile changes will be lost."),cancelLabel:a("playtest.profile.keepEditing","Keep editing"),confirmLabel:a("playtest.profile.discard","Discard changes"),onCancel:()=>$(!1),onConfirm:()=>{$(!1),e.onClose()}}),t.jsx(ft,{open:ee,title:a("playtest.profile.deleteConfirmTitle","Delete test profile?"),message:e.profile?[a("playtest.profile.deleteConfirmMessage","Delete “{{name}}”? Its {{controls}} control values and {{watches}} observed values will be removed. Game objects, scripts, test connection code, other profiles, and automated test results will remain.").replace("{{name}}",e.profile.name).replace("{{controls}}",String(e.profile.controls.length)).replace("{{watches}}",String(e.profile.watches.length)),Q?a("playtest.profile.deleteDirty","Unsaved edits will also be discarded."):""].filter(Boolean).join(" "):"",cancelLabel:a("common.cancel","Cancel"),confirmLabel:a("playtest.profile.delete","Delete profile"),loading:q,onCancel:()=>{q||te(!1)},onConfirm:()=>void ve()})]})}function Fe(e){return`${e.accessKind}:${e.fieldName??"Value"}`}function et(e){return e.fieldName??"Value"}function rc(e){const{t:a}=ue(),n=o.useId(),[i,d]=o.useState(!1),[c,u]=o.useState(""),y=o.useRef(null),m=o.useRef(null),_=o.useRef(null),C=c.trim().toLocaleLowerCase(),k=o.useMemo(()=>e.candidates.filter(P=>`${et(P)} ${P.accessKind}`.toLocaleLowerCase().includes(C)),[C,e.candidates]),x=["attribute","value","property"].map(P=>({kind:P,candidates:k.filter(E=>E.accessKind===P)})).filter(P=>P.candidates.length>0),f=et(e.selected);o.useEffect(()=>{var P;i&&((P=m.current)==null||P.focus())},[i]);const V=(P=!0)=>{var E;d(!1),u(""),P&&((E=y.current)==null||E.focus())},R=()=>{var P;return Array.from(((P=_.current)==null?void 0:P.querySelectorAll('[role="option"]'))??[])},M=P=>{var W;const E=R();(W=E[Math.max(0,Math.min(P,E.length-1))])==null||W.focus()},w=P=>{e.onSelect(P),V()},B=P=>P==="attribute"?a("playtest.profile.binding.attribute","Attribute"):P==="value"?a("playtest.profile.binding.valueBase","ValueBase.Value"):a("playtest.profile.binding.property","Property");return t.jsxs("div",{className:s.propertyPicker,children:[t.jsx("span",{className:s.propertyPickerLabel,children:a("playtest.values.selectProperty","Property")}),t.jsxs("button",{ref:y,type:"button",className:s.propertyPickerTrigger,disabled:e.disabled,"aria-haspopup":"listbox","aria-expanded":i,"aria-controls":i?n:void 0,"aria-label":`${a("playtest.values.propertyPickerAction","Select property")}: ${f}`,onClick:()=>{i?V(!1):d(!0)},children:[t.jsx("span",{children:f}),t.jsx(mt,{size:16,"aria-hidden":"true"})]}),i&&t.jsxs("div",{ref:_,className:s.propertyPickerPanel,onKeyDown:P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),V())},children:[t.jsxs("div",{className:s.propertyPickerSearchRow,children:[t.jsxs("label",{children:[a("playtest.values.searchProperties","Search properties"),t.jsx("input",{ref:m,type:"search",value:c,onChange:P=>u(P.target.value),onKeyDown:P=>{P.key==="ArrowDown"&&(P.preventDefault(),M(0))}})]}),t.jsx("button",{type:"button","aria-label":a("playtest.values.propertyPickerClose","Close property picker"),onClick:()=>V(),children:t.jsx(zt,{size:16,"aria-hidden":"true"})})]}),t.jsxs("div",{id:n,className:s.propertyPickerList,role:"listbox","aria-label":a("playtest.values.availableProperties","Available properties"),children:[x.map(P=>t.jsxs("div",{className:s.propertyPickerGroup,role:"group","aria-label":B(P.kind),children:[t.jsx("span",{children:B(P.kind)}),P.candidates.map(E=>{const W=Fe(E)===Fe(e.selected);return t.jsxs("div",{role:"option",tabIndex:0,"aria-selected":W,"aria-label":et(E),className:s.propertyPickerOption,onClick:()=>w(E),onKeyDown:$=>{var q;const te=R().indexOf($.currentTarget);$.key==="ArrowDown"&&($.preventDefault(),M(te+1)),$.key==="ArrowUp"&&($.preventDefault(),te===0?(q=m.current)==null||q.focus():M(te-1)),($.key==="Enter"||$.key===" ")&&($.preventDefault(),w(E))},children:[t.jsx("span",{children:et(E)}),t.jsx("small",{children:E.valueType}),W&&t.jsx(ua,{size:15,"aria-hidden":"true"})]},Fe(E))})]},P.kind)),k.length===0&&t.jsx("p",{role:"status",children:a("playtest.values.noProperties","No matching properties")})]})]})]})}const Tt=`local RunService = game:GetService("RunService")
66
+ [sample] preview report finished`),contextId:"sample_playtest_preview",contextSummary:n,artifactErrors:[],result:{schemaVersion:1,sessionId:"sample-session",recordId:"sample_playtest_preview",testName:e("playtest.sample.history.name","Sample Arena Smoke Test"),executionKind:"structured_session",overallStatus:"passed",overallPassed:!0,terminalReason:{code:"all_required_evidence_passed",message:e("playtest.sample.terminal","All required evidence passed")},mode:"play",place:{placeName:e("playtest.sample.place","Sample Arena")},startedAt:a,endedAt:"2026-03-27T15:26:04.820Z",durationMs:4820,agents:[{agentId:"sample-server-agent",role:"server"},{agentId:"sample-client-agent",role:"client",clientId:"client-1"}],capabilities:{semanticUiSnapshot:!0,virtualInput:!0,fixedBootstrap:!0,projectTestAdapter:!1},requiredEvidence:{server:!0,clientUi:!0,interaction:!0,visual:!1},dimensions:{server:{required:!0,status:"passed",stepIds:["wave-started"]},clientUi:{required:!0,status:"passed",stepIds:["hud-visible"]},interaction:{required:!0,status:"passed",provider:"virtual_input",stepIds:["start-click"]},visual:{required:!1,status:"not_requested",reason:"not_requested",stepIds:[]}},limitations:[{code:"play_screenshot_unsupported",message:e("playtest.sample.limit.visual","Play screenshot evidence is unavailable in structured session v1")}],steps:[{index:0,stepId:"start-click",target:{role:"client",clientId:"client-1"},action:"input_click",dimension:"interaction",required:!0,status:"passed",startedAt:a,endedAt:"2026-03-27T15:26:00.120Z",durationMs:120,expected:{activated:!0},observed:{activated:!0},evidence:{delivery:"VirtualInput",observation:"GuiButton.Activated"}}],cleanup:{status:"passed",errors:[]},artifacts:{status:"complete",files:["test-result.json","test-report.md","test-log.txt","test-context.json"]}}}}}function Ve(e,a){switch(a){case"passed":return e("playtest.result.status.passed","Passed");case"failed":return e("playtest.result.status.failed","Failed");case"timed_out":return e("playtest.result.status.timedOut","Timed out");case"cancelled":return e("playtest.result.status.cancelled","Cancelled");case"insufficient_evidence":return e("playtest.result.status.insufficientEvidence","Insufficient evidence");case"unavailable":return e("playtest.result.status.unavailable","Unavailable");case"skipped":return e("playtest.result.status.skipped","Skipped");case"not_requested":return e("playtest.result.status.notRequested","Not requested");default:return e("playtest.result.status.unknown","Unknown")}}function vt(e){return e==="passed"?"✓":e==="failed"||e==="timed_out"?"×":e==="cancelled"||e==="insufficient_evidence"||e==="unavailable"?"!":"–"}function Vt(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function at(e){return JSON.stringify(e,null,2)}function Ot(e,a,n){return a==="play_screenshot_unsupported"?e("playtest.limitations.visualUnsupported","Visual evidence unavailable — Play screenshots are not supported in structured session v1."):a==="virtual_input_unavailable"?e("playtest.limitations.virtualInputUnavailable","Virtual input is unavailable for this session."):n}function Ma(e,a){return a==="play_screenshot_unsupported"?e("playtest.limitations.visualUnsupportedReason","Play screenshots are not supported in structured session v1."):a==="not_requested"?e("playtest.result.status.notRequested","Not requested"):a==="required_evidence_missing"?e("playtest.dimension.reason.missing","Required evidence is missing."):a==="required_capability_unavailable"?e("playtest.dimension.reason.capability","The required capability is unavailable."):a}const $a="_page_14ipf_2",Va="_sampleBanner_14ipf_10",Oa="_sampleBannerRow_14ipf_22",Ba="_sampleBannerMain_14ipf_29",Fa="_sampleBadge_14ipf_36",Ga="_sampleTitle_14ipf_51",Ha="_sampleMessage_14ipf_58",qa="_sampleActions_14ipf_65",Ua="_primaryAction_14ipf_73",Ka="_secondaryAction_14ipf_74",za="_resetAction_14ipf_75",Wa="_card_14ipf_124",Ja="_cardHeader_14ipf_131",Ya="_clearButton_14ipf_144",Qa="_statusRow_14ipf_173",Xa="_statusIndicator_14ipf_180",Za="_statusRunning_14ipf_188",es="_statusPaused_14ipf_193",ts="_statusNotRunning_14ipf_197",as="_statusLabel_14ipf_201",ss="_statusMeta_14ipf_208",ns="_controlButtons_14ipf_214",is="_btn_14ipf_221",ls="_btnPrimary_14ipf_243",rs="_btnDanger_14ipf_253",os="_historyList_14ipf_265",cs="_historyItem_14ipf_271",ds="_stepDisclosure_14ipf_291",us="_historyItemSelected_14ipf_296",ps="_historyItemHeader_14ipf_301",fs="_historyIcon_14ipf_307",ms="_historyTimestamp_14ipf_312",hs="_historyName_14ipf_319",ys="_recordKind_14ipf_330",vs="_historyItemMeta_14ipf_344",gs="_historyMode_14ipf_354",bs="_historyDuration_14ipf_358",_s="_historyStatus_14ipf_362",xs="_status_passed_14ipf_369",js="_status_failed_14ipf_373",Ss="_status_running_14ipf_377",ws="_status_timed_out_14ipf_381",Ns="_status_cancelled_14ipf_385",Cs="_status_insufficient_evidence_14ipf_386",Rs="_historyError_14ipf_390",Ps="_historyEvidence_14ipf_400",ks="_historyLimitation_14ipf_410",As="_detailShell_14ipf_421",Es="_detailHeader_14ipf_429",Ds="_detailHeading_14ipf_440",Is="_detailRecordName_14ipf_451",Ts="_detailCloseButton_14ipf_460",Ls="_detailRetryButton_14ipf_480",Ms="_detailBody_14ipf_485",$s="_detailState_14ipf_494",Vs="_detailErrorTitle_14ipf_505",Os="_detailErrorMessage_14ipf_512",Bs="_reportContainer_14ipf_534",Fs="_runSummary_14ipf_540",Gs="_viewerSection_14ipf_541",Hs="_summaryLead_14ipf_554",qs="_summaryStatusMark_14ipf_560",Us="_viewerHeading_14ipf_573",Ks="_summaryName_14ipf_583",zs="_summaryReason_14ipf_594",Ws="_summaryFacts_14ipf_601",Js="_subsectionLabel_14ipf_614",Ys="_sectionHeadingRow_14ipf_629",Qs="_sectionHint_14ipf_637",Xs="_dimensionGrid_14ipf_642",Zs="_dimensionCard_14ipf_649",en="_dimensionHeader_14ipf_657",tn="_statusMark_14ipf_663",an="_dimensionName_14ipf_676",sn="_requirementBadge_14ipf_686",nn="_dimensionStatus_14ipf_694",ln="_dimensionMeta_14ipf_701",rn="_tone_passed_14ipf_709",on="_tone_failed_14ipf_710",cn="_tone_timed_out_14ipf_711",dn="_tone_cancelled_14ipf_712",un="_tone_insufficient_evidence_14ipf_713",pn="_tone_unavailable_14ipf_714",fn="_tone_skipped_14ipf_715",mn="_tone_not_requested_14ipf_716",hn="_stepList_14ipf_718",yn="_stepItem_14ipf_725",vn="_stepIndex_14ipf_749",gn="_stepIdentity_14ipf_756",bn="_stepName_14ipf_763",_n="_stepMeta_14ipf_773",xn="_stepStatus_14ipf_774",jn="_chevron_14ipf_782",Sn="_chevronOpen_14ipf_788",wn="_stepDetails_14ipf_790",Nn="_evidenceBlock_14ipf_799",Cn="_evidenceLabel_14ipf_803",Rn="_stepError_14ipf_830",Pn="_recordProblem_14ipf_831",kn="_capabilityGrid_14ipf_846",An="_capabilityItem_14ipf_853",En="_capabilityYes_14ipf_866",Dn="_capabilityNo_14ipf_867",In="_capabilityState_14ipf_868",Tn="_limitations_14ipf_870",Ln="_artifactList_14ipf_871",Mn="_agentList_14ipf_872",$n="_artifactDisclosures_14ipf_889",Vn="_artifactDisclosure_14ipf_889",On="_artifactButton_14ipf_903",Bn="_artifactContent_14ipf_928",Fn="_limitationItem_14ipf_948",Gn="_reportContextPanel_14ipf_965",Hn="_reportContextRow_14ipf_975",qn="_reportContextLabel_14ipf_983",Un="_reportSection_14ipf_991",Kn="_reportSectionHeader_14ipf_997",zn="_reportMarkdown_14ipf_1009",Wn="_reportLogs_14ipf_1022",Jn="_emptyState_14ipf_1037",Yn="_emptyStateTitle_14ipf_1044",Qn="_emptyStateMessage_14ipf_1052",Xn="_upgradePanel_14ipf_1061",Zn="_upgradePanelIcon_14ipf_1069",ei="_upgradePanelTitle_14ipf_1074",ti="_upgradePanelDesc_14ipf_1082",ai="_benefitList_14ipf_1092",si="_benefitItem_14ipf_1103",ni="_upgradeActions_14ipf_1118",ii="_workspaceTabs_14ipf_1124",li="_sessionHelp_14ipf_1137",ri="_stopAction_14ipf_1143",oi="_controlEditor_14ipf_1144",ci="_profileToolbar_14ipf_1146",di="_profileDialog_14ipf_1147",ui="_sessionBar_14ipf_1152",pi="_sessionIdentity_14ipf_1165",fi="_sessionActions_14ipf_1195",mi="_profileActions_14ipf_1196",hi="_profileDialogActions_14ipf_1197",yi="_liveWorkspace_14ipf_1238",vi="_profileLabelRow_14ipf_1254",gi="_profileHint_14ipf_1262",bi="_actualValue_14ipf_1271",_i="_watchReading_14ipf_1272",xi="_liveGrid_14ipf_1308",ji="_livePanel_14ipf_1315",Si="_panelEmpty_14ipf_1352",wi="_controlAvailability_14ipf_1358",Ni="_controlGate_14ipf_1361",Ci="_controlGateTrigger_14ipf_1364",Ri="_controlGateHint_14ipf_1366",Pi="_editorLabel_14ipf_1367",ki="_editorHeading_14ipf_1368",Ai="_savedValueState_14ipf_1369",Ei="_valueToolbar_14ipf_1373",Di="_valueFilters_14ipf_1383",Ii="_valuePagination_14ipf_1390",Ti="_valueListStatus_14ipf_1391",Li="_valueCount_14ipf_1392",Mi="_layoutHint_14ipf_1394",$i="_srOnly_14ipf_1395",Vi="_unifiedValueRows_14ipf_1396",Oi="_liveRows_14ipf_1397",Bi="_watchRows_14ipf_1397",Fi="_valueGroup_14ipf_1398",Gi="_valueGroupToggle_14ipf_1400",Hi="_valueGroupRows_14ipf_1406",qi="_controlRow_14ipf_1406",Ui="_watchRow_14ipf_1397",Ki="_actionRow_14ipf_1408",zi="_historyBrowser_14ipf_1412",Wi="_historyToolbar_14ipf_1413",Ji="_rowIdentity_14ipf_1437",Yi="_freshness_14ipf_1440",Qi="_presentationMeta_14ipf_1461",Xi="_rowFeedback_14ipf_1462",Zi="_controlEditorRow_14ipf_1468",el="_controlActions_14ipf_1469",tl="_applyOnStartOption_14ipf_1472",al="_valueDetails_14ipf_1474",sl="_valueDetailButton_14ipf_1480",nl="_valueDetailShell_14ipf_1483",il="_valueDetailBody_14ipf_1484",ll="_valueDetailList_14ipf_1485",rl="_valueDetailActions_14ipf_1489",ol="_valueDetailFeedback_14ipf_1490",cl="_defaultValueEditor_14ipf_1493",dl="_defaultBooleanEditor_14ipf_1497",ul="_booleanEditor_14ipf_1500",pl="_rangeEditor_14ipf_1509",fl="_valueWorkspacePanel_14ipf_1524",ml="_valueWorkspaceHeader_14ipf_1525",hl="_valueSections_14ipf_1526",yl="_valueSection_14ipf_1526",vl="_valueSectionHeader_14ipf_1528",gl="_valueSectionHeading_14ipf_1529",bl="_valueSectionCount_14ipf_1531",_l="_valueSectionHeaderActions_14ipf_1532",xl="_sectionDragHandle_14ipf_1533",jl="_sectionMoveButton_14ipf_1534",Sl="_valueReorderControls_14ipf_1535",wl="_dragHandle_14ipf_1537",Nl="_runtimeSettings_14ipf_1549",Cl="_runtimeSettingSwitch_14ipf_1550",Rl="_runtimeSettingSwitchInput_14ipf_1553",Pl="_runtimeSettingSwitchTrack_14ipf_1554",kl="_runtimeSettingSwitchThumb_14ipf_1555",Al="_layoutError_14ipf_1559",El="_controlValueList_14ipf_1560",Dl="_watchValueGrid_14ipf_1561",Il="_actionValueList_14ipf_1562",Tl="_valueEntryShell_14ipf_1563",Ll="_watchCardMain_14ipf_1576",Ml="_watchDetails_14ipf_1583",$l="_actionSummary_14ipf_1592",Vl="_actionExecution_14ipf_1592",Ol="_actionParameter_14ipf_1593",Bl="_actionInactiveReason_14ipf_1597",Fl="_actionParameterGrid_14ipf_1602",Gl="_actionParameterError_14ipf_1608",Hl="_deploymentGuide_14ipf_1634",ql="_deploymentScope_14ipf_1646",Ul="_deploymentLifecycle_14ipf_1649",Kl="_deploymentNotice_14ipf_1650",zl="_deploymentChecklist_14ipf_1652",Wl="_deploymentDescription_14ipf_1656",Jl="_deploymentDetails_14ipf_1659",Yl="_inlineError_14ipf_1679",Ql="_profileEditorDialog_14ipf_1682",Xl="_profileDialogBody_14ipf_1683",Zl="_profileDeleteAction_14ipf_1686",er="_profileDeleteReason_14ipf_1687",tr="_bindingTabs_14ipf_1688",ar="_bindingList_14ipf_1692",sr="_bindingEmpty_14ipf_1693",nr="_bindingItem_14ipf_1694",ir="_bindingItemCopy_14ipf_1699",lr="_bindingPresentation_14ipf_1700",rr="_bindingPin_14ipf_1703",or="_bindingItemActions_14ipf_1705",cr="_bindingDelete_14ipf_1709",dr="_addBindingButton_14ipf_1711",ur="_bindingForm_14ipf_1712",pr="_bindingFormGrid_14ipf_1713",fr="_bindingBooleanDefault_14ipf_1716",mr="_bindingPathField_14ipf_1718",hr="_rangeFields_14ipf_1719",yr="_selectionButton_14ipf_1720",vr="_bindingFormActions_14ipf_1721",gr="_bindingError_14ipf_1722",br="_valueManagerShell_14ipf_1723",_r="_valueSourceTabs_14ipf_1724",xr="_valueManagerBody_14ipf_1728",jr="_valueSourcePanel_14ipf_1729",Sr="_registeredIntro_14ipf_1730",wr="_registeredEmpty_14ipf_1734",Nr="_registeredSteps_14ipf_1737",Cr="_registeredEmptyActions_14ipf_1740",Rr="_adapterSetupList_14ipf_1745",Pr="_adapterSetupRow_14ipf_1749",kr="_adapterMethods_14ipf_1756",Ar="_connectionGuide_14ipf_1757",Er="_registrationGuide_14ipf_1760",Dr="_adapterSetupContext_14ipf_1761",Ir="_valueSearch_14ipf_1762",Tr="_firstProfileName_14ipf_1763",Lr="_sourceIntro_14ipf_1767",Mr="_catalogGroups_14ipf_1771",$r="_catalogRow_14ipf_1772",Vr="_candidateActions_14ipf_1780",Or="_candidateEntry_14ipf_1782",Br="_propertySelection_14ipf_1783",Fr="_propertySelectionHeader_14ipf_1784",Gr="_selectedInstance_14ipf_1785",Hr="_propertyPickerLabel_14ipf_1786",qr="_propertyPicker_14ipf_1786",Ur="_propertyPickerTrigger_14ipf_1792",Kr="_propertyPickerPanel_14ipf_1794",zr="_propertyPickerSearchRow_14ipf_1796",Wr="_propertyPickerList_14ipf_1800",Jr="_propertyPickerGroup_14ipf_1802",Yr="_propertyPickerOption_14ipf_1805",Qr="_compoundEditor_14ipf_1811",Xr="_compoundCoordinates_14ipf_1812",Zr="_colorSwatch_14ipf_1819",eo="_candidateAction_14ipf_1780",to="_candidateActionSizer_14ipf_1836",ao="_candidateError_14ipf_1840",so="_valueManagerFooter_14ipf_1842",no="_catalogDetails_14ipf_1843",io="_inlineNotice_14ipf_1852",lo="_subscriptionUsage_14ipf_1853",ro="_pendingProfileAction_14ipf_1854",oo="_registrationExample_14ipf_1859",co="_registrationActions_14ipf_1862",s={page:$a,sampleBanner:Va,sampleBannerRow:Oa,sampleBannerMain:Ba,sampleBadge:Fa,sampleTitle:Ga,sampleMessage:Ha,sampleActions:qa,primaryAction:Ua,secondaryAction:Ka,resetAction:za,card:Wa,cardHeader:Ja,clearButton:Ya,statusRow:Qa,statusIndicator:Xa,statusRunning:Za,statusPaused:es,statusNotRunning:ts,statusLabel:as,statusMeta:ss,controlButtons:ns,btn:is,btnPrimary:ls,btnDanger:rs,historyList:os,historyItem:cs,stepDisclosure:ds,historyItemSelected:us,historyItemHeader:ps,historyIcon:fs,historyTimestamp:ms,historyName:hs,recordKind:ys,historyItemMeta:vs,historyMode:gs,historyDuration:bs,historyStatus:_s,status_passed:xs,status_failed:js,status_running:Ss,status_timed_out:ws,status_cancelled:Ns,status_insufficient_evidence:Cs,historyError:Rs,historyEvidence:Ps,historyLimitation:ks,detailShell:As,detailHeader:Es,detailHeading:Ds,detailRecordName:Is,detailCloseButton:Ts,detailRetryButton:Ls,detailBody:Ms,detailState:$s,detailErrorTitle:Vs,detailErrorMessage:Os,reportContainer:Bs,runSummary:Fs,viewerSection:Gs,summaryLead:Hs,summaryStatusMark:qs,viewerHeading:Us,summaryName:Ks,summaryReason:zs,summaryFacts:Ws,subsectionLabel:Js,sectionHeadingRow:Ys,sectionHint:Qs,dimensionGrid:Xs,dimensionCard:Zs,dimensionHeader:en,statusMark:tn,dimensionName:an,requirementBadge:sn,dimensionStatus:nn,dimensionMeta:ln,tone_passed:rn,tone_failed:on,tone_timed_out:cn,tone_cancelled:dn,tone_insufficient_evidence:un,tone_unavailable:pn,tone_skipped:fn,tone_not_requested:mn,stepList:hn,stepItem:yn,stepIndex:vn,stepIdentity:gn,stepName:bn,stepMeta:_n,stepStatus:xn,chevron:jn,chevronOpen:Sn,stepDetails:wn,evidenceBlock:Nn,evidenceLabel:Cn,stepError:Rn,recordProblem:Pn,capabilityGrid:kn,capabilityItem:An,capabilityYes:En,capabilityNo:Dn,capabilityState:In,limitations:Tn,artifactList:Ln,agentList:Mn,artifactDisclosures:$n,artifactDisclosure:Vn,artifactButton:On,artifactContent:Bn,limitationItem:Fn,reportContextPanel:Gn,reportContextRow:Hn,reportContextLabel:qn,reportSection:Un,reportSectionHeader:Kn,reportMarkdown:zn,reportLogs:Wn,emptyState:Jn,emptyStateTitle:Yn,emptyStateMessage:Qn,upgradePanel:Xn,upgradePanelIcon:Zn,upgradePanelTitle:ei,upgradePanelDesc:ti,benefitList:ai,benefitItem:si,upgradeActions:ni,workspaceTabs:ii,sessionHelp:li,stopAction:ri,controlEditor:oi,profileToolbar:ci,profileDialog:di,sessionBar:ui,sessionIdentity:pi,sessionActions:fi,profileActions:mi,profileDialogActions:hi,liveWorkspace:yi,profileLabelRow:vi,profileHint:gi,actualValue:bi,watchReading:_i,liveGrid:xi,livePanel:ji,panelEmpty:Si,controlAvailability:wi,controlGate:Ni,controlGateTrigger:Ci,controlGateHint:Ri,editorLabel:Pi,editorHeading:ki,savedValueState:Ai,valueToolbar:Ei,valueFilters:Di,valuePagination:Ii,valueListStatus:Ti,valueCount:Li,layoutHint:Mi,srOnly:$i,unifiedValueRows:Vi,liveRows:Oi,watchRows:Bi,valueGroup:Fi,valueGroupToggle:Gi,valueGroupRows:Hi,controlRow:qi,watchRow:Ui,actionRow:Ki,historyBrowser:zi,historyToolbar:Wi,rowIdentity:Ji,freshness:Yi,presentationMeta:Qi,rowFeedback:Xi,controlEditorRow:Zi,controlActions:el,applyOnStartOption:tl,valueDetails:al,valueDetailButton:sl,valueDetailShell:nl,valueDetailBody:il,valueDetailList:ll,valueDetailActions:rl,valueDetailFeedback:ol,defaultValueEditor:cl,defaultBooleanEditor:dl,booleanEditor:ul,rangeEditor:pl,valueWorkspacePanel:fl,valueWorkspaceHeader:ml,valueSections:hl,valueSection:yl,valueSectionHeader:vl,valueSectionHeading:gl,valueSectionCount:bl,valueSectionHeaderActions:_l,sectionDragHandle:xl,sectionMoveButton:jl,valueReorderControls:Sl,dragHandle:wl,runtimeSettings:Nl,runtimeSettingSwitch:Cl,runtimeSettingSwitchInput:Rl,runtimeSettingSwitchTrack:Pl,runtimeSettingSwitchThumb:kl,layoutError:Al,controlValueList:El,watchValueGrid:Dl,actionValueList:Il,valueEntryShell:Tl,watchCardMain:Ll,watchDetails:Ml,actionSummary:$l,actionExecution:Vl,actionParameter:Ol,actionInactiveReason:Bl,actionParameterGrid:Fl,actionParameterError:Gl,deploymentGuide:Hl,deploymentScope:ql,deploymentLifecycle:Ul,deploymentNotice:Kl,deploymentChecklist:zl,deploymentDescription:Wl,deploymentDetails:Jl,inlineError:Yl,profileEditorDialog:Ql,profileDialogBody:Xl,profileDeleteAction:Zl,profileDeleteReason:er,bindingTabs:tr,bindingList:ar,bindingEmpty:sr,bindingItem:nr,bindingItemCopy:ir,bindingPresentation:lr,bindingPin:rr,bindingItemActions:or,bindingDelete:cr,addBindingButton:dr,bindingForm:ur,bindingFormGrid:pr,bindingBooleanDefault:fr,bindingPathField:mr,rangeFields:hr,selectionButton:yr,bindingFormActions:vr,bindingError:gr,valueManagerShell:br,valueSourceTabs:_r,valueManagerBody:xr,valueSourcePanel:jr,registeredIntro:Sr,registeredEmpty:wr,registeredSteps:Nr,registeredEmptyActions:Cr,adapterSetupList:Rr,adapterSetupRow:Pr,adapterMethods:kr,connectionGuide:Ar,registrationGuide:Er,adapterSetupContext:Dr,valueSearch:Ir,firstProfileName:Tr,sourceIntro:Lr,catalogGroups:Mr,catalogRow:$r,candidateActions:Vr,candidateEntry:Or,propertySelection:Br,propertySelectionHeader:Fr,selectedInstance:Gr,propertyPickerLabel:Hr,propertyPicker:qr,propertyPickerTrigger:Ur,propertyPickerPanel:Kr,propertyPickerSearchRow:zr,propertyPickerList:Wr,propertyPickerGroup:Jr,propertyPickerOption:Yr,compoundEditor:Qr,compoundCoordinates:Xr,colorSwatch:Zr,candidateAction:eo,candidateActionSizer:to,candidateError:ao,valueManagerFooter:so,catalogDetails:no,inlineNotice:io,subscriptionUsage:lo,pendingProfileAction:ro,registrationExample:oo,registrationActions:co};function We(e){return e.trim().toLowerCase()}function uo(e){switch(We(e)){case"passed":return"✓";case"failed":case"timed_out":return"×";case"running":return"◔";case"cancelled":case"insufficient_evidence":return"!";default:return"–"}}function po(e,a){switch(We(a)){case"run":return e("playtest.status.mode.run","Run");case"server":return e("playtest.status.mode.server","Server");case"edit":return e("playtest.status.mode.edit","Edit");case"play":return e("playtest.status.mode.play","Play");default:return a}}function fo(e,a){const n=We(a);return n==="running"?e("playtest.history.status.running","Running"):Ve(e,n)}function mo(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function ho(e){const a=/^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})(\d{2})$/.exec(e);if(a){const[,i,d,c,u,y,m]=a,_=new Date(Date.UTC(Number(i),Number(d)-1,Number(c),Number(u),Number(y),Number(m)));return _.getUTCFullYear()===Number(i)&&_.getUTCMonth()===Number(d)-1&&_.getUTCDate()===Number(c)&&_.getUTCHours()===Number(u)&&_.getUTCMinutes()===Number(y)&&_.getUTCSeconds()===Number(m)?_:null}const n=Date.parse(e);return Number.isNaN(n)?null:new Date(n)}function yo(e,a){const n=ho(e);return n?new Intl.DateTimeFormat(a,{dateStyle:"medium",timeStyle:"short"}).format(n):e}function vo({entries:e,onSelect:a,selectedRecordId:n}){const{t:i,locale:d}=ue(),[c,u]=o.useState(""),[y,m]=o.useState("all"),[_,C]=o.useState(0),k=o.useMemo(()=>{const R=c.trim().toLocaleLowerCase();return e.filter(M=>(y==="all"||We(M.status)===y)&&(!R||[M.testName,M.status,M.mode,M.recordKind].join(" ").toLocaleLowerCase().includes(R)))},[e,c,y]),x=Math.max(1,Math.ceil(k.length/50)),f=Math.min(_,x-1),V=k.slice(f*50,(f+1)*50);return e.length===0?t.jsx("div",{className:s.emptyState,children:i("playtest.history.empty","No test results yet")}):t.jsxs("div",{className:s.historyBrowser,children:[t.jsxs("div",{className:s.historyToolbar,children:[t.jsxs("label",{children:[t.jsx("span",{children:i("playtest.history.search","Search test results")}),t.jsx("input",{type:"search",value:c,onChange:R=>{u(R.target.value),C(0)}})]}),t.jsxs("label",{children:[t.jsx("span",{children:i("playtest.history.filter","Result")}),t.jsxs("select",{value:y,onChange:R=>{m(R.target.value),C(0)},children:[t.jsx("option",{value:"all",children:i("playtest.history.filterAll","All results")}),t.jsx("option",{value:"passed",children:i("playtest.result.status.passed","Passed")}),t.jsx("option",{value:"failed",children:i("playtest.result.status.failed","Failed")}),t.jsx("option",{value:"insufficient_evidence",children:i("playtest.result.status.insufficientEvidence","Insufficient evidence")}),t.jsx("option",{value:"timed_out",children:i("playtest.result.status.timedOut","Timed out")})]})]})]}),t.jsx("div",{className:s.valueCount,role:"status",children:i("playtest.history.filteredCount","{{visible}} of {{total}} results").replace("{{visible}}",String(k.length)).replace("{{total}}",String(e.length))}),t.jsx("div",{className:s.historyList,children:V.map(R=>{const M=R.recordId===n;return t.jsxs("button",{className:`${s.historyItem} ${M?s.historyItemSelected:""}`,onClick:w=>a(R.recordId,w.currentTarget),"aria-current":M?"true":void 0,"aria-haspopup":"dialog",children:[t.jsxs("div",{className:s.historyItemHeader,children:[t.jsx("span",{className:s.historyIcon,children:uo(R.status)}),t.jsx("span",{className:s.historyTimestamp,children:yo(R.timestamp,d)}),t.jsx("span",{className:s.historyName,children:R.testName}),t.jsx("span",{className:s.recordKind,children:R.recordKind==="structured"?i("playtest.history.kind.structured","Structured"):R.recordKind==="legacy"?i("playtest.history.kind.legacy","Legacy"):i("playtest.history.kind.attention","Needs attention")})]}),t.jsxs("div",{className:s.historyItemMeta,children:[t.jsx(it,{text:i("playtest.history.mode.tooltip","Playtest mode used for this recorded test run."),children:t.jsxs("span",{className:s.historyMode,children:[i("playtest.history.mode","Mode"),": ",po(i,R.mode)]})}),t.jsx("span",{className:s.historyDuration,children:mo(R.durationMs)}),t.jsx(it,{text:i("playtest.history.status.tooltip","Recorded result state for this automated playtest run."),children:t.jsx("span",{className:`${s.historyStatus} ${s[`status_${We(R.status)}`]??""}`,children:fo(i,R.status)})})]}),R.evidenceSummary&&t.jsxs("div",{className:s.historyEvidence,children:[t.jsxs("span",{children:[i("playtest.dimension.server","Server"),": ",Ve(i,R.evidenceSummary.server.status)]}),t.jsxs("span",{children:[i("playtest.dimension.clientUi","Client UI"),": ",Ve(i,R.evidenceSummary.clientUi.status)]}),R.agentCounts&&t.jsx("span",{children:i("playtest.history.agentCounts","Server {server} · Client {client}").replace("{server}",String(R.agentCounts.server)).replace("{client}",String(R.agentCounts.client))})]}),R.errorMessage&&t.jsx("div",{className:s.historyError,children:R.errorMessage}),!R.errorMessage&&R.limitation&&t.jsx("div",{className:s.historyLimitation,children:Ot(i,R.limitation.code,R.limitation.message)})]},R.recordId)})}),x>1&&t.jsxs("div",{className:s.valuePagination,children:[t.jsx("button",{type:"button",disabled:f===0,onClick:()=>C(R=>R-1),children:i("playtest.values.previous","Previous")}),t.jsxs("span",{children:[f+1," / ",x]}),t.jsx("button",{type:"button",disabled:f+1>=x,onClick:()=>C(R=>R+1),children:i("playtest.values.next","Next")})]})]})}function rt({label:e,open:a,onToggle:n,children:i,tooltip:d}){const c=o.useId();return t.jsxs("div",{className:s.artifactDisclosure,children:[t.jsxs("button",{className:s.artifactButton,onClick:n,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),n())},"aria-expanded":a,"aria-controls":c,children:[d?t.jsx(it,{text:d,children:t.jsx("span",{children:e})}):t.jsx("span",{children:e}),t.jsx("span",{"aria-hidden":"true",className:`${s.chevron} ${a?s.chevronOpen:""}`,children:"⌄"})]}),a&&t.jsx("div",{className:s.artifactContent,id:c,children:i})]})}function go({detail:e}){const{t:a}=ue(),[n,i]=o.useState(()=>new Set(e.recordKind==="legacy"?["report","logs"]:[])),d=y=>i(m=>{const _=new Set(m);return _.has(y)?_.delete(y):_.add(y),_}),c=e.result?{schemaVersion:e.result.schemaVersion,sessionId:e.result.sessionId,recordId:e.result.recordId,startedAt:e.result.startedAt,endedAt:e.result.endedAt,files:e.result.artifacts.files}:null,u=e.artifactErrors??[];return!c&&!e.markdown&&!e.logs&&u.length===0?null:t.jsxs("section",{className:s.viewerSection,"aria-labelledby":"playtest-artifacts-heading",children:[t.jsx("h3",{id:"playtest-artifacts-heading",className:s.viewerHeading,children:a("playtest.artifacts.title","Artifacts")}),t.jsxs("div",{className:s.artifactDisclosures,children:[c&&t.jsx(rt,{label:a("playtest.artifacts.metadata","Result metadata"),open:n.has("metadata"),onToggle:()=>d("metadata"),children:t.jsx("pre",{children:at(c)})}),e.markdown&&t.jsx(rt,{label:a("playtest.report.content","Report"),tooltip:a("playtest.report.content.tooltip","Markdown summary for the selected automated playtest run."),open:n.has("report"),onToggle:()=>d("report"),children:t.jsx("pre",{children:e.markdown})}),e.logs&&t.jsx(rt,{label:a("playtest.report.logs","Logs"),tooltip:a("playtest.report.logs.tooltip","Execution logs captured for the selected automated playtest run."),open:n.has("logs"),onToggle:()=>d("logs"),children:t.jsx("pre",{children:e.logs})})]}),u.map(y=>t.jsx("div",{className:s.stepError,children:y.message},`${y.code}-${y.message}`))]})}function bo({result:e}){const{t:a}=ue(),n=[[a("playtest.capability.semanticUi","Semantic UI snapshot"),e.capabilities.semanticUiSnapshot],[a("playtest.capability.virtualInput","Virtual input"),e.capabilities.virtualInput],[a("playtest.capability.fixedBootstrap","Fixed agent bootstrap"),e.capabilities.fixedBootstrap],[a("playtest.capability.projectAdapter","Project test adapter"),e.capabilities.projectTestAdapter]];return t.jsxs("section",{className:s.viewerSection,"aria-labelledby":"playtest-capabilities-heading",children:[t.jsx("h3",{id:"playtest-capabilities-heading",className:s.viewerHeading,children:a("playtest.capability.title","Capabilities and limits")}),t.jsx("div",{className:s.capabilityGrid,children:n.map(([i,d])=>t.jsxs("div",{className:s.capabilityItem,children:[t.jsx("span",{className:d?s.capabilityYes:s.capabilityNo,"aria-hidden":"true",children:d?"✓":"–"}),t.jsx("span",{children:i}),t.jsx("span",{className:s.capabilityState,children:d?a("playtest.capability.available","Available"):a("playtest.capability.unavailable","Unavailable")})]},i))}),e.agents.length>0&&t.jsxs("div",{className:s.agentList,children:[t.jsx("span",{className:s.subsectionLabel,children:a("playtest.agents.title","Test agents")}),e.agents.map((i,d)=>{const c=typeof i.agentId=="string"?i.agentId:`${a("playtest.agents.unknown","Agent")} ${d+1}`,u=typeof i.role=="string"?i.role:"unknown",y=typeof i.clientId=="string"?` · ${i.clientId}`:"";return t.jsxs("code",{children:[c," · ",u,y]},`${c}-${d}`)})]}),e.limitations.length>0&&t.jsxs("div",{className:s.limitations,children:[t.jsx("div",{className:s.subsectionLabel,children:a("playtest.limitations.title","Limitations")}),e.limitations.map(i=>t.jsxs("div",{className:s.limitationItem,children:["! ",Ot(a,i.code,i.message)]},i.code))]})]})}const _o=["server","clientUi","interaction","visual"];function xo({result:e}){const{t:a}=ue(),n={server:a("playtest.dimension.server","Server"),clientUi:a("playtest.dimension.clientUi","Client UI"),interaction:a("playtest.dimension.interaction","Interaction"),visual:a("playtest.dimension.visual","Visual")};return t.jsxs("section",{className:s.viewerSection,"aria-labelledby":"playtest-dimensions-heading",children:[t.jsxs("div",{className:s.sectionHeadingRow,children:[t.jsx("h3",{id:"playtest-dimensions-heading",className:s.viewerHeading,children:a("playtest.dimension.title","Evidence dimensions")}),t.jsx("span",{className:s.sectionHint,children:a("playtest.dimension.hint","Required evidence is marked below.")})]}),t.jsx("div",{className:s.dimensionGrid,children:_o.map(i=>{const d=e.dimensions[i];return t.jsxs("div",{className:s.dimensionCard,children:[t.jsxs("div",{className:s.dimensionHeader,children:[t.jsx("span",{className:`${s.statusMark} ${s[`tone_${d.status}`]??""}`,"aria-hidden":"true",children:vt(d.status)}),t.jsx("span",{className:s.dimensionName,children:n[i]}),t.jsx("span",{className:s.requirementBadge,children:d.required?a("playtest.dimension.required","Required"):a("playtest.dimension.optional","Optional")})]}),t.jsx("div",{className:s.dimensionStatus,children:Ve(a,d.status)}),d.provider&&t.jsx("div",{className:s.dimensionMeta,children:d.provider}),d.reason&&t.jsx("div",{className:s.dimensionMeta,children:Ma(a,d.reason)}),t.jsxs("div",{className:s.dimensionMeta,children:[a("playtest.dimension.steps","Steps"),": ",d.stepIds.length]})]},i)})})]})}function jo({result:e}){const{t:a}=ue(),n=o.useId(),[i,d]=o.useState(()=>new Set),c=u=>{d(y=>{const m=new Set(y);return m.has(u)?m.delete(u):m.add(u),m})};return t.jsxs("section",{className:s.viewerSection,"aria-labelledby":`${n}-heading`,children:[t.jsx("h3",{id:`${n}-heading`,className:s.viewerHeading,children:a("playtest.steps.title","Step timeline")}),t.jsx("div",{className:s.stepList,children:e.steps.map(u=>{const y=i.has(u.stepId),m=`${n}-${u.index}-details`,_=u.target.role==="server"?a("playtest.steps.server","Server"):u.target.clientId;return t.jsxs("div",{className:s.stepItem,children:[t.jsxs("button",{className:s.stepDisclosure,onClick:()=>c(u.stepId),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),c(u.stepId))},"aria-expanded":y,"aria-controls":m,children:[t.jsx("span",{className:`${s.statusMark} ${s[`tone_${u.status}`]??""}`,"aria-hidden":"true",children:vt(u.status)}),t.jsx("span",{className:s.stepIndex,children:u.index+1}),t.jsxs("span",{className:s.stepIdentity,children:[t.jsx("span",{className:s.stepName,children:u.stepId}),t.jsxs("span",{className:s.stepMeta,children:[_," · ",u.action," · ",Vt(u.durationMs)]})]}),t.jsx("span",{className:s.stepStatus,children:Ve(a,u.status)}),t.jsx("span",{className:`${s.chevron} ${y?s.chevronOpen:""}`,"aria-hidden":"true",children:"⌄"})]}),y&&t.jsxs("div",{className:s.stepDetails,id:m,role:"region","aria-label":`${u.stepId} ${a("playtest.steps.details","details")}`,children:[u.expected!==void 0&&t.jsxs("div",{className:s.evidenceBlock,children:[t.jsx("div",{className:s.evidenceLabel,children:a("playtest.steps.expected","Expected")}),t.jsx("pre",{children:at(u.expected)})]}),u.observed!==void 0&&t.jsxs("div",{className:s.evidenceBlock,children:[t.jsx("div",{className:s.evidenceLabel,children:a("playtest.steps.observed","Observed")}),t.jsx("pre",{children:at(u.observed)})]}),u.evidence!==void 0&&t.jsxs("div",{className:s.evidenceBlock,children:[t.jsx("div",{className:s.evidenceLabel,children:a("playtest.steps.evidence","Evidence")}),t.jsx("pre",{children:at(u.evidence)})]}),u.error&&t.jsxs("div",{className:s.stepError,children:[t.jsx("strong",{children:u.error.code})," — ",u.error.message]})]})]},u.stepId)})})]})}function So({report:e}){var i;const{t:a}=ue(),n=e.recordKind==="incomplete_structured"?a("playtest.record.incomplete","Structured result is incomplete"):e.recordKind==="corrupt_structured"?a("playtest.record.corrupt","Structured result is damaged"):a("playtest.record.unsupported","Structured result version is unsupported");return t.jsxs("div",{className:s.recordProblem,role:"status",children:[t.jsx("strong",{children:n}),t.jsx("span",{children:((i=e.error)==null?void 0:i.message)??a("playtest.record.unavailable","Result details are unavailable.")})]})}function wo({report:e}){var d,c,u,y,m,_;const{t:a}=ue(),n=!!((d=e.contextSummary)!=null&&d.testScenario||(c=e.contextSummary)!=null&&c.expectedBehavior||(u=e.contextSummary)!=null&&u.observedBehavior),i=e.recordKind==="structured"?e.result:void 0;return t.jsxs("div",{className:s.reportContainer,children:[i&&t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:s.runSummary,"aria-labelledby":"playtest-summary-heading",children:[t.jsxs("div",{className:s.summaryLead,children:[t.jsx("span",{className:`${s.summaryStatusMark} ${s[`tone_${i.overallStatus}`]??""}`,"aria-hidden":"true",children:vt(i.overallStatus)}),t.jsxs("div",{children:[t.jsx("h3",{id:"playtest-summary-heading",className:s.viewerHeading,children:a("playtest.summary.title","Run summary")}),t.jsx("div",{className:s.summaryName,children:i.testName}),t.jsx("div",{className:s.summaryReason,children:i.terminalReason.message})]})]}),t.jsxs("div",{className:s.summaryFacts,children:[t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.status","Status")}),t.jsx("strong",{children:Ve(a,i.overallStatus)})]}),t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.mode","Mode")}),t.jsx("strong",{children:i.mode==="play"?a("playtest.status.mode.play","Play"):a("playtest.status.mode.run","Run")})]}),t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.duration","Duration")}),t.jsx("strong",{children:Vt(i.durationMs)})]}),t.jsxs("div",{children:[t.jsx("span",{children:a("playtest.summary.cleanup","Cleanup")}),t.jsx("strong",{children:Ve(a,i.cleanup.status)})]})]})]}),t.jsx(xo,{result:i}),t.jsx(jo,{result:i}),t.jsx(bo,{result:i})]}),e.recordKind!=="structured"&&e.recordKind!=="legacy"&&t.jsx(So,{report:e}),n&&t.jsxs("div",{className:s.reportContextPanel,children:[((y=e.contextSummary)==null?void 0:y.testScenario)&&t.jsxs("div",{className:s.reportContextRow,children:[t.jsx("span",{className:s.reportContextLabel,children:a("playtest.context.why","Why this test ran")}),t.jsx("span",{children:e.contextSummary.testScenario})]}),((m=e.contextSummary)==null?void 0:m.expectedBehavior)&&t.jsxs("div",{className:s.reportContextRow,children:[t.jsx("span",{className:s.reportContextLabel,children:a("playtest.context.expected","Expected")}),t.jsx("span",{children:e.contextSummary.expectedBehavior})]}),((_=e.contextSummary)==null?void 0:_.observedBehavior)&&t.jsxs("div",{className:s.reportContextRow,children:[t.jsx("span",{className:s.reportContextLabel,children:a("playtest.context.observed","Observed")}),t.jsx("span",{children:e.contextSummary.observedBehavior})]})]}),t.jsx(go,{detail:e},e.recordId),!i&&!e.markdown&&!e.logs&&e.recordKind==="legacy"&&t.jsx("div",{className:s.emptyState,children:a("playtest.report.empty","No report content available")})]})}function Rt(e){return typeof e=="number"?{placeId:String(e)}:void 0}const me={listProfiles:async e=>De.get("/api/dashboard/playtest/control-profiles",Rt(e)),liveStatus:async(e,a)=>De.get("/api/dashboard/playtest/live",{...Rt(e)??{},...a?{leaseId:a}:{}}),liveAction:async e=>De.post("/api/dashboard/playtest/live",e),bindingDraft:async(e,a)=>De.post("/api/dashboard/playtest/binding-draft",{...e,...typeof a=="number"?{placeId:a}:{}}),bindingCandidates:async e=>De.post("/api/dashboard/playtest/binding-candidates",{...typeof e=="number"?{placeId:e}:{}}),saveProfile:async(e,a,n)=>De.put(`/api/dashboard/playtest/control-profiles/${encodeURIComponent(e.id)}`,{profile:e,expectedRevision:a,...typeof n=="number"?{placeId:n}:{}}),saveProfileMetadata:async(e,a,n,i)=>De.patch(`/api/dashboard/playtest/control-profiles/${encodeURIComponent(e)}/metadata`,{expectedRevision:a,...n,...typeof i=="number"?{placeId:i}:{}}),deleteProfile:async(e,a,n)=>{const i=new URLSearchParams({expectedRevision:String(a)});return n.placeId!==void 0&&i.set("placeId",String(n.placeId)),De.delete(`/api/dashboard/playtest/control-profiles/${encodeURIComponent(e)}?${i.toString()}`,n.clientId?{clientId:n.clientId}:void 0)}},Bt="weppy-playtest-workspace-v1",No="weppy-playtest-profile-v1:";function Je(){try{return window.localStorage}catch{return null}}function Co(){var e;try{const a=(e=Je())==null?void 0:e.getItem(Bt);return a==="live"||a==="results"?a:"live"}catch{return"live"}}function Ro(e){var a;try{(a=Je())==null||a.setItem(Bt,e)}catch{}}function gt(e){return`${No}${e}`}function Po(e){var a;if(e===null)return null;try{return((a=Je())==null?void 0:a.getItem(gt(e)))||null}catch{return null}}function Ye(e,a){var n;if(e!==null)try{(n=Je())==null||n.setItem(gt(e),a)}catch{}}function Pt(e){var a;if(e!==null)try{(a=Je())==null||a.removeItem(gt(e))}catch{}}const Qe={entries:[],diagnostics:[]},Xe={hasManagedAdapterWithoutStudioGuard:!1};function He(e){return typeof e=="object"&&e!==null&&"error"in e&&typeof e.error=="string"?e.error:e instanceof Error?e.message:String(e)}function ko(e){if(typeof e!="object"||e===null||!("payload"in e))return!1;const a=e.payload;return(a==null?void 0:a.errorCode)==="lease_agents_unavailable"}function Ao(e){const{enabled:a,canMutate:n,placeId:i,studioSnapshot:d}=e,[c,u]=o.useState([]),[y,m]=o.useState(!1),[_,C]=o.useState(null),[k,x]=o.useState(null),[f,V]=o.useState(Qe),[R,M]=o.useState(Xe),[w,B]=o.useState({}),[P,E]=o.useState({}),[W,$]=o.useState({}),[ee,te]=o.useState(!0),[H,O]=o.useState(null),[z,U]=o.useState(null),L=o.useRef(null),ae=o.useRef(null),J=o.useRef([]),le=o.useRef(!1),Q=o.useRef(Promise.resolve()),K=o.useRef(0),Z=o.useRef(0),X=o.useRef(null),he=o.useRef(Promise.resolve()),re=o.useRef(null),oe=o.useRef(i);oe.current=i;const[ye,we]=o.useState(0);L.current=k;const q=o.useMemo(()=>c.find(v=>v.id===_)??null,[c,_]);ae.current=q,J.current=c;const se=o.useCallback(()=>{E(v=>Object.fromEntries(Object.entries(v).map(([S,A])=>{const{observed:N,...G}=A;return[S,{...G,status:"unavailable",fresh:!1,...N!==void 0?{lastObserved:N}:{},reason:"session_ended"}]})))},[]),ne=o.useCallback(async()=>{X.current&&(clearTimeout(X.current),X.current=null),Z.current=0;const v=L.current;if(v){L.current=null,x(null),B({}),$({}),se();try{await me.liveAction({action:"close",leaseId:v.leaseId,...typeof i=="number"?{placeId:i}:{}})}catch{}}},[se,i]),ce=o.useCallback(async()=>{if(!(L.current||le.current)){le.current=!0;try{let v=ae.current,S=oe.current,A=await me.liveAction({action:v?"observe":"discover",...v?{profileId:v.id}:{},...typeof S=="number"?{placeId:S}:{}});const N=ae.current,G=oe.current,l=(N==null?void 0:N.id)??"__weppy_catalog__";(A.lease.profileId!==l||G!==S)&&(v=N,S=G,A=await me.liveAction({action:v?"observe":"discover",...v?{profileId:v.id}:{},...typeof S=="number"?{placeId:S}:{}})),L.current=A.lease,x(A.lease),A.lease.catalog&&V(A.lease.catalog),B({});const r=await me.liveStatus(S,A.lease.leaseId);E(Object.fromEntries(r.watches.map(g=>[g.subscriptionId,g]))),X.current&&clearTimeout(X.current),X.current=null,Z.current=0,U(null)}catch(v){if(U(He(v)),ko(v)&&!X.current){const S=Z.current;Z.current+=1;const A=Math.min(2e3,250*2**Math.min(S,3));X.current=setTimeout(()=>{X.current=null,we(N=>N+1)},A)}}finally{le.current=!1}}},[]);o.useEffect(()=>{a||ne()},[ne,a]),o.useEffect(()=>{let v=!1;return te(!0),m(!1),u([]),C(null),re.current=null,x(null),B({}),E({}),$({}),V(Qe),M(Xe),(async()=>{const A=me.listProfiles(i).then(N=>{var r,g;if(v)return;u(N.profiles),re.current=(r=N.scope)!=null&&r.placeId?{placeId:N.scope.placeId}:N.targetClientId?{clientId:N.targetClientId}:typeof i=="number"?{placeId:i}:null,V(N.catalog??Qe),M(N.releaseGuidance??Xe);const G=Po(i),l=N.profiles.some(D=>D.id===G)?G:((g=N.profiles[0])==null?void 0:g.id)??null;C(l),l&&Ye(i,l),m(!0)}).catch(N=>{v||(U(He(N)),m(!0))});try{await A}finally{v||te(!1)}})(),()=>{v=!0}},[a,i]),o.useEffect(()=>{const v=++K.current,S=a&&y&&d.targetClientId!==null&&(d.state==="Running"||d.state==="Paused");!S&&X.current&&(clearTimeout(X.current),X.current=null,Z.current=0),Q.current=Q.current.catch(()=>{}).then(async()=>{if(v!==K.current)return;const A=L.current;A&&(!S||A.target.clientId!==d.targetClientId)&&await ne(),v===K.current&&S&&!L.current&&await ce()})},[ne,a,ce,ye,y,d.state,d.mode,d.targetClientId]),o.useEffect(()=>{if(!a)return;const v=new Ut,S=v.on("playtest_watch",A=>{var G,l;const N=A;!(N!=null&&N.subscriptionId)||N.leaseId!==((G=L.current)==null?void 0:G.leaseId)||(N.profileGeneration??1)===(((l=L.current)==null?void 0:l.profileGeneration)??1)&&E(r=>{const g=r[N.subscriptionId];if(g&&N.sequence<=g.sequence&&N.sequence!==0)return r;const h=g&&N.sequence>0&&g.sequence>0&&N.sequence!==g.sequence+1?(()=>{const{observed:b,...T}=N;return{...T,status:"stale",fresh:!1,...b!==void 0?{lastObserved:b}:{},reason:"sequence_gap"}})():N;return{...r,[N.subscriptionId]:h}})});return v.connect(),()=>{S(),v.disconnect()}},[a]);const ie=o.useCallback(async v=>{var N;const S=J.current.find(G=>G.id===v);if(!S)return;const A=L.current;if(!A){C(v),Ye(i,v);return}if(A.profileId===S.id&&A.profileRevision===S.revision){C(v),Ye(i,v);return}O(v),U(null);try{const G=A.profileGeneration??1,l=await me.liveAction({action:"observe",profileId:v,...typeof i=="number"?{placeId:i}:{}});L.current=l.lease,x(l.lease),C(v),Ye(i,v),(l.lease.profileGeneration??1)!==G&&(B({}),$({}));const r=await me.liveStatus(i,l.lease.leaseId);(((N=L.current)==null?void 0:N.profileGeneration)??1)===(l.lease.profileGeneration??1)&&E(Object.fromEntries(r.watches.map(g=>[g.subscriptionId,g])))}catch(G){U(He(G))}finally{O(null)}},[i]),Ne=o.useCallback(async(v,S)=>{var G;const A=L.current;if(!A||!n)return;const N=A.profileGeneration??1;B(l=>({...l,[v]:{...l[v],status:"applying",draft:S}}));try{const l=await me.liveAction({action:"apply",leaseId:A.leaseId,expectedRevision:A.revision,values:{[v]:S},...typeof i=="number"?{placeId:i}:{}}),r=l.result.bindings.find(g=>g.bindingId===v);if((((G=L.current)==null?void 0:G.profileGeneration)??1)!==N)return;x(g=>g&&(g.profileGeneration??1)===N?{...g,revision:l.result.revision}:g),B(g=>{var D,h;return{...g,[v]:l.result.status==="applied"?{status:"applied",draft:S,requested:(r==null?void 0:r.requested)??S,observed:r==null?void 0:r.observed,original:r==null?void 0:r.original}:{...g[v],status:((D=l.result.error)==null?void 0:D.code)==="requires_adapter"?"requires_adapter":"error",draft:S,message:(h=l.result.error)==null?void 0:h.message}}})}catch(l){const r=typeof l=="object"&&l!==null&&"status"in l&&l.status===409;B(g=>({...g,[v]:{...g[v],status:r?"conflict":"error",draft:S,message:He(l)}}))}},[n,i]),ve=o.useCallback(async()=>{const v=L.current;if(!v||!n)return;const S=await me.liveAction({action:"reset",leaseId:v.leaseId,...typeof i=="number"?{placeId:i}:{}});x(S.lease),B({})},[n,i]),_e=o.useCallback(async(v,S,A)=>{var g,D;const N=L.current,G=ae.current;if(!N||!G||!n||d.state!=="Running")return;const l=structuredClone(S),r=N.profileGeneration??1;$(h=>({...h,[v]:{status:"running",requestId:A,actionId:v,arguments:l,executedAtMs:Date.now()}}));try{const h=await me.liveAction({action:"execute_action",leaseId:N.leaseId,profileId:G.id,actionId:v,requestId:A,expectedProfileRevision:G.revision,expectedRevision:N.revision,arguments:l,...typeof i=="number"?{placeId:i}:{}});(((g=L.current)==null?void 0:g.profileGeneration)??1)===r&&$(b=>({...b,[v]:h.result}))}catch(h){const b=typeof h=="object"&&h!==null&&"payload"in h?h.payload:void 0,T=(b==null?void 0:b.errorCode)==="action_result_unknown"||(b==null?void 0:b.errorCode)==="plugin_disconnected"||(b==null?void 0:b.errorCode)==="command_timeout";if((((D=L.current)==null?void 0:D.profileGeneration)??1)!==r)return;$(I=>({...I,[v]:{status:T?"unknown":"failed",requestId:A,actionId:v,arguments:l,executedAtMs:Date.now(),error:{code:(b==null?void 0:b.errorCode)??"action_failed",message:He(h)}}}))}},[n,i,d.state]),xe=o.useCallback(async v=>{const S=v.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||`profile-${Date.now()}`,A=await me.saveProfile({schemaVersion:4,id:S,name:v.trim(),controls:[],watches:[],actions:[],presentation:{},settings:{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"},sectionOrder:["watches","controls","actions"]},0,i);return u(N=>[...N,A.profile]),J.current=[...J.current,A.profile],await ie(A.profile.id),A.profile},[i,ie]),Ce=o.useCallback(async v=>{var G;const{revision:S,...A}=v,N=await me.saveProfile(A,S,i);u(l=>l.map(r=>r.id===N.profile.id?N.profile:r)),J.current=J.current.map(l=>l.id===N.profile.id?N.profile:l),((G=L.current)==null?void 0:G.profileId)===N.profile.id&&await ie(N.profile.id)},[i,ie]),be=o.useCallback(async(v,S,A)=>{const N=ae.current;if(!N)throw new Error("Select a test profile before saving a value.");const G=N.id;await new Promise((l,r)=>{he.current=he.current.catch(()=>{}).then(async()=>{var h,b;const g=J.current.find(T=>T.id===G);if(!g)throw new Error("The selected test profile is no longer available.");const D=await me.saveProfileMetadata(g.id,g.revision,{defaults:{[v]:S}},i);((h=ae.current)==null?void 0:h.id)===D.profile.id&&(ae.current=D.profile),J.current=J.current.map(T=>T.id===D.profile.id?D.profile:T),u(J.current),((b=L.current)==null?void 0:b.profileId)===D.profile.id&&await ie(D.profile.id)}),he.current.then(l,r)})},[i,ie]),fe=o.useCallback(async v=>{var A;const S=(A=ae.current)==null?void 0:A.id;if(!S)throw new Error("Select a test profile before saving display settings.");await new Promise((N,G)=>{he.current=he.current.catch(()=>{}).then(async()=>{var g,D;const l=J.current.find(h=>h.id===S);if(!l)throw new Error("The selected test profile is no longer available.");const r=await me.saveProfileMetadata(l.id,l.revision,v,i);((g=ae.current)==null?void 0:g.id)===r.profile.id&&(ae.current=r.profile),J.current=J.current.map(h=>h.id===r.profile.id?r.profile:h),u(J.current),((D=L.current)==null?void 0:D.profileId)===r.profile.id&&await ie(r.profile.id)}),he.current.then(N,G)})},[i,ie]),Re=o.useCallback(async(v,S)=>{await fe({actionDefaults:{[v]:S}})},[fe]),p=o.useCallback(async v=>({path:(await me.bindingDraft(v,i)).binding.path}),[i]),j=o.useCallback(async()=>await me.bindingCandidates(i),[i]),F=o.useCallback(async(v,S)=>{var r,g,D,h;const A=re.current,N=i;if(!A)throw Object.assign(new Error("profile_scope_unavailable"),{code:"profile_scope_unavailable"});if(((r=L.current)==null?void 0:r.profileId)===v){const b=J.current.find(T=>T.id!==v);if(b){if(await ie(b.id),((g=L.current)==null?void 0:g.profileId)!==b.id)throw new Error("Could not switch away from the active profile before deleting it.")}else{const T=await me.liveAction({action:"discover",...typeof N=="number"?{placeId:N}:{}});L.current=T.lease,x(T.lease),B({}),E({}),$({})}}await me.deleteProfile(v,S,A);let G;try{G=await me.listProfiles(N)}catch{if(oe.current!==N)return{refreshFailed:!0};const b=J.current.filter(I=>I.id!==v);J.current=b;const T=((D=b[0])==null?void 0:D.id)??null;if(u(b),B({}),E({}),$({}),T)await ie(T);else if(C(null),Pt(N),L.current&&L.current.profileId!=="__weppy_catalog__"){const I=await me.liveAction({action:"discover",...typeof N=="number"?{placeId:N}:{}});L.current=I.lease,x(I.lease)}return{refreshFailed:!0}}if(oe.current!==N)return{refreshFailed:!1};u(G.profiles),J.current=G.profiles,V(G.catalog??Qe),M(G.releaseGuidance??Xe);const l=((h=G.profiles[0])==null?void 0:h.id)??null;if(B({}),E({}),$({}),l)await ie(l);else if(C(null),Pt(N),L.current&&L.current.profileId!=="__weppy_catalog__"){const b=await me.liveAction({action:"discover",...typeof N=="number"?{placeId:N}:{}});L.current=b.lease,x(b.lease)}return{refreshFailed:!1}},[i,ie]);return{profiles:c,selectedProfileId:_,profile:q,catalog:f,releaseGuidance:R,lease:k,controls:w,watches:P,actions:W,studioState:d.state,studioMode:d.mode,canMutate:n,loading:ee,switchingProfileId:H,error:z,selectProfile:ie,apply:Ne,executeAction:_e,resetAll:ve,createProfile:xe,saveProfile:Ce,saveControlValue:be,saveActionDefaults:Re,saveProfileMetadata:fe,resolveSelection:p,resolveSelectionCandidates:j,deleteProfile:F}}function Eo(e){const{t:a}=ue(),n=[{key:"live",label:a("playtest.view.liveSession","Test Values")},{key:"results",label:a("playtest.view.testResults","Automated Test Results")}];return t.jsx(oa,{items:n,value:e.value,onChange:e.onChange,ariaLabel:a("playtest.view.workspaceLabel","Playtest workspace"),className:s.workspaceTabs})}function Do(e){const{t:a}=ue(),n=e.studioState==="Running"&&e.studioMode==="run"?a("playtest.session.state.runRunning","Run running"):e.studioState==="Running"&&e.studioMode==="play"?a("playtest.session.state.playRunning","Play running"):a(`playtest.session.state.${e.studioState.toLowerCase()}`,e.studioState),i=e.studioState==="Disconnected"?a("playtest.session.disconnectedDescription","Connect Roblox Studio and WEPPY Plugin to observe Playtest values."):e.studioState==="Edit"?null:e.studioState==="Paused"?a("playtest.session.pausedDescription","Studio Play is paused. Observations remain connected, and Pro value changes stay available."):e.lease?`${e.profileName??e.lease.profileId} · ${e.lease.target.targetAlias??e.lease.target.clientId}`:a("playtest.session.connectingDescription","Studio is playing. Connecting runtime observations…");return t.jsx("section",{className:s.sessionBar,"aria-label":a("playtest.session.label","Playtest session"),children:t.jsxs("div",{className:s.sessionIdentity,children:[t.jsx(_a,{size:16,"aria-hidden":"true"}),t.jsxs("div",{children:[t.jsx("strong",{children:n}),i&&t.jsx("span",{children:i})]})]})})}function Oe(e){const{t:a}=ue(),[n,i]=o.useState(!1),d=o.useRef(null),c=o.useRef(null),u=o.useRef(null),[y,m]=o.useState({top:0,left:0});return o.useLayoutEffect(()=>{var R;if(!n||e.active||!c.current||!u.current)return;const C=(((R=d.current)==null?void 0:R.querySelector("input, select, button"))??c.current).getBoundingClientRect(),k=u.current.getBoundingClientRect(),x=C.top-k.height-6,f=C.bottom+6,V=x<8&&f+k.height<=window.innerHeight-8?f:x;m({top:Math.max(8,Math.min(V,window.innerHeight-k.height-8)),left:Math.max(8,Math.min(C.left+C.width/2-k.width/2,window.innerWidth-k.width-8))})},[n,e.active,e.reason]),o.useEffect(()=>{if(!n)return;const _=()=>i(!1);return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[n]),t.jsxs("div",{ref:d,className:s.controlGate,children:[e.children,!e.active&&t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c,type:"button",className:s.controlGateTrigger,"aria-label":a("playtest.controls.lockedHelp","Why is {{label}} unavailable?").replace("{{label}}",e.label),"aria-describedby":"playtest-controls-availability","aria-expanded":n,onClick:()=>i(!0),onFocus:()=>i(!0),onBlur:()=>i(!1),onKeyDown:_=>{_.key==="Escape"&&i(!1)}}),n&&Kt.createPortal(t.jsx("span",{ref:u,className:s.controlGateHint,style:y,role:"status",children:e.reason}),document.body)]})]})}function bt(e){var a,n,i;return t.jsx(Ke,{open:e.open,ariaLabel:e.ariaLabel,onClose:e.onClose,returnFocusTo:e.returnFocusTo,testId:"playtest-value-detail-layer",children:t.jsxs("div",{className:s.valueDetailShell,children:[t.jsx(ze,{title:e.title,description:e.description,closeLabel:e.closeLabel,onRequestClose:e.onClose}),t.jsxs("div",{className:s.valueDetailBody,children:[t.jsx("dl",{className:s.valueDetailList,children:e.items.map(d=>t.jsxs("div",{children:[t.jsx("dt",{children:d.label}),t.jsx("dd",{children:d.value})]},d.label))}),t.jsx("div",{className:s.valueDetailFeedback,"data-state":e.error?"error":((a=e.feedback)==null?void 0:a.state)??"idle",role:e.error||((n=e.feedback)==null?void 0:n.state)==="error"?"alert":"status","aria-live":"polite",children:e.error??((i=e.feedback)==null?void 0:i.message)??" "}),e.actions&&e.actions.length>0&&t.jsx("div",{className:s.valueDetailActions,children:e.actions.map(d=>{var c,u,y;return t.jsx(Oe,{active:((c=d.gate)==null?void 0:c.active)??!0,label:((u=d.gate)==null?void 0:u.label)??d.label,reason:((y=d.gate)==null?void 0:y.reason)??"",children:t.jsx("button",{type:"button",className:d.variant==="secondary"?s.secondaryAction:s.primaryAction,"aria-label":d.accessibleLabel,disabled:d.disabled,onClick:d.onClick,children:d.label})},d.accessibleLabel)})})]})]})})}function Ge(e){return e==="vector3"||e==="color3"||e==="cframe"}function Ft(e){return e==="vector3"?["x","y","z"]:e==="color3"?["r","g","b"]:["X","Y","Z","R00","R01","R02","R10","R11","R12","R20","R21","R22"]}function _t(e,a){try{const n=JSON.parse(a),i=Ft(e);if(e==="cframe"?!Array.isArray(n)||n.length!==12:!n||Array.isArray(n)||typeof n!="object"||Object.keys(n).length!==3)return;const d=i.map((c,u)=>e==="cframe"?n[u]:n[c]);if(!d.every(c=>typeof c=="number"&&Number.isFinite(c))||e==="color3"&&d.some(c=>c<0||c>1))return;if(e==="cframe"){const c=d,u=(m,_)=>c[m]*c[_]+c[m+1]*c[_+1]+c[m+2]*c[_+2],y=c[3]*(c[7]*c[11]-c[8]*c[10])-c[4]*(c[6]*c[11]-c[8]*c[9])+c[5]*(c[6]*c[10]-c[7]*c[9]);if([3,6,9].some(m=>Math.abs(u(m,m)-1)>1e-5)||[[3,6],[3,9],[6,9]].some(([m,_])=>Math.abs(u(m,_))>1e-5)||Math.abs(y-1)>1e-5)return}return n}catch{return}}function st(e){if(e===void 0)return"—";if(typeof e=="string")return e.replace(/^Enum\.[^.]+\./,"");if(e&&typeof e=="object"&&!Array.isArray(e)){const a="x"in e?["x","y","z"]:"r"in e?["r","g","b"]:[];if(a.length===3&&a.every(n=>typeof e[n]=="number"))return a.map(n=>`${n.toUpperCase()} ${Number(e[n].toPrecision(6))}`).join(" · ")}return JSON.stringify(e)}function ht(e){const a=o.useRef(!1),n=Ft(e.type);let i={};try{i=JSON.parse(e.draft)??{}}catch{}const d=n.map((m,_)=>{const C=e.type==="cframe"?i[_]:i[m];return C==null?"":String(C)}),c=(m,_)=>{const k=d.map((x,f)=>f===m?_:x).map(x=>x.trim()!==""&&!/[.eE+-]$/.test(x)&&Number.isFinite(Number(x))?Number(x):x);e.onChange(JSON.stringify(e.type==="cframe"?k:Object.fromEntries(n.map((x,f)=>[x,k[f]]))))},u=_t(e.type,e.draft),y=u&&!Array.isArray(u)&&typeof u=="object"?`#${["r","g","b"].map(m=>Math.round(Number(u[m])*255).toString(16).padStart(2,"0")).join("")}`:"#000000";return t.jsxs("div",{className:s.compoundEditor,role:"group","aria-label":e.label,onFocus:()=>{var m;return(m=e.onFocusChange)==null?void 0:m.call(e,!0)},onBlur:m=>{var _,C;m.currentTarget.contains(m.relatedTarget)||((_=e.onFocusChange)==null||_.call(e,!1),a.current||(C=e.onCommit)==null||C.call(e))},onCompositionStart:()=>{a.current=!0},onCompositionEnd:()=>{a.current=!1},onKeyDown:m=>{var _;m.key==="Enter"&&!m.nativeEvent.isComposing&&!a.current&&((_=e.onCommit)==null||_.call(e))},children:[e.type==="color3"&&t.jsx("input",{className:s.colorSwatch,type:"color",value:y,disabled:e.disabled,"aria-label":`${e.label} RGB`,"aria-describedby":e.describedBy,onChange:m=>{const _=m.target.value.slice(1);e.onChange(JSON.stringify({r:parseInt(_.slice(0,2),16)/255,g:parseInt(_.slice(2,4),16)/255,b:parseInt(_.slice(4,6),16)/255}))}}),t.jsx("div",{className:s.compoundCoordinates,children:n.map((m,_)=>t.jsxs("label",{children:[t.jsxs("span",{children:[m.toUpperCase(),e.type==="color3"?" (0–1)":""]}),t.jsx("input",{inputMode:"decimal",value:d[_],disabled:e.disabled,"aria-label":`${e.label} ${m.toUpperCase()}`,"aria-describedby":e.describedBy,"aria-invalid":e.draft!==""&&u===void 0||void 0,onChange:C=>c(_,C.target.value)})]},m))})]})}function Ae(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function Io(e,a,n){const i=n!=null&&n.fresh?n.observed:n==null?void 0:n.lastObserved,d=(a==null?void 0:a.draft)??i??e.value;return d===void 0?"":Ae(d)}function qe(e,a){var n;if(Ge(e.valueType))return _t(e.valueType,a);if(e.valueType==="number"){if(a.trim()==="")return;const i=Number(a);return Number.isFinite(i)?i:void 0}return e.valueType==="boolean"?a==="true":e.valueType==="enum"?((n=e.enumValues)==null?void 0:n.find(i=>Ae(i)===a))??a:a}function Be(e){return e&&typeof e=="object"&&!Array.isArray(e)?`object:${Object.keys(e).sort().map(a=>`${JSON.stringify(a)}:${Be(e[a])}`).join(",")}`:`${typeof e}:${JSON.stringify(e)}`}function Ue(e){var a;return e.value!==void 0?Ae(e.value):e.valueType==="boolean"?"false":e.valueType==="enum"?Ae((a=e.enumValues)==null?void 0:a[0]):""}function To(e){var i;const{t:a}=ue();if(!e.profile||e.profile.controls.length===0)return t.jsx("div",{className:s.panelEmpty,children:a("playtest.controls.empty","No test controls in this profile yet.")});const n=((i=e.profile.settings)==null?void 0:i.runtimeApplyMode)??"manual";return t.jsx("div",{className:s.liveRows,children:e.profile.controls.map(d=>{var c,u,y;return t.jsx(Lo,{control:d,active:e.active,inactiveReason:e.inactiveReason,profileSaveLocked:e.profileSaveLocked,runtimeApplyMode:n,state:e.states[d.id],watch:e.watches[`control:${d.id}`],presentation:(u=(c=e.profile)==null?void 0:c.presentation)==null?void 0:u[d.id],draftState:(y=e.drafts)==null?void 0:y[d.id],onDraftChange:e.onDraftChange,onApply:e.onApply,onSaveValue:e.onSaveValue,onRemoveValue:e.onRemoveValue},`${e.draftScope??"profile"}:${d.id}`)})})}function Lo(e){var ie,Ne,ve,_e,xe,Ce,be,fe,Re,p,j,F,v,S,A,N,G,l,r,g,D;const{t:a}=ue(),n=Io(e.control,e.state,e.watch),[i,d]=o.useState(n),[c,u]=o.useState(!1),[y,m]=o.useState("idle"),[_,C]=o.useState(null),[k,x]=o.useState(()=>Ue(e.control)),[f,V]=o.useState(e.control.value),[R,M]=o.useState(null),[w,B]=o.useState(!1),P=o.useRef(null),E=o.useRef(!1),W=o.useRef(!1),$=o.useRef(null),ee=((ie=e.draftState)==null?void 0:ie.value)??i,te=((Ne=e.draftState)==null?void 0:Ne.dirty)??c;o.useEffect(()=>{d(n),u(!1),x(Ue(e.control)),V(e.control.value),M(null),C(null),$.current=null},[e.control.id]),o.useEffect(()=>{x(Ue(e.control)),V(e.control.value)},[e.control.value]),o.useEffect(()=>{!e.draftState&&!te&&!E.current&&d(n)},[te,n,e.draftState]),o.useEffect(()=>{var h,b,T;(((h=e.state)==null?void 0:h.status)==="error"||((b=e.state)==null?void 0:b.status)==="conflict"||((T=e.state)==null?void 0:T.status)==="requires_adapter")&&($.current=null)},[(ve=e.state)==null?void 0:ve.status]);const H=()=>qe(e.control,ee),O=h=>{if(!e.active||W.current)return;const b=h??H();if(b===void 0)return;const T=Be(b);$.current!==T&&($.current=T,e.onApply(e.control.id,b))},z=h=>{var T;d(h),u(!0),(T=e.onDraftChange)==null||T.call(e,e.control.id,h,!0);const b=qe(e.control,h);(b===void 0||Be(b)!==$.current)&&($.current=null)},U=async()=>{const h=qe(e.control,k);if(!(h===void 0||!e.onSaveValue||e.profileSaveLocked||y!=="idle")){m("saving"),C(null),M(null);try{await e.onSaveValue(e.control.id,h,e.control.applyOnStart??!1),V(h),M({state:"saved",value:Ae(h)})}catch(b){C(b instanceof Error?b.message:String(b))}finally{m("idle")}}},L=async()=>{if(!(f===void 0||!e.onRemoveValue||e.profileSaveLocked||y!=="idle")){m("removing"),C(null),M(null);try{await e.onRemoveValue(e.control.id),x(Ue({...e.control,value:void 0})),V(void 0),M({state:"removed"})}catch(h){C(h instanceof Error?h.message:String(h))}finally{m("idle")}}},ae=a("playtest.controls.inputLabel","Input value for {{label}}").replace("{{label}}",e.control.label),J=e.active?void 0:"playtest-controls-availability",le=e.inactiveReason??a("playtest.values.playRequired","Start Play in Studio to change test values."),Q=e.control.valueType==="number"&&((_e=e.control.constraints)==null?void 0:_e.minimum)!==void 0&&((xe=e.control.constraints)==null?void 0:xe.maximum)!==void 0,K=(Ce=e.watch)!=null&&Ce.fresh?e.watch.observed:(be=e.watch)==null?void 0:be.lastObserved,Z=(fe=e.watch)!=null&&fe.fresh?a("playtest.controls.currentObserved","Current value"):K!==void 0?a("playtest.watch.lastObserved","Last observed"):a("playtest.watch.notObserved","Not observed yet"),X=((Re=e.state)==null?void 0:Re.status)??"idle",he=e.control.origin?`ServerStorage.WeppyTestAdapters.${e.control.origin.adapter}`:e.control.path?[e.control.path.root,...e.control.path.segments].join("."):"adapter",re=e.runtimeApplyMode==="auto",oe=H(),ye=X==="applying"||X==="pending_resume",we=!re&&e.active&&te&&oe!==void 0&&K!==void 0&&Be(oe)!==Be(K)&&Be(oe)!==$.current&&!ye,q=f===void 0?a("playtest.controls.noSavedValue","No saved default"):Ae(f),se=a("playtest.controls.defaultInputLabel","Saved default for {{label}}").replace("{{label}}",e.control.label);let ne;Ge(e.control.valueType)?ne=t.jsx(ht,{type:e.control.valueType,draft:ee,label:ae,disabled:!e.active,describedBy:J,onChange:z,onFocusChange:h=>{E.current=h},onCommit:()=>{re&&O()}}):e.control.valueType==="boolean"?ne=t.jsxs("label",{className:s.booleanEditor,children:[t.jsx("input",{type:"checkbox",checked:ee==="true",disabled:!e.active,"aria-label":ae,"aria-describedby":J,onFocus:()=>{E.current=!0},onBlur:()=>{E.current=!1},onChange:h=>{const b=h.target.checked;z(String(b)),re&&O(b)}}),t.jsx("span",{children:ee==="true"?a("common.true","True"):a("common.false","False")})]}):e.control.valueType==="enum"?ne=t.jsx("select",{"aria-label":ae,"aria-describedby":J,value:ee,disabled:!e.active,onFocus:()=>{E.current=!0},onBlur:()=>{E.current=!1},onChange:h=>{z(h.target.value);const b=qe(e.control,h.target.value);re&&b!==void 0&&O(b)},children:(e.control.enumValues??[]).map(h=>t.jsx("option",{value:Ae(h),children:st(h)},Ae(h)))}):Q?ne=t.jsxs("div",{className:s.rangeEditor,children:[t.jsx("input",{type:"range",value:ee||String(((p=e.control.constraints)==null?void 0:p.minimum)??0),min:(j=e.control.constraints)==null?void 0:j.minimum,max:(F=e.control.constraints)==null?void 0:F.maximum,step:((v=e.control.constraints)==null?void 0:v.step)??1,disabled:!e.active,"aria-label":ae,"aria-describedby":J,onFocus:()=>{E.current=!0},onBlur:()=>{E.current=!1},onChange:h=>z(h.target.value),onPointerUp:()=>{re&&O()},onKeyUp:h=>{re&&(h.key.startsWith("Arrow")||h.key==="Home"||h.key==="End")&&O()}}),t.jsx("output",{children:ee||"—"})]}):ne=t.jsx("input",{value:ee,disabled:!e.active,inputMode:e.control.valueType==="number"?"decimal":void 0,onFocus:()=>{E.current=!0},onChange:h=>z(h.target.value),onCompositionStart:()=>{W.current=!0},onCompositionEnd:()=>{W.current=!1},onKeyDown:h=>{re&&h.key==="Enter"&&!h.nativeEvent.isComposing&&O()},onBlur:()=>{E.current=!1,re&&O()},"aria-label":ae,"aria-describedby":J});let ce;return Ge(e.control.valueType)?ce=t.jsx(ht,{type:e.control.valueType,draft:k,label:se,disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle",onChange:h=>{x(h),M(null),C(null)}}):e.control.valueType==="boolean"?ce=t.jsxs("label",{className:s.defaultBooleanEditor,children:[t.jsx("input",{type:"checkbox",checked:k==="true",disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle","aria-label":se,onChange:h=>{x(String(h.target.checked)),M(null),C(null)}}),t.jsx("span",{children:k==="true"?a("common.true","True"):a("common.false","False")})]}):e.control.valueType==="enum"?ce=t.jsx("select",{value:k,disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle","aria-label":se,onChange:h=>{x(h.target.value),M(null),C(null)},children:(e.control.enumValues??[]).map(h=>t.jsx("option",{value:Ae(h),children:st(h)},Ae(h)))}):ce=t.jsx("input",{type:e.control.valueType==="number"?"number":"text",value:k,min:(S=e.control.constraints)==null?void 0:S.minimum,max:(A=e.control.constraints)==null?void 0:A.maximum,step:(N=e.control.constraints)==null?void 0:N.step,disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle","aria-label":se,onChange:h=>{x(h.target.value),M(null),C(null)}}),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.controlRow,children:[t.jsxs("div",{className:s.rowIdentity,children:[t.jsx("strong",{children:e.control.label}),(((G=e.presentation)==null?void 0:G.pinned)||((l=e.presentation)==null?void 0:l.group))&&t.jsxs("span",{className:s.presentationMeta,children:[e.presentation.pinned?a("playtest.values.pinned","Pinned"):"",e.presentation.pinned&&e.presentation.group?" · ":"",e.presentation.group??""]}),t.jsx("button",{ref:P,type:"button",className:s.valueDetailButton,"aria-label":a("playtest.values.detailsFor","Value details for {{label}}").replace("{{label}}",e.control.label),onClick:()=>{x(Ue({...e.control,value:f})),M(null),C(null),B(!0)},children:a("playtest.values.viewDetails","View details")})]}),t.jsxs("div",{className:s.actualValue,"aria-label":`${Z} ${Ae(K)}`,children:[t.jsx("span",{children:Z}),t.jsx("strong",{children:st(K)})]}),t.jsxs("div",{className:s.controlEditor,children:[t.jsxs("div",{className:s.editorHeading,children:[t.jsx("span",{className:s.editorLabel,children:a("playtest.controls.inputValue","Input value")}),t.jsxs("span",{className:s.savedValueState,title:q,"aria-label":a("playtest.controls.savedDefaultState","Saved default for {{label}}: {{value}}").replace("{{label}}",e.control.label).replace("{{value}}",q),children:[a("playtest.controls.defaultValue","Saved default")," ",t.jsx("strong",{children:q})]})]}),t.jsxs("div",{className:s.controlEditorRow,children:[t.jsx(Oe,{active:e.active,label:`${e.control.label} input`,reason:le,children:ne}),t.jsx("div",{className:s.controlActions,children:t.jsx(Oe,{active:e.active,label:`${e.control.label} apply`,reason:le,children:t.jsx("button",{type:"button",className:s.secondaryAction,disabled:!we,"aria-label":a("playtest.controls.applyLabel","Apply the input value for {{label}}").replace("{{label}}",e.control.label),onClick:()=>O(),children:a("playtest.controls.applyRuntime","Apply manually")})})})]}),t.jsx("span",{className:s.rowFeedback,"data-state":_?"error":X,"aria-live":"polite",children:_??(X==="applying"?a("playtest.controls.applying","Applying…"):X==="pending_resume"?a("playtest.controls.pendingResume","Apply on resume"):X==="applied"?a("playtest.controls.applied","Applied · readback {{value}}").replace("{{value}}",Ae((r=e.state)==null?void 0:r.observed)):X==="conflict"?a("playtest.controls.conflict","Conflict · reload the current revision"):X==="requires_adapter"?a("playtest.controls.requiresAdapter","Requires reviewed adapter"):X==="error"?((g=e.state)==null?void 0:g.message)??a("playtest.controls.applyFailed","Apply failed"):e.active?re?a("playtest.controls.autoApplyReady","Changes apply automatically when the input is confirmed"):a("playtest.controls.readyToApply","Input value is ready to apply or save as the default"):" ")})]})]}),t.jsx(bt,{open:w,title:e.control.label,description:a("playtest.controls.details","Value details"),ariaLabel:a("playtest.values.detailsDialog","{{label}} value details").replace("{{label}}",e.control.label),closeLabel:a("common.close","Close"),returnFocusTo:P.current,onClose:()=>B(!1),items:[{label:Z,value:Ae(K)},{label:a("playtest.controls.defaultValue","Saved default"),value:t.jsx("div",{className:s.defaultValueEditor,children:ce})},{label:a("playtest.controls.originalValue","Original runtime value"),value:Ae((D=e.state)==null?void 0:D.original)},{label:a("playtest.controls.registration","Registration"),value:`${e.control.target.role} · ${e.control.access.kind}`},{label:a("playtest.values.location","Location"),value:he},{label:a("playtest.values.valueType","Value type"),value:e.control.valueType}],error:_,feedback:(R==null?void 0:R.state)==="saved"?{state:"success",message:a("playtest.controls.defaultSavedFeedback","Saved default {{value}} · Saved").replace("{{value}}",R.value??"")}:(R==null?void 0:R.state)==="removed"?{state:"success",message:a("playtest.controls.defaultRemovedFeedback","No saved default · Removed")}:null,actions:[{label:y==="removing"?a("playtest.controls.removingDefault","Removing…"):a("playtest.controls.removeDefault","Remove default"),accessibleLabel:a("playtest.controls.removeDefaultLabel","Remove saved default for {{label}}").replace("{{label}}",e.control.label),disabled:f===void 0||!e.onRemoveValue||e.profileSaveLocked||y!=="idle",variant:"secondary",onClick:()=>void L()},{label:y==="saving"?a("playtest.profile.saving","Saving…"):a("playtest.controls.saveDefault","Save default"),accessibleLabel:a("playtest.controls.saveLabel","Save default for {{label}}").replace("{{label}}",e.control.label),disabled:!e.onSaveValue||e.profileSaveLocked||y!=="idle"||qe(e.control,k)===void 0,onClick:()=>void U()}]})]})}function Ze(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function Mo(e){var C;const{t:a}=ue(),n=[...((C=e.profile)==null?void 0:C.watches.map(k=>({...k,subscriptionId:`watch:${k.id}`})))??[]],[i,d]=o.useState(null),c=o.useRef(null);if(n.length===0)return t.jsx("div",{className:s.panelEmpty,children:a("playtest.watch.empty","Observed values appear here during Play.")});const u=n.find(k=>k.id===i),y=u?e.watches[u.subscriptionId]:void 0,m=y!=null&&y.fresh?y.observed:y==null?void 0:y.lastObserved,_=u!=null&&u.path?[u.path.root,...u.path.segments].join("."):(u==null?void 0:u.access.adapter)??"adapter";return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:s.watchRows,children:n.map(k=>{var M,w;const x=e.watches[k.subscriptionId],f=(w=(M=e.profile)==null?void 0:M.presentation)==null?void 0:w[k.id],V=x!=null&&x.fresh?x.observed:x==null?void 0:x.lastObserved,R=x!=null&&x.fresh?a("playtest.watch.currentValue","Current value"):V!==void 0?a("playtest.watch.lastObserved","Last observed"):a("playtest.watch.notObserved","Not observed yet");return t.jsxs("div",{className:s.watchRow,"data-value-type":k.valueType,children:[t.jsxs("div",{className:s.watchCardMain,children:[t.jsx("strong",{children:k.label}),((f==null?void 0:f.pinned)||(f==null?void 0:f.group))&&t.jsxs("span",{className:s.presentationMeta,children:[f.pinned?a("playtest.values.pinned","Pinned"):"",f.pinned&&f.group?" · ":"",f.group??""]}),t.jsx("button",{type:"button",className:s.valueDetailButton,"aria-label":a("playtest.values.detailsFor","Value details for {{label}}").replace("{{label}}",k.label),onClick:B=>{c.current=B.currentTarget,d(k.id)},children:a("playtest.values.viewDetails","View details")})]}),t.jsxs("div",{className:s.watchReading,children:[!(x!=null&&x.fresh)&&t.jsx("span",{children:R}),t.jsx("strong",{title:Ze(V),"aria-label":`${R} ${Ze(V)}`,children:Ze(V)})]}),x&&x.status!=="fresh"&&t.jsx("span",{className:s.freshness,"data-status":x.status,children:(x==null?void 0:x.status)==="stale"?a("playtest.watch.stale","Stale"):a("playtest.watch.unavailable","Unavailable")})]},k.subscriptionId)})}),u&&t.jsx(bt,{open:i!==null,title:u.label,description:a("playtest.watch.details","Observation details"),ariaLabel:a("playtest.values.detailsDialog","{{label}} value details").replace("{{label}}",u.label),closeLabel:a("common.close","Close"),returnFocusTo:c.current,onClose:()=>d(null),items:[{label:a("playtest.watch.registration","Registration"),value:`${u.target.role} · ${u.access.kind}`},{label:a("playtest.values.location","Location"),value:_},{label:a("playtest.values.valueType","Value type"),value:u.valueType},{label:y!=null&&y.fresh?a("playtest.watch.currentValue","Current value"):m!==void 0?a("playtest.watch.lastObserved","Last observed"):a("playtest.watch.notObserved","Not observed yet"),value:Ze(m)},...y!=null&&y.observedAtMs?[{label:a("playtest.watch.observedAt","Observed at"),value:t.jsx("time",{children:new Date(y.observedAtMs).toLocaleTimeString()})}]:[]]})]})}function nt(e,a){return Object.prototype.hasOwnProperty.call(e,a)}function $o(e,a){var n;if(e.type==="string")return typeof a=="string"?a:void 0;if(e.type==="boolean")return typeof a=="boolean"?a:void 0;if(e.type==="number"||e.type==="integer"){const i=typeof a=="number"?a:typeof a=="string"&&a.trim()!==""?Number(a):NaN;return Number.isFinite(i)?i:void 0}return(n=e.enumValues)==null?void 0:n.find(i=>i===a)}function Vo(e,a){if(e.type==="integer"&&!Number.isInteger(a))return"Enter a whole number.";if(typeof a=="number"){if(e.minimum!==void 0&&a<e.minimum)return`Enter ${e.minimum} or more.`;if(e.maximum!==void 0&&a>e.maximum)return`Enter ${e.maximum} or less.`}if(typeof a=="string"){if(e.minLength!==void 0&&a.length<e.minLength)return`Enter at least ${e.minLength} characters.`;if(e.maxLength!==void 0&&a.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}return null}function Gt(e){return Object.fromEntries(e.parameters.map(a=>[a.name,e.defaultArguments&&nt(e.defaultArguments,a.name)?e.defaultArguments[a.name]:a.defaultValue]))}function kt(e,a){const n={},i=new Set(e.parameters.map(c=>c.name));for(const c of Object.keys(a))nt(e.fixedArguments,c)?n[c]="This argument is fixed and cannot be changed.":i.has(c)||(n[c]="This argument is not declared.");const d=structuredClone(e.fixedArguments);for(const c of[...e.parameters].sort((u,y)=>u.order-y.order)){const u=nt(a,c.name)?a[c.name]:e.defaultArguments&&nt(e.defaultArguments,c.name)?e.defaultArguments[c.name]:c.defaultValue;if(u===void 0){c.required&&(n[c.name]="This value is required.");continue}const y=$o(c,u);if(y===void 0){n[c.name]=c.type==="enum"?"Choose one of the available values.":"Enter a valid value.";continue}const m=Vo(c,y);m?n[c.name]=m:d[c.name]=y}return Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,arguments:d}}function At(e){const{t:a}=ue();return t.jsx("div",{className:s.actionParameterGrid,children:[...e.action.parameters].sort((n,i)=>n.order-i.order).map(n=>{var m,_;const i=(m=e.errors)==null?void 0:m[n.name],d=`playtest-action-${e.action.id}-${n.name}-error`,c=e.draft[n.name],u=`${n.label}${n.unit?` (${n.unit})`:""}`;let y;if(n.type==="boolean")y=t.jsx("input",{type:"checkbox","aria-label":u,checked:c===!0,disabled:e.disabled,"aria-invalid":!!i,"aria-describedby":i?d:void 0,onChange:C=>e.onChange(n.name,C.target.checked)});else if(n.type==="enum"){const C=((_=n.enumValues)==null?void 0:_.findIndex(k=>k===c))??-1;y=t.jsxs("select",{"aria-label":u,value:C<0?"":String(C),disabled:e.disabled,"aria-invalid":!!i,"aria-describedby":i?d:void 0,onChange:k=>{var f;const x=Number(k.target.value);e.onChange(n.name,Number.isInteger(x)?(f=n.enumValues)==null?void 0:f[x]:void 0)},children:[t.jsx("option",{value:"",children:n.required?a("playtest.actions.chooseValue","Choose a value"):a("playtest.actions.omitValue","Do not use")}),(n.enumValues??[]).map((k,x)=>t.jsx("option",{value:x,children:String(k)},`${x}:${String(k)}`))]})}else y=t.jsx("input",{type:n.type==="string"?"text":"number",inputMode:n.type==="string"?void 0:"decimal",step:n.type==="integer"?1:"any",min:n.minimum,max:n.maximum,minLength:n.minLength,maxLength:n.maxLength,"aria-label":u,"aria-invalid":!!i,"aria-describedby":i?d:void 0,disabled:e.disabled,value:typeof c=="string"||typeof c=="number"?String(c):"",onChange:C=>e.onChange(n.name,C.target.value)});return t.jsxs("label",{className:s.actionParameter,children:[t.jsxs("span",{children:[u,n.required?" *":""]}),y,n.description&&t.jsx("small",{children:n.description}),i&&t.jsx("small",{id:d,className:s.actionParameterError,role:"alert",children:i})]},n.name)})})}function ot(e){return e===void 0?"—":typeof e=="string"?e:JSON.stringify(e)}function Oo(e){var P,E,W,$,ee,te;const{t:a}=ue(),[n,i]=o.useState(!1),[d,c]=o.useState({}),u=o.useRef(null),y=e.draft??Gt(e.action),m=o.useMemo(()=>[...e.action.parameters].sort((H,O)=>H.order-O.order),[e.action.parameters]),_=kt(e.action,y),C=((P=e.state)==null?void 0:P.status)??"idle",k=C==="running",x=e.inactiveReason??a("playtest.actions.playRequired","Start Studio Play before running this action."),f=m.length===0?a("playtest.actions.noParameters","No input required"):m.map(H=>`${H.label}: ${ot(y[H.name])}`).join(" · "),V=Object.entries(e.action.fixedArguments).map(([H,O])=>`${H}: ${ot(O)}`).join(" · "),R=C==="running"?a("playtest.actions.running","Running…"):C==="succeeded"?a("playtest.actions.succeeded","Succeeded"):C==="failed"?((W=(E=e.state)==null?void 0:E.error)==null?void 0:W.message)??a("playtest.actions.failed","Failed"):C==="unknown"?a("playtest.actions.unknown","Result unknown"):" ",M=(H,O)=>{const z={...y,[H]:O};c(U=>{const L={...U};return delete L[H],L}),e.onDraftChange(e.action.id,z)},w=()=>{const H=kt(e.action,y);if(!H.ok){c(H.errors);return}e.onExecute(e.action.id,structuredClone(H.arguments))},B=()=>{if(!_.ok){c(_.errors);return}const H=new Set(e.action.parameters.map(O=>O.name));e.onSaveDefaults(e.action.id,Object.fromEntries(Object.entries(_.arguments).filter(([O])=>H.has(O))))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.actionRow,"data-state":C,children:[t.jsxs("div",{className:s.rowIdentity,children:[t.jsx("strong",{children:e.action.label}),e.action.description&&t.jsx("span",{children:e.action.description}),((($=e.presentation)==null?void 0:$.pinned)||((ee=e.presentation)==null?void 0:ee.group))&&t.jsxs("span",{className:s.presentationMeta,children:[e.presentation.pinned?a("playtest.values.pinned","Pinned"):"",e.presentation.pinned&&e.presentation.group?" · ":"",e.presentation.group??""]}),m.length>1&&t.jsx("button",{ref:u,type:"button",className:s.valueDetailButton,"aria-label":a("playtest.actions.settingsFor","Execution settings for {{label}}").replace("{{label}}",e.action.label),onClick:()=>i(!0),children:a("playtest.actions.settings","Execution settings")})]}),t.jsxs("div",{className:s.actionSummary,children:[t.jsx("span",{children:a("playtest.actions.parameters","Parameters")}),t.jsx("strong",{children:f})]}),t.jsxs("div",{className:s.actionExecution,children:[m.length===1&&t.jsx(At,{action:e.action,draft:y,errors:d,disabled:k,onChange:M}),t.jsx(Oe,{active:e.active,label:e.action.label,reason:x,children:t.jsx("button",{type:"button",className:s.primaryAction,"aria-label":a("playtest.actions.runLabel","Run {{label}}").replace("{{label}}",e.action.label),disabled:!e.active||k,onClick:w,children:k?a("playtest.actions.running","Running…"):a("playtest.actions.run","Run")})}),t.jsx("span",{className:s.rowFeedback,"data-state":C,"aria-live":"polite",children:R}),!e.active&&t.jsx("span",{className:s.actionInactiveReason,children:x})]})]}),t.jsx(bt,{open:n,title:e.action.label,description:a("playtest.actions.settings","Execution settings"),ariaLabel:a("playtest.actions.settingsDialog","{{label}} execution settings").replace("{{label}}",e.action.label),closeLabel:a("common.close","Close"),returnFocusTo:u.current,onClose:()=>i(!1),items:[{label:a("playtest.actions.parameters","Parameters"),value:t.jsx(At,{action:e.action,draft:y,errors:d,disabled:k,onChange:M})},{label:a("playtest.actions.fixedArguments","Fixed arguments"),value:V||"—"},{label:a("playtest.actions.lastResult","Last result"),value:((te=e.state)==null?void 0:te.result)===void 0?R.trim()||"—":ot(e.state.result)}],actions:[{label:a("playtest.actions.saveDefaults","Save default inputs"),accessibleLabel:a("playtest.actions.saveDefaultsFor","Save default inputs for {{label}}").replace("{{label}}",e.action.label),variant:"secondary",disabled:k||!_.ok,onClick:B}]})]})}function Bo(e,a,n,i){const d=e.indexOf(a),c=e.indexOf(n);if(d<0||c<0||a===n)return[...e];const u=e.filter(_=>_!==a),y=u.indexOf(n),m=i==="after"?y+1:y;return u.splice(m,0,a),u}const Et=["watches","controls","actions"];function Fo(e,a){const n="path"in e&&e.path?[e.path.root,...e.path.segments].join("."):"",i="access"in e?e.access.adapter:e.executor.kind==="adapter"?e.executor.adapter:"",d="access"in e?e.access.name:e.executor.kind;return[e.id,e.label,a,n,i,d].filter(Boolean).join(" ").toLocaleLowerCase()}function Go(e,a){if(a.kind==="action")return"unobserved";const n=e.watches[`${a.kind}:${a.binding.id}`];return(n==null?void 0:n.status)??"unobserved"}function Ho(e){var j,F,v,S,A,N,G,l;const{t:a}=ue(),[n,i]=o.useState(""),[d,c]=o.useState("all"),[u,y]=o.useState("all"),[m,_]=o.useState("all"),[C,k]=o.useState(new Set),[x,f]=o.useState(0),[V,R]=o.useState(50),[M,w]=o.useState(!1),[B,P]=o.useState(((F=(j=e.live.profile)==null?void 0:j.sectionOrder)==null?void 0:F.length)===3?e.live.profile.sectionOrder:Et),[E,W]=o.useState(null),[$,ee]=o.useState(null),[te,H]=o.useState(null),[O,z]=o.useState(!1),[U,L]=o.useState(!1),[ae,J]=o.useState(""),[le,Q]=o.useState(null),[K,Z]=o.useState(()=>{var r;return((r=e.live.profile)==null?void 0:r.presentation)??{}}),[X,he]=o.useState({}),[re,oe]=o.useState({}),[ye,we]=o.useState(()=>{var r;return((r=e.live.profile)==null?void 0:r.settings)??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"}}),q=e.live.profile,se=a("playtest.values.ungrouped","Ungrouped");o.useEffect(()=>{var r,g,D;P(((g=(r=e.live.profile)==null?void 0:r.sectionOrder)==null?void 0:g.length)===3?e.live.profile.sectionOrder:Et),Z(((D=e.live.profile)==null?void 0:D.presentation)??{}),z(!1)},[(v=e.live.profile)==null?void 0:v.id,(S=e.live.profile)==null?void 0:S.presentation,(A=e.live.profile)==null?void 0:A.sectionOrder]),o.useEffect(()=>{var r;we(((r=e.live.profile)==null?void 0:r.settings)??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"})},[(N=e.live.profile)==null?void 0:N.id,(G=e.live.profile)==null?void 0:G.settings]);const ne=o.useMemo(()=>{if(!q)return{entries:[],total:0,pages:1,safePage:0,groups:[]};const r=[...q.controls.map((I,Y)=>({kind:"control",binding:I,sourceOrder:Y})),...q.watches.map((I,Y)=>({kind:"watch",binding:I,sourceOrder:q.controls.length+Y})),...(q.actions??[]).map((I,Y)=>({kind:"action",binding:I,sourceOrder:q.controls.length+q.watches.length+Y}))],g=Array.from(new Set(r.map(I=>{var Y;return((Y=K[I.binding.id])==null?void 0:Y.group)??se}))).sort((I,Y)=>I.localeCompare(Y)),D=n.trim().toLocaleLowerCase(),h=r.filter(I=>{var de;const Y=((de=K[I.binding.id])==null?void 0:de.group)??se;return(d==="all"||I.kind===d)&&(m==="all"||Y===m)&&(u==="all"||I.kind==="action"||Go(e.live,I)===u)&&(!D||Fo(I.binding,Y).includes(D))}).sort((I,Y)=>{if(I.kind!==Y.kind){const Pe=Ie=>Ie==="watch"?"watches":Ie==="control"?"controls":"actions";return B.indexOf(Pe(I.kind))-B.indexOf(Pe(Y.kind))}const de=K[I.binding.id],je=K[Y.binding.id];return!!(de!=null&&de.pinned)!=!!(je!=null&&je.pinned)?de!=null&&de.pinned?-1:1:((de==null?void 0:de.order)??I.sourceOrder)-((je==null?void 0:je.order)??Y.sourceOrder)}),b=Math.max(1,Math.ceil(h.length/V)),T=Math.min(x,b-1);return{entries:h.slice(T*V,(T+1)*V),total:h.length,pages:b,safePage:T,groups:g}},[m,d,u,x,V,K,q,e.live,n,B,se]),ce=((q==null?void 0:q.controls.length)??0)+((q==null?void 0:q.watches.length)??0)+(((l=q==null?void 0:q.actions)==null?void 0:l.length)??0),ie=n.trim()!==""||d!=="all"||u!=="all"||m!=="all",Ne={watches:a("playtest.values.observedSection","Observed values"),controls:a("playtest.values.changeSection","Change values"),actions:a("playtest.actions.section","Actions")},ve=async r=>{H(null);try{await e.live.saveProfileMetadata(r)}catch(g){throw H(g instanceof Error?g.message:a("playtest.values.layoutSaveFailed","Could not save the display order")),g}},_e=r=>{we(r),ve({settings:r}).catch(()=>we((q==null?void 0:q.settings)??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"}))},xe=r=>{if(!O||U||!B.includes(r))return;const g=B,D=B.indexOf(r),h=D===0?1:D-1,b=[...B];[b[D],b[h]]=[b[h],b[D]];const T=b;P(T),L(!0),ve({sectionOrder:T}).then(()=>J(a("playtest.values.layoutSaved","Display order saved"))).catch(()=>P(g)).finally(()=>L(!1))},Ce=r=>ne.entries.filter(g=>g.kind===r),be=(r,g,D,h)=>{var Pe,Ie,Me;if(!q||!O||U)return;const b=K,T=g.map(Se=>Se.binding.id),I=Bo(T,r.binding.id,D,h);if(T.every((Se,ke)=>Se===I[ke]))return;const Y={...K},de=g.map(Se=>{var ke;return((ke=K[Se.binding.id])==null?void 0:ke.order)??Se.sourceOrder}).sort((Se,ke)=>Se-ke);for(const[Se,ke]of I.entries())Y[ke]={order:de[Se],pinned:((Pe=K[ke])==null?void 0:Pe.pinned)??!1,...(Ie=K[ke])!=null&&Ie.group?{group:(Me=K[ke])==null?void 0:Me.group}:{}};Z(Y),L(!0);const je=I.indexOf(r.binding.id)+1;ve({presentation:Y}).then(()=>J(a("playtest.values.movedTo","{{label}} moved to position {{position}}").replace("{{label}}",r.binding.label).replace("{{position}}",String(je)))).catch(()=>Z(b)).finally(()=>L(!1))},fe=r=>k(g=>{const D=new Set(g);return D.has(r)?D.delete(r):D.add(r),D}),Re=(r,g)=>{var Ie,Me,Se,ke;const D=((Ie=K[r.binding.id])==null?void 0:Ie.group)??se,h=((Me=K[r.binding.id])==null?void 0:Me.pinned)??!1,b=g.filter(pe=>{var ge,Le;return(((ge=K[pe.binding.id])==null?void 0:ge.group)??se)===D&&(((Le=K[pe.binding.id])==null?void 0:Le.pinned)??!1)===h}),T=b.findIndex(pe=>pe.binding.id===r.binding.id),I=pe=>a(pe==="previous"?"playtest.values.movePrevious":"playtest.values.moveNext",`Move {{label}} ${pe}`).replace("{{label}}",r.binding.label),Y=a("playtest.values.drag","Drag {{label}} to reorder").replace("{{label}}",r.binding.label),de=e.active&&(e.live.studioMode!=="run"||r.binding.target.role==="server"),je=e.live.studioMode==="run"&&r.binding.target.role==="client"?a("playtest.controls.playModeRequired","Client test values are available in Play."):e.inactiveReason,Pe=`${q.id}:${((Se=e.live.lease)==null?void 0:Se.leaseId)??"edit"}:${r.binding.id}`;return t.jsxs("div",{className:s.valueEntryShell,"data-layout-editing":O,"data-drop-position":(le==null?void 0:le.id)===r.binding.id?le.placement:void 0,onDragOver:pe=>{if((E==null?void 0:E.kind)!==r.kind||!b.some(qt=>qt.binding.id===E.id))return;pe.preventDefault();const ge=pe.currentTarget.getBoundingClientRect(),lt=r.kind==="watch"?pe.clientX>=ge.left+ge.width/2?"after":"before":pe.clientY>=ge.top+ge.height/2?"after":"before";Q({id:r.binding.id,placement:lt})},onDrop:pe=>{if(pe.preventDefault(),(E==null?void 0:E.kind)===r.kind&&E.id!==r.binding.id&&(le==null?void 0:le.id)===r.binding.id){const ge=b.find(Le=>Le.binding.id===E.id);ge&&be(ge,b,r.binding.id,le.placement)}W(null),Q(null)},children:[O&&t.jsxs("div",{className:s.valueReorderControls,children:[t.jsx("button",{type:"button",className:s.dragHandle,draggable:!0,"aria-label":Y,disabled:U,onDragStart:()=>W({kind:r.kind,id:r.binding.id}),onDragEnd:()=>{W(null),Q(null)},children:t.jsx(wt,{size:14,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":I("previous"),"aria-describedby":T<=0?"playtest-layout-boundary":void 0,disabled:U||T<=0,onClick:()=>be(r,b,b[T-1].binding.id,"before"),children:t.jsx(St,{size:13,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":I("next"),"aria-describedby":T===b.length-1?"playtest-layout-boundary":void 0,disabled:U||T<0||T===b.length-1,onClick:()=>be(r,b,b[T+1].binding.id,"after"),children:t.jsx(mt,{size:13,"aria-hidden":"true"})})]}),r.kind==="control"?t.jsx(To,{profile:{...q,controls:[r.binding],watches:[],settings:ye},active:de,inactiveReason:je,states:e.live.controls,watches:e.live.watches,draftScope:`${q.id}:${((ke=e.live.lease)==null?void 0:ke.leaseId)??"edit"}`,drafts:X[Pe]?{[r.binding.id]:X[Pe]}:void 0,onDraftChange:(pe,ge,Le)=>he(lt=>({...lt,[Pe]:{value:ge,dirty:Le}})),profileSaveLocked:!1,onApply:(pe,ge)=>void e.live.apply(pe,ge),onSaveValue:e.live.saveControlValue,onRemoveValue:pe=>e.live.saveProfileMetadata({removeDefaults:[pe]})}):r.kind==="watch"?t.jsx(Mo,{profile:{...q,controls:[],watches:[r.binding]},watches:e.live.watches}):t.jsx(Oo,{action:r.binding,state:e.live.actions[r.binding.id],draft:re[`${q.id}:${r.binding.id}`]??Gt(r.binding),active:e.active&&e.live.studioState==="Running"&&(e.live.studioMode!=="run"||r.binding.target.role==="server"),inactiveReason:e.live.studioState==="Paused"?a("playtest.actions.resumeRequired","Resume Studio before running this action."):e.live.studioMode==="run"&&r.binding.target.role==="client"?a("playtest.actions.playModeRequired","This action is available in Play."):e.inactiveReason,presentation:K[r.binding.id],onDraftChange:(pe,ge)=>oe(Le=>({...Le,[`${q.id}:${r.binding.id}`]:ge})),onExecute:(pe,ge)=>void e.live.executeAction(pe,ge,crypto.randomUUID()),onSaveDefaults:e.live.saveActionDefaults})]},`${r.kind}:${r.binding.id}`)},p=r=>{var T;const D=Ce(r==="watches"?"watch":r==="controls"?"control":"action"),h=new Map;for(const I of D){const Y=((T=K[I.binding.id])==null?void 0:T.group)??se;h.set(Y,[...h.get(Y)??[],I])}const b=Ne[r];return t.jsxs("section",{className:s.valueSection,"aria-label":b,onDragOver:I=>{$&&$!==r&&I.preventDefault()},onDrop:I=>{!$||$===r||(I.preventDefault(),xe($),ee(null))},children:[t.jsxs("header",{className:s.valueSectionHeader,children:[t.jsxs("div",{className:s.valueSectionHeading,children:[O&&t.jsx("button",{type:"button",className:s.sectionDragHandle,draggable:!0,"aria-label":a("playtest.values.drag","Drag {{label}} to reorder").replace("{{label}}",b),disabled:U,onDragStart:()=>ee(r),onDragEnd:()=>ee(null),children:t.jsx(wt,{size:15,"aria-hidden":"true"})}),t.jsx("h3",{children:b}),t.jsx("span",{className:s.valueSectionCount,children:D.length})]}),t.jsxs("div",{className:s.valueSectionHeaderActions,children:[r==="controls"&&q&&t.jsxs("div",{className:s.runtimeSettings,children:[t.jsx(Oe,{active:e.live.canMutate,label:a("playtest.settings.applyChangesAutomatically","Apply changes automatically"),reason:e.inactiveReason??a("playtest.controls.proRequired","Real-time value editing and Reset all are available with Pro."),children:t.jsxs("label",{className:s.runtimeSettingSwitch,children:[t.jsx("span",{children:a("playtest.settings.applyChangesAutomatically","Apply changes automatically")}),t.jsx("input",{className:s.runtimeSettingSwitchInput,type:"checkbox",role:"switch",checked:ye.runtimeApplyMode==="auto",disabled:!e.live.canMutate,onChange:I=>{_e({...ye,runtimeApplyMode:I.target.checked?"auto":"manual"})}}),t.jsx("span",{className:s.runtimeSettingSwitchTrack,"aria-hidden":"true",children:t.jsx("span",{className:s.runtimeSettingSwitchThumb})})]})}),t.jsx(Oe,{active:e.live.canMutate,label:a("playtest.settings.applyDefaultsOnPlayStart","Apply saved defaults when Play starts"),reason:e.inactiveReason??a("playtest.controls.proRequired","Real-time value editing and Reset all are available with Pro."),children:t.jsxs("label",{className:s.runtimeSettingSwitch,children:[t.jsx("span",{children:a("playtest.settings.applyDefaultsOnPlayStart","Apply saved defaults when Play starts")}),t.jsx("input",{className:s.runtimeSettingSwitchInput,type:"checkbox",role:"switch",checked:ye.applyDefaultsOnManualPlayStart,disabled:!e.live.canMutate,onChange:I=>_e({...ye,applyDefaultsOnManualPlayStart:I.target.checked})}),t.jsx("span",{className:s.runtimeSettingSwitchTrack,"aria-hidden":"true",children:t.jsx("span",{className:s.runtimeSettingSwitchThumb})})]})})]}),O&&t.jsx("button",{type:"button",className:s.sectionMoveButton,disabled:U,"aria-label":a(B[0]===r?"playtest.values.moveDown":"playtest.values.moveUp",B[0]===r?"Move {{label}} down":"Move {{label}} up").replace("{{label}}",b),onClick:()=>xe(r),children:B[0]===r?t.jsx(mt,{size:14,"aria-hidden":"true"}):t.jsx(St,{size:14,"aria-hidden":"true"})})]})]}),D.length===0?t.jsx("div",{className:s.panelEmpty,children:r==="watches"?a("playtest.watch.empty","Observed values appear here during Play."):r==="controls"?a("playtest.controls.empty","No test controls in this profile yet."):a("playtest.actions.empty","No actions in this profile yet.")}):t.jsx("div",{className:r==="watches"?s.watchValueGrid:r==="controls"?s.controlValueList:s.actionValueList,children:Array.from(h.entries()).map(([I,Y])=>{const de=C.has(`${r}:${I}`),je=t.jsx("div",{className:s.valueGroupRows,children:Y.map(Pe=>Re(Pe,D))});return h.size===1&&I===se?t.jsx("div",{className:s.valueGroup,children:je},`${r}:${I}`):t.jsxs("section",{className:s.valueGroup,children:[t.jsxs("button",{type:"button",className:s.valueGroupToggle,"aria-expanded":!de,"aria-label":`${de?a("playtest.values.expandGroup","Expand"):a("playtest.values.collapseGroup","Collapse")} ${I}`,onClick:()=>fe(`${r}:${I}`),children:[t.jsx("span",{children:I}),t.jsx("span",{children:Y.length})]}),!de&&je]},`${r}:${I}`)})})]},r)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.valueToolbar,children:[t.jsxs("label",{className:s.valueSearch,children:[t.jsx("span",{className:s.srOnly,children:a("playtest.values.search","Search test values")}),t.jsx("input",{type:"search","aria-label":a("playtest.values.search","Search test values"),value:n,onChange:r=>{i(r.target.value),f(0)},placeholder:a("playtest.values.searchPlaceholder","Name, group, source, or path")})]}),t.jsxs("button",{type:"button",className:s.secondaryAction,"aria-expanded":M,"aria-controls":"playtest-value-filters",onClick:()=>w(r=>!r),children:[a("playtest.values.filters","Filters"),ie?` (${[n.trim()!=="",d!=="all",u!=="all",m!=="all"].filter(Boolean).length})`:""]})]}),M&&t.jsxs("div",{className:s.valueFilters,id:"playtest-value-filters",children:[t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.kind","Value type")}),t.jsxs("select",{"aria-label":a("playtest.values.kind","Value type"),value:d,onChange:r=>{c(r.target.value),f(0)},children:[t.jsx("option",{value:"all",children:a("playtest.values.all","All values")}),t.jsx("option",{value:"control",children:a("playtest.values.controls","Controls")}),t.jsx("option",{value:"watch",children:a("playtest.values.watches","Watch Values")}),t.jsx("option",{value:"action",children:a("playtest.actions.section","Actions")})]})]}),t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.status","Observation status")}),t.jsxs("select",{"aria-label":a("playtest.values.status","Observation status"),value:u,onChange:r=>{y(r.target.value),f(0)},children:[t.jsx("option",{value:"all",children:a("playtest.values.statusAll","All statuses")}),t.jsx("option",{value:"fresh",children:a("playtest.watch.fresh","Fresh")}),t.jsx("option",{value:"stale",children:a("playtest.watch.stale","Stale")}),t.jsx("option",{value:"unavailable",children:a("playtest.watch.unavailable","Unavailable")}),t.jsx("option",{value:"unobserved",children:a("playtest.watch.notObserved","Not observed yet")})]})]}),t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.group","Group")}),t.jsxs("select",{"aria-label":a("playtest.values.group","Group"),value:m,onChange:r=>{_(r.target.value),f(0)},children:[t.jsx("option",{value:"all",children:a("playtest.values.allGroups","All groups")}),ne.groups.map(r=>t.jsx("option",{value:r,children:r},r))]})]}),t.jsxs("label",{children:[t.jsx("span",{children:a("playtest.values.pageSize","Rows")}),t.jsxs("select",{"aria-label":a("playtest.values.pageSize","Rows"),value:V,onChange:r=>{R(Number(r.target.value)),f(0)},children:[t.jsx("option",{value:"25",children:"25"}),t.jsx("option",{value:"50",children:"50"}),t.jsx("option",{value:"100",children:"100"})]})]})]}),t.jsxs("div",{className:s.valueListStatus,children:[t.jsx("div",{className:s.valueCount,role:"status",children:a("playtest.values.count","{{visible}} of {{total}} values").replace("{{visible}}",String(ne.total)).replace("{{total}}",String(ce))}),t.jsx("button",{type:"button",className:s.secondaryAction,disabled:U||ce===0,onClick:()=>{if(O){z(!1);return}ie&&(i(""),c("all"),y("all"),_("all"),f(0)),z(!0)},children:O?a("playtest.values.doneLayout","Done editing layout"):ie?a("playtest.values.editFullList","Edit full list"):a("playtest.values.editLayout","Edit layout")})]}),O&&t.jsx("div",{className:s.layoutHint,id:"playtest-layout-boundary",children:a("playtest.values.layoutBoundary","Move items within the current group and pinned section.")}),t.jsx("span",{className:s.srOnly,"aria-live":"polite",children:ae}),te&&t.jsx("div",{className:s.layoutError,role:"alert",children:te}),ne.total===0&&ce>0?t.jsx("div",{className:s.panelEmpty,children:a("playtest.values.noResults","No values match these filters.")}):t.jsx("div",{className:s.valueSections,children:B.map(p)}),ne.pages>1&&t.jsxs("div",{className:s.valuePagination,children:[t.jsx("button",{type:"button",disabled:ne.safePage===0,onClick:()=>f(r=>r-1),children:a("playtest.values.previous","Previous")}),t.jsxs("span",{children:[ne.safePage+1," / ",ne.pages]}),t.jsx("button",{type:"button",disabled:ne.safePage+1>=ne.pages,onClick:()=>f(r=>r+1),children:a("playtest.values.next","Next")})]})]})}const qo="_emptyState_10pjf_1",Uo="_header_10pjf_11",Ko="_method_10pjf_12",zo="_methods_10pjf_39",Wo="_singleMethod_10pjf_45",Jo="_methodTitle_10pjf_57",Yo="_moreExamples_10pjf_70",Qo="_hint_10pjf_88",Xo="_tierNote_10pjf_89",Zo="_disabledReason_10pjf_90",ec="_primaryAction_10pjf_102",Ee={emptyState:qo,header:Uo,method:Ko,methods:zo,singleMethod:Wo,methodTitle:Jo,moreExamples:Yo,hint:Qo,tierNote:Xo,disabledReason:Zo,primaryAction:ec};function Ht(e){const{t:a}=ue(),n=e.kind==="no-results",i=e.kind==="no-profile",d=n?a("playtest.emptyResults.title","Ask AI to check your game"):i?a("playtest.emptyValues.noProfileTitle","Prepare values and actions to test"):a("playtest.emptyValues.noValuesTitle","Add test values and actions to this profile"),c=n?a("playtest.emptyResults.description","When AI finishes the test, you can review pass, failure, and the reason here."):i?a("playtest.emptyValues.noProfileDescription","Ask AI to prepare values to observe or change and actions to run during Play, or select an object in Studio and add one directly."):a("playtest.emptyValues.noValuesDescription","Use the selected profile, {{name}}, to collect values to observe or change and actions to run during Play.").replace("{{name}}",e.profileName??"");return t.jsxs("section",{className:Ee.emptyState,children:[t.jsxs("header",{className:Ee.header,children:[t.jsx("h3",{children:d}),t.jsx("p",{children:c})]}),t.jsxs("div",{className:`${Ee.methods} ${n?Ee.singleMethod:""}`,children:[t.jsxs("section",{className:Ee.method,children:[t.jsxs("div",{className:Ee.methodTitle,children:[t.jsx(da,{size:16,"aria-hidden":"true"}),t.jsx("h4",{children:a("playtest.emptyValues.aiTitle","Ask AI")})]}),!n&&t.jsx("p",{children:a("playtest.emptyValues.aiDescription","Copy a request and paste it into an AI chat connected to WEPPY.")}),t.jsx(xt,{exampleIds:n?["automated-check"]:["character"]}),!n&&t.jsxs("details",{className:Ee.moreExamples,children:[t.jsx("summary",{children:a("playtest.ai.otherExamples","Other request examples")}),t.jsx(xt,{exampleIds:["selection","game-state","action"]})]}),n&&e.isBasic&&t.jsx("p",{className:Ee.tierNote,children:a("playtest.emptyResults.proDescription","Automated test runs and actual saved results are available with Pro.")})]}),!n&&t.jsxs("section",{className:Ee.method,children:[t.jsxs("div",{className:Ee.methodTitle,children:[t.jsx(Ra,{size:16,"aria-hidden":"true"}),t.jsx("h4",{children:a("playtest.emptyValues.directTitle","Select and add it yourself")})]}),t.jsx("p",{children:a("playtest.emptyValues.directDescription","Select an object in Studio, then choose a supported value to observe or change, or an available action.")}),i&&t.jsx("p",{className:Ee.hint,children:a("playtest.emptyValues.firstProfileHint","When you add the first item, enter a profile name to keep related test settings together.")}),t.jsx("button",{type:"button",className:Ee.primaryAction,disabled:!!e.directAddDisabledReason,"aria-describedby":e.directAddDisabledReason?"playtest-empty-direct-reason":void 0,onClick:e.onAddFromSelection,children:a("playtest.emptyValues.directAction","Add selected Studio value")}),e.directAddDisabledReason&&t.jsx("p",{className:Ee.disabledReason,id:"playtest-empty-direct-reason",children:e.directAddDisabledReason})]})]})]})}function tc(e){var m,_,C,k,x,f,V;const{live:a}=e,{t:n}=ue(),i=((m=a.lease)==null?void 0:m.state)==="active"&&(a.studioState==="Running"||a.studioState==="Paused"),d=i&&a.canMutate,c=d&&(a.studioMode!=="run"||!!((_=a.profile)!=null&&_.controls.some(R=>R.target.role==="server"))),u=e.inactiveReason??n("playtest.values.playRequired","Start Play in Studio to change test values."),y=(((C=a.profile)==null?void 0:C.controls.length)??0)+(((k=a.profile)==null?void 0:k.watches.length)??0)+(((f=(x=a.profile)==null?void 0:x.actions)==null?void 0:f.length)??0);return t.jsxs("div",{className:s.liveWorkspace,role:"tabpanel","aria-label":n("playtest.view.liveSession","Test Values"),children:[t.jsxs("section",{className:s.profileToolbar,children:[t.jsxs("div",{children:[t.jsxs("div",{className:s.profileLabelRow,children:[t.jsx("label",{htmlFor:"playtest-profile",children:n("playtest.profile.label","Test profiles")}),t.jsx("span",{children:n("playtest.profile.savedCount","{{count}} profiles saved").replace("{{count}}",String(a.profiles.length))})]}),t.jsxs("select",{id:"playtest-profile",value:a.selectedProfileId??"",disabled:!!a.switchingProfileId,"aria-busy":!!a.switchingProfileId,onChange:R=>void a.selectProfile(R.target.value),children:[a.profiles.length===0&&t.jsx("option",{value:"",children:n("playtest.profile.empty","No profiles yet")}),a.profiles.map(R=>t.jsx("option",{value:R.id,children:R.name},R.id))]})]}),t.jsxs("div",{className:s.profileActions,children:[t.jsxs("button",{type:"button",className:s.primaryAction,onClick:e.onManageValues,children:[t.jsx(Sa,{size:14,"aria-hidden":"true"})," ",n("playtest.values.addValue","Add value")]}),t.jsxs("button",{type:"button",className:s.secondaryAction,disabled:!a.profile||!!a.switchingProfileId,onClick:e.onEditProfile,children:[t.jsx(ka,{size:14,"aria-hidden":"true"})," ",n("playtest.profile.edit","Edit profile")]}),t.jsxs("button",{type:"button",className:s.secondaryAction,disabled:!!a.switchingProfileId,onClick:e.onNewProfile,children:[t.jsx($t,{size:14,"aria-hidden":"true"})," ",n("playtest.profile.new","New profile")]})]})]}),a.switchingProfileId&&t.jsx("div",{className:s.controlAvailability,role:"status","aria-live":"polite",children:n("playtest.profile.switching","Switching test profile…")}),a.loading?t.jsx("div",{className:s.panelEmpty,children:n("common.loading","Loading...")}):y===0?t.jsx(Ht,{kind:a.profile?"no-values":"no-profile",profileName:(V=a.profile)==null?void 0:V.name,onAddFromSelection:e.onManageValues,directAddDisabledReason:e.directAddDisabledReason}):t.jsx("div",{className:s.liveGrid,children:t.jsxs("section",{className:`${s.livePanel} ${s.valueWorkspacePanel}`,"data-runtime-state":i?"active":"inactive",children:[t.jsxs("header",{className:s.valueWorkspaceHeader,children:[t.jsxs("div",{children:[t.jsx("strong",{children:n("playtest.values.title","Test values")}),!d&&t.jsxs("span",{className:s.controlAvailability,"data-warning":a.studioState==="Edit",id:"playtest-controls-availability",role:"status",children:[a.studioState==="Edit"&&t.jsx(zt,{size:14,"aria-hidden":"true"}),u]})]}),t.jsx(Oe,{active:c,label:n("playtest.session.reset","Reset all"),reason:u,children:t.jsxs("button",{type:"button",className:s.resetAction,disabled:!c,"aria-describedby":c?void 0:"playtest-controls-availability",onClick:()=>void a.resetAll(),children:[a.canMutate?t.jsx(ua,{size:14,"aria-hidden":"true"}):t.jsx(Na,{size:14,"aria-hidden":"true"}),n("playtest.session.reset","Reset all")]})})]}),t.jsx(Ho,{live:a,active:d,inactiveReason:u})]})})]})}const ct={label:"",role:"server",path:"Workspace",accessKind:"attribute",fieldName:"",editorType:"number",defaultValue:"0",minimum:"0",maximum:"100",step:"1"};function ac(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"binding"}function Dt(e){const a=e.split(".").map(n=>n.trim()).filter(Boolean);return a.length>0?{root:a[0],segments:a.slice(1)}:null}function $e(e){return e==="range"?"number":e}function sc(e){var n;if(Ge($e(e.editorType)))return _t($e(e.editorType),e.defaultValue)??null;if(e.editorType==="enum")return((n=e.enumValues)==null?void 0:n.find(i=>String(i)===e.defaultValue))??null;if(e.editorType==="boolean")return e.defaultValue==="true";if(e.editorType==="string")return e.defaultValue;const a=Number(e.defaultValue);return Number.isFinite(a)?a:null}function It(e){return e.accessKind==="value"?{kind:"value"}:{kind:e.accessKind,name:e.fieldName.trim()}}function nc(e){var d,c;if("executor"in e)return`${e.target.role} · ${e.executor.kind} · ${e.parameters.length} parameters`;const a=e.path?[e.path.root,...e.path.segments].join("."):"adapter",n=e.access.kind==="value"?"Value":e.access.name??e.access.kind,i="constraints"in e&&((d=e.constraints)==null?void 0:d.minimum)!==void 0&&((c=e.constraints)==null?void 0:c.maximum)!==void 0;return`${e.target.role} · ${a} · ${n} · ${i?"range":e.valueType}`}function ic(e){var _e,xe,Ce,be,fe,Re;const{t:a}=ue(),n=!!e.profile,[i,d]=o.useState(""),[c,u]=o.useState([]),[y,m]=o.useState([]),[_,C]=o.useState([]),[k,x]=o.useState({}),[f,V]=o.useState("controls"),[R,M]=o.useState(!1),[w,B]=o.useState(ct),[P,E]=o.useState(!1),[W,$]=o.useState(!1),[ee,te]=o.useState(!1),[H,O]=o.useState(!1),[z,U]=o.useState(null),[L,ae]=o.useState(null),J=o.useRef(null);o.useEffect(()=>{var p,j,F,v,S;e.open&&(d(((p=e.profile)==null?void 0:p.name)??""),u(((j=e.profile)==null?void 0:j.controls)??[]),m(((F=e.profile)==null?void 0:F.watches)??[]),C(((v=e.profile)==null?void 0:v.actions)??[]),x(((S=e.profile)==null?void 0:S.presentation)??{}),V("controls"),M(!1),B(ct),$(!1),te(!1),O(!1),ae(null),U(null))},[e.open,e.profile]);const le=f==="controls"?c:f==="watches"?y:_,Q=i!==(((_e=e.profile)==null?void 0:_e.name)??"")||JSON.stringify(c)!==JSON.stringify(((xe=e.profile)==null?void 0:xe.controls)??[])||JSON.stringify(y)!==JSON.stringify(((Ce=e.profile)==null?void 0:Ce.watches)??[])||JSON.stringify(_)!==JSON.stringify(((be=e.profile)==null?void 0:be.actions)??[])||JSON.stringify(k)!==JSON.stringify(((fe=e.profile)==null?void 0:fe.presentation)??{})||R,K=o.useMemo(()=>new Set([...c,...y,..._].map(p=>p.id)),[_,c,y]),Z=(p,j)=>{B(F=>({...F,[p]:j})),U(null)},X=()=>{const p=ac(w.label);let j=p,F=2;for(;K.has(j);)j=`${p}-${F}`,F+=1;return j},he=(p,j)=>k[p]??{order:j,pinned:!1},re=(p,j,F)=>x(v=>({...v,[p]:{...he(p,j),...F}})),oe=le.map((p,j)=>({binding:p,sourceOrder:j,entry:he(p.id,j)})).sort((p,j)=>p.entry.order-j.entry.order),ye=(p,j)=>{const F=oe.findIndex(A=>A.binding.id===p),v=oe[F+j],S=oe[F];!S||!v||x(A=>({...A,[S.binding.id]:{...S.entry,order:v.entry.order},[v.binding.id]:{...v.entry,order:S.entry.order}}))},we=()=>{const p=Dt(w.path),j=sc(w);if(!w.label.trim()||!p||w.accessKind!=="value"&&!w.fieldName.trim()||j===null)return null;const F=w.editorType==="range",v=Number(w.minimum),S=Number(w.maximum),A=Number(w.step);return F&&(typeof j!="number"||!Number.isFinite(v)||!Number.isFinite(S)||!Number.isFinite(A)||v>=S||A<=0||j<v||j>S)?null:{id:X(),label:w.label.trim(),target:{role:w.role},path:p,access:It(w),valueType:$e(w.editorType),value:j,...w.editorType==="enum"?{enumValues:w.enumValues}:{},applyTiming:"after_agents_ready",restorePolicy:"session_end",...F?{constraints:{minimum:v,maximum:S,step:A}}:{}}},q=()=>{const p=Dt(w.path);return!w.label.trim()||!p||w.accessKind!=="value"&&!w.fieldName.trim()?null:{id:X(),label:w.label.trim(),target:{role:w.role},path:p,access:It(w),valueType:$e(w.editorType)}},se=()=>{const p=f==="controls"?we():q();if(!p){U(a("playtest.profile.binding.invalid","Complete the label, path, field, and type values."));return}f==="controls"?u(j=>[...j,p]):m(j=>[...j,p]),x(j=>({...j,[p.id]:{order:c.length+y.length,pinned:!1}})),M(!1),B(ct)},ne=async()=>{if(e.onResolveSelectionCandidates){try{const j=await e.onResolveSelectionCandidates();if(!j.selected.path||j.candidates.length===0){U(a("playtest.profile.binding.selectionEmpty","The selected instance has no supported fields."));return}ae(j),ce(j,0)}catch(j){U(j instanceof Error?j.message:String(j))}return}if(!e.onResolveSelection)return;const p=f==="controls"?we():q();if(!p){U(a("playtest.profile.binding.selectionNeedsFields","Enter the label, field, and type before using the Studio selection."));return}try{const j=await e.onResolveSelection({kind:f==="controls"?"control":"watch",id:p.id,label:p.label,role:p.target.role,access:p.access,valueType:p.valueType,..."value"in p?{value:p.value}:{},..."constraints"in p&&p.constraints?{constraints:p.constraints}:{},..."enumValues"in p&&p.enumValues?{enumValues:p.enumValues}:{}});j.path&&Z("path",[j.path.root,...j.path.segments].join("."))}catch(j){U(j instanceof Error?j.message:String(j))}},ce=(p,j)=>{const F=p.candidates[j];if(!F||!p.selected.path)return;const v=F.fieldName??"Value";B(S=>({...S,label:`${p.selected.name??"Selected"} ${v}`,path:[p.selected.path.root,...p.selected.path.segments].join("."),accessKind:F.accessKind,fieldName:F.fieldName??"",editorType:F.valueType,defaultValue:typeof F.value=="object"?JSON.stringify(F.value):String(F.value),enumValues:F.enumValues})),U(null)},ie=async()=>{if(!(!e.profile||!e.onSave||!i.trim())){E(!0),U(null);try{await e.onSave({...e.profile,schemaVersion:4,name:i.trim(),controls:c,watches:y,actions:_,presentation:k}),e.onClose()}catch(p){U(p instanceof Error?p.message:String(p))}finally{E(!1)}}},Ne=()=>{if(!(P||H)){if(Q){$(!0);return}e.onClose()}},ve=async()=>{var p;if(!(!e.profile||!e.onDelete||H||e.deleteDisabledReason)){O(!0),U(null);try{await e.onDelete(e.profile.id,e.profile.revision),te(!1),e.onClose()}catch(j){const F=j&&typeof j=="object"?String("payload"in j&&((p=j.payload)==null?void 0:p.errorCode)||"error"in j&&j.error||"code"in j&&j.code||""):"";U(a(F==="profile_active"?"playtest.profile.deleteActive":F==="profile_revision_conflict"?"playtest.profile.deleteConflict":F==="profile_not_found"?"playtest.profile.deleteNotFound":F==="profile_scope_unavailable"?"playtest.profile.deleteScopeUnavailable":"playtest.profile.deleteFailed",j instanceof Error?j.message:"Could not delete the profile."))}finally{O(!1)}}};return t.jsxs(Ke,{open:e.open,onClose:Ne,dismissDisabled:P||H,initialFocusRef:J,ariaLabel:n?a("playtest.profile.editTitle","Edit test profile"):a("playtest.profile.createTitle","Create test profile"),children:[t.jsxs("div",{className:`${s.profileDialog} ${n?s.profileEditorDialog:""}`,children:[t.jsx(ze,{title:n?a("playtest.profile.editTitle","Edit test profile"):a("playtest.profile.createTitle","Create test profile"),description:n?a("playtest.profile.editDescription","Add controls you can change during Play and Watch Values you only want to observe."):a("playtest.profile.createDescription","Profiles are stored locally for the selected Place. Add controls after creating it."),closeLabel:a("common.close","Close"),closeDisabled:P||H,onRequestClose:Ne}),t.jsxs("div",{className:s.profileDialogBody,children:[t.jsxs("label",{children:[a("playtest.profile.name","Profile name"),t.jsx("input",{ref:J,value:i,onChange:p=>d(p.target.value)})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:s.bindingTabs,role:"tablist","aria-label":a("playtest.profile.bindingTabs","Profile values"),children:[t.jsxs("button",{type:"button",role:"tab","aria-selected":f==="controls",onClick:()=>{V("controls"),M(!1)},children:[a("playtest.profile.controlsTab","Controls")," ",t.jsx("span",{children:c.length})]}),t.jsxs("button",{type:"button",role:"tab","aria-selected":f==="watches",onClick:()=>{V("watches"),M(!1)},children:[a("playtest.profile.watchesTab","Watch Values")," ",t.jsx("span",{children:y.length})]}),t.jsxs("button",{type:"button",role:"tab","aria-selected":f==="actions",onClick:()=>{V("actions"),M(!1)},children:[a("playtest.actions.section","Actions")," ",t.jsx("span",{children:_.length})]})]}),t.jsx("div",{className:s.bindingList,children:le.length===0?t.jsx("div",{className:s.bindingEmpty,children:f==="controls"?a("playtest.profile.controlsEmpty","No controls added yet."):f==="watches"?a("playtest.profile.watchesEmpty","No Watch Values added yet."):a("playtest.actions.empty","No actions in this profile yet.")}):oe.map(({binding:p,entry:j,sourceOrder:F},v)=>t.jsxs("div",{className:s.bindingItem,children:[t.jsxs("div",{className:s.bindingItemCopy,children:[t.jsx("strong",{children:p.label}),t.jsx("span",{children:nc(p)}),t.jsxs("div",{className:s.bindingPresentation,children:[t.jsxs("label",{children:[a("playtest.profile.group","Group"),t.jsx("input",{"aria-label":a("playtest.profile.groupFor","Group for {{label}}").replace("{{label}}",p.label),value:j.group??"",onChange:S=>re(p.id,F,{group:S.target.value||void 0})})]}),t.jsxs("label",{className:s.bindingPin,children:[t.jsx("input",{type:"checkbox","aria-label":a("playtest.profile.pinLabel","Pin {{label}}").replace("{{label}}",p.label),checked:j.pinned,onChange:S=>re(p.id,F,{pinned:S.target.checked})}),a("playtest.profile.pin","Pin")]})]})]}),t.jsxs("div",{className:s.bindingItemActions,children:[t.jsx("button",{type:"button","aria-label":a("playtest.profile.moveUp","Move {{label}} up").replace("{{label}}",p.label),disabled:v===0,onClick:()=>ye(p.id,-1),children:t.jsx(ya,{size:13,"aria-hidden":"true"})}),t.jsx("button",{type:"button","aria-label":a("playtest.profile.moveDown","Move {{label}} down").replace("{{label}}",p.label),disabled:v===oe.length-1,onClick:()=>ye(p.id,1),children:t.jsx(ma,{size:13,"aria-hidden":"true"})}),t.jsx("button",{type:"button",className:s.bindingDelete,"aria-label":a("playtest.profile.removeBinding","Remove {{label}}").replace("{{label}}",p.label),onClick:()=>{f==="controls"?u(S=>S.filter(A=>A.id!==p.id)):f==="watches"?m(S=>S.filter(A=>A.id!==p.id)):C(S=>S.filter(A=>A.id!==p.id)),x(S=>Object.fromEntries(Object.entries(S).filter(([A])=>A!==p.id)))},children:t.jsx(jt,{size:14,"aria-hidden":"true"})})]})]},p.id))}),f!=="actions"&&(R?t.jsxs("fieldset",{className:s.bindingForm,"aria-label":f==="controls"?a("playtest.profile.newControl","New control"):a("playtest.profile.newWatch","New watch"),children:[(e.onResolveSelectionCandidates||e.onResolveSelection)&&t.jsx("button",{type:"button",className:s.selectionButton,onClick:()=>void ne(),children:a("playtest.profile.binding.useSelection","Use current Studio selection")}),L&&L.candidates.length>1&&t.jsxs("label",{children:[a("playtest.profile.binding.selectedField","Selected field"),t.jsx("select",{onChange:p=>ce(L,Number(p.target.value)),children:L.candidates.map((p,j)=>t.jsx("option",{value:j,children:p.accessKind==="value"?"ValueBase.Value":`${p.accessKind} · ${p.fieldName}`},`${p.accessKind}:${p.fieldName??"Value"}`))})]}),t.jsxs("div",{className:s.bindingFormGrid,children:[t.jsxs("label",{children:[a("playtest.profile.binding.label","Label"),t.jsx("input",{value:w.label,onChange:p=>Z("label",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.role","Target"),t.jsxs("select",{value:w.role,onChange:p=>Z("role",p.target.value),children:[t.jsx("option",{value:"server",children:a("playtest.profile.binding.server","Server")}),t.jsx("option",{value:"client",children:a("playtest.profile.binding.client","Client")})]})]}),t.jsxs("label",{className:s.bindingPathField,children:[a("playtest.profile.binding.path","Runtime path"),t.jsx("input",{value:w.path,placeholder:a("playtest.profile.binding.pathPlaceholder","Workspace.Config"),onChange:p=>Z("path",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.access","Access"),t.jsxs("select",{value:w.accessKind,onChange:p=>Z("accessKind",p.target.value),children:[t.jsx("option",{value:"attribute",children:a("playtest.profile.binding.attribute","Attribute")}),t.jsx("option",{value:"value",children:a("playtest.profile.binding.valueBase","ValueBase.Value")}),t.jsx("option",{value:"property",children:a("playtest.profile.binding.property","Property")})]})]}),w.accessKind!=="value"&&t.jsxs("label",{children:[a("playtest.profile.binding.field","Field name"),t.jsx("input",{value:w.fieldName,onChange:p=>Z("fieldName",p.target.value)})]}),t.jsxs("label",{children:[f==="controls"?a("playtest.profile.binding.inputType","Input type"):a("playtest.profile.binding.valueType","Value type"),t.jsxs("select",{value:w.editorType,onChange:p=>Z("editorType",p.target.value),children:[t.jsx("option",{value:"number",children:a("playtest.profile.binding.number","Number")}),f==="controls"&&t.jsx("option",{value:"range",children:a("playtest.profile.binding.range","Range")}),t.jsx("option",{value:"string",children:a("playtest.profile.binding.string","String")}),t.jsx("option",{value:"boolean",children:a("playtest.profile.binding.boolean","Boolean")}),t.jsx("option",{value:"vector3",children:a("playtest.profile.binding.vector3","Vector3")}),t.jsx("option",{value:"color3",children:a("playtest.profile.binding.color3","Color3")}),t.jsx("option",{value:"cframe",children:a("playtest.profile.binding.cframe","CFrame")}),w.enumValues&&t.jsx("option",{value:"enum",children:a("playtest.profile.binding.enum","Enum")})]})]}),f==="controls"&&Ge($e(w.editorType))&&t.jsx(ht,{type:$e(w.editorType),draft:w.defaultValue,label:a("playtest.profile.binding.defaultValue","Default value"),onChange:p=>Z("defaultValue",p)}),f==="controls"&&w.editorType==="enum"&&t.jsxs("label",{children:[a("playtest.profile.binding.defaultValue","Default value"),t.jsx("select",{value:w.defaultValue,onChange:p=>Z("defaultValue",p.target.value),children:(Re=w.enumValues)==null?void 0:Re.map(p=>t.jsx("option",{value:String(p),children:String(p)},String(p)))})]}),f==="controls"&&!Ge($e(w.editorType))&&w.editorType!=="boolean"&&w.editorType!=="enum"&&t.jsxs("label",{children:[a("playtest.profile.binding.defaultValue","Default value"),t.jsx("input",{type:w.editorType==="string"?"text":"number",value:w.defaultValue,onChange:p=>Z("defaultValue",p.target.value)})]}),f==="controls"&&w.editorType==="boolean"&&t.jsxs("label",{className:s.bindingBooleanDefault,children:[t.jsx("input",{type:"checkbox","aria-label":a("playtest.profile.binding.defaultValue","Default value"),checked:w.defaultValue==="true",onChange:p=>Z("defaultValue",String(p.target.checked))}),t.jsx("span",{children:a("playtest.profile.binding.defaultValue","Default value")})]}),f==="controls"&&w.editorType==="range"&&t.jsxs("div",{className:s.rangeFields,children:[t.jsxs("label",{children:[a("playtest.profile.binding.minimum","Minimum"),t.jsx("input",{type:"number",value:w.minimum,onChange:p=>Z("minimum",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.maximum","Maximum"),t.jsx("input",{type:"number",value:w.maximum,onChange:p=>Z("maximum",p.target.value)})]}),t.jsxs("label",{children:[a("playtest.profile.binding.step","Step"),t.jsx("input",{type:"number",value:w.step,onChange:p=>Z("step",p.target.value)})]})]})]}),z&&t.jsx("div",{className:s.bindingError,role:"alert",children:z}),t.jsxs("div",{className:s.bindingFormActions,children:[t.jsx("button",{type:"button",className:s.secondaryAction,onClick:()=>{M(!1),U(null)},children:a("common.cancel","Cancel")}),t.jsx("button",{type:"button",className:s.primaryAction,onClick:se,children:a("playtest.profile.binding.add","Add to profile")})]})]}):t.jsxs("button",{type:"button",className:s.addBindingButton,onClick:()=>M(!0),children:[t.jsx($t,{size:14,"aria-hidden":"true"})," ",f==="controls"?a("playtest.profile.addControl","Add control"):a("playtest.profile.addWatch","Add watch")]}))]}),z&&!R&&t.jsx("div",{className:s.bindingError,role:"alert",children:z})]}),t.jsxs("div",{className:s.profileDialogActions,children:[n&&e.onDelete&&t.jsxs("button",{type:"button",className:`${s.stopAction} ${s.profileDeleteAction}`,disabled:P||H||!!e.deleteDisabledReason,title:e.deleteDisabledReason,onClick:()=>te(!0),children:[t.jsx(jt,{size:14,"aria-hidden":"true"})," ",a("playtest.profile.delete","Delete profile")]}),n&&e.deleteDisabledReason&&t.jsx("span",{className:s.profileDeleteReason,role:"status",children:e.deleteDisabledReason}),t.jsx("button",{type:"button",className:s.secondaryAction,disabled:P||H,onClick:Ne,children:a("common.cancel","Cancel")}),n?t.jsx("button",{type:"button",className:s.primaryAction,disabled:!i.trim()||P,onClick:()=>void ie(),children:P?a("playtest.profile.saving","Saving…"):a("playtest.profile.save","Save profile")}):t.jsx("button",{type:"button",className:s.primaryAction,disabled:!i.trim()||P,onClick:async()=>{E(!0);try{await e.onCreate(i),d(""),e.onClose()}finally{E(!1)}},children:P?a("playtest.profile.creating","Creating…"):a("playtest.profile.createTitle","Create test profile")})]})]}),t.jsx(ft,{open:W,title:a("playtest.profile.discardTitle","Discard profile changes?"),message:a("playtest.profile.discardMessage","Your unsaved profile changes will be lost."),cancelLabel:a("playtest.profile.keepEditing","Keep editing"),confirmLabel:a("playtest.profile.discard","Discard changes"),onCancel:()=>$(!1),onConfirm:()=>{$(!1),e.onClose()}}),t.jsx(ft,{open:ee,title:a("playtest.profile.deleteConfirmTitle","Delete test profile?"),message:e.profile?[a("playtest.profile.deleteConfirmMessage","Delete “{{name}}”? Its {{controls}} control values and {{watches}} observed values will be removed. Game objects, scripts, test connection code, other profiles, and automated test results will remain.").replace("{{name}}",e.profile.name).replace("{{controls}}",String(e.profile.controls.length)).replace("{{watches}}",String(e.profile.watches.length)),Q?a("playtest.profile.deleteDirty","Unsaved edits will also be discarded."):""].filter(Boolean).join(" "):"",cancelLabel:a("common.cancel","Cancel"),confirmLabel:a("playtest.profile.delete","Delete profile"),loading:H,onCancel:()=>{H||te(!1)},onConfirm:()=>void ve()})]})}function Fe(e){return`${e.accessKind}:${e.fieldName??"Value"}`}function et(e){return e.fieldName??"Value"}function lc(e){const{t:a}=ue(),n=o.useId(),[i,d]=o.useState(!1),[c,u]=o.useState(""),y=o.useRef(null),m=o.useRef(null),_=o.useRef(null),C=c.trim().toLocaleLowerCase(),k=o.useMemo(()=>e.candidates.filter(P=>`${et(P)} ${P.accessKind}`.toLocaleLowerCase().includes(C)),[C,e.candidates]),x=["attribute","value","property"].map(P=>({kind:P,candidates:k.filter(E=>E.accessKind===P)})).filter(P=>P.candidates.length>0),f=et(e.selected);o.useEffect(()=>{var P;i&&((P=m.current)==null||P.focus())},[i]);const V=(P=!0)=>{var E;d(!1),u(""),P&&((E=y.current)==null||E.focus())},R=()=>{var P;return Array.from(((P=_.current)==null?void 0:P.querySelectorAll('[role="option"]'))??[])},M=P=>{var W;const E=R();(W=E[Math.max(0,Math.min(P,E.length-1))])==null||W.focus()},w=P=>{e.onSelect(P),V()},B=P=>P==="attribute"?a("playtest.profile.binding.attribute","Attribute"):P==="value"?a("playtest.profile.binding.valueBase","ValueBase.Value"):a("playtest.profile.binding.property","Property");return t.jsxs("div",{className:s.propertyPicker,children:[t.jsx("span",{className:s.propertyPickerLabel,children:a("playtest.values.selectProperty","Property")}),t.jsxs("button",{ref:y,type:"button",className:s.propertyPickerTrigger,disabled:e.disabled,"aria-haspopup":"listbox","aria-expanded":i,"aria-controls":i?n:void 0,"aria-label":`${a("playtest.values.propertyPickerAction","Select property")}: ${f}`,onClick:()=>{i?V(!1):d(!0)},children:[t.jsx("span",{children:f}),t.jsx(mt,{size:16,"aria-hidden":"true"})]}),i&&t.jsxs("div",{ref:_,className:s.propertyPickerPanel,onKeyDown:P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),V())},children:[t.jsxs("div",{className:s.propertyPickerSearchRow,children:[t.jsxs("label",{children:[a("playtest.values.searchProperties","Search properties"),t.jsx("input",{ref:m,type:"search",value:c,onChange:P=>u(P.target.value),onKeyDown:P=>{P.key==="ArrowDown"&&(P.preventDefault(),M(0))}})]}),t.jsx("button",{type:"button","aria-label":a("playtest.values.propertyPickerClose","Close property picker"),onClick:()=>V(),children:t.jsx(Wt,{size:16,"aria-hidden":"true"})})]}),t.jsxs("div",{id:n,className:s.propertyPickerList,role:"listbox","aria-label":a("playtest.values.availableProperties","Available properties"),children:[x.map(P=>t.jsxs("div",{className:s.propertyPickerGroup,role:"group","aria-label":B(P.kind),children:[t.jsx("span",{children:B(P.kind)}),P.candidates.map(E=>{const W=Fe(E)===Fe(e.selected);return t.jsxs("div",{role:"option",tabIndex:0,"aria-selected":W,"aria-label":et(E),className:s.propertyPickerOption,onClick:()=>w(E),onKeyDown:$=>{var H;const te=R().indexOf($.currentTarget);$.key==="ArrowDown"&&($.preventDefault(),M(te+1)),$.key==="ArrowUp"&&($.preventDefault(),te===0?(H=m.current)==null||H.focus():M(te-1)),($.key==="Enter"||$.key===" ")&&($.preventDefault(),w(E))},children:[t.jsx("span",{children:et(E)}),t.jsx("small",{children:E.valueType}),W&&t.jsx(pa,{size:15,"aria-hidden":"true"})]},Fe(E))})]},P.kind)),k.length===0&&t.jsx("p",{role:"status",children:a("playtest.values.noProperties","No matching properties")})]})]})]})}const Tt=`local RunService = game:GetService("RunService")
72
67
  local Workspace = game:GetService("Workspace")
73
68
 
74
69
  local function requireStudioSession(context)
@@ -104,19 +99,19 @@ return {
104
99
  read = { method = "enemyCount", arguments = {}, pollIntervalMs = 1000 },
105
100
  }},
106
101
  },
107
- }`;function oc(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"value"}function tt(e,a){const n=new Set([...e.controls,...e.watches,...e.actions??[]].map(c=>c.id));let i=a,d=2;for(;n.has(i);)i=`${a}-${d}`,d+=1;return i}function dt(e){return`adapter-${e.adapter}-${e.id}`.toLowerCase().replace(/[^a-z0-9-]+/g,"-")}function cc(e){return e.accessKind==="value"?{kind:"value"}:{kind:e.accessKind,name:e.fieldName}}function yt(e){return e.fieldName??"Value"}function Lt(e,a){return`${e.selected.name??"Selected"} ${yt(a)}`}function ut(e,a,n,i){const d=a.selected.path;return!e||!d?!1:(i==="watch"?e.watches:e.controls).some(c=>{var u;return c.target.role==="server"&&((u=c.path)==null?void 0:u.root)===d.root&&JSON.stringify(c.path.segments)===JSON.stringify(d.segments)&&c.access.kind===n.accessKind&&(n.accessKind==="value"||c.access.name===n.fieldName)})}function pt(e,a,n){var i,d;return JSON.stringify([(i=e.selected.path)==null?void 0:i.root,(d=e.selected.path)==null?void 0:d.segments,a.accessKind,a.fieldName??"value",n])}function Mt(e,a){var i;if(e instanceof Wt&&((i=e.error)!=null&&i.trim()))return e.error;const n=e instanceof Error?e.message:String(e);return n.startsWith("API ")?`${a} ${n}`:n}function dc(e){var S,A,N,G;const{t:a,locale:n="en"}=ue(),[i,d]=o.useState("selection"),[c,u]=o.useState(""),[y,m]=o.useState(0),[_,C]=o.useState("My test profile"),[k,x]=o.useState(!e.profile),[f,V]=o.useState(null),[R,M]=o.useState(""),[w,B]=o.useState(!1),[P,E]=o.useState(null),W=o.useRef(!1),$=o.useRef({open:!1,profileId:null}),[ee,te]=o.useState(null),[q,O]=o.useState(null),[z,U]=o.useState(null),[L,ae]=o.useState(!1),[J,le]=o.useState(null),Q=e.profile,K=((S=e.catalog.adapters)==null?void 0:S.find(l=>l.name===J))??null,X=[K?a("playtest.values.adapterAiContext","Use the existing Test Adapter {{adapter}} at {{path}}. Detected methods: {{methods}}. Review their schemas before adding dashboard entries; do not run a method or guess value types and fixed arguments.").replace("{{adapter}}",K.name).replace("{{path}}",K.sourcePath??K.name).replace("{{methods}}",K.methods.map(l=>`${l.name} (${l.sideEffectClass})`).join(", ")):"",a("playtest.values.aiRequest")].filter(Boolean).join(`
102
+ }`;function rc(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"value"}function tt(e,a){const n=new Set([...e.controls,...e.watches,...e.actions??[]].map(c=>c.id));let i=a,d=2;for(;n.has(i);)i=`${a}-${d}`,d+=1;return i}function dt(e){return`adapter-${e.adapter}-${e.id}`.toLowerCase().replace(/[^a-z0-9-]+/g,"-")}function oc(e){return e.accessKind==="value"?{kind:"value"}:{kind:e.accessKind,name:e.fieldName}}function yt(e){return e.fieldName??"Value"}function Lt(e,a){return`${e.selected.name??"Selected"} ${yt(a)}`}function ut(e,a,n,i){const d=a.selected.path;return!e||!d?!1:(i==="watch"?e.watches:e.controls).some(c=>{var u;return c.target.role==="server"&&((u=c.path)==null?void 0:u.root)===d.root&&JSON.stringify(c.path.segments)===JSON.stringify(d.segments)&&c.access.kind===n.accessKind&&(n.accessKind==="value"||c.access.name===n.fieldName)})}function pt(e,a,n){var i,d;return JSON.stringify([(i=e.selected.path)==null?void 0:i.root,(d=e.selected.path)==null?void 0:d.segments,a.accessKind,a.fieldName??"value",n])}function Mt(e,a){var i;if(e instanceof Jt&&((i=e.error)!=null&&i.trim()))return e.error;const n=e instanceof Error?e.message:String(e);return n.startsWith("API ")?`${a} ${n}`:n}function cc(e){var S,A,N,G;const{t:a,locale:n="en"}=ue(),[i,d]=o.useState("selection"),[c,u]=o.useState(""),[y,m]=o.useState(0),[_,C]=o.useState("My test profile"),[k,x]=o.useState(!e.profile),[f,V]=o.useState(null),[R,M]=o.useState(""),[w,B]=o.useState(!1),[P,E]=o.useState(null),W=o.useRef(!1),$=o.useRef({open:!1,profileId:null}),[ee,te]=o.useState(null),[H,O]=o.useState(null),[z,U]=o.useState(null),[L,ae]=o.useState(!1),[J,le]=o.useState(null),Q=e.profile,K=((S=e.catalog.adapters)==null?void 0:S.find(l=>l.name===J))??null,X=[K?a("playtest.values.adapterAiContext","Use the existing Test Adapter {{adapter}} at {{path}}. Detected methods: {{methods}}. Review their schemas before adding dashboard entries; do not run a method or guess value types and fixed arguments.").replace("{{adapter}}",K.name).replace("{{path}}",K.sourcePath??K.name).replace("{{methods}}",K.methods.map(l=>`${l.name} (${l.sideEffectClass})`).join(", ")):"",a("playtest.values.aiRequest")].filter(Boolean).join(`
108
103
 
109
- `);o.useEffect(()=>{var D;const l=$.current,r=((D=e.profile)==null?void 0:D.id)??null;$.current={open:e.open,profileId:r};const g=l.open&&l.profileId===null&&r!==null&&W.current;!e.open||g||l.open&&l.profileId===r||(d("selection"),x(!e.profile),u(""),m(0),V(null),M(""),E(null),O(null),te(null),ae(!1),le(null))},[e.open,(A=e.profile)==null?void 0:A.id]);const he=o.useMemo(()=>{const l=c.trim().toLocaleLowerCase();return e.catalog.entries.filter(r=>!l||[r.label,r.group,r.adapter,r.sourcePath,r.id].filter(Boolean).join(" ").toLocaleLowerCase().includes(l))},[e.catalog.entries,c]),re=((f==null?void 0:f.candidates)??[]).find(l=>Fe(l)===R)??(f==null?void 0:f.candidates[0]),oe=Math.max(1,Math.ceil(he.length/50)),ye=Math.min(y,oe-1),we=he.slice(ye*50,(ye+1)*50),H=new Set([...(Q==null?void 0:Q.controls)??[],...(Q==null?void 0:Q.watches)??[],...(Q==null?void 0:Q.actions)??[]].map(l=>l.origin?`${l.origin.adapter}/${l.origin.entryId}`:"")),se=[...(Q==null?void 0:Q.controls)??[],...(Q==null?void 0:Q.watches)??[]],ne=se.filter(l=>l.access.kind==="adapter"||l.access.kind==="adapter_read").length,ce=se.length-ne,ie=ce>=64,Ne=ne>=10,ve=((N=e.catalog.adapters)==null?void 0:N.filter(l=>l.entryCount===0))??[],_e=!!(e.catalog.catalogRevision&&e.catalog.verifiedAt&&!Number.isNaN(Date.parse(e.catalog.verifiedAt))),xe=_e&&e.catalog.verifiedAt?new Intl.DateTimeFormat(n,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e.catalog.verifiedAt)):null,Ce=l=>{d(l),u(""),m(0)},be=async()=>{if(Q)return Q;if(!e.onCreateProfile||!_.trim())throw new Error(a("playtest.values.profileNameRequired","Enter a profile name before adding the first value."));return e.onCreateProfile(_.trim())},fe=async l=>{var g;const r={...l,schemaVersion:4,actions:l.actions??[],settings:l.settings??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"},sectionOrder:((g=l.sectionOrder)==null?void 0:g.length)===3?l.sectionOrder:["watches","controls","actions"]};await e.onSave(r)},Re=async(l,r)=>{if(!W.current){W.current=!0,E(`adapter:${l.id}`),O(null);try{const g=await be(),D={kind:"adapter",adapter:l.adapter,entryId:l.id,version:l.adapterVersion},h=b=>{var T;return((T=b.origin)==null?void 0:T.adapter)===l.adapter&&b.origin.entryId===l.id};if(r)await fe({...g,controls:g.controls.filter(b=>!h(b)),watches:g.watches.filter(b=>!h(b)),actions:(g.actions??[]).filter(b=>!h(b))});else if(l.kind==="action"){const b={id:tt(g,dt(l)),label:l.label,target:{role:"server"},executor:{kind:"adapter",adapter:l.adapter,method:l.execute.method},parameters:l.execute.parameters,fixedArguments:l.execute.fixedArguments,origin:D};await fe({...g,schemaVersion:4,actions:[...g.actions??[],b]})}else l.kind==="watch"?await fe({...g,schemaVersion:4,watches:[...g.watches,{id:tt(g,dt(l)),label:l.label,target:{role:"server"},access:{kind:"adapter_read",adapter:l.adapter,...l.read},valueType:l.valueType,origin:D}]}):l.write&&await fe({...g,schemaVersion:4,controls:[...g.controls,{id:tt(g,dt(l)),label:l.label,target:{role:"server"},access:{kind:"adapter",adapter:l.adapter,...l.write},observation:{kind:"adapter_read",adapter:l.adapter,...l.read},valueType:l.valueType,applyOnStart:!1,constraints:l.constraints,enumValues:l.enumValues,applyTiming:"after_agents_ready",restorePolicy:"session_end",origin:D}]})}catch(g){O(g instanceof Error?g.message:String(g))}finally{W.current=!1,E(null)}}},p=async(l,r,g)=>{if(!l.selected.path||w||W.current||ut(Q,l,r,g))return;const D=pt(l,r,g);W.current=!0,E(D),O(null),te(null);try{const h=await be(),b=Lt(l,r),I={id:tt(h,`direct-${oc([l.selected.path.root,...l.selected.path.segments,yt(r)].join("-"))}`),label:b,target:{role:"server"},path:l.selected.path,access:cc(r),valueType:r.valueType};g==="watch"?await fe({...h,schemaVersion:4,watches:[...h.watches,I]}):await fe({...h,schemaVersion:4,controls:[...h.controls,{...I,...r.enumValues?{enumValues:r.enumValues}:{},applyOnStart:!1,applyTiming:"after_agents_ready",restorePolicy:"session_end"}]})}catch(h){te({key:D,kind:g,message:Mt(h,a("playtest.profile.saveFailed","Could not save profile."))})}finally{W.current=!1,E(null)}},j=async()=>{if(!(!e.onResolveSelectionCandidates||w||W.current)){B(!0),O(null),te(null);try{const l=await e.onResolveSelectionCandidates();V(l),M(l.candidates[0]?Fe(l.candidates[0]):""),(!l.selected.path||l.candidates.length===0)&&O(a("playtest.values.selectionEmpty","Select an Instance with a supported Attribute, Value, or property in Studio."))}catch(l){V(null),O(Mt(l,a("playtest.values.selectionFailed","Could not read the Studio selection. Select one Instance in Explorer and try again.")))}finally{B(!1)}}},F=async(l,r)=>{var g;await((g=navigator.clipboard)==null?void 0:g.writeText(r)),U(l)},v=[{id:"selection",label:a("playtest.values.sourceSelection","Studio selection")},{id:"registered",label:a("playtest.values.sourceRegistered","Test Adapter")}];return t.jsx(Ke,{open:e.open,ariaLabel:a("playtest.values.addTitle","Add a test value"),onClose:e.onClose,dismissDisabled:P!==null,children:t.jsxs("div",{className:s.valueManagerShell,children:[t.jsx(ze,{title:a("playtest.values.addTitle","Add a test value"),description:a("playtest.values.addDescription","Choose where the value exists. WEPPY uses the simplest available connection and shows where it came from."),closeLabel:a("common.close","Close"),closeDisabled:P!==null,onRequestClose:e.onClose}),t.jsx("div",{className:s.valueSourceTabs,role:"tablist","aria-label":a("playtest.values.sources","Value source"),children:v.map((l,r)=>t.jsx("button",{type:"button",role:"tab","aria-selected":i===l.id,"aria-controls":`playtest-value-source-${l.id}`,tabIndex:i===l.id?0:-1,onClick:()=>Ce(l.id),onKeyDown:g=>{var T,I;if(g.key!=="ArrowLeft"&&g.key!=="ArrowRight")return;g.preventDefault();const D=g.key==="ArrowRight"?1:-1,h=(r+D+v.length)%v.length,b=v[h];if(b){Ce(b.id);const Y=(T=g.currentTarget.parentElement)==null?void 0:T.querySelectorAll('[role="tab"]');(I=Y==null?void 0:Y[h])==null||I.focus()}},children:l.label},l.id))}),t.jsxs("div",{className:s.valueManagerBody,children:[k&&t.jsxs("label",{className:s.firstProfileName,children:[t.jsx("span",{children:a("playtest.profile.name","Profile name")}),t.jsx("input",{value:((G=e.profile)==null?void 0:G.name)??_,readOnly:!!e.profile,"aria-label":a("playtest.profile.name","Profile name"),onChange:l=>C(l.target.value)}),t.jsx("small",{children:a("playtest.values.firstProfileHint","The first value and this profile are saved together for the selected Place.")})]}),t.jsx("div",{className:s.subscriptionUsage,role:"status",children:a("playtest.values.subscriptionUsage","Runtime subscriptions · Direct {{direct}}/64 · Adapter {{adapter}}/10").replace("{{direct}}",String(ce)).replace("{{adapter}}",String(ne))}),i==="selection"&&t.jsxs("section",{id:"playtest-value-source-selection",role:"tabpanel",className:s.valueSourcePanel,children:[t.jsxs("div",{className:s.sourceIntro,children:[t.jsxs("div",{children:[t.jsx("strong",{children:a("playtest.values.selectionTitle","Use the actual Studio selection")}),t.jsx("p",{children:a("playtest.values.selectionDescription","Select an Instance in Explorer, then read its Attributes, Value, and supported properties. This path does not add test code.")})]}),t.jsx("button",{type:"button",className:s.primaryAction,disabled:!e.onResolveSelectionCandidates||w||P!==null,onClick:()=>void j(),children:w?a("playtest.values.readingSelection","Reading selection…"):a("playtest.values.readSelection","Read current Studio selection")})]}),(f==null?void 0:f.selected.path)&&f.candidates.length>0&&t.jsxs("div",{className:s.propertySelection,"aria-busy":w,children:[t.jsxs("div",{className:s.propertySelectionHeader,children:[t.jsxs("div",{className:s.selectedInstance,children:[t.jsx("span",{children:a("playtest.values.selectedInstance","Instance")}),t.jsx("strong",{children:f.selected.name??"Selected"}),f.selected.className&&t.jsx("span",{children:f.selected.className}),t.jsxs("details",{children:[t.jsx("summary",{children:a("playtest.values.location","Location")}),t.jsx("code",{children:[f.selected.path.root,...f.selected.path.segments].join(".")})]})]}),re&&t.jsx(rc,{candidates:f.candidates,selected:re,disabled:w||P!==null,onSelect:l=>M(Fe(l))})]}),(re?[re]:[]).map(l=>{const r=Lt(f,l),g=yt(l),D=ee&&ee.key===pt(f,l,ee.kind)?ee:null;return t.jsxs("div",{className:s.candidateEntry,children:[t.jsxs("div",{className:s.catalogRow,children:[t.jsxs("div",{children:[t.jsxs("strong",{children:[f.selected.name??"Selected"," · ",g]}),t.jsxs("span",{children:[a("playtest.values.actualNow","Actual now"),": ",st(l.value)]})]}),t.jsx("div",{className:s.candidateActions,children:["watch","control"].map(h=>{const b=ut(Q,f,l,h),T=b&&!ut(e.profile,f,l,h),I=P===pt(f,l,h),Y=h==="watch"?a("playtest.values.addWatch","Add as Watch Value"):a("playtest.values.addControl","Add as Control"),de=h==="watch"?a("playtest.values.addedWatch","Added as Watch Value"):a("playtest.values.addedControl","Added as Control"),je=h==="watch"?a("playtest.values.pendingWatch","Watch Value · save pending"):a("playtest.values.pendingControl","Control · save pending"),Pe=a("playtest.values.adding","Adding…"),Ie=I?Pe:T?je:b?de:Y,Me=h==="watch"?a("playtest.values.addWatchLabel","Add {{label}} as Watch Value"):a("playtest.values.addControlLabel","Add {{label}} as Control");return t.jsxs("button",{type:"button",className:s.candidateAction,"data-state":I?"saving":T?"pending":b?"saved":"idle",disabled:w||!b&&ie,"aria-disabled":b||P!==null||void 0,"aria-label":b||I?`${Ie} · ${r}`:Me.replace("{{label}}",r),onClick:()=>void p(f,l,h),children:[[Y,`✓ ${de}`,je,Pe].map(Se=>t.jsx("span",{className:s.candidateActionSizer,"aria-hidden":"true",children:Se},Se)),t.jsx("span",{className:s.candidateActionLabel,"aria-live":"polite","aria-atomic":"true",children:b&&!T&&!I?`✓ ${Ie}`:Ie})]},h)})})]}),D&&t.jsxs("div",{className:s.candidateError,role:"alert",children:[t.jsx("span",{children:D.message}),t.jsx("button",{type:"button",disabled:P!==null,onClick:()=>void p(f,l,D.kind),children:a("playtest.values.retryAddition","Try again")})]})]},`${l.accessKind}:${g}`)})]})]}),i==="registered"&&t.jsxs("section",{id:"playtest-value-source-registered",role:"tabpanel",className:s.valueSourcePanel,children:[t.jsxs("div",{className:s.registeredIntro,children:[t.jsx("strong",{children:a("playtest.values.registeredTitle","Reuse values your game already exposes for testing.")}),t.jsx("p",{children:a("playtest.values.registeredDescription","These values come from Test Adapter entries checked during the last Studio Play or Run. Adding one saves it to this profile and does not change the running game.")}),xe&&t.jsx("span",{children:a("playtest.values.lastChecked","Last checked: {{time}}").replace("{{time}}",xe)})]}),ve.length>0&&t.jsxs("section",{className:s.adapterSetupList,"aria-label":a("playtest.values.adaptersNeedingSetup","Adapters that need value setup"),children:[t.jsxs("header",{children:[t.jsx("strong",{children:a("playtest.values.adaptersFound","Test Adapters found")}),t.jsx("span",{children:a("playtest.values.adaptersFoundDescription","These adapters are available to tests but do not expose a value you can select yet.")})]}),ve.map(l=>t.jsxs("div",{className:s.adapterSetupRow,children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.name}),t.jsxs("span",{children:[a("playtest.values.adapterSetupRequired","Value setup required")," · ",a("playtest.values.adapterVersion","Version")," ",l.version]}),l.sourcePath&&t.jsx("code",{children:l.sourcePath}),t.jsx("div",{className:s.adapterMethods,children:l.methods.map(r=>t.jsxs("span",{children:[r.name," · ",r.sideEffectClass==="read_only"?a("playtest.values.methodReadOnly","Read only"):r.sideEffectClass==="session_action"?a("playtest.actions.sessionAction","Session action"):a("playtest.values.methodReversible","Reversible fixture")]},r.name))})]}),t.jsx("button",{type:"button","aria-label":a("playtest.values.configureAdapterLabel","Configure values for {{adapter}}").replace("{{adapter}}",l.name),onClick:()=>{le(l.name),ae(!0)},children:a("playtest.values.configureAdapter","Configure values")})]},l.name))]}),e.catalog.entries.length>0&&t.jsxs("label",{className:s.valueSearch,children:[t.jsx("span",{children:a("playtest.values.searchRegistered","Search registered values")}),t.jsx("input",{type:"search","aria-label":a("playtest.values.searchRegistered","Search registered values"),value:c,onChange:l=>{u(l.target.value),m(0)},placeholder:a("playtest.values.searchPlaceholder","Name, group, source, or path")})]}),e.catalog.entries.length>0&&t.jsx("div",{className:s.valueCount,role:"status",children:a("playtest.values.count","{{visible}} of {{total}} values").replace("{{visible}}",String(he.length)).replace("{{total}}",String(e.catalog.entries.length))}),we.length>0?t.jsx("div",{className:s.catalogGroups,children:we.map(l=>{const r=H.has(`${l.adapter}/${l.id}`);return t.jsxs("div",{className:s.catalogRow,children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.label}),t.jsxs("span",{children:[l.group," · ",l.kind==="control"?a("playtest.values.control","Control"):l.kind==="watch"?a("playtest.values.watch","Watch"):a("playtest.actions.action","Action")]}),t.jsx("code",{children:l.sourcePath??l.adapter}),t.jsxs("details",{className:s.catalogDetails,children:[t.jsx("summary",{children:a("playtest.values.registrationDetails","Registration details")}),t.jsxs("dl",{children:[t.jsxs("div",{children:[t.jsx("dt",{children:a("playtest.values.sourceLocation","Source location")}),t.jsx("dd",{children:t.jsx("code",{children:l.sourcePath??`ServerStorage.WeppyTestAdapters.${l.adapter}`})})]}),t.jsxs("div",{children:[t.jsx("dt",{children:a("playtest.values.profileUsage","Current profile")}),t.jsx("dd",{children:r?Q==null?void 0:Q.name:a("playtest.values.notInProfile","Not included")})]}),t.jsxs("div",{children:[t.jsx("dt",{children:a("playtest.values.sourceHash","Source hash")}),t.jsx("dd",{children:a("playtest.values.hashAtPlan","Verified when a removal plan is created")})]})]}),t.jsx("p",{children:a("playtest.values.profileRemovalImpact","Removing from this profile keeps the original adapter code.")}),t.jsx("p",{children:a("playtest.values.sourceRemovalImpact","Removing the original registration changes project test code and can affect other profiles or automated tests. Review the source hash, diff, and known usages first.")}),t.jsx("button",{type:"button","aria-label":a("playtest.values.copyRemovalRequest","Copy original registration removal request"),onClick:()=>void F(`remove:${l.adapter}/${l.id}`,`Review removal of the WEPPY Playtest adapter registration ${l.adapter}/${l.id}.
104
+ `);o.useEffect(()=>{var D;const l=$.current,r=((D=e.profile)==null?void 0:D.id)??null;$.current={open:e.open,profileId:r};const g=l.open&&l.profileId===null&&r!==null&&W.current;!e.open||g||l.open&&l.profileId===r||(d("selection"),x(!e.profile),u(""),m(0),V(null),M(""),E(null),O(null),te(null),ae(!1),le(null))},[e.open,(A=e.profile)==null?void 0:A.id]);const he=o.useMemo(()=>{const l=c.trim().toLocaleLowerCase();return e.catalog.entries.filter(r=>!l||[r.label,r.group,r.adapter,r.sourcePath,r.id].filter(Boolean).join(" ").toLocaleLowerCase().includes(l))},[e.catalog.entries,c]),re=((f==null?void 0:f.candidates)??[]).find(l=>Fe(l)===R)??(f==null?void 0:f.candidates[0]),oe=Math.max(1,Math.ceil(he.length/50)),ye=Math.min(y,oe-1),we=he.slice(ye*50,(ye+1)*50),q=new Set([...(Q==null?void 0:Q.controls)??[],...(Q==null?void 0:Q.watches)??[],...(Q==null?void 0:Q.actions)??[]].map(l=>l.origin?`${l.origin.adapter}/${l.origin.entryId}`:"")),se=[...(Q==null?void 0:Q.controls)??[],...(Q==null?void 0:Q.watches)??[]],ne=se.filter(l=>l.access.kind==="adapter"||l.access.kind==="adapter_read").length,ce=se.length-ne,ie=ce>=64,Ne=ne>=10,ve=((N=e.catalog.adapters)==null?void 0:N.filter(l=>l.entryCount===0))??[],_e=!!(e.catalog.catalogRevision&&e.catalog.verifiedAt&&!Number.isNaN(Date.parse(e.catalog.verifiedAt))),xe=_e&&e.catalog.verifiedAt?new Intl.DateTimeFormat(n,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e.catalog.verifiedAt)):null,Ce=l=>{d(l),u(""),m(0)},be=async()=>{if(Q)return Q;if(!e.onCreateProfile||!_.trim())throw new Error(a("playtest.values.profileNameRequired","Enter a profile name before adding the first value."));return e.onCreateProfile(_.trim())},fe=async l=>{var g;const r={...l,schemaVersion:4,actions:l.actions??[],settings:l.settings??{applyDefaultsOnManualPlayStart:!1,runtimeApplyMode:"manual"},sectionOrder:((g=l.sectionOrder)==null?void 0:g.length)===3?l.sectionOrder:["watches","controls","actions"]};await e.onSave(r)},Re=async(l,r)=>{if(!W.current){W.current=!0,E(`adapter:${l.id}`),O(null);try{const g=await be(),D={kind:"adapter",adapter:l.adapter,entryId:l.id,version:l.adapterVersion},h=b=>{var T;return((T=b.origin)==null?void 0:T.adapter)===l.adapter&&b.origin.entryId===l.id};if(r)await fe({...g,controls:g.controls.filter(b=>!h(b)),watches:g.watches.filter(b=>!h(b)),actions:(g.actions??[]).filter(b=>!h(b))});else if(l.kind==="action"){const b={id:tt(g,dt(l)),label:l.label,target:{role:"server"},executor:{kind:"adapter",adapter:l.adapter,method:l.execute.method},parameters:l.execute.parameters,fixedArguments:l.execute.fixedArguments,origin:D};await fe({...g,schemaVersion:4,actions:[...g.actions??[],b]})}else l.kind==="watch"?await fe({...g,schemaVersion:4,watches:[...g.watches,{id:tt(g,dt(l)),label:l.label,target:{role:"server"},access:{kind:"adapter_read",adapter:l.adapter,...l.read},valueType:l.valueType,origin:D}]}):l.write&&await fe({...g,schemaVersion:4,controls:[...g.controls,{id:tt(g,dt(l)),label:l.label,target:{role:"server"},access:{kind:"adapter",adapter:l.adapter,...l.write},observation:{kind:"adapter_read",adapter:l.adapter,...l.read},valueType:l.valueType,applyOnStart:!1,constraints:l.constraints,enumValues:l.enumValues,applyTiming:"after_agents_ready",restorePolicy:"session_end",origin:D}]})}catch(g){O(g instanceof Error?g.message:String(g))}finally{W.current=!1,E(null)}}},p=async(l,r,g)=>{if(!l.selected.path||w||W.current||ut(Q,l,r,g))return;const D=pt(l,r,g);W.current=!0,E(D),O(null),te(null);try{const h=await be(),b=Lt(l,r),I={id:tt(h,`direct-${rc([l.selected.path.root,...l.selected.path.segments,yt(r)].join("-"))}`),label:b,target:{role:"server"},path:l.selected.path,access:oc(r),valueType:r.valueType};g==="watch"?await fe({...h,schemaVersion:4,watches:[...h.watches,I]}):await fe({...h,schemaVersion:4,controls:[...h.controls,{...I,...r.enumValues?{enumValues:r.enumValues}:{},applyOnStart:!1,applyTiming:"after_agents_ready",restorePolicy:"session_end"}]})}catch(h){te({key:D,kind:g,message:Mt(h,a("playtest.profile.saveFailed","Could not save profile."))})}finally{W.current=!1,E(null)}},j=async()=>{if(!(!e.onResolveSelectionCandidates||w||W.current)){B(!0),O(null),te(null);try{const l=await e.onResolveSelectionCandidates();V(l),M(l.candidates[0]?Fe(l.candidates[0]):""),(!l.selected.path||l.candidates.length===0)&&O(a("playtest.values.selectionEmpty","Select an Instance with a supported Attribute, Value, or property in Studio."))}catch(l){V(null),O(Mt(l,a("playtest.values.selectionFailed","Could not read the Studio selection. Select one Instance in Explorer and try again.")))}finally{B(!1)}}},F=async(l,r)=>{var g;await((g=navigator.clipboard)==null?void 0:g.writeText(r)),U(l)},v=[{id:"selection",label:a("playtest.values.sourceSelection","Studio selection")},{id:"registered",label:a("playtest.values.sourceRegistered","Test Adapter")}];return t.jsx(Ke,{open:e.open,ariaLabel:a("playtest.values.addTitle","Add a test value"),onClose:e.onClose,dismissDisabled:P!==null,children:t.jsxs("div",{className:s.valueManagerShell,children:[t.jsx(ze,{title:a("playtest.values.addTitle","Add a test value"),description:a("playtest.values.addDescription","Choose where the value exists. WEPPY uses the simplest available connection and shows where it came from."),closeLabel:a("common.close","Close"),closeDisabled:P!==null,onRequestClose:e.onClose}),t.jsx("div",{className:s.valueSourceTabs,role:"tablist","aria-label":a("playtest.values.sources","Value source"),children:v.map((l,r)=>t.jsx("button",{type:"button",role:"tab","aria-selected":i===l.id,"aria-controls":`playtest-value-source-${l.id}`,tabIndex:i===l.id?0:-1,onClick:()=>Ce(l.id),onKeyDown:g=>{var T,I;if(g.key!=="ArrowLeft"&&g.key!=="ArrowRight")return;g.preventDefault();const D=g.key==="ArrowRight"?1:-1,h=(r+D+v.length)%v.length,b=v[h];if(b){Ce(b.id);const Y=(T=g.currentTarget.parentElement)==null?void 0:T.querySelectorAll('[role="tab"]');(I=Y==null?void 0:Y[h])==null||I.focus()}},children:l.label},l.id))}),t.jsxs("div",{className:s.valueManagerBody,children:[k&&t.jsxs("label",{className:s.firstProfileName,children:[t.jsx("span",{children:a("playtest.profile.name","Profile name")}),t.jsx("input",{value:((G=e.profile)==null?void 0:G.name)??_,readOnly:!!e.profile,"aria-label":a("playtest.profile.name","Profile name"),onChange:l=>C(l.target.value)}),t.jsx("small",{children:a("playtest.values.firstProfileHint","The first value and this profile are saved together for the selected Place.")})]}),t.jsx("div",{className:s.subscriptionUsage,role:"status",children:a("playtest.values.subscriptionUsage","Runtime subscriptions · Direct {{direct}}/64 · Adapter {{adapter}}/10").replace("{{direct}}",String(ce)).replace("{{adapter}}",String(ne))}),i==="selection"&&t.jsxs("section",{id:"playtest-value-source-selection",role:"tabpanel",className:s.valueSourcePanel,children:[t.jsxs("div",{className:s.sourceIntro,children:[t.jsxs("div",{children:[t.jsx("strong",{children:a("playtest.values.selectionTitle","Use the actual Studio selection")}),t.jsx("p",{children:a("playtest.values.selectionDescription","Select an Instance in Explorer, then read its Attributes, Value, and supported properties. This path does not add test code.")})]}),t.jsx("button",{type:"button",className:s.primaryAction,disabled:!e.onResolveSelectionCandidates||w||P!==null,onClick:()=>void j(),children:w?a("playtest.values.readingSelection","Reading selection…"):a("playtest.values.readSelection","Read current Studio selection")})]}),(f==null?void 0:f.selected.path)&&f.candidates.length>0&&t.jsxs("div",{className:s.propertySelection,"aria-busy":w,children:[t.jsxs("div",{className:s.propertySelectionHeader,children:[t.jsxs("div",{className:s.selectedInstance,children:[t.jsx("span",{children:a("playtest.values.selectedInstance","Instance")}),t.jsx("strong",{children:f.selected.name??"Selected"}),f.selected.className&&t.jsx("span",{children:f.selected.className}),t.jsxs("details",{children:[t.jsx("summary",{children:a("playtest.values.location","Location")}),t.jsx("code",{children:[f.selected.path.root,...f.selected.path.segments].join(".")})]})]}),re&&t.jsx(lc,{candidates:f.candidates,selected:re,disabled:w||P!==null,onSelect:l=>M(Fe(l))})]}),(re?[re]:[]).map(l=>{const r=Lt(f,l),g=yt(l),D=ee&&ee.key===pt(f,l,ee.kind)?ee:null;return t.jsxs("div",{className:s.candidateEntry,children:[t.jsxs("div",{className:s.catalogRow,children:[t.jsxs("div",{children:[t.jsxs("strong",{children:[f.selected.name??"Selected"," · ",g]}),t.jsxs("span",{children:[a("playtest.values.actualNow","Actual now"),": ",st(l.value)]})]}),t.jsx("div",{className:s.candidateActions,children:["watch","control"].map(h=>{const b=ut(Q,f,l,h),T=b&&!ut(e.profile,f,l,h),I=P===pt(f,l,h),Y=h==="watch"?a("playtest.values.addWatch","Add as Watch Value"):a("playtest.values.addControl","Add as Control"),de=h==="watch"?a("playtest.values.addedWatch","Added as Watch Value"):a("playtest.values.addedControl","Added as Control"),je=h==="watch"?a("playtest.values.pendingWatch","Watch Value · save pending"):a("playtest.values.pendingControl","Control · save pending"),Pe=a("playtest.values.adding","Adding…"),Ie=I?Pe:T?je:b?de:Y,Me=h==="watch"?a("playtest.values.addWatchLabel","Add {{label}} as Watch Value"):a("playtest.values.addControlLabel","Add {{label}} as Control");return t.jsxs("button",{type:"button",className:s.candidateAction,"data-state":I?"saving":T?"pending":b?"saved":"idle",disabled:w||!b&&ie,"aria-disabled":b||P!==null||void 0,"aria-label":b||I?`${Ie} · ${r}`:Me.replace("{{label}}",r),onClick:()=>void p(f,l,h),children:[[Y,`✓ ${de}`,je,Pe].map(Se=>t.jsx("span",{className:s.candidateActionSizer,"aria-hidden":"true",children:Se},Se)),t.jsx("span",{className:s.candidateActionLabel,"aria-live":"polite","aria-atomic":"true",children:b&&!T&&!I?`✓ ${Ie}`:Ie})]},h)})})]}),D&&t.jsxs("div",{className:s.candidateError,role:"alert",children:[t.jsx("span",{children:D.message}),t.jsx("button",{type:"button",disabled:P!==null,onClick:()=>void p(f,l,D.kind),children:a("playtest.values.retryAddition","Try again")})]})]},`${l.accessKind}:${g}`)})]})]}),i==="registered"&&t.jsxs("section",{id:"playtest-value-source-registered",role:"tabpanel",className:s.valueSourcePanel,children:[t.jsxs("div",{className:s.registeredIntro,children:[t.jsx("strong",{children:a("playtest.values.registeredTitle","Reuse values your game already exposes for testing.")}),t.jsx("p",{children:a("playtest.values.registeredDescription","These values come from Test Adapter entries checked during the last Studio Play or Run. Adding one saves it to this profile and does not change the running game.")}),xe&&t.jsx("span",{children:a("playtest.values.lastChecked","Last checked: {{time}}").replace("{{time}}",xe)})]}),ve.length>0&&t.jsxs("section",{className:s.adapterSetupList,"aria-label":a("playtest.values.adaptersNeedingSetup","Adapters that need value setup"),children:[t.jsxs("header",{children:[t.jsx("strong",{children:a("playtest.values.adaptersFound","Test Adapters found")}),t.jsx("span",{children:a("playtest.values.adaptersFoundDescription","These adapters are available to tests but do not expose a value you can select yet.")})]}),ve.map(l=>t.jsxs("div",{className:s.adapterSetupRow,children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.name}),t.jsxs("span",{children:[a("playtest.values.adapterSetupRequired","Value setup required")," · ",a("playtest.values.adapterVersion","Version")," ",l.version]}),l.sourcePath&&t.jsx("code",{children:l.sourcePath}),t.jsx("div",{className:s.adapterMethods,children:l.methods.map(r=>t.jsxs("span",{children:[r.name," · ",r.sideEffectClass==="read_only"?a("playtest.values.methodReadOnly","Read only"):r.sideEffectClass==="session_action"?a("playtest.actions.sessionAction","Session action"):a("playtest.values.methodReversible","Reversible fixture")]},r.name))})]}),t.jsx("button",{type:"button","aria-label":a("playtest.values.configureAdapterLabel","Configure values for {{adapter}}").replace("{{adapter}}",l.name),onClick:()=>{le(l.name),ae(!0)},children:a("playtest.values.configureAdapter","Configure values")})]},l.name))]}),e.catalog.entries.length>0&&t.jsxs("label",{className:s.valueSearch,children:[t.jsx("span",{children:a("playtest.values.searchRegistered","Search registered values")}),t.jsx("input",{type:"search","aria-label":a("playtest.values.searchRegistered","Search registered values"),value:c,onChange:l=>{u(l.target.value),m(0)},placeholder:a("playtest.values.searchPlaceholder","Name, group, source, or path")})]}),e.catalog.entries.length>0&&t.jsx("div",{className:s.valueCount,role:"status",children:a("playtest.values.count","{{visible}} of {{total}} values").replace("{{visible}}",String(he.length)).replace("{{total}}",String(e.catalog.entries.length))}),we.length>0?t.jsx("div",{className:s.catalogGroups,children:we.map(l=>{const r=q.has(`${l.adapter}/${l.id}`);return t.jsxs("div",{className:s.catalogRow,children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.label}),t.jsxs("span",{children:[l.group," · ",l.kind==="control"?a("playtest.values.control","Control"):l.kind==="watch"?a("playtest.values.watch","Watch"):a("playtest.actions.action","Action")]}),t.jsx("code",{children:l.sourcePath??l.adapter}),t.jsxs("details",{className:s.catalogDetails,children:[t.jsx("summary",{children:a("playtest.values.registrationDetails","Registration details")}),t.jsxs("dl",{children:[t.jsxs("div",{children:[t.jsx("dt",{children:a("playtest.values.sourceLocation","Source location")}),t.jsx("dd",{children:t.jsx("code",{children:l.sourcePath??`ServerStorage.WeppyTestAdapters.${l.adapter}`})})]}),t.jsxs("div",{children:[t.jsx("dt",{children:a("playtest.values.profileUsage","Current profile")}),t.jsx("dd",{children:r?Q==null?void 0:Q.name:a("playtest.values.notInProfile","Not included")})]}),t.jsxs("div",{children:[t.jsx("dt",{children:a("playtest.values.sourceHash","Source hash")}),t.jsx("dd",{children:a("playtest.values.hashAtPlan","Verified when a removal plan is created")})]})]}),t.jsx("p",{children:a("playtest.values.profileRemovalImpact","Removing from this profile keeps the original adapter code.")}),t.jsx("p",{children:a("playtest.values.sourceRemovalImpact","Removing the original registration changes project test code and can affect other profiles or automated tests. Review the source hash, diff, and known usages first.")}),t.jsx("button",{type:"button","aria-label":a("playtest.values.copyRemovalRequest","Copy original registration removal request"),onClick:()=>void F(`remove:${l.adapter}/${l.id}`,`Review removal of the WEPPY Playtest adapter registration ${l.adapter}/${l.id}.
110
105
 
111
106
  - Call manage_studio.playtest_adapter_plan with adapterOperation=remove_entry, adapterId=${l.adapter}, and adapterRegistrationId=${l.id}.
112
107
  - Show the current source SHA-256, unified diff, profile and scenario usages, dynamic-reference coverage, and production exclusion strategy.
113
108
  - Do not change source until I review the plan.
114
109
  - Apply only the returned unexpired plan token and expected source hash.
115
- - After apply, start a new Play and confirm the catalog no longer includes this entry.`),children:z===`remove:${l.adapter}/${l.id}`?a("playtest.values.copied","Copied"):a("playtest.values.copyRemovalRequest","Copy original registration removal request")})]})]}),t.jsx("button",{type:"button",disabled:P!==null||!r&&Ne,"aria-label":r?`${a("playtest.values.remove","Remove")} ${l.label} ${a("playtest.values.fromProfile","from profile")}`:`${a("playtest.values.add","Add")} ${l.label}`,onClick:()=>void Re(l,r),children:r?a("playtest.values.removeFromProfile","Remove from profile"):P===`adapter:${l.id}`?a("playtest.profile.saving","Saving…"):a("playtest.values.add","Add")})]},`${l.adapter}/${l.id}`)})}):e.catalog.entries.length===0&&ve.length===0?t.jsxs("div",{className:s.registeredEmpty,children:[t.jsx("strong",{children:_e?a("playtest.values.registeredEmptyChecked","The last Play or Run found no registered values."):a("playtest.values.registeredNotChecked","Test Adapters have not been checked yet.")}),t.jsx("p",{children:_e?a("playtest.values.registeredEmptyDescription","Use Studio selection for values visible in Explorer. Connect a game internal value when the value only exists in code."):a("playtest.values.registeredNotCheckedDescription","Connect a game internal value, then start Play or Run in Studio so WEPPY can check it.")}),t.jsxs("ol",{className:s.registeredSteps,"aria-label":a("playtest.values.registeredSteps","How registered values appear"),children:[t.jsx("li",{children:a("playtest.values.registeredStepConnect","Connect the value")}),t.jsx("li",{children:a("playtest.values.registeredStepPlay","Start Play or Run in Studio")}),t.jsx("li",{children:a("playtest.values.registeredStepCheck","Return here and check the list")}),t.jsx("li",{children:a("playtest.values.registeredStepAdd","Add the value to this profile")})]}),t.jsx("div",{className:s.registeredEmptyActions,children:t.jsx("button",{type:"button",onClick:()=>Ce("selection"),children:a("playtest.values.useStudioSelection","Use Studio selection")})})]}):e.catalog.entries.length>0?t.jsxs("div",{className:s.registeredEmpty,children:[t.jsx("strong",{children:a("playtest.values.registeredNoResults","No registered values match your search.")}),t.jsx("button",{type:"button",onClick:()=>{u(""),m(0)},children:a("playtest.values.clearSearch","Clear search")})]}):null,oe>1&&t.jsxs("div",{className:s.valuePagination,children:[t.jsx("button",{type:"button",disabled:ye===0,onClick:()=>m(l=>l-1),children:a("playtest.values.previous","Previous")}),t.jsxs("span",{children:[ye+1," / ",oe]}),t.jsx("button",{type:"button",disabled:ye+1>=oe,onClick:()=>m(l=>l+1),children:a("playtest.values.next","Next")})]}),e.catalog.diagnostics.map(l=>t.jsxs("div",{className:s.bindingError,role:"alert",children:[l.adapter,l.entryId?`/${l.entryId}`:"",": ",l.message]},`${l.adapter}/${l.entryId??l.code}`)),t.jsxs("details",{className:s.connectionGuide,open:L,onToggle:l=>ae(l.currentTarget.open),children:[t.jsx("summary",{children:a("playtest.values.connectValues","Connect a value")}),t.jsxs("div",{className:s.registrationGuide,children:[t.jsx("strong",{children:a("playtest.values.registerTitle","Register values in a Test Adapter")}),t.jsx("p",{children:a("playtest.values.registerDescription","Use a Test Adapter only for game state that cannot be reached through an Instance Attribute, Value, or supported property.")}),K&&t.jsx("p",{className:s.adapterSetupContext,children:a("playtest.values.configuringAdapter","Configuring {{adapter}} using its detected methods.").replace("{{adapter}}",K.name)}),t.jsx("code",{children:a("playtest.values.adapterPath","ServerStorage.WeppyTestAdapters")}),t.jsx("p",{children:a("playtest.values.registerSafety")}),t.jsx("p",{children:a("playtest.values.deploymentHint")}),t.jsxs("details",{className:s.registrationExample,children:[t.jsx("summary",{children:a("playtest.values.showExample","Show Luau registration example")}),t.jsx("pre",{children:Tt})]}),t.jsxs("details",{className:s.registrationExample,children:[t.jsx("summary",{children:a("playtest.values.showAiExample","Show AI request example")}),t.jsx("pre",{children:X})]}),t.jsxs("div",{className:s.registrationActions,children:[t.jsx("button",{type:"button",onClick:()=>void F("example",Tt),children:z==="example"?a("playtest.values.copied","Copied"):a("playtest.values.copyExample","Copy Luau example")}),t.jsx("button",{type:"button",onClick:()=>void F("ai",X),children:z==="ai"?a("playtest.values.copied","Copied"):a("playtest.values.copyAi","Copy AI request")})]}),t.jsxs("ol",{className:s.registeredSteps,"aria-label":a("playtest.values.afterRegistration","After connecting the value"),children:[t.jsx("li",{children:a("playtest.values.afterRegistrationPlay","Start a new Play or Run so WEPPY can check the connection.")}),t.jsx("li",{children:a("playtest.values.afterRegistrationAdd","Stop, return to Test Adapter, and add it to the profile.")}),t.jsx("li",{children:a("playtest.values.afterRegistrationObserve","Start Play or Run again to observe the value.")})]})]})]})]}),q&&t.jsx("div",{className:s.bindingError,role:"alert",children:q})]}),t.jsx("div",{className:s.valueManagerFooter,children:t.jsx("button",{type:"button",className:s.primaryAction,disabled:P!==null||se.length===0,onClick:e.onClose,children:a("playtest.values.viewAdded","View added values")})})]})})}const uc=`{
110
+ - After apply, start a new Play and confirm the catalog no longer includes this entry.`),children:z===`remove:${l.adapter}/${l.id}`?a("playtest.values.copied","Copied"):a("playtest.values.copyRemovalRequest","Copy original registration removal request")})]})]}),t.jsx("button",{type:"button",disabled:P!==null||!r&&Ne,"aria-label":r?`${a("playtest.values.remove","Remove")} ${l.label} ${a("playtest.values.fromProfile","from profile")}`:`${a("playtest.values.add","Add")} ${l.label}`,onClick:()=>void Re(l,r),children:r?a("playtest.values.removeFromProfile","Remove from profile"):P===`adapter:${l.id}`?a("playtest.profile.saving","Saving…"):a("playtest.values.add","Add")})]},`${l.adapter}/${l.id}`)})}):e.catalog.entries.length===0&&ve.length===0?t.jsxs("div",{className:s.registeredEmpty,children:[t.jsx("strong",{children:_e?a("playtest.values.registeredEmptyChecked","The last Play or Run found no registered values."):a("playtest.values.registeredNotChecked","Test Adapters have not been checked yet.")}),t.jsx("p",{children:_e?a("playtest.values.registeredEmptyDescription","Use Studio selection for values visible in Explorer. Connect a game internal value when the value only exists in code."):a("playtest.values.registeredNotCheckedDescription","Connect a game internal value, then start Play or Run in Studio so WEPPY can check it.")}),t.jsxs("ol",{className:s.registeredSteps,"aria-label":a("playtest.values.registeredSteps","How registered values appear"),children:[t.jsx("li",{children:a("playtest.values.registeredStepConnect","Connect the value")}),t.jsx("li",{children:a("playtest.values.registeredStepPlay","Start Play or Run in Studio")}),t.jsx("li",{children:a("playtest.values.registeredStepCheck","Return here and check the list")}),t.jsx("li",{children:a("playtest.values.registeredStepAdd","Add the value to this profile")})]}),t.jsx("div",{className:s.registeredEmptyActions,children:t.jsx("button",{type:"button",onClick:()=>Ce("selection"),children:a("playtest.values.useStudioSelection","Use Studio selection")})})]}):e.catalog.entries.length>0?t.jsxs("div",{className:s.registeredEmpty,children:[t.jsx("strong",{children:a("playtest.values.registeredNoResults","No registered values match your search.")}),t.jsx("button",{type:"button",onClick:()=>{u(""),m(0)},children:a("playtest.values.clearSearch","Clear search")})]}):null,oe>1&&t.jsxs("div",{className:s.valuePagination,children:[t.jsx("button",{type:"button",disabled:ye===0,onClick:()=>m(l=>l-1),children:a("playtest.values.previous","Previous")}),t.jsxs("span",{children:[ye+1," / ",oe]}),t.jsx("button",{type:"button",disabled:ye+1>=oe,onClick:()=>m(l=>l+1),children:a("playtest.values.next","Next")})]}),e.catalog.diagnostics.map(l=>t.jsxs("div",{className:s.bindingError,role:"alert",children:[l.adapter,l.entryId?`/${l.entryId}`:"",": ",l.message]},`${l.adapter}/${l.entryId??l.code}`)),t.jsxs("details",{className:s.connectionGuide,open:L,onToggle:l=>ae(l.currentTarget.open),children:[t.jsx("summary",{children:a("playtest.values.connectValues","Connect a value")}),t.jsxs("div",{className:s.registrationGuide,children:[t.jsx("strong",{children:a("playtest.values.registerTitle","Register values in a Test Adapter")}),t.jsx("p",{children:a("playtest.values.registerDescription","Use a Test Adapter only for game state that cannot be reached through an Instance Attribute, Value, or supported property.")}),K&&t.jsx("p",{className:s.adapterSetupContext,children:a("playtest.values.configuringAdapter","Configuring {{adapter}} using its detected methods.").replace("{{adapter}}",K.name)}),t.jsx("code",{children:a("playtest.values.adapterPath","ServerStorage.WeppyTestAdapters")}),t.jsx("p",{children:a("playtest.values.registerSafety")}),t.jsx("p",{children:a("playtest.values.deploymentHint")}),t.jsxs("details",{className:s.registrationExample,children:[t.jsx("summary",{children:a("playtest.values.showExample","Show Luau registration example")}),t.jsx("pre",{children:Tt})]}),t.jsxs("details",{className:s.registrationExample,children:[t.jsx("summary",{children:a("playtest.values.showAiExample","Show AI request example")}),t.jsx("pre",{children:X})]}),t.jsxs("div",{className:s.registrationActions,children:[t.jsx("button",{type:"button",onClick:()=>void F("example",Tt),children:z==="example"?a("playtest.values.copied","Copied"):a("playtest.values.copyExample","Copy Luau example")}),t.jsx("button",{type:"button",onClick:()=>void F("ai",X),children:z==="ai"?a("playtest.values.copied","Copied"):a("playtest.values.copyAi","Copy AI request")})]}),t.jsxs("ol",{className:s.registeredSteps,"aria-label":a("playtest.values.afterRegistration","After connecting the value"),children:[t.jsx("li",{children:a("playtest.values.afterRegistrationPlay","Start a new Play or Run so WEPPY can check the connection.")}),t.jsx("li",{children:a("playtest.values.afterRegistrationAdd","Stop, return to Test Adapter, and add it to the profile.")}),t.jsx("li",{children:a("playtest.values.afterRegistrationObserve","Start Play or Run again to observe the value.")})]})]})]})]}),H&&t.jsx("div",{className:s.bindingError,role:"alert",children:H})]}),t.jsx("div",{className:s.valueManagerFooter,children:t.jsx("button",{type:"button",className:s.primaryAction,disabled:P!==null||se.length===0,onClick:e.onClose,children:a("playtest.values.viewAdded","View added values")})})]})})}const dc=`{
116
111
  "name": "Production",
117
112
  "globIgnorePaths": ["src/ServerStorage/WeppyTestAdapters/**"],
118
113
  "tree": {
119
114
  "$className": "DataModel",
120
115
  "ServerStorage": { "$path": "src/ServerStorage" }
121
116
  }
122
- }`;function pc(e){const{t:a}=ue();return t.jsxs("section",{className:s.deploymentGuide,"aria-label":a("playtest.guide.title"),children:[t.jsxs("header",{className:s.deploymentLifecycle,children:[e.showHeading!==!1&&t.jsx("h2",{children:a("playtest.guide.title")}),t.jsx("p",{children:a("playtest.guide.runtime")}),t.jsx("p",{children:a("playtest.guide.local")}),t.jsx("p",{children:a("playtest.guide.methodIntro")}),t.jsx("p",{children:a("playtest.guide.actionEffects")})]}),e.hasManagedAdapterWithoutStudioGuard&&t.jsxs("section",{className:s.deploymentNotice,children:[t.jsx("h3",{children:a("playtest.guide.studioGuardNoticeTitle")}),t.jsx("p",{children:a("playtest.guide.studioGuardNotice")})]}),t.jsxs("section",{className:s.deploymentChecklist,"aria-labelledby":"playtest-publish-checklist-title",children:[t.jsx("h3",{id:"playtest-publish-checklist-title",children:a("playtest.guide.checklistTitle")}),t.jsxs("ul",{children:[t.jsx("li",{children:a("playtest.guide.checklistTarget")}),t.jsx("li",{children:a("playtest.guide.checklistBehavior")})]})]}),t.jsxs("div",{className:s.deploymentScope,children:[t.jsxs("section",{className:s.deploymentLifecycle,children:[t.jsx("h3",{children:a("playtest.guide.excludeTitle")}),t.jsx("p",{children:a("playtest.guide.exclude")})]}),t.jsxs("section",{className:s.deploymentLifecycle,children:[t.jsx("h3",{children:a("playtest.guide.conditionalDataTitle")}),t.jsx("p",{children:a("playtest.guide.checklistData")})]})]}),t.jsxs("section",{className:s.deploymentLifecycle,children:[t.jsx("h3",{children:a("playtest.guide.afterPublishTitle")}),t.jsx("p",{children:a("playtest.guide.final")})]}),t.jsxs("details",{className:s.deploymentDetails,children:[t.jsx("summary",{children:a("playtest.guide.studioTitle")}),t.jsx("p",{children:a("playtest.guide.include")}),t.jsx("p",{children:a("playtest.guide.studio")})]}),t.jsxs("details",{className:s.deploymentDetails,children:[t.jsx("summary",{children:a("playtest.guide.rojoTitle")}),t.jsx("p",{children:a("playtest.guide.rojo")}),t.jsx("pre",{children:uc}),t.jsx("p",{children:a("playtest.guide.rojoExample")})]}),t.jsxs("details",{className:s.deploymentDetails,children:[t.jsx("summary",{children:a("playtest.guide.dataTitle")}),t.jsx("p",{children:a("playtest.guide.data")})]}),t.jsx("p",{className:s.deploymentDescription,children:a("playtest.guide.description")})]})}function fc(e){return e.studioState==="running"?"Running":e.studioState==="paused"?"Paused":"Edit"}function mc(e,a){const n=((e==null?void 0:e.pluginClients)??[]).filter(d=>d.connectionState==="connected");let i;if(a!==null){const d=n.filter(c=>c.placeId===a);i=d.length===1?d[0]:void 0}else i=Jt(n,(e==null?void 0:e.studioRoutingMode)??"recentPriority",(e==null?void 0:e.pinnedTargetClientId)??null)[0];return i?{state:fc(i),targetClientId:i.clientId,...i.studioStateUpdatedAt!==void 0?{updatedAt:i.studioStateUpdatedAt}:{},...i.playtestMode!==void 0?{mode:i.playtestMode}:{}}:{state:"Edit",targetClientId:null}}function Ic(){var be,fe,Re;const{t:e}=ue(),a=Yt(),n=Qt(),{trackEvent:i}=Xt(),{tier:d,loading:c}=Zt(),{level:u,status:y}=ea(),m=!c&&d==="basic",[_,C]=o.useState(null),k=La({enabled:!m,placeId:_}),x=mc(y,_),f=Eo({enabled:!c&&u==="studioConnected",canMutate:!m,placeId:_,studioSnapshot:x}),[V,R]=o.useState(Ro),[M,w]=o.useState(!1),[B,P]=o.useState(!1),[E,W]=o.useState(!1),$=o.useRef(null),[ee,te]=o.useState(!1),{show:q}=ta(),[O,z]=o.useState(null),[U,L]=o.useState(!1),[ae,J]=o.useState(!1);o.useEffect(()=>{const p=new URLSearchParams(a.search);if(p.get("add")!=="value")return;R("live"),P(!0),p.delete("add");const j=p.toString();n(`${a.pathname}${j?`?${j}`:""}${a.hash}`,{replace:!0})},[a.hash,a.pathname,a.search,n]);const le=u==="studioConnected",Q=le?f.profile?f.studioState==="Edit"?e("playtest.values.playRequired","Start Play or Run in Studio to change test values."):m?e("playtest.controls.proRequired","Real-time value editing and Reset all are available with Pro."):e("playtest.controls.connectingDescription","Preparing runtime controls for the selected profile…"):e("playtest.controls.profileRequired","Select or create a test profile to change values."):e("playtest.controls.studioRequired","Connect Roblox Studio and WEPPY Plugin to change test values."),K=le?f.studioState:"Disconnected",Z=o.useRef(null),{history:X,historyLoadState:he,historyError:re,selectedReport:oe,loading:ye,detailLoading:we,detailError:H}=k,se=m?Ma(e):null,ne=((be=se==null?void 0:se.history[0])==null?void 0:be.recordId)??null,ce=(se==null?void 0:se.history)??X,ie=se&&O===ne?se.report:oe,Ne=m?!1:ye,ve=ce.find(p=>p.recordId===O),_e=(p,j)=>{Z.current=j,z(p),!m&&k.loadReport(p)},xe=o.useCallback(()=>{z(null),k.clearSelectedReport()},[k.clearSelectedReport]),Ce=async()=>{J(!0);try{await k.clearHistory(),q(e("toast.clearSuccess","Cleared successfully"),"success"),L(!1),z(null)}catch{q(e("toast.clearFailed","Failed to clear data"),"error")}finally{J(!1)}};return t.jsxs("div",{className:s.page,children:[t.jsx(na,{title:e("page.playtest.title","Playtest"),description:e("page.playtest.description","Review automated playtest runs, saved reports, and result history."),helpTopicId:"playtest",helpState:{tier:d},actions:t.jsx(ia,{ref:$,type:"button",variant:"secondary",size:"sm",onClick:()=>W(!0),children:e("playtest.guide.open","Before publishing")})}),!c&&t.jsx(oa,{surface:"playtest",selectable:!0,selectedPlaceId:_,onSelectedPlaceIdChange:p=>{C(p),z(null),k.clearSelectedReport()}}),!c&&t.jsxs(t.Fragment,{children:[t.jsx(Do,{value:V,onChange:p=>{R(p),Po(p)}}),t.jsx(Io,{lease:f.lease,profileName:(fe=f.profile)==null?void 0:fe.name,studioState:K,studioMode:x.mode}),m&&t.jsx(sa,{title:e("playtest.upgrade.title","Real-time Playtest controls are available with Pro"),description:e("playtest.upgrade.description","Basic includes test profiles and live runtime observation. Upgrade when you need to change values during Play."),benefits:[e("playtest.upgrade.benefit1","Change test values while Studio Play is running"),e("playtest.upgrade.benefit2","Reset every override to its original value"),e("playtest.upgrade.benefit3","Review actual saved automated test results instead of sample data")],upgradeLabel:e("tier.upgrade","View Pro"),upgradeHref:aa.playtest}),f.error&&t.jsx("div",{className:s.inlineError,role:"alert",children:f.error}),V==="live"&&t.jsx(ac,{live:f,inactiveReason:Q,onManageValues:()=>P(!0),onNewProfile:()=>{te(!1),w(!0)},onEditProfile:()=>{te(!0),w(!0)},directAddDisabledReason:le?void 0:e("playtest.controls.studioRequired","Connect Roblox Studio and WEPPY Plugin to change test values.")})]}),V==="results"&&t.jsxs("div",{className:s.card,role:"tabpanel","aria-label":e("playtest.view.testResults","Automated Test Results"),children:[t.jsxs("div",{className:s.cardHeader,children:[t.jsx(la,{label:e("playtest.history.title","Test History"),tooltip:e("playtest.history.title.tooltip","Recorded automated playtest runs for this project.")}),m?t.jsx(it,{text:e("playtest.sample.clearDisabled","Available with Pro for live playtest history."),children:t.jsx("span",{children:t.jsx("button",{className:s.clearButton,disabled:!0,children:e("common.clear","Clear")})})}):t.jsx("button",{className:s.clearButton,onClick:()=>{i("dashboard_click_event",{click_target:"playtest_clear_history",page:"playtest"}),L(!0)},children:e("common.clear","Clear")})]}),(m||!Ne&&he==="ready"&&ce.length===0)&&t.jsx(qt,{kind:"no-results",isBasic:m}),!m&&he==="error"&&ce.length===0&&t.jsxs("div",{className:s.inlineError,role:"alert",children:[t.jsx("span",{children:re??e("playtest.emptyResults.loadFailed","Could not load test results.")}),t.jsx("button",{type:"button",className:s.secondaryAction,onClick:()=>void k.retryHistory(),children:e("common.retry","Try again")})]}),Ne?t.jsx("div",{className:s.emptyState,children:e("common.loading","Loading...")}):ce.length===0?null:t.jsx(go,{entries:ce,onSelect:_e,selectedRecordId:O??void 0})]}),t.jsx(Ke,{open:E,ariaLabel:e("playtest.guide.title","Publishing your game after playtesting"),onClose:()=>W(!1),returnFocusTo:$.current,children:t.jsxs("div",{className:s.detailShell,children:[t.jsx(ze,{title:e("playtest.guide.title","Publishing your game after playtesting"),description:e("playtest.guide.dialogDescription","Review what remains after testing and what to check before publishing."),closeLabel:e("common.close","Close"),onRequestClose:()=>W(!1)}),t.jsx("div",{className:s.detailBody,children:t.jsx(pc,{showHeading:!1,hasManagedAdapterWithoutStudioGuard:((Re=f.releaseGuidance)==null?void 0:Re.hasManagedAdapterWithoutStudioGuard)===!0})})]})}),t.jsx(Ke,{open:O!==null,ariaLabel:e("playtest.detail.dialogLabel","Playtest report detail"),onClose:xe,returnFocusTo:Z.current,testId:"playtest-detail-popup-layer",children:t.jsxs("div",{className:s.detailShell,children:[t.jsx(ze,{title:e("playtest.report.title","Selected Report"),description:ve==null?void 0:ve.testName,closeLabel:e("common.close","Close"),onRequestClose:xe}),t.jsx("div",{className:s.detailBody,children:we?t.jsx("div",{className:s.detailState,role:"status",children:e("playtest.detail.loading","Loading report...")}):H?t.jsxs("div",{className:s.detailState,role:"alert",children:[t.jsx("div",{className:s.detailErrorTitle,children:e("playtest.detail.errorTitle","Report unavailable")}),t.jsx("div",{className:s.detailErrorMessage,children:H}),t.jsx("button",{type:"button",className:s.detailRetryButton,onClick:()=>void k.retryReport(),children:e("common.retry","Retry")})]}):ie?t.jsx(No,{report:ie}):t.jsx("div",{className:s.detailState,role:"status",children:e("playtest.detail.loading","Loading report...")})})]})}),!c&&t.jsxs(t.Fragment,{children:[!m&&t.jsx(ft,{open:U,title:e("playtest.clear.title","Clear test history?"),message:e("playtest.clear.message","This permanently removes the stored playtest reports for the current place."),cancelLabel:e("common.cancel","Cancel"),confirmLabel:e("common.clear","Clear"),loading:ae,onCancel:()=>!ae&&L(!1),onConfirm:Ce}),t.jsx(lc,{open:M,onClose:()=>w(!1),profile:ee?f.profile:null,onCreate:f.createProfile,onSave:f.saveProfile,onDelete:async(p,j)=>{const F=await f.deleteProfile(p,j);q(F.refreshFailed?e("playtest.profile.deleteRefreshFailed","Profile deleted. Reload the profile list to confirm the latest state."):e("playtest.profile.deleteSuccess","Profile deleted."),F.refreshFailed?"warning":"success")},onResolveSelection:f.resolveSelection,onResolveSelectionCandidates:f.resolveSelectionCandidates}),t.jsx(dc,{open:B,profile:f.profile,catalog:f.catalog,activeLease:!!f.lease,onClose:()=>P(!1),onSave:f.saveProfile,onCreateProfile:f.createProfile,onResolveSelectionCandidates:f.resolveSelectionCandidates})]})]})}export{Ic as Component};
117
+ }`;function uc(e){const{t:a}=ue();return t.jsxs("section",{className:s.deploymentGuide,"aria-label":a("playtest.guide.title"),children:[t.jsxs("header",{className:s.deploymentLifecycle,children:[e.showHeading!==!1&&t.jsx("h2",{children:a("playtest.guide.title")}),t.jsx("p",{children:a("playtest.guide.runtime")}),t.jsx("p",{children:a("playtest.guide.local")}),t.jsx("p",{children:a("playtest.guide.methodIntro")}),t.jsx("p",{children:a("playtest.guide.actionEffects")})]}),e.hasManagedAdapterWithoutStudioGuard&&t.jsxs("section",{className:s.deploymentNotice,children:[t.jsx("h3",{children:a("playtest.guide.studioGuardNoticeTitle")}),t.jsx("p",{children:a("playtest.guide.studioGuardNotice")})]}),t.jsxs("section",{className:s.deploymentChecklist,"aria-labelledby":"playtest-publish-checklist-title",children:[t.jsx("h3",{id:"playtest-publish-checklist-title",children:a("playtest.guide.checklistTitle")}),t.jsxs("ul",{children:[t.jsx("li",{children:a("playtest.guide.checklistTarget")}),t.jsx("li",{children:a("playtest.guide.checklistBehavior")})]})]}),t.jsxs("div",{className:s.deploymentScope,children:[t.jsxs("section",{className:s.deploymentLifecycle,children:[t.jsx("h3",{children:a("playtest.guide.excludeTitle")}),t.jsx("p",{children:a("playtest.guide.exclude")})]}),t.jsxs("section",{className:s.deploymentLifecycle,children:[t.jsx("h3",{children:a("playtest.guide.conditionalDataTitle")}),t.jsx("p",{children:a("playtest.guide.checklistData")})]})]}),t.jsxs("section",{className:s.deploymentLifecycle,children:[t.jsx("h3",{children:a("playtest.guide.afterPublishTitle")}),t.jsx("p",{children:a("playtest.guide.final")})]}),t.jsxs("details",{className:s.deploymentDetails,children:[t.jsx("summary",{children:a("playtest.guide.studioTitle")}),t.jsx("p",{children:a("playtest.guide.include")}),t.jsx("p",{children:a("playtest.guide.studio")})]}),t.jsxs("details",{className:s.deploymentDetails,children:[t.jsx("summary",{children:a("playtest.guide.rojoTitle")}),t.jsx("p",{children:a("playtest.guide.rojo")}),t.jsx("pre",{children:dc}),t.jsx("p",{children:a("playtest.guide.rojoExample")})]}),t.jsxs("details",{className:s.deploymentDetails,children:[t.jsx("summary",{children:a("playtest.guide.dataTitle")}),t.jsx("p",{children:a("playtest.guide.data")})]}),t.jsx("p",{className:s.deploymentDescription,children:a("playtest.guide.description")})]})}function pc(e){return e.studioState==="running"?"Running":e.studioState==="paused"?"Paused":"Edit"}function fc(e,a){const n=((e==null?void 0:e.pluginClients)??[]).filter(d=>d.connectionState==="connected");let i;if(a!==null){const d=n.filter(c=>c.placeId===a);i=d.length===1?d[0]:void 0}else i=Yt(n,(e==null?void 0:e.studioRoutingMode)??"recentPriority",(e==null?void 0:e.pinnedTargetClientId)??null)[0];return i?{state:pc(i),targetClientId:i.clientId,...i.studioStateUpdatedAt!==void 0?{updatedAt:i.studioStateUpdatedAt}:{},...i.playtestMode!==void 0?{mode:i.playtestMode}:{}}:{state:"Edit",targetClientId:null}}function Dc(){var be,fe,Re;const{t:e}=ue(),a=Qt(),n=Xt(),{trackEvent:i}=Zt(),{tier:d,loading:c}=ea(),{level:u,status:y}=ta(),m=!c&&d==="basic",[_,C]=o.useState(null),k=Ta({enabled:!m,placeId:_}),x=fc(y,_),f=Ao({enabled:!c&&u==="studioConnected",canMutate:!m,placeId:_,studioSnapshot:x}),[V,R]=o.useState(Co),[M,w]=o.useState(!1),[B,P]=o.useState(!1),[E,W]=o.useState(!1),$=o.useRef(null),[ee,te]=o.useState(!1),{show:H}=aa(),[O,z]=o.useState(null),[U,L]=o.useState(!1),[ae,J]=o.useState(!1);o.useEffect(()=>{const p=new URLSearchParams(a.search);if(p.get("add")!=="value")return;R("live"),P(!0),p.delete("add");const j=p.toString();n(`${a.pathname}${j?`?${j}`:""}${a.hash}`,{replace:!0})},[a.hash,a.pathname,a.search,n]);const le=u==="studioConnected",Q=le?f.profile?f.studioState==="Edit"?e("playtest.values.playRequired","Start Play or Run in Studio to change test values."):m?e("playtest.controls.proRequired","Real-time value editing and Reset all are available with Pro."):e("playtest.controls.connectingDescription","Preparing runtime controls for the selected profile…"):e("playtest.controls.profileRequired","Select or create a test profile to change values."):e("playtest.controls.studioRequired","Connect Roblox Studio and WEPPY Plugin to change test values."),K=le?f.studioState:"Disconnected",Z=o.useRef(null),{history:X,historyLoadState:he,historyError:re,selectedReport:oe,loading:ye,detailLoading:we,detailError:q}=k,se=m?La(e):null,ne=((be=se==null?void 0:se.history[0])==null?void 0:be.recordId)??null,ce=(se==null?void 0:se.history)??X,ie=se&&O===ne?se.report:oe,Ne=m?!1:ye,ve=ce.find(p=>p.recordId===O),_e=(p,j)=>{Z.current=j,z(p),!m&&k.loadReport(p)},xe=o.useCallback(()=>{z(null),k.clearSelectedReport()},[k.clearSelectedReport]),Ce=async()=>{J(!0);try{await k.clearHistory(),H(e("toast.clearSuccess","Cleared successfully"),"success"),L(!1),z(null)}catch{H(e("toast.clearFailed","Failed to clear data"),"error")}finally{J(!1)}};return t.jsxs("div",{className:s.page,children:[t.jsx(ia,{title:e("page.playtest.title","Playtest"),description:e("page.playtest.description","Review automated playtest runs, saved reports, and result history."),helpTopicId:"playtest",helpState:{tier:d},actions:t.jsx(la,{ref:$,type:"button",variant:"secondary",size:"sm",onClick:()=>W(!0),children:e("playtest.guide.open","Before publishing")})}),!c&&t.jsx(ca,{surface:"playtest",selectable:!0,selectedPlaceId:_,onSelectedPlaceIdChange:p=>{C(p),z(null),k.clearSelectedReport()}}),!c&&t.jsxs(t.Fragment,{children:[t.jsx(Eo,{value:V,onChange:p=>{R(p),Ro(p)}}),t.jsx(Do,{lease:f.lease,profileName:(fe=f.profile)==null?void 0:fe.name,studioState:K,studioMode:x.mode}),m&&t.jsx(na,{title:e("playtest.upgrade.title","Real-time Playtest controls are available with Pro"),description:e("playtest.upgrade.description","Basic includes test profiles and live runtime observation. Upgrade when you need to change values during Play."),benefits:[e("playtest.upgrade.benefit1","Change test values while Studio Play is running"),e("playtest.upgrade.benefit2","Reset every override to its original value"),e("playtest.upgrade.benefit3","Review actual saved automated test results instead of sample data")],upgradeLabel:e("tier.upgrade","View Pro"),upgradeHref:sa.playtest}),f.error&&t.jsx("div",{className:s.inlineError,role:"alert",children:f.error}),V==="live"&&t.jsx(tc,{live:f,inactiveReason:Q,onManageValues:()=>P(!0),onNewProfile:()=>{te(!1),w(!0)},onEditProfile:()=>{te(!0),w(!0)},directAddDisabledReason:le?void 0:e("playtest.controls.studioRequired","Connect Roblox Studio and WEPPY Plugin to change test values.")})]}),V==="results"&&t.jsxs("div",{className:s.card,role:"tabpanel","aria-label":e("playtest.view.testResults","Automated Test Results"),children:[t.jsxs("div",{className:s.cardHeader,children:[t.jsx(ra,{label:e("playtest.history.title","Test History"),tooltip:e("playtest.history.title.tooltip","Recorded automated playtest runs for this project.")}),m?t.jsx(it,{text:e("playtest.sample.clearDisabled","Available with Pro for live playtest history."),children:t.jsx("span",{children:t.jsx("button",{className:s.clearButton,disabled:!0,children:e("common.clear","Clear")})})}):t.jsx("button",{className:s.clearButton,onClick:()=>{i("dashboard_click_event",{click_target:"playtest_clear_history",page:"playtest"}),L(!0)},children:e("common.clear","Clear")})]}),(m||!Ne&&he==="ready"&&ce.length===0)&&t.jsx(Ht,{kind:"no-results",isBasic:m}),!m&&he==="error"&&ce.length===0&&t.jsxs("div",{className:s.inlineError,role:"alert",children:[t.jsx("span",{children:re??e("playtest.emptyResults.loadFailed","Could not load test results.")}),t.jsx("button",{type:"button",className:s.secondaryAction,onClick:()=>void k.retryHistory(),children:e("common.retry","Try again")})]}),Ne?t.jsx("div",{className:s.emptyState,children:e("common.loading","Loading...")}):ce.length===0?null:t.jsx(vo,{entries:ce,onSelect:_e,selectedRecordId:O??void 0})]}),t.jsx(Ke,{open:E,ariaLabel:e("playtest.guide.title","Publishing your game after playtesting"),onClose:()=>W(!1),returnFocusTo:$.current,children:t.jsxs("div",{className:s.detailShell,children:[t.jsx(ze,{title:e("playtest.guide.title","Publishing your game after playtesting"),description:e("playtest.guide.dialogDescription","Review what remains after testing and what to check before publishing."),closeLabel:e("common.close","Close"),onRequestClose:()=>W(!1)}),t.jsx("div",{className:s.detailBody,children:t.jsx(uc,{showHeading:!1,hasManagedAdapterWithoutStudioGuard:((Re=f.releaseGuidance)==null?void 0:Re.hasManagedAdapterWithoutStudioGuard)===!0})})]})}),t.jsx(Ke,{open:O!==null,ariaLabel:e("playtest.detail.dialogLabel","Playtest report detail"),onClose:xe,returnFocusTo:Z.current,testId:"playtest-detail-popup-layer",children:t.jsxs("div",{className:s.detailShell,children:[t.jsx(ze,{title:e("playtest.report.title","Selected Report"),description:ve==null?void 0:ve.testName,closeLabel:e("common.close","Close"),onRequestClose:xe}),t.jsx("div",{className:s.detailBody,children:we?t.jsx("div",{className:s.detailState,role:"status",children:e("playtest.detail.loading","Loading report...")}):q?t.jsxs("div",{className:s.detailState,role:"alert",children:[t.jsx("div",{className:s.detailErrorTitle,children:e("playtest.detail.errorTitle","Report unavailable")}),t.jsx("div",{className:s.detailErrorMessage,children:q}),t.jsx("button",{type:"button",className:s.detailRetryButton,onClick:()=>void k.retryReport(),children:e("common.retry","Retry")})]}):ie?t.jsx(wo,{report:ie}):t.jsx("div",{className:s.detailState,role:"status",children:e("playtest.detail.loading","Loading report...")})})]})}),!c&&t.jsxs(t.Fragment,{children:[!m&&t.jsx(ft,{open:U,title:e("playtest.clear.title","Clear test history?"),message:e("playtest.clear.message","This permanently removes the stored playtest reports for the current place."),cancelLabel:e("common.cancel","Cancel"),confirmLabel:e("common.clear","Clear"),loading:ae,onCancel:()=>!ae&&L(!1),onConfirm:Ce}),t.jsx(ic,{open:M,onClose:()=>w(!1),profile:ee?f.profile:null,onCreate:f.createProfile,onSave:f.saveProfile,onDelete:async(p,j)=>{const F=await f.deleteProfile(p,j);H(F.refreshFailed?e("playtest.profile.deleteRefreshFailed","Profile deleted. Reload the profile list to confirm the latest state."):e("playtest.profile.deleteSuccess","Profile deleted."),F.refreshFailed?"warning":"success")},onResolveSelection:f.resolveSelection,onResolveSelectionCandidates:f.resolveSelectionCandidates}),t.jsx(cc,{open:B,profile:f.profile,catalog:f.catalog,activeLease:!!f.lease,onClose:()=>P(!1),onSave:f.saveProfile,onCreateProfile:f.createProfile,onResolveSelectionCandidates:f.resolveSelectionCandidates})]})]})}export{Dc as Component};