@bridge_gpt/mcp-server 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -15
- package/build/agent-config-credential-migration.js +272 -0
- package/build/agents.generated.js +1 -1
- package/build/chain-orchestrator.js +16 -1
- package/build/commands.generated.js +9 -7
- package/build/conductor/bridge-api-client.js +625 -0
- package/build/conductor/claude-hook.js +251 -0
- package/build/conductor/cli.js +1048 -0
- package/build/conductor/data-normalization.js +114 -0
- package/build/conductor/doctor.js +164 -0
- package/build/conductor/done-gate.js +325 -0
- package/build/conductor/epic-reconcile.js +139 -0
- package/build/conductor/epic-runtime.js +611 -0
- package/build/conductor/epic-state.js +125 -0
- package/build/conductor/errors.js +85 -0
- package/build/conductor/git-ci-types.js +129 -0
- package/build/conductor/git-hooks.js +218 -0
- package/build/conductor/git-inspection.js +185 -0
- package/build/conductor/git-producer.js +137 -0
- package/build/conductor/merge-ledger.js +198 -0
- package/build/conductor/paths.js +224 -0
- package/build/conductor/plan.js +77 -0
- package/build/conductor/pr-ci-producer.js +427 -0
- package/build/conductor/pr-discovery.js +135 -0
- package/build/conductor/producer-ledger.js +125 -0
- package/build/conductor/redaction.js +112 -0
- package/build/conductor/store.js +1156 -0
- package/build/conductor/supervisor-config.js +150 -0
- package/build/conductor/supervisor-escalation.js +244 -0
- package/build/conductor/supervisor-judgment-python.js +141 -0
- package/build/conductor/supervisor-judgment.js +215 -0
- package/build/conductor/supervisor-ledger.js +119 -0
- package/build/conductor/supervisor-merge.js +127 -0
- package/build/conductor/supervisor-message-relay.js +61 -0
- package/build/conductor/supervisor-notification.js +39 -0
- package/build/conductor/supervisor-runtime.js +351 -0
- package/build/conductor/supervisor-state.js +572 -0
- package/build/conductor/supervisor-types.js +16 -0
- package/build/conductor/taxonomy.js +58 -0
- package/build/conductor/tools.js +367 -0
- package/build/conductor/types.js +9 -0
- package/build/conductor-bin.js +21 -0
- package/build/conductor-claude-hook-bin.js +21 -0
- package/build/credential-store.js +175 -4
- package/build/credentials-cli.js +223 -0
- package/build/decision-page-schema.js +60 -0
- package/build/decision-page-template.js +262 -10
- package/build/doctor.js +5 -1
- package/build/index.js +558 -63
- package/build/pipeline-orchestrator.js +5 -1
- package/build/pipeline-utils.js +45 -5
- package/build/pipelines.generated.js +37 -9
- package/build/readme.generated.js +3 -0
- package/build/review-tickets.js +596 -0
- package/build/scheduled-prompt.js +16 -10
- package/build/start-tickets-conductor.js +496 -0
- package/build/start-tickets-prereqs.js +32 -23
- package/build/start-tickets-repo.js +49 -0
- package/build/start-tickets.js +683 -82
- package/build/version.generated.js +1 -1
- package/design-assets/favicon/android-chrome-192x192.png +0 -0
- package/design-assets/favicon/android-chrome-512x512.png +0 -0
- package/design-assets/favicon/apple-touch-icon.png +0 -0
- package/design-assets/favicon/favicon-16x16.png +0 -0
- package/design-assets/favicon/favicon-32x32.png +0 -0
- package/design-assets/favicon/favicon.ico +0 -0
- package/design-assets/favicon/site.webmanifest +1 -0
- package/design-assets/just-logo-rough-draft.png +0 -0
- package/package.json +18 -6
- package/pipelines/idea-to-ticket.json +5 -0
- package/pipelines/plan-epic.json +16 -1
- package/pipelines/review-ticket.json +2 -1
- package/public/css/main.min.css +2 -0
- package/public/css/main.min.css.map +1 -0
- package/public/fonts/OFL.txt +93 -0
- package/public/fonts/SourceSansPro-Black.ttf +0 -0
- package/public/fonts/SourceSansPro-BlackItalic.ttf +0 -0
- package/public/fonts/SourceSansPro-Bold.ttf +0 -0
- package/public/fonts/SourceSansPro-BoldItalic.ttf +0 -0
- package/public/fonts/SourceSansPro-ExtraLight.ttf +0 -0
- package/public/fonts/SourceSansPro-ExtraLightItalic.ttf +0 -0
- package/public/fonts/SourceSansPro-Italic.ttf +0 -0
- package/public/fonts/SourceSansPro-Light.ttf +0 -0
- package/public/fonts/SourceSansPro-LightItalic.ttf +0 -0
- package/public/fonts/SourceSansPro-Regular.ttf +0 -0
- package/public/fonts/SourceSansPro-SemiBold.ttf +0 -0
- package/public/fonts/SourceSansPro-SemiBoldItalic.ttf +0 -0
- package/public/img/bridge-logo-160x51.webp +0 -0
- package/public/img/bridge-logo-300x92.webp +0 -0
- package/public/img/favicon/android-chrome-192x192.png +0 -0
- package/public/img/favicon/android-chrome-512x512.png +0 -0
- package/public/img/favicon/apple-touch-icon.png +0 -0
- package/public/img/favicon/favicon-16x16.png +0 -0
- package/public/img/favicon/favicon-32x32.png +0 -0
- package/public/img/favicon/favicon.ico +0 -0
- package/public/img/favicon/site.webmanifest +1 -0
- package/public/img/installation/bitbucket/app-password-1.png +0 -0
- package/public/img/installation/bitbucket/app-password-2.png +0 -0
- package/public/img/installation/bitbucket/create-token-1.png +0 -0
- package/public/img/installation/bitbucket/create-token-2.png +0 -0
- package/public/img/installation/bitbucket/webhook-1.png +0 -0
- package/public/img/installation/github/github-review-webhook.png +0 -0
- package/public/img/installation/jira/credentials/api-key.png +0 -0
- package/public/img/installation/jira/webhook/create-rule.png +0 -0
- package/public/img/installation/jira/webhook/project-settings.png +0 -0
- package/public/img/installation/jira/webhook/rule-create-1.png +0 -0
- package/public/img/installation/jira/webhook/rule-create-2.png +0 -0
- package/public/img/installation/jira/webhook/rule-create-3.png +0 -0
- package/public/img/installation/pinecone/pinecone-api-key.png +0 -0
- package/public/img/installation/pinecone/pinecone-index.png +0 -0
- package/public/js/main.min.js +2 -0
- package/public/js/main.min.js.map +1 -0
- package/smoke-test/SMOKE-TEST.md +16 -8
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(()=>{"use strict";var e={406(){},743(){},883(){},310(){},941(){},764(){},619(){},436(){},328(){},246(e,t,n){n.d(t,{VB:()=>a,mg:()=>i,ri:()=>s});var o=n(723),r=n(579);async function i(e){e.preventDefault();const t=document.getElementById("client-id").value,n=document.getElementById("auth-token").value;if(!t||!n)return void(0,r.to)("Missing Fields","Please enter both Client ID and Authentication Token.");(0,o.Cs)();let i=null;try{i=await(0,o.H2)("/auth/token","POST",{client_id:t,auth_token:n})}catch(e){return console.error("Error during apiCall in handleLogin:",e),void(0,r.to)("Login Failed",(0,o.SU)(e,"Invalid Client ID or Authentication Token."))}finally{(0,o.RZ)()}i&&i.session_token?(localStorage.setItem(o.sn,i.session_token),i.redirect?window.location.href=i.redirect:window.location.href="/setup"):(0,r.to)("Login Failed","Invalid Client ID or Authentication Token.")}async function s(){(0,o.Cs)();let e=null;try{e=await(0,o.H2)("/auth/logout","POST")}catch(e){console.error("Error during logout:",e)}finally{(0,o.RZ)()}localStorage.removeItem(o.sn),e&&e.redirect?window.location.href=e.redirect:window.location.href="/setup/login"}async function a(){console.log("checkAuthentication");try{const e=await(0,o.H2)("/auth/check-auth","POST");e&&!e.authenticated&&e.redirect&&(window.location.href=e.redirect)}catch(e){console.error("Error checking authentication:",e)}}},221(e,t,n){var o=n(579),r=n(723);let i=null,s=null;const a=document.getElementById("data-health-container");function c(){return i||(a?(i=a.dataset.projectId,i):null)}function l(){return s||(a?(s=a.dataset.repoName,s):null)}function d(e){if(e)try{const t=Intl.supportedValuesOf("timeZone");if(e.innerHTML="",!t.includes("UTC")){const t=document.createElement("option");t.value="UTC",t.textContent="UTC",e.appendChild(t)}t.forEach((t=>{const n=document.createElement("option");n.value=t,n.textContent=t,e.appendChild(n)}));const n=Intl.DateTimeFormat().resolvedOptions().timeZone;("UTC"===n||t.includes(n))&&(e.value=n)}catch(t){console.error("Error populating timezone dropdown:",t);["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Paris","Asia/Tokyo"].forEach((t=>{const n=document.createElement("option");n.value=t,n.textContent=t,e.appendChild(n)})),e.value="UTC"}}const u=Object.freeze(["architecture","frontend_correctness","backend_correctness","template_correctness","style_correctness","design_principles"]);function m(e,t){const n=document.querySelector(`[data-testid="${e}"]`);n&&(t?(n.textContent=t,n.classList.remove("hidden")):(n.textContent="",n.classList.add("hidden")))}function p(e,t){const n=document.querySelector(`[data-testid="${e}"]`);n&&(t?(n.textContent=t,n.classList.remove("hidden")):(n.textContent="",n.classList.add("hidden")))}function y(e){const t=document.querySelector('[data-testid="learn-repo-schedule-message"]');t&&(t.textContent=e||"")}async function f(){const e=c(),t=l();if(!e||!t)return void(0,o.to)("Error","Project information not found.");["learn-repo-analysis-types-error","learn-repo-interval-weeks-error","learn-repo-timezone-error","learn-repo-months-back-error"].forEach((e=>m(e,"")));const n=u.filter((e=>document.querySelector(`[data-testid="learn-repo-analysis-type-${e}"]`)?.checked)),i=parseInt(document.querySelector('[data-testid="learn-repo-interval-weeks-input"]')?.value,10),s=document.querySelector('[data-testid="learn-repo-timezone-select"]')?.value,a=parseInt(document.querySelector('[data-testid="learn-repo-months-back-input"]')?.value,10),d=document.querySelector('[data-testid="learn-repo-pr-limit-input"]')?.value;let p=!1;0===n.length&&(m("learn-repo-analysis-types-error","Please select at least one analysis type."),p=!0),(!Number.isFinite(i)||i<1||i>52)&&(m("learn-repo-interval-weeks-error","Interval must be between 1 and 52 weeks."),p=!0),s||(m("learn-repo-timezone-error","Please select a timezone."),p=!0),(!Number.isFinite(a)||a<1||a>60)&&(m("learn-repo-months-back-error","Months back must be between 1 and 60."),p=!0);let f=null;if(null!=d&&""!==String(d).trim()){const e=parseInt(d,10);!Number.isFinite(e)||e<1?(m("learn-repo-pr-limit-error","PR limit must be a positive integer or left blank."),p=!0):f=e}if(p)return;const h=7*i,_=document.querySelector('[data-testid="learn-repo-schedule-button"]');_&&(_.disabled=!0),(0,r.Cs)();try{const o=await(0,r.H2)(`/setup/data/${e}/schedule-learn-repository`,"POST",{repo_name:t,analysis_types:n,interval_days:h,timezone:s,months_back:a,limit:f});if(o){if(null!=o.recommended_hour){const e=o.recommended_hour;y(`Scheduled for ${e} AM every ${`${i} week${1!==i?"s":""}`} (${s})`)}await g(e)}}catch(e){console.error("Failed to schedule Learn Repository Job",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to schedule Learn Repository Job."))}finally{_&&(_.disabled=!1),(0,r.RZ)()}}function h(e,t){const n=document.createElement("div");n.className="learn-repo-schedule-row",n.dataset.testid="learn-repo-schedule-row",n.dataset.repoName=t.repo_name||"",n.dataset.jobType=t.job_type||"";const i=document.createElement("strong");i.textContent=t.repo_name||"",n.appendChild(i);const s=Array.isArray(t.analysis_types)?t.analysis_types.join(", "):"",a=document.createElement("div");a.className="learn-repo-schedule-meta";const l=t.interval_days||0,d=l%7==0?l/7:null,u=null!=d?`Every ${d} weeks`:`Every ${l} days`,m=null!=t.limit?`, PR limit ${t.limit}`:"";a.textContent=`${s} — ${u} — ${t.timezone||""} — ${t.months_back||0} months back${m}`,n.appendChild(a);const p=document.createElement("div");p.dataset.testid="learn-repo-last-run-at",p.textContent=`Last run: ${t.last_run_at||"never"}`,n.appendChild(p);const f=document.createElement("div");f.dataset.testid="learn-repo-last-status";const h=t.last_status||"idle";f.textContent=`Status: ${h}`,f.classList.add(`learn-repo-status-${h}`),t.paused&&(f.textContent+=" (paused)"),t.scheduler_missing&&(f.textContent+=" (scheduler missing)"),n.appendChild(f);const _=document.createElement("div");if(_.dataset.testid="learn-repo-next-run-time",_.textContent=`Next run: ${t.scheduler_missing?"not scheduled (scheduler missing)":t.next_run_time||"none"}`,n.appendChild(_),t.last_diff_summary){const e=document.createElement("div");e.dataset.testid="learn-repo-diff-summaries",v=e,E=t.last_diff_summary,v.textContent="",E&&"object"==typeof E&&Object.entries(E).forEach((([e,t])=>{const n=document.createElement("details");n.dataset.testid=`learn-repo-diff-summary-${e}`;const o=document.createElement("summary");o.dataset.testid=`learn-repo-diff-summary-toggle-${e}`,o.textContent=e;const r=document.createElement("pre");r.dataset.testid=`learn-repo-diff-summary-content-${e}`,r.textContent=null==t?"":String(t),n.appendChild(o),n.appendChild(r),v.appendChild(n)})),n.appendChild(e)}var v,E;const b=document.createElement("div");if(b.className="learn-repo-row-actions",t.paused){const e=document.createElement("button");e.type="button",e.className="btn btn-sm btn-secondary",e.textContent="Resume",e.dataset.testid="learn-repo-resume-button",e.addEventListener("click",(()=>async function(e){const t=c();if(!t||!e)return;(0,r.Cs)();try{await(0,r.H2)(`/setup/data/${t}/resume-learn-repository-job`,"POST",{repo_name:e}),await g(t)}catch(e){console.error("Failed to resume Learn Repository Job",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to resume Learn Repository Job."))}finally{(0,r.RZ)()}}(t.repo_name))),b.appendChild(e)}else{const e=document.createElement("button");e.type="button",e.className="btn btn-sm btn-secondary",e.textContent="Pause",e.dataset.testid="learn-repo-pause-button",e.addEventListener("click",(()=>async function(e){const t=c();if(!t||!e)return;(0,r.Cs)();try{await(0,r.H2)(`/setup/data/${t}/pause-learn-repository-job`,"POST",{repo_name:e}),await g(t)}catch(e){console.error("Failed to pause Learn Repository Job",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to pause Learn Repository Job."))}finally{(0,r.RZ)()}}(t.repo_name))),b.appendChild(e)}const w=document.createElement("button");w.type="button",w.className="btn btn-sm btn-danger",w.textContent="Delete",w.dataset.testid="learn-repo-delete-button",w.addEventListener("click",(()=>async function(e){const t=c();if(!t||!e)return;(0,r.Cs)();try{await(0,r.H2)(`/setup/data/${t}/scheduled-learn-repository-job`,"DELETE",{repo_name:e}),y(`Schedule deleted for ${e}.`),await g(t)}catch(e){console.error("Failed to delete Learn Repository Job schedule",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to delete Learn Repository Job schedule."))}finally{(0,r.RZ)()}}(t.repo_name))),b.appendChild(w),n.appendChild(b),e.appendChild(n)}async function g(e){const t=document.querySelector('[data-testid="learn-repo-schedule-status"]');if(t)try{const n=await(0,r.H2)(`/setup/data/${e}/scheduled-jobs`,"GET");t.textContent="";(n&&n.jobs||[]).forEach((e=>{"learn_repo_auto"===e.job_type&&h(t,e)}))}catch(e){console.error("Failed to load scheduled jobs",e)}}async function _(){const e=c(),t=l();if(!e||!t)return void(0,o.to)("Error","Project information not found.");const n=document.getElementById("update-repository-btn");n&&(n.disabled=!0,n.textContent="Processing..."),(0,r.Cs)();try{const t=await(0,r.H2)(`/setup/data/${e}/parse-repository`,"POST");(0,r.RZ)(),t&&"success"===t.status&&(0,o.to)("Job Started",t.message||"Repository update started in the background.")}catch(e){console.error("Repository update error:",e),(0,r.RZ)(),(0,o.to)("Error",(0,r.SU)(e,"Failed to start repository update. Please try again."))}finally{n&&(n.disabled=!1,n.textContent="Update Repository")}}async function v(){const e=c(),t=l();if(!e||!t)return void(0,o.to)("Error","Project information not found.");["schedule-interval-error","schedule-timezone-error"].forEach((e=>p(e,"")));const n=document.getElementById("schedule-interval"),i=document.getElementById("schedule-timezone"),s=document.getElementById("schedule-repository-btn"),a=parseInt(n?.value,10),d=i?.value;let u=!1;if(d||(p("schedule-timezone-error","Please select a timezone."),u=!0),(!Number.isFinite(a)||a<1||a>365)&&(p("schedule-interval-error","Interval must be between 1 and 365 days."),u=!0),!u){s&&(s.disabled=!0,s.textContent="Scheduling..."),(0,r.Cs)();try{const n=await(0,r.H2)(`/setup/data/${e}/schedule-parse-repository`,"POST",{repo_name:t,interval:a,timezone:d});if((0,r.RZ)(),n&&"scheduled"===n.status){const e=n.next_run_time?new Date(n.next_run_time).toLocaleString():"Not scheduled";(0,o.to)("Success",`Repository parsing scheduled successfully! Next run: ${e}`)}}catch(e){console.error("Repository scheduling error:",e),(0,r.RZ)(),(0,o.to)("Error",(0,r.SU)(e,"Failed to schedule repository parsing. Please try again."))}finally{s&&(s.disabled=!1,s.textContent="Schedule Repository Parsing")}}}async function E(){const e=c(),t=l();if(!e||!t)return void(0,o.to)("Error","Project information not found.");const n=document.getElementById("pause-schedule-btn");n&&(n.disabled=!0,n.textContent="Pausing...");try{await(0,r.H2)(`/setup/data/${e}/pause-parse-schedule`,"POST",{repo_name:t}),window.location.reload()}catch(e){console.error("Pause schedule error:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to pause scheduled parsing. Please try again.")),n&&(n.disabled=!1,n.textContent="Pause")}}async function b(){const e=c(),t=l();if(!e||!t)return void(0,o.to)("Error","Project information not found.");const n=document.getElementById("resume-schedule-btn");n&&(n.disabled=!0,n.textContent="Resuming...");try{await(0,r.H2)(`/setup/data/${e}/resume-parse-schedule`,"POST",{repo_name:t}),window.location.reload()}catch(e){console.error("Resume schedule error:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to resume scheduled parsing. Please try again.")),n&&(n.disabled=!1,n.textContent="Resume")}}async function w(){const e=c(),t=l();e&&t?(0,o.to)("Cancel Scheduled Parsing",`Are you sure you want to cancel the scheduled parsing job for <strong>${t}</strong>? This cannot be undone.`,(async()=>{const n=document.getElementById("cancel-schedule-btn");n&&(n.disabled=!0,n.textContent="Cancelling...");try{await(0,r.H2)(`/setup/data/${e}/schedule-parse-repository`,"DELETE",{repo_name:t}),window.location.reload()}catch(e){console.error("Cancel schedule error:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to cancel scheduled parsing. Please try again.")),n&&(n.disabled=!1,n.textContent="Cancel")}}),!0):(0,o.to)("Error","Project information not found.")}async function C(){const e=c();if(!e)return void(0,o.to)("Error","Project information not found.");const t=document.getElementById("update-labels-btn");t&&(t.disabled=!0,t.textContent="Processing..."),(0,r.Cs)();try{const t=await(0,r.H2)(`/setup/data/${e}/update-labels`,"POST");(0,r.RZ)(),t&&"success"===t.status&&(0,o.to)("Job Started",t.message||"File label update started in the background.")}catch(e){console.error("Update labels error:",e),(0,r.RZ)(),(0,o.to)("Error",(0,r.SU)(e,"Failed to start file label update. Please try again."))}finally{t&&(t.disabled=!1,t.textContent="Update File Labels")}}async function x(e){document.getElementById("pinecone-health-loading"),document.getElementById("pinecone-health-error");const t=document.getElementById("pinecone-health-no-results"),n=document.getElementById("pinecone-health-results"),o=document.getElementById("pinecone-health-all-good"),i=document.getElementById("pinecone-namespace-container"),s=document.getElementById("pinecone-namespace-tbody"),a=document.getElementById("pinecone-failures-container"),c=document.getElementById("pinecone-failures-tbody"),l=document.getElementById("pinecone-health-status"),d=document.getElementById("pinecone-health-last-run"),u=document.getElementById("pinecone-expected-count"),m=document.getElementById("pinecone-actual-count"),p=document.getElementById("pinecone-mismatch-count"),y=document.getElementById("pinecone-sample-failures");try{const f=await(0,r.H2)(`/setup/setup-detail/${e}/pinecone-health-check`,"GET");if(!f)return t&&t.classList.remove("hidden"),void(n&&n.classList.add("hidden"));if(t&&t.classList.add("hidden"),n&&n.classList.remove("hidden"),l&&(l.textContent=f.status.toUpperCase(),l.className="pinecone-health-status","healthy"===f.status?l.classList.add("status-healthy"):"error"===f.status?l.classList.add("status-error"):"warning"===f.status?l.classList.add("status-warning"):"running"===f.status&&l.classList.add("status-running")),d&&f.created_at){const e=new Date(f.created_at);d.textContent=`Last run: ${e.toLocaleString()}`}u&&(u.textContent=f.total_expected||0),m&&(m.textContent=f.total_actual||0),p&&(p.textContent=f.total_mismatches||0,f.total_mismatches>0?p.style.color="#dc2626":p.style.color="#16a34a"),y&&(y.textContent=f.sample_failures||0,f.sample_failures>0?y.style.color="#dc2626":y.style.color="#16a34a");if(f.total_mismatches>0||f.sample_failures>0){if(o&&o.classList.add("hidden"),i&&s&&f.namespace_results){i.classList.remove("hidden"),s.innerHTML="";for(const[e,t]of Object.entries(f.namespace_results)){const n=document.createElement("tr"),o=document.createElement("td");o.textContent=e,o.style.fontWeight="500",n.appendChild(o);const r=document.createElement("td");r.textContent=t.type.replace("_"," "),n.appendChild(r);const i=document.createElement("td");i.textContent=t.expected,n.appendChild(i);const a=document.createElement("td");a.textContent=t.actual,n.appendChild(a);const c=document.createElement("td");c.textContent=t.delta,0!==t.delta&&(c.style.color="#dc2626",c.style.fontWeight="600"),n.appendChild(c);const l=document.createElement("td");t.match?(l.textContent="✅ Match",l.style.color="#16a34a"):(l.textContent="❌ Mismatch",l.style.color="#dc2626"),n.appendChild(l),s.appendChild(n)}}a&&c&&f.sample_failure_details&&f.sample_failure_details.length>0?(a.classList.remove("hidden"),c.innerHTML="",f.sample_failure_details.forEach((e=>{const t=document.createElement("tr"),n=document.createElement("td");n.textContent=e.namespace,t.appendChild(n);const o=document.createElement("td");o.textContent=e.type,t.appendChild(o);const r=document.createElement("td");r.textContent=e.file_name||"-",t.appendChild(r);const i=document.createElement("td");"missing_record"===e.type?i.textContent=e.message||"Vector not found in Pinecone":"metadata_mismatch"===e.type?i.textContent=`${e.field}: expected ${JSON.stringify(e.expected)}, got ${JSON.stringify(e.actual)}`:i.textContent=JSON.stringify(e),t.appendChild(i),c.appendChild(t)}))):a&&a.classList.add("hidden")}else o&&o.classList.remove("hidden"),i&&i.classList.add("hidden"),a&&a.classList.add("hidden")}catch(e){console.error("Error loading Pinecone health:",e),t&&t.classList.remove("hidden"),n&&n.classList.add("hidden")}}async function I(e){const t=function(){const e=document.querySelectorAll('input[name="regenerate-namespace"]:checked');return Array.from(e).map((e=>e.value))}(),n=document.getElementById("regenerate-pinecone-btn");if(0===t.length)return void(0,o.to)("Selection Required","Please select at least one namespace to regenerate.");const i=`\n <p><strong>Notice:</strong> This action will:</p>\n <ul>\n <li>Delete existing data in the selected Pinecone namespace(s)</li>\n <li>Re-upload all data from Postgres</li>\n </ul>\n <p><strong>Selected namespaces:</strong></p>\n <ul>\n ${t.map((e=>{switch(e){case"code_chunks":return"Code Chunks";case"summaries":return"File Summaries";case"metadata_summaries":return"Metadata Summaries";default:return e}})).map((e=>`<li>${e}</li>`)).join("")}\n </ul>\n <p>This operation could take up to 30 minutes for large repositories.</p>\n <p>Do you want to proceed?</p>\n `;(0,o.to)("Confirm Regeneration",i,(async()=>{n&&(n.disabled=!0,n.textContent="Starting...");try{const n=await(0,r.H2)(`/setup/setup-detail/${e}/pinecone-regenerate`,"POST",{namespaces:t});n&&"accepted"===n.status?((0,o.to)("Regeneration Started",`Regeneration has been started for ${t.length} namespace(s). This process runs in the background and may take several minutes. Check Sentry logs or run a health check later to verify completion.`),document.querySelectorAll('input[name="regenerate-namespace"]:checked').forEach((e=>{e.checked=!1}))):(0,o.to)("Error",n?.message||"Failed to start regeneration. Please try again.")}catch(e){console.error("Error triggering Pinecone regeneration:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to start regeneration. Please try again."))}finally{n&&(n.disabled=!1,n.textContent="Regenerate Selected")}}),!0)}async function k(e){const t=document.getElementById("config-health-loading"),n=document.getElementById("config-health-error"),i=document.getElementById("config-health-results"),s=document.getElementById("config-health-all-good"),a=document.getElementById("config-errors-container"),c=document.getElementById("config-warnings-container"),l=document.getElementById("config-errors-tbody"),d=document.getElementById("config-warnings-tbody"),u=document.getElementById("config-total-required"),m=document.getElementById("config-configured"),p=document.getElementById("config-errors-count"),y=document.getElementById("config-warnings-count");t&&t.classList.remove("hidden"),n&&n.classList.add("hidden"),i&&i.classList.add("hidden");try{const f=await(0,r.H2)(`/setup/data/${e}/config-health`,"GET");if(t&&t.classList.add("hidden"),!f)return void(n&&n.classList.remove("hidden"));i&&i.classList.remove("hidden"),u&&(u.textContent=f.total_required_fields||0),m&&(m.textContent=f.configured_fields||0),p&&(p.textContent=f.error_count||0),y&&(y.textContent=f.warning_count||0),f.errors&&0!==f.errors.length||f.warnings&&0!==f.warnings.length?(s&&s.classList.add("hidden"),f.errors&&0!==f.errors.length?(a&&a.classList.remove("hidden"),l&&(l.innerHTML="",f.errors.forEach((e=>{const t=document.createElement("tr"),n=document.createElement("td");n.textContent=e.display_name,n.style.fontWeight="500",t.appendChild(n);const o=document.createElement("td");o.textContent=e.section,t.appendChild(o);const r=document.createElement("td");r.textContent=e.status,r.style.fontWeight="600",r.style.color="missing"===e.status?"#dc2626":"#ea580c",r.style.textTransform="capitalize",t.appendChild(r);const i=document.createElement("td");i.textContent=e.description,t.appendChild(i),l.appendChild(t)})))):a&&a.classList.add("hidden"),f.warnings&&0!==f.warnings.length?(c&&c.classList.remove("hidden"),d&&(d.innerHTML="",f.warnings.forEach((t=>{const n=document.createElement("tr"),i=document.createElement("td");i.textContent=t.display_name,i.style.fontWeight="500",n.appendChild(i);const s=document.createElement("td");s.textContent=t.section,n.appendChild(s);const a=document.createElement("td");a.textContent=t.description,n.appendChild(a);const c=document.createElement("td"),l=document.createElement("button");l.textContent="Dismiss",l.className="btn-text",l.dataset.fieldName=t.field_name,l.addEventListener("click",(()=>async function(e,t){try{await(0,r.H2)(`/setup/data/${e}/config-health/dismiss-warning`,"POST",{field_name:t}),await k(e)}catch(e){console.error("[ERROR] Failed to dismiss warning:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to dismiss warning. Please try again."))}}(e,t.field_name))),c.appendChild(l),n.appendChild(c),d.appendChild(n)})))):c&&c.classList.add("hidden")):(s&&s.classList.remove("hidden"),a&&a.classList.add("hidden"),c&&c.classList.add("hidden"))}catch(e){console.error("[ERROR] Failed to load config health:",e),t&&t.classList.add("hidden"),n&&n.classList.remove("hidden")}}async function S(e){!async function(e){const t=document.getElementById("integrity-loading"),n=document.getElementById("integrity-error"),o=document.getElementById("integrity-results"),i=document.getElementById("integrity-empty-state"),s=document.getElementById("integrity-issues-container"),a=document.getElementById("integrity-issues-tbody"),c=document.getElementById("integrity-total-files"),l=document.getElementById("integrity-healthy-files");t&&t.classList.remove("hidden"),n&&n.classList.add("hidden"),o&&o.classList.add("hidden");try{const d=await(0,r.H2)(`/setup/data/${e}/integrity`,"GET");if(t&&t.classList.add("hidden"),!d)return void(n&&n.classList.remove("hidden"));o&&o.classList.remove("hidden"),c&&(c.textContent=d.total_files||0),l&&(l.textContent=d.healthy_files||0),d.issues&&0!==d.issues.length?(i&&i.classList.add("hidden"),s&&s.classList.remove("hidden"),a&&(a.innerHTML="",d.issues.forEach((e=>{const t=document.createElement("tr"),n=document.createElement("td");n.textContent=e.check_name,n.style.fontWeight="500",t.appendChild(n);const o=document.createElement("td");o.textContent=e.description,t.appendChild(o);const r=document.createElement("td");r.textContent=e.affected_count,r.style.fontWeight="600",r.style.color="#dc2626",t.appendChild(r);const i=document.createElement("td");if(e.affected_files&&e.affected_files.length>0){const t=document.createElement("ul");if(t.className="integrity-file-list",e.affected_files.forEach((e=>{const n=document.createElement("li");n.textContent=e,t.appendChild(n)})),i.appendChild(t),e.affected_count>e.affected_files.length){const t=document.createElement("div");t.className="integrity-more-files",t.textContent=`...and ${e.affected_count-e.affected_files.length} more`,i.appendChild(t)}}else i.textContent="-";t.appendChild(i),a.appendChild(t)})))):(i&&i.classList.remove("hidden"),s&&s.classList.add("hidden"))}catch(e){console.error("Error loading data integrity:",e),t&&t.classList.add("hidden"),n&&n.classList.remove("hidden")}}(e),k(e),x(e)}document.addEventListener("DOMContentLoaded",(async function(){if(window.location.pathname.startsWith("/setup/data/")){(0,o.QJ)();const e=c();if(!e)return void(0,o.to)("Error","Project ID not found.");(0,r.zS)({root:document,drawerSelector:"#data-health-container .drawer"}),d(document.getElementById("schedule-timezone")),d(document.getElementById("learn-repo-timezone"));const t=document.getElementById("update-repository-btn");t&&t.addEventListener("click",_);const n=document.getElementById("schedule-repository-btn");n&&n.addEventListener("click",v);const i=document.getElementById("pause-schedule-btn");i&&i.addEventListener("click",E);const s=document.getElementById("resume-schedule-btn");s&&s.addEventListener("click",b);const a=document.getElementById("cancel-schedule-btn");a&&a.addEventListener("click",w);const l=document.getElementById("update-labels-btn");l&&l.addEventListener("click",C);const u=document.getElementById("learn-repo-schedule-btn");u&&u.addEventListener("click",f),g(e);const m=document.getElementById("run-pinecone-health-check");m&&m.addEventListener("click",(()=>async function(e){const t=document.getElementById("pinecone-health-loading"),n=document.getElementById("pinecone-health-error"),o=document.getElementById("pinecone-health-error-message"),i=document.getElementById("pinecone-health-no-results"),s=document.getElementById("pinecone-health-results"),a=document.getElementById("run-pinecone-health-check");a&&(a.disabled=!0,a.textContent="Running..."),t&&t.classList.remove("hidden"),n&&n.classList.add("hidden"),i&&i.classList.add("hidden"),s&&s.classList.add("hidden");try{const i=await(0,r.H2)(`/setup/setup-detail/${e}/pinecone-health-check`,"POST");if(t&&t.classList.add("hidden"),!i)return n&&n.classList.remove("hidden"),void(o&&(o.textContent="Failed to run health check. Please try again."));if("error"===i.status&&i.message)return n&&n.classList.remove("hidden"),void(o&&(o.textContent=i.message));await x(e)}catch(e){console.error("Error triggering Pinecone health check:",e),t&&t.classList.add("hidden"),n&&n.classList.remove("hidden"),o&&(o.textContent="Failed to run health check. Please try again.")}finally{a&&(a.disabled=!1,a.textContent="Run Health Check")}}(e)));const p=document.getElementById("regenerate-pinecone-btn");p&&p.addEventListener("click",(()=>I(e))),document.querySelectorAll(".info-tooltip-btn").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation();const n=e.dataset.namespace,o=document.getElementById(`info-${n}`);o&&o.classList.toggle("hidden")}))})),await S(e)}}))},567(e,t,n){async function o(e){try{if(!(await fetch(`/setup/projects/${e}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete project");return!0}catch(e){return!1}}n.d(t,{N:()=>o,o:()=>u});let r=null,i=null,s=null,a=null,c=null,l=null,d=null;function u(e,t,n){function o(){a.value===e?c.textContent="":a.value.length>0?c.textContent="Project name does not match.":c.textContent=""}function m(){y(),n&&n()}function p(){a.value===e&&(y(),t&&t())}function y(){r.style.display="none",i.style.display="none",a.removeEventListener("input",o),l.removeEventListener("click",m),i.removeEventListener("click",m),d.removeEventListener("click",p)}r||(r=document.getElementById("delete-project-modal"),i=document.getElementById("delete-project-modal-overlay"),s=document.getElementById("delete-project-modal-project-name"),a=document.getElementById("delete-project-modal-input"),c=document.getElementById("delete-project-modal-error"),l=document.getElementById("delete-project-modal-cancel"),d=document.getElementById("delete-project-modal-confirm")),a.value="",c.textContent="",s.textContent=e,a.addEventListener("input",o),l.addEventListener("click",m),i.addEventListener("click",m),d.addEventListener("click",p),r.style.display="block",i.style.display="block",setTimeout((()=>a.focus()),100),u.hide=y}},302(e,t,n){var o=n(579),r=n(723);let i=null;async function s(e){if(navigator.clipboard&&navigator.clipboard.writeText)return void await navigator.clipboard.writeText(e);const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function a(e){let t=String(null==e?"":e).trim().toLowerCase().replace(/[^a-z0-9._+-]/g,"-").replace(/^[._+-]+/,"").replace(/[._+-]+$/,"");return t||(t="project"),`install+${t}@bridgegpt-api.com`}function c(e,t){const n=document.getElementById("editor-tabs"),o=document.getElementById("editor-tab-panels");if(!n||!o)return;const r=n.querySelectorAll('[role="tab"]'),i=o.querySelectorAll('[role="tabpanel"]');r.forEach(((t,n)=>{const o=n===e;t.setAttribute("aria-selected",o?"true":"false"),t.setAttribute("tabindex",o?"0":"-1"),t.classList.toggle("active",o)})),i.forEach(((t,n)=>{const o=n===e;t.hidden=!o,t.classList.toggle("hidden",!o)}))}async function l(e){const t=document.getElementById("get-started-loading"),n=document.getElementById("get-started-error"),o=document.getElementById("get-started-content");t&&t.classList.remove("hidden"),n&&n.classList.add("hidden"),o&&o.classList.add("hidden");try{const n=await(0,r.H2)(`/setup/install-instructions?projectId=${encodeURIComponent(e)}`,"GET");if(!n)return;t&&t.classList.add("hidden");const a=document.getElementById("get-started-container");a&&n.repo_name&&(a.dataset.repoName=n.repo_name);const l=document.getElementById("get-started-repo-label");l&&(l.textContent=`Project: ${n.repo_name}`),function(e){const t=document.getElementById("editor-tabs"),n=document.getElementById("editor-tab-panels");t&&n&&(t.innerHTML="",n.innerHTML="",e.forEach(((e,o)=>{const r=`snippet-panel-${e.id}`,i=`snippet-tab-${e.id}`,a=0===o,l=document.createElement("button");l.type="button",l.id=i,l.className="snippet-tab-btn"+(a?" active":""),l.setAttribute("role","tab"),l.setAttribute("aria-selected",a?"true":"false"),l.setAttribute("aria-controls",r),l.setAttribute("tabindex",a?"0":"-1"),l.textContent=e.label,l.addEventListener("click",(()=>c(o))),t.appendChild(l);const d=document.createElement("div");d.id=r,d.className="snippet-panel"+(a?"":" hidden"),d.setAttribute("role","tabpanel"),d.setAttribute("aria-labelledby",i),a||(d.hidden=!0);const u=document.createElement("div");if(u.className="snippet-meta",u.textContent=`${e.target_path} · ${e.language}`,d.appendChild(u),e.notes){const t=document.createElement("p");t.className="snippet-notes",t.textContent=e.notes,d.appendChild(t)}const m=document.createElement("pre"),p=document.createElement("code");p.className=`language-${e.language}`,(e.parts||[]).forEach((e=>{if("api_key"===e.kind){const t=document.createElement("span");t.setAttribute("data-bapi-api-key",""),t.className="bapi-api-key-slot",t.textContent=e.text,p.appendChild(t)}else p.appendChild(document.createTextNode(e.text))})),m.appendChild(p),d.appendChild(m);const y=document.createElement("div");y.className="snippet-copy-row";const f=document.createElement("button");f.type="button",f.className="btn btn-secondary snippet-copy-btn",f.textContent="Copy";const h=document.createElement("span");h.className="copy-status",h.setAttribute("aria-live","polite"),f.addEventListener("click",(async()=>{const e=p.textContent;try{await s(e),h.textContent="Copied!",setTimeout((()=>{h.textContent=""}),2e3)}catch(e){h.textContent="Copy failed"}})),y.appendChild(f),y.appendChild(h),d.appendChild(y),n.appendChild(d)})),i&&d(i))}(n.snippets||[]),function(){const e=document.getElementById("handoff-copy-btn"),t=document.getElementById("handoff-copy-status");e&&t&&e.addEventListener("click",(async()=>{try{await s("/install-bridge"),t.textContent="Copied!",setTimeout((()=>{t.textContent=""}),2e3)}catch(e){t.textContent="Copy failed"}}))}(),function(e){const t=document.getElementById("install-status-summary"),n=document.getElementById("install-status-groups");if(!t||!n)return;if(!e||!e.available)return t.innerHTML='<p class="status-empty">No configuration found for this project.</p>',void(n.innerHTML="");const{summary:o,groups:r}=e;if(o){const e=document.createElement("div");e.className="status-summary";const n=document.createElement("span");n.className="status-chip status-set",n.textContent=`${o.set} Set`;const r=document.createElement("span");r.className="status-chip status-unset",r.textContent=`${o.unset} Unset`;const i=document.createElement("span");i.className="status-total",i.textContent=`of ${o.total} fields`,e.appendChild(n),e.appendChild(r),e.appendChild(i),t.appendChild(e)}r&&0!==r.length?(n.innerHTML="",r.forEach((e=>{if(!e.fields||0===e.fields.length)return;const t=document.createElement("div");t.className="status-group";const o=document.createElement("h3");o.className="status-group-title",o.textContent=e.title||e.key,t.appendChild(o),e.fields.forEach((e=>{const n=document.createElement("div");n.className="status-field-row";const o=document.createElement("span");o.className="status-chip "+(e.is_set?"status-set":"status-unset"),o.textContent=e.is_set?"Set":"Unset";const r=document.createElement("span");if(r.className="status-field-name",r.textContent=e.field_name,n.appendChild(o),n.appendChild(r),null!==e.current_value&&void 0!==e.current_value){const t=document.createElement("span");t.className="status-field-value";const o="object"==typeof e.current_value?JSON.stringify(e.current_value):String(e.current_value);t.textContent=o,n.appendChild(t)}t.appendChild(n)})),n.appendChild(t)}))):n.innerHTML='<p class="status-empty">No configuration fields found.</p>'}(n.install_status),o&&o.classList.remove("hidden")}catch(e){t&&t.classList.add("hidden"),o&&o.classList.add("hidden");const i=document.getElementById("get-started-error-msg");i&&(i.textContent=(0,r.SU)(e,"Failed to load install instructions.")),n&&n.classList.remove("hidden")}}function d(e){const t=document.querySelectorAll("#get-started-container [data-bapi-api-key]");return t.forEach((t=>{t.textContent=e,t.classList.add("bapi-api-key-slot-filled")})),t.length}function u(e){const t=document.getElementById("generate-install-key-btn"),n=document.getElementById("install-key-panel"),o=document.getElementById("install-key-error");e?(o&&(o.textContent="",o.classList.add("hidden")),t&&(t.disabled=!0,t.textContent="Generating…"),n&&n.setAttribute("aria-busy","true")):(t&&(t.disabled=!1,t.textContent="Generate install key"),n&&n.removeAttribute("aria-busy"))}function m(e){const t=document.getElementById("install-key-error");t&&(t.textContent=e||"Could not generate the install key. Please try again.",t.classList.remove("hidden"))}async function p(){const e=document.getElementById("get-started-container");if(!e)return;if(i)return;const t=e.dataset.repoName;if(!t)return void m("Could not generate the install key. Please try again.");u(!0);const n={email:a(t),repo_name:t,name:"Easy Install",role:"admin"};let o,r;try{o=await fetch("/setup/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch(e){return u(!1),void m("Could not generate the install key. Please try again.")}if(201!==o.status)return u(!1),void m("Could not generate the install key. Please try again.");try{r=await o.json()}catch(e){return u(!1),void m("Could not generate the install key. Please try again.")}const s=r&&r.api_key;if(!s)return u(!1),void m("Could not generate the install key. Please try again.");i=s;const c=document.getElementById("generated-install-key");c&&(c.value=s);const l=document.getElementById("install-key-result");l&&l.classList.remove("hidden"),d(s);const p=document.getElementById("install-key-status");p&&(p.textContent="Admin install key generated and inserted into the snippets.");const y=document.getElementById("generate-install-key-btn"),f=document.getElementById("install-key-panel");y&&(y.disabled=!0,y.textContent="Install key generated"),f&&f.removeAttribute("aria-busy");const h=document.getElementById("copy-install-key-btn");h?h.focus():c&&c.focus()}!function(){const e=document.getElementById("get-started-container");if(!e)return;(0,o.QJ)(),function(e){if(!e)return;const t=document.getElementById("generate-install-key-btn");if(!t)return;t.addEventListener("click",p);const n=document.getElementById("copy-install-key-btn"),o=document.getElementById("generated-install-key"),r=document.getElementById("copy-install-key-status");n&&o&&n.addEventListener("click",(async()=>{const e=o.value;if(e)try{await s(e),r&&(r.textContent="Copied!"),n.textContent="Copied!",setTimeout((()=>{n.textContent="Copy"}),2e3)}catch(e){r&&(r.textContent="Copy failed")}}))}(e);const t=document.getElementById("editor-tabs");t&&t.addEventListener("keydown",(e=>{const n=Array.from(t.querySelectorAll('[role="tab"]'));if(!n.length)return;const o=n.findIndex((e=>"true"===e.getAttribute("aria-selected")));let r=o;if("ArrowRight"===e.key)r=(o+1)%n.length;else if("ArrowLeft"===e.key)r=(o-1+n.length)%n.length;else if("Home"===e.key)r=0;else{if("End"!==e.key)return;r=n.length-1}e.preventDefault(),c(r),n[r].focus()}));const n=new URLSearchParams(window.location.search).get("projectId"),i=document.getElementById("setup-detail-link");i&&n&&(i.href=`/setup/setup-detail?projectId=${encodeURIComponent(n)}`);const a=document.getElementById("continue-setup-link");a&&n&&(a.href=`/setup/setup-detail?projectId=${encodeURIComponent(n)}`),(0,r.zS)({root:document,drawerSelector:"#get-started-container .drawer"});const d=document.getElementById("get-started-retry-btn");if(d&&d.addEventListener("click",(()=>{n&&l(n)})),!n){const e=document.getElementById("get-started-loading"),t=document.getElementById("get-started-error"),n=document.getElementById("get-started-error-msg");return e&&e.classList.add("hidden"),n&&(n.textContent="Missing projectId — please navigate here from your project dashboard."),void(t&&t.classList.remove("hidden"))}l(n)}()},523(e,t,n){n.d(t,{X:()=>h});var o=n(723),r=n(579),i=n(575),s=n(455),a=n(995),c=n(225),l=n(87);const d=new Map;let u=null;const m="global-learning",p=3e4,y=6e5;let f=null;async function h(e=(0,i.z)()){if(f=e&&e.repoName,f){try{const e=await(0,o.H2)(`/optimize/learn-repository/${(0,i.$)(f)}/status`,"GET");e?_(e):E("Failed to load repository learning status","error")}catch(e){console.error("Error fetching learn repository status:",e),E("Error loading repository learning status","error")}s.rz.forEach((e=>{const t=(0,l.zM)(e),n=document.getElementById(`lr-${t}-approve`);n&&n.addEventListener("click",(()=>async function(e){const t=(0,l.zM)(e),n="Are you sure you want to approve these clarifications? (You will still be able to edit this later in the configuration panel if needed)";if(!await(i="Confirm Approval",s=n,new Promise((e=>{let t=!1;(0,r.to)(i,s,(()=>{t=!0,e(!0)}),!0,(()=>{t||e(!1)}))}))))return;var i,s;const a=document.getElementById(`lr-${t}-approve`),c=document.getElementById(`lr-${t}-textarea`),d=a?a.textContent:null,m=c?c.value:"";try{if(a&&(a.disabled=!0,a.textContent="Processing..."),!await(0,o.H2)("/optimize/learn-repository/approve-instructions","POST",{repo_name:f,analysis_type:e,clarifications:m}))return void(a&&(a.disabled=!1,a.textContent=d));const t=u&&u[e]&&u[e].instructions||"";(0,l.N7)(e,{instructions:m}),v(e,{mode:"approve",priorInstructions:t}),(0,r.to)("Success","Instructions approved. The AI is generating updated instructions — this section will refresh automatically when ready.")}catch(e){console.error("Error approving instructions:",e),(0,r.to)("Error",(0,o.SU)(e,"Failed to approve instructions. Please try again.")),a&&(a.disabled=!1,a.textContent=d)}}(e)));const i=document.getElementById(`lr-${t}-save`);i&&i.addEventListener("click",(()=>async function(e){const t=(0,l.zM)(e),n=document.getElementById(`lr-${t}-save`),i=document.getElementById(`lr-${t}-textarea`),s=n?n.textContent:null;if(i?.value.trim())try{n&&(n.disabled=!0,n.textContent="Saving..."),await(0,o.H2)("/optimize/learn-repository/save-instructions","POST",{repo_name:f,analysis_type:e,instructions_text:i?i.value:""})&&(0,r.to)("Success","Instructions saved successfully.")}catch(e){console.error("Error saving instructions:",e),(0,r.to)("Error",(0,o.SU)(e,"Failed to save instructions. Please try again."))}finally{n&&(n.disabled=!1,n.textContent=s)}}(e)))})),document.querySelectorAll(".lr-reanalyze-link").forEach((e=>{e.addEventListener("click",(()=>{e.classList.add("hidden");const t=e.closest(".reanalyze-container"),n=t?.querySelector(".lr-reanalyze-options");n?.classList.remove("hidden");const o=n?.querySelector('input[value="auto_complete"]');o?.focus()}))})),document.querySelectorAll(".lr-reanalyze-confirm-btn").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault(),async function(e){const t=(0,l.zM)(e),n=document.querySelector(`input[name="lr-${t}-reanalyze-mode"]:checked`),i=n?n.value:"auto_complete",s=document.getElementById(`lr-${t}-textarea`),a=s?s.value:"",c=document.querySelector(`.lr-reanalyze-confirm-btn[data-analysis-type="${e}"]`),d=c?c.textContent:null;try{c&&(c.disabled=!0,c.textContent="Confirming..."),await(0,o.H2)("/optimize/learn-repository/reanalyze","POST",{repo_name:f,analysis_type:e,mode:i})&&((0,l.N7)(e,{instructions:a}),E("Reanalyzing... This may take several minutes.","info"),v(e,{mode:i,priorInstructions:a}))}catch(e){console.error("Error starting reanalyze:",e),(0,r.to)("Error",(0,o.SU)(e,"Failed to start reanalysis. Please try again."))}finally{c&&(c.disabled=!1,c.textContent=d)}}(e.dataset.analysisType)}))})),document.querySelectorAll(".lr-reanalyze-cancel-btn").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault();const n=e.closest(".reanalyze-container"),o=n?.querySelector(".lr-reanalyze-options"),r=n?.querySelector(".lr-reanalyze-link");o?.classList.add("hidden"),r?.classList.remove("hidden");const i=o?.querySelector('input[value="auto_complete"]');i&&(i.checked=!0),r?.focus()}))})),document.querySelectorAll(".lr-accept-draft-btn").forEach((e=>{e.addEventListener("click",(()=>async function(e){const t=(0,l.zM)(e),n=document.getElementById(`lr-${t}-textarea`),s=document.querySelector(`.lr-accept-draft-btn[data-analysis-type="${e}"]`),a=s?s.textContent:null;try{if(s&&(s.disabled=!0,s.textContent="Accepting..."),await(0,o.H2)("/optimize/learn-repository/accept-draft","POST",{repo_name:f,analysis_type:e,instructions_text:n?n.value:""})){(0,r.to)("Success","Draft accepted. Instructions updated.");const e=await(0,o.H2)(`/optimize/learn-repository/${(0,i.$)(f)}/status`,"GET");e&&_(e)}}catch(e){console.error("Error accepting draft:",e),(0,r.to)("Error",(0,o.SU)(e,"Failed to accept draft. Please try again."))}finally{s&&(s.disabled=!1,s.textContent=a)}}(e.dataset.analysisType)))})),document.querySelectorAll(".lr-discard-draft-btn").forEach((e=>{e.addEventListener("click",(()=>async function(e){const t=document.querySelector(`.lr-discard-draft-btn[data-analysis-type="${e}"]`),n=t?t.textContent:null;try{if(t&&(t.disabled=!0,t.textContent="Discarding..."),await(0,o.H2)("/optimize/learn-repository/discard-draft","POST",{repo_name:f,analysis_type:e})){(0,r.to)("Success","Draft discarded.");const e=await(0,o.H2)(`/optimize/learn-repository/${(0,i.$)(f)}/status`,"GET");e&&_(e)}}catch(e){console.error("Error discarding draft:",e),(0,r.to)("Error",(0,o.SU)(e,"Failed to discard draft. Please try again."))}finally{t&&(t.disabled=!1,t.textContent=n)}}(e.dataset.analysisType)))})),document.querySelectorAll(".lr-initial-analyze-btn").forEach((e=>{e.addEventListener("click",(()=>async function(e){const t=(0,l.zM)(e),n=document.querySelector(`input[name="lr-${t}-initial-mode"]:checked`),i=n?n.value:"review";try{if((0,o.Cs)(),await(0,o.H2)("/optimize/learn-repository/start","POST",{repo_name:f,analysis_type:e,mode:i})){const t=e.replace(/_/g," ");E("auto_complete"===i?`Analysis started for ${t}. This section will update automatically when complete.`:`Analysis started for ${t}. Check back later to review the generated clarifications.`,"success");const n="auto_complete"===i?`Analysis is running for ${t}. This section will update automatically when complete — no need to do anything else.`:`Analysis is running for ${t}. Come back later to review the generated clarifications.`;(0,r.to)("Analysis Started",n),(0,l.N7)(e,{}),v(e,"auto_complete"===i?{mode:"auto_complete",priorInstructions:""}:{mode:"review",priorInstructions:"",isInitialRun:!0})}}catch(e){console.error("Error starting initial analysis:",e),E((0,o.SU)(e,"Failed to start analysis. Please try again."),"error")}finally{(0,o.RZ)()}}(e.dataset.analysisType)))}))}else console.error("Repository name not available")}function g(e){e&&(u=e)}function _(e){g(e);const t=(0,s.fX)(e);s.rz.forEach((t=>{(0,l.I3)(t,e[t]||{})})),t.learningInProgress&&!d.get(m)&&function(){!function(){const e=d.get(m);e&&(e.abort(),d.delete(m))}();const e=new AbortController;d.set(m,e);const t=`/optimize/learn-repository/${(0,i.$)(f)}/status`;(0,a.g)(t,(e=>null!=e&&!0!==e.learning_in_progress),{intervalMs:p,timeoutMs:y,continueOnError:!0,signal:e.signal,onTick:e=>{g(e),_(e)}}).then((()=>{d.delete(m),E("Learning analysis complete. Review any generated clarifications below.","success")})).catch((e=>{e&&"AbortError"===e.name||(d.delete(m),e instanceof a.t?E("Learning is taking longer than expected. Please refresh the page to see the latest status.","error"):console.error("Global learning poll error:",e))}))}()}function v(e,{mode:t,priorInstructions:n="",isInitialRun:o=!1}={}){const r=d.get(e);r&&r.abort();const s=new AbortController;d.set(e,s);const c=`/optimize/learn-repository/${(0,i.$)(f)}/status`;let u=!1;(0,a.g)(c,(r=>{if(!r)return!1;const i=r[e];if(!i)return!1;if(o)return!0!==i.reanalyzing;if("approve"===t)return!0===i.reanalyzing?(u=!0,!1):!!u||!!i.instructions&&i.instructions!==n;if("review"===t)return!!i.draft_instructions||!0!==i.reanalyzing;const s=i.instructions&&i.instructions!==n,a=i.conclusions&&i.instructions&&!n;return!(!s&&!a)||!0!==i.reanalyzing}),{intervalMs:p,timeoutMs:y,continueOnError:!0,signal:s.signal,onTick:e=>{g(e)}}).then((r=>{d.delete(e);const i=r[e]||{};if(o)_(r),E("Analysis complete. Review the generated clarifications below.","success");else if("approve"===t)(0,l.jC)(e,i.instructions),i.instructions&&i.instructions!==n?E("Instructions updated successfully.","success"):E("Reanalysis finished but instructions were not updated.","error");else if("review"===t)i.draft_instructions?((0,l.Dm)(e,i.draft_instructions,i.diff_summary),E("Draft ready for review.","success")):((0,l.jC)(e,i.instructions||n),E("Reanalysis completed but no draft was generated.","info"));else{const t=i.instructions&&i.instructions!==n,o=i.conclusions&&i.instructions&&!n;t||o?((0,l.jC)(e,i.instructions),E("Reanalysis complete.","success")):((0,l.jC)(e,i.instructions||n),E("Reanalysis completed but no changes were generated.","info"))}})).catch((t=>{if(!t||"AbortError"!==t.name)if(d.delete(e),t instanceof a.t){const t=(0,l.zM)(e),n=document.getElementById(`lr-${t}-textarea`);n&&(n.disabled=!1),E("Reanalysis is taking longer than expected. Please refresh the page.","error")}else console.error("Polling error:",t)}))}function E(e,t="info"){const n="success"===t?{autoHideMs:1e4}:{};(0,c.o9)("learn-repository-status",e,t,n)}},527(e,t,n){var o=n(579),r=n(246);document.addEventListener("DOMContentLoaded",(async function(){const e=document.getElementById("login-form");e&&e.addEventListener("submit",r.mg);const t=document.getElementById("logout-btn");t&&t.addEventListener("click",r.ri),(0,o.QJ)(),"true"===new URLSearchParams(window.location.search).get("session_expired")&&((0,o.to)("Session Expired","Your session has expired. Please log in again."),window.history.replaceState({},"","/setup/login"))}))},579(e,t,n){n.d(t,{QJ:()=>f,to:()=>m});const o=document.getElementById("modal"),r=document.getElementById("modal-title"),i=document.getElementById("modal-body"),s=document.getElementById("modal-actions"),a=document.getElementById("modal-confirm-btn"),c=document.getElementById("modal-cancel-btn"),l=document.querySelector(".close-modal");let d=null,u=null;function m(e,t,n=null,a=!1,c=null){r&&(r.textContent=e),i&&(i.textContent=t),d=n,u=c,s&&(n&&a?s.classList.remove("hidden"):s.classList.add("hidden")),o?o.style.display="block":console.error("Modal element not found.")}function p(){o?o.style.display="none":console.warn("Modal element not found for hiding."),d=null;const e=u;u=null,e&&e()}function y(){d&&d(),p()}function f(){o&&l?(l.addEventListener("click",p),c&&c.addEventListener("click",p),a&&a.addEventListener("click",y),window.addEventListener("click",(e=>{e.target===o&&p()}))):console.warn("Modal elements not found for initialization.")}},470(e,t,n){var o=n(723);document.addEventListener("DOMContentLoaded",(function(){document.getElementById("monitoring-container")&&(0,o.zS)({root:document,drawerSelector:"#monitoring-container .drawer"})}))},307(e,t,n){var o=n(579),r=n(723),i=n(575),s=n(455),a=n(225),c=n(523),l=n(60);const d=["loading","optimize","running","review"];let u=null;async function m(){let e;h("loading");try{e=await(0,r.H2)(`/optimize/${(0,i.$)(u)}/estimator/status`,"GET")}catch(e){return console.error("Error checking estimator status:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to check estimator status.")),void h("optimize")}if(null===e)return;const t=(0,s.nL)(e);"review"===t.state?function(e){const t=document.getElementById("range-json");t&&(t.value=JSON.stringify(e,null,2));h("review")}(t.meta.rangeJson):"running"===t.state?g(t.meta.message):h("optimize")}async function p(){let e;h("loading");try{e=await(0,r.H2)(`/optimize/${(0,i.$)(u)}/estimator/create-range`,"POST")}catch(e){return console.error("Error starting estimator optimization:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to start optimization.")),void h("optimize")}null!==e&&(e.accepted?(g("Estimator optimization started. This process takes about 30 minutes. Please check back later."),setTimeout((()=>{m()}),3e5)):e.need_estimate_review&&await m())}async function y(){const e=document.getElementById("range-json"),t=e?e.value:"";if(!t.trim())return void(0,o.to)("Error","Please provide range data to save.");let n;try{n=JSON.parse(t)}catch(e){return void(0,o.to)("Error","Invalid JSON format. Please check your range data.")}const s=document.getElementById("save-ranges-btn");try{const e=await(0,a.Z8)(s,"Saving...",(()=>(0,r.H2)(`/optimize/${(0,i.$)(u)}/estimator/save`,"POST",{range:n})));if(null===e)return;e.saved?((0,o.to)("Success","Estimate ranges saved successfully!"),h("optimize")):(0,o.to)("Warning","Ranges could not be saved. Please try again.")}catch(e){console.error("Error saving estimator ranges:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to save ranges."))}}function f(){h("optimize")}function h(e){d.forEach((e=>{document.getElementById(`estimator-${e}`)?.classList.add("hidden")})),document.getElementById(`estimator-${e}`)?.classList.remove("hidden")}function g(e){const t=document.getElementById("estimator-message");t&&e&&(t.textContent=e),h("running")}document.addEventListener("DOMContentLoaded",(function(){if(!window.location.pathname.startsWith("/optimize"))return;if(!document.getElementById("optimize-container"))return;const e=(0,i.z)();(0,r.zS)({root:document,drawerSelector:"#optimize-container .drawer",defaultExpanded:!0}),e.projectId&&async function(e=(0,i.z)()){if(u=e&&e.projectId,!u)return;await m(),document.getElementById("optimize-estimator-btn")?.addEventListener("click",p),document.getElementById("refresh-estimator-btn")?.addEventListener("click",m),document.getElementById("save-ranges-btn")?.addEventListener("click",y),document.getElementById("cancel-review-btn")?.addEventListener("click",f)}(e),e.repoName&&(0,c.X)(e),e.repoName&&(0,l.G)(e)}))},575(e,t,n){function o(e){return null==e||""===e?null:e}function r(e=("undefined"!=typeof document?document:null)){const t=e&&"function"==typeof e.getElementById?e.getElementById("optimize-container"):null,n=t&&t.dataset||{};return{repoName:o(n.repoName),projectId:o(n.projectId),container:t||null}}function i(e){return encodeURIComponent(String(e))}n.d(t,{$:()=>i,z:()=>r})},225(e,t,n){n.d(t,{Z8:()=>i,o9:()=>r});Object.freeze({SAVED:"Saved successfully!",SAVING:"Saving..."});function o(e){return e?"string"==typeof e?"undefined"!=typeof document&&"function"==typeof document.getElementById?document.getElementById(e):null:e:null}function r(e,t,n="info",r={}){const i=o(e);if(!i)return;i.textContent=t,i.className=`status-message ${n}`.trim(),i.classList.remove("hidden");const s=r&&r.autoHideMs;"number"==typeof s&&s>0&&setTimeout((()=>{i.classList.add("hidden")}),s)}async function i(e,t,n){const o=e?e.textContent:null,r=e?e.disabled:null;e&&(e.disabled=!0,"string"==typeof t&&(e.textContent=t));try{return await n()}finally{e&&(e.disabled=r,"string"==typeof t&&(e.textContent=o))}}},87(e,t,n){n.d(t,{Dm:()=>y,I3:()=>h,N7:()=>p,jC:()=>f,zM:()=>s});var o=n(455);const r=["lr-state-idle","lr-state-running","lr-state-review","lr-state-draft","lr-state-complete"],i=["initialContainer","inProgressContainer","textarea","approveBtn","completeStatus","saveBtn","reanalyzeContainer","draftReview"];function s(e){return e.replace(/_/g,"-")}function a(e,t=("undefined"!=typeof document?document:null)){const n=s(e),o=e=>t&&"function"==typeof t.getElementById?t.getElementById(e):null,r=o(`lr-${n}`),i=e=>r&&"function"==typeof r.querySelector?r.querySelector(e):null,a=o(`lr-${n}-reanalyze-container`),c=(e,t)=>e&&"function"==typeof e.querySelector?e.querySelector(t):null;return{sectionId:n,section:r,initialContainer:i(".lr-initial-analyze-container"),inProgressContainer:i(".lr-in-progress-container"),textarea:o(`lr-${n}-textarea`),approveBtn:o(`lr-${n}-approve`),completeStatus:o(`lr-${n}-complete`),saveBtn:o(`lr-${n}-save`),reanalyzeContainer:a,draftReview:o(`lr-${n}-draft-review`),diffDisplay:o(`lr-${n}-diff-summary`),description:i(".section-description"),reanalyzeLink:c(a,".lr-reanalyze-link"),reanalyzeOptions:c(a,".lr-reanalyze-options")}}function c(e,t){e&&e.classList&&(r.forEach((t=>e.classList.remove(t))),t&&e.classList.add(`lr-state-${t}`))}function l(e,t){const n=new Set(t||[]);Object.keys(e||{}).forEach((t=>{const o=e[t];o&&o.classList&&(n.has(t)?o.classList.remove("hidden"):o.classList.add("hidden"))}))}function d(e){const t={};return i.forEach((n=>{t[n]=e[n]})),t}function u(e){e.section&&e.section.classList&&e.section.classList.remove("hidden")}function m(e,t){e.description&&(e.description.textContent=t)}function p(e,t={},n){const o=a(e,n);if(!o.section)return o;u(o),c(o.section,"running");const r=t&&(t.draft_instructions||t.instructions||t.clarifications),i=["inProgressContainer"];return r&&i.push("textarea"),l(d(o),i),o.textarea&&r&&(o.textarea.value=t.draft_instructions||t.instructions||t.clarifications||"",o.textarea.disabled=!0),m(o,"Analysis is running for this section. This card will update when complete."),o}function y(e,t="",n="",o){const r=a(e,o);return r.section?(u(r),c(r.section,"draft"),l(d(r),["textarea","draftReview"]),r.textarea&&(r.textarea.value=t||"",r.textarea.disabled=!1),function(e,t){if(!e)return;e.innerHTML="",(t||"").split("\n").forEach(((t,n,o)=>{e.appendChild(document.createTextNode(t)),n<o.length-1&&e.appendChild(document.createElement("br"))}))}(r.diffDisplay,n),m(r,"Review the draft instructions below. Edit if needed, then Accept or Discard."),r):r}function f(e,t="",n){const o=a(e,n);return o.section?(u(o),c(o.section,"complete"),l(d(o),["textarea","saveBtn","reanalyzeContainer"]),o.textarea&&(o.textarea.value=t||"",o.textarea.disabled=!1),o.reanalyzeOptions&&o.reanalyzeOptions.classList&&o.reanalyzeOptions.classList.add("hidden"),o.reanalyzeLink&&o.reanalyzeLink.classList&&o.reanalyzeLink.classList.remove("hidden"),m(o,"Edit the instructions below and save, or reanalyze to regenerate them."),o):o}function h(e,t={},n){const{state:r}=(0,o.aA)(t);switch(r){case"running":return p(e,t,n);case"draft":return y(e,t.draft_instructions,t.diff_summary,n);case"review":return function(e,t="",n){const o=a(e,n);return o.section?(u(o),c(o.section,"review"),l(d(o),["textarea","approveBtn"]),o.textarea&&(o.textarea.value=t||"",o.textarea.disabled=!1),m(o,"Review the AI's questions about how it should write code to the codebase."),o):o}(e,t.clarifications||"",n);case"complete":return f(e,t.instructions,n);default:return function(e,t){const n=a(e,t);return n.section?(u(n),c(n.section,"idle"),l(d(n),["initialContainer"]),n):n}(e,n)}}},995(e,t,n){n.d(t,{g:()=>s,t:()=>i});var o=n(723);const r=5e3;class i extends Error{constructor(e="Polling timed out"){super(e),this.name="PollTimeoutError"}}function s(e,t,n={}){const{intervalMs:s=r,timeoutMs:a=null,onTick:c=null,onError:l=null,continueOnError:d=!1,signal:u=null,fetcher:m=null,immediate:p=!0}=n||{},y="function"==typeof m?m:()=>(0,o.H2)(e,"GET",null,{signal:u});return new Promise(((e,n)=>{let o=null,r=null,m=!1;const f=()=>{null!==o&&(clearTimeout(o),o=null),null!==r&&(clearTimeout(r),r=null),u&&"function"==typeof u.removeEventListener&&u.removeEventListener("abort",g)},h=e=>{m||(m=!0,f(),n(e))};function g(){const e=u&&u.reason||new DOMException("The poll was aborted.","AbortError");h(e)}const _=()=>{m||(o=setTimeout(v,s))};async function v(){if(m)return;let n;try{n=await y()}catch(e){if(m)return;if(d){if("function"==typeof l)try{l(e)}catch(e){}return void _()}return void h(e)}if(m)return;if("function"==typeof c)try{c(n)}catch(e){}if(m)return;let o=!1;try{o=t(n)}catch(e){return void h(e)}var r;o?(r=n,m||(m=!0,f(),e(r))):_()}if(u){if(u.aborted)return void g();u.addEventListener("abort",g)}null!=a&&(r=setTimeout((()=>{h(new i(`Polling timed out after ${a}ms`))}),a)),p?v():_()}))}},455(e,t,n){n.d(t,{WZ:()=>r,aA:()=>i,fX:()=>s,nL:()=>a,rz:()=>o});const o=Object.freeze(["architecture","frontend_correctness","backend_correctness","template_correctness","style_correctness","design_principles"]);Object.freeze(["idle","running","review","draft","complete","failed","unknown"]);function r(e={}){const t=e||{};if(t.is_locked)return{state:"running",text:"Analysis in progress...",meta:{}};const n=t.analysis_text;return t.complete&&"string"==typeof n&&""!==n.trim()?{state:"complete",text:"Analysis completed!",meta:{analysisText:n}}:{state:"idle",text:"",meta:{}}}function i(e={}){const t=e||{};let n;return n=!0===t.reanalyzing?"running":t.draft_instructions?"draft":t.clarifications&&!t.conclusions?"review":t.conclusions||t.instructions?"complete":"idle",{state:n,meta:t}}function s(e={}){const t=e||{},n={};return o.forEach((e=>{n[e]=i(t[e]||{})})),{learningInProgress:!0===t.learning_in_progress,sections:n}}function a(e={}){const t=e||{};return t.need_estimate_review?t.range_json?{state:"review",meta:{rangeJson:t.range_json}}:{state:"running",meta:{message:t.message}}:{state:"idle",meta:{}}}},60(e,t,n){n.d(t,{G:()=>u});var o=n(579),r=n(723),i=n(575),s=n(995),a=n(455),c=n(225);const l="The AI analyzed your project and wrote the instructions below. Update and correct them as needed, and then click Save when done.",d=new Map;function u(e=(0,i.z)()){e&&e.repoName?(m("build",e),m("unit_test",e),m("e2e_test",e)):console.error("Repository name not available for code analysis")}function m(e,t){const n=t&&t.repoName,s=e.replace(/_/g,"-");if(!document.getElementById(`${s}-section`))return void console.log(`Section ${s} not found, skipping initialization`);const d=document.getElementById(`${s}-user-guidance`),u=document.getElementById(`analyze-${s}-btn`),m=document.getElementById(`${s}-output`),h=document.getElementById(`save-${s}-btn`),g=document.getElementById(`${s}-info-label`);g&&(g.textContent=l),async function(e,t,n){const o=n&&n.repoName,s=`/optimize/analysis/status/${(0,i.$)(o)}/${e}`;let l;try{l=await(0,r.H2)(s,"GET")}catch(n){return console.error(`Error checking status for ${e}:`,n),void p(t)}const d=(0,a.WZ)(l);"running"===d.state?((0,c.o9)(`${t}-status`,"Analysis in progress...","processing"),f(e,t,n)):"complete"===d.state?y(t,d.meta.analysisText):p(t)}(e,s,t),u&&u.addEventListener("click",(async()=>{try{u.disabled=!0,d&&(d.disabled=!0),(0,c.o9)(`${s}-status`,"Starting analysis...","processing");const o={file_label:e,repo_name:n,custom_only:!0,user_guidance:d?d.value:null};await(0,r.H2)("/optimize/analysis/generate","POST",o),(0,c.o9)(`${s}-status`,"Analysis running...","processing"),f(e,s,t)}catch(n){if(n instanceof r.lF&&409===n.status)return(0,c.o9)(`${s}-status`,"Analysis already in progress...","processing"),void f(e,s,t);console.error(`Error starting ${e} analysis:`,n);const i=(0,r.SU)(n,"Failed to start analysis. Please try again.");(0,c.o9)(`${s}-status`,`Error: ${i}`,"error"),(0,o.to)("Error",i),u.disabled=!1,d&&(d.disabled=!1)}})),h&&h.addEventListener("click",(async()=>{const t={file_label:e,repo_name:n,analysis_text:m?m.value:""};try{await(0,c.Z8)(h,"Saving...",(()=>(0,r.H2)("/optimize/analysis/persist","POST",t))),(0,c.o9)(`${s}-status`,"Saved successfully!","success",{autoHideMs:3e3})}catch(t){console.error(`Error saving ${e} analysis:`,t);const n=(0,r.SU)(t,"Failed to save analysis. Please try again.");(0,c.o9)(`${s}-status`,`Error saving: ${n}`,"error"),(0,o.to)("Error",n)}}))}function p(e){const t=document.getElementById(`${e}-state-no-analysis`),n=document.getElementById(`${e}-state-analysis-done`);n&&n.classList.add("hidden"),t&&t.classList.remove("hidden")}function y(e,t){const n=document.getElementById(`${e}-state-no-analysis`),o=document.getElementById(`${e}-state-analysis-done`),r=document.getElementById(`${e}-output`);r&&(r.value=t),n&&n.classList.add("hidden"),o&&o.classList.remove("hidden")}function f(e,t,n){const o=n&&n.repoName,r=`/optimize/analysis/status/${(0,i.$)(o)}/${e}`,a=document.getElementById(`analyze-${t}-btn`),l=document.getElementById(`${t}-user-guidance`),u=d.get(e);u&&u.abort();const m=new AbortController;d.set(e,m);const p=()=>{a&&(a.disabled=!1),l&&(l.disabled=!1)};(0,s.g)(r,(e=>null!=e&&!e.is_locked),{intervalMs:5e3,timeoutMs:null,signal:m.signal,immediate:!1}).then((n=>{d.delete(e),p(),n.complete&&n.analysis_text?((0,c.o9)(`${t}-status`,"Analysis completed!","success"),y(t,n.analysis_text)):(0,c.o9)(`${t}-status`,"Analysis finished. Check results.","warning")})).catch((n=>{n&&"AbortError"===n.name||(d.delete(e),console.error(`Polling error for ${e}:`,n),(0,c.o9)(`${t}-status`,"Error checking status. Please refresh.","error"),p())}))}},889(e,t,n){var o=n(579),r=n(723);let i=null;const s=document.getElementById("project-detail-container"),a=document.getElementById("project-detail-title"),c=document.getElementById("project-info-form"),l=document.getElementById("estimator-form"),d=document.getElementById("code-writer-form"),u=document.getElementById("code-review-form"),m=document.getElementById("save-project-btn"),p=document.getElementById("estimate_scale"),y=document.getElementById("estimate_scale-error");let f=null;function h(e){return Array.isArray(e)?e.filter((e=>null!=e)).map((e=>"string"==typeof e?e.trim():String(e))).filter((e=>""!==e)):[]}function g(){return h(Array.from(document.querySelectorAll("#allowed_providers_group .provider-checkbox")).filter((e=>e.checked||e.disabled)).map((e=>e.value)))}const _=8192,v=Object.freeze({strategy:"poll_only",max_iterations:1,max_minutes:10,instructions:""});function E(e){return(new TextEncoder).encode(e||"").length}function b(){const e=document.querySelector('input[name="ci_followup_strategy"]:checked');return e?e.value:"poll_only"}function w(e){document.querySelectorAll('input[name="ci_followup_strategy"]').forEach((t=>{t.checked=t.value===e.strategy}));const t=document.getElementById("ci_followup_max_iterations");t&&(t.value=e.max_iterations);const n=document.getElementById("ci_followup_max_minutes");n&&(n.value=e.max_minutes);const o=document.getElementById("ci_followup_instructions");o&&(o.value=e.instructions)}function C(){const e=document.getElementById("ci_followup_instructions_byte_count");if(!e)return;const t=document.getElementById("ci_followup_instructions"),n=E(t?t.value:"");e.textContent=`${n}/8192 bytes`,e.classList.toggle("over-limit",n>_)}function x(e={}){const{clearInstructionsOnPollOnly:t=!0}=e,n=b(),o=document.getElementById("ci_followup_instructions");o&&("poll_only"===n?(t&&(o.value=""),o.disabled=!0,o.required=!1):"custom"===n?(o.disabled=!1,o.required=!0):(o.disabled=!1,o.required=!1)),C()}function I(){const e=document.getElementById("ci_followup_enabled"),t=document.getElementById("ci_followup_controls");if(!t)return;const n=!(!e||!e.checked),o=t.querySelectorAll("input, textarea, select");n?(t.classList.remove("hidden"),o.forEach((e=>{e.disabled=!1})),x({clearInstructionsOnPollOnly:!1})):(t.classList.add("hidden"),o.forEach((e=>{e.disabled=!0})))}function k(e){const t=document.getElementById("second_opinion_provider");if(!t)return;const n=void 0!==e?e:t.value,o=g();t.textContent="";const r=document.createElement("option");r.value="",r.textContent="Use default",t.appendChild(r),o.forEach((e=>{const n=document.createElement("option");n.value=e,n.textContent=T[e]||e,t.appendChild(n)})),t.value=o.includes(n)?n:""}function S(){const e=document.getElementById("deep_research_enabled"),t=document.getElementById("deep_research_stall_timeout_minutes_group"),n=document.getElementById("deep_research_stall_timeout_minutes");if(!t)return;const o=!(!e||!e.checked);t.classList.toggle("hidden",!o),n&&(n.disabled=!o)}function L(){const e=document.getElementById("update_jira"),t=document.getElementById("story_points_field_group"),n=document.getElementById("story_points_field");if(!t)return;const o=!(!e||!e.checked);t.classList.toggle("hidden",!o),n&&(n.disabled=!o)}const B=[{field:"project_description",type:"text",id:"project_description"},{field:"confluence_pattern",type:"text",id:"confluence_pattern"},{field:"ignored_domains",type:"array",delimiter:",",id:"ignored_domains"},{field:"deep_research_enabled",type:"boolean",id:"deep_research_enabled"},{field:"deep_research_stall_timeout_minutes",type:"text",id:"deep_research_stall_timeout_minutes"},{field:"allowed_providers",type:"array",getValue:g,orderInsensitive:!0},{field:"second_opinion_provider",type:"text",id:"second_opinion_provider"},{field:"unit_testing_stack",type:"text",id:"unit_testing_stack"},{field:"e2e_testing_stack",type:"text",id:"e2e_testing_stack"},{field:"estimate_qa",type:"boolean",id:"estimate_qa"},{field:"process_estimate_instructions",type:"text",id:"process_estimate_instructions"},{field:"estimate_instructions",type:"text",id:"estimate_instructions"},{field:"update_jira",type:"boolean",id:"update_jira"},{field:"estimate_scale",type:"text",id:"estimate_scale"},{field:"story_points_field",type:"text",id:"story_points_field"},{field:"provider",type:"text",id:"provider"},{field:"architecture_instructions",type:"text",id:"architecture_instructions"},{field:"tdd_document_instructions",type:"text",id:"tdd_document_instructions"},{field:"fsd_document_instructions",type:"text",id:"fsd_document_instructions"},{field:"design_principles",type:"text",id:"design_principles"},{field:"unit_testing_instructions",type:"text",id:"unit_testing_instructions"},{field:"e2e_testing_instructions",type:"text",id:"e2e_testing_instructions"},{field:"review_instructions",type:"text",id:"review_instructions"},{field:"documentation_instructions",type:"text",id:"documentation_instructions"},{field:"allow_mutating_smoke_ops",type:"boolean",id:"allow_mutating_smoke_ops"},{field:"selected_mcp_slugs",type:"array",getValue:function(){return h(Array.from(document.querySelectorAll('#selected_mcp_slugs_list input[type="checkbox"]:checked')).map((e=>e.value)))},orderInsensitive:!0},{field:"ci_followup_config",type:"text",getValue:function(){const e=document.getElementById("ci_followup_enabled");if(!e||!e.checked)return"";const t=document.getElementById("ci_followup_max_iterations"),n=document.getElementById("ci_followup_max_minutes"),o=document.getElementById("ci_followup_instructions"),r={strategy:b(),max_iterations:parseInt(t?t.value:"",10),max_minutes:parseInt(n?n.value:"",10),instructions:o?o.value:""};return JSON.stringify(r)}},{field:"frontend_correctness_standards",type:"text",id:"frontend_correctness_standards"},{field:"backend_correctness_standards",type:"text",id:"backend_correctness_standards"},{field:"template_correctness_standards",type:"text",id:"template_correctness_standards"},{field:"style_correctness_standards",type:"text",id:"style_correctness_standards"},{field:"reviewable_file_types",type:"array",delimiter:",",id:"reviewable_file_types"},{field:"include_path",type:"array",delimiter:"\n",id:"include_path"},{field:"exclude_path",type:"array",delimiter:"\n",id:"exclude_path"},{field:"frontend_styleguide",type:"text",id:"frontend_styleguide"},{field:"backend_styleguide",type:"text",id:"backend_styleguide"},{field:"css_styleguide",type:"text",id:"css_styleguide"},{field:"review_correctness",type:"boolean",id:"review_correctness"},{field:"review_style",type:"boolean",id:"review_style"},{field:"review_requirements",type:"boolean",id:"review_requirements"},{field:"review_architecture",type:"boolean",id:"review_architecture"},{field:"create_tests",type:"boolean",id:"create_tests"},{field:"create_documentation",type:"boolean",id:"create_documentation"},{field:"documentation_standards",type:"text",id:"documentation_standards"},{field:"score_threshold_for_review",type:"text",id:"score_threshold_for_review"},{field:"no_comment_on_passing_score",type:"boolean",id:"no_comment_on_passing_score"}],A={project_description:"general",confluence_pattern:"general",ignored_domains:"general",deep_research_enabled:"general",deep_research_stall_timeout_minutes:"general",allowed_providers:"general",second_opinion_provider:"general",unit_testing_stack:"general",e2e_testing_stack:"general",estimate_qa:"estimator",process_estimate_instructions:"estimator",estimate_instructions:"estimator",update_jira:"estimator",estimate_scale:"estimator",story_points_field:"estimator",provider:"code_writer",architecture_instructions:"code_writer",tdd_document_instructions:"code_writer",fsd_document_instructions:"code_writer",design_principles:"code_writer",unit_testing_instructions:"code_writer",e2e_testing_instructions:"code_writer",review_instructions:"code_writer",documentation_instructions:"code_writer",ci_followup_config:"code_writer",allow_mutating_smoke_ops:"code_writer",selected_mcp_slugs:"code_writer",frontend_correctness_standards:"code_reviewer",backend_correctness_standards:"code_reviewer",template_correctness_standards:"code_reviewer",style_correctness_standards:"code_reviewer",reviewable_file_types:"code_reviewer",include_path:"code_reviewer",exclude_path:"code_reviewer",frontend_styleguide:"code_reviewer",backend_styleguide:"code_reviewer",css_styleguide:"code_reviewer",review_correctness:"code_reviewer",review_style:"code_reviewer",review_requirements:"code_reviewer",review_architecture:"code_reviewer",create_tests:"code_reviewer",create_documentation:"code_reviewer",documentation_standards:"code_reviewer",score_threshold_for_review:"code_reviewer",no_comment_on_passing_score:"code_reviewer"};function j(e,t,n=null){return"estimate_scale"===e?n:"score_threshold_for_review"===e?parseInt(t,10)||85:"deep_research_stall_timeout_minutes"===e?""===t?null:parseInt(t,10):"second_opinion_provider"===e?""===t?null:t:"ci_followup_config"===e?""===t?null:JSON.parse(t):t}const $={project_description:"Describe your project for the AI. Be sure to include your tech stack, Commerce Cloud version, and any other crucial architectural details here.",confluence_pattern:"Optional: A URL pattern or prefix used to identify Confluence documentation links relevant to this project (e.g., bridge-test.atlassian.net/wiki).",unit_testing_stack:"Optional: Describe the frameworks or libraries used for unit testing in this project (e.g., Jest, Mocha, Chai, Sinon, and Proxyquire). Leave blank if you don't want unit tests.",e2e_testing_stack:"Optional: Describe the frameworks or tools used for end-to-end testing (e.g., Playwright, Selenium, Cypress). Leave blank if you don't want E2E tests.",ignored_domains:"Optional: A comma-separated list of domain names that you want the AI to ignore. For example, links to a sandbox environment.",estimate_qa:"When enabled, the Estimator will also add an estimate for Quality Assurance (QA) activities.",process_estimate_instructions:"Give the AI any background it needs to accurately estimate QA tasks on your project.",estimate_scale:"Enter a valid JSON array defining your custom estimate scale. Each object in the array needs 'min', 'max', and 'label' keys. Refer to the project README for detailed formatting instructions and examples.",update_jira:"If enabled, the Estimator will automatically update the story points field on the corresponding JIRA ticket after generating an estimate.",estimate_instructions:"Optional: Custom instructions that will be appended to the AI estimation prompt to guide estimates.",custom_directories:"Specify which directories within your codebase are custom and modifiable by the AI. Enter one directory path per line (e.g., `/custom-cartridge/`). Required.",exclude_file_extensions:"Specify file extensions to exclude from processing. Enter one extension per line (e.g., `.min.js`, `.map`). Optional.",exclude_directories:"Specify directories to exclude from processing. Enter one directory path per line (e.g., `/node_modules/`, `/dist/`). Optional.",architecture_instructions:"Provide specific instructions for the AI about your project's architecture. Include patterns, best practices, and architectural constraints that the AI should follow when generating plans or TDDs.",tdd_document_instructions:"Optional: Define the STRUCTURE and FORMAT of the generated Technical Design Document (TDD) — the sections, ordering, and writing style. This replaces the default TDD format verbatim. It does NOT set architecture policy (use Architecture Instructions for that). Leave blank to use the built-in default TDD format.",fsd_document_instructions:"Optional: Define the STRUCTURE and FORMAT of the generated Functional Specification Document (FSD), which targets a product/functional audience (user flows, functional requirements, acceptance criteria). This replaces the default FSD format verbatim and is distinct from the technical implementation design. Leave blank to use the built-in default FSD format.",design_principles:"Frontend design principles and visual language for this project. Describe your design tokens (color, spacing, typography), layout patterns, component inventory, and composition rules so the AI generates UI that matches your design system. This field is shared with the learn-repository / Optimize flow, which can also write it — there is no locking or merge, so it is last-write-wins (the most recent writer wins).",provider:"Choose the AI provider to use for this project (OpenAI, Google Gemini, or Anthropic). This controls which LLM is used for planning, coding, and analysis.",allowed_providers:"The set of AI providers this project is permitted to use. The selected primary AI provider is always included and locked, because it must remain in Allowed Providers. Enable additional providers here to allow them as alternates.",unit_testing_instructions:"Detailed instructions for how the AI should write unit tests. Include test frameworks, mocking patterns, naming conventions, and project-specific testing requirements.",e2e_testing_instructions:"Detailed instructions for how the AI should write end-to-end tests. Include test frameworks, selectors, setup/teardown patterns, and any project-specific E2E testing requirements.",version:'The specific version of Salesforce Commerce Cloud (SFCC) your project is using. Select "Hybrid" if your project combines any two distinct standalone SFCC versions in one codebase. Required.',base_version:"For a Hybrid project, the standalone SFCC version (SFRA, PWA Kit, SiteGenesis, or Storefront Next) that encompasses the majority of your codebase.",alternate_version_directories:"Which directories hold the alternate SFCC version (the one that isn't your base version)? Input partial directory paths that can identify them. Enter one directory path per line.",write_tests:"If enabled, the Code Writer will attempt to generate unit tests alongside the code draft. Optional, defaults to true.",allow_mutating_smoke_ops:"If selected, the AI will work to genuinely test functionality through real operations, executed against the local environment. This will provide greater quality assurance, but requires greater trust. Only runs on the sandbox.",review_instructions:"Instructions that guide how the AI validates that a plan was implemented correctly. Use this to define the specific verification steps the AI should follow during its review — such as which tools to invoke, what checks to run, and how to confirm correctness.",selected_mcp_slugs:"MCP Validation Manuals: choose which canonical MCP manuals are supplied to the final plan reviewer when it generates review, smoke, integration, and documentation steps. The available choices are loaded from the backend MCP docs catalog.",pwa_overrides_directories:"Specify the directories that contain your PWA Kit template overrides. Enter one directory path per line (e.g., `overrides`, `app/templates`, `custom-overrides`). These directories will be given special consideration when the AI generates or modifies code.",frontend_correctness_standards:"Describe how the AI should review frontend Javascript. Consider project standards, error handling, data validation, etc. Required.",backend_correctness_standards:"Describe how the AI should review backend code. Consider project standards, error handling, data validation, security, best practices",reviewable_file_types:"List the file suffixes (e.g., `js, isml, scss`) the AI should review. Required.",include_path:"Specify directory paths (one per line) to include in reviews. Prevents reviewing third-party code. Recommended.",exclude_path:"Specify directory paths (one per line) to exclude from reviews, even if they are within an included path. Recommended.",template_correctness_standards:"Define standards for reviewing template code (e.g., HTML, ISML), focusing on issues like accessibility. Recommended. If blank, template correctness is skipped.",style_correctness_standards:"Define standards for reviewing CSS/SASS/LESS code. Optional. If blank, style correctness for these files is skipped.",frontend_styleguide:"Describe style conventions for frontend Javascript. Optional. If blank, frontend style reviews are skipped.",backend_styleguide:"Describe style conventions for backend code (e.g., JSDoc, function size). Optional. If blank, backend style reviews are skipped.",css_styleguide:"Describe style conventions for CSS/SASS/LESS code. Optional. If blank, CSS style reviews are skipped.",review_correctness:"Enable/disable checking code for bugs and errors. Defaults to true. Optional.",review_style:"Enable/disable checking code for style guide adherence. Defaults to true. Optional.",review_requirements:"Enable/disable checking if the PR fulfills ticket requirements (requires ticket ID in branch/commit). Best for initial commits. Defaults to true. Optional.",review_architecture:"Enable/disable checking for integration errors and correctness (if correctness review is off). Defaults to true. Optional.",create_tests:"Enable/disable AI generation of unit/integration tests for the PR. Defaults to false. Optional.",create_documentation:"Enable/disable AI generation of documentation for the PR. Defaults to false. Optional.",documentation_standards:"If `Create Documentation` is enabled, describe the desired documentation format and standards here. Optional.",score_threshold_for_review:"Set a score (0-100) below which the AI will perform a review. Files scoring at or above this threshold are considered passing. Defaults to 85. Optional.",no_comment_on_passing_score:'If enabled, the AI will not leave a comment on files with a passing score. If disabled, it leaves a positive comment (e.g., "Looks good!"). Defaults to true (no comment). Optional.',schedule_interval:"How frequently should the repository parsing job run? This is measured in days (e.g., every 1 day, 2 days, etc.).",schedule_timezone:"The timezone for scheduling repository parsing jobs. We will run this job daily at 1:00 AM according to the timezone you select.",deep_research_enabled:"Enable or disable AI deep research for this project. When enabled, the MCP tool can perform in-depth web research on technical topics using the default Deep Research provider. Defaults to enabled.",deep_research_stall_timeout_minutes:"How long (in minutes) deep research may stall before it is abandoned. Defaults to 20 minutes. Only applies when Deep Research is enabled.",second_opinion_provider:'Optional alternate provider used for second-opinion passes. Leave blank to "Use default" (the backend resolver decides). Options are limited to this project\'s Allowed Providers, so changing Allowed Providers may reset this selection.',story_points_field:"The Jira field key / custom field identifier (e.g., customfield_10016) the Estimator writes story points to. Only used when Update JIRA Issue is enabled; leave blank to let the Estimator auto-detect the field.",documentation_instructions:"Sections and formatting for AI-generated documentation written on pull requests. This guides the documentation the Code Writer produces — distinct from the Code Reviewer's Documentation Standards, which govern review-time documentation behavior.",ci_followup_config:'Controls the CI follow-up step after a PR. Off (default) uses baseline poll-only behavior. When on, choose a strategy: "poll_only" just watches CI; "fix_and_iterate" runs a self-contained correction loop (instructions optional); "custom" uses your instructions as the complete CI follow-up instruction set (instructions required). Max Attempts is 1-10 and Max Minutes is 1-120. Instructions are limited to 8192 UTF-8 bytes (byte count, not characters).'},T={openai:"OpenAI",anthropic:"Anthropic",gemini:"Google Gemini"},P={"playwright-mcp":"Playwright MCP","pwa-kit-mcp":"PWA Kit MCP"};function R(e,t){const n=function(e){return`${T[e]||e} is locked because it is the selected primary AI provider and must remain in Allowed Providers. Select a different primary provider to unlock it.`}(t);Array.from(e||[]).forEach((e=>{const o=e.closest(".checkbox-label");e.value===t?(e.checked=!0,e.disabled=!0,e.title=n,o&&(o.title=n)):(e.disabled=!1,e.removeAttribute("title"),o&&o.removeAttribute("title"))}))}async function O(e){i=e,(0,r.Cs)();try{const t=await(0,r.H2)(`/setup/project-detail/${e}`,"GET");if(!t)return void(i=null);a&&(a.textContent=`Configuration: ${t.repo_display_name?.trim()||t.repo_name||"Project"}`),s&&(s.dataset.repoName=t.repo_name||""),function(e){if(!e)return;if(c){c.elements.project_description.value=e.project_description||"",c.elements.confluence_pattern.value=e.confluence_pattern||"",c.elements.ignored_domains.value=(0,r.mD)(e.ignored_domains||[]),c.elements.provider.value=e?.code_writer?.provider||"openai",c.elements.deep_research_enabled.checked=void 0===e.deep_research_enabled||e.deep_research_enabled,c.elements.deep_research_stall_timeout_minutes&&(c.elements.deep_research_stall_timeout_minutes.value=e.deep_research_stall_timeout_minutes||20);const t=document.getElementById("allowed_providers_group");if(t){const n=e.allowed_providers||["openai","anthropic","gemini"],o=t.querySelectorAll(".provider-checkbox");o.forEach((e=>{e.checked=n.includes(e.value)}));R(o,c.elements.provider.value),k(e.second_opinion_provider||""),o.forEach((e=>{e.addEventListener("change",(()=>k()))}))}c.elements.provider.addEventListener("change",(function(){const e=document.getElementById("allowed_providers_group");if(!e)return;R(e.querySelectorAll(".provider-checkbox"),this.value),k()}))}const t=e?.estimator||{};if(l&&(l.elements.estimate_qa.checked=t.estimate_qa||!1,l.elements.process_estimate_instructions.value=t.process_estimate_instructions||"",l.elements.estimate_instructions.value=t.estimate_instructions||"",l.elements.update_jira.checked=t.update_jira||!1,l.elements.story_points_field&&(l.elements.story_points_field.value=t.story_points_field||""),p)){let e=t.estimate_scale||"";if("object"==typeof e)try{e=JSON.stringify(e,null,2)}catch(t){console.error("Error stringifying existing estimate scale:",t),e=""}p.value=e,p.setAttribute("data-original-value",e)}const n=e?.code_writer||{};d&&(d.elements.architecture_instructions.value=n.architecture_instructions||"",d.elements.tdd_document_instructions&&(d.elements.tdd_document_instructions.value=n.tdd_document_instructions||""),d.elements.fsd_document_instructions&&(d.elements.fsd_document_instructions.value=n.fsd_document_instructions||""),d.elements.design_principles&&(d.elements.design_principles.value=n.design_principles||""),d.elements.unit_testing_stack.value=e.unit_testing_stack||"",d.elements.unit_testing_instructions.value=n.unit_testing_instructions||"",d.elements.e2e_testing_stack.value=e.e2e_testing_stack||"",d.elements.e2e_testing_instructions.value=n.e2e_testing_instructions||"",d.elements.review_instructions.value=n.review_instructions||"",d.elements.documentation_instructions&&(d.elements.documentation_instructions.value=n.documentation_instructions||""),d.elements.allow_mutating_smoke_ops&&(d.elements.allow_mutating_smoke_ops.checked=!!n.allow_mutating_smoke_ops),function(e,t){const n=document.getElementById("selected_mcp_slugs_list"),o=document.getElementById("selected_mcp_slugs_empty");if(!n)return;n.textContent="";const r=Array.isArray(e)?e:[],i=new Set(Array.isArray(t)?t:[]);if(0===r.length)return void(o&&o.classList.remove("hidden"));o&&o.classList.add("hidden");r.forEach((e=>{if(!e||!e.slug)return;const t=document.createElement("label");t.className="mcp-doc-option";const o=document.createElement("input");o.type="checkbox",o.className="mcp-doc-checkbox",o.value=e.slug,o.checked=i.has(e.slug);const r=document.createElement("span");r.className="mcp-doc-label",r.textContent=function(e){return e?P[e.slug]||e.label||e.slug:""}(e),t.appendChild(o),t.appendChild(r),n.appendChild(t)}))}(e.available_mcp_docs||[],n.selected_mcp_slugs||[]),function(e){const t=document.getElementById("ci_followup_enabled");let n=null;if(e&&"object"==typeof e)n=e;else if("string"==typeof e&&""!==e.trim())try{n=JSON.parse(e)}catch(e){n=null}if(!n||Array.isArray(n)||"object"!=typeof n)return t&&(t.checked=!1),w(v),void I();t&&(t.checked=!0),w({strategy:n.strategy||v.strategy,max_iterations:null!=n.max_iterations?n.max_iterations:v.max_iterations,max_minutes:null!=n.max_minutes?n.max_minutes:v.max_minutes,instructions:"string"==typeof n.instructions?n.instructions:v.instructions}),I()}(n.ci_followup_config));const o=e?.code_reviewer||{};["frontend_correctness_standards","backend_correctness_standards","template_correctness_standards","style_correctness_standards"].forEach((e=>{const t=document.getElementById(e);t&&(t.value=o[e]||"")})),u&&(u.elements.reviewable_file_types.value=(0,r.mD)(o.reviewable_file_types||[]),u.elements.include_path.value=(o.include_path||[]).join("\n"),u.elements.exclude_path.value=(o.exclude_path||[]).join("\n"),u.elements.frontend_styleguide.value=o.frontend_styleguide||"",u.elements.backend_styleguide.value=o.backend_styleguide||"",u.elements.css_styleguide.value=o.css_styleguide||"",u.elements.review_correctness.checked=void 0===o.review_correctness||o.review_correctness,u.elements.review_style.checked=void 0===o.review_style||o.review_style,u.elements.review_requirements.checked=void 0===o.review_requirements||o.review_requirements,u.elements.review_architecture.checked=void 0===o.review_architecture||o.review_architecture,u.elements.create_tests.checked=o.create_tests||!1,u.elements.create_documentation.checked=o.create_documentation||!1,u.elements.documentation_standards.value=o.documentation_standards||"",u.elements.score_threshold_for_review.value=void 0!==o.score_threshold_for_review?o.score_threshold_for_review:85,u.elements.no_comment_on_passing_score.checked=void 0===o.no_comment_on_passing_score||o.no_comment_on_passing_score)}(t),s&&s.classList.remove("hidden"),(0,r.zS)({root:document,drawerSelector:"#project-detail-container .drawer"}),document.querySelectorAll("#project-detail-container .drawer").forEach((e=>{const t=e.querySelector(".drawer-header"),n=t?.querySelector(".explanation-icon");n&&n.addEventListener("click",(()=>{const e=n.getAttribute("data-field-id"),r=t.querySelector("h3")?.textContent||"Explanation",i=$[e]||"No explanation available for this field.";(0,o.to)(r,i)}))}))}catch(e){i=null,console.error("Error loading project configuration:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to load project configuration."))}finally{(0,r.RZ)()}}async function q(){if(!m)return;if(m.disabled=!0,m.textContent="Saving...",!function(){let e=!0;return document.querySelectorAll(".drawer-content input, .drawer-content textarea, .drawer-content select").forEach((t=>{z(t)||(e=!1)})),e}()){(0,o.to)("Error","Please fix the errors marked in red before saving."),m.disabled=!1,m.textContent="Save Configuration";const e=document.querySelector(".input-error");if(e){const t=e.closest(".drawer");t&&(0,r.Jh)(t,!0),setTimeout((()=>{e.scrollIntoView({behavior:"smooth",block:"center"}),e.focus()}),150)}return}let e=!0,t=null;if(p){const n=p.value.trim();if(y.classList.remove("visible"),p.style.borderColor="",n)try{const e=JSON.parse(n);if(!Array.isArray(e))throw new Error("Input must be a JSON array.");t=n}catch(t){console.error("Invalid JSON in Estimate Scale:",t),y.textContent=`Invalid JSON: ${t.message}`,y.classList.add("visible"),p.style.borderColor="var(--error-color)",e=!1}else t=""}if(!e)return(0,o.to)("Validation Error","Please fix the errors in the form before saving. Check the Estimate Scale JSON format."),m.disabled=!1,void(m.textContent="Save Configuration");const n=function(e,t=null){const n={};for(const[o,r]of Object.entries(e||{})){const e=A[o];e&&(n[e]||(n[e]={}),n[e][o]=j(o,r,t))}return n.touched_fields=Object.keys(e||{}),n}((0,r.Ui)(B,f),t);try{await(0,r.H2)(`/setup/project-detail/${i}`,"PUT",n)&&((0,o.to)("Success","Project configuration saved successfully!"),f=(0,r.rM)(B))}catch(e){console.error("Error saving project configuration:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to save project configuration."))}finally{m.disabled=!1,m.textContent="Save Configuration"}}function z(e){if(!e||"hidden"===e.type||"button"===e.type||"submit"===e.type||null===e.offsetParent)return!0;const t=document.getElementById(`${e.id}-error`);let n=!0,o="";if(e.setCustomValidity(""),"ci_followup_instructions"===e.id){const t=document.getElementById("ci_followup_enabled");if(t&&t.checked){const t=b(),n=e.value||"";"custom"===t&&""===n.trim()?e.setCustomValidity("Custom CI follow-up instructions are required."):E(n)>_&&e.setCustomValidity("Instructions must be at most 8192 UTF-8 bytes.")}}if(e.checkValidity()||(n=!1,o=e.validity.valueMissing?"This field is required.":e.validity.typeMismatch?"url"===e.type&&""!==e.value.trim()?"Please enter a valid URL (e.g., https://example.com).":"email"===e.type&&""!==e.value.trim()?"Please enter a valid email address.":"Please enter a valid value.":e.validity.tooLong?`Maximum length is ${e.maxLength} characters.`:e.validity.rangeUnderflow?`Value must be at least ${e.min}.`:e.validity.rangeOverflow?`Value cannot be more than ${e.max}.`:e.validationMessage),"estimate_scale"===e.id){const t=e.value.trim();if(""!==t)try{const e=JSON.parse(t);if(!Array.isArray(e)||e.some((e=>"object"!=typeof e||null===e||!("min"in e)||!("max"in e)||!("label"in e))))throw new Error("JSON must be an array of objects with min, max, and label keys.")}catch(e){n=!1,o=`Invalid JSON format or structure: ${e.message}`}}return t?(t.textContent=o,n?(t.classList.remove("visible"),e.classList.remove("input-error")):(t.classList.add("visible"),e.classList.add("input-error"))):n?e.classList.remove("input-error"):(e.classList.add("input-error"),console.warn(`No error message element found for ID: ${e.id}-error`)),n}function N(e){z(e.target)}function D(e){const t=e.target,n=document.getElementById(`${t.id}-error`);t.classList.contains("input-error")&&(t.classList.remove("input-error"),n&&(n.textContent="",n.classList.remove("visible"))),"ci_followup_instructions"===t.id&&C()}document.addEventListener("DOMContentLoaded",(async function(){if("/setup/project-detail"===window.location.pathname){(0,o.QJ)();const e=new URLSearchParams(window.location.search).get("projectId");if(!e)return void(0,o.to)("Error","Project ID not found in URL.");await O(e),m&&m.addEventListener("click",q),m&&(m.textContent="Save Configuration",m.style.position="fixed",m.style.bottom="20px",m.style.left="50%",m.style.transform="translateX(-50%)",m.style.zIndex="1000",m.style.padding="10px 20px",m.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)"),document.querySelectorAll(".explain-link").forEach((e=>{e.addEventListener("click",(async t=>{t.preventDefault();const n=e.dataset.section,o=`${n}-explanation`,r=document.getElementById(o);if(r)if(r.classList.contains("hidden")){const e=$[n]||"Explanation not found.";r.textContent=e,r.classList.remove("hidden")}else r.classList.add("hidden");else console.error(`Explanation div not found for ID: ${o}`)}))}));document.querySelectorAll('button[type="submit"]').forEach((e=>{e!==m&&(e.style.display="none")})),p&&p.addEventListener("input",(()=>{try{p.value.trim()&&JSON.parse(p.value),y.classList.remove("visible"),p.style.borderColor=""}catch(e){y.textContent="Invalid JSON format.",y.classList.add("visible"),p.style.borderColor="var(--error-color)"}})),document.querySelectorAll(".drawer-content input, .drawer-content textarea, .drawer-content select").forEach((e=>{"button"!==e.type&&"submit"!==e.type&&"hidden"!==e.type&&"checkbox"!==e.type&&"radio"!==e.type&&(e.removeEventListener("blur",N),e.addEventListener("blur",N)),"checkbox"!==e.type&&"radio"!==e.type&&(e.removeEventListener("input",D),e.addEventListener("input",D))})),function(){const e=document.getElementById("deep_research_enabled");e&&e.addEventListener("change",S);const t=document.getElementById("update_jira");t&&t.addEventListener("change",L);const n=document.getElementById("ci_followup_enabled");n&&n.addEventListener("change",I),document.querySelectorAll('input[name="ci_followup_strategy"]').forEach((e=>{e.addEventListener("change",(()=>x()))}));const o=document.getElementById("ci_followup_instructions");o&&o.addEventListener("input",C),S(),L(),I()}(),f=(0,r.Wp)(B)}}))},118(e,t,n){var o=n(723);document.addEventListener("DOMContentLoaded",(function(){document.getElementById("security-container")&&(0,o.zS)({root:document,drawerSelector:"#security-container .drawer"})}))},589(e,t,n){var o=n(579),r=n(723);let i=null,s=null;const a=document.getElementById("setup-detail-container"),c=document.getElementById("setup-detail-title"),l=document.getElementById("identity-form"),d=document.getElementById("jira-form"),u=document.getElementById("vcs-form"),m=document.getElementById("github-form"),p=document.getElementById("bitbucket-form"),y=document.getElementById("pinecone-form"),f=document.getElementById("platform-form"),h=document.getElementById("save-setup-btn"),g=document.getElementById("version"),_=document.getElementById("base_version_group"),v=document.getElementById("base_version"),E=document.getElementById("alternate_version_group"),b=document.getElementById("alternate_version"),w=document.getElementById("alternate_version_directories_group"),C=document.getElementById("alternate_version_directories"),x=document.getElementById("pwa_overrides_group"),I=document.getElementById("pwa_overrides"),k=document.getElementById("pwa_overrides_directories_group"),S=document.getElementById("pwa_overrides_directories");let L=null;const B="\n",A={repo_name:"The unique identifier for your repository. This is typically set during project creation and cannot be changed.",repo_display_name:"A friendly display name for your repository. This is shown in the project list and can be changed at any time.",jira_ticket_key:"The key that identifies the JIRA tickets on your project. For example, if your ticket number is 'SCRUM-1', then you should enter 'SCRUM'.",ai_author:"The username the AI uses for comments in Bitbucket. Should match the name given to the Bitbucket access token. Required for Bitbucket.",jira_server_url:"The root url for your JIRA instance. For example, if the URL for your JIRA ticket was: https://bridge-test.atlassian.net/browse/BAPI-1 then the root url would be: https://bridge-test.atlassian.net.",jira_email:"The email address associated with your JIRA account used for the API token.",jira_api_token:"Your JIRA API token. Used for fetching issue details. See the README file for how to get this.",vcs_webhook_secret:"A secret string used to verify webhook payloads sent from your version control system (Github & Bitbucket). Create this secret when setting up your webhook and then enter it here.",repo_id:"Your repository ID for GitHub or Bitbucket. Required for version control integration. See the README for how to locate this.",git_app_installation_id:"The Installation ID for the Bridge GPT GitHub App installed on your repository. Find this in your GitHub organization/repository settings under Installed GitHub Apps. See README for details.",version_control_access_token:"A Bitbucket Access Token with Read access to repositories and pull requests. Create this in your Bitbucket account settings under Access tokens.",workspace:"Your Bitbucket workspace ID (e.g., bitbucket.org/workspace/{workspace-id}). See the README for details.",bitbucket_app_username:"Your Bitbucket username used for app password authentication.",bitbucket_app_password:"Your Bitbucket app password. Create this in your Bitbucket account settings under App passwords with appropriate repository access permissions.",pinecone_index_name:"The name of the Pinecone index you created for storing vector embeddings for this project. Refer to the README for Pinecone setup instructions.",base_branch:'Optional: Specify a custom base branch (e.g., "develop") to override the VCS-reported default branch. When left blank, the system automatically uses the default branch from your VCS provider (e.g., "main" or "master").',post_pr_target_status:'The Jira workflow status that tickets transition to after code is committed via pull request. Automatically resolved by the LLM status resolver agent if left blank. Set manually to override the auto-resolved value (e.g., "Ready for Testing", "In Review").',working_in:'Required: enter the platform you are working in, such as "Salesforce Commerce Cloud", "Scayle", or "Shopify".',version:'The specific version of Salesforce Commerce Cloud (SFCC) your project is using — SFRA, PWA Kit, Hybrid, SiteGenesis, or Storefront Next. Select "Hybrid" if your project combines any two distinct standalone SFCC versions in one codebase. Select "SiteGenesis" for legacy multi-cartridge SG projects (pipelines, ISML, Demandware Script). Select "Storefront Next" for the React 19 / React Router 7 / Vite SFCC storefront (TypeScript, SCAPI/SLAS, Page Designer metadata cartridges). Required.',base_version:"For a Hybrid project, the standalone SFCC version (SFRA, PWA Kit, SiteGenesis, or Storefront Next) that encompasses the majority of your codebase.",alternate_version:"For a Hybrid project, the second standalone SFCC version used by the alternate-version directories. Must be a different standalone SFCC version from your Base Version.",alternate_version_directories:"Which directories hold the alternate SFCC version (the one that isn't your base version)? Input partial directory paths that can identify them. Enter one directory path per line.",custom_directories:"Specify which directories within your codebase are custom and modifiable by the AI. Enter one directory path per line (e.g., `/custom-cartridge/`). Required.",exclude_file_extensions:"Specify file extensions to exclude from processing. Enter one extension per line (e.g., `.min.js`, `.map`). Optional.",exclude_directories:"Specify directories to exclude from processing. Enter one directory path per line (e.g., `/node_modules/`, `/dist/`). Optional.",pwa_overrides_directories:"Specify the directories that contain your PWA Kit template overrides. Enter one directory path per line (e.g., `overrides`, `app/templates`, `custom-overrides`)."},j="This field is required.",$="Please enter a valid URL (e.g., https://example.com).",T="Please enter a valid email address.",P="Please enter a valid value.",R=e=>`Maximum length is ${e} characters.`,O=e=>`Value must be at least ${e}.`,q=e=>`Value cannot be more than ${e}.`,z="Base Version is required when Hybrid is selected.",N="Alternate Version is required when Hybrid is selected.",D="Base Version and Alternate Version must be different.",M="Please fix the errors marked in red before saving.",F="Saving...",U="Save Setup",H="Setup configuration saved successfully!",J="No Changes",G="No changes to save.",V="Set by agent",W="Unset",Z="Edit",Q="Loading status…",Y="Install status unavailable",X=Object.freeze([{field:"repo_name",type:"text",id:"repo_name"},{field:"repo_display_name",type:"text",id:"repo_display_name"},{field:"jira_ticket_key",type:"text",id:"jira_ticket_key"},{field:"jira_server_url",type:"text",id:"jira_server_url"},{field:"jira_email",type:"text",id:"jira_email"},{field:"jira_api_token",type:"text",id:"jira_api_token"},{field:"version_control_system",type:"text",id:"version_control_system"},{field:"vcs_webhook_secret",type:"text",id:"vcs_webhook_secret"},{field:"repo_id",type:"text",id:"repo_id"},{field:"base_branch",type:"text",id:"base_branch"},{field:"post_pr_target_status",type:"text",id:"post_pr_target_status"},{field:"git_app_installation_id",type:"text",id:"git_app_installation_id"},{field:"ai_author",type:"text",id:"ai_author"},{field:"version_control_access_token",type:"text",id:"version_control_access_token"},{field:"workspace",type:"text",id:"workspace"},{field:"bitbucket_app_username",type:"text",id:"bitbucket_app_username"},{field:"bitbucket_app_password",type:"text",id:"bitbucket_app_password"},{field:"pinecone_index_name",type:"text",id:"pinecone_index_name"},{field:"working_in",type:"text",id:"working_in"},{field:"version",type:"text",id:"version"},{field:"base_version",type:"text",id:"base_version"},{field:"alternate_version",type:"text",id:"alternate_version"},{field:"pwa_overrides",type:"boolean",id:"pwa_overrides"},{field:"alternate_version_directories",type:"array",id:"alternate_version_directories",delimiter:B},{field:"pwa_overrides_directories",type:"array",id:"pwa_overrides_directories",delimiter:B},{field:"custom_directories",type:"array",id:"custom_directories",delimiter:B},{field:"exclude_file_extensions",type:"array",id:"exclude_file_extensions",delimiter:B},{field:"exclude_directories",type:"array",id:"exclude_directories",delimiter:B}]);function K(){L=(0,r.Wp)(X)}function ee(e){if(null==e||""===e)return"";if("boolean"==typeof e)return e?"Yes":"No";if(Array.isArray(e))return e.map((e=>ee(e))).filter((e=>""!==e)).join(", ");if("object"==typeof e)try{return JSON.stringify(e)}catch(t){return String(e)}return String(e)}function te(e){const t=document.getElementById("setup-install-status-summary"),n=document.getElementById("setup-install-status-groups"),o=document.getElementById("setup-install-status-error");if(o&&(o.textContent="",o.hidden=!0),t){t.textContent="";const n=e&&e.summary||{},o=n.total??0;[{label:"Set by agent",value:n.set??0},{label:"Unset",value:n.unset??0},{label:"Total",value:o}].forEach((e=>{const n=document.createElement("span");n.className="install-status-summary-item";const o=document.createElement("span");o.className="install-status-summary-count",o.textContent=String(e.value),n.appendChild(o),n.appendChild(document.createTextNode(` ${e.label}`)),t.appendChild(n)}))}if(!n)return;n.textContent="";(e&&Array.isArray(e.groups)?e.groups:[]).forEach((e=>{if(!e||!Array.isArray(e.fields))return;const t=document.createElement("div");t.className="install-status-group";const o=document.createElement("div");o.className="install-status-group-title",o.textContent=e.title||e.key||"",t.appendChild(o),e.fields.forEach((e=>{if(!e||"string"!=typeof e.field_name)return;const n=document.createElement("div");n.className="install-status-field-row";const o=document.createElement("span");o.className="install-status-field-name",o.textContent=e.field_name,n.appendChild(o);const i=document.createElement("span");e.is_set?(i.className="install-status-badge status-set",i.textContent=V):(i.className="install-status-badge status-unset",i.textContent=W),n.appendChild(i);const s=e.is_set?ee(e.current_value):ee(e.guidance);if(s){const e=document.createElement("span");e.className="install-status-field-value",e.textContent=s,n.appendChild(e)}if(e.requires_confirmation){const t=document.createElement("span");t.className="install-status-field-confirm",t.textContent="Requires confirmation",e.guidance&&(t.title=e.guidance),n.appendChild(t)}if(function(e){if(!e)return!1;const t=document.getElementById(e);return Boolean(t&&a&&a.contains(t))}(e.field_name)){const t=document.createElement("button");t.type="button",t.className="install-status-edit",t.textContent=Z,t.addEventListener("click",(()=>function(e){if(!e)return;const t=document.getElementById(e);if(!t)return;const n=t.closest(".drawer");n&&(0,r.Jh)(n,!0);setTimeout((()=>{try{t.scrollIntoView({behavior:"smooth",block:"center"}),t.focus()}catch(e){}}),150)}(e.field_name))),n.appendChild(t)}t.appendChild(n)})),n.appendChild(t)}))}function ne(){document.querySelectorAll("[data-install-field]").forEach((e=>{e.textContent="";const t=document.createElement("span");t.className="install-status-badge status-unavailable",t.textContent=Y,e.appendChild(t)}));const e=document.getElementById("setup-install-status-summary");e&&(e.textContent="");const t=document.getElementById("setup-install-status-groups");t&&(t.textContent="");const n=document.getElementById("setup-install-status-error");n&&(n.textContent=Y,n.hidden=!1)}async function oe(e){try{const t=await(0,r.H2)(`/setup/install-status?projectId=${encodeURIComponent(e)}`,"GET");if(!t)return;const n=Array.isArray(t.groups)&&t.groups.length>0;if(!1===t.available||!n)return void ne();te(t),function(e){const t=e instanceof Map?e:new Map;document.querySelectorAll("[data-install-field]").forEach((e=>{const n=e.dataset.installField,o=t.get(n);e.textContent="";const r=document.createElement("span");if(!o)return r.className="install-status-badge status-unavailable",r.textContent=Y,void e.appendChild(r);if(o.is_set){r.className="install-status-badge status-set";const e=ee(o.current_value);r.textContent=e?`${V}: ${e}`:V}else r.className="install-status-badge status-unset",r.textContent=W,o.guidance&&(r.title=o.guidance);o.requires_confirmation&&(r.title=o.guidance?`${o.guidance} (Requires confirmation)`:"Requires confirmation"),e.appendChild(r)}))}(function(e){const t=new Map;return e&&Array.isArray(e.groups)?(e.groups.forEach((e=>{e&&Array.isArray(e.fields)&&e.fields.forEach((e=>{e&&"string"==typeof e.field_name&&t.set(e.field_name,e)}))})),t):t}(t))}catch(e){console.error("Error loading install status:",e),ne()}}function re(e){const t=document.querySelector(".drawer:has(#github-form)"),n=document.querySelector(".drawer:has(#bitbucket-form)");"github"===e?(t&&t.classList.remove("hidden"),n&&n.classList.add("hidden")):"bitbucket"===e?(t&&t.classList.add("hidden"),n&&n.classList.remove("hidden")):(t&&t.classList.remove("hidden"),n&&n.classList.remove("hidden"))}function ie(){if(g&&_&&w){"hybrid"===g.value?(_.classList.remove("hidden"),E&&E.classList.remove("hidden"),w.classList.remove("hidden")):(_.classList.add("hidden"),E&&E.classList.add("hidden"),w.classList.add("hidden"))}}function se(){const e=g?g.value:"";if("pwakit"===e)return!0;if("hybrid"===e){const e=v?v.value:"",t=b?b.value:"";return"pwakit"===e||"pwakit"===t}return!1}function ae(){g&&x&&(se()?(x.classList.remove("hidden"),ce()):(x.classList.add("hidden"),k&&k.classList.add("hidden")))}function ce(){if(I&&k){const e=I.checked;se()&&e?k.classList.remove("hidden"):k.classList.add("hidden")}}async function le(e){i=e,(0,r.Cs)(),document.querySelectorAll("[data-install-field]").forEach((e=>{e.textContent="";const t=document.createElement("span");t.className="install-status-badge status-loading",t.textContent=Q,e.appendChild(t)}));try{const t=await(0,r.H2)(`/setup/setup-detail/${e}`,"GET");if(!t)return void(i=null);c&&(c.textContent=`Setup: ${t.repo_display_name?.trim()||t.repo_name||"Project"}`),function(e){if(!e)return;if(l){const t=l.elements.repo_name;t&&(t.value=e.repo_name||"");const n=l.elements.repo_display_name;n&&(n.value=e.repo_display_name||"");const o=l.elements.jira_ticket_key;o&&(o.value=e.jira_ticket_key||"")}d&&(d.elements.jira_server_url.value=e.jira_server_url||"",d.elements.jira_email.value=e.jira_email||"",d.elements.jira_api_token.value=e.jira_api_token||"");if(u){const t=u.elements.version_control_system;t&&(t.value=e.version_control_system||"",s=e.version_control_system||null),u.elements.vcs_webhook_secret.value=e.vcs_webhook_secret||"",u.elements.repo_id.value=e.repo_id||"";const n=document.getElementById("base_branch");n&&(n.value=e.base_branch||"");const o=document.getElementById("post_pr_target_status");o&&(o.value=e.post_pr_target_status||"")}m&&(m.elements.git_app_installation_id.value=e.git_app_installation_id||"");p&&(p.elements.ai_author.value=e.ai_author||"",p.elements.version_control_access_token.value=e.version_control_access_token||"",p.elements.workspace.value=e.workspace||"",p.elements.bitbucket_app_username.value=e.bitbucket_app_username||"",p.elements.bitbucket_app_password.value=e.bitbucket_app_password||"");re(e.version_control_system),y&&(y.elements.pinecone_index_name.value=e.pinecone_index_name||"");if(f){const t=f.elements.working_in;t&&(t.value=e.working_in||""),g&&(g.value=e.version||""),v&&(v.value=e.base_version||""),b&&(b.value=e.alternate_version||""),C&&(C.value=(e.alternate_version_directories||[]).join("\n")),I&&(I.checked=e.pwa_overrides||!1),S&&(S.value=(e.pwa_overrides_directories||[]).join("\n"));const n=document.getElementById("custom_directories");n&&(n.value=(e.custom_directories||[]).join("\n"));const o=document.getElementById("exclude_file_extensions");o&&(o.value=(e.exclude_file_extensions||[]).join("\n"));const r=document.getElementById("exclude_directories");r&&(r.value=(e.exclude_directories||[]).join("\n")),ie(),ae()}K()}(t),a&&a.classList.remove("hidden"),(0,r.zS)({root:document,drawerSelector:"#setup-detail-container .drawer"}),oe(e)}catch(e){i=null,console.error("Error loading setup details:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to load setup details."))}finally{(0,r.RZ)()}}function de(e){if(!e||"hidden"===e.type||"button"===e.type||"submit"===e.type||e.readOnly)return!0;if(function(e){if(e.closest(".drawer.hidden"))return!0;const t=e.closest("#base_version_group, #alternate_version_group, #alternate_version_directories_group, #pwa_overrides_group, #pwa_overrides_directories_group");return!(!t||!t.classList.contains("hidden"))}(e))return!0;const t=document.getElementById(`${e.id}-error`);let n=!0,o="";e.setCustomValidity(""),e.checkValidity()||(n=!1,o=e.validity.valueMissing?j:e.validity.typeMismatch?"url"===e.type&&""!==e.value.trim()?$:"email"===e.type&&""!==e.value.trim()?T:P:e.validity.tooLong?R(e.maxLength):e.validity.rangeUnderflow?O(e.min):e.validity.rangeOverflow?q(e.max):e.validationMessage);const r=g&&"hybrid"===g.value;if(r&&"base_version"===e.id&&!e.value&&(n=!1,o=z),r&&"alternate_version"===e.id){const t=v?v.value:"";e.value?t&&e.value===t&&(n=!1,o=D):(n=!1,o=N)}return t?(t.textContent=o,n?(t.classList.remove("visible"),e.classList.remove("input-error")):(t.classList.add("visible"),e.classList.add("input-error"))):n?e.classList.remove("input-error"):(e.classList.add("input-error"),console.warn(`No error message element found for ID: ${e.id}-error`)),n}function ue(e){de(e.target)}function me(e){const t=e.target,n=document.getElementById(`${t.id}-error`);t.classList.contains("input-error")&&(t.classList.remove("input-error"),n&&(n.textContent="",n.classList.remove("visible")))}async function pe(){if(!h)return;if(!function(){let e=!0;return document.querySelectorAll(".drawer-content input, .drawer-content textarea, .drawer-content select").forEach((t=>{de(t)||(e=!1)})),e}()){const e=()=>{const e=document.querySelector(".input-error");if(e){const t=e.closest(".drawer");t&&(0,r.Jh)(t,!0),setTimeout((()=>{e.scrollIntoView({behavior:"smooth",block:"center"}),e.focus()}),150)}};return void(0,o.to)("Error",M,null,!1,e)}const e=function(){L||K();const e=(0,r.Ui)(X,L)||{};return 0===Object.keys(e).length?null:{...e,touched_fields:Object.keys(e)}}();if(e){h.disabled=!0,h.textContent=F;try{await(0,r.H2)(`/setup/setup-detail/${i}`,"PUT",e)&&((0,o.to)("Success",H),L=(0,r.rM)(X)||(0,r.Wp)(X),i&&oe(i))}catch(e){console.error("Error saving setup configuration:",e),(0,o.to)("Error",(0,r.SU)(e,"Failed to save setup configuration."))}finally{h.disabled=!1,h.textContent=U}}else(0,o.to)(J,G)}document.addEventListener("DOMContentLoaded",(async function(){if("/setup/setup-detail"===window.location.pathname){(0,o.QJ)();const e=new URLSearchParams(window.location.search).get("projectId");if(!e)return void(0,o.to)("Error","Project ID not found in URL.");await le(e),h&&h.addEventListener("click",pe);const t=u?.elements.version_control_system;t&&t.addEventListener("change",(e=>{const t=e.target.value,n=s;n&&t!==n?(e.target.value=n,function(e,t,n,o){const r=document.getElementById("confirmation-modal"),i=document.getElementById("confirmation-modal-title"),s=document.getElementById("confirmation-modal-message"),a=document.getElementById("confirmation-modal-confirm"),c=document.getElementById("confirmation-modal-cancel");if(!(r&&i&&s&&a&&c))return void console.error("[ERROR] Confirmation modal elements not found");i.textContent=e,s.textContent=t;const l=a.cloneNode(!0),d=c.cloneNode(!0);a.parentNode.replaceChild(l,a),c.parentNode.replaceChild(d,c),d.addEventListener("click",(()=>{r.style.display="none",o&&o()})),l.addEventListener("click",(()=>{r.style.display="none",n&&n()})),r.style.display="flex"}("Confirm Version Control System Change","Warning: Changing this setting will break the system until the appropriate version control system settings are configured. Are you sure you want to proceed?",(()=>{e.target.value=t,s=t,re(t)}),(()=>{}))):(s=t,re(t))})),g&&g.addEventListener("change",(()=>{ie(),ae()})),v&&v.addEventListener("change",(()=>{ae(),b&&de(b)})),b&&b.addEventListener("change",(()=>{ae(),de(b)})),I&&I.addEventListener("change",ce),document.querySelectorAll(".drawer-content input, .drawer-content textarea, .drawer-content select").forEach((e=>{"button"!==e.type&&"submit"!==e.type&&"hidden"!==e.type&&"checkbox"!==e.type&&"radio"!==e.type&&(e.removeEventListener("blur",ue),e.addEventListener("blur",ue)),"checkbox"!==e.type&&"radio"!==e.type&&("SELECT"===e.tagName?(e.removeEventListener("change",me),e.addEventListener("change",me)):(e.removeEventListener("input",me),e.addEventListener("input",me)))})),document.querySelectorAll(".explain-link").forEach((e=>{e.addEventListener("click",(async t=>{t.preventDefault(),t.stopPropagation();const n=e.dataset.section,o=`${n}-explanation`,r=document.getElementById(o);if(r)if(r.classList.contains("hidden")){const e=A[n]||"Explanation not found.";r.textContent=e,r.classList.remove("hidden")}else r.classList.add("hidden");else console.error(`Explanation div not found for ID: ${o}`)}))})),h&&(h.style.position="fixed",h.style.bottom="20px",h.style.left="50%",h.style.transform="translateX(-50%)",h.style.zIndex="1000",h.style.padding="10px 20px",h.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)")}}))},923(e,t,n){var o=n(246),r=n(579),i=n(723),s=n(567);let a,c,l;async function d(){(0,i.Cs)();try{const e=await(0,i.H2)("/setup/projects/","GET");e&&function(e){const t=document.getElementById("projects-list");if(t.innerHTML="",0===e.length)return void(t.innerHTML="<p>No projects found. Create one!</p>");e.forEach((e=>{const n=e.repo_display_name||e.repo_name,o=document.createElement("div");o.className="project-card",o.setAttribute("data-project-id",e.id),o.setAttribute("data-project-name",e.repo_name),o.innerHTML=`\n <h3>${n}</h3>\n <p>${e.project_description||"No description provided."}</p>\n <div class="project-card-actions">\n <div class="project-card-actions-row">\n <button class="btn btn-secondary btn-setup" data-project-id="${e.id}">Setup</button>\n <button class="btn btn-secondary btn-config" data-project-id="${e.id}">Configure</button>\n <button class="btn btn-secondary btn-optimize" data-project-id="${e.id}">Optimize</button>\n <button class="btn btn-secondary btn-health">Data</button>\n <button class="btn btn-secondary btn-monitoring">Monitoring</button>\n <button class="btn btn-secondary btn-security" data-project-id="${e.id}">Security</button>\n <button class="btn btn-secondary btn-connect-editor" data-project-id="${e.id}">Connect editor</button>\n </div>\n <div class="project-card-actions-row project-card-actions-secondary">\n <a href="#" class="delete-link" data-project-id="${e.id}">Delete</a>\n </div>\n </div>\n `;const i=o.querySelector(".btn-setup");i&&i.addEventListener("click",(()=>{window.location.href=`/setup/setup-detail?projectId=${e.id}`}));const a=o.querySelector(".btn-config");a&&a.addEventListener("click",(()=>{window.location.href=`/setup/project-detail?projectId=${e.id}`}));const c=o.querySelector(".btn-optimize");c&&c.addEventListener("click",(()=>{window.location.href=`/optimize/${e.id}`}));const l=o.querySelector(".btn-health");l&&l.addEventListener("click",(()=>{window.location.href=`/setup/data/${e.id}`}));const d=o.querySelector(".btn-monitoring");d&&d.addEventListener("click",(()=>{window.location.href=`/setup/monitoring/${e.id}`}));const u=o.querySelector(".btn-security");u&&u.addEventListener("click",(()=>{window.location.href=`/setup/security/${e.id}`}));const m=o.querySelector(".btn-connect-editor");m&&m.addEventListener("click",(()=>{window.location.href=`/setup/get-started?projectId=${e.id}`}));const p=o.querySelector(".delete-link");p&&p.addEventListener("click",(t=>{t.preventDefault();const n=e.repo_name;n&&"string"==typeof n&&""!==n.trim()?(0,s.o)(n,(async()=>{if(await(0,s.N)(e.id)){const t=document.querySelector(`.project-card[data-project-id="${e.id}"]`);t&&t.remove()}else(0,r.to)("Error","Failed to delete project.")}),(()=>{})):(0,r.to)("Error","Could not delete your project. Try deleting from the database directly.")})),t.appendChild(o)}))}(e)}catch(e){console.error("Error loading projects:",e),(0,r.to)("Error",(0,i.SU)(e,"Failed to load projects."))}finally{(0,i.RZ)()}}async function u(e){e.preventDefault();const t=new FormData(a),n={repo_name:t.get("repo_name")},o=(t.get("repo_display_name")||"").trim();if(o&&(n.repo_display_name=o),n.repo_name)if("string"==typeof n.repo_name&&/^[a-zA-Z0-9_-]+$/.test(n.repo_name)){(0,i.Cs)();try{const e=await(0,i.H2)("/setup/","POST",n);e&&e.id&&(a.reset(),window.location.href=`/setup/get-started?projectId=${e.id}`)}catch(e){console.error("Failed to create project:",e),(0,r.to)("Error",(0,i.SU)(e,"Failed to create project."))}finally{(0,i.RZ)()}}else(0,r.to)("Invalid Repository Name","Repository name must contain only letters, numbers, underscores, and dashes (no spaces or other special characters).");else(0,r.to)("Missing Fields","Please fill in all required fields.")}document.addEventListener("DOMContentLoaded",(async function(){"/setup"===window.location.pathname&&(await(0,o.VB)(),(0,r.QJ)(),d(),function(){let e,t,n,o;c=document.getElementById("projects-container"),l=document.getElementById("create-project-container"),e=document.getElementById("projects-list"),t=document.getElementById("loading-overlay"),a=document.getElementById("create-project-form"),n=document.getElementById("create-project-btn"),o=document.getElementById("back-to-projects-btn"),n&&c&&l&&n.addEventListener("click",(()=>{c.classList.add("hidden"),l.classList.remove("hidden")})),o&&c&&l&&o.addEventListener("click",(()=>{l.classList.add("hidden"),c.classList.remove("hidden")})),a.addEventListener("submit",u),document.querySelectorAll(".explain-link").forEach((e=>{e.addEventListener("click",(async t=>{t.preventDefault();const n=e.dataset.section,o=`${n}-explanation`,r=document.getElementById(o);if(r)if(r.classList.contains("hidden")){const e=EXPLANATION_TEXTS[n]||"Explanation not found.";r.textContent=e,r.classList.remove("hidden"),r.style.display="block"}else r.classList.add("hidden"),r.style.display="none";else console.error(`Explanation div not found for ID: ${o}`)}))}))}())}))},723(e,t,n){n.d(t,{Cs:()=>s,H2:()=>l,Jh:()=>w,RZ:()=>a,SU:()=>d,Ui:()=>_,Wp:()=>h,lF:()=>c,mD:()=>u,rM:()=>v,sn:()=>r,zS:()=>C});var o=n(579);const r="bridge_setup_token",i=document.getElementById("loading-overlay");function s(){i?i.classList.remove("hidden"):console.warn("Loading overlay element not found.")}function a(){i?i.classList.add("hidden"):console.warn("Loading overlay element not found.")}class c extends Error{constructor(e,{status:t,data:n,detail:o}={}){super(e),this.name="ApiCallError",this.status=t,this.data=n,this.detail=o}}async function l(e,t="GET",n=null,i={}){const{headers:s=null,signal:a}=i||{},l=localStorage.getItem(r),d={"Content-Type":"application/json"};l&&(d.Authorization=`Bearer ${l}`),s&&Object.assign(d,s);try{const i={method:t,headers:d,credentials:"include"};a&&(i.signal=a),!n||"POST"!==t&&"PUT"!==t&&"DELETE"!==t||(i.body=JSON.stringify(n));const s=await fetch(e,i);if(401===s.status&&"/auth/token"!==e)return(0,o.to)("Session Expired","Your session has expired. Please log in again."),localStorage.removeItem(r),window.location.href="/setup/login",null;let l;try{l=204===s.status||"0"===s.headers.get("content-length")?{}:await s.json()}catch(e){throw new Error(`Failed to parse JSON response. Status: ${s.status}`)}if(!s.ok)throw new c(function(e,t){if(Array.isArray(e?.detail)){const t=e.detail[0];let n=`Validation error on '${t?.loc?.[t.loc.length-1]||"unknown field"}': ${t?.msg||"invalid value"}`;return e.detail.length>1&&(n+=` (and ${e.detail.length-1} more error${e.detail.length>2?"s":""})`),n}return e?.detail||`HTTP error! status: ${t}`}(l,s.status),{status:s.status,data:l,detail:l?.detail});return l&&l.redirect,l}catch(t){throw console.error(`API call error to ${e}:`,t),t instanceof Error?t:new Error(t?.message||"An error occurred while communicating with the server.")}}function d(e,t){const n=e&&e.message?String(e.message):"";return!n||/^HTTP error! status: \d+$/.test(n)?t:n}function u(e){return e&&Array.isArray(e)&&0!==e.length?e.join(", "):""}function m(e){const t=e&&(e.field||e.name);if(!t)throw new Error("Descriptor is missing a field name: provide `field` or `name`.");return t}function p(e,t){const n=e&&e.type;switch(n){case"text":return null==t?"":String(t).trim();case"boolean":return!0===t;case"array":return function(e,t){if("function"==typeof e.normalizer)return e.normalizer(t,e);if(null==t)return[];if(Array.isArray(t))return t.map((e=>"string"==typeof e?e.trim():e)).filter((e=>""!==e&&null!=e));if("string"==typeof t){if("string"==typeof e.delimiter)return t.split(e.delimiter).map((e=>e.trim())).filter((e=>""!==e));const n=e.field||e.name||"unknown";throw new Error(`Array descriptor '${n}' received a string value but defines neither a 'normalizer' nor a 'delimiter'; choose one explicitly.`)}const n=e.field||e.name||"unknown";throw new Error(`Array descriptor '${n}' received an unsupported value of type '${typeof t}'.`)}(e,t);default:{const t=e&&(e.field||e.name)||"unknown";throw new Error(`Unsupported descriptor type '${n}' for field '${t}'.`)}}}function y(e,t,n){if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return!1;let o=t,r=n;e&&!0===e.orderInsensitive&&(o=t.slice().sort(),r=n.slice().sort());for(let e=0;e<o.length;e++)if(o[e]!==r[e])return!1;return!0}return t===n}function f(e){if("function"==typeof e.getValue)return e.getValue(e);if("function"==typeof e.read)return e.read(e);let t=e.element||null;return!t&&e.selector&&"undefined"!=typeof document&&(t=document.querySelector(e.selector)),!t&&e.id&&"undefined"!=typeof document&&(t=document.getElementById(e.id)),"boolean"===e.type?!!t&&t.checked:t?t.value:""}function h(e){const t={};for(const n of e){const e=m(n),o=f(n);t[e]=p(n,o)}return t}function g(e,t){return e&&"array"===e.type&&Array.isArray(t)?t:p(e,t)}function _(e,t){return function(e,t,n){const o={},r=t||{},i=n||{};for(const t of e){const e=m(t),n=g(t,r[e]),s=g(t,i[e]);y(t,n,s)||(o[e]=s)}return o}(e,t,h(e))}function v(e){return h(e)}const E={root:null,drawerSelector:".drawer",headerSelector:".drawer-header",contentSelector:".drawer-content",toggleSelector:".toggle-drawer, .drawer-toggle",expandedClass:"expanded",hiddenClass:"hidden",expandedGlyph:"▲",collapsedGlyph:"▼",ignoreSelector:".explain-link, .explanation-icon, [data-drawer-ignore]",defaultExpanded:!1};function b(e){const t={...E,...e||{}};return t.root||(t.root="undefined"!=typeof document?document:null),t}function w(e,t,n={}){if(!e)return;const o=b(n),r=e.querySelector(o.headerSelector),i=e.querySelector(o.contentSelector),s=e.querySelector(o.toggleSelector);t?(e.classList.add(o.expandedClass),i&&i.classList.remove(o.hiddenClass),s&&(s.textContent=o.expandedGlyph)):(e.classList.remove(o.expandedClass),i&&i.classList.add(o.hiddenClass),s&&(s.textContent=o.collapsedGlyph)),r&&r.setAttribute("aria-expanded",t?"true":"false")}function C(e={}){const t=b(e);if(!t.root||"function"!=typeof t.root.querySelectorAll)return;t.root.querySelectorAll(t.drawerSelector).forEach((e=>{const n=e.querySelector(t.contentSelector);if(w(e,function(e,t,n){return t?!t.classList.contains(n.hiddenClass):!!n.defaultExpanded}(0,n,t),t),e.dataset&&"true"===e.dataset.drawerInitialized)return;const o=e.querySelector(t.headerSelector);o&&(o.addEventListener("click",(n=>{const o=n&&n.target;if(o&&t.ignoreSelector&&"function"==typeof o.closest&&o.closest(t.ignoreSelector))return;const r=e.querySelector(t.contentSelector),i=r?!r.classList.contains(t.hiddenClass):e.classList.contains(t.expandedClass);w(e,!i,t)})),e.dataset&&(e.dataset.drawerInitialized="true"))}))}}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(723),n(923),n(589),n(118),n(889),n(60),n(307),n(470),n(579),n(527),n(523),n(302),n(567),n(221),n(246),n(455),n(995),n(87),n(225),n(575),n(328),n(436),n(619),n(764),n(941),n(310),n(883),n(743);n(406)})();
|
|
2
|
+
//# sourceMappingURL=main.min.js.map
|