(function(e){function t(t){for(var i,c,l=t[0],r=t[1],s=t[2],b=0,d=[];b<l.length;b++)c=l[b],Object.prototype.hasOwnProperty.call(o,c)&&o[c]&&d.push(o[c][0]),o[c]=0;for(i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);u&&u(t);while(d.length)d.shift()();return a.push.apply(a,s||[]),n()}function n(){for(var e,t=0;t<a.length;t++){for(var n=a[t],i=!0,l=1;l<n.length;l++){var r=n[l];0!==o[r]&&(i=!1)}i&&(a.splice(t--,1),e=c(c.s=n[0]))}return e}var i={},o={app:0},a=[];function c(t){if(i[t])return i[t].exports;var n=i[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,c),n.l=!0,n.exports}c.m=e,c.c=i,c.d=function(e,t,n){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},c.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(c.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)c.d(n,i,function(t){return e[t]}.bind(null,i));return n},c.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="";var l=window["webpackJsonp"]=window["webpackJsonp"]||[],r=l.push.bind(l);l.push=t,l=l.slice();for(var s=0;s<l.length;s++)t(l[s]);var u=r;a.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("cd49")},"0d53":function(e,t,n){},"1eca":function(e,t,n){},"2f0f":function(e,t,n){"use strict";n("0d53")},"44dc":function(e,t,n){"use strict";n("1eca")},5721:function(e,t,n){"use strict";n("65c9")},"65c9":function(e,t,n){},cd49:function(e,t,n){"use strict";n.r(t);n("e260"),n("e6cf"),n("cca6"),n("a79d");var i=n("830f"),o=n("5c40"),a={id:"app"};function c(e,t,n,i,c,l){var r=Object(o["w"])("MyComponent"),s=Object(o["w"])("WithStreamlitConnection");return Object(o["r"])(),Object(o["d"])("div",a,[Object(o["i"])(s,null,{default:Object(o["C"])((function(e){var t=e.args;return[Object(o["i"])(r,{args:t},null,8,["args"])]})),_:1})])}function l(e,t,n,i,a,c){var l=Object(o["w"])("Annotator");return Object(o["r"])(),Object(o["d"])("div",null,[(Object(o["r"])(!0),Object(o["d"])(o["b"],null,Object(o["u"])(e.args.data,(function(t,n){return Object(o["r"])(),Object(o["d"])(l,{key:n,options:t,"onUi-updated":e.onUIUpdated,"onSubmit-data":e.submitData},null,8,["options","onUi-updated","onSubmit-data"])})),128))])}var r=n("d092");function s(){Object(o["o"])((function(){r["a"].setFrameHeight()})),Object(o["q"])((function(){r["a"].setFrameHeight()}))}
/**
 * @license
 * Copyright 2018-2020 Streamlit Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */n("caad"),n("2532");var u=n("9ff4"),b=Object(o["E"])("data-v-9bfb6f94");Object(o["t"])("data-v-9bfb6f94");var d={class:"container"},f=Object(o["i"])("div",{class:"arrow"},null,-1),p={key:0,class:"submission"};Object(o["s"])();var O=b((function(e,t,n,a,c,l){return Object(o["r"])(),Object(o["d"])("div",d,[(Object(o["r"])(!0),Object(o["d"])(o["b"],null,Object(o["u"])(e.tokens,(function(t,n){return Object(o["r"])(),Object(o["d"])("div",{class:["token",{labeled:t.labels.length>0,selected:e.selectedToken===t}],key:n,"data-index":n,onClick:function(t){return e.onTokenClick(n,t)}},[e.isHorizontal?(Object(o["r"])(),Object(o["d"])("span",{key:0,class:"text",style:e.styleObjectToString(t.style)},Object(u["F"])(t.text),5)):Object(o["e"])("",!0),(Object(o["r"])(!0),Object(o["d"])(o["b"],null,Object(o["u"])(t.labels,(function(n,i){return Object(o["r"])(),Object(o["d"])("span",{key:i,class:["label",{vertical:!e.isHorizontal,horizontal:e.isHorizontal}],style:n in e.labelDict?e.styleObjectToString(e.labelDict[n].style):""},[Object(o["h"])(Object(u["F"])(n)+" ",1),e.allowEditing?(Object(o["r"])(),Object(o["d"])("span",{key:0,class:"delete-label",onClick:function(n){return e.deleteLabel(t,i,n)}},"×",8,["onClick"])):Object(o["e"])("",!0)],6)})),128)),e.isHorizontal?Object(o["e"])("",!0):(Object(o["r"])(),Object(o["d"])("span",{key:1,class:"text",style:e.styleObjectToString(t.style)},Object(u["F"])(t.text),5))],10,["data-index","onClick"])})),128)),Object(o["D"])(Object(o["i"])("div",{class:["menu",{"menu-static":"static"===e.menuType}]},[f,(Object(o["r"])(!0),Object(o["d"])(o["b"],null,Object(o["u"])(e.labelValues,(function(t,n){return Object(o["r"])(),Object(o["d"])("a",{href:"#",class:["item",{"chosen-label":e.selectedToken&&e.selectedToken.labels.includes(t)}],key:n,onClick:function(n){return e.onMenuItemClick(t)},style:"static"===e.menuType&&t in e.labelDict?e.styleObjectToString(e.labelDict[t].style):""},Object(u["F"])(t),15,["onClick"])})),128))],2),[[i["b"],e.showMenu]]),e.submitMode&&e.isEdited?(Object(o["r"])(),Object(o["d"])("div",p,[Object(o["i"])("button",{onClick:t[1]||(t[1]=function(){return e.onSubmit.apply(e,arguments)}),title:"Submit changes"},"Submit"),Object(o["i"])("button",{onClick:t[2]||(t[2]=function(){return e.onReset.apply(e,arguments)}),title:"Discard and reset all changes"},"Reset")])):Object(o["e"])("",!0)])})),h=(n("99af"),n("4160"),n("c975"),n("d81d"),n("13d5"),n("a434"),n("ac1f"),n("1276"),n("159b"),n("ade3")),j=n("b85c"),m=n("e20a"),v=n("b8ca"),y={name:"Annotator",props:["options"],data:function(){var e={allowEditing:!1,labelOrientation:"vertical",collectLabelsFromTokens:!0,menuType:"static",labels:[],tokens:[{text:"Tokens not found",labels:["Error!"]}]};return Object.assign(e,this.options),e["isEdited"]=!1,e["submitMode"]=!0,e["showMenu"]=!1,e["selectedToken"]=null,e["isHorizontal"]="horizontal"===e.labelOrientation,e.tokens.forEach((function(e){e.labels||(e.labels=[])})),e},computed:{labelValues:function(){return this.labels.map((function(e){return e.text}))},labelDict:function(){return this.labels.reduce((function(e,t){return e[t.text]=t,e}),{})}},methods:{styleObjectToString:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e||!t)return"";var n="";for(var i in e)n+="".concat(i,":").concat(e[i],";");return n},onTokenClick:function(e,t){var n=this;this.allowEditing&&(this.showMenu=!0,t.target.classList.contains("delete-label")||this.resetSelectedToken(),this.selectedToken=this.tokens[e],this.$nextTick((function(){n.selectedToken["element"]=t.target.closest(".token");n.positionMenu();n.$emit("ui-updated")})))},resetSelectedToken:function(){this.selectedToken&&delete this.selectedToken.element,this.selectedToken=null},deleteLabel:function(e,t,n){e.labels.splice(t,1),this.isEdited=!0,this.resetSelectedToken(),this.selectedToken=e,this.$emit("labels-changed",e),this.$emit("ui-updated")},onMenuItemClick:function(e){var t=this;this.selectedToken.labels.includes(e)?this.selectedToken.labels.splice(this.selectedToken.labels.indexOf(e),1):this.selectedToken.labels.push(e),this.sortTokenLabels(this.selectedToken),this.isEdited=!0,this.$nextTick((function(){t.positionMenu(),t.$emit("menu-item-clicked"),t.$emit("ui-updated")}))},collectAllLabelsFromTokens:function(){var e,t=Object(j["a"])(this.tokens);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(n.labels.length>0){var i,o=Object(j["a"])(n.labels);try{for(o.s();!(i=o.n()).done;){var a=i.value;this.labelValues.includes(a)||this.labels.push({text:a})}}catch(c){o.e(c)}finally{o.f()}}}}catch(c){t.e(c)}finally{t.f()}},setLabelColors:function(){var e,t=["#e6194b","#3cb44b","#ffe119","#4363d8","#f58231","#911eb4","#46f0f0","#f032e6","#bcf60c","#fabebe","#008080","#e6beff","#9a6324","#fffac8","#800000","#aaffc3","#808000","#ffd8b1","#000075","#808080"],n=["#000000","#ffffff"],i=[1,1,0,1,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1],o=0,a=Object(j["a"])(this.labels);try{for(a.s();!(e=a.n()).done;){var c=e.value;if(c.style||(c.style={}),!("background-color"in c.style)&&!("color"in c.style)){var l={"background-color":t[o%20],color:n[i[o%20]]};Object.assign(c.style,l),o++}}}catch(r){a.e(r)}finally{a.f()}},sortTokenLabels:function(e){var t=this;e.labels.sort((function(e,n){return t.labelValues.indexOf(e)-t.labelValues.indexOf(n)}))},partialCopy:function(e,t){var n={};for(var i in e)t.includes(i)||(n[i]=e[i]);return n},getData:function(){var e,t=[],n=Object(j["a"])(this.tokens);try{for(n.s();!(e=n.n()).done;){var i=e.value,o=this.partialCopy(i,["element"]);t.push(o)}}catch(c){n.e(c)}finally{n.f()}var a={tokens:t};return"undefined"!==typeof this.index&&(a["index"]=this.index),a},positionMenu:function(){if("dropdown"===this.menuType){var e=this.selectedToken.element,t=document.querySelector(".menu"),n=document.querySelector(".menu .arrow"),i=8;return Object.assign(n.style,{width:"".concat(i,"px"),height:"".concat(i,"px")}),m["a"](e,t,{placement:"bottom",middleware:[v["a"]({element:n}),v["c"](i/2)]}).then((function(e){var o=e.x,a=e.y,c=e.placement,l=e.middlewareData;Object.assign(t.style,{left:"".concat(o,"px"),top:"".concat(a,"px")});var r=l.arrow.x,s=l.arrow.y,u={top:"bottom",right:"left",bottom:"top",left:"right"}[c.split("-")[0]];Object.assign(n.style,Object(h["a"])({left:null!=r?"".concat(r,"px"):"",top:null!=s?"".concat(s,"px"):"",right:"",bottom:""},u,"".concat(-i/4,"px")))})),t.getBoundingClientRect()}},onSubmit:function(){this.$emit("submit-data",this.getData()),this.isEdited=!1},onReset:function(){this.labels=JSON.parse(JSON.stringify(this.originalData.labels)),this.tokens=JSON.parse(JSON.stringify(this.originalData.tokens)),this.isEdited=!1,this.$emit("ui-updated")}},created:function(){this.collectLabelsFromTokens&&this.collectAllLabelsFromTokens(),this.setLabelColors(),this.originalData=JSON.parse(JSON.stringify(this.$data))},mounted:function(){var e=this;document.addEventListener("click",(function(t){t.target.closest(".menu")||t.target.closest(".token")||t.target.classList.contains("delete-label")||("dropdown"===e.menuType&&(e.showMenu=!1),e.showMenu=!1,e.resetSelectedToken())}))}};n("5721");y.render=O,y.__scopeId="data-v-9bfb6f94";var k=y,g={name:"MyComponent",props:["args"],components:{Annotator:k},created:function(){s()},methods:{onUIUpdated:function(){setTimeout((function(){r["a"].setFrameHeight()}),0)},submitData:function(e){r["a"].setComponentValue(JSON.stringify(e))}}};g.render=l;var T=g,x=Object(o["E"])("data-v-bef81972");Object(o["t"])("data-v-bef81972");var S={key:0},w=Object(o["i"])("h1",{class:"err__title"},"Component Error",-1),E={class:"err__msg"};Object(o["s"])();var C=x((function(e,t,n,i,a,c){return Object(o["r"])(),Object(o["d"])("div",null,[""!=e.componentError?(Object(o["r"])(),Object(o["d"])("div",S,[w,Object(o["i"])("div",E,"Message: "+Object(u["F"])(e.componentError),1)])):null!=e.renderData?Object(o["v"])(e.$slots,"default",{key:1,args:e.renderData.args,disabled:e.renderData.disabled}):Object(o["e"])("",!0)])})),D=n("a1e9"),M=Object(o["j"])({name:"WithStreamlitConnection",setup:function(){var e=Object(D["i"])(void 0),t=Object(D["i"])(""),n=function(n){var i=n;e.value=i.detail,t.value=""};return Object(o["o"])((function(){r["a"].events.addEventListener(r["a"].RENDER_EVENT,n),r["a"].setComponentReady()})),Object(o["q"])((function(){""!=t.value&&r["a"].setFrameHeight()})),Object(o["p"])((function(){r["a"].events.removeEventListener(r["a"].RENDER_EVENT,n)})),Object(o["n"])((function(e){t.value=String(e)})),{renderData:e,componentError:t}}});n("44dc");M.render=C,M.__scopeId="data-v-bef81972";var _=M,L=Object(o["j"])({name:"App",components:{MyComponent:T,WithStreamlitConnection:_}});n("2f0f");L.render=c;var F=L;Object(i["a"])(F).mount("#app")}});
//# sourceMappingURL=app.67272d70.js.map