import{R as l,o as b,s as k,j as e,E as p,C as f,G as C,cD as F,b9 as g,aw as v,f2 as w,az as N,ao as m,f3 as W,f4 as L}from"./app-BgLa5dit.js";import{F as y}from"./w68yffRy.chunk.js";import{u as S}from"./CKjyFQLY.chunk.js";import{W as I}from"./CCwkbyVL.chunk.js";const E="_listContainer_7fk7e_1",P={listContainer:E};function R(){const o=g(),{errors:s,touched:n}=v(),r=w.getCustomFormControlClassName(s,n,"name");return e.jsxs(N,{children:[e.jsx(m.Label,{htmlFor:"name",children:"Name"}),e.jsxs("div",{className:"input-group",children:[e.jsx(W,{type:"text",name:"name",id:"name",placeholder:"Name your new workbench list",autoFocus:!0,value:o.values.name,className:r}),e.jsx(y,{isNew:!0,submitText:"Create and add",variant:"outline-dark",className:"border border-secondary"}),e.jsx(L,{name:"name",children:i=>e.jsx(m.Control.Feedback,{type:"invalid",children:i})})]})]})}function A(o){const{workingLists:s,isInWorkingList:n,createWorkingList:r,addToWorkingList:i,removeFromWorkingList:u}=S(),[h,c]=l.useState(!1),t=b(k.video(o.objectId));l.useEffect(()=>{s!=null&&s.length||r("My workbench")},[s]);function d(a){n(o.objectId,a)?u(o.objectId,a,t.data.name):i(o.objectId,a,t.data.name)}function x({name:a},j){r(a,[o.objectId]),j({reset:!0}),c(!1)}return e.jsx(p,{title:"Add to your workbench",closePopup:o.closePopup,showLoadingSpinner:!t.data,children:!!t.data&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`${P.listContainer} pb-3`,children:[e.jsxs("p",{children:["Select a workbench list to add ",e.jsx("strong",{children:t.data.name})," to:"]}),s.map(a=>e.jsxs("div",{className:"d-flex align-items-center pb-1",children:[e.jsx(f,{id:a.id,onChange:()=>d(a.id),checked:n(o.objectId,a.id)}),e.jsx("div",{className:"fw-semibold cursor-pointer",onClick:()=>d(a.id),children:a.name})]},a.id))]}),e.jsx("div",{className:"border-top pt-3 px-3 mx-n3",children:h?e.jsx(C,{initialValues:{name:""},validationSchema:I,onSubmit:x,children:e.jsx(R,{})}):e.jsx(F,{variant:"link",className:"text-info p-0",onClick:()=>c(!0),children:"Create a new list"})})]})})}export{A as AddToWorkbenchView};
//# sourceMappingURL=DunguCFG.chunk.js.map
