rails-profiler 0.44.34 → 0.45.0
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.
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
`)+`
|
|
9
9
|
`,D=new Blob([K],{type:"text/plain"}),O=URL.createObjectURL(D),J=document.createElement("a");J.href=O,J.download=".env",J.click(),URL.revokeObjectURL(O),H("success",`Exported ${_.length} variables`)},je=nr(()=>kc(De),[De]),Ee=nr(()=>Object.fromEntries(Object.entries(je).filter(([,_])=>_!==hi)),[je]),Qe=Object.keys(Ee).length,Ke=Object.keys(je).length-Qe,Vt=async()=>{let _=Object.entries(Ee);if(_.length){w(!0);try{await Promise.all(_.map(([D,O])=>Fe({data:{key:D,value:O}}))),a(D=>({...D,...Ee})),be(""),Ie(!1);let K=Ke>0?`, skipped ${Ke} masked`:"";H("success",`Imported ${_.length} variables${K}`)}catch(K){H("error",K.message??"Import failed")}finally{w(!1)}}},pe=_=>{b(_),T(n[_]??"")},it=()=>{b(null),T("")},lt=async()=>{if(!g)return;let _=g;if(x===n[_]){b(null);return}w(!0);try{let K=await Fe({data:{key:_,value:x}});a(D=>({...D,[_]:x})),l(D=>{let O={...D};return K.override?O[_]=K.override:delete O[_],O}),H("success",`${_} updated`),b(null)}catch(K){H("error",K.message??"Failed to update")}finally{w(!1)}},go=async _=>{w(!0);try{let K=await Fe({data:{key:_,value:null}});a(D=>{let O={...D};return delete O[_],O}),l(D=>{let O={...D};return K.override?O[_]=K.override:delete O[_],O}),B(D=>{let O=new Set(D);return O.delete(_),Ys(O),O}),H("success",`${_} deleted`)}catch(K){H("error",K.message??"Failed to delete")}finally{w(!1)}},Ht=async(_,K)=>{let D=/^(true|yes)$/i.test(K)?"false":"true";w(!0);try{let O=await Fe({data:{key:_,value:D}});a(J=>({...J,[_]:D})),l(J=>{let Re={...J};return O.override?Re[_]=O.override:delete Re[_],Re})}catch(O){H("error",O.message??"Failed to update")}finally{w(!1)}},cr=async()=>{let _=C.trim();if(_){w(!0);try{let K=await Fe({data:{key:_,value:k}});a(D=>({...D,[_]:k})),l(D=>{let O={...D};return K.override?O[_]=K.override:delete O[_],O}),P(""),q(""),H("success",`${_} added`)}catch(K){H("error",K.message??"Failed to add")}finally{w(!1)}}},$e=_=>{_.key==="Enter"&<(),_.key==="Escape"&&it()},bo=async _=>{w(!0);try{let K=await nt({params:{key:_}});l(O=>{let J={...O};return delete J[_],J});let D=O=>{let J={...O};return K.value===null||K.value===void 0?delete J[_]:J[_]=K.value,J};a(D),s(D),H("success",`${_} reset to original`)}catch(K){H("error",K.message??"Failed to reset")}finally{w(!1)}},oe=async()=>{w(!0);try{await S(),l({});let _=await L();_&&s(_.variables),H("success","All overrides reset")}catch(_){H("error",_.message??"Failed to reset all")}finally{w(!1)}},Ir=Object.keys(i).length,ge=Object.entries(n),ut=nr(()=>{let _=y.toLowerCase().trim();return _?ge.filter(([K,D])=>K.toLowerCase().includes(_)||D.toLowerCase().includes(_)):ge},[n,y]),ve=nr(()=>{let _={};for(let K of ut){let D=Rc(K[0]);(_[D]??(_[D]=[])).push(K)}return Object.entries(_).sort(([K],[D])=>K==="OTHER"?1:D==="OTHER"?-1:K.localeCompare(D))},[ut]),jr=ut.every(([_])=>Z.has(_)),pr=()=>{let _=ut.map(([K])=>K);B(K=>{let D=new Set(K);return jr?_.forEach(O=>D.delete(O)):_.forEach(O=>D.add(O)),Ys(D),D})},$r="width:100%;font-family:monospace;font-size:12px;padding:2px 6px;border:1px solid var(--profiler-border);border-radius:4px;background:var(--profiler-bg);color:var(--profiler-text);",ct="background:none;border:none;cursor:pointer;font-size:12px;padding:0 3px;color:var(--profiler-text-muted);opacity:0.7;flex-shrink:0;",pt="background:none;border:1px solid var(--profiler-border);border-radius:4px;cursor:pointer;color:var(--profiler-text-muted);font-size:11px;padding:3px 8px;";return t(M,{children:[t("div",{class:"profiler-flex profiler-mb-4",style:"align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;",children:[t("h2",{class:"profiler-section__header",style:"margin:0;",children:"Environment Variables"}),t("div",{class:"profiler-flex profiler-flex--gap-2",children:[!r&&t(M,{children:[t("button",{onClick:L,disabled:F,style:pt,children:F?"\u2026":"\u21BA Refresh"}),t("button",{onClick:()=>Ie(_=>!_),style:`${pt}${Ne?"border-color:var(--profiler-accent);color:var(--profiler-accent);":""}`,children:"\u2B06 Import"})]}),t("button",{onClick:W,style:pt,children:"\u2B07 Export"}),t("button",{onClick:pr,style:pt,children:jr?"\u{1F648} Mask all":"\u{1F441} Reveal all"}),!r&&Ir>0&&t("button",{onClick:oe,disabled:N,title:"Remove all Sidekiq overrides and restore original values",style:`${pt}border-color:var(--profiler-warning,#f59e0b);color:var(--profiler-warning,#f59e0b);`,children:["\u21A9 Reset all (",Ir,")"]}),!r&&t("button",{onClick:()=>qe(_=>!_),title:Y?"Unlock editing":"Lock editing",style:`${pt}${Y?"border-color:var(--profiler-error,#ef4444);color:var(--profiler-error,#ef4444);":""}`,children:Y?"\u{1F512} Locked":"\u{1F513} Edit"})]})]}),r?t("div",{style:"background:var(--profiler-bg-subtle,rgba(0,0,0,0.03));border:1px solid var(--profiler-border);border-radius:6px;padding:8px 12px;margin-bottom:16px;font-size:12px;color:var(--profiler-text-muted);",children:["Snapshot taken at request time - modify env vars in ",t("a",{href:"/_profiler?section=env",style:"color:var(--profiler-accent);",children:"/_profiler?section=env"}),"."]}):t("div",{style:"background:var(--profiler-warning-bg,rgba(245,158,11,0.1));border:1px solid var(--profiler-warning,#f59e0b);border-radius:6px;padding:8px 12px;margin-bottom:16px;font-size:12px;color:var(--profiler-warning,#f59e0b);",children:"\u26A0 Changes affect the current process only - for development use."}),U&&t("div",{style:`background:${U.type==="success"?"var(--profiler-success-bg,rgba(34,197,94,0.1))":"var(--profiler-error-bg,rgba(239,68,68,0.08))"};border:1px solid ${U.type==="success"?"var(--profiler-success,#22c55e)":"var(--profiler-error,#ef4444)"};border-radius:6px;padding:6px 12px;margin-bottom:12px;font-size:12px;color:${U.type==="success"?"var(--profiler-success,#22c55e)":"var(--profiler-error,#ef4444)"};`,children:[U.type==="success"?"\u2713":"\u2717"," ",U.message]}),Ne&&t("div",{style:"border:1px solid var(--profiler-border);border-radius:6px;padding:12px;margin-bottom:16px;",children:[t("p",{class:"profiler-text--xs profiler-text--muted",style:"margin:0 0 8px;",children:["Paste the contents of a ",t("code",{children:".env"})," file. Comments and blank lines are ignored."]}),t("textarea",{value:De,onInput:_=>be(_.target.value),placeholder:`APP_NAME=MyApp
|
|
10
10
|
FEATURE_BETA=true
|
|
11
|
-
# comment`,rows:6,style:"width:100%;font-family:monospace;font-size:12px;padding:6px 8px;border:1px solid var(--profiler-border);border-radius:4px;background:var(--profiler-bg);color:var(--profiler-text);resize:vertical;box-sizing:border-box;"}),t("div",{class:"profiler-flex profiler-flex--gap-2 profiler-mt-2",style:"align-items:center;",children:[Qe>0&&t("span",{class:"profiler-text--xs profiler-text--muted",children:[Qe," variable",Qe!==1?"s":""," to import"]}),Ke>0&&t("span",{class:"profiler-text--xs profiler-text--muted",children:[Ke," masked (",hi,") skipped"]}),t("button",{onClick:Vt,disabled:N||Qe===0,style:"background:var(--profiler-accent);border:none;cursor:pointer;color:#fff;font-size:11px;padding:4px 12px;border-radius:4px;margin-left:auto;",children:"Apply"})]})]}),t("div",{class:"profiler-flex profiler-flex--gap-4 profiler-mb-4",children:[t("div",{class:"profiler-stat-card",children:[t("div",{class:"profiler-stat-card__value",children:c}),t("div",{class:"profiler-stat-card__label",children:"Total vars"})]}),y&&t("div",{class:"profiler-stat-card",children:[t("div",{class:"profiler-stat-card__value",children:ut.length}),t("div",{class:"profiler-stat-card__label",children:"Matching"})]})]}),t("div",{class:"profiler-flex profiler-flex--gap-2 profiler-mb-3",children:t("input",{type:"text",class:"profiler-filter-input",placeholder:"Filter by key or value\u2026",value:y,onInput:_=>f(_.target.value),style:"flex:1;"})}),t("table",{class:"profiler-table",children:[t("thead",{children:t("tr",{children:[t("th",{style:"width:32%",children:"Key"}),t("th",{children:"Value"}),!Y&&t("th",{style:"width:120px;text-align:right;"})]})}),t("tbody",{children:[ve.map(([_,K])=>{let D=h.has(_);return t(M,{children:[t("tr",{onClick:()=>ur(_),style:"cursor:pointer;background:var(--profiler-bg-subtle,rgba(0,0,0,0.03));",children:t("td",{colspan:Y?2:3,style:"padding:4px 8px;",children:[t("span",{style:"font-size:11px;font-weight:600;color:var(--profiler-text-muted);letter-spacing:0.05em;font-family:monospace;",children:[D?"\u25B6":"\u25BC"," ",_,"_"]}),t("span",{style:"font-size:10px;color:var(--profiler-text-muted);margin-left:6px;",children:K.length})]})},`group-${_}`),!D&&K.map(([O,J])=>{let Re=Z.has(O),Je=g===O,Gt=ce===O,_t=ce===`__key__${O}`,vo=o[O]!==void 0&&o[O]!==J,xe=o[O]===void 0,de=i[O];return t("tr",{style:de?"border-left:3px solid var(--profiler-accent);":vo?"border-left:3px solid #f59e0b;":xe?"border-left:3px solid var(--profiler-success,#22c55e);":"",children:[t("td",{children:t("div",{class:"profiler-flex",style:"align-items:center;gap:4px;",children:[t("code",{class:"profiler-text--xs profiler-text--mono",children:O}),t("button",{onClick:()=>at(O,`__key__${O}`),title:"Copy key",style:`${ct}${_t?"color:var(--profiler-success,#22c55e);opacity:1;":""}`,children:_t?"\u2713":"\u2398"})]})}),t("td",{children:Je?t("div",{class:"profiler-flex",style:"align-items:center;gap:2px;",children:[en(x)&&t("span",{style:"font-family:monospace;font-size:12px;color:var(--profiler-text-muted);opacity:0.5;flex-shrink:0;",children:'"'}),t("input",{ref:we,type:"text",value:x,onInput:xo=>T(xo.target.value),onKeyDown:$e,disabled:N,style:"flex:1;font-family:monospace;font-size:12px;padding:2px 6px;border:1px solid var(--profiler-accent);border-radius:4px;background:var(--profiler-bg);color:var(--profiler-text);"}),en(x)&&t("span",{style:"font-family:monospace;font-size:12px;color:var(--profiler-text-muted);opacity:0.5;flex-shrink:0;",children:'"'})]}):bi(J)?t(M,{children:[t("div",{class:"profiler-flex",style:"align-items:center;gap:8px;",children:[t(gi,{value:J}),t("button",{onClick:()=>!Y&&!N&&Ht(O,J),disabled:N||Y,title:`Click to set ${/^(true|yes)$/i.test(J)?"false":"true"}`,style:`position:relative;display:inline-block;width:36px;height:20px;border-radius:10px;border:none;cursor:${Y||N?"default":"pointer"};padding:0;transition:background 0.2s;background:${/^(true|yes)$/i.test(J)?"var(--profiler-accent)":"var(--profiler-border,#d1d5db)"};flex-shrink:0;`,children:t("span",{style:`position:absolute;top:3px;width:14px;height:14px;border-radius:50%;background:#fff;transition:left 0.2s;left:${/^(true|yes)$/i.test(J)?"19px":"3px"};`})}),t("span",{class:"profiler-text--xs profiler-text--mono",style:"color:var(--profiler-text-muted);",children:J}),t("button",{onClick:()=>at(J,O),title:"Copy value",style:`${ct}${Gt?"color:var(--profiler-success,#22c55e);opacity:1;":""}`,children:Gt?"\u2713":"\u2398"})]}),de&&t("div",{style:"font-size:10px;color:var(--profiler-accent);margin-top:2px;font-family:monospace;",children:["workers \u2190 ",de.value==="__profiler_deleted__"?"(deleted)":de.value," \xB7 original: ",de.original??"(unset)"]})]}):t(M,{children:[t("div",{class:"profiler-flex",style:"align-items:center;gap:4px;",children:[t(gi,{value:J}),t("span",{class:"profiler-text--xs profiler-text--mono",onClick:()=>!Y&&!Je&&pe(O),title:Y?void 0:"Click to edit",style:`word-break:break-all;flex:1;${Y?"":"cursor:pointer;"}`,children:Re?en(J)?t(M,{children:[t("span",{style:"color:var(--profiler-text-muted);opacity:0.5;",children:'"'}),J,t("span",{style:"color:var(--profiler-text-muted);opacity:0.5;",children:'"'})]}):J:"\u2022".repeat(Math.min(J.length,20))}),t("button",{onClick:()=>Ce(O),title:Re?"Hide value":"Show value",style:`${ct}${Re?"opacity:1;color:var(--profiler-accent);":""}`,children:Re?"\u{1F441}":"\u{1F648}"}),t("button",{onClick:()=>at(J,O),title:"Copy value",style:`${ct}${Gt?"color:var(--profiler-success,#22c55e);opacity:1;":""}`,children:Gt?"\u2713":"\u2398"})]}),de&&t("div",{style:"font-size:10px;color:var(--profiler-accent);margin-top:2px;font-family:monospace;",children:["workers \u2190 ",de.value==="__profiler_deleted__"?"(deleted)":Re?de.value:"\u2022".repeat(Math.min((de.value??"").length,20))," \xB7 original: ",de.original==null?"(unset)":Re?de.original:"\u2022".repeat(Math.min(de.original.length,20))]})]})}),!Y&&t("td",{style:"text-align:right;white-space:nowrap;",children:Je?t(M,{children:[t("button",{onClick:lt,disabled:N,title:"Save",style:"background:none;border:none;cursor:pointer;color:var(--profiler-success,#22c55e);font-size:14px;padding:0 4px;",children:"\u2713"}),t("button",{onClick:it,disabled:N,title:"Cancel",style:"background:none;border:none;cursor:pointer;color:var(--profiler-text-muted);font-size:14px;padding:0 4px;",children:"\u2717"})]}):t(M,{children:[t("button",{onClick:()=>pe(O),disabled:N,title:"Edit",style:"background:none;border:none;cursor:pointer;color:var(--profiler-accent);font-size:14px;padding:0 4px;",children:"\u270E"}),de&&t("button",{onClick:()=>bo(O),disabled:N,title:`Reset to original: ${de.original??"(unset)"}`,style:"background:none;border:none;cursor:pointer;color:var(--profiler-warning,#f59e0b);font-size:14px;padding:0 4px;",children:"\u21A9"}),t("button",{onClick:()=>go(O),disabled:N,title:"Delete",style:"background:none;border:none;cursor:pointer;color:var(--profiler-error,#ef4444);font-size:14px;padding:0 4px;",children:"\u2715"})]})})]},O)})]})}),!Y&&t("tr",{children:[t("td",{children:t("input",{type:"text",value:C,onInput:_=>P(_.target.value),onKeyDown:_=>_.key==="Enter"&&cr(),placeholder:"NEW_KEY",disabled:N,style:$r})}),t("td",{children:t("input",{type:"text",value:k,onInput:_=>q(_.target.value),onKeyDown:_=>_.key==="Enter"&&cr(),placeholder:"value",disabled:N,style:$r})}),t("td",{style:"text-align:right;",children:t("button",{onClick:cr,disabled:N||!C.trim(),style:"background:var(--profiler-accent);border:none;cursor:pointer;color:#fff;font-size:11px;padding:3px 8px;border-radius:4px;",children:"Add"})})]})]})]})]})}function vi({tree:e,selected:r,onToggleFile:o,onToggleDir:s}){let[n,a]=v(new Set),i=c=>{a(p=>{let y=new Set(p);return y.has(c)?y.delete(c):y.add(c),y})},l=c=>{let p=c.filter(y=>r.has(y)).length;return p===0?"none":p===c.length?"all":"partial"};return t("div",{class:"profiler-text--xs profiler-text--mono",style:"overflow-y: auto; height: 100%",children:e.map(({directory:c,files:p})=>{let y=p.map(m=>m.path),f=l(y),h=n.has(c);return t("div",{style:"margin-bottom: 4px",children:[t("div",{style:"display: flex; align-items: center; gap: 6px; padding: 3px 6px; cursor: pointer; border-radius: 4px; background: var(--profiler-bg-secondary, rgba(255,255,255,0.05))",onClick:()=>i(c),children:[t("input",{type:"checkbox",checked:f==="all",ref:m=>{m&&(m.indeterminate=f==="partial")},onClick:m=>{m.stopPropagation(),s(c,y)},style:"cursor: pointer; flex-shrink: 0"}),t("span",{style:"color: var(--profiler-text-muted, #888); flex-shrink: 0",children:h?"\u25B6":"\u25BC"}),t("span",{style:"color: var(--profiler-accent, #06b6d4); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap",title:c,children:[c,"/"]}),t("span",{style:"color: var(--profiler-text-muted, #888); margin-left: auto; flex-shrink: 0",children:["(",p.length,")"]})]}),!h&&p.map(m=>t("div",{style:"display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 24px; cursor: pointer; border-radius: 4px",onClick:()=>o(m.path),children:[t("input",{type:"checkbox",checked:r.has(m.path),onClick:g=>{g.stopPropagation(),o(m.path)},style:"cursor: pointer; flex-shrink: 0"}),t("span",{style:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--profiler-text, #e2e8f0)",title:m.path,children:m.name})]},m.path))]},c)})})}function Sc(e){return e==="passed"?"var(--profiler-success, #10b981)":e==="failed"?"var(--profiler-error, #ef4444)":e==="running"?"var(--profiler-accent, #06b6d4)":e==="killed"||e==="signaled"||e==="error"?"var(--profiler-warning, #f59e0b)":"var(--profiler-text-muted, #888)"}function Ac(e){return{pending:"\u23F3 Pending",running:"\u25CF Running\u2026",passed:"\u2713 Passed",failed:"\u2717 Failed",killed:"\u25A0 Killed",signaled:"\u26A1 Ended by a signal",error:"\u26A0 Error"}[e]||e}function Mc(e){let r={0:"",1:"font-weight:bold",31:"color:var(--ansi-red)",32:"color:var(--ansi-green)",33:"color:var(--ansi-yellow)",34:"color:var(--ansi-blue)",35:"color:var(--ansi-purple)",36:"color:var(--ansi-cyan)"},o=[],s="",n=e.split(/(\x1b\[[0-9;]*m)/);for(let a of n)if(a.startsWith("\x1B[")&&a.endsWith("m")){let i=a.slice(2,-1).split(";");if(i.includes("0"))s="";else{let l=i.map(c=>r[c]??"").filter(Boolean);s=[...s?[s]:[],...l].join(";")}}else a.length>0&&o.push({text:a,style:s});return o}function qc({text:e}){let r=Mc(e);return r.length===0?t("span",{style:"color:var(--profiler-text-muted)",children:"No output yet\u2026"}):t(M,{children:r.map((o,s)=>o.style?t("span",{style:o.style,children:o.text},s):t("span",{children:o.text},s))})}function xi({run:e}){let r=me(null);return G(()=>{r.current&&e?.status==="running"&&(r.current.scrollTop=r.current.scrollHeight)},[e?.output]),e?t("div",{style:"display: flex; flex-direction: column; height: 100%; gap: 12px",children:[t("div",{style:"display: flex; align-items: center; gap: 12px; flex-shrink: 0",children:[t("span",{style:`font-weight: 600; color: ${Sc(e.status)}`,children:Ac(e.status)}),e.duration!=null&&t("span",{class:"profiler-text--xs profiler-text--muted",children:[(e.duration/1e3).toFixed(1),"s"]}),(e.status==="passed"||e.status==="failed")&&t("a",{href:"/_profiler?section=tests",class:"profiler-text--xs",style:"color: var(--profiler-accent, #06b6d4); margin-left: auto",children:"View in Profiler \u2192"})]}),t("pre",{ref:r,style:"flex: 1; overflow-y: auto; background: var(--profiler-terminal-bg); color: var(--profiler-terminal-text); padding: 14px 16px; border-radius: 6px; font-family: var(--profiler-font-mono); font-size: 12px; line-height: 1.65; margin: 0; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--profiler-border)",children:t(qc,{text:e.output||""})}),e.files.length>0&&t("div",{class:"profiler-text--xs profiler-text--muted",style:"flex-shrink: 0",children:[e.files.length," file",e.files.length!==1?"s":""," \xB7 ",e.framework]})]}):t("div",{class:"profiler-empty",style:"height: 100%; display: flex; align-items: center; justify-content: center",children:t("div",{children:[t("div",{class:"profiler-empty__title",style:"font-size: 1.1rem",children:"Select files and click Run"}),t("p",{class:"profiler-empty__description",children:"Test output will appear here in real time"})]})})}var _i="/_profiler";function Zo(){let[e,r]=v(""),[o,s]=v(new Set),[n,a]=v(null),[i,l]=v(!1),[c,p]=v(null),{data:y,isLoading:f,refetch:h}=ri(e?{framework:e}:{},{query:{refetchOnWindowFocus:!1}}),{mutateAsync:m}=oi(),{mutateAsync:g}=si(),b=y?.frameworks??[],x=y?.tree??[];G(()=>{!e&&b.length>0&&r(b[0])},[b]);let T=ar(F=>{s(new Set),h()},[h]);G(()=>{if(!n||!i)return;if(["passed","failed","killed","signaled","error"].includes(n.status)){l(!1);return}let F=new EventSource(`${_i}/api/test_runner/runs/${n.id}/stream`);return F.addEventListener("output",I=>{try{let Z=JSON.parse(I.data);a(B=>B&&{...B,output:(B.output||"")+Z.chunk})}catch{}}),F.addEventListener("done",I=>{try{let Z=JSON.parse(I.data);a(B=>B&&{...B,status:Z.status})}catch{}l(!1),F.close()}),F.onerror=()=>{F.readyState===EventSource.CLOSED&&fetch(`${_i}/api/test_runner/runs/${n.id}`).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{I&&Array.isArray(I.files)&&a(I),l(!1)}).catch(()=>l(!1))},()=>F.close()},[n?.id,i]);let C=F=>{r(F),T(F)},P=F=>{s(I=>{let Z=new Set(I);return Z.has(F)?Z.delete(F):Z.add(F),Z})},k=(F,I)=>{s(Z=>{let B=new Set(Z);return I.every(fe=>B.has(fe))?I.forEach(fe=>B.delete(fe)):I.forEach(fe=>B.add(fe)),B})},q=()=>{let F=x.flatMap(I=>I.files.map(Z=>Z.path));s(new Set(F))},U=()=>s(new Set),Q=async()=>{if(!(o.size===0||i)){p(null);try{let F=await m({data:{files:Array.from(o),framework:e}});a(F),l(!0)}catch(F){p(F instanceof Error&&F.message?F.message:"Failed to start test run")}}},N=async()=>{if(n)try{await g({id:n.id}),l(!1),a(F=>F&&{...F,status:"killed"})}catch{}},w=x.reduce((F,I)=>F+I.files.length,0);return t("div",{children:[c&&t("div",{style:"color: var(--profiler-error, #ef4444); background: rgba(239,68,68,0.1); border: 1px solid var(--profiler-error, #ef4444); border-radius: 4px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px",children:c}),t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:b.length>0&&b.map(F=>t("button",{class:`profiler-preset-btn${e===F?" profiler-preset-btn--active":""}`,onClick:()=>C(F),disabled:i,children:F==="rspec"?"RSpec":"Minitest"},F))}),t("div",{class:"profiler-filter-group",style:"margin-left: auto",children:[t("span",{class:"profiler-text--xs profiler-text--muted",children:[o.size," / ",w," selected"]}),t("button",{class:"btn btn-secondary btn-sm",onClick:q,disabled:i||f,children:"All"}),t("button",{class:"btn btn-secondary btn-sm",onClick:U,disabled:i,children:"None"}),i?t("button",{class:"btn btn-danger btn-sm",onClick:N,children:"\u25A0 Stop"}):t("button",{class:"btn btn-sm",style:"background: var(--profiler-accent, #06b6d4); color: #000; font-weight: 600",onClick:Q,disabled:o.size===0,children:["\u25B6 Run Selected (",o.size,")"]})]})]}),t("div",{style:"display: grid; grid-template-columns: 260px 1fr; height: 460px; border: 1px solid var(--profiler-border, rgba(255,255,255,0.1)); border-radius: 6px; overflow: hidden",children:[t("div",{style:"border-right: 1px solid var(--profiler-border, rgba(255,255,255,0.1)); overflow-y: auto; padding: 8px",children:f?t("div",{class:"profiler-text--xs profiler-text--muted",style:"padding: 8px",children:"Loading files\u2026"}):x.length===0?t("div",{class:"profiler-text--xs profiler-text--muted",style:"padding: 8px",children:["No ",e," test files found"]}):t(vi,{tree:x,selected:o,onToggleFile:P,onToggleDir:k})}),t("div",{style:"overflow: hidden; display: flex; flex-direction: column",children:t(xi,{run:n})})]})]})}var Lr="/_profiler";function Ur({cols:e,rows:r=6}){return t("div",{children:Array.from({length:r}).map((o,s)=>t("div",{class:"profiler-skeleton__row",children:e.map((n,a)=>t("div",{class:`profiler-skeleton__cell profiler-skeleton__cell--${n}`},a))},s))})}function Fc(e){return{GET:"badge-info",POST:"badge-success",PUT:"badge-warning",PATCH:"badge-warning",DELETE:"badge-error"}[e]||"badge-default"}function Oc(e){return e>=200&&e<300?"badge-success":e>=300&&e<400?"badge-info":e>=400&&e<500?"badge-warning":e>=500?"badge-error":"badge-default"}function Xo(e){return e>=500?"badge-error":e>=100?"badge-warning":"badge-success"}function Ti(e){let r=e.collectors_data?.job?.status;return r||(e.status===500?"failed":"completed")}function fo(e){return new Date(e).toLocaleTimeString("en",{hour12:!1})}var wi=[{key:"slow",label:"Slow"},{key:"many_queries",label:"Many queries"},{key:"errors",label:"Errors"},{key:"has_exception",label:"Has exception"}];function Ci(){let e=Be(),r=new URLSearchParams(window.location.search),o=()=>{let u=r.get("section");return u==="http"||u==="jobs"||u==="console"||u==="tests"||u==="runner"||u==="outbound"||u==="env"?u:"http"},s=()=>{let u=r.get("sort"),R=r.get("dir");return{col:u==="date"||u==="duration"||u==="memory"||u==="status"||u==="queries"?u:null,dir:R==="desc"?"desc":"asc"}},[n,a]=v(o),i=(u,R)=>({query:{enabled:n===u,queryFn:({pageParam:j=0,signal:re})=>R(j,re),getNextPageParam:j=>j.has_more?j.offset+j.limit:void 0,initialPageParam:0,refetchOnWindowFocus:!1}}),l=Za({limit:50},i("http",(u,R)=>Jo({limit:50,offset:u},R))),c=Ba({limit:50},i("jobs",(u,R)=>Js({limit:50,offset:u},R))),p=Ka({limit:50},i("console",(u,R)=>Hs({limit:50,offset:u},R))),y=ni({limit:50},i("tests",(u,R)=>zs({limit:50,offset:u},R))),f=Wa({query:{enabled:n==="outbound",refetchOnWindowFocus:!1}}),h=Na({query:{enabled:n==="env",refetchOnWindowFocus:!1}}),{mutateAsync:m}=Ya(),{mutateAsync:g}=ti(),{mutateAsync:b}=Ja(),{mutateAsync:x}=za(),{mutateAsync:T}=La(),{mutateAsync:C}=Ua(),{mutateAsync:P}=ai(),{mutateAsync:k}=ii(),q=co(l.data?.pages.flatMap(u=>u.profiles)??[]),U=co(c.data?.pages.flatMap(u=>u.profiles)??[]),Q=co(p.data?.pages.flatMap(u=>u.profiles)??[]),N=co(y.data?.pages.flatMap(u=>u.profiles)??[]),w=f.data??[],F=h.data,I=l.isLoading,Z=c.isLoading,B=p.isLoading,ce=y.isLoading,fe=f.isLoading,Y=h.isLoading,qe=l.error?.message??null,Ne=c.error?.message??null,Ie=p.error?.message??null,De=y.error?.message??null,be=f.error?.message??null,we=h.error?.message??null,Fe=!!l.hasNextPage,nt=!!c.hasNextPage,S=!!p.hasNextPage,H=!!y.hasNextPage,Ce=l.isFetchingNextPage,at=c.isFetchingNextPage,ur=p.isFetchingNextPage,L=y.isFetchingNextPage,[W,je]=v(null),[Ee,Qe]=v(new Set),[Ke,Vt]=v(""),[pe,it]=v(""),[lt,go]=v(""),[Ht,cr]=v(""),[$e,bo]=v(()=>{let u=r.get("preset");return wi.some(R=>R.key===u)?u:""}),[oe,Ir]=v(s),[ge,ut]=v({col:null,dir:"asc"}),[ve,jr]=v({col:null,dir:"asc"}),[pr,$r]=v(""),[ct,pt]=v(""),[_,K]=v(""),[D,O]=v(""),[J,Re]=v(""),[Je,Gt]=v(""),[_t,vo]=v(""),[xe,de]=v({col:null,dir:"asc"}),[Vr,xo]=v(""),[_o,pn]=v(""),[Hr,dn]=v("");G(()=>{let u=new URL(window.location.href);oe.col?(u.searchParams.set("sort",oe.col),u.searchParams.set("dir",oe.dir)):(u.searchParams.delete("sort"),u.searchParams.delete("dir")),$e?u.searchParams.set("preset",$e):u.searchParams.delete("preset"),history.replaceState(null,"",u.toString())},[oe,$e]);let Gr=u=>{Ir(R=>R.col===u?{col:u,dir:R.dir==="asc"?"desc":"asc"}:{col:u,dir:"asc"})},ss=u=>{ut(R=>R.col===u?{col:u,dir:R.dir==="asc"?"desc":"asc"}:{col:u,dir:"asc"})},el=u=>{bo(R=>R===u?"":u)},tl=()=>l.fetchNextPage(),rl=()=>c.fetchNextPage(),ol=()=>p.fetchNextPage(),sl=()=>y.fetchNextPage(),fn=u=>{u==="http"?l.refetch():u==="jobs"?c.refetch():u==="console"?p.refetch():u==="tests"?y.refetch():u==="outbound"?f.refetch():u==="env"&&h.refetch()},Tt=u=>{if(u===n){fn(u);return}a(u);let R=new URL(window.location.href);R.searchParams.set("section",u),history.replaceState(null,"",R.toString()),Vt(""),it(""),go(""),cr(""),bo(""),Ir({col:null,dir:"asc"}),$r(""),pt(""),K(""),ut({col:null,dir:"asc"}),O(""),Re(""),jr({col:null,dir:"asc"}),Gt(""),vo(""),de({col:null,dir:"asc"}),xo(""),pn(""),dn("")},To=u=>{Dt(u).then(R=>{if(!R){window.prompt("Copy is not available here. Select the token and copy it:",u);return}je(u),setTimeout(()=>je(null),1500)})},nl=u=>m({id:u}).then(()=>l.refetch()),al=u=>{Qe(R=>{let j=new Set(R);return j.has(u)?j.delete(u):j.size<2&&j.add(u),j})},il=u=>b({id:u}).then(()=>c.refetch()),ll=u=>T({id:u}).then(()=>p.refetch()),ul=u=>P({id:u}).then(()=>y.refetch()),cl=()=>{window.confirm("Delete all HTTP profiles?")&&g().then(()=>l.refetch())},pl=()=>{window.confirm("Delete all job profiles?")&&x().then(()=>c.refetch())},dl=()=>{window.confirm("Delete all console profiles?")&&C().then(()=>p.refetch())},fl=()=>{window.confirm("Delete all test profiles?")&&k().then(()=>y.refetch())},ns=()=>{window.confirm("Delete all HTTP, job and console profiles?")&&Promise.all([g(),x(),C()]).then(()=>{l.refetch(),c.refetch(),p.refetch()})},Br=()=>fn(n),as=u=>{jr(R=>R.col===u?{col:u,dir:R.dir==="asc"?"desc":"asc"}:{col:u,dir:"asc"})},Bt=u=>`tab${n===u?" active":""}`,wo=q.filter(u=>{if(Ke&&!u.path.toLowerCase().includes(Ke.toLowerCase())||pe&&u.method!==pe)return!1;if(lt){let R=parseInt(lt);if(!(u.status>=R&&u.status<R+100))return!1}return!(Ht&&(Ht==="lt100"?u.duration>=100:u.duration<parseInt(Ht))||$e==="slow"&&u.duration<500||$e==="many_queries"&&(u.collectors_data?.database?.total_queries??0)<=20||$e==="errors"&&u.status<500||$e==="has_exception"&&!u.collectors_data?.exception)}),yl=oe.col?[...wo].sort((u,R)=>{if(oe.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return oe.dir==="asc"?Ve:-Ve}let j,re;switch(oe.col){case"duration":j=u.duration,re=R.duration;break;case"memory":j=Te(u)??0,re=Te(R)??0;break;case"status":j=u.status,re=R.status;break;case"queries":j=u.collectors_data?.database?.total_queries??0,re=R.collectors_data?.database?.total_queries??0;break;default:return 0}return oe.dir==="asc"?j-re:re-j}):wo,Co=U.filter(u=>!(pr&&!u.path.toLowerCase().includes(pr.toLowerCase())||ct&&Ti(u)!==ct||_&&(_==="lt100"?u.duration>=100:u.duration<parseInt(_)))),ml=ge.col?[...Co].sort((u,R)=>{if(ge.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return ge.dir==="asc"?Ve:-Ve}let j,re;switch(ge.col){case"duration":j=u.duration,re=R.duration;break;case"status":j=u.status,re=R.status;break;default:return 0}return ge.dir==="asc"?j-re:re-j}):Co,is=w.filter(u=>{if(Vr&&!u.url.toLowerCase().includes(Vr.toLowerCase())||_o&&u.method!==_o)return!1;if(Hr)if(Hr==="error"){if(u.status!==0)return!1}else{let R=parseInt(Hr);if(!(u.status>=R&&u.status<R+100))return!1}return!0}),Eo=Q.filter(u=>!(D&&!u.path.toLowerCase().includes(D.toLowerCase())||J==="error"&&u.status!==500||J==="ok"&&u.status===500)),hl=ve.col?[...Eo].sort((u,R)=>{if(ve.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return ve.dir==="asc"?Ve:-Ve}let j,re;switch(ve.col){case"duration":j=u.duration,re=R.duration;break;case"status":j=u.status,re=R.status;break;default:return 0}return ve.dir==="asc"?j-re:re-j}):Eo,Ro=N.filter(u=>!(Je&&!(u.collectors_data?.test?.test_name||u.path).toLowerCase().includes(Je.toLowerCase())||_t==="failed"&&u.status!==500||_t==="passed"&&u.status===500||_t==="pending"&&u.collectors_data?.test?.status!=="pending")),gl=xe.col?[...Ro].sort((u,R)=>{let j,re;if(xe.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return xe.dir==="asc"?Ve:-Ve}switch(xe.col){case"duration":j=u.duration,re=R.duration;break;case"status":j=u.status,re=R.status;break;default:return 0}return xe.dir==="asc"?j-re:re-j}):Ro,yn=!!(Ke||pe||lt||Ht||$e),mn=!!(pr||ct||_),hn=!!(D||J),gn=!!(Je||_t),bl=!!(Vr||_o||Hr),Se=(u,R,j)=>u!==j?t("span",{class:"sort-icon sort-icon--idle",children:"\u21C5"}):t("span",{class:"sort-icon sort-icon--active",children:R==="asc"?"\u25B2":"\u25BC"});return t("div",{class:"container",children:[t("div",{class:"header",children:[t("h1",{children:[t("span",{class:"h1-emoji",children:"\u{1F50D}"})," Rails Profiler"]}),t("p",{children:"Recent profiled requests and jobs"}),e&&t("span",{class:"profiler-version-badge",children:["v",e]})]}),t("div",{class:"profiler-panel profiler-mb-6",children:[t("div",{class:"tabs",children:[t("a",{href:"#",class:Bt("http"),onClick:u=>{u.preventDefault(),Tt("http")},children:"HTTP Requests"}),t("a",{href:"#",class:Bt("jobs"),onClick:u=>{u.preventDefault(),Tt("jobs")},children:"Background Jobs"}),t("a",{href:"#",class:Bt("console"),onClick:u=>{u.preventDefault(),Tt("console")},children:"Console"}),t("a",{href:"#",class:Bt("tests"),onClick:u=>{u.preventDefault(),Tt("tests")},children:"Tests"}),t("div",{style:"flex: 1"}),t("a",{href:"#",class:Bt("runner"),onClick:u=>{u.preventDefault(),Tt("runner")},children:"Test Runner"}),t("a",{href:"#",class:Bt("outbound"),onClick:u=>{u.preventDefault(),Tt("outbound")},children:"Outbound HTTP"}),t("a",{href:"#",class:Bt("env"),onClick:u=>{u.preventDefault(),Tt("env")},children:"Env"})]}),t("div",{class:"profiler-p-4 tab-content active",children:[n==="http"&&(I?t(Ur,{cols:["sm","xs","flex","sm","sm","sm","xs","sm"]}):qe?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:qe})}):q.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No profiles found"}),t("p",{class:"profiler-empty__description",children:"Make some requests to your application to see profiling data"})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-2",children:t("div",{class:"profiler-filter-group",children:wi.map(u=>t("button",{class:`profiler-preset-btn${$e===u.key?" profiler-preset-btn--active":""}`,onClick:()=>el(u.key),children:u.label},u.key))})}),t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search path\u2026",value:Ke,onInput:u=>Vt(u.target.value)}),t("select",{class:"profiler-filter-select",value:pe,onChange:u=>it(u.target.value),children:[t("option",{value:"",children:"All Methods"}),t("option",{value:"GET",children:"GET"}),t("option",{value:"POST",children:"POST"}),t("option",{value:"PUT",children:"PUT"}),t("option",{value:"PATCH",children:"PATCH"}),t("option",{value:"DELETE",children:"DELETE"})]}),t("select",{class:"profiler-filter-select",value:lt,onChange:u=>go(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"200",children:"2xx"}),t("option",{value:"300",children:"3xx"}),t("option",{value:"400",children:"4xx"}),t("option",{value:"500",children:"5xx"})]}),t("select",{class:"profiler-filter-select",value:Ht,onChange:u=>cr(u.target.value),children:[t("option",{value:"",children:"All Durations"}),t("option",{value:"lt100",children:"<100ms"}),t("option",{value:"100",children:"\u2265100ms"}),t("option",{value:"500",children:"\u2265500ms"})]})]}),t("div",{class:"profiler-filter-group",children:[yn&&t("span",{class:"profiler-filter-count",children:[wo.length," / ",q.length]}),Ee.size===2&&t("a",{class:"btn btn-secondary btn-sm",href:`${Lr}/compare?a=${encodeURIComponent(Array.from(Ee)[0])}&b=${encodeURIComponent(Array.from(Ee)[1])}`,children:"Compare 2 profiles"}),Ee.size===1&&t("span",{class:"profiler-text--xs profiler-text--muted",children:"Select 1 more to compare"}),t("button",{class:`btn-refresh${I?" btn-refresh--spinning":""}`,onClick:Br,disabled:I,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:cl,title:"Delete HTTP profiles",children:"Clear"}),t("button",{class:"btn btn-danger btn-sm",onClick:ns,title:"Delete all HTTP and job profiles",children:"Clear All"})]})]}),wo.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{style:"width:32px"}),t("th",{class:`sortable${oe.col==="date"?" sortable--active":""}`,onClick:()=>Gr("date"),children:["Time ",Se(oe.col,oe.dir,"date")]}),t("th",{children:"Method"}),t("th",{children:"Path"}),t("th",{class:`sortable${oe.col==="duration"?" sortable--active":""}`,onClick:()=>Gr("duration"),children:["Duration ",Se(oe.col,oe.dir,"duration")]}),t("th",{class:`sortable${oe.col==="queries"?" sortable--active":""}`,onClick:()=>Gr("queries"),children:["Queries ",Se(oe.col,oe.dir,"queries")]}),t("th",{class:`sortable${oe.col==="memory"?" sortable--active":""}`,onClick:()=>Gr("memory"),title:ot,children:["Allocations ",Se(oe.col,oe.dir,"memory")]}),t("th",{class:`sortable${oe.col==="status"?" sortable--active":""}`,onClick:()=>Gr("status"),children:["Status ",Se(oe.col,oe.dir,"status")]}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:yl.map(u=>{let R=Ee.has(u.token),j=!R&&Ee.size>=2;return t("tr",{class:R?"profiler-row--selected":"",children:[t("td",{children:t("input",{type:"checkbox",checked:R,disabled:j,onChange:()=>al(u.token),title:j?"Deselect another profile first":"Select for comparison"})}),t("td",{children:fo(u.started_at)}),t("td",{children:t("span",{class:Fc(u.method),children:u.method})}),t("td",{children:[t("a",{href:`${Lr}/profiles/${u.token}`,children:u.path}),u.gem_version&&u.gem_version!==e&&t("span",{class:"profiler-version-warn",title:`Captur\xE9 avec v${u.gem_version} (actuel : v${e})`,children:"\u26A0\uFE0F"})]}),t("td",{children:t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:u.collectors_data?.database?.total_queries??"-"}),t("td",{children:rt(Te(u))}),t("td",{children:t("span",{class:Oc(u.status),children:u.status})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>nl(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),Fe&&!yn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:tl,disabled:Ce,children:Ce?"Loading\u2026":"Load more"})})]})),n==="jobs"&&(Z?t(Ur,{cols:["sm","flex","md","sm","xs","xs","sm"]}):Ne?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:Ne})}):U.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No job profiles found"}),t("p",{class:"profiler-empty__description",children:"Run background jobs in your application to see profiling data"})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search job class\u2026",value:pr,onInput:u=>$r(u.target.value)}),t("select",{class:"profiler-filter-select",value:ct,onChange:u=>pt(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"running",children:"Running"}),t("option",{value:"completed",children:"Completed"}),t("option",{value:"failed",children:"Failed"})]}),t("select",{class:"profiler-filter-select",value:_,onChange:u=>K(u.target.value),children:[t("option",{value:"",children:"All Durations"}),t("option",{value:"lt100",children:"<100ms"}),t("option",{value:"100",children:"\u2265100ms"}),t("option",{value:"500",children:"\u2265500ms"})]})]}),t("div",{class:"profiler-filter-group",children:[mn&&t("span",{class:"profiler-filter-count",children:[Co.length," / ",U.length]}),t("button",{class:`btn-refresh${Z?" btn-refresh--spinning":""}`,onClick:Br,disabled:Z,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:pl,title:"Delete job profiles",children:"Clear"}),t("button",{class:"btn btn-danger btn-sm",onClick:ns,title:"Delete all HTTP and job profiles",children:"Clear All"})]})]}),Co.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{class:`sortable${ge.col==="date"?" sortable--active":""}`,onClick:()=>ss("date"),children:["Time ",Se(ge.col,ge.dir,"date")]}),t("th",{children:"Job Class"}),t("th",{children:"Queue"}),t("th",{class:`sortable${ge.col==="duration"?" sortable--active":""}`,onClick:()=>ss("duration"),children:["Duration ",Se(ge.col,ge.dir,"duration")]}),t("th",{class:`sortable${ge.col==="status"?" sortable--active":""}`,onClick:()=>ss("status"),children:["Status ",Se(ge.col,ge.dir,"status")]}),t("th",{children:"Executions"}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:ml.map(u=>{let R=u.collectors_data?.job,j=Ti(u);return t("tr",{children:[t("td",{children:fo(u.started_at)}),t("td",{children:[t("a",{href:`${Lr}/profiles/${u.token}`,children:u.path}),u.gem_version&&u.gem_version!==e&&t("span",{class:"profiler-version-warn",title:`Captur\xE9 avec v${u.gem_version} (actuel : v${e})`,children:"\u26A0\uFE0F"})]}),t("td",{children:t("span",{class:"profiler-text--xs profiler-text--mono",children:R?.queue||"-"})}),t("td",{children:j==="running"?t("span",{class:"profiler-text--muted",children:"-"}):t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:j==="running"?t("span",{class:"badge-info",children:[t("span",{class:"profiler-spinner","aria-hidden":"true",children:"\u25D0"})," Running"]}):t("span",{class:j==="failed"?"badge-error":"badge-success",children:j==="failed"?"\u2717 Failed":"\u2713 Completed"})}),t("td",{children:R?.executions??"-"}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>il(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),nt&&!mn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:rl,disabled:at,children:at?"Loading\u2026":"Load more"})})]})),n==="console"&&(B?t(Ur,{cols:["sm","flex","sm","sm","xs","sm"]}):Ie?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:Ie})}):Q.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No console profiles found"}),t("p",{class:"profiler-empty__description",children:["Run expressions in ",t("code",{children:"rails console"})," to see profiling data"]})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search expression\u2026",value:D,onInput:u=>O(u.target.value)}),t("select",{class:"profiler-filter-select",value:J,onChange:u=>Re(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"ok",children:"OK"}),t("option",{value:"error",children:"Error"})]})]}),t("div",{class:"profiler-filter-group",children:[hn&&t("span",{class:"profiler-filter-count",children:[Eo.length," / ",Q.length]}),t("button",{class:`btn-refresh${B?" btn-refresh--spinning":""}`,onClick:Br,disabled:B,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:dl,title:"Delete console profiles",children:"Clear"}),t("button",{class:"btn btn-danger btn-sm",onClick:ns,title:"Delete all profiles",children:"Clear All"})]})]}),Eo.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{class:`sortable${ve.col==="date"?" sortable--active":""}`,onClick:()=>as("date"),children:["Time ",Se(ve.col,ve.dir,"date")]}),t("th",{children:"Expression"}),t("th",{class:`sortable${ve.col==="duration"?" sortable--active":""}`,onClick:()=>as("duration"),children:["Duration ",Se(ve.col,ve.dir,"duration")]}),t("th",{children:"SQL"}),t("th",{class:`sortable${ve.col==="status"?" sortable--active":""}`,onClick:()=>as("status"),children:["Status ",Se(ve.col,ve.dir,"status")]}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:hl.map(u=>{let R=u.status===500;return t("tr",{children:[t("td",{children:fo(u.started_at)}),t("td",{children:[t("a",{href:`${Lr}/profiles/${u.token}`,class:"profiler-text--mono",style:"font-size:0.85em;",children:u.path.length>60?u.path.slice(0,60)+"\u2026":u.path}),u.gem_version&&u.gem_version!==e&&t("span",{class:"profiler-version-warn",title:`Captur\xE9 avec v${u.gem_version} (actuel : v${e})`,children:"\u26A0\uFE0F"})]}),t("td",{children:t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:u.collectors_data?.database?.total_queries??"-"}),t("td",{children:t("span",{class:R?"badge-error":"badge-success",children:R?"\u2717 Error":"\u2713 OK"})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>ll(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),S&&!hn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:ol,disabled:ur,children:ur?"Loading\u2026":"Load more"})})]})),n==="tests"&&(ce?t(Ur,{cols:["sm","flex","md","sm","xs","sm"]}):De?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:De})}):N.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No test profiles found"}),t("p",{class:"profiler-empty__description",children:["Add ",t("code",{children:"Profiler::TestHelpers::RSpecSupport.install(config)"})," to your spec_helper.rb and run your tests. Or use the ",t("a",{href:"#",style:"color:var(--profiler-accent,#06b6d4)",onClick:u=>{u.preventDefault(),Tt("runner")},children:"Test Runner"})," tab to run tests from here."]})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search test name\u2026",value:Je,onInput:u=>Gt(u.target.value)}),t("select",{class:"profiler-filter-select",value:_t,onChange:u=>vo(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"passed",children:"Passed"}),t("option",{value:"failed",children:"Failed"}),t("option",{value:"pending",children:"Pending"})]})]}),t("div",{class:"profiler-filter-group",children:[gn&&t("span",{class:"profiler-filter-count",children:[Ro.length," / ",N.length]}),t("button",{class:`btn-refresh${ce?" btn-refresh--spinning":""}`,onClick:Br,disabled:ce,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:fl,title:"Delete test profiles",children:"Clear All"})]})]}),Ro.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{class:`sortable${xe.col==="date"?" sortable--active":""}`,onClick:()=>de(u=>({col:"date",dir:u.col==="date"&&u.dir==="asc"?"desc":"asc"})),children:["Time ",Se(xe.col,xe.dir,"date")]}),t("th",{children:"Test Name"}),t("th",{children:"File"}),t("th",{class:`sortable${xe.col==="duration"?" sortable--active":""}`,onClick:()=>de(u=>({col:"duration",dir:u.col==="duration"&&u.dir==="asc"?"desc":"asc"})),children:["Duration ",Se(xe.col,xe.dir,"duration")]}),t("th",{children:"Queries"}),t("th",{class:`sortable${xe.col==="status"?" sortable--active":""}`,onClick:()=>de(u=>({col:"status",dir:u.col==="status"&&u.dir==="asc"?"desc":"asc"})),children:["Status ",Se(xe.col,xe.dir,"status")]}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:gl.map(u=>{let R=u.collectors_data?.test,j=u.status===500,re=R?.status||(j?"failed":"passed");return t("tr",{children:[t("td",{children:fo(u.started_at)}),t("td",{style:"max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap",children:t("a",{href:`${Lr}/profiles/${u.token}`,title:R?.test_name||u.path,children:R?.test_name||u.path})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:R?.test_file||"-"}),t("td",{children:t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:u.collectors_data?.database?.total_queries??"-"}),t("td",{children:t("span",{class:re==="failed"?"badge-error":re==="pending"?"badge-warning":"badge-success",children:re==="failed"?"\u2717 Failed":re==="pending"?"\u23F8 Pending":"\u2713 Passed"})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>ul(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),H&&!gn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:sl,disabled:L,children:L?"Loading\u2026":"Load more"})})]})),n==="runner"&&t(Zo,{}),n==="outbound"&&(fe?t(Ur,{cols:["sm","xs","flex","sm","xs"],rows:4}):be?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:be})}):w.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No outbound HTTP requests found"}),t("p",{class:"profiler-empty__description",children:"Make requests to external services to see outbound HTTP data"})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search URL\u2026",value:Vr,onInput:u=>xo(u.target.value)}),t("select",{class:"profiler-filter-select",value:_o,onChange:u=>pn(u.target.value),children:[t("option",{value:"",children:"All Methods"}),t("option",{value:"GET",children:"GET"}),t("option",{value:"POST",children:"POST"}),t("option",{value:"PUT",children:"PUT"}),t("option",{value:"PATCH",children:"PATCH"}),t("option",{value:"DELETE",children:"DELETE"})]}),t("select",{class:"profiler-filter-select",value:Hr,onChange:u=>dn(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"200",children:"2xx"}),t("option",{value:"300",children:"3xx"}),t("option",{value:"400",children:"4xx"}),t("option",{value:"500",children:"5xx"}),t("option",{value:"error",children:"Error"})]})]}),t("div",{class:"profiler-filter-group",children:[bl&&t("span",{class:"profiler-filter-count",children:[is.length," / ",w.length]}),t("button",{class:`btn-refresh${fe?" btn-refresh--spinning":""}`,onClick:Br,disabled:fe,title:"Refresh",children:"\u21BA"})]})]}),t("p",{class:"profiler-text--xs profiler-text--muted profiler-mb-3",children:[w.length," outbound request",w.length!==1?"s":""," across all profiles. Click a request to expand headers and body."]}),is.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):is.map((u,R)=>t("div",{style:"margin-bottom:4px",children:[t("div",{class:"profiler-text--xs profiler-text--muted",style:"margin-bottom:2px",children:[fo(u.profile_started_at)," \xB7 Profile: ",t("a",{href:`${Lr}/profiles/${u.profile_token}`,children:[u.profile_token.substring(0,8),"\u2026"]})]}),t(Xs,{req:u,index:R,threshold:500})]},R))]})),n==="env"&&(Y?t(Ur,{cols:["sm","flex","sm","sm"],rows:8}):we?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:we})}):t(st,{envData:F}))]})]})]})}function Ei(){let{data:e}=Qa({query:{retry:!1,refetchOnWindowFocus:!1}}),r=e?.slaves??[],o=Oa();return r.length===0?null:t("div",{class:"profiler-selector",style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 12px",background:"var(--profiler-bg-secondary, #f5f5f5)",borderBottom:"1px solid var(--profiler-border, #e0e0e0)"},children:[t("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--profiler-text-secondary, #666)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Profiler"}),t("select",{value:o??"__local__",onChange:a=>{let i=a.target.value;Da(i==="__local__"?null:i)},style:{fontSize:"13px",padding:"2px 6px",borderRadius:"4px",border:"1px solid var(--profiler-border, #ccc)",background:"var(--profiler-bg, #fff)",color:"var(--profiler-text, #333)",cursor:"pointer"},children:[t("option",{value:"__local__",children:"Local (master)"}),r.map(a=>t("option",{value:a.name,disabled:a.status==="offline",children:[a.name," ",a.status==="offline"?"(offline)":""]},a.name))]}),o&&t("span",{style:{fontSize:"11px",color:"var(--profiler-text-secondary, #888)",fontStyle:"italic"},children:"Viewing slave data via proxy"})]})}function Dc(e){let r=e.headers??{},o=e.params??{},s=e.request_body,n=[`curl -X ${e.method}`];Object.entries(r).filter(([i])=>i!=="User-Agent").forEach(([i,l])=>n.push(` -H '${i}: ${l}'`)),["POST","PUT","PATCH"].includes(e.method)&&(s&&s.length>0?n.push(` -d '${s.replace(/'/g,"'\\''")}'`):Object.keys(o).length>0&&((r["Content-Type"]??"").includes("application/json")?n.push(` -d '${JSON.stringify(o).replace(/'/g,"'\\''")}'`):Object.entries(o).forEach(([l,c])=>n.push(` --data-urlencode '${l}=${c}'`))));let a=`http://localhost:3000${e.path}`;return e.method==="GET"&&Object.keys(o).length>0&&(a+="?"+Object.entries(o).map(([i,l])=>`${encodeURIComponent(i)}=${encodeURIComponent(String(l))}`).join("&")),n.push(` '${a}'`),n.join(` \\
|
|
11
|
+
# comment`,rows:6,style:"width:100%;font-family:monospace;font-size:12px;padding:6px 8px;border:1px solid var(--profiler-border);border-radius:4px;background:var(--profiler-bg);color:var(--profiler-text);resize:vertical;box-sizing:border-box;"}),t("div",{class:"profiler-flex profiler-flex--gap-2 profiler-mt-2",style:"align-items:center;",children:[Qe>0&&t("span",{class:"profiler-text--xs profiler-text--muted",children:[Qe," variable",Qe!==1?"s":""," to import"]}),Ke>0&&t("span",{class:"profiler-text--xs profiler-text--muted",children:[Ke," masked (",hi,") skipped"]}),t("button",{onClick:Vt,disabled:N||Qe===0,style:"background:var(--profiler-accent);border:none;cursor:pointer;color:#fff;font-size:11px;padding:4px 12px;border-radius:4px;margin-left:auto;",children:"Apply"})]})]}),t("div",{class:"profiler-flex profiler-flex--gap-4 profiler-mb-4",children:[t("div",{class:"profiler-stat-card",children:[t("div",{class:"profiler-stat-card__value",children:c}),t("div",{class:"profiler-stat-card__label",children:"Total vars"})]}),y&&t("div",{class:"profiler-stat-card",children:[t("div",{class:"profiler-stat-card__value",children:ut.length}),t("div",{class:"profiler-stat-card__label",children:"Matching"})]})]}),t("div",{class:"profiler-flex profiler-flex--gap-2 profiler-mb-3",children:t("input",{type:"text",class:"profiler-filter-input",placeholder:"Filter by key or value\u2026",value:y,onInput:_=>f(_.target.value),style:"flex:1;"})}),t("table",{class:"profiler-table",children:[t("thead",{children:t("tr",{children:[t("th",{style:"width:32%",children:"Key"}),t("th",{children:"Value"}),!Y&&t("th",{style:"width:120px;text-align:right;"})]})}),t("tbody",{children:[ve.map(([_,K])=>{let D=h.has(_);return t(M,{children:[t("tr",{onClick:()=>ur(_),style:"cursor:pointer;background:var(--profiler-bg-subtle,rgba(0,0,0,0.03));",children:t("td",{colspan:Y?2:3,style:"padding:4px 8px;",children:[t("span",{style:"font-size:11px;font-weight:600;color:var(--profiler-text-muted);letter-spacing:0.05em;font-family:monospace;",children:[D?"\u25B6":"\u25BC"," ",_,"_"]}),t("span",{style:"font-size:10px;color:var(--profiler-text-muted);margin-left:6px;",children:K.length})]})},`group-${_}`),!D&&K.map(([O,J])=>{let Re=Z.has(O),Je=g===O,Gt=ce===O,_t=ce===`__key__${O}`,vo=o[O]!==void 0&&o[O]!==J,xe=o[O]===void 0,de=i[O];return t("tr",{style:de?"border-left:3px solid var(--profiler-accent);":vo?"border-left:3px solid #f59e0b;":xe?"border-left:3px solid var(--profiler-success,#22c55e);":"",children:[t("td",{children:t("div",{class:"profiler-flex",style:"align-items:center;gap:4px;",children:[t("code",{class:"profiler-text--xs profiler-text--mono",children:O}),t("button",{onClick:()=>at(O,`__key__${O}`),title:"Copy key",style:`${ct}${_t?"color:var(--profiler-success,#22c55e);opacity:1;":""}`,children:_t?"\u2713":"\u2398"})]})}),t("td",{children:Je?t("div",{class:"profiler-flex",style:"align-items:center;gap:2px;",children:[en(x)&&t("span",{style:"font-family:monospace;font-size:12px;color:var(--profiler-text-muted);opacity:0.5;flex-shrink:0;",children:'"'}),t("input",{ref:we,type:"text",value:x,onInput:xo=>T(xo.target.value),onKeyDown:$e,disabled:N,style:"flex:1;font-family:monospace;font-size:12px;padding:2px 6px;border:1px solid var(--profiler-accent);border-radius:4px;background:var(--profiler-bg);color:var(--profiler-text);"}),en(x)&&t("span",{style:"font-family:monospace;font-size:12px;color:var(--profiler-text-muted);opacity:0.5;flex-shrink:0;",children:'"'})]}):bi(J)?t(M,{children:[t("div",{class:"profiler-flex",style:"align-items:center;gap:8px;",children:[t(gi,{value:J}),t("button",{onClick:()=>!Y&&!N&&Ht(O,J),disabled:N||Y,title:`Click to set ${/^(true|yes)$/i.test(J)?"false":"true"}`,style:`position:relative;display:inline-block;width:36px;height:20px;border-radius:10px;border:none;cursor:${Y||N?"default":"pointer"};padding:0;transition:background 0.2s;background:${/^(true|yes)$/i.test(J)?"var(--profiler-accent)":"var(--profiler-border,#d1d5db)"};flex-shrink:0;`,children:t("span",{style:`position:absolute;top:3px;width:14px;height:14px;border-radius:50%;background:#fff;transition:left 0.2s;left:${/^(true|yes)$/i.test(J)?"19px":"3px"};`})}),t("span",{class:"profiler-text--xs profiler-text--mono",style:"color:var(--profiler-text-muted);",children:J}),t("button",{onClick:()=>at(J,O),title:"Copy value",style:`${ct}${Gt?"color:var(--profiler-success,#22c55e);opacity:1;":""}`,children:Gt?"\u2713":"\u2398"})]}),de&&t("div",{style:"font-size:10px;color:var(--profiler-accent);margin-top:2px;font-family:monospace;",children:["workers \u2190 ",de.value==="__profiler_deleted__"?"(deleted)":de.value," \xB7 original: ",de.original??"(unset)"]})]}):t(M,{children:[t("div",{class:"profiler-flex",style:"align-items:center;gap:4px;",children:[t(gi,{value:J}),t("span",{class:"profiler-text--xs profiler-text--mono",onClick:()=>!Y&&!Je&&pe(O),title:Y?void 0:"Click to edit",style:`word-break:break-all;flex:1;${Y?"":"cursor:pointer;"}`,children:Re?en(J)?t(M,{children:[t("span",{style:"color:var(--profiler-text-muted);opacity:0.5;",children:'"'}),J,t("span",{style:"color:var(--profiler-text-muted);opacity:0.5;",children:'"'})]}):J:"\u2022".repeat(Math.min(J.length,20))}),t("button",{onClick:()=>Ce(O),title:Re?"Hide value":"Show value",style:`${ct}${Re?"opacity:1;color:var(--profiler-accent);":""}`,children:Re?"\u{1F441}":"\u{1F648}"}),t("button",{onClick:()=>at(J,O),title:"Copy value",style:`${ct}${Gt?"color:var(--profiler-success,#22c55e);opacity:1;":""}`,children:Gt?"\u2713":"\u2398"})]}),de&&t("div",{style:"font-size:10px;color:var(--profiler-accent);margin-top:2px;font-family:monospace;",children:["workers \u2190 ",de.value==="__profiler_deleted__"?"(deleted)":Re?de.value:"\u2022".repeat(Math.min((de.value??"").length,20))," \xB7 original: ",de.original==null?"(unset)":Re?de.original:"\u2022".repeat(Math.min(de.original.length,20))]})]})}),!Y&&t("td",{style:"text-align:right;white-space:nowrap;",children:Je?t(M,{children:[t("button",{onClick:lt,disabled:N,title:"Save",style:"background:none;border:none;cursor:pointer;color:var(--profiler-success,#22c55e);font-size:14px;padding:0 4px;",children:"\u2713"}),t("button",{onClick:it,disabled:N,title:"Cancel",style:"background:none;border:none;cursor:pointer;color:var(--profiler-text-muted);font-size:14px;padding:0 4px;",children:"\u2717"})]}):t(M,{children:[t("button",{onClick:()=>pe(O),disabled:N,title:"Edit",style:"background:none;border:none;cursor:pointer;color:var(--profiler-accent);font-size:14px;padding:0 4px;",children:"\u270E"}),de&&t("button",{onClick:()=>bo(O),disabled:N,title:`Reset to original: ${de.original??"(unset)"}`,style:"background:none;border:none;cursor:pointer;color:var(--profiler-warning,#f59e0b);font-size:14px;padding:0 4px;",children:"\u21A9"}),t("button",{onClick:()=>go(O),disabled:N,title:"Delete",style:"background:none;border:none;cursor:pointer;color:var(--profiler-error,#ef4444);font-size:14px;padding:0 4px;",children:"\u2715"})]})})]},O)})]})}),!Y&&t("tr",{children:[t("td",{children:t("input",{type:"text",value:C,onInput:_=>P(_.target.value),onKeyDown:_=>_.key==="Enter"&&cr(),placeholder:"NEW_KEY",disabled:N,style:$r})}),t("td",{children:t("input",{type:"text",value:k,onInput:_=>q(_.target.value),onKeyDown:_=>_.key==="Enter"&&cr(),placeholder:"value",disabled:N,style:$r})}),t("td",{style:"text-align:right;",children:t("button",{onClick:cr,disabled:N||!C.trim(),style:"background:var(--profiler-accent);border:none;cursor:pointer;color:#fff;font-size:11px;padding:3px 8px;border-radius:4px;",children:"Add"})})]})]})]})]})}function vi({tree:e,selected:r,onToggleFile:o,onToggleDir:s}){let[n,a]=v(new Set),i=c=>{a(p=>{let y=new Set(p);return y.has(c)?y.delete(c):y.add(c),y})},l=c=>{let p=c.filter(y=>r.has(y)).length;return p===0?"none":p===c.length?"all":"partial"};return t("div",{class:"profiler-text--xs profiler-text--mono",style:"overflow-y: auto; height: 100%",children:e.map(({directory:c,files:p})=>{let y=p.map(m=>m.path),f=l(y),h=n.has(c);return t("div",{style:"margin-bottom: 4px",children:[t("div",{style:"display: flex; align-items: center; gap: 6px; padding: 3px 6px; cursor: pointer; border-radius: 4px; background: var(--profiler-bg-secondary, rgba(255,255,255,0.05))",onClick:()=>i(c),children:[t("input",{type:"checkbox",checked:f==="all",ref:m=>{m&&(m.indeterminate=f==="partial")},onClick:m=>{m.stopPropagation(),s(c,y)},style:"cursor: pointer; flex-shrink: 0"}),t("span",{style:"color: var(--profiler-text-muted, #888); flex-shrink: 0",children:h?"\u25B6":"\u25BC"}),t("span",{style:"color: var(--profiler-accent, #06b6d4); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap",title:c,children:[c,"/"]}),t("span",{style:"color: var(--profiler-text-muted, #888); margin-left: auto; flex-shrink: 0",children:["(",p.length,")"]})]}),!h&&p.map(m=>t("div",{style:"display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 24px; cursor: pointer; border-radius: 4px",onClick:()=>o(m.path),children:[t("input",{type:"checkbox",checked:r.has(m.path),onClick:g=>{g.stopPropagation(),o(m.path)},style:"cursor: pointer; flex-shrink: 0"}),t("span",{style:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--profiler-text, #e2e8f0)",title:m.path,children:m.name})]},m.path))]},c)})})}function Sc(e){return e==="passed"?"var(--profiler-success, #10b981)":e==="failed"?"var(--profiler-error, #ef4444)":e==="running"?"var(--profiler-accent, #06b6d4)":e==="killed"||e==="signaled"||e==="error"?"var(--profiler-warning, #f59e0b)":"var(--profiler-text-muted, #888)"}function Ac(e){return{pending:"\u23F3 Pending",running:"\u25CF Running\u2026",passed:"\u2713 Passed",failed:"\u2717 Failed",killed:"\u25A0 Killed",signaled:"\u26A1 Ended by a signal",error:"\u26A0 Error"}[e]||e}function Mc(e){let r={0:"",1:"font-weight:bold",31:"color:var(--ansi-red)",32:"color:var(--ansi-green)",33:"color:var(--ansi-yellow)",34:"color:var(--ansi-blue)",35:"color:var(--ansi-purple)",36:"color:var(--ansi-cyan)"},o=[],s="",n=e.split(/(\x1b\[[0-9;]*m)/);for(let a of n)if(a.startsWith("\x1B[")&&a.endsWith("m")){let i=a.slice(2,-1).split(";");if(i.includes("0"))s="";else{let l=i.map(c=>r[c]??"").filter(Boolean);s=[...s?[s]:[],...l].join(";")}}else a.length>0&&o.push({text:a,style:s});return o}function qc({text:e}){let r=Mc(e);return r.length===0?t("span",{style:"color:var(--profiler-text-muted)",children:"No output yet\u2026"}):t(M,{children:r.map((o,s)=>o.style?t("span",{style:o.style,children:o.text},s):t("span",{children:o.text},s))})}function xi({run:e}){let r=me(null);return G(()=>{r.current&&e?.status==="running"&&(r.current.scrollTop=r.current.scrollHeight)},[e?.output]),e?t("div",{style:"display: flex; flex-direction: column; height: 100%; gap: 12px",children:[t("div",{style:"display: flex; align-items: center; gap: 12px; flex-shrink: 0",children:[t("span",{style:`font-weight: 600; color: ${Sc(e.status)}`,children:Ac(e.status)}),e.duration!=null&&t("span",{class:"profiler-text--xs profiler-text--muted",children:[(e.duration/1e3).toFixed(1),"s"]}),(e.status==="passed"||e.status==="failed")&&t("a",{href:"/_profiler?section=tests",class:"profiler-text--xs",style:"color: var(--profiler-accent, #06b6d4); margin-left: auto",children:"View in Profiler \u2192"})]}),t("pre",{ref:r,style:"flex: 1; overflow-y: auto; background: var(--profiler-terminal-bg); color: var(--profiler-terminal-text); padding: 14px 16px; border-radius: 6px; font-family: var(--profiler-font-mono); font-size: 12px; line-height: 1.65; margin: 0; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--profiler-border)",children:t(qc,{text:e.output||""})}),e.files.length>0&&t("div",{class:"profiler-text--xs profiler-text--muted",style:"flex-shrink: 0",children:[e.files.length," file",e.files.length!==1?"s":""," \xB7 ",e.framework]})]}):t("div",{class:"profiler-empty",style:"height: 100%; display: flex; align-items: center; justify-content: center",children:t("div",{children:[t("div",{class:"profiler-empty__title",style:"font-size: 1.1rem",children:"Select files and click Run"}),t("p",{class:"profiler-empty__description",children:"Test output will appear here in real time"})]})})}var _i="/_profiler";function Zo(){let[e,r]=v(""),[o,s]=v(new Set),[n,a]=v(null),[i,l]=v(!1),[c,p]=v(null),{data:y,isLoading:f,refetch:h}=ri(e?{framework:e}:{},{query:{refetchOnWindowFocus:!1}}),{mutateAsync:m}=oi(),{mutateAsync:g}=si(),b=y?.frameworks??[],x=y?.tree??[];G(()=>{!e&&b.length>0&&r(b[0])},[b]);let T=ar(F=>{s(new Set),h()},[h]);G(()=>{if(!n||!i)return;if(["passed","failed","killed","signaled","error"].includes(n.status)){l(!1);return}let F=new EventSource(`${_i}/api/test_runner/runs/${n.id}/stream`);return F.addEventListener("output",I=>{try{let Z=JSON.parse(I.data);a(B=>B&&{...B,output:(B.output||"")+Z.chunk})}catch{}}),F.addEventListener("done",I=>{try{let Z=JSON.parse(I.data);a(B=>B&&{...B,status:Z.status})}catch{}l(!1),F.close()}),F.onerror=()=>{F.readyState===EventSource.CLOSED&&fetch(`${_i}/api/test_runner/runs/${n.id}`).then(I=>{if(!I.ok)throw new Error(`HTTP ${I.status}`);return I.json()}).then(I=>{I&&Array.isArray(I.files)&&a(I),l(!1)}).catch(()=>l(!1))},()=>F.close()},[n?.id,i]);let C=F=>{r(F),T(F)},P=F=>{s(I=>{let Z=new Set(I);return Z.has(F)?Z.delete(F):Z.add(F),Z})},k=(F,I)=>{s(Z=>{let B=new Set(Z);return I.every(fe=>B.has(fe))?I.forEach(fe=>B.delete(fe)):I.forEach(fe=>B.add(fe)),B})},q=()=>{let F=x.flatMap(I=>I.files.map(Z=>Z.path));s(new Set(F))},U=()=>s(new Set),Q=async()=>{if(!(o.size===0||i)){p(null);try{let F=await m({data:{files:Array.from(o),framework:e}});a(F),l(!0)}catch(F){p(F instanceof Error&&F.message?F.message:"Failed to start test run")}}},N=async()=>{if(n)try{await g({id:n.id}),l(!1),a(F=>F&&{...F,status:"killed"})}catch{}},w=x.reduce((F,I)=>F+I.files.length,0);return t("div",{children:[c&&t("div",{style:"color: var(--profiler-error, #ef4444); background: rgba(239,68,68,0.1); border: 1px solid var(--profiler-error, #ef4444); border-radius: 4px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px",children:c}),t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:b.length>0&&b.map(F=>t("button",{class:`profiler-preset-btn${e===F?" profiler-preset-btn--active":""}`,onClick:()=>C(F),disabled:i,children:F==="rspec"?"RSpec":"Minitest"},F))}),t("div",{class:"profiler-filter-group",style:"margin-left: auto",children:[t("span",{class:"profiler-text--xs profiler-text--muted",children:[o.size," / ",w," selected"]}),t("button",{class:"btn btn-secondary btn-sm",onClick:q,disabled:i||f,children:"All"}),t("button",{class:"btn btn-secondary btn-sm",onClick:U,disabled:i,children:"None"}),i?t("button",{class:"btn btn-danger btn-sm",onClick:N,children:"\u25A0 Stop"}):t("button",{class:"btn btn-sm",style:"background: var(--profiler-accent, #06b6d4); color: #000; font-weight: 600",onClick:Q,disabled:o.size===0,children:["\u25B6 Run Selected (",o.size,")"]})]})]}),t("div",{style:"display: grid; grid-template-columns: 260px 1fr; height: 460px; border: 1px solid var(--profiler-border, rgba(255,255,255,0.1)); border-radius: 6px; overflow: hidden",children:[t("div",{style:"border-right: 1px solid var(--profiler-border, rgba(255,255,255,0.1)); overflow-y: auto; padding: 8px",children:f?t("div",{class:"profiler-text--xs profiler-text--muted",style:"padding: 8px",children:"Loading files\u2026"}):x.length===0?t("div",{class:"profiler-text--xs profiler-text--muted",style:"padding: 8px",children:["No ",e," test files found"]}):t(vi,{tree:x,selected:o,onToggleFile:P,onToggleDir:k})}),t("div",{style:"overflow: hidden; display: flex; flex-direction: column",children:t(xi,{run:n})})]})]})}var Lr="/_profiler";function Ur({cols:e,rows:r=6}){return t("div",{children:Array.from({length:r}).map((o,s)=>t("div",{class:"profiler-skeleton__row",children:e.map((n,a)=>t("div",{class:`profiler-skeleton__cell profiler-skeleton__cell--${n}`},a))},s))})}function Fc(e){return{GET:"badge-info",POST:"badge-success",PUT:"badge-warning",PATCH:"badge-warning",DELETE:"badge-error"}[e]||"badge-default"}function Oc(e){return e>=200&&e<300?"badge-success":e>=300&&e<400?"badge-info":e>=400&&e<500?"badge-warning":e>=500?"badge-error":"badge-default"}function Xo(e){return e>=500?"badge-error":e>=100?"badge-warning":"badge-success"}function Ti(e){let r=e.collectors_data?.job?.status;return r||(e.status===500?"failed":"completed")}function fo(e){return new Date(e).toLocaleTimeString("en",{hour12:!1})}var wi=[{key:"slow",label:"Slow"},{key:"many_queries",label:"Many queries"},{key:"errors",label:"Errors"},{key:"has_exception",label:"Has exception"}];function Ci(){let e=Be(),r=new URLSearchParams(window.location.search),o=()=>{let u=r.get("section");return u==="http"||u==="jobs"||u==="console"||u==="tests"||u==="runner"||u==="outbound"||u==="env"?u:"http"},s=()=>{let u=r.get("sort"),R=r.get("dir");return{col:u==="date"||u==="duration"||u==="memory"||u==="status"||u==="queries"?u:null,dir:R==="desc"?"desc":"asc"}},[n,a]=v(o),i=(u,R)=>({query:{enabled:n===u,queryFn:({pageParam:j=0,signal:re})=>R(j,re),getNextPageParam:j=>j.has_more?j.offset+j.limit:void 0,initialPageParam:0,refetchOnWindowFocus:!1}}),l=Za({limit:50},i("http",(u,R)=>Jo({limit:50,offset:u},R))),c=Ba({limit:50},i("jobs",(u,R)=>Js({limit:50,offset:u},R))),p=Ka({limit:50},i("console",(u,R)=>Hs({limit:50,offset:u},R))),y=ni({limit:50},i("tests",(u,R)=>zs({limit:50,offset:u},R))),f=Wa({query:{enabled:n==="outbound",refetchOnWindowFocus:!1}}),h=Na({query:{enabled:n==="env",refetchOnWindowFocus:!1}}),{mutateAsync:m}=Ya(),{mutateAsync:g}=ti(),{mutateAsync:b}=Ja(),{mutateAsync:x}=za(),{mutateAsync:T}=La(),{mutateAsync:C}=Ua(),{mutateAsync:P}=ai(),{mutateAsync:k}=ii(),q=co(l.data?.pages.flatMap(u=>u.profiles)??[]),U=co(c.data?.pages.flatMap(u=>u.profiles)??[]),Q=co(p.data?.pages.flatMap(u=>u.profiles)??[]),N=co(y.data?.pages.flatMap(u=>u.profiles)??[]),w=f.data??[],F=h.data,I=l.isLoading,Z=c.isLoading,B=p.isLoading,ce=y.isLoading,fe=f.isLoading,Y=h.isLoading,qe=l.error?.message??null,Ne=c.error?.message??null,Ie=p.error?.message??null,De=y.error?.message??null,be=f.error?.message??null,we=h.error?.message??null,Fe=!!l.hasNextPage,nt=!!c.hasNextPage,S=!!p.hasNextPage,H=!!y.hasNextPage,Ce=l.isFetchingNextPage,at=c.isFetchingNextPage,ur=p.isFetchingNextPage,L=y.isFetchingNextPage,[W,je]=v(null),[Ee,Qe]=v(new Set),[Ke,Vt]=v(""),[pe,it]=v(""),[lt,go]=v(""),[Ht,cr]=v(""),[$e,bo]=v(()=>{let u=r.get("preset");return wi.some(R=>R.key===u)?u:""}),[oe,Ir]=v(s),[ge,ut]=v({col:null,dir:"asc"}),[ve,jr]=v({col:null,dir:"asc"}),[pr,$r]=v(""),[ct,pt]=v(""),[_,K]=v(""),[D,O]=v(""),[J,Re]=v(""),[Je,Gt]=v(""),[_t,vo]=v(""),[xe,de]=v({col:null,dir:"asc"}),[Vr,xo]=v(""),[_o,pn]=v(""),[Hr,dn]=v("");G(()=>{let u=new URL(window.location.href);oe.col?(u.searchParams.set("sort",oe.col),u.searchParams.set("dir",oe.dir)):(u.searchParams.delete("sort"),u.searchParams.delete("dir")),$e?u.searchParams.set("preset",$e):u.searchParams.delete("preset"),history.replaceState(null,"",u.toString())},[oe,$e]);let Gr=u=>{Ir(R=>R.col===u?{col:u,dir:R.dir==="asc"?"desc":"asc"}:{col:u,dir:"asc"})},ss=u=>{ut(R=>R.col===u?{col:u,dir:R.dir==="asc"?"desc":"asc"}:{col:u,dir:"asc"})},el=u=>{bo(R=>R===u?"":u)},tl=()=>l.fetchNextPage(),rl=()=>c.fetchNextPage(),ol=()=>p.fetchNextPage(),sl=()=>y.fetchNextPage(),fn=u=>{u==="http"?l.refetch():u==="jobs"?c.refetch():u==="console"?p.refetch():u==="tests"?y.refetch():u==="outbound"?f.refetch():u==="env"&&h.refetch()},Tt=u=>{if(u===n){fn(u);return}a(u);let R=new URL(window.location.href);R.searchParams.set("section",u),history.replaceState(null,"",R.toString()),Vt(""),it(""),go(""),cr(""),bo(""),Ir({col:null,dir:"asc"}),$r(""),pt(""),K(""),ut({col:null,dir:"asc"}),O(""),Re(""),jr({col:null,dir:"asc"}),Gt(""),vo(""),de({col:null,dir:"asc"}),xo(""),pn(""),dn("")},To=u=>{Dt(u).then(R=>{if(!R){window.prompt("Copy is not available here. Select the token and copy it:",u);return}je(u),setTimeout(()=>je(null),1500)})},nl=u=>m({id:u}).then(()=>l.refetch()),al=u=>{Qe(R=>{let j=new Set(R);return j.has(u)?j.delete(u):j.size<2&&j.add(u),j})},il=u=>b({id:u}).then(()=>c.refetch()),ll=u=>T({id:u}).then(()=>p.refetch()),ul=u=>P({id:u}).then(()=>y.refetch()),cl=()=>{window.confirm("Delete all HTTP profiles?")&&g().then(()=>l.refetch())},pl=()=>{window.confirm("Delete all job profiles?")&&x().then(()=>c.refetch())},dl=()=>{window.confirm("Delete all console profiles?")&&C().then(()=>p.refetch())},fl=()=>{window.confirm("Delete all test profiles?")&&k().then(()=>y.refetch())},ns=()=>{window.confirm("Delete all HTTP, job and console profiles?")&&Promise.all([g(),x(),C()]).then(()=>{l.refetch(),c.refetch(),p.refetch()})},Br=()=>fn(n),as=u=>{jr(R=>R.col===u?{col:u,dir:R.dir==="asc"?"desc":"asc"}:{col:u,dir:"asc"})},Bt=u=>`tab${n===u?" active":""}`,wo=q.filter(u=>{if(Ke&&!u.path.toLowerCase().includes(Ke.toLowerCase())||pe&&u.method!==pe)return!1;if(lt){let R=parseInt(lt);if(!(u.status>=R&&u.status<R+100))return!1}return!(Ht&&(Ht==="lt100"?u.duration>=100:u.duration<parseInt(Ht))||$e==="slow"&&u.duration<500||$e==="many_queries"&&(u.collectors_data?.database?.total_queries??0)<=20||$e==="errors"&&u.status<500||$e==="has_exception"&&!u.collectors_data?.exception)}),yl=oe.col?[...wo].sort((u,R)=>{if(oe.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return oe.dir==="asc"?Ve:-Ve}let j,re;switch(oe.col){case"duration":j=u.duration,re=R.duration;break;case"memory":j=Te(u)??0,re=Te(R)??0;break;case"status":j=u.status,re=R.status;break;case"queries":j=u.collectors_data?.database?.total_queries??0,re=R.collectors_data?.database?.total_queries??0;break;default:return 0}return oe.dir==="asc"?j-re:re-j}):wo,Co=U.filter(u=>!(pr&&!u.path.toLowerCase().includes(pr.toLowerCase())||ct&&Ti(u)!==ct||_&&(_==="lt100"?u.duration>=100:u.duration<parseInt(_)))),ml=ge.col?[...Co].sort((u,R)=>{if(ge.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return ge.dir==="asc"?Ve:-Ve}let j,re;switch(ge.col){case"duration":j=u.duration,re=R.duration;break;case"status":j=u.status,re=R.status;break;default:return 0}return ge.dir==="asc"?j-re:re-j}):Co,is=w.filter(u=>{if(Vr&&!u.url.toLowerCase().includes(Vr.toLowerCase())||_o&&u.method!==_o)return!1;if(Hr)if(Hr==="error"){if(u.status!==0)return!1}else{let R=parseInt(Hr);if(!(u.status>=R&&u.status<R+100))return!1}return!0}),Eo=Q.filter(u=>!(D&&!u.path.toLowerCase().includes(D.toLowerCase())||J==="error"&&u.status!==500||J==="ok"&&u.status===500)),hl=ve.col?[...Eo].sort((u,R)=>{if(ve.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return ve.dir==="asc"?Ve:-Ve}let j,re;switch(ve.col){case"duration":j=u.duration,re=R.duration;break;case"status":j=u.status,re=R.status;break;default:return 0}return ve.dir==="asc"?j-re:re-j}):Eo,Ro=N.filter(u=>!(Je&&!(u.collectors_data?.test?.test_name||u.path).toLowerCase().includes(Je.toLowerCase())||_t==="failed"&&u.status!==500||_t==="passed"&&u.status===500||_t==="pending"&&u.collectors_data?.test?.status!=="pending")),gl=xe.col?[...Ro].sort((u,R)=>{let j,re;if(xe.col==="date"){let Ve=new Date(u.started_at).getTime()-new Date(R.started_at).getTime();return xe.dir==="asc"?Ve:-Ve}switch(xe.col){case"duration":j=u.duration,re=R.duration;break;case"status":j=u.status,re=R.status;break;default:return 0}return xe.dir==="asc"?j-re:re-j}):Ro,yn=!!(Ke||pe||lt||Ht||$e),mn=!!(pr||ct||_),hn=!!(D||J),gn=!!(Je||_t),bl=!!(Vr||_o||Hr),Se=(u,R,j)=>u!==j?t("span",{class:"sort-icon sort-icon--idle",children:"\u21C5"}):t("span",{class:"sort-icon sort-icon--active",children:R==="asc"?"\u25B2":"\u25BC"});return t("div",{class:"container",children:[t("div",{class:"header",children:[t("h1",{children:[t("svg",{class:"h1-logo",viewBox:"24 32 80 64",width:"28",height:"22","aria-hidden":"true",focusable:"false",children:t("g",{fill:"currentColor",children:[t("rect",{x:"24",y:"32",width:"80",height:"16"}),t("rect",{x:"32",y:"56",width:"40",height:"16"}),t("rect",{x:"48",y:"80",width:"48",height:"16"})]})})," ","Rails Profiler"]}),t("p",{children:"Recent profiled requests and jobs"}),e&&t("span",{class:"profiler-version-badge",children:["v",e]})]}),t("div",{class:"profiler-panel profiler-mb-6",children:[t("div",{class:"tabs",children:[t("a",{href:"#",class:Bt("http"),onClick:u=>{u.preventDefault(),Tt("http")},children:"HTTP Requests"}),t("a",{href:"#",class:Bt("jobs"),onClick:u=>{u.preventDefault(),Tt("jobs")},children:"Background Jobs"}),t("a",{href:"#",class:Bt("console"),onClick:u=>{u.preventDefault(),Tt("console")},children:"Console"}),t("a",{href:"#",class:Bt("tests"),onClick:u=>{u.preventDefault(),Tt("tests")},children:"Tests"}),t("div",{style:"flex: 1"}),t("a",{href:"#",class:Bt("runner"),onClick:u=>{u.preventDefault(),Tt("runner")},children:"Test Runner"}),t("a",{href:"#",class:Bt("outbound"),onClick:u=>{u.preventDefault(),Tt("outbound")},children:"Outbound HTTP"}),t("a",{href:"#",class:Bt("env"),onClick:u=>{u.preventDefault(),Tt("env")},children:"Env"})]}),t("div",{class:"profiler-p-4 tab-content active",children:[n==="http"&&(I?t(Ur,{cols:["sm","xs","flex","sm","sm","sm","xs","sm"]}):qe?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:qe})}):q.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No profiles found"}),t("p",{class:"profiler-empty__description",children:"Make some requests to your application to see profiling data"})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-2",children:t("div",{class:"profiler-filter-group",children:wi.map(u=>t("button",{class:`profiler-preset-btn${$e===u.key?" profiler-preset-btn--active":""}`,onClick:()=>el(u.key),children:u.label},u.key))})}),t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search path\u2026",value:Ke,onInput:u=>Vt(u.target.value)}),t("select",{class:"profiler-filter-select",value:pe,onChange:u=>it(u.target.value),children:[t("option",{value:"",children:"All Methods"}),t("option",{value:"GET",children:"GET"}),t("option",{value:"POST",children:"POST"}),t("option",{value:"PUT",children:"PUT"}),t("option",{value:"PATCH",children:"PATCH"}),t("option",{value:"DELETE",children:"DELETE"})]}),t("select",{class:"profiler-filter-select",value:lt,onChange:u=>go(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"200",children:"2xx"}),t("option",{value:"300",children:"3xx"}),t("option",{value:"400",children:"4xx"}),t("option",{value:"500",children:"5xx"})]}),t("select",{class:"profiler-filter-select",value:Ht,onChange:u=>cr(u.target.value),children:[t("option",{value:"",children:"All Durations"}),t("option",{value:"lt100",children:"<100ms"}),t("option",{value:"100",children:"\u2265100ms"}),t("option",{value:"500",children:"\u2265500ms"})]})]}),t("div",{class:"profiler-filter-group",children:[yn&&t("span",{class:"profiler-filter-count",children:[wo.length," / ",q.length]}),Ee.size===2&&t("a",{class:"btn btn-secondary btn-sm",href:`${Lr}/compare?a=${encodeURIComponent(Array.from(Ee)[0])}&b=${encodeURIComponent(Array.from(Ee)[1])}`,children:"Compare 2 profiles"}),Ee.size===1&&t("span",{class:"profiler-text--xs profiler-text--muted",children:"Select 1 more to compare"}),t("button",{class:`btn-refresh${I?" btn-refresh--spinning":""}`,onClick:Br,disabled:I,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:cl,title:"Delete HTTP profiles",children:"Clear"}),t("button",{class:"btn btn-danger btn-sm",onClick:ns,title:"Delete all HTTP and job profiles",children:"Clear All"})]})]}),wo.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{style:"width:32px"}),t("th",{class:`sortable${oe.col==="date"?" sortable--active":""}`,onClick:()=>Gr("date"),children:["Time ",Se(oe.col,oe.dir,"date")]}),t("th",{children:"Method"}),t("th",{children:"Path"}),t("th",{class:`sortable${oe.col==="duration"?" sortable--active":""}`,onClick:()=>Gr("duration"),children:["Duration ",Se(oe.col,oe.dir,"duration")]}),t("th",{class:`sortable${oe.col==="queries"?" sortable--active":""}`,onClick:()=>Gr("queries"),children:["Queries ",Se(oe.col,oe.dir,"queries")]}),t("th",{class:`sortable${oe.col==="memory"?" sortable--active":""}`,onClick:()=>Gr("memory"),title:ot,children:["Allocations ",Se(oe.col,oe.dir,"memory")]}),t("th",{class:`sortable${oe.col==="status"?" sortable--active":""}`,onClick:()=>Gr("status"),children:["Status ",Se(oe.col,oe.dir,"status")]}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:yl.map(u=>{let R=Ee.has(u.token),j=!R&&Ee.size>=2;return t("tr",{class:R?"profiler-row--selected":"",children:[t("td",{children:t("input",{type:"checkbox",checked:R,disabled:j,onChange:()=>al(u.token),title:j?"Deselect another profile first":"Select for comparison"})}),t("td",{children:fo(u.started_at)}),t("td",{children:t("span",{class:Fc(u.method),children:u.method})}),t("td",{children:[t("a",{href:`${Lr}/profiles/${u.token}`,children:u.path}),u.gem_version&&u.gem_version!==e&&t("span",{class:"profiler-version-warn",title:`Captur\xE9 avec v${u.gem_version} (actuel : v${e})`,children:"\u26A0\uFE0F"})]}),t("td",{children:t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:u.collectors_data?.database?.total_queries??"-"}),t("td",{children:rt(Te(u))}),t("td",{children:t("span",{class:Oc(u.status),children:u.status})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>nl(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),Fe&&!yn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:tl,disabled:Ce,children:Ce?"Loading\u2026":"Load more"})})]})),n==="jobs"&&(Z?t(Ur,{cols:["sm","flex","md","sm","xs","xs","sm"]}):Ne?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:Ne})}):U.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No job profiles found"}),t("p",{class:"profiler-empty__description",children:"Run background jobs in your application to see profiling data"})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search job class\u2026",value:pr,onInput:u=>$r(u.target.value)}),t("select",{class:"profiler-filter-select",value:ct,onChange:u=>pt(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"running",children:"Running"}),t("option",{value:"completed",children:"Completed"}),t("option",{value:"failed",children:"Failed"})]}),t("select",{class:"profiler-filter-select",value:_,onChange:u=>K(u.target.value),children:[t("option",{value:"",children:"All Durations"}),t("option",{value:"lt100",children:"<100ms"}),t("option",{value:"100",children:"\u2265100ms"}),t("option",{value:"500",children:"\u2265500ms"})]})]}),t("div",{class:"profiler-filter-group",children:[mn&&t("span",{class:"profiler-filter-count",children:[Co.length," / ",U.length]}),t("button",{class:`btn-refresh${Z?" btn-refresh--spinning":""}`,onClick:Br,disabled:Z,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:pl,title:"Delete job profiles",children:"Clear"}),t("button",{class:"btn btn-danger btn-sm",onClick:ns,title:"Delete all HTTP and job profiles",children:"Clear All"})]})]}),Co.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{class:`sortable${ge.col==="date"?" sortable--active":""}`,onClick:()=>ss("date"),children:["Time ",Se(ge.col,ge.dir,"date")]}),t("th",{children:"Job Class"}),t("th",{children:"Queue"}),t("th",{class:`sortable${ge.col==="duration"?" sortable--active":""}`,onClick:()=>ss("duration"),children:["Duration ",Se(ge.col,ge.dir,"duration")]}),t("th",{class:`sortable${ge.col==="status"?" sortable--active":""}`,onClick:()=>ss("status"),children:["Status ",Se(ge.col,ge.dir,"status")]}),t("th",{children:"Executions"}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:ml.map(u=>{let R=u.collectors_data?.job,j=Ti(u);return t("tr",{children:[t("td",{children:fo(u.started_at)}),t("td",{children:[t("a",{href:`${Lr}/profiles/${u.token}`,children:u.path}),u.gem_version&&u.gem_version!==e&&t("span",{class:"profiler-version-warn",title:`Captur\xE9 avec v${u.gem_version} (actuel : v${e})`,children:"\u26A0\uFE0F"})]}),t("td",{children:t("span",{class:"profiler-text--xs profiler-text--mono",children:R?.queue||"-"})}),t("td",{children:j==="running"?t("span",{class:"profiler-text--muted",children:"-"}):t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:j==="running"?t("span",{class:"badge-info",children:[t("span",{class:"profiler-spinner","aria-hidden":"true",children:"\u25D0"})," Running"]}):t("span",{class:j==="failed"?"badge-error":"badge-success",children:j==="failed"?"\u2717 Failed":"\u2713 Completed"})}),t("td",{children:R?.executions??"-"}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>il(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),nt&&!mn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:rl,disabled:at,children:at?"Loading\u2026":"Load more"})})]})),n==="console"&&(B?t(Ur,{cols:["sm","flex","sm","sm","xs","sm"]}):Ie?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:Ie})}):Q.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No console profiles found"}),t("p",{class:"profiler-empty__description",children:["Run expressions in ",t("code",{children:"rails console"})," to see profiling data"]})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search expression\u2026",value:D,onInput:u=>O(u.target.value)}),t("select",{class:"profiler-filter-select",value:J,onChange:u=>Re(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"ok",children:"OK"}),t("option",{value:"error",children:"Error"})]})]}),t("div",{class:"profiler-filter-group",children:[hn&&t("span",{class:"profiler-filter-count",children:[Eo.length," / ",Q.length]}),t("button",{class:`btn-refresh${B?" btn-refresh--spinning":""}`,onClick:Br,disabled:B,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:dl,title:"Delete console profiles",children:"Clear"}),t("button",{class:"btn btn-danger btn-sm",onClick:ns,title:"Delete all profiles",children:"Clear All"})]})]}),Eo.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{class:`sortable${ve.col==="date"?" sortable--active":""}`,onClick:()=>as("date"),children:["Time ",Se(ve.col,ve.dir,"date")]}),t("th",{children:"Expression"}),t("th",{class:`sortable${ve.col==="duration"?" sortable--active":""}`,onClick:()=>as("duration"),children:["Duration ",Se(ve.col,ve.dir,"duration")]}),t("th",{children:"SQL"}),t("th",{class:`sortable${ve.col==="status"?" sortable--active":""}`,onClick:()=>as("status"),children:["Status ",Se(ve.col,ve.dir,"status")]}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:hl.map(u=>{let R=u.status===500;return t("tr",{children:[t("td",{children:fo(u.started_at)}),t("td",{children:[t("a",{href:`${Lr}/profiles/${u.token}`,class:"profiler-text--mono",style:"font-size:0.85em;",children:u.path.length>60?u.path.slice(0,60)+"\u2026":u.path}),u.gem_version&&u.gem_version!==e&&t("span",{class:"profiler-version-warn",title:`Captur\xE9 avec v${u.gem_version} (actuel : v${e})`,children:"\u26A0\uFE0F"})]}),t("td",{children:t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:u.collectors_data?.database?.total_queries??"-"}),t("td",{children:t("span",{class:R?"badge-error":"badge-success",children:R?"\u2717 Error":"\u2713 OK"})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>ll(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),S&&!hn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:ol,disabled:ur,children:ur?"Loading\u2026":"Load more"})})]})),n==="tests"&&(ce?t(Ur,{cols:["sm","flex","md","sm","xs","sm"]}):De?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:De})}):N.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No test profiles found"}),t("p",{class:"profiler-empty__description",children:["Add ",t("code",{children:"Profiler::TestHelpers::RSpecSupport.install(config)"})," to your spec_helper.rb and run your tests. Or use the ",t("a",{href:"#",style:"color:var(--profiler-accent,#06b6d4)",onClick:u=>{u.preventDefault(),Tt("runner")},children:"Test Runner"})," tab to run tests from here."]})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search test name\u2026",value:Je,onInput:u=>Gt(u.target.value)}),t("select",{class:"profiler-filter-select",value:_t,onChange:u=>vo(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"passed",children:"Passed"}),t("option",{value:"failed",children:"Failed"}),t("option",{value:"pending",children:"Pending"})]})]}),t("div",{class:"profiler-filter-group",children:[gn&&t("span",{class:"profiler-filter-count",children:[Ro.length," / ",N.length]}),t("button",{class:`btn-refresh${ce?" btn-refresh--spinning":""}`,onClick:Br,disabled:ce,title:"Refresh",children:"\u21BA"}),t("button",{class:"btn btn-danger btn-sm",onClick:fl,title:"Delete test profiles",children:"Clear All"})]})]}),Ro.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):t("table",{children:[t("thead",{children:t("tr",{children:[t("th",{class:`sortable${xe.col==="date"?" sortable--active":""}`,onClick:()=>de(u=>({col:"date",dir:u.col==="date"&&u.dir==="asc"?"desc":"asc"})),children:["Time ",Se(xe.col,xe.dir,"date")]}),t("th",{children:"Test Name"}),t("th",{children:"File"}),t("th",{class:`sortable${xe.col==="duration"?" sortable--active":""}`,onClick:()=>de(u=>({col:"duration",dir:u.col==="duration"&&u.dir==="asc"?"desc":"asc"})),children:["Duration ",Se(xe.col,xe.dir,"duration")]}),t("th",{children:"Queries"}),t("th",{class:`sortable${xe.col==="status"?" sortable--active":""}`,onClick:()=>de(u=>({col:"status",dir:u.col==="status"&&u.dir==="asc"?"desc":"asc"})),children:["Status ",Se(xe.col,xe.dir,"status")]}),t("th",{children:"Token"}),t("th",{})]})}),t("tbody",{children:gl.map(u=>{let R=u.collectors_data?.test,j=u.status===500,re=R?.status||(j?"failed":"passed");return t("tr",{children:[t("td",{children:fo(u.started_at)}),t("td",{style:"max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap",children:t("a",{href:`${Lr}/profiles/${u.token}`,title:R?.test_name||u.path,children:R?.test_name||u.path})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:R?.test_file||"-"}),t("td",{children:t("span",{class:Xo(u.duration),children:[u.duration.toFixed(2)," ms"]})}),t("td",{children:u.collectors_data?.database?.total_queries??"-"}),t("td",{children:t("span",{class:re==="failed"?"badge-error":re==="pending"?"badge-warning":"badge-success",children:re==="failed"?"\u2717 Failed":re==="pending"?"\u23F8 Pending":"\u2713 Passed"})}),t("td",{class:"profiler-text--xs profiler-text--mono profiler-text--muted",children:t("button",{class:"token-copy",onClick:()=>To(u.token),title:"Copy full token",children:W===u.token?"\u2713":u.token.substring(0,8)+"\u2026"})}),t("td",{children:t("button",{class:"btn-row-delete",onClick:()=>ul(u.token),title:"Delete",children:"\xD7"})})]},u.token)})})]}),H&&!gn&&t("div",{class:"profiler-load-more",children:t("button",{class:"btn btn-secondary",onClick:sl,disabled:L,children:L?"Loading\u2026":"Load more"})})]})),n==="runner"&&t(Zo,{}),n==="outbound"&&(fe?t(Ur,{cols:["sm","xs","flex","sm","xs"],rows:4}):be?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:be})}):w.length===0?t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__title",children:"No outbound HTTP requests found"}),t("p",{class:"profiler-empty__description",children:"Make requests to external services to see outbound HTTP data"})]}):t(M,{children:[t("div",{class:"profiler-action-bar profiler-mb-3",children:[t("div",{class:"profiler-filter-group",children:[t("input",{type:"text",class:"profiler-filter-input",placeholder:"Search URL\u2026",value:Vr,onInput:u=>xo(u.target.value)}),t("select",{class:"profiler-filter-select",value:_o,onChange:u=>pn(u.target.value),children:[t("option",{value:"",children:"All Methods"}),t("option",{value:"GET",children:"GET"}),t("option",{value:"POST",children:"POST"}),t("option",{value:"PUT",children:"PUT"}),t("option",{value:"PATCH",children:"PATCH"}),t("option",{value:"DELETE",children:"DELETE"})]}),t("select",{class:"profiler-filter-select",value:Hr,onChange:u=>dn(u.target.value),children:[t("option",{value:"",children:"All Statuses"}),t("option",{value:"200",children:"2xx"}),t("option",{value:"300",children:"3xx"}),t("option",{value:"400",children:"4xx"}),t("option",{value:"500",children:"5xx"}),t("option",{value:"error",children:"Error"})]})]}),t("div",{class:"profiler-filter-group",children:[bl&&t("span",{class:"profiler-filter-count",children:[is.length," / ",w.length]}),t("button",{class:`btn-refresh${fe?" btn-refresh--spinning":""}`,onClick:Br,disabled:fe,title:"Refresh",children:"\u21BA"})]})]}),t("p",{class:"profiler-text--xs profiler-text--muted profiler-mb-3",children:[w.length," outbound request",w.length!==1?"s":""," across all profiles. Click a request to expand headers and body."]}),is.length===0?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:"No results match filters"})}):is.map((u,R)=>t("div",{style:"margin-bottom:4px",children:[t("div",{class:"profiler-text--xs profiler-text--muted",style:"margin-bottom:2px",children:[fo(u.profile_started_at)," \xB7 Profile: ",t("a",{href:`${Lr}/profiles/${u.profile_token}`,children:[u.profile_token.substring(0,8),"\u2026"]})]}),t(Xs,{req:u,index:R,threshold:500})]},R))]})),n==="env"&&(Y?t(Ur,{cols:["sm","flex","sm","sm"],rows:8}):we?t("div",{class:"profiler-empty",children:t("div",{class:"profiler-empty__title",children:we})}):t(st,{envData:F}))]})]})]})}function Ei(){let{data:e}=Qa({query:{retry:!1,refetchOnWindowFocus:!1}}),r=e?.slaves??[],o=Oa();return r.length===0?null:t("div",{class:"profiler-selector",style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 12px",background:"var(--profiler-bg-secondary, #f5f5f5)",borderBottom:"1px solid var(--profiler-border, #e0e0e0)"},children:[t("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--profiler-text-secondary, #666)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Profiler"}),t("select",{value:o??"__local__",onChange:a=>{let i=a.target.value;Da(i==="__local__"?null:i)},style:{fontSize:"13px",padding:"2px 6px",borderRadius:"4px",border:"1px solid var(--profiler-border, #ccc)",background:"var(--profiler-bg, #fff)",color:"var(--profiler-text, #333)",cursor:"pointer"},children:[t("option",{value:"__local__",children:"Local (master)"}),r.map(a=>t("option",{value:a.name,disabled:a.status==="offline",children:[a.name," ",a.status==="offline"?"(offline)":""]},a.name))]}),o&&t("span",{style:{fontSize:"11px",color:"var(--profiler-text-secondary, #888)",fontStyle:"italic"},children:"Viewing slave data via proxy"})]})}function Dc(e){let r=e.headers??{},o=e.params??{},s=e.request_body,n=[`curl -X ${e.method}`];Object.entries(r).filter(([i])=>i!=="User-Agent").forEach(([i,l])=>n.push(` -H '${i}: ${l}'`)),["POST","PUT","PATCH"].includes(e.method)&&(s&&s.length>0?n.push(` -d '${s.replace(/'/g,"'\\''")}'`):Object.keys(o).length>0&&((r["Content-Type"]??"").includes("application/json")?n.push(` -d '${JSON.stringify(o).replace(/'/g,"'\\''")}'`):Object.entries(o).forEach(([l,c])=>n.push(` --data-urlencode '${l}=${c}'`))));let a=`http://localhost:3000${e.path}`;return e.method==="GET"&&Object.keys(o).length>0&&(a+="?"+Object.entries(o).map(([i,l])=>`${encodeURIComponent(i)}=${encodeURIComponent(String(l))}`).join("&")),n.push(` '${a}'`),n.join(` \\
|
|
12
12
|
`)}function Qc(e,r){let o=[],s=(a,i,l,c)=>{if(i){let p=l!=null?`${c?"at least ":""}${l.toLocaleString("en")} bytes, `:"";o.push(`${a} body truncated: ${p}only the beginning was kept (max_captured_body_bytes).`)}};s("Request",e.request_body_truncated??r.request_body_truncated,e.request_body_size??r.request_body_size,e.request_body_size_is_minimum??r.request_body_size_is_minimum),s("Response",e.response_body_truncated??r.response_body_truncated,e.response_body_size??r.response_body_size,e.response_body_size_is_minimum??r.response_body_size_is_minimum);let n=e.collectors_released_after_seconds??r.collectors_released_after_seconds;return n!=null&&o.push(`Incomplete profile: the collectors of this stream were released after ${n} s, before the server closed it; what it did later is missing.`),o}var Kc=["POST","PUT","PATCH","DELETE"];function Lc({profile:e}){let{mutateAsync:r,isPending:o}=ei(),[s,n]=v(null),[a,i]=v(null);return t("div",{class:"profiler-ajax-card__row",children:[t("button",{class:"profiler-btn profiler-btn--sm",disabled:o,onClick:async()=>{let c=Kc.includes(e.method)?`
|
|
13
13
|
|
|
14
14
|
${e.method} requests usually change data: the replay will really do it.`:"",p=`Replay ${e.method} ${e.path} against the application for real?${c}`;if(window.confirm(p)){i(null),n(null);try{n(await r({id:e.token,data:{}}))}catch(y){i(y instanceof Error?y.message:String(y))}}},children:o?"Replaying\u2026":"\u21BB Replay request"}),a&&t("span",{class:"profiler-text--xs profiler-text--error",style:"margin-left:8px",children:a}),s&&s.replays.map(c=>t("span",{class:"profiler-text--xs",style:"margin-left:8px",children:c.error?c.error:c.token?t("a",{href:`/_profiler/profiles/${c.token}?tab=request`,children:[c.status," \xB7 open the new profile"]}):`${c.status} (not profiled)`},c.index))]})}function Ri({profile:e}){let r=e.collectors_data?.request??{},o=e.params&&Object.keys(e.params).length>0,s=Qc(e,r);return t("div",{class:"profiler-ajax-card profiler-ajax-card--success",style:"margin-bottom:8px;background:var(--profiler-bg-elevated);transform:translateX(3px);box-shadow:var(--profiler-shadow-sm);transition:none",children:[t(Wo,{method:e.method,url:e.path,copyUrl:`http://localhost:3000${e.path}`,status:e.status,duration:e.duration,curlCommand:Dc(e)}),e.replay_of&&t("div",{class:"profiler-ajax-card__row profiler-text--xs profiler-text--muted",children:["Replay of ",t("a",{href:`/_profiler/profiles/${e.replay_of}?tab=request`,children:e.replay_of})]}),t(Lc,{profile:e}),(r.controller_action||r.route_pattern)&&t("div",{class:"profiler-ajax-card__row",children:[r.controller_action&&t("span",{class:"profiler-text--xs profiler-text--muted",style:"margin-right:16px",children:r.controller_action}),r.route_pattern&&t("span",{class:"profiler-text--xs profiler-text--muted",style:"font-family:monospace",children:[r.route_name?`${r.route_name} \xB7 `:"",r.route_pattern]})]}),s.map(n=>t("div",{class:"profiler-ajax-card__row profiler-text--xs profiler-text--warning",children:n},n)),t(zo,{request:{headers:e.headers??{},body:e.request_body??void 0,body_encoding:e.request_body_encoding,params:o?e.params:void 0},response:{headers:e.response_headers??{},body:e.response_body??void 0,body_encoding:e.response_body_encoding}})]})}function Uc(e){return e.replace(/\$\d+/g,"?").replace(/\b\d+\b/g,"?").replace(/'[^']*'/g,"?").replace(/"[^"]*"/g,"?").trim()}function Nc(e){let r=new Map;e.forEach((s,n)=>{if(s.cached||s.transaction)return;let a=Uc(s.sql);r.has(a)||r.set(a,{indices:[],backtrace:s.backtrace??[]}),r.get(a).indices.push(n)});let o=[];return r.forEach(({indices:s,backtrace:n},a)=>{s.length>=3&&o.push({pattern:a,indices:s,backtrace:n})}),o.sort((s,n)=>n.indices.length-s.indices.length)}function ki(e,r=0){let o=e["Node Type"]??"",s=e["Actual Rows"]??0,n=e["Plan Rows"]??1,a=o.includes("Seq Scan")||o.includes("Hash Join")||o.includes("Nested Loop")||o.includes("Filter")||s>0&&n>0&&s>n*10,i=e.Plans??[];return t("div",{class:`profiler-explain-node${a?" profiler-explain-node--expensive":""}`,style:`margin-left:${r*14}px`,children:[t("span",{class:"profiler-explain-node__type",children:o}),e["Relation Name"]&&t("span",{class:"profiler-text--muted",children:[" on ",e["Relation Name"]]}),e["Index Name"]&&t("span",{class:"profiler-text--muted",children:[" using ",e["Index Name"]]}),t("div",{class:"profiler-explain-node__stats profiler-text--xs profiler-text--muted",children:[e["Actual Total Time"]!=null&&t("span",{children:["time: ",e["Actual Total Time"].toFixed(3),"ms"]}),e["Actual Rows"]!=null&&t("span",{children:["rows: ",s," (est: ",n,")"]}),e["Total Cost"]!=null&&t("span",{children:["cost: ",e["Total Cost"].toFixed(2)]}),e.Filter&&t("span",{class:"profiler-text--warning",children:["filter: ",e.Filter]})]}),i.map((l,c)=>ki(l,r+1))]})}function Ic({state:e,onClose:r}){if(G(()=>{if(!e.open)return;let s=n=>{n.key==="Escape"&&r()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e.open]),!e.open)return null;let o=()=>{if(e.loading)return t("div",{class:"profiler-text--muted",children:"Running EXPLAIN ANALYZE\u2026"});if(e.error)return t("div",{class:"profiler-text--error",children:e.error});if(!e.result)return null;if(e.format==="json")try{let s=typeof e.result=="string"?JSON.parse(e.result):e.result,n=Array.isArray(s)?s:[s];return t("div",{class:"profiler-explain-result",children:n.map((a,i)=>t("div",{children:[ki(a.Plan??a),a["Planning Time"]!=null&&t("div",{class:"profiler-text--xs profiler-text--muted profiler-mt-2",children:["Planning: ",a["Planning Time"].toFixed(3),"ms",a["Execution Time"]!=null&&t(M,{children:[" \xB7 Execution: ",a["Execution Time"].toFixed(3),"ms"]})]})]},i))})}catch{return t("pre",{class:"profiler-explain-result",children:String(e.result)})}return t("pre",{class:"profiler-explain-result",children:String(e.result)})};return t("div",{class:"profiler-modal__overlay",onClick:r,children:t("div",{class:"profiler-modal",onClick:s=>s.stopPropagation(),children:[t("div",{class:"profiler-modal__header",children:[t("span",{class:"profiler-modal__title",children:"EXPLAIN ANALYZE"}),t("span",{class:"profiler-text--xs profiler-text--muted",children:e.adapter}),t("button",{class:"profiler-modal__close",onClick:r,children:"\xD7"})]}),t("div",{class:"profiler-modal__body",children:o()})]})})}function Qt({dbData:e,token:r}){let[o,s]=v(new Set),[n,a]=v({open:!1,loading:!1,result:null,format:"text",adapter:"",error:null}),{mutateAsync:i}=Va();if(!e?.queries)return t("div",{class:"profiler-empty",children:t("p",{class:"profiler-empty__description",children:"No database queries recorded"})});let l=Nc(e.queries),c=new Set(l.flatMap(h=>h.indices)),p=h=>{s(m=>{let g=new Set(m);return g.has(h)?g.delete(h):g.add(h),g})},y=async h=>{a({open:!0,loading:!0,result:null,format:"text",adapter:"",error:null});try{let m=await i({data:{token:r,query_index:h}});a(g=>({...g,loading:!1,result:m.result,format:m.format??"text",adapter:m.adapter??""}))}catch(m){a(g=>({...g,loading:!1,error:m.message??"Request failed"}))}},f=()=>a(h=>({...h,open:!1}));return t(M,{children:[t("h2",{class:"profiler-section__header",children:["Database Queries (",e.total_queries,")"]}),t("div",{class:"profiler-flex profiler-flex--gap-4 profiler-mb-4 profiler-text--sm",children:[t("span",{children:["Total Duration: ",t("strong",{children:[e.total_duration," ms"]})]}),t("span",{children:["Slow Queries: ",t("strong",{class:"profiler-text--error",children:e.slow_queries})]}),t("span",{children:["Cached: ",t("strong",{children:e.cached_queries})]})]}),l.length>0&&t("div",{class:"profiler-alert-banner profiler-alert-banner--warning profiler-mb-4",children:[t("span",{class:"profiler-alert-banner__icon",children:"\u26A0\uFE0F"}),t("div",{style:"flex:1",children:[t("strong",{children:"Potential N+1 detected"})," - ",l.length," pattern",l.length>1?"s":""," repeated ",l.reduce((h,m)=>h+m.indices.length,0)," times total",t("div",{class:"profiler-text--xs profiler-text--muted profiler-mt-1",children:"Queries causing N+1 are highlighted below. Expand each group to see the call stack."})]}),l.length>1&&t("button",{class:"profiler-btn profiler-btn--sm",style:"flex-shrink:0;align-self:flex-start",onClick:()=>{let h=l.every(m=>o.has(m.pattern));s(h?new Set:new Set(l.map(m=>m.pattern)))},children:l.every(h=>o.has(h.pattern))?"Collapse all":"Expand all"})]}),l.map(h=>t("div",{class:"profiler-n1-group profiler-mb-4",children:[t("div",{class:"profiler-n1-group__header",onClick:()=>p(h.pattern),children:[t("span",{class:"profiler-n1-group__count",children:["N+1 \xB7 ",h.indices.length,"\xD7"]}),t("code",{class:"profiler-n1-group__pattern",children:h.pattern}),t("span",{class:"profiler-n1-group__toggle",children:[o.has(h.pattern)?"\u25B2":"\u25BC"," backtrace"]})]}),o.has(h.pattern)&&h.backtrace.length>0&&t("div",{class:"profiler-n1-backtrace",children:h.backtrace.map((m,g)=>t("div",{class:"profiler-n1-backtrace__frame",children:t(vt,{frame:m})},g))})]},h.pattern)),e.queries.map((h,m)=>t("div",{class:["profiler-query-card",h.slow?"profiler-query-card--slow":"",c.has(m)?"profiler-query-card--n1":""].filter(Boolean).join(" "),children:[t("div",{class:"profiler-query-card__header",children:[t("div",{class:"profiler-flex profiler-flex--gap-2",children:[t("span",{class:"profiler-text--muted",children:["#",m+1]}),c.has(m)&&t("span",{class:"profiler-badge profiler-badge--warning",children:"N+1"}),h.name&&t("span",{class:"profiler-text--xs profiler-text--muted",children:h.name})]}),t("div",{class:"profiler-flex profiler-flex--gap-2",children:[t("span",{class:`profiler-query-card__duration ${h.slow?"profiler-query-card__duration--slow":"profiler-query-card__duration--fast"}`,children:[h.duration.toFixed(2)," ms"]}),!h.cached&&!h.transaction&&t("button",{class:"profiler-btn profiler-btn--sm",onClick:()=>y(m),children:"Explain"})]})]}),t("code",{class:"profiler-query-card__code",children:h.sql})]},m)),t(Ic,{state:n,onClose:f})]})}function Kt({dumpData:e}){return e?.dumps?.length?t(M,{children:[t("h2",{class:"profiler-section__header",children:["Dumped Variables (",e.count,")"]}),e.dumps.map((r,o)=>t("div",{class:"profiler-dump-card",children:[t("div",{class:"profiler-dump-card__header",children:[t("div",{children:[t("span",{class:"profiler-text--xs profiler-text--muted",children:["#",o+1]}),r.label&&t("span",{class:"profiler-dump-card__label",children:r.label})]}),t("div",{children:[t("div",{class:"profiler-dump-card__location",children:t(ir,{file:r.file,line:r.line})}),t("div",{class:"profiler-text--xs profiler-text--muted profiler-mt-1",children:new Date(r.timestamp).toLocaleTimeString("en",{hour12:!1})})]})]}),t("div",{class:"profiler-dump-card__content",children:t("pre",{children:r.formatted})})]},o))]}):t("div",{class:"profiler-empty",children:[t("div",{class:"profiler-empty__icon",children:"\u{1F50D}"}),t("h3",{class:"profiler-empty__title",children:"No dumps recorded"}),t("div",{class:"profiler-empty__description",children:[t("p",{children:["Use ",t("code",{children:"Profiler.dump(variable)"})," in your code to dump variables here."]}),t("p",{class:"profiler-mt-3",children:["Example: ",t("code",{children:'Profiler.dump(@user, "Current user")'})]})]})]})}var jc={controller:"#60a5fa",view:"#34d399",partial:"#f59e0b",sql:"#fb923c",cache:"#a78bfa",http:"#f87171",custom:"#e879f9",method:"#94a3b8"},xt=24,$c=1,tn=xt+$c,Vc=1,Hc=60,Gc=300,yo=class{constructor(r,o,s){this.frames=[];this.maxDepth=0;this.globalStart=0;this.globalEnd=0;this.viewport={start:0,end:0};this.targetViewport={start:0,end:0};this.animating=!1;this.animStart=0;this.prevViewport={start:0,end:0};this.dpr=1;this.hoveredFrame=null;this.zoomStack=[];this.searchQuery="";this.highlightName="";this.isPanning=!1;this.panStartX=0;this.panStartViewport={start:0,end:0};this.panDistance=0;this.boundHandlers={};this.canvas=r,this.ctx=r.getContext("2d"),this.callbacks=s,this.flatten(o),this.computeGlobalBounds(),this.viewport={start:this.globalStart,end:this.globalEnd},this.targetViewport={...this.viewport},this.setupCanvas(),this.bindEvents(),this.render()}flatten(r){this.frames=[],this.maxDepth=0;let o=(s,n)=>{for(let a of s)this.frames.push({node:a,depth:n,absStart:a.started_at,absEnd:a.finished_at}),n>this.maxDepth&&(this.maxDepth=n),a.children?.length&&o(a.children,n+1)};o(r,0)}computeGlobalBounds(){if(this.frames.length===0){this.globalStart=0,this.globalEnd=1;return}let r=1/0,o=-1/0;for(let s of this.frames)s.absStart<r&&(r=s.absStart),s.absEnd>o&&(o=s.absEnd);this.globalStart=r===1/0?0:r,this.globalEnd=o===-1/0?1:o,this.globalEnd<=this.globalStart&&(this.globalEnd=this.globalStart+1)}setupCanvas(){this.dpr=window.devicePixelRatio||1,this.resizeCanvas()}resizeCanvas(){let o=this.canvas.getBoundingClientRect().width,s=(this.maxDepth+1)*tn+8;this.canvas.width=o*this.dpr,this.canvas.height=s*this.dpr,this.canvas.style.height=`${s}px`,this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0),this.render()}bindEvents(){this.boundHandlers.mousemove=r=>this.onMouseMove(r),this.boundHandlers.mouseleave=()=>this.onMouseLeave(),this.boundHandlers.click=r=>this.onClickEvent(r),this.boundHandlers.wheel=r=>this.onWheel(r),this.boundHandlers.mousedown=r=>this.onMouseDown(r),this.boundHandlers.mouseupmove=r=>this.onMouseUpOrMove(r),this.boundHandlers.mouseup=()=>this.onMouseUp(),this.canvas.addEventListener("mousemove",this.boundHandlers.mousemove),this.canvas.addEventListener("mouseleave",this.boundHandlers.mouseleave),this.canvas.addEventListener("click",this.boundHandlers.click),this.canvas.addEventListener("wheel",this.boundHandlers.wheel,{passive:!1}),this.canvas.addEventListener("mousedown",this.boundHandlers.mousedown),window.addEventListener("mousemove",this.boundHandlers.mouseupmove),window.addEventListener("mouseup",this.boundHandlers.mouseup)}frameWidth(r,o,s){return r.absEnd===r.absStart?Vc:(r.absEnd-r.absStart)/o*s}hitTest(r,o){let s=this.canvas.getBoundingClientRect(),n=r-s.left,a=o-s.top,i=s.width,l=this.viewport.end-this.viewport.start;for(let c=this.frames.length-1;c>=0;c--){let p=this.frames[c],y=(p.absStart-this.viewport.start)/l*i,f=this.frameWidth(p,l,i),h=p.depth*tn;if(n>=y&&n<=y+f&&a>=h&&a<=h+xt)return p}return null}onMouseMove(r){if(this.isPanning)return;let o=this.hitTest(r.clientX,r.clientY);this.hoveredFrame=o,this.canvas.style.cursor=o?"pointer":"default",this.callbacks.onHover(o,r.clientX,r.clientY),this.render()}onMouseLeave(){this.hoveredFrame=null,this.canvas.style.cursor="default",this.callbacks.onHover(null,0,0),this.render()}onClickEvent(r){if(this.isPanning||this.panDistance>3)return;let o=this.hitTest(r.clientX,r.clientY);o&&(this.callbacks.onClick(o),this.zoomTo(o.node))}onWheel(r){r.preventDefault();let o=this.canvas.getBoundingClientRect(),n=(r.clientX-o.left)/o.width,a=this.viewport.end-this.viewport.start,i=r.deltaY>0?1.3:.7,l=Math.min(this.globalEnd-this.globalStart,a*i),c=this.viewport.start+n*a,p=c-n*l,y=c+(1-n)*l;p<this.globalStart&&(p=this.globalStart,y=p+l),y>this.globalEnd&&(y=this.globalEnd,p=y-l),this.animateViewport({start:p,end:y}),this.updateZoomStack(p,y)}onMouseDown(r){r.button===0&&(this.isPanning=!0,this.panStartX=r.clientX,this.panStartViewport={...this.viewport},this.panDistance=0,this.canvas.style.cursor="grabbing")}onMouseUpOrMove(r){if(!this.isPanning)return;let o=r.clientX-this.panStartX;this.panDistance=Math.max(this.panDistance,Math.abs(o));let s=this.canvas.getBoundingClientRect(),n=this.panStartViewport.end-this.panStartViewport.start,a=-(o/s.width)*n,i=this.panStartViewport.start+a,l=this.panStartViewport.end+a;i<this.globalStart&&(l+=this.globalStart-i,i=this.globalStart),l>this.globalEnd&&(i-=l-this.globalEnd,l=this.globalEnd),this.viewport={start:i,end:l},this.targetViewport={...this.viewport},this.render()}onMouseUp(){this.isPanning&&(this.isPanning=!1,this.canvas.style.cursor="default")}zoomTo(r){let o=[],s=(a,i,l)=>{for(let c of a){if(c===i)return o.push(...l,c),!0;if(c.children?.length&&s(c.children,i,[...l,c]))return!0}return!1},n=this.frames.filter(a=>a.depth===0).map(a=>a.node);s(n,r,[]),this.zoomStack=o,this.animateViewport({start:r.started_at,end:r.finished_at}),this.callbacks.onZoomChange(o)}resetZoom(){this.zoomStack=[],this.animateViewport({start:this.globalStart,end:this.globalEnd}),this.callbacks.onZoomChange([])}updateZoomStack(r,o){let s=this.globalEnd-this.globalStart;o-r>=s*.99&&(this.zoomStack=[],this.callbacks.onZoomChange([]))}animateViewport(r){this.prevViewport={...this.viewport},this.targetViewport=r,this.animStart=performance.now(),this.animating||(this.animating=!0,this.animLoop())}animLoop(){let r=Math.min(1,(performance.now()-this.animStart)/Gc),o=r<.5?2*r*r:1-Math.pow(-2*r+2,2)/2;this.viewport={start:this.prevViewport.start+(this.targetViewport.start-this.prevViewport.start)*o,end:this.prevViewport.end+(this.targetViewport.end-this.prevViewport.end)*o},this.render(),r<1?requestAnimationFrame(()=>this.animLoop()):(this.animating=!1,this.viewport={...this.targetViewport},this.render())}setSearchQuery(r){this.searchQuery=r,this.render()}setHighlightName(r){this.highlightName=r,this.render()}render(){let r=this.ctx,o=this.canvas.width/this.dpr,s=this.canvas.height/this.dpr,n=this.viewport.end-this.viewport.start;r.clearRect(0,0,o,s);let a=getComputedStyle(this.canvas),i=a.getPropertyValue("--profiler-text").trim()||"#eef2f7",l=a.getPropertyValue("--profiler-text-muted").trim()||"#5e7080",c=this.searchQuery.toLowerCase(),p=c.length>0;if(p&&this.callbacks.onSearchResults){let y=0;for(let f of this.frames)f.node.name.toLowerCase().includes(c)&&y++;this.callbacks.onSearchResults(y,this.frames.length)}for(let y of this.frames){let f=(y.absStart-this.viewport.start)/n*o,h=this.frameWidth(y,n,o),m=y.depth*tn;if(f+h<0||f>o||h<.5)continue;let g=jc[y.node.category]||"#a78bfa",b=y===this.hoveredFrame,x=!!this.highlightName&&y.node.name===this.highlightName,T=!p||y.node.name.toLowerCase().includes(c);if(r.fillStyle=b||x?this.lightenColor(g,.2):g,r.globalAlpha=p&&!T?.2:b||x?1:.85,this.roundRect(r,f,m,h,xt,3),r.fill(),r.globalAlpha=1,b?(r.strokeStyle="#ffffff",r.lineWidth=1.5,this.roundRect(r,f,m,h,xt,3),r.stroke()):x?(r.strokeStyle="#fbbf24",r.lineWidth=2,this.roundRect(r,f,m,h,xt,3),r.stroke()):p&&T&&(r.strokeStyle="#ffffff",r.lineWidth=1,r.globalAlpha=.5,this.roundRect(r,f,m,h,xt,3),r.stroke(),r.globalAlpha=1),h>Hc&&T){r.fillStyle=this.getTextColor(g),r.font='11px "JetBrains Mono", monospace',r.textBaseline="middle";let C=y.node.name,P=`${y.node.duration.toFixed(1)}ms`,k=h-8,q=r.measureText(P).width;if(k>q+20){let U=k-q-8;r.fillText(this.truncateText(r,C,U),f+4,m+xt/2),r.fillStyle=b?i:l,r.fillText(P,f+h-q-4,m+xt/2)}else r.fillText(this.truncateText(r,C,k),f+4,m+xt/2)}}}roundRect(r,o,s,n,a,i){r.beginPath(),r.moveTo(o+i,s),r.lineTo(o+n-i,s),r.quadraticCurveTo(o+n,s,o+n,s+i),r.lineTo(o+n,s+a-i),r.quadraticCurveTo(o+n,s+a,o+n-i,s+a),r.lineTo(o+i,s+a),r.quadraticCurveTo(o,s+a,o,s+a-i),r.lineTo(o,s+i),r.quadraticCurveTo(o,s,o+i,s),r.closePath()}truncateText(r,o,s){if(r.measureText(o).width<=s)return o;let n=o;for(;n.length>0&&r.measureText(n+"...").width>s;)n=n.slice(0,-1);return n.length>0?n+"...":""}lightenColor(r,o){let s=parseInt(r.slice(1),16),n=Math.min(255,(s>>16&255)+Math.round(255*o)),a=Math.min(255,(s>>8&255)+Math.round(255*o)),i=Math.min(255,(s&255)+Math.round(255*o));return`rgb(${n},${a},${i})`}getTextColor(r){let o=parseInt(r.slice(1),16),s=o>>16&255,n=o>>8&255,a=o&255;return(.299*s+.587*n+.114*a)/255>.5?"#1a1a2e":"#f0f0f0"}destroy(){this.canvas.removeEventListener("mousemove",this.boundHandlers.mousemove),this.canvas.removeEventListener("mouseleave",this.boundHandlers.mouseleave),this.canvas.removeEventListener("click",this.boundHandlers.click),this.canvas.removeEventListener("wheel",this.boundHandlers.wheel),this.canvas.removeEventListener("mousedown",this.boundHandlers.mousedown),window.removeEventListener("mousemove",this.boundHandlers.mouseupmove),window.removeEventListener("mouseup",this.boundHandlers.mouseup)}};var Bc={controller:"Controller",view:"View",partial:"Partial",sql:"SQL",cache:"Cache",http:"HTTP",custom:"Custom",method:"Method"},Jc={controller:"#60a5fa",view:"#34d399",partial:"#f59e0b",sql:"#fb923c",cache:"#a78bfa",http:"#f87171",custom:"#e879f9",method:"#94a3b8"};function zc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}var mo=class{constructor(r,o){this.totalDuration=o,this.el=document.createElement("div"),this.el.className="profiler-flamegraph__tooltip",r.appendChild(this.el)}show(r,o,s){let n=r.node,a=n.category,i=Jc[a]||"#a78bfa",l=Bc[a]||a,c=this.totalDuration>0?(n.duration/this.totalDuration*100).toFixed(1):"0";this.el.textContent="";let p=document.createElement("div");if(p.className="tooltip-header",p.textContent=n.name,this.el.appendChild(p),this.addRow("Category",()=>{let m=document.createElement("span");return m.className="tooltip-badge",m.style.background=i,m.textContent=l,m}),this.addRow("Duration",()=>{let m=document.createElement("span");return m.className="value",m.textContent=`${n.duration.toFixed(2)} ms`,m}),this.addRow("% of total",()=>{let m=document.createElement("span");return m.className="value",m.textContent=`${c}%`,m}),a==="method"&&n.payload&&(n.payload.memory_bytes!=null&&this.addRow("Memory",()=>{let m=document.createElement("span");return m.className="value",m.textContent=zc(n.payload.memory_bytes),m}),n.payload.allocated_objects!=null&&this.addRow("Objects",()=>{let m=document.createElement("span");return m.className="value",m.textContent=`${n.payload.allocated_objects.toLocaleString()} obj`,m}),n.payload.recursive&&this.addRow("Recursive",()=>{let m=document.createElement("span");return m.className="value",m.style.color="var(--profiler-warning)",m.textContent="\u21BA yes",m}),n.payload.file)){let m=document.createElement("div");m.className="tooltip-payload",m.textContent=`${n.payload.file}:${n.payload.line}`,this.el.appendChild(m)}if(n.payload&&a!=="method"){let m=null;if(a==="sql"&&n.payload.sql){let g=n.payload.sql;m=g.length>200?g.slice(0,200)+"...":g}else if(a==="cache"&&n.payload.key)m=`Key: ${n.payload.key}`;else if(a==="http"&&n.payload.url)m=n.payload.url;else if(a==="custom"&&Object.keys(n.payload).length>0){let g=Object.entries(n.payload).map(([b,x])=>`${b}: ${JSON.stringify(x)}`).join(`
|
|
@@ -333,7 +333,11 @@ module Profiler
|
|
|
333
333
|
color: var(--pf-amber);
|
|
334
334
|
font-weight: 600;
|
|
335
335
|
letter-spacing: .02em;
|
|
336
|
+
display: inline-flex;
|
|
337
|
+
align-items: center;
|
|
338
|
+
gap: 6px;
|
|
336
339
|
}
|
|
340
|
+
#profiler-toolbar .profiler-toolbar-logo-mark { flex: none; display: block; }
|
|
337
341
|
#profiler-toolbar .profiler-toolbar-logo:hover { color: var(--pf-amber-h); }
|
|
338
342
|
|
|
339
343
|
/* Error state: the profile could not be loaded, or a component failed. */
|
data/lib/profiler/version.rb
CHANGED