import{r as c,a as b,u as f,j as e,i as M,l as k,m as A,T as H}from"./index-BIVkyPD7.js";import{I}from"./InfoLabel-BkXtpBzT.js";import{T as _}from"./TooltipText-59Xfc1Ui.js";import{C as D}from"./ConfirmModal-lSOkaAvB.js";const E=5e3;function $(t){const r=(t==null?void 0:t.enabled)??!0,[d,o]=c.useState([]),[a,n]=c.useState(null),[p,l]=c.useState(r),i=c.useRef(null),h=c.useCallback(async()=>{try{const x=await b.get("/api/dashboard/playtest/history");o(x.entries??[])}catch{}},[]),m=c.useCallback(async()=>{if(!r){l(!1);return}await h(),l(!1)},[r,h]),y=c.useCallback(async()=>{r&&(await b.post("/api/dashboard/playtest/history/clear"),o([]),n(null))},[r]),g=c.useCallback(async x=>{if(r)try{const S=await b.get(`/api/dashboard/playtest/report/${x}`);n(S)}catch{n(null)}},[r]);return c.useEffect(()=>{if(!r){l(!1);return}return m(),i.current=setInterval(m,E),()=>{i.current&&clearInterval(i.current)}},[r,m]),{history:d,selectedReport:a,loading:p,loadReport:g,clearHistory:y}}function U(t){const r="2026-03-27T15:26:00.000Z",d={testScenario:t("playtest.sample.context.why","Spawn into the arena, survive the opener, and verify the HUD responds immediately."),expectedBehavior:t("playtest.sample.context.expected","The player spawns safely, the countdown UI appears within one second, and the first wave starts without errors."),observedBehavior:t("playtest.sample.context.observed","Spawn protection held, the HUD updated on time, and wave one completed with no gameplay regressions.")};return{history:[{timestamp:r,testName:t("playtest.sample.history.name","Sample Arena Smoke Test"),mode:"play",status:"passed",durationMs:4820,contextId:"sample_playtest_preview",contextSummary:d}],report:{markdown:t("playtest.sample.report.markdown",`# Sample Arena Smoke Test

- Spawn flow: PASS
- HUD countdown: PASS
- Wave bootstrap: PASS

This is a sample preview. Live playtests and real reports are available with Pro.`),logs:t("playtest.sample.report.logs",`[sample] boot playtest preview
[sample] spawn protection active
[sample] hud countdown rendered
[sample] wave one completed
[sample] preview report finished`),contextId:"sample_playtest_preview",contextSummary:d}}}const O="_page_3lq3l_2",F="_sampleBanner_3lq3l_9",W="_sampleBannerRow_3lq3l_21",V="_sampleBannerMain_3lq3l_28",Y="_sampleBadge_3lq3l_35",z="_sampleTitle_3lq3l_50",G="_sampleMessage_3lq3l_57",Z="_sampleActions_3lq3l_64",J="_primaryAction_3lq3l_72",K="_secondaryAction_3lq3l_73",Q="_card_3lq3l_109",X="_cardHeader_3lq3l_116",ee="_clearButton_3lq3l_128",te="_statusRow_3lq3l_143",se="_statusIndicator_3lq3l_150",ae="_statusRunning_3lq3l_158",re="_statusPaused_3lq3l_163",oe="_statusNotRunning_3lq3l_167",ne="_statusLabel_3lq3l_171",le="_statusMeta_3lq3l_178",ie="_controlButtons_3lq3l_184",ce="_btn_3lq3l_191",de="_btnPrimary_3lq3l_213",pe="_btnDanger_3lq3l_223",me="_historyList_3lq3l_233",ue="_historyItem_3lq3l_241",he="_historyItemSelected_3lq3l_260",ye="_historyItemHeader_3lq3l_265",_e="_historyIcon_3lq3l_271",xe="_historyTimestamp_3lq3l_276",ge="_historyName_3lq3l_283",ve="_historyItemMeta_3lq3l_293",Se="_historyMode_3lq3l_302",be="_historyDuration_3lq3l_306",fe="_historyStatus_3lq3l_310",je="_status_passed_3lq3l_317",Ne="_status_failed_3lq3l_321",we="_status_running_3lq3l_325",Ce="_historyError_3lq3l_329",qe="_historyContext_3lq3l_339",Le="_historyContextLine_3lq3l_348",Ie="_historyContextLabel_3lq3l_354",Re="_reportContainer_3lq3l_363",Pe="_reportContextPanel_3lq3l_369",Be="_reportContextRow_3lq3l_379",Te="_reportContextLabel_3lq3l_387",Me="_reportSection_3lq3l_395",ke="_reportSectionHeader_3lq3l_401",Ae="_reportMarkdown_3lq3l_413",He="_reportLogs_3lq3l_426",De="_emptyState_3lq3l_441",Ee="_emptyStateTitle_3lq3l_448",$e="_emptyStateMessage_3lq3l_456",Ue="_upgradePanel_3lq3l_465",Oe="_upgradePanelIcon_3lq3l_473",Fe="_upgradePanelTitle_3lq3l_478",We="_upgradePanelDesc_3lq3l_486",Ve="_benefitList_3lq3l_496",Ye="_benefitItem_3lq3l_507",ze="_upgradeActions_3lq3l_522",s={page:O,sampleBanner:F,sampleBannerRow:W,sampleBannerMain:V,sampleBadge:Y,sampleTitle:z,sampleMessage:G,sampleActions:Z,primaryAction:J,secondaryAction:K,card:Q,cardHeader:X,clearButton:ee,statusRow:te,statusIndicator:se,statusRunning:ae,statusPaused:re,statusNotRunning:oe,statusLabel:ne,statusMeta:le,controlButtons:ie,btn:ce,btnPrimary:de,btnDanger:pe,historyList:me,historyItem:ue,historyItemSelected:he,historyItemHeader:ye,historyIcon:_e,historyTimestamp:xe,historyName:ge,historyItemMeta:ve,historyMode:Se,historyDuration:be,historyStatus:fe,status_passed:je,status_failed:Ne,status_running:we,historyError:Ce,historyContext:qe,historyContextLine:Le,historyContextLabel:Ie,reportContainer:Re,reportContextPanel:Pe,reportContextRow:Be,reportContextLabel:Te,reportSection:Me,reportSectionHeader:ke,reportMarkdown:Ae,reportLogs:He,emptyState:De,emptyStateTitle:Ee,emptyStateMessage:$e,upgradePanel:Ue,upgradePanelIcon:Oe,upgradePanelTitle:Fe,upgradePanelDesc:We,benefitList:Ve,benefitItem:Ye,upgradeActions:ze};function v(t){return t.trim().toLowerCase()}function Ge(t){switch(v(t)){case"passed":return"✅";case"failed":return"❌";case"running":return"⏱";default:return"❓"}}function Ze(t,r){switch(v(r)){case"run":return t("playtest.status.mode.run","Run");case"server":return t("playtest.status.mode.server","Server");case"edit":return t("playtest.status.mode.edit","Edit");case"play":return t("playtest.status.mode.play","Play");default:return r}}function Je(t,r){switch(v(r)){case"passed":return t("playtest.history.status.passed","Passed");case"failed":return t("playtest.history.status.failed","Failed");case"running":return t("playtest.history.status.running","Running");default:return t("playtest.history.status.unknown","Unknown")}}function Ke(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Qe({entries:t,onSelect:r,selectedTimestamp:d}){const{t:o}=f();return t.length===0?e.jsx("div",{className:s.emptyState,children:o("playtest.history.empty","No test results yet")}):e.jsx("div",{className:s.historyList,children:t.map(a=>{var p,l,i,h,m,y;const n=a.timestamp===d;return e.jsxs("button",{className:`${s.historyItem} ${n?s.historyItemSelected:""}`,onClick:()=>r(a.timestamp),children:[e.jsxs("div",{className:s.historyItemHeader,children:[e.jsx("span",{className:s.historyIcon,children:Ge(a.status)}),e.jsx("span",{className:s.historyTimestamp,children:a.timestamp}),e.jsx("span",{className:s.historyName,children:a.testName})]}),e.jsxs("div",{className:s.historyItemMeta,children:[e.jsx(_,{text:o("playtest.history.mode.tooltip","Playtest mode used for this recorded test run."),children:e.jsxs("span",{className:s.historyMode,children:[o("playtest.history.mode","Mode"),": ",Ze(o,a.mode)]})}),e.jsx("span",{className:s.historyDuration,children:Ke(a.durationMs)}),e.jsx(_,{text:o("playtest.history.status.tooltip","Recorded result state for this automated playtest run."),children:e.jsx("span",{className:`${s.historyStatus} ${s[`status_${v(a.status)}`]??""}`,children:Je(o,a.status)})})]}),a.errorMessage&&e.jsx("div",{className:s.historyError,children:a.errorMessage}),(a.contextId||((p=a.contextSummary)==null?void 0:p.testScenario)||((l=a.contextSummary)==null?void 0:l.expectedBehavior)||((i=a.contextSummary)==null?void 0:i.observedBehavior))&&e.jsxs("div",{className:s.historyContext,children:[a.contextId&&e.jsxs("div",{className:s.historyContextLine,children:[e.jsx("span",{className:s.historyContextLabel,children:o("playtest.context.contextId","Context ID")}),e.jsx("span",{children:a.contextId})]}),((h=a.contextSummary)==null?void 0:h.testScenario)&&e.jsxs("div",{className:s.historyContextLine,children:[e.jsx("span",{className:s.historyContextLabel,children:o("playtest.context.why","Why this test ran")}),e.jsx("span",{children:a.contextSummary.testScenario})]}),((m=a.contextSummary)==null?void 0:m.expectedBehavior)&&e.jsxs("div",{className:s.historyContextLine,children:[e.jsx("span",{className:s.historyContextLabel,children:o("playtest.context.expected","Expected")}),e.jsx("span",{children:a.contextSummary.expectedBehavior})]}),((y=a.contextSummary)==null?void 0:y.observedBehavior)&&e.jsxs("div",{className:s.historyContextLine,children:[e.jsx("span",{className:s.historyContextLabel,children:o("playtest.context.observed","Observed")}),e.jsx("span",{children:a.contextSummary.observedBehavior})]})]})]},a.timestamp)})})}function Xe({report:t}){var o,a,n,p,l,i;const{t:r}=f(),d=!!((o=t.contextSummary)!=null&&o.testScenario||(a=t.contextSummary)!=null&&a.expectedBehavior||(n=t.contextSummary)!=null&&n.observedBehavior);return e.jsxs("div",{className:s.reportContainer,children:[d&&e.jsxs("div",{className:s.reportContextPanel,children:[((p=t.contextSummary)==null?void 0:p.testScenario)&&e.jsxs("div",{className:s.reportContextRow,children:[e.jsx("span",{className:s.reportContextLabel,children:r("playtest.context.why","Why this test ran")}),e.jsx("span",{children:t.contextSummary.testScenario})]}),((l=t.contextSummary)==null?void 0:l.expectedBehavior)&&e.jsxs("div",{className:s.reportContextRow,children:[e.jsx("span",{className:s.reportContextLabel,children:r("playtest.context.expected","Expected")}),e.jsx("span",{children:t.contextSummary.expectedBehavior})]}),((i=t.contextSummary)==null?void 0:i.observedBehavior)&&e.jsxs("div",{className:s.reportContextRow,children:[e.jsx("span",{className:s.reportContextLabel,children:r("playtest.context.observed","Observed")}),e.jsx("span",{children:t.contextSummary.observedBehavior})]})]}),t.markdown&&e.jsxs("div",{className:s.reportSection,children:[e.jsx("div",{className:s.reportSectionHeader,children:e.jsx(_,{text:r("playtest.report.content.tooltip","Markdown summary for the selected automated playtest run."),children:e.jsx("span",{children:r("playtest.report.content","Report")})})}),e.jsx("pre",{className:s.reportMarkdown,children:t.markdown})]}),t.logs&&e.jsxs("div",{className:s.reportSection,children:[e.jsx("div",{className:s.reportSectionHeader,children:e.jsx(_,{text:r("playtest.report.logs.tooltip","Execution logs captured for the selected automated playtest run."),children:e.jsx("span",{children:r("playtest.report.logs","Logs")})})}),e.jsx("pre",{className:s.reportLogs,children:t.logs})]}),!t.markdown&&!t.logs&&e.jsx("div",{className:s.emptyState,children:r("playtest.report.empty","No report content available")})]})}function rt(){var q;const{t}=f(),{trackEvent:r}=M(),{tier:d,loading:o}=k(),a=!o&&d==="basic",n=$({enabled:!a}),{show:p}=A(),[l,i]=c.useState(null),[h,m]=c.useState(!1),[y,g]=c.useState(!1),{history:x,selectedReport:S,loading:R}=n,u=a?U(t):null,j=((q=u==null?void 0:u.history[0])==null?void 0:q.timestamp)??null,N=a?l??j:l,w=(u==null?void 0:u.history)??x,C=u&&N===j?u.report:S,P=a?!1:R,B=L=>{i(L),!a&&n.loadReport(L)},T=async()=>{g(!0);try{await n.clearHistory(),p(t("toast.clearSuccess","Cleared successfully"),"success"),m(!1),i(null)}catch{p(t("toast.clearFailed","Failed to clear data"),"error")}finally{g(!1)}};return e.jsxs("div",{className:s.page,children:[a&&e.jsx("div",{className:s.sampleBanner,children:e.jsxs("div",{className:s.sampleBannerRow,children:[e.jsxs("div",{className:s.sampleBannerMain,children:[e.jsx("div",{className:s.sampleBadge,children:t("playtest.sample.badge","Preview of the Pro playtest view")}),e.jsx("div",{className:s.sampleTitle,children:t("playtest.sample.title","You are previewing the report viewer that becomes available after upgrading to Pro.")}),e.jsx("div",{className:s.sampleMessage,children:t("playtest.sample.message","This preview uses sample data. Real playtest history management and stored reports unlock with Pro.")})]}),e.jsx("div",{className:s.sampleActions,children:e.jsx("a",{className:s.primaryAction,href:H.playtest,target:"_blank",rel:"noreferrer",onClick:()=>r("dashboard_click_event",{click_target:"upgrade_cta",placement:"playtest_sample_banner",page:"playtest"}),children:t("tier.upgrade","View Pro")})})]})}),e.jsxs("div",{className:s.card,children:[e.jsxs("div",{className:s.cardHeader,children:[e.jsx(I,{label:t("playtest.history.title","Test History"),tooltip:t("playtest.history.title.tooltip","Recorded automated playtest runs for this project.")}),a?e.jsx(_,{text:t("playtest.sample.clearDisabled","Available with Pro for live playtest history."),children:e.jsx("span",{children:e.jsx("button",{className:s.clearButton,disabled:!0,children:t("common.clear","Clear")})})}):e.jsx("button",{className:s.clearButton,onClick:()=>{r("dashboard_click_event",{click_target:"playtest_clear_history",page:"playtest"}),m(!0)},children:t("common.clear","Clear")})]}),P?e.jsx("div",{className:s.emptyState,children:t("common.loading","Loading...")}):w.length===0?e.jsxs("div",{className:s.emptyState,children:[e.jsx("div",{className:s.emptyStateTitle,children:t("playtest.empty.title","No playtest results yet")}),e.jsxs("div",{className:s.emptyStateMessage,children:[t("playtest.empty.message.before","Test results will appear here when the AI agent runs automated tests via")," ",e.jsx(_,{text:t("playtest.empty.runTest.tooltip","WEPPY Dashboard automation entry point that runs Roblox playtest checks through the system_info tool."),children:e.jsx("span",{children:"system_info.run_test"})}),t("playtest.empty.message.after",".")]})]}):e.jsx(Qe,{entries:w,onSelect:B,selectedTimestamp:N??void 0})]}),C&&e.jsxs("div",{className:s.card,children:[e.jsx("div",{className:s.cardHeader,children:e.jsx(I,{label:t("playtest.report.title","Selected Report"),tooltip:t("playtest.report.title.tooltip","Detailed output for the currently selected automated playtest run.")})}),e.jsx(Xe,{report:C})]}),!a&&e.jsx(D,{open:h,title:t("playtest.clear.title","Clear test history?"),message:t("playtest.clear.message","This permanently removes the stored playtest reports for the current place."),cancelLabel:t("common.cancel","Cancel"),confirmLabel:t("common.clear","Clear"),loading:y,onCancel:()=>!y&&m(!1),onConfirm:T})]})}export{rt as Component};
