"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[1611],{52630:(e,t,a)=>{t.iB=t.YM=void 0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},o=l(a(67294)),r=l(a(45697)),i=a(2371);function l(e){return e&&e.__esModule?e:{default:e}}t.YM=function(e){var t=e.itemTypeToComponent,a=e.WrapperComponent,l=void 0===a?"div":a,s=function(e){var a=e.currentPage,r=e.totalPages,s=e.boundaryPagesRange,d=e.siblingPagesRange,u=e.hideEllipsis,c=e.hidePreviousAndNextPageLinks,g=e.hideFirstAndLastPageLinks,h=e.onChange,m=e.disabled,p=function(e,t){var a={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=e[n]);return a}(e,["currentPage","totalPages","boundaryPagesRange","siblingPagesRange","hideEllipsis","hidePreviousAndNextPageLinks","hideFirstAndLastPageLinks","onChange","disabled"]),P=(0,i.getPaginationModel)({currentPage:a,totalPages:r,boundaryPagesRange:s,siblingPagesRange:d,hideEllipsis:u,hidePreviousAndNextPageLinks:c,hideFirstAndLastPageLinks:g}),_=function(e,t,a){return function(r){var i,l,s,d=e[r.type],u=(l=(i=r).value,s=i.isDisabled,function(){!s&&a&&t!==l&&a(l)});return o.default.createElement(d,n({onClick:u},r))}}(t,a,h);return o.default.createElement(l,p,P.map((function(e){return _(n({},e,{isDisabled:!!m}))})))};return s.propTypes={currentPage:r.default.number.isRequired,totalPages:r.default.number.isRequired,boundaryPagesRange:r.default.number,siblingPagesRange:r.default.number,hideEllipsis:r.default.bool,hidePreviousAndNextPageLinks:r.default.bool,hideFirstAndLastPageLinks:r.default.bool,onChange:r.default.func,disabled:r.default.bool},s},t.iB=i.ITEM_TYPES},29848:(e,t,a)=>{a.d(t,{Z:()=>d}),a(67294);var n=a(51995),o=a(58593),r=a(70707),i=a(11965);const l=n.iK.span`
  white-space: nowrap;
  min-width: 100px;
  svg,
  i {
    margin-right: 8px;

    &:hover {
      path {
        fill: ${({theme:e})=>e.colors.primary.base};
      }
    }
  }
`,s=n.iK.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`;function d({actions:e}){return(0,i.tZ)(l,{className:"actions"},e.map(((e,t)=>{const a=r.Z[e.icon];return e.tooltip?(0,i.tZ)(o.u,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,key:t},(0,i.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick},(0,i.tZ)(a,null))):(0,i.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,key:t},(0,i.tZ)(a,null))})))}},98217:(e,t,a)=>{a.r(t),a.d(t,{default:()=>M});var n=a(67294),o=a(16550),r=a(73727),i=a(51995),l=a(11965),s=a(61988),d=a(31069),u=a(30381),c=a.n(u),g=a(15926),h=a.n(g),m=a(29848),p=a(19259),P=a(17198),_=a(93139),E=a(86074),b=a(98286),f=a(14114),v=a(34858),S=a(40768),y=a(62276),L=a(70707),I=a(74069),T=a(94670);const A=i.iK.div`
  margin: ${({theme:e})=>2*e.gridUnit}px auto
    ${({theme:e})=>4*e.gridUnit}px auto;
`,N=(0,i.iK)(T.Ad)`
  border-radius: ${({theme:e})=>e.borderRadius}px;
  border: 1px solid ${({theme:e})=>e.colors.secondary.light2};
`,Z=i.iK.div`
  margin-bottom: ${({theme:e})=>5*e.gridUnit}px;

  .control-label {
    margin-bottom: ${({theme:e})=>2*e.gridUnit}px;
  }

  .required {
    margin-left: ${({theme:e})=>e.gridUnit/2}px;
    color: ${({theme:e})=>e.colors.error.base};
  }

  textarea {
    flex: 1 1 auto;
    height: ${({theme:e})=>17*e.gridUnit}px;
    resize: none;
    width: 100%;
  }

  textarea,
  input[type='text'] {
    padding: ${({theme:e})=>1.5*e.gridUnit}px
      ${({theme:e})=>2*e.gridUnit}px;
    border: 1px solid ${({theme:e})=>e.colors.grayscale.light2};
    border-radius: ${({theme:e})=>e.gridUnit}px;
  }

  input[type='text'] {
    width: 65%;
  }
`,k=(0,f.ZP)((({addDangerToast:e,addSuccessToast:t,annotationLayerId:a,annotation:o=null,onAnnotationAdd:r,onHide:i,show:d})=>{var u,g;const[h,m]=(0,n.useState)(!0),[p,P]=(0,n.useState)(null),_=null!==o,{state:{loading:E,resource:b},fetchResource:f,createResource:T,updateResource:k}=(0,v.LE)(`annotation_layer/${a}/annotation`,(0,s.t)("annotation"),e),w=()=>{P({short_descr:"",start_dttm:"",end_dttm:"",json_metadata:"",long_descr:""})},M=()=>{_?P(b):w(),i()},x=e=>{const{target:t}=e,a={...p,end_dttm:p?p.end_dttm:"",short_descr:p?p.short_descr:"",start_dttm:p?p.start_dttm:""};a[t.name]=t.value,P(a)};return(0,n.useEffect)((()=>{if(_&&(null==p||!p.id||o&&o.id!==p.id||d)){if(null!==(null==o?void 0:o.id)&&!E){const e=o.id||0;f(e)}}else _||p&&!p.id&&!d||w()}),[o]),(0,n.useEffect)((()=>{b&&P(b)}),[b]),(0,n.useEffect)((()=>{var e,t,a;null!=p&&null!=(e=p.short_descr)&&e.length&&null!=p&&null!=(t=p.start_dttm)&&t.length&&null!=p&&null!=(a=p.end_dttm)&&a.length?m(!1):m(!0)}),[p?p.short_descr:"",p?p.start_dttm:"",p?p.end_dttm:""]),(0,l.tZ)(I.default,{disablePrimaryButton:h,onHandledPrimaryAction:()=>{if(_){if(null!=p&&p.id){const e=p.id;delete p.id,delete p.created_by,delete p.changed_by,delete p.changed_on_delta_humanized,delete p.layer,k(e,p).then((e=>{e&&(r&&r(),M(),t((0,s.t)("The annotation has been updated")))}))}}else p&&T(p).then((e=>{e&&(r&&r(),M(),t((0,s.t)("The annotation has been saved")))}))},onHide:M,primaryButtonName:_?(0,s.t)("Save"):(0,s.t)("Add"),show:d,width:"55%",title:(0,l.tZ)("h4",null,_?(0,l.tZ)(L.Z.EditAlt,{css:S.xL}):(0,l.tZ)(L.Z.PlusLarge,{css:S.xL}),_?(0,s.t)("Edit annotation"):(0,s.t)("Add annotation"))},(0,l.tZ)(A,null,(0,l.tZ)("h4",null,(0,s.t)("Basic information"))),(0,l.tZ)(Z,null,(0,l.tZ)("div",{className:"control-label"},(0,s.t)("Name"),(0,l.tZ)("span",{className:"required"},"*")),(0,l.tZ)("input",{name:"short_descr",onChange:x,type:"text",value:null==p?void 0:p.short_descr})),(0,l.tZ)(Z,null,(0,l.tZ)("div",{className:"control-label"},(0,s.t)("date"),(0,l.tZ)("span",{className:"required"},"*")),(0,l.tZ)(y.S,{placeholder:[(0,s.t)("Start date"),(0,s.t)("End date")],format:"YYYY-MM-DD HH:mm",onChange:(e,t)=>{const a={...p,end_dttm:p&&t[1].length?c()(t[1]).format("YYYY-MM-DD HH:mm"):"",short_descr:p?p.short_descr:"",start_dttm:p&&t[0].length?c()(t[0]).format("YYYY-MM-DD HH:mm"):""};P(a)},showTime:{format:"hh:mm a"},use12Hours:!0,value:null!=p&&null!=(u=p.start_dttm)&&u.length||null!=p&&null!=(g=p.end_dttm)&&g.length?[c()(p.start_dttm),c()(p.end_dttm)]:null})),(0,l.tZ)(A,null,(0,l.tZ)("h4",null,(0,s.t)("Additional information"))),(0,l.tZ)(Z,null,(0,l.tZ)("div",{className:"control-label"},(0,s.t)("description")),(0,l.tZ)("textarea",{name:"long_descr",value:p?p.long_descr:"",placeholder:(0,s.t)("Description (this can be seen in the list)"),onChange:x})),(0,l.tZ)(Z,null,(0,l.tZ)("div",{className:"control-label"},(0,s.t)("JSON metadata")),(0,l.tZ)(N,{onChange:e=>{const t={...p,end_dttm:p?p.end_dttm:"",json_metadata:e,short_descr:p?p.short_descr:"",start_dttm:p?p.start_dttm:""};P(t)},value:null!=p&&p.json_metadata?p.json_metadata:"",width:"100%",height:"120px"})))})),w=i.iK.div`
  ${({theme:e})=>l.iv`
    display: flex;
    flex-direction: row;

    a,
    Link {
      margin-left: ${4*e.gridUnit}px;
      font-size: ${e.typography.sizes.s}px;
      font-weight: ${e.typography.weights.normal};
      text-decoration: underline;
    }
  `}
`,M=(0,f.ZP)((function({addDangerToast:e,addSuccessToast:t}){const{annotationLayerId:a}=(0,o.UO)(),{state:{loading:i,resourceCount:u,resourceCollection:g,bulkSelectEnabled:f},fetchData:y,refreshData:L,toggleBulkSelect:I}=(0,v.Yi)(`annotation_layer/${a}/annotation`,(0,s.t)("annotation"),e,!1),[T,A]=(0,n.useState)(!1),[N,Z]=(0,n.useState)(""),[M,x]=(0,n.useState)(null),[R,K]=(0,n.useState)(null),Y=e=>{x(e),A(!0)},C=(0,n.useCallback)((async function(){try{const e=await d.Z.get({endpoint:`/api/v1/annotation_layer/${a}`});Z(e.json.result.name)}catch(t){await(0,b.O$)(t).then((({error:t})=>{e(t.error||t.statusText||t)}))}}),[a]);(0,n.useEffect)((()=>{C()}),[C]);const $=[{id:"short_descr",desc:!0}],D=(0,n.useMemo)((()=>[{accessor:"short_descr",Header:(0,s.t)("Name")},{accessor:"long_descr",Header:(0,s.t)("Description")},{Cell:({row:{original:{start_dttm:e}}})=>c()(new Date(e)).format("ll"),Header:(0,s.t)("Start"),accessor:"start_dttm"},{Cell:({row:{original:{end_dttm:e}}})=>c()(new Date(e)).format("ll"),Header:(0,s.t)("End"),accessor:"end_dttm"},{Cell:({row:{original:e}})=>{const t=[{label:"edit-action",tooltip:(0,s.t)("Edit annotation"),placement:"bottom",icon:"Edit",onClick:()=>Y(e)},{label:"delete-action",tooltip:(0,s.t)("Delete annotation"),placement:"bottom",icon:"Trash",onClick:()=>K(e)}];return(0,l.tZ)(m.Z,{actions:t})},Header:(0,s.t)("Actions"),id:"actions",disableSortBy:!0}]),[!0,!0]),F=[];F.push({name:(0,l.tZ)(n.Fragment,null,(0,l.tZ)("i",{className:"fa fa-plus"})," ",(0,s.t)("Annotation")),buttonStyle:"primary",onClick:()=>{Y(null)}}),F.push({name:(0,s.t)("Bulk select"),onClick:I,buttonStyle:"secondary","data-test":"annotation-bulk-select"});let G=!0;try{(0,o.k6)()}catch(e){G=!1}const H={title:(0,s.t)("No annotation yet"),image:"filter-results.svg",buttonAction:()=>{Y(null)},buttonText:(0,l.tZ)(n.Fragment,null,(0,l.tZ)("i",{className:"fa fa-plus"})," ",(0,s.t)("Annotation"))};return(0,l.tZ)(n.Fragment,null,(0,l.tZ)(E.Z,{name:(0,l.tZ)(w,null,(0,l.tZ)("span",null,(0,s.t)("Annotation Layer %s",N)),(0,l.tZ)("span",null,G?(0,l.tZ)(r.rU,{to:"/annotationlayer/list/"},(0,s.t)("Back to all")):(0,l.tZ)("a",{href:"/annotationlayer/list/"},(0,s.t)("Back to all")))),buttons:F}),(0,l.tZ)(k,{addDangerToast:e,addSuccessToast:t,annotation:M,show:T,onAnnotationAdd:()=>L(),annotationLayerId:a,onHide:()=>A(!1)}),R&&(0,l.tZ)(P.Z,{description:(0,s.t)("Are you sure you want to delete %s?",null==R?void 0:R.short_descr),onConfirm:()=>{R&&(({id:n,short_descr:o})=>{d.Z.delete({endpoint:`/api/v1/annotation_layer/${a}/annotation/${n}`}).then((()=>{L(),K(null),t((0,s.t)("Deleted: %s",o))}),(0,S.v$)((t=>e((0,s.t)("There was an issue deleting %s: %s",o,t)))))})(R)},onHide:()=>K(null),open:!0,title:(0,s.t)("Delete Annotation?")}),(0,l.tZ)(p.Z,{title:(0,s.t)("Please confirm"),description:(0,s.t)("Are you sure you want to delete the selected annotations?"),onConfirm:n=>{d.Z.delete({endpoint:`/api/v1/annotation_layer/${a}/annotation/?q=${h().encode(n.map((({id:e})=>e)))}`}).then((({json:e={}})=>{L(),t(e.message)}),(0,S.v$)((t=>e((0,s.t)("There was an issue deleting the selected annotations: %s",t)))))}},(a=>{const n=[{key:"delete",name:(0,s.t)("Delete"),onSelect:a,type:"danger"}];return(0,l.tZ)(_.Z,{className:"annotations-list-view",bulkActions:n,bulkSelectEnabled:f,columns:D,count:u,data:g,disableBulkSelect:I,emptyState:H,fetchData:y,addDangerToast:e,addSuccessToast:t,refreshData:L,initialSort:$,loading:i,pageSize:25})})))}))},56590:(e,t)=>{t.ITEM_TYPES={PAGE:"PAGE",ELLIPSIS:"ELLIPSIS",FIRST_PAGE_LINK:"FIRST_PAGE_LINK",PREVIOUS_PAGE_LINK:"PREVIOUS_PAGE_LINK",NEXT_PAGE_LINK:"NEXT_PAGE_LINK",LAST_PAGE_LINK:"LAST_PAGE_LINK"},t.ITEM_KEYS={FIRST_ELLIPSIS:-1,SECOND_ELLIPSIS:-2,FIRST_PAGE_LINK:-3,PREVIOUS_PAGE_LINK:-4,NEXT_PAGE_LINK:-5,LAST_PAGE_LINK:-6}},53804:(e,t,a)=>{var n=a(56590);t.createFirstEllipsis=function(e){return{type:n.ITEM_TYPES.ELLIPSIS,key:n.ITEM_KEYS.FIRST_ELLIPSIS,value:e,isActive:!1}},t.createSecondEllipsis=function(e){return{type:n.ITEM_TYPES.ELLIPSIS,key:n.ITEM_KEYS.SECOND_ELLIPSIS,value:e,isActive:!1}},t.createFirstPageLink=function(e){var t=e.currentPage;return{type:n.ITEM_TYPES.FIRST_PAGE_LINK,key:n.ITEM_KEYS.FIRST_PAGE_LINK,value:1,isActive:1===t}},t.createPreviousPageLink=function(e){var t=e.currentPage;return{type:n.ITEM_TYPES.PREVIOUS_PAGE_LINK,key:n.ITEM_KEYS.PREVIOUS_PAGE_LINK,value:Math.max(1,t-1),isActive:1===t}},t.createNextPageLink=function(e){var t=e.currentPage,a=e.totalPages;return{type:n.ITEM_TYPES.NEXT_PAGE_LINK,key:n.ITEM_KEYS.NEXT_PAGE_LINK,value:Math.min(a,t+1),isActive:t===a}},t.createLastPageLink=function(e){var t=e.currentPage,a=e.totalPages;return{type:n.ITEM_TYPES.LAST_PAGE_LINK,key:n.ITEM_KEYS.LAST_PAGE_LINK,value:a,isActive:t===a}},t.createPageFunctionFactory=function(e){var t=e.currentPage;return function(e){return{type:n.ITEM_TYPES.PAGE,key:e,value:e,isActive:e===t}}}},1158:(e,t)=>{t.createRange=function(e,t){for(var a=[],n=e;n<=t;n++)a.push(n);return a}},2371:(e,t,a)=>{var n=a(1158),o=a(53804);t.getPaginationModel=function(e){if(null==e)throw new Error("getPaginationModel(): options object should be a passed");var t=Number(e.totalPages);if(isNaN(t))throw new Error("getPaginationModel(): totalPages should be a number");if(t<0)throw new Error("getPaginationModel(): totalPages shouldn't be a negative number");var a=Number(e.currentPage);if(isNaN(a))throw new Error("getPaginationModel(): currentPage should be a number");if(a<0)throw new Error("getPaginationModel(): currentPage shouldn't be a negative number");if(a>t)throw new Error("getPaginationModel(): currentPage shouldn't be greater than totalPages");var r=null==e.boundaryPagesRange?1:Number(e.boundaryPagesRange);if(isNaN(r))throw new Error("getPaginationModel(): boundaryPagesRange should be a number");if(r<0)throw new Error("getPaginationModel(): boundaryPagesRange shouldn't be a negative number");var i=null==e.siblingPagesRange?1:Number(e.siblingPagesRange);if(isNaN(i))throw new Error("getPaginationModel(): siblingPagesRange should be a number");if(i<0)throw new Error("getPaginationModel(): siblingPagesRange shouldn't be a negative number");var l=Boolean(e.hidePreviousAndNextPageLinks),s=Boolean(e.hideFirstAndLastPageLinks),d=Boolean(e.hideEllipsis),u=d?0:1,c=[],g=o.createPageFunctionFactory(e);if(s||c.push(o.createFirstPageLink(e)),l||c.push(o.createPreviousPageLink(e)),1+2*u+2*i+2*r>=t){var h=n.createRange(1,t).map(g);c.push.apply(c,h)}else{var m=r,p=n.createRange(1,m).map(g),P=t+1-r,_=t,E=n.createRange(P,_).map(g),b=Math.min(Math.max(a-i,m+u+1),P-u-2*i-1),f=b+2*i,v=n.createRange(b,f).map(g);if(c.push.apply(c,p),!d){var S=b-1,y=(S===m+1?g:o.createFirstEllipsis)(S);c.push(y)}if(c.push.apply(c,v),!d){var L=f+1,I=(L===P-1?g:o.createSecondEllipsis)(L);c.push(I)}c.push.apply(c,E)}return l||c.push(o.createNextPageLink(e)),s||c.push(o.createLastPageLink(e)),c};var r=a(56590);t.ITEM_TYPES=r.ITEM_TYPES,t.ITEM_KEYS=r.ITEM_KEYS}}]);
//# sourceMappingURL=ac37f9330af6fc94147b.chunk.js.map