easy_ml 0.2.0.pre.rc23 → 0.2.0.pre.rc25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/easy_ml/application_controller.rb +1 -2
- data/app/controllers/easy_ml/health_controller.rb +1 -0
- data/app/frontend/pages/DatasourcesPage.tsx +5 -1
- data/app/views/layouts/easy_ml/application.html.erb +2 -2
- data/lib/easy_ml/engine.rb +20 -6
- data/lib/easy_ml/version.rb +1 -1
- data/public/easy_ml/assets/.vite/manifest.json +2 -2
- data/public/easy_ml/assets/assets/Application-Cu7lNJmG.css +1 -0
- data/public/easy_ml/assets/assets/entrypoints/{Application.tsx-GDgZ4vVt.js → Application.tsx-BRRjHz4-.js} +2 -1
- data/public/easy_ml/assets/assets/entrypoints/Application.tsx-BRRjHz4-.js.map +1 -0
- metadata +7 -6
- data/public/easy_ml/assets/assets/Application-tsa3Id3n.css +0 -1
@@ -430,7 +430,7 @@ module Features
|
|
430
430
|
name: "Did Convert",
|
431
431
|
description: "Boolean true/false..."
|
432
432
|
end
|
433
|
-
end`})})]})})}function _R({options:e,initialFeatures:t=[],onFeaturesChange:n}){const[r,i]=A.useState(t),[l,u]=A.useState(null);console.log(r);const d=e.filter(E=>!r.find(w=>w.name===E.name)),f=E=>{const w=E.map((S,C)=>({...S,feature_position:C}));i(w),n(w)},m=E=>{const w=e.find(S=>S.name===E);if(w){const S={...w,feature_position:r.length};f([...r,S])}},h=E=>{const w=[...r];w.splice(E,1),f(w)},g=E=>{if(E===0)return;const w=[...r];[w[E-1],w[E]]=[w[E],w[E-1]],f(w)},y=E=>{if(E===r.length-1)return;const w=[...r];[w[E],w[E+1]]=[w[E+1],w[E]],f(w)},N=(E,w)=>{u(w)},x=(E,w)=>{if(E.preventDefault(),l===null||l===w)return;const S=[...r],[C]=S.splice(l,1);S.splice(w,0,C),f(S),u(w)},b=()=>{u(null)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"flex-1",children:a.jsx(ot,{options:d.map(E=>({value:E.name,label:E.name,description:E.description})),value:"",onChange:E=>m(E),placeholder:"Add a transform..."})}),a.jsx(wR,{})]}),a.jsxs("div",{className:"space-y-2",children:[r.map((E,w)=>a.jsxs("div",{draggable:!0,onDragStart:S=>N(S,w),onDragOver:S=>x(S,w),onDragEnd:b,className:`flex items-center gap-3 p-3 bg-white border rounded-lg ${l===w?"border-blue-500 shadow-lg":"border-gray-200"} ${l!==null?"cursor-grabbing":""}`,children:[a.jsx("button",{type:"button",className:"p-1 text-gray-400 hover:text-gray-600 cursor-grab active:cursor-grabbing",children:a.jsx(_T,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium text-gray-900",children:E.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${E.feature_type==="calculation"?"bg-blue-100 text-blue-800":E.feature_type==="lookup"?"bg-purple-100 text-purple-800":"bg-green-100 text-green-800"}`,children:"feature"})]}),a.jsx("p",{className:"text-sm text-gray-500 truncate",children:E.description})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>g(w),disabled:w===0,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move up",children:a.jsx(fT,{className:"w-4 h-4"})}),a.jsx("button",{type:"button",onClick:()=>y(w),disabled:w===r.length-1,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move down",children:a.jsx(cT,{className:"w-4 h-4"})}),a.jsx("button",{type:"button",onClick:()=>h(w),className:"p-1 text-gray-400 hover:text-red-600",title:"Remove transform",children:a.jsx(Wl,{className:"w-4 h-4"})})]})]},E.name)),r.length===0&&a.jsxs("div",{className:"text-center py-8 bg-gray-50 border-2 border-dashed border-gray-200 rounded-lg",children:[a.jsx(Js,{className:"w-8 h-8 text-gray-400 mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Add features to enrich your dataset"})]})]})]})}function SR({isOpen:e,onClose:t,initialDataset:n,onSave:r,constants:i}){const[l,u]=A.useState(n),[d,f]=A.useState("columns"),[m,h]=A.useState(!1),[g,y]=A.useState({targetColumn:l.target}),[N,x]=A.useState(null),[b,E]=A.useState(""),[w,S]=A.useState({view:"all",types:[]}),[C,O]=A.useState(n.needs_refresh||!1),R=A.useCallback(async G=>{await r(G)},[r]),{saving:F,saved:D,error:z}=vR(l,R,2e3),B=G=>{var ge,_e,De;return((ge=G.preprocessing_steps)==null?void 0:ge.training)!=null&&((De=(_e=G.preprocessing_steps)==null?void 0:_e.training)==null?void 0:De.method)!=="none"},H=A.useMemo(()=>l.columns.filter(G=>{const ge=G.name.toLowerCase().includes(b.toLowerCase()),_e=w.types.length===0||w.types.includes(G.datatype),De=(()=>{var me,Y;switch(w.view){case"training":return!G.hidden&&!G.drop_if_null;case"hidden":return G.hidden;case"preprocessed":return B(G);case"nulls":return(((Y=(me=G.statistics)==null?void 0:me.processed)==null?void 0:Y.null_count)||0)>0;default:return!0}})();return ge&&_e&&De}),[l.columns,b,w]),ce=A.useMemo(()=>({total:l.columns.length,filtered:H.length,training:l.columns.filter(G=>!G.hidden&&!G.drop_if_null).length,hidden:l.columns.filter(G=>G.hidden).length,withPreprocessing:l.columns.filter(B).length,withNulls:l.columns.filter(G=>{var ge,_e;return(((_e=(ge=G.statistics)==null?void 0:ge.processed)==null?void 0:_e.null_count)||0)>0}).length}),[l.columns,H]),ue=A.useMemo(()=>Array.from(new Set(l.columns.map(G=>G.datatype))),[l.columns]),we=G=>{x(G)},ne=G=>{const ge=l.columns.map(_e=>({..._e,hidden:_e.name===G?!_e.hidden:_e.hidden}));u({...l,columns:ge}),O(!0)},Z=G=>{const ge=String(G);y({targetColumn:G});const _e=l.columns.map(De=>({...De,is_target:De.name===ge}));u({...l,columns:_e}),O(!0)},de=(G,ge)=>{const _e=l.columns.map(De=>({...De,datatype:De.name===G?ge:De.datatype}));u({...l,columns:_e}),O(!0)},se=(G,ge,_e,De)=>{if(!l.columns.find(pe=>pe.name===G))return;const Y=l.columns.map(pe=>pe.name!==G?pe:{...pe,preprocessing_steps:{training:ge,...De&&_e?{inference:_e}:{}}});u({...l,columns:Y}),O(!0)},Q=G=>{const _e=(l.features||[]).filter(me=>!G.find(Y=>Y.name===me.name)).map(me=>({...me,_destroy:!0})),De=[...G,..._e].map((me,Y)=>({...me,dataset_id:l.id,feature_position:Y}));u(me=>({...me,features:De})),O(!0)},re=async()=>{h(!0);try{await r(l),rt.post(`/easy_ml/datasets/${l.id}/refresh`,{},{onSuccess:()=>{h(!1)},onError:()=>{console.error("Error refreshing dataset"),h(!1)}})}catch(G){console.error("Error refreshing dataset:",G),h(!1)}};if(!e)return null;const ee=N?l.columns.find(G=>G.name===N):null;return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex justify-between items-center p-4 border-b shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Column Configuration"}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"min-w-[0px]",children:a.jsx(xO,{saving:F,saved:D,error:z})}),a.jsxs("div",{className:"relative",children:[a.jsx(Zh,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),a.jsx("input",{type:"text",placeholder:"Search columns...",value:b,onChange:G=>E(G.target.value),className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:a.jsx(Wl,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex border-b shrink-0",children:[a.jsx("button",{onClick:()=>f("columns"),className:`px-4 py-2 text-sm font-medium border-b-2 ${d==="columns"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ui,{className:"w-4 h-4"}),"Column Configuration"]})}),a.jsx("button",{onClick:()=>f("features"),className:`px-4 py-2 text-sm font-medium border-b-2 ${d==="features"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(TT,{className:"w-4 h-4"}),"Features",a.jsx("span",{className:"px-1.5 py-0.5 text-xs font-medium bg-blue-100 text-blue-600 rounded-full",children:i.feature_options.length})]})}),C&&a.jsx("div",{className:"ml-auto px-4 flex items-center",children:a.jsxs("button",{onClick:re,disabled:m,className:"group relative inline-flex items-center gap-2 px-6 py-2.5 bg-gradient-to-r from-blue-600 to-indigo-600 text-white text-sm font-medium rounded-md hover:from-blue-700 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 transition-all duration-200 shadow-md hover:shadow-lg",children:[a.jsx("div",{className:"absolute inset-0 bg-white/10 rounded-md opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),m?a.jsxs(a.Fragment,{children:[a.jsx(Li,{className:"w-4 h-4 animate-spin"}),"Applying Preprocessing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(kT,{className:"w-4 h-4"}),"Apply Preprocessing"]})]})})]}),d==="columns"?a.jsxs(tr.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-7 flex-1 min-h-0",children:[a.jsxs("div",{className:"col-span-3 border-r overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"p-4 border-b shrink-0",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Target Column"}),a.jsx(ot,{options:l.columns.map(G=>({value:G.name,label:G.name})),value:g.targetColumn||"",onChange:G=>G&&Z(String(G))})]}),a.jsx("div",{className:"shrink-0",children:a.jsx(yO,{types:ue,activeFilters:w,onFilterChange:S,columnStats:ce,columns:l.columns,colHasPreprocessingSteps:B})}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:a.jsx(gO,{columns:H,selectedColumn:N,onColumnSelect:we,onToggleHidden:ne})})]}),a.jsx("div",{className:"col-span-4 overflow-y-auto p-4",children:ee?a.jsx(hO,{column:ee,dataset:l,setColumnType:de,setDataset:u,constants:i,onUpdate:(G,ge,_e)=>se(ee.name,G,ge,_e)}):a.jsx("div",{className:"h-full flex items-center justify-center text-gray-500",children:"Select a column to configure preprocessing"})})]}),a.jsxs("div",{className:"border-t p-4 flex justify-between items-center shrink-0",children:[a.jsxs("div",{className:"text-sm text-gray-600",children:[l.columns.filter(G=>!G.hidden).length," columns selected for training"]}),a.jsx("div",{className:"flex gap-3",children:a.jsx("button",{onClick:t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Close"})})]})]}):a.jsx("div",{className:"p-6 h-[calc(90vh-8rem)] overflow-y-auto",children:a.jsx(_R,{options:i.feature_options,initialFeatures:l.features,onFeaturesChange:Q})})]})})}function jR({dataset:e,constants:t}){const[n,r]=A.useState(!1),[i,l]=A.useState(e),{rootPath:u}=_r().props,d=A.useCallback(f=>{var y;const m=Object.entries(f).reduce((N,[x,b])=>(x!=="columns"&&x!=="features"&&!Ot.isEqual(i[x],b)&&(N[x]=b),N),{}),h=f.columns.reduce((N,x)=>{const b=i.columns.find(E=>E.id===x.id);if(!b||!Ot.isEqual(b,x)){const E=Object.entries(x).reduce((w,[S,C])=>((!b||!Ot.isEqual(b[S],C))&&(w[S]=C),w),{});Object.keys(E).length>0&&(N[x.id]={...E,id:x.id})}return N},{}),g=(y=f.features)==null?void 0:y.map((N,x)=>({id:N.id,name:N.name,feature_class:N.feature_class,feature_position:x,_destroy:N._destroy}));(Object.keys(m).length>0||Object.keys(h).length>0||!Ot.isEqual(i.features,f.features))&&rt.patch(`${u}/datasets/${e.id}`,{dataset:{...m,columns_attributes:h,features_attributes:g}},{preserveState:!0,preserveScroll:!0}),l(f)},[i,e.id,u]);return a.jsxs("div",{className:"p-8 space-y-6",children:[a.jsx("div",{className:"flex justify-end",children:a.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50",children:[a.jsx(Bl,{className:"w-4 h-4"}),"Configure Columns"]})}),a.jsx(OT,{dataset:i}),a.jsx(SR,{isOpen:n,onClose:()=>r(!1),initialDataset:i,constants:t,onSave:d})]})}const NR=Object.freeze(Object.defineProperty({__proto__:null,default:jR},Symbol.toStringTag,{value:"Module"}));function Pd({icon:e,title:t,description:n,actionLabel:r,onAction:i}){return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:a.jsx(e,{className:"w-8 h-8 text-gray-400"})}),a.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:t}),a.jsx("p",{className:"text-gray-500 mb-6 max-w-sm mx-auto",children:n}),a.jsx("button",{onClick:i,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r})]})}function tg({value:e,onChange:t,placeholder:n="Search..."}){return a.jsxs("div",{className:"relative",children:[a.jsx(Zh,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),a.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]})}function ng({currentPage:e,totalPages:t,onPageChange:n}){return a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[a.jsxs("div",{className:"flex-1 flex justify-between sm:hidden",children:[a.jsx("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Previous"}),a.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Next"})]}),a.jsxs("div",{className:"hidden sm:flex-1 sm:flex sm:items-center sm:justify-between",children:[a.jsx("div",{children:a.jsxs("p",{className:"text-sm text-gray-700",children:["Page ",a.jsx("span",{className:"font-medium",children:e})," of"," ",a.jsx("span",{className:"font-medium",children:t})]})}),a.jsx("div",{children:a.jsxs("nav",{className:"relative z-0 inline-flex rounded-md shadow-sm -space-x-px","aria-label":"Pagination",children:[a.jsxs("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[a.jsx("span",{className:"sr-only",children:"Previous"}),a.jsx(Ad,{className:"h-5 w-5"})]}),Array.from({length:t},(r,i)=>i+1).map(r=>a.jsx("button",{onClick:()=>n(r),className:`relative inline-flex items-center px-4 py-2 border text-sm font-medium ${r===e?"z-10 bg-blue-50 border-blue-500 text-blue-600":"bg-white border-gray-300 text-gray-500 hover:bg-gray-50"}`,children:r},r)),a.jsxs("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[a.jsx("span",{className:"sr-only",children:"Next"}),a.jsx(qo,{className:"h-5 w-5"})]})]})})]})]})}const qp=6,Gp={analyzing:{bg:"bg-blue-100",text:"text-blue-800",icon:a.jsx(Li,{className:"w-4 h-4 animate-spin"})},ready:{bg:"bg-green-100",text:"text-green-800",icon:null},failed:{bg:"bg-red-100",text:"text-red-800",icon:a.jsx(on,{className:"w-4 h-4"})}};function CR({datasets:e,constants:t}){console.log(e);const{rootPath:n}=_r().props,[r,i]=A.useState(""),[l,u]=A.useState(1),[d,f]=A.useState([]),m=A.useMemo(()=>e.filter(x=>x.name.toLowerCase().includes(r.toLowerCase())||x.description.toLowerCase().includes(r.toLowerCase())),[e,r]),h=Math.ceil(m.length/qp),g=m.slice((l-1)*qp,l*qp),y=x=>{confirm("Are you sure you want to delete this dataset?")&&rt.delete(`${n}/datasets/${x}`)};A.useEffect(()=>{let x;return e.some(E=>E.workflow_status==="analyzing")&&(x=window.setInterval(()=>{rt.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasets"]})},2e3)),()=>{x&&window.clearInterval(x)}},[e]);const N=x=>{f(b=>b.includes(x)?b.filter(E=>E!==x):[...b,x])};return e.length===0?a.jsx("div",{className:"p-8",children:a.jsx(Pd,{icon:Ln,title:"Create your first dataset",description:"Create a dataset to start training your machine learning models",actionLabel:"Create Dataset",onAction:()=>{rt.visit(`${n}/datasets/new`)}})}):a.jsx("div",{className:"p-8",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasets"}),a.jsx(tg,{value:r,onChange:i,placeholder:"Search datasets..."})]}),a.jsxs(yr,{href:`${n}/datasets/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4"}),"New Dataset"]})]}),g.length===0?a.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[a.jsx(Ln,{className:"mx-auto h-12 w-12 text-gray-400"}),a.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasets found"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasets match your search criteria. Try adjusting your search or create a new dataset."}),a.jsx("div",{className:"mt-6",children:a.jsxs(yr,{href:`${n}/datasets/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4 mr-2"}),"New Dataset"]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:g.map(x=>a.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[a.jsxs("div",{className:"flex justify-between items-start mb-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ln,{className:"w-5 h-5 text-blue-600 mt-1"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:x.name}),a.jsxs("div",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${Gp[x.workflow_status].bg} ${Gp[x.workflow_status].text}`,children:[Gp[x.workflow_status].icon,a.jsx("span",{children:x.workflow_status.charAt(0).toUpperCase()+x.workflow_status.slice(1)})]})]}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:x.description})]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(yr,{href:`${n}/datasets/${x.id}`,className:`transition-colors ${x.workflow_status==="analyzing"?"text-gray-300 cursor-not-allowed pointer-events-none":"text-gray-400 hover:text-blue-600"}`,title:x.workflow_status==="analyzing"?"Dataset is being analyzed":"View details",children:a.jsx(Jh,{className:"w-5 h-5"})}),a.jsx("button",{className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete dataset",onClick:()=>y(x.id),children:a.jsx(aa,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Columns"}),a.jsxs("p",{className:"text-sm font-medium text-gray-900",children:[x.columns.length," columns"]})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Rows"}),a.jsx("p",{className:"text-sm font-medium text-gray-900",children:x.num_rows.toLocaleString()})]})]}),a.jsx("div",{className:"mt-4 pt-4 border-t border-gray-100",children:a.jsxs("div",{className:"flex flex-wrap gap-2",children:[x.columns.slice(0,3).map(b=>a.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800",children:b.name},b.name)),x.columns.length>3&&a.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800",children:["+",x.columns.length-3," more"]})]})}),x.workflow_status==="failed"&&x.stacktrace&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[a.jsxs("button",{onClick:()=>N(x.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[a.jsx(on,{className:"w-4 h-4"}),a.jsx("span",{children:"View Error Details"}),d.includes(x.id)?a.jsx(Ul,{className:"w-4 h-4"}):a.jsx(oa,{className:"w-4 h-4"})]}),d.includes(x.id)&&a.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:a.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap font-mono",children:x.stacktrace})})]})]},x.id))}),h>1&&a.jsx(ng,{currentPage:l,totalPages:h,onPageChange:u})]})]})})}const ER=Object.freeze(Object.defineProperty({__proto__:null,default:CR},Symbol.toStringTag,{value:"Module"})),Yb=()=>{const e=tr.createContext(null);return[()=>{const t=tr.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]},zm=e=>{const t=structuredClone(e??{});for(const n in t)Ot.isPlainObject(t[n])?t[n]=zm(t[n]):Array.isArray(t[n])?t[n]=t[n].map(r=>zm(r)):t[n]!==void 0&&t[n]!==null||(t[n]="");return t},Jb=(e,t)=>{Object.entries(e).forEach(([n,r])=>{Ot.isPlainObject(r)?(iv(e,n,`${n}${t}`),Jb(r,t)):Array.isArray(r)&&iv(e,n,`${n}${t}`)})},iv=(e,t,n)=>{t!==n&&(e[n]=e[t],delete e[t])},Zb=(e,t)=>{var r;const n=t.replace(/\[\]$/,"");if(n.includes("[]")){const i=n.indexOf("[]"),l=n.slice(0,i),u=n.slice(i+2),d=Ot.get(e,l);if(Array.isArray(d))for(let f=0;f<d.length;f++)Zb(e,`${l}[${f}]${u}`)}if(n.charAt(n.length-1)==="]"){const i=n.match(/(?<index>\d*)\]$/),l=Ot.get(e,n.slice(0,n.lastIndexOf("[")));Array.isArray(l)&&((r=i==null?void 0:i.groups)==null?void 0:r.index)!==void 0&&l.splice(Number(i.groups.index),1)}else Ot.unset(e,n)},ov=e=>Array.isArray(e)?e:[e],[kR,NM]=Yb();function Td(e,t){const n=A.useCallback(()=>{let Z=null,de=e;return typeof e=="string"&&(Z=e,de=t),[Z,zm(de)]},[e,t]),[r,i]=n(),[l,u]=A.useState(i||{}),[d,f]=r?Vx(i,`${r}:data`):A.useState(i),m=A.useMemo(()=>{const Z=d?Object.keys(d):[];if(Z.length===1)return Z[0]},[d]),[h,g]=r?Vx({},`${r}:errors`):A.useState({}),[y,N]=A.useState(!1),[x,b]=A.useState(!1),[E,w]=A.useState(),[S,C]=A.useState(!1),[O,R]=A.useState(!1),F=A.useRef(null),D=A.useRef();let z=A.useRef(Z=>Z);const B=A.useRef();A.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]);let H=A.useRef(),ce=A.useRef();A.useEffect(()=>{H.current&&ce.current&&H.current(...ce.current)},[d]);let ue=!1;try{ue=kR().railsAttributes}catch{}const we=(Z,de,se={})=>{const Q={...se,onCancelToken:ee=>{if(F.current=ee,se.onCancelToken)return se.onCancelToken(ee)},onBefore:ee=>{if(C(!1),R(!1),clearTimeout(D.current),se.onBefore)return se.onBefore(ee)},onStart:ee=>{if(b(!0),se.onStart)return se.onStart(ee)},onProgress:ee=>{if(w(ee),se.onProgress)return se.onProgress(ee)},onSuccess:ee=>{if(B.current&&(b(!1),w(null),g({}),N(!1),C(!0),R(!0),D.current=setTimeout(()=>{B.current&&R(!1)},2e3)),se.onSuccess)return se.onSuccess(ee)},onError:ee=>{if(B.current&&(b(!1),w(null),g((G=>{if(!G||!m)return G;const ge={};return Object.keys(G).forEach(_e=>{ge[`${m}.${_e}`]=G[_e]}),ge})(ee)),N(!0)),se.onError)return se.onError(ee)},onCancel:()=>{if(B.current&&(b(!1),w(null)),se.onCancel)return se.onCancel()},onFinish:ee=>{if(B.current&&(b(!1),w(null)),F.current=null,se.onFinish)return se.onFinish(ee)}};let re=z.current(structuredClone(d));ue&&(re=((ee,G="_attributes")=>{const ge=structuredClone(ee);return Object.values(ge).forEach(_e=>{Ot.isPlainObject(_e)&&Jb(_e,G)}),ge})(re)),Z==="delete"?rt.delete(de,{...Q,data:re}):rt[Z](de,re,Q)},ne=Z=>{if(!Z)return void g({});const de=ov(Z);g(se=>{const Q=Object.keys(se).reduce((re,ee)=>({...re,...de.length>0&&!de.includes(String(ee))?{[ee]:se[ee]}:{}}),{});return N(Object.keys(Q).length>0),Q})};return{data:d,isDirty:!Ot.isEqual(d,l),errors:h,hasErrors:y,processing:x,progress:E,wasSuccessful:S,recentlySuccessful:O,transform:Z=>{z.current=Z},onChange:Z=>{H.current=Z},setData:(Z,de)=>{if(typeof Z=="string")return f(se=>{const Q=structuredClone(se);return H.current&&(ce.current=[Z,de,Ot.get(se,Z)]),Ot.set(Q,Z,de),Q});Z instanceof Function?f(se=>{const Q=Z(structuredClone(se));return H.current&&(ce.current=[void 0,Q,se]),Q}):(H.current&&(ce.current=[void 0,d,Z]),f(Z))},getData:Z=>Ot.get(d,Z),unsetData:Z=>{f(de=>{const se=structuredClone(de);return H.current&&(ce.current=[Z,Ot.get(de,Z),void 0]),Zb(se,Z),se})},setDefaults:(Z,de)=>{u(Z!==void 0?se=>({...se,...typeof Z=="string"?{[Z]:de}:Z}):()=>d)},reset:Z=>{if(!Z)return H.current&&(ce.current=[void 0,l,d]),f(l),void g({});const de=ov(Z),se=structuredClone(d);de.forEach(Q=>{Ot.set(se,Q,Ot.get(l,Q))}),ne(Z),H.current&&(ce.current=[void 0,se,d]),f(se)},setError:(Z,de)=>{g(se=>{const Q={...se,...typeof Z=="string"?{[Z]:de}:Z};return N(Object.keys(Q).length>0),Q})},getError:Z=>Ot.get(h,Z),clearErrors:ne,submit:we,get:(Z,de)=>{we("get",Z,de)},post:(Z,de)=>{we("post",Z,de)},put:(Z,de)=>{we("put",Z,de)},patch:(Z,de)=>{we("patch",Z,de)},delete:(Z,de)=>{we("delete",Z,de)},cancel:()=>{F.current&&F.current.cancel()}}}const[AR,CM]=(()=>{const e=tr.createContext(null);return[()=>{const t=tr.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]})();Yb();const PR=tr.forwardRef(({children:e,type:t="submit",disabled:n=!1,component:r="button",requiredFields:i,...l},u)=>{const{data:d,getData:f,processing:m}=AR(),h=A.useCallback(()=>!(!i||i.length===0)&&i.some(g=>{return typeof(y=f(g))=="string"?y==="":typeof y=="number"?y!==0&&!y:Ot.isEmpty(y);var y}),[d]);return tr.createElement(r,{children:e,type:t,disabled:n||m||i&&h(),ref:u,...l})});tr.memo(PR);function TR({datasource:e,constants:t}){var m,h,g,y;const{rootPath:n}=_r().props,r=!!e,{data:i,setData:l,processing:u,errors:d}=Td({datasource:{name:(e==null?void 0:e.name)??"",datasource_type:(e==null?void 0:e.datasource_type)??"s3",s3_bucket:(e==null?void 0:e.s3_bucket)??"",s3_prefix:(e==null?void 0:e.s3_prefix)??"",s3_region:(e==null?void 0:e.s3_region)??"us-east-1"}}),f=N=>{N.preventDefault(),r?rt.patch(`${n}/datasources/${e.id}`,i):rt.post(`${n}/datasources`,i)};return a.jsx("div",{className:"max-w-2xl mx-auto py-8",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-6",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-6",children:r?"Edit Datasource":"New Datasource"}),a.jsxs("form",{onSubmit:f,className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700",children:"Name"}),a.jsx("input",{type:"text",id:"name",value:i.datasource.name,onChange:N=>l("datasource.name",N.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((m=d.datasource)==null?void 0:m.name)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.name})]}),!r&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),a.jsx(ot,{options:t.DATASOURCE_TYPES,value:i.datasource.datasource_type,onChange:N=>l("datasource.datasource_type",N),placeholder:"Select datasource type"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"s3_bucket",className:"block text-sm font-medium text-gray-700",children:"S3 Bucket"}),a.jsx("input",{type:"text",id:"s3_bucket",value:i.datasource.s3_bucket,onChange:N=>l("datasource.s3_bucket",N.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((h=d.datasource)==null?void 0:h.s3_bucket)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_bucket})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"s3_prefix",className:"block text-sm font-medium text-gray-700",children:"S3 Prefix"}),a.jsx("input",{type:"text",id:"s3_prefix",value:i.datasource.s3_prefix,onChange:N=>l("datasource.s3_prefix",N.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",placeholder:"data/raw/"}),((g=d.datasource)==null?void 0:g.s3_prefix)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_prefix})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"S3 Region"}),a.jsx(ot,{options:t.s3.S3_REGIONS,value:i.datasource.s3_region,onChange:N=>l("datasource.s3_region",N),placeholder:"Select s3 region"}),((y=d.datasource)==null?void 0:y.s3_region)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_region})]}),a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx("button",{type:"button",onClick:()=>rt.visit(`${n}/datasources`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:u,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:u?"Saving...":r?"Save Changes":"Create Datasource"})]})]})]})})}const OR=Object.freeze(Object.defineProperty({__proto__:null,default:TR},Symbol.toStringTag,{value:"Module"})),Kp=6;function RR({datasources:e}){const{rootPath:t}=_r().props,[n,r]=A.useState(""),[i,l]=A.useState(1),[u,d]=A.useState([]),f=A.useMemo(()=>e.filter(b=>b.name.toLowerCase().includes(n.toLowerCase())||b.s3_bucket.toLowerCase().includes(n.toLowerCase())),[n,e]),m=Math.ceil(f.length/Kp),h=f.slice((i-1)*Kp,i*Kp),g=b=>{confirm("Are you sure you want to delete this datasource? This action cannot be undone.")&&rt.delete(`${t}/datasources/${b}`)},y=b=>{d(E=>E.includes(b)?E.filter(w=>w!==b):[...E,b])},N=async b=>{try{rt.post(`${t}/datasources/${b}/sync`,{},{preserveScroll:!0,preserveState:!0,onSuccess:()=>{},onError:()=>{console.error("Failed to sync datasource")}})}catch(E){console.error("Failed to sync datasource:",E)}},x=b=>{if(b==="Not Synced")return b;const E=new Date(b);return isNaN(E.getTime())?b:E.toLocaleString()};return A.useEffect(()=>{let b;return e.some(w=>w.is_syncing)&&(b=window.setInterval(()=>{rt.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasources"]})},2e3)),()=>{b&&window.clearInterval(b)}},[e]),e.length===0?a.jsx("div",{className:"p-8",children:a.jsx(Pd,{icon:Ro,title:"Connect your first data source",description:"Connect to your data sources to start creating datasets and training models",actionLabel:"Add Datasource",onAction:()=>{rt.visit(`${t}/datasources/new`)}})}):a.jsx("div",{className:"p-8",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasources"}),a.jsx(tg,{value:n,onChange:r,placeholder:"Search datasources..."})]}),a.jsxs(yr,{href:`${t}/datasources/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4"}),"New Datasource"]})]}),h.length===0?a.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[a.jsx(Ro,{className:"mx-auto h-12 w-12 text-gray-400"}),a.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasources found"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasources match your search criteria. Try adjusting your search or add a new datasource."}),a.jsx("div",{className:"mt-6",children:a.jsxs(yr,{href:`${t}/datasources/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4 mr-2"}),"New Datasource"]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map(b=>a.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[a.jsxs("div",{className:"flex justify-between items-start mb-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ro,{className:"w-5 h-5 text-blue-600 mt-1"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:b.name}),b.is_syncing?a.jsx(Za,{variant:"warning",children:"syncing"}):b.sync_error?a.jsx(Za,{variant:"important",children:"sync error"}):b.last_synced_at!=="Not Synced"?a.jsx(Za,{variant:"success",children:"synced"}):a.jsx(Za,{variant:"warning",children:"not synced"})]}),a.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["s3://",b.s3_bucket,"/",b.s3_prefix]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>N(b.id),disabled:b.is_syncing,className:`text-gray-400 hover:text-blue-600 transition-colors ${b.is_syncing?"animate-spin":""}`,title:"Sync datasource",children:a.jsx(ET,{className:"w-5 h-5"})}),a.jsx(yr,{href:`${t}/datasources/${b.id}/edit`,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Edit datasource",children:a.jsx(Bl,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>g(b.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete datasource",children:a.jsx(aa,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Region"}),a.jsx("p",{className:"text-sm font-medium text-gray-900",children:b.s3_region})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Last Sync"}),a.jsx("p",{className:"text-sm font-medium text-gray-900",children:x(b.last_synced_at)})]})]}),b.sync_error&&b.stacktrace&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[a.jsxs("button",{onClick:()=>y(b.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[a.jsx(on,{className:"w-4 h-4"}),a.jsx("span",{children:"View Error Details"}),u.includes(b.id)?a.jsx(Ul,{className:"w-4 h-4"}):a.jsx(oa,{className:"w-4 h-4"})]}),u.includes(b.id)&&a.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:a.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap font-mono",children:b.stacktrace})})]})]},b.id))}),m>1&&a.jsx(ng,{currentPage:i,totalPages:m,onPageChange:l})]})]})})}const IR=Object.freeze(Object.defineProperty({__proto__:null,default:RR},Symbol.toStringTag,{value:"Module"})),av={classification:[{value:"accuracy_score",label:"Accuracy",description:"Overall prediction accuracy"},{value:"precision_score",label:"Precision",description:"Ratio of true positives to predicted positives"},{value:"recall_score",label:"Recall",description:"Ratio of true positives to actual positives"},{value:"f1_score",label:"F1 Score",description:"Harmonic mean of precision and recall"}],regression:[{value:"mean_absolute_error",label:"Mean Absolute Error",description:"Average absolute differences between predicted and actual values"},{value:"mean_squared_error",label:"Mean Squared Error",description:"Average squared differences between predicted and actual values"},{value:"root_mean_squared_error",label:"Root Mean Squared Error",description:"Square root of mean squared error"},{value:"r2_score",label:"R² Score",description:"Proportion of variance in the target that is predictable"}]};function LR({isOpen:e,onClose:t,onSave:n,initialData:r,tunerJobConstants:i,timezone:l,retrainingJobConstants:u}){var O,R,F,D,z,B,H,ce,ue,we,ne,Z,de,se,Q,re,ee,G,ge,_e,De,me;const[d,f]=A.useState(!1);A.useState(null);const m=Object.entries(i).filter(([Y,pe])=>Array.isArray(pe.options)).reduce((Y,[pe,ye])=>({...Y,[pe]:ye.options[0].value}),{}),h=m.booster,g=Object.entries(i.hyperparameters[h]||{}).filter(([Y,pe])=>!Array.isArray(pe.options)).reduce((Y,[pe,ye])=>({...Y,[pe]:{min:ye.min,max:ye.max}}),{}),[y,N]=A.useState({retraining_job_attributes:{id:((O=r.retraining_job)==null?void 0:O.id)||null,active:((R=r.retraining_job)==null?void 0:R.active)??!1,frequency:((F=r.retraining_job)==null?void 0:F.frequency)||u.frequency[0].value,tuning_frequency:((D=r.retraining_job)==null?void 0:D.tuning_frequency)||"month",direction:((z=r.retraining_job)==null?void 0:z.direction)||"maximize",batch_mode:((B=r.retraining_job)==null?void 0:B.batch_mode)||!1,batch_size:((H=r.retraining_job)==null?void 0:H.batch_size)||100,batch_overlap:((ce=r.retraining_job)==null?void 0:ce.batch_overlap)||1,batch_key:((ue=r.retraining_job)==null?void 0:ue.batch_key)||"",at:{hour:((ne=(we=r.retraining_job)==null?void 0:we.at)==null?void 0:ne.hour)??2,day_of_week:((de=(Z=r.retraining_job)==null?void 0:Z.at)==null?void 0:de.day_of_week)??1,day_of_month:((Q=(se=r.retraining_job)==null?void 0:se.at)==null?void 0:Q.day_of_month)??1},metric:((re=r.retraining_job)==null?void 0:re.metric)||av[r.task==="classification"?"classification":"regression"][0].value,threshold:((ee=r.retraining_job)==null?void 0:ee.threshold)||(r.task==="classification"?.85:.1),tuner_config:(G=r.retraining_job)!=null&&G.tuner_config?{n_trials:r.retraining_job.tuner_config.n_trials||10,config:{...m,...g,...r.retraining_job.tuner_config.config}}:void 0,tuning_enabled:((ge=r.retraining_job)==null?void 0:ge.tuning_enabled)??!1}});if(A.useEffect(()=>{y.retraining_job_attributes.tuner_config&&Object.keys(y.retraining_job_attributes.tuner_config.config).length===0&&N(Y=>({...Y,retraining_job_attributes:{...Y.retraining_job_attributes,tuner_config:{...Y.retraining_job_attributes.tuner_config,config:{...m,...g}}}}))},[y.retraining_job_attributes.tuner_config]),!e)return null;const x=(Y,pe)=>{N(ye=>({...ye,retraining_job_attributes:{...ye.retraining_job_attributes,tuner_config:{...ye.retraining_job_attributes.tuner_config,config:{...ye.retraining_job_attributes.tuner_config.config,[Y]:pe}}}}))},b=()=>{const Y=Object.entries(i).filter(([ye,Je])=>Array.isArray(Je.options)),pe=Y.map(([ye])=>ye);return a.jsxs("div",{className:"space-y-4",children:[Y.map(([ye,Je])=>{var zn;return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:Je.label}),a.jsx(ot,{options:Je.options.map(Et=>({value:Et.value,label:Et.label,description:Et.description})),value:((zn=y.retraining_job_attributes.tuner_config)==null?void 0:zn.config[ye])||Je.options[0].value,onChange:Et=>x(ye,Et)})]},ye)}),pe.map(ye=>{var Et;const Je=Object.entries(i).filter(([_n,Un])=>Un.depends_on===ye),zn=((Et=y.retraining_job_attributes.tuner_config)==null?void 0:Et.config[ye])||i[ye].options[0].value;return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Parameter Ranges"}),a.jsx("div",{className:"space-y-4 max-h-[400px] overflow-y-auto pr-2",children:Je.map(([_n,Un])=>{const _t=Un[zn];return _t?Object.entries(_t).map(([Vt,kt])=>{var zt,Sr,Ur,Sn;return kt.min!==void 0&&kt.max!==void 0?a.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm font-medium text-gray-900",children:kt.label}),a.jsx("span",{className:"text-xs text-gray-500",children:kt.description})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Minimum"}),a.jsx("input",{type:"number",min:kt.min,max:kt.max,step:kt.step,value:((Sr=(zt=y.retraining_job_attributes.tuner_config)==null?void 0:zt.config[Vt])==null?void 0:Sr.min)??kt.min,onChange:St=>E(Vt,"min",parseFloat(St.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Maximum"}),a.jsx("input",{type:"number",min:kt.min,max:kt.max,step:kt.step,value:((Sn=(Ur=y.retraining_job_attributes.tuner_config)==null?void 0:Ur.config[Vt])==null?void 0:Sn.max)??kt.max,onChange:St=>E(Vt,"max",parseFloat(St.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]})]})]},Vt):null}):null})})]},ye)})]})},E=(Y,pe,ye)=>{N(Je=>({...Je,retraining_job_attributes:{...Je.retraining_job_attributes,tuner_config:{...Je.retraining_job_attributes.tuner_config,config:{...Je.retraining_job_attributes.tuner_config.config,[Y]:{...Je.retraining_job_attributes.tuner_config.config[Y],[pe]:ye}}}}}))},w=(Y,pe)=>{N(ye=>Y==="hour"||Y==="day_of_week"||Y==="day_of_month"?{...ye,retraining_job_attributes:{...ye.retraining_job_attributes,at:{...ye.retraining_job_attributes.at,[Y]:pe}}}:{...ye,retraining_job_attributes:{...ye.retraining_job_attributes,[Y]:pe}})},S=(Y,pe)=>{N(ye=>({...ye,retraining_job_attributes:{...ye.retraining_job_attributes,[Y]:pe}}))},C=()=>{const{retraining_job_attributes:Y}=y,pe={hour:Y.at.hour};switch(Y.frequency){case"day":break;case"week":pe.day_of_week=Y.at.day_of_week;break;case"month":pe.day_of_month=Y.at.day_of_month;break}const ye={retraining_job_attributes:{...Y,at:pe}};n(ye),t()};return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl max-h-[90vh] overflow-hidden",children:[a.jsxs("div",{className:"flex justify-between items-center p-4 border-b",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Training Configuration"}),a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:a.jsx(Wl,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 grid grid-cols-2 gap-8 max-h-[calc(90vh-8rem)] overflow-y-auto",children:[a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xh,{className:"w-5 h-5 text-blue-600"}),a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Training Schedule"})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("input",{type:"checkbox",id:"scheduleEnabled",checked:y.retraining_job_attributes.active,onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,active:Y.target.checked}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsx("label",{htmlFor:"scheduleEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable scheduled training"})]})]}),!y.retraining_job_attributes.active&&a.jsx("div",{className:"bg-gray-50 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(on,{className:"w-5 h-5 text-gray-400 mt-0.5"}),a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Manual Training Mode"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"The model will only be trained when you manually trigger training. You can do this from the model details page at any time."})]})]})}),y.retraining_job_attributes.active&&a.jsx(a.Fragment,{children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),a.jsx(ot,{options:u.frequency.map(Y=>({value:Y.value,label:Y.label,description:Y.description})),value:y.retraining_job_attributes.frequency,onChange:Y=>w("frequency",Y)})]}),y.retraining_job_attributes.frequency==="week"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Week"}),a.jsx(ot,{options:[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],value:y.retraining_job_attributes.at.day_of_week,onChange:Y=>w("day_of_week",Y)})]}),y.retraining_job_attributes.frequency==="month"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Month"}),a.jsx(ot,{options:Array.from({length:31},(Y,pe)=>({value:pe+1,label:`Day ${pe+1}`})),value:y.retraining_job_attributes.at.day_of_month,onChange:Y=>w("day_of_month",Y)})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Hour (",l,")"]}),a.jsx(ot,{options:Array.from({length:24},(Y,pe)=>({value:pe,label:`${pe}:00`})),value:y.retraining_job_attributes.at.hour,onChange:Y=>w("hour",Y)})]})]})})}),a.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("label",{htmlFor:"batchTrainingEnabled",className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:["Enable Batch Training",a.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-gray-400 hover:text-gray-600",children:a.jsx(Mb,{className:"w-4 h-4"})})]})}),a.jsx("input",{type:"checkbox",id:"batchMode",checked:y.retraining_job_attributes.batch_mode,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_mode:Y.target.checked}}),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"})]}),d&&a.jsx("div",{className:"bg-blue-50 rounded-lg p-4 text-sm text-blue-700",children:a.jsxs("ul",{className:"space-y-2",children:[a.jsx("li",{children:"• When disabled, the model will train on the entire dataset in a single pass."}),a.jsx("li",{children:"• When enabled, the model will learn from small batches of data iteratively, improving training speed"})]})}),y.retraining_job_attributes.batch_mode&&a.jsxs("div",{className:"mt-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Size"}),a.jsx("input",{type:"number",value:y.retraining_job_attributes.batch_size,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_size:parseInt(Y.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Overlap"}),a.jsx("input",{type:"number",value:y.retraining_job_attributes.batch_overlap,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_overlap:parseInt(Y.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),a.jsx(ot,{value:y.retraining_job_attributes.batch_key,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_key:Y}}),options:((De=(_e=r.dataset)==null?void 0:_e.columns)==null?void 0:De.map(Y=>({value:Y.name,label:Y.name})))||[],placeholder:"Select a column for batch key"})]})]})]}),a.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(on,{className:"w-5 h-5 text-blue-600"}),a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Evaluator Configuration"})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Metric"}),a.jsx(ot,{options:av[r.task==="classification"?"classification":"regression"].map(Y=>({value:Y.value,label:Y.label,description:Y.description})),value:y.retraining_job_attributes.metric,onChange:Y=>S("metric",Y)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Threshold"}),a.jsx("input",{type:"number",value:y.retraining_job_attributes.threshold,onChange:Y=>S("threshold",parseFloat(Y.target.value)),step:.01,min:0,max:1,className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),a.jsx("div",{className:"bg-blue-50 rounded-md p-4",children:a.jsxs("div",{className:"flex items-start",children:[a.jsx(on,{className:"w-5 h-5 text-blue-400 mt-0.5"}),a.jsxs("div",{className:"ml-3",children:[a.jsx("h3",{className:"text-sm font-medium text-blue-800",children:"Deployment Criteria"}),a.jsxs("p",{className:"mt-2 text-sm text-blue-700",children:["The model will be automatically deployed when the ",y.retraining_job_attributes.metric," is"," ",y.retraining_job_attributes.direction==="minimize"?"below":"above"," ",y.retraining_job_attributes.threshold,"."]})]})]})})]})]})]})}),a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ui,{className:"w-5 h-5 text-blue-600"}),a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Hyperparameter Tuning"})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("input",{type:"checkbox",id:"tuningEnabled",checked:y.retraining_job_attributes.tuning_enabled||!1,onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_enabled:Y.target.checked,tuner_config:Y.target.checked?{n_trials:10,config:g}:void 0}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsx("label",{htmlFor:"tuningEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable tuning"})]})]}),y.retraining_job_attributes.tuning_enabled&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),a.jsx(ot,{options:[{value:"always",label:"Always",description:"Tune hyperparameters every time"},{value:"week",label:"Weekly",description:"Tune hyperparameters once every week"},{value:"month",label:"Monthly",description:"Tune hyperparameters once every month"}],value:y.retraining_job_attributes.tuning_frequency||"week",onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_frequency:Y}}))})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Number of Trials"}),a.jsx("input",{type:"number",min:"1",max:"1000",value:((me=y.retraining_job_attributes.tuner_config)==null?void 0:me.n_trials)||10,onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuner_config:{...pe.retraining_job_attributes.tuner_config,n_trials:parseInt(Y.target.value)}}})),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),b()]})]})})]}),a.jsxs("div",{className:"flex justify-end gap-4 p-4 border-t",children:[a.jsx("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-500",children:"Cancel"}),a.jsx("button",{onClick:C,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md",children:"Save Changes"})]})]})})}const yo=({error:e})=>e?a.jsxs("div",{className:"mt-1 flex items-center gap-1 text-sm text-red-600",children:[a.jsx(on,{className:"w-4 h-4"}),e]}):null;function ew({initialData:e,datasets:t,constants:n,isEditing:r,errors:i}){var z,B,H,ce,ue,we;const{rootPath:l}=_r().props,[u,d]=A.useState(!1),[f,m]=A.useState(!1),h=Td({model:{id:e==null?void 0:e.id,name:(e==null?void 0:e.name)||"",model_type:(e==null?void 0:e.model_type)||"xgboost",dataset_id:(e==null?void 0:e.dataset_id)||"",task:(e==null?void 0:e.task)||"classification",objective:(e==null?void 0:e.objective)||"binary:logistic",metrics:(e==null?void 0:e.metrics)||["accuracy"],retraining_job_attributes:e!=null&&e.retraining_job?{id:e.retraining_job.id,frequency:e.retraining_job.frequency,tuning_frequency:e.retraining_job.tuning_frequency||"month",batch_mode:e.retraining_job.batch_mode,batch_size:e.retraining_job.batch_size,batch_overlap:e.retraining_job.batch_overlap,batch_key:e.retraining_job.batch_key,at:{hour:((z=e.retraining_job.at)==null?void 0:z.hour)??2,day_of_week:((B=e.retraining_job.at)==null?void 0:B.day_of_week)??1,day_of_month:((H=e.retraining_job.at)==null?void 0:H.day_of_month)??1},active:e.retraining_job.active,metric:e.retraining_job.metric,threshold:e.retraining_job.threshold,tuner_config:e.retraining_job.tuner_config,tuning_enabled:e.retraining_job.tuning_enabled||!1}:void 0}}),{data:g,setData:y,post:N,patch:x,processing:b,errors:E}=h,w={...i,...E},S=((ce=n.objectives[g.model.model_type])==null?void 0:ce[g.model.task])||[];A.useEffect(()=>{var ne;if(e!=null&&e.metrics)y({...g,model:{...g.model,objective:g.model.task==="classification"?"binary:logistic":"reg:squarederror"}});else{const Z=((ne=n.metrics[g.model.task])==null?void 0:ne.map(de=>de.value))||[];y({...g,model:{...g.model,objective:g.model.task==="classification"?"binary:logistic":"reg:squarederror",metrics:Z}})}},[g.model.task]),A.useEffect(()=>{f&&(O(),m(!1))},[f]);const C=ne=>{y({...g,model:{...g.model,retraining_job_attributes:ne.retraining_job_attributes}}),m(!0)},O=()=>{if(g.model.retraining_job_attributes){const ne={hour:g.model.retraining_job_attributes.at.hour};switch(g.model.retraining_job_attributes.frequency){case"day":break;case"week":ne.day_of_week=g.model.retraining_job_attributes.at.day_of_week;break;case"month":ne.day_of_month=g.model.retraining_job_attributes.at.day_of_month;break}y("model.retraining_job_attributes.at",ne)}g.model.id?x(`${l}/models/${g.model.id}`,{onSuccess:()=>{rt.visit(`${l}/models`)}}):N(`${l}/models`,{onSuccess:()=>{rt.visit(`${l}/models`)}})},R=ne=>{ne.preventDefault(),O()};console.log(g.model);const F=t.find(ne=>ne.id===g.model.dataset_id),D=n.tuner_job_constants[g.model.model_type]||{};return a.jsxs("form",{onSubmit:R,className:"space-y-8",children:[a.jsxs("div",{className:"flex justify-between items-center border-b pb-4",children:[a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Model Configuration"}),a.jsxs("button",{type:"button",onClick:()=>d(!0),className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(PT,{className:"w-4 h-4"}),"Configure Training"]})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Name"}),a.jsx("input",{type:"text",id:"name",value:g.model.name,onChange:ne=>y("model.name",ne.target.value),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"}),a.jsx(yo,{error:w.name})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Type"}),a.jsx(ot,{options:[{value:"xgboost",label:"XGBoost",description:"Gradient boosting framework"}],value:g.model.model_type,onChange:ne=>y("model.model_type",ne),placeholder:"Select model type"}),a.jsx(yo,{error:w.model_type})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Dataset"}),r?a.jsxs("div",{className:"flex items-center gap-2 p-2 bg-gray-50 rounded-md border border-gray-200",children:[a.jsx(ST,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-gray-700",children:F==null?void 0:F.name})]}):a.jsx(ot,{options:t.map(ne=>({value:ne.id,label:ne.name,description:`${ne.num_rows.toLocaleString()} rows`})),value:g.model.dataset_id,onChange:ne=>y("model.dataset_id",ne),placeholder:"Select dataset"}),a.jsx(yo,{error:w.dataset_id})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Task"}),a.jsx(ot,{options:n.tasks,value:g.model.task,onChange:ne=>y("model.task",ne),placeholder:"Select task"}),a.jsx(yo,{error:w.task})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Objective"}),a.jsx(ot,{options:S||[],value:g.model.objective,onChange:ne=>y("model.objective",ne),placeholder:"Select objective"}),a.jsx(yo,{error:w.objective})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Metrics"}),a.jsx("div",{className:"grid grid-cols-2 gap-4",children:(ue=n.metrics[g.model.task])==null?void 0:ue.map(ne=>a.jsxs("label",{className:"relative flex items-center px-4 py-3 bg-white border rounded-lg hover:bg-gray-50 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:g.model.metrics.includes(ne.value),onChange:Z=>{const de=Z.target.checked?[...g.model.metrics,ne.value]:g.model.metrics.filter(se=>se!==ne.value);y("model.metrics",de)},className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsxs("div",{className:"ml-3",children:[a.jsx("span",{className:"block text-sm font-medium text-gray-900",children:ne.label}),a.jsx("span",{className:"block text-xs text-gray-500",children:ne.direction==="maximize"?"Higher is better":"Lower is better"})]})]},ne.value))})]})]}),g.model.retraining_job_attributes&&g.model.retraining_job_attributes.batch_mode&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),a.jsx(ot,{value:g.model.retraining_job_attributes.batch_key||"",onChange:ne=>y("model",{...g.model,retraining_job_attributes:{...g.model.retraining_job_attributes,batch_key:ne}}),options:((we=F==null?void 0:F.columns)==null?void 0:we.map(ne=>({value:ne.name,label:ne.name})))||[],placeholder:"Select a column for batch key"}),a.jsx(yo,{error:w["model.retraining_job_attributes.batch_key"]})]})}),a.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[a.jsx("button",{type:"button",onClick:()=>rt.visit(`${l}/models`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r?"Save Changes":"Create Model"})]}),a.jsx(LR,{isOpen:u,onClose:()=>d(!1),onSave:C,initialData:{task:g.model.task,metrics:g.model.metrics,modelType:g.model.model_type,dataset:F,retraining_job:g.model.retraining_job_attributes},tunerJobConstants:D,timezone:n.timezone,retrainingJobConstants:n.retraining_job_constants})]})}function MR({model:e,datasets:t,constants:n}){return a.jsx("div",{className:"max-w-3xl mx-auto py-8",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-lg",children:[a.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Bs,{className:"w-6 h-6 text-blue-600"}),a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Edit Model"})]})}),a.jsx("div",{className:"p-6",children:a.jsx(ew,{initialData:e,datasets:t,constants:n,isEditing:!0})})]})})}const FR=Object.freeze(Object.defineProperty({__proto__:null,default:MR},Symbol.toStringTag,{value:"Module"})),Xe=e=>{const t=new Date;return t.setDate(t.getDate()-e),t.toISOString()},tw=[{id:1,name:"Customer Churn Dataset",description:"Historical customer data for churn prediction",columns:[{name:"usage_days",type:"numeric",description:"Number of days customer has used the product",statistics:{mean:145.7,median:130,min:1,max:365,nullCount:0}},{name:"total_spend",type:"numeric",description:"Total customer spend in USD",statistics:{mean:487.32,median:425.5,min:0,max:2500,nullCount:1250}},{name:"support_tickets",type:"numeric",description:"Number of support tickets opened",statistics:{mean:2.3,median:1,min:0,max:15,nullCount:3750}},{name:"subscription_tier",type:"categorical",description:"Customer subscription level",statistics:{uniqueCount:3,nullCount:125}},{name:"last_login",type:"datetime",description:"Last time the customer logged in",statistics:{nullCount:5e3}}],sampleData:[{usage_days:234,total_spend:567.89,support_tickets:1,subscription_tier:"premium",last_login:"2024-03-01"},{usage_days:45,total_spend:null,support_tickets:null,subscription_tier:"basic",last_login:null}],rowCount:25e3,updatedAt:"2024-03-10T12:00:00Z"}];Xe(30),Xe(0);Xe(7),Xe(1),Xe(30),Xe(0);Xe(1),Xe(1),Xe(1),Xe(1),Xe(2),Xe(2),Xe(2),Xe(2),Xe(3),Xe(3),Xe(3),Xe(3),Xe(4),Xe(4),Xe(4),Xe(4);const $R=[{id:1,name:"Normalize state",description:"Turn state names into 2 letter state abbreviations",groupId:1,testDatasetId:1,inputColumns:["state"],outputColumns:["state"],code:"",createdAt:Xe(30),updatedAt:Xe(0)}],Ni=[{id:1,name:"Customer Churn",description:"Features for customer churn dataset",features:$R,createdAt:Xe(30),updatedAt:Xe(0)}];function DR({value:e,onChange:t,language:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-800",children:[a.jsx("span",{className:"text-sm text-gray-400",children:"Ruby Feature"}),a.jsx("span",{className:"text-xs px-2 py-1 bg-gray-700 rounded text-gray-300",children:n})]}),a.jsx("textarea",{value:e,onChange:r=>t(r.target.value),className:"w-full h-64 p-4 bg-gray-900 text-gray-100 font-mono text-sm focus:outline-none",placeholder:`def transform(df)
|
433
|
+
end`})})]})})}function _R({options:e,initialFeatures:t=[],onFeaturesChange:n}){const[r,i]=A.useState(t),[l,u]=A.useState(null);console.log(r);const d=e.filter(E=>!r.find(w=>w.name===E.name)),f=E=>{const w=E.map((S,C)=>({...S,feature_position:C}));i(w),n(w)},m=E=>{const w=e.find(S=>S.name===E);if(w){const S={...w,feature_position:r.length};f([...r,S])}},h=E=>{const w=[...r];w.splice(E,1),f(w)},g=E=>{if(E===0)return;const w=[...r];[w[E-1],w[E]]=[w[E],w[E-1]],f(w)},y=E=>{if(E===r.length-1)return;const w=[...r];[w[E],w[E+1]]=[w[E+1],w[E]],f(w)},N=(E,w)=>{u(w)},x=(E,w)=>{if(E.preventDefault(),l===null||l===w)return;const S=[...r],[C]=S.splice(l,1);S.splice(w,0,C),f(S),u(w)},b=()=>{u(null)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"flex-1",children:a.jsx(ot,{options:d.map(E=>({value:E.name,label:E.name,description:E.description})),value:"",onChange:E=>m(E),placeholder:"Add a transform..."})}),a.jsx(wR,{})]}),a.jsxs("div",{className:"space-y-2",children:[r.map((E,w)=>a.jsxs("div",{draggable:!0,onDragStart:S=>N(S,w),onDragOver:S=>x(S,w),onDragEnd:b,className:`flex items-center gap-3 p-3 bg-white border rounded-lg ${l===w?"border-blue-500 shadow-lg":"border-gray-200"} ${l!==null?"cursor-grabbing":""}`,children:[a.jsx("button",{type:"button",className:"p-1 text-gray-400 hover:text-gray-600 cursor-grab active:cursor-grabbing",children:a.jsx(_T,{className:"w-4 h-4"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium text-gray-900",children:E.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${E.feature_type==="calculation"?"bg-blue-100 text-blue-800":E.feature_type==="lookup"?"bg-purple-100 text-purple-800":"bg-green-100 text-green-800"}`,children:"feature"})]}),a.jsx("p",{className:"text-sm text-gray-500 truncate",children:E.description})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>g(w),disabled:w===0,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move up",children:a.jsx(fT,{className:"w-4 h-4"})}),a.jsx("button",{type:"button",onClick:()=>y(w),disabled:w===r.length-1,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move down",children:a.jsx(cT,{className:"w-4 h-4"})}),a.jsx("button",{type:"button",onClick:()=>h(w),className:"p-1 text-gray-400 hover:text-red-600",title:"Remove transform",children:a.jsx(Wl,{className:"w-4 h-4"})})]})]},E.name)),r.length===0&&a.jsxs("div",{className:"text-center py-8 bg-gray-50 border-2 border-dashed border-gray-200 rounded-lg",children:[a.jsx(Js,{className:"w-8 h-8 text-gray-400 mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-gray-500",children:"Add features to enrich your dataset"})]})]})]})}function SR({isOpen:e,onClose:t,initialDataset:n,onSave:r,constants:i}){const[l,u]=A.useState(n),[d,f]=A.useState("columns"),[m,h]=A.useState(!1),[g,y]=A.useState({targetColumn:l.target}),[N,x]=A.useState(null),[b,E]=A.useState(""),[w,S]=A.useState({view:"all",types:[]}),[C,O]=A.useState(n.needs_refresh||!1),R=A.useCallback(async G=>{await r(G)},[r]),{saving:F,saved:D,error:z}=vR(l,R,2e3),B=G=>{var ge,_e,De;return((ge=G.preprocessing_steps)==null?void 0:ge.training)!=null&&((De=(_e=G.preprocessing_steps)==null?void 0:_e.training)==null?void 0:De.method)!=="none"},H=A.useMemo(()=>l.columns.filter(G=>{const ge=G.name.toLowerCase().includes(b.toLowerCase()),_e=w.types.length===0||w.types.includes(G.datatype),De=(()=>{var me,Y;switch(w.view){case"training":return!G.hidden&&!G.drop_if_null;case"hidden":return G.hidden;case"preprocessed":return B(G);case"nulls":return(((Y=(me=G.statistics)==null?void 0:me.processed)==null?void 0:Y.null_count)||0)>0;default:return!0}})();return ge&&_e&&De}),[l.columns,b,w]),ce=A.useMemo(()=>({total:l.columns.length,filtered:H.length,training:l.columns.filter(G=>!G.hidden&&!G.drop_if_null).length,hidden:l.columns.filter(G=>G.hidden).length,withPreprocessing:l.columns.filter(B).length,withNulls:l.columns.filter(G=>{var ge,_e;return(((_e=(ge=G.statistics)==null?void 0:ge.processed)==null?void 0:_e.null_count)||0)>0}).length}),[l.columns,H]),ue=A.useMemo(()=>Array.from(new Set(l.columns.map(G=>G.datatype))),[l.columns]),we=G=>{x(G)},ne=G=>{const ge=l.columns.map(_e=>({..._e,hidden:_e.name===G?!_e.hidden:_e.hidden}));u({...l,columns:ge}),O(!0)},Z=G=>{const ge=String(G);y({targetColumn:G});const _e=l.columns.map(De=>({...De,is_target:De.name===ge}));u({...l,columns:_e}),O(!0)},de=(G,ge)=>{const _e=l.columns.map(De=>({...De,datatype:De.name===G?ge:De.datatype}));u({...l,columns:_e}),O(!0)},se=(G,ge,_e,De)=>{if(!l.columns.find(pe=>pe.name===G))return;const Y=l.columns.map(pe=>pe.name!==G?pe:{...pe,preprocessing_steps:{training:ge,...De&&_e?{inference:_e}:{}}});u({...l,columns:Y}),O(!0)},Q=G=>{const _e=(l.features||[]).filter(me=>!G.find(Y=>Y.name===me.name)).map(me=>({...me,_destroy:!0})),De=[...G,..._e].map((me,Y)=>({...me,dataset_id:l.id,feature_position:Y}));u(me=>({...me,features:De})),O(!0)},re=async()=>{h(!0);try{await r(l),rt.post(`/easy_ml/datasets/${l.id}/refresh`,{},{onSuccess:()=>{h(!1)},onError:()=>{console.error("Error refreshing dataset"),h(!1)}})}catch(G){console.error("Error refreshing dataset:",G),h(!1)}};if(!e)return null;const ee=N?l.columns.find(G=>G.name===N):null;return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl max-h-[90vh] overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"flex justify-between items-center p-4 border-b shrink-0",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Column Configuration"}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"min-w-[0px]",children:a.jsx(xO,{saving:F,saved:D,error:z})}),a.jsxs("div",{className:"relative",children:[a.jsx(Zh,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),a.jsx("input",{type:"text",placeholder:"Search columns...",value:b,onChange:G=>E(G.target.value),className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:a.jsx(Wl,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"flex border-b shrink-0",children:[a.jsx("button",{onClick:()=>f("columns"),className:`px-4 py-2 text-sm font-medium border-b-2 ${d==="columns"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ui,{className:"w-4 h-4"}),"Column Configuration"]})}),a.jsx("button",{onClick:()=>f("features"),className:`px-4 py-2 text-sm font-medium border-b-2 ${d==="features"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(TT,{className:"w-4 h-4"}),"Features",a.jsx("span",{className:"px-1.5 py-0.5 text-xs font-medium bg-blue-100 text-blue-600 rounded-full",children:i.feature_options.length})]})}),C&&a.jsx("div",{className:"ml-auto px-4 flex items-center",children:a.jsxs("button",{onClick:re,disabled:m,className:"group relative inline-flex items-center gap-2 px-6 py-2.5 bg-gradient-to-r from-blue-600 to-indigo-600 text-white text-sm font-medium rounded-md hover:from-blue-700 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 transition-all duration-200 shadow-md hover:shadow-lg",children:[a.jsx("div",{className:"absolute inset-0 bg-white/10 rounded-md opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),m?a.jsxs(a.Fragment,{children:[a.jsx(Li,{className:"w-4 h-4 animate-spin"}),"Applying Preprocessing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(kT,{className:"w-4 h-4"}),"Apply Preprocessing"]})]})})]}),d==="columns"?a.jsxs(tr.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-7 flex-1 min-h-0",children:[a.jsxs("div",{className:"col-span-3 border-r overflow-hidden flex flex-col",children:[a.jsxs("div",{className:"p-4 border-b shrink-0",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Target Column"}),a.jsx(ot,{options:l.columns.map(G=>({value:G.name,label:G.name})),value:g.targetColumn||"",onChange:G=>G&&Z(String(G))})]}),a.jsx("div",{className:"shrink-0",children:a.jsx(yO,{types:ue,activeFilters:w,onFilterChange:S,columnStats:ce,columns:l.columns,colHasPreprocessingSteps:B})}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:a.jsx(gO,{columns:H,selectedColumn:N,onColumnSelect:we,onToggleHidden:ne})})]}),a.jsx("div",{className:"col-span-4 overflow-y-auto p-4",children:ee?a.jsx(hO,{column:ee,dataset:l,setColumnType:de,setDataset:u,constants:i,onUpdate:(G,ge,_e)=>se(ee.name,G,ge,_e)}):a.jsx("div",{className:"h-full flex items-center justify-center text-gray-500",children:"Select a column to configure preprocessing"})})]}),a.jsxs("div",{className:"border-t p-4 flex justify-between items-center shrink-0",children:[a.jsxs("div",{className:"text-sm text-gray-600",children:[l.columns.filter(G=>!G.hidden).length," columns selected for training"]}),a.jsx("div",{className:"flex gap-3",children:a.jsx("button",{onClick:t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Close"})})]})]}):a.jsx("div",{className:"p-6 h-[calc(90vh-8rem)] overflow-y-auto",children:a.jsx(_R,{options:i.feature_options,initialFeatures:l.features,onFeaturesChange:Q})})]})})}function jR({dataset:e,constants:t}){const[n,r]=A.useState(!1),[i,l]=A.useState(e),{rootPath:u}=_r().props,d=A.useCallback(f=>{var y;const m=Object.entries(f).reduce((N,[x,b])=>(x!=="columns"&&x!=="features"&&!Ot.isEqual(i[x],b)&&(N[x]=b),N),{}),h=f.columns.reduce((N,x)=>{const b=i.columns.find(E=>E.id===x.id);if(!b||!Ot.isEqual(b,x)){const E=Object.entries(x).reduce((w,[S,C])=>((!b||!Ot.isEqual(b[S],C))&&(w[S]=C),w),{});Object.keys(E).length>0&&(N[x.id]={...E,id:x.id})}return N},{}),g=(y=f.features)==null?void 0:y.map((N,x)=>({id:N.id,name:N.name,feature_class:N.feature_class,feature_position:x,_destroy:N._destroy}));(Object.keys(m).length>0||Object.keys(h).length>0||!Ot.isEqual(i.features,f.features))&&rt.patch(`${u}/datasets/${e.id}`,{dataset:{...m,columns_attributes:h,features_attributes:g}},{preserveState:!0,preserveScroll:!0}),l(f)},[i,e.id,u]);return a.jsxs("div",{className:"p-8 space-y-6",children:[a.jsx("div",{className:"flex justify-end",children:a.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50",children:[a.jsx(Bl,{className:"w-4 h-4"}),"Configure Columns"]})}),a.jsx(OT,{dataset:i}),a.jsx(SR,{isOpen:n,onClose:()=>r(!1),initialDataset:i,constants:t,onSave:d})]})}const NR=Object.freeze(Object.defineProperty({__proto__:null,default:jR},Symbol.toStringTag,{value:"Module"}));function Pd({icon:e,title:t,description:n,actionLabel:r,onAction:i}){return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:a.jsx(e,{className:"w-8 h-8 text-gray-400"})}),a.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:t}),a.jsx("p",{className:"text-gray-500 mb-6 max-w-sm mx-auto",children:n}),a.jsx("button",{onClick:i,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r})]})}function tg({value:e,onChange:t,placeholder:n="Search..."}){return a.jsxs("div",{className:"relative",children:[a.jsx(Zh,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),a.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]})}function ng({currentPage:e,totalPages:t,onPageChange:n}){return a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[a.jsxs("div",{className:"flex-1 flex justify-between sm:hidden",children:[a.jsx("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Previous"}),a.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Next"})]}),a.jsxs("div",{className:"hidden sm:flex-1 sm:flex sm:items-center sm:justify-between",children:[a.jsx("div",{children:a.jsxs("p",{className:"text-sm text-gray-700",children:["Page ",a.jsx("span",{className:"font-medium",children:e})," of"," ",a.jsx("span",{className:"font-medium",children:t})]})}),a.jsx("div",{children:a.jsxs("nav",{className:"relative z-0 inline-flex rounded-md shadow-sm -space-x-px","aria-label":"Pagination",children:[a.jsxs("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[a.jsx("span",{className:"sr-only",children:"Previous"}),a.jsx(Ad,{className:"h-5 w-5"})]}),Array.from({length:t},(r,i)=>i+1).map(r=>a.jsx("button",{onClick:()=>n(r),className:`relative inline-flex items-center px-4 py-2 border text-sm font-medium ${r===e?"z-10 bg-blue-50 border-blue-500 text-blue-600":"bg-white border-gray-300 text-gray-500 hover:bg-gray-50"}`,children:r},r)),a.jsxs("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[a.jsx("span",{className:"sr-only",children:"Next"}),a.jsx(qo,{className:"h-5 w-5"})]})]})})]})]})}const qp=6,Gp={analyzing:{bg:"bg-blue-100",text:"text-blue-800",icon:a.jsx(Li,{className:"w-4 h-4 animate-spin"})},ready:{bg:"bg-green-100",text:"text-green-800",icon:null},failed:{bg:"bg-red-100",text:"text-red-800",icon:a.jsx(on,{className:"w-4 h-4"})}};function CR({datasets:e,constants:t}){console.log(e);const{rootPath:n}=_r().props,[r,i]=A.useState(""),[l,u]=A.useState(1),[d,f]=A.useState([]),m=A.useMemo(()=>e.filter(x=>x.name.toLowerCase().includes(r.toLowerCase())||x.description.toLowerCase().includes(r.toLowerCase())),[e,r]),h=Math.ceil(m.length/qp),g=m.slice((l-1)*qp,l*qp),y=x=>{confirm("Are you sure you want to delete this dataset?")&&rt.delete(`${n}/datasets/${x}`)};A.useEffect(()=>{let x;return e.some(E=>E.workflow_status==="analyzing")&&(x=window.setInterval(()=>{rt.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasets"]})},2e3)),()=>{x&&window.clearInterval(x)}},[e]);const N=x=>{f(b=>b.includes(x)?b.filter(E=>E!==x):[...b,x])};return e.length===0?a.jsx("div",{className:"p-8",children:a.jsx(Pd,{icon:Ln,title:"Create your first dataset",description:"Create a dataset to start training your machine learning models",actionLabel:"Create Dataset",onAction:()=>{rt.visit(`${n}/datasets/new`)}})}):a.jsx("div",{className:"p-8",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasets"}),a.jsx(tg,{value:r,onChange:i,placeholder:"Search datasets..."})]}),a.jsxs(yr,{href:`${n}/datasets/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4"}),"New Dataset"]})]}),g.length===0?a.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[a.jsx(Ln,{className:"mx-auto h-12 w-12 text-gray-400"}),a.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasets found"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasets match your search criteria. Try adjusting your search or create a new dataset."}),a.jsx("div",{className:"mt-6",children:a.jsxs(yr,{href:`${n}/datasets/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4 mr-2"}),"New Dataset"]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:g.map(x=>a.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[a.jsxs("div",{className:"flex justify-between items-start mb-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ln,{className:"w-5 h-5 text-blue-600 mt-1"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:x.name}),a.jsxs("div",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${Gp[x.workflow_status].bg} ${Gp[x.workflow_status].text}`,children:[Gp[x.workflow_status].icon,a.jsx("span",{children:x.workflow_status.charAt(0).toUpperCase()+x.workflow_status.slice(1)})]})]}),a.jsx("p",{className:"text-sm text-gray-500 mt-1",children:x.description})]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(yr,{href:`${n}/datasets/${x.id}`,className:`transition-colors ${x.workflow_status==="analyzing"?"text-gray-300 cursor-not-allowed pointer-events-none":"text-gray-400 hover:text-blue-600"}`,title:x.workflow_status==="analyzing"?"Dataset is being analyzed":"View details",children:a.jsx(Jh,{className:"w-5 h-5"})}),a.jsx("button",{className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete dataset",onClick:()=>y(x.id),children:a.jsx(aa,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Columns"}),a.jsxs("p",{className:"text-sm font-medium text-gray-900",children:[x.columns.length," columns"]})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Rows"}),a.jsx("p",{className:"text-sm font-medium text-gray-900",children:x.num_rows.toLocaleString()})]})]}),a.jsx("div",{className:"mt-4 pt-4 border-t border-gray-100",children:a.jsxs("div",{className:"flex flex-wrap gap-2",children:[x.columns.slice(0,3).map(b=>a.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800",children:b.name},b.name)),x.columns.length>3&&a.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800",children:["+",x.columns.length-3," more"]})]})}),x.workflow_status==="failed"&&x.stacktrace&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[a.jsxs("button",{onClick:()=>N(x.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[a.jsx(on,{className:"w-4 h-4"}),a.jsx("span",{children:"View Error Details"}),d.includes(x.id)?a.jsx(Ul,{className:"w-4 h-4"}):a.jsx(oa,{className:"w-4 h-4"})]}),d.includes(x.id)&&a.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:a.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap font-mono",children:x.stacktrace})})]})]},x.id))}),h>1&&a.jsx(ng,{currentPage:l,totalPages:h,onPageChange:u})]})]})})}const ER=Object.freeze(Object.defineProperty({__proto__:null,default:CR},Symbol.toStringTag,{value:"Module"})),Yb=()=>{const e=tr.createContext(null);return[()=>{const t=tr.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]},zm=e=>{const t=structuredClone(e??{});for(const n in t)Ot.isPlainObject(t[n])?t[n]=zm(t[n]):Array.isArray(t[n])?t[n]=t[n].map(r=>zm(r)):t[n]!==void 0&&t[n]!==null||(t[n]="");return t},Jb=(e,t)=>{Object.entries(e).forEach(([n,r])=>{Ot.isPlainObject(r)?(iv(e,n,`${n}${t}`),Jb(r,t)):Array.isArray(r)&&iv(e,n,`${n}${t}`)})},iv=(e,t,n)=>{t!==n&&(e[n]=e[t],delete e[t])},Zb=(e,t)=>{var r;const n=t.replace(/\[\]$/,"");if(n.includes("[]")){const i=n.indexOf("[]"),l=n.slice(0,i),u=n.slice(i+2),d=Ot.get(e,l);if(Array.isArray(d))for(let f=0;f<d.length;f++)Zb(e,`${l}[${f}]${u}`)}if(n.charAt(n.length-1)==="]"){const i=n.match(/(?<index>\d*)\]$/),l=Ot.get(e,n.slice(0,n.lastIndexOf("[")));Array.isArray(l)&&((r=i==null?void 0:i.groups)==null?void 0:r.index)!==void 0&&l.splice(Number(i.groups.index),1)}else Ot.unset(e,n)},ov=e=>Array.isArray(e)?e:[e],[kR,NM]=Yb();function Td(e,t){const n=A.useCallback(()=>{let Z=null,de=e;return typeof e=="string"&&(Z=e,de=t),[Z,zm(de)]},[e,t]),[r,i]=n(),[l,u]=A.useState(i||{}),[d,f]=r?Vx(i,`${r}:data`):A.useState(i),m=A.useMemo(()=>{const Z=d?Object.keys(d):[];if(Z.length===1)return Z[0]},[d]),[h,g]=r?Vx({},`${r}:errors`):A.useState({}),[y,N]=A.useState(!1),[x,b]=A.useState(!1),[E,w]=A.useState(),[S,C]=A.useState(!1),[O,R]=A.useState(!1),F=A.useRef(null),D=A.useRef();let z=A.useRef(Z=>Z);const B=A.useRef();A.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]);let H=A.useRef(),ce=A.useRef();A.useEffect(()=>{H.current&&ce.current&&H.current(...ce.current)},[d]);let ue=!1;try{ue=kR().railsAttributes}catch{}const we=(Z,de,se={})=>{const Q={...se,onCancelToken:ee=>{if(F.current=ee,se.onCancelToken)return se.onCancelToken(ee)},onBefore:ee=>{if(C(!1),R(!1),clearTimeout(D.current),se.onBefore)return se.onBefore(ee)},onStart:ee=>{if(b(!0),se.onStart)return se.onStart(ee)},onProgress:ee=>{if(w(ee),se.onProgress)return se.onProgress(ee)},onSuccess:ee=>{if(B.current&&(b(!1),w(null),g({}),N(!1),C(!0),R(!0),D.current=setTimeout(()=>{B.current&&R(!1)},2e3)),se.onSuccess)return se.onSuccess(ee)},onError:ee=>{if(B.current&&(b(!1),w(null),g((G=>{if(!G||!m)return G;const ge={};return Object.keys(G).forEach(_e=>{ge[`${m}.${_e}`]=G[_e]}),ge})(ee)),N(!0)),se.onError)return se.onError(ee)},onCancel:()=>{if(B.current&&(b(!1),w(null)),se.onCancel)return se.onCancel()},onFinish:ee=>{if(B.current&&(b(!1),w(null)),F.current=null,se.onFinish)return se.onFinish(ee)}};let re=z.current(structuredClone(d));ue&&(re=((ee,G="_attributes")=>{const ge=structuredClone(ee);return Object.values(ge).forEach(_e=>{Ot.isPlainObject(_e)&&Jb(_e,G)}),ge})(re)),Z==="delete"?rt.delete(de,{...Q,data:re}):rt[Z](de,re,Q)},ne=Z=>{if(!Z)return void g({});const de=ov(Z);g(se=>{const Q=Object.keys(se).reduce((re,ee)=>({...re,...de.length>0&&!de.includes(String(ee))?{[ee]:se[ee]}:{}}),{});return N(Object.keys(Q).length>0),Q})};return{data:d,isDirty:!Ot.isEqual(d,l),errors:h,hasErrors:y,processing:x,progress:E,wasSuccessful:S,recentlySuccessful:O,transform:Z=>{z.current=Z},onChange:Z=>{H.current=Z},setData:(Z,de)=>{if(typeof Z=="string")return f(se=>{const Q=structuredClone(se);return H.current&&(ce.current=[Z,de,Ot.get(se,Z)]),Ot.set(Q,Z,de),Q});Z instanceof Function?f(se=>{const Q=Z(structuredClone(se));return H.current&&(ce.current=[void 0,Q,se]),Q}):(H.current&&(ce.current=[void 0,d,Z]),f(Z))},getData:Z=>Ot.get(d,Z),unsetData:Z=>{f(de=>{const se=structuredClone(de);return H.current&&(ce.current=[Z,Ot.get(de,Z),void 0]),Zb(se,Z),se})},setDefaults:(Z,de)=>{u(Z!==void 0?se=>({...se,...typeof Z=="string"?{[Z]:de}:Z}):()=>d)},reset:Z=>{if(!Z)return H.current&&(ce.current=[void 0,l,d]),f(l),void g({});const de=ov(Z),se=structuredClone(d);de.forEach(Q=>{Ot.set(se,Q,Ot.get(l,Q))}),ne(Z),H.current&&(ce.current=[void 0,se,d]),f(se)},setError:(Z,de)=>{g(se=>{const Q={...se,...typeof Z=="string"?{[Z]:de}:Z};return N(Object.keys(Q).length>0),Q})},getError:Z=>Ot.get(h,Z),clearErrors:ne,submit:we,get:(Z,de)=>{we("get",Z,de)},post:(Z,de)=>{we("post",Z,de)},put:(Z,de)=>{we("put",Z,de)},patch:(Z,de)=>{we("patch",Z,de)},delete:(Z,de)=>{we("delete",Z,de)},cancel:()=>{F.current&&F.current.cancel()}}}const[AR,CM]=(()=>{const e=tr.createContext(null);return[()=>{const t=tr.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]})();Yb();const PR=tr.forwardRef(({children:e,type:t="submit",disabled:n=!1,component:r="button",requiredFields:i,...l},u)=>{const{data:d,getData:f,processing:m}=AR(),h=A.useCallback(()=>!(!i||i.length===0)&&i.some(g=>{return typeof(y=f(g))=="string"?y==="":typeof y=="number"?y!==0&&!y:Ot.isEmpty(y);var y}),[d]);return tr.createElement(r,{children:e,type:t,disabled:n||m||i&&h(),ref:u,...l})});tr.memo(PR);function TR({datasource:e,constants:t}){var m,h,g,y;const{rootPath:n}=_r().props,r=!!e,{data:i,setData:l,processing:u,errors:d}=Td({datasource:{name:(e==null?void 0:e.name)??"",datasource_type:(e==null?void 0:e.datasource_type)??"s3",s3_bucket:(e==null?void 0:e.s3_bucket)??"",s3_prefix:(e==null?void 0:e.s3_prefix)??"",s3_region:(e==null?void 0:e.s3_region)??"us-east-1"}}),f=N=>{N.preventDefault(),r?rt.patch(`${n}/datasources/${e.id}`,i):rt.post(`${n}/datasources`,i)};return a.jsx("div",{className:"max-w-2xl mx-auto py-8",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-6",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-6",children:r?"Edit Datasource":"New Datasource"}),a.jsxs("form",{onSubmit:f,className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700",children:"Name"}),a.jsx("input",{type:"text",id:"name",value:i.datasource.name,onChange:N=>l("datasource.name",N.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((m=d.datasource)==null?void 0:m.name)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.name})]}),!r&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),a.jsx(ot,{options:t.DATASOURCE_TYPES,value:i.datasource.datasource_type,onChange:N=>l("datasource.datasource_type",N),placeholder:"Select datasource type"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"s3_bucket",className:"block text-sm font-medium text-gray-700",children:"S3 Bucket"}),a.jsx("input",{type:"text",id:"s3_bucket",value:i.datasource.s3_bucket,onChange:N=>l("datasource.s3_bucket",N.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((h=d.datasource)==null?void 0:h.s3_bucket)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_bucket})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"s3_prefix",className:"block text-sm font-medium text-gray-700",children:"S3 Prefix"}),a.jsx("input",{type:"text",id:"s3_prefix",value:i.datasource.s3_prefix,onChange:N=>l("datasource.s3_prefix",N.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",placeholder:"data/raw/"}),((g=d.datasource)==null?void 0:g.s3_prefix)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_prefix})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"S3 Region"}),a.jsx(ot,{options:t.s3.S3_REGIONS,value:i.datasource.s3_region,onChange:N=>l("datasource.s3_region",N),placeholder:"Select s3 region"}),((y=d.datasource)==null?void 0:y.s3_region)&&a.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_region})]}),a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx("button",{type:"button",onClick:()=>rt.visit(`${n}/datasources`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),a.jsx("button",{type:"submit",disabled:u,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:u?"Saving...":r?"Save Changes":"Create Datasource"})]})]})]})})}const OR=Object.freeze(Object.defineProperty({__proto__:null,default:TR},Symbol.toStringTag,{value:"Module"})),Kp=6;function RR({datasources:e}){const{rootPath:t}=_r().props;console.log(`rootPath: ${t}`);const[n,r]=A.useState(""),[i,l]=A.useState(1),[u,d]=A.useState([]),f=A.useMemo(()=>e.filter(b=>b.name.toLowerCase().includes(n.toLowerCase())||b.s3_bucket.toLowerCase().includes(n.toLowerCase())),[n,e]),m=Math.ceil(f.length/Kp),h=f.slice((i-1)*Kp,i*Kp),g=b=>{confirm("Are you sure you want to delete this datasource? This action cannot be undone.")&&rt.delete(`${t}/datasources/${b}`)},y=b=>{d(E=>E.includes(b)?E.filter(w=>w!==b):[...E,b])},N=async b=>{try{rt.post(`${t}/datasources/${b}/sync`,{},{preserveScroll:!0,preserveState:!0,onSuccess:E=>{debugger;console.log("SUCCESS")},onError:()=>{debugger;console.error("Failed to sync datasource")}})}catch(E){console.error("Failed to sync datasource:",E)}},x=b=>{if(b==="Not Synced")return b;const E=new Date(b);return isNaN(E.getTime())?b:E.toLocaleString()};return A.useEffect(()=>{let b;return e.some(w=>w.is_syncing)&&(b=window.setInterval(()=>{rt.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasources"]})},2e3)),()=>{b&&window.clearInterval(b)}},[e]),e.length===0?a.jsx("div",{className:"p-8",children:a.jsx(Pd,{icon:Ro,title:"Connect your first data source",description:"Connect to your data sources to start creating datasets and training models",actionLabel:"Add Datasource",onAction:()=>{rt.visit(`${t}/datasources/new`)}})}):a.jsx("div",{className:"p-8",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasources"}),a.jsx(tg,{value:n,onChange:r,placeholder:"Search datasources..."})]}),a.jsxs(yr,{href:`${t}/datasources/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4"}),"New Datasource"]})]}),h.length===0?a.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[a.jsx(Ro,{className:"mx-auto h-12 w-12 text-gray-400"}),a.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasources found"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasources match your search criteria. Try adjusting your search or add a new datasource."}),a.jsx("div",{className:"mt-6",children:a.jsxs(yr,{href:`${t}/datasources/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(Js,{className:"w-4 h-4 mr-2"}),"New Datasource"]})})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map(b=>a.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[a.jsxs("div",{className:"flex justify-between items-start mb-4",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ro,{className:"w-5 h-5 text-blue-600 mt-1"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:b.name}),b.is_syncing?a.jsx(Za,{variant:"warning",children:"syncing"}):b.sync_error?a.jsx(Za,{variant:"important",children:"sync error"}):b.last_synced_at!=="Not Synced"?a.jsx(Za,{variant:"success",children:"synced"}):a.jsx(Za,{variant:"warning",children:"not synced"})]}),a.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["s3://",b.s3_bucket,"/",b.s3_prefix]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>N(b.id),disabled:b.is_syncing,className:`text-gray-400 hover:text-blue-600 transition-colors ${b.is_syncing?"animate-spin":""}`,title:"Sync datasource",children:a.jsx(ET,{className:"w-5 h-5"})}),a.jsx(yr,{href:`${t}/datasources/${b.id}/edit`,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Edit datasource",children:a.jsx(Bl,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>g(b.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete datasource",children:a.jsx(aa,{className:"w-5 h-5"})})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Region"}),a.jsx("p",{className:"text-sm font-medium text-gray-900",children:b.s3_region})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-500",children:"Last Sync"}),a.jsx("p",{className:"text-sm font-medium text-gray-900",children:x(b.last_synced_at)})]})]}),b.sync_error&&b.stacktrace&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[a.jsxs("button",{onClick:()=>y(b.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[a.jsx(on,{className:"w-4 h-4"}),a.jsx("span",{children:"View Error Details"}),u.includes(b.id)?a.jsx(Ul,{className:"w-4 h-4"}):a.jsx(oa,{className:"w-4 h-4"})]}),u.includes(b.id)&&a.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:a.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap font-mono",children:b.stacktrace})})]})]},b.id))}),m>1&&a.jsx(ng,{currentPage:i,totalPages:m,onPageChange:l})]})]})})}const IR=Object.freeze(Object.defineProperty({__proto__:null,default:RR},Symbol.toStringTag,{value:"Module"})),av={classification:[{value:"accuracy_score",label:"Accuracy",description:"Overall prediction accuracy"},{value:"precision_score",label:"Precision",description:"Ratio of true positives to predicted positives"},{value:"recall_score",label:"Recall",description:"Ratio of true positives to actual positives"},{value:"f1_score",label:"F1 Score",description:"Harmonic mean of precision and recall"}],regression:[{value:"mean_absolute_error",label:"Mean Absolute Error",description:"Average absolute differences between predicted and actual values"},{value:"mean_squared_error",label:"Mean Squared Error",description:"Average squared differences between predicted and actual values"},{value:"root_mean_squared_error",label:"Root Mean Squared Error",description:"Square root of mean squared error"},{value:"r2_score",label:"R² Score",description:"Proportion of variance in the target that is predictable"}]};function LR({isOpen:e,onClose:t,onSave:n,initialData:r,tunerJobConstants:i,timezone:l,retrainingJobConstants:u}){var O,R,F,D,z,B,H,ce,ue,we,ne,Z,de,se,Q,re,ee,G,ge,_e,De,me;const[d,f]=A.useState(!1);A.useState(null);const m=Object.entries(i).filter(([Y,pe])=>Array.isArray(pe.options)).reduce((Y,[pe,ye])=>({...Y,[pe]:ye.options[0].value}),{}),h=m.booster,g=Object.entries(i.hyperparameters[h]||{}).filter(([Y,pe])=>!Array.isArray(pe.options)).reduce((Y,[pe,ye])=>({...Y,[pe]:{min:ye.min,max:ye.max}}),{}),[y,N]=A.useState({retraining_job_attributes:{id:((O=r.retraining_job)==null?void 0:O.id)||null,active:((R=r.retraining_job)==null?void 0:R.active)??!1,frequency:((F=r.retraining_job)==null?void 0:F.frequency)||u.frequency[0].value,tuning_frequency:((D=r.retraining_job)==null?void 0:D.tuning_frequency)||"month",direction:((z=r.retraining_job)==null?void 0:z.direction)||"maximize",batch_mode:((B=r.retraining_job)==null?void 0:B.batch_mode)||!1,batch_size:((H=r.retraining_job)==null?void 0:H.batch_size)||100,batch_overlap:((ce=r.retraining_job)==null?void 0:ce.batch_overlap)||1,batch_key:((ue=r.retraining_job)==null?void 0:ue.batch_key)||"",at:{hour:((ne=(we=r.retraining_job)==null?void 0:we.at)==null?void 0:ne.hour)??2,day_of_week:((de=(Z=r.retraining_job)==null?void 0:Z.at)==null?void 0:de.day_of_week)??1,day_of_month:((Q=(se=r.retraining_job)==null?void 0:se.at)==null?void 0:Q.day_of_month)??1},metric:((re=r.retraining_job)==null?void 0:re.metric)||av[r.task==="classification"?"classification":"regression"][0].value,threshold:((ee=r.retraining_job)==null?void 0:ee.threshold)||(r.task==="classification"?.85:.1),tuner_config:(G=r.retraining_job)!=null&&G.tuner_config?{n_trials:r.retraining_job.tuner_config.n_trials||10,config:{...m,...g,...r.retraining_job.tuner_config.config}}:void 0,tuning_enabled:((ge=r.retraining_job)==null?void 0:ge.tuning_enabled)??!1}});if(A.useEffect(()=>{y.retraining_job_attributes.tuner_config&&Object.keys(y.retraining_job_attributes.tuner_config.config).length===0&&N(Y=>({...Y,retraining_job_attributes:{...Y.retraining_job_attributes,tuner_config:{...Y.retraining_job_attributes.tuner_config,config:{...m,...g}}}}))},[y.retraining_job_attributes.tuner_config]),!e)return null;const x=(Y,pe)=>{N(ye=>({...ye,retraining_job_attributes:{...ye.retraining_job_attributes,tuner_config:{...ye.retraining_job_attributes.tuner_config,config:{...ye.retraining_job_attributes.tuner_config.config,[Y]:pe}}}}))},b=()=>{const Y=Object.entries(i).filter(([ye,Je])=>Array.isArray(Je.options)),pe=Y.map(([ye])=>ye);return a.jsxs("div",{className:"space-y-4",children:[Y.map(([ye,Je])=>{var zn;return a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:Je.label}),a.jsx(ot,{options:Je.options.map(Et=>({value:Et.value,label:Et.label,description:Et.description})),value:((zn=y.retraining_job_attributes.tuner_config)==null?void 0:zn.config[ye])||Je.options[0].value,onChange:Et=>x(ye,Et)})]},ye)}),pe.map(ye=>{var Et;const Je=Object.entries(i).filter(([_n,Un])=>Un.depends_on===ye),zn=((Et=y.retraining_job_attributes.tuner_config)==null?void 0:Et.config[ye])||i[ye].options[0].value;return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Parameter Ranges"}),a.jsx("div",{className:"space-y-4 max-h-[400px] overflow-y-auto pr-2",children:Je.map(([_n,Un])=>{const _t=Un[zn];return _t?Object.entries(_t).map(([Vt,kt])=>{var zt,Sr,Ur,Sn;return kt.min!==void 0&&kt.max!==void 0?a.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm font-medium text-gray-900",children:kt.label}),a.jsx("span",{className:"text-xs text-gray-500",children:kt.description})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Minimum"}),a.jsx("input",{type:"number",min:kt.min,max:kt.max,step:kt.step,value:((Sr=(zt=y.retraining_job_attributes.tuner_config)==null?void 0:zt.config[Vt])==null?void 0:Sr.min)??kt.min,onChange:St=>E(Vt,"min",parseFloat(St.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Maximum"}),a.jsx("input",{type:"number",min:kt.min,max:kt.max,step:kt.step,value:((Sn=(Ur=y.retraining_job_attributes.tuner_config)==null?void 0:Ur.config[Vt])==null?void 0:Sn.max)??kt.max,onChange:St=>E(Vt,"max",parseFloat(St.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]})]})]},Vt):null}):null})})]},ye)})]})},E=(Y,pe,ye)=>{N(Je=>({...Je,retraining_job_attributes:{...Je.retraining_job_attributes,tuner_config:{...Je.retraining_job_attributes.tuner_config,config:{...Je.retraining_job_attributes.tuner_config.config,[Y]:{...Je.retraining_job_attributes.tuner_config.config[Y],[pe]:ye}}}}}))},w=(Y,pe)=>{N(ye=>Y==="hour"||Y==="day_of_week"||Y==="day_of_month"?{...ye,retraining_job_attributes:{...ye.retraining_job_attributes,at:{...ye.retraining_job_attributes.at,[Y]:pe}}}:{...ye,retraining_job_attributes:{...ye.retraining_job_attributes,[Y]:pe}})},S=(Y,pe)=>{N(ye=>({...ye,retraining_job_attributes:{...ye.retraining_job_attributes,[Y]:pe}}))},C=()=>{const{retraining_job_attributes:Y}=y,pe={hour:Y.at.hour};switch(Y.frequency){case"day":break;case"week":pe.day_of_week=Y.at.day_of_week;break;case"month":pe.day_of_month=Y.at.day_of_month;break}const ye={retraining_job_attributes:{...Y,at:pe}};n(ye),t()};return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:a.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl max-h-[90vh] overflow-hidden",children:[a.jsxs("div",{className:"flex justify-between items-center p-4 border-b",children:[a.jsx("h2",{className:"text-lg font-semibold",children:"Training Configuration"}),a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:a.jsx(Wl,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 grid grid-cols-2 gap-8 max-h-[calc(90vh-8rem)] overflow-y-auto",children:[a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xh,{className:"w-5 h-5 text-blue-600"}),a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Training Schedule"})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("input",{type:"checkbox",id:"scheduleEnabled",checked:y.retraining_job_attributes.active,onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,active:Y.target.checked}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsx("label",{htmlFor:"scheduleEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable scheduled training"})]})]}),!y.retraining_job_attributes.active&&a.jsx("div",{className:"bg-gray-50 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(on,{className:"w-5 h-5 text-gray-400 mt-0.5"}),a.jsxs("div",{children:[a.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Manual Training Mode"}),a.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"The model will only be trained when you manually trigger training. You can do this from the model details page at any time."})]})]})}),y.retraining_job_attributes.active&&a.jsx(a.Fragment,{children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),a.jsx(ot,{options:u.frequency.map(Y=>({value:Y.value,label:Y.label,description:Y.description})),value:y.retraining_job_attributes.frequency,onChange:Y=>w("frequency",Y)})]}),y.retraining_job_attributes.frequency==="week"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Week"}),a.jsx(ot,{options:[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],value:y.retraining_job_attributes.at.day_of_week,onChange:Y=>w("day_of_week",Y)})]}),y.retraining_job_attributes.frequency==="month"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Month"}),a.jsx(ot,{options:Array.from({length:31},(Y,pe)=>({value:pe+1,label:`Day ${pe+1}`})),value:y.retraining_job_attributes.at.day_of_month,onChange:Y=>w("day_of_month",Y)})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Hour (",l,")"]}),a.jsx(ot,{options:Array.from({length:24},(Y,pe)=>({value:pe,label:`${pe}:00`})),value:y.retraining_job_attributes.at.hour,onChange:Y=>w("hour",Y)})]})]})})}),a.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("label",{htmlFor:"batchTrainingEnabled",className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:["Enable Batch Training",a.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-gray-400 hover:text-gray-600",children:a.jsx(Mb,{className:"w-4 h-4"})})]})}),a.jsx("input",{type:"checkbox",id:"batchMode",checked:y.retraining_job_attributes.batch_mode,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_mode:Y.target.checked}}),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"})]}),d&&a.jsx("div",{className:"bg-blue-50 rounded-lg p-4 text-sm text-blue-700",children:a.jsxs("ul",{className:"space-y-2",children:[a.jsx("li",{children:"• When disabled, the model will train on the entire dataset in a single pass."}),a.jsx("li",{children:"• When enabled, the model will learn from small batches of data iteratively, improving training speed"})]})}),y.retraining_job_attributes.batch_mode&&a.jsxs("div",{className:"mt-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Size"}),a.jsx("input",{type:"number",value:y.retraining_job_attributes.batch_size,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_size:parseInt(Y.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Overlap"}),a.jsx("input",{type:"number",value:y.retraining_job_attributes.batch_overlap,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_overlap:parseInt(Y.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]})]}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),a.jsx(ot,{value:y.retraining_job_attributes.batch_key,onChange:Y=>N({...y,retraining_job_attributes:{...y.retraining_job_attributes,batch_key:Y}}),options:((De=(_e=r.dataset)==null?void 0:_e.columns)==null?void 0:De.map(Y=>({value:Y.name,label:Y.name})))||[],placeholder:"Select a column for batch key"})]})]})]}),a.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(on,{className:"w-5 h-5 text-blue-600"}),a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Evaluator Configuration"})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Metric"}),a.jsx(ot,{options:av[r.task==="classification"?"classification":"regression"].map(Y=>({value:Y.value,label:Y.label,description:Y.description})),value:y.retraining_job_attributes.metric,onChange:Y=>S("metric",Y)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Threshold"}),a.jsx("input",{type:"number",value:y.retraining_job_attributes.threshold,onChange:Y=>S("threshold",parseFloat(Y.target.value)),step:.01,min:0,max:1,className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),a.jsx("div",{className:"bg-blue-50 rounded-md p-4",children:a.jsxs("div",{className:"flex items-start",children:[a.jsx(on,{className:"w-5 h-5 text-blue-400 mt-0.5"}),a.jsxs("div",{className:"ml-3",children:[a.jsx("h3",{className:"text-sm font-medium text-blue-800",children:"Deployment Criteria"}),a.jsxs("p",{className:"mt-2 text-sm text-blue-700",children:["The model will be automatically deployed when the ",y.retraining_job_attributes.metric," is"," ",y.retraining_job_attributes.direction==="minimize"?"below":"above"," ",y.retraining_job_attributes.threshold,"."]})]})]})})]})]})]})}),a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ui,{className:"w-5 h-5 text-blue-600"}),a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Hyperparameter Tuning"})]}),a.jsxs("div",{className:"flex items-center",children:[a.jsx("input",{type:"checkbox",id:"tuningEnabled",checked:y.retraining_job_attributes.tuning_enabled||!1,onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_enabled:Y.target.checked,tuner_config:Y.target.checked?{n_trials:10,config:g}:void 0}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsx("label",{htmlFor:"tuningEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable tuning"})]})]}),y.retraining_job_attributes.tuning_enabled&&a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),a.jsx(ot,{options:[{value:"always",label:"Always",description:"Tune hyperparameters every time"},{value:"week",label:"Weekly",description:"Tune hyperparameters once every week"},{value:"month",label:"Monthly",description:"Tune hyperparameters once every month"}],value:y.retraining_job_attributes.tuning_frequency||"week",onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_frequency:Y}}))})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Number of Trials"}),a.jsx("input",{type:"number",min:"1",max:"1000",value:((me=y.retraining_job_attributes.tuner_config)==null?void 0:me.n_trials)||10,onChange:Y=>N(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuner_config:{...pe.retraining_job_attributes.tuner_config,n_trials:parseInt(Y.target.value)}}})),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),b()]})]})})]}),a.jsxs("div",{className:"flex justify-end gap-4 p-4 border-t",children:[a.jsx("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-500",children:"Cancel"}),a.jsx("button",{onClick:C,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md",children:"Save Changes"})]})]})})}const yo=({error:e})=>e?a.jsxs("div",{className:"mt-1 flex items-center gap-1 text-sm text-red-600",children:[a.jsx(on,{className:"w-4 h-4"}),e]}):null;function ew({initialData:e,datasets:t,constants:n,isEditing:r,errors:i}){var z,B,H,ce,ue,we;const{rootPath:l}=_r().props,[u,d]=A.useState(!1),[f,m]=A.useState(!1),h=Td({model:{id:e==null?void 0:e.id,name:(e==null?void 0:e.name)||"",model_type:(e==null?void 0:e.model_type)||"xgboost",dataset_id:(e==null?void 0:e.dataset_id)||"",task:(e==null?void 0:e.task)||"classification",objective:(e==null?void 0:e.objective)||"binary:logistic",metrics:(e==null?void 0:e.metrics)||["accuracy"],retraining_job_attributes:e!=null&&e.retraining_job?{id:e.retraining_job.id,frequency:e.retraining_job.frequency,tuning_frequency:e.retraining_job.tuning_frequency||"month",batch_mode:e.retraining_job.batch_mode,batch_size:e.retraining_job.batch_size,batch_overlap:e.retraining_job.batch_overlap,batch_key:e.retraining_job.batch_key,at:{hour:((z=e.retraining_job.at)==null?void 0:z.hour)??2,day_of_week:((B=e.retraining_job.at)==null?void 0:B.day_of_week)??1,day_of_month:((H=e.retraining_job.at)==null?void 0:H.day_of_month)??1},active:e.retraining_job.active,metric:e.retraining_job.metric,threshold:e.retraining_job.threshold,tuner_config:e.retraining_job.tuner_config,tuning_enabled:e.retraining_job.tuning_enabled||!1}:void 0}}),{data:g,setData:y,post:N,patch:x,processing:b,errors:E}=h,w={...i,...E},S=((ce=n.objectives[g.model.model_type])==null?void 0:ce[g.model.task])||[];A.useEffect(()=>{var ne;if(e!=null&&e.metrics)y({...g,model:{...g.model,objective:g.model.task==="classification"?"binary:logistic":"reg:squarederror"}});else{const Z=((ne=n.metrics[g.model.task])==null?void 0:ne.map(de=>de.value))||[];y({...g,model:{...g.model,objective:g.model.task==="classification"?"binary:logistic":"reg:squarederror",metrics:Z}})}},[g.model.task]),A.useEffect(()=>{f&&(O(),m(!1))},[f]);const C=ne=>{y({...g,model:{...g.model,retraining_job_attributes:ne.retraining_job_attributes}}),m(!0)},O=()=>{if(g.model.retraining_job_attributes){const ne={hour:g.model.retraining_job_attributes.at.hour};switch(g.model.retraining_job_attributes.frequency){case"day":break;case"week":ne.day_of_week=g.model.retraining_job_attributes.at.day_of_week;break;case"month":ne.day_of_month=g.model.retraining_job_attributes.at.day_of_month;break}y("model.retraining_job_attributes.at",ne)}g.model.id?x(`${l}/models/${g.model.id}`,{onSuccess:()=>{rt.visit(`${l}/models`)}}):N(`${l}/models`,{onSuccess:()=>{rt.visit(`${l}/models`)}})},R=ne=>{ne.preventDefault(),O()};console.log(g.model);const F=t.find(ne=>ne.id===g.model.dataset_id),D=n.tuner_job_constants[g.model.model_type]||{};return a.jsxs("form",{onSubmit:R,className:"space-y-8",children:[a.jsxs("div",{className:"flex justify-between items-center border-b pb-4",children:[a.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Model Configuration"}),a.jsxs("button",{type:"button",onClick:()=>d(!0),className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[a.jsx(PT,{className:"w-4 h-4"}),"Configure Training"]})]}),a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Name"}),a.jsx("input",{type:"text",id:"name",value:g.model.name,onChange:ne=>y("model.name",ne.target.value),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"}),a.jsx(yo,{error:w.name})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Type"}),a.jsx(ot,{options:[{value:"xgboost",label:"XGBoost",description:"Gradient boosting framework"}],value:g.model.model_type,onChange:ne=>y("model.model_type",ne),placeholder:"Select model type"}),a.jsx(yo,{error:w.model_type})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Dataset"}),r?a.jsxs("div",{className:"flex items-center gap-2 p-2 bg-gray-50 rounded-md border border-gray-200",children:[a.jsx(ST,{className:"w-4 h-4 text-gray-400"}),a.jsx("span",{className:"text-gray-700",children:F==null?void 0:F.name})]}):a.jsx(ot,{options:t.map(ne=>({value:ne.id,label:ne.name,description:`${ne.num_rows.toLocaleString()} rows`})),value:g.model.dataset_id,onChange:ne=>y("model.dataset_id",ne),placeholder:"Select dataset"}),a.jsx(yo,{error:w.dataset_id})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Task"}),a.jsx(ot,{options:n.tasks,value:g.model.task,onChange:ne=>y("model.task",ne),placeholder:"Select task"}),a.jsx(yo,{error:w.task})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Objective"}),a.jsx(ot,{options:S||[],value:g.model.objective,onChange:ne=>y("model.objective",ne),placeholder:"Select objective"}),a.jsx(yo,{error:w.objective})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Metrics"}),a.jsx("div",{className:"grid grid-cols-2 gap-4",children:(ue=n.metrics[g.model.task])==null?void 0:ue.map(ne=>a.jsxs("label",{className:"relative flex items-center px-4 py-3 bg-white border rounded-lg hover:bg-gray-50 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:g.model.metrics.includes(ne.value),onChange:Z=>{const de=Z.target.checked?[...g.model.metrics,ne.value]:g.model.metrics.filter(se=>se!==ne.value);y("model.metrics",de)},className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),a.jsxs("div",{className:"ml-3",children:[a.jsx("span",{className:"block text-sm font-medium text-gray-900",children:ne.label}),a.jsx("span",{className:"block text-xs text-gray-500",children:ne.direction==="maximize"?"Higher is better":"Lower is better"})]})]},ne.value))})]})]}),g.model.retraining_job_attributes&&g.model.retraining_job_attributes.batch_mode&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),a.jsx(ot,{value:g.model.retraining_job_attributes.batch_key||"",onChange:ne=>y("model",{...g.model,retraining_job_attributes:{...g.model.retraining_job_attributes,batch_key:ne}}),options:((we=F==null?void 0:F.columns)==null?void 0:we.map(ne=>({value:ne.name,label:ne.name})))||[],placeholder:"Select a column for batch key"}),a.jsx(yo,{error:w["model.retraining_job_attributes.batch_key"]})]})}),a.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[a.jsx("button",{type:"button",onClick:()=>rt.visit(`${l}/models`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),a.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r?"Save Changes":"Create Model"})]}),a.jsx(LR,{isOpen:u,onClose:()=>d(!1),onSave:C,initialData:{task:g.model.task,metrics:g.model.metrics,modelType:g.model.model_type,dataset:F,retraining_job:g.model.retraining_job_attributes},tunerJobConstants:D,timezone:n.timezone,retrainingJobConstants:n.retraining_job_constants})]})}function MR({model:e,datasets:t,constants:n}){return a.jsx("div",{className:"max-w-3xl mx-auto py-8",children:a.jsxs("div",{className:"bg-white rounded-lg shadow-lg",children:[a.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Bs,{className:"w-6 h-6 text-blue-600"}),a.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Edit Model"})]})}),a.jsx("div",{className:"p-6",children:a.jsx(ew,{initialData:e,datasets:t,constants:n,isEditing:!0})})]})})}const FR=Object.freeze(Object.defineProperty({__proto__:null,default:MR},Symbol.toStringTag,{value:"Module"})),Xe=e=>{const t=new Date;return t.setDate(t.getDate()-e),t.toISOString()},tw=[{id:1,name:"Customer Churn Dataset",description:"Historical customer data for churn prediction",columns:[{name:"usage_days",type:"numeric",description:"Number of days customer has used the product",statistics:{mean:145.7,median:130,min:1,max:365,nullCount:0}},{name:"total_spend",type:"numeric",description:"Total customer spend in USD",statistics:{mean:487.32,median:425.5,min:0,max:2500,nullCount:1250}},{name:"support_tickets",type:"numeric",description:"Number of support tickets opened",statistics:{mean:2.3,median:1,min:0,max:15,nullCount:3750}},{name:"subscription_tier",type:"categorical",description:"Customer subscription level",statistics:{uniqueCount:3,nullCount:125}},{name:"last_login",type:"datetime",description:"Last time the customer logged in",statistics:{nullCount:5e3}}],sampleData:[{usage_days:234,total_spend:567.89,support_tickets:1,subscription_tier:"premium",last_login:"2024-03-01"},{usage_days:45,total_spend:null,support_tickets:null,subscription_tier:"basic",last_login:null}],rowCount:25e3,updatedAt:"2024-03-10T12:00:00Z"}];Xe(30),Xe(0);Xe(7),Xe(1),Xe(30),Xe(0);Xe(1),Xe(1),Xe(1),Xe(1),Xe(2),Xe(2),Xe(2),Xe(2),Xe(3),Xe(3),Xe(3),Xe(3),Xe(4),Xe(4),Xe(4),Xe(4);const $R=[{id:1,name:"Normalize state",description:"Turn state names into 2 letter state abbreviations",groupId:1,testDatasetId:1,inputColumns:["state"],outputColumns:["state"],code:"",createdAt:Xe(30),updatedAt:Xe(0)}],Ni=[{id:1,name:"Customer Churn",description:"Features for customer churn dataset",features:$R,createdAt:Xe(30),updatedAt:Xe(0)}];function DR({value:e,onChange:t,language:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-800",children:[a.jsx("span",{className:"text-sm text-gray-400",children:"Ruby Feature"}),a.jsx("span",{className:"text-xs px-2 py-1 bg-gray-700 rounded text-gray-300",children:n})]}),a.jsx("textarea",{value:e,onChange:r=>t(r.target.value),className:"w-full h-64 p-4 bg-gray-900 text-gray-100 font-mono text-sm focus:outline-none",placeholder:`def transform(df)
|
434
434
|
# Your feature code here
|
435
435
|
# Example:
|
436
436
|
# df["column"] = df["column"].map { |value| value.upcase }
|
@@ -481,3 +481,4 @@ Error generating stack: `+l.message+`
|
|
481
481
|
flex-grow: 1;
|
482
482
|
}
|
483
483
|
`},nonce:l}),a.jsx(vs.div,{"data-radix-scroll-area-viewport":"",...u,asChild:i,ref:m,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...e.style},children:tM({asChild:i,children:r},h=>a.jsx("div",{"data-radix-scroll-area-content":"",ref:d.onContentChange,style:{minWidth:d.scrollbarXEnabled?"fit-content":void 0},children:h}))})]})});pS.displayName=fS;var zr="ScrollAreaScrollbar",Kg=A.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=sr(zr,e.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:u}=i,d=e.orientation==="horizontal";return A.useEffect(()=>(d?l(!0):u(!0),()=>{d?l(!1):u(!1)}),[d,l,u]),i.type==="hover"?a.jsx(qL,{...r,ref:t,forceMount:n}):i.type==="scroll"?a.jsx(GL,{...r,ref:t,forceMount:n}):i.type==="auto"?a.jsx(mS,{...r,ref:t,forceMount:n}):i.type==="always"?a.jsx(Qg,{...r,ref:t}):null});Kg.displayName=zr;var qL=A.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=sr(zr,e.__scopeScrollArea),[l,u]=A.useState(!1);return A.useEffect(()=>{const d=i.scrollArea;let f=0;if(d){const m=()=>{window.clearTimeout(f),u(!0)},h=()=>{f=window.setTimeout(()=>u(!1),i.scrollHideDelay)};return d.addEventListener("pointerenter",m),d.addEventListener("pointerleave",h),()=>{window.clearTimeout(f),d.removeEventListener("pointerenter",m),d.removeEventListener("pointerleave",h)}}},[i.scrollArea,i.scrollHideDelay]),a.jsx(da,{present:n||l,children:a.jsx(mS,{"data-state":l?"visible":"hidden",...r,ref:t})})}),GL=A.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=sr(zr,e.__scopeScrollArea),l=e.orientation==="horizontal",u=Kd(()=>f("SCROLL_END"),100),[d,f]=HL("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return A.useEffect(()=>{if(d==="idle"){const m=window.setTimeout(()=>f("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(m)}},[d,i.scrollHideDelay,f]),A.useEffect(()=>{const m=i.viewport,h=l?"scrollLeft":"scrollTop";if(m){let g=m[h];const y=()=>{const N=m[h];g!==N&&(f("SCROLL"),u()),g=N};return m.addEventListener("scroll",y),()=>m.removeEventListener("scroll",y)}},[i.viewport,l,f,u]),a.jsx(da,{present:n||d!=="hidden",children:a.jsx(Qg,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ys(e.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Ys(e.onPointerLeave,()=>f("POINTER_LEAVE"))})})}),mS=A.forwardRef((e,t)=>{const n=sr(zr,e.__scopeScrollArea),{forceMount:r,...i}=e,[l,u]=A.useState(!1),d=e.orientation==="horizontal",f=Kd(()=>{if(n.viewport){const m=n.viewport.offsetWidth<n.viewport.scrollWidth,h=n.viewport.offsetHeight<n.viewport.scrollHeight;u(d?m:h)}},10);return ea(n.viewport,f),ea(n.content,f),a.jsx(da,{present:r||l,children:a.jsx(Qg,{"data-state":l?"visible":"hidden",...i,ref:t})})}),Qg=A.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,i=sr(zr,e.__scopeScrollArea),l=A.useRef(null),u=A.useRef(0),[d,f]=A.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=vS(d.viewport,d.content),h={...r,sizes:d,onSizesChange:f,hasThumb:m>0&&m<1,onThumbChange:y=>l.current=y,onThumbPointerUp:()=>u.current=0,onThumbPointerDown:y=>u.current=y};function g(y,N){return ZL(y,u.current,d,N)}return n==="horizontal"?a.jsx(KL,{...h,ref:t,onThumbPositionChange:()=>{if(i.viewport&&l.current){const y=i.viewport.scrollLeft,N=h1(y,d,i.dir);l.current.style.transform=`translate3d(${N}px, 0, 0)`}},onWheelScroll:y=>{i.viewport&&(i.viewport.scrollLeft=y)},onDragScroll:y=>{i.viewport&&(i.viewport.scrollLeft=g(y,i.dir))}}):n==="vertical"?a.jsx(QL,{...h,ref:t,onThumbPositionChange:()=>{if(i.viewport&&l.current){const y=i.viewport.scrollTop,N=h1(y,d);l.current.style.transform=`translate3d(0, ${N}px, 0)`}},onWheelScroll:y=>{i.viewport&&(i.viewport.scrollTop=y)},onDragScroll:y=>{i.viewport&&(i.viewport.scrollTop=g(y))}}):null}),KL=A.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...i}=e,l=sr(zr,e.__scopeScrollArea),[u,d]=A.useState(),f=A.useRef(null),m=ii(t,f,l.onScrollbarXChange);return A.useEffect(()=>{f.current&&d(getComputedStyle(f.current))},[f]),a.jsx(gS,{"data-orientation":"horizontal",...i,ref:m,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Gd(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.x),onDragScroll:h=>e.onDragScroll(h.x),onWheelScroll:(h,g)=>{if(l.viewport){const y=l.viewport.scrollLeft+h.deltaX;e.onWheelScroll(y),wS(y,g)&&h.preventDefault()}},onResize:()=>{f.current&&l.viewport&&u&&r({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:f.current.clientWidth,paddingStart:wd(u.paddingLeft),paddingEnd:wd(u.paddingRight)}})}})}),QL=A.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...i}=e,l=sr(zr,e.__scopeScrollArea),[u,d]=A.useState(),f=A.useRef(null),m=ii(t,f,l.onScrollbarYChange);return A.useEffect(()=>{f.current&&d(getComputedStyle(f.current))},[f]),a.jsx(gS,{"data-orientation":"vertical",...i,ref:m,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Gd(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.y),onDragScroll:h=>e.onDragScroll(h.y),onWheelScroll:(h,g)=>{if(l.viewport){const y=l.viewport.scrollTop+h.deltaY;e.onWheelScroll(y),wS(y,g)&&h.preventDefault()}},onResize:()=>{f.current&&l.viewport&&u&&r({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:f.current.clientHeight,paddingStart:wd(u.paddingTop),paddingEnd:wd(u.paddingBottom)}})}})}),[XL,hS]=cS(zr),gS=A.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:l,onThumbPointerUp:u,onThumbPointerDown:d,onThumbPositionChange:f,onDragScroll:m,onWheelScroll:h,onResize:g,...y}=e,N=sr(zr,n),[x,b]=A.useState(null),E=ii(t,B=>b(B)),w=A.useRef(null),S=A.useRef(""),C=N.viewport,O=r.content-r.viewport,R=us(h),F=us(f),D=Kd(g,10);function z(B){if(w.current){const H=B.clientX-w.current.left,ce=B.clientY-w.current.top;m({x:H,y:ce})}}return A.useEffect(()=>{const B=H=>{const ce=H.target;(x==null?void 0:x.contains(ce))&&R(H,O)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[C,x,O,R]),A.useEffect(F,[r,F]),ea(x,D),ea(N.content,D),a.jsx(XL,{scope:n,scrollbar:x,hasThumb:i,onThumbChange:us(l),onThumbPointerUp:us(u),onThumbPositionChange:F,onThumbPointerDown:us(d),children:a.jsx(vs.div,{...y,ref:E,style:{position:"absolute",...y.style},onPointerDown:Ys(e.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),w.current=x.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",N.viewport&&(N.viewport.style.scrollBehavior="auto"),z(B))}),onPointerMove:Ys(e.onPointerMove,z),onPointerUp:Ys(e.onPointerUp,B=>{const H=B.target;H.hasPointerCapture(B.pointerId)&&H.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=S.current,N.viewport&&(N.viewport.style.scrollBehavior=""),w.current=null})})})}),bd="ScrollAreaThumb",yS=A.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=hS(bd,e.__scopeScrollArea);return a.jsx(da,{present:n||i.hasThumb,children:a.jsx(YL,{ref:t,...r})})}),YL=A.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...i}=e,l=sr(bd,n),u=hS(bd,n),{onThumbPositionChange:d}=u,f=ii(t,g=>u.onThumbChange(g)),m=A.useRef(),h=Kd(()=>{m.current&&(m.current(),m.current=void 0)},100);return A.useEffect(()=>{const g=l.viewport;if(g){const y=()=>{if(h(),!m.current){const N=eM(g,d);m.current=N,d()}};return d(),g.addEventListener("scroll",y),()=>g.removeEventListener("scroll",y)}},[l.viewport,h,d]),a.jsx(vs.div,{"data-state":u.hasThumb?"visible":"hidden",...i,ref:f,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Ys(e.onPointerDownCapture,g=>{const N=g.target.getBoundingClientRect(),x=g.clientX-N.left,b=g.clientY-N.top;u.onThumbPointerDown({x,y:b})}),onPointerUp:Ys(e.onPointerUp,u.onThumbPointerUp)})});yS.displayName=bd;var Xg="ScrollAreaCorner",xS=A.forwardRef((e,t)=>{const n=sr(Xg,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?a.jsx(JL,{...e,ref:t}):null});xS.displayName=Xg;var JL=A.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,i=sr(Xg,n),[l,u]=A.useState(0),[d,f]=A.useState(0),m=!!(l&&d);return ea(i.scrollbarX,()=>{var g;const h=((g=i.scrollbarX)==null?void 0:g.offsetHeight)||0;i.onCornerHeightChange(h),f(h)}),ea(i.scrollbarY,()=>{var g;const h=((g=i.scrollbarY)==null?void 0:g.offsetWidth)||0;i.onCornerWidthChange(h),u(h)}),m?a.jsx(vs.div,{...r,ref:t,style:{width:l,height:d,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function wd(e){return e?parseInt(e,10):0}function vS(e,t){const n=e/t;return isNaN(n)?0:n}function Gd(e){const t=vS(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function ZL(e,t,n,r="ltr"){const i=Gd(n),l=i/2,u=t||l,d=i-u,f=n.scrollbar.paddingStart+u,m=n.scrollbar.size-n.scrollbar.paddingEnd-d,h=n.content-n.viewport,g=r==="ltr"?[0,h]:[h*-1,0];return bS([f,m],g)(e)}function h1(e,t,n="ltr"){const r=Gd(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,l=t.scrollbar.size-i,u=t.content-t.viewport,d=l-r,f=n==="ltr"?[0,u]:[u*-1,0],m=WL(e,f);return bS([0,u],[0,d])(m)}function bS(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function wS(e,t){return e>0&&e<t}var eM=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function i(){const l={left:e.scrollLeft,top:e.scrollTop},u=n.left!==l.left,d=n.top!==l.top;(u||d)&&t(),n=l,r=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(r)};function Kd(e,t){const n=us(e),r=A.useRef(0);return A.useEffect(()=>()=>window.clearTimeout(r.current),[]),A.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ea(e,t){const n=us(t);Ll(()=>{let r=0;if(e){const i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(r),i.unobserve(e)}}},[e,n])}function tM(e,t){const{asChild:n,children:r}=e;if(!n)return typeof t=="function"?t(r):t;const i=A.Children.only(r);return A.cloneElement(i,{children:typeof t=="function"?t(i.props.children):t})}var _S=dS,nM=pS,rM=xS;const SS=A.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(_S,{ref:r,className:gr("relative overflow-hidden",e),...n,children:[a.jsx(nM,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(jS,{}),a.jsx(rM,{})]}));SS.displayName=_S.displayName;const jS=A.forwardRef(({className:e,orientation:t="vertical",...n},r)=>a.jsx(Kg,{ref:r,orientation:t,className:gr("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:a.jsx(yS,{className:"relative flex-1 rounded-full bg-border"})}));jS.displayName=Kg.displayName;var sM="Separator",g1="horizontal",iM=["horizontal","vertical"],NS=A.forwardRef((e,t)=>{const{decorative:n,orientation:r=g1,...i}=e,l=oM(r)?r:g1,d=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return a.jsx(vs.div,{"data-orientation":l,...d,...i,ref:t})});NS.displayName=sM;function oM(e){return iM.includes(e)}var CS=NS;const ES=A.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>a.jsx(CS,{ref:i,decorative:n,orientation:t,className:gr("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ES.displayName=CS.displayName;function aM({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=lM({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:r,d=us(n),f=A.useCallback(m=>{if(l){const g=typeof m=="function"?m(e):m;g!==e&&d(g)}else i(m)},[l,e,i,d]);return[u,f]}function lM({defaultProp:e,onChange:t}){const n=A.useState(e),[r]=n,i=A.useRef(r),l=us(t);return A.useEffect(()=>{i.current!==r&&(l(r),i.current=r)},[r,i,l]),n}var uM=Ck.useId||(()=>{}),cM=0;function dM(e){const[t,n]=A.useState(uM());return Ll(()=>{e||n(r=>r??String(cM++))},[e]),e||(t?`radix-${t}`:"")}var Yg="Collapsible",[fM,kM]=uS(Yg),[pM,Jg]=fM(Yg),kS=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:l,onOpenChange:u,...d}=e,[f=!1,m]=aM({prop:r,defaultProp:i,onChange:u});return a.jsx(pM,{scope:n,disabled:l,contentId:dM(),open:f,onOpenToggle:A.useCallback(()=>m(h=>!h),[m]),children:a.jsx(vs.div,{"data-state":e0(f),"data-disabled":l?"":void 0,...d,ref:t})})});kS.displayName=Yg;var AS="CollapsibleTrigger",PS=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=Jg(AS,n);return a.jsx(vs.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":e0(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:Ys(e.onClick,i.onOpenToggle)})});PS.displayName=AS;var Zg="CollapsibleContent",TS=A.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=Jg(Zg,e.__scopeCollapsible);return a.jsx(da,{present:n||i.open,children:({present:l})=>a.jsx(mM,{...r,ref:t,present:l})})});TS.displayName=Zg;var mM=A.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...l}=e,u=Jg(Zg,n),[d,f]=A.useState(r),m=A.useRef(null),h=ii(t,m),g=A.useRef(0),y=g.current,N=A.useRef(0),x=N.current,b=u.open||d,E=A.useRef(b),w=A.useRef();return A.useEffect(()=>{const S=requestAnimationFrame(()=>E.current=!1);return()=>cancelAnimationFrame(S)},[]),Ll(()=>{const S=m.current;if(S){w.current=w.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();g.current=C.height,N.current=C.width,E.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),f(r)}},[u.open,r]),a.jsx(vs.div,{"data-state":e0(u.open),"data-disabled":u.disabled?"":void 0,id:u.contentId,hidden:!b,...l,ref:h,style:{"--radix-collapsible-content-height":y?`${y}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:b&&i})});function e0(e){return e?"open":"closed"}var hM=kS;const gM=hM,yM=PS,xM=TS;function y1({href:e,className:t=l=>"",activeClassName:n="active",children:r,...i}){const{rootPath:l,url:u}=_r().props,d=u===e;let f=t(d);return a.jsx(yr,{href:`${l}${e}`,className:gr(f,d&&n),...i,children:r})}const vM=[{title:"Models",icon:Bs,href:"/",children:[{title:"All Models",icon:Bs,href:"/models"},{title:"New Model",icon:Bs,href:"/models/new"}]},{title:"Datasources",icon:Ro,href:"/datasources",children:[{title:"All Datasources",icon:Ro,href:"/datasources"},{title:"New Datasource",icon:Ro,href:"/datasources/new"}]},{title:"Datasets",icon:Ln,href:"/datasets",children:[{title:"All Datasets",icon:Ln,href:"/datasets"},{title:"New Dataset",icon:Ln,href:"/datasets/new"}]}];function bM(e){const{rootPath:t}=_r().props,n=e.split("/").filter(Boolean),r=[];let i=t;if(n.length===0)return[];let l,u;switch(["datasources","datasets","models","settings"].includes(n[0])?(l=n[0],u=0):(l=n[1],u=1),l){case"models":r.push({title:"Models",href:`${t}/models`});break;case"datasources":r.push({title:"Datasources",href:`${t}/datasources`});break;case"datasets":r.push({title:"Datasets",href:`${t}/datasets`});break;case"settings":r.push({title:"Settings",href:`${t}/settings`});break;default:r.push({title:"Models",href:`${t}/models`})}for(let d=u+1;d<n.length;d++){const f=n[d];if(i+=`/${n[d]}`,n[d-1]==="datasets"&&f!=="new")r.push({title:"Details",href:i});else if(n[d-1]==="models"&&f!=="new")r.push({title:"Details",href:i});else{const m=f==="new"?"New":f==="edit"?"Edit":f.charAt(0).toUpperCase()+f.slice(1);r.push({title:m,href:i})}}return r}function wM({children:e}){const[t,n]=A.useState(!0),[r,i]=A.useState(["Models"]),l=bM(location.pathname),u=d=>{i(f=>f.includes(d)?f.filter(m=>m!==d):[...f,d])};return a.jsxs("div",{className:"min-h-screen bg-gray-50",children:[a.jsxs("div",{className:gr("fixed left-0 top-0 z-40 h-screen bg-white border-r transition-all duration-300",t?"w-64":"w-16"),children:[a.jsxs("div",{className:"flex h-16 items-center border-b px-4",children:[t?a.jsxs(a.Fragment,{children:[a.jsx(Bs,{className:"w-8 h-8 text-blue-600"}),a.jsx("h1",{className:"text-xl font-bold text-gray-900 ml-2",children:"EasyML"})]}):a.jsx(Bs,{className:"w-8 h-8 text-blue-600"}),a.jsx("button",{onClick:()=>n(!t),className:"ml-auto p-2 hover:bg-gray-100 rounded-md",children:a.jsx(jT,{className:"w-4 h-4"})})]}),a.jsx(SS,{className:"h-[calc(100vh-4rem)] px-3",children:a.jsxs("div",{className:"space-y-2 py-4",children:[vM.map(d=>{var f;return a.jsxs(gM,{open:r.includes(d.title),onOpenChange:()=>u(d.title),children:[a.jsxs(yM,{className:"flex items-center w-full p-2 hover:bg-gray-100 rounded-md",children:[a.jsx(d.icon,{className:"w-4 h-4"}),t&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"ml-2 text-sm font-medium flex-1 text-left",children:d.title}),r.includes(d.title)?a.jsx(oa,{className:"w-4 h-4"}):a.jsx(qo,{className:"w-4 h-4"})]})]}),a.jsx(xM,{children:t&&((f=d.children)==null?void 0:f.map(m=>a.jsxs(y1,{href:m.href,className:({isActive:h})=>gr("flex items-center pl-8 pr-2 py-2 text-sm rounded-md",h?"bg-blue-50 text-blue-600":"text-gray-600 hover:bg-gray-50"),children:[a.jsx(m.icon,{className:"w-4 h-4"}),a.jsx("span",{className:"ml-2",children:m.title})]},m.href)))})]},d.title)}),a.jsx(ES,{className:"my-4"}),a.jsxs(y1,{href:"/settings",className:({isActive:d})=>gr("flex items-center w-full p-2 rounded-md",d?"bg-blue-50 text-blue-600":"text-gray-600 hover:bg-gray-50"),children:[a.jsx(Ui,{className:"w-4 h-4"}),t&&a.jsx("span",{className:"ml-2 text-sm font-medium",children:"Settings"})]})]})})]}),a.jsxs("div",{className:gr("transition-all duration-300",t?"ml-64":"ml-16"),children:[a.jsx(PL,{}),a.jsx("div",{className:"h-16 border-b bg-white flex items-center px-4",children:a.jsx("nav",{className:"flex","aria-label":"Breadcrumb",children:a.jsx("ol",{className:"flex items-center space-x-2",children:l.map((d,f)=>a.jsxs(tr.Fragment,{children:[f>0&&a.jsx(qo,{className:"w-4 h-4 text-gray-400"}),a.jsx("li",{children:a.jsx(yr,{href:d.href,className:gr("text-sm",f===l.length-1?"text-blue-600 font-medium":"text-gray-500 hover:text-gray-700"),children:d.title})})]},d.href))})})}),a.jsx("main",{className:"min-h-[calc(100vh-4rem)]",children:e})]})]})}function _M({children:e}){const{showAlert:t}=oS(),{flash:n}=_r().props;return A.useEffect(()=>{n&&n.forEach(({type:r,message:i})=>{t(r,i)})},[n,t]),a.jsx(a.Fragment,{children:e})}function SM({children:e}){return a.jsx(AL,{children:a.jsx(_M,{children:a.jsx(wM,{children:e})})})}document.addEventListener("DOMContentLoaded",()=>{iT({resolve:e=>{let n=Object.assign({"../pages/DatasetDetailsPage.tsx":NR,"../pages/DatasetsPage.tsx":ER,"../pages/DatasourceFormPage.tsx":OR,"../pages/DatasourcesPage.tsx":IR,"../pages/EditModelPage.tsx":FR,"../pages/EditTransformationPage.tsx":BR,"../pages/ModelsPage.tsx":VR,"../pages/NewDatasetPage.tsx":l6,"../pages/NewModelPage.tsx":c6,"../pages/NewTransformationPage.tsx":f6,"../pages/SettingsPage.tsx":g6,"../pages/ShowModelPage.tsx":v6,"../pages/TransformationsPage.tsx":S6})[`../${e}.tsx`];if(!n.default){alert(`The page ${e} could not be found, you probably forgot to export default.`);return}return n.default.layout=n.default.layout||(r=>a.jsx(SM,{children:r})),n},setup({el:e,App:t,props:n}){sS(e).render(a.jsx(t,{...n}))}})});
|
484
|
+
//# sourceMappingURL=Application.tsx-BRRjHz4-.js.map
|