import{r as y,j as u}from"./vendor-react-wBh_31cN.js";import{b3 as m,b5 as v,d0 as $,h as w,e9 as j,f as T,cj as F,j as q,o as k,cg as d,d2 as x,dO as E,R as L}from"./index-dNe6i2rS.js";import{d as g}from"./dumbPluralize-CcxDsNiu.js";import{i as O}from"./isAfter-RvXmHnAf.js";import{w as A}from"./where-5NF5DPVb.js";import{w as C}from"./whereEq-qRDwP6XF.js";import{p as P}from"./project-BNFK3R_4.js";import{a as K,C as R}from"./index.esm-CAGtek53.js";import{L as h}from"./label-gPWmc6ow.js";import{E as V}from"./editable-select-DItn4ZHW.js";import{u as G}from"./vendor-redux-CJZrIb6x.js";import{u as M}from"./useUpdateTdOrFvInfoService-CFSSGYE8.js";import{c as D}from"./vendor-router-D1GqFWiT.js";function U(r,t,a){const[s,e]=[+m(r.start),+m(r.end)].sort((l,o)=>l-o),[i,n]=[+m(t.start),+m(t.end)].sort((l,o)=>l-o);return a!=null&&a.inclusive?s<=n&&i<=e:s<n&&i<e}const _=v(U,2),Q=v(O,2);P(["name"]);const ne=$({"TF Record":"tfrecord",CSV:"csv",Parquet:"parquet",TSV:"tsv",ORC:"orc",Avro:"avro"}),le=(r,t)=>{let a=!0;return r.forEach(({features:s,transformation:e},i)=>{if((!s||s.length===0)&&(t(`transformations[${i}].feature`,{message:"Select a feature"}),a=!1),(!e||e.name==="")&&(t(`transformations[${i}].transformation`,{message:"Select a transformation"}),a=!1),e!=null&&e.argNum&&(e==null?void 0:e.argNum)!==s.length){const{name:n="",argNum:l}=e,o=(e==null?void 0:e.argNum)>s.length?`${n} requires ${l} ${g("feature",l)}`:`${n} accepts ${l} ${g("feature",l)}`;t(`transformations[${i}].feature`,{message:o}),a=!1}}),a},oe=(r,t)=>{if(r.length===2&&r.every(({name:a,percentage:s})=>a===""&&s===""))return!0;if(r.length===1)return t("splits",{type:"splits count",message:"At least 2 splits are required to enable the function"}),!1;if(r.length){const{splitType:a}=r[0];if(a==="RANDOM_SPLIT"){if(r.find(({name:s,percentage:e})=>!s||!e))return t("splits",{type:"splits reqired values",message:"Every split requires a name and a percentage"}),!1;if(r.forEach(({percentage:s},e)=>{if(s&&!Number.isInteger(+s))return t(`splits[${e}].percentage`,{type:"percentage",message:"Invalid percentage"}),!1}),r.reduce((s,{percentage:e})=>s+ +e,0)!==100)return t("splits",{type:"splits sum",message:"The sum of all splits should be 100"}),!1}if(a==="TIME_SERIES_SPLIT"){if(r.find(({name:e,startTime:i,endTime:n})=>!e||!i||!n))return t("splits",{type:"time-series splits",message:"Every split requires a name, a start time and an end time"}),!1;const s=r.map(({startTime:e,endTime:i},n)=>{try{const l=w(j(n,1),T(o=>Q(o.startTime,o.endTime)&&_({start:e,end:i},{start:o.startTime,end:o.endTime})))(r);if(l)return{index:n,error:{type:"overlapping splits",message:`Overlapping time range with ${l.name}`}}}catch{return{index:n,error:{type:"splits invalid start time",message:"End time should be after Start time"}}}return null}).filter(e=>e!==null);return s.length>0?(t("splits",{type:"overlapping splits",message:"Invalid time ranges"}),s.forEach(({index:e,error:i})=>{t(`splits[${e}].startTime`,i)}),!1):!0}}return!0},ue=(r,t)=>r.length!==t.length?!1:(Array.from(new Set([...r,...t])).forEach(s=>{const e=r.filter(n=>n===s).length,i=t.filter(n=>n===s).length;if(e!==i)return!1}),!0),me=F(2,(r,t)=>t.filter(({transformation:a})=>!!a).map(({features:a,transformation:{name:s}})=>{const[e,i]=s.split(" v");return w(T(A({hopsworksUdf:C({name:e}),version:k(+i)})),q(["hopsworksUdf","transformationFeatures"],a))(r)})),z=({isDisabled:r,isEdit:t,type:a=d.fg})=>{const{id:s,fsId:e,fgId:i}=D(),{control:n,formState:l,setValue:o,watch:S}=K(),b=S("keywords");M({keywords:b},a,![d.fv,d.td].includes(a)),G(p=>p.featureGroupLabels);const{currentData:I=[]}=x(s),{data:c,isFetching:f}=E({pId:s,fsId:+e,fgId:+i},{skip:!i||Number.isNaN(+i)});return y.useEffect(()=>{!t||f||l.dirtyFields.keywords||c&&a===d.fg&&o("keywords",c)},[c,l.dirtyFields.keywords,t,f,o,a]),f?u.jsxs("div",{className:"mt-5",children:[u.jsx(h,{className:"mb-1",children:"Keywords"}),u.jsx(L,{gray:!0,children:"loading..."})]}):u.jsxs("div",{className:"mt-5",children:[u.jsx(h,{className:"mb-1",children:"Keywords"}),u.jsx(R,{control:n,name:"keywords",render:({field:{onChange:p,value:N=[]}})=>u.jsx("div",{className:"mt-1.5",children:u.jsx(V,{isMulti:!0,value:N,options:I,onChange:p,disabled:r,placeholder:"keywords",noResultsText:"No keywords defined"})})})]})},de=y.memo(z);export{de as L,oe as a,me as c,ne as d,ue as e,le as v};
