@rero/sonar-ui
Version:
User interface for SONAR.
2 lines (1 loc) • 46.2 kB
JavaScript
import{a as Kt}from"./chunk-CPEDLTDA.js";import{b as Yt}from"./chunk-OCFEN5PB.js";import{a as ti,b as ii,c as ni,e as oi}from"./chunk-REGRCEQZ.js";import{b as Xt}from"./chunk-5VFGEJYA.js";import{a as Qt}from"./chunk-LUYCTK2V.js";import{$a as ot,$b as Q,$e as Zt,Aa as b,Ad as Ie,Ae as jt,B as L,Ba as c,Bd as Fe,Be as Ut,Cb as pt,Cd as bt,Ce as zt,D as ge,Db as lt,Dc as H,De as Ot,Ed as yt,Fa as tt,G as d,Ga as it,Ge as Z,H as C,Ha as nt,Hd as X,I as S,Ib as dt,Ic as ft,Ie as Ve,Jd as N,Je as Le,Kc as ht,Kd as Y,Ke as Ht,L as xe,La as ye,Lb as ct,Le as Pe,M as Qe,Me as qt,Na as ue,Nc as _t,O as T,Oa as B,Od as Ct,P as Xe,Pa as _,Pd as St,Q as je,Qa as E,Qd as wt,Ra as ae,Rd as Tt,Re as Gt,Sa as te,Tb as mt,U as K,Ua as se,V as ee,Va as pe,Ve as Jt,W as Ye,Wa as le,Wb as we,X as p,Xd as kt,Xe as Wt,Yd as Dt,Zb as Te,Zd as Et,Ze as A,_ as k,_b as R,_e as Ne,a as ie,aa as be,ab as F,ac as V,ae as U,af as ei,b as he,bb as Ce,c as w,ca as Ze,cb as rt,ce as Be,da as q,fa as ne,g as qe,h as j,hd as vt,i as _e,ia as v,id as P,ie as J,j as W,ja as g,jb as f,je as Mt,ka as et,kb as h,ke as It,l as Ge,lb as fe,le as Ft,m as Je,ma as oe,me as Bt,na as re,nb as Se,ne as ce,oa as m,ob as G,p as O,pa as l,pc as ze,pd as de,q as We,qa as s,qc as ut,ra as x,rb as D,sb as at,se as Re,tb as I,td as gt,te as Rt,ue as Vt,vd as De,ve as Lt,w as Ke,wd as Ee,we as Pt,xe as Nt,ya as M,yb as Ue,yd as xt,ye as At,z as ve,zb as st,zc as ke,zd as Me,ze as $t}from"./chunk-OW4VQFLY.js";var Ae=(()=>{let o=class o{constructor(){this.apiService=d(Pe),this.httpClient=d(we),this.store=d(A),this.messageService=d(H),this.translateService=d(R),this.recordService=d(qt)}get depositEndPoint(){return"".concat(this.apiService.getEndpointByType("deposits",!0))}get(i){return this.httpClient.get("".concat(this.apiService.getEndpointByType("deposits",!0),"/").concat(i)).pipe(L(e=>{if(this.store.hasRole(["moderator","admin","superuser"])===!1&&this.store.checkUserReference(e.metadata.user.$ref)===!1)throw new Error("Logged user is not owning this deposit")}))}create(){return this.httpClient.post("".concat(this.apiService.getEndpointByType("deposits",!0),"/"),{user:{$ref:this.store.getUserRefEndpoint()},step:"metadata",status:"in_progress"})}update(i,e){return e=Ht(e),this.httpClient.put("".concat(this.apiService.getEndpointByType("deposits",!0),"/").concat(i),e).pipe(O(n=>(this.messageService.add({severity:"error",detail:this.translateService.instant(n.error.message),sticky:!0,closable:!0}),j(null))))}delete(i){let e=j(null);return i._files&&(e=qe(i._files).pipe(Ge(n=>this.removeFile(i.pid,n.key,n.version_id)),Ke())),Je(e,this.httpClient.delete("".concat(this.apiService.getEndpointByType("deposits",!0),"/").concat(i.pid))).pipe(We(()=>!0))}publish(i){return this.httpClient.post("".concat(this.depositEndPoint,"/").concat(i,"/publish"),null).pipe(O(e=>this._handleError(e)))}removeFile(i,e,n=null){return this.httpClient.delete("".concat(this.apiService.getEndpointByType("deposits",!0),"/").concat(i,"/files/").concat(e).concat(n?"?versionId="+n:"")).pipe(O(()=>j(null)))}getJsonSchema(i){return this.recordService.getSchemaForm(i).pipe(W(e=>{let n=e;return n.schema=Le(Ve(n.schema,n.schema.properties)),n.schema}))}reviewDeposit(i,e,n=null){return this.httpClient.post("".concat(this.depositEndPoint,"/").concat(i.pid,"/review"),{action:e,user:{$ref:this.store.getUserRefEndpoint()},comment:n||null}).pipe(O(a=>this._handleError(a)))}extractPDFMetadata(i){return this.httpClient.get("".concat(this.depositEndPoint,"/").concat(i.pid,"/extract-pdf-metadata")).pipe(O(e=>this._handleError(e)))}_handleError(i){return this.messageService.add({severity:"error",detail:this.translateService.instant(i.message),sticky:!0,closable:!0}),_e(()=>new Error("Something bad happened; please try again later."))}};o.\u0275fac=function(e){return new(e||o)},o.\u0275prov=ge({token:o,factory:o.\u0275fac,providedIn:"root"});let t=o;return t})();var z=Mt(Bt({deposit:null,schema:null,isLoading:!1,error:null}),It(t=>{let o=d(A);return{canAccess:D(()=>{var e;let r=t.deposit();if(!r)return!1;let{status:i}=r;return(i==="in_progress"||i==="ask_for_changes")&&o.checkUserReference(r.user.$ref)?!0:i==="to_validate"&&!!((e=o.user())!=null&&e.is_moderator)}),mainFile:D(()=>{var r,i,e;return(e=(i=(r=t.deposit())==null?void 0:r._files)==null?void 0:i[0])!=null?e:null}),additionalFiles:D(()=>{var r,i,e;return(e=(i=(r=t.deposit())==null?void 0:r._files)==null?void 0:i.slice(1))!=null?e:[]}),maxStep:D(()=>{var r,i;return(i=(r=t.deposit())==null?void 0:r.step)!=null?i:"metadata"})}}),Ft((t,o=d(Ae))=>({load(r){return J(t,{isLoading:!0,error:null}),o.get(r).pipe(L(i=>{var n;let e=[...(n=i.metadata._files)!=null?n:[]].sort((a,u)=>{var y,me;return((y=a.order)!=null?y:0)-((me=u.order)!=null?me:0)});J(t,{deposit:he(ie({},i.metadata),{_files:e}),isLoading:!1})}),W(()=>{}),O(i=>(J(t,{isLoading:!1,error:i.message}),_e(()=>i))))},create(){return o.create().pipe(L(r=>J(t,{deposit:r.metadata})))},update(r,i){return o.update(r,i).pipe(L(e=>{e&&J(t,{deposit:e.metadata})}))},delete(r){return o.delete(r).pipe(L(()=>J(t,{deposit:null})))},publish(r){return o.publish(r)},removeFile(r,i,e=null){return o.removeFile(r,i,e)},loadSchema(r){let i=t.schema();return i!==null?j(i):o.getJsonSchema(r).pipe(L(e=>J(t,{schema:e})))},reviewDeposit(r,i,e=null){return o.reviewDeposit(r,i,e)},extractPDFMetadata(r){return o.extractPDFMetadata(r)},mergeDeposit(r){let i=t.deposit();i&&J(t,{deposit:ie(ie({},i),r)})}})));var gi=()=>({width:"75vw"}),xi=()=>({height:"300px"}),bi=()=>({"min-width":"50rem"}),yi=t=>["/records","documents","detail",t],ri=t=>["/deposit",t,"files"];function Ci(t,o){if(t&1&&(x(0,"span",5),f(1,"nl2br")),t&2){let r=c(2);m("innerHtml",h(1,1,r.record().metadata.metadata.title),K)}}function Si(t,o){if(t&1&&(l(0,"span"),_(1),f(2,"translate"),s()),t&2){let r=c(2);p(),te("",h(2,2,"Deposit")," #",r.record().id)}}function wi(t,o){t&1&&(l(0,"tr")(1,"th",10),_(2,"Action"),s(),l(3,"th",10),_(4,"Date"),s(),l(5,"th",10),_(6,"User"),s(),l(7,"th",10),_(8,"Comment"),s()())}function Ti(t,o){if(t&1&&(l(0,"tr")(1,"td"),_(2),f(3,"translate"),s(),l(4,"td"),_(5),f(6,"dateTranslate"),s(),l(7,"td"),_(8),s(),x(9,"td",5),f(10,"nl2br"),s()),t&2){let r=o.$implicit;p(2),E(h(3,5,"deposit_log_action_"+r.action)),p(3),E(fe(6,7,r.date,"medium")),p(3),te("",r.user.first_name," ",r.user.last_name),p(),m("innerHtml",h(10,10,r.comment),K)}}function ki(t,o){if(t&1){let r=M();l(0,"p-button",13),f(1,"translate"),b("onClick",function(){C(r);let e=c(2);return S(e.historyDialogVisible.set(!0))}),s(),l(2,"p-dialog",14),f(3,"translate"),le("visibleChange",function(e){C(r);let n=c(2);return pe(n.historyDialogVisible,e)||(n.historyDialogVisible=e),S(e)}),l(4,"p-table",15),q(5,wi,9,0,"ng-template",null,0,G)(7,Ti,11,12,"ng-template",null,1,G),s()()}if(t&2){let r=c(2);m("label",h(1,10,"History")),p(2),ue(F(14,gi)),m("header",h(3,12,"History"))("resizable",!1)("modal",!0),se("visible",r.historyDialogVisible),m("contentStyle",F(15,xi)),p(2),m("value",r.record().metadata.logs)("tableStyle",F(16,bi))}}function Di(t,o){t&1&&(x(0,"p-tag",7),f(1,"translate")),t&2&&m("value",h(1,1,"New"))}function Ei(t,o){if(t&1&&(x(0,"p-tag",8),f(1,"translate")),t&2){let r=c(2);m("severity",r.statusSeverity())("value",h(1,2,"deposit_status_"+r.record().metadata.status))}}function Mi(t,o){if(t&1&&(l(0,"p"),_(1),f(2,"truncateText"),s()),t&2){let r=c(2);p(),E(fe(2,1,r.record().metadata.metadata.abstracts[0].abstract,30))}}function Ii(t,o){if(t&1&&(l(0,"dt",10),_(1,"Document"),s(),l(2,"dd")(3,"a",16),_(4),s()()),t&2){let r=c(2);p(3),m("routerLink",Ce(2,yi,r.record().metadata.document.pid)),p(),ae(" ",r.record().metadata.metadata.title," ")}}function Fi(t,o){if(t&1&&(x(0,"p-button",12),f(1,"translate")),t&2){let r=c(2);m("routerLink",Ce(4,ri,r.record().id))("label",h(1,2,"Continue process"))}}function Bi(t,o){if(t&1&&(x(0,"p-button",12),f(1,"translate")),t&2){let r=c(2);m("routerLink",Ce(4,ri,r.record().id))("label",h(1,2,"Review deposit"))}}function Ri(t,o){if(t&1&&(l(0,"div",2)(1,"div",3)(2,"h4",4),v(3,Ci,2,3,"span",5)(4,Si,3,4,"span"),s(),v(5,ki,9,17),s(),l(6,"div",6),v(7,Di,2,3,"p-tag",7),v(8,Ei,2,4,"p-tag",8),s(),v(9,Mi,3,4,"p"),l(10,"dl",9)(11,"dt",10),_(12,"Created by"),s(),l(13,"dd"),_(14),s(),l(15,"dt",10),_(16,"Created at"),s(),l(17,"dd"),_(18),f(19,"dateTranslate"),s(),l(20,"dt",10),_(21,"Updated at"),s(),l(22,"dd"),_(23),f(24,"dateTranslate"),s(),v(25,Ii,5,4),s(),l(26,"div",11),v(27,Fi,2,6,"p-button",12),v(28,Bi,2,6,"p-button",12),s()()),t&2){let r,i,e=c();p(3),g(!((r=e.record())==null||r.metadata==null)&&r.metadata.metadata?3:4),p(2),g(e.record().metadata.logs?5:-1),p(2),g(!e.record().metadata.logs||e.record().metadata.logs.length===1?7:-1),p(),g(e.statusSeverity()?8:-1),p(),g(!((i=e.record())==null||i.metadata==null||i.metadata.metadata==null)&&i.metadata.metadata.abstracts?9:-1),p(5),te("",e.record().metadata.user.first_name," ",e.record().metadata.user.last_name),p(4),E(fe(19,12,e.record().created,"medium")),p(5),E(fe(24,15,e.record().updated,"medium")),p(2),g(e.canAccessToDocumentRedirect()&&e.record().metadata.document?25:-1),p(2),g(e.canContinueProcess()?27:-1),p(),g(e.canReview()?28:-1)}}var ai=(()=>{let o=class o{constructor(){this.store=d(A),this.record=I.required(),this.type=I.required(),this.detailUrl=I(),this.user=this.store.user,this.historyDialogVisible=T(!1),this.depositMetadata=D(()=>this.record().metadata),this.canContinueProcess=D(()=>{let i=this.depositMetadata();return["in_progress","ask_for_changes"].includes(i.status)?this.store.checkUserPid(i.user.pid):!1}),this.canReview=D(()=>{var i;return this.depositMetadata().status==="to_validate"&&!!((i=this.user())!=null&&i.is_moderator)}),this.canAccessToDocumentRedirect=D(()=>this.store.hasRole(["moderator","admin","superuser"])),this.statusSeverity=D(()=>{var e;let i=(e=this.depositMetadata())==null?void 0:e.status;return i?oi[i]:null})}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-brief-view"]],inputs:{record:[1,"record"],type:[1,"type"],detailUrl:[1,"detailUrl"]},decls:1,vars:1,consts:[["header",""],["body",""],[1,"ui:flex","ui:flex-col","ui:gap-2"],[1,"ui:flex","ui:gap-1"],[1,"ui:flex-grow"],[3,"innerHtml"],[1,"ui:flex","ui:gap-1","ui:align-middle"],["severity","contrast",3,"value"],[3,"severity","value"],[1,"metadata","ui:text-sm"],["translate",""],[1,"ui:flex","ui:gap-1","ui:flex-wrap"],["severity","primary","size","small",3,"routerLink","label"],["variant","outlined","severity","secondary","icon","fa fa-history",3,"onClick","label"],["appendTo","body","position","top",3,"visibleChange","header","resizable","modal","visible","contentStyle"],[3,"value","tableStyle"],[3,"routerLink"]],template:function(e,n){e&1&&v(0,Ri,29,18,"div",2),e&2&&g(n.record()&&n.user()?0:-1)},dependencies:[P,de,ii,ti,Q,Qt,Y,V,Gt,Ut,Ot],encapsulation:2,changeDetection:0});let t=o;return t})();var Vi=()=>["/deposit","create"];function Li(t,o){t&1&&(l(0,"p-message",2),_(1),f(2,"translate"),s()),t&2&&(p(),E(h(2,1,"This deposit will be reviewed and published shortly.")))}function Pi(t,o){t&1&&(l(0,"p-message",3),_(1),f(2,"translate"),s()),t&2&&(p(),E(h(2,1,"This deposit will be published shortly.")))}function Ni(t,o){if(t&1&&(l(0,"div",4)(1,"div",5)(2,"a",6),_(3,"Back to public interface"),s()(),l(4,"a",7),_(5,"Deposit another publication"),s()()),t&2){let r=c(2);p(2),m("href",r.publicInterfaceLink,ee),p(2),m("routerLink",F(2,Vi))}}function Ai(t,o){if(t&1&&(l(0,"div",0)(1,"p-message",1),_(2),f(3,"translate"),s(),v(4,Li,3,3,"p-message",2),v(5,Pi,3,3,"p-message",3),v(6,Ni,6,3,"div",4),s()),t&2){let r=o,i=c();p(2),E(h(3,4,"Thank you for submitting a publication!")),p(2),g(r.status==="to_validate"?4:-1),p(),g(r.status==="validated"?5:-1),p(),g(i.isSubmitter?6:-1)}}var si=(()=>{let o=class o{constructor(){this.messageService=d(H),this.route=d(X),this.depositService=d(Ae),this.router=d(N),this.translateService=d(R),this.store=d(A),this.deposit=Be(this.route.params.pipe(ve(i=>this.depositService.get(i.id)),W(i=>i.metadata),O(()=>(this.messageService.add({severity:"success",detail:this.translateService.instant("Deposit not found"),life:Z.MESSAGE_LIFE}),this.router.navigate(["records","deposits"]),j(null)))))}get isSubmitter(){return this.store.hasRole("submitter")}get publicInterfaceLink(){return this.store.getPublicInterfaceLink()}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-confirmation"]],decls:1,vars:1,consts:[[1,"ui:flex","ui:flex-col","ui:gap-3"],["severity","success"],["severity","warn"],["severity","error"],[1,"ui:flex","ui:mt-4"],[1,"ui:grow"],["translate","",3,"href"],["translate","",3,"routerLink"]],template:function(e,n){if(e&1&&v(0,Ai,7,6,"div",0),e&2){let a;g((a=n.deposit())?0:-1,a)}},dependencies:[Re,Q,Y,V],encapsulation:2,changeDetection:0});let t=o;return t})();var pi=(()=>{let o=class o{constructor(){this.sanitizer=d(Te)}transform(i){let e=i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return e=e.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g,n=>{let a="ui:text-muted-color";return/^"/.test(n)?/:$/.test(n)?a="text-error":a="text-success":/true|false/.test(n)?a="text-primary":/null/.test(n)&&(a="text-warning"),'<span class="'.concat(a,'">').concat(n,"</span>")}),this.sanitizer.bypassSecurityTrustHtml(e)}};o.\u0275fac=function(e){return new(e||o)},o.\u0275pipe=be({name:"highlightJson",type:o,pure:!0});let t=o;return t})();var li="\n .p-steps {\n position: relative;\n }\n\n .p-steps-list {\n padding: 0;\n margin: 0;\n list-style-type: none;\n display: flex;\n }\n\n .p-steps-item {\n position: relative;\n display: flex;\n justify-content: center;\n flex: 1 1 auto;\n }\n\n .p-steps-item.p-disabled,\n .p-steps-item.p-disabled * {\n opacity: 1;\n pointer-events: auto;\n user-select: auto;\n cursor: auto;\n }\n\n .p-steps-item:before {\n content: ' ';\n border-top: 2px solid dt('steps.separator.background');\n width: 100%;\n top: 50%;\n left: 0;\n display: block;\n position: absolute;\n margin-top: calc(-1rem + 1px);\n }\n\n .p-steps-item:first-child::before {\n width: calc(50% + 1rem);\n transform: translateX(100%);\n }\n\n .p-steps-item:last-child::before {\n width: 50%;\n }\n\n .p-steps-item-link {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n overflow: hidden;\n text-decoration: none;\n transition:\n outline-color dt('steps.transition.duration'),\n box-shadow dt('steps.transition.duration');\n border-radius: dt('steps.item.link.border.radius');\n outline-color: transparent;\n gap: dt('steps.item.link.gap');\n }\n\n .p-steps-item-link:not(.p-disabled):focus-visible {\n box-shadow: dt('steps.item.link.focus.ring.shadow');\n outline: dt('steps.item.link.focus.ring.width') dt('steps.item.link.focus.ring.style') dt('steps.item.link.focus.ring.color');\n outline-offset: dt('steps.item.link.focus.ring.offset');\n }\n\n .p-steps-item-label {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 100%;\n color: dt('steps.item.label.color');\n display: block;\n font-weight: dt('steps.item.label.font.weight');\n }\n\n .p-steps-item-number {\n display: flex;\n align-items: center;\n justify-content: center;\n color: dt('steps.item.number.color');\n border: 2px solid dt('steps.item.number.border.color');\n background: dt('steps.item.number.background');\n min-width: dt('steps.item.number.size');\n height: dt('steps.item.number.size');\n line-height: dt('steps.item.number.size');\n font-size: dt('steps.item.number.font.size');\n z-index: 1;\n border-radius: dt('steps.item.number.border.radius');\n position: relative;\n font-weight: dt('steps.item.number.font.weight');\n }\n\n .p-steps-item-number::after {\n content: ' ';\n position: absolute;\n width: 100%;\n height: 100%;\n border-radius: dt('steps.item.number.border.radius');\n box-shadow: dt('steps.item.number.shadow');\n }\n\n .p-steps:not(.p-readonly) .p-steps-item {\n cursor: pointer;\n }\n\n .p-steps-item-active .p-steps-item-number {\n background: dt('steps.item.number.active.background');\n border-color: dt('steps.item.number.active.border.color');\n color: dt('steps.item.number.active.color');\n }\n\n .p-steps-item-active .p-steps-item-label {\n color: dt('steps.item.label.active.color');\n }\n";var $i=["list"],ji=(t,o)=>({item:t,index:o}),Ui=()=>({exact:!1}),zi=(t,o)=>o.label;function Oi(t,o){if(t&1&&(l(0,"span"),_(1),s()),t&2){let r=c(3).$implicit,i=c();B(i.cx("itemLabel")),p(),E(r.label)}}function Hi(t,o){if(t&1&&x(0,"span",12),t&2){let r=c(3).$implicit,i=c();B(i.cx("itemLabel")),m("innerHTML",r.label,K)}}function qi(t,o){if(t&1){let r=M();l(0,"a",10),b("click",function(e){C(r);let n=c(2),a=n.$implicit,u=n.$index,y=c();return S(y.onItemClick(e,a,u))})("keydown",function(e){C(r);let n=c(2),a=n.$implicit,u=n.$index,y=c();return S(y.onItemKeydown(e,a,u))}),l(1,"span"),_(2),s(),q(3,Oi,2,3,"span",11)(4,Hi,1,3,"ng-template",null,3,G),s()}if(t&2){let r=ye(5),i=c(2),e=i.$implicit,n=i.$index,a=c();B(a.cx("itemLink")),m("routerLink",e.routerLink)("queryParams",e.queryParams)("routerLinkActiveOptions",e.routerLinkActiveOptions||F(21,Ui))("target",e.target)("fragment",e.fragment)("queryParamsHandling",e.queryParamsHandling)("preserveFragment",e.preserveFragment)("skipLocationChange",e.skipLocationChange)("replaceUrl",e.replaceUrl)("state",e.state),ne("tabindex",a.getItemTabIndex(e,n))("aria-expanded",n===a.activeIndex)("aria-disabled",e.disabled||a.readonly&&n!==a.activeIndex)("ariaCurrentWhenActive",a.exact?"step":void 0),p(),B(a.cx("itemNumber")),p(),E(n+1),p(),m("ngIf",e.escape!==!1)("ngIfElse",r)}}function Gi(t,o){if(t&1&&(l(0,"span"),_(1),s()),t&2){let r=c(3).$implicit,i=c();B(i.cx("itemLabel")),p(),E(r.label)}}function Ji(t,o){if(t&1&&x(0,"span",12),t&2){let r=c(3).$implicit,i=c();B(i.cx("itemLabel")),m("innerHTML",r.label,K)}}function Wi(t,o){if(t&1){let r=M();l(0,"a",13),b("click",function(e){C(r);let n=c(2),a=n.$implicit,u=n.$index,y=c();return S(y.onItemClick(e,a,u))})("keydown",function(e){C(r);let n=c(2),a=n.$implicit,u=n.$index,y=c();return S(y.onItemKeydown(e,a,u))}),l(1,"span"),_(2),s(),q(3,Gi,2,3,"span",11)(4,Ji,1,3,"ng-template",null,4,G),s()}if(t&2){let r=ye(5),i=c(2),e=i.$implicit,n=i.$index,a=c();B(a.cx("itemLink")),m("target",e.target),ne("href",e.url,ee)("tabindex",a.getItemTabIndex(e,n))("aria-expanded",n===a.activeIndex)("aria-disabled",e.disabled||a.readonly&&n!==a.activeIndex)("ariaCurrentWhenActive",a.exact&&(!e.disabled||a.readonly)?"step":void 0),p(),B(a.cx("itemNumber")),p(),E(n+1),p(),m("ngIf",e.escape!==!1)("ngIfElse",r)}}function Ki(t,o){if(t&1&&(l(0,"li",8,1),q(2,qi,6,22,"a",9)(3,Wi,6,13,"ng-template",null,2,G),s()),t&2){let r=ye(4),i=c(),e=i.$implicit,n=i.$index,a=c();B(a.cx("item",rt(10,ji,e,n))),m("ngStyle",e.style)("tooltipOptions",e.tooltipOptions)("pTooltipUnstyled",a.unstyled()),ne("aria-current",a.isActive(e,n)?"step":void 0)("id",e.id)("data-pc-section","menuitem"),p(2),m("ngIf",a.isClickableRouterLink(e))("ngIfElse",r)}}function Qi(t,o){if(t&1&&q(0,Ki,5,13,"li",7),t&2){let r=o.$implicit;m("ngIf",r.visible!==!1)}}var Xi={root:({instance:t})=>["p-steps p-component",{"p-readonly":t.readonly}],list:"p-steps-list",item:({instance:t,item:o,index:r})=>["p-steps-item",{"p-steps-item-active":t.isActive(o,r),"p-disabled":t.isItemDisabled(o,r)}],itemLink:"p-steps-item-link",itemNumber:"p-steps-item-number",itemLabel:"p-steps-item-label"},di=(()=>{let o=class o extends ht{constructor(){super(...arguments);w(this,"name","steps");w(this,"style",li);w(this,"classes",Xi)}};w(o,"\u0275fac",(()=>{let e;return function(a){return(e||(e=je(o)))(a||o)}})()),w(o,"\u0275prov",ge({token:o,factory:o.\u0275fac}));let t=o;return t})();var ci=(()=>{let o=class o extends _t{constructor(){super(...arguments);w(this,"componentName","Steps");w(this,"activeIndex",0);w(this,"model");w(this,"readonly",!0);w(this,"style");w(this,"styleClass");w(this,"exact",!0);w(this,"activeIndexChange",new Qe);w(this,"listViewChild");w(this,"router",d(N));w(this,"route",d(X));w(this,"_componentStyle",d(di));w(this,"subscription")}onInit(){this.subscription=this.router.events.subscribe(()=>this.cd.markForCheck())}onItemClick(e,n,a){if(this.readonly||n.disabled){e.preventDefault();return}this.activeIndexChange.emit(a),!n.url&&!n.routerLink&&e.preventDefault(),n.command&&n.command({originalEvent:e,item:n,index:a})}onItemKeydown(e,n,a){var u,y,me;switch(e.code){case"ArrowRight":{this.navigateToNextItem(e.target),e.preventDefault();break}case"ArrowLeft":{this.navigateToPrevItem(e.target),e.preventDefault();break}case"Home":{this.navigateToFirstItem(e.target),e.preventDefault();break}case"End":{this.navigateToLastItem(e.target),e.preventDefault();break}case"Tab":if(a!==((u=this.activeIndex)!=null?u:-1)){let He=ze((y=this.listViewChild)==null?void 0:y.nativeElement,'[data-pc-section="menuitem"]');He[a].children[0].tabIndex="-1",He[(me=this.activeIndex)!=null?me:0].children[0].tabIndex="0"}break;case"Enter":case"Space":{this.onItemClick(e,n,a),e.preventDefault();break}default:break}}navigateToNextItem(e){let n=this.findNextItem(e);n&&this.setFocusToMenuitem(e,n)}navigateToPrevItem(e){let n=this.findPrevItem(e);n&&this.setFocusToMenuitem(e,n)}navigateToFirstItem(e){let n=this.findFirstItem();n&&this.setFocusToMenuitem(e,n)}navigateToLastItem(e){let n=this.findLastItem();n&&this.setFocusToMenuitem(e,n)}findNextItem(e){let n=e.parentElement.nextElementSibling;return n?n.children[0]:null}findPrevItem(e){let n=e.parentElement.previousElementSibling;return n?n.children[0]:null}findFirstItem(){var n;let e=ut((n=this.listViewChild)==null?void 0:n.nativeElement,'[data-pc-section="menuitem"]');return e?e.children[0]:null}findLastItem(){var n;let e=ze((n=this.listViewChild)==null?void 0:n.nativeElement,'[data-pc-section="menuitem"]');return e?e[e.length-1].children[0]:null}setFocusToMenuitem(e,n){e.tabIndex="-1",n.tabIndex="0",n.focus()}isClickableRouterLink(e){return e.routerLink&&!this.readonly&&!e.disabled}isItemDisabled(e,n){return e.disabled||this.readonly&&!this.isActive(e,n)}isActive(e,n){if(e.routerLink){let a=Array.isArray(e.routerLink)?e.routerLink:[e.routerLink];return this.router.isActive(this.router.createUrlTree(a,{relativeTo:this.route}).toString(),!1)}return n===this.activeIndex}getItemTabIndex(e,n){var a;return e.disabled?"-1":!e.disabled&&this.activeIndex===n?e.tabindex||"0":(a=e.tabindex)!=null?a:"-1"}onDestroy(){this.subscription&&this.subscription.unsubscribe()}};w(o,"\u0275fac",(()=>{let e;return function(a){return(e||(e=je(o)))(a||o)}})()),w(o,"\u0275cmp",k({type:o,selectors:[["p-steps"]],viewQuery:function(n,a){if(n&1&&tt($i,5),n&2){let u;it(u=nt())&&(a.listViewChild=u.first)}},inputs:{activeIndex:[2,"activeIndex","activeIndex",st],model:"model",readonly:[2,"readonly","readonly",Ue],style:"style",styleClass:"styleClass",exact:[2,"exact","exact",Ue]},outputs:{activeIndexChange:"activeIndexChange"},features:[ot([di]),Ze],decls:5,vars:7,consts:[["list",""],["menuitem",""],["elseBlock",""],["htmlLabel",""],["htmlRouteLabel",""],[3,"ngStyle"],["pTooltip","",3,"class","ngStyle","tooltipOptions","pTooltipUnstyled"],["pTooltip","",3,"class","ngStyle","tooltipOptions","pTooltipUnstyled",4,"ngIf"],["pTooltip","",3,"ngStyle","tooltipOptions","pTooltipUnstyled"],["role","link",3,"routerLink","queryParams","routerLinkActiveOptions","class","target","fragment","queryParamsHandling","preserveFragment","skipLocationChange","replaceUrl","state","click","keydown",4,"ngIf","ngIfElse"],["role","link",3,"click","keydown","routerLink","queryParams","routerLinkActiveOptions","target","fragment","queryParamsHandling","preserveFragment","skipLocationChange","replaceUrl","state"],[3,"class",4,"ngIf","ngIfElse"],[3,"innerHTML"],["role","link",3,"click","keydown","target"]],template:function(n,a){n&1&&(l(0,"nav",5)(1,"ul",null,0),oe(3,Qi,1,1,"li",6,zi),s()()),n&2&&(B(a.cn(a.cx("root"),a.styleClass)),m("ngStyle",a.style),ne("data-pc-name","steps"),p(),B(a.cx("list")),ne("data-pc-section","menu"),p(2),re(a.model))},dependencies:[ct,pt,lt,Ct,Y,Dt,kt,ft],encapsulation:2,changeDetection:0}));let t=o;return t})();var $e=(()=>{let o=class o{constructor(){this.translateService=d(R),this.maxStep=I.required(),this.steps=I.required(),this.items=D(()=>this.getItems()),this.language=Be(this.translateService.onLangChange)}getItems(){let i=!1;return this.language(),this.steps().map(e=>{let n={label:this.translateService.instant("step_".concat(e)),routerLink:["..",e],disabled:i};return this.maxStep()===e&&(i=!0),n})}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-step"]],inputs:{maxStep:[1,"maxStep"],steps:[1,"steps"]},decls:2,vars:2,consts:[[3,"model","readonly"]],template:function(e,n){e&1&&x(0,"p-steps",0)(1,"p-divider"),e&2&&m("model",n.items())("readonly",!1)},dependencies:[ci,Rt],encapsulation:2,changeDetection:0});let t=o;return t})();function Zi(t,o){if(t&1&&(l(0,"li"),_(1),s()),t&2){let r=o.$implicit;p(),E(r.name)}}function en(t,o){if(t&1&&(l(0,"dt",6),_(1,"Contributors"),s(),l(2,"dd")(3,"ul"),oe(4,Zi,2,1,"li",null,et),s()()),t&2){let r=c(3);p(4),re(r.scResult().contributors)}}function tn(t,o){if(t&1){let r=M();l(0,"div",0)(1,"dl",5)(2,"dt",6),_(3,"Title"),s(),l(4,"dd"),_(5),f(6,"translate"),s(),v(7,en,6,0),s(),l(8,"p-button",7),f(9,"translate"),b("onClick",function(){C(r);let e=c(2);return S(e.save())}),s()()}if(t&2){let r,i,e=c(2);p(5),E(!((r=e.scResult())==null||r.metadata==null)&&r.metadata.title?e.scResult().metadata.title:h(6,3,"no title")),p(2),g((i=e.scResult())!=null&&i.contributors?7:-1),p(),m("label",h(9,5,"Import"))}}function nn(t,o){t&1&&(l(0,"p-message",4),_(1),f(2,"translate"),s()),t&2&&(p(),E(h(2,1,"No result found")))}function on(t,o){if(t&1&&v(0,tn,10,7,"div",0)(1,nn,3,3,"p-message",4),t&2){let r=c();g(r.hasSwisscoveryResult()?0:1)}}var mi=(()=>{let o=class o{constructor(){this.spinner=d(ce),this.apiService=d(Pe),this.httpClient=d(we),this.translateService=d(R),this.data=at(),this.types=T([{name:this.translateService.instant("Everywhere"),code:"all_for_ui"},{name:this.translateService.instant("DOI"),code:"digital_object_identifier"},{name:this.translateService.instant("ID swisscovery (MARC 001)"),code:"mms_id"},{name:this.translateService.instant("ISBN"),code:"isbn"},{name:this.translateService.instant("ISSN"),code:"issn"}]),this.searchTerms=T(""),this.scType=T(this.types()[0]),this.scResult=T(null),this.hasSwisscoveryResult=D(()=>{let i=this.scResult();return i!==null&&Object.keys(i).length>0})}searchSwisscovery(){if(!this.searchTerms())return;this.spinner.show();let i=new mt().set("type",this.scType().code).set("query",this.searchTerms()).set("format","deposit");this.httpClient.get("".concat(this.apiService.getEndpointByType("swisscovery",!0),"/"),{params:i,observe:"response"}).pipe(W(e=>e.status===200?e.body:null)).subscribe(e=>{if(e===null)this.scResult.set(null);else{let n={};e.metadata&&(n.metadata=e.metadata),e.contributors&&(n.contributors=e.contributors),this.scResult.set(n)}this.spinner.hide()})}save(){this.data.emit(this.scResult())}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-editor-swisscovery"]],outputs:{data:"data"},decls:8,vars:7,consts:[[1,"ui:flex","ui:flex-col","ui:gap-2"],["appendTo","body","optionLabel","name",1,"ui:w-full",3,"ngModelChange","options","ngModel","placeholder"],["type","text","pAutoFocus","","pInputText","","placeholder","Keyword",3,"ngModelChange","keyup.enter","ngModel"],["icon","fa fa-search","severity","secondary","variant","text",3,"onClick"],["severity","warn"],[1,"metadata"],["translate",""],[3,"onClick","label"]],template:function(e,n){e&1&&(l(0,"div",0)(1,"p-select",1),f(2,"translate"),b("ngModelChange",function(u){return n.scType.set(u)}),s(),l(3,"p-inputgroup")(4,"input",2),b("ngModelChange",function(u){return n.searchTerms.set(u)})("keyup.enter",function(){return n.searchSwisscovery()}),s(),l(5,"p-inputgroup-addon")(6,"p-button",3),b("onClick",function(){return n.searchSwisscovery()}),s()()(),v(7,on,2,1),s()),e&2&&(p(),m("options",n.types())("ngModel",n.scType())("placeholder",h(2,5,"Search in ...")),p(3),m("ngModel",n.searchTerms()),p(3),g(n.scResult()?7:-1))},dependencies:[Et,Fe,De,Ee,Ie,Me,gt,bt,yt,P,Q,Re,V],encapsulation:2,changeDetection:0});let t=o;return t})();function rn(t,o){if(t&1&&(x(0,"p-splitButton",1),f(1,"translate")),t&2){let r=c();m("label",h(1,2,"Import metadata"))("model",r.importMenuItems())}}function an(t,o){if(t&1){let r=M();l(0,"p-button",7),f(1,"translate"),b("onClick",function(){C(r);let e=c();return S(e.save())}),s()}t&2&&m("label",h(1,1,"Save"))}function sn(t,o){if(t&1){let r=M();l(0,"p-button",8),f(1,"translate"),b("onClick",function(){C(r);let e=c();return S(e.save())}),s()}t&2&&m("label",h(1,1,"Continue"))}function pn(t,o){if(t&1){let r=M();l(0,"p-button",7),f(1,"translate"),f(2,"translate"),b("onClick",function(){C(r);let e=c();return S(e.confirmPublish())}),s()}if(t&2){let r=c();m("label",r.isAdminUser()?h(1,1,"Publish"):h(2,3,"Submit"))}}var ui=(()=>{let o=class o{constructor(){this.messageService=d(H),this.router=d(N),this.formlyJsonschema=d($t),this.translateService=d(R),this.appStore=d(A),this.spinner=d(ce),this.jsonschemaService=d(Wt),this.confirmationService=d(ke),this.store=d(z),this.destroyRef=d(xe),this.currentStep=I.required(),this.steps=I.required(),this.form=T(new xt({})),this.model=T({}),this.fields=T([]),this.importModalIsVisible=T(!1),this.isAdminUser=D(()=>this.appStore.hasRole(["superuser","admin","moderator"])),this.nextStep=D(()=>this.getNextStep()),this.canSubmit=D(()=>{var e;let i=this.store.deposit();return i!==null&&["in_progress","ask_for_changes"].includes(i.status)&&this.currentStep()==="diffusion"&&((e=i.diffusion)==null?void 0:e.license)!==void 0}),this.importMenuItems=D(()=>{let i=[{label:this.translateService.instant("Import from swisscovery"),command:()=>this.importModalIsVisible.set(!0)}];return this.store.mainFile()&&i.push({label:this.translateService.instant("Analyze uploaded PDF"),command:()=>this.confirmPdfImport()}),i}),this.store.loadSchema("deposits").pipe(U()).subscribe(),Xe(()=>{var y;let i=this.store.schema(),e=this.store.deposit();if(!i||!e)return;let n=this.getDepositFields(i);this.fields.set(this.getFormFields((y=n.fieldGroup)!=null?y:[],this.currentStep()));let a=e[this.currentStep()],u={};a&&(u[this.currentStep()]=a),this.model.set(u)})}save(){if(this.form().updateValueAndValidity(),!this.form().valid){this.form().markAllAsTouched();return}let i=this.store.deposit(),e=this.nextStep(),n=this.getUpgradedStep(i.step,e),a=he(ie({},i),{[this.currentStep()]:this.model()[this.currentStep()],step:n});this.store.update(i.pid,a).pipe(U(this.destroyRef)).subscribe(u=>{u&&(this.messageService.add({severity:"success",detail:this.translateService.instant("Deposit saved"),life:Z.MESSAGE_LIFE}),this.currentStep()!==this.steps()[this.steps().length-1]&&this.router.navigate(["deposit",i.pid,e]))})}confirmPublish(){this.confirmationService.confirm({message:this.translateService.instant("Do you really want to publish this document ?"),header:this.translateService.instant("Confirmation"),rejectButtonStyleClass:"p-button-text",closable:!1,accept:()=>{this.publish()}})}publish(){this.spinner.show(),this.store.publish(this.store.deposit().pid).pipe(U(this.destroyRef)).subscribe(()=>{this.spinner.hide(),this.router.navigate(["deposit",this.store.deposit().pid,"confirmation"])})}confirmPdfImport(){this.confirmationService.confirm({message:this.translateService.instant("Do you really want to extract metadata from PDF and overwrite current data ?"),header:this.translateService.instant("Confirmation"),closable:!1,accept:()=>{this.extractPdfMetadata()}})}extractPdfMetadata(){this.spinner.show(),this.store.extractPDFMetadata(this.store.deposit()).pipe(L(i=>{if(!i)return;let e={};["title","documentDate","publication","abstract","languages"].forEach(a=>{if(i[a])switch(a){case"abstract":e.abstracts=[{language:i.languages[0]||"eng",abstract:i.abstract}];break;case"languages":e.language=i.languages[0];break;default:e[a]=i[a]}});let n={};Object.keys(e).length&&(n.metadata=e),i.authors&&(n.contributors=i.authors),Object.keys(n).length&&this.store.mergeDeposit(n)})).subscribe({next:()=>this.spinner.hide(),error:()=>this.spinner.hide()})}mapSwisscoveryRecord(i){this.importModalIsVisible.set(!1),i&&this.store.mergeDeposit(i)}getNextStep(){var e;let i=this.steps().findIndex(n=>n===this.currentStep());return(e=this.steps()[i+1])!=null?e:this.steps()[i]}getUpgradedStep(i,e){let n=this.steps().findIndex(u=>u===i),a=this.steps().findIndex(u=>u===e);return n<a?e:i!=null?i:this.steps()[0]}getDepositFields(i){i=Le(Ve(i,i.properties));let e={pid:this.store.deposit().pid,longMode:!1,recordType:"deposits"};return this.formlyJsonschema.toFieldConfig(i,{map:(n,a)=>(n=this.jsonschemaService.processField(n,a),n.props.editorConfig=e,n.props.getRoot=()=>this.fields()[0],a.key&&a.key==="identified_by_type"&&(n.props.change=u=>{if(u.parent.model.value){let y=u.parent.formControl.controls;y.value.markAsTouched(),y.value.updateValueAndValidity()}}),a.key&&a.key==="identified_by_value"&&(n.validators={identifier:{expression:u=>{switch(u.parent.controls.type.value){case"bf:Doi":return/^10\..+\/.+$/.test(u.value);case"bf:Isbn":return/^(97(8|9))?\d{9}(\d|X)$/.test(u.value);case"pmid":return/^[1-3]\d{7}|[1-9]\d{0,6}$/.test(u.value);case"uri":return/^https?:\/\/.+\..+$/.test(u.value)}return!0},message:(u,y)=>this.translateService.instant("The format is not valid for this type of identifier.")}}),n)})}getFormFields(i,e){let n=i.filter(a=>a.key===e);return console.log(this.store.schema(),this.currentStep(),e,n),[n[0]]}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-editor"]],inputs:{currentStep:[1,"currentStep"],steps:[1,"steps"]},decls:9,vars:13,consts:[[1,"ui:flex","ui:justify-end","ui:items-center","ui:flex-wrap","ui:gap-2"],["appendTo","body",3,"label","model"],["iconPos","right",3,"label"],["icon","fa fa-chevron-right","iconPos","right",3,"label"],[3,"form","model","fields"],[1,"ui:w-[40lvw]",3,"visibleChange","header","modal","visible"],[3,"data"],["iconPos","right",3,"onClick","label"],["icon","fa fa-chevron-right","iconPos","right",3,"onClick","label"]],template:function(e,n){e&1&&(l(0,"div",0),v(1,rn,2,4,"p-splitButton",1),v(2,an,2,3,"p-button",2)(3,sn,2,3,"p-button",3),v(4,pn,3,5,"p-button",2),s(),x(5,"formly-form",4),l(6,"p-dialog",5),f(7,"translate"),le("visibleChange",function(u){return pe(n.importModalIsVisible,u)||(n.importModalIsVisible=u),u}),l(8,"sonar-deposit-editor-swisscovery",6),b("data",function(u){return n.mapSwisscoveryRecord(u)}),s()()),e&2&&(p(),g(n.currentStep()==="metadata"?1:-1),p(),g(n.currentStep()==="diffusion"?2:3),p(2),g(n.canSubmit()?4:-1),p(),B("step-"+n.currentStep),m("form",n.form())("model",n.model())("fields",n.fields()),p(),m("header",h(7,11,"Import from swisscovery"))("modal",!0),se("visible",n.importModalIsVisible))},dependencies:[wt,St,jt,P,de,mi,V],encapsulation:2,changeDetection:0});let t=o;return t})();var fi=(()=>{let o=class o{constructor(){this.sanitizer=d(Te)}transform(i,e,n,a="files"){return this.sanitizer.bypassSecurityTrustResourceUrl("".concat(e,"/").concat(n,"/").concat(a,"/").concat(i))}};o.\u0275fac=function(e){return new(e||o)},o.\u0275pipe=be({name:"fileLink",type:o,pure:!0});let t=o;return t})();var ln=()=>({width:"50vw"}),dn=()=>({"1199px":"75vw","575px":"90vw"}),cn=()=>({width:"100%",height:"800px",border:"none"}),mn=(t,o)=>o.key;function un(t,o){if(t&1){let r=M();l(0,"div"),_(1),f(2,"filesize"),l(3,"p-button",1),b("onClick",function(){let e=C(r).$implicit,n=c(2);return n.previewFileKey.set(e.key),S(n.isShowPreview.set(!0))}),s(),l(4,"a",7),f(5,"fileLink"),x(6,"i",3),s()()}if(t&2){let r=o.$implicit,i=c(2);p(),te(" ",r.key," (",h(2,3,r.size),") "),p(3),m("href",Se(5,5,r.key,"deposits",i.depositPid(),"files"),ee)}}function fn(t,o){if(t&1&&(l(0,"div",4)(1,"h4",0),_(2,"Additional files"),s(),oe(3,un,7,10,"div",null,mn),s()),t&2){let r=c();p(3),re(r.additionalFiles())}}var hi=(()=>{let o=class o{constructor(){this.mainFile=I.required(),this.depositPid=I.required(),this.additionalFiles=I(),this.previewFileKey=T(""),this.isShowPreview=T(!1)}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-files"]],inputs:{mainFile:[1,"mainFile"],depositPid:[1,"depositPid"],additionalFiles:[1,"additionalFiles"]},decls:12,vars:28,consts:[["translate",""],["href","#","icon","fa fa-eye","variant","text",3,"onClick"],["pButton","","target","_blank","text","",3,"href"],[1,"fa","fa-download"],[1,"ui:mt-2"],[3,"visibleChange","header","modal","visible","breakpoints"],[3,"src"],["pButton","","text","","target","_blank",3,"href"]],template:function(e,n){if(e&1&&(l(0,"h4",0),_(1,"Main file"),s(),_(2),f(3,"filesize"),l(4,"p-button",1),b("onClick",function(u){return u.preventDefault(),n.previewFileKey.set(n.mainFile().key),n.isShowPreview.set(!0)}),s(),l(5,"a",2),f(6,"fileLink"),x(7,"i",3),s(),v(8,fn,5,0,"div",4),l(9,"p-dialog",5),le("visibleChange",function(u){return pe(n.isShowPreview,u)||(n.isShowPreview=u),u}),x(10,"iframe",6),f(11,"fileLink"),s()),e&2){let a;p(2),te("\n",n.mainFile().key," (",h(3,13,n.mainFile().size),")\n"),p(3),m("href",Se(6,15,n.mainFile().key,"deposits",n.depositPid(),"files"),ee),p(3),g(((a=n.additionalFiles())==null?null:a.length)>0?8:-1),p(),ue(F(25,ln)),m("header",n.previewFileKey())("modal",!0),se("visible",n.isShowPreview),m("breakpoints",F(26,dn)),p(),ue(F(27,cn)),m("src",Se(11,20,n.previewFileKey(),"deposits",n.depositPid(),"preview"),Ye)}},dependencies:[Q,P,vt,de,zt,fi],encapsulation:2,changeDetection:0});let t=o;return t})();function hn(t,o){if(t&1){let r=M();l(0,"div",4)(1,"p-button",5),f(2,"translate"),b("onClick",function(){C(r);let e=c(2);return S(e.review("approve",!0))}),s(),l(3,"p-button",6),f(4,"translate"),b("onClick",function(){C(r);let e=c(2);return S(e.review("approve"))}),s(),l(5,"p-button",7),f(6,"translate"),b("onClick",function(){C(r);let e=c(2);return S(e.review("ask_for_changes"))}),s(),l(7,"p-button",8),f(8,"translate"),b("onClick",function(){C(r);let e=c(2);return S(e.review("reject"))}),s()()}t&2&&(p(),m("label",h(2,4,"Validate")),p(2),m("label",h(4,6,"Validate and see other deposits")),p(2),m("label",h(6,8,"Ask for changes")),p(2),m("label",h(8,10,"Reject")))}function _n(t,o){if(t&1){let r=M();l(0,"p-panel",1),f(1,"translate"),l(2,"div",2)(3,"textarea",3),f(4,"translate"),b("ngModelChange",function(e){C(r);let n=c();return S(n.comment.set(e))}),s()(),q(5,hn,9,12,"ng-template",null,0,G),s()}if(t&2){let r=c();m("header",h(1,4,"Deposit review")),p(3),m("autoResize",!0)("placeholder",h(4,6,"Leave a comment for the user..."))("ngModel",r.comment())}}var _i=(()=>{let o=class o{constructor(){this.confirmationService=d(ke),this.translateService=d(R),this.store=d(z),this.messageService=d(H),this.router=d(N),this.destroyRef=d(xe),this.deposit=I.required(),this.user=d(A).user,this.comment=T(void 0)}review(i,e=!1){this.confirmationService.confirm({header:this.translateService.instant("deposit_log_action_"+i),message:this.translateService.instant("Do you really want to do this action?"),closable:!1,accept:()=>{this.store.reviewDeposit(this.deposit(),i,this.comment()).pipe(U(this.destroyRef)).subscribe(n=>{var u;let a=n;if(this.messageService.add({severity:"success",detail:this.translateService.instant("Review has been done successfully!"),life:Z.MESSAGE_LIFE}),e){let y=(u=a.document)==null?void 0:u.$ref.split("/").pop();this.router.navigate(["records","documents","detail",y])}else this.router.navigate(["records","deposits"],{queryParams:{status:ni.TO_VALIDATE}})})}})}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-review"]],inputs:{deposit:[1,"deposit"]},decls:1,vars:1,consts:[["footer",""],[3,"header"],[1,"ui:flex","ui:justify-center"],["pTextarea","",1,"ui:min-w-lg","ui:my-4",3,"ngModelChange","autoResize","placeholder","ngModel"],[1,"ui:flex","ui:gap-2","ui:justify-center"],["severity","success",3,"onClick","label"],["severity","primary",3,"onClick","label"],["severity","warn",3,"onClick","label"],["severity","danger",3,"onClick","label"]],template:function(e,n){e&1&&v(0,_n,7,8,"p-panel",1),e&2&&g(n.user()&&n.deposit()&&n.deposit().status==="to_validate"&&n.user().is_moderator?0:-1)},dependencies:[Xt,Fe,De,Ee,Tt,Ie,Me,P,V],encapsulation:2,changeDetection:0});let t=o;return t})();function vn(t,o){if(t&1&&x(0,"sonar-deposit-review",1),t&2){let r=c(2);m("deposit",r.store.deposit())}}function gn(t,o){t&1&&(l(0,"p-tab",4),_(1),f(2,"translate"),s()),t&2&&(p(),ae(" ",h(2,1,"Files")," "))}function xn(t,o){if(t&1&&(l(0,"p-tabpanel",4),x(1,"sonar-deposit-files",7),s()),t&2){let r=c(2);p(),m("mainFile",r.store.mainFile())("depositPid",r.store.deposit().pid)("additionalFiles",r.store.additionalFiles())}}function bn(t,o){if(t&1&&(x(0,"sonar-deposit-step",0),v(1,vn,1,1,"sonar-deposit-review",1),l(2,"p-tabs",2)(3,"p-tablist")(4,"p-tab",2),_(5),f(6,"translate"),s(),l(7,"p-tab",3),_(8),f(9,"translate"),s(),v(10,gn,3,3,"p-tab",4),s(),l(11,"p-tabpanels")(12,"p-tabpanel",2),x(13,"sonar-deposit-editor",5),s(),l(14,"p-tabpanel",3),x(15,"pre",6),f(16,"json"),f(17,"highlightJson"),s(),v(18,xn,2,3,"p-tabpanel",4),s()()),t&2){let r=c();m("maxStep",r.store.maxStep())("steps",r.steps()),p(),g(r.currentStep()==="diffusion"?1:-1),p(4),ae(" ",h(6,10,"Editor")," "),p(3),ae(" ",h(9,12,"JSON")," "),p(2),g(r.store.mainFile()?10:-1),p(3),m("currentStep",r.currentStep())("steps",r.steps()),p(2),m("innerHTML",h(17,16,h(16,14,r.store.deposit())),K),p(3),g(r.store.mainFile()?18:-1)}}var vi=(()=>{let o=class o{constructor(){this.messageService=d(H),this.router=d(N),this.translateService=d(R),this.store=d(z),this.currentStep=T("metadata"),this.steps=T(["files","metadata","contributors","projects","diffusion"]),d(X).params.pipe(L(i=>this.currentStep.set(i.step)),ve(i=>this.store.load(i.id)),U()).subscribe({next:()=>{this.store.canAccess()||this.router.navigate(["deposit",this.store.deposit().pid,"confirmation"])},error:()=>{this.messageService.add({severity:"error",detail:this.translateService.instant("Deposit not found"),life:Z.MESSAGE_LIFE}),this.router.navigate(["records","deposits"])}})}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-metadata"]],decls:1,vars:1,consts:[[3,"maxStep","steps"],[3,"deposit"],["value","editor"],["value","json"],["value","files"],[3,"currentStep","steps"],[1,"p-3",3,"innerHTML"],[3,"mainFile","depositPid","additionalFiles"]],template:function(e,n){e&1&&v(0,bn,19,18),e&2&&g(n.store.deposit()?0:-1)},dependencies:[$e,_i,Vt,Lt,Pt,At,Nt,ui,hi,dt,V,pi],encapsulation:2,changeDetection:0});let t=o;return t})();var yn=()=>["files","metadata","contributors","projects","diffusion"],Cn=()=>["..","metadata"];function Sn(t,o){if(t&1&&x(0,"sonar-upload-files",3),t&2){let r=c();m("pid",r.deposit().pid)}}var Oe=(()=>{let o=class o{constructor(){var e;this.store=d(z),this.router=d(N),this.spinner=d(ce),this.deposit=this.store.deposit,this.maxStep=this.store.maxStep;let i=d(X);i.snapshot.data.mode==="create"?this.createEmptyDeposit():(e=i.snapshot.params)!=null&&e.id&&(this.spinner.show(),this.store.load(i.snapshot.params.id).pipe(U()).subscribe({next:()=>{this.spinner.hide(),this.store.canAccess()||this.router.navigate(["deposit",this.store.deposit().pid,"confirmation"])},error:()=>this.spinner.hide()}))}createEmptyDeposit(){this.store.create().pipe(U()).subscribe(i=>{this.router.navigate(["deposit",i.metadata.pid,"files"])})}saveAndContinue(i){i.preventDefault();let e=this.deposit();e&&this.router.navigate(["deposit",e.pid,"metadata"])}};o.\u0275fac=function(e){return new(e||o)},o.\u0275cmp=k({type:o,selectors:[["sonar-deposit-upload"]],decls:5,vars:9,consts:[[3,"maxStep","steps"],[1,"ui:flex","ui:justify-end","ui:flex-wrap"],["icon","fa fa-chevron-right","iconPos","right",1,"ui:flex","ui:align-center","ui:justify-center",3,"routerLink","label"],["recordType","deposits",3,"pid"]],template:function(e,n){e&1&&(x(0,"sonar-deposit-step",0),l(1,"div",1),x(2,"p-button",2),f(3,"translate"),s(),v(4,Sn,1,1,"sonar-upload-files",3)),e&2&&(m("maxStep",n.maxStep())("steps",F(7,yn)),p(2),m("routerLink",F(8,Cn))("label",h(3,5,"Continue")),p(2),g(n.deposit()?4:-1))},dependencies:[$e,P,Y,Yt,V],encapsulation:2,changeDetection:0});let t=o;return t})();var ts=()=>{let t=d(ei);return[{key:"deposits",label:"Deposits",component:ai,aggregations:Kt.filter,aggregationsExpand:["status","user","contributor"],aggregationsOrder:["status","user","contributor","subdivision"],aggregationsBucketSize:10,showFacetsIfNoResults:!0,exportFormats:[],sortOptions:[{label:"Relevance",value:"relevance",icon:"fa fa-sort-amount-desc",defaultQuery:!0},{label:"Date descending",value:"newest",icon:"fa fa-sort-amount-desc",defaultNoQuery:!0},{label:"Date ascending",value:"oldest",icon:"fa fa-sort-amount-asc"}],canAdd:()=>j({can:!1,message:""}),canUpdate:()=>j({can:!1,message:""}),canDelete:o=>t.canAccess("deposits","delete",o),canRead:o=>t.canAccess("deposits","read",o)}]},is=[{path:"",title:Zt,component:Jt,canActivate:[Ne],data:{role:"submitter",showSearchInput:!0}}],ns=[{path:"create",title:"Deposit",canActivate:[Ne],component:Oe,providers:[z],data:{mode:"create"}},{path:":id",title:"Deposit",canActivate:[Ne],providers:[z],data:{role:"submitter"},children:[{path:"files",title:"Deposit",component:Oe},{path:"confirmation",title:"Deposit",component:si},{path:":step",title:"Deposit",component:vi}]}];export{ts as a,is as b,ns as c};