!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=33)}([function(e,t,n){"use strict";t.__esModule=!0,t.extend=i,t.indexOf=function(e,t){for(var n=0,r=e.length;n":">",'"':""","'":"'","`":"`","=":"="},o=/[&<>"'`=]/g,a=/[&<>"'`=]/;function s(e){return r[e]}function i(e){for(var t=1;t= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};function u(e,t,n){this.helpers=e||{},this.partials=t||{},this.decorators=n||{},s.registerDefaultHelpers(this),i.registerDefaultDecorators(this)}u.prototype={constructor:u,logger:l.default,log:l.default.log,registerHelper:function(e,t){if("[object Object]"===o.toString.call(e)){if(t)throw new a.default("Arg not supported with multiple helpers");o.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if("[object Object]"===o.toString.call(e))o.extend(this.partials,e);else{if(void 0===t)throw new a.default('Attempting to register a partial called "'+e+'" as undefined');this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if("[object Object]"===o.toString.call(e)){if(t)throw new a.default("Arg not supported with multiple decorators");o.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]},resetLoggedPropertyAccesses:function(){c.resetLoggedProperties()}};var d=l.default.log;t.log=d,t.createFrame=o.createFrame,t.logger=l.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.registerDefaultHelpers=function(e){o.default(e),a.default(e),s.default(e),i.default(e),l.default(e),c.default(e),u.default(e)},t.moveHelperToHooks=function(e,t,n){e.helpers[t]&&(e.hooks[t]=e.helpers[t],n||delete e.helpers[t])};var o=r(n(16)),a=r(n(17)),s=r(n(18)),i=r(n(19)),l=r(n(20)),c=r(n(21)),u=r(n(22))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0),o={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(e){if("string"==typeof e){var t=r.indexOf(o.methodMap,e.toLowerCase());e=t>=0?t:parseInt(e,10)}return e},log:function(e){if(e=o.lookupLevel(e),"undefined"!=typeof console&&o.lookupLevel(o.level)<=e){var t=o.methodMap[e];console[t]||(t="log");for(var n=arguments.length,r=Array(n>1?n-1:0),a=1;a]/;e.exports=function(e){var t,n=""+e,o=r.exec(n);if(!o)return n;var a="",s=0,i=0;for(s=o.index;s'+(null!=(a="function"==typeof(s=null!=(s=i(n,"tagMarkup")||(null!=t?i(t,"tagMarkup"):t))?s:e.hooks.helperMissing)?s.call(null!=t?t:e.nullContext||{},{name:"tagMarkup",hash:{},data:o,loc:{start:{line:4,column:22},end:{line:4,column:37}}}):s)?a:"")+"\n"},5:function(e,t,n,r,o){var a,s=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'\t\t'+e.escapeExpression("function"==typeof(a=null!=(a=s(n,"name")||(null!=t?s(t,"name"):t))?a:e.hooks.helperMissing)?a.call(null!=t?t:e.nullContext||{},{name:"name",hash:{},data:o,loc:{start:{line:6,column:22},end:{line:6,column:30}}}):a)+"\n"},7:function(e,t,n,r,o){var a,s=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'\t\t\n\t\t\t\n\t\t\n'},compiler:[8,">= 4.3.0"],main:function(e,t,n,r,o){var a,s,i,l=null!=t?t:e.nullContext||{},c=e.hooks.helperMissing,u=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]},d='\n\n'+(null!=(a=u(n,"if").call(l,null!=t?u(t,"isAdmin"):t,{name:"if",hash:{},fn:e.program(3,o,0),inverse:e.program(5,o,0),data:o,loc:{start:{line:3,column:1},end:{line:7,column:8}}}))?a:"");return s=null!=(s=u(n,"allowActions")||(null!=t?u(t,"allowActions"):t))?s:c,i={name:"allowActions",hash:{},fn:e.program(7,o,0),inverse:e.noop,data:o,loc:{start:{line:8,column:1},end:{line:12,column:18}}},a="function"==typeof s?s.call(l,i):s,u(n,"allowActions")||(a=e.hooks.blockHelperMissing.call(t,a,i)),null!=a&&(d+=a),d+"\n"},useData:!0})},function(e,t,n){var r=n(2);e.exports=(r.default||r).template({1:function(e,t,n,r,o){var a,s=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'\t\t\n'},compiler:[8,">= 4.3.0"],main:function(e,t,n,r,o){var a,s,i=null!=t?t:e.nullContext||{},l=e.hooks.helperMissing,c=e.escapeExpression,u=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'
\n\t \n\t\n'+(null!=(a=u(n,"if").call(i,null!=t?u(t,"isAdmin"):t,{name:"if",hash:{},fn:e.program(1,o,0),inverse:e.noop,data:o,loc:{start:{line:4,column:1},end:{line:6,column:8}}}))?a:"")+"
\n"},useData:!0})},function(e,t,n){var r=n(2);e.exports=(r.default||r).template({1:function(e,t,n,r,o){var a,s,i=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'\t'+(null!=(a="function"==typeof(s=null!=(s=i(n,"tagMarkup")||(null!=t?i(t,"tagMarkup"):t))?s:e.hooks.helperMissing)?s.call(null!=t?t:e.nullContext||{},{name:"tagMarkup",hash:{},data:o,loc:{start:{line:2,column:21},end:{line:2,column:36}}}):s)?a:"")+"\n"},3:function(e,t,n,r,o){var a,s=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'\t'+e.escapeExpression("function"==typeof(a=null!=(a=s(n,"name")||(null!=t?s(t,"name"):t))?a:e.hooks.helperMissing)?a.call(null!=t?t:e.nullContext||{},{name:"name",hash:{},data:o,loc:{start:{line:4,column:21},end:{line:4,column:29}}}):a)+"\n"},compiler:[8,">= 4.3.0"],main:function(e,t,n,r,o){var a,s=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return null!=(a=s(n,"if").call(null!=t?t:e.nullContext||{},null!=t?s(t,"isAdmin"):t,{name:"if",hash:{},fn:e.program(1,o,0),inverse:e.program(3,o,0),data:o,loc:{start:{line:1,column:0},end:{line:5,column:7}}}))?a:""},useData:!0})},function(e,t){!function(e){_.extend(e.Files.Client,{PROPERTY_FILEID:"{"+e.Files.Client.NS_OWNCLOUD+"}id",PROPERTY_CAN_ASSIGN:"{"+e.Files.Client.NS_OWNCLOUD+"}can-assign",PROPERTY_DISPLAYNAME:"{"+e.Files.Client.NS_OWNCLOUD+"}display-name",PROPERTY_USERVISIBLE:"{"+e.Files.Client.NS_OWNCLOUD+"}user-visible",PROPERTY_USERASSIGNABLE:"{"+e.Files.Client.NS_OWNCLOUD+"}user-assignable"});var t=e.Backbone.Model.extend({sync:e.Backbone.davSync,defaults:{userVisible:!0,userAssignable:!0,canAssign:!0},davProperties:{id:e.Files.Client.PROPERTY_FILEID,name:e.Files.Client.PROPERTY_DISPLAYNAME,userVisible:e.Files.Client.PROPERTY_USERVISIBLE,userAssignable:e.Files.Client.PROPERTY_USERASSIGNABLE,canAssign:e.Files.Client.PROPERTY_CAN_ASSIGN},parse:function(e){return{id:e.id,name:e.name,userVisible:!0===e.userVisible||"true"===e.userVisible,userAssignable:!0===e.userAssignable||"true"===e.userAssignable,canAssign:!0===e.canAssign||"true"===e.canAssign}}});e.SystemTags=e.SystemTags||{},e.SystemTags.SystemTagModel=t}(OC)},function(e,t){!function(e){var t=e.Backbone.Collection.extend({sync:e.Backbone.davSync,usePUT:!0,_objectId:null,_objectType:"files",model:e.SystemTags.SystemTagModel,url:function(){return e.linkToRemote("dav")+"/systemtags-relations/"+this._objectType+"/"+this._objectId},setObjectId:function(e){this._objectId=e},setObjectType:function(e){this._objectType=e},initialize:function(e,t){t=t||{},_.isUndefined(t.objectId)||(this._objectId=t.objectId),_.isUndefined(t.objectType)||(this._objectType=t.objectType)},getTagIds:function(){return this.map((function(e){return e.id}))}});e.SystemTags=e.SystemTags||{},e.SystemTags.SystemTagsMappingCollection=t}(OC)},function(e,t){!function(e){var t=e.Backbone.Collection.extend({sync:e.Backbone.davSync,model:e.SystemTags.SystemTagModel,url:function(){return e.linkToRemote("dav")+"/systemtags/"},filterByName:function(e){return this.filter((function(t){return function(e,t){return e.get("name").substr(0,t.length).toLowerCase()===t.toLowerCase()}(t,e)}))},reset:function(){return this.fetched=!1,e.Backbone.Collection.prototype.reset.apply(this,arguments)},fetch:function(t){var n=this;if(t=t||{},this.fetched||t.force)return t.success&&t.success(this,null,t),this.trigger("sync",this,null,t),Promise.resolve();var r=t.success;return(t=_.extend({},t)).success=function(){if(n.fetched=!0,r)return r.apply(this,arguments)},e.Backbone.Collection.prototype.fetch.call(this,t)}});e.SystemTags=e.SystemTags||{},e.SystemTags.SystemTagsCollection=t,e.SystemTags.collection=new e.SystemTags.SystemTagsCollection}(OC)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}t.__esModule=!0;var a=o(n(3)),s=r(n(26)),i=r(n(1)),l=o(n(0)),c=o(n(27)),u=r(n(29));function d(){var e=new a.HandlebarsEnvironment;return l.extend(e,a),e.SafeString=s.default,e.Exception=i.default,e.Utils=l,e.escapeExpression=l.escapeExpression,e.VM=c,e.template=function(t){return c.template(t,e)},e}var f=d();f.create=d,u.default(f),f.default=f,t.default=f,e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var r=n(0);t.default=function(e){e.registerHelper("blockHelperMissing",(function(t,n){var o=n.inverse,a=n.fn;if(!0===t)return a(this);if(!1===t||null==t)return o(this);if(r.isArray(t))return t.length>0?(n.ids&&(n.ids=[n.name]),e.helpers.each(t,n)):o(this);if(n.data&&n.ids){var s=r.createFrame(n.data);s.contextPath=r.appendContextPath(n.data.contextPath,n.name),n={data:s}}return a(t,n)}))},e.exports=t.default},function(e,t,n){"use strict";(function(r){t.__esModule=!0;var o,a=n(0),s=n(1),i=(o=s)&&o.__esModule?o:{default:o};t.default=function(e){e.registerHelper("each",(function(e,t){if(!t)throw new i.default("Must pass iterator to #each");var n,o=t.fn,s=t.inverse,l=0,c="",u=void 0,d=void 0;function f(t,n,r){u&&(u.key=t,u.index=n,u.first=0===n,u.last=!!r,d&&(u.contextPath=d+t)),c+=o(e[t],{data:u,blockParams:a.blockParams([e[t],t],[d+t,null])})}if(t.data&&t.ids&&(d=a.appendContextPath(t.data.contextPath,t.ids[0])+"."),a.isFunction(e)&&(e=e.call(this)),t.data&&(u=a.createFrame(t.data)),e&&"object"==typeof e)if(a.isArray(e))for(var p=e.length;l=i.LAST_COMPATIBLE_COMPILER_REVISION&&t<=i.COMPILER_REVISION)return;if(t").addClass("non-existing-tag").text(t("core","Non-existing tag #{tag}",{tag:e}));var n,r=$("");return r.append(a()(e.name)),e.userAssignable||(n=t("core","restricted")),e.userVisible||(n=t("core","invisible")),n&&r.append($("").text(" ("+n+")")),r}}}(OC);r(12),r(13),r(14);var s=r(9),i=r.n(s),l=r(10),c=r.n(l),u=r(11),d=r.n(u);!function(e){var n=e.Backbone.View.extend({_rendered:!1,_newTag:null,_lastUsedTags:[],className:"systemTagsInputFieldContainer",template:function(e){return''},initialize:function(t){t=t||{},this._multiple=!!t.multiple,this._allowActions=_.isUndefined(t.allowActions)||!!t.allowActions,this._allowCreate=_.isUndefined(t.allowCreate)||!!t.allowCreate,this._isAdmin=!!t.isAdmin,_.isFunction(t.initSelection)&&(this._initSelection=t.initSelection),this.collection=t.collection||e.SystemTags.collection;var n=this;this.collection.on("change:name remove",(function(){_.defer(n._refreshSelection)})),_.defer(_.bind(this._getLastUsedTags,this)),_.bindAll(this,"_refreshSelection","_onClickRenameTag","_onClickDeleteTag","_onSelectTag","_onDeselectTag","_onSubmitRenameTag")},_getLastUsedTags:function(){var t=this;$.ajax({type:"GET",url:e.generateUrl("/apps/systemtags/lastused"),success:function(e){t._lastUsedTags=e}})},_refreshSelection:function(){this.$tagsField.select2("val",this.$tagsField.val())},_onClickRenameTag:function(e){var n=$(e.target).closest(".systemtags-item"),r=n.attr("data-id"),o=this.collection.get(r).get("name"),a=$(c()({cid:this.cid,name:o,deleteTooltip:t("core","Delete"),renameLabel:t("core","Rename"),isAdmin:this._isAdmin}));return n.find(".label").after(a),n.find(".label, .systemtags-actions").addClass("hidden"),n.closest(".select2-result").addClass("has-form"),a.find("[title]").tooltip({placement:"bottom",container:"body"}),a.find("input").focus().selectRange(0,o.length),!1},_onSubmitRenameTag:function(e){e.preventDefault();var t=$(e.target),n=t.closest(".systemtags-item"),r=n.attr("data-id"),o=this.collection.get(r),a=$(e.target).find("input").val().trim();a&&a!==o.get("name")&&(o.save({name:a}),n.find(".label").text(a)),n.find(".label, .systemtags-actions").removeClass("hidden"),t.remove(),n.closest(".select2-result").removeClass("has-form")},_onClickDeleteTag:function(e){var t=$(e.target).closest(".systemtags-item"),n=t.attr("data-id");return this.collection.get(n).destroy(),$(e.target).tooltip("hide"),t.closest(".select2-result").remove(),!1},_addToSelect2Selection:function(e){var t=this.$tagsField.select2("data");t.push(e),this.$tagsField.select2("data",t)},_onSelectTag:function(e){var t,n=this;if(e.object&&e.object.isNew)return t=this.collection.create({name:e.object.name.trim(),userVisible:!0,userAssignable:!0,canAssign:!0},{success:function(e){n._addToSelect2Selection(e.toJSON()),n._lastUsedTags.unshift(e.id),n.trigger("select",e)},error:function(t,r){409===r.status&&(n.collection.reset(),n.collection.fetch({success:function(t){var r=t.where({name:e.object.name.trim(),userVisible:!0,userAssignable:!0});r.length&&(r=r[0],n._addToSelect2Selection(r.toJSON()),n.trigger("select",r))}}))}}),this.$tagsField.select2("close"),e.preventDefault(),!1;t=this.collection.get(e.object.id),this._lastUsedTags.unshift(t.id),this._newTag=null,this.trigger("select",t)},_onDeselectTag:function(e){this.trigger("deselect",e.choice.id)},_queryTagsAutocomplete:function(e){var t=this;this.collection.fetch({success:function(n){var r=n.filterByName(e.term.trim());t._isAdmin||(r=_.filter(r,(function(e){return e.get("canAssign")}))),e.callback({results:_.invoke(r,"toJSON")})}})},_preventDefault:function(e){e.stopPropagation()},_formatDropDownResult:function(n){return i()(_.extend({renameTooltip:t("core","Rename"),allowActions:this._allowActions,tagMarkup:this._isAdmin?e.SystemTags.getDescriptiveTag(n)[0].innerHTML:null,isAdmin:this._isAdmin},n))},_formatSelection:function(t){return d()(_.extend({tagMarkup:this._isAdmin?e.SystemTags.getDescriptiveTag(t)[0].innerHTML:null,isAdmin:this._isAdmin},t))},_createSearchChoice:function(e){if(e=e.trim(),!this.collection.filter((function(t){return t.get("name")===e})).length)return this._newTag?this._newTag.name=e:this._newTag={id:-1,name:e,userAssignable:!0,userVisible:!0,canAssign:!0,isNew:!0},this._newTag},_initSelection:function(e,t){var n=this,r=$(e).val().split(",");function o(e){var t=e.toJSON();return n._isAdmin||t.canAssign||(t.locked=!0),t}this.collection.fetch({success:function(){t(function(e){var t=n.collection.filter((function(t){return e.indexOf(t.id)>=0&&(n._isAdmin||t.get("userVisible"))}));return _.map(t,o)}(r))}})},render:function(){var n=this;this.$el.html(this.template()),this.$el.find("[title]").tooltip({placement:"bottom"}),this.$tagsField=this.$el.find("[name=tags]"),this.$tagsField.select2({placeholder:t("core","Collaborative tags"),containerCssClass:"systemtags-select2-container",dropdownCssClass:"systemtags-select2-dropdown",closeOnSelect:!1,allowClear:!1,multiple:this._multiple,toggleSelect:this._multiple,query:_.bind(this._queryTagsAutocomplete,this),id:function(e){return e.id},initSelection:_.bind(this._initSelection,this),formatResult:_.bind(this._formatDropDownResult,this),formatSelection:_.bind(this._formatSelection,this),createSearchChoice:this._allowCreate?_.bind(this._createSearchChoice,this):void 0,sortResults:function(t){var r=_.pluck(n.$tagsField.select2("data"),"id");return t.sort((function(t,o){var a=r.indexOf(t.id)>=0,s=r.indexOf(o.id)>=0;if(a===s){var i=n._lastUsedTags.indexOf(t.id),l=n._lastUsedTags.indexOf(o.id);return i!==l?-1===l?-1:-1===i?1:in.parts.length&&(r.parts.length=n.parts.length)}else{var s=[];for(o=0;o