quantum-component-library 1.4.48-dev.7 → 1.4.48-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.cjs +1 -1
- package/dist/components.js +44 -43
- package/dist/{dnd-core-vendor-C8EkmZ-Q.js → dnd-core-vendor-CEbjUoFs.js} +2 -2
- package/dist/{dnd-core-vendor-CrbsA5lC.cjs → dnd-core-vendor-gqRN0Czq.cjs} +1 -1
- package/dist/generated/graphql.d.ts +1 -1
- package/dist/{graphql-vendor-BGoVZGn3.cjs → graphql-vendor-AFHxLsy8.cjs} +1 -1
- package/dist/{graphql-vendor-BsmTENtE.js → graphql-vendor-hJezYUeG.js} +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +13 -13
- package/dist/index.cjs +1 -1
- package/dist/index.js +130 -125
- package/dist/lib/utils/cn.d.ts +2 -0
- package/dist/lib/utils/index.d.ts +1 -2
- package/dist/{lodash-vendor-CR237hSU.cjs → lodash-vendor-CF0pV_0E.cjs} +1 -1
- package/dist/{lodash-vendor-D4ZPCr77.js → lodash-vendor-apNdTTav.js} +1 -1
- package/dist/other-D9ROT7p0.js +20 -0
- package/dist/other-DyoApG-9.cjs +1 -0
- package/dist/{react-dnd-vendor-DQO87S4J.js → react-dnd-vendor-BCrg2QCX.js} +2 -2
- package/dist/{react-dnd-vendor-BuaDqq1-.cjs → react-dnd-vendor-PwwXhPmK.cjs} +1 -1
- package/dist/{react-select-vendor-C09H7eSP.cjs → react-select-vendor-BeWvSe2q.cjs} +1 -1
- package/dist/{react-select-vendor-D8Fzpeg3.js → react-select-vendor-BxbsY5Z-.js} +1 -1
- package/dist/services-action-CfZFwhy-.js +40 -0
- package/dist/services-action-DBOzfgMl.cjs +1 -0
- package/dist/services-human-B98qxeuS.js +798 -0
- package/dist/services-human-CnvSTmoF.cjs +1 -0
- package/dist/services-rom-DmV5X8yu.cjs +1 -0
- package/dist/services-rom-omMeC-vQ.js +18 -0
- package/dist/services.cjs +1 -1
- package/dist/services.js +52 -844
- package/dist/types.cjs +1 -1
- package/dist/types.js +11 -11
- package/dist/utils-cn-CgdSr4hO.js +7 -0
- package/dist/utils-cn-FIKrq5Mb.cjs +1 -0
- package/dist/utils-conversion-CWypeWsT.cjs +1 -0
- package/dist/utils-conversion-ChFbq8I2.js +94 -0
- package/dist/utils-memo-BJJP2KfI.cjs +1 -0
- package/dist/utils-memo-DtXdOqCT.js +13 -0
- package/dist/utils-parameters-BBFuBK2B.js +21 -0
- package/dist/utils-parameters-dwKmz1VU.cjs +1 -0
- package/dist/utils-text-CN3zLiZ7.js +5 -0
- package/dist/utils-text-lORqO4uI.cjs +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +29 -126
- package/dist/{vendor-CRvKgRcl.js → vendor-BOD7IxCS.js} +1 -1
- package/dist/{vendor-BwXiOWc8.cjs → vendor-IPtJZCbx.cjs} +1 -1
- package/package.json +1 -1
- package/dist/other-C4VnLmM6.js +0 -15
- package/dist/other-Dp3RPYfF.cjs +0 -1
package/dist/components.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./react-jsx-runtime-vendor-Dszzpdy0.cjs"),t=require("@chakra-ui/react"),n=require("react"),Y=require("urql"),ue=require("./utils.cjs"),ne=require("./hooks.cjs"),Te=require("./ufuzzy-vendor-7qHa_k39.cjs"),pe=require("./react-icons-vendor-BF_sZq07.cjs"),oe=require("./react-select-vendor-C09H7eSP.cjs"),P=require("./generated.cjs"),b=require("./graphql-Ce2MNCsk.cjs");require("./moment-vendor-1cRqq0AH.cjs");const he=require("./react-dnd-vendor-BuaDqq1-.cjs"),D=require("./generated-graphql.cjs"),ae=require("./services.cjs"),le=require("./types.cjs"),ye=({setSearch:o,actions:s,updateUseCases:l,hideUseCaseFilter:d=!1})=>{const m=n.useMemo(()=>s?.flatMap(u=>u.useCases).filter((u,x,h)=>h.findIndex(c=>c.id===u.id)===x).map(u=>({label:u.name,value:u.id}))||[],[s]);return e.jsxRuntimeExports.jsxs(t.Flex,{width:"100%",alignContent:"space-evenly",gap:4,children:[e.jsxRuntimeExports.jsxs(t.InputGroup,{size:"md",flex:1,children:[e.jsxRuntimeExports.jsx(t.InputLeftElement,{children:e.jsxRuntimeExports.jsx(t.Icon,{as:pe.FaSearch,color:"gray.300"})}),e.jsxRuntimeExports.jsx(t.Input,{placeholder:"Search by name...",width:"100%",maxW:d?void 0:"30rem",onChange:u=>o(u.target.value)})]}),!d&&e.jsxRuntimeExports.jsx(t.InputGroup,{size:"md",children:e.jsxRuntimeExports.jsx(oe.st,{size:"md",chakraStyles:{container:u=>({...u,width:"100%"})},menuPortalTarget:document.body,placeholder:"Filter use case",isMulti:!0,options:m,onChange:u=>l(u.map(x=>x.value))})})]})},se=({children:o})=>e.jsxRuntimeExports.jsx(t.FormLabel,{fontWeight:"bold",fontFamily:"sans-serif",fontSize:"large",children:o}),Se=({value:o,onChange:s})=>{const l=n.useState(()=>Math.random().toString(36).substring(2,15))[0],d=n.useCallback((m,u)=>{s(x=>{const h=[...x],[c]=h.splice(m,1);return h.splice(u,0,c),h})},[s]);return e.jsxRuntimeExports.jsx(t.Box,{children:e.jsxRuntimeExports.jsx(he.DndProvider,{backend:he.HTML5Backend,children:e.jsxRuntimeExports.jsx(t.TableContainer,{children:e.jsxRuntimeExports.jsxs(t.Table,{variant:"simple",size:"md",children:[e.jsxRuntimeExports.jsx(t.Thead,{children:e.jsxRuntimeExports.jsxs(t.Tr,{children:[e.jsxRuntimeExports.jsx(t.Th,{children:"Order"}),e.jsxRuntimeExports.jsx(t.Th,{children:"Name"})]})}),e.jsxRuntimeExports.jsx(t.Tbody,{children:o.map((m,u)=>e.jsxRuntimeExports.jsx(ve,{listKey:l,index:u,id:m.id,name:m.name,move:d},m.id))})]})})})})},ve=({listKey:o,index:s,id:l,name:d,move:m})=>{const u=n.useRef(null),[{handlerId:x},h]=he.useDrop({accept:o,collect:j=>({handlerId:j.getHandlerId()?.toString()??""}),hover:(j,v)=>{if(!u.current)return;const C=j.index,r=s;if(C===r)return;const R=u.current?.getBoundingClientRect(),T=(R.bottom-R.top)/2,M=v.getClientOffset().y-R.top;C<r&&M<T||C>r&&M>T||(m(C,r),j.index=r)}}),[{isDragging:c},E]=he.useDrag({type:o,item:()=>({id:l,index:s}),collect:j=>({isDragging:j.isDragging()})}),p=c?.6:1,L=c?"grabbing":"grab";return E(h(u)),e.jsxRuntimeExports.jsxs(t.Tr,{ref:u,style:{opacity:p,cursor:L},"data-handler-id":x,children:[e.jsxRuntimeExports.jsx(t.Td,{children:s+1}),e.jsxRuntimeExports.jsx(t.Td,{children:d})]})},Me=({items:o,onChange:s,selectedItem:l,isDisabled:d,selectedProps:m,buttonProps:u})=>{const x=c=>c===l||c.value===l,h=c=>x(c)?{...u,...m}:u;return e.jsxRuntimeExports.jsx(t.ButtonGroup,{isAttached:!0,isDisabled:d,children:o.map((c,E)=>e.jsxRuntimeExports.jsx(t.Tooltip,{label:c.tooltip,openDelay:50,closeDelay:200,placement:"top",visibility:c.tooltip?"visible":"hidden",hasArrow:!0,children:e.jsxRuntimeExports.jsx(t.Button,{onClick:()=>x(c)?null:s(c,E),isDisabled:c.disabled,...h(c),children:c.label})},E))})},xe=(o,s)=>s<0?-1*Math.abs(o):Math.abs(o),we=({isReversed:o,min:s,max:l,value:d,onChange:m,inputProps:u,size:x,zeroMarker:h,formatValue:c,valueLabel:E,positiveNegativeLabels:p,isDisabled:L,...j})=>{const[v,C]=n.useState([void 0,void 0]),r=v[0],R=v[1],T=h&&s<-5&&l>5,f=Number(d?.[0]??R??s)>0?1:-1,M=Number(d?.[1]??R??l)<0?-1:1,k=p?.[0]===p?.[1],I=d?.[0],z=d?.[1];n.useEffect(()=>{I!==void 0&&z!==void 0&&C([I.toFixed(0),z.toFixed(0)])},[I,z,C]);const N=n.useCallback(([y,_])=>{y<_&&C([y.toFixed(0),_.toFixed(0)])},[C]),O=n.useCallback(([y,_])=>{y<_&&m([y,_])},[m]),w=n.useCallback(()=>{C(([y,_])=>{const V=isNaN(Number(y))?s:Number(y),K=isNaN(Number(_))?l:Number(_),G=xe(Number(V),f),a=xe(Number(K),M),i=f<0?Math.max(G,s):Math.min(G,l),S=M<0?Math.max(a,s):Math.min(a,l);return i>S?(m([S,i]),[S.toFixed(0),i.toFixed(0)]):(m([i,S]),[i.toFixed(0),S.toFixed(0)])})},[m,C,f,M,s,l]),ee=n.useCallback(y=>{const _=y===""||isNaN(Number(y))?y:xe(Number(y),f);C(([V,K])=>[_.toString(),K])},[C,f]),J=n.useCallback(y=>{const _=y===""||isNaN(Number(y))?y:xe(Number(y),M);C(([V,K])=>[V,_.toString()])},[C,M]),g=n.useMemo(()=>x==="xs"?"0.75rem":void 0,[x]),A=n.useCallback((y,_)=>{const V=Number(_.target.value);if(!r||!R||![-1,1].includes(V))return;const K=i=>V<0?-1*Math.abs(i):Math.abs(i),G=y?K(Number(r)):Number(r),a=y?Number(R):K(Number(R));G>a?m([a,G]):m([G,a])},[r,R,m]);return e.jsxRuntimeExports.jsxs(t.Flex,{direction:"column",...j,children:[e.jsxRuntimeExports.jsx(t.Box,{pt:"1em",mb:"-0.5em",children:e.jsxRuntimeExports.jsxs(t.RangeSlider,{"aria-label":["min","max"],isReversed:o,value:[Number(r??s),Number(R??l)],max:l,min:s,minStepsBetweenThumbs:3,step:1,onChange:N,onChangeEnd:O,isDisabled:L,children:[e.jsxRuntimeExports.jsx(t.RangeSliderMark,{value:s,top:"-1em",children:e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:c?c?.(s):s})}),e.jsxRuntimeExports.jsx(t.RangeSliderMark,{value:l,top:"-1em",children:e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",style:{transform:"translateX(-100%)"},whiteSpace:"nowrap",children:c?c(l):l})}),T&&e.jsxRuntimeExports.jsxs(t.RangeSliderMark,{value:0,top:"-1em",pos:"relative",children:[e.jsxRuntimeExports.jsx(t.Text,{fontSize:x,fontWeight:"semibold",children:c?.(0)??"0"}),e.jsxRuntimeExports.jsx(t.Box,{position:"absolute",width:"2px",height:"1em",top:"90%",left:"20%",backgroundColor:"var(--chakra-colors-gray-300)"})]}),e.jsxRuntimeExports.jsx(t.RangeSliderTrack,{children:e.jsxRuntimeExports.jsx(t.RangeSliderFilledTrack,{})}),e.jsxRuntimeExports.jsx(t.RangeSliderThumb,{index:0,w:g,h:g}),e.jsxRuntimeExports.jsx(t.RangeSliderThumb,{index:1,w:g,h:g})]})}),E&&e.jsxRuntimeExports.jsxs(t.Flex,{direction:o?"row-reverse":"row",justifyContent:"space-between",children:[e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:E(s)}),e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:E(l)})]}),e.jsxRuntimeExports.jsxs(t.Flex,{direction:o?"row-reverse":"row",justifyContent:"center",alignItems:"center",gap:"0.125em",children:[p&&e.jsxRuntimeExports.jsxs(t.Select,{width:"auto",size:x,fontWeight:"bold",value:f,onChange:y=>A(!0,y),isDisabled:k||L,children:[e.jsxRuntimeExports.jsx("option",{value:-1,children:p[0]}),e.jsxRuntimeExports.jsx("option",{value:1,children:p[1]})]}),e.jsxRuntimeExports.jsx(t.NumberInput,{precision:0,size:x??"sm",min:0,max:f<0?Math.abs(s):z??l,value:r===""?"":Math.abs(Number(r??s)),onChange:ee,onBlur:w,borderWidth:1,borderRadius:3,borderColor:"#ccc",isDisabled:L,...u,children:e.jsxRuntimeExports.jsx(t.NumberInputField,{backgroundColor:"#fff",paddingRight:0,width:"4em"})}),e.jsxRuntimeExports.jsx(t.NumberInput,{size:x??"sm",min:0,max:M<0?Math.abs(I??s):l,precision:0,value:R===""?"":Math.abs(Number(R??l)),onChange:J,onBlur:w,borderWidth:1,borderRadius:3,borderColor:"#ccc",isDisabled:L,...u,children:e.jsxRuntimeExports.jsx(t.NumberInputField,{backgroundColor:"#fff",paddingRight:0,width:"4em"})}),p&&e.jsxRuntimeExports.jsxs(t.Select,{width:"auto",size:x,fontWeight:"bold",value:M,onChange:y=>A(!1,y),isDisabled:k||L,children:[e.jsxRuntimeExports.jsx("option",{value:-1,children:p[0]}),e.jsxRuntimeExports.jsx("option",{value:1,children:p[1]})]})]})]})},Le=({tags:o,containerProps:s,...l})=>e.jsxRuntimeExports.jsx(t.HStack,{...s,children:o.map((d,m)=>e.jsxRuntimeExports.jsx(t.Tag,{...l,children:d},m))}),Ae=new Te.uFuzzy({}),Fe=({action:o,quantumIconSrc:s})=>{const{getLabel:l}=ne.useUiLabelContext(),d=n.useMemo(()=>({actionLowerCase:l("action").toLocaleLowerCase()}),[l]);return o.quantumOwned?e.jsxRuntimeExports.jsx(t.Tooltip,{label:`This ${d.actionLowerCase} is owned by Quantum`,"aria-label":"Quantum owned",children:e.jsxRuntimeExports.jsx(t.Box,{boxSize:"1.5em",borderRadius:"full",bg:"black",display:"flex",alignItems:"center",justifyContent:"center",children:e.jsxRuntimeExports.jsx(t.Image,{src:s,boxSize:"1em",alt:`Quantum-owned ${d.actionLowerCase}`})})}):null},Ie=(o,s)=>{if(!s||!s.trim().length)return o;const l=o.map(m=>m.name??"");return Ae.filter(l,s)?.map(m=>o[m])??[]},Ne=o=>!o||o.length===0?"None":o.map(s=>s.replace(/([A-Z])/g," $1").trim()).join(", "),Oe=(o,s)=>!s||s.length==0?o:o.filter(l=>l.useCases?.some(d=>s.includes(d.id))??!1),ge=({actions:o,totalActions:s,onCreate:l,onDelete:d,onEdit:m,onView:u,onSelected:x,onDuplicate:h,disableMultiSelect:c,disableDelete:E,disableEdit:p,disableCreate:L,hideUseCase:j=!0,tableProps:v,containerProps:C,quantumIconSrc:r="/favicon.ico"})=>{const[R,T]=n.useState(""),[f,M]=n.useState(),{getLabel:k}=ne.useUiLabelContext(),I=n.useMemo(()=>({action:k("action"),actionPlural:k("action_plural"),actionLowerCase:k("action").toLocaleLowerCase(),actionPluralLowerCase:k("action_plural").toLocaleLowerCase()}),[k]),z=n.useMemo(()=>{if(!o)return;const g=Ie(o,R);return j?g:Oe(g,f)},[o,R,f,j]),N=n.useCallback(()=>{if(!d)return;const A=o.filter(y=>y.selected&&!y.quantumOwned).map(y=>y.id);d(A)},[o,d]),O=n.useCallback(()=>{if(!h)return;const g=o.filter(A=>A.selected);h(g.map(A=>A.id)),x&&g.forEach(A=>x(A,!1))},[o,h,x]),w=n.useMemo(()=>o.some(g=>g.selected&&!g.quantumOwned),[o]),ee=n.useMemo(()=>o.some(g=>g.selected),[o]),J=n.useMemo(()=>o.some(g=>g.selected&&g.quantumOwned),[o]);return e.jsxRuntimeExports.jsxs(t.Box,{...C,children:[e.jsxRuntimeExports.jsxs(t.Flex,{alignContent:"space-between",gap:4,children:[(l||d||h)&&e.jsxRuntimeExports.jsxs(t.ButtonGroup,{mb:"1rem",gap:4,children:[l&&e.jsxRuntimeExports.jsxs(t.Button,{isDisabled:!l||L,colorScheme:"blackAlpha",backgroundColor:"gray.700",onClick:l,children:["Create New ",I.action]}),d&&!c&&e.jsxRuntimeExports.jsx(t.Tooltip,{label:J?w?`Quantum-owned ${I.actionPluralLowerCase} are selected and will be skipped`:`Selected ${I.actionPluralLowerCase} are quantum-owned and cannot be deleted`:void 0,shouldWrapChildren:!0,children:e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:!w||!d||E,onClick:N,children:"Delete Selected"})}),h&&!c&&e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:!ee,onClick:O,children:"Duplicate Selected"})]}),e.jsxRuntimeExports.jsx(ye,{setSearch:T,actions:o,updateUseCases:M,hideUseCaseFilter:j})]}),e.jsxRuntimeExports.jsx(t.TableContainer,{mr:"2rem",overflowX:"hidden",...v,children:e.jsxRuntimeExports.jsxs(t.Table,{size:"md",variant:"simple",children:[e.jsxRuntimeExports.jsx(t.Thead,{position:"sticky",top:0,bg:"white",zIndex:1,children:e.jsxRuntimeExports.jsxs(t.Tr,{children:[e.jsxRuntimeExports.jsxs(t.Th,{fontWeight:"normal",children:["(showing ",z?.length??0," of"," ",s??o.length,")"]}),e.jsxRuntimeExports.jsx(t.Th,{children:"Name"}),e.jsxRuntimeExports.jsx(t.Th,{children:"Sensor Locations"}),!j&&e.jsxRuntimeExports.jsx(t.Th,{children:"Use Case"}),e.jsxRuntimeExports.jsx(t.Th,{})]})}),e.jsxRuntimeExports.jsx(t.Tbody,{children:z?.map(g=>e.jsxRuntimeExports.jsxs(t.Tr,{className:ue.cn("hover:bg-[#f7f7f7]",!c&&"cursor-pointer",g.selected&&"bg-gray-200"),onClick:()=>{c||x?.(g,!g.selected)},children:[e.jsxRuntimeExports.jsx(t.Td,{children:e.jsxRuntimeExports.jsxs(t.Flex,{children:[!c&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:g.selected?e.jsxRuntimeExports.jsx(pe.FaCheckSquare,{className:"text-blue-500"}):e.jsxRuntimeExports.jsx(pe.FaSquare,{className:"text-gray-400"})}),(g.quantumOwned||!m)&&u&&e.jsxRuntimeExports.jsx(t.Button,{ml:"1em",size:"sm",variant:"link",colorScheme:"blue",onClick:A=>{A.stopPropagation(),u(g.id)},children:"View"}),!g.quantumOwned&&m&&e.jsxRuntimeExports.jsx(t.Button,{isDisabled:p,ml:"1em",size:"sm",variant:"link",colorScheme:"blue",onClick:A=>{A.stopPropagation(),m(g.id)},children:"Edit"})]})}),e.jsxRuntimeExports.jsx(t.Td,{whiteSpace:"break-spaces",children:e.jsxRuntimeExports.jsxs(t.Flex,{align:"center",gap:2,children:[e.jsxRuntimeExports.jsx(Fe,{action:g,quantumIconSrc:r}),g.name]})}),e.jsxRuntimeExports.jsx(t.Td,{maxW:"20rem",whiteSpace:"break-spaces",children:Ne(g.sensorLocations)}),!j&&e.jsxRuntimeExports.jsx(t.Td,{maxW:"20rem",children:e.jsxRuntimeExports.jsx(Le,{containerProps:{flexWrap:"wrap"},tags:g.useCases?.map(A=>A.name)??[]})})]},g.id))})]})})]})},ke=({onSave:o,onCancel:s,onError:l,hideButtons:d=!1,setButtonDisabled:m,setButtonOnClick:u,quantumOwned:x})=>{const h=t.useToast(),{getLabel:c}=ne.useUiLabelContext(),E=n.useMemo(()=>({singular:c("action"),plural:c("action_plural"),pluralLowerCase:c("action_plural").toLowerCase(),singularLowerCase:c("action").toLowerCase()}),[c]),[p,L]=n.useState("copy"),[j,v]=n.useState(""),[C,r]=n.useState([]),[R,T]=n.useState(!1),[f]=Y.useQuery({query:b.GET_GROUPS}),[M]=Y.useQuery({query:b.GET_ACTIONS_BY_GROUP,variables:{groupId:j},pause:!j}),[,k]=Y.useMutation(b.CREATE_ACTION),[,I]=Y.useMutation(b.CONVERT_ACTION_TO_QUANTUM_OWNED),z=n.useMemo(()=>f.data?.groups?f.data.groups.map(a=>P.getFragmentData(b.GROUP_FRAGMENT,a)):[],[f.data]),N=n.useMemo(()=>M.data?M.data.actions.map(i=>P.getFragmentData(b.ACTION_FRAGMENT,i)):[],[M.data]),O=n.useMemo(()=>N.filter(a=>C.includes(a.id)),[N,C]),w=n.useCallback(a=>{const i=a?.value||"";v(i),r([])},[]),ee=n.useCallback(a=>{const i=a.map(S=>S.value);r(i)},[]),J=n.useCallback(async a=>{const i=P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,a.categories),$=P.getFragmentData(b.METADATA_GROUP_FRAGMENT,a.metadataGroups).flatMap(U=>U.data.map(X=>P.getFragmentData(b.METADATA_ITEM_FRAGMENT,X).id)),B={...a,name:`${a.name} (Copy)`,description:a.description||void 0,instructionsPointOfInterest:a.instructionsPointOfInterest||void 0,instructionsMovementReport:a.instructionsMovementReport||void 0,laterality:a.laterality,activityKind:a.activityKind,sensorLocations:a.sensorLocations,thresholds:a.thresholds.map(U=>({...U,id:void 0})),categories:i?.map(U=>U.id),quantumOwned:x,metadataItemIds:$,id:void 0},q=await k({fields:B});if(q.error)throw new Error(q.error.message);if(q.data?.createAction)return P.getFragmentData(b.ACTION_FRAGMENT,q.data.createAction);throw new Error("No action data returned")},[k,x]),g=n.useCallback(async a=>{const i=await I({id:a.id});if(i.error)throw new Error(i.error.message);if(i.data?.convertActionToQuantumOwned)return P.getFragmentData(b.ACTION_FRAGMENT,i.data.convertActionToQuantumOwned);throw new Error("No action data returned")},[I]),A=n.useCallback(async()=>{if(T(!0),!O.length){const a=new Error(`No ${E.pluralLowerCase} selected for ${p==="copy"?"copying":"converting"}`);l?.(a),T(!1);return}try{const a=[];let i=0;const S=p==="copy"?J:g,$=p==="copy"?"copy":"convert";for(const B of O)try{const q=await S(B);a.push(q)}catch(q){console.error(`Failed to ${$} ${E.singularLowerCase} "${B.name}":`,q),i++}if(a.length>0){const B=a.length,q=O.length,U=p==="copy"?"copied":"converted",X=p==="copy"?"copy":"convert";h({title:i>0?`Partial ${X} completed`:`${E.plural} ${U} successfully`,description:i>0?`${B} of ${q} ${E.pluralLowerCase} ${U} successfully`:`${B} ${B>1?E.pluralLowerCase:E.singularLowerCase} ${U} successfully`,status:i>0?"warning":"success",duration:3e3,isClosable:!0}),o?.(),v(""),r([])}else throw new Error(`Failed to ${$} any ${E.pluralLowerCase}`)}catch(a){const i=p==="copy"?"copy":"convert",S=a instanceof Error?a.message:`Failed to ${i} ${E.pluralLowerCase}`;h({title:`${p==="copy"?"Copy":"Convert"} failed`,description:S,status:"error",duration:5e3,isClosable:!0}),l?.(a instanceof Error?a:new Error(S))}finally{T(!1)}},[O,p,J,g,h,o,l]),y=n.useCallback(()=>{v(""),r([]),L("copy"),s?.()},[s]);n.useEffect(()=>{m&&m({cancelButton:!1,saveButton:O.length===0||R})},[O.length,R,m]),n.useEffect(()=>{u&&u({cancelButton:y,saveButton:A})},[u,y,A]);const _=n.useMemo(()=>z.map(a=>({value:a.id,label:a.name})),[z]),V=n.useMemo(()=>N.filter(a=>p==="copy"?!0:!a.quantumOwned).map(a=>({value:a.id,label:a.name,isQuantumOwned:a.quantumOwned})),[N,p]),K=f.fetching,G=M.fetching;return e.jsxRuntimeExports.jsx(t.Box,{children:e.jsxRuntimeExports.jsxs(t.VStack,{spacing:6,align:"stretch",children:[x&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Operation Mode"}),e.jsxRuntimeExports.jsx(t.RadioGroup,{value:p,onChange:a=>{L(a),r([])},children:e.jsxRuntimeExports.jsxs(t.HStack,{spacing:6,children:[e.jsxRuntimeExports.jsx(t.Radio,{value:"copy",colorScheme:"blue",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",children:["Copy ",E.plural]}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Create new ",E.plural.toLocaleLowerCase()," ","based on selected ones"]})]})}),e.jsxRuntimeExports.jsx(t.Radio,{value:"convert",colorScheme:"green",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",children:["Convert to Quantum Owned ",E.singular]}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Convert existing"," ",E.plural.toLocaleLowerCase()," to quantum-owned"]})]})})]})})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Select Source Group"}),e.jsxRuntimeExports.jsx(oe.st,{placeholder:"Choose a group...",options:_,value:_.find(a=>a.value===j)||null,onChange:w,isLoading:K,isDisabled:K,isClearable:!0}),f.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load groups: ",f.error.message]})]})]}),j&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsxs(se,{children:["Select ",E.plural," to"," ",p==="copy"?"Copy":"Convert"]}),G?e.jsxRuntimeExports.jsxs(t.HStack,{children:[e.jsxRuntimeExports.jsx(t.Spinner,{size:"sm"}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Loading ",E.pluralLowerCase,"..."]})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(oe.st,{placeholder:`Choose ${E.pluralLowerCase} to ${p}...`,options:V,value:V.filter(a=>C.includes(a.value)),onChange:ee,isDisabled:V.length===0,isClearable:!0,isMulti:!0,closeMenuOnSelect:!1,formatOptionLabel:(a,{context:i})=>e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",w:"100%",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(t.Text,{children:a.label}),i==="value"&&a.isQuantumOwned&&e.jsxRuntimeExports.jsx(t.Text,{color:"blue",fontSize:"xs",children:"(Quantum Owned)"})]}),a.isQuantumOwned&&i==="menu"&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]})}),V.length===0&&e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.500",mt:2,children:["No ",E.pluralLowerCase," found"]})]}),M.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load ",E.pluralLowerCase,":"," ",M.error.message]})]})]}),O.length>0&&e.jsxRuntimeExports.jsxs(t.Box,{p:4,bg:"gray.50",borderRadius:"md",children:[e.jsxRuntimeExports.jsx(t.Text,{fontWeight:"semibold",mb:3,children:O.length===1?`${E.singular} to ${p==="copy"?"Copy":"Convert"}:`:`${O.length} ${E.plural} to ${p==="copy"?"Copy":"Convert"}:`}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:3,children:[O.map((a,i)=>e.jsxRuntimeExports.jsxs(t.Box,{w:"100%",p:3,bg:"white",borderRadius:"md",border:"1px solid",borderColor:"gray.200",children:[e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",align:"start",mb:2,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",fontSize:"sm",children:[i+1,". ",a.name]}),a.quantumOwned&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,fontSize:"sm",color:"gray.600",children:[a.description&&e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Description:"})," ",a.description]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Type:"})," ",a.activityKind]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Laterality:"})," ",a.laterality]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Sensor Locations:"})," ",a.sensorLocations.length]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Thresholds:"})," ",a.thresholds.length]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Use Cases:"})," ",a.useCases.map(S=>S.name).join(", ")||"None"]})]})]},a.id)),O.length>1&&e.jsxRuntimeExports.jsx(t.Box,{w:"100%",p:2,bg:"blue.50",borderRadius:"md",border:"1px solid",borderColor:"blue.200",children:e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",fontWeight:"medium",color:"blue.800",children:["Total: ",O.length," ",E.pluralLowerCase," will be"," ",p==="copy"?"copied":"converted"]})})]})]}),!d&&e.jsxRuntimeExports.jsxs(t.ButtonGroup,{spacing:4,justifyContent:"flex-end",children:[e.jsxRuntimeExports.jsx(t.Button,{variant:"outline",onClick:y,isDisabled:R,children:"Cancel"}),e.jsxRuntimeExports.jsxs(t.Button,{colorScheme:p==="copy"?"blue":"green",onClick:A,isDisabled:O.length===0||R,isLoading:R,loadingText:`${p==="copy"?"Copying":"Converting"}...`,children:[p==="copy"?"Copy":"Convert"," ",O.length===1?E.singular:`${O.length} ${E.plural}`]})]})]})})},De=({onSave:o,onCancel:s,onError:l,hideButtons:d=!1,setButtonDisabled:m,setButtonOnClick:u,quantumOwned:x})=>{const h=t.useToast(),{getLabel:c}=ne.useUiLabelContext(),[E,p]=n.useState(""),[L,j]=n.useState([]),[v,C]=n.useState(!1),[r,R]=n.useState("copy"),[T]=Y.useQuery({query:b.GET_GROUPS}),[f]=Y.useQuery({query:b.GET_MODULES_BY_GROUP,variables:{groupId:E},pause:!E}),[,M]=Y.useMutation(b.CREATE_MODULE),[,k]=Y.useMutation(b.UPDATE_MODULE),[,I]=Y.useMutation(b.CREATE_ACTION),[,z]=Y.useMutation(b.CONVERT_ACTION_TO_QUANTUM_OWNED),N=n.useMemo(()=>T.data?.groups?T.data.groups.map(i=>P.getFragmentData(b.GROUP_FRAGMENT,i)):[],[T.data]),O=n.useMemo(()=>f.data?.modules?P.getFragmentData(b.ACTION_MODULE_FRAGMENT,f.data?.modules).map(S=>{const $=P.getFragmentData(b.MODULE_ACTION_FRAGMENT,S.moduleActions);return{...S,moduleActions:$.map(B=>({...B,action:P.getFragmentData(b.ACTION_FRAGMENT,B.action)})),categories:P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,S.categories)}}):[],[f.data]),w=n.useMemo(()=>O.filter(i=>L.includes(i.id)),[O,L]),ee=n.useCallback(i=>{const S=i?.value||"";p(S),j([])},[]),J=n.useCallback(i=>{const S=i.map($=>$.value);j(S)},[]),g=n.useCallback(async()=>{if(C(!0),!w.length){C(!1);const i=new Error(`No modules selected for ${r==="convert"?"converting":"copying"}`);l?.(i);return}try{const i=[];let S=0;for(const $ of w)try{let B=$.moduleActions.map(q=>q.actionId);if(x){const q=$.moduleActions.map(W=>W.action),U=async W=>{if(r==="copy"){if(W.quantumOwned)return W;const F=P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,W.categories),H={...W,quantumOwned:!0,thresholds:W.thresholds.map(Z=>({...Z,id:void 0})),categories:F?.map(Z=>Z.id),id:void 0},Q=await I({fields:H});return Q.error||!Q.data?.createAction?null:P.getFragmentData(b.ACTION_FRAGMENT,Q.data.createAction)}if(W.quantumOwned)return W;const ce=await z({id:W.id});return ce.error||!ce.data?.convertActionToQuantumOwned?null:P.getFragmentData(b.ACTION_FRAGMENT,ce.data.convertActionToQuantumOwned)};B=(await Promise.all(q.map(U))).filter(W=>!!W).map(W=>W.id)}if(r==="convert"){const q={name:$.name,description:$.description||void 0,actions:B,categories:$.categories.map(X=>X.id),quantumOwned:!0},U=await k({id:$.id,input:q});if(U.error)throw new Error(U.error.message);if(U.data?.updateModule){const X=P.getFragmentData(b.ACTION_MODULE_FRAGMENT,U.data.updateModule);i.push(X)}}else{const q={name:`${$.name} (Copy)`,description:$.description||void 0,actions:B,categories:$.categories.map(X=>X.id),quantumOwned:x},U=await M({input:q});if(U.error)throw new Error(U.error.message);if(U.data?.createModule){const X=P.getFragmentData(b.ACTION_MODULE_FRAGMENT,U.data.createModule);i.push(X)}}}catch(B){console.error(`Failed to ${r==="convert"?"convert":"copy"} module "${$.name}":`,B),S++}if(i.length>0){const $=i.length,B=w.length;h({title:S>0?`Partial ${r==="convert"?"convert":"copy"} completed`:`Modules ${r==="convert"?"converted":"copied"} successfully`,description:S>0?`${$} of ${B} modules ${r==="convert"?"converted":"copied"} successfully`:`${$} module${$>1?"s":""} ${r==="convert"?"converted":"copied"} successfully`,status:S>0?"warning":"success",duration:3e3,isClosable:!0}),i.length>0&&o?.(),p(""),j([])}else throw new Error(`Failed to ${r==="convert"?"convert":"copy"} any modules`)}catch(i){const S=i instanceof Error?i.message:`Failed to ${r==="convert"?"convert":"copy"} modules`;h({title:r==="convert"?"Convert failed":"Copy failed",description:S,status:"error",duration:5e3,isClosable:!0}),l?.(i instanceof Error?i:new Error(S))}finally{C(!1)}},[w,M,k,h,o,l,x,I,z,r]),A=n.useCallback(()=>{p(""),j([]),R("copy"),s?.()},[s]);n.useEffect(()=>{m&&m({cancelButton:!1,saveButton:w.length===0||v})},[w.length,v,m]),n.useEffect(()=>{u&&u({cancelButton:A,saveButton:g})},[u,A,g]);const y=n.useMemo(()=>N.map(i=>({value:i.id,label:i.name})),[N]),_=n.useMemo(()=>O.filter(i=>r==="copy"?!0:!i.quantumOwned).map(i=>({value:i.id,label:i.name,isQuantumOwned:i.quantumOwned})),[O,r]),V=T.fetching,K=f.fetching,G=n.useMemo(()=>({singular:c("module"),plural:c("module_plural"),pluralLowerCase:c("module_plural").toLowerCase(),singularLowerCase:c("module").toLowerCase()}),[c]),a=n.useMemo(()=>({singular:c("action"),plural:c("action_plural"),pluralLowerCase:c("action_plural").toLowerCase(),singularLowerCase:c("action").toLowerCase()}),[c]);return e.jsxRuntimeExports.jsx(t.Box,{children:e.jsxRuntimeExports.jsxs(t.VStack,{spacing:6,align:"stretch",children:[x&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Operation Mode"}),e.jsxRuntimeExports.jsx(t.RadioGroup,{value:r,onChange:i=>{R(i),j([])},children:e.jsxRuntimeExports.jsxs(t.HStack,{spacing:6,children:[e.jsxRuntimeExports.jsx(t.Radio,{value:"copy",colorScheme:"blue",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",children:["Copy ",G.plural]}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Create new ",G.pluralLowerCase," based on selected ones"]})]})}),e.jsxRuntimeExports.jsx(t.Radio,{value:"convert",colorScheme:"green",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsx(t.Text,{fontWeight:"medium",children:"Convert to Quantum Owned"}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Convert existing ",G.pluralLowerCase," to quantum-owned"]})]})})]})})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Select Source Group"}),e.jsxRuntimeExports.jsx(oe.st,{placeholder:"Choose a group...",options:y,value:y.find(i=>i.value===E)||null,onChange:ee,isLoading:V,isDisabled:V,isClearable:!0}),T.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load groups: ",T.error.message]})]})]}),E&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:r==="convert"?`Select ${G.plural} to Convert`:`Select ${G.plural} to Copy`}),K?e.jsxRuntimeExports.jsxs(t.HStack,{children:[e.jsxRuntimeExports.jsx(t.Spinner,{size:"sm"}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Loading ",G.pluralLowerCase,"..."]})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(oe.st,{placeholder:r==="convert"?`Choose ${G.pluralLowerCase} to convert...`:`Choose ${G.pluralLowerCase} to copy...`,options:_,value:_.filter(i=>L.includes(i.value)),onChange:J,isDisabled:_.length===0,isClearable:!0,isMulti:!0,closeMenuOnSelect:!1,formatOptionLabel:(i,{context:S})=>e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",w:"100%",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(t.Text,{children:i.label}),S==="value"&&i.isQuantumOwned&&e.jsxRuntimeExports.jsx(t.Text,{color:"blue",fontSize:"xs",children:"(Quantum Owned)"})]}),i.isQuantumOwned&&S==="menu"&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]})}),_.length===0&&e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.500",mt:2,children:["No ",G.pluralLowerCase," found in this group"]})]}),f.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load ",G.pluralLowerCase,":"," ",f.error.message]})]})]}),w.length>0&&e.jsxRuntimeExports.jsxs(t.Box,{p:4,bg:"gray.50",borderRadius:"md",children:[e.jsxRuntimeExports.jsx(t.Text,{fontWeight:"semibold",mb:3,children:w.length===1?`${G.singular} to ${r==="copy"?"Copy":"Convert"}`:`${w.length} ${G.plural} to ${r==="copy"?"Copy":"Convert"}`}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:3,children:[w.map((i,S)=>e.jsxRuntimeExports.jsxs(t.Box,{w:"100%",p:3,bg:"white",borderRadius:"md",border:"1px solid",borderColor:"gray.200",children:[e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",align:"start",mb:2,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",fontSize:"sm",children:[S+1,". ",i.name]}),i.quantumOwned&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,fontSize:"sm",color:"gray.600",children:[i.description&&e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Description:"})," ",i.description]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Activities:"})," ",i.moduleActions.length]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Categories:"})," ",i.categories.map($=>$.name).join(", ")||"None"]})]})]},i.id)),w.length>1&&e.jsxRuntimeExports.jsx(t.Box,{w:"100%",p:2,bg:"blue.50",borderRadius:"md",border:"1px solid",borderColor:"blue.200",children:e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",fontWeight:"medium",color:"blue.800",children:["Total: ",w.length," ",G.pluralLowerCase," will be"," ",r==="copy"?"copied":"converted"]})}),x&&w.filter(i=>i.moduleActions.some(S=>!S.action.quantumOwned)).length>0&&e.jsxRuntimeExports.jsx(t.Box,{p:2,bg:"yellow.50",borderRadius:"md",border:"1px solid",borderColor:"yellow.200",children:e.jsxRuntimeExports.jsx(t.Text,{fontSize:"sm",fontWeight:"medium",color:"yellow.800",children:r==="convert"?`Converting ${G.plural} will convert non QM-Owned ${a.plural} to QM-Owned ${a.plural}`:`Copying ${G.plural} with Non QM-Owned ${a.plural} will create corresponding QM-Owned ${a.plural}`})})]})]}),!d&&e.jsxRuntimeExports.jsxs(t.ButtonGroup,{spacing:4,justifyContent:"flex-end",children:[e.jsxRuntimeExports.jsx(t.Button,{variant:"outline",onClick:A,isDisabled:v,children:"Cancel"}),e.jsxRuntimeExports.jsxs(t.Button,{colorScheme:r==="copy"?"blue":"green",onClick:g,isDisabled:w.length===0||v,isLoading:v,loadingText:`${r==="copy"?"Copying":"Converting"}...`,children:[r==="copy"?"Copy":"Convert"," ",w.length===1?G.singular:`${w.length} ${G.plural}`]})]})]})})},Ee=({name:o,setName:s,actions:l,selectedActionIds:d,setSelectedActionIds:m,availableCategories:u,selectedCategoryIds:x,setSelectedCategoryIds:h,description:c,setDescription:E,...p})=>{const L=t.useDisclosure(),j=n.useMemo(()=>l.map(f=>({...f,selected:d.includes(f.id)})),[l,d]),v=n.useMemo(()=>l.reduce((f,M)=>(f[M.id]=M,f),{}),[l]),C=n.useMemo(()=>d.map(f=>v[f]),[d,v]),r=n.useCallback((f,M)=>{m(M?[...d,f.id]:d.filter(k=>k!==f.id))},[d,m]),R=n.useCallback(f=>{s(f.target.value)},[s]),T=n.useCallback(f=>{E?.(f.target.value)},[E]);return e.jsxRuntimeExports.jsxs(t.Box,{...p,children:[e.jsxRuntimeExports.jsxs(t.HStack,{gap:"2rem",children:[e.jsxRuntimeExports.jsx(_e,{name:o??"",onInputChange:R}),e.jsxRuntimeExports.jsx(Ge,{availableCategories:u,value:x,onChange:h})]}),e.jsxRuntimeExports.jsx($e,{description:c??"",onInputChange:T}),e.jsxRuntimeExports.jsx(Pe,{value:C,onChange:m,onAdjustActivities:()=>L.onOpen()}),e.jsxRuntimeExports.jsxs(t.Modal,{isOpen:L.isOpen,onClose:L.onClose,size:"6xl",children:[e.jsxRuntimeExports.jsx(t.ModalOverlay,{}),e.jsxRuntimeExports.jsxs(t.ModalContent,{children:[e.jsxRuntimeExports.jsx(t.ModalHeader,{children:"Select Activities"}),e.jsxRuntimeExports.jsx(t.ModalCloseButton,{}),e.jsxRuntimeExports.jsx(t.ModalBody,{children:e.jsxRuntimeExports.jsx(ge,{actions:j,onSelected:r,disableCreate:!0,disableDelete:!0,tableProps:{height:"28rem",overflowY:"auto"}})}),e.jsxRuntimeExports.jsx(t.ModalFooter,{children:e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"blue",onClick:L.onClose,isDisabled:d.length===0,children:"Done"})})]})]})]})},_e=n.memo(({name:o,onInputChange:s})=>{const{getLabel:l}=ne.useUiLabelContext(),d=l("module");return e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsxs(se,{children:[d," Name"]}),e.jsxRuntimeExports.jsx(t.Input,{placeholder:"i.e. ACL RTP Test Battery",value:o,onChange:s,isRequired:!0})]})}),Ge=n.memo(({availableCategories:o,value:s,onChange:l})=>{const{getLabel:d}=ne.useUiLabelContext(),m=d("module"),u=n.useMemo(()=>[...o,{id:"other",name:"Other"}],[o]),x=n.useMemo(()=>u.map(h=>({value:h.id,label:h.name})),[u]);return e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsxs(se,{children:[m," Category"]}),e.jsxRuntimeExports.jsx(oe.st,{isDisabled:o.length===0,options:x,value:s.length===0?{value:"other",label:"Other"}:u.filter(h=>s.includes(h.id)).map(h=>({value:h.id,label:h.name}))[0],onChange:h=>l(h?[h.value]:[]),placeholder:"Select category"})]})}),$e=n.memo(({description:o,onInputChange:s})=>e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsx(se,{children:e.jsxRuntimeExports.jsxs("span",{children:["Description",e.jsxRuntimeExports.jsx(t.Text,{fontSize:"sm",color:"gray.500",children:"Briefly describe the objective of this module. Max 40 words."})]})}),e.jsxRuntimeExports.jsx(t.Input,{placeholder:"i.e. Assess readiness to return to play post-ACL reconstruction",value:o,onChange:s})]})),Pe=n.memo(({value:o,onChange:s,onAdjustActivities:l})=>{const{getLabel:d}=ne.useUiLabelContext(),m=n.useMemo(()=>({module:d("module"),moduleLowerCase:d("module").toLocaleLowerCase(),action:d("action"),actionPlural:d("action_plural"),actionPluralLowerCase:d("action_plural").toLocaleLowerCase()}),[d]),u=n.useMemo(()=>o.map(x=>({id:x.id,name:x.name})),[o]);return e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsxs(t.HStack,{justifyContent:"space-between",children:[e.jsxRuntimeExports.jsx(se,{children:e.jsxRuntimeExports.jsxs("span",{children:[m.actionPlural,e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.500",children:["Drag and drop to reorder the ",m.actionPluralLowerCase," in this ",m.moduleLowerCase,"."]})]})}),e.jsxRuntimeExports.jsxs(t.Button,{size:"sm",variant:"solid",colorScheme:"blue",onClick:l,children:["Add / Remove ",m.actionPlural]})]}),u.length===0?e.jsxRuntimeExports.jsx(t.VStack,{children:e.jsxRuntimeExports.jsxs(t.Text,{color:"gray.500",fontSize:"lg",mb:"4rem",mt:"4rem",children:["No ",m.actionPluralLowerCase," selected for this"," ",m.moduleLowerCase,".",e.jsxRuntimeExports.jsxs(t.Button,{ml:"0.5em",size:"sm",variant:"link",colorScheme:"blue",onClick:l,children:["Add ",m.actionPluralLowerCase,"."]})]})}):e.jsxRuntimeExports.jsx(Se,{value:u,onChange:x=>{const h=x(u);s(h.map(c=>c.id))}})]})}),Re=({value:o,onChange:s,forceKind:l,disableRemove:d,disableKind:m,isDisabled:u,lockRanges:x,...h})=>{const c=n.useMemo(()=>[...o].sort((j,v)=>{const C=le.availablePlanes.indexOf(j.plane),r=le.availablePlanes.indexOf(v.plane);return C-r}),[o]),E=n.useCallback(j=>"segment"in j.id?ae.getSegmentNameWithPlane(j.id.segment,j.plane,!0)??"Unknown":ae.getJointNameWithPlane(j.id.joint,j.plane,!0)??"Unknown",[]),p=n.useCallback((j,v)=>{const C=c.findIndex(R=>R.id===v.id&&R.plane===v.plane);let r=[...c];l&&(v={...v,kind:l}),r[C]=v,x&&(r=r.map(R=>({...R,min:v.min,max:v.max}))),s(r)},[s,c,l,x]),L=n.useCallback(j=>{const v=c.filter(C=>C.id!==j.id||C.plane!==j.plane);s(v)},[s,c]);return e.jsxRuntimeExports.jsx(t.VStack,{alignItems:"flex-start",overflowY:"auto",...h,children:c.map((j,v)=>e.jsxRuntimeExports.jsx(Be,{label:E(j),parameter:j,onChange:C=>p(v,C),onRemove:d||u?void 0:()=>L(j),forceKind:l,disableKind:m||u,isDisabled:u},`${JSON.stringify(j.id)}-${j.plane}`))})},Be=({label:o,parameter:s,onChange:l,onRemove:d,forceKind:m,disableKind:u,isDisabled:x})=>{const h=n.useCallback(p=>"joint"in s.id?ae.getJointAngleDirectionName(s.id.joint,s.plane,p<0?-1:1):ae.getSegmentAngleDirectionName(s.id.segment,s.plane,p<0?-1:1),[s]),{min:c,max:E}="joint"in s.id?ae.getNormativeJointRange(s.id.joint,s.plane):{min:-180,max:180};return e.jsxRuntimeExports.jsxs(t.VStack,{borderRadius:"md",p:2,px:4,bg:"gray.100",w:"100%",overflow:"hidden",flexShrink:"0",children:[e.jsxRuntimeExports.jsxs(t.HStack,{w:"100%",children:[e.jsxRuntimeExports.jsx(t.Text,{fontSize:"sm",flex:1,textTransform:"capitalize",fontWeight:"semibold",children:o}),d&&!x&&e.jsxRuntimeExports.jsx(t.IconButton,{size:"xs",variant:"ghost","aria-label":"delete",icon:e.jsxRuntimeExports.jsx(t.Icon,{as:pe.FaTrash}),onClick:d}),!m&&e.jsxRuntimeExports.jsx(Me,{selectedItem:s?.kind??D.ThresholdKind.Limit,onChange:({value:p})=>l({...s,kind:p}),isDisabled:u||x,buttonProps:{size:"sm",variant:"outline",colorScheme:"gray"},selectedProps:{variant:"solid",colorScheme:"teal"},items:[{value:D.ThresholdKind.Limit,label:"limit"},{value:D.ThresholdKind.Target,label:"target"}]})]}),e.jsxRuntimeExports.jsx(we,{w:"100%",size:"xs",min:c,max:E,zeroMarker:!0,value:[s.min,s.max],onChange:p=>l({...s,min:p[0],max:p[1]}),formatValue:p=>`${Math.abs(p)}°`,valueLabel:p=>h(p)??"",positiveNegativeLabels:h(0)?[h(-1)??"",h(1)??""]:void 0,isDisabled:x})]})},me=(o,s)=>"segment"in o&&"segment"in s&&o.segment===s.segment||"joint"in o&&"joint"in s&&o.joint===s.joint,fe=({options:o,value:s,onChange:l,forceKind:d,singleValue:m,singleValueSideless:u,editOnly:x,disableKind:h,maxParameters:c,...E})=>{const p=u?2:c,L=n.useMemo(()=>o.map(r=>({label:"segment"in r.id?ae.getSegmentNameWithPlane(r.id.segment,r.plane,!0)??"Unknown":ae.getJointNameWithPlane(r.id.joint,r.plane,!0)??"Unknown",value:r.id,plane:r.plane})),[o]),j=n.useMemo(()=>{if(!u||s.length===0)return L;const r=s[0];return L.filter(R=>le.getAnalysisPartIdNoSide(R.value)===le.getAnalysisPartIdNoSide(r.id)&&R.plane===r.plane)},[L,s,u]),v=n.useMemo(()=>L.filter(r=>s.some(R=>me(R.id,r.value)&&R.plane===r.plane)),[L,s]),C=n.useCallback(r=>{const R=r.map(T=>{const f=s.find(N=>me(N.id,T.value)&&N.plane===T.plane),M=o.find(N=>me(N.id,T.value)&&N.plane===T.plane),k=u?s.find(N=>le.getAnalysisPartIdNoSide(N.id)===le.getAnalysisPartIdNoSide(T.value)&&N.plane===T.plane):void 0,I=k&&!f?k.min:M&&M.min?M.min:0,z=k&&!f?k.max:M&&M.max?M.max:0;return f??{id:T.value,plane:T.plane,min:I,max:z,kind:d??D.ThresholdKind.Limit}});l(R)},[l,s,o,d,u]);return n.useEffect(()=>{const r=s.filter(R=>o.some(T=>me(T.id,R.id)&&T.plane===R.plane));r.length!==s.length&&l(r)},[o,l]),e.jsxRuntimeExports.jsxs(t.Box,{...E,children:[e.jsxRuntimeExports.jsx(oe.st,{isMulti:!m,placeholder:s.length?`${s.length} selected`:"Search...",value:v,isDisabled:x||v.length>=(p??1/0),onChange:r=>Array.isArray(r)?C([...r]):C(r!==null?[r]:[]),options:j,controlShouldRenderValue:!1}),e.jsxRuntimeExports.jsx(Re,{marginTop:2,maxH:"28rem",value:s,onChange:l,forceKind:d,disableKind:h,isDisabled:x,lockRanges:u})]})},Ce=o=>{switch(o){case D.SensorLocation.Thorax:return"Thorax";case D.SensorLocation.CenterBack:return"Center Back";case D.SensorLocation.Pelvis:return"Pelvis";case D.SensorLocation.LeftThigh:return"Left Thigh";case D.SensorLocation.RightThigh:return"Right Thigh";case D.SensorLocation.LeftShank:return"Left Shank";case D.SensorLocation.RightShank:return"Right Shank";case D.SensorLocation.LeftFoot:return"Left Foot";case D.SensorLocation.RightFoot:return"Right Foot";case D.SensorLocation.LeftUpperArm:return"Left Upper Arm";case D.SensorLocation.RightUpperArm:return"Right Upper Arm";case D.SensorLocation.LeftForearm:return"Left Forearm";case D.SensorLocation.RightForearm:return"Right Forearm";case D.SensorLocation.Head:return"Head"}return console.warn(`Unknown sensor location: ${o}`),"Unknown"},Ue=6,ze=[D.SensorLocation.LeftFoot,D.SensorLocation.LeftShank,D.SensorLocation.LeftThigh,D.SensorLocation.Pelvis,D.SensorLocation.RightFoot,D.SensorLocation.RightShank,D.SensorLocation.RightThigh,D.SensorLocation.Thorax,D.SensorLocation.CenterBack,D.SensorLocation.Head],qe=ze.map(o=>({label:Ce(o),value:o})),Qe=({id:o,onError:s,onCancel:l,onSave:d,hideButtons:m,setButtonOnClick:u,setButtonDisabled:x,quantumOwned:h,isView:c})=>{const E=Y.useClient(),[{fetching:p},L]=Y.useMutation(b.CREATE_ACTION),[{fetching:j},v]=Y.useMutation(b.UPDATE_ACTION),[{data:C}]=Y.useQuery({query:b.GET_ACTION_BY_ID,variables:{id:o??""},pause:!o}),r=P.getFragmentData(b.ACTION_FRAGMENT,C?.getActionById),R=p||j,T=!!r&&!!o,{getLabel:f}=ne.useUiLabelContext(),M=n.useMemo(()=>({action:f("action")}),[f]),k=n.useMemo(()=>[{key:"module_category",label:"Link Category",multi:!0},{key:"activity_type",label:`${M.action} Type`,multi:!1},{key:"session_type",label:"Session Type",multi:!0},{key:"body_region",label:"Body Region",multi:!0},{key:"sport",label:"Sport",multi:!0}],[M.action]),[I,z]=n.useState(""),[N,O]=n.useState(""),[w,ee]=n.useState(""),[J,g]=n.useState(""),[A,y]=n.useState([]),[_,V]=n.useState([]),[K,G]=n.useState({}),a=n.useMemo(()=>A.map(F=>F.value),[A]),i=ne.usePartOptionsForSensorLocations(a),[S,$]=n.useState([]),B=I.length>0,[q,U]=n.useState({});n.useEffect(()=>{const F=k.map(H=>E.query(b.GET_METADATA_BY_KEY,{key:H.key}));Promise.all(F).then(H=>{const Q={};H.forEach(Z=>{if(Z.error||!Z.data)return;const te=P.getFragmentData(b.METADATA_GROUP_FRAGMENT,Z.data.getMetadataByKey),je=P.getFragmentData(b.METADATA_ITEM_FRAGMENT,te.data);Q[te.key]=je.map(ie=>({label:ie.label||ie.value,value:ie.value,id:ie.id}))}),G(Q)})},[E,k]),n.useEffect(()=>{if(r){const H=P.getFragmentData(b.METADATA_GROUP_FRAGMENT,r.metadataGroups).map(Z=>Z.data.map(te=>P.getFragmentData(b.METADATA_ITEM_FRAGMENT,te).id)),Q={name:r.name,description:r.description||"",cameraPlacement:r.cameraPlacement||"",videoLink:r.videoLink||"",sensorLocations:r.sensorLocations.map(Z=>({label:Ce(Z),value:Z})),thresholds:ue.thresholdsToParameters(r.thresholds),metadataIds:H.flat()};z(Q.name),O(Q.description),ee(Q.cameraPlacement),g(Q.videoLink),y(Q.sensorLocations),$(Q.thresholds),V(Q.metadataIds),U(Q)}},[r]);const X=n.useMemo(()=>JSON.stringify(q)!==JSON.stringify({name:I,description:N,cameraPlacement:w,videoLink:J,sensorLocations:a,thresholds:ue.parametersToThresholds(S),metadataIds:_}),[q,I,a,N,w,J,_,S]),W=n.useCallback(()=>{const F={name:I,description:N,cameraPlacement:w,videoLink:J,sensorLocations:a,thresholds:ue.parametersToThresholds(S),metadataItemIds:_,laterality:D.ActionLaterality.Either,quantumOwned:h,sessionType:[]};let H;T&&o?H=v({id:o,fields:F}):H=L({fields:F}),H.then(({error:Q})=>{Q?s(Q):d()})},[h,L,v,o,I,a,N,w,J,_,T,S,d,s]);n.useEffect(()=>{x&&x({cancelButton:R,saveButton:c?!0:R||!B||!X})},[R,x,B,X,c]),n.useEffect(()=>{u&&u({cancelButton:l,saveButton:c?()=>{}:W})},[u,l,W,c]);const ce=(F,H)=>{const Q=k.find(te=>te.key===F);if(!Q)return;const Z=Q.multi?(H??[]).map(te=>te.id):H?[H.id]:[];V(te=>[...te.filter(ie=>Object.values(K).flat().find(de=>de.id===ie)&&!Object.keys(K).find(de=>K[de]?.some(be=>be.id===ie&&de===F))),...Z])};return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-4 w-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"col-span-2 lg:col-span-1 flex flex-col gap-4",children:[e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Name"}),e.jsxRuntimeExports.jsx(t.Input,{value:I,onChange:F=>z(F.target.value),type:"text",placeholder:"i.e. Lunge & Return",isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Camera Placement"}),e.jsxRuntimeExports.jsx(t.Textarea,{value:w,onChange:F=>ee(F.target.value),rows:2,placeholder:"(optional) Describe camera setup, placement, angles",isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Video Link"}),e.jsxRuntimeExports.jsx(t.Input,{value:J,onChange:F=>g(F.target.value),type:"url",placeholder:"(optional) https://...",isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Description"}),e.jsxRuntimeExports.jsx(t.Textarea,{value:N,onChange:F=>O(F.target.value),rows:2,placeholder:"(optional) Describe how to perform the test or exercise",isDisabled:c})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(re,{children:"Metadata Tags"}),k.map(F=>e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:F.label}),e.jsxRuntimeExports.jsx(oe.st,{isMulti:F.multi,value:K[F.key]?.filter(H=>_.includes(H.id)),onChange:H=>{ce(F.key,H)},options:K[F.key],placeholder:`Select ${F.multi?"one or more":"one"} ${F.label.toLowerCase()}`,isDisabled:c,isClearable:F.multi})]},F.key))]})]}),e.jsxRuntimeExports.jsxs("div",{className:"col-span-2 lg:col-span-1 flex flex-col gap-4",children:[e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Sensor Locations"}),e.jsxRuntimeExports.jsx(oe.st,{isMulti:!0,value:A,onChange:F=>y([...F]),options:qe,isOptionDisabled:()=>A.length>=Ue,isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Default Parameters"}),e.jsxRuntimeExports.jsx(fe,{options:i,value:S,onChange:$,editOnly:c})]})]}),e.jsxRuntimeExports.jsx("div",{className:ue.cn("col-span-2 flex justify-end",(m||c)&&"hidden"),children:e.jsxRuntimeExports.jsxs(t.ButtonGroup,{mt:16,gap:4,children:[e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:R,onClick:l,children:"Cancel"}),e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"blue",isDisabled:R||!B||!X,isLoading:R,onClick:W,children:"Save changes"})]})})]})},re=({children:o})=>e.jsxRuntimeExports.jsx(t.FormLabel,{fontWeight:"bold",fontFamily:"sans-serif",fontSize:"large",children:o}),We=({id:o,onCancel:s,onSave:l,onError:d,hideButtons:m,quantumOwned:u,setButtonOnClick:x,setButtonDisabled:h})=>{const[{data:c}]=Y.useQuery({query:u?b.GET_QUANTUM_OWNED_ACTIONS:b.GET_ACTIONS}),[{data:E}]=Y.useQuery({query:b.GET_MODULE_BY_ID,variables:{id:o},pause:!o}),[{data:p}]=Y.useQuery({query:b.GET_ALL_MODULE_CATEGORIES}),L=P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,p?.moduleCategories),[{fetching:j},v]=Y.useMutation(b.UPDATE_MODULE),[{fetching:C},r]=Y.useMutation(b.CREATE_MODULE),R=P.getFragmentData(b.ACTION_FRAGMENT,u?c?.quantumOwnedActions:c?.actions)??[],T=P.getFragmentData(b.ACTION_MODULE_FRAGMENT,E?.module),f=P.getFragmentData(b.MODULE_ACTION_FRAGMENT,T?.moduleActions)??[],[M,k]=n.useState([...f.map(g=>g.actionId)??[]]),[I,z]=n.useState(T?.name??""),[N,O]=n.useState([]),[w,ee]=n.useState(T?.description??"");n.useEffect(()=>{T&&(k(f.map(g=>g.actionId)),z(T.name),ee(T.description??""),O(T.categories.map(g=>P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,g).id)??[]))},[T,f]);const J=n.useCallback(()=>{let g;const A={actions:M,name:I,categories:N.filter(y=>y!=="other"),description:w,quantumOwned:u};T?g=v({id:T.id,input:A}):g=r({input:A}),g.then(({error:y})=>{y?d(y):l()})},[r,v,M,I,w,N,T,l,d,u]);return n.useEffect(()=>{h&&h({cancelButton:j||C,saveButton:j||C||!I||w.trim().split(/\s+/).filter(Boolean).length>40})},[h,j,C,M,I,w]),n.useEffect(()=>{x&&x({cancelButton:s,saveButton:J})},[x,s,J]),e.jsxRuntimeExports.jsxs(t.Box,{width:"100%",children:[e.jsxRuntimeExports.jsx(Ee,{name:I,setName:z,actions:R,selectedActionIds:M,setSelectedActionIds:k,availableCategories:L??[],selectedCategoryIds:N,setSelectedCategoryIds:O,description:w,setDescription:ee}),!m&&e.jsxRuntimeExports.jsx(t.HStack,{justifyContent:"flex-start",children:e.jsxRuntimeExports.jsxs(t.ButtonGroup,{mt:16,gap:4,children:[e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:j||C,onClick:s,children:"Cancel"}),e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"blue",isDisabled:j||C||!I||w.trim().split(/\s+/).filter(Boolean).length>40,isLoading:j||C,onClick:J,children:"Save"})]})})]})};exports.ActivityList=ge;exports.CopyActivityForm=ke;exports.CopyModuleForm=De;exports.ModuleForm=Ee;exports.ParameterEditList=Re;exports.ParameterEditSelect=fe;exports.UpsertActivityForm=Qe;exports.UpsertModuleForm=We;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./react-jsx-runtime-vendor-Dszzpdy0.cjs"),t=require("@chakra-ui/react"),n=require("react"),Y=require("urql"),ge=require("./utils-cn-FIKrq5Mb.cjs");require("./moment-vendor-1cRqq0AH.cjs");const ne=require("./hooks.cjs"),ye=require("./ufuzzy-vendor-7qHa_k39.cjs"),me=require("./react-icons-vendor-BF_sZq07.cjs"),oe=require("./react-select-vendor-BeWvSe2q.cjs"),P=require("./generated.cjs"),b=require("./graphql-Ce2MNCsk.cjs"),pe=require("./react-dnd-vendor-PwwXhPmK.cjs"),D=require("./generated-graphql.cjs"),ae=require("./services-human-CnvSTmoF.cjs"),le=require("./types.cjs"),je=require("./utils-parameters-dwKmz1VU.cjs"),Se=({setSearch:o,actions:s,updateUseCases:l,hideUseCaseFilter:d=!1})=>{const m=n.useMemo(()=>s?.flatMap(u=>u.useCases).filter((u,x,h)=>h.findIndex(c=>c.id===u.id)===x).map(u=>({label:u.name,value:u.id}))||[],[s]);return e.jsxRuntimeExports.jsxs(t.Flex,{width:"100%",alignContent:"space-evenly",gap:4,children:[e.jsxRuntimeExports.jsxs(t.InputGroup,{size:"md",flex:1,children:[e.jsxRuntimeExports.jsx(t.InputLeftElement,{children:e.jsxRuntimeExports.jsx(t.Icon,{as:me.FaSearch,color:"gray.300"})}),e.jsxRuntimeExports.jsx(t.Input,{placeholder:"Search by name...",width:"100%",maxW:d?void 0:"30rem",onChange:u=>o(u.target.value)})]}),!d&&e.jsxRuntimeExports.jsx(t.InputGroup,{size:"md",children:e.jsxRuntimeExports.jsx(oe.st,{size:"md",chakraStyles:{container:u=>({...u,width:"100%"})},menuPortalTarget:document.body,placeholder:"Filter use case",isMulti:!0,options:m,onChange:u=>l(u.map(x=>x.value))})})]})},se=({children:o})=>e.jsxRuntimeExports.jsx(t.FormLabel,{fontWeight:"bold",fontFamily:"sans-serif",fontSize:"large",children:o}),ve=({value:o,onChange:s})=>{const l=n.useState(()=>Math.random().toString(36).substring(2,15))[0],d=n.useCallback((m,u)=>{s(x=>{const h=[...x],[c]=h.splice(m,1);return h.splice(u,0,c),h})},[s]);return e.jsxRuntimeExports.jsx(t.Box,{children:e.jsxRuntimeExports.jsx(pe.DndProvider,{backend:pe.HTML5Backend,children:e.jsxRuntimeExports.jsx(t.TableContainer,{children:e.jsxRuntimeExports.jsxs(t.Table,{variant:"simple",size:"md",children:[e.jsxRuntimeExports.jsx(t.Thead,{children:e.jsxRuntimeExports.jsxs(t.Tr,{children:[e.jsxRuntimeExports.jsx(t.Th,{children:"Order"}),e.jsxRuntimeExports.jsx(t.Th,{children:"Name"})]})}),e.jsxRuntimeExports.jsx(t.Tbody,{children:o.map((m,u)=>e.jsxRuntimeExports.jsx(Me,{listKey:l,index:u,id:m.id,name:m.name,move:d},m.id))})]})})})})},Me=({listKey:o,index:s,id:l,name:d,move:m})=>{const u=n.useRef(null),[{handlerId:x},h]=pe.useDrop({accept:o,collect:j=>({handlerId:j.getHandlerId()?.toString()??""}),hover:(j,v)=>{if(!u.current)return;const C=j.index,r=s;if(C===r)return;const R=u.current?.getBoundingClientRect(),T=(R.bottom-R.top)/2,M=v.getClientOffset().y-R.top;C<r&&M<T||C>r&&M>T||(m(C,r),j.index=r)}}),[{isDragging:c},E]=pe.useDrag({type:o,item:()=>({id:l,index:s}),collect:j=>({isDragging:j.isDragging()})}),p=c?.6:1,L=c?"grabbing":"grab";return E(h(u)),e.jsxRuntimeExports.jsxs(t.Tr,{ref:u,style:{opacity:p,cursor:L},"data-handler-id":x,children:[e.jsxRuntimeExports.jsx(t.Td,{children:s+1}),e.jsxRuntimeExports.jsx(t.Td,{children:d})]})},we=({items:o,onChange:s,selectedItem:l,isDisabled:d,selectedProps:m,buttonProps:u})=>{const x=c=>c===l||c.value===l,h=c=>x(c)?{...u,...m}:u;return e.jsxRuntimeExports.jsx(t.ButtonGroup,{isAttached:!0,isDisabled:d,children:o.map((c,E)=>e.jsxRuntimeExports.jsx(t.Tooltip,{label:c.tooltip,openDelay:50,closeDelay:200,placement:"top",visibility:c.tooltip?"visible":"hidden",hasArrow:!0,children:e.jsxRuntimeExports.jsx(t.Button,{onClick:()=>x(c)?null:s(c,E),isDisabled:c.disabled,...h(c),children:c.label})},E))})},de=(o,s)=>s<0?-1*Math.abs(o):Math.abs(o),Le=({isReversed:o,min:s,max:l,value:d,onChange:m,inputProps:u,size:x,zeroMarker:h,formatValue:c,valueLabel:E,positiveNegativeLabels:p,isDisabled:L,...j})=>{const[v,C]=n.useState([void 0,void 0]),r=v[0],R=v[1],T=h&&s<-5&&l>5,f=Number(d?.[0]??R??s)>0?1:-1,M=Number(d?.[1]??R??l)<0?-1:1,k=p?.[0]===p?.[1],I=d?.[0],z=d?.[1];n.useEffect(()=>{I!==void 0&&z!==void 0&&C([I.toFixed(0),z.toFixed(0)])},[I,z,C]);const N=n.useCallback(([y,_])=>{y<_&&C([y.toFixed(0),_.toFixed(0)])},[C]),O=n.useCallback(([y,_])=>{y<_&&m([y,_])},[m]),w=n.useCallback(()=>{C(([y,_])=>{const V=isNaN(Number(y))?s:Number(y),K=isNaN(Number(_))?l:Number(_),G=de(Number(V),f),a=de(Number(K),M),i=f<0?Math.max(G,s):Math.min(G,l),S=M<0?Math.max(a,s):Math.min(a,l);return i>S?(m([S,i]),[S.toFixed(0),i.toFixed(0)]):(m([i,S]),[i.toFixed(0),S.toFixed(0)])})},[m,C,f,M,s,l]),ee=n.useCallback(y=>{const _=y===""||isNaN(Number(y))?y:de(Number(y),f);C(([V,K])=>[_.toString(),K])},[C,f]),J=n.useCallback(y=>{const _=y===""||isNaN(Number(y))?y:de(Number(y),M);C(([V,K])=>[V,_.toString()])},[C,M]),g=n.useMemo(()=>x==="xs"?"0.75rem":void 0,[x]),A=n.useCallback((y,_)=>{const V=Number(_.target.value);if(!r||!R||![-1,1].includes(V))return;const K=i=>V<0?-1*Math.abs(i):Math.abs(i),G=y?K(Number(r)):Number(r),a=y?Number(R):K(Number(R));G>a?m([a,G]):m([G,a])},[r,R,m]);return e.jsxRuntimeExports.jsxs(t.Flex,{direction:"column",...j,children:[e.jsxRuntimeExports.jsx(t.Box,{pt:"1em",mb:"-0.5em",children:e.jsxRuntimeExports.jsxs(t.RangeSlider,{"aria-label":["min","max"],isReversed:o,value:[Number(r??s),Number(R??l)],max:l,min:s,minStepsBetweenThumbs:3,step:1,onChange:N,onChangeEnd:O,isDisabled:L,children:[e.jsxRuntimeExports.jsx(t.RangeSliderMark,{value:s,top:"-1em",children:e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:c?c?.(s):s})}),e.jsxRuntimeExports.jsx(t.RangeSliderMark,{value:l,top:"-1em",children:e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",style:{transform:"translateX(-100%)"},whiteSpace:"nowrap",children:c?c(l):l})}),T&&e.jsxRuntimeExports.jsxs(t.RangeSliderMark,{value:0,top:"-1em",pos:"relative",children:[e.jsxRuntimeExports.jsx(t.Text,{fontSize:x,fontWeight:"semibold",children:c?.(0)??"0"}),e.jsxRuntimeExports.jsx(t.Box,{position:"absolute",width:"2px",height:"1em",top:"90%",left:"20%",backgroundColor:"var(--chakra-colors-gray-300)"})]}),e.jsxRuntimeExports.jsx(t.RangeSliderTrack,{children:e.jsxRuntimeExports.jsx(t.RangeSliderFilledTrack,{})}),e.jsxRuntimeExports.jsx(t.RangeSliderThumb,{index:0,w:g,h:g}),e.jsxRuntimeExports.jsx(t.RangeSliderThumb,{index:1,w:g,h:g})]})}),E&&e.jsxRuntimeExports.jsxs(t.Flex,{direction:o?"row-reverse":"row",justifyContent:"space-between",children:[e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:E(s)}),e.jsxRuntimeExports.jsx(t.Text,{fontSize:x??"sm",fontWeight:"semibold",whiteSpace:"nowrap",children:E(l)})]}),e.jsxRuntimeExports.jsxs(t.Flex,{direction:o?"row-reverse":"row",justifyContent:"center",alignItems:"center",gap:"0.125em",children:[p&&e.jsxRuntimeExports.jsxs(t.Select,{width:"auto",size:x,fontWeight:"bold",value:f,onChange:y=>A(!0,y),isDisabled:k||L,children:[e.jsxRuntimeExports.jsx("option",{value:-1,children:p[0]}),e.jsxRuntimeExports.jsx("option",{value:1,children:p[1]})]}),e.jsxRuntimeExports.jsx(t.NumberInput,{precision:0,size:x??"sm",min:0,max:f<0?Math.abs(s):z??l,value:r===""?"":Math.abs(Number(r??s)),onChange:ee,onBlur:w,borderWidth:1,borderRadius:3,borderColor:"#ccc",isDisabled:L,...u,children:e.jsxRuntimeExports.jsx(t.NumberInputField,{backgroundColor:"#fff",paddingRight:0,width:"4em"})}),e.jsxRuntimeExports.jsx(t.NumberInput,{size:x??"sm",min:0,max:M<0?Math.abs(I??s):l,precision:0,value:R===""?"":Math.abs(Number(R??l)),onChange:J,onBlur:w,borderWidth:1,borderRadius:3,borderColor:"#ccc",isDisabled:L,...u,children:e.jsxRuntimeExports.jsx(t.NumberInputField,{backgroundColor:"#fff",paddingRight:0,width:"4em"})}),p&&e.jsxRuntimeExports.jsxs(t.Select,{width:"auto",size:x,fontWeight:"bold",value:M,onChange:y=>A(!1,y),isDisabled:k||L,children:[e.jsxRuntimeExports.jsx("option",{value:-1,children:p[0]}),e.jsxRuntimeExports.jsx("option",{value:1,children:p[1]})]})]})]})},Ae=({tags:o,containerProps:s,...l})=>e.jsxRuntimeExports.jsx(t.HStack,{...s,children:o.map((d,m)=>e.jsxRuntimeExports.jsx(t.Tag,{...l,children:d},m))}),Fe=new ye.uFuzzy({}),Ie=({action:o,quantumIconSrc:s})=>{const{getLabel:l}=ne.useUiLabelContext(),d=n.useMemo(()=>({actionLowerCase:l("action").toLocaleLowerCase()}),[l]);return o.quantumOwned?e.jsxRuntimeExports.jsx(t.Tooltip,{label:`This ${d.actionLowerCase} is owned by Quantum`,"aria-label":"Quantum owned",children:e.jsxRuntimeExports.jsx(t.Box,{boxSize:"1.5em",borderRadius:"full",bg:"black",display:"flex",alignItems:"center",justifyContent:"center",children:e.jsxRuntimeExports.jsx(t.Image,{src:s,boxSize:"1em",alt:`Quantum-owned ${d.actionLowerCase}`})})}):null},Ne=(o,s)=>{if(!s||!s.trim().length)return o;const l=o.map(m=>m.name??"");return Fe.filter(l,s)?.map(m=>o[m])??[]},Oe=o=>!o||o.length===0?"None":o.map(s=>s.replace(/([A-Z])/g," $1").trim()).join(", "),ke=(o,s)=>!s||s.length==0?o:o.filter(l=>l.useCases?.some(d=>s.includes(d.id))??!1),Ee=({actions:o,totalActions:s,onCreate:l,onDelete:d,onEdit:m,onView:u,onSelected:x,onDuplicate:h,disableMultiSelect:c,disableDelete:E,disableEdit:p,disableCreate:L,hideUseCase:j=!0,tableProps:v,containerProps:C,quantumIconSrc:r="/favicon.ico"})=>{const[R,T]=n.useState(""),[f,M]=n.useState(),{getLabel:k}=ne.useUiLabelContext(),I=n.useMemo(()=>({action:k("action"),actionPlural:k("action_plural"),actionLowerCase:k("action").toLocaleLowerCase(),actionPluralLowerCase:k("action_plural").toLocaleLowerCase()}),[k]),z=n.useMemo(()=>{if(!o)return;const g=Ne(o,R);return j?g:ke(g,f)},[o,R,f,j]),N=n.useCallback(()=>{if(!d)return;const A=o.filter(y=>y.selected&&!y.quantumOwned).map(y=>y.id);d(A)},[o,d]),O=n.useCallback(()=>{if(!h)return;const g=o.filter(A=>A.selected);h(g.map(A=>A.id)),x&&g.forEach(A=>x(A,!1))},[o,h,x]),w=n.useMemo(()=>o.some(g=>g.selected&&!g.quantumOwned),[o]),ee=n.useMemo(()=>o.some(g=>g.selected),[o]),J=n.useMemo(()=>o.some(g=>g.selected&&g.quantumOwned),[o]);return e.jsxRuntimeExports.jsxs(t.Box,{...C,children:[e.jsxRuntimeExports.jsxs(t.Flex,{alignContent:"space-between",gap:4,children:[(l||d||h)&&e.jsxRuntimeExports.jsxs(t.ButtonGroup,{mb:"1rem",gap:4,children:[l&&e.jsxRuntimeExports.jsxs(t.Button,{isDisabled:!l||L,colorScheme:"blackAlpha",backgroundColor:"gray.700",onClick:l,children:["Create New ",I.action]}),d&&!c&&e.jsxRuntimeExports.jsx(t.Tooltip,{label:J?w?`Quantum-owned ${I.actionPluralLowerCase} are selected and will be skipped`:`Selected ${I.actionPluralLowerCase} are quantum-owned and cannot be deleted`:void 0,shouldWrapChildren:!0,children:e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:!w||!d||E,onClick:N,children:"Delete Selected"})}),h&&!c&&e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:!ee,onClick:O,children:"Duplicate Selected"})]}),e.jsxRuntimeExports.jsx(Se,{setSearch:T,actions:o,updateUseCases:M,hideUseCaseFilter:j})]}),e.jsxRuntimeExports.jsx(t.TableContainer,{mr:"2rem",overflowX:"hidden",...v,children:e.jsxRuntimeExports.jsxs(t.Table,{size:"md",variant:"simple",children:[e.jsxRuntimeExports.jsx(t.Thead,{position:"sticky",top:0,bg:"white",zIndex:1,children:e.jsxRuntimeExports.jsxs(t.Tr,{children:[e.jsxRuntimeExports.jsxs(t.Th,{fontWeight:"normal",children:["(showing ",z?.length??0," of"," ",s??o.length,")"]}),e.jsxRuntimeExports.jsx(t.Th,{children:"Name"}),e.jsxRuntimeExports.jsx(t.Th,{children:"Sensor Locations"}),!j&&e.jsxRuntimeExports.jsx(t.Th,{children:"Use Case"}),e.jsxRuntimeExports.jsx(t.Th,{})]})}),e.jsxRuntimeExports.jsx(t.Tbody,{children:z?.map(g=>e.jsxRuntimeExports.jsxs(t.Tr,{className:ge.cn("hover:bg-[#f7f7f7]",!c&&"cursor-pointer",g.selected&&"bg-gray-200"),onClick:()=>{c||x?.(g,!g.selected)},children:[e.jsxRuntimeExports.jsx(t.Td,{children:e.jsxRuntimeExports.jsxs(t.Flex,{children:[!c&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:g.selected?e.jsxRuntimeExports.jsx(me.FaCheckSquare,{className:"text-blue-500"}):e.jsxRuntimeExports.jsx(me.FaSquare,{className:"text-gray-400"})}),(g.quantumOwned||!m)&&u&&e.jsxRuntimeExports.jsx(t.Button,{ml:"1em",size:"sm",variant:"link",colorScheme:"blue",onClick:A=>{A.stopPropagation(),u(g.id)},children:"View"}),!g.quantumOwned&&m&&e.jsxRuntimeExports.jsx(t.Button,{isDisabled:p,ml:"1em",size:"sm",variant:"link",colorScheme:"blue",onClick:A=>{A.stopPropagation(),m(g.id)},children:"Edit"})]})}),e.jsxRuntimeExports.jsx(t.Td,{whiteSpace:"break-spaces",children:e.jsxRuntimeExports.jsxs(t.Flex,{align:"center",gap:2,children:[e.jsxRuntimeExports.jsx(Ie,{action:g,quantumIconSrc:r}),g.name]})}),e.jsxRuntimeExports.jsx(t.Td,{maxW:"20rem",whiteSpace:"break-spaces",children:Oe(g.sensorLocations)}),!j&&e.jsxRuntimeExports.jsx(t.Td,{maxW:"20rem",children:e.jsxRuntimeExports.jsx(Ae,{containerProps:{flexWrap:"wrap"},tags:g.useCases?.map(A=>A.name)??[]})})]},g.id))})]})})]})},De=({onSave:o,onCancel:s,onError:l,hideButtons:d=!1,setButtonDisabled:m,setButtonOnClick:u,quantumOwned:x})=>{const h=t.useToast(),{getLabel:c}=ne.useUiLabelContext(),E=n.useMemo(()=>({singular:c("action"),plural:c("action_plural"),pluralLowerCase:c("action_plural").toLowerCase(),singularLowerCase:c("action").toLowerCase()}),[c]),[p,L]=n.useState("copy"),[j,v]=n.useState(""),[C,r]=n.useState([]),[R,T]=n.useState(!1),[f]=Y.useQuery({query:b.GET_GROUPS}),[M]=Y.useQuery({query:b.GET_ACTIONS_BY_GROUP,variables:{groupId:j},pause:!j}),[,k]=Y.useMutation(b.CREATE_ACTION),[,I]=Y.useMutation(b.CONVERT_ACTION_TO_QUANTUM_OWNED),z=n.useMemo(()=>f.data?.groups?f.data.groups.map(a=>P.getFragmentData(b.GROUP_FRAGMENT,a)):[],[f.data]),N=n.useMemo(()=>M.data?M.data.actions.map(i=>P.getFragmentData(b.ACTION_FRAGMENT,i)):[],[M.data]),O=n.useMemo(()=>N.filter(a=>C.includes(a.id)),[N,C]),w=n.useCallback(a=>{const i=a?.value||"";v(i),r([])},[]),ee=n.useCallback(a=>{const i=a.map(S=>S.value);r(i)},[]),J=n.useCallback(async a=>{const i=P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,a.categories),$=P.getFragmentData(b.METADATA_GROUP_FRAGMENT,a.metadataGroups).flatMap(U=>U.data.map(X=>P.getFragmentData(b.METADATA_ITEM_FRAGMENT,X).id)),B={...a,name:`${a.name} (Copy)`,description:a.description||void 0,instructionsPointOfInterest:a.instructionsPointOfInterest||void 0,instructionsMovementReport:a.instructionsMovementReport||void 0,laterality:a.laterality,activityKind:a.activityKind,sensorLocations:a.sensorLocations,thresholds:a.thresholds.map(U=>({...U,id:void 0})),categories:i?.map(U=>U.id),quantumOwned:x,metadataItemIds:$,id:void 0},q=await k({fields:B});if(q.error)throw new Error(q.error.message);if(q.data?.createAction)return P.getFragmentData(b.ACTION_FRAGMENT,q.data.createAction);throw new Error("No action data returned")},[k,x]),g=n.useCallback(async a=>{const i=await I({id:a.id});if(i.error)throw new Error(i.error.message);if(i.data?.convertActionToQuantumOwned)return P.getFragmentData(b.ACTION_FRAGMENT,i.data.convertActionToQuantumOwned);throw new Error("No action data returned")},[I]),A=n.useCallback(async()=>{if(T(!0),!O.length){const a=new Error(`No ${E.pluralLowerCase} selected for ${p==="copy"?"copying":"converting"}`);l?.(a),T(!1);return}try{const a=[];let i=0;const S=p==="copy"?J:g,$=p==="copy"?"copy":"convert";for(const B of O)try{const q=await S(B);a.push(q)}catch(q){console.error(`Failed to ${$} ${E.singularLowerCase} "${B.name}":`,q),i++}if(a.length>0){const B=a.length,q=O.length,U=p==="copy"?"copied":"converted",X=p==="copy"?"copy":"convert";h({title:i>0?`Partial ${X} completed`:`${E.plural} ${U} successfully`,description:i>0?`${B} of ${q} ${E.pluralLowerCase} ${U} successfully`:`${B} ${B>1?E.pluralLowerCase:E.singularLowerCase} ${U} successfully`,status:i>0?"warning":"success",duration:3e3,isClosable:!0}),o?.(),v(""),r([])}else throw new Error(`Failed to ${$} any ${E.pluralLowerCase}`)}catch(a){const i=p==="copy"?"copy":"convert",S=a instanceof Error?a.message:`Failed to ${i} ${E.pluralLowerCase}`;h({title:`${p==="copy"?"Copy":"Convert"} failed`,description:S,status:"error",duration:5e3,isClosable:!0}),l?.(a instanceof Error?a:new Error(S))}finally{T(!1)}},[O,p,J,g,h,o,l]),y=n.useCallback(()=>{v(""),r([]),L("copy"),s?.()},[s]);n.useEffect(()=>{m&&m({cancelButton:!1,saveButton:O.length===0||R})},[O.length,R,m]),n.useEffect(()=>{u&&u({cancelButton:y,saveButton:A})},[u,y,A]);const _=n.useMemo(()=>z.map(a=>({value:a.id,label:a.name})),[z]),V=n.useMemo(()=>N.filter(a=>p==="copy"?!0:!a.quantumOwned).map(a=>({value:a.id,label:a.name,isQuantumOwned:a.quantumOwned})),[N,p]),K=f.fetching,G=M.fetching;return e.jsxRuntimeExports.jsx(t.Box,{children:e.jsxRuntimeExports.jsxs(t.VStack,{spacing:6,align:"stretch",children:[x&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Operation Mode"}),e.jsxRuntimeExports.jsx(t.RadioGroup,{value:p,onChange:a=>{L(a),r([])},children:e.jsxRuntimeExports.jsxs(t.HStack,{spacing:6,children:[e.jsxRuntimeExports.jsx(t.Radio,{value:"copy",colorScheme:"blue",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",children:["Copy ",E.plural]}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Create new ",E.plural.toLocaleLowerCase()," ","based on selected ones"]})]})}),e.jsxRuntimeExports.jsx(t.Radio,{value:"convert",colorScheme:"green",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",children:["Convert to Quantum Owned ",E.singular]}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Convert existing"," ",E.plural.toLocaleLowerCase()," to quantum-owned"]})]})})]})})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Select Source Group"}),e.jsxRuntimeExports.jsx(oe.st,{placeholder:"Choose a group...",options:_,value:_.find(a=>a.value===j)||null,onChange:w,isLoading:K,isDisabled:K,isClearable:!0}),f.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load groups: ",f.error.message]})]})]}),j&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsxs(se,{children:["Select ",E.plural," to"," ",p==="copy"?"Copy":"Convert"]}),G?e.jsxRuntimeExports.jsxs(t.HStack,{children:[e.jsxRuntimeExports.jsx(t.Spinner,{size:"sm"}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Loading ",E.pluralLowerCase,"..."]})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(oe.st,{placeholder:`Choose ${E.pluralLowerCase} to ${p}...`,options:V,value:V.filter(a=>C.includes(a.value)),onChange:ee,isDisabled:V.length===0,isClearable:!0,isMulti:!0,closeMenuOnSelect:!1,formatOptionLabel:(a,{context:i})=>e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",w:"100%",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(t.Text,{children:a.label}),i==="value"&&a.isQuantumOwned&&e.jsxRuntimeExports.jsx(t.Text,{color:"blue",fontSize:"xs",children:"(Quantum Owned)"})]}),a.isQuantumOwned&&i==="menu"&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]})}),V.length===0&&e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.500",mt:2,children:["No ",E.pluralLowerCase," found"]})]}),M.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load ",E.pluralLowerCase,":"," ",M.error.message]})]})]}),O.length>0&&e.jsxRuntimeExports.jsxs(t.Box,{p:4,bg:"gray.50",borderRadius:"md",children:[e.jsxRuntimeExports.jsx(t.Text,{fontWeight:"semibold",mb:3,children:O.length===1?`${E.singular} to ${p==="copy"?"Copy":"Convert"}:`:`${O.length} ${E.plural} to ${p==="copy"?"Copy":"Convert"}:`}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:3,children:[O.map((a,i)=>e.jsxRuntimeExports.jsxs(t.Box,{w:"100%",p:3,bg:"white",borderRadius:"md",border:"1px solid",borderColor:"gray.200",children:[e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",align:"start",mb:2,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",fontSize:"sm",children:[i+1,". ",a.name]}),a.quantumOwned&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,fontSize:"sm",color:"gray.600",children:[a.description&&e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Description:"})," ",a.description]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Type:"})," ",a.activityKind]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Laterality:"})," ",a.laterality]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Sensor Locations:"})," ",a.sensorLocations.length]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Thresholds:"})," ",a.thresholds.length]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Use Cases:"})," ",a.useCases.map(S=>S.name).join(", ")||"None"]})]})]},a.id)),O.length>1&&e.jsxRuntimeExports.jsx(t.Box,{w:"100%",p:2,bg:"blue.50",borderRadius:"md",border:"1px solid",borderColor:"blue.200",children:e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",fontWeight:"medium",color:"blue.800",children:["Total: ",O.length," ",E.pluralLowerCase," will be"," ",p==="copy"?"copied":"converted"]})})]})]}),!d&&e.jsxRuntimeExports.jsxs(t.ButtonGroup,{spacing:4,justifyContent:"flex-end",children:[e.jsxRuntimeExports.jsx(t.Button,{variant:"outline",onClick:y,isDisabled:R,children:"Cancel"}),e.jsxRuntimeExports.jsxs(t.Button,{colorScheme:p==="copy"?"blue":"green",onClick:A,isDisabled:O.length===0||R,isLoading:R,loadingText:`${p==="copy"?"Copying":"Converting"}...`,children:[p==="copy"?"Copy":"Convert"," ",O.length===1?E.singular:`${O.length} ${E.plural}`]})]})]})})},_e=({onSave:o,onCancel:s,onError:l,hideButtons:d=!1,setButtonDisabled:m,setButtonOnClick:u,quantumOwned:x})=>{const h=t.useToast(),{getLabel:c}=ne.useUiLabelContext(),[E,p]=n.useState(""),[L,j]=n.useState([]),[v,C]=n.useState(!1),[r,R]=n.useState("copy"),[T]=Y.useQuery({query:b.GET_GROUPS}),[f]=Y.useQuery({query:b.GET_MODULES_BY_GROUP,variables:{groupId:E},pause:!E}),[,M]=Y.useMutation(b.CREATE_MODULE),[,k]=Y.useMutation(b.UPDATE_MODULE),[,I]=Y.useMutation(b.CREATE_ACTION),[,z]=Y.useMutation(b.CONVERT_ACTION_TO_QUANTUM_OWNED),N=n.useMemo(()=>T.data?.groups?T.data.groups.map(i=>P.getFragmentData(b.GROUP_FRAGMENT,i)):[],[T.data]),O=n.useMemo(()=>f.data?.modules?P.getFragmentData(b.ACTION_MODULE_FRAGMENT,f.data?.modules).map(S=>{const $=P.getFragmentData(b.MODULE_ACTION_FRAGMENT,S.moduleActions);return{...S,moduleActions:$.map(B=>({...B,action:P.getFragmentData(b.ACTION_FRAGMENT,B.action)})),categories:P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,S.categories)}}):[],[f.data]),w=n.useMemo(()=>O.filter(i=>L.includes(i.id)),[O,L]),ee=n.useCallback(i=>{const S=i?.value||"";p(S),j([])},[]),J=n.useCallback(i=>{const S=i.map($=>$.value);j(S)},[]),g=n.useCallback(async()=>{if(C(!0),!w.length){C(!1);const i=new Error(`No modules selected for ${r==="convert"?"converting":"copying"}`);l?.(i);return}try{const i=[];let S=0;for(const $ of w)try{let B=$.moduleActions.map(q=>q.actionId);if(x){const q=$.moduleActions.map(W=>W.action),U=async W=>{if(r==="copy"){if(W.quantumOwned)return W;const F=P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,W.categories),H={...W,quantumOwned:!0,thresholds:W.thresholds.map(Z=>({...Z,id:void 0})),categories:F?.map(Z=>Z.id),id:void 0},Q=await I({fields:H});return Q.error||!Q.data?.createAction?null:P.getFragmentData(b.ACTION_FRAGMENT,Q.data.createAction)}if(W.quantumOwned)return W;const ce=await z({id:W.id});return ce.error||!ce.data?.convertActionToQuantumOwned?null:P.getFragmentData(b.ACTION_FRAGMENT,ce.data.convertActionToQuantumOwned)};B=(await Promise.all(q.map(U))).filter(W=>!!W).map(W=>W.id)}if(r==="convert"){const q={name:$.name,description:$.description||void 0,actions:B,categories:$.categories.map(X=>X.id),quantumOwned:!0},U=await k({id:$.id,input:q});if(U.error)throw new Error(U.error.message);if(U.data?.updateModule){const X=P.getFragmentData(b.ACTION_MODULE_FRAGMENT,U.data.updateModule);i.push(X)}}else{const q={name:`${$.name} (Copy)`,description:$.description||void 0,actions:B,categories:$.categories.map(X=>X.id),quantumOwned:x},U=await M({input:q});if(U.error)throw new Error(U.error.message);if(U.data?.createModule){const X=P.getFragmentData(b.ACTION_MODULE_FRAGMENT,U.data.createModule);i.push(X)}}}catch(B){console.error(`Failed to ${r==="convert"?"convert":"copy"} module "${$.name}":`,B),S++}if(i.length>0){const $=i.length,B=w.length;h({title:S>0?`Partial ${r==="convert"?"convert":"copy"} completed`:`Modules ${r==="convert"?"converted":"copied"} successfully`,description:S>0?`${$} of ${B} modules ${r==="convert"?"converted":"copied"} successfully`:`${$} module${$>1?"s":""} ${r==="convert"?"converted":"copied"} successfully`,status:S>0?"warning":"success",duration:3e3,isClosable:!0}),i.length>0&&o?.(),p(""),j([])}else throw new Error(`Failed to ${r==="convert"?"convert":"copy"} any modules`)}catch(i){const S=i instanceof Error?i.message:`Failed to ${r==="convert"?"convert":"copy"} modules`;h({title:r==="convert"?"Convert failed":"Copy failed",description:S,status:"error",duration:5e3,isClosable:!0}),l?.(i instanceof Error?i:new Error(S))}finally{C(!1)}},[w,M,k,h,o,l,x,I,z,r]),A=n.useCallback(()=>{p(""),j([]),R("copy"),s?.()},[s]);n.useEffect(()=>{m&&m({cancelButton:!1,saveButton:w.length===0||v})},[w.length,v,m]),n.useEffect(()=>{u&&u({cancelButton:A,saveButton:g})},[u,A,g]);const y=n.useMemo(()=>N.map(i=>({value:i.id,label:i.name})),[N]),_=n.useMemo(()=>O.filter(i=>r==="copy"?!0:!i.quantumOwned).map(i=>({value:i.id,label:i.name,isQuantumOwned:i.quantumOwned})),[O,r]),V=T.fetching,K=f.fetching,G=n.useMemo(()=>({singular:c("module"),plural:c("module_plural"),pluralLowerCase:c("module_plural").toLowerCase(),singularLowerCase:c("module").toLowerCase()}),[c]),a=n.useMemo(()=>({singular:c("action"),plural:c("action_plural"),pluralLowerCase:c("action_plural").toLowerCase(),singularLowerCase:c("action").toLowerCase()}),[c]);return e.jsxRuntimeExports.jsx(t.Box,{children:e.jsxRuntimeExports.jsxs(t.VStack,{spacing:6,align:"stretch",children:[x&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Operation Mode"}),e.jsxRuntimeExports.jsx(t.RadioGroup,{value:r,onChange:i=>{R(i),j([])},children:e.jsxRuntimeExports.jsxs(t.HStack,{spacing:6,children:[e.jsxRuntimeExports.jsx(t.Radio,{value:"copy",colorScheme:"blue",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",children:["Copy ",G.plural]}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Create new ",G.pluralLowerCase," based on selected ones"]})]})}),e.jsxRuntimeExports.jsx(t.Radio,{value:"convert",colorScheme:"green",children:e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,children:[e.jsxRuntimeExports.jsx(t.Text,{fontWeight:"medium",children:"Convert to Quantum Owned"}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Convert existing ",G.pluralLowerCase," to quantum-owned"]})]})})]})})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:"Select Source Group"}),e.jsxRuntimeExports.jsx(oe.st,{placeholder:"Choose a group...",options:y,value:y.find(i=>i.value===E)||null,onChange:ee,isLoading:V,isDisabled:V,isClearable:!0}),T.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load groups: ",T.error.message]})]})]}),E&&e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(se,{children:r==="convert"?`Select ${G.plural} to Convert`:`Select ${G.plural} to Copy`}),K?e.jsxRuntimeExports.jsxs(t.HStack,{children:[e.jsxRuntimeExports.jsx(t.Spinner,{size:"sm"}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.600",children:["Loading ",G.pluralLowerCase,"..."]})]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(oe.st,{placeholder:r==="convert"?`Choose ${G.pluralLowerCase} to convert...`:`Choose ${G.pluralLowerCase} to copy...`,options:_,value:_.filter(i=>L.includes(i.value)),onChange:J,isDisabled:_.length===0,isClearable:!0,isMulti:!0,closeMenuOnSelect:!1,formatOptionLabel:(i,{context:S})=>e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",w:"100%",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(t.Text,{children:i.label}),S==="value"&&i.isQuantumOwned&&e.jsxRuntimeExports.jsx(t.Text,{color:"blue",fontSize:"xs",children:"(Quantum Owned)"})]}),i.isQuantumOwned&&S==="menu"&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]})}),_.length===0&&e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.500",mt:2,children:["No ",G.pluralLowerCase," found in this group"]})]}),f.error&&e.jsxRuntimeExports.jsxs(t.Alert,{status:"error",mt:2,children:[e.jsxRuntimeExports.jsx(t.AlertIcon,{}),e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",children:["Failed to load ",G.pluralLowerCase,":"," ",f.error.message]})]})]}),w.length>0&&e.jsxRuntimeExports.jsxs(t.Box,{p:4,bg:"gray.50",borderRadius:"md",children:[e.jsxRuntimeExports.jsx(t.Text,{fontWeight:"semibold",mb:3,children:w.length===1?`${G.singular} to ${r==="copy"?"Copy":"Convert"}`:`${w.length} ${G.plural} to ${r==="copy"?"Copy":"Convert"}`}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:3,children:[w.map((i,S)=>e.jsxRuntimeExports.jsxs(t.Box,{w:"100%",p:3,bg:"white",borderRadius:"md",border:"1px solid",borderColor:"gray.200",children:[e.jsxRuntimeExports.jsxs(t.HStack,{justify:"space-between",align:"start",mb:2,children:[e.jsxRuntimeExports.jsxs(t.Text,{fontWeight:"medium",fontSize:"sm",children:[S+1,". ",i.name]}),i.quantumOwned&&e.jsxRuntimeExports.jsx(t.Tag,{size:"sm",colorScheme:"blue",variant:"solid",children:"Quantum Owned"})]}),e.jsxRuntimeExports.jsxs(t.VStack,{align:"start",spacing:1,fontSize:"sm",color:"gray.600",children:[i.description&&e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Description:"})," ",i.description]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Activities:"})," ",i.moduleActions.length]}),e.jsxRuntimeExports.jsxs(t.Text,{children:[e.jsxRuntimeExports.jsx("strong",{children:"Categories:"})," ",i.categories.map($=>$.name).join(", ")||"None"]})]})]},i.id)),w.length>1&&e.jsxRuntimeExports.jsx(t.Box,{w:"100%",p:2,bg:"blue.50",borderRadius:"md",border:"1px solid",borderColor:"blue.200",children:e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",fontWeight:"medium",color:"blue.800",children:["Total: ",w.length," ",G.pluralLowerCase," will be"," ",r==="copy"?"copied":"converted"]})}),x&&w.filter(i=>i.moduleActions.some(S=>!S.action.quantumOwned)).length>0&&e.jsxRuntimeExports.jsx(t.Box,{p:2,bg:"yellow.50",borderRadius:"md",border:"1px solid",borderColor:"yellow.200",children:e.jsxRuntimeExports.jsx(t.Text,{fontSize:"sm",fontWeight:"medium",color:"yellow.800",children:r==="convert"?`Converting ${G.plural} will convert non QM-Owned ${a.plural} to QM-Owned ${a.plural}`:`Copying ${G.plural} with Non QM-Owned ${a.plural} will create corresponding QM-Owned ${a.plural}`})})]})]}),!d&&e.jsxRuntimeExports.jsxs(t.ButtonGroup,{spacing:4,justifyContent:"flex-end",children:[e.jsxRuntimeExports.jsx(t.Button,{variant:"outline",onClick:A,isDisabled:v,children:"Cancel"}),e.jsxRuntimeExports.jsxs(t.Button,{colorScheme:r==="copy"?"blue":"green",onClick:g,isDisabled:w.length===0||v,isLoading:v,loadingText:`${r==="copy"?"Copying":"Converting"}...`,children:[r==="copy"?"Copy":"Convert"," ",w.length===1?G.singular:`${w.length} ${G.plural}`]})]})]})})},Re=({name:o,setName:s,actions:l,selectedActionIds:d,setSelectedActionIds:m,availableCategories:u,selectedCategoryIds:x,setSelectedCategoryIds:h,description:c,setDescription:E,...p})=>{const L=t.useDisclosure(),j=n.useMemo(()=>l.map(f=>({...f,selected:d.includes(f.id)})),[l,d]),v=n.useMemo(()=>l.reduce((f,M)=>(f[M.id]=M,f),{}),[l]),C=n.useMemo(()=>d.map(f=>v[f]),[d,v]),r=n.useCallback((f,M)=>{m(M?[...d,f.id]:d.filter(k=>k!==f.id))},[d,m]),R=n.useCallback(f=>{s(f.target.value)},[s]),T=n.useCallback(f=>{E?.(f.target.value)},[E]);return e.jsxRuntimeExports.jsxs(t.Box,{...p,children:[e.jsxRuntimeExports.jsxs(t.HStack,{gap:"2rem",children:[e.jsxRuntimeExports.jsx(Ge,{name:o??"",onInputChange:R}),e.jsxRuntimeExports.jsx($e,{availableCategories:u,value:x,onChange:h})]}),e.jsxRuntimeExports.jsx(Pe,{description:c??"",onInputChange:T}),e.jsxRuntimeExports.jsx(Be,{value:C,onChange:m,onAdjustActivities:()=>L.onOpen()}),e.jsxRuntimeExports.jsxs(t.Modal,{isOpen:L.isOpen,onClose:L.onClose,size:"6xl",children:[e.jsxRuntimeExports.jsx(t.ModalOverlay,{}),e.jsxRuntimeExports.jsxs(t.ModalContent,{children:[e.jsxRuntimeExports.jsx(t.ModalHeader,{children:"Select Activities"}),e.jsxRuntimeExports.jsx(t.ModalCloseButton,{}),e.jsxRuntimeExports.jsx(t.ModalBody,{children:e.jsxRuntimeExports.jsx(Ee,{actions:j,onSelected:r,disableCreate:!0,disableDelete:!0,tableProps:{height:"28rem",overflowY:"auto"}})}),e.jsxRuntimeExports.jsx(t.ModalFooter,{children:e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"blue",onClick:L.onClose,isDisabled:d.length===0,children:"Done"})})]})]})]})},Ge=n.memo(({name:o,onInputChange:s})=>{const{getLabel:l}=ne.useUiLabelContext(),d=l("module");return e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsxs(se,{children:[d," Name"]}),e.jsxRuntimeExports.jsx(t.Input,{placeholder:"i.e. ACL RTP Test Battery",value:o,onChange:s,isRequired:!0})]})}),$e=n.memo(({availableCategories:o,value:s,onChange:l})=>{const{getLabel:d}=ne.useUiLabelContext(),m=d("module"),u=n.useMemo(()=>[...o,{id:"other",name:"Other"}],[o]),x=n.useMemo(()=>u.map(h=>({value:h.id,label:h.name})),[u]);return e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsxs(se,{children:[m," Category"]}),e.jsxRuntimeExports.jsx(oe.st,{isDisabled:o.length===0,options:x,value:s.length===0?{value:"other",label:"Other"}:u.filter(h=>s.includes(h.id)).map(h=>({value:h.id,label:h.name}))[0],onChange:h=>l(h?[h.value]:[]),placeholder:"Select category"})]})}),Pe=n.memo(({description:o,onInputChange:s})=>e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsx(se,{children:e.jsxRuntimeExports.jsxs("span",{children:["Description",e.jsxRuntimeExports.jsx(t.Text,{fontSize:"sm",color:"gray.500",children:"Briefly describe the objective of this module. Max 40 words."})]})}),e.jsxRuntimeExports.jsx(t.Input,{placeholder:"i.e. Assess readiness to return to play post-ACL reconstruction",value:o,onChange:s})]})),Be=n.memo(({value:o,onChange:s,onAdjustActivities:l})=>{const{getLabel:d}=ne.useUiLabelContext(),m=n.useMemo(()=>({module:d("module"),moduleLowerCase:d("module").toLocaleLowerCase(),action:d("action"),actionPlural:d("action_plural"),actionPluralLowerCase:d("action_plural").toLocaleLowerCase()}),[d]),u=n.useMemo(()=>o.map(x=>({id:x.id,name:x.name})),[o]);return e.jsxRuntimeExports.jsxs(t.FormControl,{mb:4,children:[e.jsxRuntimeExports.jsxs(t.HStack,{justifyContent:"space-between",children:[e.jsxRuntimeExports.jsx(se,{children:e.jsxRuntimeExports.jsxs("span",{children:[m.actionPlural,e.jsxRuntimeExports.jsxs(t.Text,{fontSize:"sm",color:"gray.500",children:["Drag and drop to reorder the ",m.actionPluralLowerCase," in this ",m.moduleLowerCase,"."]})]})}),e.jsxRuntimeExports.jsxs(t.Button,{size:"sm",variant:"solid",colorScheme:"blue",onClick:l,children:["Add / Remove ",m.actionPlural]})]}),u.length===0?e.jsxRuntimeExports.jsx(t.VStack,{children:e.jsxRuntimeExports.jsxs(t.Text,{color:"gray.500",fontSize:"lg",mb:"4rem",mt:"4rem",children:["No ",m.actionPluralLowerCase," selected for this"," ",m.moduleLowerCase,".",e.jsxRuntimeExports.jsxs(t.Button,{ml:"0.5em",size:"sm",variant:"link",colorScheme:"blue",onClick:l,children:["Add ",m.actionPluralLowerCase,"."]})]})}):e.jsxRuntimeExports.jsx(ve,{value:u,onChange:x=>{const h=x(u);s(h.map(c=>c.id))}})]})}),fe=({value:o,onChange:s,forceKind:l,disableRemove:d,disableKind:m,isDisabled:u,lockRanges:x,...h})=>{const c=n.useMemo(()=>[...o].sort((j,v)=>{const C=le.availablePlanes.indexOf(j.plane),r=le.availablePlanes.indexOf(v.plane);return C-r}),[o]),E=n.useCallback(j=>"segment"in j.id?ae.getSegmentNameWithPlane(j.id.segment,j.plane,!0)??"Unknown":ae.getJointNameWithPlane(j.id.joint,j.plane,!0)??"Unknown",[]),p=n.useCallback((j,v)=>{const C=c.findIndex(R=>R.id===v.id&&R.plane===v.plane);let r=[...c];l&&(v={...v,kind:l}),r[C]=v,x&&(r=r.map(R=>({...R,min:v.min,max:v.max}))),s(r)},[s,c,l,x]),L=n.useCallback(j=>{const v=c.filter(C=>C.id!==j.id||C.plane!==j.plane);s(v)},[s,c]);return e.jsxRuntimeExports.jsx(t.VStack,{alignItems:"flex-start",overflowY:"auto",...h,children:c.map((j,v)=>e.jsxRuntimeExports.jsx(Ue,{label:E(j),parameter:j,onChange:C=>p(v,C),onRemove:d||u?void 0:()=>L(j),forceKind:l,disableKind:m||u,isDisabled:u},`${JSON.stringify(j.id)}-${j.plane}`))})},Ue=({label:o,parameter:s,onChange:l,onRemove:d,forceKind:m,disableKind:u,isDisabled:x})=>{const h=n.useCallback(p=>"joint"in s.id?ae.getJointAngleDirectionName(s.id.joint,s.plane,p<0?-1:1):ae.getSegmentAngleDirectionName(s.id.segment,s.plane,p<0?-1:1),[s]),{min:c,max:E}="joint"in s.id?ae.getNormativeJointRange(s.id.joint,s.plane):{min:-180,max:180};return e.jsxRuntimeExports.jsxs(t.VStack,{borderRadius:"md",p:2,px:4,bg:"gray.100",w:"100%",overflow:"hidden",flexShrink:"0",children:[e.jsxRuntimeExports.jsxs(t.HStack,{w:"100%",children:[e.jsxRuntimeExports.jsx(t.Text,{fontSize:"sm",flex:1,textTransform:"capitalize",fontWeight:"semibold",children:o}),d&&!x&&e.jsxRuntimeExports.jsx(t.IconButton,{size:"xs",variant:"ghost","aria-label":"delete",icon:e.jsxRuntimeExports.jsx(t.Icon,{as:me.FaTrash}),onClick:d}),!m&&e.jsxRuntimeExports.jsx(we,{selectedItem:s?.kind??D.ThresholdKind.Limit,onChange:({value:p})=>l({...s,kind:p}),isDisabled:u||x,buttonProps:{size:"sm",variant:"outline",colorScheme:"gray"},selectedProps:{variant:"solid",colorScheme:"teal"},items:[{value:D.ThresholdKind.Limit,label:"limit"},{value:D.ThresholdKind.Target,label:"target"}]})]}),e.jsxRuntimeExports.jsx(Le,{w:"100%",size:"xs",min:c,max:E,zeroMarker:!0,value:[s.min,s.max],onChange:p=>l({...s,min:p[0],max:p[1]}),formatValue:p=>`${Math.abs(p)}°`,valueLabel:p=>h(p)??"",positiveNegativeLabels:h(0)?[h(-1)??"",h(1)??""]:void 0,isDisabled:x})]})},xe=(o,s)=>"segment"in o&&"segment"in s&&o.segment===s.segment||"joint"in o&&"joint"in s&&o.joint===s.joint,Ce=({options:o,value:s,onChange:l,forceKind:d,singleValue:m,singleValueSideless:u,editOnly:x,disableKind:h,maxParameters:c,...E})=>{const p=u?2:c,L=n.useMemo(()=>o.map(r=>({label:"segment"in r.id?ae.getSegmentNameWithPlane(r.id.segment,r.plane,!0)??"Unknown":ae.getJointNameWithPlane(r.id.joint,r.plane,!0)??"Unknown",value:r.id,plane:r.plane})),[o]),j=n.useMemo(()=>{if(!u||s.length===0)return L;const r=s[0];return L.filter(R=>le.getAnalysisPartIdNoSide(R.value)===le.getAnalysisPartIdNoSide(r.id)&&R.plane===r.plane)},[L,s,u]),v=n.useMemo(()=>L.filter(r=>s.some(R=>xe(R.id,r.value)&&R.plane===r.plane)),[L,s]),C=n.useCallback(r=>{const R=r.map(T=>{const f=s.find(N=>xe(N.id,T.value)&&N.plane===T.plane),M=o.find(N=>xe(N.id,T.value)&&N.plane===T.plane),k=u?s.find(N=>le.getAnalysisPartIdNoSide(N.id)===le.getAnalysisPartIdNoSide(T.value)&&N.plane===T.plane):void 0,I=k&&!f?k.min:M&&M.min?M.min:0,z=k&&!f?k.max:M&&M.max?M.max:0;return f??{id:T.value,plane:T.plane,min:I,max:z,kind:d??D.ThresholdKind.Limit}});l(R)},[l,s,o,d,u]);return n.useEffect(()=>{const r=s.filter(R=>o.some(T=>xe(T.id,R.id)&&T.plane===R.plane));r.length!==s.length&&l(r)},[o,l]),e.jsxRuntimeExports.jsxs(t.Box,{...E,children:[e.jsxRuntimeExports.jsx(oe.st,{isMulti:!m,placeholder:s.length?`${s.length} selected`:"Search...",value:v,isDisabled:x||v.length>=(p??1/0),onChange:r=>Array.isArray(r)?C([...r]):C(r!==null?[r]:[]),options:j,controlShouldRenderValue:!1}),e.jsxRuntimeExports.jsx(fe,{marginTop:2,maxH:"28rem",value:s,onChange:l,forceKind:d,disableKind:h,isDisabled:x,lockRanges:u})]})},be=o=>{switch(o){case D.SensorLocation.Thorax:return"Thorax";case D.SensorLocation.CenterBack:return"Center Back";case D.SensorLocation.Pelvis:return"Pelvis";case D.SensorLocation.LeftThigh:return"Left Thigh";case D.SensorLocation.RightThigh:return"Right Thigh";case D.SensorLocation.LeftShank:return"Left Shank";case D.SensorLocation.RightShank:return"Right Shank";case D.SensorLocation.LeftFoot:return"Left Foot";case D.SensorLocation.RightFoot:return"Right Foot";case D.SensorLocation.LeftUpperArm:return"Left Upper Arm";case D.SensorLocation.RightUpperArm:return"Right Upper Arm";case D.SensorLocation.LeftForearm:return"Left Forearm";case D.SensorLocation.RightForearm:return"Right Forearm";case D.SensorLocation.Head:return"Head"}return console.warn(`Unknown sensor location: ${o}`),"Unknown"},ze=6,qe=[D.SensorLocation.LeftFoot,D.SensorLocation.LeftShank,D.SensorLocation.LeftThigh,D.SensorLocation.Pelvis,D.SensorLocation.RightFoot,D.SensorLocation.RightShank,D.SensorLocation.RightThigh,D.SensorLocation.Thorax,D.SensorLocation.CenterBack,D.SensorLocation.Head],Qe=qe.map(o=>({label:be(o),value:o})),We=({id:o,onError:s,onCancel:l,onSave:d,hideButtons:m,setButtonOnClick:u,setButtonDisabled:x,quantumOwned:h,isView:c})=>{const E=Y.useClient(),[{fetching:p},L]=Y.useMutation(b.CREATE_ACTION),[{fetching:j},v]=Y.useMutation(b.UPDATE_ACTION),[{data:C}]=Y.useQuery({query:b.GET_ACTION_BY_ID,variables:{id:o??""},pause:!o}),r=P.getFragmentData(b.ACTION_FRAGMENT,C?.getActionById),R=p||j,T=!!r&&!!o,{getLabel:f}=ne.useUiLabelContext(),M=n.useMemo(()=>({action:f("action")}),[f]),k=n.useMemo(()=>[{key:"module_category",label:"Link Category",multi:!0},{key:"activity_type",label:`${M.action} Type`,multi:!1},{key:"session_type",label:"Session Type",multi:!0},{key:"body_region",label:"Body Region",multi:!0},{key:"sport",label:"Sport",multi:!0}],[M.action]),[I,z]=n.useState(""),[N,O]=n.useState(""),[w,ee]=n.useState(""),[J,g]=n.useState(""),[A,y]=n.useState([]),[_,V]=n.useState([]),[K,G]=n.useState({}),a=n.useMemo(()=>A.map(F=>F.value),[A]),i=ne.usePartOptionsForSensorLocations(a),[S,$]=n.useState([]),B=I.length>0,[q,U]=n.useState({});n.useEffect(()=>{const F=k.map(H=>E.query(b.GET_METADATA_BY_KEY,{key:H.key}));Promise.all(F).then(H=>{const Q={};H.forEach(Z=>{if(Z.error||!Z.data)return;const te=P.getFragmentData(b.METADATA_GROUP_FRAGMENT,Z.data.getMetadataByKey),he=P.getFragmentData(b.METADATA_ITEM_FRAGMENT,te.data);Q[te.key]=he.map(ie=>({label:ie.label||ie.value,value:ie.value,id:ie.id}))}),G(Q)})},[E,k]),n.useEffect(()=>{if(r){const H=P.getFragmentData(b.METADATA_GROUP_FRAGMENT,r.metadataGroups).map(Z=>Z.data.map(te=>P.getFragmentData(b.METADATA_ITEM_FRAGMENT,te).id)),Q={name:r.name,description:r.description||"",cameraPlacement:r.cameraPlacement||"",videoLink:r.videoLink||"",sensorLocations:r.sensorLocations.map(Z=>({label:be(Z),value:Z})),thresholds:je.thresholdsToParameters(r.thresholds),metadataIds:H.flat()};z(Q.name),O(Q.description),ee(Q.cameraPlacement),g(Q.videoLink),y(Q.sensorLocations),$(Q.thresholds),V(Q.metadataIds),U(Q)}},[r]);const X=n.useMemo(()=>JSON.stringify(q)!==JSON.stringify({name:I,description:N,cameraPlacement:w,videoLink:J,sensorLocations:a,thresholds:je.parametersToThresholds(S),metadataIds:_}),[q,I,a,N,w,J,_,S]),W=n.useCallback(()=>{const F={name:I,description:N,cameraPlacement:w,videoLink:J,sensorLocations:a,thresholds:je.parametersToThresholds(S),metadataItemIds:_,laterality:D.ActionLaterality.Either,quantumOwned:h,sessionType:[]};let H;T&&o?H=v({id:o,fields:F}):H=L({fields:F}),H.then(({error:Q})=>{Q?s(Q):d()})},[h,L,v,o,I,a,N,w,J,_,T,S,d,s]);n.useEffect(()=>{x&&x({cancelButton:R,saveButton:c?!0:R||!B||!X})},[R,x,B,X,c]),n.useEffect(()=>{u&&u({cancelButton:l,saveButton:c?()=>{}:W})},[u,l,W,c]);const ce=(F,H)=>{const Q=k.find(te=>te.key===F);if(!Q)return;const Z=Q.multi?(H??[]).map(te=>te.id):H?[H.id]:[];V(te=>[...te.filter(ie=>Object.values(K).flat().find(ue=>ue.id===ie)&&!Object.keys(K).find(ue=>K[ue]?.some(Te=>Te.id===ie&&ue===F))),...Z])};return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-4 w-full",children:[e.jsxRuntimeExports.jsxs("div",{className:"col-span-2 lg:col-span-1 flex flex-col gap-4",children:[e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Name"}),e.jsxRuntimeExports.jsx(t.Input,{value:I,onChange:F=>z(F.target.value),type:"text",placeholder:"i.e. Lunge & Return",isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Camera Placement"}),e.jsxRuntimeExports.jsx(t.Textarea,{value:w,onChange:F=>ee(F.target.value),rows:2,placeholder:"(optional) Describe camera setup, placement, angles",isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Video Link"}),e.jsxRuntimeExports.jsx(t.Input,{value:J,onChange:F=>g(F.target.value),type:"url",placeholder:"(optional) https://...",isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Description"}),e.jsxRuntimeExports.jsx(t.Textarea,{value:N,onChange:F=>O(F.target.value),rows:2,placeholder:"(optional) Describe how to perform the test or exercise",isDisabled:c})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(re,{children:"Metadata Tags"}),k.map(F=>e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:F.label}),e.jsxRuntimeExports.jsx(oe.st,{isMulti:F.multi,value:K[F.key]?.filter(H=>_.includes(H.id)),onChange:H=>{ce(F.key,H)},options:K[F.key],placeholder:`Select ${F.multi?"one or more":"one"} ${F.label.toLowerCase()}`,isDisabled:c,isClearable:F.multi})]},F.key))]})]}),e.jsxRuntimeExports.jsxs("div",{className:"col-span-2 lg:col-span-1 flex flex-col gap-4",children:[e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Sensor Locations"}),e.jsxRuntimeExports.jsx(oe.st,{isMulti:!0,value:A,onChange:F=>y([...F]),options:Qe,isOptionDisabled:()=>A.length>=ze,isDisabled:c})]}),e.jsxRuntimeExports.jsxs(t.FormControl,{children:[e.jsxRuntimeExports.jsx(re,{children:"Default Parameters"}),e.jsxRuntimeExports.jsx(Ce,{options:i,value:S,onChange:$,editOnly:c})]})]}),e.jsxRuntimeExports.jsx("div",{className:ge.cn("col-span-2 flex justify-end",(m||c)&&"hidden"),children:e.jsxRuntimeExports.jsxs(t.ButtonGroup,{mt:16,gap:4,children:[e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:R,onClick:l,children:"Cancel"}),e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"blue",isDisabled:R||!B||!X,isLoading:R,onClick:W,children:"Save changes"})]})})]})},re=({children:o})=>e.jsxRuntimeExports.jsx(t.FormLabel,{fontWeight:"bold",fontFamily:"sans-serif",fontSize:"large",children:o}),He=({id:o,onCancel:s,onSave:l,onError:d,hideButtons:m,quantumOwned:u,setButtonOnClick:x,setButtonDisabled:h})=>{const[{data:c}]=Y.useQuery({query:u?b.GET_QUANTUM_OWNED_ACTIONS:b.GET_ACTIONS}),[{data:E}]=Y.useQuery({query:b.GET_MODULE_BY_ID,variables:{id:o},pause:!o}),[{data:p}]=Y.useQuery({query:b.GET_ALL_MODULE_CATEGORIES}),L=P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,p?.moduleCategories),[{fetching:j},v]=Y.useMutation(b.UPDATE_MODULE),[{fetching:C},r]=Y.useMutation(b.CREATE_MODULE),R=P.getFragmentData(b.ACTION_FRAGMENT,u?c?.quantumOwnedActions:c?.actions)??[],T=P.getFragmentData(b.ACTION_MODULE_FRAGMENT,E?.module),f=P.getFragmentData(b.MODULE_ACTION_FRAGMENT,T?.moduleActions)??[],[M,k]=n.useState([...f.map(g=>g.actionId)??[]]),[I,z]=n.useState(T?.name??""),[N,O]=n.useState([]),[w,ee]=n.useState(T?.description??"");n.useEffect(()=>{T&&(k(f.map(g=>g.actionId)),z(T.name),ee(T.description??""),O(T.categories.map(g=>P.getFragmentData(b.MODULE_CATEGORY_FRAGMENT,g).id)??[]))},[T,f]);const J=n.useCallback(()=>{let g;const A={actions:M,name:I,categories:N.filter(y=>y!=="other"),description:w,quantumOwned:u};T?g=v({id:T.id,input:A}):g=r({input:A}),g.then(({error:y})=>{y?d(y):l()})},[r,v,M,I,w,N,T,l,d,u]);return n.useEffect(()=>{h&&h({cancelButton:j||C,saveButton:j||C||!I||w.trim().split(/\s+/).filter(Boolean).length>40})},[h,j,C,M,I,w]),n.useEffect(()=>{x&&x({cancelButton:s,saveButton:J})},[x,s,J]),e.jsxRuntimeExports.jsxs(t.Box,{width:"100%",children:[e.jsxRuntimeExports.jsx(Re,{name:I,setName:z,actions:R,selectedActionIds:M,setSelectedActionIds:k,availableCategories:L??[],selectedCategoryIds:N,setSelectedCategoryIds:O,description:w,setDescription:ee}),!m&&e.jsxRuntimeExports.jsx(t.HStack,{justifyContent:"flex-start",children:e.jsxRuntimeExports.jsxs(t.ButtonGroup,{mt:16,gap:4,children:[e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"gray",isDisabled:j||C,onClick:s,children:"Cancel"}),e.jsxRuntimeExports.jsx(t.Button,{colorScheme:"blue",isDisabled:j||C||!I||w.trim().split(/\s+/).filter(Boolean).length>40,isLoading:j||C,onClick:J,children:"Save"})]})})]})};exports.ActivityList=Ee;exports.CopyActivityForm=De;exports.CopyModuleForm=_e;exports.ModuleForm=Re;exports.ParameterEditList=fe;exports.ParameterEditSelect=Ce;exports.UpsertActivityForm=We;exports.UpsertModuleForm=He;
|
package/dist/components.js
CHANGED
|
@@ -2,18 +2,19 @@ import { j as e } from "./react-jsx-runtime-vendor-OVHDjVDe.js";
|
|
|
2
2
|
import { Flex as fe, InputGroup as Ge, InputLeftElement as gt, Icon as Je, Input as ye, FormLabel as Xe, Box as V, TableContainer as Ze, Table as Ke, Thead as Ve, Tr as Oe, Th as xe, Tbody as et, Td as je, ButtonGroup as be, Tooltip as _e, Button as ee, RangeSlider as xt, RangeSliderMark as De, Text as v, RangeSliderTrack as ft, RangeSliderFilledTrack as jt, RangeSliderThumb as We, Select as Ue, NumberInput as Be, NumberInputField as Qe, HStack as re, Tag as ve, Image as bt, useToast as tt, VStack as oe, FormControl as K, RadioGroup as nt, Radio as Ne, Alert as ke, AlertIcon as $e, Spinner as st, useDisclosure as Ct, Modal as yt, ModalOverlay as vt, ModalContent as wt, ModalHeader as Lt, ModalCloseButton as St, ModalBody as Mt, ModalFooter as At, IconButton as Tt, Textarea as qe } from "@chakra-ui/react";
|
|
3
3
|
import { useMemo as A, useState as z, useCallback as R, useRef as It, useEffect as ae, memo as Fe } from "react";
|
|
4
4
|
import { useQuery as he, useMutation as ie, useClient as Ot } from "urql";
|
|
5
|
-
import {
|
|
6
|
-
import { useUiLabelContext as pe, usePartOptionsForSensorLocations as kt } from "./hooks.js";
|
|
7
|
-
import { u as $t } from "./ufuzzy-vendor-Dl0ZI6Av.js";
|
|
8
|
-
import { F as Ft, a as Rt, b as Dt, c as Et } from "./react-icons-vendor-CMsTQrA0.js";
|
|
9
|
-
import { s as de } from "./react-select-vendor-D8Fzpeg3.js";
|
|
10
|
-
import { getFragmentData as _ } from "./generated.js";
|
|
11
|
-
import { G as rt, a as Pt, C as ze, b as at, M as we, c as Ee, A as me, d as Pe, e as lt, f as _t, g as it, U as ct, h as Te, i as dt, j as zt, k as Gt, l as Wt, m as Ut, n as Bt, o as Qt, p as qt } from "./graphql-_vGi4u4K.js";
|
|
5
|
+
import { c as ot } from "./utils-cn-CgdSr4hO.js";
|
|
12
6
|
import "./moment-vendor-DMLRxgRE.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
7
|
+
import { useUiLabelContext as pe, usePartOptionsForSensorLocations as Nt } from "./hooks.js";
|
|
8
|
+
import { u as kt } from "./ufuzzy-vendor-Dl0ZI6Av.js";
|
|
9
|
+
import { F as $t, a as Ft, b as Rt, c as Dt } from "./react-icons-vendor-CMsTQrA0.js";
|
|
10
|
+
import { s as de } from "./react-select-vendor-BxbsY5Z-.js";
|
|
11
|
+
import { getFragmentData as _ } from "./generated.js";
|
|
12
|
+
import { G as rt, a as Et, C as ze, b as at, M as we, c as Ee, A as me, d as Pe, e as lt, f as Pt, g as it, U as ct, h as Te, i as dt, j as _t, k as zt, l as Gt, m as Wt, n as Ut, o as Bt, p as Qt } from "./graphql-_vGi4u4K.js";
|
|
13
|
+
import { D as qt, H as Yt, u as Ht, a as Jt } from "./react-dnd-vendor-BCrg2QCX.js";
|
|
14
|
+
import { ThresholdKind as Ie, SensorLocation as G, ActionLaterality as Xt } from "./generated-graphql.js";
|
|
15
|
+
import { g as ut, a as ht, b as Zt, c as Kt, d as Vt } from "./services-human-B98qxeuS.js";
|
|
16
|
+
import { availablePlanes as Ye, getAnalysisPartIdNoSide as Se } from "./types.js";
|
|
17
|
+
import { t as en, p as He } from "./utils-parameters-BBFuBK2B.js";
|
|
17
18
|
const tn = ({
|
|
18
19
|
setSearch: n,
|
|
19
20
|
actions: t,
|
|
@@ -29,7 +30,7 @@ const tn = ({
|
|
|
29
30
|
);
|
|
30
31
|
return /* @__PURE__ */ e.jsxs(fe, { width: "100%", alignContent: "space-evenly", gap: 4, children: [
|
|
31
32
|
/* @__PURE__ */ e.jsxs(Ge, { size: "md", flex: 1, children: [
|
|
32
|
-
/* @__PURE__ */ e.jsx(gt, { children: /* @__PURE__ */ e.jsx(Je, { as:
|
|
33
|
+
/* @__PURE__ */ e.jsx(gt, { children: /* @__PURE__ */ e.jsx(Je, { as: $t, color: "gray.300" }) }),
|
|
33
34
|
/* @__PURE__ */ e.jsx(
|
|
34
35
|
ye,
|
|
35
36
|
{
|
|
@@ -72,7 +73,7 @@ const tn = ({
|
|
|
72
73
|
},
|
|
73
74
|
[t]
|
|
74
75
|
);
|
|
75
|
-
return /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsx(
|
|
76
|
+
return /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsx(qt, { backend: Yt, children: /* @__PURE__ */ e.jsx(Ze, { children: /* @__PURE__ */ e.jsxs(Ke, { variant: "simple", size: "md", children: [
|
|
76
77
|
/* @__PURE__ */ e.jsx(Ve, { children: /* @__PURE__ */ e.jsxs(Oe, { children: [
|
|
77
78
|
/* @__PURE__ */ e.jsx(xe, { children: "Order" }),
|
|
78
79
|
/* @__PURE__ */ e.jsx(xe, { children: "Name" })
|
|
@@ -90,7 +91,7 @@ const tn = ({
|
|
|
90
91
|
)) })
|
|
91
92
|
] }) }) }) });
|
|
92
93
|
}, sn = ({ listKey: n, index: t, id: a, name: c, move: u }) => {
|
|
93
|
-
const i = It(null), [{ handlerId: d }, m] =
|
|
94
|
+
const i = It(null), [{ handlerId: d }, m] = Ht({
|
|
94
95
|
accept: n,
|
|
95
96
|
collect: (p) => ({
|
|
96
97
|
handlerId: p.getHandlerId()?.toString() ?? ""
|
|
@@ -104,7 +105,7 @@ const tn = ({
|
|
|
104
105
|
const f = i.current?.getBoundingClientRect(), C = (f.bottom - f.top) / 2, S = L.getClientOffset().y - f.top;
|
|
105
106
|
b < s && S < C || b > s && S > C || (u(b, s), p.index = s);
|
|
106
107
|
}
|
|
107
|
-
}), [{ isDragging: l }, x] =
|
|
108
|
+
}), [{ isDragging: l }, x] = Jt({
|
|
108
109
|
type: n,
|
|
109
110
|
item: () => ({ id: a, index: t }),
|
|
110
111
|
collect: (p) => ({
|
|
@@ -377,7 +378,7 @@ const tn = ({
|
|
|
377
378
|
}
|
|
378
379
|
)
|
|
379
380
|
] });
|
|
380
|
-
}, an = ({ tags: n, containerProps: t, ...a }) => /* @__PURE__ */ e.jsx(re, { ...t, children: n.map((c, u) => /* @__PURE__ */ e.jsx(ve, { ...a, children: c }, u)) }), ln = new
|
|
381
|
+
}, an = ({ tags: n, containerProps: t, ...a }) => /* @__PURE__ */ e.jsx(re, { ...t, children: n.map((c, u) => /* @__PURE__ */ e.jsx(ve, { ...a, children: c }, u)) }), ln = new kt({}), cn = ({
|
|
381
382
|
action: n,
|
|
382
383
|
quantumIconSrc: t
|
|
383
384
|
}) => {
|
|
@@ -543,7 +544,7 @@ const tn = ({
|
|
|
543
544
|
},
|
|
544
545
|
children: [
|
|
545
546
|
/* @__PURE__ */ e.jsx(je, { children: /* @__PURE__ */ e.jsxs(fe, { children: [
|
|
546
|
-
!l && /* @__PURE__ */ e.jsx(e.Fragment, { children: g.selected ? /* @__PURE__ */ e.jsx(
|
|
547
|
+
!l && /* @__PURE__ */ e.jsx(e.Fragment, { children: g.selected ? /* @__PURE__ */ e.jsx(Ft, { className: "text-blue-500" }) : /* @__PURE__ */ e.jsx(Rt, { className: "text-gray-400" }) }),
|
|
547
548
|
(g.quantumOwned || !u) && i && /* @__PURE__ */ e.jsx(
|
|
548
549
|
ee,
|
|
549
550
|
{
|
|
@@ -596,7 +597,7 @@ const tn = ({
|
|
|
596
597
|
)) })
|
|
597
598
|
] }) })
|
|
598
599
|
] });
|
|
599
|
-
},
|
|
600
|
+
}, Un = ({
|
|
600
601
|
onSave: n,
|
|
601
602
|
onCancel: t,
|
|
602
603
|
onError: a,
|
|
@@ -613,7 +614,7 @@ const tn = ({
|
|
|
613
614
|
}), [l]), [h, T] = z("copy"), [p, L] = z(""), [b, s] = z([]), [f, C] = z(!1), [j] = he({
|
|
614
615
|
query: rt
|
|
615
616
|
}), [S] = he({
|
|
616
|
-
query:
|
|
617
|
+
query: Et,
|
|
617
618
|
variables: { groupId: p },
|
|
618
619
|
pause: !p
|
|
619
620
|
// Only run when group is selected
|
|
@@ -995,7 +996,7 @@ const tn = ({
|
|
|
995
996
|
)
|
|
996
997
|
] })
|
|
997
998
|
] }) });
|
|
998
|
-
},
|
|
999
|
+
}, Bn = ({
|
|
999
1000
|
onSave: n,
|
|
1000
1001
|
onCancel: t,
|
|
1001
1002
|
onError: a,
|
|
@@ -1007,7 +1008,7 @@ const tn = ({
|
|
|
1007
1008
|
const m = tt(), { getLabel: l } = pe(), [x, h] = z(""), [T, p] = z([]), [L, b] = z(!1), [s, f] = z("copy"), [C] = he({
|
|
1008
1009
|
query: rt
|
|
1009
1010
|
}), [j] = he({
|
|
1010
|
-
query:
|
|
1011
|
+
query: Pt,
|
|
1011
1012
|
variables: { groupId: x },
|
|
1012
1013
|
pause: !x
|
|
1013
1014
|
// Only run when group is selected
|
|
@@ -1691,7 +1692,7 @@ const tn = ({
|
|
|
1691
1692
|
...m
|
|
1692
1693
|
}) => {
|
|
1693
1694
|
const l = A(() => [...n].sort((p, L) => {
|
|
1694
|
-
const b =
|
|
1695
|
+
const b = Ye.indexOf(p.plane), s = Ye.indexOf(L.plane);
|
|
1695
1696
|
return b - s;
|
|
1696
1697
|
}), [n]), x = R((p) => "segment" in p.id ? ut(p.id.segment, p.plane, !0) ?? "Unknown" : ht(p.id.joint, p.plane, !0) ?? "Unknown", []), h = R(
|
|
1697
1698
|
(p, L) => {
|
|
@@ -1738,17 +1739,17 @@ const tn = ({
|
|
|
1738
1739
|
isDisabled: d
|
|
1739
1740
|
}) => {
|
|
1740
1741
|
const m = R(
|
|
1741
|
-
(h) => "joint" in t.id ?
|
|
1742
|
+
(h) => "joint" in t.id ? Zt(
|
|
1742
1743
|
t.id.joint,
|
|
1743
1744
|
t.plane,
|
|
1744
1745
|
h < 0 ? -1 : 1
|
|
1745
|
-
) :
|
|
1746
|
+
) : Kt(
|
|
1746
1747
|
t.id.segment,
|
|
1747
1748
|
t.plane,
|
|
1748
1749
|
h < 0 ? -1 : 1
|
|
1749
1750
|
),
|
|
1750
1751
|
[t]
|
|
1751
|
-
), { min: l, max: x } = "joint" in t.id ?
|
|
1752
|
+
), { min: l, max: x } = "joint" in t.id ? Vt(t.id.joint, t.plane) : { min: -180, max: 180 };
|
|
1752
1753
|
return /* @__PURE__ */ e.jsxs(
|
|
1753
1754
|
oe,
|
|
1754
1755
|
{
|
|
@@ -1777,7 +1778,7 @@ const tn = ({
|
|
|
1777
1778
|
size: "xs",
|
|
1778
1779
|
variant: "ghost",
|
|
1779
1780
|
"aria-label": "delete",
|
|
1780
|
-
icon: /* @__PURE__ */ e.jsx(Je, { as:
|
|
1781
|
+
icon: /* @__PURE__ */ e.jsx(Je, { as: Dt }),
|
|
1781
1782
|
onClick: c
|
|
1782
1783
|
}
|
|
1783
1784
|
),
|
|
@@ -1953,7 +1954,7 @@ const tn = ({
|
|
|
1953
1954
|
], Ln = wn.map((n) => ({
|
|
1954
1955
|
label: mt(n),
|
|
1955
1956
|
value: n
|
|
1956
|
-
})),
|
|
1957
|
+
})), Qn = ({
|
|
1957
1958
|
id: n,
|
|
1958
1959
|
onError: t,
|
|
1959
1960
|
onCancel: a,
|
|
@@ -1964,8 +1965,8 @@ const tn = ({
|
|
|
1964
1965
|
quantumOwned: m,
|
|
1965
1966
|
isView: l
|
|
1966
1967
|
}) => {
|
|
1967
|
-
const x = Ot(), [{ fetching: h }, T] = ie(ze), [{ fetching: p }, L] = ie(
|
|
1968
|
-
query:
|
|
1968
|
+
const x = Ot(), [{ fetching: h }, T] = ie(ze), [{ fetching: p }, L] = ie(_t), [{ data: b }] = he({
|
|
1969
|
+
query: zt,
|
|
1969
1970
|
variables: { id: n ?? "" },
|
|
1970
1971
|
pause: !n
|
|
1971
1972
|
}), s = _(
|
|
@@ -1982,10 +1983,10 @@ const tn = ({
|
|
|
1982
1983
|
], [S.action]), [N, B] = z(""), [k, $] = z(""), [M, se] = z(""), [J, g] = z(""), [I, y] = z([]), [D, X] = z([]), [Z, E] = z({}), r = A(
|
|
1983
1984
|
() => I.map((O) => O.value),
|
|
1984
1985
|
[I]
|
|
1985
|
-
), o =
|
|
1986
|
+
), o = Nt(r), [w, P] = z([]), W = N.length > 0, [Q, U] = z({});
|
|
1986
1987
|
ae(() => {
|
|
1987
1988
|
const O = F.map(
|
|
1988
|
-
(H) => x.query(
|
|
1989
|
+
(H) => x.query(Gt, { key: H.key })
|
|
1989
1990
|
);
|
|
1990
1991
|
Promise.all(O).then((H) => {
|
|
1991
1992
|
const q = {};
|
|
@@ -2021,7 +2022,7 @@ const tn = ({
|
|
|
2021
2022
|
label: mt(ne),
|
|
2022
2023
|
value: ne
|
|
2023
2024
|
})),
|
|
2024
|
-
thresholds:
|
|
2025
|
+
thresholds: en(s.thresholds),
|
|
2025
2026
|
metadataIds: H.flat()
|
|
2026
2027
|
};
|
|
2027
2028
|
B(q.name), $(q.description), se(q.cameraPlacement), g(q.videoLink), y(q.sensorLocations), P(q.thresholds), X(q.metadataIds), U(q);
|
|
@@ -2034,7 +2035,7 @@ const tn = ({
|
|
|
2034
2035
|
cameraPlacement: M,
|
|
2035
2036
|
videoLink: J,
|
|
2036
2037
|
sensorLocations: r,
|
|
2037
|
-
thresholds:
|
|
2038
|
+
thresholds: He(w),
|
|
2038
2039
|
metadataIds: D
|
|
2039
2040
|
}),
|
|
2040
2041
|
[
|
|
@@ -2054,10 +2055,10 @@ const tn = ({
|
|
|
2054
2055
|
cameraPlacement: M,
|
|
2055
2056
|
videoLink: J,
|
|
2056
2057
|
sensorLocations: r,
|
|
2057
|
-
thresholds:
|
|
2058
|
+
thresholds: He(w),
|
|
2058
2059
|
metadataItemIds: D,
|
|
2059
2060
|
// Backend requires laterality; keep existing default since UI no longer edits it
|
|
2060
|
-
laterality:
|
|
2061
|
+
laterality: Xt.Either,
|
|
2061
2062
|
quantumOwned: m,
|
|
2062
2063
|
//Backend requires session type; keep existing default since UI no longer edits it
|
|
2063
2064
|
sessionType: []
|
|
@@ -2239,7 +2240,7 @@ const tn = ({
|
|
|
2239
2240
|
}
|
|
2240
2241
|
)
|
|
2241
2242
|
] });
|
|
2242
|
-
}, ue = ({ children: n }) => /* @__PURE__ */ e.jsx(Xe, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: n }),
|
|
2243
|
+
}, ue = ({ children: n }) => /* @__PURE__ */ e.jsx(Xe, { fontWeight: "bold", fontFamily: "sans-serif", fontSize: "large", children: n }), qn = ({
|
|
2243
2244
|
id: n,
|
|
2244
2245
|
onCancel: t,
|
|
2245
2246
|
onSave: a,
|
|
@@ -2250,13 +2251,13 @@ const tn = ({
|
|
|
2250
2251
|
setButtonDisabled: m
|
|
2251
2252
|
}) => {
|
|
2252
2253
|
const [{ data: l }] = he({
|
|
2253
|
-
query: i ?
|
|
2254
|
+
query: i ? Wt : Ut
|
|
2254
2255
|
}), [{ data: x }] = he({
|
|
2255
|
-
query:
|
|
2256
|
+
query: Bt,
|
|
2256
2257
|
variables: { id: n },
|
|
2257
2258
|
pause: !n
|
|
2258
2259
|
}), [{ data: h }] = he({
|
|
2259
|
-
query:
|
|
2260
|
+
query: Qt
|
|
2260
2261
|
}), T = _(
|
|
2261
2262
|
we,
|
|
2262
2263
|
h?.moduleCategories
|
|
@@ -2353,11 +2354,11 @@ const tn = ({
|
|
|
2353
2354
|
};
|
|
2354
2355
|
export {
|
|
2355
2356
|
mn as ActivityList,
|
|
2356
|
-
|
|
2357
|
-
|
|
2357
|
+
Un as CopyActivityForm,
|
|
2358
|
+
Bn as CopyModuleForm,
|
|
2358
2359
|
pn as ModuleForm,
|
|
2359
2360
|
bn as ParameterEditList,
|
|
2360
2361
|
yn as ParameterEditSelect,
|
|
2361
|
-
|
|
2362
|
-
|
|
2362
|
+
Qn as UpsertActivityForm,
|
|
2363
|
+
qn as UpsertModuleForm
|
|
2363
2364
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as j } from "./vendor-
|
|
2
|
-
import { i as s, b as M } from "./react-dnd-vendor-
|
|
1
|
+
import { c as j } from "./vendor-BOD7IxCS.js";
|
|
2
|
+
import { i as s, b as M } from "./react-dnd-vendor-BCrg2QCX.js";
|
|
3
3
|
function H(t, e, r) {
|
|
4
4
|
return e.split(".").reduce(
|
|
5
5
|
(n, i) => n && n[i] ? n[i] : r || null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const M=require("./vendor-BwXiOWc8.cjs"),s=require("./react-dnd-vendor-BuaDqq1-.cjs");function j(t,e,r){return e.split(".").reduce((n,i)=>n&&n[i]?n[i]:r||null,t)}function H(t,e){return t.filter(r=>r!==e)}function U(t){return typeof t=="object"}function N(t,e){const r=new Map,n=o=>{r.set(o,r.has(o)?r.get(o)+1:1)};t.forEach(n),e.forEach(n);const i=[];return r.forEach((o,a)=>{o===1&&i.push(a)}),i}function L(t,e){return t.filter(r=>e.indexOf(r)>-1)}const E="dnd-core/INIT_COORDS",p="dnd-core/BEGIN_DRAG",I="dnd-core/PUBLISH_DRAG_SOURCE",h="dnd-core/HOVER",y="dnd-core/DROP",S="dnd-core/END_DRAG";function _(t,e){return{type:E,payload:{sourceClientOffset:e||null,clientOffset:t||null}}}const V={type:E,payload:{clientOffset:null,sourceClientOffset:null}};function k(t){return function(r=[],n={publishSource:!0}){const{publishSource:i=!0,clientOffset:o,getSourceClientOffset:a}=n,c=t.getMonitor(),l=t.getRegistry();t.dispatch(_(o)),q(r,c,l);const f=X(r,c);if(f==null){t.dispatch(V);return}let D=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");B(a),D=a(f)}t.dispatch(_(o,D));const b=l.getSource(f).beginDrag(c,f);if(b==null)return;F(b),l.pinSource(f);const $=l.getSourceType(f);return{type:p,payload:{itemType:$,item:b,sourceId:f,clientOffset:o||null,sourceClientOffset:D||null,isSourcePublic:!!i}}}}function q(t,e,r){s.invariant(!e.isDragging(),"Cannot call beginDrag while dragging."),t.forEach(function(n){s.invariant(r.getSource(n),"Expected sourceIds to be registered.")})}function B(t){s.invariant(typeof t=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function F(t){s.invariant(U(t),"Item must be an object.")}function X(t,e){let r=null;for(let n=t.length-1;n>=0;n--)if(e.canDragSource(t[n])){r=t[n];break}return r}function W(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function z(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){W(t,i,r[i])})}return t}function J(t){return function(r={}){const n=t.getMonitor(),i=t.getRegistry();Q(n),K(n).forEach((a,c)=>{const l=Y(a,c,i,n),f={type:y,payload:{dropResult:z({},r,l)}};t.dispatch(f)})}}function Q(t){s.invariant(t.isDragging(),"Cannot call drop while not dragging."),s.invariant(!t.didDrop(),"Cannot call drop twice during one drag operation.")}function Y(t,e,r,n){const i=r.getTarget(t);let o=i?i.drop(n,t):void 0;return Z(o),typeof o>"u"&&(o=e===0?{}:n.getDropResult()),o}function Z(t){s.invariant(typeof t>"u"||U(t),"Drop result must either be an object or undefined.")}function K(t){const e=t.getTargetIds().filter(t.canDropOnTarget,t);return e.reverse(),e}function ee(t){return function(){const r=t.getMonitor(),n=t.getRegistry();te(r);const i=r.getSourceId();return i!=null&&(n.getSource(i,!0).endDrag(r,i),n.unpinSource()),{type:S}}}function te(t){s.invariant(t.isDragging(),"Cannot call endDrag while not dragging.")}function v(t,e){return e===null?t===null:Array.isArray(t)?t.some(r=>r===e):t===e}function re(t){return function(r,{clientOffset:n}={}){ne(r);const i=r.slice(0),o=t.getMonitor(),a=t.getRegistry(),c=o.getItemType();return oe(i,a,c),ie(i,o,a),se(i,o,a),{type:h,payload:{targetIds:i,clientOffset:n||null}}}}function ne(t){s.invariant(Array.isArray(t),"Expected targetIds to be an array.")}function ie(t,e,r){s.invariant(e.isDragging(),"Cannot call hover while not dragging."),s.invariant(!e.didDrop(),"Cannot call hover after drop.");for(let n=0;n<t.length;n++){const i=t[n];s.invariant(t.lastIndexOf(i)===n,"Expected targetIds to be unique in the passed array.");const o=r.getTarget(i);s.invariant(o,"Expected targetIds to be registered.")}}function oe(t,e,r){for(let n=t.length-1;n>=0;n--){const i=t[n],o=e.getTargetType(i);v(o,r)||t.splice(n,1)}}function se(t,e,r){t.forEach(function(n){r.getTarget(n).hover(e,n)})}function ae(t){return function(){if(t.getMonitor().isDragging())return{type:I}}}function ce(t){return{beginDrag:k(t),publishDragSource:ae(t),hover:re(t),drop:J(t),endDrag:ee(t)}}class ue{receiveBackend(e){this.backend=e}getMonitor(){return this.monitor}getBackend(){return this.backend}getRegistry(){return this.monitor.registry}getActions(){const e=this,{dispatch:r}=this.store;function n(o){return(...a)=>{const c=o.apply(e,a);typeof c<"u"&&r(c)}}const i=ce(this);return Object.keys(i).reduce((o,a)=>{const c=i[a];return o[a]=n(c),o},{})}dispatch(e){this.store.dispatch(e)}constructor(e,r){this.isSetUp=!1,this.handleRefCountChange=()=>{const n=this.store.getState().refCount>0;this.backend&&(n&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!n&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=e,this.monitor=r,e.subscribe(this.handleRefCountChange)}}function fe(t,e){return{x:t.x+e.x,y:t.y+e.y}}function G(t,e){return{x:t.x-e.x,y:t.y-e.y}}function le(t){const{clientOffset:e,initialClientOffset:r,initialSourceClientOffset:n}=t;return!e||!r||!n?null:G(fe(e,n),r)}function de(t){const{clientOffset:e,initialClientOffset:r}=t;return!e||!r?null:G(e,r)}const g=[],m=[];g.__IS_NONE__=!0;m.__IS_ALL__=!0;function ge(t,e){return t===g?!1:t===m||typeof e>"u"?!0:L(e,t).length>0}class pe{subscribeToStateChange(e,r={}){const{handlerIds:n}=r;s.invariant(typeof e=="function","listener must be a function."),s.invariant(typeof n>"u"||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");let i=this.store.getState().stateId;const o=()=>{const a=this.store.getState(),c=a.stateId;try{c===i||c===i+1&&!ge(a.dirtyHandlerIds,n)||e()}finally{i=c}};return this.store.subscribe(o)}subscribeToOffsetChange(e){s.invariant(typeof e=="function","listener must be a function.");let r=this.store.getState().dragOffset;const n=()=>{const i=this.store.getState().dragOffset;i!==r&&(r=i,e())};return this.store.subscribe(n)}canDragSource(e){if(!e)return!1;const r=this.registry.getSource(e);return s.invariant(r,`Expected to find a valid source. sourceId=${e}`),this.isDragging()?!1:r.canDrag(this,e)}canDropOnTarget(e){if(!e)return!1;const r=this.registry.getTarget(e);if(s.invariant(r,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop())return!1;const n=this.registry.getTargetType(e),i=this.getItemType();return v(n,i)&&r.canDrop(this,e)}isDragging(){return!!this.getItemType()}isDraggingSource(e){if(!e)return!1;const r=this.registry.getSource(e,!0);if(s.invariant(r,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic())return!1;const n=this.registry.getSourceType(e),i=this.getItemType();return n!==i?!1:r.isDragging(this,e)}isOverTarget(e,r={shallow:!1}){if(!e)return!1;const{shallow:n}=r;if(!this.isDragging())return!1;const i=this.registry.getTargetType(e),o=this.getItemType();if(o&&!v(i,o))return!1;const a=this.getTargetIds();if(!a.length)return!1;const c=a.indexOf(e);return n?c===a.length-1:c>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return!!this.store.getState().dragOperation.isSourcePublic}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return le(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return de(this.store.getState().dragOffset)}constructor(e,r){this.store=e,this.registry=r}}const C="dnd-core/ADD_SOURCE",R="dnd-core/ADD_TARGET",x="dnd-core/REMOVE_SOURCE",O="dnd-core/REMOVE_TARGET";function he(t){return{type:C,payload:{sourceId:t}}}function ye(t){return{type:R,payload:{targetId:t}}}function Se(t){return{type:x,payload:{sourceId:t}}}function Oe(t){return{type:O,payload:{targetId:t}}}function De(t){s.invariant(typeof t.canDrag=="function","Expected canDrag to be a function."),s.invariant(typeof t.beginDrag=="function","Expected beginDrag to be a function."),s.invariant(typeof t.endDrag=="function","Expected endDrag to be a function.")}function be(t){s.invariant(typeof t.canDrop=="function","Expected canDrop to be a function."),s.invariant(typeof t.hover=="function","Expected hover to be a function."),s.invariant(typeof t.drop=="function","Expected beginDrag to be a function.")}function T(t,e){if(e&&Array.isArray(t)){t.forEach(r=>T(r,!1));return}s.invariant(typeof t=="string"||typeof t=="symbol",e?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var u;(function(t){t.SOURCE="SOURCE",t.TARGET="TARGET"})(u||(u={}));let ve=0;function Te(){return ve++}function Ee(t){const e=Te().toString();switch(t){case u.SOURCE:return`S${e}`;case u.TARGET:return`T${e}`;default:throw new Error(`Unknown Handler Role: ${t}`)}}function w(t){switch(t[0]){case"S":return u.SOURCE;case"T":return u.TARGET;default:throw new Error(`Cannot parse handler ID: ${t}`)}}function P(t,e){const r=t.entries();let n=!1;do{const{done:i,value:[,o]}=r.next();if(o===e)return!0;n=!!i}while(!n);return!1}class Ie{addSource(e,r){T(e),De(r);const n=this.addHandler(u.SOURCE,e,r);return this.store.dispatch(he(n)),n}addTarget(e,r){T(e,!0),be(r);const n=this.addHandler(u.TARGET,e,r);return this.store.dispatch(ye(n)),n}containsHandler(e){return P(this.dragSources,e)||P(this.dropTargets,e)}getSource(e,r=!1){return s.invariant(this.isSourceId(e),"Expected a valid source ID."),r&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}getTarget(e){return s.invariant(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}getSourceType(e){return s.invariant(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}getTargetType(e){return s.invariant(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}isSourceId(e){return w(e)===u.SOURCE}isTargetId(e){return w(e)===u.TARGET}removeSource(e){s.invariant(this.getSource(e),"Expected an existing source."),this.store.dispatch(Se(e)),s.asap(()=>{this.dragSources.delete(e),this.types.delete(e)})}removeTarget(e){s.invariant(this.getTarget(e),"Expected an existing target."),this.store.dispatch(Oe(e)),this.dropTargets.delete(e),this.types.delete(e)}pinSource(e){const r=this.getSource(e);s.invariant(r,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=r}unpinSource(){s.invariant(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(e,r,n){const i=Ee(e);return this.types.set(i,r),e===u.SOURCE?this.dragSources.set(i,n):e===u.TARGET&&this.dropTargets.set(i,n),i}constructor(e){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=e}}const me=(t,e)=>t===e;function Ce(t,e){return!t&&!e?!0:!t||!e?!1:t.x===e.x&&t.y===e.y}function Re(t,e,r=me){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(!r(t[n],e[n]))return!1;return!0}function xe(t=g,e){switch(e.type){case h:break;case C:case R:case O:case x:return g;case p:case I:case S:case y:default:return m}const{targetIds:r=[],prevTargetIds:n=[]}=e.payload,i=N(r,n);if(!(i.length>0||!Re(r,n)))return g;const a=n[n.length-1],c=r[r.length-1];return a!==c&&(a&&i.push(a),c&&i.push(c)),i}function _e(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function we(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){_e(t,i,r[i])})}return t}const A={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function Pe(t=A,e){const{payload:r}=e;switch(e.type){case E:case p:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case h:return Ce(t.clientOffset,r.clientOffset)?t:we({},t,{clientOffset:r.clientOffset});case S:case y:return A;default:return t}}function Ae(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){Ae(t,i,r[i])})}return t}const Ue={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function Ge(t=Ue,e){const{payload:r}=e;switch(e.type){case p:return d({},t,{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case I:return d({},t,{isSourcePublic:!0});case h:return d({},t,{targetIds:r.targetIds});case O:return t.targetIds.indexOf(r.targetId)===-1?t:d({},t,{targetIds:H(t.targetIds,r.targetId)});case y:return d({},t,{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case S:return d({},t,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return t}}function $e(t=0,e){switch(e.type){case C:case R:return t+1;case x:case O:return t-1;default:return t}}function Me(t=0){return t+1}function je(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function He(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){je(t,i,r[i])})}return t}function Ne(t={},e){return{dirtyHandlerIds:xe(t.dirtyHandlerIds,{type:e.type,payload:He({},e.payload,{prevTargetIds:j(t,"dragOperation.targetIds",[])})}),dragOffset:Pe(t.dragOffset,e),refCount:$e(t.refCount,e),dragOperation:Ge(t.dragOperation,e),stateId:Me(t.stateId)}}function Le(t,e=void 0,r={},n=!1){const i=Ve(n),o=new pe(i,new Ie(i)),a=new ue(i,o),c=t(a,e,r);return a.receiveBackend(c),a}function Ve(t){const e=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__;return M.createStore(Ne,t&&e&&e({name:"dnd-core",instanceId:"dnd-core"}))}exports.createDragDropManager=Le;
|
|
1
|
+
"use strict";const M=require("./vendor-IPtJZCbx.cjs"),s=require("./react-dnd-vendor-PwwXhPmK.cjs");function j(t,e,r){return e.split(".").reduce((n,i)=>n&&n[i]?n[i]:r||null,t)}function H(t,e){return t.filter(r=>r!==e)}function U(t){return typeof t=="object"}function N(t,e){const r=new Map,n=o=>{r.set(o,r.has(o)?r.get(o)+1:1)};t.forEach(n),e.forEach(n);const i=[];return r.forEach((o,a)=>{o===1&&i.push(a)}),i}function L(t,e){return t.filter(r=>e.indexOf(r)>-1)}const E="dnd-core/INIT_COORDS",p="dnd-core/BEGIN_DRAG",I="dnd-core/PUBLISH_DRAG_SOURCE",h="dnd-core/HOVER",y="dnd-core/DROP",S="dnd-core/END_DRAG";function _(t,e){return{type:E,payload:{sourceClientOffset:e||null,clientOffset:t||null}}}const V={type:E,payload:{clientOffset:null,sourceClientOffset:null}};function k(t){return function(r=[],n={publishSource:!0}){const{publishSource:i=!0,clientOffset:o,getSourceClientOffset:a}=n,c=t.getMonitor(),l=t.getRegistry();t.dispatch(_(o)),q(r,c,l);const f=X(r,c);if(f==null){t.dispatch(V);return}let D=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");B(a),D=a(f)}t.dispatch(_(o,D));const b=l.getSource(f).beginDrag(c,f);if(b==null)return;F(b),l.pinSource(f);const $=l.getSourceType(f);return{type:p,payload:{itemType:$,item:b,sourceId:f,clientOffset:o||null,sourceClientOffset:D||null,isSourcePublic:!!i}}}}function q(t,e,r){s.invariant(!e.isDragging(),"Cannot call beginDrag while dragging."),t.forEach(function(n){s.invariant(r.getSource(n),"Expected sourceIds to be registered.")})}function B(t){s.invariant(typeof t=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function F(t){s.invariant(U(t),"Item must be an object.")}function X(t,e){let r=null;for(let n=t.length-1;n>=0;n--)if(e.canDragSource(t[n])){r=t[n];break}return r}function W(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function z(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){W(t,i,r[i])})}return t}function J(t){return function(r={}){const n=t.getMonitor(),i=t.getRegistry();Q(n),K(n).forEach((a,c)=>{const l=Y(a,c,i,n),f={type:y,payload:{dropResult:z({},r,l)}};t.dispatch(f)})}}function Q(t){s.invariant(t.isDragging(),"Cannot call drop while not dragging."),s.invariant(!t.didDrop(),"Cannot call drop twice during one drag operation.")}function Y(t,e,r,n){const i=r.getTarget(t);let o=i?i.drop(n,t):void 0;return Z(o),typeof o>"u"&&(o=e===0?{}:n.getDropResult()),o}function Z(t){s.invariant(typeof t>"u"||U(t),"Drop result must either be an object or undefined.")}function K(t){const e=t.getTargetIds().filter(t.canDropOnTarget,t);return e.reverse(),e}function ee(t){return function(){const r=t.getMonitor(),n=t.getRegistry();te(r);const i=r.getSourceId();return i!=null&&(n.getSource(i,!0).endDrag(r,i),n.unpinSource()),{type:S}}}function te(t){s.invariant(t.isDragging(),"Cannot call endDrag while not dragging.")}function v(t,e){return e===null?t===null:Array.isArray(t)?t.some(r=>r===e):t===e}function re(t){return function(r,{clientOffset:n}={}){ne(r);const i=r.slice(0),o=t.getMonitor(),a=t.getRegistry(),c=o.getItemType();return oe(i,a,c),ie(i,o,a),se(i,o,a),{type:h,payload:{targetIds:i,clientOffset:n||null}}}}function ne(t){s.invariant(Array.isArray(t),"Expected targetIds to be an array.")}function ie(t,e,r){s.invariant(e.isDragging(),"Cannot call hover while not dragging."),s.invariant(!e.didDrop(),"Cannot call hover after drop.");for(let n=0;n<t.length;n++){const i=t[n];s.invariant(t.lastIndexOf(i)===n,"Expected targetIds to be unique in the passed array.");const o=r.getTarget(i);s.invariant(o,"Expected targetIds to be registered.")}}function oe(t,e,r){for(let n=t.length-1;n>=0;n--){const i=t[n],o=e.getTargetType(i);v(o,r)||t.splice(n,1)}}function se(t,e,r){t.forEach(function(n){r.getTarget(n).hover(e,n)})}function ae(t){return function(){if(t.getMonitor().isDragging())return{type:I}}}function ce(t){return{beginDrag:k(t),publishDragSource:ae(t),hover:re(t),drop:J(t),endDrag:ee(t)}}class ue{receiveBackend(e){this.backend=e}getMonitor(){return this.monitor}getBackend(){return this.backend}getRegistry(){return this.monitor.registry}getActions(){const e=this,{dispatch:r}=this.store;function n(o){return(...a)=>{const c=o.apply(e,a);typeof c<"u"&&r(c)}}const i=ce(this);return Object.keys(i).reduce((o,a)=>{const c=i[a];return o[a]=n(c),o},{})}dispatch(e){this.store.dispatch(e)}constructor(e,r){this.isSetUp=!1,this.handleRefCountChange=()=>{const n=this.store.getState().refCount>0;this.backend&&(n&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!n&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=e,this.monitor=r,e.subscribe(this.handleRefCountChange)}}function fe(t,e){return{x:t.x+e.x,y:t.y+e.y}}function G(t,e){return{x:t.x-e.x,y:t.y-e.y}}function le(t){const{clientOffset:e,initialClientOffset:r,initialSourceClientOffset:n}=t;return!e||!r||!n?null:G(fe(e,n),r)}function de(t){const{clientOffset:e,initialClientOffset:r}=t;return!e||!r?null:G(e,r)}const g=[],m=[];g.__IS_NONE__=!0;m.__IS_ALL__=!0;function ge(t,e){return t===g?!1:t===m||typeof e>"u"?!0:L(e,t).length>0}class pe{subscribeToStateChange(e,r={}){const{handlerIds:n}=r;s.invariant(typeof e=="function","listener must be a function."),s.invariant(typeof n>"u"||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");let i=this.store.getState().stateId;const o=()=>{const a=this.store.getState(),c=a.stateId;try{c===i||c===i+1&&!ge(a.dirtyHandlerIds,n)||e()}finally{i=c}};return this.store.subscribe(o)}subscribeToOffsetChange(e){s.invariant(typeof e=="function","listener must be a function.");let r=this.store.getState().dragOffset;const n=()=>{const i=this.store.getState().dragOffset;i!==r&&(r=i,e())};return this.store.subscribe(n)}canDragSource(e){if(!e)return!1;const r=this.registry.getSource(e);return s.invariant(r,`Expected to find a valid source. sourceId=${e}`),this.isDragging()?!1:r.canDrag(this,e)}canDropOnTarget(e){if(!e)return!1;const r=this.registry.getTarget(e);if(s.invariant(r,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop())return!1;const n=this.registry.getTargetType(e),i=this.getItemType();return v(n,i)&&r.canDrop(this,e)}isDragging(){return!!this.getItemType()}isDraggingSource(e){if(!e)return!1;const r=this.registry.getSource(e,!0);if(s.invariant(r,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic())return!1;const n=this.registry.getSourceType(e),i=this.getItemType();return n!==i?!1:r.isDragging(this,e)}isOverTarget(e,r={shallow:!1}){if(!e)return!1;const{shallow:n}=r;if(!this.isDragging())return!1;const i=this.registry.getTargetType(e),o=this.getItemType();if(o&&!v(i,o))return!1;const a=this.getTargetIds();if(!a.length)return!1;const c=a.indexOf(e);return n?c===a.length-1:c>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return!!this.store.getState().dragOperation.isSourcePublic}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return le(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return de(this.store.getState().dragOffset)}constructor(e,r){this.store=e,this.registry=r}}const C="dnd-core/ADD_SOURCE",R="dnd-core/ADD_TARGET",x="dnd-core/REMOVE_SOURCE",O="dnd-core/REMOVE_TARGET";function he(t){return{type:C,payload:{sourceId:t}}}function ye(t){return{type:R,payload:{targetId:t}}}function Se(t){return{type:x,payload:{sourceId:t}}}function Oe(t){return{type:O,payload:{targetId:t}}}function De(t){s.invariant(typeof t.canDrag=="function","Expected canDrag to be a function."),s.invariant(typeof t.beginDrag=="function","Expected beginDrag to be a function."),s.invariant(typeof t.endDrag=="function","Expected endDrag to be a function.")}function be(t){s.invariant(typeof t.canDrop=="function","Expected canDrop to be a function."),s.invariant(typeof t.hover=="function","Expected hover to be a function."),s.invariant(typeof t.drop=="function","Expected beginDrag to be a function.")}function T(t,e){if(e&&Array.isArray(t)){t.forEach(r=>T(r,!1));return}s.invariant(typeof t=="string"||typeof t=="symbol",e?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var u;(function(t){t.SOURCE="SOURCE",t.TARGET="TARGET"})(u||(u={}));let ve=0;function Te(){return ve++}function Ee(t){const e=Te().toString();switch(t){case u.SOURCE:return`S${e}`;case u.TARGET:return`T${e}`;default:throw new Error(`Unknown Handler Role: ${t}`)}}function w(t){switch(t[0]){case"S":return u.SOURCE;case"T":return u.TARGET;default:throw new Error(`Cannot parse handler ID: ${t}`)}}function P(t,e){const r=t.entries();let n=!1;do{const{done:i,value:[,o]}=r.next();if(o===e)return!0;n=!!i}while(!n);return!1}class Ie{addSource(e,r){T(e),De(r);const n=this.addHandler(u.SOURCE,e,r);return this.store.dispatch(he(n)),n}addTarget(e,r){T(e,!0),be(r);const n=this.addHandler(u.TARGET,e,r);return this.store.dispatch(ye(n)),n}containsHandler(e){return P(this.dragSources,e)||P(this.dropTargets,e)}getSource(e,r=!1){return s.invariant(this.isSourceId(e),"Expected a valid source ID."),r&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}getTarget(e){return s.invariant(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}getSourceType(e){return s.invariant(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}getTargetType(e){return s.invariant(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}isSourceId(e){return w(e)===u.SOURCE}isTargetId(e){return w(e)===u.TARGET}removeSource(e){s.invariant(this.getSource(e),"Expected an existing source."),this.store.dispatch(Se(e)),s.asap(()=>{this.dragSources.delete(e),this.types.delete(e)})}removeTarget(e){s.invariant(this.getTarget(e),"Expected an existing target."),this.store.dispatch(Oe(e)),this.dropTargets.delete(e),this.types.delete(e)}pinSource(e){const r=this.getSource(e);s.invariant(r,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=r}unpinSource(){s.invariant(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(e,r,n){const i=Ee(e);return this.types.set(i,r),e===u.SOURCE?this.dragSources.set(i,n):e===u.TARGET&&this.dropTargets.set(i,n),i}constructor(e){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=e}}const me=(t,e)=>t===e;function Ce(t,e){return!t&&!e?!0:!t||!e?!1:t.x===e.x&&t.y===e.y}function Re(t,e,r=me){if(t.length!==e.length)return!1;for(let n=0;n<t.length;++n)if(!r(t[n],e[n]))return!1;return!0}function xe(t=g,e){switch(e.type){case h:break;case C:case R:case O:case x:return g;case p:case I:case S:case y:default:return m}const{targetIds:r=[],prevTargetIds:n=[]}=e.payload,i=N(r,n);if(!(i.length>0||!Re(r,n)))return g;const a=n[n.length-1],c=r[r.length-1];return a!==c&&(a&&i.push(a),c&&i.push(c)),i}function _e(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function we(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){_e(t,i,r[i])})}return t}const A={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function Pe(t=A,e){const{payload:r}=e;switch(e.type){case E:case p:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case h:return Ce(t.clientOffset,r.clientOffset)?t:we({},t,{clientOffset:r.clientOffset});case S:case y:return A;default:return t}}function Ae(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){Ae(t,i,r[i])})}return t}const Ue={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function Ge(t=Ue,e){const{payload:r}=e;switch(e.type){case p:return d({},t,{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case I:return d({},t,{isSourcePublic:!0});case h:return d({},t,{targetIds:r.targetIds});case O:return t.targetIds.indexOf(r.targetId)===-1?t:d({},t,{targetIds:H(t.targetIds,r.targetId)});case y:return d({},t,{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case S:return d({},t,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return t}}function $e(t=0,e){switch(e.type){case C:case R:return t+1;case x:case O:return t-1;default:return t}}function Me(t=0){return t+1}function je(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function He(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{},n=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable}))),n.forEach(function(i){je(t,i,r[i])})}return t}function Ne(t={},e){return{dirtyHandlerIds:xe(t.dirtyHandlerIds,{type:e.type,payload:He({},e.payload,{prevTargetIds:j(t,"dragOperation.targetIds",[])})}),dragOffset:Pe(t.dragOffset,e),refCount:$e(t.refCount,e),dragOperation:Ge(t.dragOperation,e),stateId:Me(t.stateId)}}function Le(t,e=void 0,r={},n=!1){const i=Ve(n),o=new pe(i,new Ie(i)),a=new ue(i,o),c=t(a,e,r);return a.receiveBackend(c),a}function Ve(t){const e=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__;return M.createStore(Ne,t&&e&&e({name:"dnd-core",instanceId:"dnd-core"}))}exports.createDragDropManager=Le;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
2
2
|
export type Maybe<T> = T | null;
|
|
3
|
-
export type InputMaybe<T> =
|
|
3
|
+
export type InputMaybe<T> = T | null | undefined;
|
|
4
4
|
export type Exact<T extends {
|
|
5
5
|
[key: string]: unknown;
|
|
6
6
|
}> = {
|