Socket
Socket
Sign inDemoInstall

opentok-annotation

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opentok-annotation - npm Package Compare versions

Comparing version 2.0.20 to 2.0.21

4

dist/opentok-annotation.min.js

@@ -1,2 +0,2 @@

(function(){var t,e,n,o={clientVersion:"js-vsol-1.1.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionStartDrawing:"StartDrawing",actionEndDrawing:"EndDrawing",variationSuccess:"Success"},i=function(){var i=window.location.href,a={clientVersion:o.clientVersion,source:i,componentId:o.componentId,name:o.name};e=new t(a);var s={sessionId:n.id,connectionId:n.connection.connectionId,partnerId:n.apiKey};e.addSessionInfo(s)},a=function(t,n){var o={action:t,variation:n};e.logEvent(o)},s="https://assets.tokbox.com/solutions/images/";OTSolution=this.OTSolution||{},OTSolution.Annotations=function(n){function r(t,e,n){for(var o=e.split(" "),i=0,a=o.length;i<a;i++)t.addEventListener(o[i],n,!0)}function c(t,e){0===u.width&&(u.width=h.parent.getBoundingClientRect().width),0===u.height&&(u.height=h.parent.getBoundingClientRect().height);var n,i=e?t.canvas.width:h.parent.clientWidth,s=e?t.canvas.height:h.parent.clientHeight,r=e?t.canvas.offsetLeft:u.offsetLeft,c=e?t.canvas.offsetTop:u.offsetTop,l=u.width/i,d=u.height/s,p=t.offsetX||t.pageX-r||t.changedTouches&&t.changedTouches[0].pageX-r,g=t.offsetY||t.pageY-c||t.changedTouches&&t.changedTouches[0].pageY-c,f=p*l,b=g*d,v=e?t.selectedItem:h.selectedItem;if(v)if("OT_pen"===v.id)switch(t.type){case"mousedown":case"touchstart":T.dragging=!0,T.lastX=f,T.lastY=b,h.isStartPoint=!0,!e&&a(o.actionStartDrawing,o.variationSuccess);break;case"mousemove":case"touchmove":T.dragging&&(n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.lastX,fromY:T.lastY,toX:f,toY:b,color:e?t.userColor:h.userColor,lineWidth:h.lineWidth,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,startPoint:h.isStartPoint,endPoint:!1,selectedItem:v,platform:"web",guid:t.guid},W(n,!0),T.lastX=f,T.lastY=b,!e&&D(n),h.isStartPoint=!1);break;case"mouseup":case"touchend":T.dragging=!1,n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.lastX,fromY:T.lastY,toX:f,toY:b,color:e?t.userColor:h.userColor,lineWidth:h.lineWidth,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,startPoint:h.isStartPoint,endPoint:!0,selectedItem:v,platform:"web",guid:t.guid},W(n,!0),T.lastX=f,T.lastY=b,!e&&D(n),h.isStartPoint=!1,!e&&a(o.actionEndDrawing,o.variationSuccess);break;case"mouseout":T.dragging=!1}else if("OT_text"===v.id)n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:f,fromY:b+t.inputHeight,color:t.userColor,font:t.font,text:t.text,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,selectedItem:v,platform:"web",guid:t.guid},W(n),!e&&D(n);else{var x=2;if(v&&v.points)switch(T.mX=f,T.mY=b,t.type){case"mousedown":case"touchstart":T.isDrawing=!0,T.dragging=!0,T.startX=f,T.startY=b;break;case"mousemove":case"touchmove":T.dragging&&(n={color:e?t.userColor:h.userColor,lineWidth:e?t.lineWidth:x,selectedItem:v},W(n,!0));break;case"mouseup":case"touchend":T.isDrawing=!1;var I=v.points;if(2===I.length)n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.startX,fromY:T.startY,toX:T.mX,toY:T.mY,color:e?t.userColor:h.userColor,lineWidth:e?t.lineWidth:x,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,smoothed:!1,startPoint:!0,selectedItem:v,platform:"web",guid:t.guid},w.push(n),!e&&D(n);else{for(var y=L(I),k=0;k<I.length;k++){var O=!1,M=!1,_=T.startX+y.x*I[k][0],C=T.startY+y.y*I[k][1];0===k?(T.lastX=_,T.lastY=C,O=!0):k===I.length-1&&(M=!0),n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.lastX,fromY:T.lastY,toX:_,toY:C,color:e?t.userColor:h.userColor,lineWidth:e?t.lineWidth:x,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,smoothed:v.enableSmoothing,startPoint:O,endPoint:M,selectedItem:v,platform:"web",guid:t.guid},w.push(n),!e&&D(n),T.lastX=_,T.lastY=C}W(null)}T.dragging=!1}}}function l(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"==t?e:3&e|8;return n.toString(16)})}n=n||{},this.widgetVersion="js-1.0.0-beta",this.parent=n.container,this.videoFeed=n.feed,this.imageAssets=n.imageAssets||s,t=t||n.OTKAnalytics,e||i();var d=n.externalWindow?n.externalWindow.document:window.document,h=this;if(this.parent){var u=document.createElement("canvas");u.setAttribute("id","opentok_canvas"),u.style.position="absolute",this.parent.appendChild(u),u.setAttribute("width",this.parent.clientWidth+"px"),u.style.width=window.getComputedStyle(this.parent).width,u.setAttribute("height",this.parent.clientHeight+"px"),u.style.height=window.getComputedStyle(this.parent).height}var p,g,m,f,b,h=this,v=[],x=[],w=[],I=[],y=[],T={dragging:!1};g=(" "+h.videoFeed.element.className+" ").indexOf(" OT_publisher ")>-1,m=!!g&&(" "+h.videoFeed.element.className+" ").indexOf(" OT_mirrored ")>-1,f=(" "+h.videoFeed.element.className+" ").indexOf(" OT_fit-mode-cover ")>-1,this.canvas=function(){return u},this.link=function(t){this.session=t},this.changeColor=function(t){h.userColor=t,h.lineWidth||(h.lineWidth=2)},this.changeLineWidth=function(t){this.lineWidth=t},this.selectItem=function(t){h.overlay&&(h.parent.removeChild(h.overlay),h.overlay=null);var e=function(){var e=d.getElementById(h.selectedItem.id),n=d.getElementById("OT_shapes"),o=n.classList.contains("selected");o?n.classList.remove("selected"):e.classList.remove("selected");var i=d.getElementById(t.id);i.parentElement.classList.contains("shapes")?n.classList.add("selected"):i.classList.add("selected")};t&&"OT_capture"===t.id?h.captureScreenshot():t&&t.id.indexOf("OT_line_width")!==-1?t.size&&h.changeLineWidth(t.size):"OT_undo"!==t.id&&"OT_clear"!==t.id&&(e(),h.selectedItem=t)},this.colors=function(t){this.colors=t,this.changeColor(t[0])},this.clear=function(){j(!1,h.session.connection.connectionId),h.session&&h.session.signal({type:"otAnnotation_clear"})},this.undo=function(){F(!1,h.session.connection.connectionId)},this.captureScreenshot=function(){var t=document.createElement("canvas");t.width=u.width,t.height=u.height;var e=h.videoFeed.videoWidth(),n=h.videoFeed.videoHeight(),o=1,i=0,a=0;f?e<n?(o=u.width/e,e=u.width,n*=o):(o=u.height/n,n=u.height,e*=o):e>n?(o=u.width/e,e=u.width,n*=o):(o=u.height/n,n=u.height,e*=o),i=(e-u.width)/2,a=(n-u.height)/2;var s=new Image;s.onload=function(){var o=t.getContext("2d");m&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(s,i,a,e,n),m&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(u,0,0),v.forEach(function(e){e.call(h,t.toDataURL())}),t=null},s.src="data:image/png;base64,"+h.videoFeed.getImgData()},this.onScreenCapture=function(t){v.push(t)},this.onResize=function(){w=[],z(I,!0),y.forEach(function(t){c(t,!0)})},r(u,"mousedown mousemove mouseup mouseout touchstart touchmove touchend",function(t){var e=h.selectedItem&&"OT_text"===h.selectedItem.id,n="mousemove"===t.type&&!T.dragging;e||n||(t.preventDefault(),t.selectedItem=h.selectedItem,t.selectedItem&&(t.canvas={width:u.width,height:u.height,offsetLeft:u.offsetLeft,offsetTop:u.offsetTop},t.userColor=h.userColor,t.lineWidth=h.lineWidth,t.guid=l(),y.push(t)),c(t))});var k,O="textAnnotation",M=!1,_=function(t){t.preventDefault(),h.selectedItem&&"OT_text"===h.selectedItem.id&&!M&&(M=!0,t.selectedItem=h.selectedItem,S(t))},C=function(t){13===t.which&&A(),27===t.which&&(d.getElementById(O).remove(),k=null),M=!1},E=function(){d.addEventListener("keydown",C)},P=function(){d.removeEventListener("keydown",C)},A=function(){var t=d.getElementById(O);t.clientHeight;return t.value?(t.remove(),P(),k.text=t.value,k.font="16px Arial",k.userColor=h.userColor,k.canvas={width:u.width,height:u.height,offsetLeft:u.offsetLeft,offsetTop:u.offsetTop},y.push(k),void c(k)):void(k=null)},S=function(t){var e=d.createElement("input");e.setAttribute("type","text"),e.style.position="absolute",e.style.top=t.clientY+"px",e.style.left=t.clientX+"px",e.style.background="rgba(255,255,255, .5)",e.style.width="100px",e.style.maxWidth="200px",e.style.border="1px dashed red",e.style.fontSize="16px",e.style.color=h.userColor,e.style.fontFamily="Arial",e.style.zIndex="1001",e.setAttribute("data-canvas-origin",JSON.stringify({x:t.offsetX,y:t.offsetY})),e.id=O,d.body.appendChild(e),e.focus(),k=t,k.inputHeight=e.clientHeight,E()};r(u,"click",_);var W=function(t,e){p||(p=u.getContext("2d"),p.lineCap="round",p.lineJoin="round",p.fillStyle="solid"),p.clearRect(0,0,u.width,u.height),w.forEach(function(t){p.strokeStyle=t.color,p.lineWidth=t.lineWidth,t.smoothed=!!t.smoothed,t.startPoint=!!t.startPoint;var e=!1,n=t.hasOwnProperty("text");n?(p.font=t.font,p.fillStyle=t.color,p.fillText(t.text,t.fromX,t.fromY)):t.smoothed?(t.startPoint?h.isStartPoint=!0:h.isStartPoint&&(e=!0,h.isStartPoint=!1),t.startPoint?(p.closePath(),p.beginPath()):e?p.moveTo((t.fromX+t.toX)/2,(t.fromY+t.toY)/2):(p.quadraticCurveTo(t.fromX,t.fromY,(t.fromX+t.toX)/2,(t.fromY+t.toY)/2),p.stroke())):(p.beginPath(),p.moveTo(t.fromX,t.fromY),p.lineTo(t.toX,t.toY),p.stroke(),p.closePath())});var n=e?t.selectedItem:h.selectedItem;!n||"Pen"!==n.title&&"Text"!==n.title?T.isDrawing&&(t&&(p.strokeStyle=t.color,p.lineWidth=t.lineWidth),n&&n.points&&X(p,h.selectedItem.points)):t&&("Pen"===n.title&&(p.strokeStyle=t.color,p.lineWidth=t.lineWidth,p.beginPath(),p.moveTo(t.fromX,t.fromY),p.lineTo(t.toX,t.toY),p.stroke(),p.closePath()),"Text"===n.title&&(p.font=t.font,p.fillStyle=t.color,p.fillText(t.text,t.fromX,t.fromY)),w.push(t))},X=function(t,e){var n=L(e);if(t.beginPath(),2===e.length)t.moveTo(T.startX,T.startY),t.lineTo(T.mX,T.mY);else for(var o=0;o<e.length;o++){var i=T.startX+n.x*e[o][0],a=T.startY+n.y*e[o][1];h.selectedItem.enableSmoothing?0===o||(1===o?(t.moveTo((i+T.lastX)/2,(a+T.lastY)/2),T.lastX=(i+T.lastX)/2,T.lastX=(a+T.lastY)/2):(t.quadraticCurveTo(T.lastX,T.lastY,(i+T.lastX)/2,(a+T.lastY)/2),T.lastX=(i+T.lastX)/2,T.lastY=(a+T.lastY)/2)):0===o?t.moveTo(i,a):t.lineTo(i,a),T.lastX=i,T.lastY=a}t.stroke(),t.closePath()},L=function(t){for(var e=Number.MAX_VALUE,n=Number.MAX_VALUE,o=0,i=0,a=0;a<t.length;a++)t[a][0]<e?e=t[a][0]:t[a][0]>o&&(o=t[a][0]),t[a][1]<n?n=t[a][1]:t[a][1]>i&&(i=t[a][1]);var s=Math.abs(o-e),r=Math.abs(i-n),c=(T.mX-T.startX)/s,l=(T.mY-T.startY)/r;return{x:c,y:l}},Y=function(t,e,n){var o={width:t.canvasWidth,height:t.canvasHeight},i={width:t.videoWidth,height:t.videoHeight},a={width:h.videoFeed.videoElement().clientWidth,height:h.videoFeed.videoElement().clientHeight},s=1,r=u.width/u.height;a.width/a.height,o.width/o.height,i.width/i.height;s=r<0?u.width/o.width:u.height/o.height;var c=u.width/2,l=u.height/2,d=o.width/2,p=o.height/2;t.fromX=c-s*(d-t.fromX),t.fromY=l-s*(p-t.fromY),t.toX=c-s*(d-t.toX),t.toY=l-s*(p-t.toY),t.mirrored=!!t.mirrored,t.mirrored&&(t.fromX=u.width-t.fromX,t.toX=u.width-t.toX),m&&(t.fromX=u.width-t.fromX,t.toX=u.width-t.toX);var g=JSON.parse(JSON.stringify(t));g.canvasWidth=u.width,g.canvasHeight=u.height,g.videoWidth=a.width,g.videoHeight=a.height,e?I[n]=g:I.push(g),w.push(t),W(null)},z=function(t,e){t.forEach(function(t,n){h.videoFeed.stream&&t.id===h.videoFeed.stream.connection.connectionId&&Y(t,e,n)})},j=function(t,e){w=w.filter(function(t){return t.fromId!==e}),t?I=[]:(h.session&&h.session.signal({type:"otAnnotation_clear"}),y=[]),W()},F=function(t,e,n){for(var o,i,a=!1,s=[],r=w.length-1;r>=0&&(o=w[r],o.fromId!==e||(a=a||o.endPoint,i=w.splice(r,1)[0],s.push(i.guid),a&&(!a||i.startPoint!==!0)));r--);t?I=I.filter(function(t){return!n.includes(t.guid)}):(y=y.filter(function(t){return!s.includes(t.guid)}),h.session.signal({type:"otAnnotation_undo",data:JSON.stringify(s)})),W()};h.videoFeed.session&&h.videoFeed.session.on({"signal:otAnnotation_pen":function(t){t.from.connectionId!==h.session.connection.connectionId&&z(JSON.parse(t.data))},"signal:otAnnotation_text":function(t){t.from.connectionId!==h.session.connection.connectionId&&z(JSON.parse(t.data))},"signal:otAnnotation_history":function(t){b&&b!==t.from.connectionId||(b=t.from.connectionId,z(JSON.parse(t.data)))},"signal:otAnnotation_clear":function(t){t.from.connectionId!==h.session.connection.connectionId&&j(!0,t.from.connectionId)},"signal:otAnnotation_undo":function(t){t.from.connectionId!==h.session.connection.connectionId&&F(!0,t.from.connectionId,JSON.parse(t.data))},connectionCreated:function(t){w.length>0&&t.connection.connectionId!==h.session.connection.connectionId&&B("otWhiteboard_history",w,t.connection)}});var H,B=function(t,e){for(var n,o=function(t){t&&TB.error(t)},i="otAnnotation_pen",a=function(t){if(t&&t[0]&&t[0].selectedItem&&t[0].selectedItem.id){var e=t[0].selectedItem.id;i="OT_text"===e?"otAnnotation_text":"otAnnotation_pen"}},s=0,r=7;s<t.length;){n=t.slice(s,s+r),a(n),s+=r;var c={type:i,data:JSON.stringify(n)};e&&(c.to=e),h.session.signal(c,o)}},D=function(t){h.session&&(x.push(t),H||(H=setTimeout(function(){B(x),x=[],H=null},100)))}},OTSolution.Annotations.Toolbar=function(o){var a=this,r=this;if(o||(o={}),!o.session)throw new Error("OpenTok Annotation Widget requires an OpenTok session");if(n=o.session,!t&&!o.OTKAnalytics)throw new Error("OpenTok Annotation Widget requires an OpenTok Solution");t=t||o.OTKAnalytics,e||i(),this.session=o.session,this.parent=o.container,this.externalWindow=o.externalWindow,this.backgroundColor=o.backgroundColor||"rgba(102, 102, 102, 0.90)",this.subpanelBackgroundColor=o.subpanelBackgroundColor||"#323232";var c=o.imageAssets||s,l=[{id:"OT_pen",title:"Pen",icon:[c,"annotation-pencil.png"].join(""),selectedIcon:[c,"annotation-pencil.png"].join(""),items:{}},{id:"OT_colors",title:"Colors",icon:"",items:{}},{id:"OT_shapes",title:"Shapes",icon:[c,"annotation-shapes.png"].join(""),items:[{id:"OT_rect",title:"Rectangle",icon:[c,"annotation-rectangle.png"].join(""),points:[[0,0],[1,0],[1,1],[0,1],[0,0]]},{id:"OT_rect_fill",title:"Rectangle-Fill",icon:[c,"annotation-rectangle.png"].join(""),points:[[0,0],[1,0],[1,1],[0,1],[0,0]]},{id:"OT_oval",title:"Oval",icon:[c,"annotation-oval.png"].join(""),enableSmoothing:!0,points:[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]},{id:"OT_oval_fill",title:"Oval-Fill",icon:[c,"annotation-oval-fill.png"].join(""),enableSmoothing:!0,points:[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]},{id:"OT_star",title:"Star",icon:[c,"annotation-star.png"].join(""),points:[[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))],[.5+.25*Math.cos(126*(Math.PI/180)),.5+.25*Math.sin(126*(Math.PI/180))],[.5+.5*Math.cos(162*(Math.PI/180)),.5+.5*Math.sin(162*(Math.PI/180))],[.5+.25*Math.cos(198*(Math.PI/180)),.5+.25*Math.sin(198*(Math.PI/180))],[.5+.5*Math.cos(234*(Math.PI/180)),.5+.5*Math.sin(234*(Math.PI/180))],[.5+.25*Math.cos(270*(Math.PI/180)),.5+.25*Math.sin(270*(Math.PI/180))],[.5+.5*Math.cos(306*(Math.PI/180)),.5+.5*Math.sin(306*(Math.PI/180))],[.5+.25*Math.cos(342*(Math.PI/180)),.5+.25*Math.sin(342*(Math.PI/180))],[.5+.5*Math.cos(18*(Math.PI/180)),.5+.5*Math.sin(18*(Math.PI/180))],[.5+.25*Math.cos(54*(Math.PI/180)),.5+.25*Math.sin(54*(Math.PI/180))],[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))]]},{id:"OT_arrow",title:"Arrow",icon:[c,"annotation-arrow.png"].join(""),points:[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]},{id:"OT_line",title:"Line",icon:[c,"annotation-line.png"].join(""),selectedIcon:[c,"annotation-line.png"].join(""),points:[[0,0],[0,1]]}]},{id:"OT_text",title:"Text",icon:[c,"annotation-text.png"].join(""),selectedIcon:[c,"annotation-text.png"].join("")},{id:"OT_capture",title:"Capture",icon:[c,"annotation-camera.png"].join(""),selectedIcon:[c,"annotation-camera.png"].join("")},{id:"OT_undo",title:"Undo",icon:[c,"annotation-undo.png"].join("")},{id:"OT_clear",title:"Clear",icon:[c,"annotation-clear.png"].join("")}],d=function(){var t=["pen","colors","shapes","text","capture","undo","clear"],e=["rectangle","rectangle-fill","oval","oval-fill","star","arrow","line"],n=function(n,i){var a=t.indexOf(i);if(a!==-1){var s=l[a];if("Shapes"===s.title&&o.shapes){var r=o.shapes.reduce(function(t,n){var o=e.indexOf(n);return o!==-1?t.concat(s.items[o]):t},[]);s.items=r}n.push(s)}return n};if(o.items&&o.items.length){var i="*"===o.items[0]?t:o.items;return i.reduce(n,[])}return l};this.items=d(),this.colors=o.colors||["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],this.cbs=[];var h,u=[],p=function(t,e,n){var o=this,i=r.externalWindow?r.externalWindow.document:document;this.getElm=function(t,e){return"string"==typeof t?e?i.querySelectorAll(t):i.querySelector(t):t},this.render=function(){var t=this,e="";t.colors.forEach(function(n){e+=t.options.template.replace(/\{color\}/g,n)}),t.elm.innerHTML=e},this.close=function(){this.elm.classList.add("ots-hidden")},this.open=function(){this.elm.classList.remove("ots-hidden")},this.colorChosen=function(t){this.cbs.push(t)},this.set=function(t,e){var n=this;n.color=t,e!==!1&&n.cbs.forEach(function(e){e.call(n,t)})},n=n||{},n.openEvent=n.openEvent||"click",n.style=Object(n.style),n.template=n.template||'<div class="color-choice" data-col="{color}" style="background-color: {color}"></div>',o.elm=o.getElm(t),o.cbs=[],o.colors=e,o.options=n,o.render(),o.elm.addEventListener("click",function(t){var e=t.target.getAttribute("data-col");if(e){var n=Array.from(o.getElm(".color-choice",!0));n.forEach(function(t){t.classList.remove("active")}),t.target.classList.add("active"),o.set(e),o.close()}}),n.autoclose!==!1&&o.close()};this.createPanel=function(t){if(r.parent){var e=t?t.document:document;h=e.createElement("div"),h.setAttribute("id","OT_toolbar"),h.setAttribute("class","OT_panel"),h.style.width="100%",h.style.height="100%",this.parent.appendChild(h),this.parent.style.position="relative",this.parent.zIndex=1e3;for(var n=[],o=e.createElement("div"),i=0,s=this.items.length;i<s;i++){var c=this.items[i],l=e.createElement("input");if(l.setAttribute("type","button"),l.setAttribute("id",c.id),l.classList.add("annotation-btn"),l.classList.add(c.title.split(" ").join("-").toLowerCase()),"OT_colors"===c.id){var d=e.createElement("div");d.setAttribute("class","color-picker"),this.parent.appendChild(d);var m=new p(".color-picker",this.colors,{externalWindow:r.externalWindow});m.colorChosen(function(t){var n=e.getElementById("OT_colors");n.style.backgroundColor=t,u.forEach(function(e){e.changeColor(t)})});var f=e.querySelectorAll(".color-choice");f[0].classList.add("active"),l.setAttribute("class","OT_color annotation-btn colors"),l.style.borderRadius="50%",l.style.backgroundColor=this.colors[0]}"Pen"!==c.title||Array.isArray(c.items)||(c.items=[{id:"OT_line_width_2",title:"Line Width 2",size:2},{id:"OT_line_width_4",title:"Line Width 4",size:4},{id:"OT_line_width_6",title:"Line Width 6",size:6},{id:"OT_line_width_8",title:"Line Width 8",size:8},{id:"OT_line_width_10",title:"Line Width 10",size:10},{id:"OT_line_width_12",title:"Line Width 12",size:12},{id:"OT_line_width_14",title:"Line Width 14",size:14}]),c.items&&l.setAttribute("data-type","group"),l.setAttribute("data-col",c.title),n.push(l.outerHTML)}h.innerHTML=n.join("");var b=function(t){var e=t?"add":"remove";document.getElementById("OT_toolbar").classList[e]("colors-hover")},v=e.getElementById("OT_colors");v.addEventListener("mouseenter",function(){b(!0)}),v.addEventListener("mouseleave",function(){b(!1)}),h.onclick=function(t){var n="group"===t.target.getAttribute("data-type"),i=t.target.getAttribute("data-col"),s=t.target.getAttribute("id");n?a.items.forEach(function(t){if(t.title===i){if(a.selectedGroup=t,t.items&&(o.setAttribute("class",["OT_subpanel","ots-hidden",t.title.toLowerCase()].join(" ")),a.parent.appendChild(o),Array.isArray(t.items))){var n=[];"OT_pen"===t.id?t.items.forEach(function(t){var o=e.createElement("div");o.setAttribute("data-col",t.title),o.setAttribute("class",["line-width-option",t.size].join(" ")),o.setAttribute("id",t.id);var i=e.createElement("div");i.setAttribute("class","line-width-icon"),i.style.backgroundColor="#FFFFFF",i.style.width="80%",i.style.height=t.size+"px",i.style.position="relative",i.style.left="50%",i.style.top="50%",i.style.transform="translateX(-50%) translateY(-50%)",i.style.pointerEvents="none",o.appendChild(i),n.push(o.outerHTML)}):t.items.forEach(function(t){var o=e.createElement("input");o.setAttribute("type","button"),o.setAttribute("data-col",t.title),o.setAttribute("id",t.id),o.setAttribute("class",["annotation-btn",t.title.toLowerCase()].join(" ")),n.push(o.outerHTML)}),o.innerHTML=n.join("")}"OT_shapes"===s||"OT_pen"===s?(o&&o.classList.remove("ots-hidden"),m.close()):"OT_colors"===s&&(o&&o.classList.add("ots-hidden"),m.open())}}):(a.items.forEach(function(t){if(("Clear"!==t.title||"Undo"!==t.title)&&t.title===i)return a.selectedItem=t,g(t),u.forEach(function(t){t.selectItem(a.selectedItem)}),!1}),o.classList.add("ots-hidden")),a.cbs.forEach(function(t){t.call(a,s)})},o.onclick=function(t){var e="group"===t.target.getAttribute("data-type"),n=(t.target.getAttribute("data-col"),t.target.getAttribute("id"));n&&"linewidth"===n.replace(/[^a-z]/g,"")&&u.forEach(function(t){t.selectItem(a.selectedGroup)}),o.classList.add("ots-hidden"),e||a.selectedGroup.items.forEach(function(t){if("OT_clear"!==t.id&&t.id===n){if(a.selectedItem)var e=document.getElementById(a.selectedItem.id);if(t.selectedIcon){var o=document.getElementById(t.id);e&&(o.style.background='url("'+t.selectedIcon+'") no-repeat',o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center")}return a.selectedItem=t,g(t),u.forEach(function(t){t.selectItem(a.selectedItem)}),!1}}),a.cbs.forEach(function(t){t.call(a,n)})};var x=e.getElementById("OT_clear").onclick=function(){u.forEach(function(t){t.clear()})};e.getElementById("OT_undo").onclick=function(){u.forEach(function(t){t.undo()})},window.addEventListener("OT_clear",function(){x(),a.selectedItem=null,u.forEach(function(t){t.selectItem(a.selectedItem)})}),window.addEventListener("OT_pen",function(t){var e=a.items.find(function(t){return"OT_pen"===t.id});a.selectedItem=e,g(e);var n=t.detail.color;u.forEach(function(t){t.selectItem(a.selectedItem),n&&t.changeColor(n)})})}},!this.externalWindow&&this.createPanel();var g=function(t){t.points||("OT_line"===t.id?a.selectedItem.points=[[0,0],[0,1]]:"OT_arrow"===t.id?a.selectedItem.points=[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]:"OT_rect"===t.id?a.selectedItem.points=[[0,0],[1,0],[1,1],[0,1],[0,0]]:"OT_oval"===t.id&&(a.selectedItem.enableSmoothing=!0,a.selectedItem.points=[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]))};this.itemClicked=function(t){this.cbs.push(t)},this.addCanvas=function(t){var e=this;t.link(e.session),t.colors(e.colors),u.push(t),u.forEach(function(t){t.selectedItem=t.selectedItem||e.items[0],document.getElementById(t.selectedItem.id).classList.add("selected")})},this.removeCanvas=function(t){u.forEach(function(e){var n=e.canvas();e.videoFeed.stream.connection.connectionId===t&&n.parentNode&&n.parentNode.removeChild(n)}),u=u.filter(function(e){return e.videoFeed.stream.connection.connectionId!==t})},this.remove=function(){try{h.parentNode.removeChild(h)}catch(t){console.log(t)}u.forEach(function(t){var e=t.canvas();e.parentNode&&e.parentNode.removeChild(e)}),u=[]}}}).call(this),function(){var t,e,n;"object"==typeof module&&"object"==typeof module.exports?(t=require("underscore"),e=require("jquery"),n=require("opentok-solutions-logging")):(t=this._,e=this.$,n=this.OTKAnalytics);var o,i,a,s,r,c={},l={clientVersion:"js-vsol-1.1.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionInitialize:"Init",actionStart:"Start",actionEnd:"End",actionFreeHand:"FreeHand",actionPickerColor:"PickerColor",actionText:"Text",actionScreenCapture:"ScreenCapture",actionErase:"Erase",actionUseToolbar:"UseToolbar",variationAttempt:"Attempt",variationError:"Failure",variationSuccess:"Success"},d=function(){var t=window.location.href,e={clientVersion:l.clientVersion,source:t,componentId:l.componentId,name:l.name};r=new n(e);var o={sessionId:a.id,connectionId:a.connection.connectionId,partnerId:a.apiKey};r.addSessionInfo(o)},h=function(t,e){var n={action:t,variation:e};r.logEvent(n)},u=function(t,e){i&&i.triggerEvent(t,e)},p=function(){if(i){var t=["startAnnotation","linkAnnotation","resizeCanvas","annotationWindowClosed","endAnnotation"];i.registerEvents(t)}},g=function(){var t=['<div id="annotationToolbarContainer" class="ots-annotation-toolbar-container">','<div id="toolbar"></div>',"</div>"].join("\n");e("body").append(t),h(l.actionUseToolbar,l.variationSuccess)},m=["#1abc9c","#2ecc71","#3498db","#9b59b6","#8e44ad","#f1c40f","#e67e22","#e74c3c","#ded5d5"],f=10/6,b=t.throttle(function(){s.onResize()},1e3),v=function(){var t,n;if(c.externalWindow){var o={width:c.externalWindow.innerWidth,height:c.externalWindow.innerHeight},i=o.width/f;i<=o.height?(t=o.width,n=i):(n=o.height,t=n*f)}else{var a=c.absoluteParent||c.canvasContainer;t=a.clientWidth,n=t/f,a.clientHeight<t/f&&(n=a.clientHeight,t=n*f)}e(c.canvasContainer).css({width:t,height:n}),e(c.canvasContainer).find("canvas").css({width:t,height:n}),e(c.canvasContainer).find("canvas").attr({width:t,height:n}),b(),u("resizeCanvas")},x=function(){e(c.resizeSubject).on("resize",t.throttle(function(){v()},500))},w=function(e,o,i){g();var a=t.property("toolbarId")(o)||"toolbar",s=t.property("toolbarItems")(o)||[],r=t.property("toolbarShapes")(o)||[],c=t.property("colors")(o)||m,d=t.property("imageAssets")(o)||null,u=t.property("backgroundColor")(o)||null,p=function(){var t=i?i:window;return t.document.getElementById(a)};toolbar=new OTSolution.Annotations.Toolbar({session:e,container:p(),colors:c,items:s.length?s:["*"],shapes:r.length?r:["rectangle","oval","star","arrow","line"],externalWindow:i||null,imageAssets:d,backgroundColor:u,OTKAnalytics:n}),toolbar.itemClicked(function(t){var e={OT_pen:l.actionFreeHand,OT_colors:l.actionPickerColor,OT_text:l.actionText,OT_clear:l.actionErase},n=e[t];n&&h(n,l.variationSuccess)})},I=function(){var t=e.Deferred(),n=.8*screen.width|0,o=n/f,i='<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><style type="text/css" media="screen"> body{margin:0;background-color:rgba(0,153,203,.7);box-sizing:border-box;height:100vh}canvas{top:0;z-index:1000}.hidden{display:none}.ots-hidden{display:none !important}.main-wrap{width:100%;height:100%;-ms-box-orient:horizontal;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-moz-flex;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center}.inner-wrap{position:relative;border-radius:8px;overflow:hidden}.ots-annotation-toolbar-container{position:fixed;top:125px;right:0;width:60px;z-index:1000;background-color:#666}.ots-annotation-toolbar-container .OT_panel{display:flex;flex-direction:column;align-items:center}.ots-annotation-toolbar-container .annotation-btn{height:60px;width:60px;background-position:center center;background-repeat:no-repeat!important;background-color:#666;cursor:pointer;border:none}.ots-annotation-toolbar-container .annotation-btn.pen{background-image:url(https://assets.tokbox.com/solutions/images/annotation-pencil.png);background-size:27px 30px}.ots-annotation-toolbar-container .annotation-btn.colors{width:23px;height:24px;border:3px solid #fff;margin:18px 18.5px}.ots-annotation-toolbar-container .annotation-btn.line{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.line-width{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line_width.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.shapes{background-image:url(https://assets.tokbox.com/solutions/images/annotation-shapes.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.text{background-image:url(https://assets.tokbox.com/solutions/images/annotation-text.png);background-size:21px 25px}.ots-annotation-toolbar-container .annotation-btn.capture{background-image:url(https://assets.tokbox.com/solutions/images/annotation-camera.png);background-size:34px 31px}.ots-annotation-toolbar-container .annotation-btn.clear{background-image:url(https://assets.tokbox.com/solutions/images/annotation-trash.png);background-size:31px 31px}.ots-annotation-toolbar-container .annotation-btn.undo{background-image:url(https://assets.tokbox.com/solutions/images/annotation-undo.png);background-size:34px 31px}.ots-annotation-toolbar-container .OT_subpanel,.ots-annotation-toolbar-container .color-picker{position:absolute;right:65px;width:40px;background-color:#333;display:flex;flex-direction:column;align-items:center;transition:opacity .5s ease-out}.ots-annotation-toolbar-container .OT_subpanel.pen{top:0}.ots-annotation-toolbar-container .OT_subpanel.pen .line-width-option{width:40px;height:40px;cursor:pointer}.ots-annotation-toolbar-container .OT_subpanel.pen:after,.ots-annotation-toolbar-container .color-picker:after{width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333;right:-15px;content:"";position:absolute}.ots-annotation-toolbar-container .OT_subpanel.pen:after{top:15px}.ots-annotation-toolbar-container .color-picker{top:0}.ots-annotation-toolbar-container .color-picker:after{top:75px}.ots-annotation-toolbar-container .color-picker .color-choice{width:20px;height:20px;margin:10px;cursor:pointer;border-radius:100%}.ots-annotation-toolbar-container .color-picker .color-choice.active{border:2px solid #fff}.ots-annotation-toolbar-container .OT_subpanel.shapes{display:flex;flex-direction:column;top:75px;min-height:159.89px}.ots-annotation-toolbar-container .OT_subpanel.shapes:after{position:absolute;top:62.5px;right:-15px;content:"";width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333}.ots-annotation-toolbar-container .OT_subpanel.shapes input{width:22px;height:22px;margin:9px;border:none;background-color:#333;background-repeat:no-repeat;background-position:center center}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle-fill.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval-fill.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.star{background-image:url(https://assets.tokbox.com/solutions/images/annotation-star.png);background-size:22px 22px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.arrow{background-image:url(https://assets.tokbox.com/solutions/images/annotation-arrow.png);background-size:6.5px 23.5px}.publisherContainer{display:block;background-color:#000;position:absolute}.publisher-wrap{height:100%;width:100%}.subscriberContainer{position:absolute;top:20px;left:20px;width:200px;height:120px;background-color:#000;border:2px solid #fff;border-radius:6px}.subscriberContainer .OT_video-poster{width:100%;height:100%;opacity:.25;background-repeat:no-repeat;background-image:url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg);background-size:50%;background-position:center}.OT_video-element{height:100%;width:100%}.OT_edge-bar-item{display:none}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="ots-annotation-toolbar-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, subscribeToVideo: "true", subscribeToAudio: "false", fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); var subscriber=session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>',s=["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no",["width=",n].join(""),["height=",o].join(""),["left=",screen.width/2-n/2].join(""),["top=",screen.height/2-o/2].join("")].join(","),r=window.open("about:blank","",s);
r.document.write(i),window.onbeforeunload=function(){r.close()},r.toolbar=toolbar,r.OT=OT,r.session=a,r.$=e,r.triggerCloseEvent=function(){u("annotationWindowClosed")},r.onbeforeunload=function(){u("annotationWindowClosed")};var c=function(){r.createContainerElements?e(r.document).ready(function(){t.resolve(r)}):setTimeout(c,100)};return c(),t.promise()},y=function(){e(c.resizeSubject).off("resize",v),toolbar.remove(),c.externalWindow||e("#annotationToolbarContainer").remove()},T=function(n,o){var i=e.Deferred();return t.property("screensharing")(o)?I().then(function(t){w(n,o,t),toolbar.createPanel(t),u("startAnnotation",t),h(l.actionStart,l.variationSuccess),i.resolve(t)}):(w(n,o),u("startAnnotation"),h(l.actionStart,l.variationSuccess),i.resolve()),i.promise()},k=function(n,i,a){c.resizeSubject=t.property("externalWindow")(a)||window,c.externalWindow=t.property("externalWindow")(a)||null,c.absoluteParent=t.property("absoluteParent")(a)||null,c.canvasContainer=i,s=new OTSolution.Annotations({feed:n,container:i,externalWindow:c.externalWindow}),toolbar.addCanvas(s);var r=o.options.onScreenCapture?o.options.onScreenCapture:function(t){var e=window.open(t,"_blank");e.focus()};s.onScreenCapture(r);var l=c.externalWindow?c.externalWindow:window;c.canvas=e(t.first(l.document.getElementsByTagName("canvas"))),x(),v(),u("linkAnnotation")},O=function(){v()},M=function(t){c.externalWindow?c.externalWindow.addSubscriberVideo(t):console.log("OT Annotation: External window does not exist. Cannot add subscriber video.")},_=function(){y(),c.canvas=null,c.externalWindow&&(c.externalWindow.close(),c.externalWindow=null,c.resizeSubject=null),u("endAnnotation"),h(l.actionEnd,l.variationSuccess)},C=function(e){if(o=this,o.options=t.omit(e,"accPack","session"),i=t.property("accPack")(e),a=t.property("session")(e),!a)throw new Error("OpenTok Annotation Accelerator Pack requires an OpenTok session");p(),d(),h(l.actionInitialize,l.variationSuccess)};C.prototype={constructor:C,start:T,linkCanvas:k,resizeCanvas:O,addSubscriberToExternalWindow:M,end:_},"object"==typeof exports?module.exports=C:"function"==typeof define&&define.amd?define(function(){return C}):this.AnnotationAccPack=C}.call(this);
(function(){var t,e,n,o={clientVersion:"js-vsol-1.1.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionStartDrawing:"StartDrawing",actionEndDrawing:"EndDrawing",variationSuccess:"Success"},i=function(){var i=window.location.href,a={clientVersion:o.clientVersion,source:i,componentId:o.componentId,name:o.name};e=new t(a);var s={sessionId:n.id,connectionId:n.connection.connectionId,partnerId:n.apiKey};e.addSessionInfo(s)},a=function(t,n){var o={action:t,variation:n};e.logEvent(o)},s="https://assets.tokbox.com/solutions/images/";OTSolution=this.OTSolution||{},OTSolution.Annotations=function(n){function r(t,e,n){for(var o=e.split(" "),i=0,a=o.length;i<a;i++)t.addEventListener(o[i],n,!0)}function c(t,e){0===u.width&&(u.width=h.parent.getBoundingClientRect().width),0===u.height&&(u.height=h.parent.getBoundingClientRect().height);var n,i=e?t.canvas.width:h.parent.clientWidth,s=e?t.canvas.height:h.parent.clientHeight,r=e?t.canvas.offsetLeft:u.offsetLeft,c=e?t.canvas.offsetTop:u.offsetTop,l=u.width/i,d=u.height/s,p=t.offsetX||t.pageX-r||t.changedTouches&&t.changedTouches[0].pageX-r,g=t.offsetY||t.pageY-c||t.changedTouches&&t.changedTouches[0].pageY-c,f=p*l,b=g*d,v=e?t.selectedItem:h.selectedItem;if(v)if("OT_pen"===v.id)switch(t.type){case"mousedown":case"touchstart":T.dragging=!0,T.lastX=f,T.lastY=b,h.isStartPoint=!0,!e&&a(o.actionStartDrawing,o.variationSuccess);break;case"mousemove":case"touchmove":T.dragging&&(n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.lastX,fromY:T.lastY,toX:f,toY:b,color:e?t.userColor:h.userColor,lineWidth:h.lineWidth,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,startPoint:h.isStartPoint,endPoint:!1,selectedItem:v,platform:"web",guid:t.guid},S(n,!0),T.lastX=f,T.lastY=b,!e&&D(n),h.isStartPoint=!1);break;case"mouseup":case"touchend":T.dragging=!1,n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.lastX,fromY:T.lastY,toX:f,toY:b,color:e?t.userColor:h.userColor,lineWidth:h.lineWidth,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,startPoint:h.isStartPoint,endPoint:!0,selectedItem:v,platform:"web",guid:t.guid},S(n,!0),T.lastX=f,T.lastY=b,!e&&D(n),h.isStartPoint=!1,!e&&a(o.actionEndDrawing,o.variationSuccess);break;case"mouseout":T.dragging=!1}else if("OT_text"===v.id)n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:f,fromY:b+t.inputHeight,color:t.userColor,font:t.font,text:t.text,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,selectedItem:v,platform:"web",guid:t.guid},S(n),!e&&D(n);else{var x=2;if(v&&v.points)switch(T.mX=f,T.mY=b,t.type){case"mousedown":case"touchstart":T.isDrawing=!0,T.dragging=!0,T.startX=f,T.startY=b;break;case"mousemove":case"touchmove":T.dragging&&(n={color:e?t.userColor:h.userColor,lineWidth:e?t.lineWidth:x,selectedItem:v},S(n,!0));break;case"mouseup":case"touchend":T.isDrawing=!1;var I=v.points;if(2===I.length)n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.startX,fromY:T.startY,toX:T.mX,toY:T.mY,color:e?t.userColor:h.userColor,lineWidth:e?t.lineWidth:x,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,smoothed:!1,startPoint:!0,selectedItem:v,platform:"web",guid:t.guid},w.push(n),!e&&D(n);else{for(var y=L(I),k=0;k<I.length;k++){var O=!1,M=!1,_=T.startX+y.x*I[k][0],C=T.startY+y.y*I[k][1];0===k?(T.lastX=_,T.lastY=C,O=!0):k===I.length-1&&(M=!0),n={id:h.videoFeed.stream.connection.connectionId,fromId:h.session.connection.connectionId,fromX:T.lastX,fromY:T.lastY,toX:_,toY:C,color:e?t.userColor:h.userColor,lineWidth:e?t.lineWidth:x,videoWidth:h.videoFeed.videoElement().clientWidth,videoHeight:h.videoFeed.videoElement().clientHeight,canvasWidth:u.width,canvasHeight:u.height,mirrored:m,smoothed:v.enableSmoothing,startPoint:O,endPoint:M,selectedItem:v,platform:"web",guid:t.guid},w.push(n),!e&&D(n),T.lastX=_,T.lastY=C}S(null)}T.dragging=!1}}}function l(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0,n="x"==t?e:3&e|8;return n.toString(16)})}n=n||{},this.widgetVersion="js-1.0.0-beta",this.parent=n.container,this.videoFeed=n.feed,this.imageAssets=n.imageAssets||s,t=t||n.OTKAnalytics,e||i();var d=n.externalWindow?n.externalWindow.document:window.document,h=this;if(this.parent){var u=document.createElement("canvas");u.setAttribute("id","opentok_canvas"),u.style.position="absolute",this.parent.appendChild(u),u.setAttribute("width",this.parent.clientWidth+"px"),u.style.width=window.getComputedStyle(this.parent).width,u.setAttribute("height",this.parent.clientHeight+"px"),u.style.height=window.getComputedStyle(this.parent).height}var p,g,m,f,b,h=this,v=[],x=[],w=[],I=[],y=[],T={dragging:!1};g=(" "+h.videoFeed.element.className+" ").indexOf(" OT_publisher ")>-1,m=!!g&&(" "+h.videoFeed.element.className+" ").indexOf(" OT_mirrored ")>-1,f=(" "+h.videoFeed.element.className+" ").indexOf(" OT_fit-mode-cover ")>-1,this.canvas=function(){return u},this.link=function(t){this.session=t},this.changeColor=function(t){h.userColor=t,h.lineWidth||(h.lineWidth=2)},this.changeLineWidth=function(t){this.lineWidth=t},this.selectItem=function(t){h.overlay&&(h.parent.removeChild(h.overlay),h.overlay=null);var e=function(){var e=d.getElementById(h.selectedItem.id),n=d.getElementById("OT_shapes"),o=n.classList.contains("selected");o?n.classList.remove("selected"):e.classList.remove("selected");var i=d.getElementById(t.id);i.parentElement.classList.contains("shapes")?n.classList.add("selected"):i.classList.add("selected")};t&&"OT_capture"===t.id?h.captureScreenshot():t&&t.id.indexOf("OT_line_width")!==-1?t.size&&h.changeLineWidth(t.size):"OT_undo"!==t.id&&"OT_clear"!==t.id&&(e(),h.selectedItem=t)},this.colors=function(t){this.colors=t,this.changeColor(t[0])},this.clear=function(){j(!1,h.session.connection.connectionId),h.session&&h.session.signal({type:"otAnnotation_clear"})},this.undo=function(){F(!1,h.session.connection.connectionId)},this.captureScreenshot=function(){var t=document.createElement("canvas");t.width=u.width,t.height=u.height;var e=h.videoFeed.videoWidth(),n=h.videoFeed.videoHeight(),o=1,i=0,a=0;f?e<n?(o=u.width/e,e=u.width,n*=o):(o=u.height/n,n=u.height,e*=o):e>n?(o=u.width/e,e=u.width,n*=o):(o=u.height/n,n=u.height,e*=o),i=(e-u.width)/2,a=(n-u.height)/2;var s=new Image;s.onload=function(){var o=t.getContext("2d");m&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(s,i,a,e,n),m&&(o.translate(e,0),o.scale(-1,1)),o.drawImage(u,0,0),v.forEach(function(e){e.call(h,t.toDataURL())}),t=null},s.src="data:image/png;base64,"+h.videoFeed.getImgData()},this.onScreenCapture=function(t){v.push(t)},this.onResize=function(){w=[],z(I,!0),y.forEach(function(t){c(t,!0)})},r(u,"mousedown mousemove mouseup mouseout touchstart touchmove touchend",function(t){var e=h.selectedItem&&"OT_text"===h.selectedItem.id,n="mousemove"===t.type&&!T.dragging;e||n||(t.preventDefault(),t.selectedItem=h.selectedItem,t.selectedItem&&(t.canvas={width:u.width,height:u.height,offsetLeft:u.offsetLeft,offsetTop:u.offsetTop},t.userColor=h.userColor,t.lineWidth=h.lineWidth,t.guid=l(),y.push(t)),c(t))});var k,O="textAnnotation",M=!1,_=function(t){t.preventDefault(),h.selectedItem&&"OT_text"===h.selectedItem.id&&!M&&(M=!0,t.selectedItem=h.selectedItem,W(t))},C=function(t){13===t.which&&A(),27===t.which&&(d.getElementById(O).remove(),k=null),M=!1},E=function(){d.addEventListener("keydown",C)},P=function(){d.removeEventListener("keydown",C)},A=function(){var t=d.getElementById(O);t.clientHeight;return t.value?(t.remove(),P(),k.text=t.value,k.font="16px Arial",k.userColor=h.userColor,k.canvas={width:u.width,height:u.height,offsetLeft:u.offsetLeft,offsetTop:u.offsetTop},y.push(k),void c(k)):void(k=null)},W=function(t){var e=d.createElement("input");e.setAttribute("type","text"),e.style.position="absolute",e.style.top=t.clientY+"px",e.style.left=t.clientX+"px",e.style.background="rgba(255,255,255, .5)",e.style.width="100px",e.style.maxWidth="200px",e.style.border="1px dashed red",e.style.fontSize="16px",e.style.color=h.userColor,e.style.fontFamily="Arial",e.style.zIndex="1001",e.setAttribute("data-canvas-origin",JSON.stringify({x:t.offsetX,y:t.offsetY})),e.id=O,d.body.appendChild(e),e.focus(),k=t,k.inputHeight=e.clientHeight,E()};r(u,"click",_);var S=function(t,e){p||(p=u.getContext("2d"),p.lineCap="round",p.lineJoin="round",p.fillStyle="solid"),p.clearRect(0,0,u.width,u.height),w.forEach(function(t){p.strokeStyle=t.color,p.lineWidth=t.lineWidth,t.smoothed=!!t.smoothed,t.startPoint=!!t.startPoint;var e=!1,n=t.hasOwnProperty("text");n?(p.font=t.font,p.fillStyle=t.color,p.fillText(t.text,t.fromX,t.fromY)):t.smoothed?(t.startPoint?h.isStartPoint=!0:h.isStartPoint&&(e=!0,h.isStartPoint=!1),t.startPoint?(p.closePath(),p.beginPath()):e?p.moveTo((t.fromX+t.toX)/2,(t.fromY+t.toY)/2):(p.quadraticCurveTo(t.fromX,t.fromY,(t.fromX+t.toX)/2,(t.fromY+t.toY)/2),p.stroke())):(p.beginPath(),p.moveTo(t.fromX,t.fromY),p.lineTo(t.toX,t.toY),p.stroke(),p.closePath())});var n=e?t.selectedItem:h.selectedItem;!n||"Pen"!==n.title&&"Text"!==n.title?T.isDrawing&&(t&&(p.strokeStyle=t.color,p.lineWidth=t.lineWidth),n&&n.points&&X(p,h.selectedItem.points)):t&&("Pen"===n.title&&(p.strokeStyle=t.color,p.lineWidth=t.lineWidth,p.beginPath(),p.moveTo(t.fromX,t.fromY),p.lineTo(t.toX,t.toY),p.stroke(),p.closePath()),"Text"===n.title&&(p.font=t.font,p.fillStyle=t.color,p.fillText(t.text,t.fromX,t.fromY)),w.push(t))},X=function(t,e){var n=L(e);if(t.beginPath(),2===e.length)t.moveTo(T.startX,T.startY),t.lineTo(T.mX,T.mY);else for(var o=0;o<e.length;o++){var i=T.startX+n.x*e[o][0],a=T.startY+n.y*e[o][1];h.selectedItem.enableSmoothing?0===o||(1===o?(t.moveTo((i+T.lastX)/2,(a+T.lastY)/2),T.lastX=(i+T.lastX)/2,T.lastX=(a+T.lastY)/2):(t.quadraticCurveTo(T.lastX,T.lastY,(i+T.lastX)/2,(a+T.lastY)/2),T.lastX=(i+T.lastX)/2,T.lastY=(a+T.lastY)/2)):0===o?t.moveTo(i,a):t.lineTo(i,a),T.lastX=i,T.lastY=a}t.stroke(),t.closePath()},L=function(t){for(var e=Number.MAX_VALUE,n=Number.MAX_VALUE,o=0,i=0,a=0;a<t.length;a++)t[a][0]<e?e=t[a][0]:t[a][0]>o&&(o=t[a][0]),t[a][1]<n?n=t[a][1]:t[a][1]>i&&(i=t[a][1]);var s=Math.abs(o-e),r=Math.abs(i-n),c=(T.mX-T.startX)/s,l=(T.mY-T.startY)/r;return{x:c,y:l}},Y=function(t,e,n){var o={width:t.canvasWidth,height:t.canvasHeight},i={width:t.videoWidth,height:t.videoHeight},a={width:h.videoFeed.videoElement().clientWidth,height:h.videoFeed.videoElement().clientHeight},s=1,r=u.width/u.height;a.width/a.height,o.width/o.height,i.width/i.height;s=r<0?u.width/o.width:u.height/o.height;var c=u.width/2,l=u.height/2,d=o.width/2,p=o.height/2;t.fromX=c-s*(d-t.fromX),t.fromY=l-s*(p-t.fromY),t.toX=c-s*(d-t.toX),t.toY=l-s*(p-t.toY),t.mirrored=!!t.mirrored,t.mirrored&&(t.fromX=u.width-t.fromX,t.toX=u.width-t.toX),m&&(t.fromX=u.width-t.fromX,t.toX=u.width-t.toX);var g=JSON.parse(JSON.stringify(t));g.canvasWidth=u.width,g.canvasHeight=u.height,g.videoWidth=a.width,g.videoHeight=a.height,e?I[n]=g:I.push(g),w.push(t),S(null)},z=function(t,e){t.forEach(function(t,n){h.videoFeed.stream&&t.id===h.videoFeed.stream.connection.connectionId&&Y(t,e,n)})},j=function(t,e){w=w.filter(function(t){return t.fromId!==e}),t?I=[]:(h.session&&h.session.signal({type:"otAnnotation_clear"}),y=[]),S()},F=function(t,e,n){for(var o,i,a=!1,s=[],r=w.length-1;r>=0&&(o=w[r],o.fromId!==e||(a=a||o.endPoint,i=w.splice(r,1)[0],s.push(i.guid),a&&(!a||i.startPoint!==!0)));r--);t?I=I.filter(function(t){return!n.includes(t.guid)}):(y=y.filter(function(t){return!s.includes(t.guid)}),h.session.signal({type:"otAnnotation_undo",data:JSON.stringify(s)})),S()};h.videoFeed.session&&h.videoFeed.session.on({"signal:otAnnotation_pen":function(t){t.from.connectionId!==h.session.connection.connectionId&&z(JSON.parse(t.data))},"signal:otAnnotation_text":function(t){t.from.connectionId!==h.session.connection.connectionId&&z(JSON.parse(t.data))},"signal:otAnnotation_history":function(t){b&&b!==t.from.connectionId||(b=t.from.connectionId,z(JSON.parse(t.data)))},"signal:otAnnotation_clear":function(t){t.from.connectionId!==h.session.connection.connectionId&&j(!0,t.from.connectionId)},"signal:otAnnotation_undo":function(t){t.from.connectionId!==h.session.connection.connectionId&&F(!0,t.from.connectionId,JSON.parse(t.data))},connectionCreated:function(t){w.length>0&&t.connection.connectionId!==h.session.connection.connectionId&&B("otWhiteboard_history",w,t.connection)}});var H,B=function(t,e){for(var n,o=function(t){t&&TB.error(t)},i="otAnnotation_pen",a=function(t){if(t&&t[0]&&t[0].selectedItem&&t[0].selectedItem.id){var e=t[0].selectedItem.id;i="OT_text"===e?"otAnnotation_text":"otAnnotation_pen"}},s=0,r=7;s<t.length;){n=t.slice(s,s+r),a(n),s+=r;var c={type:i,data:JSON.stringify(n)};e&&(c.to=e),h.session.signal(c,o)}},D=function(t){h.session&&(x.push(t),H||(H=setTimeout(function(){B(x),x=[],H=null},100)))}},OTSolution.Annotations.Toolbar=function(o){var a=this,r=this;if(o||(o={}),!o.session)throw new Error("OpenTok Annotation Widget requires an OpenTok session");if(n=o.session,!t&&!o.OTKAnalytics)throw new Error("OpenTok Annotation Widget requires an OpenTok Solution");t=t||o.OTKAnalytics,e||i(),this.session=o.session,this.parent=o.container,this.externalWindow=o.externalWindow,this.backgroundColor=o.backgroundColor||"rgba(102, 102, 102, 0.90)",this.subpanelBackgroundColor=o.subpanelBackgroundColor||"#323232";var c=o.imageAssets||s,l=[{id:"OT_pen",title:"Pen",icon:[c,"annotation-pencil.png"].join(""),selectedIcon:[c,"annotation-pencil.png"].join(""),items:{}},{id:"OT_colors",title:"Colors",icon:"",items:{}},{id:"OT_shapes",title:"Shapes",icon:[c,"annotation-shapes.png"].join(""),items:[{id:"OT_rect",title:"Rectangle",icon:[c,"annotation-rectangle.png"].join(""),points:[[0,0],[1,0],[1,1],[0,1],[0,0]]},{id:"OT_rect_fill",title:"Rectangle-Fill",icon:[c,"annotation-rectangle.png"].join(""),points:[[0,0],[1,0],[1,1],[0,1],[0,0]]},{id:"OT_oval",title:"Oval",icon:[c,"annotation-oval.png"].join(""),enableSmoothing:!0,points:[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]},{id:"OT_oval_fill",title:"Oval-Fill",icon:[c,"annotation-oval-fill.png"].join(""),enableSmoothing:!0,points:[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]},{id:"OT_star",title:"Star",icon:[c,"annotation-star.png"].join(""),points:[[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))],[.5+.25*Math.cos(126*(Math.PI/180)),.5+.25*Math.sin(126*(Math.PI/180))],[.5+.5*Math.cos(162*(Math.PI/180)),.5+.5*Math.sin(162*(Math.PI/180))],[.5+.25*Math.cos(198*(Math.PI/180)),.5+.25*Math.sin(198*(Math.PI/180))],[.5+.5*Math.cos(234*(Math.PI/180)),.5+.5*Math.sin(234*(Math.PI/180))],[.5+.25*Math.cos(270*(Math.PI/180)),.5+.25*Math.sin(270*(Math.PI/180))],[.5+.5*Math.cos(306*(Math.PI/180)),.5+.5*Math.sin(306*(Math.PI/180))],[.5+.25*Math.cos(342*(Math.PI/180)),.5+.25*Math.sin(342*(Math.PI/180))],[.5+.5*Math.cos(18*(Math.PI/180)),.5+.5*Math.sin(18*(Math.PI/180))],[.5+.25*Math.cos(54*(Math.PI/180)),.5+.25*Math.sin(54*(Math.PI/180))],[.5+.5*Math.cos(90*(Math.PI/180)),.5+.5*Math.sin(90*(Math.PI/180))]]},{id:"OT_arrow",title:"Arrow",icon:[c,"annotation-arrow.png"].join(""),points:[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]},{id:"OT_line",title:"Line",icon:[c,"annotation-line.png"].join(""),selectedIcon:[c,"annotation-line.png"].join(""),points:[[0,0],[0,1]]}]},{id:"OT_text",title:"Text",icon:[c,"annotation-text.png"].join(""),selectedIcon:[c,"annotation-text.png"].join("")},{id:"OT_capture",title:"Capture",icon:[c,"annotation-camera.png"].join(""),selectedIcon:[c,"annotation-camera.png"].join("")},{id:"OT_undo",title:"Undo",icon:[c,"annotation-undo.png"].join("")},{id:"OT_clear",title:"Clear",icon:[c,"annotation-clear.png"].join("")}],d=function(){var t=["pen","colors","shapes","text","capture","undo","clear"],e=["rectangle","rectangle-fill","oval","oval-fill","star","arrow","line"],n=function(n,i){var a=t.indexOf(i);if(a!==-1){var s=l[a];if("Shapes"===s.title&&o.shapes){var r=o.shapes.reduce(function(t,n){var o=e.indexOf(n);return o!==-1?t.concat(s.items[o]):t},[]);s.items=r}n.push(s)}return n};if(o.items&&o.items.length){var i="*"===o.items[0]?t:o.items;return i.reduce(n,[])}return l};this.items=d(),this.colors=o.colors||["#1abc9c","#2ecc71","#3498db","#9b59b6","#34495e","#16a085","#27ae60","#2980b9","#8e44ad","#2c3e50","#f1c40f","#e67e22","#e74c3c","#ecf0f1","#95a5a6","#f39c12","#d35400","#c0392b","#bdc3c7","#7f8c8d"],this.cbs=[];var h,u=[],p=function(t,e,n){var o=this,i=r.externalWindow?r.externalWindow.document:document;this.getElm=function(t,e){return"string"==typeof t?e?i.querySelectorAll(t):i.querySelector(t):t},this.render=function(){var t=this,e="";t.colors.forEach(function(n){e+=t.options.template.replace(/\{color\}/g,n)}),t.elm.innerHTML=e},this.close=function(){this.elm.classList.add("ots-hidden")},this.open=function(){this.elm.classList.remove("ots-hidden")},this.colorChosen=function(t){this.cbs.push(t)},this.set=function(t,e){var n=this;n.color=t,e!==!1&&n.cbs.forEach(function(e){e.call(n,t)})},n=n||{},n.openEvent=n.openEvent||"click",n.style=Object(n.style),n.template=n.template||'<div class="color-choice" data-col="{color}" style="background-color: {color}"></div>',o.elm=o.getElm(t),o.cbs=[],o.colors=e,o.options=n,o.render(),o.elm.addEventListener("click",function(t){var e=t.target.getAttribute("data-col");if(e){var n=Array.from(o.getElm(".color-choice",!0));n.forEach(function(t){t.classList.remove("active")}),t.target.classList.add("active"),o.set(e),o.close()}}),n.autoclose!==!1&&o.close()};this.createPanel=function(t){if(r.parent){var e=t?t.document:document;h=e.createElement("div"),h.setAttribute("id","OT_toolbar"),h.setAttribute("class","OT_panel"),h.style.width="100%",h.style.height="100%",this.parent.appendChild(h),this.parent.style.position="relative",this.parent.zIndex=1e3;for(var n=[],o=e.createElement("div"),i=0,s=this.items.length;i<s;i++){var c=this.items[i],l=e.createElement("input");if(l.setAttribute("type","button"),l.setAttribute("id",c.id),l.classList.add("annotation-btn"),l.classList.add(c.title.split(" ").join("-").toLowerCase()),"OT_colors"===c.id){var d=e.createElement("div");d.setAttribute("class","color-picker"),this.parent.appendChild(d);var m=new p(".color-picker",this.colors,{externalWindow:r.externalWindow});m.colorChosen(function(t){var n=e.getElementById("OT_colors");n.style.backgroundColor=t,u.forEach(function(e){e.changeColor(t)})});var f=e.querySelectorAll(".color-choice");f[0].classList.add("active"),l.setAttribute("class","OT_color annotation-btn colors"),l.style.borderRadius="50%",l.style.backgroundColor=this.colors[0]}"Pen"!==c.title||Array.isArray(c.items)||(c.items=[{id:"OT_line_width_2",title:"Line Width 2",size:2},{id:"OT_line_width_4",title:"Line Width 4",size:4},{id:"OT_line_width_6",title:"Line Width 6",size:6},{id:"OT_line_width_8",title:"Line Width 8",size:8},{id:"OT_line_width_10",title:"Line Width 10",size:10},{id:"OT_line_width_12",title:"Line Width 12",size:12},{id:"OT_line_width_14",title:"Line Width 14",size:14}]),c.items&&l.setAttribute("data-type","group"),l.setAttribute("data-col",c.title),n.push(l.outerHTML)}h.innerHTML=n.join("");var b=function(t){var e=t?"add":"remove";document.getElementById("OT_toolbar").classList[e]("colors-hover")},v=e.getElementById("OT_colors");v.addEventListener("mouseenter",function(){b(!0)}),v.addEventListener("mouseleave",function(){b(!1)}),h.onclick=function(t){var n="group"===t.target.getAttribute("data-type"),i=t.target.getAttribute("data-col"),s=t.target.getAttribute("id");n?a.items.forEach(function(t){if(t.title===i){if(a.selectedGroup=t,t.items&&(o.setAttribute("class",["OT_subpanel","ots-hidden",t.title.toLowerCase()].join(" ")),a.parent.appendChild(o),Array.isArray(t.items))){var n=[];"OT_pen"===t.id?t.items.forEach(function(t){var o=e.createElement("div");o.setAttribute("data-col",t.title),o.setAttribute("class",["line-width-option",t.size].join(" ")),o.setAttribute("id",t.id);var i=e.createElement("div");i.setAttribute("class","line-width-icon"),i.style.backgroundColor="#FFFFFF",i.style.width="80%",i.style.height=t.size+"px",i.style.position="relative",i.style.left="50%",i.style.top="50%",i.style.transform="translateX(-50%) translateY(-50%)",i.style.pointerEvents="none",o.appendChild(i),n.push(o.outerHTML)}):t.items.forEach(function(t){var o=e.createElement("input");o.setAttribute("type","button"),o.setAttribute("data-col",t.title),o.setAttribute("id",t.id),o.setAttribute("class",["annotation-btn",t.title.toLowerCase()].join(" ")),n.push(o.outerHTML)}),o.innerHTML=n.join("")}"OT_shapes"===s||"OT_pen"===s?(o&&o.classList.remove("ots-hidden"),m.close()):"OT_colors"===s&&(o&&o.classList.add("ots-hidden"),m.open())}}):(a.items.forEach(function(t){if(("Clear"!==t.title||"Undo"!==t.title)&&t.title===i)return a.selectedItem=t,g(t),u.forEach(function(t){t.selectItem(a.selectedItem)}),!1}),o.classList.add("ots-hidden")),a.cbs.forEach(function(t){t.call(a,s)})},o.onclick=function(t){var e="group"===t.target.getAttribute("data-type"),n=(t.target.getAttribute("data-col"),t.target.getAttribute("id"));n&&"linewidth"===n.replace(/[^a-z]/g,"")&&u.forEach(function(t){t.selectItem(a.selectedGroup)}),o.classList.add("ots-hidden"),e||a.selectedGroup.items.forEach(function(t){if("OT_clear"!==t.id&&t.id===n){if(a.selectedItem)var e=document.getElementById(a.selectedItem.id);if(t.selectedIcon){var o=document.getElementById(t.id);e&&(o.style.background='url("'+t.selectedIcon+'") no-repeat',o.style.backgroundSize=a.iconWidth+" "+a.iconHeight,o.style.backgroundPosition="center")}return a.selectedItem=t,g(t),u.forEach(function(t){t.selectItem(a.selectedItem)}),!1}}),a.cbs.forEach(function(t){t.call(a,n)})};var x=e.getElementById("OT_clear").onclick=function(){u.forEach(function(t){t.clear()})};e.getElementById("OT_undo").onclick=function(){u.forEach(function(t){t.undo()})},window.addEventListener("OT_clear",function(){x(),a.selectedItem=null,u.forEach(function(t){t.selectItem(a.selectedItem)})}),window.addEventListener("OT_pen",function(t){var e=a.items.find(function(t){return"OT_pen"===t.id});a.selectedItem=e,g(e);var n=t.detail.color;u.forEach(function(t){t.selectItem(a.selectedItem),n&&t.changeColor(n)})})}},!this.externalWindow&&this.createPanel();var g=function(t){t.points||("OT_line"===t.id?a.selectedItem.points=[[0,0],[0,1]]:"OT_arrow"===t.id?a.selectedItem.points=[[0,1],[3,1],[3,0],[5,2],[3,4],[3,3],[0,3],[0,1]]:"OT_rect"===t.id?a.selectedItem.points=[[0,0],[1,0],[1,1],[0,1],[0,0]]:"OT_oval"===t.id&&(a.selectedItem.enableSmoothing=!0,a.selectedItem.points=[[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)],[.5,0],[.5+.5*Math.cos(7*Math.PI/4),.5+.5*Math.sin(7*Math.PI/4)],[1,.5],[.5+.5*Math.cos(Math.PI/4),.5+.5*Math.sin(Math.PI/4)],[.5,1],[.5+.5*Math.cos(3*Math.PI/4),.5+.5*Math.sin(3*Math.PI/4)],[0,.5],[.5+.5*Math.cos(5*Math.PI/4),.5+.5*Math.sin(5*Math.PI/4)]]))};this.itemClicked=function(t){this.cbs.push(t)},this.addCanvas=function(t,e){var n=this,o=e?e.document:document;t.link(n.session),t.colors(n.colors),u.push(t),u.forEach(function(t){t.selectedItem=t.selectedItem||n.items[0],o.getElementById(t.selectedItem.id).classList.add("selected")})},this.removeCanvas=function(t){u.forEach(function(e){var n=e.canvas();e.videoFeed.stream.connection.connectionId===t&&n.parentNode&&n.parentNode.removeChild(n)}),u=u.filter(function(e){return e.videoFeed.stream.connection.connectionId!==t})},this.remove=function(){try{h.parentNode.removeChild(h)}catch(t){console.log(t)}u.forEach(function(t){var e=t.canvas();e.parentNode&&e.parentNode.removeChild(e)}),u=[]}}}).call(this),function(){var t,e,n;"object"==typeof module&&"object"==typeof module.exports?(t=require("underscore"),e=require("jquery"),n=require("opentok-solutions-logging")):(t=this._,e=this.$,n=this.OTKAnalytics);var o,i,a,s,r,c={},l={clientVersion:"js-vsol-1.1.0",componentId:"annotationsAccPack",name:"guidAnnotationsKit",actionInitialize:"Init",actionStart:"Start",actionEnd:"End",actionFreeHand:"FreeHand",actionPickerColor:"PickerColor",actionText:"Text",actionScreenCapture:"ScreenCapture",actionErase:"Erase",actionUseToolbar:"UseToolbar",variationAttempt:"Attempt",variationError:"Failure",variationSuccess:"Success"},d=function(){var t=window.location.href,e={clientVersion:l.clientVersion,source:t,componentId:l.componentId,name:l.name};r=new n(e);var o={sessionId:a.id,connectionId:a.connection.connectionId,partnerId:a.apiKey};r.addSessionInfo(o)},h=function(t,e){var n={action:t,variation:e};r.logEvent(n)},u=function(t,e){i&&i.triggerEvent(t,e)},p=function(){if(i){var t=["startAnnotation","linkAnnotation","resizeCanvas","annotationWindowClosed","endAnnotation"];i.registerEvents(t)}},g=function(){var t=['<div id="annotationToolbarContainer" class="ots-annotation-toolbar-container">','<div id="toolbar"></div>',"</div>"].join("\n");e("body").append(t),h(l.actionUseToolbar,l.variationSuccess)},m=["#1abc9c","#2ecc71","#3498db","#9b59b6","#8e44ad","#f1c40f","#e67e22","#e74c3c","#ded5d5"],f=10/6,b=t.throttle(function(){s.onResize()},1e3),v=function(){var t,n;if(c.externalWindow){var o={width:c.externalWindow.innerWidth,height:c.externalWindow.innerHeight},i=o.width/f;i<=o.height?(t=o.width,n=i):(n=o.height,t=n*f)}else{var a=c.absoluteParent||c.canvasContainer;t=a.clientWidth,n=t/f,a.clientHeight<t/f&&(n=a.clientHeight,t=n*f)}e(c.canvasContainer).css({width:t,height:n}),e(c.canvasContainer).find("canvas").css({width:t,height:n}),e(c.canvasContainer).find("canvas").attr({width:t,height:n}),b(),u("resizeCanvas")},x=function(){e(c.resizeSubject).on("resize",t.throttle(function(){v()},500))},w=function(e,o,i){g();var a=t.property("toolbarId")(o)||"toolbar",s=t.property("toolbarItems")(o)||[],r=t.property("toolbarShapes")(o)||[],c=t.property("colors")(o)||m,d=t.property("imageAssets")(o)||null,u=t.property("backgroundColor")(o)||null,p=function(){var t=i?i:window;return t.document.getElementById(a)};toolbar=new OTSolution.Annotations.Toolbar({session:e,container:p(),colors:c,items:s.length?s:["*"],shapes:r.length?r:["rectangle","oval","star","arrow","line"],externalWindow:i||null,imageAssets:d,backgroundColor:u,OTKAnalytics:n}),toolbar.itemClicked(function(t){var e={OT_pen:l.actionFreeHand,OT_colors:l.actionPickerColor,OT_text:l.actionText,OT_clear:l.actionErase},n=e[t];n&&h(n,l.variationSuccess)})},I=function(){var t=e.Deferred(),n=.8*screen.width|0,o=n/f,i='<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><link rel="stylesheet" href="https://assets.tokbox.com/solutions/css/style.css"><style type="text/css" media="screen"> body{margin:0;background-color:rgba(0,153,203,.7);box-sizing:border-box;height:100vh}canvas{top:0;z-index:1000}.hidden{display:none}.ots-hidden{display:none !important}.main-wrap{width:100%;height:100%;-ms-box-orient:horizontal;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-moz-flex;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center}.inner-wrap{position:relative;border-radius:8px;overflow:hidden}.ots-annotation-toolbar-container{position:fixed;top:125px;right:0;width:60px;z-index:1000;background-color:#666}.ots-annotation-toolbar-container .OT_panel{display:flex;flex-direction:column;align-items:center}.ots-annotation-toolbar-container .annotation-btn{height:60px;width:60px;background-position:center center;background-repeat:no-repeat!important;background-color:#666;cursor:pointer;border:none}.ots-annotation-toolbar-container .annotation-btn.pen{background-image:url(https://assets.tokbox.com/solutions/images/annotation-pencil.png);background-size:27px 30px}.ots-annotation-toolbar-container .annotation-btn.colors{width:23px;height:24px;border:3px solid #fff;margin:18px 18.5px}.ots-annotation-toolbar-container .annotation-btn.line{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.line-width{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line_width.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.shapes{background-image:url(https://assets.tokbox.com/solutions/images/annotation-shapes.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.text{background-image:url(https://assets.tokbox.com/solutions/images/annotation-text.png);background-size:21px 25px}.ots-annotation-toolbar-container .annotation-btn.capture{background-image:url(https://assets.tokbox.com/solutions/images/annotation-camera.png);background-size:34px 31px}.ots-annotation-toolbar-container .annotation-btn.clear{background-image:url(https://assets.tokbox.com/solutions/images/annotation-trash.png);background-size:31px 31px}.ots-annotation-toolbar-container .annotation-btn.undo{background-image:url(https://assets.tokbox.com/solutions/images/annotation-undo.png);background-size:34px 31px}.ots-annotation-toolbar-container .OT_subpanel,.ots-annotation-toolbar-container .color-picker{position:absolute;right:65px;width:40px;background-color:#333;display:flex;flex-direction:column;align-items:center;transition:opacity .5s ease-out}.ots-annotation-toolbar-container .OT_subpanel.pen{top:0}.ots-annotation-toolbar-container .OT_subpanel.pen .line-width-option{width:40px;height:40px;cursor:pointer}.ots-annotation-toolbar-container .OT_subpanel.pen:after,.ots-annotation-toolbar-container .color-picker:after{width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333;right:-15px;content:"";position:absolute}.ots-annotation-toolbar-container .OT_subpanel.pen:after{top:15px}.ots-annotation-toolbar-container .color-picker{top:0}.ots-annotation-toolbar-container .color-picker:after{top:75px}.ots-annotation-toolbar-container .color-picker .color-choice{width:20px;height:20px;margin:10px;cursor:pointer;border-radius:100%}.ots-annotation-toolbar-container .color-picker .color-choice.active{border:2px solid #fff}.ots-annotation-toolbar-container .OT_subpanel.shapes{display:flex;flex-direction:column;top:75px;min-height:159.89px}.ots-annotation-toolbar-container .OT_subpanel.shapes:after{position:absolute;top:62.5px;right:-15px;content:"";width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333}.ots-annotation-toolbar-container .OT_subpanel.shapes input{width:22px;height:22px;margin:9px;border:none;background-color:#333;background-repeat:no-repeat;background-position:center center}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle-fill.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval-fill.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.star{background-image:url(https://assets.tokbox.com/solutions/images/annotation-star.png);background-size:22px 22px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.arrow{background-image:url(https://assets.tokbox.com/solutions/images/annotation-arrow.png);background-size:6.5px 23.5px}.publisherContainer{display:block;background-color:#000;position:absolute}.publisher-wrap{height:100%;width:100%}.subscriberContainer{position:absolute;top:20px;left:20px;width:200px;height:120px;background-color:#000;border:2px solid #fff;border-radius:6px}.subscriberContainer .OT_video-poster{width:100%;height:100%;opacity:.25;background-repeat:no-repeat;background-image:url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg);background-size:50%;background-position:center}.OT_video-element{height:100%;width:100%}.OT_edge-bar-item{display:none}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="ots-annotation-toolbar-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, subscribeToVideo: "true", subscribeToAudio: "false", fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); var subscriber=session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>',s=["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no",["width=",n].join(""),["height=",o].join(""),["left=",screen.width/2-n/2].join(""),["top=",screen.height/2-o/2].join("")].join(","),r=window.open("about:blank","",s);
r.document.write(i),window.onbeforeunload=function(){r.close()},r.toolbar=toolbar,r.OT=OT,r.session=a,r.$=e,r.triggerCloseEvent=function(){u("annotationWindowClosed")},r.onbeforeunload=function(){u("annotationWindowClosed")};var c=function(){r.createContainerElements?e(r.document).ready(function(){t.resolve(r)}):setTimeout(c,100)};return c(),t.promise()},y=function(){e(c.resizeSubject).off("resize",v),toolbar.remove(),c.externalWindow||e("#annotationToolbarContainer").remove()},T=function(n,o){var i=e.Deferred();return t.property("screensharing")(o)?I().then(function(t){w(n,o,t),toolbar.createPanel(t),u("startAnnotation",t),h(l.actionStart,l.variationSuccess),i.resolve(t)}):(w(n,o),u("startAnnotation"),h(l.actionStart,l.variationSuccess),i.resolve()),i.promise()},k=function(n,i,a){c.resizeSubject=t.property("externalWindow")(a)||window,c.externalWindow=t.property("externalWindow")(a)||null,c.absoluteParent=t.property("absoluteParent")(a)||null,c.canvasContainer=i,s=new OTSolution.Annotations({feed:n,container:i,externalWindow:c.externalWindow}),toolbar.addCanvas(s,c.externalWindow);var r=o.options.onScreenCapture?o.options.onScreenCapture:function(t){var e=window.open(t,"_blank");e.focus()};s.onScreenCapture(r);var l=c.externalWindow?c.externalWindow:window;c.canvas=e(t.first(l.document.getElementsByTagName("canvas"))),x(),v(),u("linkAnnotation")},O=function(){v()},M=function(t){c.externalWindow?c.externalWindow.addSubscriberVideo(t):console.log("OT Annotation: External window does not exist. Cannot add subscriber video.")},_=function(){y(),c.canvas=null,c.externalWindow&&(c.externalWindow.close(),c.externalWindow=null,c.resizeSubject=null),u("endAnnotation"),h(l.actionEnd,l.variationSuccess)},C=function(e){if(o=this,o.options=t.omit(e,"accPack","session"),i=t.property("accPack")(e),a=t.property("session")(e),!a)throw new Error("OpenTok Annotation Accelerator Pack requires an OpenTok session");p(),d(),h(l.actionInitialize,l.variationSuccess)};C.prototype={constructor:C,start:T,linkCanvas:k,resizeCanvas:O,addSubscriberToExternalWindow:M,end:_},"object"==typeof exports?module.exports=C:"function"==typeof define&&define.amd?define(function(){return C}):this.AnnotationAccPack=C}.call(this);
{
"name": "opentok-annotation",
"version": "2.0.20",
"version": "2.0.21",
"description": "OpenTok annotation accelerator pack",

@@ -5,0 +5,0 @@ "main": "dist/opentok-annotation.js",

@@ -239,3 +239,3 @@ /* global OT OTSolution OTKAnalytics ScreenSharingAccPack define */

var height = width / (_aspectRatio);
var externalWindowHTML = '<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><style type="text/css" media="screen"> body{margin:0;background-color:rgba(0,153,203,.7);box-sizing:border-box;height:100vh}canvas{top:0;z-index:1000}.hidden{display:none}.ots-hidden{display:none !important}.main-wrap{width:100%;height:100%;-ms-box-orient:horizontal;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-moz-flex;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center}.inner-wrap{position:relative;border-radius:8px;overflow:hidden}.ots-annotation-toolbar-container{position:fixed;top:125px;right:0;width:60px;z-index:1000;background-color:#666}.ots-annotation-toolbar-container .OT_panel{display:flex;flex-direction:column;align-items:center}.ots-annotation-toolbar-container .annotation-btn{height:60px;width:60px;background-position:center center;background-repeat:no-repeat!important;background-color:#666;cursor:pointer;border:none}.ots-annotation-toolbar-container .annotation-btn.pen{background-image:url(https://assets.tokbox.com/solutions/images/annotation-pencil.png);background-size:27px 30px}.ots-annotation-toolbar-container .annotation-btn.colors{width:23px;height:24px;border:3px solid #fff;margin:18px 18.5px}.ots-annotation-toolbar-container .annotation-btn.line{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.line-width{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line_width.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.shapes{background-image:url(https://assets.tokbox.com/solutions/images/annotation-shapes.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.text{background-image:url(https://assets.tokbox.com/solutions/images/annotation-text.png);background-size:21px 25px}.ots-annotation-toolbar-container .annotation-btn.capture{background-image:url(https://assets.tokbox.com/solutions/images/annotation-camera.png);background-size:34px 31px}.ots-annotation-toolbar-container .annotation-btn.clear{background-image:url(https://assets.tokbox.com/solutions/images/annotation-trash.png);background-size:31px 31px}.ots-annotation-toolbar-container .annotation-btn.undo{background-image:url(https://assets.tokbox.com/solutions/images/annotation-undo.png);background-size:34px 31px}.ots-annotation-toolbar-container .OT_subpanel,.ots-annotation-toolbar-container .color-picker{position:absolute;right:65px;width:40px;background-color:#333;display:flex;flex-direction:column;align-items:center;transition:opacity .5s ease-out}.ots-annotation-toolbar-container .OT_subpanel.pen{top:0}.ots-annotation-toolbar-container .OT_subpanel.pen .line-width-option{width:40px;height:40px;cursor:pointer}.ots-annotation-toolbar-container .OT_subpanel.pen:after,.ots-annotation-toolbar-container .color-picker:after{width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333;right:-15px;content:"";position:absolute}.ots-annotation-toolbar-container .OT_subpanel.pen:after{top:15px}.ots-annotation-toolbar-container .color-picker{top:0}.ots-annotation-toolbar-container .color-picker:after{top:75px}.ots-annotation-toolbar-container .color-picker .color-choice{width:20px;height:20px;margin:10px;cursor:pointer;border-radius:100%}.ots-annotation-toolbar-container .color-picker .color-choice.active{border:2px solid #fff}.ots-annotation-toolbar-container .OT_subpanel.shapes{display:flex;flex-direction:column;top:75px;min-height:159.89px}.ots-annotation-toolbar-container .OT_subpanel.shapes:after{position:absolute;top:62.5px;right:-15px;content:"";width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333}.ots-annotation-toolbar-container .OT_subpanel.shapes input{width:22px;height:22px;margin:9px;border:none;background-color:#333;background-repeat:no-repeat;background-position:center center}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle-fill.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval-fill.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.star{background-image:url(https://assets.tokbox.com/solutions/images/annotation-star.png);background-size:22px 22px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.arrow{background-image:url(https://assets.tokbox.com/solutions/images/annotation-arrow.png);background-size:6.5px 23.5px}.publisherContainer{display:block;background-color:#000;position:absolute}.publisher-wrap{height:100%;width:100%}.subscriberContainer{position:absolute;top:20px;left:20px;width:200px;height:120px;background-color:#000;border:2px solid #fff;border-radius:6px}.subscriberContainer .OT_video-poster{width:100%;height:100%;opacity:.25;background-repeat:no-repeat;background-image:url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg);background-size:50%;background-position:center}.OT_video-element{height:100%;width:100%}.OT_edge-bar-item{display:none}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="ots-annotation-toolbar-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, subscribeToVideo: "true", subscribeToAudio: "false", fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); var subscriber=session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>';
var externalWindowHTML = '<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><link rel="stylesheet" href="https://assets.tokbox.com/solutions/css/style.css"><style type="text/css" media="screen"> body{margin:0;background-color:rgba(0,153,203,.7);box-sizing:border-box;height:100vh}canvas{top:0;z-index:1000}.hidden{display:none}.ots-hidden{display:none !important}.main-wrap{width:100%;height:100%;-ms-box-orient:horizontal;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-moz-flex;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center}.inner-wrap{position:relative;border-radius:8px;overflow:hidden}.publisherContainer{display:block;background-color:#000;position:absolute}.publisher-wrap{height:100%;width:100%}.subscriberContainer{position:absolute;top:20px;left:20px;width:200px;height:120px;background-color:#000;border:2px solid #fff;border-radius:6px}.subscriberContainer .OT_video-poster{width:100%;height:100%;opacity:.25;background-repeat:no-repeat;background-image:url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg);background-size:50%;background-position:center}.OT_video-element{height:100%;width:100%}.OT_edge-bar-item{display:none}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="ots-annotation-toolbar-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, subscribeToVideo: "true", subscribeToAudio: "false", fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); var subscriber=session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>';

@@ -242,0 +242,0 @@ /* eslint-disable max-len */

@@ -7,2 +7,2 @@

var template = '<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><style type="text/css" media="screen"> body{margin:0;background-color:rgba(0,153,203,.7);box-sizing:border-box;height:100vh}canvas{top:0;z-index:1000}.hidden{display:none}..ots-hidden{display:none !important;}main-wrap{width:100%;height:100%;-ms-box-orient:horizontal;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-moz-flex;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center}.inner-wrap{position:relative;border-radius:8px;overflow:hidden}.ots-annotation-toolbar-container{position:fixed;top:125px;right:0;width:60px;z-index:1000;background-color:#666}.ots-annotation-toolbar-container .OT_panel{display:flex;flex-direction:column;align-items:center}.ots-annotation-toolbar-container .annotation-btn{height:60px;width:60px;background-position:center center;background-repeat:no-repeat!important;background-color:#666;cursor:pointer;border:none}.ots-annotation-toolbar-container .annotation-btn.pen{background-image:url(https://assets.tokbox.com/solutions/images/annotation-pencil.png);background-size:27px 30px}.ots-annotation-toolbar-container .annotation-btn.colors{width:23px;height:24px;border:3px solid #fff;margin:18px 18.5px}.ots-annotation-toolbar-container .annotation-btn.line{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.line-width{background-image:url(https://assets.tokbox.com/solutions/images/annotation-line_width.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.shapes{background-image:url(https://assets.tokbox.com/solutions/images/annotation-shapes.png);background-size:26px 31px}.ots-annotation-toolbar-container .annotation-btn.text{background-image:url(https://assets.tokbox.com/solutions/images/annotation-text.png);background-size:21px 25px}.ots-annotation-toolbar-container .annotation-btn.capture{background-image:url(https://assets.tokbox.com/solutions/images/annotation-camera.png);background-size:34px 31px}.ots-annotation-toolbar-container .annotation-btn.clear{background-image:url(https://assets.tokbox.com/solutions/images/annotation-trash.png);background-size:31px 31px}.ots-annotation-toolbar-container .annotation-btn.undo{background-image:url(https://assets.tokbox.com/solutions/images/annotation-undo.png);background-size:34px 31px}.ots-annotation-toolbar-container .OT_subpanel,.ots-annotation-toolbar-container .color-picker{position:absolute;right:65px;width:40px;background-color:#333;display:flex;flex-direction:column;align-items:center;transition:opacity .5s ease-out}.ots-annotation-toolbar-container .OT_subpanel.pen{top:0}.ots-annotation-toolbar-container .OT_subpanel.pen .line-width-option{width:40px;height:40px;cursor:pointer}.ots-annotation-toolbar-container .OT_subpanel.pen:after,.ots-annotation-toolbar-container .color-picker:after{width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333;right:-15px;content:"";position:absolute}.ots-annotation-toolbar-container .OT_subpanel.pen:after{top:15px}.ots-annotation-toolbar-container .color-picker{top:0}.ots-annotation-toolbar-container .color-picker:after{top:75px}.ots-annotation-toolbar-container .color-picker .color-choice{width:20px;height:20px;margin:10px;cursor:pointer;border-radius:100%}.ots-annotation-toolbar-container .color-picker .color-choice.active{border:2px solid #fff}.ots-annotation-toolbar-container .OT_subpanel.shapes{display:flex;flex-direction:column;top:75px;min-height:159.89px}.ots-annotation-toolbar-container .OT_subpanel.shapes:after{position:absolute;top:62.5px;right:-15px;content:"";width:0;height:0;border-top:15px solid transparent;border-bottom:15px solid transparent;border-left:15px solid #333}.ots-annotation-toolbar-container .OT_subpanel.shapes input{width:22px;height:22px;margin:9px;border:none;background-color:#333;background-repeat:no-repeat;background-position:center center}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.rectangle-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-rectangle-fill.png);background-size:18px 18px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.oval-fill{background-image:url(https://assets.tokbox.com/solutions/images/annotation-oval-fill.png);background-size:20px 20px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.star{background-image:url(https://assets.tokbox.com/solutions/images/annotation-star.png);background-size:22px 22px}.ots-annotation-toolbar-container .OT_subpanel.shapes .annotation-btn.arrow{background-image:url(https://assets.tokbox.com/solutions/images/annotation-arrow.png);background-size:6.5px 23.5px}.publisherContainer{display:block;background-color:#000;position:absolute}.publisher-wrap{height:100%;width:100%}.subscriberContainer{position:absolute;top:20px;left:20px;width:200px;height:120px;background-color:#000;border:2px solid #fff;border-radius:6px}.subscriberContainer .OT_video-poster{width:100%;height:100%;opacity:.25;background-repeat:no-repeat;background-image:url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg);background-size:50%;background-position:center}.OT_video-element{height:100%;width:100%}.OT_edge-bar-item{display:none}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="ots-annotation-toolbar-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>';
var template = '<!DOCTYPE html><html lang="en"><head><meta http-equiv="Content-type" content="text/html; charset=utf-8"><title>OpenTok Screen Sharing Solution Annotation</title><link rel="stylesheet" href="https://assets.tokbox.com/solutions/css/style.css"><style type="text/css" media="screen"> body{margin:0;background-color:rgba(0,153,203,.7);box-sizing:border-box;height:100vh}canvas{top:0;z-index:1000}.hidden{display:none}..ots-hidden{display:none !important;}main-wrap{width:100%;height:100%;-ms-box-orient:horizontal;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-moz-flex;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center}.inner-wrap{position:relative;border-radius:8px;overflow:hidden}.publisherContainer{display:block;background-color:#000;position:absolute}.publisher-wrap{height:100%;width:100%}.subscriberContainer{position:absolute;top:20px;left:20px;width:200px;height:120px;background-color:#000;border:2px solid #fff;border-radius:6px}.subscriberContainer .OT_video-poster{width:100%;height:100%;opacity:.25;background-repeat:no-repeat;background-image:url(https://static.opentok.com/webrtc/v2.8.2/images/rtc/audioonly-silhouette.svg);background-size:50%;background-position:center}.OT_video-element{height:100%;width:100%}.OT_edge-bar-item{display:none}</style></head><body> <div class="main-wrap"> <div id="annotationContainer" class="inner-wrap"></div></div><div id="toolbarContainer" class="ots-annotation-toolbar-container"> <div id="toolbar" class="toolbar-wrap"></div></div><div id="subscriberVideo" class="subscriberContainer hidden"></div><script type="text/javascript" charset="utf-8"> /** Must use double-quotes since everything must be converted to a string */ var opener; var canvas; if (!toolbar){alert("Something went wrong: You must pass an OpenTok annotation toolbar object into the window.")}else{opener=window.opener; window.onbeforeunload=window.triggerCloseEvent;}var localScreenProperties={insertMode: "append", width: "100%", height: "100%", videoSource: "window", showControls: false, style:{buttonDisplayMode: "off"}, fitMode: "contain"}; var createContainerElements=function(){var parentDiv=document.getElementById("annotationContainer"); var publisherContainer=document.createElement("div"); publisherContainer.setAttribute("id", "screenshare_publisher"); publisherContainer.classList.add("publisher-wrap"); parentDiv.appendChild(publisherContainer); return{annotation: parentDiv, publisher: publisherContainer};}; var addSubscriberVideo=function(stream){var container=document.getElementById("subscriberVideo"); session.subscribe(stream, container, localScreenProperties, function(error){if (error){console.log("Failed to add subscriber video", error);}container.classList.remove("hidden");});}; if (navigator.userAgent.indexOf("Firefox") !==-1){var ghost=window.open("about:blank"); ghost.focus(); ghost.close();}</script></body></html>';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc