text: var RG2_VERSION="3.6.2";var RG2_INIT=false;var RG2_BASE=Date.now();var RG2_CONFETTI="rg-confetti";var RG2_CONFETTI_MSG;var RG2_MKDN_RENDER;var RG_DATE_CDN_MOMENTJS="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js";var RG_CODE_CDN_ACEJS="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.js";var RG_CHART_CDN_CHARTJS="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js";var RG_CREDIT_CARD_PAYMENT_FONTS="https://cdnjs.cloudflare.com/ajax/libs/paymentfont/1.1.2/css/paymentfont.min.css";var RG_MARKDOWN_CDN_MARKDOWN="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/8.3.0/markdown-it.min.js";function RGVersion(){return RG2_VERSION}function loadCSS(file,callback,error){var _file=file;var loaded=document.querySelector('link[href="'+file+'"]');if(loaded){loaded.onload=callback;loaded.onreadystatechange=callback;return}var css=document.createElement("script");css.type="text/css";css.rel="stylesheet";css.href=file;script.onload=callback;loaded.onreadystatechange=callback;if(error){css.onerror=error}else{css.onerror=function(e){console.error("CSS File '"+_file+"' not found :-(")}}document.head.appendChild(css)}function loadJS(file,callback,error,type){var _file=file;var loaded=document.querySelector('script[src="'+file+'"]');if(loaded){loaded.onload=callback;loaded.onreadystatechange=callback;return}var script=document.createElement("script");script.type=typeof type==="string"?type:"application/javascript";script.src=file;script.async=false;script.defer=false;script.onload=callback;if(error){script.onerror=error}else{script.onerror=function(e){console.error("Script File '"+_file+"' not found :-(")}}script.onreadystatechange=callback;document.body.appendChild(script)}function isBoolean(bool){if(bool){if(typeof bool==="number"){bool=Number(bool);if(bool===1)return true;else return false}if(typeof bool==="string"){bool=bool.toLowerCase();if(bool==="true"||bool==="false")if(bool==="true")return true;else return false;if(bool==="yes"||bool==="no")if(bool==="yes")return true;else return false;if(bool==="on"||bool==="off")if(bool==="on")return true;else return false}else if(typeof bool==="boolean")return true}else return false}function toBoolean(bool){if(bool)return isBoolean(bool);else return undefined}function toNumber(num){if(num){if(typeof num==="number"||typeof num==="string")return Number(num)}else return NaN}function stripParas(text){if(text){text=text.replace(/<\/?p[^>]*>/g,"")}return text}function toMarkdown(content,renderCallback){var markdownOK=!(typeof markdownit==="undefined");RG2_MKDN_RENDER=markdownOK?markdownit({html:true,linkify:true,typographer:true}):undefined;var _content=content;var callbackMkdn=function callbackMkdn(){markdownOK=!(typeof markdownit==="undefined");if(!RG2_MKDN_RENDER&&markdownOK&&_content){RG2_MKDN_RENDER=markdownit({html:true,linkify:true,typographer:true});if(markdownOK){rendered=RG2_MKDN_RENDER.render(_content);rendered=stripParas(rendered);if(renderCallback)renderCallback(rendered);return rendered}}};if(!markdownOK)loadJS(RG_MARKDOWN_CDN_MARKDOWN,callbackMkdn);else{rendered=RG2_MKDN_RENDER.render(_content);if(renderCallback)renderCallback(rendered);return stripParas(rendered)}}function RiotGearInit(){if(RG2_INIT===true)return;var localCB=function(text){console.log(text);RG2_INIT=true};toMarkdown("**RG2** ["+RG2_VERSION+"] started",localCB)}document.addEventListener("DOMContentLoaded",function(event){RiotGearInit()});riot.tag("rg-accordion",'<div class="c-card c-card--accordion" each="{item, index in opts.accordion.panels}">'+'     <input type="checkbox" ref="accordion-ref{index}" id="accordion-{index}" onclick="{notify}">'+'     <label class="c-card__item" for="accordion-{index}">{item.title}</label>'+'     <div class="c-accordion-content c-card__item"><rg-markdown content="{item.content}"></rg-markdown></div>'+"</div>",".c-accordion-content {padding-left: 2em;}",function(){var _this=this;this.notify=function(e){not={index:e.item.index,title:e.item.item.title,open:e.target.checked};_this.trigger("notify",not)}});riot.tag("rg-address",'<address class="c-address">'+'  <span class="c-address__heading">{opts.address.recipient}</span>'+'  <div each="{addr in opts.address.lines}">'+"     <span class=\"{'c-address--road':addr.road} {'c-address--district':addr.district} {'c-address--town':addr.town} {'c-address--code':addr.code} {'c-address--state':addr.state} {'c-address--country':addr.country}\">{addr.line}<br></span>"+"  </div>"+"</address>","",function(){var _this=this});riot.tag2("rg-alerts",'<div class="alerts"> <div each="{opts.alerts}" class="alerts__alert {\'alerts__alert--\' + type}" if="{isvisible}" onclick="{select}"> <button class="button button--close" if="{dismissable != false}" onclick="{parent.dismiss}"> &times; </button> {text} </div> </div>',"","",function(opts){"use strict";var _this=this;this.on("update",function(){if(!opts.alerts)return;opts.alerts.forEach(function(alert){if(typeof alert.isvisible==="undefined")alert.isvisible=true;if(alert.timeout){alert.startTimer=function(){alert.timer=setTimeout(function(){_this.dismiss({item:alert})},alert.timeout)};alert.startTimer()}})});this.dismiss=function(e){var alert=e.item;alert.isvisible=false;clearTimeout(alert.timer);_this.trigger("dismiss",alert);_this.update()};this.select=function(e){var alert=e.item;if(alert.onclick)alert.onclick(alert);_this.trigger("select",alert)}});riot.tag2("rg-bubble",'<div class="context"> <div class="bubble bubble--top" if="{isvisible}"> {opts.bubble.text} </div> <div class="content" onmouseover="{showBubble}" onmouseout="{hideBubble}" onclick="{toggleBubble}"> <yield></yield> </div> </div>','rg-bubble .context,[data-is="rg-bubble"] .context,rg-bubble .content,[data-is="rg-bubble"] .content{ display: inline-block; position: relative; } rg-bubble .bubble,[data-is="rg-bubble"] .bubble{ position: absolute; top: -70px; left: 50%; transform: translate3d(-50%, 0, 0); }',"",function(opts){"use strict";var _this=this;this.showBubble=function(){clearTimeout(_this._timer);_this.isvisible=true};this.hideBubble=function(){_this._timer=setTimeout(function(){_this.isvisible=false;_this.update()},1e3)};this.toggleBubble=function(){_this.isvisible=!_this.isvisible}});riot.tag("rg-card","<div class=\"c-card  {'u-' + opts.card.shadow}\"> "+'<img class="o-image" riot-src="{opts.card.header.image}" if="{opts.card.header.image && (opts.card.header.text || opts.card.header.subhead)}">'+' <header class="c-card__header" if="{opts.card.header.text || opts.card.header.subhead}">'+'<h2 class="c-heading c-heading--small"><rg-html content="{opts.card.header.text}"></rg-html>'+'<div class="c-heading__sub"><rg-html content="{opts.card.header.subhead}"></rg-html></div>'+"</h2>"+"</header>"+'<div class="c-card__item c-card__item{\'--\'+opts.card.header.style}" if="{opts.card.header.divider && opts.card.header.text}"></div>'+'  <div class"c-card__body">'+'<div class="rg-card-content">'+'   <rg-html content="<p class=\'c-paragraph\'>{opts.card.text}</p>" if="{opts.card.text}"></rg-html>'+"   <yield>"+"</div>"+"</div>"+'<div class="c-card__item c-card__item{\'--\'+opts.card.footer.style}" if="{opts.card.footer.divider && (opts.card.footer.text || (opts.card.footer.items.length > 0))}"></div>'+'<footer class="c-card__footer {\'c-card__footer--block\':opts.card.footer.block}" if="{(opts.card.footer.items.length > 0) || opts.card.footer.text}">'+'<p class="c-text--quiet"><rg-html content="{opts.card.footer.text}" if="{opts.card.footer.text}"></rg-html></p>'+'<div class="c-input-group"> <button each="{button in opts.card.footer.items}" class="c-button c-button--block {\'c-button--active\':button.active}'+" {'c-button--'+button.style}\" "+'disabled="{button.disabled}" onclick="{btnclicked}">{button.text}</button>'+" </div>"+"</footer>"+"</div>",".rg-card-content {margin: 0.8em}","",function(opts){var self=this;if(!opts.card)opts.card={header:{},footer:{items:[]}};if(this.root._innerHTML)opts.card.contents=toMarkdown(this.root._innerHTML);if(opts.card.header.text)opts.card.header.text=toMarkdown(opts.card.header.text);if(opts.card.header.subhead)opts.card.header.subhead=toMarkdown(opts.card.header.subhead);if(opts.card.footer.text)opts.card.footer.text=toMarkdown(opts.card.footer.text);if(opts.card.text)opts.card.text=toMarkdown(opts.card.text);if(opts.header)opts.card.header.text=toMarkdown(opts.header);if(opts.subhead)opts.card.header.subhead=toMarkdown(opts.subhead);if(opts.image)opts.card.header.image=opts.image;if(opts.footer)opts.card.footer.text=toMarkdown(opts.footer);if(opts.block)opts.card.footer.block=toBoolean(opts.block);if(opts.divider)opts.card.footer.divider=toBoolean(opts.divider);if(opts.divider)opts.card.header.divider=toBoolean(opts.divider);if(opts.text)opts.card.text=toMarkdown(opts.text);if(opts.shadow)opts.card.shadow=opts.shadow;if(opts.buttons)opts.card.footer.items=opts.buttons;btnclicked=function(e){selbtn=e.item.button;btn={text:selbtn.text};self.trigger("button-clicked",btn)}});riot.tag2("rg-chart","<canvas></canvas>",'rg-chart,[data-is="rg-chart"]{ display: inline-block; width: 100%; }',"",function(opts){"use strict";var _this=this;Chart.defaults.global.responsive=true;this.on("mount",function(){drawChart()});this.on("loaded",function(c){_this.on("unmount",function(){c.destroy()})});var drawChart=function drawChart(){if(!opts.chart)opts.chart={};var ctx=_this.root.querySelector("canvas").getContext("2d");var chart=new Chart(ctx);var c=null;switch(opts.chart.type){case"line":c=chart.Line(opts.chart.data,opts.chart.options);break;case"radar":c=chart.Radar(opts.chart.data,opts.chart.options);break;case"polar":c=chart.PolarArea(opts.chart.data,opts.chart.options);break;case"pie":c=chart.Pie(opts.chart.data,opts.chart.options);break;case"doughnut":c=chart.Doughnut(opts.chart.data,opts.chart.options);break;default:c=chart.Bar(opts.chart.data,opts.chart.options);break}_this.trigger("loaded",c)}});riot.tag2("rg-code",'<div class="editor"></div>','rg-code .editor,[data-is="rg-code"] .editor{ position: absolute; top: 0; right: 0; bottom: 0; left: 0; }',"",function(opts){"use strict";var _this=this;if(!opts.editor)opts.editor={code:""};var editor=void 0;var setupEditor=function setupEditor(){editor.setTheme("ace/theme/"+(opts.editor.theme||"monokai"));editor.getSession().setMode("ace/mode/"+(opts.editor.mode||"html"));editor.getSession().setTabSize(opts.editor.tabsize||2);editor.getSession().setUseSoftTabs(opts.editor.softtabs);editor.getSession().setUseWrapMode(opts.editor.wordwrap);editor.setReadOnly(opts.editor.readonly)};this.on("mount",function(){editor=ace.edit(_this.root.querySelector(".editor"));editor.$blockScrolling=Infinity;_this.on("update",function(){setupEditor();if(opts.editor.code!=editor.getValue())editor.setValue(opts.editor.code,1)});if(opts.url){var req=new XMLHttpRequest;req.onload=function(resp){opts.editor.code=resp;_this.update()};req.open("get",opts.url,true);req.send()}editor.setValue(opts.editor.code,1);editor.getSession().on("change",function(e){opts.editor.code=editor.getValue();_this.trigger("onchange",editor.getValue())});setupEditor();_this.update()})});riot.tag2("rg-credit-card-number",'<input type="text" name="cardnumber" class="field card-no {icon} {\'field--success\': opts.card.valid}" oninput="{validate}" placeholder="{opts.card.placeholder}">','rg-credit-card-number .card-no,[data-is="rg-credit-card-number"] .card-no{ padding-right: 60px; background-repeat: no-repeat; background-position: right center; background-size: 60px; } rg-credit-card-number .amex,[data-is="rg-credit-card-number"] .amex{ background-image: url(img/amex.png); } rg-credit-card-number .diners_club,[data-is="rg-credit-card-number"] .diners_club{ background-image: url(img/diners_club.png); } rg-credit-card-number .discover,[data-is="rg-credit-card-number"] .discover{ background-image: url(img/discover.png); } rg-credit-card-number .jcb,[data-is="rg-credit-card-number"] .jcb{ background-image: url(img/jcb.png); } rg-credit-card-number .mastercard,[data-is="rg-credit-card-number"] .mastercard{ background-image: url(img/mastercard.png); } rg-credit-card-number .visa,[data-is="rg-credit-card-number"] .visa{ background-image: url(img/visa.png); }',"",function(opts){"use strict";var _this2=this;if(!opts.card)opts.card={cardnumber:""};this.on("update",function(){if(_this2.cardnumber.value!=opts.card.cardnumber)_this2.cardnumber.value=opts.card.cardnumber;_this2.validate()});this.validate=function(){opts.card.cardnumber=_this2.cardnumber.value;var res=validateCreditCard(opts.card.cardnumber);opts.card.valid=res.valid;_this2.icon=opts.card.valid?res.card_type.name:""};function validateCreditCard(input){var __indexOf=[].indexOf||function(item){for(var i=0,l=this.length;i<l;i++){if(i in this&&this[i]===item)return i}return-1};var card,card_type,card_types,get_card_type,is_valid_length,is_valid_luhn,normalize,validate,validate_number,_i,_len,_ref;card_types=[{name:"amex",icon:"images/amex.png",pattern:/^3[47]/,valid_length:[15]},{name:"diners_club",icon:"images/diners_club.png",pattern:/^30[0-5]/,valid_length:[14]},{name:"diners_club",icon:"images/diners_club.png",pattern:/^36/,valid_length:[14]},{name:"jcb",icon:"images/jcb.png",pattern:/^35(2[89]|[3-8][0-9])/,valid_length:[16]},{name:"laser",pattern:/^(6304|670[69]|6771)/,valid_length:[16,17,18,19]},{name:"visa_electron",pattern:/^(4026|417500|4508|4844|491(3|7))/,valid_length:[16]},{name:"visa",icon:"images/visa.png",pattern:/^4/,valid_length:[16]},{name:"mastercard",icon:"images/mastercard.png",pattern:/^5[1-5]/,valid_length:[16]},{name:"maestro",pattern:/^(5018|5020|5038|6304|6759|676[1-3])/,valid_length:[12,13,14,15,16,17,18,19]},{name:"discover",icon:"images/discover.png",pattern:/^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,valid_length:[16]}];var options={};if(options.accept==null){options.accept=function(){var _i,_len,_results;_results=[];for(_i=0,_len=card_types.length;_i<_len;_i++){card=card_types[_i];_results.push(card.name)}return _results}()}_ref=options.accept;for(_i=0,_len=_ref.length;_i<_len;_i++){card_type=_ref[_i];if(__indexOf.call(function(){var _j,_len1,_results;_results=[];for(_j=0,_len1=card_types.length;_j<_len1;_j++){card=card_types[_j];_results.push(card.name)}return _results}(),card_type)<0){throw"Credit card type '"+card_type+"' is not supported"}}get_card_type=function get_card_type(number){var _j,_len1,_ref1;_ref1=function(){var _k,_len1,_ref1,_results;_results=[];for(_k=0,_len1=card_types.length;_k<_len1;_k++){card=card_types[_k];if(_ref1=card.name,__indexOf.call(options.accept,_ref1)>=0){_results.push(card)}}return _results}();for(_j=0,_len1=_ref1.length;_j<_len1;_j++){card_type=_ref1[_j];if(number.match(card_type.pattern)){return card_type}}return null};is_valid_luhn=function is_valid_luhn(number){var digit,n,sum,_j,_len1,_ref1;sum=0;_ref1=number.split("").reverse();for(n=_j=0,_len1=_ref1.length;_j<_len1;n=++_j){digit=_ref1[n];digit=+digit;if(n%2){digit*=2;if(digit<10){sum+=digit}else{sum+=digit-9}}else{sum+=digit}}return sum%10===0};is_valid_length=function is_valid_length(number,card_type){var _ref1;return _ref1=number.length,__indexOf.call(card_type.valid_length,_ref1)>=0};validate_number=function(_this){return function(number){var length_valid,luhn_valid;card_type=get_card_type(number);luhn_valid=false;length_valid=false;if(card_type!=null){luhn_valid=is_valid_luhn(number);length_valid=is_valid_length(number,card_type)}return{card_type:card_type,valid:luhn_valid&&length_valid,luhn_valid:luhn_valid,length_valid:length_valid}}}(this);normalize=function normalize(number){return number.replace(/[ -]/g,"")};validate=function(_this){return function(){return validate_number(normalize(input))}}(this);return validate(input)}});riot.tag2("rg-date",'<div class="container"> <input type="text" class="field" onclick="{open}" riot-value="{opts.date.date.format(format)}" readonly> <div class="calendar calendar--high" if="{opts.date.isvisible}"> <button class="calendar__control" disabled="{opts.date.min.isSame(opts.date.date, \'year\')}" onclick="{prevYear}">‹</button> <div class="calendar__header">{opts.date.date.format(yearFormat)}</div> <button class="calendar__control" disabled="{opts.date.max.isSame(opts.date.date, \'year\')}" onclick="{nextYear}">›</button> <button class="calendar__control" disabled="{opts.date.min.isSame(opts.date.date, \'month\')}" onclick="{prevMonth}">‹</button> <div class="calendar__header">{opts.date.date.format(monthFormat)}</div> <button class="calendar__control" disabled="{opts.date.max.isSame(opts.date.date, \'month\')}" onclick="{nextMonth}">›</button> <div class="calendar__day">Mo</div> <div class="calendar__day">Tu</div> <div class="calendar__day">We</div> <div class="calendar__day">Th</div> <div class="calendar__day">Fr</div> <div class="calendar__day">Sa</div> <div class="calendar__day">Su</div> <button class="calendar__date {\'calendar__date--selected\': day.selected, \'calendar__date--today\': day.today}" disabled="{day.disabled}" each="{day in startBuffer}" onclick="{select}">{day.date.format(dayFormat)}</button> <button class="calendar__date calendar__date--in-month {\'calendar__date--selected\': day.selected, \'calendar__date--today\': day.today}" disabled="{day.disabled}" each="{day in days}" onclick="{select}">{day.date.format(dayFormat)}</button> <button class="calendar__date {\'calendar__date--selected\': day.selected, \'calendar__date--today\': day.today}" disabled="{day.disabled}" each="{day in endBuffer}" onclick="{select}">{day.date.format(dayFormat)}</button> <button class="button button--block button--primary" disabled="{opts.date.min.isAfter(moment(), \'day\') || opts.date.max.isBefore(moment(), \'day\')}" onclick="{setToday}">Today</button> </div> </div>','rg-date .container,[data-is="rg-date"] .container{ position: relative; display: inline-block; cursor: pointer; } rg-date .calendar,[data-is="rg-date"] .calendar{ position: absolute; min-width: 300px; margin-top: .5em; left: 0; }',"",function(opts){"use strict";var _this=this;var toMoment=function toMoment(d){if(!moment.isMoment(d))d=moment(d);if(d.isValid())return d;return moment()};var handleClickOutside=function handleClickOutside(e){if(!_this.root.contains(e.target))_this.close();_this.update()};var dayObj=function dayObj(dayDate){var dateObj=dayDate||moment();return{date:dateObj,selected:opts.date.date.isSame(dayDate,"day"),today:moment().isSame(dayDate,"day"),disabled:opts.date.min&&opts.date.min.isAfter(dayDate)||opts.date.max&&opts.date.max.isBefore(dayDate)}};var buildCalendar=function buildCalendar(){_this.format="LL";_this.yearFormat="YYYY";_this.monthFormat="MMMM";_this.dayFormat="DD";_this.days=[];_this.startBuffer=[];_this.endBuffer=[];var begin=moment(opts.date.date).startOf("month");var daysInMonth=moment(opts.date.date).daysInMonth();var end=moment(opts.date.date).endOf("month");for(var i=begin.isoWeekday()-1;i>0;i-=1){var d=moment(begin).subtract(i,"days");_this.startBuffer.push(dayObj(d))}for(var _i=0;_i<daysInMonth;_i++){var current=moment(begin).add(_i,"days");_this.days.push(dayObj(current))}for(var _i2=end.isoWeekday()+1;_i2<=7;_i2++){var _d=moment(end).add(_i2-end.isoWeekday(),"days");_this.endBuffer.push(dayObj(_d))}};this.on("mount",function(){if(!opts.date)opts.date={date:moment()};if(!opts.date.date)opts.date.date=moment();opts.date.date=toMoment(opts.date.date);if(opts.date.min){opts.date.min=toMoment(opts.date.min);if(opts.date.min.isAfter(moment(),"day")){opts.date.date=moment(opts.date.min)}}if(opts.date.max){opts.date.max=toMoment(opts.date.max);if(opts.date.max.isBefore(moment(),"day")){opts.date.date=moment(opts.date.max)}}_this.on("update",function(){opts.date.date=toMoment(opts.date.date);buildCalendar();positionDropdown()});document.addEventListener("click",handleClickOutside);_this.update()});this.on("unmount",function(){document.removeEventListener("click",handleClickOutside)});this.open=function(){opts.date.isvisible=true;_this.trigger("open")};this.close=function(){if(opts.date.isvisible){opts.date.isvisible=false;_this.trigger("close")}};this.select=function(e){opts.date.date=e.item.day.date;_this.trigger("select",opts.date.date)};this.setToday=function(){opts.date.date=moment();_this.trigger("select",opts.date.date)};this.prevYear=function(){opts.date.date=opts.date.date.subtract(1,"year")};this.nextYear=function(){opts.date.date=opts.date.date.add(1,"year")};this.prevMonth=function(){opts.date.date=opts.date.date.subtract(1,"month")};this.nextMonth=function(){opts.date.date=opts.date.date.add(1,"month")};function getWindowDimensions(){var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName("body")[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;return{width:x,height:y}}var positionDropdown=function positionDropdown(){var w=getWindowDimensions();var m=_this.root.querySelector(".calendar");if(!m)return;if(!opts.date.isvisible){m.style.marginTop="";m.style.marginLeft="";return}var pos=m.getBoundingClientRect();if(w.width<pos.left+pos.width){m.style.marginLeft=w.width-(pos.left+pos.width)-20+"px"}if(pos.left<0){m.style.marginLeft="20px"}if(w.height<pos.top+pos.height){m.style.marginTop=w.height-(pos.top+pos.height)-20+"px"}}});riot.tag("rg-drawer",'<div class="c-overlay c-overlay--dismissable" if="{opts.isvisible}" onclick="{close}"></div>'+" <div class=\"o-drawer u-highest {'o-drawer--' + opts.position || 'c-drawer--top'} {'o-drawer--visible': opts.isvisible}\">"+' <div class="c-card">'+' <header class="c-card__header">'+'<h2 class="c-heading c-heading--xsmall">{opts.header}'+'<div class="c-heading__sub">{opts.subheading}</div>'+"</h2>"+"</header>"+' <ul class="c-card--menu"> <li class="c-card__item {\'c-card__item--active\': active}" each="{opts.items}" onclick="{parent.select}"> {text} </li> </ul>'+' <div class="c-card__body"> <yield></yield> </div>'+"</div>"+'<div class="c-card__footer">'+'<div class="c-input-group"> <button class="c-button c-button--block" each="{opts.footer.items}" onclick="{parent.select}"> {text} </button>'+" </div></div></div>","","",function(opts){var _this=this;this.on("before-mount",function(){if(!opts.footer){footer:[]}});this.close=function(){opts.isvisible=false;_this.trigger("close")};this.select=function(e){opts.items.forEach(function(item){return item.active=false});e.item.active=true;_this.trigger("select",e.item)}});riot.tag2("rg-ga","","","",function(opts){"use strict";(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date;a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");ga("create",opts.property,"auto");ga("send","pageview")});riot.tag2("rg-html",'<span class="rg-html"></span>',"","",function(opts){"use strict";debugger;if(!opts.html)opts.html={};if(!opts.html.content)opts.html.content=this.root._innerHTML;if(!opts.content&&this.root._innerHTML)opts.html.content=this.root._innerHTML;if(opts.content)opts.html.content=opts.content;this.root.innerHTML=typeof opts.html.content==="undefined"?"":opts.html.content});riot.tag2("rg-iframify",'<div class="iframify"> <div class="frame"> <yield></yield> </div> </div>','rg-iframify .iframify,[data-is="rg-iframify"] .iframify{ margin: 0; padding: 0; } rg-iframify iframe,[data-is="rg-iframify"] iframe{ position: relative; width: 100%; border: 0; }',"",function(opts){"use strict";var _this=this;this.on("mount",function(){iframify(_this.root.querySelector(".frame"),_this.opts)})});riot.tag2("rg-include","<div> {responseText} </div>","","",function(opts){"use strict";var _this=this;var fetch=function fetch(){var req=new XMLHttpRequest;req.onload=function(resp){if(opts.include.unsafe)_this.root.innerHTML=req.responseText;else _this.responseText=req.responseText;_this.update();_this.trigger("loaded")};req.open("get",opts.include.url,true);req.send();_this.trigger("loading")};this.on("mount",function(){fetch()})});riot.tag2("rg-map",'<div class="rg-map"></div>','rg-map .rg-map,[data-is="rg-map"] .rg-map{ margin: 0; padding: 0; width: 100%; height: 100%; } rg-map .rg-map img,[data-is="rg-map"] .rg-map img{ max-width: inherit; }',"",function(opts){"use strict";var _this=this;window.rg=window.rg||{};window.rg.gmap=riot.observable({initialize:function initialize(){window.rg.gmap.trigger("initialize")}});this.on("mount",function(){if(!opts.map)opts.map={center:{lat:53.806,lng:-1.535},zoom:7};rg.gmap.on("initialize",function(){opts.map.mapObj=new google.maps.Map(_this.root.querySelector(".rg-map"),opts.map);_this.trigger("loaded",opts.map.mapObj)});if(!document.getElementById("gmap_script")){var script=document.createElement("script");script.setAttribute("id","gmap_script");script.type="text/javascript";script.src="https://maps.googleapis.com/maps/api/js?callback=window.rg.gmap.initialize";document.body.appendChild(script)}})});riot.tag2("rg-markdown","","","",function(opts){"use strict";var _this=this;if(commonmark){this.reader=new commonmark.Parser;this.writer=new commonmark.HtmlRenderer}this.on("update",function(){if(!opts.markdown)opts.markdown={};if(opts.markdown.content){_this.root.innerHTML=_this.writer.render(_this.reader.parse(opts.markdown.content))}else if(opts.markdown.url){var req=new XMLHttpRequest;req.onload=function(resp){_this.root.innerHTML=_this.writer.render(_this.reader.parse(req.responseText));_this.trigger("loaded")};req.open("get",opts.markdown.url,true);req.send();_this.trigger("loading")}})});riot.tag2("rg-modal",'<div class="overlay {overlay--dismissable: opts.modal.dismissable}" if="{opts.modal.isvisible}" onclick="{close}"></div> <div class="modal {modal--ghost: opts.modal.ghost}" if="{opts.modal.isvisible}"> <header class="modal__header"> <button if="{opts.modal.dismissable}" type="button" class="button button--close" onclick="{close}"> &times; </button> <h3 class="heading heading--small">{opts.modal.heading}</h3> </header> <div class="modal__body"> <yield></yield> </div> <footer class="modal__footer {\'modal__footer--block\': !opts.modal.ghost}"> <button each="{opts.modal.buttons}" type="button" class="button {\'button--\' + type}" onclick="{action}" riot-style="{style}"> {text} </button> </footer> </div>','rg-modal .modal--ghost .modal__footer .button,[data-is="rg-modal"] .modal--ghost .modal__footer .button{ margin: 0 .5em 0 0; }',"",function(opts){"use strict";var _this=this;this.on("mount",function(){if(!opts.modal)opts.modal={}});this.close=function(){if(opts.modal.dismissable){opts.modal.isvisible=false;_this.trigger("close")}}});riot.tag2("rg-pagination",'<div class="pagination"> <div class="pagination__controls pagination__controls--backward"> <button class="pagination__control" disabled="{opts.pagination.page <= 1}" onclick="{first}">«</button> <button class="pagination__control" disabled="{opts.pagination.page <= 1}" onclick="{back}">‹</button> </div> <div class="pagination__controls"> <span class="pagination__ellipsis" if="{opts.pagination.page > 2}">&hellip;</span> <button class="pagination__page" onclick="{back}" if="{opts.pagination.page > 1}">{opts.pagination.page - 1}</button> <button class="pagination__page pagination__page--current">{opts.pagination.page}</button> <button class="pagination__page" onclick="{forward}" if="{opts.pagination.page < opts.pagination.pages}">{opts.pagination.page + 1}</button> <span class="pagination__ellipsis" if="{opts.pagination.page < opts.pagination.pages - 1}">&hellip;</span> </div> <div class="pagination__controls pagination__controls--forward"> <button class="pagination__control" disabled="{opts.pagination.page >= opts.pagination.pages}" onclick="{forward}">›</button> <button class="pagination__control" disabled="{opts.pagination.page >= opts.pagination.pages}" onclick="{last}">»</button> </div> </div>',"","",function(opts){"use strict";var _this=this;this.on("update",function(){if(!opts.pagination)opts.pagination={pages:1,page:1}});this.on("page",function(){var btns=_this.root.querySelectorAll("button");for(var i=0;i<btns.length;i++){btns[i].blur()}});this.forward=function(){opts.pagination.page++;_this.trigger("page",opts.pagination.page)};this.back=function(){opts.pagination.page--;_this.trigger("page",opts.pagination.page)};this.first=function(){opts.pagination.page=1;_this.trigger("page",opts.pagination.page)};this.last=function(){opts.pagination.page=opts.pagination.pages;_this.trigger("page",opts.pagination.page)}});riot.tag2("rg-phone-sim",'<div class="emulator"> <iframe class="screen" riot-src="{opts.phonesim.url}"></iframe> </div>','rg-phone-sim .emulator,[data-is="rg-phone-sim"] .emulator{ position: relative; width: 365px; height: 792px; background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAW0AAAMYCAMAAAA3r0ZLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAwBQTFRFMDk6+vr6KTM0lJucMz4/PklKJS8wLTg5Qk1OxsjILzo7gomJ2NvbdH5/ho2O9fb2KzY3ztHRPEdIOkVGZWxtjJSVOEJDkpeYWGRluL2+KTQ1vcHBoaWlPUZHcnp6nKKjOkRF1NfXqa2tp62tZnBxanV2VmFiZ29wVl1eaXJzbXR04uTktbq7QElK1tnZipKTi5CRTlZXpKioo6mqXmlqUVlaOEFCSVFSUFxdISssT1tcTlpbJC4vIiwtTVlaJjAxIy0uTFhZS1dYJzEyKDIzSlZXPUhJOURFO0ZHSVVWKzU2P0pLKjQ1OENEND0+QEtMLDY3SFRVN0JDQ05PLTc4ND9ANUBBQUxNNkFCR1NUMTo7RE9QLjg5N0BBR1JTRlJTLzk6RVFSMjs8RVBRRlFSNj9AMzw9SFNUMj0+IissMTs8MDo7SVRVRFBRMDs8MTw9IiwsMz0+Mjw9SlVWQ09QLjk6NT4/S1ZXND4/JC4uQU1OIy0tQk5PTFdYTVhZQExNTllaJS8vJzIyP0tMLzg5LDc4KDMzNT9AKjU1N0FCNkBBJjAwIywtMDs7Mj09NkFBJjExLjk5LDc3N0JCNUBAKjU2MTw8LDU2Ljc4OUNEKDEyQU1NPEhIPEhJO0dHOkZGND8/Qk5ORFBQQ09PLTY3OUREPkpKPkpLPUlJT1pbP0tLJTAwPUlKJzAxKjM07u/vKTIzsbW2YGprtLm50tXWPkhJo6endn+A3d/f6uvreoOEg4yN2tvc/Pz8n6am8/T0VFtcm6CgJS4v4OLi5ufnYGdncnt8dHp7gYaHJC0uu8DAjJGRQkxNxMfHKzQ1YGtsS1NUaXN0bnh5yMzMyszMy83Oy8/PdoCAKDIy7O3tT1dYuLu70NTUbXd46Onq6erreoCA2dzc8PHx8vPz5OXlnaSkn6Wmqq6ucHZ2t7y8o6eoeoSEkJaWm5+gW2ZnZG5vqa+wOEFB09bWtru7qrCwcXd4t7u83eDgzM7O7/DwNT4+7e7uwMPDwcPEeH5/////70wnUQAAAQB0Uk5T////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////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VeLdrD+WxCZVx3J9ba0QNeAnj9T/twuOi87GcF9pLSdKM8U7Q2rV6+O0jcQMoXJJB2t96tzorzB99Y2NzfPjdQL9zLJZDJynw2YK85rvZ1ku9Cjuq+4xXknb4Js+XxU/WsQ5wnec7LlDcn6d544P+ddLFu+zlT/Vorzxd5k2fIJqfq3TJwney/Lls+RGBwniPPL3g6y5aOWBstWcd7BmypbLjhS/1LiPNWTTTMWBik02mijTWijTWijjTbFVTuZTqSTRW8OUzqJdpGyxT89mU2ELYv25kO4+LvnyUT4kmj3LV38YzjpGmin3dReIm2pF9BlU+LmMDmnrdBbUntQje0trj2o5m2FPlBiTWKQQm9R7cG03nZAexCFNtpoE9poE9poo01oo01oo01oo4021VT7MxIUBik02mijTeG1D5agMEih0UYbbUIbbUIbbbQJbbQJbbQJbbTRplppf1qCwiCFRhtttCm89lwJCoMUGm200Sa00Sa00Uab0Eab0Eab0EY73tqnS1AYpNBoo402hdc+VILCIIVGG220CW20CW200Sa00Sa00aYC9GkSFAYpNNpoo01oR0v7bRIUBik02mijTWijTWijjTahjTah7bL2hyUoDFJotNFGm9BGm0ppv0OCwiCFRhtttAlttAlttNEmtOOhfbwEhUEKjTbaaBPaaBPaLmi/T4LCIIVGG220CW20CW200ab6aS+UoDBIodFGG21CG21C2wXt4yQoDFJotNFGm9BGm9BGe7BpL5KgMEih0UYbbUIbbULbBe0PSFAYpNBoo402oY02oY32YNP+oASFQQqNNtpoE9poE9poDzbtj0hQGKTQaKONNqGNNpXS/qkEhUEKfYwEhUEKjTbaaBPaaBPaaA827Y9LUBik0GijjTahHS3tn0lQGKTQCyQoDFJotNFGm9BGm9BGG22qn/anJCgMUmi00Uabwmv/RILCIIVukKAwSKHRRhttQhttQhtttKl+2p+UoDBIodFGG20Kr/09CQqDFPo9EhQGKTTaaKNNaKNNaKONNtVP+7MSFAYpNNpoo03htY+UoDBIodFGG21CG21CG220Ce14aH9egsIghUYb7bhq/1qCwiCFPlyCwiCFRhtttAlttAlttNEmt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N2h7d8sv7l44bRUxddwcPPLe8PF92a/U3uM/NayymnuKF+fZFXAO6ZL23/C0cEdj2vvBEP7Cb9be2KLozN3HK4rFczaLRN7aPuvOros8WJwzbRgQfKq31N7ROC/xs1Xu/n1ALNRuh7gkID23l7a/p5y05xjPfeHd9Sudblijsi+6PfWvjApNzr7z3pG+DquB4nrjG36aPu/d3gu8aJ7jeI1Aetefl9t/wVXF91dy+piAzzt9vW3dan9N39z7cdODdYlrS6/9shdW741WI+c+lgRbf/5FlePcfpMKtH5dxOC45qW5/1i2v7I4L42j2pVWwA60i+u7Y8N7l2HUo1aF3CO9Utpb7VbcP8QnGp3WLPbViW1/Uv2gbum2Ptc4pfW9v/ZGDxmHlahmxdANt7r96ft/0+521vhCrf0a1fs//r9a/u3zjhZumoFYmFOjlwVIM641R9I239ldvDIxcsxq7rliwPC2a/4A2v7D14bPPbkNmaTKmeRNvW79kG/HG3fn6wPP5PhXdXAPlP1JheDLartX6lPOPlsZu+KZ+z2At2Vfvna/pjdTtCYTiqcRApsV6z3K9H2/fGF553Txvgue1y3nVNAG18KtaS2P2Ja4akntDN/lzVft3d4vXGEX7m27+81q+P5N7atQrPfVrXd2GE1a69+RPvTlr3lHft11NJ+BFNKiQnkiPaWTqY7/tivZ//avn/+7P26ahl+yJD5q1a0sufUPWLrilXzhxwyvKUbaPb5A2gOpC3z956N+9HANe05YkDLgbWlh0fOQLPfZox8uBzIsrSlC6Zcj3gJ6eunXFCmYrnaQWtHTLph7EONresQlta1Nj409oZJI9ZWIPh/AQYA2whzWlA9R/cAAAAASUVORK5CYII=\'); background-repeat: no-repeat; background-position: center; background-size: cover; } rg-phone-sim .screen,[data-is="rg-phone-sim"] .screen{ position: absolute; top: 105px; left: 22px; background-color: white; width: 320px; height: 568px; border: 0; }',"",function(opts){});
  riot.tag2("rg-placeholdit",'<img riot-src="https://placeholdit.imgix.net/~text?bg={opts.placeholdit.background}&txtclr={opts.placeholdit.color}&txt={opts.placeholdit.text}&txtsize={opts.placeholdit.textsize}&w={opts.placeholdit.width}&h={opts.placeholdit.height}&fm={opts.placeholdit.format}">',"","",function(opts){"use strict";this.on("update",function(){if(!opts.placeholdit)opts.placeholdit={};opts.placeholdit.width=opts.placeholdit.width||450;opts.placeholdit.height=opts.placeholdit.height||250;opts.placeholdit.background=opts.placeholdit.background||"000";opts.placeholdit.color=opts.placeholdit.color||"fff";opts.placeholdit.text=opts.placeholdit.text||opts.placeholdit.width+" x "+opts.placeholdit.height;opts.placeholdit.textsize=opts.placeholdit.textsize||30;opts.placeholdit.format=opts.placeholdit.format||"png"})});riot.tag2("rg-raw","<span></span>","","",function(opts){"use strict";this.on("mount update",function(){this.root.innerHTML=opts.content||""})});riot.tag2("rg-select",'<input type="{opts.select.filter ? \'search\' : \'text\'}" name="selectfield" class="field" placeholder="{opts.select.placeholder}" onkeydown="{navigate}" oninput="{filterOptions}" onfocus="{open}" readonly="{!opts.select.filter}"> <ul class="menu menu--high" if="{opts.select.isvisible}"> <li each="{options}" no-reorder onclick="{parent.select}" class="menu__item {\'menu__item--active\': selected, \'menu__item--disabled\': disabled, \'menu__item--hover\': active}"> {text} </li> </ul>','rg-select .menu,[data-is="rg-select"] .menu{ position: absolute; }',"",function(opts){"use strict";var _this=this;if(!opts.select)opts.select={options:[]};var handleClickOutside=function handleClickOutside(e){if(!_this.root.contains(e.target))_this.close();_this.update()};var applyFieldText=function applyFieldText(){for(var i=0;i<opts.select.options.length;i++){var item=opts.select.options[i];if(item.selected){_this.selectfield.value=item.text;break}}};this.filterOptions=function(){_this.options=opts.select.options;if(opts.select.filter)_this.options=_this.options.filter(function(option){var attr=option[opts.select.filter];return attr&&attr.toLowerCase().indexOf(_this.selectfield.value.toLowerCase())>-1});_this.trigger("filter",_this.selectfield.value)};function getWindowDimensions(){var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName("body")[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;return{width:x,height:y}}var positionDropdown=function positionDropdown(){var w=getWindowDimensions();var m=_this.root.querySelector(".menu");if(!m)return;if(!opts.select.isvisible){m.style.marginTop="";m.style.marginLeft="";return}var pos=m.getBoundingClientRect();if(w.width<pos.left+pos.width){m.style.marginLeft=w.width-(pos.left+pos.width)-20+"px"}if(pos.left<0){m.style.marginLeft="20px"}if(w.height<pos.top+pos.height){m.style.marginTop=w.height-(pos.top+pos.height)-20+"px"}};this.navigate=function(e){if([13,38,40].indexOf(e.keyCode)>-1&&!opts.select.isvisible){e.preventDefault();_this.open();return true}var length=_this.options.length;if(length>0&&[13,38,40].indexOf(e.keyCode)>-1){e.preventDefault();var activeIndex=null;for(var i=0;i<length;i++){var item=_this.options[i];if(item.active){activeIndex=i;break}}if(activeIndex!=null)_this.options[activeIndex].active=false;if(e.keyCode==38){if(activeIndex==null||activeIndex==0)_this.options[length-1].active=true;else _this.options[activeIndex-1].active=true}else if(e.keyCode==40){if(activeIndex==null||activeIndex==length-1)_this.options[0].active=true;else _this.options[activeIndex+1].active=true}else if(e.keyCode==13&&activeIndex!=null){_this.select({item:_this.options[activeIndex]})}}return true};this.open=function(){opts.select.isvisible=true;_this.trigger("open")};this.close=function(){if(opts.select.isvisible){opts.select.isvisible=false;_this.trigger("close")}};this.select=function(e){opts.select.options.forEach(function(i){return i.selected=false});e.item.selected=true;applyFieldText();_this.filterOptions();opts.select.isvisible=false;_this.trigger("select",e.item)};this.on("mount",function(){applyFieldText();_this.filterOptions();document.addEventListener("click",handleClickOutside);_this.update()});this.on("update",function(){if(!opts.select.filter)applyFieldText();positionDropdown()});this.on("unmount",function(){document.removeEventListener("click",handleClickOutside)})});riot.tag2("rg-tabs",'<div class="tabs {\'tabs--\' + opts.tabs.type}"> <div class="tabs__headings"> <div each="{opts.tabs.tabs}" class="tab-heading {\'tab-heading--active\': active, \'tab-heading--disabled\': disabled}" onclick="{parent.open}"> {heading} </div> </div> <div each="{opts.tabs.tabs}" class="tabs__tab {\'tabs__tab--active\': active}"> <div if="{text}"> {text} </div> <div if="{include}"> {include.responseText} </div> </div> </div>',"","",function(opts){"use strict";var _this=this;var fetch=function fetch(tab){var req=new XMLHttpRequest;req.onload=function(resp){var activeTab=_this.root.querySelector(".tabs__tab--active");if(activeTab)activeTab.innerHTML=req.responseText;_this.trigger("loaded",tab)};req.open("get",tab.include,true);req.send();_this.trigger("loading",tab)};this.open=function(e){var tab=e.item;if(!tab.disabled&&!tab.active){opts.tabs.tabs.forEach(function(tab){tab.active=false});_this.trigger("open",tab);tab.active=true}};this.on("update",function(){if(!opts.tabs)opts.tabs={};if(!Array.isArray(opts.tabs.tabs))return;opts.tabs.tabs.forEach(function(tab){if(!tab.disabled&&tab.active&&tab.include){fetch(tab)}})})});riot.tag2("rg-tags",'<div class="tags"> <span class="tags__container"> <button each="{opts.tags.tags}" onclick="{removeTag}" type="button" class="button button--primary tag"> {text} <span class="tag__close">×</span> </button> </span> <div class="tags__field-container"> <input type="{opts.tags.filter ? \'search\' : \'text\'}" name="selectfield" class="field" placeholder="{opts.tags.placeholder}" onkeydown="{navigate}" oninput="{filterOptions}" onfocus="{open}" readonly="{!opts.tags.filter}"> <ul class="menu menu--high" if="{opts.tags.isvisible}"> <li each="{options}" no-reorder onclick="{parent.select}" class="menu__item {\'menu__item--active\': selected, \'menu__item--disabled\': disabled, \'menu__item--hover\': active}"> {text} </li> </ul> </div> </div>','rg-tags .menu,[data-is="rg-tags"] .menu{ position: absolute; }',"",function(opts){"use strict";var _this=this;if(!opts.tags)opts.tags={options:[],tags:[]};if(!opts.tags.options)opts.tags.options=[];if(!opts.tags.tags)opts.tags.tags=[];var handleClickOutside=function handleClickOutside(e){if(!_this.root.contains(e.target))_this.close();_this.update()};var applyFieldText=function applyFieldText(){_this.selectfield.value="";for(var i=0;i<opts.tags.options.length;i++){var item=opts.tags.options[i];item.selected=false}};this.filterOptions=function(){_this.options=opts.tags.options;if(opts.tags.filter)_this.options=_this.options.filter(function(option){var attr=option[opts.tags.filter];return attr&&attr.toLowerCase().indexOf(_this.selectfield.value.toLowerCase())>-1});_this.trigger("filter",_this.selectfield.value)};function getWindowDimensions(){var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName("body")[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;return{width:x,height:y}}var positionDropdown=function positionDropdown(){var w=getWindowDimensions();var m=_this.root.querySelector(".menu");if(!m)return;if(!opts.tags.isvisible){m.style.marginTop="";m.style.marginLeft="";return}var pos=m.getBoundingClientRect();if(w.width<pos.left+pos.width){m.style.marginLeft=w.width-(pos.left+pos.width)-20+"px"}if(pos.left<0){m.style.marginLeft="20px"}if(w.height<pos.top+pos.height){m.style.marginTop=w.height-(pos.top+pos.height)-20+"px"}};this.navigate=function(e){if([13,38,40].indexOf(e.keyCode)>-1&&!opts.tags.isvisible){e.preventDefault();_this.open();return true}var length=_this.options.length;if(length>0&&[13,38,40].indexOf(e.keyCode)>-1){e.preventDefault();var activeIndex=null;for(var i=0;i<length;i++){var item=_this.options[i];if(item.active){activeIndex=i;break}}if(activeIndex!=null)_this.options[activeIndex].active=false;if(e.keyCode==38){if(activeIndex==null||activeIndex==0)_this.options[length-1].active=true;else _this.options[activeIndex-1].active=true}else if(e.keyCode==40){if(activeIndex==null||activeIndex==length-1)_this.options[0].active=true;else _this.options[activeIndex+1].active=true}else if(e.keyCode==13&&activeIndex!=null){_this.select({item:_this.options[activeIndex]})}}return true};this.open=function(){opts.tags.isvisible=true;_this.trigger("open")};this.close=function(){if(opts.tags.isvisible){opts.tags.isvisible=false;_this.trigger("close")}};this.select=function(e){opts.tags.options.forEach(function(i){return i.selected=false});e.item.selected=true;_this.addTag(e.item);applyFieldText();_this.filterOptions();_this.trigger("select",e.item)};this.addTag=function(item){if(opts.tags.tags.indexOf(item)==-1){opts.tags.tags.push(item)}};this.removeTag=function(e){opts.tags.tags=opts.tags.tags.filter(function(tag){if(tag._id!=e.item._id)return tag})};this.on("mount",function(){applyFieldText();_this.filterOptions();document.addEventListener("click",handleClickOutside);_this.update()});this.on("update",function(){opts.tags.options.forEach(function(item){item._id=item._id||(Math.floor(Math.random()*60466175)+1679615).toString(36)});opts.tags.tags.forEach(function(tag){tag._id=tag._id||(Math.floor(Math.random()*60466175)+1679615).toString(36)});if(!opts.tags.filter)applyFieldText();positionDropdown()});this.on("unmount",function(){document.removeEventListener("click",handleClickOutside)})});riot.tag2("rg-toasts",'<div if="{opts.toasts.isvisible}" class="toasts {\'toasts--\' + opts.toasts.position}"> <div each="{opts.toasts.toasts}" class="toast {\'toast--\' + type}" if="{isvisible}" onclick="{parent.toastClicked}"> {text} </div> </div>',"","",function(opts){"use strict";var _this=this;this.toastClicked=function(e){var toast=e.item;window.clearTimeout(toast.timer);toast.isvisible=false;_this.trigger("select",toast)};var _uid=1;var uid=function uid(){return _uid++};this.on("update",function(){if(!opts.toasts||!Array.isArray(opts.toasts.toasts))return;opts.toasts.position=opts.toasts.position||"bottomright";opts.toasts.toasts.forEach(function(toast){if(typeof toast.isvisible=="undefined")toast.isvisible=true;toast.id=toast.id||uid();if(!toast.timer&&!toast.sticky){toast.startTimer=function(){toast.timer=window.setTimeout(function(){toast.isvisible=false;_this.trigger("close",toast);_this.update()},toast.timeout||6e3)};toast.startTimer()}});opts.toasts.isvisible=opts.toasts.toasts.filter(function(toast){return toast.isvisible}).length>0})});riot.tag2("rg-toggle",'<div class="toggle {\'toggle--\' + opts.toggle.type}"> <label class="toggle__wrapper"> <input type="checkbox" checked="{opts.toggle.checked}" onclick="{toggle}"> <div class="toggle__track"> <div class="toggle__handle"></div> </div> </label> </div>',"","",function(opts){"use strict";var _this=this;this.on("mount",function(){if(!opts.toggle)opts.toggle={checked:false}});this.toggle=function(){opts.toggle.checked=!opts.toggle.checked;_this.trigger("toggle",opts.toggle.checked)}});riot.tag2("rg-unsplash",'<img riot-src="https://unsplash.it/{opts.unsplash.greyscale}{opts.unsplash.width}/{opts.unsplash.height}/?{options}">',"","",function(opts){"use strict";var _this=this;this.on("update",function(){_this.options="";if(!opts.unsplash)opts.unsplash={};opts.unsplash.width=opts.unsplash.width||450;opts.unsplash.height=opts.unsplash.height||250;if(opts.unsplash.greyscale)opts.unsplash.greyscale="g/";if(opts.unsplash.random)_this.options+="random&";if(opts.unsplash.blur)_this.options+="blur&";if(opts.unsplash.image)_this.options+="image="+opts.unsplash.image+"&";if(typeof opts.unsplash.gravity!=="undefined")_this.options+="gravity="+opts.unsplash.gravity})});