"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[1440],{18575:(e,t,n)=>{t.w$=t.uv=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(96540)),o=l(n(5556)),i=n(11447);function l(e){return e&&e.__esModule?e:{default:e}}t.uv=function(e){var t=e.itemTypeToComponent,n=e.WrapperComponent,l=void 0===n?"div":n,s=function(e){var n=e.currentPage,o=e.totalPages,s=e.boundaryPagesRange,d=e.siblingPagesRange,c=e.hideEllipsis,u=e.hidePreviousAndNextPageLinks,h=e.hideFirstAndLastPageLinks,g=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,i.getPaginationModel)({currentPage:n,totalPages:o,boundaryPagesRange:s,siblingPagesRange:d,hideEllipsis:c,hidePreviousAndNextPageLinks:u,hideFirstAndLastPageLinks:h}),_=function(e,t,n){return function(o){var i,l,s,d=e[o.type],c=(l=(i=o).value,s=i.isDisabled,function(){!s&&n&&t!==l&&n(l)});return r.default.createElement(d,a({onClick:c},o))}}(t,n,g);return r.default.createElement(l,p,P.map((function(e){return _(a({},e,{isDisabled:!!m}))})))};return s.propTypes={currentPage:o.default.number.isRequired,totalPages:o.default.number.isRequired,boundaryPagesRange:o.default.number,siblingPagesRange:o.default.number,hideEllipsis:o.default.bool,hidePreviousAndNextPageLinks:o.default.bool,hideFirstAndLastPageLinks:o.default.bool,onChange:o.default.func,disabled:o.default.bool},s},t.w$=i.ITEM_TYPES},83691:(e,t,n)=>{n.d(t,{A:()=>d});var a=n(96453),r=n(19129),o=n(12249),i=n(2445);const l=a.I4.span`
  white-space: nowrap;
  min-width: 100px;
  svg,
  i {
    margin-right: 8px;

    &:hover {
      path {
        fill: ${({theme:e})=>e.colors.primary.base};
      }
    }
  }
`,s=a.I4.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`;function d({actions:e}){return(0,i.Y)(l,{className:"actions",children:e.map(((e,t)=>{const n=o.A[e.icon];return e.tooltip?(0,i.Y)(r.m,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,children:(0,i.Y)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,i.Y)(n,{})})},t):(0,i.Y)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,i.Y)(n,{})},t)}))})}},50684:(e,t,n)=>{n.r(t),n.d(t,{default:()=>R});var a=n(96540),r=n(61574),o=n(71519),i=n(96453),l=n(17437),s=n(95579),d=n(35742),c=n(51436),u=n(74353),h=n.n(u),g=n(58561),m=n.n(g),p=n(83691),P=n(63358),_=n(37020),E=n(39854),b=n(51713),f=n(5261),v=n(50500),y=n(30703),S=n(6094),A=n(7089),I=n(12249),L=n(85861),T=n(24976),N=n(2445);const Y=i.I4.div`
  margin: ${({theme:e})=>2*e.gridUnit}px auto
    ${({theme:e})=>4*e.gridUnit}px auto;
`,w=(0,i.I4)(T.iN)`
  border-radius: ${({theme:e})=>e.borderRadius}px;
  border: 1px solid ${({theme:e})=>e.colors.secondary.light2};
`,k=i.I4.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.Ay)((({addDangerToast:e,addSuccessToast:t,annotationLayerId:n,annotation:r=null,onAnnotationAdd:o,onHide:i,show:l})=>{var d,c;const[u,h]=(0,a.useState)(!0),[g,m]=(0,a.useState)(null),p=null!==r,{state:{loading:P,resource:_},fetchResource:E,createResource:b,updateResource:f}=(0,v.fn)(`annotation_layer/${n}/annotation`,(0,s.t)("annotation"),e),T=()=>{m({short_descr:"",start_dttm:"",end_dttm:"",json_metadata:"",long_descr:""})},M=()=>{p?m(_):T(),i()},x=e=>{const{target:t}=e,n={...g,end_dttm:g?g.end_dttm:"",short_descr:g?g.short_descr:"",start_dttm:g?g.start_dttm:""};n[t.name]=t.value,m(n)};return(0,a.useEffect)((()=>{if(p&&(null==g||!g.id||r&&r.id!==g.id||l)){if(null!==(null==r?void 0:r.id)&&!P){const e=r.id||0;E(e)}}else p||g&&!g.id&&!l||T()}),[r]),(0,a.useEffect)((()=>{_&&m(_)}),[_]),(0,a.useEffect)((()=>{var e,t,n;null!=g&&null!=(e=g.short_descr)&&e.length&&null!=g&&null!=(t=g.start_dttm)&&t.length&&null!=g&&null!=(n=g.end_dttm)&&n.length?h(!1):h(!0)}),[g?g.short_descr:"",g?g.start_dttm:"",g?g.end_dttm:""]),(0,N.FD)(L.Ay,{disablePrimaryButton:u,onHandledPrimaryAction:()=>{if(p){if(null!=g&&g.id){const e=g.id;delete g.id,delete g.created_by,delete g.changed_by,delete g.changed_on_delta_humanized,delete g.layer,f(e,g).then((e=>{e&&(o&&o(),M(),t((0,s.t)("The annotation has been updated")))}))}}else g&&b(g).then((e=>{e&&(o&&o(),M(),t((0,s.t)("The annotation has been saved")))}))},onHide:M,primaryButtonName:p?(0,s.t)("Save"):(0,s.t)("Add"),show:l,width:"55%",title:(0,N.FD)("h4",{children:[p?(0,N.Y)(I.A.EditAlt,{css:y.vE}):(0,N.Y)(I.A.PlusLarge,{css:y.vE}),p?(0,s.t)("Edit annotation"):(0,s.t)("Add annotation")]}),children:[(0,N.Y)(Y,{children:(0,N.Y)("h4",{children:(0,s.t)("Basic information")})}),(0,N.FD)(k,{children:[(0,N.FD)("div",{className:"control-label",children:[(0,s.t)("Name"),(0,N.Y)("span",{className:"required",children:"*"})]}),(0,N.Y)("input",{name:"short_descr",onChange:x,type:"text",value:null==g?void 0:g.short_descr})]}),(0,N.FD)(k,{children:[(0,N.FD)("div",{className:"control-label",children:[(0,s.t)("date"),(0,N.Y)("span",{className:"required",children:"*"})]}),(0,N.Y)(S.c,{placeholder:[(0,s.t)("Start date"),(0,s.t)("End date")],format:"YYYY-MM-DD HH:mm",onCalendarChange:(e,t)=>{var n;if(null==e||!e[0]||null==e||!e[1]){var a;const e={...g,start_dttm:"",end_dttm:"",short_descr:null!=(a=null==g?void 0:g.short_descr)?a:""};return void m(e)}const r={...g,start_dttm:e[0].format("YYYY-MM-DD HH:mm"),end_dttm:e[1].format("YYYY-MM-DD HH:mm"),short_descr:null!=(n=null==g?void 0:g.short_descr)?n:""};m(r)},showTime:{format:"hh:mm a"},use12Hours:!0,value:null!=g&&null!=(d=g.start_dttm)&&d.length||null!=g&&null!=(c=g.end_dttm)&&c.length?[(0,A.XV)(g.start_dttm),(0,A.XV)(g.end_dttm)]:null})]}),(0,N.Y)(Y,{children:(0,N.Y)("h4",{children:(0,s.t)("Additional information")})}),(0,N.FD)(k,{children:[(0,N.Y)("div",{className:"control-label",children:(0,s.t)("description")}),(0,N.Y)("textarea",{name:"long_descr",value:g?g.long_descr:"",placeholder:(0,s.t)("Description (this can be seen in the list)"),onChange:x})]}),(0,N.FD)(k,{children:[(0,N.Y)("div",{className:"control-label",children:(0,s.t)("JSON metadata")}),(0,N.Y)(w,{onChange:e=>{const t={...g,end_dttm:g?g.end_dttm:"",json_metadata:e,short_descr:g?g.short_descr:"",start_dttm:g?g.start_dttm:""};m(t)},value:null!=g&&g.json_metadata?g.json_metadata:"",width:"100%",height:"120px"})]})]})})),x=i.I4.div`
  ${({theme:e})=>l.AH`
    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;
    }
  `}
`,R=(0,f.Ay)((function({addDangerToast:e,addSuccessToast:t}){const{annotationLayerId:n}=(0,r.g)(),{state:{loading:i,resourceCount:l,resourceCollection:u,bulkSelectEnabled:g},fetchData:f,refreshData:S,toggleBulkSelect:A}=(0,v.RU)(`annotation_layer/${n}/annotation`,(0,s.t)("annotation"),e,!1),[I,L]=(0,a.useState)(!1),[T,Y]=(0,a.useState)(""),[w,k]=(0,a.useState)(null),[R,D]=(0,a.useState)(null),F=e=>{k(e),L(!0)},K=(0,a.useCallback)((async function(){try{const e=await d.A.get({endpoint:`/api/v1/annotation_layer/${n}`});Y(e.json.result.name)}catch(t){await(0,c.h4)(t).then((({error:t})=>{e(t.error||t.statusText||t)}))}}),[n]);(0,a.useEffect)((()=>{K()}),[K]);const C=[{id:"short_descr",desc:!0}],$=(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}}})=>h()(new Date(e)).format("ll"),Header:(0,s.t)("Start"),accessor:"start_dttm"},{Cell:({row:{original:{end_dttm:e}}})=>h()(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:()=>F(e)},{label:"delete-action",tooltip:(0,s.t)("Delete annotation"),placement:"bottom",icon:"Trash",onClick:()=>D(e)}];return(0,N.Y)(p.A,{actions:t})},Header:(0,s.t)("Actions"),id:"actions",disableSortBy:!0}]),[!0,!0]),G=[];G.push({name:(0,N.FD)(N.FK,{children:[(0,N.Y)("i",{className:"fa fa-plus"})," ",(0,s.t)("Annotation")]}),buttonStyle:"primary",onClick:()=>{F(null)}}),G.push({name:(0,s.t)("Bulk select"),onClick:A,buttonStyle:"secondary"});let H=!0;try{(0,r.W6)()}catch(e){H=!1}const U={title:(0,s.t)("No annotation yet"),image:"filter-results.svg",buttonAction:()=>{F(null)},buttonText:(0,N.FD)(N.FK,{children:[(0,N.Y)("i",{className:"fa fa-plus"})," ",(0,s.t)("Annotation")]})};return(0,N.FD)(N.FK,{children:[(0,N.Y)(b.A,{name:(0,N.FD)(x,{children:[(0,N.Y)("span",{children:(0,s.t)("Annotation Layer %s",T)}),(0,N.Y)("span",{children:H?(0,N.Y)(o.N_,{to:"/annotationlayer/list/",children:(0,s.t)("Back to all")}):(0,N.Y)("a",{href:"/annotationlayer/list/",children:(0,s.t)("Back to all")})})]}),buttons:G}),(0,N.Y)(M,{addDangerToast:e,addSuccessToast:t,annotation:w,show:I,onAnnotationAdd:()=>S(),annotationLayerId:n,onHide:()=>L(!1)}),R&&(0,N.Y)(_.A,{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.A.delete({endpoint:`/api/v1/annotation_layer/${n}/annotation/${a}`}).then((()=>{S(),D(null),t((0,s.t)("Deleted: %s",r))}),(0,y.JF)((t=>e((0,s.t)("There was an issue deleting %s: %s",r,t)))))})(R)},onHide:()=>D(null),open:!0,title:(0,s.t)("Delete Annotation?")}),(0,N.Y)(P.A,{title:(0,s.t)("Please confirm"),description:(0,s.t)("Are you sure you want to delete the selected annotations?"),onConfirm:a=>{d.A.delete({endpoint:`/api/v1/annotation_layer/${n}/annotation/?q=${m().encode(a.map((({id:e})=>e)))}`}).then((({json:e={}})=>{S(),t(e.message)}),(0,y.JF)((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,N.Y)(E.A,{className:"annotations-list-view",bulkActions:a,bulkSelectEnabled:g,columns:$,count:l,data:u,disableBulkSelect:A,emptyState:U,fetchData:f,addDangerToast:e,addSuccessToast:t,refreshData:S,initialSort:C,loading:i,pageSize:25})}})]})}))},30327:(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}},8960:(e,t,n)=>{var a=n(30327);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}}}},17991:(e,t)=>{t.createRange=function(e,t){for(var n=[],a=e;a<=t;a++)n.push(a);return n}},11447:(e,t,n)=>{var a=n(17991),r=n(8960);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 o=null==e.boundaryPagesRange?1:Number(e.boundaryPagesRange);if(isNaN(o))throw new Error("getPaginationModel(): boundaryPagesRange should be a number");if(o<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),c=d?0:1,u=[],h=r.createPageFunctionFactory(e);if(s||u.push(r.createFirstPageLink(e)),l||u.push(r.createPreviousPageLink(e)),1+2*c+2*i+2*o>=t){var g=a.createRange(1,t).map(h);u.push.apply(u,g)}else{var m=o,p=a.createRange(1,m).map(h),P=t+1-o,_=t,E=a.createRange(P,_).map(h),b=Math.min(Math.max(n-i,m+c+1),P-c-2*i-1),f=b+2*i,v=a.createRange(b,f).map(h);if(u.push.apply(u,p),!d){var y=b-1,S=(y===m+1?h:r.createFirstEllipsis)(y);u.push(S)}if(u.push.apply(u,v),!d){var A=f+1,I=(A===P-1?h:r.createSecondEllipsis)(A);u.push(I)}u.push.apply(u,E)}return l||u.push(r.createNextPageLink(e)),s||u.push(r.createLastPageLink(e)),u};var o=n(30327);t.ITEM_TYPES=o.ITEM_TYPES,t.ITEM_KEYS=o.ITEM_KEYS}}]);