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

    &:hover {
      path {
        fill: ${({theme:e})=>e.colors.primary.base};
      }
    }
  }
`,s=a.iK.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`;function d({actions:e}){return(0,o.tZ)(l,{className:"actions",children:e.map(((e,t)=>{const n=i.Z[e.icon];return e.tooltip?(0,o.tZ)(r.u,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,children:(0,o.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,o.tZ)(n,{})})},t):(0,o.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,o.tZ)(n,{})},t)}))})}},598217:(e,t,n)=>{n.r(t),n.d(t,{default:()=>x});var a=n(667294),r=n(616550),i=n(473727),o=n(751995),l=n(211965),s=n(61988),d=n(431069),c=n(844818),u=n(730381),g=n.n(u),h=n(115926),m=n.n(h),p=n(129848),P=n(419259),_=n(217198),E=n(593139),b=n(586074),f=n(414114),v=n(34858),S=n(440768),y=n(662276),L=n(313322),I=n(774069),T=n(749140),A=n(135944);const N=o.iK.div`
  margin: ${({theme:e})=>2*e.gridUnit}px auto
    ${({theme:e})=>4*e.gridUnit}px auto;
`,k=(0,o.iK)(T.Ad)`
  border-radius: ${({theme:e})=>e.borderRadius}px;
  border: 1px solid ${({theme:e})=>e.colors.secondary.light2};
`,w=o.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%;
  }
`,M=(0,f.ZP)((({addDangerToast:e,addSuccessToast:t,annotationLayerId:n,annotation:r=null,onAnnotationAdd:i,onHide:o,show:l})=>{var d,c;const[u,h]=(0,a.useState)(!0),[m,p]=(0,a.useState)(null),P=null!==r,{state:{loading:_,resource:E},fetchResource:b,createResource:f,updateResource:T}=(0,v.LE)(`annotation_layer/${n}/annotation`,(0,s.t)("annotation"),e),M=()=>{p({short_descr:"",start_dttm:"",end_dttm:"",json_metadata:"",long_descr:""})},Z=()=>{P?p(E):M(),o()},x=e=>{const{target:t}=e,n={...m,end_dttm:m?m.end_dttm:"",short_descr:m?m.short_descr:"",start_dttm:m?m.start_dttm:""};n[t.name]=t.value,p(n)};return(0,a.useEffect)((()=>{if(P&&(null==m||!m.id||r&&r.id!==m.id||l)){if(null!==(null==r?void 0:r.id)&&!_){const e=r.id||0;b(e)}}else P||m&&!m.id&&!l||M()}),[r]),(0,a.useEffect)((()=>{E&&p(E)}),[E]),(0,a.useEffect)((()=>{var e,t,n;null!=m&&null!=(e=m.short_descr)&&e.length&&null!=m&&null!=(t=m.start_dttm)&&t.length&&null!=m&&null!=(n=m.end_dttm)&&n.length?h(!1):h(!0)}),[m?m.short_descr:"",m?m.start_dttm:"",m?m.end_dttm:""]),(0,A.BX)(I.default,{disablePrimaryButton:u,onHandledPrimaryAction:()=>{if(P){if(null!=m&&m.id){const e=m.id;delete m.id,delete m.created_by,delete m.changed_by,delete m.changed_on_delta_humanized,delete m.layer,T(e,m).then((e=>{e&&(i&&i(),Z(),t((0,s.t)("The annotation has been updated")))}))}}else m&&f(m).then((e=>{e&&(i&&i(),Z(),t((0,s.t)("The annotation has been saved")))}))},onHide:Z,primaryButtonName:P?(0,s.t)("Save"):(0,s.t)("Add"),show:l,width:"55%",title:(0,A.BX)("h4",{children:[P?(0,A.tZ)(L.Z.EditAlt,{css:S.xL}):(0,A.tZ)(L.Z.PlusLarge,{css:S.xL}),P?(0,s.t)("Edit annotation"):(0,s.t)("Add annotation")]}),children:[(0,A.tZ)(N,{children:(0,A.tZ)("h4",{children:(0,s.t)("Basic information")})}),(0,A.BX)(w,{children:[(0,A.BX)("div",{className:"control-label",children:[(0,s.t)("Name"),(0,A.tZ)("span",{className:"required",children:"*"})]}),(0,A.tZ)("input",{name:"short_descr",onChange:x,type:"text",value:null==m?void 0:m.short_descr})]}),(0,A.BX)(w,{children:[(0,A.BX)("div",{className:"control-label",children:[(0,s.t)("date"),(0,A.tZ)("span",{className:"required",children:"*"})]}),(0,A.tZ)(y.S,{placeholder:[(0,s.t)("Start date"),(0,s.t)("End date")],format:"YYYY-MM-DD HH:mm",onChange:(e,t)=>{const n={...m,end_dttm:m&&t[1].length?g()(t[1]).format("YYYY-MM-DD HH:mm"):"",short_descr:m?m.short_descr:"",start_dttm:m&&t[0].length?g()(t[0]).format("YYYY-MM-DD HH:mm"):""};p(n)},showTime:{format:"hh:mm a"},use12Hours:!0,value:null!=m&&null!=(d=m.start_dttm)&&d.length||null!=m&&null!=(c=m.end_dttm)&&c.length?[g()(m.start_dttm),g()(m.end_dttm)]:null})]}),(0,A.tZ)(N,{children:(0,A.tZ)("h4",{children:(0,s.t)("Additional information")})}),(0,A.BX)(w,{children:[(0,A.tZ)("div",{className:"control-label",children:(0,s.t)("description")}),(0,A.tZ)("textarea",{name:"long_descr",value:m?m.long_descr:"",placeholder:(0,s.t)("Description (this can be seen in the list)"),onChange:x})]}),(0,A.BX)(w,{children:[(0,A.tZ)("div",{className:"control-label",children:(0,s.t)("JSON metadata")}),(0,A.tZ)(k,{onChange:e=>{const t={...m,end_dttm:m?m.end_dttm:"",json_metadata:e,short_descr:m?m.short_descr:"",start_dttm:m?m.start_dttm:""};p(t)},value:null!=m&&m.json_metadata?m.json_metadata:"",width:"100%",height:"120px"})]})]})})),Z=o.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;
    }
  `}
`,x=(0,f.ZP)((function({addDangerToast:e,addSuccessToast:t}){const{annotationLayerId:n}=(0,r.UO)(),{state:{loading:o,resourceCount:l,resourceCollection:u,bulkSelectEnabled:h},fetchData:f,refreshData:y,toggleBulkSelect:L}=(0,v.Yi)(`annotation_layer/${n}/annotation`,(0,s.t)("annotation"),e,!1),[I,T]=(0,a.useState)(!1),[N,k]=(0,a.useState)(""),[w,x]=(0,a.useState)(null),[R,Y]=(0,a.useState)(null),K=e=>{x(e),T(!0)},C=(0,a.useCallback)((async function(){try{const e=await d.Z.get({endpoint:`/api/v1/annotation_layer/${n}`});k(e.json.result.name)}catch(t){await(0,c.O$)(t).then((({error:t})=>{e(t.error||t.statusText||t)}))}}),[n]);(0,a.useEffect)((()=>{C()}),[C]);const $=[{id:"short_descr",desc:!0}],B=(0,a.useMemo)((()=>[{accessor:"short_descr",Header:(0,s.t)("Name")},{accessor:"long_descr",Header:(0,s.t)("Description")},{Cell:({row:{original:{start_dttm:e}}})=>g()(new Date(e)).format("ll"),Header:(0,s.t)("Start"),accessor:"start_dttm"},{Cell:({row:{original:{end_dttm:e}}})=>g()(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:()=>K(e)},{label:"delete-action",tooltip:(0,s.t)("Delete annotation"),placement:"bottom",icon:"Trash",onClick:()=>Y(e)}];return(0,A.tZ)(p.Z,{actions:t})},Header:(0,s.t)("Actions"),id:"actions",disableSortBy:!0}]),[!0,!0]),D=[];D.push({name:(0,A.BX)(A.HY,{children:[(0,A.tZ)("i",{className:"fa fa-plus"})," ",(0,s.t)("Annotation")]}),buttonStyle:"primary",onClick:()=>{K(null)}}),D.push({name:(0,s.t)("Bulk select"),onClick:L,buttonStyle:"secondary"});let G=!0;try{(0,r.k6)()}catch(e){G=!1}const F={title:(0,s.t)("No annotation yet"),image:"filter-results.svg",buttonAction:()=>{K(null)},buttonText:(0,A.BX)(A.HY,{children:[(0,A.tZ)("i",{className:"fa fa-plus"})," ",(0,s.t)("Annotation")]})};return(0,A.BX)(A.HY,{children:[(0,A.tZ)(b.Z,{name:(0,A.BX)(Z,{children:[(0,A.tZ)("span",{children:(0,s.t)("Annotation Layer %s",N)}),(0,A.tZ)("span",{children:G?(0,A.tZ)(i.rU,{to:"/annotationlayer/list/",children:(0,s.t)("Back to all")}):(0,A.tZ)("a",{href:"/annotationlayer/list/",children:(0,s.t)("Back to all")})})]}),buttons:D}),(0,A.tZ)(M,{addDangerToast:e,addSuccessToast:t,annotation:w,show:I,onAnnotationAdd:()=>y(),annotationLayerId:n,onHide:()=>T(!1)}),R&&(0,A.tZ)(_.Z,{description:(0,s.t)("Are you sure you want to delete %s?",null==R?void 0:R.short_descr),onConfirm:()=>{R&&(({id:a,short_descr:r})=>{d.Z.delete({endpoint:`/api/v1/annotation_layer/${n}/annotation/${a}`}).then((()=>{y(),Y(null),t((0,s.t)("Deleted: %s",r))}),(0,S.v$)((t=>e((0,s.t)("There was an issue deleting %s: %s",r,t)))))})(R)},onHide:()=>Y(null),open:!0,title:(0,s.t)("Delete Annotation?")}),(0,A.tZ)(P.Z,{title:(0,s.t)("Please confirm"),description:(0,s.t)("Are you sure you want to delete the selected annotations?"),onConfirm:a=>{d.Z.delete({endpoint:`/api/v1/annotation_layer/${n}/annotation/?q=${m().encode(a.map((({id:e})=>e)))}`}).then((({json:e={}})=>{y(),t(e.message)}),(0,S.v$)((t=>e((0,s.t)("There was an issue deleting the selected annotations: %s",t)))))},children:n=>{const a=[{key:"delete",name:(0,s.t)("Delete"),onSelect:n,type:"danger"}];return(0,A.tZ)(E.Z,{className:"annotations-list-view",bulkActions:a,bulkSelectEnabled:h,columns:B,count:l,data:u,disableBulkSelect:L,emptyState:F,fetchData:f,addDangerToast:e,addSuccessToast:t,refreshData:y,initialSort:$,loading:o,pageSize:25})}})]})}))},656590:(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}},653804:(e,t,n)=>{var a=n(656590);t.createFirstEllipsis=function(e){return{type:a.ITEM_TYPES.ELLIPSIS,key:a.ITEM_KEYS.FIRST_ELLIPSIS,value:e,isActive:!1}},t.createSecondEllipsis=function(e){return{type:a.ITEM_TYPES.ELLIPSIS,key:a.ITEM_KEYS.SECOND_ELLIPSIS,value:e,isActive:!1}},t.createFirstPageLink=function(e){var t=e.currentPage;return{type:a.ITEM_TYPES.FIRST_PAGE_LINK,key:a.ITEM_KEYS.FIRST_PAGE_LINK,value:1,isActive:1===t}},t.createPreviousPageLink=function(e){var t=e.currentPage;return{type:a.ITEM_TYPES.PREVIOUS_PAGE_LINK,key:a.ITEM_KEYS.PREVIOUS_PAGE_LINK,value:Math.max(1,t-1),isActive:1===t}},t.createNextPageLink=function(e){var t=e.currentPage,n=e.totalPages;return{type:a.ITEM_TYPES.NEXT_PAGE_LINK,key:a.ITEM_KEYS.NEXT_PAGE_LINK,value:Math.min(n,t+1),isActive:t===n}},t.createLastPageLink=function(e){var t=e.currentPage,n=e.totalPages;return{type:a.ITEM_TYPES.LAST_PAGE_LINK,key:a.ITEM_KEYS.LAST_PAGE_LINK,value:n,isActive:t===n}},t.createPageFunctionFactory=function(e){var t=e.currentPage;return function(e){return{type:a.ITEM_TYPES.PAGE,key:e,value:e,isActive:e===t}}}},1158:(e,t)=>{t.createRange=function(e,t){for(var n=[],a=e;a<=t;a++)n.push(a);return n}},402371:(e,t,n)=>{var a=n(1158),r=n(653804);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 n=Number(e.currentPage);if(isNaN(n))throw new Error("getPaginationModel(): currentPage should be a number");if(n<0)throw new Error("getPaginationModel(): currentPage shouldn't be a negative number");if(n>t)throw new Error("getPaginationModel(): currentPage shouldn't be greater than totalPages");var i=null==e.boundaryPagesRange?1:Number(e.boundaryPagesRange);if(isNaN(i))throw new Error("getPaginationModel(): boundaryPagesRange should be a number");if(i<0)throw new Error("getPaginationModel(): boundaryPagesRange shouldn't be a negative number");var o=null==e.siblingPagesRange?1:Number(e.siblingPagesRange);if(isNaN(o))throw new Error("getPaginationModel(): siblingPagesRange should be a number");if(o<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),c=d?0:1,u=[],g=r.createPageFunctionFactory(e);if(s||u.push(r.createFirstPageLink(e)),l||u.push(r.createPreviousPageLink(e)),1+2*c+2*o+2*i>=t){var h=a.createRange(1,t).map(g);u.push.apply(u,h)}else{var m=i,p=a.createRange(1,m).map(g),P=t+1-i,_=t,E=a.createRange(P,_).map(g),b=Math.min(Math.max(n-o,m+c+1),P-c-2*o-1),f=b+2*o,v=a.createRange(b,f).map(g);if(u.push.apply(u,p),!d){var S=b-1,y=(S===m+1?g:r.createFirstEllipsis)(S);u.push(y)}if(u.push.apply(u,v),!d){var L=f+1,I=(L===P-1?g:r.createSecondEllipsis)(L);u.push(I)}u.push.apply(u,E)}return l||u.push(r.createNextPageLink(e)),s||u.push(r.createLastPageLink(e)),u};var i=n(656590);t.ITEM_TYPES=i.ITEM_TYPES,t.ITEM_KEYS=i.ITEM_KEYS}}]);
//# sourceMappingURL=5dddc4316b1c8e529faf.chunk.js.map