(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){var e=((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports))(((e,t)=>{t.exports={}}));function t(e,t,r,i){if(!1===t||t==null||!t&&(e===`class`||e===`style`))return``;if(!0===t)return` `+(i?e:e+`="`+e+`"`);var a=typeof t;return a!==`object`&&a!==`function`||typeof t.toJSON!=`function`||(t=t.toJSON()),typeof t==`string`||(t=JSON.stringify(t),r||t.indexOf(`"`)===-1)?(r&&(t=n(t)),` `+e+`="`+t+`"`):` `+e+`='`+t.replace(/'/g,`&#39;`)+`'`}function n(e){var t=``+e,n=r.exec(t);if(!n)return e;var i,a,o,s=``;for(i=n.index,a=0;i<t.length;i++){switch(t.charCodeAt(i)){case 34:o=`&quot;`;break;case 38:o=`&amp;`;break;case 60:o=`&lt;`;break;case 62:o=`&gt;`;break;default:continue}a!==i&&(s+=t.substring(a,i)),a=i+1,s+=o}return a===i?s:s+t.substring(a,i)}var r=/["&<>]/;function i(t,n,r,a){if(!(t instanceof Error))throw t;if(!(typeof window>`u`&&n||a))throw t.message+=` on line `+r,t;var o,s,c,l;try{a||=e().readFileSync(n,{encoding:`utf8`}),o=3,s=a.split(`
`),c=Math.max(r-o,0),l=Math.min(s.length,r+o)}catch(e){t.message+=` - could not read from `+n+` (`+e.message+`)`,i(t,null,r);return}o=s.slice(c,l).map(function(e,t){var n=t+c+1;return(n==r?`  > `:`    `)+n+`| `+e}).join(`
`),t.path=n;try{t.message=(n||`Pug`)+`:`+r+`
`+o+`

`+t.message}catch{}throw t}function a(e){var r=``,a,o;try{var s=e||{};(function(e){o=1,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<div class="g-body-title">`,o=1,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`Authorize upload into folder `,o=1,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r=r+`<a`+t(`href`,`#folder/${e.id}`,!0,!1)+`>`,o=1,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r=r+n(e.name()??``)+`</a>`,o=1,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`</div>`,o=3,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<p>`,o=4,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`This will generate a secure URL that can be used to upload a single file into this folder.`,o=5,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`
`,o=5,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`</p>`,o=6,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<form>`,o=7,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<div class="form-group">`,o=8,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<label>`,o=8,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`Number of days until URL expires (optional, defaults to lifetime of user sessions)</label>`,o=9,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<input class="g-num-days form-control"/></div></form>`,o=11,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<btn class="g-create-authorized-upload btn btn-primary">`,o=12,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<i class="icon-link"></i>`,o=13,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=` Generate URL</btn>`,o=15,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<div class="g-url-container hide">`,o=16,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<p>`,o=17,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`Your secure URL is below. Copy this value and send it to the user who will perform the`,o=18,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`
`,o=18,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`upload. They do not need to register a user in order to perform the upload. This token`,o=19,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`
`,o=19,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`will allow the user to upload a single file to the destination folder.</p>`,o=20,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`<p>`,o=20,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r+=`You will be notified via email when the upload is complete.</p>`,o=21,a=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizeUpload.pug`,r=r+`<input`+(` class="g-authorized-upload-url-target form-control"`+t(`readonly`,!0,!0,!1))+`/></div>`}).call(this,`folder`in s?s.folder:typeof folder<`u`?folder:void 0)}catch(e){i(e,a,o)}return r}var o=girder.views.View,{restRequest:s}=girder.rest,c=o.extend({events:{"click .g-create-authorized-upload":function(){s({url:`authorized_upload`,method:`POST`,data:{folderId:this.folder.id,duration:this.$(`.g-num-days`).val()||30}}).done(e=>{this.$(`.g-url-container`).removeClass(`hide`),this.$(`.g-authorized-upload-url-target`).val(e.url).trigger(`select`)})}},initialize:function(e){this.folder=e.folder,this.render()},render:function(){return this.$el.html(a({folder:this.folder})),this}});function l(t,n,r,i){if(!(t instanceof Error))throw t;if(!(typeof window>`u`&&n||i))throw t.message+=` on line `+r,t;var a,o,s,c;try{i||=e().readFileSync(n,{encoding:`utf8`}),a=3,o=i.split(`
`),s=Math.max(r-a,0),c=Math.min(o.length,r+a)}catch(e){t.message+=` - could not read from `+n+` (`+e.message+`)`,l(t,null,r);return}a=o.slice(s,c).map(function(e,t){var n=t+s+1;return(n==r?`  > `:`    `)+n+`| `+e}).join(`
`),t.path=n;try{t.message=(n||`Pug`)+`:`+r+`
`+a+`

`+t.message}catch{}throw t}function u(e){var t=``,n,r;try{r=1,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<div class="g-authorized-upload-page-wrapper">`,r=2,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<div class="g-upload-wrapper">`,r=3,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<p>`,r=4,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`You have been authorized to upload a file to this server. Please drag and drop your file`,r=5,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`
`,r=5,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`here, or click the button to select it using a file browser, and then click `,r=5,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<b>`,r=5,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`Start Upload</b>`,r=5,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`.`,r=6,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`
`,r=6,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`</p>`,r=7,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<p>`,r=8,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`You may also include your email address and a description of the data.`,r=9,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`
`,r=9,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`</p>`,r=10,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<label for="g-authorized-upload-email">`,r=10,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`Your email address (optional)</label>`,r=11,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<input class="form-control" id="g-authorized-upload-email" placeholder="Enter email"/>`,r=13,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<label for="g-authorized-upload-description">`,r=13,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`Description of data (optional)</label>`,r=14,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<input class="form-control" id="g-authorized-upload-description" placeholder="Enter description"/>`,r=16,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<div class="g-upload-widget-container"></div></div>`,r=17,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<div class="g-complete-wrapper hide">`,r=18,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`<p>`,r=18,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/authorizedUpload.pug`,t+=`Thank you! Your file has been received.</p></div></div>`}catch(e){l(e,n,r)}return t}var d=girder.models.FolderModel,f=girder.views.View,p=girder.views.widgets.UploadWidget,{setCurrentToken:m}=girder.auth,h=f.extend({initialize:function(e){this.folder=new d({_id:e.folderId,name:``}),m(e.token),this.uploadWidget=new p({parent:this.folder,title:!1,multiFile:!1,modal:!1,parentView:this,otherParams:()=>({authorizedUploadDescription:this.$(`#g-authorized-upload-description`).val(),authorizedUploadEmail:this.$(`#g-authorized-upload-email`).val()})}).on(`g:uploadFinished`,function(){this.$(`.g-upload-wrapper`).addClass(`hide`),this.$(`.g-complete-wrapper`).removeClass(`hide`)},this),this.render()},render:function(){return this.$el.html(u()),this.uploadWidget.setElement(this.$(`.g-upload-widget-container`)).render(),this}}),g=girder.router,_=girder.events,v=girder.models.FolderModel,y=girder.constants.Layout;g.route(`authorize_upload/:folderId`,`authorizeUpload`,e=>{var t=new v({_id:e}).once(`g:fetched`,()=>{_.trigger(`g:navigateTo`,c,{folder:t})});t.fetch()}),g.route(`authorized_upload/:folderId/:token`,`authorizedUpload`,function(e,t){_.trigger(`g:navigateTo`,h,{token:t,folderId:e},{layout:y.EMPTY})});function b(e,t,n,r){if(!1===t||t==null||!t&&(e===`class`||e===`style`))return``;if(!0===t)return` `+(r?e:e+`="`+e+`"`);var i=typeof t;return i!==`object`&&i!==`function`||typeof t.toJSON!=`function`||(t=t.toJSON()),typeof t==`string`||(t=JSON.stringify(t),n||t.indexOf(`"`)===-1)?(n&&(t=x(t)),` `+e+`="`+t+`"`):` `+e+`='`+t.replace(/'/g,`&#39;`)+`'`}function x(e){var t=``+e,n=S.exec(t);if(!n)return e;var r,i,a,o=``;for(r=n.index,i=0;r<t.length;r++){switch(t.charCodeAt(r)){case 34:a=`&quot;`;break;case 38:a=`&amp;`;break;case 60:a=`&lt;`;break;case 62:a=`&gt;`;break;default:continue}i!==r&&(o+=t.substring(i,r)),i=r+1,o+=a}return i===r?o:o+t.substring(i,r)}var S=/["&<>]/;function C(t,n,r,i){if(!(t instanceof Error))throw t;if(!(typeof window>`u`&&n||i))throw t.message+=` on line `+r,t;var a,o,s,c;try{i||=e().readFileSync(n,{encoding:`utf8`}),a=3,o=i.split(`
`),s=Math.max(r-a,0),c=Math.min(o.length,r+a)}catch(e){t.message+=` - could not read from `+n+` (`+e.message+`)`,C(t,null,r);return}a=o.slice(s,c).map(function(e,t){var n=t+s+1;return(n==r?`  > `:`    `)+n+`| `+e}).join(`
`),t.path=n;try{t.message=(n||`Pug`)+`:`+r+`
`+a+`

`+t.message}catch{}throw t}function w(e){var t=``,n,r;try{var i=e||{};(function(e){r=1,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/folderActions.pug`,t+=`<li role="presentation">`,r=2,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/folderActions.pug`,t=t+`<a`+(` class="g-authorize-upload-here"`+b(`href`,`#authorize_upload/${e.id}`,!0,!1))+`>`,r=3,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/folderActions.pug`,t+=`<i class="icon-upload"></i>`,r=4,n=`/home/circleci/project/girder/plugins/authorized_upload/girder_authorized_upload/web_client/templates/folderActions.pug`,t+=`Authorize upload here</a></li>`}).call(this,`folder`in i?i.folder:typeof folder<`u`?folder:void 0)}catch(e){C(e,n,r)}return t}var T=girder.views.widgets.HierarchyWidget,{wrap:E}=girder.utilities.PluginUtils,{AccessType:D}=girder.constants;E(T,`render`,function(e){return e.call(this),this.parentModel.resourceName===`folder`&&this.parentModel.getAccessLevel()>=D.WRITE&&this.$(`.g-folder-actions-menu a.g-edit-folder`).parent().after(w({folder:this.parentModel})),this})});