var Sa=Object.defineProperty;var Ca=(t,n,s)=>n in t?Sa(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var rn=(t,n,s)=>Ca(t,typeof n!="symbol"?n+"":n,s);var Y,ts,Ta,He,ln,Pt,ns,Et,ss,pn,cn,Ma,It={},Lt=[],Ea=/^m(i|n|o|s|text|space)$/,un=Array.isArray,os=Lt.slice,Ve=Object.assign;function Ke(t){t&&t.parentNode&&t.remove()}function At(t,n,s,a,i){var l={type:t,props:n,key:s,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i||++ts,__i:-1,__u:0};return!i&&Y.vnode&&Y.vnode(l),l}function z(t){return t.children}function Rt(t,n){this.props=t,this.context=n,this.__g=0}function Oe(t,n){if(n==null)return t.__&&Oe(t.__,t.__i+1);for(var s;n<t.__k.length;n++)if((s=t.__k[n])&&s.__e)return s.__e;return typeof t.type!="function"||t.props.__P?null:Oe(t)}function as(t){if((t=t.__)&&t.__c&&!t.props.__P)return t.__e=null,t.__k.some(function(n){return n&&(t.__e=n.__e)}),as(t)}function Qn(t){(8&t.__g||(t.__g|=8,He.push(t),Pt++))&&ln==Y.debounceRendering||((ln=Y.debounceRendering)||queueMicrotask)(is)}function is(){var t,n,s,a,i,l,r,c,d;try{for(n=1;He.length;)He.length>n&&He.sort(ns),t=He.shift(),n=He.length,8&t.__g&&(a=void 0,i=void 0,l=(i=(s=t).__v).__e,r=[],c=[],(d=s.__P)&&((a=Ve({constructor:void 0},i)).__v=i.__v+1,Y.vnode&&Y.vnode(a),mn(d,a,i,s.__n,d.namespaceURI,32&i.__u?[l]:null,r,l||Oe(i),32&i.__u,c),a.__v=i.__v,a.__.__k[a.__i]=a,ds(r,a,c),i.__=i.__e=null,a.__e!=l&&as(a)))}finally{(Pt=He.length)&&(ln||queueMicrotask)(is)}}function rs(t,n,s,a,i,l,r,c,d,u,g){var h,v,p,y,w,f,b=a.__k||Lt,S=n.length;for(d=Aa(s,n,b,d,S),h=0;h<S;h++)(p=s.__k[h])!=null&&(v=~p.__i&&b[p.__i]||It,p.__i=h,f=mn(t,p,v,i,l,r,c,d,u,g),y=p.__e,(v.ref!=p.ref||8&v.__u)&&(v.ref&&hn(v.ref,null,p,v),p.ref&&g.push(p.ref,p.__c||y,p)),w=w||y,4&p.__u?(d=ls(p,d,t,!v.__v),v.__e&&(v.__e=null)):typeof p.type=="function"&&f!==void 0?d=f:y&&(d=y.nextSibling),p.__u&=-21);return s.__e=w,d}function Aa(t,n,s,a,i){var l,r,c,d,u,g,h,v,p,y=s.length,w=y,f=0,b=0,S=t.__k=Array(i);for(l=0;l<i;l++)(r=n[l])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r!="object"||r.constructor==String?r=S[l]=At(null,r):un(r)?r=S[l]=At(z,{children:r}):r.constructor===void 0&&r.__b?r=S[l]=At(r.type,r.props,r.key,r.ref,r.__v):S[l]=r,d=l+f,r.__=t,r.__b=t.__b+1,c=null,~(u=r.__i=Ra(r,s,d,w))&&(w--,(c=s[u])&&(c.__u|=2)),c&&c.__v?(r.__u|=16,u==d-1?f--:u==d+1?f++:u!=d&&(u>d?f--:f++,b=1)):(~u||(i>y?f--:i<y&&f++),typeof r.type!="function"&&(r.__u|=4))):S[l]=null;if(b){for(g=[],h=[],l=0;l<i;l++)if((r=S[l])&&16&r.__u){for(f=0,v=g.length;f<v;)g[p=f+v>>1]<r.__i?f=p+1:v=p;g[f]=r.__i,h[l]=f+1}for(f=g.length;l--;)h[l]&&(h[l]==f?f--:S[l].__u|=4)}if(w)for(l=0;l<y;l++)!(c=s[l])||2&c.__u||(c.__e==a&&(a=Oe(c)),gn(c,c));return a}function ls(t,n,s,a){var i,l,r,c;if(typeof t.type=="function"){if(t.props.__P)return n;if(i=t.__k)for(l=0;l<i.length;l++)i[l]&&(i[l].__=t,n=ls(i[l],n,s,!1));return n}for(n&&!n.parentNode&&(n=Oe(t))&&!n.parentNode&&(n=null),r=t.__e,c=n;c&&c.nodeType==8;)c=c.nextSibling;for(r!=c&&(!a&&s.moveBefore&&r.parentNode?s.moveBefore(r,n):s.insertBefore(r,n||null)),n=r;(n=n&&n.nextSibling)&&n.nodeType==8&&!n.data.startsWith("$s"););return n}function Ra(t,n,s,a){var i,l=t.key,r=t.type,c=n[s],d=c&&!(2&c.__u);if(c===null&&l==null||d&&l==c.key&&r==c.type)return s;if(a>(d?1:0)){for(i=s-1;i>=0;i--)if((c=n[i])&&!(2&c.__u)&&l==c.key&&r==c.type)return i;for(i=s+1;i<n.length;i++)if((c=n[i])&&!(2&c.__u)&&l==c.key&&r==c.type)return i}return-1}function es(t,n,s){s==null&&(s=""),n[0]=="-"?t.setProperty(n,s):t[n]=s}function Mt(t,n,s,a,i){var l,r;if(n=="style")if(typeof s=="string")t.style.cssText=s;else{if(typeof a=="string"&&(t.style.cssText=a=""),a)for(n in a)s&&n in s||es(t.style,n);if(s)for(n in s)a&&s[n]==a[n]||es(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")(t.__e||(t.__e={}))[n]=s,s&&a||(r=cn[n]||(cn[n]=Pa(n)),(t.__a||(t.__a={}))[n]=pn,l=n!=(n=n.replace(ss,"$1")),(n=n.slice(2))[0]<"a"&&(n=n.toLowerCase()),s?t.addEventListener(n,r,l):t.removeEventListener(n,r,l));else{if(i=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in t)try{return void(t[n]=s??"")}catch{}if(typeof s=="function")return;s==null||s===!1&&n[4]!="-"?t.removeAttribute(n):t.setAttribute(n,n=="popover"&&s==1?"":s)}}function Pa(t){return function(n){var s=this.__e;if(s){if(s=s[t],n[Et]==null)n[Et]=pn++;else if(n[Et]<this.__a[t])return;return s(Y.event?Y.event(n):n)}}}function mn(t,n,s,a,i,l,r,c,d,u){var g,h,v,p,y,w,f,b,S,E,$,A,x,k,L,N,D,H,M=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(d=32&s.__u,g=s.__c.__z)&&(n.__u|=d,h=l=[],g.nodeType==8?c=dn(g,l):l.push(g),c=l[0]||c),(g=Y.__b)&&g(n);e:if(typeof M=="function"){v=r.length;try{if(b=n.props,S=(g=M.prototype)&&g.render,E=(g=M.contextType)&&a[g.__c],$=g?E?E.props.value:g.__:a,(p=s.__c)?(n.__c=p,2&p.__g&&(p.__g|=1)):(S?n.__c=p=new M(b,$):(n.__c=p=new Rt(b,$),p.constructor=M,p.render=La),E&&E.sub(p),p.state||(p.state={}),p.__n=a,p.__g|=8,p.__h=[],p.__k=[]),S&&(p.__s||(p.__s=p.state),M.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=Ve({},p.__s)),Ve(p.__s,M.getDerivedStateFromProps(b,p.__s)))),y=p.props,w=p.state,p.__v=n,s.__c){if(b!==y&&S&&!M.getDerivedStateFromProps&&p.componentWillReceiveProps&&p.componentWillReceiveProps(b,$),n.__v==s.__v&&!(8&p.__g)||!(4&p.__g)&&p.shouldComponentUpdate&&p.shouldComponentUpdate(b,p.__s,$)===!1){n.__v!=s.__v&&(p.props=b,p.state=p.__s,p.__g&=-9),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(C){C&&(C.__=n)}),Lt.push.apply(p.__h,p.__k),p.__k=[],p.__h.length&&r.push(p),c=Oe(s);break e}p.componentWillUpdate&&p.componentWillUpdate(b,p.__s,$),S&&p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(y,w,f)})}else S&&!M.getDerivedStateFromProps&&p.componentWillMount&&p.componentWillMount(),S&&p.componentDidMount&&p.__h.push(p.componentDidMount);if(p.context=$,p.props=b,p.__P=t,p.__g&=-5,A=Y.__r,x=0,S)p.state=p.__s,p.__g&=-9,A&&A(n),g=p.render(p.props,p.state,p.context),Lt.push.apply(p.__h,p.__k),p.__k=[];else do p.__g&=-9,A&&A(n),g=p.render(p.props,p.state,p.context),p.state=p.__s;while(8&p.__g&&++x<25);p.state=p.__s,p.getChildContext&&(a=Ve({},a,p.getChildContext())),S&&s.__c&&p.getSnapshotBeforeUpdate&&(f=p.getSnapshotBeforeUpdate(y,w)),k=g&&g.type===z&&g.key==null?g.props.children:g,b.__P&&(g=c,i=(t=b.__P).namespaceURI,d=l=null,s.props&&s.props.__P!=t&&(s.__k.some(function(C){C&&gn(C,C)}),s.__k=null),c=s.__k?Oe(s,0):null),c=rs(t,un(k)?k:[k],n,s,a,i,l,r,c,d,u),b.__P&&(n.__e=null,c=g),n.__u&=-161,h&&h.some(Ke),p.__h.length&&r.push(p),1&p.__g&&(p.__g&=-4)}catch(C){if(r.length=v,n.__v=null,d||l)if(C.then){if(L=0,n.__u|=128|d,l){for(~(D=l.indexOf(c||void 0))||(D=l.length);(H=l[D-1])&&H.nodeType==8;)D--;for(;D<l.length;D++)if(H=l[D]){if(l[D]=null,H.nodeType==8){if(H.data.startsWith("$s"))L++||(N=H);else if(L&&H.data.startsWith("/$s")&&!--L)break}else if(!L)break}}if(!N){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;N=c}(g=dn(N=n.__c.__z||(n.__c.__z=N)))?(n.__e=N,c=g):n.__e=c,c=c&&c.nextSibling}else l&&l.some(Ke);else n.__e=s.__e;n.__k||(n.__k=s.__k||[]),C.then||cs(n),Y.__e(C,n,s)}}else c=n.__e=Ia(s.__e,n,s,a,i,l,r,d,u,t);return(g=Y.diffed)&&g(n),c}function dn(t,n){if(t&&t.nodeType==8&&t.data.startsWith("$s"))for(var s=1;t=t.nextSibling;){if(t.nodeType==8){if(t.data.startsWith("$s"))s++;else if(t.data.startsWith("/$s")&&!--s)return t}n&&n.push(t)}}function cs(t){t&&(t.__c&&(t.__c.__g|=4),t.__k&&t.__k.some(cs))}function ds(t,n,s){for(var a=0;a<s.length;)hn(s[a++],s[a++],s[a++]);Y.__c&&Y.__c(n,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(l){l.call(i)})}catch(l){Y.__e(l,i.__v)}})}function Ia(t,n,s,a,i,l,r,c,d,u){var g,h,v,p,y,w,f,b,S,E=s.props||It,$=n.props,A=n.type;if(A=="svg"?i="http://www.w3.org/2000/svg":A=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),l){for(g=0;g<l.length;g++)if((y=l[g])&&(A?y.localName==A:y.nodeType==3)){t=y,l[g]=null;break}}if(!t){if(b=u.ownerDocument||document,!A)return b.createTextNode($);t=b.createElementNS(i,A,$.is&&$),c&&(Y.__m&&Y.__m(n,l),c=!1),l=null}if(A){if(u=A=="template"?t.content:t,l=A=="textarea"&&$.defaultValue!=null?null:l&&os.call(u.childNodes),!c&&l)for(E={},g=0;g<t.attributes.length;g++)E[(y=t.attributes[g]).name]=y.value;for(g in E)y=E[g],g=="dangerouslySetInnerHTML"?v=y:g=="children"||g in $||g=="value"&&"defaultValue"in $||g=="checked"&&"defaultChecked"in $||Mt(t,g,null,y,i);for(g in S=1&s.__u,$)y=$[g],g=="children"?p=y:g=="dangerouslySetInnerHTML"?h=y:g=="value"?w=y:g=="checked"?f=y:c&&typeof y!="function"||!(E[g]!==y||S&&y!=null)||Mt(t,g,y,E[g],i);h?(c||v&&(h.__html==v.__html||h.__html==t.innerHTML)||(t.innerHTML=h.__html),n.__k=[]):(v&&(t.textContent=""),(A=="foreignObject"||i=="http://www.w3.org/1998/Math/MathML"&&Ea.test(A))&&(i="http://www.w3.org/1999/xhtml"),rs(u,un(p)?p:[p],n,s,a,i,l,r,l?l[0]:s.__k&&Oe(s,0),c,d),l&&l.some(Ke)),c&&A!="textarea"||(g="value",A=="progress"&&w==null?t.removeAttribute(g):w==null||w===t[g]&&(A!="progress"||w)||Mt(t,g,w,E[g],i),g="checked",f!=null&&f!=t[g]&&Mt(t,g,f,E[g],i))}else E===$||c&&t.data==$||(t.data=$);return t}function hn(t,n,s,a){try{typeof t=="function"?n?n.__x=t(n)||1:a&&(a=a.__c||a.__e)&&(n=a.__x)&&(a.__x=null,typeof n=="function"?n():t(null)):t.current=n}catch(i){Y.__e(i,s)}}function gn(t,n,s){var a,i,l,r;if(Y.unmount&&Y.unmount(t),!(a=t.ref)||a.current&&a.current!=t.__e||hn(a,null,n,t),a=t.__c){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(c){Y.__e(c,n)}a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&gn(a[r],n,typeof t.type!="function"||s&&!t.props.__P);!s&&(a=t.__c)&&(a=a.__z)&&(i=dn(a,l=[]))&&(a==t.__e&&l.some(Ke),Ke(i),Ke(a)),(a=t.__e)&&(s||Ke(a),a.__e&&(a.__e=null)),t.__e=t.__c=t.__=null}function La(t,n,s){return this.constructor(t,s)}function ps(t,n){var s,a,i,l;Y.__&&Y.__(t,n),n.nodeType==9&&(n=n.documentElement),a=(s=t&&32&t.__u)?null:n.__k,n.__k=At(z,{children:[t]}),i=[],l=[],mn(n,n.__k,a||It,It,n.namespaceURI,a?null:n.firstChild?os.call(n.childNodes):null,i,a?a.__e:n.firstChild,s,l),ds(i,n.__k,l),n.__k.props.children=null}Y={__e:function(t,n,s,a){for(var i,l,r;n=n.__;)if((i=n.__c)&&!(1&i.__g)){i.__g|=4;try{if((r=(l=i.constructor)&&l.getDerivedStateFromError)&&i.setState(l.getDerivedStateFromError(t)),i.componentDidCatch&&(i.componentDidCatch(t,a||{}),r=1),r&&8&i.__g)return void(i.__g|=2)}catch(c){t=c}}throw Pt=0,t}},ts=0,Ta=function(t){return t!=null&&t.constructor===void 0},Rt.prototype.setState=function(t,n){var s=this.__s;s&&s!=this.state||(s=this.__s=Ve({},this.state)),typeof t=="function"&&(t=t(Ve({},s),this.props)),t&&(Ve(s,t),this.__v&&(n&&this.__k.push(n),Qn(this)))},Rt.prototype.forceUpdate=function(t){this.__v&&(this.__g|=4,t&&this.__h.push(t),Qn(this))},Rt.prototype.render=z,He=[],Pt=0,ns=function(t,n){return t.__v.__b-n.__v.__b},Et=Symbol(),ss=/(PointerCapture)$|Capture$/i,pn=0,cn={},Ma=0;var Ye,se,fn,us,vn=Object.is,pt=0,xs=[],bn=[],ee=Y,ms=ee.__b,hs=ee.__r,gs=ee.diffed,fs=ee.__c,vs=ee.unmount,bs=ee.__;function Dt(t,n){ee.__h&&ee.__h(se,t,pt||n),pt=0;var s=se.__H||(se.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function m(t){return pt=1,Da(ks,t)}function Da(t,n,s){var a=Dt(Ye++,2);if(a.t=t,!a.__c&&(a.__=[s?s(n):ks(void 0,n),function(l){var r=a.__N?a.__N[0]:a.__[0],c=a.t(r,l);vn(r,c)||(a.__N=[c,a.__[1]],a.__c.setState({}))}],a.__c=se,!se.__f)){se.__f=!0;var i=se.shouldComponentUpdate;se.shouldComponentUpdate=function(l,r,c){var d=this.__H;if(!d)return!0;var u=!1,g=this.props!=l;if(d.__.some(function(v){v.__N&&(u=!0,vn(v.__[0],v.__N[0])||(g=!0))}),i){var h=i.call(this,l,r,c);return u?h||g:h}return!u||g}}return a.__}function F(t,n){var s=Dt(Ye++,3);!ee.__s&&wn(s.__H,n)&&(s.__P=!0,s.__=t,s.u=n,se.__H.__h.push(s))}function $t(t,n){var s=Dt(Ye++,4);!ee.__s&&wn(s.__H,n)&&(s.__P=!1,s.__=t,s.u=n,se.__h.push(s))}function q(t){return pt=5,Ee(function(){return{current:t}},[])}function Ee(t,n){var s=Dt(Ye++,7);return wn(s.__H,n)&&(s.__=t(),s.__H=n),s.__}function ut(t,n){return pt=8,Ee(function(){return t},n)}function $a(){var t;do{for(;t=bn.shift();)try{dt(t)}catch(s){ee.__e(s,{__:(t=t.__P)&&t.__v})}for(;t=xs.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(dt),n.__h.some(yn),n.__h=[]}catch(s){n.__h=[],ee.__e(s,t.__v)}}}while(bn.length)}ee.__b=function(t){se=null,ms&&ms(t)},ee.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),bs&&bs(t,n)},ee.__r=function(t){hs&&hs(t),Ye=0;var n=(se=t.__c).__H;n&&(fn==se?se.__h=[]:(n.__h.some(dt),n.__h.some(yn),Ye=0),n.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})),fn=se},ee.diffed=function(t){gs&&gs(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&ws(xs.push(n)),n.__H.__.some(function(s){s.u&&(s.__H=s.u)})),fn=se=null},ee.__c=function(t,n){n.some(function(s){try{s.__h.some(dt),s.__h=s.__h.filter(function(a){return!a.__||yn(a)})}catch(a){n.some(function(i){i.__h&&(i.__h=[])}),n=[],ee.__e(a,s.__v)}}),fs&&fs(t,n)},ee.unmount=function(t){vs&&vs(t);var n,s,a=t.__c;a&&a.__H&&(a.__H.__.some(function(i){try{if(i.__P&&i.__c){if(s===void 0){for(s=t.__;s&&(!s.__c||!s.__c.__P);)s=s.__;s=s&&s.__c}i.__P=s,ws(bn.push(i))}else dt(i)}catch(l){n=l}}),a.__H=void 0,n&&ee.__e(n,a.__v))};var ys=typeof requestAnimationFrame=="function";function Ha(t){var n,s=function(){clearTimeout(a),ys&&cancelAnimationFrame(n),setTimeout(t)},a=setTimeout(s,35);ys&&(n=requestAnimationFrame(s))}function ws(t){t!=1&&us==ee.requestAnimationFrame||((us=ee.requestAnimationFrame)||Ha)($a)}function dt(t){var n=se,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),se=n}function yn(t){var n=se;t.__c=t.__(),se=n}function wn(t,n){return!t||t.length!=n.length||n.some(function(s,a){return!vn(s,t[a])})}function ks(t,n){return typeof n=="function"?n(t):n}var Ae={"app.site":"Site","app.moving":"Older visits are being copied into ClickHouse. Reports reach back to {day} so far, and further as the copy goes on.","app.confirmDelete":"Delete {name}?","app.signedOut":"Open this page once with {token} followed by your {env} to sign in.","app.live.title":"Visitors in the last five minutes","app.live_one":"{n} here now","app.live_other":"{n} here now","headline.who_one":"{n} person","headline.who_other":"{n} people","headline.visited_one":"visited","headline.visited_other":"visited","headline.matched_one":"matched these filters","headline.matched_other":"matched these filters","headline.plain":"{who} {verb} {when}.","headline.up":"{who} {verb} {when}, {change} than {against}.","headline.down":"{who} {verb} {when}, {change} than {against}.","headline.same":"{who} {verb} {when}, the same as {against}.","headline.more":"{pct}% more","headline.fewer":"{pct}% fewer","headline.lastYear":"the same days last year","when.today":"today","when.yesterday":"yesterday","when.7d":"in the last 7 days","when.30d":"in the last 30 days","when.90d":"in the last 90 days","when.month":"this month","when.last_month":"last month","when.year":"this year","when.12mo":"in the last 12 months","when.all":"since tracking began","when.range":"from {range}","when.day":"on {day}","before.today":"yesterday","before.yesterday":"the day before","before.7d":"the 7 days before","before.30d":"the 30 days before","before.90d":"the 90 days before","before.month":"the same stretch before it","before.last_month":"the month before","before.year":"the same stretch before it","before.12mo":"the 12 months before","before.all":"the stretch before","before.range":"the same stretch before","period.today":"Today","period.yesterday":"Yesterday","period.7d":"Last 7 days","period.30d":"Last 30 days","period.90d":"Last 90 days","period.month":"This month","period.last_month":"Last month","period.year":"This year","period.12mo":"Last 12 months","period.all":"All time","compare.title":"Compare to","compare.vs":"vs","compare.previous":"Previous period","compare.year":"Same period last year","compare.custom":"Custom range","compare.off":"No comparison","compare.apply":"Compare","compare.dialog":"Compare with","calendar.dialog":"Choose dates","calendar.earlier":"Earlier months","calendar.later":"Later months","calendar.pick":"Pick a start and an end day","calendar.range":"{from} to {to}","calendar.open":"{from} to ...","calendar.apply":"Apply","common.cancel":"Cancel","common.close":"Close","common.clearAll":"Clear all","common.loading":"Loading","common.search":"Search","common.none":"(none)","metric.visitors":"Visitors","metric.visits":"Visits","metric.pageviews":"Pageviews","metric.viewsPerVisit":"Views per visit","metric.bounceRate":"Bounce rate","metric.visitDuration":"Visit duration","hint.visitors":"Different people, counted once a day","hint.visits":"A visit is a session, and it ends after 30 idle minutes","hint.pageviews":"Every page loaded, repeats included","hint.viewsPerVisit":"Pageviews divided by visits","hint.bounceRate":"A visit with one pageview and no event that lasts under ten seconds","hint.visitDuration":"Average time per visit while the page was visible and in focus","delta.title":"Against the comparison period","delta.none":"no change","chart.label":"{metrics} over time","chart.scaled":"Each line is scaled to its own peak. Hover for values.","chart.pick":"Click cards to add them to the chart.","chart.dashed":"Dashed: {range}.","chart.then":"then: {when}","panel.pages":"Pages","panel.sources":"Sources","panel.locations":"Locations","panel.rhythm":"When people visit","panel.ai":"AI agents","panel.devices":"Devices","panel.events":"Events","panel.campaigns":"Campaigns","panel.views":"{title} views","panel.empty":"Nothing in this range","panel.more":"Show more","panel.filterBy":"Filter by {name}","panel.showMap":"Show a map","panel.showList":"Show the list","panel.fullMap":"Full screen map","tab.top":"Top","tab.entry":"Entry","tab.exit":"Exit","tab.channels":"Channels","tab.sources":"Sources","tab.referrers":"Referrers","tab.countries":"Countries","tab.regions":"Regions","tab.cities":"Cities","tab.agents":"Agents","tab.pages":"Pages","tab.device":"Device","tab.browser":"Browser","tab.os":"OS","tab.screen":"Screen","tab.language":"Language","tab.event":"Event","tab.campaign":"Campaign","tab.source":"Source","tab.medium":"Medium","tab.content":"Content","tab.term":"Term","column.visitors":"visitors","column.fetches":"fetches","column.events":"events","column.time":"time","column.bounce":"bounce","channel.Direct":"Direct","channel.Organic Search":"Organic Search","channel.Paid Search":"Paid Search","channel.Social":"Social","channel.Email":"Email","channel.AI":"AI","channel.Referral":"Referral","channel.Campaign":"Campaign","device.desktop":"Desktop","device.mobile":"Mobile","device.tablet":"Tablet","ai.live":"Live fetches","ai.crawl":"Crawls","rhythm.busiest":"Busiest: {when}","rhythm.table":"Visits by weekday and hour","rhythm.cell_one":"{when}: {n} visit","rhythm.cell_other":"{when}: {n} visits","scale.fewer":"Fewer","scale.more":"More","map.failed":"Could not load the map","map.label":"Visitors by country: {top}","map.visitors_one":"{n} visitor","map.visitors_other":"{n} visitors","map.none":"No visitors","map.title":"Around the world","filter.button":"Filter","filter.remove":"Remove filter","filter.title":"Show visits","filter.where":"where","filter.and":"and","filter.field":"Field","filter.match":"Match","filter.is":"is","filter.not":"is not","filter.contains":"contains","filter.value":"Value","filter.placeholder":"Type a value or pick one below","filter.placeholderContains":"Any part of the value","filter.removeCondition":"Remove this condition","filter.add":"+ Add a condition","filter.note":"Every condition has to hold. Click any row on the dashboard to add one without opening this.","filter.apply_one":"Apply {n} condition","filter.apply_other":"Apply {n} conditions","filter.everything":"Show everything","group.pages":"Pages","group.sources":"Sources","group.location":"Location","group.device":"Device","group.behaviour":"Behaviour","field.page":"Page","field.entry":"Entry page","field.exit":"Exit page","field.hostname":"Hostname","field.channel":"Channel","field.source":"Source","field.referrer":"Referrer","field.utm_campaign":"Campaign","field.utm_source":"UTM source","field.utm_medium":"UTM medium","field.utm_content":"UTM content","field.utm_term":"UTM term","field.country":"Country","field.region":"Region","field.city":"City","field.device":"Device","field.browser":"Browser","field.browser_version":"Browser version","field.os":"OS","field.os_version":"OS version","field.screen":"Screen","field.language":"Language","field.event":"Event","foot.powered":"Powered by {name}","foot.language":"Language","theme.light":"Light theme","theme.dark":"Dark theme","column.visits":"visits","column.pageviews":"pageviews","column.scroll":"scroll","column.duration":"duration","column.share":"share","rhythm.typical":"{x}\xD7 a typical hour","rhythm.quiet":"No visits in this hour","app.home":"Back to the overview","settings.open":"Settings","settings.title":"Settings","settings.general":"General","settings.install":"Install","settings.siteName":"Site name","settings.timezone":"Timezone","settings.timezoneHint":"Days in your reports start at midnight here.","settings.save":"Save","settings.saving":"Saving","settings.saved":"Saved","settings.language":"Language","settings.languageHint":"Just for this browser.","settings.theme":"Theme","settings.themeSystem":"Device setting","settings.themeLight":"Light","settings.themeDark":"Dark","install.live":"Receiving visits. The last one was {when}.","install.none":"No visits yet. Add the script below, then open a page on your site.","install.cms":"Runlight in {cms} adds the script to every page, so there is nothing to add.","install.script":"Add this to every page, just before {tag}.","install.copy":"Copy","install.copied":"Copied","install.events":"Clicks on anything can be counted with no JavaScript.","install.eventsJs":"You can also send events from JavaScript, for things that are not clicks.","install.agents":"To see AI agents like ChatGPT and Claude reading your pages, pass each request to Runlight in your middleware with the code below.","install.ignore":"Your own visits","install.ignored":"Your visits from this browser are not counted.","install.counted":"Your visits from this browser are counted.","install.ignoreButton":"Ignore this browser","install.trackButton":"Count this browser again","install.ignoreElsewhere":"Dashboard on a different domain from the site? Open {link} once in each browser you use.","theme.system":"Device setting","theme.cycle":"Theme: {current}. Click for {next}.","panel.links":"Links","links.new":"New link","links.manage":"Manage","links.clicks":"clicks","links.url":"Destination URL","links.urlPlaceholder":"https://example.com/a/long/address","links.name":"Name","links.namePlaceholder":"Optional, for your own reference","links.slug":"Slug","links.slugPlaceholder":"Leave blank for a random one","links.domain":"Domain","links.create":"Create link","links.save":"Save changes","links.created":"Your short link is ready.","links.another":"Make another","links.edit":"Edit link","links.delete":"Delete","links.confirmDelete":"Delete {name}? Its clicks stay in your stats.","links.copy":"Copy","links.copied":"Copied","links.search":"Search links","links.sortClicks":"Most clicked","links.sortNewest":"Newest","links.sortName":"Name","links.import":"Import CSV","links.importDone_one":"Imported {n} link.","links.importDone_other":"Imported {n} links.","links.importFailed":"Row {row}: {reason}","links.importHelp":"Use the columns name and url, plus slug and domain when you have them.","links.destination":"Goes to","links.clicksOverTime":"Clicks over time","links.sources":"Sources","links.countries":"Countries","links.devices":"Devices","links.browsers":"Browsers","links.total_one":"{n} click","links.total_other":"{n} clicks","links.domains":"Domains for short links","links.domainsHelp":"Use a domain or subdomain you own for short links, like t.example.com. Links on it live at its root, as in t.example.com/sale.","links.addDomain":"Add domain","links.domainPlaceholder":"t.example.com","links.ownDomain":"This site ({prefix})","links.removeDomain":"Remove","settings.links":"Custom domains","links.confirm":"Confirm delete","links.editButton":"Edit","links.step1":"At your DNS provider, add a CNAME record for the subdomain that points to {host}, where this dashboard runs. For a bare domain with no subdomain, use an A or ALIAS record to the same server instead.","links.step2":"Make your host accept the domain and serve HTTPS for it. On Vercel or Netlify, add it to your project's domains, and on your own server, add it to the config and the certificate. If Runlight runs inside your app, pass requests to rl.linkDomainResponse() in your middleware.","links.step3":"Add the domain below. Runlight then checks that it reaches this dashboard.","links.checking":"Checking","links.working":"Working","links.notWorking":"Not reaching Runlight yet: {reason}","links.recheck":"Check again","links.sortBy":"Sort links","links.removeNote":"Removing a domain keeps its links and their clicks. They move to {fallback} until you add the domain back, then return to it.","links.removedDomain":"{domain}/ (removed)","prompt.copy":"Copy prompt","prompt.domainHint":"Copy these steps with your addresses filled in, and paste them into it.","prompt.installHint":"Copy the setup steps and paste them into it.","links.showing":"Showing {shown} of {total}","links.showMore":"Show {n} more","links.clicksLabel":"Clicks","links.createdOn":"Created {date}","settings.import":"Import","import.intro":"Bring your short links over from another service, with their click history where the service shares it. Your key or password is used for this import only and never saved. Importing again skips links already here.","import.source":"Import from","import.csv":"Any CSV","import.url":"Umami address","import.apiKey":"API key","import.username":"Username","import.password":"Password","import.signIn":"Sign in with","import.withKey":"API key","import.withPassword":"Username and password","import.start":"Start import","import.stop":"Stop","import.running":"Importing {done} of {total} links","import.done":"Finished: {links} links and {clicks} clicks imported, {skipped} already here.","import.stopped":"Stopped after {done} of {total} links. Start again to carry on; links already imported are skipped.","import.failed":"These could not be imported.","import.history.full":"This imports every click, with its country, device, browser, and referrer.","import.history.daily":"This imports clicks per day, without country or device.","import.history.none":"This imports links only, since the service does not share dated clicks.","import.umamiHelp":"In Umami, create an API key under Settings, API keys. Stock self-hosted Umami has no API keys, so sign in with your username and password instead. Either one is used for this import only and never saved.","import.csvHelp":"Use the columns name and url, plus slug and domain when you have them.","import.chooseFile":"Choose a CSV file","import.token":"Access token","import.workspace":"Workspace id (optional)","import.dubHelp":"In Dub, create an API key under Settings, API Keys, with read access to links and analytics. Every click comes across on Business plans, daily counts on Pro, links only on Free.","import.bitlyHelp":"In Bitly, go to Settings, API, enter your password, and generate a token. Bitly keeps daily counts only, as far back as your plan allows (none on Free).","import.shortioHelp":"In Short.io, open Integrations and API and create a secret API key (a public key cannot read links). Short.io allows 60 statistics requests a minute, so this import paces itself.","import.rebrandlyHelp":"In Rebrandly, create an API key under Settings, API keys. Rebrandly shares only total clicks, so links come across without history.","import.soFar_one":"Imported {n} link so far","import.soFar_other":"Imported {n} links so far","import.moveNote":"Links on the service's own domain (bit.ly, dub.sh, rebrand.ly, short.gy) move to {fallback} with the same slug; branded domains are added under Custom domains.","prompt.title":"Using a coding assistant?","compare.allTime":"There is nothing before all time to compare with.","view.reset":"Reset","view.resetHint":"Back to the last 30 days, with no filters or comparison","settings.sharing":"Sharing","share.intro":"A share link shows this site's stats to anyone who has it, with no sign-in. It never shows your short links, your settings, or the site's address.","share.namePlaceholder":"Who it is for, like a client or your team","share.create":"Create share link","share.empty":"Make one below and send it to anyone who should see these stats.","share.unnamed":"Untitled","share.open":"Open","share.rename":"Rename","share.save":"Save","share.revokeNote":"Deleting a share link stops it working at once. Anyone who had it then sees a page saying so.","share.gone":"Whoever shared it has turned it off. Ask them for a new link.","live.title":"Right now","live.sub":"Refreshes every 10 seconds","live.now_one":"{n} person on the site","live.now_other":"{n} people on the site","live.nowHint":"Anyone who viewed a page or did something in the last 5 minutes.","live.total_one":"{n} pageview in the last 30 minutes","live.total_other":"{n} pageviews in the last 30 minutes","live.minute_one":"{n} pageview at {time}","live.minute_other":"{n} pageviews at {time}","live.ago30":"30 min ago","live.nowLabel":"Now","live.pages":"Pages","live.sources":"Sources","live.countries":"Countries","live.nobody":"Visitors show up here as they arrive.","live.feed":"Latest activity","live.quiet":"Visits from the last 30 minutes show up here.","live.someone":"Someone","live.someoneIn":"Someone in {place}","live.viewed":"{who} viewed {path}","live.viewedVia":"{who} viewed {path} from {source}","live.did":"{who} did {name} on {path}","live.didVia":"{who} did {name} on {path}, from {source}","welcome.title":"Add Runlight to {name}","welcome.lead":"Waiting for the first visit. This page fills in by itself once it arrives.","settings.goals":"Goals","settings.funnels":"Funnels","panel.conversions":"Conversions","goals.revenueAside":"{amount} revenue","goals.add":"Add goal","goals.emptyTitle":"Your goals and funnels will show up here","goals.emptyHint":"Goals track actions like signups and clicks. Funnels show the steps people take and where they drop off.","goals.goal":"Goal","goals.rate":"Rate","goals.conversions":"Conversions","goals.unknown":"(none)","goals.converted":"People who converted","goals.revenue":"Revenue","goals.overTime":"Conversions over time","goals.overTimeValued":"Conversions and revenue over time, each on its own scale","goals.byChannel":"By channel","goals.bySource":"By source","goals.byPage":"Where it happened","goals.describe.event":"Event: {match}","goals.describe.page":"Visits to {match}","goals.describe.selector":"Clicks on {match}","goals.describe.link":"Clicks on links to {match}","goals.value.each":"{amount} each","goals.value.fromProp":"amount from {prop}, in {currency}","goals.name":"Name","goals.namePlaceholder":"Signup, Purchase, Booked a call","goals.counts":"Counts","goals.kind.event":"An event","goals.kind.page":"A page visit","goals.kind.click":"A click","goals.clickOn":"Clicks on","goals.click.selector":"An element","goals.click.link":"Links to an address","goals.match.event":"Event name","goals.match.page":"Page","goals.match.link":"Link address","goals.match.selector":"CSS selector","goals.pick":"Pick on my site","goals.picking":"Waiting for your pick","goals.pickUpdate":"The Runlight that counts this site is too old to send a pick back here. Update it, or type a selector.","goals.hint.event":'The name you send with runlight("Name") or a data-runlight attribute.',"goals.hint.page":"A path like /thanks. Use * for anything: /blog/* or /thanks*. A full URL works too.","goals.hint.link":"Clicks on links whose address matches. Use * for anything, like https://buy.stripe.com/*, or start with / for your own pages.","goals.hint.selector":"Enter a CSS selector or pick an element on your site. The picker requires the Runlight tracking script.","goals.valueLabel":"Worth","goals.value.none":"Nothing","goals.value.fixed":"A fixed amount","goals.value.prop":"An amount sent with the event","goals.amount":"Amount each time","goals.property":"Property with the amount","goals.currency":"Currency","goals.save":"Save goal","goals.create":"Add goal","goals.cancel":"Cancel","goals.edit":"Edit","goals.intro":"Goals turn visits into conversions. Each one counts an event, a page visit, or a click, and can carry a money value so you can see revenue by source and page.","goals.none":"Add one below to start counting it.","goals.pastNote":"Goals are counted from the data you already have, so a new goal shows past conversions too. Click goals start counting within about five minutes of being added.","settings.email":"Email reports","settings.mail":"Email service","mail.intro":"Runlight sends reports and invites through your own email service. Set it up once and every site uses it.","mail.service":"Service","mail.optional":"(optional)","mail.keepSaved":"Saved. Leave blank to keep it.","mail.from":"From address","mail.fromName":"From name","mail.fromHint":"Use an address your service lets you send from, on a domain you have verified with it.","mail.save":"Save mail service","mail.change":"Change","mail.fromLine":"Sends from {from}","mail.fromCode":"Set in code. Sends from {from}","mail.viaApp":"Reports are sent through {via}, from {from}.","mail.useAnother":"Use another service","mail.backToApp":"Go back to {via}","mail.replacesApp":"This service sends in place of {via}.","mail.testTo":"Send a test to","mail.test":"Send test","mail.testSent":"Test sent to {to}. Check the inbox, and the spam folder.","mail.notEncryptedTitle":"Your keys will be stored unencrypted","mail.notEncrypted":"This Runlight has no RUNLIGHT_SECRET, so the keys are kept in its database exactly as you type them. Set RUNLIGHT_SECRET or RUNLIGHT_TOKEN on the server to keep them encrypted.","mail.field.region":"Region","mail.field.accessKeyId":"Access key ID","mail.field.secretAccessKey":"Secret access key","mail.field.apiKey":"API key","mail.field.serverToken":"Server API token","mail.field.stream":"Message stream","mail.field.domain":"Sending domain","mail.field.secretKey":"Secret key","mail.field.host":"Host","mail.field.port":"Port","mail.field.security":"Security","mail.field.username":"Username","mail.field.password":"Password","mail.field.url":"URL","mail.field.secret":"Signing secret","reports.title":"Who gets reports","reports.intro":"A summary of {site} by email, with visitors, top pages, sources, countries, and conversions against the period before.","reports.none":"Add an email address below to start sending them.","reports.weekly":"Weekly","reports.monthly":"Monthly","reports.frequency":"How often","reports.language":"Language","reports.lastSent":"last sent {when}","reports.never":"not yet","reports.sample":"Send a sample now","reports.sampleSent":"Sample sent to {to}.","reports.emailPlaceholder":"name@example.com","reports.add":"Add","reports.when":"Weekly reports cover Monday to Sunday and go out on Monday from 8am, monthly ones on the 1st, in this site's timezone. They are sent by the hourly check (a cron calling POST /api/check).","reports.needsMail":"Reports start going out once an email service is set up. One service sends them for every site.","reports.setUpMail":"Set up email service","reports.needsMailTitle":"No email service yet","email.subject.week":"{site}: {who} last week","email.subject.month":"{site}: {who} in {month}","email.when.week":"last week","email.before.week":"the week before","email.when.month":"in {month}","email.range":"{from} to {to}","email.pages":"Top pages","email.sources":"Top sources","email.countries":"Top countries","email.conversions":"Conversions","email.open":"Open the dashboard","email.at":"Your dashboard is at {where}","email.footer":"You get this {frequency} report for {site} from Runlight.","email.weekly":"weekly","email.monthly":"monthly","email.unsubscribe":"Unsubscribe","email.test.subject":"Runlight can send email","email.test.body":"This test came through {service}. Reports for your sites will arrive the same way.","email.unsub.title":"Stop the {site} reports?","email.unsub.body":"{email} will get no more reports for this site.","email.unsub.doneTitle":"You are unsubscribed","email.unsub.done":"No more reports for {site} will reach {email}.","email.unsub.goneTitle":"Nothing to unsubscribe from","email.unsub.gone":"This link has been used already, or the report was removed.","settings.api":"MCP & API","tokens.intro":"Ask your AI assistant about your stats. Make a token, then add Runlight to Claude, Cursor, or any app that connects to MCP servers. A read token never changes anything, and a manage token can change one site's settings. The same token works with the HTTP API.","tokens.server":"MCP server address","tokens.namePlaceholder":"What it is for, like Claude or a script","tokens.scope":"Which sites it can read","tokens.allSites":"Every site","tokens.siteOnly":"{site} only","tokens.create":"Create token","tokens.empty":"Make one below to connect an AI assistant or a script.","tokens.used":"last used {date}","tokens.never":"never used","tokens.revokeNote":"Deleting a token stops it working at once.","tokens.once":"Copy this token now. It is shown only once, and Runlight keeps only a fingerprint of it.","tokens.claudeCode":"Claude Code takes the token with this command.","tokens.json":"Cursor and other apps that take an mcpServers JSON config use this instead.","tokens.done":"Done, I have copied it","sites.domains":"Domains","sites.domainsHint":"Enter the domain the site runs on, like example.com, and separate several with commas.","sites.name":"Name","sites.namePlaceholder":"My blog","sites.timezoneHint":"Days are counted in {zone}, which you can change later in Settings.","sites.add":"Add site","sites.addTitle":"Add a site","sites.firstTitle":"Add your first site","sites.firstLead":"Runlight counts each site you add here. Enter the site's domain, and the next screen shows the script tag to put on its pages.","sites.delete":"Delete this site","sites.deleteHint":"Deleting a site removes every visit, link, goal, and report recorded for it, and it cannot be undone.","app.signOut":"Sign out","install.ignoreServer":"To stop counting your own visits, open {link} once in each browser you use.","panel.geoCredit":"Locations by {name}","visits.tab":"Visits","visits.linksTab":"Short links","visits.intro":"Bring your visit history over so your charts reach back before Runlight started counting. Only visits from before Runlight's own first one come across, so nothing is counted twice.","visits.onlyUmami":"Umami's API hands over every visit with its page, source, place, and device, which is what Runlight keeps. Plausible, Fathom, and Google Analytics only give out totals, and totals cannot be turned back into visits. If you have every pageview in a file, import it as a CSV instead.","visits.csvMoment":"More than {max} rows share one moment, more than one batch can hold.","visits.csvStopped":"Stopped. Importing the same file again is safe, since rows already brought in are replaced.","visits.csvSkipped":"{n} rows were left out because they came after Runlight's own first visit, fell before what this site keeps, or were not a pageview or a named event.","visits.csvRunning":"{done} of {total} rows sent, {pageviews} pageviews so far","visits.csvRunlight":"{name} is in Runlight's visit format, with {rows} rows.","visits.csvUmami":"{name} is an Umami export with {rows} rows.","visits.csvOther":"Choose another file","visits.csvChoose":"Choose CSV file","visits.csvHelp":"Use the CSV from Umami's data export, or a file with a row for each pageview in Runlight's visit format, described in the Dashboard docs.","visits.fromCsv":"A CSV file","visits.fromUmami":"Umami","visits.from":"Import from","visits.onlyUmamiTitle":"Why only Umami","visits.find":"Find websites","visits.website":"Umami website","visits.noWebsites":"This Umami account has no websites.","visits.start":"Import visits","visits.running":"{done} of {total} days read, {pageviews} pageviews so far","visits.done":"Finished. {pageviews} pageviews and {events} events came across in {visits} visits.","visits.stopped":"Stopped. Start again to carry on from the last day imported.","props.title":"Properties","props.open":"Properties of {name}","props.none":"They appear once the event is sent with properties.","account.title":"Account","account.owner":"You are the owner, so you can change everything and manage people. Nobody else can remove you.","account.viewer":"You are a viewer, so you can read every site's stats without changing anything.","account.current":"Current password","account.next":"New password","account.nextHint":"Use at least ten characters. Changing it signs out your other browsers.","account.save":"Change password","account.saved":"Password changed","account.revokeTokens":"Also revoke the API tokens and connected apps this account made","account.everywhere":"Sign out everywhere","account.everywhereHint":"Ends every sign-in to this account, in this browser and all others, such as on a lost phone. Signing out from the menu ends only this browser's.","account.everywhereConfirm":"Sign out of Runlight in every browser, this one too?","settings.people":"Team Members","people.intro":"Invite teammates to this site, or choose access to all sites. Their role controls what they can do.","people.you":"you","people.role":"Role","people.owner":"Owner","people.viewer":"Viewer","people.roles":"Admins manage the entire instance and all sites. Members change settings for their assigned sites. Viewers can only read their assigned sites.","people.emailPlaceholder":"Their email address","plugin.title":"WordPress, Drupal, and Craft","plugin.intro":"In the Runlight plugin's settings, enter this Runlight's address and press Connect, then pick this site. Or copy these into the settings under the same names.","plugin.address":"Runlight address","plugin.addressHint":"Where this Runlight answers. The plugin adds its script from here.","plugin.site":"Site id","plugin.siteHint":"Optional. Only needed when this Runlight cannot tell the site by its domain.","plugin.agentsKey":"Agents key","plugin.agentsKeyHint":"Lets your CMS plugin report AI crawler visits that may not run JavaScript. Cannot read your stats. Replacing the key disables the old one.","plugin.replace":"Replace key","plugin.dashboardKey":"Dashboard key","plugin.dashboardKeyHint":"Lets your CMS plugin show this site's read-only dashboard. Keep it private. Revoke a key below to stop it opening the dashboard.","plugin.make":"Make a key","plugin.another":"Make another key","plugin.dashboardKeyName":"Dashboard key","export.csv":"Download CSV","export.zip":"Export","export.title":"Download everything in this view as CSV files","funnels.title":"Funnels","funnels.intro":"A funnel follows the steps you expect a visit to take, such as the pricing page and then signup, and shows how many visits made it through each step in order.","funnels.none":"Add one below to see where people stop along the way.","funnels.add":"Add funnel","funnels.name":"Name","funnels.namePlaceholder":"Signup","funnels.steps":"Steps","funnels.stepsHint":"A page path can use * to match anything, like /blog/*. Each step has to happen after the one before it, in the same visit.","funnels.kind":"What the step is","funnels.page":"Page","funnels.event":"Event","funnels.removeStep":"Remove this step","funnels.addStep":"Add a step","funnels.save":"Save funnel","funnels.create":"Create funnel","funnels.stepPage":"Page {match}","funnels.stepEvent":"Event {match}","funnels.wentOn":"{pct} went on","funnels.tab":"Funnels","funnels.goalsTab":"Goals","sites.modeHere":"Count it here","sites.modeConnect":"Connect another Runlight","sites.connectIntro":"Connect a site here when it already counts itself with Runlight inside its own app. Its numbers stay there. You sign in to it once and allow this server, and then you can see and change the site from here.","sites.connectUrl":"Its Runlight address","sites.connectToken":"API token","sites.connectTokenHint":"Make a token on that install, in Settings, MCP & API. With a read token the numbers show here and the settings stay there.","sites.connect":"Connect","sites.all":"All sites","sites.remoteNote":"This site is counted by its own Runlight at {url}, which lets this server read it. Allow changes to manage its settings from here too.","sites.disconnect":"Disconnect this site","sites.disconnectHint":"Disconnecting removes the site from this server. Its own Runlight and everything it has counted stay as they are.","sites.disconnectButton":"Disconnect site","sites.confirmDisconnect":"Confirm disconnect","sites.disconnectName":"Disconnect {name}?","settings.data":"Data","data.retention":"Keep visits for","data.retentionHint":"Older visits and events are deleted for good when you save, then every day after. Goals, links, and settings stay.","data.forever":"Forever","data.months":"{n} months","data.years":"{n} years","data.deletesBefore":"Visits before {date} will be deleted when you save.","data.unreachable":"Could not reach {url} to read this setting. Try again in a minute.","data.export":"Export everything","data.exportHint":"The ZIP holds every report for this site since its first visit, as CSV files.","data.download":"Download ZIP","sites.remoteTitle":"Counted by another Runlight","sites.openRemote":"Open its dashboard","sites.useToken":"Use an API token instead","sites.useSignIn":"Sign in to it instead","sites.remoteManaged":"This site is counted by its own Runlight at {url}. Changes you make here are saved there.","sites.allowChanges":"Allow changes","sites.reconnect":"Connect again","sites.reconnectHint":"Use this if the install no longer accepts this server, for example after its token was deleted there.","sites.connectError.expired":"That connection took too long or was already used. Start again.","sites.connectError.denied":"The connection was not allowed.","sites.connectError.refused":"The install would not let this server connect. Start again, or connect it with an API token.","sites.connectError.token":"The install did not give this server a token. Start again.","sites.connectError.failed":"Connecting did not finish. Start again.","mail.fromRemote":"Sent by {host} from {from}","mail.noneRemote":"{host} has no mail service yet, so it cannot send these reports. Set one up in its own dashboard, under Settings, Email service.","tokens.manages":"Can change settings","account.again":"New password again","account.mismatch":"The two new passwords are not the same.","account.strength0":"Too short","account.strength1":"Weak","account.strength2":"Fair","account.strength3":"Good","account.strength4":"Strong","auth.signIn":"Sign in","auth.signInIntro":"Sign in to see your sites.","auth.email":"Email","auth.password":"Password","auth.passwordAgain":"Password again","auth.forgot":"If you have forgotten your password, {link}.","auth.forgotLink":"the docs say how to set a new one","auth.codeTitle":"Enter your code","auth.codeIntro":"Open your authenticator app and enter the six-digit code for Runlight.","auth.code":"Code","auth.codeHint":"Lost your phone? Enter one of your recovery codes instead. Each works once.","auth.codeWrong":"That code is not right. Check the time on your phone, or use a recovery code.","auth.wrongPassword":"That email and password do not match an account.","auth.tooManyLink":"Too many tries for this account. If the password was right, a link to sign in is on its way to its email address.","auth.linkExpired":"That sign-in link has run out. Sign in again.","auth.roleViewerSite":"a viewer, who can read the stats for {site} only","auth.roleMemberSite":"a member, who can change the settings of {site} only","auth.roleViewer":"a viewer, who can read every site's stats","auth.roleMember":"a member, who can change the settings of every site","auth.roleAdmin":"an admin, who can change everything and manage people","auth.joinTitle":"Join Runlight","auth.joinIntro":"You were invited to {host} as {role}. Choose a password to finish.","auth.join":"Join","auth.passwordHint":"Use at least ten characters.","auth.mismatch":"The two passwords are not the same.","auth.inviteGoneTitle":"This invite no longer works","auth.inviteGone":"It has expired or was already used. Ask whoever invited you to send a new one.","auth.setupTitle":"Create your account","auth.setupIntro":"This account owns the dashboard. You can invite more people later in Settings, Team Members.","auth.setupToken":"Your RUNLIGHT_TOKEN","auth.tokenWrong":"That is not this app's RUNLIGHT_TOKEN.","auth.createAccount":"Create account","auth.finishTitle":"Finish setting up","auth.setupLocked":"Runlight has no account yet. Open the setup link printed in the server's log when it started, which carries a one-time code, to create the first account.","auth.setupLockedFile":"Runlight has no account yet. Open the setup link in the file setup.txt in Runlight's data folder ({command} prints it too), which carries a one-time code, to create the first account.","auth.setupNeedsToken":"Runlight has no account yet. Set RUNLIGHT_TOKEN, or pass token to routes(), and open this page again. Creating the first account asks for it, so only whoever runs the app can.","auth.switchTheme":"Switch theme","auth.themeLight":"Theme: light","auth.themeDark":"Theme: dark","auth.themeSystem":"Theme: device setting","auth.showPassword":"Show password","auth.hidePassword":"Hide password","oauth.connectTitle":"Connect {app}","oauth.readIntro":"{app} wants to read your Runlight stats so it can answer questions about them. It will be able to read and never to change anything.","oauth.readSites":"Which sites it can read","oauth.siteOnly":"{site} only","oauth.readNote":"Its token appears in Settings, API and AI, where deleting it disconnects the app.","oauth.manageIntro":"{app} wants to show this site\u2019s stats and change its settings, so you can manage it from there.","oauth.manageDetail":"It will be able to change goals, funnels, short links, link domains, email reports, and share links for the site you pick, along with its name, timezone, and retention. It cannot read other sites, add people, make tokens, or change how email is sent.","oauth.manageNote":"Its token appears in Settings, API and AI, where deleting it disconnects {app}.","oauth.cmsIntro":"{app} wants to count {host} in this Runlight.","oauth.cmsDetail":"It will get the site's agents key, to report AI agents such as ChatGPT and Claude reading its pages, and a dashboard key, to show the site's read-only dashboard in its admin pages. It cannot change anything here or read other sites.","oauth.cmsNote":"Its dashboard key appears in Settings, API and AI, where deleting it stops the dashboard in {app}.","oauth.newSite":"A new site for {host}","oauth.sendsTo":"Allowing sends you back to {host}. Only allow it if you started connecting there.","oauth.allow":"Allow","oauth.deny":"Deny","oauth.addSiteTitle":"Add this site first","oauth.addSite":"No site in this Runlight counts {host}. Add it to a site's domains in your code, then connect again from {app}.","oauth.unregisteredTitle":"This app is not registered","oauth.startAgain":"Start connecting again from the app.","oauth.unsupportedTitle":"This app asked in a way Runlight does not support","oauth.unsupported":"{app} sent {error}. Start connecting again from the app.","oauth.viewerTitle":"Ask an owner to connect this","oauth.viewer":"You are signed in as a viewer, and only an owner of this Runlight can connect {app}.","oauth.signInTitle":"Sign in first","oauth.signIn":"Open your Runlight dashboard at {link} and sign in, then connect {app} again.","oauth.anotherSiteTitle":"This request came from another site","mail.introRemote":"Reports for this site go out through the email service set up on {host}.","settings.assistant":"AI Assistant","assistant.open":"Ask about your stats","assistant.title":"AI Assistant","assistant.about":"Answers from {site}'s latest stats.","assistant.clear":"New chat","assistant.intro":"Ask about your stats, or create goals, funnels, email reports, share links, and member invitations. Review and confirm each change in the chat.","assistant.ask1":"How is my site doing?","assistant.ask2":"What has changed recently?","assistant.ask3":"What should I pay attention to?","assistant.ask4":"How could I improve my site?","assistant.placeholder":"Ask a question","assistant.send":"Send","assistant.thinking":"Reading your numbers","assistant.empty":"The assistant had nothing to say.","assistant.checked_one":"Read {n} report","assistant.checked_other":"Read {n} reports","assistant.setupOwner":"The assistant needs an AI service to answer with. Add a key for Anthropic, OpenAI, or Gemini, or point it at a model on your own machine.","assistant.setupViewer":"The assistant is not set up yet. The owner or an admin can add an AI service in Settings, AI Assistant.","assistant.setup":"Set up the assistant","assistant.ownersOnly":"Only the owner or an admin can set up the assistant.","assistant.settingsIntro":"Choose an AI service and paste an API key from it below. The robot button beside Filter then opens an assistant that answers questions about your stats in plain words.","assistant.privacyTitle":"What the service sees","assistant.privacy":"Your questions, the details you enter, and the reports the assistant reads are sent to your chosen AI service. Creation drafts need your confirmation and use your existing permissions. MCP tools remain read-only.","assistant.notEncryptedTitle":"Your key will be stored unencrypted","assistant.notEncrypted":"This Runlight has no RUNLIGHT_SECRET, so the key is kept in its database exactly as you type it. Set RUNLIGHT_SECRET or RUNLIGHT_TOKEN on the server to keep it encrypted.","assistant.provider":"AI service","assistant.address":"Address","assistant.addressHint":"Where the service's OpenAI-compatible API lives, ending before /chat/completions.","assistant.addressLocal":"Where the model runs. The server running Runlight must be able to reach it.","assistant.model":"Model","assistant.modelPlaceholder":"The model's name, as the service lists it","assistant.modelDefault":"Leave it empty to use {model}.","assistant.modelHint":"Enter the key above, then load the service's models, or type a model's name. A model that can call tools works best.","assistant.key":"API key","assistant.remove":"Turn off the assistant","assistant.removeHint":"Removes the service and its key. The robot button then asks an owner to set it up again.","journeys.open":"Journeys","journeys.title":"Journeys","journeys.intro":"The paths visits take through the site, a page at a time. Click a page to follow only the visits that passed through it.","journeys.steps":"Steps","journeys.stepCount":"{n} steps","journeys.start":"Starting at","journeys.end":"Ending at","journeys.anyPage":"Any page","journeys.step":"Step {n}","journeys.other":"Other pages","journeys.left":"{n} went no further","journeys.follow":"Follow visits through {page}","journeys.following":"Following visits through {page} at step {step}.","journeys.none":"Try a wider date range to see more visits.","secret.show":"Show","secret.hide":"Hide","people.invite":"Invite","people.invited":"invited","people.invitedMeta":"{role}, the link works until {date}","people.resend":"Send again","people.emailed":"An invite is on its way to {email}. You can also send them this link yourself.","people.noMail":"This server has no mail service, so send {email} this link yourself. Set one up in Settings, Email service to send invites by email.","people.mailFailed":"The email to {email} did not go out ({error}). Send them this link yourself.","people.linkHint":"The link works once, for seven days. Sending again makes a new link and stops this one.","twofa.title":"Two-factor sign-in","twofa.off":"Off. Turn it on and signing in also asks for a code from an authenticator app on your phone.","twofa.on_one":"On. Signing in asks for a code from your authenticator app. You have {n} recovery code left.","twofa.on_other":"On. Signing in asks for a code from your authenticator app. You have {n} recovery codes left.","twofa.turnOn":"Turn on","twofa.turnOff":"Turn off","twofa.newCodes":"New recovery codes","twofa.password":"Your password","twofa.continue":"Continue","twofa.scan":"Scan this with an authenticator app, such as 1Password, Google Authenticator, or Authy, then enter the six-digit code it shows.","twofa.qr":"QR code for your authenticator app","twofa.manual":"Or type this key into the app.","twofa.code":"Code from the app","twofa.confirm":"Turn on","twofa.codesIntro":"Keep these recovery codes somewhere safe. Each one signs you in once if you lose your phone, and they are not shown again.","twofa.download":"Download","twofa.copy":"Copy","twofa.saved":"I saved them","people.twoFactor":"two-factor","people.resetTwoFactor":"Reset two-factor","people.resetTwoFactorHint":"Turns off two-factor sign-in for this person, for when they lost their phone and recovery codes","assistant.loadModels":"Load models","assistant.loadingModels":"Loading","assistant.pickModel":"Choose a model","assistant.typeModel":"Type a model's name instead","assistant.chooseFromList":"Choose from the list","journeys.sampled":"These are the paths of the newest {n} visits in these dates.","funnels.sampled":"Counted over the newest {n} visits in these dates.","error.owner_only":"Only an owner can change this.","error.domain_invalid":"That is not a domain name.","error.domain_in_use":"{domain} is where this dashboard or one of your sites lives. Use a separate domain or subdomain for short links, such as go.{domain}.","error.domain_taken":"{domain} already belongs to another site.","error.link_url":"The destination must be a full URL, starting with https://","error.link_protocol":"The destination must start with http:// or https://","error.link_long":"The destination is longer than 2,000 characters.","error.link_domain":"Add {domain} as a link domain in Settings first.","error.link_slug":"A slug is letters, digits, dashes, and underscores, up to 100.","error.link_taken":"/{slug} is already taken.","error.link_no_slug":"Could not find a free slug. Try again.","error.test_email":"Enter an email address to send the test to.","error.mail_unset":"Set up a mail service first.","error.email_invalid":"Enter an email address.","error.report_exists":"{email} already gets this report.","error.report_limit":"A site can send to at most 50 addresses.","error.sample_soon":"A sample went out a moment ago. Wait a minute and try again.","error.test_soon":"A test went out a moment ago. Wait a minute and try again.","error.network":"Could not reach the server. Check the connection and try again.","error.http":"The server answered {status}. Try again in a moment.","error.people_owner":"Only the owner or an admin can manage people.","error.role_needed":"Pick admin, member, or viewer.","error.account_exists":"{email} already has an account.","error.remove_self":"You cannot remove yourself.","people.demoted":"You are a viewer now, so settings are closed and nothing here can be changed. The owner or an admin can change it back.","links.importNoUrl":"Nothing was imported because the file has no url column with addresses in it. Use the columns name and url, plus slug and domain when you have them.","app.sessionEnded":"You were signed out, which happens when a session runs out or a password changes. {link} and you come back to this view.","app.signInAgain":"Sign in again","links.noneYet":"Nobody has made a short link for this site yet.","error.remote_slow":"{host} took too long to answer. Try a shorter range.","error.domain_not_public":"{domain} is not a public domain name. Use one that browsers anywhere can reach.","error.unreachable":"Could not reach {host}.","error.redirected":"{host} answered with a redirect.","error.token_refused":"{host} refused the token. Connect it again from the site's settings.","error.mail_failed":"The email could not be sent ({detail}).","error.mail_unreachable":"Could not reach {host}.","error.mail_slow":"{host} took too long to answer, so the email was not sent.","error.mail_refused":"{host} turned the email down ({detail}).","error.mail_app_failed":"{via} could not send the email ({detail}).","error.mail_service":"Pick a mail service that is offered here.","error.mail_field":"{field} is needed.","error.mail_option":"{field} must be one of {options}.","error.mail_https":"The webhook URL must use https.","error.mail_url":"Enter the webhook's whole URL, like https://example.com/hooks/mail.","error.mail_port":"The port must be a whole number from 1 to 65535.","error.mail_region":"That is not an AWS region, like us-east-1.","error.mail_in_code":"The mail service is set in code, so it cannot be changed here.","error.mail_from":"Enter the address reports come from, like reports@example.com.","error.smtp_starttls":"The SMTP server does not offer STARTTLS. Pick TLS or none for Security.","error.unknown_account":"That account no longer exists.","error.password_short":"Use a password of at least {min} characters.","error.invite_gone":"This invite has expired or was already used. Ask for a new one.","error.too_many_tries":"Too many tries. Wait fifteen minutes and try again.","error.password_current_wrong":"Your current password is not right.","error.password_wrong":"Your password is not right.","error.code_wrong":"That code is not right. Check the time on your phone and try the next one.","error.twofactor_off":"Turn on two-factor sign-in first.","error.twofactor_self":"Turn off your own two-factor sign-in under Account.","error.unknown_invite":"That invite no longer exists.","error.origin_needed":"Set this Runlight's own address first (RUNLIGHT_URL on the server, or origin in routes()), so a connected hub can add link domains and email reports.","error.twofactor_restart":"Too many wrong codes. Start turning on two-factor sign-in again.","error.pick_origin":"Send the dashboard's origin, such as https://stats.example.com","error.pick_hub":"This hub's address is not the one it connected from. Connect the site again from here.","error.pick_return":"Send the dashboard's address with /pick-return on the end, on its origin, and a nonce of 32 hex digits","assistant.viewerDaily":"Questions each viewer can ask a day","assistant.viewerDailyHint":"Every question is paid for with your AI key. Viewers are the people you invite under People who can read stats but change nothing, and each of them can ask this many a day. Set 0 to keep the assistant for owners. Share links never get the assistant.","error.assistant_soon":"You have asked a lot in a short time. Wait a little and ask again.","error.assistant_daily":"Viewers can ask {limit} questions a day. Ask again tomorrow.","error.assistant_limit":"Use a whole number from 0 to 1,000.","error.token_unset":"Set RUNLIGHT_TOKEN, or pass token or authorize to routes(). Without one, Runlight only runs open when NODE_ENV is development.","error.unauthorized":"Sign in or send a token to see this.","error.sign_in":"Sign in first.","error.unknown_site":"That site is not here.","error.filters_max":"Use at most {max} filters at once.","error.filter_bad":'The filter "{filter}" is not one Runlight reads.',"error.range_bad":"Those dates are not a range Runlight can read.","error.compare_bad":'"{compare}" is not a comparison Runlight knows.',"error.compare_range_bad":"Pick both dates to compare with.","error.send_json":"Send this as JSON.","error.send_object":"Send a JSON object.","error.unknown_domain":"That domain is not one of this site's.","error.rows_needed":"Send the links as a list of rows.","error.unknown_link":"That link no longer exists.","error.not_found":"That is not here.","error.unknown_goal":"That goal no longer exists.","error.goal_invalid":"The goal was not saved ({detail}).","error.funnel_invalid":"The funnel was not saved ({detail}).","error.import_failed":"The import stopped ({detail}).","error.assistant_failed":"The AI service did not answer as expected ({detail}).","error.assistant_invalid":"The assistant was not saved ({detail}).","error.site_invalid":"The site was not saved ({detail}).","error.connect_failed":"Connecting did not start ({detail}).","error.method_not_allowed":"That cannot be done here.","error.unknown_report":"That report no longer exists.","error.unknown_share":"That share link no longer exists.","error.token_name":"Name the token.","error.token_site":"A token that changes settings is for one site. Pick the site.","error.unknown_token":"That token no longer exists.","error.sites_in_code":"Sites are set in code here, so they are changed there.","error.connect_url":"Enter the install's address, like https://example.com/runlight","error.connect_not_runlight":"{url} did not answer like a Runlight install.","error.connect_endpoints":"{url} named endpoints on another address.","error.connect_old":"{url} runs an older Runlight. Update it, or connect it with an API token from its Settings.","error.connect_register":"{url} would not let this server connect. {reason}","error.connect_expired":"That connection took too long or was already used. Start again.","error.connect_denied":"The connection was not allowed.","error.connect_refused":"The install would not let this server connect. Start again, or connect it with an API token.","error.connect_token":"The install did not give this server a token. Start again.","error.connect_again":"Connect this site again to change it from here.","error.hub_domains":"A connected hub cannot change a site's domains.","error.site_domains":"Your account cannot change a site's domains.","error.observe_many":"Send at most 500 fetches at a time.","error.observe_url":"Send the page's address.","error.site_remote":"This site is counted by its own Runlight. Connect it again from its settings to change it from here.","error.unknown_funnel":"That funnel no longer exists.","error.assistant_dashboard":"Only the dashboard can use the assistant.","error.share_not_available":"That is not available on a shared dashboard.","error.assistant_unset":"The assistant is not set up yet. An owner can set it up in Settings, AI Assistant.","error.question_needed":"Ask a question.","error.site_name":"A site name is 1 to 80 characters.","error.unknown_timezone":'"{timezone}" is not a timezone Runlight knows.',"error.retention_bad":"Keep visits for {months} months, or forever.","error.share_gone":"This share link no longer works.","error.token_read_only":"API tokens can only read.","error.icon_none":"This site has no icon.","error.event_needed":"Name the event.","error.property_bad":"That is not a property name Runlight can read.","error.unknown_dimension":'"{dimension}" is not a breakdown Runlight knows.',"error.internal":"Something went wrong on the server. Try again.","error.busy":"Runlight is busy checking other sign-ins. Try again in a moment.","error.tables_busy":"Runlight is creating or upgrading its tables. Try again in a minute.","filter.max":"Up to {max} filters apply at once. Remove one to add another.","error.sample_soon_hub":"A connected hub can send one sample every ten minutes. Wait a few minutes and try again.","people.demoteSelf":"Only the owner or an admin can change it back.","people.demoteConfirm":"Switch to {role}","error.check_not_public":"it is not a public domain name","error.check_timeout":"it took too long to answer","error.check_https":"it could not be reached over HTTPS","error.check_not_runlight":"something answered, but not Runlight","error.check_status":"it answered {status}","error.assistant_address":"Enter the service's address in Settings, AI Assistant.","error.address_refused":"{host} is a link-local or cloud metadata address, which Runlight never connects to.","error.redirect_refused":"{host} redirected to {to}. Runlight sends a service's key and request only to the address it was set up with, so set it up with that address instead.","error.assistant_address_bad":"Enter the service's address, starting with https://","error.assistant_cancelled":"The question was cancelled.","error.assistant_key":"Enter your {provider} key.","error.assistant_model":"Enter a model in Settings, AI Assistant.","error.assistant_no_models":"{host} listed no models. Type the model's name instead.","error.assistant_provider":"Choose an AI service in Settings, AI Assistant.","error.assistant_refused":"{host} turned the request down ({detail}).","error.assistant_slow":"That question took too long to answer. Try asking something narrower.","error.assistant_status":"{host} answered {status}.","error.assistant_steps":"The assistant needed too many steps for that question. Try asking something narrower.","error.assistant_timeout":"{host} took too long to answer.","error.funnel_exists":'There is already a funnel called "{name}".',"error.funnel_long":"A funnel has at most eight steps.","error.funnel_name":"Give the funnel a name.","error.funnel_page_bad":'"{match}" is not a path or a URL.',"error.funnel_short":"A funnel needs at least two steps.","error.goal_amount":"Enter an amount, like 49 or 9.99.","error.goal_click_taken":'The click goal "{match}" already sends events with that name.',"error.goal_currency":"Use a three-letter currency code, like USD or EUR.","error.goal_event":"Enter the event's name.","error.goal_event_taken":'An event goal already counts events called "{name}", so give this click goal another name.',"error.goal_exists":'There is already a goal called "{name}".',"error.goal_kind":"Pick what the goal counts, an event, a page visit, or a click.","error.goal_link":"Enter the link's address, like https://buy.stripe.com/*","error.goal_name":"Give the goal a name.","error.goal_page":"Enter a page path, like /thanks or /blog/*","error.goal_page_bad":"That page is not a path or a URL.","error.goal_prop_kind":"Only an event goal can take its amount from the event. Use a fixed amount instead.","error.goal_prop_name":"A property name uses letters, numbers, dots, dashes, and underscores.","error.goal_selector":"Enter a CSS selector, like #signup or .buy-button","error.import_day_full":"One day has more than {limit} events, more than an import step can read.","error.import_key":"Enter your {service} key.","error.import_refused":"The key or sign-in was refused.","error.import_slug_bad":"/{slug} has characters Runlight slugs cannot use.","error.import_slug_taken":'/{slug} is already used by "{name}".',"error.import_source":"Runlight cannot import from {source}.","error.import_status":"{host} answered {status}.","error.import_umami_address":"Enter your Umami address, like https://stats.example.com","error.import_umami_login":"Enter an API key, or a username and password.","error.import_website":"Pick the Umami website to import.","error.import_csv_batch":"Send at most {max} rows at a time.","error.import_moving":"Visits are still being copied into ClickHouse. Import once that has finished.","error.import_csv_format":"This file is not an Umami export or in Runlight's visit format. Check its header row.","error.install_refused":"That install refused the token.","error.install_token":"Enter an API token from that install.","error.site_domain_invalid":'"{host}" is not a domain name.',"error.site_domain_needed":"Add the site's domain, like example.com","error.site_domain_taken":"{host} already belongs to {site}.","share.goneTitle":"This share link no longer works","error.token_manage_only":"A manage token changes only its own site's settings.","empty.pages.title":"Your top pages will show up here","empty.pages.hint":"Every page people open is listed, with how long they stay on it.","empty.sources.title":"Your traffic sources will show up here","empty.sources.hint":"The searches and sites that send people your way are listed by name.","empty.locations.title":"Your visitors\u2019 locations will show up here","empty.locations.hint":"See which countries and cities people visit from.","empty.rhythm.title":"Your busiest times will show up here","empty.rhythm.hint":"Each hour of the week fills in as visits come in.","empty.ai.title":"AI agents reading your site will show up here","empty.ai.hint":"Count AI agents with a Runlight CMS plugin, app middleware, or server logs. The tracking script alone cannot see most agents.","empty.devices.title":"Your visitors\u2019 devices will show up here","empty.devices.hint":"See which browsers and screens people use.","empty.events.title":"Your events will show up here","empty.events.hint":"Clicks on outbound links and the events you send are counted as they happen.","empty.campaigns.title":"Your campaigns will show up here","empty.campaigns.hint":"Visits from links with UTM tags are grouped by campaign, source, and medium.","empty.links.title":"Your short links will show up here","empty.links.hint":"Make a short link to share, and every click on it is counted.","sites.refused":"{host} no longer accepts this server\u2019s connection, so its numbers cannot be read. Connect it again to fix that.","sites.connected":"Connected to {host}.","links.totalTip":"All clicks on your short links in the dates you picked","links.setup":"How to set it up","links.recordType":"Type","links.recordName":"Name","links.recordValue":"Value","links.doDns":"Add this record at your DNS provider.","links.doDnsAlias":"Add this record at your DNS provider. If it has no ALIAS records, use an A record to your server\u2019s IP address.","links.doHttps":"Have your host serve HTTPS for {domain}.","links.doCheck":"Check again. A new record can take a few minutes to arrive.","links.localNote":"This dashboard runs at {host}, so the record works once it has a public address.","links.guide":"Setup guide","funnels.emptyTitle":"Your funnels will show up here","share.emptyTitle":"Your share links will show up here","tokens.emptyTitle":"Your tokens will show up here","reports.emptyTitle":"Your email reports will show up here","journeys.emptyTitle":"The paths people take will show up here","props.emptyTitle":"This event\u2019s details will show up here","empty.mini":"This list fills in as visits come in.","empty.search":"Nothing here matches \u201C{q}\u201D yet, so try another word.","delta.fromNone":"from 0","people.admin":"Admin","people.member":"Member","people.handOver":"Make owner","people.handOverHint":"Hands ownership to this admin, and you become an admin","people.handOverConfirm":"Hand over","people.demotedMember":"You are a member now, so People and the install-wide settings are closed to you. The owner or an admin can change it back.","account.admin":"You are an admin, so you can change everything and manage people, apart from the owner.","account.member":"You are a member, so you can change the settings of every site. The owner and admins manage people and the install-wide settings.","mail.adminOnly":"No mail service is set up yet. The owner or an admin can set one up here.","error.admin_only":"Only the owner or an admin can change this.","error.owner_protected":"Nobody but the owner can change or remove the owner.","error.owner_hand_over":"Only the owner can hand over ownership.","error.owner_needs_admin":"Make them an admin first.","embed.goneTitle":"This dashboard link does not work","embed.gone":"Open the dashboard again from your site's admin pages.","embed.expiredTitle":"This view has expired","embed.expired":"The dashboard inside your admin pages stays open for an hour at a time. Reload the page to open it again.","embed.reload":"Reload the page","tokens.embeds":"Opens the dashboard in a CMS","error.embed_expired":"This dashboard has expired. Reload the page to open it again.","error.embed_site":"A dashboard key is for one site. Pick the site.","error.embed_token":"Use the site's dashboard key, made in Settings, Install, under WordPress, Drupal, and Craft.","error.embed_origin":"Send the admin page's origin, such as https://example.com","error.embed_host":"{host} is not one of this site's domains. Add it to the site's domains, in Settings, General, or in code when sites are set there.","error.token_embed_only":"A dashboard key only opens the dashboard inside a CMS.","pick.doneTitle":"Picked","pick.done":"It is in the goal on your dashboard. You can close this tab.","pick.goneTitle":"This pick did not reach the dashboard","pick.gone":"It was not started from this browser's dashboard, or it was sent already. Go back to the dashboard and pick again.","plugin.keysHint":"These optional keys are for CMS plugins. You do not need them to install the tracking script.","live.quietTitle":"No activity in the last 30 minutes","live.noPages":"No recent pageviews","live.noSources":"No recent sources","live.noCountries":"Location unavailable for recent visits","goals.pickBlocked":"Allow pop-ups for this dashboard, then try again.","goals.pickWaiting":"Choose an element in the new tab. No picker? Check that the Runlight script is installed and allowed by the site's security policy.","sites.search":"Search sites","plugin.revoke":"Revoke key","goals.value.fixedHint":"Enter your own amount below. Every conversion gets this value.","goals.value.propHint":"The amount comes from your website with each event. The field below names the property to read, not the amount. To enter one value here, choose A fixed amount.","sites.addNew":"Add New Site","assistant.action.goal":"Create goal","assistant.action.funnel":"Create funnel","assistant.action.invite":"Send invitation","assistant.action.report":"Create email report","assistant.action.share":"Create share link","assistant.action.allSites":"All sites in this install","assistant.action.email":"Email","assistant.action.shareHint":"Anyone with this link can read this site\u2019s dashboard.","assistant.action.inviteHint":"This grants the selected role for the current site only. An invitation email will be sent if mail is configured.","assistant.action.reportHint":"Weekly reports use the previous week; monthly reports use the previous month. Delivery starts at 8am on Monday or the first of the month, in the site\u2019s timezone, when the scheduler runs.","assistant.action.review":"Review these details. Nothing happens until you click the button below.","assistant.action.denied":"Your account cannot perform this action.","assistant.action.saving":"Creating\u2026","assistant.action.done":"Created successfully.","assistant.action.cancelled":"Cancelled. Nothing was created.","assistant.action.failed":"Could not confirm creation.","assistant.action.openLink":"Open link","assistant.action.ready":"Review this draft before creating it.","assistant.action.incomplete":"I could not prepare a complete draft. Please provide the missing details or rephrase your request.","assistant.action.unknown":"Check Settings before trying again, in case the request completed.","assistant.action.invited":"Invitation sent.","assistant.action.inviteManual":"Invitation created, but no email was sent. Open the link to share it yourself.","people.areYouSure":"Are you sure?","people.handOverWarning":"This makes {email} the owner of this entire Runlight instance and ALL its sites. You will become an admin and cannot take ownership back yourself.","people.handOverWarningSingle":"This makes {email} the owner of this Runlight install. You will become an admin and cannot take ownership back yourself.","people.confirmOwnership":"I understand this transfers ownership of this install.","people.confirmAllSites":"I understand this transfers ownership of all sites.","people.allSites":"Invite to all sites","people.allSitesHint":"This invitation grants access to every current and future site.","people.siteHint":"This invitation grants access only to {site}.","ai.setup":"Set up AI agent tracking","sites.deleteAcknowledge":"I understand this permanently deletes this site and its data.","sites.deleting":"Removing...","account.siteMember":"You can change settings for {site} only.","account.siteViewer":"You can read reports for {site} only.","welcome.waiting":"Waiting for the first visit","welcome.waitingHint":"This page fills in automatically once a visit arrives.","app.signOutConfirm":"Sign out of Runlight?"};var Ne=[["en","English"],["fr","Fran\xE7ais"],["es","Espa\xF1ol"],["de","Deutsch"],["pt","Portugu\xEAs"]],_s="runlight_language",Na=(()=>{try{return JSON.parse(document.getElementById("app")?.dataset.locales??"{}")}catch{return{}}})(),Ss="en",Je=Ae,Cs=new Intl.PluralRules("en");function Q(){return Ss}function Ts(){let t=null;try{t=localStorage.getItem(_s)}catch{}let n=[t,...navigator.languages??[navigator.language]].filter(Boolean);for(let s of n){let a=s.toLowerCase().split("-")[0];if(Ne.some(([i])=>i===a))return a}return"en"}async function Ht(t,n=!1){if(t==="en")Je=Ae;else{let s=Na[t];if(!s)throw new Error(`No messages for ${t}`);let a=await fetch(s);if(!a.ok)throw new Error(`Could not load ${t}`);Je={...Ae,...await a.json()}}if(Ss=t,Cs=new Intl.PluralRules(t),document.documentElement.lang=t,n)try{localStorage.setItem(_s,t)}catch{}}function xn(t,n){return t.replace(/\{(\w+)\}/g,(s,a)=>a in n?String(n[a]):s)}function Ms(t){return Object.prototype.hasOwnProperty.call(Ae,t)}function o(t,n={}){return xn(Je[t]??Ae[t]??t,n)}function X(t,n,s={}){let a=Cs.select(n),i=Je,l=i[`${t}_${a}`]??i[`${t}_other`]??Ae[`${t}_other`]??t;return xn(l,{n,...s})}function ve(t,n={}){let s=`error.${t}`,a={...Ae,...Je},i=a[s];if(i===void 0)return null;let l=n.field&&a[`mail.field.${n.field}`];return xn(i,l?{...n,field:l}:n)}function fe(t,n){let s=Je[t]??Ae[t]??t,a=[],i=0;for(let l of s.matchAll(/\{(\w+)\}/g))a.push(s.slice(i,l.index)),a.push(n[l[1]]??l[0]),i=(l.index??0)+l[0].length;return a.push(s.slice(i)),a}var Fa=0;function e(t,n,s,a,i,l){n||(n={});var r,c,d=n;if("ref"in d&&typeof t!="function")for(c in d={},n)c=="ref"?r=n[c]:d[c]=n[c];var u={type:t,props:d,key:s,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Fa,__i:-1,__u:0};return(i||l)&&(u.__source=i,u.__self=l),Y.vnode&&Y.vnode(u),u}function ne({chart:t=!1}){let[n,s]=m(!1);return F(()=>{let a=window.setTimeout(()=>s(!0),300);return()=>window.clearTimeout(a)},[]),e("div",{class:t?"loading-skeleton loading-chart":"loading-skeleton",role:"status",children:[e("span",{class:"visually-hidden",children:o("common.loading")}),e("div",{"aria-hidden":"true",style:{visibility:n?"visible":"hidden"},children:t?e("span",{class:"chart-spinner"}):[72,56,83,43,63].map(a=>e("div",{class:"loading-row",children:[e("span",{style:{width:`${a}%`}}),e("span",{})]}))})]})}function Ot(){return e("div",{class:"settings-loading",role:"status",children:[e("span",{class:"chart-spinner","aria-hidden":"true"}),e("span",{children:o("common.loading")})]})}function Nt(t=1e4,n=64){let s=new Map;return{clear:()=>s.clear(),peek(a){return s.get(a)?.value},read(a,i){let l=s.get(a);if(l&&l.until>Date.now())return l.result;s.delete(a);let r={until:1/0,result:Promise.resolve().then(i),value:l?.value};for(s.set(a,r);s.size>n;)s.delete(s.keys().next().value);return r.result=r.result.then(c=>(r.value=c,r.until=Date.now()+t,c),c=>{throw s.get(a)===r&&s.delete(a),c}),r.result}}}var le=document.getElementById("app")?.dataset.base??"",mt=document.getElementById("app")?.dataset.share??"",Pe=document.getElementById("app")?.dataset.embedOrigin??"",As=document.getElementById("app")?.dataset.embed??"",Rs=!!As,Ie=!!(mt||Pe),Es=document.getElementById("app")?.dataset.csrf??"",Ps=t=>({...t?{"content-type":"application/json"}:{},...Es?{"x-runlight-csrf":Es}:{}}),Ft=()=>mt?{"x-runlight-share":mt}:Pe?{"x-runlight-embed":As}:void 0,kn=new Set;function Is(t){return kn.add(t),()=>kn.delete(t)}function Ls(t){if(!Pe||t.status!==401)return!1;for(let n of kn)n();return!0}var Le=document.getElementById("app")?.dataset.signOut??"",_n=document.getElementById("app")?.dataset.signIn??"",Qe=document.getElementById("app")?.dataset.accounts!==void 0,Ds=document.getElementById("app")?.dataset.geoCredit!==void 0,_e=document.getElementById("app")?.dataset.cms??"",ae={managed:!1},Re=class extends Error{constructor(s,a,i=""){super(a);rn(this,"status",s);rn(this,"code",i)}};async function ht(t){let n=await t.json().catch(()=>null),s=n?.code&&ve(n.code,n.params)||n?.error||ve("http",{status:String(t.status)});return new Re(t.status,s,n?.code??"")}async function gt(t,n){try{return await fetch(t,n)}catch(s){throw s?.name==="AbortError"?s:new Re(0,ve("network"),"network")}}var Ze=Nt(),Ua=Nt(1e3),Xe=Nt(3e4,1),za=new Set(["stats","series","breakdown","goals","funnels","rhythm"]);function $s(){Ze.clear()}function Z(t,n){let s=()=>ja(t,n);return t==="realtime"?Ua.read(`${le}/${t}?${n}:${JSON.stringify(Ft())}`,s):za.has(t)||t==="links"||/^links\/[a-f0-9]+$/.test(t)?Ze.read(`${le}/${t}?${n}:${JSON.stringify(Ft())}`,s):s()}async function ja(t,n){let s=await gt(`${le}/api/${t}?${n}`,{credentials:"same-origin",headers:Ft()});if(!s.ok)throw Ls(s),await ht(s);return s.json()}async function et(t,n){let s=await gt(`${le}/api/${t}?${n}`,{credentials:"same-origin",headers:Ft()});if(!s.ok)throw Ls(s),await ht(s);let a=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??"")?.[1]??"runlight-export",i=document.createElement("a");i.href=URL.createObjectURL(await s.blob()),i.download=a,document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(i.href),1e4)}function re(t){let n=new URLSearchParams;t.site&&n.set("site",t.site),t.from&&t.to?(n.set("from",t.from),n.set("to",t.to)):n.set("period",t.period);for(let s of t.filters)n.append("filter",`${s.dimension}:${s.op}:${s.value}`);return n.set("compare",t.compare),t.compare==="custom"&&(n.set("compare_from",t.compareFrom),n.set("compare_to",t.compareTo)),n}async function K(t,n,s){Ze.clear(),(n.startsWith("assistant")||n.startsWith("account"))&&Xe.clear();try{let a=await gt(`${le}/api/${n}`,{method:t,credentials:"same-origin",headers:Ps(!0),body:JSON.stringify(s)});if(!a.ok)throw await ht(a);return await a.json()}finally{Ze.clear(),(n.startsWith("assistant")||n.startsWith("account"))&&Xe.clear()}}var ye=async t=>{Ze.clear(),(t.startsWith("assistant")||t.startsWith("account"))&&Xe.clear();try{let n=await gt(`${le}/api/${t}`,{method:"DELETE",credentials:"same-origin",headers:Ps(!1)});if(!n.ok)throw await ht(n)}finally{Ze.clear(),(t.startsWith("assistant")||t.startsWith("account"))&&Xe.clear()}},te=t=>t?`?site=${encodeURIComponent(t)}`:"",R={links:t=>Z("links",re(t)),link:(t,n)=>Z(`links/${n}`,re(t)),createLink:(t,n)=>K("POST",`links${te(t)}`,n),updateLink:(t,n,s)=>K("PATCH",`links/${n}${te(t)}`,s),deleteLink:(t,n)=>ye(`links/${n}${te(t)}`),importLinks:(t,n)=>K("POST",`links/import${te(t)}`,{rows:n}),importStep:(t,n,s,a,i)=>K("POST",`links/import/${n}${te(t)}`,{credentials:s,cursor:a,done:i}),observeKey:t=>Z("observe-key",new URLSearchParams({site:t})),newObserveKey:t=>K("POST",`observe-key/new${te(t)}`,{}),goalDefinitions:t=>Z("goals",new URLSearchParams({site:t,definitions:"1"})),funnelDefinitions:t=>Z("funnels",new URLSearchParams({site:t,definitions:"1"})),funnels:t=>Z("funnels",re(t)),saveFunnel:(t,n,s)=>K(n?"PATCH":"POST",`funnels${n?`/${n}`:""}${te(t)}`,s),deleteFunnel:(t,n)=>ye(`funnels/${n}${te(t)}`),account:()=>Z("account",new URLSearchParams),changePassword:(t,n,s=!1)=>K("POST","account/password",{current:t,next:n,...s?{revokeTokens:!0}:{}}),signOutEverywhere:()=>K("POST","account/sign-out-everywhere",{}),twoFactorStart:t=>K("POST","account/2fa/start",{password:t}),twoFactorConfirm:t=>K("POST","account/2fa/confirm",{code:t}),twoFactorRecovery:t=>K("POST","account/2fa/recovery",{password:t}),twoFactorDisable:t=>K("POST","account/2fa/disable",{password:t}),pickTicket:(t,n,s,a)=>K("POST",`pick${te(t)}`,{origin:n,return:s,nonce:a}),resetTwoFactor:(t,n)=>K("DELETE",`people/${t}/2fa`,{password:n}),people:()=>Z("people",new URLSearchParams),addPerson:(t,n,s)=>K("POST","people",{email:t,role:n,...s===void 0?{allSites:!0}:{site:s}}),resendInvite:t=>K("POST",`invites/${t}/resend`,{}),cancelInvite:t=>ye(`invites/${t}`),handOver:(t,n)=>K("POST",`people/${t}/owner`,{password:n}),setRole:(t,n)=>K("PATCH",`people/${t}`,{role:n}),removePerson:t=>ye(`people/${t}`),eventProps:(t,n,s)=>{let a=re(t);return a.set("event",n),s&&a.set("key",s),Z("event-props",a)},umamiWebsites:t=>K("POST","import/umami/websites",{credentials:t}),importVisits:(t,n,s,a)=>K("POST",`import/umami/visits${te(t)}`,{credentials:n,website:s,cursor:a}),importCsvVisits:(t,n,s)=>K("POST",`import/csv/visits${te(t)}`,{rows:n,...s?{secret:s}:{}}),goals:t=>Z("goals",re(t)),goal:(t,n)=>Z(`goals/${n}`,re(t)),createGoal:(t,n)=>K("POST",`goals${te(t)}`,n),updateGoal:(t,n,s)=>K("PATCH",`goals/${n}${te(t)}`,s),deleteGoal:(t,n)=>ye(`goals/${n}${te(t)}`),mail:t=>Z("mail",new URLSearchParams(t?{site:t}:{})),connect:(t,n)=>K("POST","sites/connect",{url:t,...n?{site:n}:{}}),assistant:()=>Xe.read("assistant",()=>Z("assistant",new URLSearchParams)),cachedAssistant:()=>Xe.peek("assistant"),saveAssistant:t=>K("PUT","assistant",t),removeAssistant:()=>ye("assistant"),saveAssistantLimit:t=>K("PUT","assistant/limits",{viewerDaily:t}),assistantModels:t=>K("POST","assistant/models",t),ask:(t,n,s,a)=>K("POST","assistant/chat",{site:t,messages:n,view:s,language:a}),saveMail:t=>K("PUT","mail",t),removeMail:()=>ye("mail"),testMail:(t,n)=>K("POST","mail/test",{to:t,lang:n}),reports:t=>Z("reports",new URLSearchParams(t?{site:t}:{})),addReport:(t,n)=>K("POST",`reports${te(t)}`,n),deleteReport:(t,n)=>ye(`reports/${n}${te(t)}`),sendReport:(t,n)=>K("POST",`reports/${n}/send${te(t)}`,{}),tokens:()=>Z("tokens",new URLSearchParams),createToken:(t,n,s)=>K("POST","tokens",{name:t,site:n,...s?{scope:s}:{}}),deleteToken:t=>ye(`tokens/${t}`),shares:t=>Z("shares",new URLSearchParams(t?{site:t}:{})),createShare:(t,n)=>K("POST",`shares${te(t)}`,{name:n}),renameShare:(t,n,s)=>K("PATCH",`shares/${n}${te(t)}`,{name:s}),deleteShare:(t,n)=>ye(`shares/${n}${te(t)}`),linkDomains:t=>Z("link-domains",new URLSearchParams(t?{site:t}:{})),addLinkDomain:(t,n)=>K("POST",`link-domains${te(t)}`,{domain:n}),checkLinkDomain:(t,n)=>Z(`link-domains/${encodeURIComponent(n)}/check`,new URLSearchParams(t?{site:t}:{})),removeLinkDomain:(t,n)=>ye(`link-domains/${encodeURIComponent(n)}${te(t)}`),updateSite:(t,n)=>K("PATCH",`sites/${encodeURIComponent(t)}`,n),about:async()=>{let t=await gt(`${le}/api`,{credentials:"same-origin"});if(!t.ok)throw await ht(t);return await t.json()},sites:()=>Z("sites",new URLSearchParams).then(t=>(ae.managed=!!t.managed,t)),addSite:t=>K("POST","sites",t),deleteSite:(t,n)=>K("DELETE",`sites/${encodeURIComponent(t)}`,n===void 0?{}:{password:n}),stats:t=>Z("stats",re(t)),hostnameSuggestions:t=>{let n=re({...t,compare:"off",compareFrom:"",compareTo:""});return n.set("dimension","hostname"),n.set("limit","12"),n.set("suggestions","1"),Z("breakdown",n)},series:t=>Z("series",re(t)),breakdown:(t,n,s)=>{let a=re({...t,compare:"off",compareFrom:"",compareTo:""});return a.set("dimension",n),a.set("limit",String(Math.max(50,s))),Z("breakdown",a).then(i=>({...i,rows:i.rows.slice(0,s)}))},rhythm:t=>Z("rhythm",re(t)),journeys:(t,n)=>{let s=re(t);return s.set("steps",String(n.steps)),n.start&&s.set("start",n.start),n.end&&s.set("end",n.end),n.through&&s.set("through",`${n.through.step}:${n.through.value}`),Z("journeys",s)},realtime:t=>Z("realtime",new URLSearchParams(t?{site:t}:{}))};function Ut({site:t}){let[n,s]=m(null),a=n===t.id,i=(t.name.replace(/^www\./,"")[0]??"R").toUpperCase();return a?e("span",{class:"avatar letter","aria-hidden":"true",children:i}):e("img",{class:"avatar",src:`${le}/api/icon?site=${encodeURIComponent(t.id)}`,alt:"",width:40,height:40,onError:()=>s(t.id)})}var zt=new Map;function Sn(t,n){let s=`${Q()}|${t}`;if(!zt.has(s))try{zt.set(s,n())}catch{zt.set(s,null)}return zt.get(s)}var ft=(t,n)=>Sn(t,()=>new Intl.NumberFormat(Q(),n)),vt=(t,n)=>Sn(t,()=>new Intl.DateTimeFormat(Q(),n));function tt(t){return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,n=>{try{let s=decodeURIComponent(n);return/[\s/?#%\p{C}]/u.test(s)?n:s}catch{return n}})}function O(t){return t<1e4?De(t):ft("compact",{notation:"compact",maximumFractionDigits:1}).format(t)}function De(t){return ft("whole",{}).format(t)}function Hs(t){return ft("decimal",{minimumFractionDigits:1,maximumFractionDigits:1}).format(t)}function ce(t){return ft("percent",{style:"percent",maximumFractionDigits:0}).format(t)}function Fe(t){let n=Math.round(t/1e3);if(n<60)return`${n}s`;let s=Math.floor(n/60);return s<60?`${s}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m`}function Cn(t,n){return n===void 0||n===0?null:(t-n)/n}function we(t){try{return Sn("regions",()=>new Intl.DisplayNames([Q()],{type:"region"}))?.of(t)??t}catch{return t}}function xe(t){return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(n=>127397+n.charCodeAt(0))):""}function jt(t,n,s){let a=n==="hour"?{hour:"numeric",timeZone:s}:n==="month"?{month:"short",year:"numeric",timeZone:s}:{month:"short",day:"numeric",timeZone:s};return vt(`bucket|${n}|${s}`,a).format(new Date(t))}function de(t,n=!0){let s=n?{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"};return vt(`day|${n}`,s).format(new Date(`${t}T00:00:00Z`))}function Tn(t,n){return vt("month",{month:"long",year:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(t,n,1)))}function Bt(t){let n=vt(`weekday|${t}`,{weekday:t,timeZone:"UTC"});return Array.from({length:7},(s,a)=>n.format(new Date(Date.UTC(2024,0,1+a))))}function nt(t){return vt("hour",{hour:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(2024,0,1,t)))}function Ge(t,n){let s=Number.isInteger(t),a=ft(`money:${n}:${s}`,{style:"currency",currency:n,minimumFractionDigits:s?0:2,maximumFractionDigits:2});return a?a.format(t):`${t} ${n}`}var qt=[{key:"visitors",slot:1,format:O},{key:"visits",slot:2,format:O},{key:"pageviews",slot:3,format:O},{key:"viewsPerVisit",slot:4,format:Hs},{key:"bounceRate",slot:5,format:ce,lowerIsBetter:!0},{key:"visitDuration",slot:7,format:Fe}],Kt=t=>o(`metric.${t.key}`),Os=t=>o(`hint.${t.key}`),Vt=6,Ns=3;function Fs(t){return qt.find(n=>n.key===t)}var Bs=t=>({key:t.key,slot:t.slot,label:Kt(t),format:t.format}),Us={top:18,right:14,bottom:30,left:52};function zs(t){if(t<=0)return 1;let n=10**Math.floor(Math.log10(t));for(let s of[1,1.5,2,2.5,3,4,5,6,8,10])if(s*n>=t)return s*n;return 10*n}function st({points:t,previous:n,metrics:s,interval:a,timezone:i,shared:l,height:r=300}){let c=r,d=q(null),[u,g]=m(800),[h,v]=m(null);F(()=>{let C=d.current;if(!C)return;let _=new ResizeObserver(([P])=>P&&g(Math.max(280,P.contentRect.width)));return _.observe(C),()=>_.disconnect()},[]);let p=s.length===1||l?s[0]:void 0,y={...Us,left:p?Us.left:16},w=u-y.left-y.right,f=c-y.top-y.bottom,b=t.length>1?w/(t.length-1):0,S=C=>y.left+(t.length>1?C*b:w/2),E=n??[],$=C=>Math.max(0,...t.map(_=>_[C.key]??0),...E.map(_=>_[C.key]??0)),A=zs(Math.max(0,...s.map($))),x=new Map(s.map(C=>[C.key,l?A:zs($(C))])),k=(C,_)=>y.top+f-(_??0)/(x.get(C.key)??1)*f,L=y.top+f,N=Math.max(1,Math.ceil(t.length/Math.max(2,Math.floor(w/92)))),D=C=>{let _=C.currentTarget.getBoundingClientRect(),P=Math.round((C.clientX-_.left-y.left)/(b||1));v(t.length?Math.min(t.length-1,Math.max(0,P)):null)},H=h!==null?t[h]:void 0,M=[0,.25,.5,.75,1];return e("div",{class:"chart",ref:d,children:[e("svg",{width:u,height:c,role:"img","aria-label":o("chart.label",{metrics:s.map(C=>C.label).join(", ")}),onPointerMove:D,onPointerLeave:()=>v(null),children:[M.map(C=>e("line",{class:C===0?"gridline base":"gridline",x1:y.left,x2:u-y.right,y1:L-C*f,y2:L-C*f})),p?M.filter((C,_)=>_%2===0).map(C=>e("text",{class:"axis",x:y.left-10,y:L-C*f+4,"text-anchor":"end",children:p.format((x.get(p.key)??1)*C)})):null,t.map((C,_)=>_%N===0?e("text",{class:"axis",x:S(_),y:c-8,"text-anchor":_===0?"start":"middle",children:jt(C.start,a,i)}):null),s.map(C=>{if(E.length<2)return null;let _=js(E.map((P,U)=>S(U)),E.map(P=>k(C,P[C.key])));return e("path",{class:`then s${C.slot}`,d:_})}),s.map(C=>{let _=js(t.map((U,G)=>S(G)),t.map(U=>k(C,U[C.key]))),P=t.length?`${_}L${S(t.length-1).toFixed(1)},${L}L${S(0).toFixed(1)},${L}Z`:"";return e("g",{class:`series s${C.slot}`,children:[s.length<=Ns&&(!l||C===s[0])?e("path",{class:"area",d:P}):null,e("path",{class:"line",d:_})]})}),H&&h!==null?e("g",{children:[e("line",{class:"cursor",x1:S(h),x2:S(h),y1:y.top,y2:L}),s.map(C=>e("circle",{class:`dot s${C.slot}`,cx:S(h),cy:k(C,H[C.key]),r:4.5}))]}):null]}),H&&h!==null?e("div",{class:S(h)>u/2?"tip left":"tip",style:{left:`${S(h)}px`},children:[e("span",{class:"tip-when",children:jt(H.start,a==="hour"?"hour":a==="month"?"month":"day",i)}),s.map(C=>{let _=h!==null?E[h]:void 0;return e("span",{class:"tip-row",children:[e("span",{class:`swatch s${C.slot}`}),e("span",{class:"tip-label",children:C.label}),e("strong",{children:C.format(H[C.key]??0)}),_?e("span",{class:"tip-then",children:C.format(_[C.key]??0)}):null]})}),h!==null&&E[h]?e("span",{class:"tip-then-when",children:o("chart.then",{when:jt(E[h].start,a==="hour"?"hour":a==="month"?"month":"day",i)})}):null]}):null]})}function js(t,n){if(t.length===0)return"";let s=`M${t[0].toFixed(2)},${n[0].toFixed(2)}`;for(let a=0;a<t.length-1;a++){let i=t[a-1]??t[a],l=n[a-1]??n[a],r=t[a],c=n[a],d=t[a+1],u=n[a+1],g=t[a+2]??d,h=n[a+2]??u,v=Math.min(c,u),p=Math.max(c,u),y=Math.min(p,Math.max(v,c+(u-l)/6)),w=Math.min(p,Math.max(v,u-(h-c)/6));s+=`C${(r+(d-i)/6).toFixed(2)},${y.toFixed(2)} ${(d-(g-r)/6).toFixed(2)},${w.toFixed(2)} ${d.toFixed(2)},${u.toFixed(2)}`}return s}var Ba="input:not([type=hidden]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])",bt=[];function qa(t){return[...t.querySelectorAll(Ba)].filter(n=>n.getClientRects().length===0||n.closest("[hidden], [inert]")?!1:n instanceof HTMLInputElement&&n.type==="radio"&&n.name&&!n.checked?!t.querySelector(`input[type=radio][name="${CSS.escape(n.name)}"]:checked`):!0)}function be(t){F(()=>{let n=document.activeElement instanceof HTMLElement?document.activeElement:null,s=t.current;if(!s)return;if(bt.push(s),!s.contains(document.activeElement)){let i=s.querySelector("input:not([type=hidden]):not([disabled]), select:not([disabled]), textarea:not([disabled])")??s.querySelector("button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])");i?i.focus():(s.tabIndex=-1,s.focus())}let a=i=>{if(i.key!=="Tab"||bt[bt.length-1]!==s)return;let l=qa(s);if(!l.length){i.preventDefault();return}let r=l[0],c=l[l.length-1],d=document.activeElement;s.contains(d)?i.shiftKey&&(d===r||d===s)?(i.preventDefault(),c.focus()):!i.shiftKey&&d===c&&(i.preventDefault(),r.focus()):(i.preventDefault(),(i.shiftKey?c:r).focus())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a),bt.splice(bt.indexOf(s),1),n?.isConnected&&n.focus()}},[])}var Ka=document.getElementById("app")?.dataset.world??"",yt=null;function Va(){return yt??(yt=fetch(Ka).then(t=>{if(!t.ok)throw new Error(o("map.failed"));return t.json()})),yt.catch(()=>yt=null),yt}var qs=6;function Mn({view:t,onFilter:n,large:s}){let[a,i]=m(null),[l,r]=m([]),[c,d]=m(""),[u,g]=m(null),h=q(null);F(()=>{Va().then(i).catch(f=>d(f.message))},[]),F(()=>{let f=!0;return R.breakdown(t,"country",300).then(b=>f&&r(b.rows)).catch(b=>f&&d(b.message)),()=>{f=!1}},[t]);let v=new Map(l.map(f=>[f.value,f.visitors])),p=Math.max(0,...l.map(f=>f.visitors)),y=f=>f<=0||p===0?0:Math.max(1,Math.ceil(Math.sqrt(f/p)*qs));if(c)return e("p",{class:"empty",children:c});if(!a)return e("div",{class:s?"map large":"map"});let w=u?{id:u.id,n:v.get(u.id)??0}:null;return e("div",{class:s?"map large":"map",ref:h,children:[e("svg",{viewBox:`0 0 ${a.w} ${a.h}`,role:"img","aria-label":o("map.label",{top:l.slice(0,5).map(f=>`${we(f.value)} ${O(f.visitors)}`).join(", ")}),onPointerLeave:()=>g(null),children:a.shapes.map(f=>{let b=v.get(f.id)??0;return e("path",{d:f.d,class:`land q${y(b)}${u?.id===f.id?" hot":""}${f.id&&b?" has":""}`,onPointerMove:S=>{let E=h.current?.getBoundingClientRect();E&&f.id&&g({id:f.id,x:S.clientX-E.left,y:S.clientY-E.top})},onClick:()=>f.id&&b&&n("country",f.id)})})}),w&&w.id?e("div",{class:"map-tip",style:{left:`${u.x}px`,top:`${u.y}px`},children:[e("strong",{children:[xe(w.id)," ",we(w.id)]}),e("span",{children:w.n?X("map.visitors",w.n,{n:O(w.n)}):o("map.none")})]}):null,e("div",{class:"map-scale","aria-hidden":"true",children:[e("span",{children:o("scale.fewer")}),Array.from({length:qs},(f,b)=>e("span",{class:`cell q${b+1}`})),e("span",{children:o("scale.more")})]})]})}function Ks({view:t,onFilter:n,onClose:s}){let[a,i]=m([]),l=q(null);be(l),F(()=>{R.breakdown(t,"country",30).then(c=>i(c.rows)).catch(()=>i([]))},[t]),F(()=>{let c=d=>d.key==="Escape"&&s();return document.addEventListener("keydown",c),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",c),document.body.classList.remove("locked")}},[]);let r=a.reduce((c,d)=>c+d.visitors,0);return e("div",{class:"scrim center",onPointerDown:c=>c.target===c.currentTarget&&s(),children:e("div",{class:"map-sheet",role:"dialog","aria-modal":"true","aria-label":o("map.title"),ref:l,children:[e("header",{class:"drawer-head",children:[e("h2",{children:o("map.title")}),e("button",{type:"button",class:"remove","aria-label":o("common.close"),onClick:s,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),e("div",{class:"map-sheet-body",children:[e(Mn,{view:t,large:!0,onFilter:(c,d)=>{n(c,d),s()}}),e("ol",{class:"map-list",children:a.map(c=>e("li",{children:e("button",{type:"button",onClick:()=>{n("country",c.value),s()},children:[e("span",{class:"map-list-name",children:[xe(c.value)," ",we(c.value)]}),e("span",{class:"map-list-share",children:r?`${Math.round(c.visitors/r*100)}%`:""}),e("b",{children:O(c.visitors)})]})}))})]})]})})}var Ga={signOut:"M6.5 2.5H3v11h3.5M6 8h8M11 5l3 3-3 3","arrow-up":"M8 13V3M4 7l4-4 4 4","arrow-down":"M8 3v10M4 9l4 4 4-4",plus:"M8 3.5v9M3.5 8h9",key:"M10.3 2.5a3.2 3.2 0 1 0 0 6.4 3.2 3.2 0 0 0 0-6.4zM8 7.9l-5.5 5.6M4.2 11.8l1.6 1.6M5.8 10.2l1.4 1.4",copy:"M5.5 5.5V3.8c0-.7.6-1.3 1.3-1.3h5.4c.7 0 1.3.6 1.3 1.3v5.4c0 .7-.6 1.3-1.3 1.3h-1.7M3.8 5.5h5.4c.7 0 1.3.6 1.3 1.3v5.4c0 .7-.6 1.3-1.3 1.3H3.8c-.7 0-1.3-.6-1.3-1.3V6.8c0-.7.6-1.3 1.3-1.3z",check:"M3.5 8.5l3 3 6-7",edit:"M10.5 3l2.5 2.5-7 7H3.5V10z M9 4.5l2.5 2.5",trash:"M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.3c0 .4.4.7.8.7h4.2c.4 0 .8-.3.8-.7l.6-8.3M6.8 7v4M9.2 7v4",download:"M8 3v7.5M5 7.5l3 3 3-3M3 10.5v1.5c0 .6.4 1 1 1h8c.6 0 1-.4 1-1v-1.5",robot:"M5 6h6a1.5 1.5 0 0 1 1.5 1.5v4A1.5 1.5 0 0 1 11 13H5a1.5 1.5 0 0 1-1.5-1.5v-4A1.5 1.5 0 0 1 5 6zM8 6V3.6M8 2.4v.2M6.2 9v.6M9.8 9v.6M6.5 11.2h3M2 8.5v2M14 8.5v2",eye:"M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8s-2.4 4.5-6.5 4.5S1.5 8 1.5 8zM8 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4z",eyeOff:"M1.5 8s2.4-4.5 6.5-4.5c1 0 1.9.3 2.7.7M14.5 8s-2.4 4.5-6.5 4.5c-1 0-1.9-.3-2.7-.7M6.6 6.6a2 2 0 0 0 2.8 2.8M2.5 2.5l11 11",upload:"M8 10.5V3M5 6l3-3 3 3M3 10.5v1.7c0 .7.6 1.3 1.3 1.3h7.4c.7 0 1.3-.6 1.3-1.3v-1.7",chart:"M3 13V8M6.3 13V5M9.7 13V9.5M13 13V3",refresh:"M12.5 6A4.8 4.8 0 1 0 13 9.5M12.5 2.8V6H9.3",reset:"M3.5 6A4.8 4.8 0 1 1 3 9.5M3.5 2.8V6H6.7",list:"M5.5 4.5h7M5.5 8h7M5.5 11.5h7M3 4.5h.01M3 8h.01M3 11.5h.01",expand:"M9.5 3H13v3.5M6.5 13H3V9.5M13 3L9 7M3 13l4-4",x:"M4.5 4.5l7 7M11.5 4.5l-7 7",save:"M3.5 8.5l3 3 6-7",sparkle:"M8 2.5l1.3 3.2 3.2 1.3-3.2 1.3L8 11.5 6.7 8.3 3.5 7l3.2-1.3zM12.5 11l.5 1.5 1.5.5-1.5.5-.5 1.5-.5-1.5-1.5-.5 1.5-.5z",globe:"M8 2.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11zM2.5 8h11M8 2.5c1.5 1.6 2.2 3.4 2.2 5.5S9.5 11.9 8 13.5M8 2.5C6.5 4.1 5.8 5.9 5.8 8s.7 3.9 2.2 5.5",target:"M8 2.5v2M8 11.5v2M2.5 8h2M11.5 8h2M8 5a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM8 7.4a.6.6 0 1 0 0 1.2.6.6 0 0 0 0-1.2z",send:"M13.5 2.5L7 9M13.5 2.5l-4 11-2.5-4.5-4.5-2.5z",share:"M6.8 9.2l2.4-2.4M7.3 4.8l1-1a2.6 2.6 0 0 1 3.7 3.7l-1 1M8.7 11.2l-1 1A2.6 2.6 0 0 1 4 8.5l1-1",page:"M4.5 2h5l3 3v9h-8z M9.5 2v3h3 M6.5 8.5h4M6.5 11h4",arrive:"M9 2.5h3.5v11H9 M2.5 8h7 M6.5 5l3 3-3 3",monitor:"M2.5 3.5h11v7h-11z M6 13.5h4M8 10.5v3",bolt:"M9 1.5L3.5 9H8l-1 5.5L12.5 7H8z",megaphone:"M2.5 6.5v3h2l5 3v-9l-5 3z M12 6a2.5 2.5 0 0 1 0 4",clock:"M8 2.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11z M8 5v3.2l2.2 1.4",funnel:"M2.5 3.5h11l-4.2 5v4.6l-2.6-1.3V8.5z",unlink:"M8.5 4.3l.6-.6a2.5 2.5 0 0 1 3.5 3.5l-.6.6M7.5 11.7l-.6.6a2.5 2.5 0 0 1-3.5-3.5l.6-.6M3 3l10 10",external:"M9.5 3H13v3.5M13 3L7.5 8.5M11 9.5v2.7c0 .7-.6 1.3-1.3 1.3H4.3c-.7 0-1.3-.6-1.3-1.3V6.8c0-.7.6-1.3 1.3-1.3H7"};function T({name:t}){return e("svg",{class:"icon",viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:Ga[t]})})}function J({icon:t,title:n,hint:s,size:a,children:i}){return e("div",{class:a?`empty-state ${a}`:"empty-state",children:[e("span",{class:"empty-mark","aria-hidden":"true",children:e(T,{name:t})}),e("p",{class:"empty-title",children:n}),s?e("p",{class:"empty-hint",children:s}):null,i]})}var Vs=!!_e&&window.top!==window.self,En=window.parent===window.self?"":Pe||(Vs?location.origin:"");function Gs(){if(!En)return;let t=document.documentElement;t.classList.add("framed");let n=0,s=!1;new ResizeObserver(()=>{s||(s=!0,requestAnimationFrame(()=>{s=!1;let a=Math.ceil(t.getBoundingClientRect().height);a!==n&&(n=a,window.parent.postMessage({type:"runlight:height",height:a},En))}))}).observe(t),window.addEventListener("message",a=>{if(a.source!==window.parent||a.origin!==En)return;let i=a.data;i?.type!=="runlight:viewport"||typeof i.top!="number"||typeof i.height!="number"||!Number.isFinite(i.top)||!Number.isFinite(i.height)||(t.style.setProperty("--frame-top",`${Math.max(0,i.top)}px`),t.style.setProperty("--frame-height",`${Math.max(0,i.height)}px`))})}var wt=new URLSearchParams(location.search).get("open")??"";function he(t){if(!Vs)return!1;let n=new URLSearchParams(location.search);return n.set("open",t),window.open(`${location.pathname}?${n}`,"_blank","noopener"),!0}function ot(t){return wt!==t?!1:(wt="",!0)}function Ue(t){if(!wt.startsWith(`${t}:`))return null;let n=wt.slice(t.length+1);return wt="",n}function Yt(t,n,s){return t.domain&&s.includes(t.domain)?`https://${t.domain}/${t.slug}`:`${n}/${t.slug}`}var Se=t=>t.replace(/^https?:\/\//,""),Ws=t=>de(new Date(t.createdAt).toISOString().slice(0,10));function An({text:t,small:n}){let[s,a]=m(!1);return e("button",{type:"button",class:n?"copy inline":"copy",onClick:i=>{i.stopPropagation(),navigator.clipboard?.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},children:[e(T,{name:s?"check":"copy"}),o(s?"links.copied":"links.copy")]})}function pe({title:t,sub:n,wide:s,action:a,onClose:i,children:l}){let r=q(null);return be(r),F(()=>{let c=d=>d.key==="Escape"&&i();return document.addEventListener("keydown",c),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",c),document.body.classList.remove("locked")}},[]),e("div",{class:"scrim center",onPointerDown:c=>c.target===c.currentTarget&&i(),children:e("div",{class:s?"list-sheet wide link-sheet":"list-sheet link-sheet small",role:"dialog","aria-modal":"true","aria-label":t,ref:r,children:[e("header",{class:"drawer-head",children:[a?e("div",{class:"sheet-heading-actions",children:[e("h2",{children:[t," ",n?e("span",{class:"sheet-sub",children:n}):null]}),a]}):e("h2",{children:[t," ",n?e("span",{class:"sheet-sub",children:n}):null]}),e("button",{type:"button",class:"remove","aria-label":o("common.close"),onClick:i,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),l]})})}var Ys=t=>`runlight_link_domain:${t}`;function Wa(t,n){try{let s=localStorage.getItem(Ys(t));return s!==null&&(s===""||n.includes(s))?s:null}catch{return null}}function Ya(t,n){try{localStorage.setItem(Ys(t),n)}catch{}}function Js({site:t,prefix:n,domains:s,link:a,onClose:i,onSaved:l}){let[r,c]=m(a?.url??""),[d,u]=m(a?.name??""),[g,h]=m(a?.slug??""),v=Wa(t,s),[p,y]=m(a?.domain??v??""),w=q(!1);F(()=>{a||!s.length||v!==null||R.checkLinkDomain(t,s[0]).then(N=>{N.working&&!w.current&&y(s[0])}).catch(()=>{})},[]);let f=N=>{w.current=!0,y(N.target.value)},[b,S]=m(""),[E,$]=m(!1),[A,x]=m(null),k=q(null);F(()=>k.current?.focus(),[A]);let L=N=>{N.preventDefault(),$(!0),S("");let D={url:r.trim(),name:d.trim(),slug:g.trim(),domain:p};(a?R.updateLink(t,a.id,D):R.createLink(t,D)).then(H=>{l(),a?i():(Ya(t,p),x(H.link))}).catch(H=>S(H.message)).finally(()=>$(!1))};if(A){let N=Yt(A,n,s);return e(pe,{title:o("links.new"),onClose:i,children:e("div",{class:"sheet-body link-form",children:[e("p",{class:"settings-text",children:o("links.created")}),e("div",{class:"made",children:[e("a",{href:N,target:"_blank",rel:"noopener",children:Se(N)}),e(An,{text:N})]}),e("p",{class:"field-hint",children:[o("links.destination")," ",Se(A.url)]}),e("div",{class:"settings-actions",children:[e("button",{type:"button",class:"ghost",onClick:()=>{x(null),c(""),u(""),h("")},children:[e(T,{name:"plus"}),o("links.another")]}),e("button",{type:"button",class:"solid",onClick:i,children:o("common.close")})]})]})})}return e(pe,{title:o(a?"links.edit":"links.new"),onClose:i,children:e("form",{class:"sheet-body link-form",onSubmit:L,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("links.url")}),e("input",{ref:k,class:"value",type:"url",required:!0,placeholder:o("links.urlPlaceholder"),value:r,onInput:N=>c(N.target.value)})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("links.name")}),e("input",{class:"value",type:"text",maxLength:100,placeholder:o("links.namePlaceholder"),value:d,onInput:N=>u(N.target.value)})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("links.slug")}),e("div",{class:"slug-row",children:[s.length?e("select",{class:"value","aria-label":o("links.domain"),value:p,onChange:f,children:[s.map(N=>e("option",{value:N,children:[N,"/"]})),a?.domain&&!s.includes(a.domain)?e("option",{value:a.domain,children:o("links.removedDomain",{domain:a.domain})}):null,e("option",{value:"",children:[Se(n),"/"]})]}):a?.domain?e("select",{class:"value","aria-label":o("links.domain"),value:p,onChange:f,children:[e("option",{value:a.domain,children:o("links.removedDomain",{domain:a.domain})}),e("option",{value:"",children:[Se(n),"/"]})]}):e("span",{class:"slug-prefix",children:[Se(n),"/"]}),e("input",{class:"value",type:"text",maxLength:100,pattern:"[A-Za-z0-9][A-Za-z0-9_\\-]*",placeholder:o("links.slugPlaceholder"),value:g,onInput:N=>h(N.target.value)})]})]}),e("div",{class:"settings-actions",children:[b?e("span",{class:"settings-error",children:b}):null,e("button",{type:"button",class:"ghost",onClick:i,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",disabled:E||!r.trim(),children:[e(T,{name:a?"save":"plus"}),o(a?"links.save":"links.create")]})]})]})})}function Gt({title:t,rows:n,dimension:s}){let a=Math.max(1,...n.map(i=>Number(i.events??0)));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(J,{size:"line",icon:"chart",title:o("empty.mini")}):null,e("ol",{class:"rows",children:n.map(i=>e("li",{children:[e("span",{class:"bar",style:{width:`${Number(i.events??0)/a*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:s==="country"?`${xe(i.value)} ${we(i.value)}`:ge(s,i.value)})}),e("span",{class:"num",children:O(Number(i.events??0))})]}))})]})}function Zs({view:t,id:n,prefix:s,domains:a,onClose:i}){let[l,r]=m(null),[c,d]=m("");F(()=>{let h=!0;return r(null),d(""),R.link(t,n).then(v=>{h&&r(v)}).catch(v=>{h&&d(v.message)}),()=>{h=!1}},[t,n]);let u=l?Yt(l.link,s,a):"",g=[{key:"clicks",slot:1,label:o("links.clicksLabel"),format:O}];return e(pe,{title:l?.link.name??o("common.loading"),sub:l?X("links.total",l.clicks,{n:O(l.clicks)}):void 0,wide:!0,onClose:i,children:e("div",{class:"sheet-body",children:[c?e("p",{class:"failure",children:c}):null,!l&&!c?e(ne,{chart:!0}):null,l?e(z,{children:[e("div",{class:"link-head",children:[e("div",{class:"made",children:[e("a",{href:u,target:"_blank",rel:"noopener",children:Se(u)}),e(An,{text:u})]}),e("p",{class:"field-hint",children:[o("links.destination")," ",e("a",{href:l.link.url,target:"_blank",rel:"noopener",children:Se(l.link.url)}),e("span",{class:"link-date-inline",children:o("links.createdOn",{date:Ws(l.link)})})]})]}),e("h3",{class:"mini-title",children:o("links.clicksOverTime")}),e("div",{class:"link-chart",children:e(st,{points:l.series,metrics:g,interval:l.range.interval,timezone:l.range.timezone,shared:!0,height:240})}),e("div",{class:"mini-grid",children:[e(Gt,{title:"links.sources",rows:l.sources,dimension:"source"}),e(Gt,{title:"links.countries",rows:l.countries,dimension:"country"}),e(Gt,{title:"links.devices",rows:l.devices,dimension:"device"}),e(Gt,{title:"links.browsers",rows:l.browsers,dimension:"browser"})]})]}):null]})})}function xt(t){let n=[],s=[],a="",i=!1;for(let d=0;d<t.length;d++){let u=t[d];i?u==='"'&&t[d+1]==='"'?(a+='"',d++):u==='"'?i=!1:a+=u:u==='"'?i=!0:u===","?(s.push(a),a=""):u===`
`||u==="\r"?(u==="\r"&&t[d+1]===`
`&&d++,s.push(a),a="",s.some(g=>g.trim())&&n.push(s),s=[]):a+=u}s.push(a),s.some(d=>d.trim())&&n.push(s);let[l,...r]=n;if(!l)return[];let c=l.map(d=>d.trim().toLowerCase().replace(/^/,""));return r.map(d=>Object.fromEntries(c.map((u,g)=>[u,(d[g]??"").trim()])))}var Wt=100;function ie({name:t,onDelete:n,label:s,confirm:a,icon:i="trash",hint:l}){let[r,c]=m(!1);return F(()=>{if(!r)return;let d=setTimeout(()=>c(!1),4e3);return()=>clearTimeout(d)},[r]),e("button",{type:"button",class:r?"copy inline danger armed":"copy inline danger",title:r?l??o("app.confirmDelete",{name:t}):void 0,onClick:()=>r?n():c(!0),children:[e(T,{name:i}),r?a??o("links.confirm"):s??o("links.delete")]})}function Ja({view:t,site:n,readOnly:s,onClose:a,onChanged:i}){let[l,r]=m(null),[c,d]=m(""),[u,g]=m([]),[h,v]=m(""),[p,y]=m(""),[w,f]=m("newest"),[b,S]=m(Wt);F(()=>{let _=setTimeout(()=>v(p),120);return()=>clearTimeout(_)},[p]),F(()=>S(Wt),[h,w]);let[E,$]=m(null),[A,x]=m(null),[k,L]=m(null),N=q(null),D=()=>{R.links(t).then(_=>{r(_.links),d(_.prefix),g(_.domains)}).catch(_=>{r(P=>P??[]),L({text:_.message,failures:[]})})};F(D,[t]);let H=Ee(()=>{let _=h.trim().toLowerCase();return(l??[]).filter(U=>!_||`${U.name} ${U.slug} ${U.url} ${U.domain}`.toLowerCase().includes(_)).sort((U,G)=>w==="clicks"?(G.clicks??0)-(U.clicks??0)||G.createdAt-U.createdAt:w==="newest"?G.createdAt-U.createdAt:U.name.localeCompare(G.name))},[l,h,w]),M=()=>{D(),i()},C=async _=>{try{let P=xt(await _.text());if(!P.some(B=>B.url||B.destination_url)){L({text:o("links.importNoUrl"),failures:[]});return}let U=await R.importLinks(n,P),G=U.failed.map(B=>({row:B.row,reason:B.code&&ve(B.code,B.params)||B.reason}));L({text:X("links.importDone",U.created,{n:O(U.created)}),failures:G}),M()}catch(P){L({text:P.message,failures:[]})}};return A?e(Zs,{view:t,id:A,prefix:c,domains:u,onClose:()=>x(null)}):E?e(Js,{site:n,prefix:c,domains:u,link:E==="new"?void 0:E,onClose:()=>$(null),onSaved:M}):e(pe,{title:o("panel.links"),sub:l?h?`${O(H.length)} / ${O(l.length)}`:O(l.length):void 0,wide:!0,onClose:a,children:[e("div",{class:"sheet-search link-tools",children:[e("input",{class:"value",type:"search",placeholder:o("links.search"),"aria-label":o("links.search"),value:p,onInput:_=>y(_.target.value)}),e("select",{class:"field","aria-label":o("links.sortBy"),value:w,onChange:_=>f(_.target.value),children:[e("option",{value:"newest",children:o("links.sortNewest")}),e("option",{value:"clicks",children:o("links.sortClicks")}),e("option",{value:"name",children:o("links.sortName")})]}),s?null:e(z,{children:[e("button",{type:"button",class:"ghost",title:o("links.importHelp"),onClick:()=>N.current?.click(),children:[e(T,{name:"upload"}),o("links.import")]}),e("input",{ref:N,type:"file",accept:".csv,text/csv",hidden:!0,onChange:_=>{let P=_.target.files?.[0];P&&C(P),_.target.value=""}}),e("button",{type:"button",class:"solid",onClick:()=>$("new"),children:[e(T,{name:"plus"}),o("links.new")]})]})]}),k?e("div",{class:"import-result",children:[e("strong",{children:k.text}),k.failures.slice(0,8).map(_=>e("span",{children:o("links.importFailed",{row:_.row,reason:_.reason})}))]}):null,e("div",{class:"sheet-body",children:[l&&l.length===0?e(J,{icon:"share",title:o("empty.links.title"),hint:o(s?"links.noneYet":"empty.links.hint")}):null,e("table",{class:"sheet-table links-table",children:e("tbody",{children:H.slice(0,b).map(_=>{let P=Yt(_,c,u);return e("tr",{children:[e("td",{class:"sheet-name",children:e("button",{type:"button",class:"link-cell",onClick:()=>x(_.id),children:[e("span",{class:"link-name",children:_.name}),e("span",{class:"link-short",children:Se(P)}),e("span",{class:"link-dest",children:Se(_.url)}),e("span",{class:"link-date",children:o("links.createdOn",{date:Ws(_)})})]})}),e("td",{class:"numeric lead",children:[O(_.clicks??0),e("span",{class:"link-unit",children:o("links.clicks")})]}),e("td",{class:"numeric link-actions",children:[e(An,{text:P,small:!0}),s?null:e(z,{children:[e("button",{type:"button",class:"copy inline",onClick:()=>$(_),children:[e(T,{name:"edit"}),o("links.editButton")]}),e(ie,{name:_.name,hint:o("links.confirmDelete",{name:_.name}),onDelete:()=>R.deleteLink(n,_.id).then(M,U=>L({text:U.message,failures:[]}))})]})]})]})})})}),H.length>b?e("div",{class:"more-row",children:[e("span",{class:"field-hint",children:o("links.showing",{shown:O(b),total:O(H.length)})}),e("button",{type:"button",class:"more",onClick:()=>S(b+Wt),children:[e(T,{name:"plus"}),o("links.showMore",{n:Wt})]})]}):null]})]})}function Xs({view:t,site:n,readOnly:s}){let[a,i]=m(null),[l,r]=m(""),[c,d]=m([]),[u,g]=m(()=>ot("links:manage")?"manage":!s&&ot("links:new")?"new":null),[h,v]=m(()=>Ue("links:link")??""),[p,y]=m(0),[w,f]=m("newest");F(()=>{let $=!0;return i(null),R.links(t).then(A=>{$&&(i(A.links),r(A.prefix),d(A.domains),h&&(A.links.some(x=>x.id===h)&&g({id:h}),v("")))}).catch(()=>$&&i([])),()=>{$=!1}},[t,p]);let b=[...a??[]].sort(($,A)=>w==="newest"?A.createdAt-$.createdAt:(A.clicks??0)-($.clicks??0)||A.createdAt-$.createdAt).slice(0,10),S=Math.max(1,...b.map($=>$.clicks??0)),E=(a??[]).reduce(($,A)=>$+(A.clicks??0),0);return e("section",{class:"panel wide",children:[e("header",{class:"panel-head",children:[e("h2",{children:[o("panel.links")," ",a?.length?e("span",{class:"aside has-tip",tabindex:0,"aria-describedby":"links-total-tip",children:[X("links.total",E,{n:O(E)}),e("span",{class:"hover-tip",role:"tooltip",id:"links-total-tip",children:o("links.totalTip")})]}):null]}),e("div",{class:"head-tools",children:[a&&a.length===0?null:e("nav",{class:"tabs","aria-label":o("links.sortBy"),children:[e("button",{type:"button",class:w==="newest"?"tab on":"tab","aria-pressed":w==="newest",onClick:()=>f("newest"),children:o("links.sortNewest")}),e("button",{type:"button",class:w==="clicks"?"tab on":"tab","aria-pressed":w==="clicks",onClick:()=>f("clicks"),children:o("links.sortClicks")})]}),s?null:e(z,{children:[a?.length?e("button",{type:"button",class:"box-button",onClick:()=>he("links:manage")||g("manage"),children:[e(T,{name:"list"}),o("links.manage")]}):null,e("button",{type:"button",class:"box-button solid",onClick:()=>he("links:new")||g("new"),children:[e(T,{name:"plus"}),o("links.new")]})]})]})]}),a&&a.length===0?e(J,{icon:"share",title:o("empty.links.title"),hint:o(s?"links.noneYet":"empty.links.hint")}):null,a&&a.length===0?null:e("div",{class:"table",children:[e("div",{class:"cols",children:[e("span",{children:o("panel.links")}),e("span",{class:"num-head",children:o("links.clicks")})]}),a?null:e(ne,{}),e("ol",{class:"rows",children:b.map($=>e("li",{children:[e("span",{class:"bar",style:{width:`${($.clicks??0)/S*100}%`}}),e("button",{type:"button",class:"name",title:Se(Yt($,l,c)),onMouseEnter:()=>{R.link(t,$.id).catch(()=>{})},onFocus:()=>{R.link(t,$.id).catch(()=>{})},onClick:()=>he(`links:link:${$.id}`)||g({id:$.id}),children:[e("span",{class:"name-text",children:$.name}),e("span",{class:"link-slug",children:["/",$.slug]})]}),e("span",{class:"num",children:O($.clicks??0)})]}))})]}),a&&a.length>b.length?e("button",{type:"button",class:"more",onClick:()=>he("links:manage")||g("manage"),children:[e(T,{name:"expand"}),o("panel.more")]}):null,u==="new"?e(Js,{site:n,prefix:l,domains:c,onClose:()=>g(null),onSaved:()=>y($=>$+1)}):u==="manage"?e(Ja,{view:t,site:n,readOnly:s,onClose:()=>g(null),onChanged:()=>y($=>$+1)}):u?e(Zs,{view:t,id:u.id,prefix:l,domains:c,onClose:()=>g(null)}):null]})}function Qs({view:t,event:n,onClose:s}){let[a,i]=m(null),[l,r]=m(null),[c,d]=m("");F(()=>{let h=!0;return R.eventProps(t,n,a).then(v=>h&&r(v)).catch(v=>h&&d(v.message)),()=>{h=!1}},[n,a,t]);let u=l?.rows??[],g=Math.max(1,...u.map(h=>h.events));return e(pe,{title:n,sub:o("props.title"),wide:!0,onClose:s,children:e("div",{class:"sheet-body props-body",children:[l&&l.keys.length>1?e("div",{class:"ops props-keys",role:"radiogroup","aria-label":o("props.title"),children:l.keys.map(h=>e("button",{type:"button",role:"radio","aria-checked":l.key===h.key,class:l.key===h.key?"op on":"op",onClick:()=>i(h.key),children:h.key}))}):null,c?e("p",{class:"settings-error",children:c}):null,l&&l.keys.length===0?e(J,{icon:"list",title:o("props.emptyTitle"),hint:o("props.none")}):null,l&&l.key?e(z,{children:e("div",{class:"table",children:[e("div",{class:"cols",children:[e("span",{children:l.key}),e("span",{class:"extra",children:o("column.visitors")}),e("span",{class:"num-head",children:o("column.events")})]}),e("ol",{class:"rows",children:u.map(h=>e("li",{children:[e("span",{class:"bar",style:{width:`${h.events/g*100}%`}}),e("span",{class:"name",title:h.value,children:e("span",{class:"name-text",children:h.value})}),e("span",{class:"extra",children:O(h.visitors)}),e("span",{class:"num",children:O(h.events)})]}))})]})}):null,!l&&!c?e(ne,{}):null]})})}var Za=[2,3,4,5,6,7,8],Rn=(t,n)=>`${t}\0${n}`;function eo({view:t,onClose:n}){let[s,a]=m(5),[i,l]=m(""),[r,c]=m(""),[d,u]=m(null),[g,h]=m(null),[v,p]=m([]),[y,w]=m(""),[f,b]=m(new Map),S=q(null);F(()=>{R.breakdown(t,"page",100).then(k=>p(k.rows.map(L=>L.value))).catch(()=>{})},[t]),F(()=>{let k=!0;return w(""),R.journeys(t,{steps:s,start:i,end:r,through:d}).then(L=>k&&h(L)).catch(L=>k&&w(L.message)),()=>{k=!1}},[t,s,i,r,d]),$t(()=>{let k=S.current;if(!k||!g)return;let L=()=>{let D=k.getBoundingClientRect(),H=new Map;for(let M of k.querySelectorAll("[data-box]")){let C=M.getBoundingClientRect();H.set(M.dataset.box,{x1:C.left-D.left,x2:C.right-D.left,y:C.top-D.top+C.height/2})}b(H)};L();let N=new ResizeObserver(L);return N.observe(k),()=>N.disconnect()},[g]);let E=g?.columns??[],$=Math.max(1,...(g?.links??[]).map(k=>k.visits)),A=k=>k?tt(k):o("journeys.other"),x=(k,L)=>u(d&&d.step===k&&d.value===L?null:L?{step:k,value:L}:null);return e(pe,{title:o("journeys.title"),wide:!0,onClose:n,children:e("div",{class:"sheet-body journeys",children:[e("p",{class:"settings-text",children:o("journeys.intro")}),e("div",{class:"journey-controls",children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.steps")}),e("select",{class:"value",value:String(s),onChange:k=>{let L=Number(k.target.value);a(L),d&&d.step>=L&&u(null)},children:Za.map(k=>e("option",{value:String(k),children:o("journeys.stepCount",{n:k})}))})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.start")}),e("select",{class:"value",value:i,onChange:k=>{l(k.target.value),u(null)},children:[e("option",{value:"",children:o("journeys.anyPage")}),v.map(k=>e("option",{value:k,children:k}))]})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.end")}),e("select",{class:"value",value:r,onChange:k=>c(k.target.value),children:[e("option",{value:"",children:o("journeys.anyPage")}),v.map(k=>e("option",{value:k,children:k}))]})]})]}),d?e("p",{class:"journey-following",children:[o("journeys.following",{page:tt(d.value),step:d.step+1}),e("button",{type:"button",class:"copy inline",onClick:()=>u(null),children:[e(T,{name:"x"}),o("common.clearAll")]})]}):null,g?.sampled?e("p",{class:"field-hint",children:o("journeys.sampled",{n:O(g.sampled)})}):null,y?e("p",{class:"settings-error",children:y}):null,g?g.visits===0?e(J,{icon:"arrive",title:o("journeys.emptyTitle"),hint:o("journeys.none")}):e("div",{class:"journey-scroll",children:e("div",{class:"journey-grid",ref:S,style:{gridTemplateColumns:`repeat(${E.length}, minmax(150px, 1fr))`},children:[e("svg",{class:"journey-links","aria-hidden":"true",children:g.links.map(k=>{let L=f.get(Rn(k.step,k.from)),N=f.get(Rn(k.step+1,k.to));if(!L||!N)return null;let D=(L.x2+N.x1)/2,H=d?d.step===k.step&&d.value===k.from||d.step===k.step+1&&d.value===k.to:!1;return e("path",{class:H?"lit":"",d:`M${L.x2},${L.y} C${D},${L.y} ${D},${N.y} ${N.x1},${N.y}`,style:{strokeWidth:Math.max(1.5,k.visits/$*16)}})})}),E.map((k,L)=>e("div",{class:"journey-column",children:[e("p",{class:"journey-step",children:[o("journeys.step",{n:L+1}),e("span",{children:O(k.visits)})]}),k.items.map(N=>e("button",{type:"button","data-box":Rn(L,N.value),class:`journey-page${N.value?"":" other"}${d&&d.step===L&&d.value===N.value?" on":""}`,title:N.value?o("journeys.follow",{page:tt(N.value)}):void 0,disabled:!N.value,onClick:()=>x(L,N.value),children:[e("span",{class:"journey-name",children:A(N.value)}),e("span",{class:"journey-count",children:[O(N.visits),e("span",{class:"journey-share",children:[Math.round(N.visits/k.visits*100),"%"]})]})]})),k.left?e("p",{class:"journey-left",children:o("journeys.left",{n:O(k.left)})}):null]}))]})}):e(ne,{})]})})}var to=8,no=1e3;function ge(t,n){return n?t==="country"?`${xe(n)} ${we(n)}`.trim():t==="region"?`${xe(n.slice(0,2))} ${n}`.trim():t==="channel"?o(`channel.${n}`):t==="device"?o(`device.${n}`):t==="page"||t==="entry"||t==="exit"||t==="ai_page"||t==="path"?tt(n):n:o("common.none")}function Xa({parts:t}){let n=t.reduce((s,a)=>s+a.n,0);return n===0?null:e("div",{class:"mix",children:[e("div",{class:"mix-bar",role:"img","aria-label":t.map(s=>`${s.name} ${ce(s.n/n)}`).join(", "),children:t.map(s=>e("span",{class:`mix-part s${s.slot}`,style:{flexGrow:String(s.n)},title:`${s.name}: ${ce(s.n/n)}`}))}),e("div",{class:"mix-key",children:t.map(s=>e("span",{children:[e("span",{class:`swatch s${s.slot}`}),s.name," ",e("b",{children:ce(s.n/n)})]}))})]})}function Qa({rows:t,tab:n,onFilter:s,onDetail:a}){let i=n.column??"visitors",l=Math.max(1,...t.map(c=>Number(c[i]??0))),r=c=>n.colors?.[c]??(n.groups?n.groups.slots[n.groups.of(c)]:void 0);return e("ol",{class:"rows",children:t.map(c=>{let d=Number(c[i]??0),u=ge(n.dimension,c.value),g=r(c.value),h=e(z,{children:[g!==void 0?e("span",{class:`swatch s${g}`}):null,e("span",{class:"name-text",children:u})]});return e("li",{children:[e("span",{class:"bar",style:{width:`${d/l*100}%`}}),n.filterable?e("button",{type:"button",class:"name",title:o("panel.filterBy",{name:u}),onClick:()=>s(n.dimension,c.value),children:h}):e("span",{class:"name",children:h}),n.extra?e("span",{class:"extra",children:n.extra.format(Number(c[n.extra.key]??0))}):null,a?e("button",{type:"button",class:"row-detail",title:o("props.open",{name:u}),"aria-label":o("props.open",{name:u}),onClick:()=>a(c.value),children:e(T,{name:"list"})}):null,e("span",{class:"num",children:O(d)})]})})})}function ei({tab:t}){return e("div",{class:"cols",children:[e("span",{children:o(t.label)}),t.extra?e("span",{class:"extra",children:o(t.extra.label)}):null,e("span",{class:"num-head",children:o(`column.${t.column??"visitors"}`)})]})}var ti=new Set(["referrer","source","channel","utm_source","utm_medium","utm_campaign","utm_term","utm_content","country","region","city","browser","browser_version","os","os_version","device","screen","language"]);function oo(t){let n=l=>r=>Number(r[l]??0),s=(l,r)=>({label:l,value:c=>O(n(r)(c)),by:n(r)}),a=l=>({label:"column.share",value:(r,c)=>c?ce(n(l)(r)/c):"",by:n(l)}),i={label:"column.bounce",value:l=>ce(l.bounceRate??0),by:n("bounceRate")};return t.column==="fetches"?[s("column.fetches","fetches"),a("fetches")]:t.column==="events"?[s("column.visitors","visitors"),s("column.events","events"),a("events")]:t.dimension==="page"?[s("column.visitors","visitors"),s("column.pageviews","pageviews"),{label:"column.time",value:l=>l.timeOnPage?Fe(l.timeOnPage):"",by:n("timeOnPage")},{label:"column.scroll",value:l=>l.scrollDepth?`${l.scrollDepth}%`:"",by:n("scrollDepth")}]:t.dimension==="hostname"?[s("column.visitors","visitors"),s("column.pageviews","pageviews")]:t.dimension==="entry"||t.dimension==="exit"?[s("column.visitors","visitors"),s("column.visits","visits"),i]:ti.has(t.dimension)?[s("column.visitors","visitors"),s("column.visits","visits"),s("column.pageviews","pageviews"),i,{label:"column.duration",value:l=>Fe(l.visitDuration??0),by:n("visitDuration")},a("visitors")]:[s("column.visitors","visitors")]}function ni({rows:t,tab:n,onFilter:s}){let a=n.column??"visitors",i=oo(n),l=t.reduce((v,p)=>v+Number(p[a]??0),0),r=Math.max(1,...t.map(v=>Number(v[a]??0))),[c,d]=m(null),u=v=>d(c?.by===v?{by:v,descending:!c.descending}:{by:v,descending:v>=0}),g=c?[...t].sort((v,p)=>{let y=c.by<0?ge(n.dimension,v.value).localeCompare(ge(n.dimension,p.value),void 0,{numeric:!0,sensitivity:"base"}):i[c.by].by(v)-i[c.by].by(p);return c.descending?-y:y}):t,h=(v,p,y)=>e("th",{class:y?"numeric":void 0,"aria-sort":c?.by===p?c.descending?"descending":"ascending":void 0,children:e("button",{type:"button",class:c?.by===p?"sort on":"sort",onClick:()=>u(p),children:[v,e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:c?.by===p&&!c.descending?"M5 10l3-3 3 3":"M5 6.5l3 3 3-3"})})]})});return e("table",{class:"sheet-table",children:[e("thead",{children:e("tr",{children:[h(o(n.label),-1,!1),i.map((v,p)=>h(o(v.label),p,!0))]})}),e("tbody",{children:g.map(v=>{let p=ge(n.dimension,v.value);return e("tr",{children:[e("td",{class:"sheet-name",children:[e("span",{class:"bar",style:{width:`${Number(v[a]??0)/r*100}%`}}),n.filterable?e("button",{type:"button",class:"name",title:o("panel.filterBy",{name:p}),onClick:()=>s(n.dimension,v.value),children:e("span",{class:"name-text",children:p})}):e("span",{class:"name",children:e("span",{class:"name-text",children:p})})]}),i.map((y,w)=>e("td",{class:w===0?"numeric lead":"numeric",children:y.value(v,l)}))]})})})]})}function si({title:t,tab:n,view:s,onFilter:a,onClose:i}){let l=q(null);be(l);let[r,c]=m(null),[d,u]=m(""),g=q(null);F(()=>{R.breakdown(s,n.dimension,no).then(y=>c(y.rows)).catch(()=>c([]));let p=y=>y.key==="Escape"&&i();return document.addEventListener("keydown",p),document.body.classList.add("locked"),g.current?.focus(),()=>{document.removeEventListener("keydown",p),document.body.classList.remove("locked")}},[]);let h=d.trim().toLowerCase(),v=(r??[]).filter(p=>!h||ge(n.dimension,p.value).toLowerCase().includes(h));return e("div",{class:"scrim center",onPointerDown:p=>p.target===p.currentTarget&&i(),children:e("div",{class:oo(n).length>3?"list-sheet wide":"list-sheet",role:"dialog","aria-modal":"true","aria-label":`${o(t)}: ${o(n.label)}`,ref:l,children:[e("header",{class:"drawer-head",children:[e("h2",{children:[o(t)," ",e("span",{class:"sheet-sub",children:o(n.label)})]}),e("button",{type:"button",class:"copy inline sheet-download",onClick:()=>{let p=re(s);p.set("dimension",n.dimension),p.set("limit",String(no)),p.set("format","csv"),et("breakdown",p).catch(()=>{})},children:[e(T,{name:"upload"}),o("export.csv")]}),e("button",{type:"button",class:"remove","aria-label":o("common.close"),onClick:i,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),e("div",{class:"sheet-search",children:[e("input",{ref:g,class:"value",type:"search",placeholder:o("common.search"),"aria-label":o("common.search"),value:d,onInput:p=>u(p.target.value)}),e("span",{class:"sheet-tools",children:[d?e("button",{type:"button",class:"sheet-clear","aria-label":o("common.clearAll"),onClick:()=>{u(""),g.current?.focus()},children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4.5 4.5l7 7M11.5 4.5l-7 7"})})}):null,e("span",{class:"sheet-count",children:r?h?`${O(v.length)} / ${O(r.length)}`:O(r.length):""})]})]}),e("div",{class:"sheet-body",children:[r?null:e(ne,{}),r&&v.length===0?h?e(J,{size:"line",icon:"list",title:o("empty.search",{q:h})}):e(J,{size:"line",icon:"chart",title:o("empty.mini")}):null,v.length?e(ni,{rows:v,tab:n,onFilter:(p,y)=>{a(p,y),i()}}):null]})]})})}function ao({title:t,tabs:n,view:s,onFilter:a,wide:i,map:l}){let r=`panel:${t.replace(/^panel\./,"")}`,[c]=m(()=>Ue(r)??""),d=c.startsWith("all:")?n.findIndex(B=>B.dimension===c.slice(4)):-1,[u,g]=m(Math.max(0,d)),[h,v]=m(!1),[p,y]=m(c==="map"&&!!l),[w,f]=m(c==="journeys"&&t==="panel.pages"),[b,S]=m(d>=0),[E,$]=m(null),[A,x]=m(c.startsWith("detail:")&&n[0]?.dimension==="event"?c.slice(7):""),[k,L]=m(null),[N,D]=m(""),[H,M]=m(!1),C=n[u]??n[0],_=C.column??"visitors";F(()=>{let B=!0;D("");let oe=setTimeout(()=>B&&M(!0),300);return R.breakdown(s,C.dimension,50).then(Te=>{B&&(L(Te.rows),A&&(Te.rows.some(nn=>nn.value===A)&&$(A),x("")))}).catch(Te=>{B&&(L(null),D(Te.message))}).finally(()=>{clearTimeout(oe),B&&M(!1)}),()=>{B=!1,clearTimeout(oe)}},[s,C.dimension]);let P=k??[],U=!N&&k!==null&&P.length===0,G=[];if(C.colors)G=P.filter(B=>C.colors[B.value]!==void 0).map(B=>({name:ge(C.dimension,B.value),n:Number(B[_]??0),slot:C.colors[B.value]}));else if(C.groups){let B=new Map;for(let oe of P)B.set(C.groups.of(oe.value),(B.get(C.groups.of(oe.value))??0)+Number(oe[_]??0));G=Object.entries(C.groups.slots).map(([oe,Te])=>({name:o(oe),n:B.get(oe)??0,slot:Te}))}return e("section",{class:i?"panel wide":"panel","aria-busy":H,children:[e("header",{class:"panel-head",children:[e("h2",{children:o(t)}),e("div",{class:"head-tools",children:[n.length>1&&!h?e("nav",{class:"tabs","aria-label":o("panel.views",{title:o(t)}),children:n.map((B,oe)=>e("button",{type:"button",class:oe===u?"tab on":"tab","aria-pressed":oe===u,onClick:()=>{oe!==u&&(g(oe),L(null))},children:o(B.label)}))}):null,t==="panel.pages"&&!U?e("button",{type:"button",class:"tool",title:o("journeys.open"),"aria-label":o("journeys.open"),onClick:()=>he(`${r}:journeys`)||f(!0),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M2 3.5h3.5c2.5 0 2.5 4.5 5 4.5H14M2 12.5h3.5c2.5 0 2.5-4.5 5-4.5M11.5 5.5L14 8l-2.5 2.5"})})}):null,l&&!U?e(z,{children:[e("button",{type:"button",class:h?"tool on":"tool","aria-label":o(h?"panel.showList":"panel.showMap"),title:o(h?"panel.showList":"panel.showMap"),onClick:()=>v(!h),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M1.5 3.5l4-1.5 5 2 4-1.5v10l-4 1.5-5-2-4 1.5z M5.5 2v10 M10.5 4v10"})})}),e("button",{type:"button",class:"tool","aria-label":o("panel.fullMap"),title:o("panel.fullMap"),onClick:()=>he(`${r}:map`)||y(!0),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4"})})})]}):null]})]}),p?e(Ks,{view:s,onFilter:a,onClose:()=>y(!1)}):null,w?e(eo,{view:s,onClose:()=>f(!1)}):null,E?e(Qs,{view:s,event:E,onClose:()=>$(null)}):null,b?e(si,{title:t,tab:C,view:s,onFilter:a,onClose:()=>S(!1)}):null,H&&!N?e(ne,{}):U?e(J,{icon:Jt[t]?.icon??"chart",title:o(Jt[t]?.title??"panel.empty"),hint:Jt[t]?o(Jt[t].hint):void 0,children:t==="panel.ai"?e("a",{class:"empty-setup",href:"https://runlight.sh/docs/ai/",target:"_blank",rel:"noopener noreferrer",children:[o("ai.setup"),e(T,{name:"external"})]}):null}):h?e(Mn,{view:s,onFilter:a}):e(z,{children:[G.length>0?e(Xa,{parts:G}):null,e("div",{class:"table",children:[e(ei,{tab:C}),N?e("p",{class:"empty",children:N}):null,!k&&!N?e(ne,{}):null,e(Qa,{rows:P.slice(0,to),tab:C,onFilter:a,onDetail:C.dimension==="event"?B=>he(`${r}:detail:${B}`)||$(B):void 0})]}),P.length>to?e("button",{type:"button",class:"more",onClick:()=>he(`${r}:all:${C.dimension}`)||S(!0),children:[e(T,{name:"expand"}),o("panel.more")]}):null]}),l&&Ds?e("a",{class:"geo-credit",href:"https://db-ip.com",target:"_blank",rel:"noopener",children:fe("panel.geoCredit",{name:e("span",{children:"DB-IP"})})}):null]})}var Jt={"panel.pages":{icon:"page",title:"empty.pages.title",hint:"empty.pages.hint"},"panel.sources":{icon:"arrive",title:"empty.sources.title",hint:"empty.sources.hint"},"panel.locations":{icon:"globe",title:"empty.locations.title",hint:"empty.locations.hint"},"panel.ai":{icon:"robot",title:"empty.ai.title",hint:"empty.ai.hint"},"panel.devices":{icon:"monitor",title:"empty.devices.title",hint:"empty.devices.hint"},"panel.events":{icon:"bolt",title:"empty.events.title",hint:"empty.events.hint"},"panel.campaigns":{icon:"megaphone",title:"empty.campaigns.title",hint:"empty.campaigns.hint"}},so=6;function io({view:t,wide:n}){let[s,a]=m(null),[i,l]=m([]),[r,c]=m(""),[d,u]=m(null),g=q(null);F(()=>{let f=!0;return c(""),a(null),u(null),R.rhythm(t).then(b=>{f&&(a(b.grid),l(b.cells??[]))}).catch(b=>f&&c(b.message)),()=>{f=!1}},[t]);let h=Bt("short"),v=s?Math.max(0,...s.flat()):0,p=null;if(s&&v>0)for(let f=0;f<7&&!p;f++){let b=s[f].indexOf(v);b>=0&&(p=[f,b])}let y=s?s.flat().reduce((f,b)=>f+b,0)/168:0,w=d&&s?{n:s[d.d][d.h],cell:i[d.d]?.[d.h]}:null;return e("section",{class:n?"panel wide":"panel",children:[e("header",{class:"panel-head",children:[e("h2",{children:o("panel.rhythm")}),p?e("span",{class:"aside",children:o("rhythm.busiest",{when:`${h[p[0]]} ${nt(p[1])}`})}):null]}),r?e("p",{class:"empty",children:r}):null,!s&&!r?e("div",{class:"rhythm-loading",role:"status","aria-label":o("common.loading"),children:e("div",{class:"rhythm","aria-hidden":"true",children:[h.map(f=>e("div",{class:"rhythm-row",children:[e("span",{class:"rhythm-day",children:f}),Array.from({length:24},()=>e("span",{class:"cell"}))]})),e("div",{class:"rhythm-row hours",children:[e("span",{class:"rhythm-day"}),Array.from({length:24},(f,b)=>e("span",{class:"hour",children:b%6===0?nt(b):""}))]})]})}):null,s&&v===0?e(J,{icon:"clock",title:o("empty.rhythm.title"),hint:o("empty.rhythm.hint")}):null,s&&v>0?e("div",{class:"rhythm",role:"table","aria-label":o("rhythm.table"),ref:g,onPointerLeave:()=>u(null),children:[s.map((f,b)=>e("div",{class:"rhythm-row",role:"row",children:[e("span",{class:"rhythm-day",role:"rowheader",children:h[b]}),f.map((S,E)=>e("span",{role:"cell","aria-label":X("rhythm.cell",S,{when:`${h[b]} ${nt(E)}`,n:O(S)}),class:`cell q${S===0||v===0?0:Math.max(1,Math.ceil(S/v*so))}${d?.d===b&&d.h===E?" hot":""}`,onPointerEnter:$=>{let A=g.current?.getBoundingClientRect(),x=$.currentTarget.getBoundingClientRect();A&&u({d:b,h:E,x:x.left-A.left+x.width/2,y:x.top-A.top})}}))]})),e("div",{class:"rhythm-row hours","aria-hidden":"true",children:[e("span",{class:"rhythm-day"}),Array.from({length:24},(f,b)=>e("span",{class:"hour",children:b%6===0?nt(b):""}))]}),d&&w?e("div",{class:d.x>(g.current?.clientWidth??0)*.6?"rhythm-tip left":"rhythm-tip",style:{left:`${d.x}px`,top:`${d.y}px`},children:[e("span",{class:"tip-when",children:[h[d.d]," ",nt(d.h)]}),w.n&&w.cell?e(z,{children:[e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.visits")}),e("strong",{children:O(w.cell.visits)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.visitors")}),e("strong",{children:O(w.cell.visitors)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.pageviews")}),e("strong",{children:O(w.cell.pageviews)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.bounceRate")}),e("strong",{children:ce(w.cell.bounceRate)})]}),y>0?e("span",{class:"tip-note",children:o("rhythm.typical",{x:(w.n/y).toFixed(1)})}):null]}):e("span",{class:"tip-note",children:o("rhythm.quiet")})]}):null,e("div",{class:"rhythm-scale","aria-hidden":"true",children:[e("span",{children:o("scale.fewer")}),Array.from({length:so},(f,b)=>e("span",{class:`cell q${b+1}`})),e("span",{children:o("scale.more")})]})]}):null]})}var ro={key:"timeOnPage",label:"column.time",format:t=>t?Fe(t):""},lo={key:"bounceRate",label:"column.bounce",format:ce};var oi=[{group:"group.pages",fields:["page","entry","exit","hostname"]},{group:"group.sources",fields:["channel","source","referrer","utm_campaign","utm_source","utm_medium","utm_content","utm_term"]},{group:"group.location",fields:["country","region","city"]},{group:"group.device",fields:["device","browser","browser_version","os","os_version","screen","language"]},{group:"group.behaviour",fields:["event"]}],In=t=>o(`field.${t}`),Zt=6,ai=["is","not","contains"],Ln=t=>o(`filter.${t}`),Pn=1;function ii({draft:t,view:n,first:s,onChange:a,onRemove:i}){let[l,r]=m([]),[c,d]=m(!1),u={...n,filters:n.filters.filter(h=>h.dimension!==t.dimension)},g=re(u).toString();return F(()=>{let h=!0;return r([]),d(!0),(t.dimension==="hostname"?R.hostnameSuggestions(u):R.breakdown(u,t.dimension,12)).then(v=>h&&r(v.rows)).catch(()=>h&&r([])).finally(()=>h&&d(!1)),()=>{h=!1}},[t.dimension,g]),e("div",{class:"clause",children:[e("span",{class:"joiner",children:o(s?"filter.where":"filter.and")}),e("div",{class:"clause-body",children:[e("div",{class:"clause-line",children:[e("select",{class:"value","aria-label":o("filter.field"),value:t.dimension,onChange:h=>a({...t,dimension:h.target.value,value:""}),children:oi.map(h=>e("optgroup",{label:o(h.group),children:h.fields.map(v=>e("option",{value:v,children:In(v)}))}))}),e("div",{class:"ops",role:"radiogroup","aria-label":o("filter.match"),children:ai.map(h=>e("button",{type:"button",role:"radio","aria-checked":t.op===h,class:t.op===h?"op on":"op",onClick:()=>a({...t,op:h}),children:Ln(h)}))}),e("button",{type:"button",class:"remove","aria-label":o("filter.removeCondition"),onClick:i,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),e("input",{class:"value",type:"text","aria-label":o("filter.value"),placeholder:o(t.op==="contains"?"filter.placeholderContains":"filter.placeholder"),value:t.value,onInput:h=>a({...t,value:h.target.value})}),c?e("p",{class:"field-hint suggestions-loading",role:"status",children:[e("span",{class:"chart-spinner","aria-hidden":"true"}),e("span",{children:o("common.loading")})]}):null,l.length?e("div",{class:"suggestions",children:l.map(h=>e("button",{type:"button",class:h.value===t.value?"suggestion on":"suggestion",onClick:()=>a({...t,value:h.value}),children:[ge(t.dimension,h.value),t.dimension!=="hostname"?e("span",{children:O(Number(h.visitors||h.events||0))}):null]}))}):null]})]})}function co({view:t,onApply:n,onClose:s}){let[a,i]=m(()=>t.filters.length?t.filters.map(d=>({...d,id:Pn++})):[{dimension:"page",op:"is",value:"",id:Pn++}]),l=q(null);be(l),F(()=>{let d=u=>u.key==="Escape"&&s();return document.addEventListener("keydown",d),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",d),document.body.classList.remove("locked")}},[]);let r=a.filter(d=>d.value.trim()!=="");return e("div",{class:"scrim",onPointerDown:d=>d.target===d.currentTarget&&s(),children:e("div",{class:"drawer",role:"dialog","aria-modal":"true","aria-labelledby":"filter-title",ref:l,children:e("form",{class:"drawer-form",onSubmit:d=>{d.preventDefault(),n(r.map(({dimension:u,op:g,value:h})=>({dimension:u,op:g,value:h.trim()}))),s()},children:[e("header",{class:"drawer-head",children:[e("h2",{id:"filter-title",children:o("filter.title")}),e("button",{type:"button",class:"remove","aria-label":o("common.close"),onClick:s,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),e("div",{class:"drawer-body",children:[a.map((d,u)=>e(ii,{draft:d,view:t,first:u===0,onChange:g=>i(h=>h.map(v=>v.id===d.id?g:v)),onRemove:()=>i(a.filter(g=>g.id!==d.id))},d.id)),a.length<Zt?e("button",{type:"button",class:"add",onClick:()=>i([...a,{dimension:"country",op:"is",value:"",id:Pn++}]),children:[e(T,{name:"plus"}),o("filter.add").replace(/^\+\s*/,"")]}):e("p",{class:"drawer-note",children:o("filter.max",{max:Zt})}),e("p",{class:"drawer-note",children:o("filter.note")})]}),e("footer",{class:"drawer-foot",children:[e("button",{type:"button",class:"ghost",onClick:()=>i([]),children:[e(T,{name:"x"}),o("common.clearAll")]}),e("span",{class:"grow"}),e("button",{type:"button",class:"ghost",onClick:s,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",children:[e(T,{name:"check"}),r.length?X("filter.apply",r.length):o("filter.everything")]})]})]})})})}function ue(t){let[n,s]=m(!1);return e("span",{class:"secret",children:[e("input",{...t,type:n?"text":"password"}),e("button",{type:"button",class:"secret-toggle","aria-label":o(n?"secret.hide":"secret.show"),title:o(n?"secret.hide":"secret.show"),"aria-pressed":n,onClick:()=>s(!n),children:e(T,{name:n?"eyeOff":"eye"})})]})}var Xt=["today","yesterday","7d","30d","90d","month","last_month","year","12mo","all"],We="30d",po=t=>Xt.includes(t)?o(`period.${t}`):o("period.30d");function ri(t,n,s){return new Date(Date.UTC(t,n,s)).toISOString().slice(0,10)}function ze(t,n){if(t===n)return de(t);let s=t.slice(0,4)===n.slice(0,4);return o("calendar.range",{from:de(t,!s),to:de(n)})}function uo({y:t,m:n,start:s,end:a,hoverDay:i,today:l,onDay:r,onHover:c}){let u=(new Date(Date.UTC(t,n,1)).getUTCDay()+6)%7,g=new Date(Date.UTC(t,n+1,0)).getUTCDate(),h=a||(s&&i?i:""),v=s&&h?s<h?s:h:s,p=s&&h&&s<h?h:s;return e("div",{class:"month",children:[e("div",{class:"month-title","aria-hidden":"true",children:Tn(t,n)}),e("div",{class:"month-grid",role:"group","aria-label":Tn(t,n),children:[Bt("short").map(y=>e("span",{class:"weekday","aria-hidden":"true",children:y.slice(0,2)})),Array.from({length:u},()=>e("span",{"aria-hidden":"true"})),Array.from({length:g},(y,w)=>{let f=ri(t,n,w+1),b=v&&p&&f>=v&&f<=p,S=!!v&&(f===v||f===p);return e("button",{type:"button",class:`day${b?" in":""}${S?" edge":""}${f===l?" today":""}`,disabled:f>l,"aria-pressed":S,"aria-label":de(f),onClick:()=>r(f),onPointerEnter:()=>c(f),children:w+1})})]})]})}function mo({from:t,to:n,today:s,onApply:a,onCancel:i,applyLabel:l}){let[r,c]=m(t),[d,u]=m(n),[g,h]=m(""),[v,p]=s.split("-").map(Number),y=(n||s).split("-").map(Number),[w,f]=m([y[0],y[1]-1]),b=k=>{if(!r||d)c(k),u("");else{let[L,N]=k<r?[k,r]:[r,k];c(L),u(N)}},[S,E]=w,$=new Date(Date.UTC(S,E-1,1)),A=new Date(Date.UTC(S,E,1)),x=A.getUTCFullYear()>v||A.getUTCFullYear()===v&&A.getUTCMonth()>=p-1;return e("div",{class:"calendars",children:[e("div",{class:"cal-nav",children:[e("button",{type:"button",class:"nav","aria-label":o("calendar.earlier"),onClick:()=>f([S,E-1]),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M10 4l-4 4 4 4"})})}),e("button",{type:"button",class:"nav","aria-label":o("calendar.later"),disabled:x,onClick:()=>f([S,E+1]),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M6 4l4 4-4 4"})})})]}),e("div",{class:"months",onPointerLeave:()=>h(""),children:[e(uo,{y:$.getUTCFullYear(),m:$.getUTCMonth(),start:r,end:d,hoverDay:g,today:s,onDay:b,onHover:h}),e(uo,{y:A.getUTCFullYear(),m:A.getUTCMonth(),start:r,end:d,hoverDay:g,today:s,onDay:b,onHover:h})]}),e("div",{class:"cal-foot",children:[e("span",{class:"cal-sel",children:r?d?ze(r,d):o("calendar.open",{from:de(r)}):o("calendar.pick")}),e("button",{type:"button",class:"ghost",onClick:i,children:o("common.cancel")}),e("button",{type:"button",class:"solid",disabled:!r,onClick:()=>a(r,d||r),children:l??o("calendar.apply")})]})]})}function at(){let[t,n]=m(!1),s=q(null),a=ut(i=>{!i&&s.current?.contains(document.activeElement)&&s.current.querySelector("[aria-expanded]")?.focus(),n(i)},[]);return F(()=>{if(!t)return;let i=c=>{(c instanceof KeyboardEvent?c.key==="Escape":!s.current?.contains(c.target))&&a(!1)},l=c=>{c.relatedTarget&&!s.current?.contains(c.relatedTarget)&&n(!1)},r=s.current;return document.addEventListener("pointerdown",i),document.addEventListener("keydown",i),r?.addEventListener("focusout",l),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",i),r?.removeEventListener("focusout",l)}},[t]),{open:t,setOpen:a,root:s}}var it=()=>e("svg",{class:"chev",viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 6l4 4 4-4"})});function ho({period:t,from:n,to:s,today:a,onPeriod:i,onRange:l}){let{open:r,setOpen:c,root:d}=at(),u=n&&s?ze(n,s):po(t);return e("div",{class:"picker",ref:d,children:[e("button",{type:"button",class:"picker-button","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>c(!r),children:[e("svg",{class:"icon",viewBox:"0 0 16 16","aria-hidden":"true",children:[e("rect",{x:"2",y:"3",width:"12",height:"11",rx:"2"}),e("path",{d:"M2 6.5h12M5.5 1.5v3M10.5 1.5v3"})]}),e("span",{children:u}),e(it,{})]}),r?e("div",{class:"flyout",role:"dialog","aria-label":o("calendar.dialog"),children:[e("ul",{class:"presets",children:Xt.map(g=>e("li",{children:e("button",{type:"button",class:!n&&t===g?"preset on":"preset",onClick:()=>{i(g),c(!1)},children:po(g)})}))}),e(mo,{from:n,to:s,today:a,onCancel:()=>c(!1),onApply:(g,h)=>{l(g,h),c(!1)}})]}):null]})}var li=["previous","year","custom","off"];function go({mode:t,from:n,to:s,today:a,allTime:i,onChange:l}){let{open:r,setOpen:c,root:d}=at(),[u,g]=m(!1),h=t==="custom"&&n&&s?ze(n,s):o(`compare.${t}`);return e("div",{class:"picker",ref:d,children:[e("button",{type:"button",class:t==="off"?"picker-button compare off":"picker-button compare","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>{g(t==="custom"),c(!r)},children:[e("span",{class:"compare-vs",children:o("compare.vs")}),e("span",{children:h}),e(it,{})]}),r?e("div",{class:"flyout compare-flyout",role:"dialog","aria-label":o("compare.dialog"),children:[e("ul",{class:"presets",children:[e("li",{class:"presets-title",children:o("compare.title")}),li.map(v=>e("li",{children:e("button",{type:"button",class:(u?v==="custom":t===v)?"preset on":"preset",disabled:i&&v!=="off",onClick:()=>{if(v==="custom")return g(!0);l(v),c(!1)},children:o(`compare.${v}`)})})),i?e("li",{class:"presets-note",children:o("compare.allTime")}):null]}),u&&!i?e(mo,{from:n,to:s,today:a,applyLabel:o("compare.apply"),onCancel:()=>c(!1),onApply:(v,p)=>{l("custom",v,p),c(!1)}}):null]}):null]})}function fo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function Dn({onAdded:t,onCancel:n}){let[s,a]=m("here"),[i,l]=m(""),[r,c]=m(""),[d,u]=m(""),[g,h]=m(""),[v,p]=m(!1),[y,w]=m(""),[f,b]=m(!1);return e("form",{class:"sheet-body link-form",onSubmit:E=>{if(E.preventDefault(),b(!0),w(""),s==="connect"&&!v){R.connect(d.trim()).then(A=>location.assign(A.authorize)).catch(A=>{w(A.message),b(!1)});return}let $=s==="here"?{name:i.trim(),hostnames:r,timezone:fo()}:{name:i.trim(),remote:{url:d.trim(),token:g.trim()}};R.addSite($).then(A=>t(A.site)).catch(A=>{w(A.message),b(!1)})},children:[e("div",{class:"ops add-mode",role:"radiogroup","aria-label":o("sites.addTitle"),children:["here","connect"].map(E=>e("button",{type:"button",role:"radio","aria-checked":s===E,class:s===E?"op on":"op",onClick:()=>a(E),children:o(E==="here"?"sites.modeHere":"sites.modeConnect")}))}),s==="here"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("sites.domains")}),e("input",{class:"value",type:"text",required:!0,autoFocus:!0,placeholder:"example.com",value:r,onInput:E=>c(E.target.value)}),e("span",{class:"field-hint",children:o("sites.domainsHint")})]}):e(z,{children:[e("p",{class:"settings-text",children:o("sites.connectIntro")}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("sites.connectUrl")}),e("input",{class:"value",type:"url",required:!0,placeholder:"https://example.com/runlight",value:d,onInput:E=>u(E.target.value)})]}),v?e(z,{children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("sites.connectToken")}),e(ue,{class:"value",required:!0,autoComplete:"off",placeholder:"rl_...",value:g,onInput:E=>h(E.target.value)}),e("span",{class:"field-hint",children:o("sites.connectTokenHint")})]}),e("button",{type:"button",class:"text-button",onClick:()=>p(!1),children:o("sites.useSignIn")})]}):e("button",{type:"button",class:"text-button",onClick:()=>p(!0),children:o("sites.useToken")})]}),s==="connect"&&!v?null:e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("sites.name")}),e("input",{class:"value",type:"text",maxLength:80,placeholder:o("sites.namePlaceholder"),value:i,onInput:E=>l(E.target.value)}),s==="here"?e("span",{class:"field-hint",children:o("sites.timezoneHint",{zone:fo().replace(/_/g," ")})}):null]}),e("div",{class:"settings-actions",children:[y?e("span",{class:"settings-error",children:y}):null,n?e("button",{type:"button",class:"ghost",onClick:n,children:o("common.cancel")}):null,e("button",{type:"submit",class:"solid",disabled:f||(s==="here"?!r.trim():!d.trim()||v&&!g.trim()),children:[e(T,{name:"plus"}),o(s==="here"?"sites.add":"sites.connect")]})]})]})}function vo({onAdded:t}){return e("main",{class:"first-site",children:e("div",{class:"first-site-card",children:[e("h1",{children:o("sites.firstTitle")}),e("p",{class:"settings-text",children:o("sites.firstLead")}),e(Dn,{onAdded:t})]})})}function bo({sites:t,current:n,canAdd:s,onPick:a,onAdd:i,onAll:l}){let{open:r,setOpen:c,root:d}=at(),[u,g]=m(""),h=q(null),v=t.length>7,p=u.trim().toLocaleLowerCase(),y=v&&p?t.filter(w=>[w.name,...w.hostnames].some(f=>f.toLocaleLowerCase().includes(p))):t;return $t(()=>{r&&v&&h.current?.focus()},[r,v]),e("div",{class:"site-menu",ref:d,children:[e("button",{type:"button",class:"site-button","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>{r||g(""),c(!r)},children:[e("span",{class:"site-button-name",children:n?.name??"Runlight"}),e(it,{})]}),r?e("div",{class:"site-flyout",role:"dialog","aria-label":o("app.site"),onKeyDown:w=>{w.key==="Escape"&&d.current?.querySelector(".site-button")?.focus();let f=Array.from(d.current?.querySelectorAll(".site-option")??[]);if(w.key==="ArrowDown"||w.key==="ArrowUp"){w.preventDefault();let b=h.current?[h.current,...f]:f,S=b.indexOf(w.target),E=w.key==="ArrowDown"?(S+1)%b.length:S<0?b.length-1:(S-1+b.length)%b.length;b[E]?.focus()}else w.key==="Enter"&&w.target===h.current&&(w.preventDefault(),f[0]?.focus())},children:[v?e("div",{class:"site-search",children:e("input",{ref:h,type:"search",class:"value","aria-label":o("sites.search"),placeholder:o("sites.search"),value:u,onInput:w=>g(w.currentTarget.value)})}):null,y.length===0?e("p",{class:"site-no-results",role:"status",children:o("empty.search",{q:u.trim()})}):null,y.map(w=>e("button",{type:"button","aria-pressed":w.id===n?.id,class:w.id===n?.id?"site-option on":"site-option",onClick:()=>{c(!1),w.id!==n?.id&&a(w.id)},children:[e("span",{class:"site-option-text",children:[e("span",{class:"site-option-name",children:w.name}),w.hostnames[0]&&w.hostnames[0]!==w.name?e("span",{class:"site-option-host",children:w.hostnames[0]}):null]}),w.id===n?.id?e(T,{name:"check"}):null]})),l&&t.length>1?e(z,{children:[e("hr",{}),e("button",{type:"button",class:"site-option site-add",onClick:()=>{c(!1),l()},children:[e(T,{name:"list"}),e("span",{children:o("sites.all")})]})]}):null,s?e(z,{children:[e("hr",{}),e("button",{type:"button",class:"site-option site-add",onClick:()=>{c(!1),i()},children:[e(T,{name:"plus"}),e("span",{children:o("sites.addTitle")})]})]}):null]}):null]})}function yo({sites:t,view:n,onPick:s,onAdd:a,onClose:i}){let[l,r]=m({}),[c,d]=m("visitors"),[u,g]=m(!1),h=[["name","sites.name"],["visitors","metric.visitors"],["visits","metric.visits"],["pageviews","metric.pageviews"],["bounceRate","metric.bounceRate"],["visitDuration","metric.visitDuration"]],v=y=>{g(y===c?!u:y==="name"),d(y)};F(()=>{for(let y of t)R.stats({...n,site:y.id,filters:[]}).then(w=>r(f=>({...f,[y.id]:w.stats}))).catch(()=>r(w=>({...w,[y.id]:null})))},[]);let p=[...t].sort((y,w)=>{if(c==="name")return(u?1:-1)*y.name.localeCompare(w.name)||y.id.localeCompare(w.id);let f=l[y.id]?.[c],b=l[w.id]?.[c];return f===void 0||b===void 0?f===b?y.name.localeCompare(w.name):f===void 0?1:-1:(u?1:-1)*(f-b)||y.name.localeCompare(w.name)});return e(pe,{title:o("sites.all"),wide:!0,onClose:i,action:a?e("button",{type:"button",class:"ghost sheet-add-site",onClick:a,children:[e(T,{name:"plus"}),o("sites.addNew")]}):void 0,children:e("div",{class:"sheet-body all-sites",children:e("table",{class:"all-table",children:[e("thead",{children:e("tr",{children:h.map(([y,w])=>e("th",{"aria-sort":c===y?u?"ascending":"descending":"none",children:e("button",{type:"button",class:"sort-heading",onClick:()=>v(y),children:[o(w),c===y?e(T,{name:u?"arrow-up":"arrow-down"}):null]})}))})}),e("tbody",{children:p.map(y=>{let w=l[y.id];return e("tr",{children:[e("td",{children:e("button",{type:"button",class:"name",onClick:()=>s(y.id),children:[e(Ut,{site:y}),e("span",{class:"name-text",children:y.name})]})}),e("td",{children:w?O(w.visitors):w===null?"?":"\u2026"}),e("td",{children:w?O(w.visits):""}),e("td",{children:w?O(w.pageviews):""}),e("td",{children:w?ce(w.bounceRate):""}),e("td",{children:w?Fe(w.visitDuration):""})]})})})]})})})}var ci=["password","passw0rd","123456","qwerty","azerty","letmein","welcome","admin","runlight","iloveyou","abc123","monkey","dragon","football","baseball","sunshine","princess","shadow","master"];function wo(t,n=[]){if(t.length<10)return 0;let s=0;/[a-z]/.test(t)&&(s+=26),/[A-Z]/.test(t)&&(s+=26),/[0-9]/.test(t)&&(s+=10),/[^A-Za-z0-9]/.test(t)&&(s+=33);let a=0;for(let r=0;r<t.length;r++){let c=t.charCodeAt(r),d=t.charCodeAt(r-1),u=!1;for(let v=1;v<=4&&!u;v++)u=r-1-v>=0&&t[r]===t[r-v]&&t[r-1]===t[r-1-v];let g=r>0&&c===d,h=r>1&&c-d===d-t.charCodeAt(r-2)&&Math.abs(c-d)===1;a+=u?0:g||h?.25:1}let i=a*Math.log2(Math.max(s,10)),l=t.toLowerCase();for(let r of[...ci,...n.map(c=>c.toLowerCase()).filter(c=>c.length>=3)])i-=(l.split(r).length-1)*r.length*3;return i<40?1:i<60?2:i<80?3:4}function xo(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let n=t,s=(l,r)=>typeof n[l]=="string"&&n[l].trim().length<=r?n[l].trim():"",a=s("name",80),i=s("email",254);if(n.action==="share")return a?{action:"share",input:{name:a}}:null;if(n.action==="invite")return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i)&&(n.role==="member"||n.role==="viewer")?{action:"invite",input:{email:i,role:n.role}}:null;if(n.action==="report")return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i)&&(n.frequency==="weekly"||n.frequency==="monthly")&&["en","fr","de","es","pt"].includes(String(n.lang))?{action:"report",input:{email:i,frequency:n.frequency,lang:String(n.lang)}}:null;if(n.action==="funnel"){if(!a||!Array.isArray(n.steps)||n.steps.length<2||n.steps.length>8)return null;let l=[];for(let r of n.steps){if(!r||r.kind!=="page"&&r.kind!=="event"||typeof r.match!="string"||!r.match.trim()||r.match.length>500)return null;l.push({kind:r.kind,match:r.match.trim()})}return{action:"funnel",input:{name:a,steps:l}}}if(n.action==="goal"){let l=s("match",500);if(!a||!l||n.kind!=="page"&&n.kind!=="event"&&n.kind!=="click")return null;let r=n.valueMode??"none";if(r!=="none"&&r!=="fixed"&&r!=="prop"||n.kind==="click"&&n.clickBy!=="selector"&&n.clickBy!=="link")return null;let c=s("currency",3);if(r!=="none"&&!/^[A-Z]{3}$/.test(c)||r==="fixed"&&(typeof n.value!="number"||!Number.isFinite(n.value)||n.value<0||n.value>=1e9))return null;let d=s("valueProp",40);return r==="prop"&&(n.kind!=="event"||!/^[A-Za-z0-9_.-]{1,40}$/.test(d))?null:{action:"goal",input:{name:a,kind:n.kind,match:l,clickBy:n.clickBy==="link"?"link":"selector",valueMode:r,value:r==="fixed"?Math.round(Number(n.value)*100)/100:0,valueProp:r==="prop"?d:"",currency:c||"USD"}}}return null}function ko({action:t,site:n,allowed:s,disabled:a,onConfirm:i,onCancel:l}){let r=t.draft,c=[[o("app.site"),n]];return"name"in r.input&&c.push([o("goals.name"),r.input.name]),r.action==="goal"&&(c.push([o("goals.counts"),o(`goals.kind.${r.input.kind}`)],[o(r.input.kind==="event"?"goals.match.event":r.input.kind==="page"?"goals.match.page":r.input.clickBy==="link"?"goals.match.link":"goals.match.selector"),r.input.match]),c.push([o("goals.valueLabel"),r.input.valueMode==="none"?o("goals.value.none"):r.input.valueMode==="fixed"?`${r.input.value} ${r.input.currency}`:`${r.input.valueProp} (${r.input.currency})`])),r.action==="funnel"&&r.input.steps.forEach((d,u)=>c.push([`${u+1}. ${o(d.kind==="page"?"goals.kind.page":"goals.kind.event")}`,d.match])),(r.action==="invite"||r.action==="report")&&c.push([o("assistant.action.email"),r.input.email]),r.action==="invite"&&c.push([o("people.role"),o(`people.${r.input.role}`)]),r.action==="report"&&c.push([o("reports.frequency"),o(r.input.frequency==="weekly"?"reports.weekly":"reports.monthly")],[o("reports.language"),r.input.lang]),e("section",{class:"assistant-action","aria-label":o(`assistant.action.${r.action}`),children:[e("h3",{children:o(`assistant.action.${r.action}`)}),e("dl",{children:c.map(([d,u])=>e("div",{children:[e("dt",{children:d}),e("dd",{children:u})]}))}),r.action==="share"?e("p",{children:o("assistant.action.shareHint")}):r.action==="invite"?e("p",{children:o("assistant.action.inviteHint")}):r.action==="report"?e("p",{children:o("assistant.action.reportHint")}):null,t.status==="pending"?e(z,{children:[e("p",{children:o(s?"assistant.action.review":"assistant.action.denied")}),e("div",{class:"settings-actions start",children:[e("button",{type:"button",class:"solid",disabled:!s||a,onClick:i,children:[e(T,{name:"check"}),o(`assistant.action.${r.action}`)]}),e("button",{type:"button",class:"ghost",disabled:a,onClick:l,children:o("common.cancel")})]})]}):e("p",{role:"status",children:t.result||o(`assistant.action.${t.status}`)}),t.link?e("a",{href:t.link,target:"_blank",rel:"noopener noreferrer",children:o("assistant.action.openLink")}):null]})}function je({icon:t,title:n,tone:s,action:a,children:i}){return e("div",{class:s?`callout-box ${s}`:"callout-box",role:s?"note":void 0,children:[e("span",{class:"callout-box-icon","aria-hidden":"true",children:e(T,{name:t})}),e("div",{class:"callout-box-text",children:[e("strong",{children:n}),e("p",{children:i})]}),a?e("div",{class:"callout-box-action",children:a}):null]})}function di(t){let n=t.from&&t.to?`${t.from} to ${t.to}`:`the period "${t.period}"`,s=t.filters.map(a=>`${a.dimension} ${a.op} ${a.value}`).join(", ");return s?`${n}, filtered to ${s}`:n}function kt(t){let n=[],s=/\*\*([^*]+)\*\*|`([^`]+)`/g,a=0;for(let i=s.exec(t);i;i=s.exec(t))i.index>a&&n.push(t.slice(a,i.index)),n.push(i[1]!==void 0?e("strong",{children:i[1]}):e("code",{children:i[2]})),a=i.index+i[0].length;return a<t.length&&n.push(t.slice(a)),n}function pi({text:t}){let n=[],s=t.replace(/\r/g,"").split(`
`);for(let a=0;a<s.length;){let i=s[a];if(!i.trim()){a++;continue}if(/^\s*[-*] /.test(i)||/^\s*\d+[.)] /.test(i)){let r=/^\s*\d/.test(i),c=[];for(;a<s.length&&(/^\s*[-*] /.test(s[a])||/^\s*\d+[.)] /.test(s[a]));)c.push(s[a++].replace(/^\s*(?:[-*]|\d+[.)]) /,""));n.push(r?e("ol",{children:c.map(d=>e("li",{children:kt(d)}))}):e("ul",{children:c.map(d=>e("li",{children:kt(d)}))}));continue}if(i.trim().startsWith("|")){let r=[];for(;a<s.length&&s[a].trim().startsWith("|");){let u=s[a++].trim().replace(/^\||\|$/g,"").split("|").map(g=>g.trim());u.every(g=>/^:?-{2,}:?$/.test(g))||r.push(u)}let[c,...d]=r;n.push(e("div",{class:"reply-table",children:e("table",{children:[c?e("thead",{children:e("tr",{children:c.map(u=>e("th",{children:kt(u)}))})}):null,e("tbody",{children:d.map(u=>e("tr",{children:u.map(g=>e("td",{children:kt(g)}))}))})]})}));continue}let l=[];for(;a<s.length&&s[a].trim()&&!/^\s*(?:[-*]|\d+[.)]) /.test(s[a])&&!s[a].trim().startsWith("|");)l.push(s[a++].replace(/^#+\s*/,""));n.push(e("p",{children:kt(l.join(" "))}))}return e("div",{class:"reply",children:n})}var ui=["assistant.ask1","assistant.ask2","assistant.ask3","assistant.ask4"];function _o({site:t,view:n,owner:s,canWrite:a,canInvite:i,onSetup:l,onClose:r}){let c=`runlight_assistant:${t.id}`,d=q(null);be(d);let[u,g]=m(()=>R.cachedAssistant()??null),[h,v]=m(""),[p,y]=m(()=>{try{let M=JSON.parse(sessionStorage.getItem(c)??"[]");for(;M.length&&M[M.length-1].role==="user";)M.pop();return M.map(C=>C.action?.status==="saving"?{...C,action:{...C.action,status:"failed",result:o("assistant.action.unknown")}}:C)}catch{return[]}}),[w,f]=m(""),[b,S]=m(!1),E=q(null),$=q(!1),[A,x]=m(!1),k=q(0),L=q(null);F(()=>{R.assistant().then(g).catch(C=>v(C.message));let M=C=>C.key==="Escape"&&r();return document.addEventListener("keydown",M),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",M),document.body.classList.remove("locked")}},[]),F(()=>{try{sessionStorage.setItem(c,JSON.stringify(p.slice(-40)))}catch{}E.current?.scrollTo({top:E.current.scrollHeight,behavior:"smooth"})},[p,b]),F(()=>{u?.configured&&L.current?.focus()},[u?.configured]);let N=M=>{let C=M.trim();if(!C||b||$.current)return;let _=[...p.map(U=>U.action?.status==="pending"?{...U,action:{...U.action,status:"cancelled"}}:U),{role:"user",content:C}];y(_),f(""),S(!0);let P=k.current;R.ask(t.id,_.filter(U=>!U.error).map(({role:U,content:G,action:B})=>({role:U,content:G+(B?`
Draft: ${JSON.stringify(B.draft)}. Status: ${B.status}.`:"")})),di(n),Q()).then(U=>{if(P!==k.current)return;let G=xo(U.action);y([..._,{role:"assistant",content:G?o("assistant.action.ready"):U.action?o("assistant.action.incomplete"):U.reply||o("assistant.empty"),checked:U.tools.length,...G?{action:{draft:G,status:"pending"}}:{}}])}).catch(U=>P===k.current&&y([..._,{role:"assistant",content:U.message,error:!0}])).finally(()=>P===k.current&&S(!1))},D=(M,C)=>{y(_=>{let P=_.map((U,G)=>G===M?{...U,action:C}:U);try{sessionStorage.setItem(c,JSON.stringify(P.slice(-40)))}catch{}return P})},H=async M=>{let C=p[M]?.action;if(!C||C.status!=="pending"||$.current||!(C.draft.action==="invite"?i:a))return;$.current=!0,x(!0),D(M,{...C,status:"saving"});let _=o("assistant.action.done"),P;try{let U=C.draft;if(U.action==="goal"&&await R.createGoal(t.id,U.input),U.action==="funnel"&&await R.saveFunnel(t.id,null,U.input),U.action==="report"&&await R.addReport(t.id,U.input),U.action==="share"){let G=await R.createShare(t.id,U.input.name);P=new URL(G.share.path,location.origin).href}if(U.action==="invite"){let G=await R.addPerson(U.input.email,U.input.role,t.id);_=o(G.emailed?"assistant.action.invited":"assistant.action.inviteManual"),P=G.link}D(M,{...C,status:"done",result:_,link:P})}catch(U){D(M,{...C,status:"failed",result:`${U instanceof Error?U.message:String(U)} ${o("assistant.action.unknown")}`})}finally{$.current=!1,x(!1)}};return e("div",{class:"scrim",onPointerDown:M=>M.target===M.currentTarget&&r(),children:e("div",{class:"drawer assistant",role:"dialog","aria-modal":"true","aria-labelledby":"assistant-title",ref:d,children:[e("header",{class:"drawer-head",children:[e("h2",{id:"assistant-title",children:o("assistant.title")}),e("div",{class:"assistant-tools",children:[p.length?e("button",{type:"button",class:"copy inline",disabled:A,onClick:()=>{k.current++,S(!1),y([])},children:[e(T,{name:"reset"}),o("assistant.clear")]}):null,e("button",{type:"button",class:"remove","aria-label":o("common.close"),onClick:r,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]})]}),e("p",{class:"assistant-about",children:o("assistant.about",{site:t.name})}),e("div",{class:"drawer-body assistant-messages",ref:E,"aria-live":"polite",children:[h?e("p",{class:"failure",role:"alert",children:h}):null,u===null?h?null:e(ne,{chart:!0}):u.configured?p.length===0?e("div",{class:"assistant-empty",children:[e("span",{class:"assistant-mark","aria-hidden":"true",children:e(T,{name:"robot"})}),e("p",{children:o("assistant.intro")}),e("div",{class:"assistant-suggestions",children:ui.map(M=>e("button",{type:"button",class:"ghost",disabled:!u,onClick:()=>N(o(M)),children:o(M)}))})]}):p.map((M,C)=>e("div",{class:`message ${M.role}${M.error?" error":""}`,children:[M.role==="user"?e("p",{children:M.content}):e(pi,{text:M.content}),M.action?e(ko,{action:M.action,site:t.name,allowed:M.action.draft.action==="invite"?i:a,disabled:b||A,onConfirm:()=>{H(C)},onCancel:()=>D(C,{...M.action,status:"cancelled"})}):null,M.checked?e("span",{class:"message-meta",children:X("assistant.checked",M.checked)}):null]})):e("div",{class:"assistant-empty",children:[e("span",{class:"assistant-mark","aria-hidden":"true",children:e(T,{name:"robot"})}),e("p",{children:o(s?"assistant.setupOwner":"assistant.setupViewer")}),s?e("button",{type:"button",class:"solid",onClick:l,children:[e(T,{name:"key"}),o("assistant.setup")]}):null]}),b?e("div",{class:"message assistant thinking",children:e("span",{class:"dots",role:"status","aria-label":o("assistant.thinking"),children:[e("span",{}),e("span",{}),e("span",{})]})}):null]}),u?.configured?e("form",{class:"drawer-foot assistant-ask",onSubmit:M=>{M.preventDefault(),N(w)},children:[e("textarea",{ref:L,class:"value",rows:2,"aria-label":o("assistant.placeholder"),placeholder:o("assistant.placeholder"),value:w,onInput:M=>f(M.target.value),onKeyDown:M=>{M.key==="Enter"&&!M.shiftKey&&!M.isComposing&&(M.preventDefault(),N(w))}}),e("button",{type:"submit",class:"solid",disabled:b||!w.trim(),"aria-label":o("assistant.send"),children:e(T,{name:"send"})})]}):null]})})}function So({owner:t}){let[n,s]=m(null),[a,i]=m({provider:"anthropic",model:"",baseUrl:"",key:""}),[l,r]=m(""),[c,d]=m(!1),[u,g]=m(!1),[h,v]=m(null),[p,y]=m(!1),[w,f]=m(!1),[b,S]=m(""),[E,$]=m(""),[A,x]=m({}),[k,L]=m(""),N=()=>{S(""),f(!0),R.assistantModels({provider:a.provider,baseUrl:a.baseUrl,key:a.key}).then(P=>{v(P.models),y(!1),a.model||i(U=>({...U,model:P.models.some(G=>G.id===M?.model)?M.model:P.models[0]?.id??""}))}).catch(P=>S(P.message)).finally(()=>f(!1))},D=()=>R.assistant().then(P=>{s(P),i({provider:P.provider||"anthropic",model:P.model??"",baseUrl:P.baseUrl??"",key:""}),$(String(P.viewerDaily??""))}).catch(P=>r(P.message));if(F(()=>{D()},[]),!t)return e("p",{class:"settings-text",children:o("assistant.ownersOnly")});if(!n)return l?e("p",{class:"settings-error",children:l}):null;let H=n.providers??[],M=H.find(P=>P.id===a.provider),C=n.provider===a.provider,_=P=>{P.preventDefault(),r(""),d(!1),g(!0),R.saveAssistant(a).then(()=>(d(!0),D())).catch(U=>r(U.message)).finally(()=>g(!1))};return e(z,{children:[e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("assistant.settingsIntro")}),e(je,{icon:"eye",title:o("assistant.privacyTitle"),children:o("assistant.privacy")}),n.encrypted?null:e(je,{icon:"key",tone:"warn",title:o("assistant.notEncryptedTitle"),children:o("assistant.notEncrypted")})]}),e("form",{class:"settings-group",onSubmit:_,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.provider")}),e("select",{class:"value",value:a.provider,onChange:P=>{let U=P.target.value;i({provider:U,model:U===n.provider?n.model??"":"",baseUrl:U===n.provider?n.baseUrl??"":"",key:""}),v(null),S(""),d(!1)},children:H.map(P=>e("option",{value:P.id,children:P.name}))})]}),M&&(M.key!=="yes"||!M.baseUrl)?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.address")}),e("input",{class:"value",type:"url",placeholder:M.baseUrl||"https://api.example.com/v1",value:a.baseUrl,onInput:P=>i({...a,baseUrl:P.target.value})}),e("span",{class:"field-hint",children:o(M.key==="no"?"assistant.addressLocal":"assistant.addressHint")})]}):null,M?.key!=="no"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.key")}),e(ue,{class:"value",autoComplete:"off",placeholder:C&&n.keySaved?o("mail.keepSaved"):"",value:a.key,onInput:P=>i({...a,key:P.target.value})})]}):null,e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.model")}),e("div",{class:"model-row",children:[h&&!p?e("select",{class:"value",value:a.model,onChange:P=>i({...a,model:P.target.value}),children:[a.model?null:e("option",{value:"",children:o("assistant.pickModel")}),a.model&&!h.some(P=>P.id===a.model)?e("option",{value:a.model,children:a.model}):null,h.map(P=>e("option",{value:P.id,children:P.name===P.id?P.id:`${P.name} (${P.id})`}))]}):e("input",{class:"value",type:"text",spellcheck:!1,"aria-label":o("assistant.model"),placeholder:M?.model||o("assistant.modelPlaceholder"),value:a.model,onInput:P=>i({...a,model:P.target.value})}),e("button",{type:"button",class:"ghost",disabled:w,onClick:N,children:[e(T,{name:"refresh"}),o(w?"assistant.loadingModels":"assistant.loadModels")]})]}),h?e("button",{type:"button",class:"text-button",onClick:()=>y(!p),children:o(p?"assistant.chooseFromList":"assistant.typeModel")}):e("span",{class:"field-hint",children:M?.model?o("assistant.modelDefault",{model:M.model}):o("assistant.modelHint")}),b?e("span",{class:"settings-error",children:b}):null]}),e("div",{class:"settings-actions",children:[e("button",{type:"submit",class:"solid",disabled:u,children:[e(T,{name:"save"}),o("settings.save")]}),c?e("span",{class:"settings-ok",children:o("settings.saved")}):null,l?e("span",{class:"settings-error",children:l}):null]})]}),n.configured?e("form",{class:"settings-group",onSubmit:P=>{P.preventDefault(),x({}),R.saveAssistantLimit(Number(E)).then(()=>x({saved:!0})).catch(U=>x({error:U.message}))},children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.viewerDaily")}),e("input",{class:"value",type:"number",min:0,max:1e3,step:1,required:!0,value:E,onInput:P=>$(P.target.value)}),e("span",{class:"field-hint",children:o("assistant.viewerDailyHint")})]}),e("div",{class:"settings-actions",children:[e("button",{type:"submit",class:"solid",children:[e(T,{name:"save"}),o("settings.save")]}),A.saved?e("span",{class:"settings-ok",children:o("settings.saved")}):null,A.error?e("span",{class:"settings-error",children:A.error}):null]})]}):null,n.configured?e("div",{class:"settings-group",children:e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.remove")}),e("span",{class:"field-hint",children:o("assistant.removeHint")}),e("div",{children:e(ie,{name:M?.name??"",onDelete:()=>{L(""),R.removeAssistant().then(D).catch(P=>L(P.message))}})}),k?e("span",{class:"settings-error",children:k}):null]})}):null]})}var mi=(t,n)=>{let s=`mail.field.${t}`,a=o(s);return a===s?n:a};function hi({site:t,admin:n}){let[s,a]=m(null),[i,l]=m(!1),[r,c]=m({}),[d,u]=m(""),[g,h]=m(!1),[v,p]=m(""),[y,w]=m(""),f=()=>R.mail(t.remote?t.id:void 0).then(k=>{a(k),c({service:k.service||"ses",from:k.from,fromName:k.fromName,...k.fields})}).catch(k=>u(k.message));if(F(()=>{f()},[]),!s)return d?e("p",{class:"settings-error",children:d}):null;let b=s.services.find(k=>k.id===s.service),S=s.source==="app"?s.app?.via??"":b?.name??s.service,E=s.fromName?`${s.fromName} <${s.from}>`:s.from;if(t.remote)return s.source?e("ul",{class:"domain-list",children:e("li",{children:e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:S}),e("span",{class:"share-meta",children:o("mail.fromRemote",{from:s.fromName?`${s.fromName} <${s.from}>`:s.from,host:new URL(t.remote).host})})]})})}):e("div",{class:"settings-warning with-action",children:[e("span",{children:o("mail.noneRemote",{host:new URL(t.remote).host})}),e("a",{class:"ghost",href:t.remote,target:"_blank",rel:"noopener",children:[e(T,{name:"external"}),o("sites.openRemote")]})]});let $=s.services.find(k=>k.id===r.service)??s.services[0],A=k=>{k.preventDefault(),u(""),h(!0),R.saveMail(r).then(()=>(l(!1),f())).catch(L=>u(L.message)).finally(()=>h(!1))},x=k=>{k.preventDefault(),u(""),w(""),h(!0),R.testMail(v.trim(),Q()).then(()=>w(o("mail.testSent",{to:v.trim()}))).catch(L=>u(L.message)).finally(()=>h(!1))};return!n&&!s.source?e("p",{class:"settings-note",children:o("mail.adminOnly")}):i||!s.source?e("form",{class:"goal-form",onSubmit:A,children:[s.encrypted?null:e(je,{icon:"key",tone:"warn",title:o("mail.notEncryptedTitle"),children:o("mail.notEncrypted")}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("mail.service")}),e("select",{class:"value",value:r.service,onChange:k=>c({...r,service:k.target.value}),children:s.services.map(k=>e("option",{value:k.id,children:k.name}))})]}),$.fields.map(k=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:[mi(k.name,k.label),k.optional?e("span",{class:"optional",children:[" ",o("mail.optional")]}):null]}),k.options?e("select",{class:"value",value:r[k.name]||k.options[0],onChange:L=>c({...r,[k.name]:L.target.value}),children:k.options.map(L=>e("option",{value:L,children:L}))}):k.secret?e(ue,{class:"value",autoComplete:"off",spellcheck:!1,placeholder:s.saved.includes(k.name)&&s.service===$.id?o("mail.keepSaved"):k.placeholder??"",value:r[k.name]??"",onInput:L=>c({...r,[k.name]:L.target.value})}):e("input",{class:"value",type:"text",autoComplete:"off",spellcheck:!1,placeholder:k.placeholder??"",value:r[k.name]??"",onInput:L=>c({...r,[k.name]:L.target.value})})]})),e("div",{class:"value-row even",children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("mail.from")}),e("input",{class:"value",type:"email",placeholder:"reports@example.com",value:r.from??"",onInput:k=>c({...r,from:k.target.value})})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:[o("mail.fromName"),e("span",{class:"optional",children:[" ",o("mail.optional")]})]}),e("input",{class:"value",type:"text",placeholder:"Runlight",value:r.fromName??"",onInput:k=>c({...r,fromName:k.target.value})})]})]}),e("p",{class:"field-hint",children:o("mail.fromHint")}),d?e("p",{class:"settings-error",children:d}):null,e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:g,children:[e(T,{name:"check"}),o("mail.save")]}),s.source?e("button",{type:"button",class:"ghost",onClick:()=>l(!1),children:o("goals.cancel")}):null]})]}):e("div",{class:"settings-group",children:[e("ul",{class:"domain-list",children:e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:S}),e("span",{class:"share-meta",children:s.source==="app"?o("mail.viaApp",{via:S,from:E}):o(s.source==="code"?"mail.fromCode":"mail.fromLine",{from:E})})]}),s.source==="app"&&n?e("div",{class:"domain-actions",children:e("button",{type:"button",class:"copy inline",onClick:()=>l(!0),children:[e(T,{name:"edit"}),o("mail.useAnother")]})}):s.source==="dashboard"&&n?e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>l(!0),children:[e(T,{name:"edit"}),o("mail.change")]}),s.app?e("button",{type:"button",class:"copy inline",disabled:g,onClick:()=>{R.removeMail().then(f).catch(k=>u(k.message))},children:[e(T,{name:"reset"}),o("mail.backToApp",{via:s.app.via})]}):e(ie,{name:b?.name??"",onDelete:()=>{R.removeMail().then(f).catch(k=>u(k.message))}})]}):null]})}),s.source==="dashboard"&&s.app?e("p",{class:"field-hint",children:o("mail.replacesApp",{via:s.app.via})}):null,e("form",{class:"domain-add",onSubmit:x,children:[e("input",{class:"value",type:"email",placeholder:o("mail.testTo"),value:v,onInput:k=>p(k.target.value)}),e("button",{type:"submit",class:"solid",disabled:g||!v.trim(),children:[e(T,{name:"send"}),o("mail.test")]})]}),y?e("p",{class:"settings-ok-text",children:[e(T,{name:"check"}),y]}):null,d?e("p",{class:"settings-error",children:d}):null]})}function gi(t){return t?new Intl.DateTimeFormat(Q(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t):o("reports.never")}function Co({site:t,admin:n}){return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:t.remote?o("mail.introRemote",{host:new URL(t.remote).host}):o("mail.intro")}),e(hi,{site:t,admin:n})]})}function To({site:t,onSetUp:n}){let[s,a]=m(null),[i,l]=m(null),[r,c]=m(""),[d,u]=m("weekly"),[g,h]=m(Q()),[v,p]=m(""),[y,w]=m(""),[f,b]=m(""),S=()=>R.reports(t.id).then(x=>l(x.reports)).catch(x=>p(x.message));F(()=>{S(),R.mail(t.remote?t.id:void 0).then(x=>a(!!x.source)).catch(()=>a(!1))},[t.id]);let E=x=>{x.preventDefault(),p(""),R.addReport(t.id,{email:r.trim(),frequency:d,lang:g}).then(()=>(c(""),S())).catch(k=>p(k.message))},$=x=>{p(""),w(""),b(x.id),R.sendReport(t.id,x.id).then(()=>w(o("reports.sampleSent",{to:x.email}))).catch(k=>p(k.message)).finally(()=>b(""))},A=x=>Ne.find(([k])=>k===x)?.[1]??x;return e(z,{children:[s===!1?e("div",{class:"settings-group",children:e(je,{icon:"send",tone:"warn",title:o("reports.needsMailTitle"),action:t.remote?null:e("button",{type:"button",class:"ghost",onClick:n,children:[e(T,{name:"send"}),o("reports.setUpMail")]}),children:t.remote?o("mail.noneRemote",{host:new URL(t.remote).host}):o("reports.needsMail")})}):null,e("div",{class:"settings-group",children:[e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("reports.title")}),e("span",{class:"settings-text",children:o("reports.intro",{site:t.name})})]}),i&&i.length?e("ul",{class:"domain-list",children:i.map(x=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:x.email}),e("span",{class:"share-meta",children:[o(x.frequency==="monthly"?"reports.monthly":"reports.weekly")," \xB7 ",A(x.lang)," \xB7 ",o("reports.lastSent",{when:gi(x.lastSentAt)})]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",disabled:!s||f===x.id,onClick:()=>$(x),children:[e(T,{name:"send"}),o("reports.sample")]}),e(ie,{name:x.email,onDelete:()=>{R.deleteReport(t.id,x.id).then(S)}})]})]}))}):i?e(J,{size:"card",icon:"send",title:o("reports.emptyTitle"),hint:o("reports.none")}):null,y?e("p",{class:"settings-ok-text",children:[e(T,{name:"check"}),y]}):null,e("form",{class:"report-add",onSubmit:E,children:[e("input",{class:"value",type:"email",placeholder:o("reports.emailPlaceholder"),value:r,onInput:x=>c(x.target.value)}),e("select",{class:"value",value:d,"aria-label":o("reports.frequency"),onChange:x=>u(x.target.value),children:[e("option",{value:"weekly",children:o("reports.weekly")}),e("option",{value:"monthly",children:o("reports.monthly")})]}),e("select",{class:"value",value:g,"aria-label":o("reports.language"),onChange:x=>h(x.target.value),children:Ne.map(([x,k])=>e("option",{value:x,children:k}))}),e("button",{type:"submit",class:"solid",disabled:!r.trim(),children:[e(T,{name:"plus"}),o("reports.add")]})]}),v?e("p",{class:"settings-error",children:v}):null,e("p",{class:"field-hint",children:o("reports.when")})]})]})}var Mo=t=>o(t.kind==="page"?"funnels.stepPage":"funnels.stepEvent",{match:t.match});function Eo({funnel:t}){let n=Math.max(1,t.steps[0]?.visits??0);return e("ol",{class:"funnel",children:t.steps.map((s,a)=>{let i=s.visits??0,l=a===0?i:t.steps[a-1].visits??0;return e("li",{children:[e("div",{class:"funnel-label",children:[e("span",{class:"funnel-step",children:a+1}),e("span",{class:"name-text",children:Mo(s)}),e("span",{class:"num",children:O(i)})]}),e("div",{class:"funnel-track",children:e("span",{class:"funnel-fill",style:{width:`${i/n*100}%`}})}),a>0?e("span",{class:"funnel-rate",children:o("funnels.wentOn",{pct:l?ce(i/l):ce(0)})}):null]})})})}function Ao({site:t}){let[n,s]=m(null),[a,i]=m(null),[l,r]=m(""),c=()=>R.funnelDefinitions(t.id).then(d=>s(d.funnels)).catch(d=>r(d.message));return F(()=>{c()},[t.id]),a?e(fi,{site:t,funnel:a==="new"?null:a,onDone:()=>{i(null),c()}}):e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("funnels.intro")}),n===null&&!l?e(Ot,{}):null,n&&n.length?e("ul",{class:"domain-list goal-list",children:n.map(d=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:d.name}),e("span",{class:"share-meta",children:d.steps.map(Mo).join(" \u2192 ")})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(d),children:[e(T,{name:"edit"}),o("goals.edit")]}),e(ie,{name:d.name,onDelete:()=>{R.deleteFunnel(t.id,d.id).then(c)}})]})]}))}):n?e(J,{size:"card",icon:"funnel",title:o("funnels.emptyTitle"),hint:o("funnels.none")}):null,l?e("p",{class:"settings-error",children:l}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"solid",onClick:()=>i("new"),children:[e(T,{name:"plus"}),o("funnels.add")]})})]})}function fi({site:t,funnel:n,onDone:s}){let[a,i]=m(n?.name??""),[l,r]=m(n?.steps.map(h=>({kind:h.kind,match:h.match}))??[{kind:"page",match:""},{kind:"page",match:""}]),[c,d]=m(""),u=(h,v)=>r(l.map((p,y)=>y===h?{...p,...v}:p));return e("form",{class:"settings-group",onSubmit:h=>{h.preventDefault(),d(""),R.saveFunnel(t.id,n?.id??null,{name:a.trim(),steps:l}).then(s).catch(v=>d(v.message))},children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("funnels.name")}),e("input",{class:"value",type:"text",maxLength:80,required:!0,placeholder:o("funnels.namePlaceholder"),value:a,onInput:h=>i(h.target.value)})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("funnels.steps")}),e("ol",{class:"funnel-steps",children:l.map((h,v)=>e("li",{children:[e("span",{class:"funnel-step",children:v+1}),e("select",{class:"value",value:h.kind,"aria-label":o("funnels.kind"),onChange:p=>u(v,{kind:p.target.value}),children:[e("option",{value:"page",children:o("funnels.page")}),e("option",{value:"event",children:o("funnels.event")})]}),e("input",{class:"value",type:"text",required:!0,placeholder:h.kind==="page"?"/pricing":"Signup",value:h.match,onInput:p=>u(v,{match:p.target.value})}),e("button",{type:"button",class:"remove","aria-label":o("funnels.removeStep"),disabled:l.length<=2,onClick:()=>r(l.filter((p,y)=>y!==v)),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}))}),e("span",{class:"field-hint",children:o("funnels.stepsHint")}),l.length<8?e("div",{children:e("button",{type:"button",class:"ghost",onClick:()=>r([...l,{kind:"page",match:""}]),children:[e(T,{name:"plus"}),o("funnels.addStep")]})}):null]}),e("div",{class:"settings-actions",children:[c?e("span",{class:"settings-error",children:c}):null,e("button",{type:"button",class:"ghost",onClick:s,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",children:[e(T,{name:"save"}),o(n?"funnels.save":"funnels.create")]})]})]})}var vi=["USD","EUR","GBP","CAD","AUD","NZD","JPY","CHF","SEK","NOK","DKK","PLN","BRL","MXN","INR","SGD","HKD","ZAR"];function On(t){return t.kind==="page"?o("goals.describe.page",{match:t.match}):t.kind==="click"?o(t.clickBy==="link"?"goals.describe.link":"goals.describe.selector",{match:t.match}):o("goals.describe.event",{match:t.match})}function Ro(t){return t.valueMode==="fixed"?o("goals.value.each",{amount:Ge(t.value,t.currency)}):t.valueMode==="prop"?o("goals.value.fromProp",{prop:t.valueProp,currency:t.currency}):""}function bi(t){let n=new Map;for(let s of t)s.valueMode!=="none"&&s.revenue&&n.set(s.currency,(n.get(s.currency)??0)+s.revenue);return[...n].map(([s,a])=>Ge(a,s)).join(" + ")}function Po({view:t,funnelView:n,readOnly:s,onAdd:a}){let[i,l]=m(null),[r,c]=m(""),[d,u]=m(null),[g,h]=m(()=>Ue("goal")??""),[v,p]=m([]),[y,w]=m(!0),[f,b]=m("goals");if(F(()=>{let A=!0;return c(""),l(null),Promise.allSettled([R.stats(t),R.series(t)]).then(()=>A?R.goals(t):null).then(x=>{!A||!x||(l(x.goals),g&&(x.goals.some(k=>k.id===g)&&u(g),h("")))}).catch(x=>A&&c(x.message)),()=>{A=!1}},[t]),F(()=>{let A=!0;return w(!0),R.funnels(n).then(x=>A&&p(x.funnels)).catch(()=>{}).finally(()=>A&&w(!1)),()=>{A=!1}},[n]),s&&i&&i.length===0&&v.length===0)return null;if(f==="funnels"&&v.length)return e("section",{class:s?"panel full":"panel",children:[e("header",{class:"panel-head",children:[e("h2",{children:o("panel.conversions")}),e("div",{class:"head-tools",children:[e("nav",{class:"tabs","aria-label":o("panel.conversions"),children:[e("button",{type:"button",class:"tab","aria-pressed":!1,onClick:()=>b("goals"),children:o("funnels.goalsTab")}),e("button",{type:"button",class:"tab on","aria-pressed":!0,children:o("funnels.tab")})]}),s?null:e("button",{type:"button",class:"box-button icon-only",title:o(f==="funnels"?"funnels.add":"goals.add"),"aria-label":o(f==="funnels"?"funnels.add":"goals.add"),onClick:()=>a(f),children:e(T,{name:"plus"})})]})]}),y?e(ne,{}):v.map(A=>e("div",{class:"funnel-block",children:[e("h3",{class:"funnel-name",children:A.name}),e(Eo,{funnel:A}),A.sampled?e("p",{class:"field-hint",children:o("funnels.sampled",{n:O(A.sampled)})}):null]}))]});let S=Math.max(1,...(i??[]).map(A=>A.conversions)),E=i?bi(i):"",$=[...i??[]].sort((A,x)=>x.conversions-A.conversions||A.name.localeCompare(x.name));return e("section",{class:s?"panel full":"panel",children:[e("header",{class:"panel-head",children:[e("h2",{children:[o("panel.conversions")," ",E?e("span",{class:"aside",children:o("goals.revenueAside",{amount:E})}):null]}),e("div",{class:"head-tools",children:[v.length?e("nav",{class:"tabs","aria-label":o("panel.conversions"),children:[e("button",{type:"button",class:"tab on","aria-pressed":!0,children:o("funnels.goalsTab")}),e("button",{type:"button",class:"tab","aria-pressed":!1,onClick:()=>b("funnels"),children:o("funnels.tab")})]}):null,!s&&!v.length?e("button",{type:"button",class:"box-button",onClick:()=>a("funnels"),children:[e(T,{name:"plus"}),o("funnels.add")]}):null,s?null:e("button",{type:"button",class:v.length?"box-button icon-only":"box-button",title:o(f==="funnels"?"funnels.add":"goals.add"),"aria-label":o(f==="funnels"?"funnels.add":"goals.add"),onClick:()=>a(f),children:[e(T,{name:"plus"}),v.length?null:o("goals.add")]})]})]}),r?e("p",{class:"empty",children:r}):null,!i&&!r?e(ne,{}):null,i&&i.length===0?e(J,{icon:"target",title:o("goals.emptyTitle"),hint:o("goals.emptyHint")}):null,i&&i.length?e(z,{children:e("div",{class:"table",children:[e("div",{class:"cols",children:[e("span",{children:o("goals.goal")}),e("span",{class:"extra",children:o("goals.rate")}),e("span",{class:"num-head",children:o("goals.conversions")})]}),e("ol",{class:"rows",children:$.map(A=>e("li",{children:[e("span",{class:"bar",style:{width:`${A.conversions/S*100}%`}}),e("button",{type:"button",class:"name",title:On(A),onClick:()=>he(`goal:${A.id}`)||u(A.id),children:[e("span",{class:"name-text",children:A.name}),A.valueMode!=="none"&&A.revenue?e("span",{class:"goal-money",children:Ge(A.revenue,A.currency)}):null]}),e("span",{class:"extra",children:ce(A.rate)}),e("span",{class:"num",children:O(A.conversions)})]}))})]})}):null,d?e(yi,{view:t,id:d,goal:i?.find(A=>A.id===d),onClose:()=>u(null)}):null]})}function $n({title:t,rows:n,dimension:s,currency:a,valued:i}){let l=Math.max(1,...n.map(r=>r.conversions));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(J,{size:"line",icon:"chart",title:o("empty.mini")}):null,e("ol",{class:"rows",children:n.map(r=>e("li",{children:[e("span",{class:"bar",style:{width:`${r.conversions/l*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:ge(s,r.value)||o("goals.unknown")})}),i?e("span",{class:"extra",children:Ge(r.revenue,a)}):null,e("span",{class:"num",children:O(r.conversions)})]}))})]})}function yi({view:t,id:n,goal:s,onClose:a}){let[i,l]=m(null),[r,c]=m("");F(()=>{R.goal(t,n).then(l).catch(h=>c(h.message))},[t,n]);let d=i?.goal??s,u=!!(d&&d.valueMode!=="none"),g=d?[{key:"conversions",slot:1,label:o("goals.conversions"),format:O},...u?[{key:"revenue",slot:4,label:o("goals.revenue"),format:h=>Ge(h,d.currency)}]:[]]:[];return e(pe,{title:d?.name??o("common.loading"),sub:d?On(d):void 0,wide:!0,onClose:a,children:e("div",{class:"sheet-body",children:[r?e("p",{class:"failure",children:r}):null,!i&&!r?e(ne,{chart:!0}):null,i&&d?e(z,{children:[e("div",{class:"goal-tiles",children:[e("div",{children:[e("span",{children:o("goals.conversions")}),e("strong",{children:O(i.totals.conversions)})]}),e("div",{children:[e("span",{children:o("goals.converted")}),e("strong",{children:O(i.totals.visitors)})]}),e("div",{children:[e("span",{children:o("goals.rate")}),e("strong",{children:ce(i.totals.rate)})]}),u?e("div",{children:[e("span",{children:o("goals.revenue")}),e("strong",{children:Ge(i.totals.revenue,d.currency)})]}):null]}),e("h3",{class:"mini-title",children:o(u?"goals.overTimeValued":"goals.overTime")}),e("div",{class:"link-chart",children:e(st,{points:i.series,metrics:g,interval:i.range.interval,timezone:i.range.timezone,height:240})}),e("div",{class:"mini-grid three",children:[e($n,{title:"goals.byChannel",rows:i.channels,dimension:"channel",currency:d.currency,valued:u}),e($n,{title:"goals.bySource",rows:i.sources,dimension:"source",currency:d.currency,valued:u}),e($n,{title:"goals.byPage",rows:i.pages,dimension:"page",currency:d.currency,valued:u})]})]}):null]})})}var wi={name:"",kind:"event",match:"",clickBy:"selector",valueMode:"none",value:0,valueProp:"revenue",currency:"USD"};function Hn({value:t,options:n,onChange:s,label:a}){return e("div",{class:"ops",role:"radiogroup","aria-label":a,children:n.map(([i,l])=>e("button",{type:"button",role:"radio","aria-checked":t===i,class:t===i?"op on":"op",onClick:()=>s(i),children:o(l)}))})}function xi({site:t,goal:n,view:s,onDone:a}){let[i,l]=m(()=>n?{...n}:{...wi,currency:ki()}),[r,c]=m(n?.valueMode==="fixed"?String(n.value):""),[d,u]=m(""),[g,h]=m(!1),[v,p]=m([]),[y,w]=m(!1),f=q(""),b=x=>l(k=>({...k,...x}));F(()=>{if(i.kind==="click")return p([]);R.breakdown({...s,period:"90d",from:"",to:"",filters:[]},i.kind==="event"?"event":"page",50).then(x=>p(x.rows.map(k=>k.value).filter(Boolean))).catch(()=>p([]))},[i.kind]),F(()=>{if(typeof BroadcastChannel>"u")return;let x=new BroadcastChannel("runlight-pick");return x.onmessage=k=>{let L=k.data;L?.runlight!=="pick"||!f.current||L.nonce!==f.current||typeof L.selector!="string"||(f.current="",w(!1),b({match:L.selector.slice(0,500),clickBy:"selector",...i.name?{}:{name:String(L.text||"").slice(0,60)}}))},()=>x.close()},[i.name]);let S=t.hostnames[0],E=()=>{if(!S)return;u(""),w(!0);let x=Array.from(crypto.getRandomValues(new Uint8Array(16)),L=>L.toString(16).padStart(2,"0")).join("");f.current=x;try{localStorage.setItem("runlight-pick",x)}catch{}let k=window.open("about:blank","_blank");if(!k){f.current="",w(!1),u(o("goals.pickBlocked"));return}k.opener=null,R.pickTicket(t.id,location.origin,`${location.origin}${le}/pick-return`,x).then(({ticket:L})=>{if(L.split(".").length<6)throw new Error(o("goals.pickUpdate"));k&&(k.location.href=`https://${S}/?runlight=pick&runlight_lang=${Q().slice(0,2)}&runlight_ticket=${encodeURIComponent(L)}`)}).catch(L=>{k?.close(),f.current="",w(!1),u(L.message)})},$=x=>{x.preventDefault(),u(""),h(!0);let k={...i,value:i.valueMode==="fixed"?Number(r):i.value};(n?R.updateGoal(t.id,n.id,k):R.createGoal(t.id,k)).then(a).catch(L=>u(L.message)).finally(()=>h(!1))},A="goal-suggestions";return e("form",{class:"goal-form",onSubmit:$,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.name")}),e("input",{class:"value",type:"text",maxLength:80,value:i.name,placeholder:o("goals.namePlaceholder"),onInput:x=>b({name:x.target.value})})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.counts")}),e(Hn,{label:o("goals.counts"),value:i.kind,options:[["event","goals.kind.event"],["page","goals.kind.page"],["click","goals.kind.click"]],onChange:x=>b({kind:x,match:"",...x!=="event"&&i.valueMode==="prop"?{valueMode:"fixed"}:{}})})]}),i.kind==="click"?e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.clickOn")}),e(Hn,{label:o("goals.clickOn"),value:i.clickBy==="link"?"link":"selector",options:[["selector","goals.click.selector"],["link","goals.click.link"]],onChange:x=>b({clickBy:x,match:""})})]}):null,e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o(i.kind==="event"?"goals.match.event":i.kind==="page"?"goals.match.page":i.clickBy==="link"?"goals.match.link":"goals.match.selector")}),e("div",{class:"match-row",children:[e("input",{class:"value",type:"text",spellcheck:!1,list:v.length?A:void 0,value:i.match,placeholder:i.kind==="event"?"Signup":i.kind==="page"?"/thanks*":i.clickBy==="link"?"https://buy.stripe.com/*":"#signup, .buy-button",onInput:x=>b({match:x.target.value})}),i.kind==="click"&&i.clickBy!=="link"&&S?e("button",{type:"button",class:"ghost",onClick:E,children:[e(T,{name:"target"}),o(y?"goals.picking":"goals.pick")]}):null]}),e("datalist",{id:A,children:v.map(x=>e("option",{value:x}))}),e("span",{class:"field-hint",children:o(i.kind==="event"?"goals.hint.event":i.kind==="page"?"goals.hint.page":i.clickBy==="link"?"goals.hint.link":"goals.hint.selector")}),y?e("span",{class:"field-hint",role:"status",children:o("goals.pickWaiting")}):null]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.valueLabel")}),e(Hn,{label:o("goals.valueLabel"),value:i.valueMode,options:[["none","goals.value.none"],["fixed","goals.value.fixed"],...i.kind==="event"?[["prop","goals.value.prop"]]:[]],onChange:x=>b({valueMode:x})}),i.valueMode!=="none"?e("span",{class:"field-hint",children:o(i.valueMode==="fixed"?"goals.value.fixedHint":"goals.value.propHint")}):null]}),i.valueMode!=="none"?e("div",{class:"value-row",children:[i.valueMode==="fixed"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.amount")}),e("input",{class:"value",type:"number",inputmode:"decimal",min:"0",max:"999999999.99",step:"0.01",required:!0,placeholder:"49.99",value:r,onInput:x=>c(x.target.value)})]}):e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.property")}),e("input",{class:"value",type:"text",spellcheck:!1,maxLength:40,value:i.valueProp,onInput:x=>b({valueProp:x.target.value})})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.currency")}),e("select",{class:"value",value:i.currency,onChange:x=>b({currency:x.target.value}),children:vi.map(x=>e("option",{value:x,children:x}))})]})]}):null,i.valueMode==="prop"?e("div",{class:"code small",children:e("pre",{tabIndex:0,children:e("code",{children:`runlight(${JSON.stringify(i.match||"Purchase")}, { ${JSON.stringify(i.valueProp||"revenue")}: 49.99 })`})})}):null,d?e("p",{class:"settings-error",children:d}):null,e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:g,children:[e(T,{name:"check"}),o(n?"goals.save":"goals.create")]}),e("button",{type:"button",class:"ghost",onClick:a,children:o("goals.cancel")})]})]})}function ki(){let t=(navigator.language.split("-")[1]??"").toUpperCase(),n={GB:"GBP",CA:"CAD",AU:"AUD",NZ:"NZD",JP:"JPY",CH:"CHF",SE:"SEK",NO:"NOK",DK:"DKK",PL:"PLN",BR:"BRL",MX:"MXN",IN:"INR",SG:"SGD",HK:"HKD",ZA:"ZAR"},s=new Set(["DE","FR","ES","IT","NL","BE","AT","PT","IE","FI","GR","LU","SK","SI","EE","LV","LT","MT","CY","HR"]);return n[t]??(s.has(t)?"EUR":"USD")}function Io({site:t,view:n}){let[s,a]=m(null),[i,l]=m(null),[r,c]=m(""),d=()=>R.goalDefinitions(t.id).then(g=>a(g.goals)).catch(g=>c(g.message));F(()=>{d()},[t.id]);let u=Ee(()=>s??[],[s]);return i?e("div",{class:"settings-group",children:e(xi,{site:t,view:n,goal:i==="new"?null:i,onDone:()=>{l(null),d()}})}):e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("goals.intro")}),s===null&&!r?e(Ot,{}):null,u.length?e("ul",{class:"domain-list goal-list",children:u.map(g=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:g.name}),e("span",{class:"share-meta",children:[On(g),Ro(g)?` \xB7 ${Ro(g)}`:""]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>l(g),children:[e(T,{name:"edit"}),o("goals.edit")]}),e(ie,{name:g.name,onDelete:()=>{R.deleteGoal(t.id,g.id).then(d)}})]})]}))}):s?e(J,{size:"card",icon:"target",title:o("goals.emptyTitle"),hint:o("goals.none")}):null,r?e("p",{class:"settings-error",children:r}):null,e("p",{class:"field-hint domain-note",children:o("goals.pastNote")}),e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"solid",onClick:()=>l("new"),children:[e(T,{name:"plus"}),o("goals.add")]})})]})}var Lo=[{id:"umami",name:"Umami",help:"import.umamiHelp",history:"full",fields:[{name:"url",label:"import.url",type:"url",placeholder:"https://stats.example.com"}]},{id:"dub",name:"Dub",help:"import.dubHelp",history:"full",fields:[{name:"apiKey",label:"import.apiKey",type:"password",placeholder:"dub_..."}]},{id:"bitly",name:"Bitly",help:"import.bitlyHelp",history:"daily",fields:[{name:"token",label:"import.token",type:"password"}]},{id:"shortio",name:"Short.io",help:"import.shortioHelp",history:"daily",fields:[{name:"apiKey",label:"import.apiKey",type:"password",placeholder:"sk_..."}]},{id:"rebrandly",name:"Rebrandly",help:"import.rebrandlyHelp",history:"none",fields:[{name:"apiKey",label:"import.apiKey",type:"password"},{name:"workspace",label:"import.workspace"}]},{id:"csv",name:"CSV",help:"import.csvHelp",history:"none",fields:[]}],Do=t=>t.code&&ve(t.code,t.params)||t.reason,rt={running:!1,done:0,total:null,links:0,clicks:0,skipped:0,failed:[],finished:!1,stopped:!1,error:""};function $o({site:t}){let[n,s]=m("umami"),[a,i]=m({}),[l,r]=m("key"),[c,d]=m(rt),u=q(!1),g=q(null),h=Lo.find(f=>f.id===n),v=n==="umami"?[...h.fields,...l==="key"?[{name:"apiKey",label:"import.apiKey",type:"password"}]:[{name:"username",label:"import.username"},{name:"password",label:"import.password",type:"password"}]]:h.fields,p=async()=>{u.current=!1;let f={...rt,running:!0};d(f);let b=Object.fromEntries(v.map(E=>[E.name,a[E.name]??""])),S=null;try{do{let E=await R.importStep(t.id,n,b,S,f.done);S=E.cursor,f={...f,done:E.done,total:E.total,links:f.links+E.links,clicks:f.clicks+E.clicks,skipped:f.skipped+E.skipped,failed:[...f.failed,...E.failed.map($=>({slug:$.slug,reason:Do($)}))]},d(f)}while(S&&!u.current);d({...f,running:!1,finished:!S,stopped:!!S})}catch(E){d({...f,running:!1,error:E instanceof Error?E.message:String(E)})}},y=async f=>{d({...rt,running:!0});try{let b=xt(await f.text()),S=await R.importLinks(t.id,b);d({...rt,finished:!0,links:S.created,done:b.length,total:b.length,failed:S.failed.map(E=>({slug:`#${E.row}`,reason:Do(E)}))})}catch(b){d({...rt,error:b instanceof Error?b.message:String(b)})}},w=c.total?Math.min(100,Math.round(c.done/c.total*100)):null;return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("import.intro")}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("import.source")}),e("div",{class:"source-grid",role:"radiogroup","aria-label":o("import.source"),children:Lo.map(f=>e("button",{type:"button",role:"radio","aria-checked":n===f.id,class:n===f.id?"source on":"source",disabled:c.running,onClick:()=>{s(f.id),d(rt)},children:[e("strong",{children:f.id==="csv"?o("import.csv"):f.name}),e("span",{children:o(`import.history.${f.history}`)})]}))})]}),e("p",{class:"field-hint",children:o(h.help)}),n==="umami"?e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("import.signIn")}),e("div",{class:"ops",role:"radiogroup","aria-label":o("import.signIn"),children:["key","password"].map(f=>e("button",{type:"button",role:"radio","aria-checked":l===f,class:l===f?"op on":"op",onClick:()=>r(f),children:o(f==="key"?"import.withKey":"import.withPassword")}))})]}):null,v.map(f=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o(f.label)}),f.type==="password"?e(ue,{class:"value",autoComplete:"off",spellcheck:!1,placeholder:f.placeholder,value:a[f.name]??"",onInput:b=>i({...a,[f.name]:b.target.value})}):e("input",{class:"value",type:f.type??"text",autoComplete:"off",spellcheck:!1,placeholder:f.placeholder,value:a[f.name]??"",onInput:b=>i({...a,[f.name]:b.target.value})})]})),e("p",{class:"field-hint",children:o("import.moveNote",{fallback:`${location.host}/go`})}),e("div",{class:"settings-actions start",children:n==="csv"?e(z,{children:[e("button",{type:"button",class:"solid",disabled:c.running,onClick:()=>g.current?.click(),children:[e(T,{name:"upload"}),o("import.chooseFile")]}),e("input",{ref:g,type:"file",accept:".csv,text/csv",hidden:!0,onChange:f=>{let b=f.target.files?.[0];b&&y(b),f.target.value=""}})]}):c.running?e("button",{type:"button",class:"ghost",onClick:()=>u.current=!0,children:[e(T,{name:"x"}),o("import.stop")]}):e("button",{type:"button",class:"solid",onClick:()=>{p()},children:[e(T,{name:"upload"}),o("import.start")]})}),c.running||c.finished||c.stopped||c.error?e("div",{class:"import-progress","aria-live":"polite",children:[c.running?e(z,{children:[e("div",{class:"progress-bar",children:e("span",{class:w===null?"progress-fill indeterminate":"progress-fill",style:w===null?void 0:{width:`${w}%`}})}),e("span",{class:"field-hint",children:[c.total?o("import.running",{done:O(c.done),total:O(c.total)}):X("import.soFar",c.links,{n:O(c.links)}),c.clicks?` \xB7 ${X("links.total",c.clicks,{n:O(c.clicks)})}`:""]})]}):null,c.error?e("p",{class:"settings-error",children:c.error}):null,c.finished?e("p",{class:"settings-ok-text",children:[e(T,{name:"check"}),o("import.done",{links:O(c.links),clicks:O(c.clicks),skipped:O(c.skipped)})]}):null,c.stopped?e("p",{class:"field-hint",children:o("import.stopped",{done:O(c.done),total:O(c.total??c.done)})}):null,c.failed.length?e("div",{class:"import-result",children:[e("strong",{children:o("import.failed")}),c.failed.slice(0,20).map(f=>e("span",{children:[f.slug,": ",f.reason]}))]}):null]}):null]})}function Ho(t){let n=s=>t.includes(s);return n("created_at")&&n("url_path")?"umami":n("time")&&(n("path")||n("url"))?"runlight":null}function Oo(t,n){let s=(n==="umami"?t.created_at:t.time)?.trim()??"";if(!s)return NaN;if(/^\d+(\.\d+)?$/.test(s)){let i=Number(s);return i<1e12?Math.round(i*1e3):Math.round(i)}let a=s.replace(" ","T");return Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(a)||!/T\d/.test(a)?a:`${a}Z`)}var $e={running:!1,done:0,total:0,pageviews:0,events:0,visits:0,finished:!1,stopped:!1,error:""},_i=t=>t.toLowerCase().replace(/^https?:\/\//,"").replace(/^www\./,"").replace(/\/.*$/,"");function Fo({site:t}){let[n,s]=m("umami");return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("visits.intro")}),e(je,{icon:"chart",title:o("visits.onlyUmamiTitle"),children:o("visits.onlyUmami")}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("visits.from")}),e("div",{class:"ops",role:"radiogroup","aria-label":o("visits.from"),children:["umami","csv"].map(a=>e("button",{type:"button",role:"radio","aria-checked":n===a,class:n===a?"op on":"op",onClick:()=>s(a),children:o(a==="umami"?"visits.fromUmami":"visits.fromCsv")}))})]}),n==="umami"?e(Ti,{site:t}):e(Ci,{site:t})]})}function Si(t,n){let s=t.map(l=>({row:l,ts:Oo(l,n)})).filter(l=>Number.isFinite(l.ts));s.sort((l,r)=>l.ts-r.ts);let a=[],i=0;for(;i<s.length;){let l=Math.min(i+2e3,s.length);for(;l<s.length&&l>i&&s[l].ts===s[l-1].ts;)l--;if(l===i)return null;a.push(s.slice(i,l).map(r=>r.row)),i=l}return a}function Ci({site:t}){let[n,s]=m(null),[a,i]=m({...$e,skipped:0}),l=q(null),r=q(!1),c=async g=>{s(null),i({...$e,skipped:0});let h=xt(await g.text()),v=Ho(Object.keys(h[0]??{}));if(!v||!h.length){i({...$e,skipped:0,error:o("error.import_csv_format")});return}s({name:g.name,rows:h,format:v})},d=async()=>{if(!n)return;r.current=!1;let g=Si(n.rows,n.format);if(!g){i({...$e,skipped:0,error:o("visits.csvMoment",{max:O(2e3)})});return}let h=n.rows.length-g.reduce((y,w)=>y+w.length,0),v={...$e,skipped:h,running:!0,total:n.rows.length};i(v);let p;try{for(let w of g){if(r.current)break;let f=await R.importCsvVisits(t.id,w,p);p=f.secret??p,v={...v,done:v.done+w.length,pageviews:v.pageviews+f.pageviews,events:v.events+f.events,visits:v.visits+f.visits,skipped:v.skipped+f.skipped},i(v)}let y=v.done+h>=n.rows.length;i({...v,running:!1,finished:y,stopped:!y})}catch(y){i({...v,running:!1,error:y instanceof Error?y.message:String(y)})}},u=a.total?Math.min(100,Math.round(a.done/a.total*100)):0;return e(z,{children:[e("p",{class:"field-hint",children:o("visits.csvHelp")}),e("div",{class:"settings-actions start",children:[a.running?e("button",{type:"button",class:"ghost",onClick:()=>r.current=!0,children:[e(T,{name:"x"}),o("import.stop")]}):e(z,{children:[e("button",{type:"button",class:n?"ghost":"solid",onClick:()=>l.current?.click(),children:[e(T,{name:"upload"}),o(n?"visits.csvOther":"visits.csvChoose")]}),n?e("button",{type:"button",class:"solid",onClick:()=>{d()},children:[e(T,{name:"upload"}),o("visits.start")]}):null]}),e("input",{ref:l,type:"file",accept:".csv,text/csv",hidden:!0,onChange:g=>{let h=g.target.files?.[0];h&&c(h),g.target.value=""}})]}),n&&!a.running&&!a.finished?e("p",{class:"field-hint",children:o(n.format==="umami"?"visits.csvUmami":"visits.csvRunlight",{name:n.name,rows:O(n.rows.length)})}):null,a.running||a.finished||a.stopped||a.error?e("div",{class:"import-progress","aria-live":"polite",children:[a.running?e(z,{children:[e("div",{class:"progress-bar",children:e("span",{class:"progress-fill",style:{width:`${u}%`}})}),e("span",{class:"field-hint",children:o("visits.csvRunning",{done:O(a.done),total:O(a.total),pageviews:O(a.pageviews)})})]}):null,a.error?e("p",{class:"settings-error",children:a.error}):null,a.finished?e("p",{class:"settings-ok-text",children:[e(T,{name:"check"}),o("visits.done",{pageviews:O(a.pageviews),visits:O(a.visits),events:O(a.events)})]}):null,(a.finished||a.stopped)&&a.skipped?e("p",{class:"field-hint",children:o("visits.csvSkipped",{n:O(a.skipped)})}):null,a.stopped?e("p",{class:"field-hint",children:o("visits.csvStopped")}):null]}):null]})}function Ti({site:t}){let[n,s]=m({}),[a,i]=m("key"),[l,r]=m(null),[c,d]=m(""),[u,g]=m(!1),[h,v]=m($e),p=q(!1),y=a==="key"?["url","apiKey"]:["url","username","password"],w=()=>Object.fromEntries(y.map(x=>[x,n[x]??""])),f=()=>{r(null),d("")},b=(x,k)=>{s({...n,[x]:k}),f()},S=async()=>{g(!0),v($e);try{let x=await R.umamiWebsites(w());r(x.websites);let k=x.websites.find(L=>t.hostnames.includes(_i(L.domain)));d(k?.id??x.websites[0]?.id??"")}catch(x){v({...$e,error:x instanceof Error?x.message:String(x)})}finally{g(!1)}},E=async()=>{p.current=!1;let x={...$e,running:!0};v(x);let k=null;try{do{let L=await R.importVisits(t.id,w(),c,k);k=L.cursor,x={...x,done:L.done,total:L.total,pageviews:x.pageviews+L.pageviews,events:x.events+L.events,visits:x.visits+L.visits},v(x)}while(k&&!p.current);v({...x,running:!1,finished:!k,stopped:!!k})}catch(L){v({...x,running:!1,error:L instanceof Error?L.message:String(L)})}},$=h.total?Math.min(100,Math.round(h.done/h.total*100)):0,A=x=>o(x==="url"?"import.url":x==="apiKey"?"import.apiKey":x==="username"?"import.username":"import.password");return e(z,{children:[e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("import.signIn")}),e("div",{class:"ops",role:"radiogroup","aria-label":o("import.signIn"),children:["key","password"].map(x=>e("button",{type:"button",role:"radio","aria-checked":a===x,class:a===x?"op on":"op",disabled:h.running,onClick:()=>{i(x),f()},children:o(x==="key"?"import.withKey":"import.withPassword")}))})]}),y.map(x=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:A(x)}),x==="url"||x==="username"?e("input",{class:"value",type:x==="url"?"url":"text",autoComplete:"off",spellcheck:!1,placeholder:x==="url"?"https://stats.example.com":void 0,value:n[x]??"",disabled:h.running,onInput:k=>b(x,k.target.value)}):e(ue,{class:"value",autoComplete:"off",spellcheck:!1,value:n[x]??"",disabled:h.running,onInput:k=>b(x,k.target.value)})]})),e("p",{class:"field-hint",children:o("import.umamiHelp")}),l?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("visits.website")}),l.length?e("select",{class:"value",value:c,disabled:h.running,onChange:x=>d(x.target.value),children:l.map(x=>e("option",{value:x.id,children:x.domain&&x.domain!==x.name?`${x.name} (${x.domain})`:x.name}))}):e("span",{class:"settings-text",children:o("visits.noWebsites")})]}):null,e("div",{class:"settings-actions start",children:!l||!c?e("button",{type:"button",class:"solid",disabled:u||!n.url,onClick:()=>{S()},children:[e(T,{name:"refresh"}),o("visits.find")]}):h.running?e("button",{type:"button",class:"ghost",onClick:()=>p.current=!0,children:[e(T,{name:"x"}),o("import.stop")]}):e("button",{type:"button",class:"solid",onClick:()=>{E()},children:[e(T,{name:"upload"}),o("visits.start")]})}),h.running||h.finished||h.stopped||h.error?e("div",{class:"import-progress","aria-live":"polite",children:[h.running?e(z,{children:[e("div",{class:"progress-bar",children:e("span",{class:"progress-fill",style:{width:`${$}%`}})}),e("span",{class:"field-hint",children:o("visits.running",{done:O(h.done),total:O(h.total),pageviews:O(h.pageviews)})})]}):null,h.error?e("p",{class:"settings-error",children:h.error}):null,h.finished?e("p",{class:"settings-ok-text",children:[e(T,{name:"check"}),o("visits.done",{pageviews:O(h.pageviews),visits:O(h.visits),events:O(h.events)})]}):null,h.stopped?e("p",{class:"field-hint",children:o("visits.stopped")}):null]}):null]})}function Uo(t){let{domain:n,host:s,origin:a,base:i,linkPath:l}=t;return`Set up a custom short link domain for Runlight, the analytics in this project.
Runlight's dashboard runs at ${a}${i}. Short links are served at ${a}${l}/<slug>. I want them also served at the root of ${n}, like https://${n}/<slug>.
Please do these steps, and tell me anything I have to do by hand:
1. DNS. Tell me the record to add at my DNS provider: a CNAME for ${n} pointing to ${s}. If ${n} has no subdomain, it needs an A or ALIAS record to the same server instead.
2. Hosting. Make the app accept requests for ${n} over HTTPS. On Vercel or Netlify, that means adding ${n} to the project's domains. On my own server, add it to the web server config (for nginx: a server_name and a certificate, for example with certbot; for Caddy: list it beside the main domain) and proxy it to the app the same way as the main domain.
3. App. A request on ${n} has to reach Runlight before the app's own routes see it, because its short links sit at the root of the name. Find how Runlight is set up in this project (package.json, composer.json, pyproject.toml or requirements.txt, Gemfile, go.mod, pom.xml or build.gradle, a .csproj, mix.exs, or Cargo.toml), then follow the matching part below. Every adapter answers only on link domains added in the dashboard and passes every other host on untouched, so the rest of the app is unaffected. Keep any middleware already there, and change only what is needed. Each part names the docs page with the details.
Standalone server. If ${a} is a Runlight of its own (the runlight command in any language, the Docker image, or PHP's drop-in), there is no code to change: point the domain at that server and skip to step 4. https://runlight.sh/docs/server/
TypeScript (@runlight/sdk). https://runlight.sh/docs/links/#custom-domains
- Next.js 16 and later: in proxy.ts, answer link domains first:
import { rl } from "@/lib/runlight";
export async function proxy(request: Request) {
const link = await rl.linkDomainResponse(request);
if (link) return link;
// ...whatever the proxy already does
}
Next.js 15 and earlier use middleware.ts, with the same body in export async function middleware(request: Request). From 15.5, also add export const config = { runtime: "nodejs" }; so it can reach a SQLite or Postgres store. Before 15.5, middleware only runs on the edge, where only an edge store (Turso over HTTP, D1) works; without one, keep to ${l}/<slug> links.
- Express, Connect, and NestJS: app.use(shortLinks(rl)) from "@runlight/sdk/node", before the app's own routes. A plain http server calls await links(req, res) first and stops when it returns true.
- Fastify: an onRequest hook that calls shortLinks(rl)(req.raw, reply.raw) and calls reply.hijack() when it answers. Koa: a middleware that sets ctx.respond = false when it answers, and otherwise calls next().
- Hono, SvelteKit (handle in src/hooks.server.ts), Astro (src/middleware.ts), Bun, Deno, and Cloudflare Workers: return (await rl.linkDomainResponse(request)) when it is not null, before anything else. A Worker needs ${n} routed to it too. Nuxt and h3: a server middleware that builds new Request(getRequestURL(event), { method: event.method, headers: event.headers }) and returns the answer when there is one.
PHP (runlight/runlight). https://runlight.sh/docs/php/
- Laravel: in bootstrap/app.php, ->withMiddleware(fn (Middleware $middleware) => $middleware->prepend(\\Runlight\\Bridge\\ShortLinks::class)).
- Symfony: a kernel.request listener (priority 64) that calls (new \\Runlight\\Bridge\\ShortLinks($rl))->onKernelRequest($event).
- Plain PHP: at the top of the front controller, $linked = $rl->linkDomainResponse($request, ['ip' => $request->remoteAddress]); and when it is not null, $linked->emit() and stop.
- The standalone drop-in needs no code, as above.
Python (runlight). https://runlight.sh/docs/python/
- Django: runlight.django.RunlightMiddleware first in MIDDLEWARE already answers link domains. Add ${n} to ALLOWED_HOSTS.
- Flask (runlight.flask.init_app), FastAPI and Starlette (runlight.fastapi.init_app), and the WSGI and ASGI RunlightMiddleware already answer link domains. Check that Runlight is added this way and wraps the whole app.
Ruby (runlight gem). Rack apps: use Runlight::RackApp in config.ru already answers link domains. https://runlight.sh/docs/ruby/
Rails: the engine's middleware already answers them. If the app sets config.hosts, add ${n} to it. https://runlight.sh/docs/rails/
Go (runlight.sh/go). https://runlight.sh/docs/go/
- net/http: wrap the handler the server runs in rl.LinkDomains(...), or send every request through routes.Middleware(next).
- chi: runlightchi.Mount(r, rl, routes) on the top router, before the app's own routes. Echo: runlightecho.Register(e, rl, routes).
- Any other router: wrap its http.Handler in rl.LinkDomains.
Java (sh.runlight). https://runlight.sh/docs/java/
- The JDK's HttpServer: JdkServer.mount(server, rl, routes, yourHandler) serves the app behind a filter that answers link domains.
- Servlet containers: register RunlightFilter on /* as well as RunlightServlet. The app must be at the root context.
- Spring Boot: the starter already answers link domains before the app's routing.
.NET (Runlight). app.MapRunlight() or app.UseRunlight() already answers link domains. If the app sets AllowedHosts, add ${n} to it. https://runlight.sh/docs/dotnet/
Elixir (runlight). https://runlight.sh/docs/elixir/
- Phoenix: plug Runlight.Plug.LinkDomains in the endpoint, just before plug MyAppWeb.Router, since the router only runs plugs for paths it matches.
- Plug.Router: plug Runlight.Plug.LinkDomains before plug :match.
Rust (runlight crate). https://runlight.sh/docs/rust/
- axum: keep .layer(axum::middleware::from_fn_with_state(rl.clone(), runlight::adapters::axum_support::middleware)) on the whole app, beside .merge(rl.link_router()).
- hyper or another tower server: the Routes service and rl.link_service() answer link domains as they are.
Any other stack: answer a request whose host is a link domain before anything else, using the language's link domain check from its docs page.
4. Check. https://${n}/.well-known/runlight-link-domain should answer {"runlight":true,"domain":"${n}"}. Once it does, ${n} shows as Working under Settings, Custom domains in the Runlight dashboard (add it there if it is not listed yet). A slug opened on ${n} should then redirect like ${a}${l}/<slug> does.
Do not change anything else about how links or analytics work.
`}function zo(t){return`Add Runlight, privacy friendly web analytics, to this site${t.host?` (${t.host})`:""}.
Add this script tag to every page, just before </head>, in the shared layout or template so it is on every page:
${t.script}
Runlight sets no cookies and stores no personal data, so do not add a cookie banner for it. To count a custom event, add data-runlight="Event name" to an element, or call runlight("Event name") in JavaScript.
Keep the site's existing behaviour unchanged otherwise.
`}function jo(t){let{origin:n,base:s,site:a}=t;return`Add Runlight, privacy friendly web analytics, to this project.
The dashboard should live at ${s} on this site (it is at ${n}${s} here).
1. Install the package: npm install @runlight/sdk (and better-sqlite3 for a SQLite file, or pg for Postgres; use Postgres on Vercel or anywhere without a persistent disk).
2. Create lib/runlight.ts:
import { runlight } from "@runlight/sdk";
import { sqlite } from "@runlight/sdk/sqlite";
export const rl = runlight({ store: sqlite({ path: "./data/runlight.db" }) });
For Postgres: import { postgres } from "@runlight/sdk/postgres" and use postgres({ url: process.env.DATABASE_URL }).
3. Mount the routes. In Next.js, app${s}/[[...path]]/route.ts:
import { rl } from "@/lib/runlight";
export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = rl.routes(${s==="/runlight"?"":`{ basePath: "${s}" }`});
For Express or plain Node, use toNodeHandler(rl.routes().handler) from "@runlight/sdk/node".
4. Short links: app/go/[slug]/route.ts with export const GET = rl.linkHandler();
5. Add the tracker to every page, just before </head>:
<script defer src="${s}/s.js"${a?` data-site="${a}"`:""}><\/script>
6. Set RUNLIGHT_TOKEN to a long random string in the environment; open ${s}?token=<that string> once to sign in to the dashboard.
7. Optional, to see AI agents like ChatGPT and Claude reading pages: call void rl.observe(request) for every request in the middleware: export function proxy in proxy.ts in Next.js 16 and later, or export async function middleware in middleware.ts in Next.js 15 and earlier, with export const config = { runtime: "nodejs" }; from 15.5.
Keep the site's existing behaviour unchanged otherwise.
`}var Bo=(t,n)=>`${n}${t.path}`;function Mi({site:t,share:n,home:s,onChanged:a}){let[i,l]=m(!1),[r,c]=m(n.name),[d,u]=m(!1),[g,h]=m("");return e("li",{children:[e("div",{class:"domain-main",children:[i?e("form",{class:"share-rename",onSubmit:p=>{p.preventDefault(),h(""),R.renameShare(t,n.id,r).then(()=>{l(!1),a()}).catch(y=>h(y.message))},children:[e("input",{class:"value",type:"text",value:r,maxLength:100,autoFocus:!0,onInput:p=>c(p.target.value)}),e("button",{type:"submit",class:"solid",children:[e(T,{name:"check"}),o("share.save")]})]}):e("span",{class:"share-name",children:n.name||o("share.unnamed")}),e("span",{class:"share-meta",children:o("links.createdOn",{date:de(new Date(n.createdAt).toISOString().slice(0,10))})})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>navigator.clipboard?.writeText(Bo(n,s)).then(()=>{u(!0),setTimeout(()=>u(!1),1600)}).catch(()=>{}),children:[e(T,{name:d?"check":"copy"}),d?o("install.copied"):o("install.copy")]}),e("a",{class:"copy inline",href:Bo(n,s),target:"_blank",rel:"noopener noreferrer",children:[e(T,{name:"external"}),o("share.open")]}),i?null:e("button",{type:"button",class:"copy inline",onClick:()=>l(!0),children:[e(T,{name:"edit"}),o("share.rename")]}),e(ie,{name:n.name||o("share.unnamed"),onDelete:()=>{R.deleteShare(t,n.id).then(a).catch(p=>h(p.message))}})]}),g?e("span",{class:"settings-error",children:g}):null]})}function qo({site:t}){let[n,s]=m(null),[a,i]=m(""),[l,r]=m(""),c=()=>R.shares(t.id).then(u=>s(u.shares)).catch(u=>r(u.message));F(()=>{c()},[t.id]);let d=u=>{u.preventDefault(),r(""),R.createShare(t.id,a.trim()).then(()=>(i(""),c())).catch(g=>r(g.message))};return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("share.intro")}),n&&n.length?e("ul",{class:"domain-list share-list",children:n.map(u=>e(Mi,{site:t.id,share:u,home:t.remote?new URL(t.remote).origin:location.origin,onChanged:()=>{c()}},u.id))}):n?e(J,{size:"card",icon:"eye",title:o("share.emptyTitle"),hint:o("share.empty")}):null,e("p",{class:"field-hint domain-note",children:o("share.revokeNote")}),e("form",{class:"domain-add",onSubmit:d,children:[e("input",{class:"value",type:"text",maxLength:100,placeholder:o("share.namePlaceholder"),value:a,onInput:u=>i(u.target.value)}),e("button",{type:"submit",class:"solid",children:[e(T,{name:"share"}),o("share.create")]})]}),l?e("span",{class:"settings-error",children:l}):null]})}var Ko=t=>de(new Date(t).toISOString().slice(0,10));function Vo({sites:t}){let[n,s]=m(null),[a,i]=m(""),[l,r]=m(""),[c,d]=m(null),[u,g]=m(""),h=`${location.origin}${le}/mcp`,v=f=>t.find(b=>b.id===f)?.name??f,p=()=>R.tokens().then(f=>s(f.tokens)).catch(f=>g(f.message));F(()=>{p()},[]);let y=f=>{f.preventDefault(),g("");let b=a.trim();R.createToken(b,l).then(S=>(d({name:b,secret:S.secret}),i(""),p())).catch(S=>g(S.message))},w=c?.secret??"YOUR_TOKEN";return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("tokens.intro")}),e("p",{class:"settings-text",children:e("strong",{children:o("tokens.server")})}),e(me,{children:h}),c?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:[e("strong",{children:c.name})," ",o("tokens.once")]}),e(me,{children:c.secret}),e("p",{class:"settings-text",children:o("tokens.claudeCode")}),e(me,{children:`claude mcp add --transport http runlight ${h} --header "Authorization: Bearer ${w}"`}),e("p",{class:"settings-text",children:o("tokens.json")}),e(me,{children:JSON.stringify({mcpServers:{runlight:{url:h,headers:{Authorization:`Bearer ${w}`}}}},null,2)}),e("button",{type:"button",class:"ghost token-done",onClick:()=>d(null),children:[e(T,{name:"check"}),o("tokens.done")]})]}):null,n&&n.length?e("ul",{class:"domain-list share-list",children:n.map(f=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:f.name}),e("span",{class:"share-meta",children:[`rl_\u2026${f.hint}`," \xB7 ",f.site?o("tokens.siteOnly",{site:v(f.site)}):o("tokens.allSites"),f.scope==="manage"?` \xB7 ${o("tokens.manages")}`:f.scope==="embed"?` \xB7 ${o("tokens.embeds")}`:""," \xB7 ",o("links.createdOn",{date:Ko(f.createdAt)})," \xB7 ",f.lastUsedAt?o("tokens.used",{date:Ko(f.lastUsedAt)}):o("tokens.never")]})]}),e("div",{class:"domain-actions",children:e(ie,{name:f.name,onDelete:()=>{g(""),R.deleteToken(f.id).then(p).catch(b=>g(b.message))}})})]},f.id))}):n?e(J,{size:"card",icon:"key",title:o("tokens.emptyTitle"),hint:o("tokens.empty")}):null,e("p",{class:"field-hint domain-note",children:o("tokens.revokeNote")}),e("form",{class:"domain-add token-add",onSubmit:y,children:[e("input",{class:"value",type:"text",maxLength:100,required:!0,placeholder:o("tokens.namePlaceholder"),value:a,onInput:f=>i(f.target.value)}),t.length>1?e("select",{class:"value",value:l,"aria-label":o("tokens.scope"),onChange:f=>r(f.target.value),children:[e("option",{value:"",children:o("tokens.allSites")}),t.map(f=>e("option",{value:f.id,children:o("tokens.siteOnly",{site:f.name})}))]}):null,e("button",{type:"submit",class:"solid",children:[e(T,{name:"key"}),o("tokens.create")]})]}),u?e("span",{class:"settings-error",children:u}):null]})}var Go="runlight_theme",Nn=new Set;function Ei(){if(document.getElementById("app")?.dataset.embedOrigin===void 0)return"light";let t=new URLSearchParams(location.search).get("theme");return t==="light"||t==="dark"?t:"system"}function lt(){try{let t=localStorage.getItem(Go);if(t==="light"||t==="dark"||t==="system")return t}catch{}return Ei()}function Wo(){let t=lt();return t==="system"?matchMedia("(prefers-color-scheme: dark)").matches:t==="dark"}function Fn(){let t=lt();t==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t}function _t(t){try{localStorage.setItem(Go,t)}catch{}Fn();for(let n of Nn)n()}function Yo(t){return Nn.add(t),()=>Nn.delete(t)}var Un=[["general","settings.general"],["install","settings.install"],["goals","settings.goals"],["funnels","settings.funnels"],["mail","settings.mail"],["email","settings.email"],["sharing","settings.sharing"],["api","settings.api"],["links","settings.links"],["import","settings.import"],["data","settings.data"],["assistant","settings.assistant"]],Xo=t=>t==="people"||Un.some(([n])=>n===t);function Qo({menu:t=!1}){return Le?e("div",{class:"settings-sign-out-row",children:e("a",{class:"settings-sign-out",role:t?"menuitem":void 0,href:Le,onClick:n=>{window.confirm(o("app.signOutConfirm"))||n.preventDefault()},children:[e(T,{name:"signOut"}),o("app.signOut")]})}):null}function Ai({sections:t,section:n,site:s,onPick:a}){let{open:i,setOpen:l,root:r}=at();return e("div",{class:"section-menu",ref:r,children:[e("button",{type:"button",class:"section-button","aria-haspopup":"menu","aria-expanded":i,onClick:()=>l(!i),children:[e("span",{children:o(t.find(([c])=>c===n)[1])}),e(it,{})]}),i?e("div",{class:"site-flyout section-flyout",role:"menu","aria-label":o("settings.title"),children:[e("p",{class:"section-flyout-site",children:s}),t.map(([c,d])=>e("button",{type:"button",role:"menuitemradio","aria-checked":c===n,class:c===n?"site-option on":"site-option",onClick:()=>{l(!1),a(c)},children:[e("span",{class:"site-option-text",children:e("span",{class:"site-option-name",children:o(d)})}),c===n?e(T,{name:"check"}):null]})),e(Qo,{menu:!0})]}):null]})}function Ri(){try{return Intl.supportedValuesOf("timeZone")}catch{return["UTC"]}}function Pi(t){let n=Math.round((t-Date.now())/1e3),s=new Intl.RelativeTimeFormat(Q(),{numeric:"auto"}),a=Math.abs(n);return a<60?s.format(n,"second"):a<3600?s.format(Math.round(n/60),"minute"):a<86400?s.format(Math.round(n/3600),"hour"):s.format(Math.round(n/86400),"day")}function Ct({text:t,label:n,class:s,iconOnly:a}){let[i,l]=m(!1);if(a){let r=i?o("install.copied"):o("install.copy");return e("button",{type:"button",class:i?"copy-icon done":"copy-icon",title:r,"aria-label":r,onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1600)}).catch(()=>{})},children:e(T,{name:i?"check":"copy"})})}return e("button",{type:"button",class:s?`copy ${s}`:"copy",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1600)}).catch(()=>{})},children:[e(T,{name:i?"check":n?"sparkle":"copy"}),i?o("install.copied"):n??o("install.copy")]})}function me({children:t}){return e("div",{class:"code",children:[e("pre",{tabIndex:0,children:e("code",{children:t})}),e(Ct,{text:t})]})}function St({label:t,hint:n,children:s}){return e("label",{class:"field-row",children:[e("span",{class:"field-label",children:t}),s,n?e("span",{class:"field-hint",children:n}):null]})}function Ii({site:t,admin:n,requirePassword:s,onSaved:a,onLanguage:i,onDeleted:l}){let[r,c]=m(t.name),[d,u]=m(t.hostnames.join(", ")),[g,h]=m(t.timezone),[v,p]=m("idle"),[y,w]=m(""),[f,b]=m(lt()),S=Ri(),E=ae.managed&&n&&d.split(/[\s,]+/).filter(Boolean).join(",")!==t.hostnames.join(","),$=r.trim()!==t.name||g!==t.timezone||E,A=x=>{x.preventDefault(),p("saving"),w(""),R.updateSite(t.id,{name:r.trim(),timezone:g,...E?{hostnames:d}:{}}).then(k=>{a(k.site),p("saved")}).catch(k=>{w(k.message),p("idle")})};return e(z,{children:[t.remote?e(Hi,{site:t}):null,e("form",{class:"settings-group",onSubmit:A,children:[e(St,{label:o("settings.siteName"),children:e("input",{class:"value",type:"text",maxLength:80,value:r,onInput:x=>c(x.target.value)})}),ae.managed&&!t.remote&&n?e(St,{label:o("sites.domains"),hint:o("sites.domainsHint"),children:e("input",{class:"value",type:"text",value:d,onInput:x=>u(x.target.value)})}):null,t.remote&&!t.manage?null:e(St,{label:o("settings.timezone"),hint:o("settings.timezoneHint"),children:e("select",{class:"value",value:g,onChange:x=>h(x.target.value),children:(S.includes(g)?S:[g,...S]).map(x=>e("option",{value:x,children:x.replace(/_/g," ")}))})}),e("div",{class:"settings-actions",children:[y?e("span",{class:"settings-error",children:y}):null,v==="saved"&&!$?e("span",{class:"settings-ok",children:o("settings.saved")}):null,e("button",{type:"submit",class:"solid",disabled:!$||v==="saving"||!r.trim(),children:[e(T,{name:"save"}),o(v==="saving"?"settings.saving":"settings.save")]})]})]}),e("div",{class:"settings-group",children:[e(St,{label:o("settings.language"),hint:o("settings.languageHint"),children:e("select",{class:"value",value:Q(),onChange:x=>i(x.target.value),children:Ne.map(([x,k])=>e("option",{value:x,children:k}))})}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("settings.theme")}),e("div",{class:"ops",role:"radiogroup","aria-label":o("settings.theme"),children:["system","light","dark"].map(x=>e("button",{type:"button",role:"radio","aria-checked":f===x,class:f===x?"op on":"op",onClick:()=>{_t(x),b(x)},children:o(x==="system"?"settings.themeSystem":x==="light"?"settings.themeLight":"settings.themeDark")}))}),e("span",{class:"field-hint",children:o("settings.languageHint")})]})]}),e(Fi,{site:t}),ae.managed&&n?e("div",{class:"settings-group",children:e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o(t.remote?"sites.disconnect":"sites.delete")}),e("span",{class:"field-hint",children:o(t.remote?"sites.disconnectHint":"sites.deleteHint")}),e("div",{children:e(Li,{site:t,requirePassword:s,onDeleted:l})})]})}):null]})}function Li({site:t,requirePassword:n,onDeleted:s}){let[a,i]=m(!1),[l,r]=m(""),[c,d]=m(!1),[u,g]=m(!1),[h,v]=m(""),p=o(t.remote?"sites.disconnectButton":"sites.delete");return a?e("form",{class:"settings-group",onSubmit:async w=>{if(w.preventDefault(),!(u||!c||n&&!l)){g(!0),v("");try{await R.deleteSite(t.id,n?l:void 0),s(t.id)}catch(f){v(f instanceof Error?f.message:String(f)),r(""),g(!1)}}},children:[e("p",{class:"settings-text",children:o(t.remote?"sites.disconnectName":"app.confirmDelete",{name:t.name})}),n?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("twofa.password")}),e(ue,{class:"value",autoComplete:"current-password",required:!0,value:l,disabled:u,onInput:w=>r(w.target.value)})]}):null,e("label",{class:"invite-scope",children:[e("input",{type:"checkbox",required:!0,checked:c,disabled:u,onChange:w=>d(w.target.checked)}),o(t.remote?"sites.confirmDisconnect":"sites.deleteAcknowledge")]}),h?e("p",{class:"settings-error",role:"alert",children:h}):null,e("div",{class:"settings-actions start",children:[e("button",{class:"solid danger",type:"submit",disabled:u||!c||n&&!l,children:[e(T,{name:t.remote?"unlink":"trash"}),o(u?"sites.deleting":t.remote?"sites.disconnectButton":"sites.delete")]}),e("button",{class:"ghost",type:"button",disabled:u,onClick:()=>{i(!1),r(""),d(!1),v("")},children:o("common.cancel")})]})]}):e("button",{type:"button",class:"copy inline danger",onClick:()=>i(!0),children:[e(T,{name:t.remote?"unlink":"trash"}),p]})}var Di=[6,12,24,36,60];function $i({site:t,onSaved:n}){let s=t.retentionMonths??null,a=!!t.remote&&t.retentionMonths===void 0,[i,l]=m(s),[r,c]=m("idle"),[d,u]=m(""),g=p=>p%12===0?o("data.years",{n:p/12}):o("data.months",{n:p}),h=i===null||s!==null&&i>=s?null:(()=>{let p=new Date;return p.setMonth(p.getMonth()-i),p.toLocaleDateString(Q(),{day:"numeric",month:"long",year:"numeric"})})();return e(z,{children:[e("form",{class:"settings-group",onSubmit:p=>{p.preventDefault(),c("saving"),u(""),R.updateSite(t.id,{retentionMonths:i}).then(y=>{n({...y.site,retentionMonths:i}),c("saved")}).catch(y=>{u(y.message),c("idle")})},children:[e(St,{label:o("data.retention"),hint:o("data.retentionHint"),children:e("select",{class:"value",disabled:a,value:i===null?"":String(i),onChange:p=>{let y=p.target.value;l(y?Number(y):null),c("idle")},children:[e("option",{value:"",children:o("data.forever")}),Di.map(p=>e("option",{value:String(p),children:g(p)}))]})}),a?e("p",{class:"settings-warning",children:o("data.unreachable",{url:t.remote})}):null,h?e("p",{class:"settings-warning",children:o("data.deletesBefore",{date:h})}):null,e("div",{class:"settings-actions",children:[d?e("span",{class:"settings-error",children:d}):null,r==="saved"&&i===s?e("span",{class:"settings-ok",children:o("settings.saved")}):null,e("button",{type:"submit",class:"solid",disabled:i===s||r==="saving",children:[e(T,{name:"save"}),o(r==="saving"?"settings.saving":"settings.save")]})]})]}),e("div",{class:"settings-group",children:e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("data.export")}),e("span",{class:"field-hint",children:o("data.exportHint")}),e("div",{children:e("button",{type:"button",class:"ghost",onClick:()=>{et("export",new URLSearchParams({site:t.id,period:"all"})).catch(p=>u(p.message))},children:[e(T,{name:"download"}),o("data.download")]})})]})})]})}var Jo=new URLSearchParams(location.search).get("connected")==="1",Zo=t=>{try{return new URL(t).host}catch{return t}};function Hi({site:t}){let[n,s]=m(""),[a,i]=m(!1),l=()=>{s(""),i(!0),R.connect(t.remote,t.remoteSite).then(r=>location.assign(r.authorize)).catch(r=>{s(r.message),i(!1)})};return e("div",{class:"remote-callout",children:[Jo?e("p",{class:"settings-ok-text",role:"status",children:[e(T,{name:"check"}),o("sites.connected",{host:Zo(t.remote)})]}):null,e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(T,{name:"external"})}),e("span",{class:"callout-text settings-text",children:[e("strong",{children:o("sites.remoteTitle")}),o(t.manage?"sites.remoteManaged":"sites.remoteNote",{url:t.remote})]}),t.connection==="refused"?e("button",{type:"button",class:"box-button solid",disabled:a,title:o("sites.reconnectHint"),onClick:l,children:[e(T,{name:"key"}),o("sites.reconnect")]}):t.manage?e("a",{class:"box-button",href:t.remote,target:"_blank",rel:"noopener",children:[e(T,{name:"external"}),o("sites.openRemote")]}):e("button",{type:"button",class:"box-button solid",disabled:a,onClick:l,children:[e(T,{name:"key"}),o("sites.allowChanges")]})]}),t.connection==="refused"&&!Jo?e("p",{class:"settings-error",children:o("sites.refused",{host:Zo(t.remote)})}):null,n?e("p",{class:"settings-error",children:n}):null]})}function Qt({label:t,hint:n,children:s}){return e("div",{class:"field-row",children:[e("span",{class:"field-label",children:t}),e("span",{class:"field-hint",children:n}),s]})}function Oi({site:t}){let[n,s]=m(""),[a,i]=m(""),[l,r]=m(""),[c,d]=m([]),[u,g]=m(!1),[h,v]=m(""),p=()=>R.tokens().then(b=>d(b.tokens.filter(S=>S.site===t.id&&S.scope==="embed")));F(()=>{p().catch(b=>v(b.message)),R.observeKey(t.id).then(b=>s(b.key)).catch(b=>v(b.message))},[t.id]);let y=()=>R.newObserveKey(t.id).then(b=>s(b.key)).catch(b=>v(b.message)),w=()=>(g(!0),R.createToken(o("plugin.dashboardKeyName"),t.id,"embed").then(b=>(v(""),i(b.secret),r(b.token.id),p())).catch(b=>v(b.message)).finally(()=>g(!1))),f=b=>{v(""),R.deleteToken(b).then(()=>(l===b&&(r(""),i("")),p())).catch(S=>v(S.message))};return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:e("strong",{children:o("plugin.title")})}),e("p",{class:"settings-text",children:o("plugin.intro")}),e(Qt,{label:o("plugin.address"),hint:o("plugin.addressHint"),children:e(me,{children:`${location.origin}${le}`})}),e(Qt,{label:o("plugin.site"),hint:o("plugin.siteHint"),children:[e(me,{children:t.id}),e("p",{class:"field-hint plugin-keys-note",children:o("plugin.keysHint")})]}),e("div",{class:"plugin-keys",children:[e(Qt,{label:o("plugin.agentsKey"),hint:o("plugin.agentsKeyHint"),children:[n?e(me,{children:n}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"ghost",onClick:()=>{y()},children:[e(T,{name:"refresh"}),o("plugin.replace")]})})]}),e(Qt,{label:o("plugin.dashboardKey"),hint:o("plugin.dashboardKeyHint"),children:[a?e(z,{children:[e("p",{class:"settings-text",children:o("tokens.once")}),e(me,{children:a})]}):null,c.length?e("ul",{class:"domain-list share-list",children:c.map(b=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:b.name}),e("span",{class:"share-meta",children:[`rl_\u2026${b.hint}`," \xB7 ",o("links.createdOn",{date:de(new Date(b.createdAt).toISOString().slice(0,10))})]})]}),e("div",{class:"domain-actions",children:e(ie,{name:b.name,label:o("plugin.revoke"),onDelete:()=>f(b.id)})})]},b.id))}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"ghost",disabled:u,onClick:()=>{w()},children:[e(T,{name:"key"}),o(c.length?"plugin.another":"plugin.make")]})})]})]}),h?e("span",{class:"settings-error",children:h}):null]})}function Ni({site:t}){let[n,s]=m("visits");return e(z,{children:[e("div",{class:"ops import-kind",role:"radiogroup","aria-label":o("settings.import"),children:["visits","links"].map(a=>e("button",{type:"button",role:"radio","aria-checked":n===a,class:n===a?"op on":"op",onClick:()=>s(a),children:o(a==="visits"?"visits.tab":"visits.linksTab")}))}),n==="visits"?e(Fo,{site:t}):e($o,{site:t})]})}function Fi({site:t}){let[n,s]=m(()=>{try{return localStorage.getItem("runlight_ignore")==="1"}catch{return!1}}),a=t.hostnames[0],i=a?`https://${a}/?runlight=ignore`:"",l=()=>{try{n?localStorage.removeItem("runlight_ignore"):localStorage.setItem("runlight_ignore","1"),s(!n)}catch{}};return e("div",{class:"settings-group",children:e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("install.ignore")}),ae.managed?null:e(z,{children:[e("span",{class:"settings-text",children:o(n?"install.ignored":"install.counted")}),e("div",{children:e("button",{type:"button",class:"ghost",onClick:l,children:[e(T,{name:n?"refresh":"x"}),o(n?"install.trackButton":"install.ignoreButton")]})})]}),i?e("span",{class:ae.managed?"settings-text":"field-hint",children:fe(ae.managed?"install.ignoreServer":"install.ignoreElsewhere",{link:e("a",{href:i,target:"_blank",rel:"noopener",children:i})})}):null]})})}function zn({site:t,sites:n}){let s=location.origin,a=n.length>1||ae.managed,l=`<script defer src="${`${s}${le}/s.js${ae.managed?`?site=${encodeURIComponent(t.id)}`:""}`}"${a?` data-site="${t.id}"`:""}><\/script>`,r=t.hostnames[0];return e(z,{children:[e("p",{class:t.lastSeen?"status live":"status",children:[e("span",{class:t.lastSeen?"beat on":"beat","aria-hidden":"true"}),t.lastSeen?o("install.live",{when:Pi(t.lastSeen)}):o("install.none")]}),_e?e("p",{class:"settings-text",children:o("install.cms",{cms:_e})}):e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(T,{name:"sparkle"})}),e("span",{class:"callout-text settings-text",children:[e("strong",{children:o("prompt.title")}),o("prompt.installHint")]}),e(Ct,{class:"prompt-button",label:o("prompt.copy"),text:ae.managed?zo({script:l,host:r}):jo({origin:location.origin,base:le,site:a?t.id:void 0})})]}),e("div",{class:"settings-group",children:[_e?null:e(z,{children:[e("p",{class:"settings-text",children:fe("install.script",{tag:e("code",{children:"</head>"})})}),e(me,{children:l})]}),e("p",{class:"settings-text",children:o("install.events")}),e(me,{children:'<button data-runlight="Signup" data-runlight-plan="pro">Sign up</button>'}),e("p",{class:"settings-text",children:o("install.eventsJs")}),e(me,{children:'runlight("Newsletter signup", { source: "footer" })'}),ae.managed||_e?null:e(z,{children:[e("p",{class:"settings-text",children:o("install.agents")}),e(me,{children:`// proxy.ts, in Next.js 16 and later
import { rl } from "@/lib/runlight";
export function proxy(request: Request) {
void rl.observe(request);
}`}),e(me,{children:`// middleware.ts, in Next.js 15 and earlier
import { rl } from "@/lib/runlight";
export async function middleware(request: Request) {
void rl.observe(request);
}
// From Next.js 15.5, so it can reach a SQLite or Postgres store; before that, middleware only runs on the edge.
export const config = { runtime: "nodejs" };`})]})]}),_e?null:e(Oi,{site:t})]})}function Ui(t,n){let[s,a]=m(null),i=()=>{a(null),R.checkLinkDomain(t,n).then(l=>a({working:l.working,reason:l.code&&ve(l.code,l.params)||l.reason,target:l.target})).catch(l=>a({working:!1,reason:l.message}))};return F(i,[n]),{state:s,check:i}}var zi=new Set(["co.uk","org.uk","ac.uk","gov.uk","me.uk","com.au","net.au","org.au","co.nz","org.nz","com.br","co.jp","co.za","com.mx","com.tr","co.in","com.sg","com.hk","co.il","com.ar","com.cn","co.kr"]);function ji(t){let n=t.split("."),s=zi.has(n.slice(-2).join("."))?3:2;return n.length<=s?"@":n.slice(0,n.length-s).join(".")}function Bi({domain:t,target:n,onCheck:s}){let a=ji(t),i=a==="@",l=/^[\d.]+$/.test(n.host)||n.host.includes(":")||n.host==="localhost"||n.host.endsWith(".localhost"),r=i?n.addresses.length?n.addresses.map(c=>({type:c.includes(":")?"AAAA":"A",value:c})):[{type:"ALIAS",value:n.host}]:[{type:"CNAME",value:n.host}];return e("div",{class:"domain-setup",children:[r.map(c=>e("div",{class:"dns-record",children:[e("span",{class:"dns-field",children:[e("span",{class:"dns-label",children:o("links.recordType")}),e("code",{children:c.type})]}),e("span",{class:"dns-field",children:[e("span",{class:"dns-label",children:o("links.recordName")}),e("span",{class:"dns-value",children:[e("code",{children:a}),e(Ct,{iconOnly:!0,text:a})]})]}),e("span",{class:"dns-field grow",children:[e("span",{class:"dns-label",children:o("links.recordValue")}),e("span",{class:"dns-value",children:[e("code",{children:c.value}),e(Ct,{iconOnly:!0,text:c.value})]})]})]})),e("ol",{class:"setup-steps",children:[e("li",{children:o(r[0].type==="ALIAS"?"links.doDnsAlias":"links.doDns")}),e("li",{children:o("links.doHttps",{domain:t})}),e("li",{children:o("links.doCheck")})]}),l?e("p",{class:"field-hint",children:o("links.localNote",{host:n.host})}):null,e("div",{class:"setup-actions",children:[e("button",{type:"button",class:"copy inline",onClick:s,children:[e(T,{name:"refresh"}),o("links.recheck")]}),e("a",{class:"copy inline",href:"https://runlight.sh/docs/links/#custom-domains",target:"_blank",rel:"noopener",children:[e(T,{name:"external"}),o("links.guide")]})]})]})}function qi({site:t,domain:n,fallbackHost:s,onRemove:a}){let{state:i,check:l}=Ui(t,n),r=i?i.target??{host:s,addresses:[]}:null,[c,d]=m(null),u=c??(i!==null&&!i.working);return e("li",{class:"domain-row",children:[e("div",{class:"domain-main",children:[e("span",{class:"domain-name",children:n}),e("span",{class:i?i.working?"domain-status ok":"domain-status bad":"domain-status",children:[i?e("span",{class:i.working?"beat on":"beat off","aria-hidden":"true"}):null,i?i.working?o("links.working"):o("links.notWorking",{reason:i.reason}):o("links.checking")]})]}),e("div",{class:"domain-actions",children:[r?e("button",{type:"button",class:u?"copy inline on":"copy inline","aria-expanded":u,onClick:()=>d(!u),children:[e(T,{name:"list"}),o("links.setup")]}):null,e("button",{type:"button",class:"copy inline danger",onClick:a,children:[e(T,{name:"trash"}),o("links.removeDomain")]})]}),u&&r?e(Bi,{domain:n,target:r,onCheck:l}):null]})}function Ki({site:t}){let n=t.remote?new URL(t.remote):null,s=n?n.hostname:location.hostname,a=n?n.host:location.host,[i,l]=m(null),[r,c]=m(""),[d,u]=m(""),g=()=>R.linkDomains(t.id).then(v=>l(v.domains)).catch(v=>u(v.message));F(()=>{g()},[t.id]);let h=v=>{v.preventDefault(),u(""),R.addLinkDomain(t.id,r).then(()=>(c(""),g())).catch(p=>u(p.message))};return e("div",{class:"settings-group",children:[e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("links.domains")}),e("span",{class:"settings-text",children:o("links.domainsHelp")})]}),e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(T,{name:"sparkle"})}),e("span",{class:"callout-text settings-text",children:[e("strong",{children:o("prompt.title")}),o("prompt.domainHint")]}),e(Ct,{class:"prompt-button",label:o("prompt.copy"),text:Uo({domain:r.trim()||i?.[0]||"t.example.com",host:s,origin:n?n.origin:location.origin,base:n?n.pathname.replace(/\/$/,""):le,linkPath:"/go"})})]}),e("ol",{class:"steps",children:[e("li",{children:fe("links.step1",{host:e("code",{children:s})})}),e("li",{children:o("links.step2")}),e("li",{children:o("links.step3")})]}),e("ul",{class:"domain-list",children:[e("li",{children:e("span",{class:"domain-name",children:o("links.ownDomain",{prefix:`${a}/go`})})}),(i??[]).map(v=>e(qi,{site:t.id,domain:v,fallbackHost:s,onRemove:()=>R.removeLinkDomain(t.id,v).then(g).catch(p=>u(p.message))}))]}),e("p",{class:"field-hint domain-note",children:o("links.removeNote",{fallback:`${a}/go`})}),e("form",{class:"domain-add",onSubmit:h,children:[e("input",{class:"value",type:"text",placeholder:o("links.domainPlaceholder"),value:r,onInput:v=>c(v.target.value)}),e("button",{type:"submit",class:"solid",disabled:!r.trim(),children:[e(T,{name:"globe"}),o("links.addDomain")]})]}),d?e("span",{class:"settings-error",children:d}):null]})}function ea({site:t,sites:n,view:s,start:a,onClose:i,onSaved:l,onLanguage:r,onDeleted:c,onDemoted:d,me:u,onSite:g}){let h=Qe?u?.role==="owner"||u?.role==="admin":!0,v=t.remote?t.manage?Un.filter(([b])=>["general","goals","funnels","mail","email","sharing","links","data","assistant"].includes(b)):[["general","settings.general"],["assistant","settings.assistant"]]:Un,p=u&&h?[...v,["people","settings.people"]]:v,[y,w]=m(a&&p.some(([b])=>b===a)?a:"general"),f=q(null);return be(f),F(()=>{let b=S=>S.key==="Escape"&&i();return document.addEventListener("keydown",b),document.body.classList.add("locked"),f.current?.querySelector(".settings-nav button")?.focus(),()=>{document.removeEventListener("keydown",b),document.body.classList.remove("locked")}},[]),e("div",{class:"scrim center",onPointerDown:b=>b.target===b.currentTarget&&i(),children:e("div",{class:"settings",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",ref:f,children:[e("header",{class:"settings-toolbar",children:[e("h2",{id:"settings-title",children:o("settings.title")}),n.length>1?e("select",{class:"value settings-site-picker","aria-label":o("app.site"),value:t.id,onChange:b=>g(b.currentTarget.value,y),children:n.map(b=>e("option",{value:b.id,children:b.name}))}):null,e("button",{type:"button",class:"remove","aria-label":o("common.close"),onClick:i,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),e("nav",{class:"settings-nav","aria-label":o("settings.title"),children:[p.map(([b,S])=>e("button",{type:"button",class:y===b?"settings-tab on":"settings-tab","aria-current":y===b?"page":void 0,onClick:()=>w(b),children:o(S)})),e(Qo,{})]}),e("div",{class:"settings-body",children:[e("header",{class:"settings-head",children:[e("h3",{children:o(p.find(([b])=>b===y)[1])}),e(Ai,{sections:p,section:y,site:t.name,onPick:w})]}),e("div",{class:"settings-content",children:y==="general"?e(Ii,{site:t,admin:h,requirePassword:!!u,onSaved:l,onLanguage:r,onDeleted:c}):y==="install"?e(zn,{site:t,sites:n}):y==="goals"?e(Io,{site:t,view:s}):y==="funnels"?e(Ao,{site:t,view:s}):y==="email"?e(To,{site:t,onSetUp:()=>w("mail")}):y==="mail"?e(Co,{site:t,admin:h}):y==="sharing"?e(qo,{site:t}):y==="people"&&u?e(ta,{me:u,site:t,multiSite:ae.managed||n.length>1,onDemoted:d}):y==="api"?e(Vo,{sites:n}):y==="links"?e(Ki,{site:t}):y==="data"?e($i,{site:t,onSaved:l}):y==="assistant"?e(So,{owner:h}):e(Ni,{site:t})})]})]})})}var sa=[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],oa=[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],Vi=0,Ce=(t,n)=>(t>>>n&1)!==0;function aa(t){let n=(16*t+128)*t+64;if(t>=2){let s=Math.floor(t/7)+2;n-=(25*s-10)*s-55,t>=7&&(n-=36)}return n}var na=t=>Math.floor(aa(t)/8)-sa[t]*oa[t];function Gi(t,n){if(t===1)return[];let s=Math.floor(t/7)+2,a=t===32?26:Math.ceil((t*4+4)/(s*2-2))*2,i=[6];for(let l=n-7;i.length<s;l-=a)i.splice(1,0,l);return i}function jn(t,n){let s=0;for(let a=7;a>=0;a--)s=s<<1^(s>>>7)*285,s^=(n>>>a&1)*t;return s}function Wi(t){let n=new Array(t).fill(0);n[t-1]=1;let s=1;for(let a=0;a<t;a++){for(let i=0;i<t;i++)n[i]=jn(n[i],s),i+1<t&&(n[i]^=n[i+1]);s=jn(s,2)}return n}function Yi(t,n){let s=new Array(n.length).fill(0);for(let a of t){let i=a^s.shift();s.push(0),n.forEach((l,r)=>s[r]^=jn(l,i))}return s}function Ji(t){let n=t.length,s=0,a=[];for(let r=0;r<n;r++)a.push(t[r]);for(let r=0;r<n;r++)a.push(t.map(c=>c[r]));for(let r of a){let c=1;for(let u=1;u<=n;u++)u<n&&r[u]===r[u-1]?c++:(c>=5&&(s+=3+(c-5)),c=1);let d=r.map(u=>u?"1":"0").join("");for(let u of["10111010000","00001011101"])for(let g=d.indexOf(u);g>=0;g=d.indexOf(u,g+1))s+=40}for(let r=0;r+1<n;r++)for(let c=0;c+1<n;c++){let d=t[r][c];d===t[r][c+1]&&d===t[r+1][c]&&d===t[r+1][c+1]&&(s+=3)}let i=t.reduce((r,c)=>r+c.filter(Boolean).length,0),l=n*n;return s+=(Math.ceil(Math.abs(i*20-l*10)/l)-1)*10,s}var Zi=[(t,n)=>(t+n)%2===0,(t,n)=>n%2===0,t=>t%3===0,(t,n)=>(t+n)%3===0,(t,n)=>(Math.floor(t/3)+Math.floor(n/2))%2===0,(t,n)=>t*n%2+t*n%3===0,(t,n)=>(t*n%2+t*n%3)%2===0,(t,n)=>((t+n)%2+t*n%3)%2===0];function Xi(t,n){let s=Array.from(new TextEncoder().encode(t)),a=1;for(;a<=40&&!(4+(a<=9?8:16)+s.length*8<=na(a)*8);a++);if(a>40)throw new RangeError("Too much text for a QR code");let i=na(a)*8,l=[],r=(D,H)=>{for(let M=H-1;M>=0;M--)l.push(D>>>M&1)};r(4,4),r(s.length,a<=9?8:16);for(let D of s)r(D,8);r(0,Math.min(4,i-l.length)),r(0,(8-l.length%8)%8);for(let D=236;l.length<i;D^=253)r(D,8);let c=[];for(let D=0;D<l.length;D+=8)c.push(l.slice(D,D+8).reduce((H,M)=>H<<1|M,0));let d=oa[a],u=sa[a],g=Math.floor(aa(a)/8),h=d-g%d,v=Math.floor(g/d),p=Wi(u),y=[];for(let D=0,H=0;D<d;D++){let M=c.slice(H,H+v-u+(D<h?0:1));H+=M.length;let C=Yi(M,p);D<h&&M.push(0),y.push([...M,...C])}let w=[];for(let D=0;D<y[0].length;D++)y.forEach((H,M)=>{(D!==v-u||M>=h)&&w.push(H[D])});let f=a*4+17,b=Array.from({length:f},()=>new Array(f).fill(!1)),S=Array.from({length:f},()=>new Array(f).fill(!1)),E=(D,H,M)=>{b[H][D]=M,S[H][D]=!0};for(let D=0;D<f;D++)E(6,D,D%2===0),E(D,6,D%2===0);for(let[D,H]of[[3,3],[f-4,3],[3,f-4]])for(let M=-4;M<=4;M++)for(let C=-4;C<=4;C++){let _=D+C,P=H+M;if(_>=0&&_<f&&P>=0&&P<f){let U=Math.max(Math.abs(C),Math.abs(M));E(_,P,U!==2&&U!==4)}}let $=Gi(a,f),A=$.length-1;$.forEach((D,H)=>$.forEach((M,C)=>{if(!(H===0&&C===0||H===0&&C===A||H===A&&C===0))for(let _=-2;_<=2;_++)for(let P=-2;P<=2;P++)E(D+P,M+_,Math.max(Math.abs(P),Math.abs(_))!==1)}));let x=D=>{let H=Vi<<3|D,M=H;for(let _=0;_<10;_++)M=M<<1^(M>>>9)*1335;let C=(H<<10|M)^21522;for(let _=0;_<=5;_++)E(8,_,Ce(C,_));E(8,7,Ce(C,6)),E(8,8,Ce(C,7)),E(7,8,Ce(C,8));for(let _=9;_<15;_++)E(14-_,8,Ce(C,_));for(let _=0;_<8;_++)E(f-1-_,8,Ce(C,_));for(let _=8;_<15;_++)E(8,f-15+_,Ce(C,_));E(8,f-8,!0)};if(x(0),a>=7){let D=a;for(let M=0;M<12;M++)D=D<<1^(D>>>11)*7973;let H=a<<12|D;for(let M=0;M<18;M++){let C=f-11+M%3,_=Math.floor(M/3);E(C,_,Ce(H,M)),E(_,C,Ce(H,M))}}let k=0;for(let D=f-1;D>=1;D-=2){D===6&&(D=5);for(let H=0;H<f;H++)for(let M=0;M<2;M++){let C=D-M,P=(D+1&2)===0?f-1-H:H;!S[P][C]&&k<w.length*8&&(b[P][C]=Ce(w[k>>>3],7-(k&7)),k++)}}let L=D=>{for(let H=0;H<f;H++)for(let M=0;M<f;M++)!S[H][M]&&Zi[D](M,H)&&(b[H][M]=!b[H][M])},N=n??-1;if(N<0){let D=1/0;for(let H=0;H<8;H++){L(H),x(H);let M=Ji(b);M<D&&(D=M,N=H),L(H)}}return L(N),x(N),b}function ia(t){let n=Xi(t),s=n.length+8,a="";return n.forEach((i,l)=>i.forEach((r,c)=>r&&(a+=`M${c+4},${l+4}h1v1h-1z`))),{size:s,path:a}}var ra=t=>de(new Date(t).toISOString().slice(0,10));function da({me:t,onClose:n}){let[s,a]=m(""),[i,l]=m(""),[r,c]=m(""),[d,u]=m(!1),g=wo(i,[t.email.split("@")[0],t.email]),h=r.length>0&&r!==i,[v,p]=m("idle"),[y,w]=m(""),f=S=>{S.preventDefault(),p("saving"),w(""),R.changePassword(s,i,d).then(()=>{p("saved"),a(""),l(""),c(""),u(!1)}).catch(E=>{w(E.message),p("idle")})},b=(S,E)=>{S(E.target.value),w("")};return e(pe,{title:o("account.title"),sub:t.email,onClose:n,children:e("div",{class:"sheet-body account-body",children:[e("form",{class:"link-form",onSubmit:f,children:[e("p",{class:"settings-text",children:t.site?o(t.role==="viewer"?"account.siteViewer":"account.siteMember",{site:t.site}):o(`account.${t.role}`)}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.current")}),e(ue,{class:"value",autoComplete:"current-password",required:!0,value:s,onInput:S=>b(a,S)})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.next")}),e(ue,{class:"value",autoComplete:"new-password",minLength:10,required:!0,value:i,onInput:S=>b(l,S),"aria-describedby":"password-strength"}),i?e("span",{class:"strength",id:"password-strength","data-score":g,"aria-live":"polite",children:[e("span",{class:"strength-bar","aria-hidden":"true",children:[1,2,3,4].map(S=>e("span",{class:g>=S?"on":""}))}),e("span",{class:"strength-label",children:o(`account.strength${g}`)})]}):null,e("span",{class:"field-hint",children:o("account.nextHint")})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.again")}),e(ue,{class:"value",autoComplete:"new-password",required:!0,value:r,"aria-invalid":h,onInput:S=>b(c,S)}),h?e("span",{class:"field-hint field-bad",children:o("account.mismatch")}):null]}),t.site?null:e("label",{class:"invite-scope",children:[e("input",{type:"checkbox",checked:d,onChange:S=>u(S.currentTarget.checked)}),o("account.revokeTokens")]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:v==="saving"||!s||i.length<10||r!==i,children:[e(T,{name:"save"}),o("account.save")]}),v==="saved"?e("span",{class:"settings-ok",children:o("account.saved")}):null,y?e("span",{class:"settings-error",children:y}):null]})]}),e(er,{me:t}),e(Qi,{})]})})}function Qi(){let[t,n]=m(!1),[s,a]=m(""),i=()=>{window.confirm(o("account.everywhereConfirm"))&&(n(!0),a(""),R.signOutEverywhere().then(()=>Le?location.assign(Le):location.reload()).catch(l=>{a(l.message),n(!1)}))};return e("div",{class:"link-form",children:[e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.everywhere")}),e("span",{class:"field-hint",children:o("account.everywhereHint")})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"button",disabled:t,onClick:i,children:[e(T,{name:"signOut"}),o("account.everywhere")]}),s?e("span",{class:"settings-error",children:s}):null]})]})}function er({me:t}){let[n,s]=m(!!t.twoFactor),[a,i]=m(t.recoveryLeft??0),[l,r]=m(null),[c,d]=m(""),[u,g]=m(null),[h,v]=m(""),[p,y]=m(null),[w,f]=m(!1),[b,S]=m(""),[E,$]=m(!1),A=(D,H)=>{S(""),$(!0),D.then(H).catch(M=>S(M.message)).finally(()=>$(!1))},x=D=>{D.preventDefault(),l==="start"&&A(R.twoFactorStart(c),H=>{g(H),r(null),d("")}),l==="recovery"&&A(R.twoFactorRecovery(c),H=>{y(H.recovery),i(H.recovery.length),r(null),d("")}),l==="disable"&&A(R.twoFactorDisable(c),()=>{s(!1),r(null),d("")})},k=D=>{D.preventDefault(),A(R.twoFactorConfirm(h).catch(H=>{throw H instanceof Re&&H.code==="twofactor_restart"&&(g(null),v("")),H}),H=>{y(H.recovery),i(H.recovery.length),s(!0),g(null),v("")})},L=u?ia(u.uri):null,N=()=>{let D=new Blob([`Runlight recovery codes for ${t.email}
${p.join(`
`)}
Each code works once.
`],{type:"text/plain"}),H=document.createElement("a");H.href=URL.createObjectURL(D),H.download="runlight-recovery-codes.txt",H.click(),URL.revokeObjectURL(H.href)};return e("div",{class:"link-form twofactor",children:[e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("twofa.title")}),e("span",{class:"field-hint",children:n?X("twofa.on",a):o("twofa.off")})]}),p?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:o("twofa.codesIntro")}),e("ol",{class:"recovery-codes",children:p.map(D=>e("li",{children:e("code",{children:D})}))}),e("div",{class:"settings-actions start",children:[e("button",{type:"button",class:"ghost",onClick:N,children:[e(T,{name:"download"}),o("twofa.download")]}),e("button",{type:"button",class:"ghost",onClick:()=>{navigator.clipboard?.writeText(p.join(`
`)).then(()=>f(!0)).catch(()=>{})},children:[e(T,{name:w?"check":"copy"}),o(w?"install.copied":"twofa.copy")]}),e("button",{type:"button",class:"solid",onClick:()=>y(null),children:[e(T,{name:"check"}),o("twofa.saved")]})]})]}):u&&L?e("form",{class:"twofactor-setup",onSubmit:k,children:[e("p",{class:"settings-text",children:o("twofa.scan")}),e("div",{class:"qr",children:e("svg",{viewBox:`0 0 ${L.size} ${L.size}`,role:"img","aria-label":o("twofa.qr"),"shape-rendering":"crispEdges",children:[e("rect",{width:L.size,height:L.size,fill:"#ffffff"}),e("path",{d:L.path,fill:"#000000"})]})}),e("p",{class:"field-hint",children:o("twofa.manual")}),e(me,{children:u.secret.replace(/(.{4})/g,"$1 ").trim()}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("twofa.code")}),e("input",{class:"value",type:"text",inputmode:"numeric",autoComplete:"one-time-code",maxLength:7,required:!0,value:h,onInput:D=>v(D.target.value)})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:E||h.replace(/\s/g,"").length!==6,children:[e(T,{name:"check"}),o("twofa.confirm")]}),e("button",{type:"button",class:"ghost",onClick:()=>{g(null),S("")},children:o("common.cancel")})]})]}):l?e("form",{class:"twofactor-setup",onSubmit:x,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("twofa.password")}),e(ue,{class:"value",autoComplete:"current-password",required:!0,value:c,onInput:D=>d(D.target.value)})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:l==="disable"?"solid danger":"solid",disabled:E||!c,children:[e(T,{name:l==="disable"?"x":"check"}),o(l==="start"?"twofa.continue":l==="recovery"?"twofa.newCodes":"twofa.turnOff")]}),e("button",{type:"button",class:"ghost",onClick:()=>{r(null),S("")},children:o("common.cancel")})]})]}):e("div",{class:"settings-actions start",children:n?e(z,{children:[e("button",{type:"button",class:"ghost",onClick:()=>r("recovery"),children:[e(T,{name:"refresh"}),o("twofa.newCodes")]}),e("button",{type:"button",class:"ghost",onClick:()=>r("disable"),children:[e(T,{name:"x"}),o("twofa.turnOff")]})]}):e("button",{type:"button",class:"solid",onClick:()=>r("start"),children:[e(T,{name:"key"}),o("twofa.turnOn")]})}),b?e("p",{class:"settings-error",children:b}):null]})}function la({icon:t,label:n,warning:s,confirmation:a,onConfirm:i,onCancel:l}){let[r,c]=m(""),[d,u]=m(!1),[g,h]=m(!1),[v,p]=m("");return e("form",{class:"reset-twofactor",onSubmit:w=>{if(w.preventDefault(),h(!0),p(""),s&&!d){h(!1);return}i(r).catch(f=>p(f.message)).finally(()=>h(!1))},children:[s?e("div",{class:"ownership-warning",children:[e("strong",{children:o("people.areYouSure")}),e("p",{children:s}),e("label",{children:[e("input",{type:"checkbox",required:!0,checked:d,onChange:w=>u(w.currentTarget.checked)}),a??o("people.confirmAllSites")]})]}):null,e(ue,{class:"value",autoComplete:"current-password",required:!0,placeholder:o("twofa.password"),value:r,onInput:w=>c(w.target.value)}),e("button",{type:"submit",class:"copy inline armed",disabled:g||!r||!!(s&&!d),children:[e(T,{name:t}),n]}),e("button",{type:"button",class:"copy inline",onClick:l,children:o("common.cancel")}),v?e("span",{class:"settings-error",children:v}):null]})}var ca=["admin","member","viewer"],en=t=>o(`people.${t}`);function ta({me:t,site:n,multiSite:s,onDemoted:a}){let[i,l]=m(null),[r,c]=m([]),[d,u]=m(""),[g,h]=m("member"),[v,p]=m(!1),[y,w]=m(null),[f,b]=m(""),[S,E]=m(!1),[$,A]=m(null),[x,k]=m(null),[L,N]=m(null),D=()=>R.people().then(_=>{l(_.people),c(_.invites??[])}).catch(_=>b(_.message));F(()=>{D()},[]);let H=_=>(w(_),D()),M=_=>{_.preventDefault(),b(""),E(!0),R.addPerson(d.trim(),g,g==="admin"||s&&v?void 0:n.id).then(P=>(u(""),H(P))).catch(P=>b(P.message)).finally(()=>E(!1))},C=(_,P)=>{let U=_===t.id&&P!=="admin";return U&&L!==P?N(P):(N(null),R.setRole(_,P).then(()=>U?a(P):D()).catch(G=>b(G.message)))};return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("people.intro")}),y?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:y.emailed?o("people.emailed",{email:y.invite.email}):y.mailError?o("people.mailFailed",{email:y.invite.email,error:(y.mailCode&&ve(y.mailCode,y.mailParams)||y.mailError).replace(/\.$/,"")}):o("people.noMail",{email:y.invite.email})}),e("div",{class:"invite-link",children:e(me,{children:y.link})}),e("p",{class:"field-hint",children:o("people.linkHint")}),e("button",{type:"button",class:"ghost token-done",onClick:()=>w(null),children:[e(T,{name:"check"}),o("tokens.done")]})]}):null,i?e("ul",{class:"domain-list share-list",children:[i.map(_=>e("li",{class:x===_.id||$===_.id?"people-confirming":void 0,children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:[_.email,_.id===t.id?e("span",{class:"people-you",children:o("people.you")}):null,_.twoFactor?e("span",{class:"people-you",children:o("people.twoFactor")}):null]}),e("span",{class:"share-meta",children:[o("links.createdOn",{date:ra(_.createdAt)}),s?e(z,{children:[" \xB7 ",_.site===n.id?n.name:_.site??o("assistant.action.allSites")]}):null]})]}),e("div",{class:"domain-actions",children:$===_.id?e(la,{icon:"reset",label:o("people.resetTwoFactor"),onCancel:()=>A(null),onConfirm:P=>R.resetTwoFactor(_.id,P).then(()=>(A(null),b(""),D()))}):x===_.id?e(la,{icon:"key",label:o("people.handOverConfirm"),warning:o(s?"people.handOverWarning":"people.handOverWarningSingle",{email:_.email}),confirmation:o(s?"people.confirmAllSites":"people.confirmOwnership"),onCancel:()=>k(null),onConfirm:P=>R.handOver(_.id,P).then(()=>(k(null),b(""),a("admin"),D()))}):_.role==="owner"?e("span",{class:"people-owner",children:o("people.owner")}):e(z,{children:[t.role==="owner"&&_.role==="admin"&&_.site===void 0?e("button",{type:"button",class:"copy inline",title:o("people.handOverHint"),onClick:()=>k(_.id),children:[e(T,{name:"key"}),o("people.handOver")]}):null,_.twoFactor&&_.id!==t.id?e("button",{type:"button",class:"copy inline",title:o("people.resetTwoFactorHint"),onClick:()=>A(_.id),children:[e(T,{name:"reset"}),o("people.resetTwoFactor")]}):null,_.id===t.id&&L?e("span",{class:"confirm-demote",children:[e("span",{class:"settings-text",children:o("people.demoteSelf")}),e("button",{type:"button",class:"copy inline armed",onClick:()=>{C(_.id,L)},children:o("people.demoteConfirm",{role:en(L)})}),e("button",{type:"button",class:"copy inline",onClick:()=>N(null),children:o("common.cancel")})]}):e("select",{class:"value people-role",value:_.role,"aria-label":o("people.role"),onChange:P=>{C(_.id,P.target.value)},children:ca.filter(P=>_.site===void 0||P!=="admin").map(P=>e("option",{value:P,children:en(P)}))}),_.id===t.id?null:e(ie,{name:_.email,onDelete:()=>{R.removePerson(_.id).then(D).catch(P=>b(P.message))}})]})})]},_.id)),r.map(_=>e("li",{class:"invited",children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:[_.email,e("span",{class:"people-you",children:o("people.invited")})]}),e("span",{class:"share-meta",children:[o("people.invitedMeta",{role:en(_.role),date:ra(_.expiresAt)}),s?e(z,{children:[" \xB7 ",_.site===n.id?n.name:_.site??o("assistant.action.allSites")]}):null]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",disabled:S,onClick:()=>{E(!0),R.resendInvite(_.id).then(H).catch(P=>b(P.message)).finally(()=>E(!1))},children:[e(T,{name:"send"}),o("people.resend")]}),e(ie,{name:_.email,onDelete:()=>{R.cancelInvite(_.id).then(D).catch(P=>b(P.message))}})]})]},_.id))]}):null,e("p",{class:"field-hint domain-note",children:o("people.roles")}),s?e("div",{class:"invite-scope-group",children:[e("label",{class:"invite-scope",children:[e("input",{type:"checkbox",checked:v,onChange:_=>{p(_.currentTarget.checked),!_.currentTarget.checked&&g==="admin"&&h("member")}}),o("people.allSites")]}),e("p",{class:"field-hint",children:v?o("people.allSitesHint"):o("people.siteHint",{site:n.name})})]}):null,e("form",{class:"domain-add token-add",onSubmit:M,children:[e("input",{class:"value",type:"email",required:!0,placeholder:o("people.emailPlaceholder"),value:d,onInput:_=>u(_.target.value)}),e("select",{class:"value",value:g,"aria-label":o("people.role"),onChange:_=>h(_.target.value),children:ca.filter(_=>v||!s||_!=="admin").map(_=>e("option",{value:_,children:en(_)}))}),e("button",{type:"submit",class:"solid",disabled:S,children:[e(T,{name:"send"}),o("people.invite")]})]}),f?e("span",{class:"settings-error",children:f}):null]})}var tr=1e4;function nr(t){let n=Math.round((t-Date.now())/1e3),s=new Intl.RelativeTimeFormat(Q(),{numeric:"auto",style:"short"});return Math.abs(n)<60?s.format(Math.min(0,n),"second"):s.format(Math.round(n/60),"minute")}function sr(t){return new Intl.DateTimeFormat(Q(),{hour:"numeric",minute:"2-digit"}).format(t)}function or({minutes:t}){let[n,s]=m(null),a=Math.max(1,...t),i=t.reduce((r,c)=>r+c,0),l=Math.floor(Date.now()/6e4)*6e4-(t.length-1)*6e4;return e("section",{class:"minutes",children:[e("p",{class:"minutes-note",children:n===null?X("live.total",i,{n:De(i)}):X("live.minute",t[n]??0,{n:De(t[n]??0),time:sr(l+n*6e4)})}),e("div",{class:"minute-bars",onPointerLeave:()=>s(null),children:t.map((r,c)=>e("span",{class:n===c?"minute on":"minute",onPointerEnter:()=>s(c),children:e("span",{class:"minute-bar",style:{height:`${r?Math.max(4,r/a*100):0}%`}})}))}),e("div",{class:"minute-axis",children:[e("span",{children:o("live.ago30")}),e("span",{children:o("live.nowLabel")})]})]})}function Bn({title:t,rows:n,dimension:s}){let a=Math.max(1,...n.map(i=>i.visitors));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(J,{size:"line",icon:"monitor",title:o(s==="country"?"live.noCountries":s==="source"?"live.noSources":"live.noPages")}):null,e("ol",{class:"rows",children:n.map(i=>e("li",{children:[e("span",{class:"bar",style:{width:`${i.visitors/a*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:s==="country"?`${xe(i.value)} ${we(i.value)}`:s==="source"&&!i.value?o("channel.Direct"):ge(s,i.value)})}),e("span",{class:"num",children:O(i.visitors)})]}))})]})}function ar({recent:t}){return e("section",{class:"feed",children:[e("h3",{children:o("live.feed")}),t.length===0?e(J,{size:"line",icon:"clock",title:o("live.quiet")}):null,e("ol",{children:t.map(n=>{let s=[n.city,n.country?we(n.country):""].filter(Boolean).join(", "),i={who:s?o("live.someoneIn",{place:s}):o("live.someone"),path:e("strong",{children:n.path||"/"}),name:e("strong",{children:n.name}),source:n.source},l=n.kind==="event"?n.source?"live.didVia":"live.did":n.source?"live.viewedVia":"live.viewed";return e("li",{children:[e("span",{class:"feed-flag","aria-hidden":"true",children:n.country?xe(n.country):"\xB7"}),e("span",{class:"feed-text",children:fe(l,i)}),e("span",{class:"feed-time",children:nr(n.ts)})]})})})]})}function pa({site:t,initialData:n,onClose:s}){let[a,i]=m(n??null),[l,r]=m("");return F(()=>{let c=!0,d=()=>R.realtime(t).then(g=>{c&&(i(g),r(""))}).catch(g=>c&&r(g.message));d();let u=setInterval(d,tr);return()=>{c=!1,clearInterval(u)}},[t]),e(pe,{title:o("live.title"),sub:o("live.sub"),wide:!0,onClose:s,children:e("div",{class:"live-body",children:[l?e("p",{class:"failure",role:"alert",children:l}):null,a?e(z,{children:[e("p",{class:"live-count",children:[e("span",{class:a.visitors>0?"beat on":"beat","aria-hidden":"true"}),fe(new Intl.PluralRules(Q()).select(a.visitors)==="one"?"live.now_one":"live.now_other",{n:e("strong",{children:De(a.visitors)})}),e("span",{class:"live-hint",children:o("live.nowHint")})]}),a.visitors===0&&a.recent.length===0&&a.minutes.every(c=>c===0)?e("div",{class:"live-empty",children:e(J,{icon:"clock",title:o("live.quietTitle"),hint:o("live.nobody")})}):e(z,{children:[e(or,{minutes:a.minutes}),e("div",{class:"mini-grid three",children:[e(Bn,{title:"live.pages",rows:a.pages,dimension:"path"}),e(Bn,{title:"live.sources",rows:a.sources,dimension:"source"}),e(Bn,{title:"live.countries",rows:a.countries,dimension:"country"})]}),Ie?null:e(ar,{recent:a.recent})]})]}):l?null:e(ne,{chart:!0})]})})}var Tt="off";function tn(t){if(!t||!/^\d{4}-\d{2}-\d{2}$/.test(t))return"";let n=new Date(`${t}T00:00:00Z`);return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t?t:""}function ua(){let t=new URLSearchParams(location.search),n=[];for(let c of t.getAll("filter")){let[d,u,...g]=c.split(":");d&&(u==="is"||u==="not"||u==="contains")&&n.push({dimension:d,op:u,value:g.join(":")})}let s=["previous","year","custom","off"].includes(t.get("compare")??"")?t.get("compare"):Tt,a=tn(t.get("compare_from")),i=tn(t.get("compare_to")),l=tn(t.get("from")),r=tn(t.get("to"));return{site:t.get("site")??"",period:t.get("period")==="custom"&&!(l&&r)?We:t.get("period")??We,...l&&r?{from:l,to:r}:{from:"",to:""},filters:n,compare:t.get("period")==="all"?"off":s==="custom"&&!(a&&i)?Tt:s,compareFrom:a,compareTo:i}}function ma(){let t=(new URLSearchParams(location.search).get("chart")??"").split(",").filter(n=>Fs(n));return t.length?t.slice(0,Vt):["visitors"]}function ir(t,n){if(Pe)return;let s=new URLSearchParams;t.site&&s.set("site",t.site),t.from&&t.to?(s.set("from",t.from),s.set("to",t.to)):t.period!==We&&s.set("period",t.period);for(let i of t.filters)s.append("filter",`${i.dimension}:${i.op}:${i.value}`);t.compare!==Tt&&s.set("compare",t.compare),t.compare==="custom"&&(s.set("compare_from",t.compareFrom),s.set("compare_to",t.compareTo)),n.join(",")!=="visitors"&&s.set("chart",n.join(","));let a=s.toString();history.replaceState(null,"",a?`?${a}`:location.pathname)}function ha(t,n=new Date){try{return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(n)}catch{return n.toISOString().slice(0,10)}}var rr=t=>Xt.includes(t);function lr({now:t,before:n,lowerIsBetter:s,compared:a}){let i=Cn(t,n);if(i===null&&n===0&&a)return t?e("span",{class:`delta ${s?"down":"up"}`,title:o("delta.title"),children:`\u2191 ${o("delta.fromNone")}`}):e("span",{class:"delta flat",title:o("delta.title"),children:o("delta.none")});if(i===null)return e("span",{class:"delta"});let l=Math.abs(i)<.005,r=s?i<0:i>0;return e("span",{class:`delta ${l?"flat":r?"up":"down"}`,title:o("delta.title"),children:l?o("delta.none"):`${i>0?"\u2191":"\u2193"} ${Math.abs(Math.round(i*100))}%`})}function cr({site:t,ready:n}){let[s,a]=m(null),i=s?.visitors??null;F(()=>{let c=!0,d=()=>R.realtime(t).then(g=>c&&a(g)).catch(()=>{});d();let u=setInterval(d,3e4);return()=>{c=!1,clearInterval(u)}},[t]);let[l,r]=m(()=>ot("live"));return i===null?e("span",{class:"live",role:"status","aria-label":o("common.loading"),children:e("span",{class:"live-placeholder","aria-hidden":"true"})}):n?e(z,{children:[e("button",{type:"button",class:"live",title:o("app.live.title"),onClick:()=>he("live")||r(!0),children:[e("span",{class:i>0?"beat on":"beat","aria-hidden":"true"}),X("app.live",i,{n:De(i)})]}),l?e(pa,{site:t,initialData:s??void 0,onClose:()=>r(!1)}):null]}):e("span",{class:"live",children:[e("span",{class:"beat","aria-hidden":"true"}),X("app.live",i,{n:De(i)})]})}function dr({view:t,stats:n,previous:s,compare:a}){let i=rr(t.period)?t.period:We,l=t.from?t.from===t.to?o("when.day",{day:ze(t.from,t.to)}):o("when.range",{range:ze(t.from,t.to)}):o(`when.${i}`),r=t.compare==="off"||!a?"":t.compare==="year"?o("headline.lastYear"):t.compare==="custom"?ze(a.from,a.to):t.from?o("before.range"):o(`before.${i}`),c=Cn(n.visitors,s?.visitors),d={who:e("strong",{children:X("headline.who",n.visitors,{n:De(n.visitors)})}),verb:X(t.filters.length?"headline.matched":"headline.visited",n.visitors),when:l,against:r,change:c===null?"":e("span",{class:c>0?"up":"down",children:o(c>0?"headline.more":"headline.fewer",{pct:Math.abs(Math.round(c*100))})})},u=c===null||!r?"headline.plain":Math.abs(c)<.005?"headline.same":c>0?"headline.up":"headline.down";return e("p",{class:"headline",children:fe(u,d)})}function pr(){let[,t]=m(Q()),[n,s]=m(null),[a,i]=m(ua),l=Ee(()=>({...a,compare:"off",compareFrom:"",compareTo:""}),[a.site,a.period,a.from,a.to,a.filters]),[r,c]=m(ma),[d,u]=m(null),[g,h]=m([]),[v,p]=m(void 0),[y,w]=m(""),[f,b]=m(()=>{let I=new URLSearchParams(location.search).get("connect_error");return I===null?null:{key:/^[a-z]+$/.test(I)&&Ms(`sites.connectError.${I}`)?`sites.connectError.${I}`:"sites.connectError.failed",error:!0}}),[S,E]=m(null),[$,A]=m(!1),[x,k]=m(()=>ot("assistant")),[L,N]=m(()=>{let I=Ue("settings");return I!==null?Xo(I)?I:null:new URLSearchParams(location.search).get("settings")==="general"?"general":null}),D=I=>he(`settings:${I}`)||N(I),[H,M]=m(!1),[C,_]=m(null),[P,U]=m(!1),[G,B]=m(!1),oe=()=>{Qe&&R.account().then(I=>_(I.account)).catch(()=>{})};F(oe,[]);let[Te,nn]=m("");F(()=>{Ie||R.about().then(I=>nn(I.version)).catch(()=>{})},[]);let va=Qe?C?.role==="owner"||C?.role==="admin":!0,Be=Ie||C?.role==="viewer",[ba,ya]=m(!1);F(()=>Is(()=>ya(!0)),[]);let Kn=I=>w(I instanceof Re&&I.status===401?"signed-out":mt&&I instanceof Re&&I.status===404?o("share.gone"):I.message);F(()=>{Ie||R.assistant().catch(()=>{}),R.sites().then(I=>{let j=I.sites.find(V=>V.id===a.site)??I.sites[0];j&&R.realtime(j.id).catch(()=>{}),s(I.sites),E(I.moving?.through??null),i(V=>V.site&&!I.sites.some(ke=>ke.id===V.site)?{...V,site:I.sites[0]?.id??""}:V)}).catch(Kn)},[]),F(()=>{if(S===null)return;let I=setInterval(()=>{R.sites().then(j=>E(j.moving?.through??null)).catch(()=>{})},6e4);return()=>clearInterval(I)},[S===null]),F(()=>{ir(a,r)},[a,r]);let[ct,Vn]=m(!1),[sn,Gn]=m(!1),on=ae.managed&&!n?.length;F(()=>{if(on)return;let I=!0,j=setTimeout(()=>I&&Vn(!0),300);return Gn(!1),Promise.all([R.stats(a),R.series(a)]).then(([V,ke])=>{I&&(w(""),u(V),h(ke.points),p(ke.previous))}).catch(V=>{I&&(u(null),h([]),p(void 0),Gn(!0),Kn(V))}).finally(()=>{clearTimeout(j),I&&Vn(!1)}),()=>{I=!1,clearTimeout(j)}},[a,on]);let Me=ut(I=>i(j=>({...j,...I})),[]),wa=ut((I,j)=>i(V=>({...V,filters:[...V.filters.filter(ke=>ke.dimension!==I),{dimension:I,op:"is",value:j}].slice(-Zt)})),[]),xa=I=>c(j=>{if(j.includes(I))return j.length>1?j.filter(ke=>ke!==I):j;let V=[...j,I];return V.length>Vt?V.slice(V.length-Vt):V}),Wn=!a.from&&a.period===We&&!a.filters.length&&a.compare===Tt&&r.join(",")==="visitors";F(()=>{let I=()=>{i(ua()),c(ma())};return window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)},[]);let an=()=>{Wn||history.pushState(null,"",location.href),i(I=>({site:I.site,period:We,from:"",to:"",filters:[],compare:Tt,compareFrom:"",compareTo:""})),c(["visitors"]),window.scrollTo({top:0,behavior:"smooth"})},Yn=I=>{Ht(I,!0).then(()=>t(I)).catch(j=>w(j.message))},W=n?.find(I=>I.id===a.site)??n?.[0],qe=!!(W&&W.lastSeen==null&&!Ie&&!W.remote&&!_e),Jn=!!(W?.remote&&!W.manage);F(()=>{if(!qe)return;let I=setInterval(()=>{R.sites().then(j=>{s(j.sites),j.sites.find(V=>V.id===W?.id)?.lastSeen!=null&&($s(),i(V=>({...V,filters:[...V.filters]})))}).catch(()=>{})},5e3);return()=>clearInterval(I)},[qe,W?.id]);let ka=Ee(gr,[]),Zn=ha(W?.timezone??"UTC");if(ba)return e(fa,{});if(y==="signed-out")return e("main",{class:"signed-out",children:[e("h1",{children:"Runlight"}),_n?e("p",{children:fe("app.sessionEnded",{link:e("a",{href:`${_n}?next=${encodeURIComponent(location.pathname+location.search)}`,children:o("app.signInAgain")})})}):e("p",{children:fe("app.signedOut",{token:e("code",{children:"?token="}),env:e("code",{children:"RUNLIGHT_TOKEN"})})})]});let Xn=I=>{s(j=>[...j??[],I].sort((V,ke)=>V.name.localeCompare(ke.name))),M(!1),i(j=>({...j,site:I.id,filters:[]}))};if(n&&n.length===0&&ae.managed)return e(vo,{onAdded:Xn});if(on)return e("main",{"aria-busy":"true"});let _a=qt.filter(I=>r.includes(I.key));return e("main",{children:[e("header",{class:"hero",children:[e("div",{class:"hero-top",children:[e("div",{class:"identity",children:[e("button",{type:"button",class:"home",title:o("app.home"),onClick:an,children:W?e(Ut,{site:W}):e("span",{class:"avatar letter"})}),e("div",{class:"identity-text",children:[n&&(n.length>1||ae.managed&&!Be)?e(bo,{sites:n,current:W,canAdd:ae.managed&&!Be,onPick:I=>Me({site:I,filters:[]}),onAdd:()=>M(!0),onAll:()=>B(!0)}):e("h1",{children:e("button",{type:"button",class:"home",title:o("app.home"),onClick:an,children:W?.name??"Runlight"})}),W?e(cr,{site:W.id,ready:W.lastSeen!=null},W.id):null]}),W&&!Be?e("button",{type:"button",class:"gear","aria-label":o("settings.open"),title:o("settings.open"),onClick:()=>D("general"),children:e("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[e("circle",{cx:"10",cy:"10",r:"2.6"}),e("path",{d:"M10 1.8l1.3 2.3 2.6-.6.8 2.5 2.5.8-.6 2.6 2.3 1.3-2.3 1.3.6 2.6-2.5.8-.8 2.5-2.6-.6L10 18.2l-1.3-2.3-2.6.6-.8-2.5-2.5-.8.6-2.6L1.8 10l2.3-1.3-.6-2.6 2.5-.8.8-2.5 2.6.6z"})]})}):null]}),e("div",{class:"actions",hidden:qe,children:[Wn?null:e("button",{type:"button",class:"reset-button",onClick:an,title:o("view.resetHint"),children:[e(T,{name:"reset"}),o("view.reset")]}),W&&!Ie?e("button",{type:"button",class:"filter-button assistant-button","aria-label":o("assistant.open"),title:o("assistant.open"),onClick:()=>he("assistant")||k(!0),children:e(T,{name:"robot"})}):null,e("button",{type:"button",class:a.filters.length?"filter-button on":"filter-button",onClick:()=>A(!0),children:[e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M2.5 3.5h11M4.5 8h7M6.5 12.5h3"})}),o("filter.button"),a.filters.length?e("span",{class:"count",children:a.filters.length}):null]}),e(ho,{period:a.period,from:a.from,to:a.to,today:Zn,onPeriod:I=>Me(I==="all"?{period:I,from:"",to:"",compare:"off",compareFrom:"",compareTo:""}:{period:I,from:"",to:""}),onRange:(I,j)=>Me({from:I,to:j})}),e(go,{mode:a.compare,from:a.compareFrom,to:a.compareTo,today:Zn,allTime:a.period==="all"&&!a.from,onChange:(I,j="",V="")=>Me({compare:I,compareFrom:j,compareTo:V})})]})]}),qe||sn?null:d&&!ct?e(dr,{view:a,stats:d.stats,previous:d.previous,compare:d.compare}):e("p",{class:"headline",role:"status","aria-label":o("common.loading"),children:e("span",{class:"headline-placeholder","aria-hidden":"true"})}),a.filters.length?e("div",{class:"filters",children:[a.filters.map(I=>e("span",{class:"filter",children:[e("span",{class:"filter-dim",children:In(I.dimension)}),Ln(I.op)," ",e("strong",{children:ge(I.dimension,I.value)}),e("button",{type:"button","aria-label":o("filter.remove"),onClick:()=>Me({filters:a.filters.filter(j=>j!==I)}),children:"\xD7"})]})),a.filters.length>1?e("button",{type:"button",class:"clear",onClick:()=>Me({filters:[]}),children:[e(T,{name:"x"}),o("common.clearAll")]}):null]}):null]}),f?e("p",{class:f.error?"failure dismissable":"failure dismissable notice",role:"alert",children:[f.key?o(f.key):f.text,e("button",{type:"button",class:"remove","aria-label":o("common.close"),title:o("common.close"),onClick:()=>b(null),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}):null,S!==null?e("p",{class:"failure notice",role:"status",children:o("app.moving",{day:de(ha(W?.timezone??"UTC",new Date(S+864e5-1)))})}):null,y?e("p",{class:"failure",children:y}):null,L&&W&&n?e(ea,{site:W,sites:n,view:a,onSite:(I,j)=>{N(j),Me({site:I,filters:[]})},start:L,onClose:()=>{N(null),i(I=>({...I,filters:[...I.filters]})),oe()},onSaved:I=>{s(j=>(j??[]).map(V=>V.id===I.id?{...V,...I}:V)),i(j=>({...j,filters:[...j.filters]}))},onLanguage:Yn,onDemoted:I=>{I!=="admin"&&(N(null),b({text:o(I==="member"?"people.demotedMember":"people.demoted"),error:!1})),oe()},me:C,onDeleted:I=>{N(null);let j=(n??[]).filter(V=>V.id!==I);s(j),i(V=>({...V,site:j[0]?.id??"",filters:[]}))}},W.id):null,G&&n?e(yo,{sites:n,view:a,onClose:()=>B(!1),onAdd:ae.managed&&!Be?()=>{B(!1),M(!0)}:void 0,onPick:I=>{B(!1),Me({site:I,filters:[]})}}):null,P&&C?e(da,{me:C,onClose:()=>{U(!1),oe()}}):null,H?e(pe,{title:o("sites.addTitle"),onClose:()=>M(!1),children:e(Dn,{onAdded:Xn,onCancel:()=>M(!1)})}):null,$?e(co,{view:a,onApply:I=>Me({filters:I}),onClose:()=>A(!1)}):null,x&&W?e(_o,{site:W,view:a,owner:va,canWrite:!Be&&!W.remote,canInvite:Qe&&(C?.role==="owner"||C?.role==="admin"),onSetup:()=>{k(!1),D("assistant")},onClose:()=>{k(!1),i(I=>({...I,filters:[...I.filters]}))}}):null,qe&&W&&n?e("section",{class:"welcome",children:[e("h2",{children:o("welcome.title",{name:W.name})}),e("p",{class:"welcome-lead",role:"status",children:[e("span",{class:"beat wait","aria-hidden":"true"}),e("span",{children:[e("strong",{children:o("welcome.waiting")}),e("span",{children:o("welcome.waitingHint")})]})]}),e("div",{class:"welcome-steps",children:e(zn,{site:W,sites:n})})]}):null,e("section",{class:"overview",hidden:qe,"aria-busy":ct,children:[e("div",{class:"metrics",children:qt.map(I=>{let j=r.includes(I.key),V=d?.stats[I.key];return e("button",{type:"button",class:`metric s${I.slot}${j?" on":""}`,"aria-pressed":j,onClick:()=>xa(I.key),title:Os(I),children:[e("span",{class:"metric-label",children:[e("span",{class:`swatch s${I.slot}`}),Kt(I)]}),e("span",{class:"metric-value",children:sn?"\xA0":!d||ct?e("span",{class:"metric-placeholder","aria-label":o("common.loading")}):V===void 0?"\xA0":I.format(V)}),e("span",{class:"metric-foot",children:d&&!ct?e(lr,{now:d.stats[I.key],before:d.previous?.[I.key],lowerIsBetter:I.lowerIsBetter,compared:!!d.previous?.visits}):null})]})})}),d&&!ct?e(st,{points:g,previous:v,metrics:_a.map(Bs),interval:d.range.interval,timezone:d.range.timezone}):sn?e("div",{class:"chart"}):e("div",{class:"chart chart-loading",children:e(ne,{chart:!0})})]}),e("div",{class:"board",hidden:qe,children:[ka.map((I,j)=>I.title==="panel.rhythm"?e(io,{view:l,wide:I.wide}):e(ao,{title:I.title,tabs:I.tabs,view:l,onFilter:wa,wide:I.wide,map:I.title==="panel.locations"},j)),W&&!Ie&&!Jn?e(Xs,{view:l,site:W.id,readOnly:Be}):null,W?e(Po,{view:a,funnelView:l,readOnly:Be||Jn,onAdd:I=>D(I)}):null]}),e("footer",{class:"foot",children:[e("a",{href:"https://runlight.sh",class:"powered",target:"_blank",rel:"noopener",children:[e("svg",{class:"powered-mark",viewBox:"0 0 32 32","aria-hidden":"true",children:[e("rect",{x:"2.5",y:"2.5",width:"27",height:"27",rx:"7"}),e("path",{d:"M11 23V9h6.2a4.3 4.3 0 0 1 0 8.6H11m6 0 5 5.4"}),e("circle",{cx:"23.6",cy:"8.4",r:"2.6"})]}),fe("foot.powered",{name:e("span",{children:"Runlight"})})]}),Te?e("span",{class:"powered-version",children:["v",Te]}):null,e("span",{class:"foot-range",children:d?`${ze(d.range.from,d.range.to)} \xB7 ${d.range.timezone}`:""}),e("label",{class:"language",children:[e("span",{class:"visually-hidden",children:o("foot.language")}),e("select",{value:Q(),onChange:I=>Yn(I.target.value),children:Ne.map(([I,j])=>e("option",{value:I,children:j}))})]}),e(fr,{}),e("button",{type:"button",class:"sign-out",title:o("export.title"),onClick:()=>{et("export",re(a)).catch(I=>w(I.message))},children:o("export.zip")}),C?e("button",{type:"button",class:"sign-out",onClick:()=>U(!0),children:o("account.title")}):null,Le?e("a",{class:"sign-out",href:Le,children:o("app.signOut")}):null]})]})}var ur={"Organic Search":1,Social:2,Direct:3,Email:4,Referral:5,"Paid Search":6,AI:7,Campaign:8},mr={desktop:1,mobile:2,tablet:3},hr=new Set(["ChatGPT-User","Claude-User","Perplexity-User","MistralAI-User","meta-externalfetcher"]);function gr(){let t={filterable:!0};return[{title:"panel.pages",wide:!0,tabs:[{dimension:"page",label:"tab.top",...t,extra:ro},{dimension:"entry",label:"tab.entry",...t,extra:lo},{dimension:"exit",label:"tab.exit",...t}]},{title:"panel.sources",tabs:[{dimension:"channel",label:"tab.channels",...t,colors:ur},{dimension:"source",label:"tab.sources",...t},{dimension:"referrer",label:"tab.referrers",...t}]},{title:"panel.locations",tabs:[{dimension:"country",label:"tab.countries",...t},{dimension:"region",label:"tab.regions",...t},{dimension:"city",label:"tab.cities",...t}]},{title:"panel.rhythm",wide:!0,tabs:[]},{title:"panel.ai",wide:!0,tabs:[{dimension:"ai_agent",label:"tab.agents",column:"fetches",groups:{of:n=>hr.has(n)?"ai.live":"ai.crawl",slots:{"ai.live":3,"ai.crawl":1}}},{dimension:"ai_page",label:"tab.pages",column:"fetches"}]},{title:"panel.devices",tabs:[{dimension:"device",label:"tab.device",...t,colors:mr},{dimension:"browser",label:"tab.browser",...t},{dimension:"os",label:"tab.os",...t},{dimension:"screen",label:"tab.screen",...t},{dimension:"language",label:"tab.language",...t}]},{title:"panel.events",tabs:[{dimension:"event",label:"tab.event",column:"events",...t}]},{title:"panel.campaigns",wide:!0,tabs:[{dimension:"utm_campaign",label:"tab.campaign",...t},{dimension:"utm_source",label:"tab.source",...t},{dimension:"utm_medium",label:"tab.medium",...t},{dimension:"utm_content",label:"tab.content",...t},{dimension:"utm_term",label:"tab.term",...t}]}]}function fa(){return e("main",{class:"signed-out",children:[e("h1",{children:o("embed.expiredTitle")}),e("p",{children:o("embed.expired")}),e("button",{type:"button",class:"solid",onClick:()=>parent.postMessage({type:"runlight:reload"},Pe),children:[e(T,{name:"refresh"}),o("embed.reload")]})]})}var qn=["light","dark","system"],ga=t=>o(t==="light"?"theme.light":t==="dark"?"theme.dark":"theme.system");function fr(){let[,t]=m(0);F(()=>Yo(()=>t(l=>l+1)),[]);let n=lt(),s=qn[(qn.indexOf(n)+1)%qn.length];F(()=>{let l=r=>{(r.metaKey||r.ctrlKey)&&r.shiftKey&&r.key.toLowerCase()==="d"&&(r.preventDefault(),_t(Wo()?"light":"dark"))};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[]);let a=/Mac|iPhone|iPad/.test(navigator.platform),i=o("theme.cycle",{current:ga(n),next:ga(s)});return e("button",{type:"button",class:"theme","aria-label":i,"aria-keyshortcuts":a?"Meta+Shift+D":"Control+Shift+D",title:`${i} (${a?"\u2318\u21E7D":"Ctrl+Shift+D"})`,onClick:()=>_t(s),children:n==="light"?e("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[e("circle",{cx:"10",cy:"10",r:"3.6"}),e("path",{d:"M10 1.8v2.2M10 16v2.2M1.8 10H4M16 10h2.2M4.2 4.2l1.6 1.6M14.2 14.2l1.6 1.6M4.2 15.8l1.6-1.6M14.2 5.8l1.6-1.6"})]}):n==="dark"?e("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:e("path",{d:"M16.5 12.6A7 7 0 0 1 7.4 3.5a7 7 0 1 0 9.1 9.1z"})}):e("svg",{viewBox:"0 0 20 20","aria-hidden":"true",children:[e("rect",{x:"2.5",y:"3.5",width:"15",height:"10",rx:"1.6"}),e("path",{d:"M7 17h6M10 13.5V17"})]})})}Fn();Gs();var vr=document.getElementById("app");Ht(Ts()).catch(()=>Ht("en")).finally(()=>ps(Pe&&!Rs?e(fa,{}):e(pr,{}),vr));