'};L.prototype.options={readOnly:false};function L(M){this.onDeleteClick=f(this.onDeleteClick,this);this.onEditClick=f(this.onEditClick,this);this.load=f(this.load,this);this.hide=f(this.hide,this);this.show=f(this.show,this);L.__super__.constructor.call(this,y(this.html.element)[0],M);this.item=y(this.html.item)[0];this.fields=[];this.annotations=[]}L.prototype.show=function(N){var M,O=this;d.Util.preventEventDefault(N);M=this.element.find(".annotator-controls").addClass(this.classes.showControls);setTimeout((function(){return M.removeClass(O.classes.showControls)}),500);this.element.removeClass(this.classes.hide);return this.checkOrientation().publish("show")};L.prototype.isShown=function(){return !this.element.hasClass(this.classes.hide)};L.prototype.hide=function(M){d.Util.preventEventDefault(M);this.element.addClass(this.classes.hide);return this.publish("hide")};L.prototype.load=function(M){var U,Y,X,W,Z,S,P,ab,V,R,aa,O,N,ad,ac,T,Q;this.annotations=M||[];aa=this.element.find("ul:first").empty();T=this.annotations;for(O=0,ad=T.length;O")[0];this.fields.push(N);N.element;return this};L.prototype.onEditClick=function(M){return this.onButtonClick(M,"edit")};L.prototype.onDeleteClick=function(M){return this.onButtonClick(M,"delete")};L.prototype.onButtonClick=function(O,M){var N;N=y(O.target).parents(".annotator-annotation");return this.publish(M,[N.data("annotation")])};return L})(d.Widget);s=(function(){function g(L){this.data=L}g.prototype.get=function(V,S){var R,P,U,Q,T,N,L,M,O;if(S==null){S={}}S=y.extend({},S,{rel:V});U=(function(){var W;W=[];for(P in S){if(!K.call(S,P)){continue}T=S[P];W.push(P)}return W})();M=this.data;O=[];for(N=0,L=M.length;N",classes:{show:"annotator-notice-show",info:"annotator-notice-info",success:"annotator-notice-success",error:"annotator-notice-error"}};function L(M){this.hide=f(this.hide,this);this.show=f(this.show,this);L.__super__.constructor.call(this,y(this.options.html).appendTo(document.body)[0],M)}L.prototype.show=function(N,M){if(M==null){M=d.Notification.INFO}this.currentStatus=M;y(this.element).addClass(this.options.classes.show).addClass(this.options.classes[this.currentStatus]).html(c.escape(N||""));setTimeout(this.hide,5000);return this};L.prototype.hide=function(){if(this.currentStatus==null){this.currentStatus=d.Notification.INFO}y(this.element).removeClass(this.options.classes.show).removeClass(this.options.classes[this.currentStatus]);return this};return L})(b);d.Notification.INFO="info";d.Notification.SUCCESS="success";d.Notification.ERROR="error";y(function(){var g;g=new d.Notification;d.showNotification=g.show;return d.hideNotification=g.hide});d.Plugin.Unsupported=(function(g){j(L,g);function L(){n=L.__super__.constructor.apply(this,arguments);return n}L.prototype.options={message:d._t("Sorry your current browser does not support the Annotator")};L.prototype.pluginInit=function(){var M=this;if(!d.supported()){return y(function(){d.showNotification(M.options.message);if((window.XMLHttpRequest===void 0)&&(ActiveXObject!==void 0)){return y("html").addClass("ie6")}})}};return L})(d.Plugin);e=function(L){var Q,g,P,M,N,O;M="([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";Q=L.match(new RegExp(M));P=0;g=new Date(Q[1],0,1);if(Q[3]){g.setMonth(Q[3]-1)}if(Q[5]){g.setDate(Q[5])}if(Q[7]){g.setHours(Q[7])}if(Q[8]){g.setMinutes(Q[8])}if(Q[10]){g.setSeconds(Q[10])}if(Q[12]){g.setMilliseconds(Number("0."+Q[12])*1000)}if(Q[14]){P=(Number(Q[16])*60)+Number(Q[17]);P*=(O=Q[15]==="-")!=null?O:{1:-1}}P-=g.getTimezoneOffset();N=Number(g)+(P*60*1000);g.setTime(Number(N));return g};H=function(R){var X,N,W,O,V,U,T,S,Q,M,L,g,P;if(typeof atob!=="undefined"&&atob!==null){return atob(R)}else{N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";Q=0;X=0;O="";P=[];if(!R){return R}R+="";while(Q>16&255;L=W>>8&255;g=W&255;if(T===64){P[X++]=String.fromCharCode(M)}else{if(S===64){P[X++]=String.fromCharCode(M,L)}else{P[X++]=String.fromCharCode(M,L,g)}}}return P.join("")}};a=function(N){var L,g,M,O;g=N.length%4;if(g!==0){for(L=M=0,O=4-g;0<=O?MO;L=0<=O?++M:--M){N+="="}}N=N.replace(/-/g,"+");N=N.replace(/_/g,"/");return H(N)};J=function(L){var g,M,O,N;N=L.split("."),g=N[0],M=N[1],O=N[2];return JSON.parse(a(M))};d.Plugin.Auth=(function(L){j(g,L);g.prototype.options={token:null,tokenUrl:"/auth/token",autoFetch:true,requestMethod:"GET",requestData:null,unauthorizedCallback:null};function g(N,M){g.__super__.constructor.apply(this,arguments);this.waitingForToken=[];if(this.options.token){this.setToken(this.options.token)}else{this.requestToken()}}g.prototype.requestToken=function(){var M=this;this.requestInProgress=true;return y.ajax({url:this.options.tokenUrl,dataType:"text",data:this.options.requestData,type:this.options.requestMethod,xhrFields:{withCredentials:true}}).done(function(O,N,P){return M.setToken(O)}).fail(function(Q,N,O){var R,P;if(Q.status===401){R=M.options.unauthorizedCallback;if((R!=null)&&R(M)){M.retryTimeout=setTimeout((function(){return M.requestToken()}),1000);return}}P=d._t("Couldn't get auth token:");console.error(""+P+" "+O,Q);return d.showNotification(""+P+" "+Q.responseText,d.Notification.ERROR)}).always(function(){return M.requestInProgress=false})};g.prototype.setToken=function(N){var M,O=this;this.token=N;this._unsafeToken=J(N);if(this.haveValidToken()){if(this.options.autoFetch){this.refreshTimeout=setTimeout((function(){return O.requestToken()}),(this.timeToExpiry()-2)*1000)}this.updateHeaders();M=[];while(this.waitingForToken.length>0){M.push(this.waitingForToken.pop()(this._unsafeToken))}return M}else{console.warn(d._t("Didn't get a valid token."));if(this.options.autoFetch){console.warn(d._t("Getting a new token in 10s."));return setTimeout((function(){return O.requestToken()}),10*1000)}}};g.prototype.haveValidToken=function(){var M;M=this._unsafeToken&&this._unsafeToken.issuedAt&&this._unsafeToken.ttl&&this._unsafeToken.consumerKey;if(M&&this.timeToExpiry()>0){return true}else{return false}};g.prototype.timeToExpiry=function(){var O,M,N,P;N=new Date().getTime()/1000;M=e(this._unsafeToken.issuedAt).getTime()/1000;O=M+this._unsafeToken.ttl;P=O-N;if(P>0){return P}else{return 0}};g.prototype.updateHeaders=function(){var M;M=this.element.data("annotator:headers");return this.element.data("annotator:headers",y.extend(M,{"x-annotator-auth-token":this.token}))};g.prototype.withToken=function(M){if(M==null){return}if(this.haveValidToken()){return M(this._unsafeToken)}else{this.waitingForToken.push(M);if(!this.requestInProgress){return this.requestToken()}}};return g})(d.Plugin);d.Plugin.Store=(function(g){j(L,g);L.prototype.events={annotationCreated:"annotationCreated",annotationDeleted:"annotationDeleted",annotationUpdated:"annotationUpdated"};L.prototype.options={annotationData:{},emulateHTTP:false,loadFromSearch:false,prefix:"/store",urls:{create:"/annotations",read:"/annotations/:id",update:"/annotations/:id",destroy:"/annotations/:id",search:"/search"}};function L(N,M){this._onError=f(this._onError,this);this._onLoadAnnotationsFromSearch=f(this._onLoadAnnotationsFromSearch,this);this._onLoadAnnotations=f(this._onLoadAnnotations,this);this._getAnnotations=f(this._getAnnotations,this);L.__super__.constructor.apply(this,arguments);this.annotations=[]}L.prototype.pluginInit=function(){if(!d.supported()){return}if(this.annotator.plugins.Auth){return this.annotator.plugins.Auth.withToken(this._getAnnotations)}else{return this._getAnnotations()}};L.prototype._getAnnotations=function(){if(this.options.loadFromSearch){return this.loadAnnotationsFromSearch(this.options.loadFromSearch)}else{return this.loadAnnotations()}};L.prototype.annotationCreated=function(M){var N=this;if(o.call(this.annotations,M)<0){this.registerAnnotation(M);return this._apiRequest("create",M,function(O){if(O.id==null){console.warn(d._t("Warning: No ID returned from server for annotation "),M)}return N.updateAnnotation(M,O)})}else{return this.updateAnnotation(M,{})}};L.prototype.annotationUpdated=function(M){var N=this;if(o.call(this.annotations,M)>=0){return this._apiRequest("update",M,(function(O){return N.updateAnnotation(M,O)}))}};L.prototype.annotationDeleted=function(M){var N=this;if(o.call(this.annotations,M)>=0){return this._apiRequest("destroy",M,(function(){N.publish("annotationDestroyed",[M]);return N.unregisterAnnotation(M)}))}};L.prototype.registerAnnotation=function(M){return this.annotations.push(M)};L.prototype.unregisterAnnotation=function(M){return this.annotations.splice(this.annotations.indexOf(M),1)};L.prototype.updateAnnotation=function(M,N){if(o.call(this.annotations,M)<0){console.error(d._t("Trying to update unregistered annotation!"))}else{y.extend(M,N)}this.publish("annotationStored",[N]);return y(M.highlights).data("annotation",M)};L.prototype.loadAnnotations=function(){return this._apiRequest("read",null,this._onLoadAnnotations)};L.prototype._onLoadAnnotations=function(S){var U,R,T,V,Q,P,N,M,O;this.publish("annotationRead",[this.annotations,S]);if(S==null){S=[]}T={};O=this.annotations;for(Q=0,N=O.length;Qview this annotation"),load:M("updatePermissionsField","read"),submit:M("updateAnnotationPermissions","read")})}if(this.options.showEditPermissionsCheckbox===true){this.annotator.editor.addField({type:"checkbox",label:d._t("Allow anyone to edit this annotation"),load:M("updatePermissionsField","update"),submit:M("updateAnnotationPermissions","update")})}this.annotator.viewer.addField({load:this.updateViewer});if(this.annotator.plugins.Filter){return this.annotator.plugins.Filter.addFilter({label:d._t("User"),property:"user",isFiltered:function(S,R){var Q,T,P,U;R=O.options.userString(R);if(!(S&&R)){return false}U=S.split(/\s*/);for(T=0,P=U.length;T
=0){return true}}}return false}else{if(N.user){if(O){return this.userId(O)===this.userId(N.user)}else{return false}}}return true},user:"",groups:[],permissions:{read:[],update:[],"delete":[],admin:[]}};function L(N,M){this._setAuthFromToken=f(this._setAuthFromToken,this);this._cleanPermissions=f(this._cleanPermissions,this);this.updateViewer=f(this.updateViewer,this);this.updateAnnotationPermissions=f(this.updateAnnotationPermissions,this);this.updateGroupPermissionsField=f(this.updateGroupPermissionsField,this);this.updatePermissionsField=f(this.updatePermissionsField,this);this.addFieldsToAnnotation=f(this.addFieldsToAnnotation,this);L.__super__.constructor.apply(this,arguments);if(this.options.user){this.setUser(this.options.user);delete this.options.user}if(this.options.groups&&this.options.groups.length>0){this.setGroups(this.options.groups);delete this.options.groups}}L.prototype.pluginInit=function(){var M,N,O=this;if(!d.supported()){return}N=this;M=function(Q,P){return function(S,R){return N[Q].call(N,P,S,R)}};if(!this.user&&this.annotator.plugins.Auth){this.annotator.plugins.Auth.withToken(this._setAuthFromToken)}if(this.options.showViewPermissionsCheckbox===true){this.annotator.editor.addField({type:"checkbox",label:d._t("Allow anyone to view this annotation"),load:M("updatePermissionsField","read"),submit:M("updateAnnotationPermissions","read")})}if(this.options.showEditPermissionsCheckbox===true){this.annotator.editor.addField({type:"checkbox",label:d._t("Allow anyone to edit this annotation"),load:M("updatePermissionsField","update"),submit:M("updateAnnotationPermissions","update")})}if(this.options.showAdminGroupSelection===true){this.annotator.editor.addField({type:"select",label:d._t(" group manages this annotation"),load:M("updateGroupPermissionsField","admin"),submit:M("updateAnnotationPermissions","admin")})}this.annotator.viewer.addField({load:this.updateViewer});if(this.annotator.plugins.Filter){return this.annotator.plugins.Filter.addFilter({label:d._t("User"),property:"user",isFiltered:function(S,R){var Q,T,P,U;R=O.options.userString(R);if(!(S&&R)){return false}U=S.split(/\s*/);for(T=0,P=U.length;T