YUI.add("moodle-atto_managefiles-usedfiles",function(o,e){var f="has-missing-files",r="has-unused-files",u=".fitem",m="#atto_managefiles_manageform",g=".missing-files";M.atto_managefiles=M.atto_managefiles||{},M.atto_managefiles.usedfiles=M.atto_managefiles.usedfiles||{_usercontext:null,_itemid:null,_elementid:null,init:function(e){var i,n,t,s,l,a,d;if(this._usercontext=e.usercontext,this._itemid=e.itemid,this._elementid=e.elementid,i=e.files,(n=o.one(m))&&window.parent)if(t=this._getUsedFiles(),s=this.findUnusedFiles(i,t),l=this.findMissingFiles(i,t),0<s.length?(n.all('input[type=checkbox][name^="deletefile"]').each(function(e){-1===o.Array.indexOf(s,e.getData("filename"))&&e.ancestor(u).remove()}),n.addClass(r)):n.removeClass(r),0<l.length){for(a="<ul>",d=0;d<l.length;d++)a+="<li>"+o.Escape.html(l[d])+"</li>";a+="</ul>",n.one(g).setHTML("").append(a),n.addClass(f)}else n.removeClass(f)},_getUsedFiles:function(){for(var e=o.one(window.parent.document.getElementById(this._elementid+"editable")),i=M.cfg.wwwroot+"/draftfile.php/"+this._usercontext+"/user/draft/"+this._itemid+"/",n=new RegExp(i.replace(/[\-\/\\\^$*+?.()|\[\]{}]/g,"\\$&")+"(.+?)[\\?\"']","gm"),t="",s={};null!==(t=n.exec(e.get("innerHTML")));)s[decodeURIComponent(t[1])]=!0;return s},findUnusedFiles:function(e,i){var n,t=[];for(n in e)i[n]||t.push(n);return t},findMissingFiles:function(e,i){var n,t=[];for(n in i)e[n]||t.push(n);return t}}},"@VERSION@",{requires:["node","escape"]});