import{r as o,j as e}from"./vendor-tanstack-BVzzyDEt.js";import{u as O,a as E}from"./primitives-BxgEGUr4.js";import{SchemaForm as V}from"./schema-form-savMxoOe.js";import{a3 as k,at as C,au as T,av as j,aw as f,G as i,K as d,bu as u,j as F,L as J}from"./index-BJkJ93Lr.js";function D({baseJobTemplate:n,onBaseJobTemplateChange:l}){const[x,h]=o.useState(()=>JSON.stringify(n||{},null,2)),[c,m]=o.useState(null),s=o.useMemo(()=>n?.variables,[n?.variables]),b=o.useMemo(()=>s?.properties&&Object.keys(s.properties).length>0,[s?.properties]),v=o.useMemo(()=>{if(!s?.properties)return{};const r={};return Object.entries(s.properties).forEach(([a,t])=>{t&&typeof t=="object"&&"default"in t&&(r[a]=t.default)}),r},[s?.properties]),[S,p]=O(v),[y]=E([]),N=o.useCallback(r=>{if(p(r),!s?.properties)return;const a={...n,variables:{...s,properties:Object.fromEntries(Object.entries(s.properties).map(([t,w])=>[t,{...w,default:r[t]}]))}};l(a),h(JSON.stringify(a,null,2))},[n,s,l,p]),g=o.useCallback(r=>{h(r),m(null);try{const a=JSON.parse(r);l(a)}catch(a){m(a instanceof Error?a.message:"Invalid JSON")}},[l]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{variant:"h3",children:"Base Job Template"}),e.jsxs(C,{defaultValue:"defaults",className:"w-full",children:[e.jsxs(T,{children:[e.jsx(j,{value:"defaults",children:"Defaults"}),e.jsx(j,{value:"advanced",children:"Advanced"})]}),e.jsx(f,{value:"defaults",className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[e.jsx(i,{children:e.jsx(d,{children:e.jsx(u,{children:"The fields below control the default values for the base job template. These values can be overridden by deployments."})})}),s&&e.jsx(V,{schema:s,kinds:["json"],values:S,onValuesChange:N,errors:y})]}):e.jsx(i,{children:e.jsx(d,{children:e.jsxs(u,{children:["This work pool's base job template does not have any customizations. To add customizations, edit the base job template directly with the ",e.jsx("strong",{children:"Advanced"})," tab."]})})})}),e.jsxs(f,{value:"advanced",className:"space-y-4",children:[e.jsx(i,{children:e.jsx(d,{children:e.jsxs(u,{children:["This is the JSON representation of the base job template. A work pool's job template controls infrastructure configuration for all flow runs in the work pool, and specifies the configuration that can be overridden by deployments.",e.jsx("br",{}),e.jsx("br",{}),"For more information on the structure of a work pool's base job template, check out the docs."]})})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{children:"Base Job Template JSON"}),e.jsx(J,{value:x,onChange:g,className:c?"border-destructive":""}),c&&e.jsx("p",{className:"text-sm text-destructive",children:c})]})]})]})]})}export{D as B};
//# sourceMappingURL=base-job-template-form-section-DiW18Fhk.js.map
