"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[906],{452630:(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},r=l(a(667294)),i=l(a(45697)),o=a(402371);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,i=e.totalPages,s=e.boundaryPagesRange,d=e.siblingPagesRange,c=e.hideEllipsis,u=e.hidePreviousAndNextPageLinks,g=e.hideFirstAndLastPageLinks,h=e.onChange,p=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"]),m=(0,o.getPaginationModel)({currentPage:a,totalPages:i,boundaryPagesRange:s,siblingPagesRange:d,hideEllipsis:c,hidePreviousAndNextPageLinks:u,hideFirstAndLastPageLinks:g}),E=function(e,t,a){return function(i){var o,l,s,d=e[i.type],c=(l=(o=i).value,s=o.isDisabled,function(){!s&&a&&t!==l&&a(l)});return r.default.createElement(d,n({onClick:c},i))}}(t,a,h);return r.default.createElement(l,P,m.map((function(e){return E(n({},e,{isDisabled:!!p}))})))};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},554070:(e,t,a)=>{a.d(t,{w:()=>l});var n=a(358593),r=a(83379),i=a(61988),o=a(135944);const l=({user:e,date:t})=>{const a=(0,o.tZ)("span",{className:"no-wrap",children:t});if(e){const t=(0,r.Z)(e),l=(0,i.t)("Modified by: %s",t);return(0,o.tZ)(n.u,{title:l,placement:"bottom",children:a})}return a}},129848:(e,t,a)=>{a.d(t,{Z:()=>d});var n=a(751995),r=a(358593),i=a(313322),o=a(135944);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,o.tZ)(l,{className:"actions",children:e.map(((e,t)=>{const a=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)(a,{})})},t):(0,o.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,o.tZ)(a,{})},t)}))})}},778768:(e,t,a)=>{a.r(t),a.d(t,{default:()=>A});var n=a(667294),r=a(115926),i=a.n(r),o=a(61988),l=a(431069),s=a(616550),d=a(473727),c=a(34858),u=a(440768),g=a(414114),h=a(586074),p=a(129848),P=a(593139),m=a(217198),E=a(419259),b=a(751995),y=a(313322),f=a(774069),_=a(135944);const v=b.iK.div`
  margin: ${({theme:e})=>2*e.gridUnit}px auto
    ${({theme:e})=>4*e.gridUnit}px auto;
`,S=b.iK.div`
  margin-bottom: ${({theme:e})=>10*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,
  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;
    width: 50%;
  }

  input,
  textarea {
    flex: 1 1 auto;
  }

  textarea {
    width: 100%;
    height: 160px;
    resize: none;
  }

  input::placeholder,
  textarea::placeholder {
    color: ${({theme:e})=>e.colors.grayscale.light1};
  }
`,L=(0,g.ZP)((({addDangerToast:e,addSuccessToast:t,onLayerAdd:a,onHide:r,show:i,layer:l=null})=>{const[s,d]=(0,n.useState)(!0),[g,h]=(0,n.useState)(),[p,P]=(0,n.useState)(!0),m=null!==l,{state:{loading:E,resource:b},fetchResource:L,createResource:I,updateResource:T}=(0,c.LE)("annotation_layer",(0,o.t)("annotation_layer"),e),A=()=>{h({name:"",descr:""})},N=()=>{P(!0),A(),r()},w=e=>{const{target:t}=e,a={...g,name:g?g.name:"",descr:g?g.descr:""};a[t.name]=t.value,h(a)};return(0,n.useEffect)((()=>{if(m&&(null==g||!g.id||l&&l.id!==g.id||p&&i)){if(i&&l&&null!==l.id&&!E){const e=l.id||0;L(e)}}else!m&&(!g||g.id||p&&i)&&A()}),[l,i]),(0,n.useEffect)((()=>{b&&h(b)}),[b]),(0,n.useEffect)((()=>{var e;null!=g&&null!=(e=g.name)&&e.length?d(!1):d(!0)}),[g?g.name:"",g?g.descr:""]),p&&i&&P(!1),(0,_.BX)(f.default,{disablePrimaryButton:s,onHandledPrimaryAction:()=>{if(m){if(null!=g&&g.id){const e=g.id;delete g.id,delete g.created_by,T(e,g).then((e=>{e&&(N(),t((0,o.t)("Annotation template updated")))}))}}else g&&I(g).then((e=>{e&&(a&&a(e),N(),t((0,o.t)("Annotation template created")))}))},onHide:N,primaryButtonName:m?(0,o.t)("Save"):(0,o.t)("Add"),show:i,width:"55%",title:(0,_.BX)("h4",{children:[m?(0,_.tZ)(y.Z.EditAlt,{css:u.xL}):(0,_.tZ)(y.Z.PlusLarge,{css:u.xL}),m?(0,o.t)("Edit annotation layer properties"):(0,o.t)("Add annotation layer")]}),children:[(0,_.tZ)(v,{children:(0,_.tZ)("h4",{children:(0,o.t)("Basic information")})}),(0,_.BX)(S,{children:[(0,_.BX)("div",{className:"control-label",children:[(0,o.t)("Annotation layer name"),(0,_.tZ)("span",{className:"required",children:"*"})]}),(0,_.tZ)("input",{name:"name",onChange:w,type:"text",value:null==g?void 0:g.name})]}),(0,_.BX)(S,{children:[(0,_.tZ)("div",{className:"control-label",children:(0,o.t)("description")}),(0,_.tZ)("textarea",{name:"descr",value:null==g?void 0:g.descr,placeholder:(0,o.t)("Description (this can be seen in the list)"),onChange:w})]})]})}));var I=a(554070),T=a(400012);const A=(0,g.ZP)((function({addDangerToast:e,addSuccessToast:t,user:a}){const{state:{loading:r,resourceCount:g,resourceCollection:b,bulkSelectEnabled:y},hasPerm:f,fetchData:v,refreshData:S,toggleBulkSelect:A}=(0,c.Yi)("annotation_layer",(0,o.t)("Annotation layers"),e),[N,w]=(0,n.useState)(!1),[k,M]=(0,n.useState)(null),[Z,R]=(0,n.useState)(null),x=f("can_write"),K=f("can_write"),C=f("can_write");function Y(e){M(e),w(!0)}const G=[{id:"name",desc:!0}],$=(0,n.useMemo)((()=>[{accessor:"name",Header:(0,o.t)("Name"),Cell:({row:{original:{id:e,name:t}}})=>{let a=!0;try{(0,s.k6)()}catch(e){a=!1}return a?(0,_.tZ)(d.rU,{to:`/annotationlayer/${e}/annotation`,children:t}):(0,_.tZ)("a",{href:`/annotationlayer/${e}/annotation`,children:t})}},{accessor:"descr",Header:(0,o.t)("Description")},{Cell:({row:{original:{changed_on_delta_humanized:e,changed_by:t}}})=>(0,_.tZ)(I.w,{date:e,user:t}),Header:(0,o.t)("Last modified"),accessor:"changed_on",size:"xl"},{Cell:({row:{original:e}})=>{const t=[K?{label:"edit-action",tooltip:(0,o.t)("Edit template"),placement:"bottom",icon:"Edit",onClick:()=>Y(e)}:null,C?{label:"delete-action",tooltip:(0,o.t)("Delete template"),placement:"bottom",icon:"Trash",onClick:()=>R(e)}:null].filter((e=>!!e));return(0,_.tZ)(p.Z,{actions:t})},Header:(0,o.t)("Actions"),id:"actions",disableSortBy:!0,hidden:!K&&!C,size:"xl"},{accessor:T.J.ChangedBy,hidden:!0}]),[C,x]),B=[];x&&B.push({name:(0,_.BX)(_.HY,{children:[(0,_.tZ)("i",{className:"fa fa-plus"})," ",(0,o.t)("Annotation layer")]}),buttonStyle:"primary",onClick:()=>{Y(null)}}),C&&B.push({name:(0,o.t)("Bulk select"),onClick:A,buttonStyle:"secondary"});const F=(0,n.useMemo)((()=>[{Header:(0,o.t)("Name"),key:"search",id:"name",input:"search",operator:P.p.Contains},{Header:(0,o.t)("Changed by"),key:"changed_by",id:"changed_by",input:"select",operator:P.p.RelationOneMany,unfilteredLabel:(0,o.t)("All"),fetchSelects:(0,u.tm)("annotation_layer","changed_by",(0,u.v$)((e=>(0,o.t)("An error occurred while fetching dataset datasource values: %s",e))),a),paginate:!0}]),[]),D={title:(0,o.t)("No annotation layers yet"),image:"filter-results.svg",buttonAction:()=>Y(null),buttonText:(0,_.BX)(_.HY,{children:[(0,_.tZ)("i",{className:"fa fa-plus"})," ",(0,o.t)("Annotation layer")]})};return(0,_.BX)(_.HY,{children:[(0,_.tZ)(h.Z,{name:(0,o.t)("Annotation layers"),buttons:B}),(0,_.tZ)(L,{addDangerToast:e,layer:k,onLayerAdd:e=>{window.location.href=`/annotationlayer/${e}/annotation`},onHide:()=>{S(),w(!1)},show:N}),Z&&(0,_.tZ)(m.Z,{description:(0,o.t)("This action will permanently delete the layer."),onConfirm:()=>{Z&&(({id:a,name:n})=>{l.Z.delete({endpoint:`/api/v1/annotation_layer/${a}`}).then((()=>{S(),R(null),t((0,o.t)("Deleted: %s",n))}),(0,u.v$)((t=>e((0,o.t)("There was an issue deleting %s: %s",n,t)))))})(Z)},onHide:()=>R(null),open:!0,title:(0,o.t)("Delete Layer?")}),(0,_.tZ)(E.Z,{title:(0,o.t)("Please confirm"),description:(0,o.t)("Are you sure you want to delete the selected layers?"),onConfirm:a=>{l.Z.delete({endpoint:`/api/v1/annotation_layer/?q=${i().encode(a.map((({id:e})=>e)))}`}).then((({json:e={}})=>{S(),t(e.message)}),(0,u.v$)((t=>e((0,o.t)("There was an issue deleting the selected layers: %s",t)))))},children:a=>{const n=C?[{key:"delete",name:(0,o.t)("Delete"),onSelect:a,type:"danger"}]:[];return(0,_.tZ)(P.Z,{className:"annotation-layers-list-view",columns:$,count:g,data:b,fetchData:v,filters:F,initialSort:G,loading:r,pageSize:25,bulkActions:n,bulkSelectEnabled:y,disableBulkSelect:A,addDangerToast:e,addSuccessToast:t,emptyState:D,refreshData:S})}})]})}))},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,a)=>{var n=a(656590);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}},402371:(e,t,a)=>{var n=a(1158),r=a(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 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 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=n.createRange(1,t).map(g);u.push.apply(u,h)}else{var p=i,P=n.createRange(1,p).map(g),m=t+1-i,E=t,b=n.createRange(m,E).map(g),y=Math.min(Math.max(a-o,p+c+1),m-c-2*o-1),f=y+2*o,_=n.createRange(y,f).map(g);if(u.push.apply(u,P),!d){var v=y-1,S=(v===p+1?g:r.createFirstEllipsis)(v);u.push(S)}if(u.push.apply(u,_),!d){var L=f+1,I=(L===m-1?g:r.createSecondEllipsis)(L);u.push(I)}u.push.apply(u,b)}return l||u.push(r.createNextPageLink(e)),s||u.push(r.createLastPageLink(e)),u};var i=a(656590);t.ITEM_TYPES=i.ITEM_TYPES,t.ITEM_KEYS=i.ITEM_KEYS}}]);
//# sourceMappingURL=e5ad77fb17bf5ce2010c.chunk.js.map