runlight 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/build.json +3 -3
- data/assets/dashboard.js +17 -9
- data/assets/locales.json +5 -5
- data/lib/runlight/accounts/accounts.rb +82 -13
- data/lib/runlight/accounts/throttle.rb +123 -38
- data/lib/runlight/accounts/web.rb +50 -14
- data/lib/runlight/assistant.rb +11 -0
- data/lib/runlight/connect.rb +2 -3
- data/lib/runlight/core.rb +23 -0
- data/lib/runlight/db/connect.rb +5 -2
- data/lib/runlight/db/db.rb +79 -7
- data/lib/runlight/http/fetcher.rb +4 -1
- data/lib/runlight/http/request.rb +14 -3
- data/lib/runlight/importers/csv_visits.rb +1 -1
- data/lib/runlight/importers/index.rb +10 -2
- data/lib/runlight/importers/visits.rb +17 -6
- data/lib/runlight/importers/write.rb +21 -6
- data/lib/runlight/links.rb +14 -9
- data/lib/runlight/mail/smtp.rb +2 -0
- data/lib/runlight/mail/smtp_session.rb +22 -1
- data/lib/runlight/mcp.rb +8 -1
- data/lib/runlight/oauth.rb +2 -3
- data/lib/runlight/rack_app.rb +54 -7
- data/lib/runlight/routes.rb +101 -55
- data/lib/runlight/safefetch.rb +35 -0
- data/lib/runlight/version.rb +1 -1
- metadata +2 -2
data/assets/dashboard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Go=Object.defineProperty;var Wo=(t,n,s)=>n in t?Go(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var Ft=(t,n,s)=>Wo(t,typeof n!="symbol"?n+"":n,s);var q,Dn,Yo,Me,Pn,gt,$n,ut,We,Hn,zt,Nt,Ut,Zo,ft={},vt=[],Jo=/^m(i|n|o|s|text|space)$/,jt=Array.isArray,On=vt.slice,He=Object.assign;function bt(t){t&&t.parentNode&&t.remove()}function mt(t,n,s,a,r){var i={type:t,props:n,key:s,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r||++Dn,__i:-1,__u:0};return!r&&q.vnode&&q.vnode(i),i}function U(t){return t.children}function ht(t,n){this.props=t,this.context=n,this.__g=0}function Ee(t,n){if(n==null)return t.__?Ee(t.__,t.__i+1):null;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:Ee(t)}function Fn(t){if((t=t.__)&&t.__c&&!t.props.__P)return t.__e=null,t.__k.some(function(n){return n&&(t.__e=n.__e)}),Fn(t)}function Rn(t){(8&t.__g||!(t.__g|=8)||!Me.push(t)||gt++)&&Pn==q.debounceRendering||((Pn=q.debounceRendering)||queueMicrotask)(Xo)}function Xo(){var t,n,s,a,r,i,c,l,d;try{for(n=1;Me.length;)Me.length>n&&Me.sort($n),t=Me.shift(),n=Me.length,8&t.__g&&(a=void 0,r=void 0,i=(r=(s=t).__v).__e,c=[],l=[],(d=s.__P)&&((a=He({constructor:void 0},r)).__v=r.__v+1,q.vnode&&q.vnode(a),Kt(d,a,r,s.__n,d.namespaceURI,32&r.__u?[i]:null,c,i||Ee(r),32&r.__u,l),a.__v=r.__v,a.__.__k[a.__i]=a,jn(c,a,l),r.__=r.__e=null,a.__e!=i&&Fn(a)))}finally{Me.length=gt=0}}function Nn(t,n,s,a,r,i,c,l,d,p,m){var f,b,g,_,v,u,S=a.__k||vt,E=n.length;for(d=Qo(s,n,S,d,E),f=0;f<E;f++)(g=s.__k[f])!=null&&(b=~g.__i&&S[g.__i]||ft,g.__i=f,u=Kt(t,g,b,r,i,c,l,d,p,m),_=g.__e,g.ref&&(b.ref!=g.ref||8&b.__u)&&(b.ref!=g.ref&&b.ref&&Bt(b.ref,null,g),m.push(g.ref,g.__c||_,g)),v=v||_,4&g.__u?(d=Un(g,d,t,!b.__v),b.__e&&(b.__e=null)):typeof g.type=="function"&&u!==void 0?d=u:_&&(d=_.nextSibling),g.__u&=-7);return s.__e=v,d}function Qo(t,n,s,a,r){var i,c,l,d,p,m,f,b,g,_,v=s.length,u=v,S=0,E=!1,y=t.__k=Array(r);for(i=0;i<r;i++)(c=n[i])!=null&&typeof c!="boolean"&&typeof c!="function"?(typeof c!="object"||c.constructor==String?c=y[i]=mt(null,c):jt(c)?c=y[i]=mt(U,{children:c}):c.constructor===void 0&&c.__b?c=y[i]=mt(c.type,c.props,c.key,c.ref,c.__v):y[i]=c,d=i+S,c.__=t,c.__b=t.__b+1,l=null,~(p=c.__i=ea(c,s,d,u))&&(u--,(l=s[p])&&(l.__u|=2)),l&&l.__v?(c.__u|=2,p==d-1?S--:p==d+1?S++:p!=d&&(p>d?S--:S++,E=!0)):(~p||(r>v?S--:r<v&&S++),typeof c.type!="function"&&(c.__u|=4))):y[i]=null;if(E){for(m=[],f=[],i=0;i<r;i++)if((c=y[i])&&2&c.__u){for(b=0,g=m.length;b<g;)m[_=b+g>>1]<c.__i?b=_+1:g=_;m[b]=c.__i,f[i]=b+1}for(S=m.length;i--;)f[i]&&(f[i]==S?S--:y[i].__u|=4)}if(u)for(i=0;i<v;i++)!(l=s[i])||2&l.__u||(l.__e==a&&(a=Ee(l)),qt(l,l));return a}function Un(t,n,s,a){var r,i;if(typeof t.type=="function"){if(t.props.__P)return n;if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&(r[i].__=t,n=Un(r[i],n,s,!1));return n}for(n&&!n.parentNode&&(n=Ee(t))&&!n.parentNode&&(n=null),t.__e!=n&&(!a&&s.moveBefore&&t.__e.parentNode?s.moveBefore(t.__e,n):s.insertBefore(t.__e,n||null)),n=t.__e;(n=n&&n.nextSibling)&&n.nodeType==8;);return n}function ea(t,n,s,a){var r,i,c,l=t.key,d=t.type,p=n[s],m=p&&!(2&p.__u);if(p===null&&l==null||m&&l==p.key&&d==p.type)return s;if(a>(m?1:0)){for(r=s-1,i=s+1;r>=0||i<n.length;)if((p=n[c=r>=0?r--:i++])&&!(2&p.__u)&&l==p.key&&d==p.type)return c}return-1}function Ln(t,n,s){s==null&&(s=""),n[0]=="-"?t.setProperty(n,s):t[n]=s}function pt(t,n,s,a,r){var i;e: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||Ln(t.style,n,"");if(s)for(n in s)a&&s[n]==a[n]||Ln(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")i=n!=(n=n.replace(Hn,"$1")),(n=n.slice(2))[0]<"a"&&(n=n.toLowerCase()),(t.__e||(t.__e={}))[n+i]=s,s?a?s[We]=a[We]:(s[We]=zt,t.addEventListener(n,i?Ut:Nt,i)):t.removeEventListener(n,i?Ut:Nt,i);else{if(r=="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{t[n]=s??"";break e}catch{}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?t.removeAttribute(n):t.setAttribute(n,n=="popover"&&s==1?"":s))}}function In(t){return function(n){if(this.__e){var s=this.__e[n.type+t];if(n[ut]==null)n[ut]=zt++;else if(n[ut]<s[We])return;return s(q.event?q.event(n):n)}}}function Kt(t,n,s,a,r,i,c,l,d,p){var m,f,b,g,_,v,u,S,E,y,R,w,x,P,D,F,k,A,$,C,T=n.type;if(n.constructor!==void 0)return null;if(128&s.__u&&(d=32&s.__u,m=s.__c.__z)){if(n.__u|=d,f=i=[],m.nodeType==8)for(b=1,g=m.nextSibling;g;g=g.nextSibling){if(g.nodeType==8){if(g.data.startsWith("$s"))b++;else if(g.data.startsWith("/$s")&&!--b)break}i.push(g)}else i.push(m);l=i[0]}(m=q.__b)&&m(n);e:if(typeof T=="function"){_=c.length;try{if(y=n.props,R=(m=T.prototype)&&m.render,w=(m=T.contextType)&&a[m.__c],x=m?w?w.props.value:m.__:a,s.__c?2&(v=n.__c=s.__c).__g&&(v.__g|=1):(R?n.__c=v=new T(y,x):(n.__c=v=new ht(y,x),v.constructor=T,v.render=na),w&&w.sub(v),v.state||(v.state={}),v.__n=a,v.__g|=8,v.__h=[],v.__k=[]),R&&(v.__s||(v.__s=v.state),T.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=He({},v.__s)),He(v.__s,T.getDerivedStateFromProps(y,v.__s)))),u=v.props,S=v.state,v.__v=n,s.__c){if(R&&!T.getDerivedStateFromProps&&y!==u&&v.componentWillReceiveProps&&v.componentWillReceiveProps(y,x),n.__v==s.__v&&!(8&v.__g)||!(4&v.__g)&&v.shouldComponentUpdate&&v.shouldComponentUpdate(y,v.__s,x)===!1){n.__v!=s.__v&&(v.props=y,v.state=v.__s,v.__g&=-9),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(N){N&&(N.__=n)}),vt.push.apply(v.__h,v.__k),v.__k=[],v.__h.length&&c.push(v),l=Ee(s);break e}v.componentWillUpdate&&v.componentWillUpdate(y,v.__s,x),R&&v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(u,S,E)})}else R&&!T.getDerivedStateFromProps&&v.componentWillMount&&v.componentWillMount(),R&&v.componentDidMount&&v.__h.push(v.componentDidMount);if(v.context=x,v.props=y,v.__P=t,v.__g&=-5,P=q.__r,D=0,R)v.state=v.__s,v.__g&=-9,P&&P(n),m=v.render(v.props,v.state,v.context),vt.push.apply(v.__h,v.__k),v.__k=[];else do v.__g&=-9,P&&P(n),m=v.render(v.props,v.state,v.context),v.state=v.__s;while(8&v.__g&&++D<25);v.state=v.__s,v.getChildContext&&(a=He({},a,v.getChildContext())),R&&s.__c&&v.getSnapshotBeforeUpdate&&(E=v.getSnapshotBeforeUpdate(u,S)),F=m&&m.type===U&&m.key==null?m.props.children:m,y.__P&&(m=l,r=(t=y.__P).namespaceURI,d=i=null,s.props&&s.props.__P!=t&&(s.__k.some(function(N){N&&qt(N,N)}),s.__k=null),l=s.__k?Ee(s,0):null),l=Nn(t,jt(F)?F:[F],n,s,a,r,i,c,l,d,p),y.__P&&(n.__e=null,l=m),n.__u&=-161,128&s.__u&&(v.__z=null),f&&f.some(bt),v.__h.length&&c.push(v),1&v.__g&&(v.__g&=-4)}catch(N){if(c.length=_,n.__v=null,d||i)if(N.then){if(k=0,n.__u|=d?160:128,i){for($=0;$<i.length;$++)if(C=i[$])if(C.nodeType==8){if(i[$]=null,C.data.startsWith("$s"))k++||(A=C);else if(C.data.startsWith("/$s")&&!--k){l=C;break}}else k&&(i[$]=null)}if(!A){for(;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i&&(i[i.indexOf(l)]=null),A=l}n.__c.__z||(n.__c.__z=A),n.__e=l}else i&&i.some(bt);else n.__e=s.__e;n.__k||(n.__k=s.__k||[]),N.then||zn(n),q.__e(N,n,s)}}else l=n.__e=ta(s.__e,n,s,a,r,i,c,d,p,t);return(m=q.diffed)&&m(n),128&n.__u?void 0:l}function zn(t){t&&(t.__c&&(t.__c.__g|=4),t.__k&&t.__k.some(zn))}function jn(t,n,s){for(var a=0;a<s.length;)Bt(s[a++],s[a++],s[a++]);q.__c&&q.__c(n,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){q.__e(i,r.__v)}})}function ta(t,n,s,a,r,i,c,l,d,p){var m,f,b,g,_,v,u,S,E,y=s.props||ft,R=n.props,w=n.type;if(w=="svg"?r="http://www.w3.org/2000/svg":w=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i){for(m=0;m<i.length;m++)if((_=i[m])&&(w?_.localName==w:_.nodeType==3)){t=_,i[m]=null;break}}if(!t){if(S=p.ownerDocument||document,!w)return S.createTextNode(R);t=S.createElementNS(r,w,R.is&&R),l&&(q.__m&&q.__m(n,i),l=!1),i=null}if(w){if(p=w=="template"?t.content:t,i=w=="textarea"&&R.defaultValue!=null?null:i&&On.call(p.childNodes),!l&&i)for(y={},m=0;m<t.attributes.length;m++)y[(_=t.attributes[m]).name]=_.value;for(m in y)_=y[m],m=="dangerouslySetInnerHTML"?b=_:m=="children"||m in R||m=="value"&&"defaultValue"in R||m=="checked"&&"defaultChecked"in R||pt(t,m,null,_,r);for(m in E=1&s.__u,R)_=R[m],m=="children"?g=_:m=="dangerouslySetInnerHTML"?f=_:m=="value"?v=_:m=="checked"?u=_:l&&typeof _!="function"||!(y[m]!==_||E&&_!=null)||pt(t,m,_,y[m],r);f?(l||b&&(f.__html==b.__html||f.__html==t.innerHTML)||(t.innerHTML=f.__html),n.__k=[]):(b&&(t.textContent=""),(w=="foreignObject"||r=="http://www.w3.org/1998/Math/MathML"&&Jo.test(w))&&(r="http://www.w3.org/1999/xhtml"),Nn(p,jt(g)?g:[g],n,s,a,r,i,c,i?i[0]:s.__k&&Ee(s,0),l,d),i&&i.some(bt)),l&&w!="textarea"||(m="value",w=="progress"&&v==null?t.removeAttribute(m):v==null||v===t[m]&&(w!="progress"||v)||pt(t,m,v,y[m],r),m="checked",u!=null&&u!=t[m]&&pt(t,m,u,y[m],r))}else y===R||l&&t.data==R||(t.data=R);return t}function Bt(t,n,s){try{typeof t=="function"?(typeof t.__u=="function"&&t.__u(),(typeof t.__u!="function"||n)&&(t.__u=t(n))):t.current=n}catch(a){q.__e(a,s)}}function qt(t,n,s){var a,r;if(q.unmount&&q.unmount(t),!(a=t.ref)||a.current&&a.current!=t.__e||Bt(a,null,n),a=t.__c){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){q.__e(i,n)}a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&qt(a[r],n,typeof t.type!="function"||s&&!t.props.__P);(a=t.__e)&&(s||bt(a),a.__e&&(a.__e=null)),t.__e=t.__c=t.__=null}function na(t,n,s){return this.constructor(t,s)}function Kn(t,n){var s,a,r,i;q.__&&q.__(t,n),n.nodeType==9&&(n=n.documentElement),a=(s=t&&32&t.__u)?null:n.__k,n.__k=mt(U,{children:[t]}),r=[],i=[],Kt(n,n.__k,a||ft,ft,n.namespaceURI,a?null:n.firstChild?On.call(n.childNodes):null,r,a?a.__e:n.firstChild,s,i),jn(r,n.__k,i),n.__k.props.children=null}q={__e:function(t,n,s,a){for(var r,i,c;n=n.__;)if((r=n.__c)&&!(1&r.__g)){r.__g|=4;try{if((i=r.constructor)&&i.getDerivedStateFromError&&(r.setState(i.getDerivedStateFromError(t)),c=8&r.__g),r.componentDidCatch&&(r.componentDidCatch(t,a||{}),c=8&r.__g),c)return void(r.__g|=2)}catch(l){t=l,c=0}}throw gt=0,t}},Dn=0,Yo=function(t){return t!=null&&t.constructor===void 0},ht.prototype.setState=function(t,n){var s=this.__s;s&&s!=this.state||(s=this.__s=He({},this.state)),typeof t=="function"&&(t=t(He({},s),this.props)),t&&(He(s,t),this.__v&&(n&&this.__k.push(n),Rn(this)))},ht.prototype.forceUpdate=function(t){this.__v&&(this.__g|=4,t&&this.__h.push(t),Rn(this))},ht.prototype.render=U,Me=[],gt=0,$n=function(t,n){return t.__v.__b-n.__v.__b},ut=Symbol(),We=Symbol(),Hn=/(PointerCapture)$|Capture$/i,zt=0,Nt=In(!1),Ut=In(!0),Zo=0;var Ne,ee,Vt,Bn,Gt=Object.is,Ze=0,Qn=[],Wt=[],X=q,qn=X.__b,Vn=X.__r,Gn=X.diffed,Wn=X.__c,Yn=X.unmount,Zn=X.__;function yt(t,n){X.__h&&X.__h(ee,t,Ze||n),Ze=0;var s=ee.__H||(ee.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function h(t){return Ze=1,sa(ts,t)}function sa(t,n,s){var a=yt(Ne++,2);if(a.t=t,!a.__c&&(a.__=[s?s(n):ts(void 0,n),function(i){var c=a.__N?a.__N[0]:a.__[0],l=a.t(c,i);Gt(c,l)||(a.__N=[l,a.__[1]],a.__c.setState({}))}],a.__c=ee,!ee.__f)){ee.__f=!0;var r=ee.shouldComponentUpdate;ee.shouldComponentUpdate=function(i,c,l){var d=this.__H;if(!d)return!0;var p=!1,m=this.props!=i;if(d.__.some(function(b){b.__N&&(p=!0,Gt(b.__[0],b.__N[0])||(m=!0))}),r){var f=r.call(this,i,c,l);return p?f||m:f}return!p||m}}return a.__}function O(t,n){var s=yt(Ne++,3);!X.__s&&Jt(s.__H,n)&&(s.__P=!0,s.__=t,s.u=n,ee.__H.__h.push(s))}function es(t,n){var s=yt(Ne++,4);!X.__s&&Jt(s.__H,n)&&(s.__P=!1,s.__=t,s.u=n,ee.__h.push(s))}function K(t){return Ze=5,Ae(function(){return{current:t}},[])}function Ae(t,n){var s=yt(Ne++,7);return Jt(s.__H,n)&&(s.__=t(),s.__H=n),s.__}function Zt(t,n){return Ze=8,Ae(function(){return t},n)}function oa(){var t;do{for(;t=Wt.shift();)try{Ye(t)}catch(s){X.__e(s,{__:(t=t.__P)&&t.__v})}for(;t=Qn.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(Ye),n.__h.some(Yt),n.__h=[]}catch(s){n.__h=[],X.__e(s,t.__v)}}}while(Wt.length)}X.__b=function(t){ee=null,qn&&qn(t)},X.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),Zn&&Zn(t,n)},X.__r=function(t){Vn&&Vn(t),Ne=0;var n=(ee=t.__c).__H;n&&(Vt==ee?ee.__h=[]:(n.__h.some(Ye),n.__h.some(Yt),Ne=0),n.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})),Vt=ee},X.diffed=function(t){Gn&&Gn(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&Xn(Qn.push(n)),n.__H.__.some(function(s){s.u&&(s.__H=s.u)})),Vt=ee=null},X.__c=function(t,n){n.some(function(s){try{s.__h.some(Ye),s.__h=s.__h.filter(function(a){return!a.__||Yt(a)})}catch(a){n.some(function(r){r.__h&&(r.__h=[])}),n=[],X.__e(a,s.__v)}}),Wn&&Wn(t,n)},X.unmount=function(t){Yn&&Yn(t);var n,s,a=t.__c;a&&a.__H&&(a.__H.__.some(function(r){try{if(r.__P&&r.__c){if(s===void 0){for(s=t.__;s&&(!s.__c||!s.__c.__P);)s=s.__;s=s&&s.__c}r.__P=s,Xn(Wt.push(r))}else Ye(r)}catch(i){n=i}}),a.__H=void 0,n&&X.__e(n,a.__v))};var Jn=typeof requestAnimationFrame=="function";function aa(t){var n,s=function(){clearTimeout(a),Jn&&cancelAnimationFrame(n),setTimeout(t)},a=setTimeout(s,35);Jn&&(n=requestAnimationFrame(s))}function Xn(t){t!=1&&Bn==X.requestAnimationFrame||((Bn=X.requestAnimationFrame)||aa)(oa)}function Ye(t){var n=ee,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),ee=n}function Yt(t){var n=ee;t.__c=t.__(),ee=n}function Jt(t,n){return!t||t.length!=n.length||n.some(function(s,a){return!Gt(s,t[a])})}function ts(t,n){return typeof n=="function"?n(t):n}var we={"app.site":"Site","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.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 will show up here","goals.emptyHint":"A goal counts what matters to you, like a signup or a click on a button. An event or page goal you add counts past visits too, and a click goal counts from when you add it.","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.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 any CSS selector, or use Pick on my site, which opens your site so you can click the element and then Use this.","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.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":"API and AI","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","settings.people":"People","people.intro":"Everyone here can sign in to this server. Admins can change everything the owner can and manage people, though nobody can remove the owner. Members change the settings of every site, and viewers read every site's stats without changing anything. Invite a coworker and they choose their own password.","people.you":"you","people.role":"Role","people.owner":"Owner","people.viewer":"Viewer","people.roles":"Members can't manage people, set up the mail service or the assistant, or delete a site. Only the owner can hand ownership to an admin.","people.emailPlaceholder":"Their email address","pluginKey.title":"Key for CMS plugins","pluginKey.intro":"The WordPress, Drupal, and Craft plugins use this key to report AI agents reading this site's pages. It can only report for this site and cannot read anything. Replacing it stops the old key at once.","pluginKey.replace":"Replace 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, API and AI. 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","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":"It answers from {site}'s numbers, which it reads the moment you ask.","assistant.clear":"New chat","assistant.intro":"Ask about visitors, sources, pages, goals, or anything else this dashboard shows.","assistant.ask1":"How did this period compare with the one before?","assistant.ask2":"Where are most visitors coming from?","assistant.ask3":"Which pages keep people reading longest?","assistant.ask4":"Are AI assistants sending visitors here?","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":"Each question goes to that service with the numbers the assistant reads to answer it. Runlight keeps nothing about individual visitors, so nothing personal is sent. The assistant only reads, through the same tools as the MCP server, so it can never change anything.","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.","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.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_service":"Pick a mail service.","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_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.","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.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.","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.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_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":"Assistants such as ChatGPT and Claude are listed when they fetch your pages.","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","embedKey.title":"Key for the dashboard in your CMS","embedKey.intro":"With this key in their settings, the WordPress, Drupal, and Craft plugins show this site's dashboard inside your admin pages. It opens the read-only view a share link shows and cannot read anything itself. Delete it in Settings, API and AI to stop it at once.","embedKey.make":"Make a key","embedKey.another":"Make another key","embedKey.name":"Dashboard in a CMS","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 key for the dashboard in a CMS is for one site. Pick the site."};var Pe=[["en","English"],["fr","Fran\xE7ais"],["es","Espa\xF1ol"],["de","Deutsch"],["pt","Portugu\xEAs"]],ns="runlight_language",ia=(()=>{try{return JSON.parse(document.getElementById("app")?.dataset.locales??"{}")}catch{return{}}})(),ss="en",Ue=we,os=new Intl.PluralRules("en");function Z(){return ss}function as(){let t=null;try{t=localStorage.getItem(ns)}catch{}let n=[t,...navigator.languages??[navigator.language]].filter(Boolean);for(let s of n){let a=s.toLowerCase().split("-")[0];if(Pe.some(([r])=>r===a))return a}return"en"}async function xt(t,n=!1){if(t==="en")Ue=we;else{let s=ia[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}`);Ue={...we,...await a.json()}}if(ss=t,os=new Intl.PluralRules(t),document.documentElement.lang=t,n)try{localStorage.setItem(ns,t)}catch{}}function Xt(t,n){return t.replace(/\{(\w+)\}/g,(s,a)=>a in n?String(n[a]):s)}function rs(t){return Object.prototype.hasOwnProperty.call(we,t)}function o(t,n={}){return Xt(Ue[t]??we[t]??t,n)}function Y(t,n,s={}){let a=os.select(n),r=Ue,i=r[`${t}_${a}`]??r[`${t}_other`]??we[`${t}_other`]??t;return Xt(i,{n,...s})}function be(t,n={}){let s=`error.${t}`,a={...we,...Ue},r=a[s];if(r===void 0)return null;let i=n.field&&a[`mail.field.${n.field}`];return Xt(r,i?{...n,field:i}:n)}function ce(t,n){let s=Ue[t]??we[t]??t,a=[],r=0;for(let i of s.matchAll(/\{(\w+)\}/g))a.push(s.slice(r,i.index)),a.push(n[i[1]]??i[0]),r=(i.index??0)+i[0].length;return a.push(s.slice(r)),a}var de=document.getElementById("app")?.dataset.base??"",Je=document.getElementById("app")?.dataset.share??"",Le=document.getElementById("app")?.dataset.embedOrigin??"",is=document.getElementById("app")?.dataset.embed??"",ls=!!is,Xe=!!(Je||Le),cs=()=>Je?{"x-runlight-share":Je}:Le?{"x-runlight-embed":is}:void 0,Qt=new Set;function ds(t){return Qt.add(t),()=>Qt.delete(t)}function ps(t){if(!Le||t.status!==401)return!1;for(let n of Qt)n();return!0}var en=document.getElementById("app")?.dataset.signOut??"",tn=document.getElementById("app")?.dataset.signIn??"",Qe=document.getElementById("app")?.dataset.accounts!==void 0,us=document.getElementById("app")?.dataset.geoCredit!==void 0,oe={managed:!1},Re=class extends Error{constructor(s,a,r=""){super(a);Ft(this,"status",s);Ft(this,"code",r)}};async function wt(t){let n=await t.json().catch(()=>null);return new Re(t.status,n?.code&&be(n.code,n.params)||n?.error||t.statusText,n?.code??"")}async function J(t,n){let s=await fetch(`${de}/api/${t}?${n}`,{credentials:"same-origin",headers:cs()});if(!s.ok)throw ps(s),await wt(s);return s.json()}async function ze(t,n){let s=await fetch(`${de}/api/${t}?${n}`,{credentials:"same-origin",headers:cs()});if(!s.ok)throw ps(s),await wt(s);let a=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??"")?.[1]??"runlight-export",r=document.createElement("a");r.href=URL.createObjectURL(await s.blob()),r.download=a,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e4)}function ie(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 j(t,n,s){let a=await fetch(`${de}/api/${n}`,{method:t,credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw await wt(a);return a.json()}var me=async t=>{let n=await fetch(`${de}/api/${t}`,{method:"DELETE",credentials:"same-origin"});if(!n.ok)throw await wt(n)},Q=t=>t?`?site=${encodeURIComponent(t)}`:"",L={links:t=>J("links",ie(t)),link:(t,n)=>J(`links/${n}`,ie(t)),createLink:(t,n)=>j("POST",`links${Q(t)}`,n),updateLink:(t,n,s)=>j("PATCH",`links/${n}${Q(t)}`,s),deleteLink:(t,n)=>me(`links/${n}${Q(t)}`),importLinks:(t,n)=>j("POST",`links/import${Q(t)}`,{rows:n}),importStep:(t,n,s,a,r)=>j("POST",`links/import/${n}${Q(t)}`,{credentials:s,cursor:a,done:r}),observeKey:t=>J("observe-key",new URLSearchParams({site:t})),newObserveKey:t=>j("POST",`observe-key/new${Q(t)}`,{}),funnels:t=>J("funnels",ie(t)),saveFunnel:(t,n,s)=>j(n?"PATCH":"POST",`funnels${n?`/${n}`:""}${Q(t)}`,s),deleteFunnel:(t,n)=>me(`funnels/${n}${Q(t)}`),account:()=>J("account",new URLSearchParams),changePassword:(t,n)=>j("POST","account/password",{current:t,next:n}),twoFactorStart:t=>j("POST","account/2fa/start",{password:t}),twoFactorConfirm:t=>j("POST","account/2fa/confirm",{code:t}),twoFactorRecovery:t=>j("POST","account/2fa/recovery",{password:t}),twoFactorDisable:t=>j("POST","account/2fa/disable",{password:t}),pickTicket:(t,n)=>j("POST",`pick${Q(t)}`,{origin:n}),resetTwoFactor:(t,n)=>j("DELETE",`people/${t}/2fa`,{password:n}),people:()=>J("people",new URLSearchParams),addPerson:(t,n)=>j("POST","people",{email:t,role:n}),resendInvite:t=>j("POST",`invites/${t}/resend`,{}),cancelInvite:t=>me(`invites/${t}`),handOver:(t,n)=>j("POST",`people/${t}/owner`,{password:n}),setRole:(t,n)=>j("PATCH",`people/${t}`,{role:n}),removePerson:t=>me(`people/${t}`),eventProps:(t,n,s)=>{let a=ie(t);return a.set("event",n),s&&a.set("key",s),J("event-props",a)},umamiWebsites:t=>j("POST","import/umami/websites",{credentials:t}),importVisits:(t,n,s,a)=>j("POST",`import/umami/visits${Q(t)}`,{credentials:n,website:s,cursor:a}),importCsvVisits:(t,n)=>j("POST",`import/csv/visits${Q(t)}`,{rows:n}),goals:t=>J("goals",ie(t)),goal:(t,n)=>J(`goals/${n}`,ie(t)),createGoal:(t,n)=>j("POST",`goals${Q(t)}`,n),updateGoal:(t,n,s)=>j("PATCH",`goals/${n}${Q(t)}`,s),deleteGoal:(t,n)=>me(`goals/${n}${Q(t)}`),mail:t=>J("mail",new URLSearchParams(t?{site:t}:{})),connect:(t,n)=>j("POST","sites/connect",{url:t,...n?{site:n}:{}}),assistant:()=>J("assistant",new URLSearchParams),saveAssistant:t=>j("PUT","assistant",t),removeAssistant:()=>me("assistant"),saveAssistantLimit:t=>j("PUT","assistant/limits",{viewerDaily:t}),assistantModels:t=>j("POST","assistant/models",t),ask:(t,n,s,a)=>j("POST","assistant/chat",{site:t,messages:n,view:s,language:a}),saveMail:t=>j("PUT","mail",t),removeMail:()=>me("mail"),testMail:(t,n)=>j("POST","mail/test",{to:t,lang:n}),reports:t=>J("reports",new URLSearchParams(t?{site:t}:{})),addReport:(t,n)=>j("POST",`reports${Q(t)}`,n),deleteReport:(t,n)=>me(`reports/${n}${Q(t)}`),sendReport:(t,n)=>j("POST",`reports/${n}/send${Q(t)}`,{}),tokens:()=>J("tokens",new URLSearchParams),createToken:(t,n,s)=>j("POST","tokens",{name:t,site:n,...s?{scope:s}:{}}),deleteToken:t=>me(`tokens/${t}`),shares:t=>J("shares",new URLSearchParams(t?{site:t}:{})),createShare:(t,n)=>j("POST",`shares${Q(t)}`,{name:n}),renameShare:(t,n,s)=>j("PATCH",`shares/${n}${Q(t)}`,{name:s}),deleteShare:(t,n)=>me(`shares/${n}${Q(t)}`),linkDomains:t=>J("link-domains",new URLSearchParams(t?{site:t}:{})),addLinkDomain:(t,n)=>j("POST",`link-domains${Q(t)}`,{domain:n}),checkLinkDomain:(t,n)=>J(`link-domains/${encodeURIComponent(n)}/check`,new URLSearchParams(t?{site:t}:{})),removeLinkDomain:(t,n)=>me(`link-domains/${encodeURIComponent(n)}${Q(t)}`),updateSite:(t,n)=>j("PATCH",`sites/${encodeURIComponent(t)}`,n),sites:()=>J("sites",new URLSearchParams).then(t=>(oe.managed=!!t.managed,t)),addSite:t=>j("POST","sites",t),deleteSite:t=>me(`sites/${encodeURIComponent(t)}`),stats:t=>J("stats",ie(t)),series:t=>J("series",ie(t)),breakdown:(t,n,s)=>{let a=ie(t);return a.set("dimension",n),a.set("limit",String(s)),J("breakdown",a)},rhythm:t=>J("rhythm",ie(t)),journeys:(t,n)=>{let s=ie(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}`),J("journeys",s)},realtime:t=>J("realtime",new URLSearchParams(t?{site:t}:{}))};var kt=new Map;function nn(t,n){let s=`${Z()}|${t}`;if(!kt.has(s))try{kt.set(s,n())}catch{kt.set(s,null)}return kt.get(s)}var et=(t,n)=>nn(t,()=>new Intl.NumberFormat(Z(),n)),tt=(t,n)=>nn(t,()=>new Intl.DateTimeFormat(Z(),n));function je(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 H(t){return t<1e4?ke(t):et("compact",{notation:"compact",maximumFractionDigits:1}).format(t)}function ke(t){return et("whole",{}).format(t)}function ms(t){return et("decimal",{minimumFractionDigits:1,maximumFractionDigits:1}).format(t)}function ne(t){return et("percent",{style:"percent",maximumFractionDigits:0}).format(t)}function Ie(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 sn(t,n){return n===void 0||n===0?null:(t-n)/n}function ge(t){try{return nn("regions",()=>new Intl.DisplayNames([Z()],{type:"region"}))?.of(t)??t}catch{return t}}function fe(t){return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(n=>127397+n.charCodeAt(0))):""}function _t(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 tt(`bucket|${n}|${s}`,a).format(new Date(t))}function pe(t,n=!0){let s=n?{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"};return tt(`day|${n}`,s).format(new Date(`${t}T00:00:00Z`))}function hs(t,n){return tt("month",{month:"long",year:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(t,n,1)))}function St(t){let n=tt(`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 tt("hour",{hour:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(2024,0,1,t)))}function Oe(t,n){let s=Number.isInteger(t),a=et(`money:${n}:${s}`,{style:"currency",currency:n,minimumFractionDigits:s?0:2,maximumFractionDigits:2});return a?a.format(t):`${t} ${n}`}var Ct=[{key:"visitors",slot:1,format:H},{key:"visits",slot:2,format:H},{key:"pageviews",slot:3,format:H},{key:"viewsPerVisit",slot:4,format:ms},{key:"bounceRate",slot:5,format:ne,lowerIsBetter:!0},{key:"visitDuration",slot:7,format:Ie}],Tt=t=>o(`metric.${t.key}`),gs=t=>o(`hint.${t.key}`),Mt=6,fs=3;function vs(t){return Ct.find(n=>n.key===t)}var la=0;function e(t,n,s,a,r,i){n||(n={});var c,l,d=n;if("ref"in d&&typeof t!="function")for(l in d={},n)l=="ref"?c=n[l]:d[l]=n[l];var p={type:t,props:d,key:s,ref:c,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--la,__i:-1,__u:0};return(r||i)&&(p.__source=r,p.__self=i),q.vnode&&q.vnode(p),p}var ws=t=>({key:t.key,slot:t.slot,label:Tt(t),format:t.format}),bs={top:18,right:14,bottom:30,left:52};function ys(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 Ke({points:t,previous:n,metrics:s,interval:a,timezone:r,shared:i,height:c=300}){let l=c,d=K(null),[p,m]=h(800),[f,b]=h(null);O(()=>{let C=d.current;if(!C)return;let T=new ResizeObserver(([N])=>N&&m(Math.max(280,N.contentRect.width)));return T.observe(C),()=>T.disconnect()},[]);let g=s.length===1||i?s[0]:void 0,_={...bs,left:g?bs.left:16},v=p-_.left-_.right,u=l-_.top-_.bottom,S=t.length>1?v/(t.length-1):0,E=C=>_.left+(t.length>1?C*S:v/2),y=n??[],R=C=>Math.max(0,...t.map(T=>T[C.key]??0),...y.map(T=>T[C.key]??0)),w=ys(Math.max(0,...s.map(R))),x=new Map(s.map(C=>[C.key,i?w:ys(R(C))])),P=(C,T)=>_.top+u-(T??0)/(x.get(C.key)??1)*u,D=_.top+u,F=Math.max(1,Math.ceil(t.length/Math.max(2,Math.floor(v/92)))),k=C=>{let T=C.currentTarget.getBoundingClientRect(),N=Math.round((C.clientX-T.left-_.left)/(S||1));b(t.length?Math.min(t.length-1,Math.max(0,N)):null)},A=f!==null?t[f]:void 0,$=[0,.25,.5,.75,1];return e("div",{class:"chart",ref:d,children:[e("svg",{width:p,height:l,role:"img","aria-label":o("chart.label",{metrics:s.map(C=>C.label).join(", ")}),onPointerMove:k,onPointerLeave:()=>b(null),children:[$.map(C=>e("line",{class:C===0?"gridline base":"gridline",x1:_.left,x2:p-_.right,y1:D-C*u,y2:D-C*u})),g?$.filter((C,T)=>T%2===0).map(C=>e("text",{class:"axis",x:_.left-10,y:D-C*u+4,"text-anchor":"end",children:g.format((x.get(g.key)??1)*C)})):null,t.map((C,T)=>T%F===0?e("text",{class:"axis",x:E(T),y:l-8,"text-anchor":T===0?"start":"middle",children:_t(C.start,a,r)}):null),s.map(C=>{if(y.length<2)return null;let T=xs(y.map((N,W)=>E(W)),y.map(N=>P(C,N[C.key])));return e("path",{class:`then s${C.slot}`,d:T})}),s.map(C=>{let T=xs(t.map((W,le)=>E(le)),t.map(W=>P(C,W[C.key]))),N=t.length?`${T}L${E(t.length-1).toFixed(1)},${D}L${E(0).toFixed(1)},${D}Z`:"";return e("g",{class:`series s${C.slot}`,children:[s.length<=fs&&(!i||C===s[0])?e("path",{class:"area",d:N}):null,e("path",{class:"line",d:T})]})}),A&&f!==null?e("g",{children:[e("line",{class:"cursor",x1:E(f),x2:E(f),y1:_.top,y2:D}),s.map(C=>e("circle",{class:`dot s${C.slot}`,cx:E(f),cy:P(C,A[C.key]),r:4.5}))]}):null]}),A&&f!==null?e("div",{class:E(f)>p/2?"tip left":"tip",style:{left:`${E(f)}px`},children:[e("span",{class:"tip-when",children:_t(A.start,a==="hour"?"hour":a==="month"?"month":"day",r)}),s.map(C=>{let T=f!==null?y[f]: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(A[C.key]??0)}),T?e("span",{class:"tip-then",children:C.format(T[C.key]??0)}):null]})}),f!==null&&y[f]?e("span",{class:"tip-then-when",children:o("chart.then",{when:_t(y[f].start,a==="hour"?"hour":a==="month"?"month":"day",r)})}):null]}):null]})}function xs(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 r=t[a-1]??t[a],i=n[a-1]??n[a],c=t[a],l=n[a],d=t[a+1],p=n[a+1],m=t[a+2]??d,f=n[a+2]??p,b=Math.min(l,p),g=Math.max(l,p),_=Math.min(g,Math.max(b,l+(p-i)/6)),v=Math.min(g,Math.max(b,p-(f-l)/6));s+=`C${(c+(d-r)/6).toFixed(2)},${_.toFixed(2)} ${(d-(m-c)/6).toFixed(2)},${v.toFixed(2)} ${d.toFixed(2)},${p.toFixed(2)}`}return s}var ca="input:not([type=hidden]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])",st=[];function da(t){return[...t.querySelectorAll(ca)].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 he(t){O(()=>{let n=document.activeElement instanceof HTMLElement?document.activeElement:null,s=t.current;if(!s)return;if(st.push(s),!s.contains(document.activeElement)){let r=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'])");r?r.focus():(s.tabIndex=-1,s.focus())}let a=r=>{if(r.key!=="Tab"||st[st.length-1]!==s)return;let i=da(s);if(!i.length){r.preventDefault();return}let c=i[0],l=i[i.length-1],d=document.activeElement;s.contains(d)?r.shiftKey&&(d===c||d===s)?(r.preventDefault(),l.focus()):!r.shiftKey&&d===l&&(r.preventDefault(),c.focus()):(r.preventDefault(),(r.shiftKey?l:c).focus())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a),st.splice(st.indexOf(s),1),n?.isConnected&&n.focus()}},[])}var pa=document.getElementById("app")?.dataset.world??"",ot=null;function ua(){return ot??(ot=fetch(pa).then(t=>{if(!t.ok)throw new Error(o("map.failed"));return t.json()})),ot.catch(()=>ot=null),ot}var ks=6;function on({view:t,onFilter:n,large:s}){let[a,r]=h(null),[i,c]=h([]),[l,d]=h(""),[p,m]=h(null),f=K(null);O(()=>{ua().then(r).catch(u=>d(u.message))},[]),O(()=>{let u=!0;return L.breakdown(t,"country",300).then(S=>u&&c(S.rows)).catch(S=>u&&d(S.message)),()=>{u=!1}},[t]);let b=new Map(i.map(u=>[u.value,u.visitors])),g=Math.max(0,...i.map(u=>u.visitors)),_=u=>u<=0||g===0?0:Math.max(1,Math.ceil(Math.sqrt(u/g)*ks));if(l)return e("p",{class:"empty",children:l});if(!a)return e("div",{class:s?"map large":"map"});let v=p?{id:p.id,n:b.get(p.id)??0}:null;return e("div",{class:s?"map large":"map",ref:f,children:[e("svg",{viewBox:`0 0 ${a.w} ${a.h}`,role:"img","aria-label":o("map.label",{top:i.slice(0,5).map(u=>`${ge(u.value)} ${H(u.visitors)}`).join(", ")}),onPointerLeave:()=>m(null),children:a.shapes.map(u=>{let S=b.get(u.id)??0;return e("path",{d:u.d,class:`land q${_(S)}${p?.id===u.id?" hot":""}${u.id&&S?" has":""}`,onPointerMove:E=>{let y=f.current?.getBoundingClientRect();y&&u.id&&m({id:u.id,x:E.clientX-y.left,y:E.clientY-y.top})},onClick:()=>u.id&&S&&n("country",u.id)})})}),v&&v.id?e("div",{class:"map-tip",style:{left:`${p.x}px`,top:`${p.y}px`},children:[e("strong",{children:[fe(v.id)," ",ge(v.id)]}),e("span",{children:v.n?Y("map.visitors",v.n,{n:H(v.n)}):o("map.none")})]}):null,e("div",{class:"map-scale","aria-hidden":"true",children:[e("span",{children:o("scale.fewer")}),Array.from({length:ks},(u,S)=>e("span",{class:`cell q${S+1}`})),e("span",{children:o("scale.more")})]})]})}function _s({view:t,onFilter:n,onClose:s}){let[a,r]=h([]),i=K(null);he(i),O(()=>{L.breakdown(t,"country",30).then(l=>r(l.rows)).catch(()=>r([]))},[t]),O(()=>{let l=d=>d.key==="Escape"&&s();return document.addEventListener("keydown",l),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",l),document.body.classList.remove("locked")}},[]);let c=a.reduce((l,d)=>l+d.visitors,0);return e("div",{class:"scrim center",onPointerDown:l=>l.target===l.currentTarget&&s(),children:e("div",{class:"map-sheet",role:"dialog","aria-modal":"true","aria-label":o("map.title"),ref:i,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(on,{view:t,large:!0,onFilter:(l,d)=>{n(l,d),s()}}),e("ol",{class:"map-list",children:a.map(l=>e("li",{children:e("button",{type:"button",onClick:()=>{n("country",l.value),s()},children:[e("span",{class:"map-list-name",children:[fe(l.value)," ",ge(l.value)]}),e("span",{class:"map-list-share",children:c?`${Math.round(l.visitors/c*100)}%`:""}),e("b",{children:H(l.visitors)})]})}))})]})]})})}var ma={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 M({name:t}){return e("svg",{class:"icon",viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:ma[t]})})}function V({icon:t,title:n,hint:s,size:a,children:r}){return e("div",{class:a?`empty-state ${a}`:"empty-state",children:[e("span",{class:"empty-mark","aria-hidden":"true",children:e(M,{name:t})}),e("p",{class:"empty-title",children:n}),s?e("p",{class:"empty-hint",children:s}):null,r]})}function Pt(t,n,s){return t.domain&&s.includes(t.domain)?`https://${t.domain}/${t.slug}`:`${n}/${t.slug}`}var ye=t=>t.replace(/^https?:\/\//,""),Ss=t=>pe(new Date(t.createdAt).toISOString().slice(0,10));function an({text:t,small:n}){let[s,a]=h(!1);return e("button",{type:"button",class:n?"copy inline":"copy",onClick:r=>{r.stopPropagation(),navigator.clipboard?.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},children:[e(M,{name:s?"check":"copy"}),o(s?"links.copied":"links.copy")]})}function se({title:t,sub:n,wide:s,onClose:a,children:r}){let i=K(null);return he(i),O(()=>{let c=l=>l.key==="Escape"&&a();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&&a(),children:e("div",{class:s?"list-sheet wide link-sheet":"list-sheet link-sheet small",role:"dialog","aria-modal":"true","aria-label":t,ref:i,children:[e("header",{class:"drawer-head",children:[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:a,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),r]})})}var Cs=t=>`runlight_link_domain:${t}`;function ha(t,n){try{let s=localStorage.getItem(Cs(t));return s!==null&&(s===""||n.includes(s))?s:null}catch{return null}}function ga(t,n){try{localStorage.setItem(Cs(t),n)}catch{}}function Ts({site:t,prefix:n,domains:s,link:a,onClose:r,onSaved:i}){let[c,l]=h(a?.url??""),[d,p]=h(a?.name??""),[m,f]=h(a?.slug??""),b=ha(t,s),[g,_]=h(a?.domain??b??""),v=K(!1);O(()=>{a||!s.length||b!==null||L.checkLinkDomain(t,s[0]).then(F=>{F.working&&!v.current&&_(s[0])}).catch(()=>{})},[]);let u=F=>{v.current=!0,_(F.target.value)},[S,E]=h(""),[y,R]=h(!1),[w,x]=h(null),P=K(null);O(()=>P.current?.focus(),[w]);let D=F=>{F.preventDefault(),R(!0),E("");let k={url:c.trim(),name:d.trim(),slug:m.trim(),domain:g};(a?L.updateLink(t,a.id,k):L.createLink(t,k)).then(A=>{i(),a?r():(ga(t,g),x(A.link))}).catch(A=>E(A.message)).finally(()=>R(!1))};if(w){let F=Pt(w,n,s);return e(se,{title:o("links.new"),onClose:r,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:F,target:"_blank",rel:"noopener",children:ye(F)}),e(an,{text:F})]}),e("p",{class:"field-hint",children:[o("links.destination")," ",ye(w.url)]}),e("div",{class:"settings-actions",children:[e("button",{type:"button",class:"ghost",onClick:()=>{x(null),l(""),p(""),f("")},children:[e(M,{name:"plus"}),o("links.another")]}),e("button",{type:"button",class:"solid",onClick:r,children:o("common.close")})]})]})})}return e(se,{title:o(a?"links.edit":"links.new"),onClose:r,children:e("form",{class:"sheet-body link-form",onSubmit:D,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("links.url")}),e("input",{ref:P,class:"value",type:"url",required:!0,placeholder:o("links.urlPlaceholder"),value:c,onInput:F=>l(F.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:F=>p(F.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:g,onChange:u,children:[s.map(F=>e("option",{value:F,children:[F,"/"]})),a?.domain&&!s.includes(a.domain)?e("option",{value:a.domain,children:o("links.removedDomain",{domain:a.domain})}):null,e("option",{value:"",children:[ye(n),"/"]})]}):a?.domain?e("select",{class:"value","aria-label":o("links.domain"),value:g,onChange:u,children:[e("option",{value:a.domain,children:o("links.removedDomain",{domain:a.domain})}),e("option",{value:"",children:[ye(n),"/"]})]}):e("span",{class:"slug-prefix",children:[ye(n),"/"]}),e("input",{class:"value",type:"text",maxLength:100,pattern:"[A-Za-z0-9][A-Za-z0-9_\\-]*",placeholder:o("links.slugPlaceholder"),value:m,onInput:F=>f(F.target.value)})]})]}),e("div",{class:"settings-actions",children:[S?e("span",{class:"settings-error",children:S}):null,e("button",{type:"button",class:"ghost",onClick:r,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",disabled:y||!c.trim(),children:[e(M,{name:a?"save":"plus"}),o(a?"links.save":"links.create")]})]})]})})}function Et({title:t,rows:n,dimension:s}){let a=Math.max(1,...n.map(r=>Number(r.events??0)));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(V,{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:`${Number(r.events??0)/a*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:s==="country"?`${fe(r.value)} ${ge(r.value)}`:ae(s,r.value)})}),e("span",{class:"num",children:H(Number(r.events??0))})]}))})]})}function Ms({view:t,id:n,prefix:s,domains:a,onClose:r}){let[i,c]=h(null),[l,d]=h("");O(()=>{L.link(t,n).then(c).catch(f=>d(f.message))},[t,n]);let p=i?Pt(i.link,s,a):"",m=[{key:"clicks",slot:1,label:o("links.clicksLabel"),format:H},{key:"visitors",slot:2,label:o("metric.visitors"),format:H}];return e(se,{title:i?.link.name??o("common.loading"),sub:i?Y("links.total",i.clicks,{n:H(i.clicks)}):void 0,wide:!0,onClose:r,children:e("div",{class:"sheet-body",children:[l?e("p",{class:"failure",children:l}):null,i?e(U,{children:[e("div",{class:"link-head",children:[e("div",{class:"made",children:[e("a",{href:p,target:"_blank",rel:"noopener",children:ye(p)}),e(an,{text:p})]}),e("p",{class:"field-hint",children:[o("links.destination")," ",e("a",{href:i.link.url,target:"_blank",rel:"noopener",children:ye(i.link.url)}),e("span",{class:"link-date-inline",children:o("links.createdOn",{date:Ss(i.link)})})]})]}),e("h3",{class:"mini-title",children:o("links.clicksOverTime")}),e("div",{class:"link-chart",children:e(Ke,{points:i.series,metrics:m,interval:i.range.interval,timezone:i.range.timezone,shared:!0,height:240})}),e("div",{class:"mini-grid",children:[e(Et,{title:"links.sources",rows:i.sources,dimension:"source"}),e(Et,{title:"links.countries",rows:i.countries,dimension:"country"}),e(Et,{title:"links.devices",rows:i.devices,dimension:"device"}),e(Et,{title:"links.browsers",rows:i.browsers,dimension:"browser"})]})]}):null]})})}function at(t){let n=[],s=[],a="",r=!1;for(let d=0;d<t.length;d++){let p=t[d];r?p==='"'&&t[d+1]==='"'?(a+='"',d++):p==='"'?r=!1:a+=p:p==='"'?r=!0:p===","?(s.push(a),a=""):p===`
|
|
1
|
+
var Go=Object.defineProperty;var Wo=(t,n,s)=>n in t?Go(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var Ft=(t,n,s)=>Wo(t,typeof n!="symbol"?n+"":n,s);var V,$n,Yo,Me,Rn,gt,Hn,ut,Ye,On,zt,Nt,Ut,Zo,ft={},vt=[],Jo=/^m(i|n|o|s|text|space)$/,jt=Array.isArray,Fn=vt.slice,He=Object.assign;function bt(t){t&&t.parentNode&&t.remove()}function mt(t,n,s,a,r){var i={type:t,props:n,key:s,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r||++$n,__i:-1,__u:0};return!r&&V.vnode&&V.vnode(i),i}function U(t){return t.children}function ht(t,n){this.props=t,this.context=n,this.__g=0}function Ee(t,n){if(n==null)return t.__?Ee(t.__,t.__i+1):null;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:Ee(t)}function Nn(t){if((t=t.__)&&t.__c&&!t.props.__P)return t.__e=null,t.__k.some(function(n){return n&&(t.__e=n.__e)}),Nn(t)}function Ln(t){(8&t.__g||!(t.__g|=8)||!Me.push(t)||gt++)&&Rn==V.debounceRendering||((Rn=V.debounceRendering)||queueMicrotask)(Xo)}function Xo(){var t,n,s,a,r,i,c,l,d;try{for(n=1;Me.length;)Me.length>n&&Me.sort(Hn),t=Me.shift(),n=Me.length,8&t.__g&&(a=void 0,r=void 0,i=(r=(s=t).__v).__e,c=[],l=[],(d=s.__P)&&((a=He({constructor:void 0},r)).__v=r.__v+1,V.vnode&&V.vnode(a),Kt(d,a,r,s.__n,d.namespaceURI,32&r.__u?[i]:null,c,i||Ee(r),32&r.__u,l),a.__v=r.__v,a.__.__k[a.__i]=a,Kn(c,a,l),r.__=r.__e=null,a.__e!=i&&Nn(a)))}finally{Me.length=gt=0}}function Un(t,n,s,a,r,i,c,l,d,p,m){var f,b,g,k,v,u,_=a.__k||vt,T=n.length;for(d=Qo(s,n,_,d,T),f=0;f<T;f++)(g=s.__k[f])!=null&&(b=~g.__i&&_[g.__i]||ft,g.__i=f,u=Kt(t,g,b,r,i,c,l,d,p,m),k=g.__e,g.ref&&(b.ref!=g.ref||8&b.__u)&&(b.ref!=g.ref&&b.ref&&Bt(b.ref,null,g),m.push(g.ref,g.__c||k,g)),v=v||k,4&g.__u?(d=zn(g,d,t,!b.__v),b.__e&&(b.__e=null)):typeof g.type=="function"&&u!==void 0?d=u:k&&(d=k.nextSibling),g.__u&=-7);return s.__e=v,d}function Qo(t,n,s,a,r){var i,c,l,d,p,m,f,b,g,k,v=s.length,u=v,_=0,T=!1,y=t.__k=Array(r);for(i=0;i<r;i++)(c=n[i])!=null&&typeof c!="boolean"&&typeof c!="function"?(typeof c!="object"||c.constructor==String?c=y[i]=mt(null,c):jt(c)?c=y[i]=mt(U,{children:c}):c.constructor===void 0&&c.__b?c=y[i]=mt(c.type,c.props,c.key,c.ref,c.__v):y[i]=c,d=i+_,c.__=t,c.__b=t.__b+1,l=null,~(p=c.__i=ea(c,s,d,u))&&(u--,(l=s[p])&&(l.__u|=2)),l&&l.__v?(c.__u|=2,p==d-1?_--:p==d+1?_++:p!=d&&(p>d?_--:_++,T=!0)):(~p||(r>v?_--:r<v&&_++),typeof c.type!="function"&&(c.__u|=4))):y[i]=null;if(T){for(m=[],f=[],i=0;i<r;i++)if((c=y[i])&&2&c.__u){for(b=0,g=m.length;b<g;)m[k=b+g>>1]<c.__i?b=k+1:g=k;m[b]=c.__i,f[i]=b+1}for(_=m.length;i--;)f[i]&&(f[i]==_?_--:y[i].__u|=4)}if(u)for(i=0;i<v;i++)!(l=s[i])||2&l.__u||(l.__e==a&&(a=Ee(l)),qt(l,l));return a}function zn(t,n,s,a){var r,i;if(typeof t.type=="function"){if(t.props.__P)return n;if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&(r[i].__=t,n=zn(r[i],n,s,!1));return n}for(n&&!n.parentNode&&(n=Ee(t))&&!n.parentNode&&(n=null),t.__e!=n&&(!a&&s.moveBefore&&t.__e.parentNode?s.moveBefore(t.__e,n):s.insertBefore(t.__e,n||null)),n=t.__e;(n=n&&n.nextSibling)&&n.nodeType==8;);return n}function ea(t,n,s,a){var r,i,c,l=t.key,d=t.type,p=n[s],m=p&&!(2&p.__u);if(p===null&&l==null||m&&l==p.key&&d==p.type)return s;if(a>(m?1:0)){for(r=s-1,i=s+1;r>=0||i<n.length;)if((p=n[c=r>=0?r--:i++])&&!(2&p.__u)&&l==p.key&&d==p.type)return c}return-1}function In(t,n,s){s==null&&(s=""),n[0]=="-"?t.setProperty(n,s):t[n]=s}function pt(t,n,s,a,r){var i;e: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||In(t.style,n,"");if(s)for(n in s)a&&s[n]==a[n]||In(t.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")i=n!=(n=n.replace(On,"$1")),(n=n.slice(2))[0]<"a"&&(n=n.toLowerCase()),(t.__e||(t.__e={}))[n+i]=s,s?a?s[Ye]=a[Ye]:(s[Ye]=zt,t.addEventListener(n,i?Ut:Nt,i)):t.removeEventListener(n,i?Ut:Nt,i);else{if(r=="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{t[n]=s??"";break e}catch{}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?t.removeAttribute(n):t.setAttribute(n,n=="popover"&&s==1?"":s))}}function Dn(t){return function(n){if(this.__e){var s=this.__e[n.type+t];if(n[ut]==null)n[ut]=zt++;else if(n[ut]<s[Ye])return;return s(V.event?V.event(n):n)}}}function Kt(t,n,s,a,r,i,c,l,d,p){var m,f,b,g,k,v,u,_,T,y,P,w,x,A,$,N,S,E,H,R,M=n.type;if(n.constructor!==void 0)return null;if(128&s.__u&&(d=32&s.__u,m=s.__c.__z)){if(n.__u|=d,f=i=[],m.nodeType==8)for(b=1,g=m.nextSibling;g;g=g.nextSibling){if(g.nodeType==8){if(g.data.startsWith("$s"))b++;else if(g.data.startsWith("/$s")&&!--b)break}i.push(g)}else i.push(m);l=i[0]}(m=V.__b)&&m(n);e:if(typeof M=="function"){k=c.length;try{if(y=n.props,P=(m=M.prototype)&&m.render,w=(m=M.contextType)&&a[m.__c],x=m?w?w.props.value:m.__:a,s.__c?2&(v=n.__c=s.__c).__g&&(v.__g|=1):(P?n.__c=v=new M(y,x):(n.__c=v=new ht(y,x),v.constructor=M,v.render=na),w&&w.sub(v),v.state||(v.state={}),v.__n=a,v.__g|=8,v.__h=[],v.__k=[]),P&&(v.__s||(v.__s=v.state),M.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=He({},v.__s)),He(v.__s,M.getDerivedStateFromProps(y,v.__s)))),u=v.props,_=v.state,v.__v=n,s.__c){if(P&&!M.getDerivedStateFromProps&&y!==u&&v.componentWillReceiveProps&&v.componentWillReceiveProps(y,x),n.__v==s.__v&&!(8&v.__g)||!(4&v.__g)&&v.shouldComponentUpdate&&v.shouldComponentUpdate(y,v.__s,x)===!1){n.__v!=s.__v&&(v.props=y,v.state=v.__s,v.__g&=-9),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(I){I&&(I.__=n)}),vt.push.apply(v.__h,v.__k),v.__k=[],v.__h.length&&c.push(v),l=Ee(s);break e}v.componentWillUpdate&&v.componentWillUpdate(y,v.__s,x),P&&v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(u,_,T)})}else P&&!M.getDerivedStateFromProps&&v.componentWillMount&&v.componentWillMount(),P&&v.componentDidMount&&v.__h.push(v.componentDidMount);if(v.context=x,v.props=y,v.__P=t,v.__g&=-5,A=V.__r,$=0,P)v.state=v.__s,v.__g&=-9,A&&A(n),m=v.render(v.props,v.state,v.context),vt.push.apply(v.__h,v.__k),v.__k=[];else do v.__g&=-9,A&&A(n),m=v.render(v.props,v.state,v.context),v.state=v.__s;while(8&v.__g&&++$<25);v.state=v.__s,v.getChildContext&&(a=He({},a,v.getChildContext())),P&&s.__c&&v.getSnapshotBeforeUpdate&&(T=v.getSnapshotBeforeUpdate(u,_)),N=m&&m.type===U&&m.key==null?m.props.children:m,y.__P&&(m=l,r=(t=y.__P).namespaceURI,d=i=null,s.props&&s.props.__P!=t&&(s.__k.some(function(I){I&&qt(I,I)}),s.__k=null),l=s.__k?Ee(s,0):null),l=Un(t,jt(N)?N:[N],n,s,a,r,i,c,l,d,p),y.__P&&(n.__e=null,l=m),n.__u&=-161,128&s.__u&&(v.__z=null),f&&f.some(bt),v.__h.length&&c.push(v),1&v.__g&&(v.__g&=-4)}catch(I){if(c.length=k,n.__v=null,d||i)if(I.then){if(S=0,n.__u|=d?160:128,i){for(H=0;H<i.length;H++)if(R=i[H])if(R.nodeType==8){if(i[H]=null,R.data.startsWith("$s"))S++||(E=R);else if(R.data.startsWith("/$s")&&!--S){l=R;break}}else S&&(i[H]=null)}if(!E){for(;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i&&(i[i.indexOf(l)]=null),E=l}n.__c.__z||(n.__c.__z=E),n.__e=l}else i&&i.some(bt);else n.__e=s.__e;n.__k||(n.__k=s.__k||[]),I.then||jn(n),V.__e(I,n,s)}}else l=n.__e=ta(s.__e,n,s,a,r,i,c,d,p,t);return(m=V.diffed)&&m(n),128&n.__u?void 0:l}function jn(t){t&&(t.__c&&(t.__c.__g|=4),t.__k&&t.__k.some(jn))}function Kn(t,n,s){for(var a=0;a<s.length;)Bt(s[a++],s[a++],s[a++]);V.__c&&V.__c(n,t),t.some(function(r){try{t=r.__h,r.__h=[],t.some(function(i){i.call(r)})}catch(i){V.__e(i,r.__v)}})}function ta(t,n,s,a,r,i,c,l,d,p){var m,f,b,g,k,v,u,_,T,y=s.props||ft,P=n.props,w=n.type;if(w=="svg"?r="http://www.w3.org/2000/svg":w=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i){for(m=0;m<i.length;m++)if((k=i[m])&&(w?k.localName==w:k.nodeType==3)){t=k,i[m]=null;break}}if(!t){if(_=p.ownerDocument||document,!w)return _.createTextNode(P);t=_.createElementNS(r,w,P.is&&P),l&&(V.__m&&V.__m(n,i),l=!1),i=null}if(w){if(p=w=="template"?t.content:t,i=w=="textarea"&&P.defaultValue!=null?null:i&&Fn.call(p.childNodes),!l&&i)for(y={},m=0;m<t.attributes.length;m++)y[(k=t.attributes[m]).name]=k.value;for(m in y)k=y[m],m=="dangerouslySetInnerHTML"?b=k:m=="children"||m in P||m=="value"&&"defaultValue"in P||m=="checked"&&"defaultChecked"in P||pt(t,m,null,k,r);for(m in T=1&s.__u,P)k=P[m],m=="children"?g=k:m=="dangerouslySetInnerHTML"?f=k:m=="value"?v=k:m=="checked"?u=k:l&&typeof k!="function"||!(y[m]!==k||T&&k!=null)||pt(t,m,k,y[m],r);f?(l||b&&(f.__html==b.__html||f.__html==t.innerHTML)||(t.innerHTML=f.__html),n.__k=[]):(b&&(t.textContent=""),(w=="foreignObject"||r=="http://www.w3.org/1998/Math/MathML"&&Jo.test(w))&&(r="http://www.w3.org/1999/xhtml"),Un(p,jt(g)?g:[g],n,s,a,r,i,c,i?i[0]:s.__k&&Ee(s,0),l,d),i&&i.some(bt)),l&&w!="textarea"||(m="value",w=="progress"&&v==null?t.removeAttribute(m):v==null||v===t[m]&&(w!="progress"||v)||pt(t,m,v,y[m],r),m="checked",u!=null&&u!=t[m]&&pt(t,m,u,y[m],r))}else y===P||l&&t.data==P||(t.data=P);return t}function Bt(t,n,s){try{typeof t=="function"?(typeof t.__u=="function"&&t.__u(),(typeof t.__u!="function"||n)&&(t.__u=t(n))):t.current=n}catch(a){V.__e(a,s)}}function qt(t,n,s){var a,r;if(V.unmount&&V.unmount(t),!(a=t.ref)||a.current&&a.current!=t.__e||Bt(a,null,n),a=t.__c){if(a.componentWillUnmount)try{a.componentWillUnmount()}catch(i){V.__e(i,n)}a.__P=a.__n=null}if(a=t.__k)for(r=0;r<a.length;r++)a[r]&&qt(a[r],n,typeof t.type!="function"||s&&!t.props.__P);(a=t.__e)&&(s||bt(a),a.__e&&(a.__e=null)),t.__e=t.__c=t.__=null}function na(t,n,s){return this.constructor(t,s)}function Bn(t,n){var s,a,r,i;V.__&&V.__(t,n),n.nodeType==9&&(n=n.documentElement),a=(s=t&&32&t.__u)?null:n.__k,n.__k=mt(U,{children:[t]}),r=[],i=[],Kt(n,n.__k,a||ft,ft,n.namespaceURI,a?null:n.firstChild?Fn.call(n.childNodes):null,r,a?a.__e:n.firstChild,s,i),Kn(r,n.__k,i),n.__k.props.children=null}V={__e:function(t,n,s,a){for(var r,i,c;n=n.__;)if((r=n.__c)&&!(1&r.__g)){r.__g|=4;try{if((i=r.constructor)&&i.getDerivedStateFromError&&(r.setState(i.getDerivedStateFromError(t)),c=8&r.__g),r.componentDidCatch&&(r.componentDidCatch(t,a||{}),c=8&r.__g),c)return void(r.__g|=2)}catch(l){t=l,c=0}}throw gt=0,t}},$n=0,Yo=function(t){return t!=null&&t.constructor===void 0},ht.prototype.setState=function(t,n){var s=this.__s;s&&s!=this.state||(s=this.__s=He({},this.state)),typeof t=="function"&&(t=t(He({},s),this.props)),t&&(He(s,t),this.__v&&(n&&this.__k.push(n),Ln(this)))},ht.prototype.forceUpdate=function(t){this.__v&&(this.__g|=4,t&&this.__h.push(t),Ln(this))},ht.prototype.render=U,Me=[],gt=0,Hn=function(t,n){return t.__v.__b-n.__v.__b},ut=Symbol(),Ye=Symbol(),On=/(PointerCapture)$|Capture$/i,zt=0,Nt=Dn(!1),Ut=Dn(!0),Zo=0;var Ue,ee,Vt,qn,Gt=Object.is,Je=0,es=[],Wt=[],X=V,Vn=X.__b,Gn=X.__r,Wn=X.diffed,Yn=X.__c,Zn=X.unmount,Jn=X.__;function yt(t,n){X.__h&&X.__h(ee,t,Je||n),Je=0;var s=ee.__H||(ee.__H={__:[],__h:[]});return t>=s.__.length&&s.__.push({}),s.__[t]}function h(t){return Je=1,sa(ns,t)}function sa(t,n,s){var a=yt(Ue++,2);if(a.t=t,!a.__c&&(a.__=[s?s(n):ns(void 0,n),function(i){var c=a.__N?a.__N[0]:a.__[0],l=a.t(c,i);Gt(c,l)||(a.__N=[l,a.__[1]],a.__c.setState({}))}],a.__c=ee,!ee.__f)){ee.__f=!0;var r=ee.shouldComponentUpdate;ee.shouldComponentUpdate=function(i,c,l){var d=this.__H;if(!d)return!0;var p=!1,m=this.props!=i;if(d.__.some(function(b){b.__N&&(p=!0,Gt(b.__[0],b.__N[0])||(m=!0))}),r){var f=r.call(this,i,c,l);return p?f||m:f}return!p||m}}return a.__}function F(t,n){var s=yt(Ue++,3);!X.__s&&Jt(s.__H,n)&&(s.__P=!0,s.__=t,s.u=n,ee.__H.__h.push(s))}function ts(t,n){var s=yt(Ue++,4);!X.__s&&Jt(s.__H,n)&&(s.__P=!1,s.__=t,s.u=n,ee.__h.push(s))}function K(t){return Je=5,Ae(function(){return{current:t}},[])}function Ae(t,n){var s=yt(Ue++,7);return Jt(s.__H,n)&&(s.__=t(),s.__H=n),s.__}function Zt(t,n){return Je=8,Ae(function(){return t},n)}function oa(){var t;do{for(;t=Wt.shift();)try{Ze(t)}catch(s){X.__e(s,{__:(t=t.__P)&&t.__v})}for(;t=es.shift();){var n=t.__H;if(t.__P&&n)try{n.__h.some(Ze),n.__h.some(Yt),n.__h=[]}catch(s){n.__h=[],X.__e(s,t.__v)}}}while(Wt.length)}X.__b=function(t){ee=null,Vn&&Vn(t)},X.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),Jn&&Jn(t,n)},X.__r=function(t){Gn&&Gn(t),Ue=0;var n=(ee=t.__c).__H;n&&(Vt==ee?ee.__h=[]:(n.__h.some(Ze),n.__h.some(Yt),Ue=0),n.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})),Vt=ee},X.diffed=function(t){Wn&&Wn(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&Qn(es.push(n)),n.__H.__.some(function(s){s.u&&(s.__H=s.u)})),Vt=ee=null},X.__c=function(t,n){n.some(function(s){try{s.__h.some(Ze),s.__h=s.__h.filter(function(a){return!a.__||Yt(a)})}catch(a){n.some(function(r){r.__h&&(r.__h=[])}),n=[],X.__e(a,s.__v)}}),Yn&&Yn(t,n)},X.unmount=function(t){Zn&&Zn(t);var n,s,a=t.__c;a&&a.__H&&(a.__H.__.some(function(r){try{if(r.__P&&r.__c){if(s===void 0){for(s=t.__;s&&(!s.__c||!s.__c.__P);)s=s.__;s=s&&s.__c}r.__P=s,Qn(Wt.push(r))}else Ze(r)}catch(i){n=i}}),a.__H=void 0,n&&X.__e(n,a.__v))};var Xn=typeof requestAnimationFrame=="function";function aa(t){var n,s=function(){clearTimeout(a),Xn&&cancelAnimationFrame(n),setTimeout(t)},a=setTimeout(s,35);Xn&&(n=requestAnimationFrame(s))}function Qn(t){t!=1&&qn==X.requestAnimationFrame||((qn=X.requestAnimationFrame)||aa)(oa)}function Ze(t){var n=ee,s=t.__c;typeof s=="function"&&(t.__c=void 0,s()),ee=n}function Yt(t){var n=ee;t.__c=t.__(),ee=n}function Jt(t,n){return!t||t.length!=n.length||n.some(function(s,a){return!Gt(s,t[a])})}function ns(t,n){return typeof n=="function"?n(t):n}var we={"app.site":"Site","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.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 will show up here","goals.emptyHint":"A goal counts what matters to you, like a signup or a click on a button. An event or page goal you add counts past visits too, and a click goal counts from when you add it.","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.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 any CSS selector, or use Pick on my site, which opens your site so you can click the element and then Use this.","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.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":"API and AI","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","settings.people":"People","people.intro":"Everyone here can sign in to this server. Admins can change everything the owner can and manage people, though nobody can remove the owner. Members change the settings of every site, and viewers read every site's stats without changing anything. Invite a coworker and they choose their own password.","people.you":"you","people.role":"Role","people.owner":"Owner","people.viewer":"Viewer","people.roles":"Members can't manage people, set up the mail service or the assistant, or delete a site. Only the owner can hand ownership to an admin.","people.emailPlaceholder":"Their email address","pluginKey.title":"Key for CMS plugins","pluginKey.intro":"The WordPress, Drupal, and Craft plugins use this key to report AI agents reading this site's pages. It can only report for this site and cannot read anything. Replacing it stops the old key at once.","pluginKey.replace":"Replace 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, API and AI. 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","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":"It answers from {site}'s numbers, which it reads the moment you ask.","assistant.clear":"New chat","assistant.intro":"Ask about visitors, sources, pages, goals, or anything else this dashboard shows.","assistant.ask1":"How did this period compare with the one before?","assistant.ask2":"Where are most visitors coming from?","assistant.ask3":"Which pages keep people reading longest?","assistant.ask4":"Are AI assistants sending visitors here?","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":"Each question goes to that service with the numbers the assistant reads to answer it. Runlight keeps nothing about individual visitors, so nothing personal is sent. The assistant only reads, through the same tools as the MCP server, so it can never change anything.","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.","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.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_service":"Pick a mail service.","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_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.","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.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.","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.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_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":"Assistants such as ChatGPT and Claude are listed when they fetch your pages.","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","embedKey.title":"Key for the dashboard in your CMS","embedKey.intro":"With this key in their settings, the WordPress, Drupal, and Craft plugins show this site's dashboard inside your admin pages. It opens the read-only view a share link shows and cannot read anything itself. Delete it in Settings, API and AI to stop it at once.","embedKey.make":"Make a key","embedKey.another":"Make another key","embedKey.name":"Dashboard in a CMS","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 key for the dashboard in a CMS is for one site. Pick the site."};var Pe=[["en","English"],["fr","Fran\xE7ais"],["es","Espa\xF1ol"],["de","Deutsch"],["pt","Portugu\xEAs"]],ss="runlight_language",ia=(()=>{try{return JSON.parse(document.getElementById("app")?.dataset.locales??"{}")}catch{return{}}})(),os="en",ze=we,as=new Intl.PluralRules("en");function Z(){return os}function rs(){let t=null;try{t=localStorage.getItem(ss)}catch{}let n=[t,...navigator.languages??[navigator.language]].filter(Boolean);for(let s of n){let a=s.toLowerCase().split("-")[0];if(Pe.some(([r])=>r===a))return a}return"en"}async function xt(t,n=!1){if(t==="en")ze=we;else{let s=ia[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}`);ze={...we,...await a.json()}}if(os=t,as=new Intl.PluralRules(t),document.documentElement.lang=t,n)try{localStorage.setItem(ss,t)}catch{}}function Xt(t,n){return t.replace(/\{(\w+)\}/g,(s,a)=>a in n?String(n[a]):s)}function is(t){return Object.prototype.hasOwnProperty.call(we,t)}function o(t,n={}){return Xt(ze[t]??we[t]??t,n)}function Y(t,n,s={}){let a=as.select(n),r=ze,i=r[`${t}_${a}`]??r[`${t}_other`]??we[`${t}_other`]??t;return Xt(i,{n,...s})}function be(t,n={}){let s=`error.${t}`,a={...we,...ze},r=a[s];if(r===void 0)return null;let i=n.field&&a[`mail.field.${n.field}`];return Xt(r,i?{...n,field:i}:n)}function de(t,n){let s=ze[t]??we[t]??t,a=[],r=0;for(let i of s.matchAll(/\{(\w+)\}/g))a.push(s.slice(r,i.index)),a.push(n[i[1]]??i[0]),r=(i.index??0)+i[0].length;return a.push(s.slice(r)),a}var me=document.getElementById("app")?.dataset.base??"",Xe=document.getElementById("app")?.dataset.share??"",Le=document.getElementById("app")?.dataset.embedOrigin??"",ls=document.getElementById("app")?.dataset.embed??"",cs=!!ls,Oe=!!(Xe||Le),ds=()=>Xe?{"x-runlight-share":Xe}:Le?{"x-runlight-embed":ls}:void 0,Qt=new Set;function ps(t){return Qt.add(t),()=>Qt.delete(t)}function us(t){if(!Le||t.status!==401)return!1;for(let n of Qt)n();return!0}var en=document.getElementById("app")?.dataset.signOut??"",tn=document.getElementById("app")?.dataset.signIn??"",Qe=document.getElementById("app")?.dataset.accounts!==void 0,ms=document.getElementById("app")?.dataset.geoCredit!==void 0,oe={managed:!1},Re=class extends Error{constructor(s,a,r=""){super(a);Ft(this,"status",s);Ft(this,"code",r)}};async function wt(t){let n=await t.json().catch(()=>null);return new Re(t.status,n?.code&&be(n.code,n.params)||n?.error||t.statusText,n?.code??"")}async function J(t,n){let s=await fetch(`${me}/api/${t}?${n}`,{credentials:"same-origin",headers:ds()});if(!s.ok)throw us(s),await wt(s);return s.json()}async function je(t,n){let s=await fetch(`${me}/api/${t}?${n}`,{credentials:"same-origin",headers:ds()});if(!s.ok)throw us(s),await wt(s);let a=/filename="([^"]+)"/.exec(s.headers.get("content-disposition")??"")?.[1]??"runlight-export",r=document.createElement("a");r.href=URL.createObjectURL(await s.blob()),r.download=a,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e4)}function le(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 j(t,n,s){let a=await fetch(`${me}/api/${n}`,{method:t,credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!a.ok)throw await wt(a);return a.json()}var ue=async t=>{let n=await fetch(`${me}/api/${t}`,{method:"DELETE",credentials:"same-origin"});if(!n.ok)throw await wt(n)},Q=t=>t?`?site=${encodeURIComponent(t)}`:"",L={links:t=>J("links",le(t)),link:(t,n)=>J(`links/${n}`,le(t)),createLink:(t,n)=>j("POST",`links${Q(t)}`,n),updateLink:(t,n,s)=>j("PATCH",`links/${n}${Q(t)}`,s),deleteLink:(t,n)=>ue(`links/${n}${Q(t)}`),importLinks:(t,n)=>j("POST",`links/import${Q(t)}`,{rows:n}),importStep:(t,n,s,a,r)=>j("POST",`links/import/${n}${Q(t)}`,{credentials:s,cursor:a,done:r}),observeKey:t=>J("observe-key",new URLSearchParams({site:t})),newObserveKey:t=>j("POST",`observe-key/new${Q(t)}`,{}),funnels:t=>J("funnels",le(t)),saveFunnel:(t,n,s)=>j(n?"PATCH":"POST",`funnels${n?`/${n}`:""}${Q(t)}`,s),deleteFunnel:(t,n)=>ue(`funnels/${n}${Q(t)}`),account:()=>J("account",new URLSearchParams),changePassword:(t,n)=>j("POST","account/password",{current:t,next:n}),twoFactorStart:t=>j("POST","account/2fa/start",{password:t}),twoFactorConfirm:t=>j("POST","account/2fa/confirm",{code:t}),twoFactorRecovery:t=>j("POST","account/2fa/recovery",{password:t}),twoFactorDisable:t=>j("POST","account/2fa/disable",{password:t}),pickTicket:(t,n)=>j("POST",`pick${Q(t)}`,{origin:n}),resetTwoFactor:(t,n)=>j("DELETE",`people/${t}/2fa`,{password:n}),people:()=>J("people",new URLSearchParams),addPerson:(t,n)=>j("POST","people",{email:t,role:n}),resendInvite:t=>j("POST",`invites/${t}/resend`,{}),cancelInvite:t=>ue(`invites/${t}`),handOver:(t,n)=>j("POST",`people/${t}/owner`,{password:n}),setRole:(t,n)=>j("PATCH",`people/${t}`,{role:n}),removePerson:t=>ue(`people/${t}`),eventProps:(t,n,s)=>{let a=le(t);return a.set("event",n),s&&a.set("key",s),J("event-props",a)},umamiWebsites:t=>j("POST","import/umami/websites",{credentials:t}),importVisits:(t,n,s,a)=>j("POST",`import/umami/visits${Q(t)}`,{credentials:n,website:s,cursor:a}),importCsvVisits:(t,n,s)=>j("POST",`import/csv/visits${Q(t)}`,{rows:n,...s?{secret:s}:{}}),goals:t=>J("goals",le(t)),goal:(t,n)=>J(`goals/${n}`,le(t)),createGoal:(t,n)=>j("POST",`goals${Q(t)}`,n),updateGoal:(t,n,s)=>j("PATCH",`goals/${n}${Q(t)}`,s),deleteGoal:(t,n)=>ue(`goals/${n}${Q(t)}`),mail:t=>J("mail",new URLSearchParams(t?{site:t}:{})),connect:(t,n)=>j("POST","sites/connect",{url:t,...n?{site:n}:{}}),assistant:()=>J("assistant",new URLSearchParams),saveAssistant:t=>j("PUT","assistant",t),removeAssistant:()=>ue("assistant"),saveAssistantLimit:t=>j("PUT","assistant/limits",{viewerDaily:t}),assistantModels:t=>j("POST","assistant/models",t),ask:(t,n,s,a)=>j("POST","assistant/chat",{site:t,messages:n,view:s,language:a}),saveMail:t=>j("PUT","mail",t),removeMail:()=>ue("mail"),testMail:(t,n)=>j("POST","mail/test",{to:t,lang:n}),reports:t=>J("reports",new URLSearchParams(t?{site:t}:{})),addReport:(t,n)=>j("POST",`reports${Q(t)}`,n),deleteReport:(t,n)=>ue(`reports/${n}${Q(t)}`),sendReport:(t,n)=>j("POST",`reports/${n}/send${Q(t)}`,{}),tokens:()=>J("tokens",new URLSearchParams),createToken:(t,n,s)=>j("POST","tokens",{name:t,site:n,...s?{scope:s}:{}}),deleteToken:t=>ue(`tokens/${t}`),shares:t=>J("shares",new URLSearchParams(t?{site:t}:{})),createShare:(t,n)=>j("POST",`shares${Q(t)}`,{name:n}),renameShare:(t,n,s)=>j("PATCH",`shares/${n}${Q(t)}`,{name:s}),deleteShare:(t,n)=>ue(`shares/${n}${Q(t)}`),linkDomains:t=>J("link-domains",new URLSearchParams(t?{site:t}:{})),addLinkDomain:(t,n)=>j("POST",`link-domains${Q(t)}`,{domain:n}),checkLinkDomain:(t,n)=>J(`link-domains/${encodeURIComponent(n)}/check`,new URLSearchParams(t?{site:t}:{})),removeLinkDomain:(t,n)=>ue(`link-domains/${encodeURIComponent(n)}${Q(t)}`),updateSite:(t,n)=>j("PATCH",`sites/${encodeURIComponent(t)}`,n),sites:()=>J("sites",new URLSearchParams).then(t=>(oe.managed=!!t.managed,t)),addSite:t=>j("POST","sites",t),deleteSite:t=>ue(`sites/${encodeURIComponent(t)}`),stats:t=>J("stats",le(t)),series:t=>J("series",le(t)),breakdown:(t,n,s)=>{let a=le(t);return a.set("dimension",n),a.set("limit",String(s)),J("breakdown",a)},rhythm:t=>J("rhythm",le(t)),journeys:(t,n)=>{let s=le(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}`),J("journeys",s)},realtime:t=>J("realtime",new URLSearchParams(t?{site:t}:{}))};var kt=new Map;function nn(t,n){let s=`${Z()}|${t}`;if(!kt.has(s))try{kt.set(s,n())}catch{kt.set(s,null)}return kt.get(s)}var et=(t,n)=>nn(t,()=>new Intl.NumberFormat(Z(),n)),tt=(t,n)=>nn(t,()=>new Intl.DateTimeFormat(Z(),n));function Ke(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?ke(t):et("compact",{notation:"compact",maximumFractionDigits:1}).format(t)}function ke(t){return et("whole",{}).format(t)}function hs(t){return et("decimal",{minimumFractionDigits:1,maximumFractionDigits:1}).format(t)}function ne(t){return et("percent",{style:"percent",maximumFractionDigits:0}).format(t)}function Ie(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 sn(t,n){return n===void 0||n===0?null:(t-n)/n}function ge(t){try{return nn("regions",()=>new Intl.DisplayNames([Z()],{type:"region"}))?.of(t)??t}catch{return t}}function fe(t){return/^[A-Z]{2}$/.test(t)?String.fromCodePoint(...[...t].map(n=>127397+n.charCodeAt(0))):""}function _t(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 tt(`bucket|${n}|${s}`,a).format(new Date(t))}function pe(t,n=!0){let s=n?{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"};return tt(`day|${n}`,s).format(new Date(`${t}T00:00:00Z`))}function on(t,n){return tt("month",{month:"long",year:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(t,n,1)))}function St(t){let n=tt(`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 tt("hour",{hour:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(2024,0,1,t)))}function Fe(t,n){let s=Number.isInteger(t),a=et(`money:${n}:${s}`,{style:"currency",currency:n,minimumFractionDigits:s?0:2,maximumFractionDigits:2});return a?a.format(t):`${t} ${n}`}var Ct=[{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:ne,lowerIsBetter:!0},{key:"visitDuration",slot:7,format:Ie}],Tt=t=>o(`metric.${t.key}`),gs=t=>o(`hint.${t.key}`),Mt=6,fs=3;function vs(t){return Ct.find(n=>n.key===t)}var la=0;function e(t,n,s,a,r,i){n||(n={});var c,l,d=n;if("ref"in d&&typeof t!="function")for(l in d={},n)l=="ref"?c=n[l]:d[l]=n[l];var p={type:t,props:d,key:s,ref:c,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--la,__i:-1,__u:0};return(r||i)&&(p.__source=r,p.__self=i),V.vnode&&V.vnode(p),p}var ws=t=>({key:t.key,slot:t.slot,label:Tt(t),format:t.format}),bs={top:18,right:14,bottom:30,left:52};function ys(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 Be({points:t,previous:n,metrics:s,interval:a,timezone:r,shared:i,height:c=300}){let l=c,d=K(null),[p,m]=h(800),[f,b]=h(null);F(()=>{let R=d.current;if(!R)return;let M=new ResizeObserver(([I])=>I&&m(Math.max(280,I.contentRect.width)));return M.observe(R),()=>M.disconnect()},[]);let g=s.length===1||i?s[0]:void 0,k={...bs,left:g?bs.left:16},v=p-k.left-k.right,u=l-k.top-k.bottom,_=t.length>1?v/(t.length-1):0,T=R=>k.left+(t.length>1?R*_:v/2),y=n??[],P=R=>Math.max(0,...t.map(M=>M[R.key]??0),...y.map(M=>M[R.key]??0)),w=ys(Math.max(0,...s.map(P))),x=new Map(s.map(R=>[R.key,i?w:ys(P(R))])),A=(R,M)=>k.top+u-(M??0)/(x.get(R.key)??1)*u,$=k.top+u,N=Math.max(1,Math.ceil(t.length/Math.max(2,Math.floor(v/92)))),S=R=>{let M=R.currentTarget.getBoundingClientRect(),I=Math.round((R.clientX-M.left-k.left)/(_||1));b(t.length?Math.min(t.length-1,Math.max(0,I)):null)},E=f!==null?t[f]:void 0,H=[0,.25,.5,.75,1];return e("div",{class:"chart",ref:d,children:[e("svg",{width:p,height:l,role:"img","aria-label":o("chart.label",{metrics:s.map(R=>R.label).join(", ")}),onPointerMove:S,onPointerLeave:()=>b(null),children:[H.map(R=>e("line",{class:R===0?"gridline base":"gridline",x1:k.left,x2:p-k.right,y1:$-R*u,y2:$-R*u})),g?H.filter((R,M)=>M%2===0).map(R=>e("text",{class:"axis",x:k.left-10,y:$-R*u+4,"text-anchor":"end",children:g.format((x.get(g.key)??1)*R)})):null,t.map((R,M)=>M%N===0?e("text",{class:"axis",x:T(M),y:l-8,"text-anchor":M===0?"start":"middle",children:_t(R.start,a,r)}):null),s.map(R=>{if(y.length<2)return null;let M=xs(y.map((I,B)=>T(B)),y.map(I=>A(R,I[R.key])));return e("path",{class:`then s${R.slot}`,d:M})}),s.map(R=>{let M=xs(t.map((B,ae)=>T(ae)),t.map(B=>A(R,B[R.key]))),I=t.length?`${M}L${T(t.length-1).toFixed(1)},${$}L${T(0).toFixed(1)},${$}Z`:"";return e("g",{class:`series s${R.slot}`,children:[s.length<=fs&&(!i||R===s[0])?e("path",{class:"area",d:I}):null,e("path",{class:"line",d:M})]})}),E&&f!==null?e("g",{children:[e("line",{class:"cursor",x1:T(f),x2:T(f),y1:k.top,y2:$}),s.map(R=>e("circle",{class:`dot s${R.slot}`,cx:T(f),cy:A(R,E[R.key]),r:4.5}))]}):null]}),E&&f!==null?e("div",{class:T(f)>p/2?"tip left":"tip",style:{left:`${T(f)}px`},children:[e("span",{class:"tip-when",children:_t(E.start,a==="hour"?"hour":a==="month"?"month":"day",r)}),s.map(R=>{let M=f!==null?y[f]:void 0;return e("span",{class:"tip-row",children:[e("span",{class:`swatch s${R.slot}`}),e("span",{class:"tip-label",children:R.label}),e("strong",{children:R.format(E[R.key]??0)}),M?e("span",{class:"tip-then",children:R.format(M[R.key]??0)}):null]})}),f!==null&&y[f]?e("span",{class:"tip-then-when",children:o("chart.then",{when:_t(y[f].start,a==="hour"?"hour":a==="month"?"month":"day",r)})}):null]}):null]})}function xs(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 r=t[a-1]??t[a],i=n[a-1]??n[a],c=t[a],l=n[a],d=t[a+1],p=n[a+1],m=t[a+2]??d,f=n[a+2]??p,b=Math.min(l,p),g=Math.max(l,p),k=Math.min(g,Math.max(b,l+(p-i)/6)),v=Math.min(g,Math.max(b,p-(f-l)/6));s+=`C${(c+(d-r)/6).toFixed(2)},${k.toFixed(2)} ${(d-(m-c)/6).toFixed(2)},${v.toFixed(2)} ${d.toFixed(2)},${p.toFixed(2)}`}return s}var ca="input:not([type=hidden]):not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])",st=[];function da(t){return[...t.querySelectorAll(ca)].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 he(t){F(()=>{let n=document.activeElement instanceof HTMLElement?document.activeElement:null,s=t.current;if(!s)return;if(st.push(s),!s.contains(document.activeElement)){let r=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'])");r?r.focus():(s.tabIndex=-1,s.focus())}let a=r=>{if(r.key!=="Tab"||st[st.length-1]!==s)return;let i=da(s);if(!i.length){r.preventDefault();return}let c=i[0],l=i[i.length-1],d=document.activeElement;s.contains(d)?r.shiftKey&&(d===c||d===s)?(r.preventDefault(),l.focus()):!r.shiftKey&&d===l&&(r.preventDefault(),c.focus()):(r.preventDefault(),(r.shiftKey?l:c).focus())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a),st.splice(st.indexOf(s),1),n?.isConnected&&n.focus()}},[])}var pa=document.getElementById("app")?.dataset.world??"",ot=null;function ua(){return ot??(ot=fetch(pa).then(t=>{if(!t.ok)throw new Error(o("map.failed"));return t.json()})),ot.catch(()=>ot=null),ot}var ks=6;function an({view:t,onFilter:n,large:s}){let[a,r]=h(null),[i,c]=h([]),[l,d]=h(""),[p,m]=h(null),f=K(null);F(()=>{ua().then(r).catch(u=>d(u.message))},[]),F(()=>{let u=!0;return L.breakdown(t,"country",300).then(_=>u&&c(_.rows)).catch(_=>u&&d(_.message)),()=>{u=!1}},[t]);let b=new Map(i.map(u=>[u.value,u.visitors])),g=Math.max(0,...i.map(u=>u.visitors)),k=u=>u<=0||g===0?0:Math.max(1,Math.ceil(Math.sqrt(u/g)*ks));if(l)return e("p",{class:"empty",children:l});if(!a)return e("div",{class:s?"map large":"map"});let v=p?{id:p.id,n:b.get(p.id)??0}:null;return e("div",{class:s?"map large":"map",ref:f,children:[e("svg",{viewBox:`0 0 ${a.w} ${a.h}`,role:"img","aria-label":o("map.label",{top:i.slice(0,5).map(u=>`${ge(u.value)} ${O(u.visitors)}`).join(", ")}),onPointerLeave:()=>m(null),children:a.shapes.map(u=>{let _=b.get(u.id)??0;return e("path",{d:u.d,class:`land q${k(_)}${p?.id===u.id?" hot":""}${u.id&&_?" has":""}`,onPointerMove:T=>{let y=f.current?.getBoundingClientRect();y&&u.id&&m({id:u.id,x:T.clientX-y.left,y:T.clientY-y.top})},onClick:()=>u.id&&_&&n("country",u.id)})})}),v&&v.id?e("div",{class:"map-tip",style:{left:`${p.x}px`,top:`${p.y}px`},children:[e("strong",{children:[fe(v.id)," ",ge(v.id)]}),e("span",{children:v.n?Y("map.visitors",v.n,{n:O(v.n)}):o("map.none")})]}):null,e("div",{class:"map-scale","aria-hidden":"true",children:[e("span",{children:o("scale.fewer")}),Array.from({length:ks},(u,_)=>e("span",{class:`cell q${_+1}`})),e("span",{children:o("scale.more")})]})]})}function _s({view:t,onFilter:n,onClose:s}){let[a,r]=h([]),i=K(null);he(i),F(()=>{L.breakdown(t,"country",30).then(l=>r(l.rows)).catch(()=>r([]))},[t]),F(()=>{let l=d=>d.key==="Escape"&&s();return document.addEventListener("keydown",l),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",l),document.body.classList.remove("locked")}},[]);let c=a.reduce((l,d)=>l+d.visitors,0);return e("div",{class:"scrim center",onPointerDown:l=>l.target===l.currentTarget&&s(),children:e("div",{class:"map-sheet",role:"dialog","aria-modal":"true","aria-label":o("map.title"),ref:i,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(an,{view:t,large:!0,onFilter:(l,d)=>{n(l,d),s()}}),e("ol",{class:"map-list",children:a.map(l=>e("li",{children:e("button",{type:"button",onClick:()=>{n("country",l.value),s()},children:[e("span",{class:"map-list-name",children:[fe(l.value)," ",ge(l.value)]}),e("span",{class:"map-list-share",children:c?`${Math.round(l.visitors/c*100)}%`:""}),e("b",{children:O(l.visitors)})]})}))})]})]})})}var ma={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 C({name:t}){return e("svg",{class:"icon",viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:ma[t]})})}function G({icon:t,title:n,hint:s,size:a,children:r}){return e("div",{class:a?`empty-state ${a}`:"empty-state",children:[e("span",{class:"empty-mark","aria-hidden":"true",children:e(C,{name:t})}),e("p",{class:"empty-title",children:n}),s?e("p",{class:"empty-hint",children:s}):null,r]})}function Pt(t,n,s){return t.domain&&s.includes(t.domain)?`https://${t.domain}/${t.slug}`:`${n}/${t.slug}`}var ye=t=>t.replace(/^https?:\/\//,""),Ss=t=>pe(new Date(t.createdAt).toISOString().slice(0,10));function rn({text:t,small:n}){let[s,a]=h(!1);return e("button",{type:"button",class:n?"copy inline":"copy",onClick:r=>{r.stopPropagation(),navigator.clipboard?.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},children:[e(C,{name:s?"check":"copy"}),o(s?"links.copied":"links.copy")]})}function se({title:t,sub:n,wide:s,onClose:a,children:r}){let i=K(null);return he(i),F(()=>{let c=l=>l.key==="Escape"&&a();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&&a(),children:e("div",{class:s?"list-sheet wide link-sheet":"list-sheet link-sheet small",role:"dialog","aria-modal":"true","aria-label":t,ref:i,children:[e("header",{class:"drawer-head",children:[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:a,children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}),r]})})}var Cs=t=>`runlight_link_domain:${t}`;function ha(t,n){try{let s=localStorage.getItem(Cs(t));return s!==null&&(s===""||n.includes(s))?s:null}catch{return null}}function ga(t,n){try{localStorage.setItem(Cs(t),n)}catch{}}function Ts({site:t,prefix:n,domains:s,link:a,onClose:r,onSaved:i}){let[c,l]=h(a?.url??""),[d,p]=h(a?.name??""),[m,f]=h(a?.slug??""),b=ha(t,s),[g,k]=h(a?.domain??b??""),v=K(!1);F(()=>{a||!s.length||b!==null||L.checkLinkDomain(t,s[0]).then(N=>{N.working&&!v.current&&k(s[0])}).catch(()=>{})},[]);let u=N=>{v.current=!0,k(N.target.value)},[_,T]=h(""),[y,P]=h(!1),[w,x]=h(null),A=K(null);F(()=>A.current?.focus(),[w]);let $=N=>{N.preventDefault(),P(!0),T("");let S={url:c.trim(),name:d.trim(),slug:m.trim(),domain:g};(a?L.updateLink(t,a.id,S):L.createLink(t,S)).then(E=>{i(),a?r():(ga(t,g),x(E.link))}).catch(E=>T(E.message)).finally(()=>P(!1))};if(w){let N=Pt(w,n,s);return e(se,{title:o("links.new"),onClose:r,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:ye(N)}),e(rn,{text:N})]}),e("p",{class:"field-hint",children:[o("links.destination")," ",ye(w.url)]}),e("div",{class:"settings-actions",children:[e("button",{type:"button",class:"ghost",onClick:()=>{x(null),l(""),p(""),f("")},children:[e(C,{name:"plus"}),o("links.another")]}),e("button",{type:"button",class:"solid",onClick:r,children:o("common.close")})]})]})})}return e(se,{title:o(a?"links.edit":"links.new"),onClose:r,children:e("form",{class:"sheet-body link-form",onSubmit:$,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("links.url")}),e("input",{ref:A,class:"value",type:"url",required:!0,placeholder:o("links.urlPlaceholder"),value:c,onInput:N=>l(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=>p(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:g,onChange:u,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:[ye(n),"/"]})]}):a?.domain?e("select",{class:"value","aria-label":o("links.domain"),value:g,onChange:u,children:[e("option",{value:a.domain,children:o("links.removedDomain",{domain:a.domain})}),e("option",{value:"",children:[ye(n),"/"]})]}):e("span",{class:"slug-prefix",children:[ye(n),"/"]}),e("input",{class:"value",type:"text",maxLength:100,pattern:"[A-Za-z0-9][A-Za-z0-9_\\-]*",placeholder:o("links.slugPlaceholder"),value:m,onInput:N=>f(N.target.value)})]})]}),e("div",{class:"settings-actions",children:[_?e("span",{class:"settings-error",children:_}):null,e("button",{type:"button",class:"ghost",onClick:r,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",disabled:y||!c.trim(),children:[e(C,{name:a?"save":"plus"}),o(a?"links.save":"links.create")]})]})]})})}function Et({title:t,rows:n,dimension:s}){let a=Math.max(1,...n.map(r=>Number(r.events??0)));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(G,{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:`${Number(r.events??0)/a*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:s==="country"?`${fe(r.value)} ${ge(r.value)}`:re(s,r.value)})}),e("span",{class:"num",children:O(Number(r.events??0))})]}))})]})}function Ms({view:t,id:n,prefix:s,domains:a,onClose:r}){let[i,c]=h(null),[l,d]=h("");F(()=>{L.link(t,n).then(c).catch(f=>d(f.message))},[t,n]);let p=i?Pt(i.link,s,a):"",m=[{key:"clicks",slot:1,label:o("links.clicksLabel"),format:O},{key:"visitors",slot:2,label:o("metric.visitors"),format:O}];return e(se,{title:i?.link.name??o("common.loading"),sub:i?Y("links.total",i.clicks,{n:O(i.clicks)}):void 0,wide:!0,onClose:r,children:e("div",{class:"sheet-body",children:[l?e("p",{class:"failure",children:l}):null,i?e(U,{children:[e("div",{class:"link-head",children:[e("div",{class:"made",children:[e("a",{href:p,target:"_blank",rel:"noopener",children:ye(p)}),e(rn,{text:p})]}),e("p",{class:"field-hint",children:[o("links.destination")," ",e("a",{href:i.link.url,target:"_blank",rel:"noopener",children:ye(i.link.url)}),e("span",{class:"link-date-inline",children:o("links.createdOn",{date:Ss(i.link)})})]})]}),e("h3",{class:"mini-title",children:o("links.clicksOverTime")}),e("div",{class:"link-chart",children:e(Be,{points:i.series,metrics:m,interval:i.range.interval,timezone:i.range.timezone,shared:!0,height:240})}),e("div",{class:"mini-grid",children:[e(Et,{title:"links.sources",rows:i.sources,dimension:"source"}),e(Et,{title:"links.countries",rows:i.countries,dimension:"country"}),e(Et,{title:"links.devices",rows:i.devices,dimension:"device"}),e(Et,{title:"links.browsers",rows:i.browsers,dimension:"browser"})]})]}):null]})})}function at(t){let n=[],s=[],a="",r=!1;for(let d=0;d<t.length;d++){let p=t[d];r?p==='"'&&t[d+1]==='"'?(a+='"',d++):p==='"'?r=!1:a+=p:p==='"'?r=!0:p===","?(s.push(a),a=""):p===`
|
|
2
2
|
`||p==="\r"?(p==="\r"&&t[d+1]===`
|
|
3
|
-
`&&d++,s.push(a),a="",s.some(m=>m.trim())&&n.push(s),s=[]):a+=p}s.push(a),s.some(d=>d.trim())&&n.push(s);let[i,...c]=n;if(!i)return[];let l=i.map(d=>d.trim().toLowerCase().replace(/^/,""));return c.map(d=>Object.fromEntries(l.map((p,m)=>[p,(d[m]??"").trim()])))}var At=100;function te({name:t,onDelete:n,label:s,confirm:a,icon:r="trash",hint:i}){let[c,l]=h(!1);return O(()=>{if(!c)return;let d=setTimeout(()=>l(!1),4e3);return()=>clearTimeout(d)},[c]),e("button",{type:"button",class:c?"copy inline danger armed":"copy inline danger",title:c?i??o("app.confirmDelete",{name:t}):void 0,onClick:()=>c?n():l(!0),children:[e(M,{name:r}),c?a??o("links.confirm"):s??o("links.delete")]})}function fa({view:t,site:n,readOnly:s,onClose:a,onChanged:r}){let[i,c]=h(null),[l,d]=h(""),[p,m]=h([]),[f,b]=h(""),[g,_]=h(""),[v,u]=h("newest"),[S,E]=h(At);O(()=>{let T=setTimeout(()=>b(g),120);return()=>clearTimeout(T)},[g]),O(()=>E(At),[f,v]);let[y,R]=h(null),[w,x]=h(null),[P,D]=h(null),F=K(null),k=()=>{L.links(t).then(T=>{c(T.links),d(T.prefix),m(T.domains)}).catch(T=>{c(N=>N??[]),D({text:T.message,failures:[]})})};O(k,[t]);let A=Ae(()=>{let T=f.trim().toLowerCase();return(i??[]).filter(W=>!T||`${W.name} ${W.slug} ${W.url} ${W.domain}`.toLowerCase().includes(T)).sort((W,le)=>v==="clicks"?(le.clicks??0)-(W.clicks??0)||le.createdAt-W.createdAt:v==="newest"?le.createdAt-W.createdAt:W.name.localeCompare(le.name))},[i,f,v]),$=()=>{k(),r()},C=async T=>{try{let N=at(await T.text());if(!N.some(ve=>ve.url||ve.destination_url)){D({text:o("links.importNoUrl"),failures:[]});return}let W=await L.importLinks(n,N),le=W.failed.map(ve=>({row:ve.row,reason:ve.code&&be(ve.code,ve.params)||ve.reason}));D({text:Y("links.importDone",W.created,{n:H(W.created)}),failures:le}),$()}catch(N){D({text:N.message,failures:[]})}};return w?e(Ms,{view:t,id:w,prefix:l,domains:p,onClose:()=>x(null)}):y?e(Ts,{site:n,prefix:l,domains:p,link:y==="new"?void 0:y,onClose:()=>R(null),onSaved:$}):e(se,{title:o("panel.links"),sub:i?f?`${H(A.length)} / ${H(i.length)}`:H(i.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:g,onInput:T=>_(T.target.value)}),e("select",{class:"field","aria-label":o("links.sortBy"),value:v,onChange:T=>u(T.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(U,{children:[e("button",{type:"button",class:"ghost",title:o("links.importHelp"),onClick:()=>F.current?.click(),children:[e(M,{name:"upload"}),o("links.import")]}),e("input",{ref:F,type:"file",accept:".csv,text/csv",hidden:!0,onChange:T=>{let N=T.target.files?.[0];N&&C(N),T.target.value=""}}),e("button",{type:"button",class:"solid",onClick:()=>R("new"),children:[e(M,{name:"plus"}),o("links.new")]})]})]}),P?e("div",{class:"import-result",children:[e("strong",{children:P.text}),P.failures.slice(0,8).map(T=>e("span",{children:o("links.importFailed",{row:T.row,reason:T.reason})}))]}):null,e("div",{class:"sheet-body",children:[i&&i.length===0?e(V,{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:A.slice(0,S).map(T=>{let N=Pt(T,l,p);return e("tr",{children:[e("td",{class:"sheet-name",children:e("button",{type:"button",class:"link-cell",onClick:()=>x(T.id),children:[e("span",{class:"link-name",children:T.name}),e("span",{class:"link-short",children:ye(N)}),e("span",{class:"link-dest",children:ye(T.url)}),e("span",{class:"link-date",children:o("links.createdOn",{date:Ss(T)})})]})}),e("td",{class:"numeric lead",children:[H(T.clicks??0),e("span",{class:"link-unit",children:o("links.clicks")})]}),e("td",{class:"numeric link-actions",children:[e(an,{text:N,small:!0}),s?null:e(U,{children:[e("button",{type:"button",class:"copy inline",onClick:()=>R(T),children:[e(M,{name:"edit"}),o("links.editButton")]}),e(te,{name:T.name,hint:o("links.confirmDelete",{name:T.name}),onDelete:()=>L.deleteLink(n,T.id).then($,W=>D({text:W.message,failures:[]}))})]})]})]})})})}),A.length>S?e("div",{class:"more-row",children:[e("span",{class:"field-hint",children:o("links.showing",{shown:H(S),total:H(A.length)})}),e("button",{type:"button",class:"more",onClick:()=>E(S+At),children:[e(M,{name:"plus"}),o("links.showMore",{n:At})]})]}):null]})]})}function Es({view:t,site:n,readOnly:s}){let[a,r]=h(null),[i,c]=h(""),[l,d]=h([]),[p,m]=h(null),[f,b]=h(0),[g,_]=h("newest");O(()=>{let E=!0;return L.links(t).then(y=>{E&&(r(y.links),c(y.prefix),d(y.domains))}).catch(()=>E&&r([])),()=>{E=!1}},[t,f]);let v=[...a??[]].sort((E,y)=>g==="newest"?y.createdAt-E.createdAt:(y.clicks??0)-(E.clicks??0)||y.createdAt-E.createdAt).slice(0,10),u=Math.max(1,...v.map(E=>E.clicks??0)),S=(a??[]).reduce((E,y)=>E+(y.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:[Y("links.total",S,{n:H(S)}),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:g==="newest"?"tab on":"tab","aria-pressed":g==="newest",onClick:()=>_("newest"),children:o("links.sortNewest")}),e("button",{type:"button",class:g==="clicks"?"tab on":"tab","aria-pressed":g==="clicks",onClick:()=>_("clicks"),children:o("links.sortClicks")})]}),s?null:e(U,{children:[a?.length?e("button",{type:"button",class:"box-button",onClick:()=>m("manage"),children:[e(M,{name:"list"}),o("links.manage")]}):null,e("button",{type:"button",class:"box-button solid",onClick:()=>m("new"),children:[e(M,{name:"plus"}),o("links.new")]})]})]})]}),a&&a.length===0?e(V,{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("p",{class:"empty",children:o("common.loading")}),e("ol",{class:"rows",children:v.map(E=>e("li",{children:[e("span",{class:"bar",style:{width:`${(E.clicks??0)/u*100}%`}}),e("button",{type:"button",class:"name",title:ye(Pt(E,i,l)),onClick:()=>m({id:E.id}),children:[e("span",{class:"name-text",children:E.name}),e("span",{class:"link-slug",children:["/",E.slug]})]}),e("span",{class:"num",children:H(E.clicks??0)})]}))})]}),a&&a.length>v.length?e("button",{type:"button",class:"more",onClick:()=>m("manage"),children:[e(M,{name:"expand"}),o("panel.more")]}):null,p==="new"?e(Ts,{site:n,prefix:i,domains:l,onClose:()=>m(null),onSaved:()=>b(E=>E+1)}):p==="manage"?e(fa,{view:t,site:n,readOnly:s,onClose:()=>m(null),onChanged:()=>b(E=>E+1)}):p?e(Ms,{view:t,id:p.id,prefix:i,domains:l,onClose:()=>m(null)}):null]})}function As({view:t,event:n,onClose:s}){let[a,r]=h(null),[i,c]=h(null),[l,d]=h("");O(()=>{let f=!0;return L.eventProps(t,n,a).then(b=>f&&c(b)).catch(b=>f&&d(b.message)),()=>{f=!1}},[n,a,t]);let p=i?.rows??[],m=Math.max(1,...p.map(f=>f.events));return e(se,{title:n,sub:o("props.title"),wide:!0,onClose:s,children:e("div",{class:"sheet-body props-body",children:[i&&i.keys.length>1?e("div",{class:"ops props-keys",role:"radiogroup","aria-label":o("props.title"),children:i.keys.map(f=>e("button",{type:"button",role:"radio","aria-checked":i.key===f.key,class:i.key===f.key?"op on":"op",onClick:()=>r(f.key),children:f.key}))}):null,l?e("p",{class:"settings-error",children:l}):null,i&&i.keys.length===0?e(V,{icon:"list",title:o("props.emptyTitle"),hint:o("props.none")}):null,i&&i.key?e(U,{children:e("div",{class:"table",children:[e("div",{class:"cols",children:[e("span",{children:i.key}),e("span",{class:"extra",children:o("column.visitors")}),e("span",{class:"num-head",children:o("column.events")})]}),e("ol",{class:"rows",children:p.map(f=>e("li",{children:[e("span",{class:"bar",style:{width:`${f.events/m*100}%`}}),e("span",{class:"name",title:f.value,children:e("span",{class:"name-text",children:f.value})}),e("span",{class:"extra",children:H(f.visitors)}),e("span",{class:"num",children:H(f.events)})]}))})]})}):null,!i&&!l?e("p",{class:"empty",children:o("common.loading")}):null]})})}var va=[2,3,4,5,6,7,8],rn=(t,n)=>`${t}\0${n}`;function Ps({view:t,onClose:n}){let[s,a]=h(5),[r,i]=h(""),[c,l]=h(""),[d,p]=h(null),[m,f]=h(null),[b,g]=h([]),[_,v]=h(""),[u,S]=h(new Map),E=K(null);O(()=>{L.breakdown(t,"page",100).then(P=>g(P.rows.map(D=>D.value))).catch(()=>{})},[t]),O(()=>{let P=!0;return v(""),L.journeys(t,{steps:s,start:r,end:c,through:d}).then(D=>P&&f(D)).catch(D=>P&&v(D.message)),()=>{P=!1}},[t,s,r,c,d]),es(()=>{let P=E.current;if(!P||!m)return;let D=()=>{let k=P.getBoundingClientRect(),A=new Map;for(let $ of P.querySelectorAll("[data-box]")){let C=$.getBoundingClientRect();A.set($.dataset.box,{x1:C.left-k.left,x2:C.right-k.left,y:C.top-k.top+C.height/2})}S(A)};D();let F=new ResizeObserver(D);return F.observe(P),()=>F.disconnect()},[m]);let y=m?.columns??[],R=Math.max(1,...(m?.links??[]).map(P=>P.visits)),w=P=>P?je(P):o("journeys.other"),x=(P,D)=>p(d&&d.step===P&&d.value===D?null:D?{step:P,value:D}:null);return e(se,{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:P=>{let D=Number(P.target.value);a(D),d&&d.step>=D&&p(null)},children:va.map(P=>e("option",{value:String(P),children:o("journeys.stepCount",{n:P})}))})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.start")}),e("select",{class:"value",value:r,onChange:P=>{i(P.target.value),p(null)},children:[e("option",{value:"",children:o("journeys.anyPage")}),b.map(P=>e("option",{value:P,children:P}))]})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.end")}),e("select",{class:"value",value:c,onChange:P=>l(P.target.value),children:[e("option",{value:"",children:o("journeys.anyPage")}),b.map(P=>e("option",{value:P,children:P}))]})]})]}),d?e("p",{class:"journey-following",children:[o("journeys.following",{page:je(d.value),step:d.step+1}),e("button",{type:"button",class:"copy inline",onClick:()=>p(null),children:[e(M,{name:"x"}),o("common.clearAll")]})]}):null,m?.sampled?e("p",{class:"field-hint",children:o("journeys.sampled",{n:H(m.sampled)})}):null,_?e("p",{class:"settings-error",children:_}):null,m?m.visits===0?e(V,{icon:"arrive",title:o("journeys.emptyTitle"),hint:o("journeys.none")}):e("div",{class:"journey-scroll",children:e("div",{class:"journey-grid",ref:E,style:{gridTemplateColumns:`repeat(${y.length}, minmax(150px, 1fr))`},children:[e("svg",{class:"journey-links","aria-hidden":"true",children:m.links.map(P=>{let D=u.get(rn(P.step,P.from)),F=u.get(rn(P.step+1,P.to));if(!D||!F)return null;let k=(D.x2+F.x1)/2,A=d?d.step===P.step&&d.value===P.from||d.step===P.step+1&&d.value===P.to:!1;return e("path",{class:A?"lit":"",d:`M${D.x2},${D.y} C${k},${D.y} ${k},${F.y} ${F.x1},${F.y}`,style:{strokeWidth:Math.max(1.5,P.visits/R*16)}})})}),y.map((P,D)=>e("div",{class:"journey-column",children:[e("p",{class:"journey-step",children:[o("journeys.step",{n:D+1}),e("span",{children:H(P.visits)})]}),P.items.map(F=>e("button",{type:"button","data-box":rn(D,F.value),class:`journey-page${F.value?"":" other"}${d&&d.step===D&&d.value===F.value?" on":""}`,title:F.value?o("journeys.follow",{page:je(F.value)}):void 0,disabled:!F.value,onClick:()=>x(D,F.value),children:[e("span",{class:"journey-name",children:w(F.value)}),e("span",{class:"journey-count",children:[H(F.visits),e("span",{class:"journey-share",children:[Math.round(F.visits/P.visits*100),"%"]})]})]})),P.left?e("p",{class:"journey-left",children:o("journeys.left",{n:H(P.left)})}):null]}))]})}):e("p",{class:"empty",children:o("common.loading")})]})})}var Rs=8,Ls=1e3;function ae(t,n){return n?t==="country"?`${fe(n)} ${ge(n)}`.trim():t==="region"?`${fe(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"?je(n):n:o("common.none")}function ba({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} ${ne(s.n/n)}`).join(", "),children:t.map(s=>e("span",{class:`mix-part s${s.slot}`,style:{flexGrow:String(s.n)},title:`${s.name}: ${ne(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:ne(s.n/n)})]}))})]})}function ya({rows:t,tab:n,onFilter:s,onDetail:a}){let r=n.column??"visitors",i=Math.max(1,...t.map(l=>Number(l[r]??0))),c=l=>n.colors?.[l]??(n.groups?n.groups.slots[n.groups.of(l)]:void 0);return e("ol",{class:"rows",children:t.map(l=>{let d=Number(l[r]??0),p=ae(n.dimension,l.value),m=c(l.value),f=e(U,{children:[m!==void 0?e("span",{class:`swatch s${m}`}):null,e("span",{class:"name-text",children:p})]});return e("li",{children:[e("span",{class:"bar",style:{width:`${d/i*100}%`}}),n.filterable?e("button",{type:"button",class:"name",title:o("panel.filterBy",{name:p}),onClick:()=>s(n.dimension,l.value),children:f}):e("span",{class:"name",children:f}),n.extra?e("span",{class:"extra",children:n.extra.format(Number(l[n.extra.key]??0))}):null,a?e("button",{type:"button",class:"row-detail",title:o("props.open",{name:p}),"aria-label":o("props.open",{name:p}),onClick:()=>a(l.value),children:e(M,{name:"list"})}):null,e("span",{class:"num",children:H(d)})]})})})}function xa({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 wa=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 Ds(t){let n=i=>c=>Number(c[i]??0),s=(i,c)=>({label:i,value:l=>H(n(c)(l)),by:n(c)}),a=i=>({label:"column.share",value:(c,l)=>l?ne(n(i)(c)/l):"",by:n(i)}),r={label:"column.bounce",value:i=>ne(i.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:i=>i.timeOnPage?Ie(i.timeOnPage):"",by:n("timeOnPage")},{label:"column.scroll",value:i=>i.scrollDepth?`${i.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"),r]:wa.has(t.dimension)?[s("column.visitors","visitors"),s("column.visits","visits"),s("column.pageviews","pageviews"),r,{label:"column.duration",value:i=>Ie(i.visitDuration??0),by:n("visitDuration")},a("visitors")]:[s("column.visitors","visitors")]}function ka({rows:t,tab:n,onFilter:s}){let a=n.column??"visitors",r=Ds(n),i=t.reduce((b,g)=>b+Number(g[a]??0),0),c=Math.max(1,...t.map(b=>Number(b[a]??0))),[l,d]=h(null),p=b=>d(l?.by===b?{by:b,descending:!l.descending}:{by:b,descending:b>=0}),m=l?[...t].sort((b,g)=>{let _=l.by<0?ae(n.dimension,b.value).localeCompare(ae(n.dimension,g.value),void 0,{numeric:!0,sensitivity:"base"}):r[l.by].by(b)-r[l.by].by(g);return l.descending?-_:_}):t,f=(b,g,_)=>e("th",{class:_?"numeric":void 0,"aria-sort":l?.by===g?l.descending?"descending":"ascending":void 0,children:e("button",{type:"button",class:l?.by===g?"sort on":"sort",onClick:()=>p(g),children:[b,e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:l?.by===g&&!l.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:[f(o(n.label),-1,!1),r.map((b,g)=>f(o(b.label),g,!0))]})}),e("tbody",{children:m.map(b=>{let g=ae(n.dimension,b.value);return e("tr",{children:[e("td",{class:"sheet-name",children:[e("span",{class:"bar",style:{width:`${Number(b[a]??0)/c*100}%`}}),n.filterable?e("button",{type:"button",class:"name",title:o("panel.filterBy",{name:g}),onClick:()=>s(n.dimension,b.value),children:e("span",{class:"name-text",children:g})}):e("span",{class:"name",children:e("span",{class:"name-text",children:g})})]}),r.map((_,v)=>e("td",{class:v===0?"numeric lead":"numeric",children:_.value(b,i)}))]})})})]})}function _a({title:t,tab:n,view:s,onFilter:a,onClose:r}){let i=K(null);he(i);let[c,l]=h(null),[d,p]=h(""),m=K(null);O(()=>{L.breakdown(s,n.dimension,Ls).then(_=>l(_.rows)).catch(()=>l([]));let g=_=>_.key==="Escape"&&r();return document.addEventListener("keydown",g),document.body.classList.add("locked"),m.current?.focus(),()=>{document.removeEventListener("keydown",g),document.body.classList.remove("locked")}},[]);let f=d.trim().toLowerCase(),b=(c??[]).filter(g=>!f||ae(n.dimension,g.value).toLowerCase().includes(f));return e("div",{class:"scrim center",onPointerDown:g=>g.target===g.currentTarget&&r(),children:e("div",{class:Ds(n).length>3?"list-sheet wide":"list-sheet",role:"dialog","aria-modal":"true","aria-label":`${o(t)}: ${o(n.label)}`,ref:i,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 g=ie(s);g.set("dimension",n.dimension),g.set("limit",String(Ls)),g.set("format","csv"),ze("breakdown",g).catch(()=>{})},children:[e(M,{name:"upload"}),o("export.csv")]}),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("div",{class:"sheet-search",children:[e("input",{ref:m,class:"value",type:"search",placeholder:o("common.search"),"aria-label":o("common.search"),value:d,onInput:g=>p(g.target.value)}),e("span",{class:"sheet-tools",children:[d?e("button",{type:"button",class:"sheet-clear","aria-label":o("common.clearAll"),onClick:()=>{p(""),m.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:c?f?`${H(b.length)} / ${H(c.length)}`:H(c.length):""})]})]}),e("div",{class:"sheet-body",children:[c?null:e("p",{class:"empty",children:o("common.loading")}),c&&b.length===0?f?e(V,{size:"line",icon:"list",title:o("empty.search",{q:f})}):e(V,{size:"line",icon:"chart",title:o("empty.mini")}):null,b.length?e(ka,{rows:b,tab:n,onFilter:(g,_)=>{a(g,_),r()}}):null]})]})})}function $s({title:t,tabs:n,view:s,onFilter:a,wide:r,map:i}){let[c,l]=h(0),[d,p]=h(!1),[m,f]=h(!1),[b,g]=h(!1),[_,v]=h(!1),[u,S]=h(null),[E,y]=h(null),[R,w]=h(""),[x,P]=h(!1),D=n[c]??n[0],F=D.column??"visitors";O(()=>{let C=!0;w("");let T=setTimeout(()=>C&&P(!0),300);return L.breakdown(s,D.dimension,50).then(N=>C&&y(N.rows)).catch(N=>C&&w(N.message)).finally(()=>{clearTimeout(T),C&&P(!1)}),()=>{C=!1,clearTimeout(T)}},[s,D.dimension]);let k=E??[],A=!R&&E!==null&&k.length===0,$=[];if(D.colors)$=k.filter(C=>D.colors[C.value]!==void 0).map(C=>({name:ae(D.dimension,C.value),n:Number(C[F]??0),slot:D.colors[C.value]}));else if(D.groups){let C=new Map;for(let T of k)C.set(D.groups.of(T.value),(C.get(D.groups.of(T.value))??0)+Number(T[F]??0));$=Object.entries(D.groups.slots).map(([T,N])=>({name:o(T),n:C.get(T)??0,slot:N}))}return e("section",{class:`${r?"panel wide":"panel"}${x&&E?" stale":""}`,"aria-busy":x,children:[e("header",{class:"panel-head",children:[e("h2",{children:o(t)}),e("div",{class:"head-tools",children:[n.length>1&&!d?e("nav",{class:"tabs","aria-label":o("panel.views",{title:o(t)}),children:n.map((C,T)=>e("button",{type:"button",class:T===c?"tab on":"tab","aria-pressed":T===c,onClick:()=>{l(T),y(null)},children:o(C.label)}))}):null,t==="panel.pages"&&!A?e("button",{type:"button",class:"tool",title:o("journeys.open"),"aria-label":o("journeys.open"),onClick:()=>g(!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,i&&!A?e(U,{children:[e("button",{type:"button",class:d?"tool on":"tool","aria-label":o(d?"panel.showList":"panel.showMap"),title:o(d?"panel.showList":"panel.showMap"),onClick:()=>p(!d),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:()=>f(!0),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4"})})})]}):null]})]}),m?e(_s,{view:s,onFilter:a,onClose:()=>f(!1)}):null,b?e(Ps,{view:s,onClose:()=>g(!1)}):null,u?e(As,{view:s,event:u,onClose:()=>S(null)}):null,_?e(_a,{title:t,tab:D,view:s,onFilter:a,onClose:()=>v(!1)}):null,A?e(V,{icon:Rt[t]?.icon??"chart",title:o(Rt[t]?.title??"panel.empty"),hint:Rt[t]?o(Rt[t].hint):void 0}):d?e(on,{view:s,onFilter:a}):e(U,{children:[$.length>0?e(ba,{parts:$}):null,e("div",{class:"table",children:[e(xa,{tab:D}),R?e("p",{class:"empty",children:R}):null,!E&&!R?e("p",{class:"empty",children:o("common.loading")}):null,e(ya,{rows:k.slice(0,Rs),tab:D,onFilter:a,onDetail:D.dimension==="event"?S:void 0})]}),k.length>Rs?e("button",{type:"button",class:"more",onClick:()=>v(!0),children:[e(M,{name:"expand"}),o("panel.more")]}):null]}),i&&us?e("a",{class:"geo-credit",href:"https://db-ip.com",target:"_blank",rel:"noopener",children:ce("panel.geoCredit",{name:e("span",{children:"DB-IP"})})}):null]})}var Rt={"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"}},Is=6;function Hs({view:t,wide:n}){let[s,a]=h(null),[r,i]=h([]),[c,l]=h(""),[d,p]=h(null),m=K(null);O(()=>{let u=!0;return l(""),L.rhythm(t).then(S=>{u&&(a(S.grid),i(S.cells??[]))}).catch(S=>u&&l(S.message)),()=>{u=!1}},[t]);let f=St("short"),b=s?Math.max(0,...s.flat()):0,g=null;if(s&&b>0)for(let u=0;u<7&&!g;u++){let S=s[u].indexOf(b);S>=0&&(g=[u,S])}let _=s?s.flat().reduce((u,S)=>u+S,0)/168:0,v=d&&s?{n:s[d.d][d.h],cell:r[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")}),g?e("span",{class:"aside",children:o("rhythm.busiest",{when:`${f[g[0]]} ${nt(g[1])}`})}):null]}),c?e("p",{class:"empty",children:c}):null,!s&&!c?e("p",{class:"empty",children:o("common.loading")}):null,s&&b===0?e(V,{icon:"clock",title:o("empty.rhythm.title"),hint:o("empty.rhythm.hint")}):null,s&&b>0?e("div",{class:"rhythm",role:"table","aria-label":o("rhythm.table"),ref:m,onPointerLeave:()=>p(null),children:[s.map((u,S)=>e("div",{class:"rhythm-row",role:"row",children:[e("span",{class:"rhythm-day",role:"rowheader",children:f[S]}),u.map((E,y)=>e("span",{role:"cell","aria-label":Y("rhythm.cell",E,{when:`${f[S]} ${nt(y)}`,n:H(E)}),class:`cell q${E===0||b===0?0:Math.max(1,Math.ceil(E/b*Is))}${d?.d===S&&d.h===y?" hot":""}`,onPointerEnter:R=>{let w=m.current?.getBoundingClientRect(),x=R.currentTarget.getBoundingClientRect();w&&p({d:S,h:y,x:x.left-w.left+x.width/2,y:x.top-w.top})}}))]})),e("div",{class:"rhythm-row hours","aria-hidden":"true",children:[e("span",{class:"rhythm-day"}),Array.from({length:24},(u,S)=>e("span",{class:"hour",children:S%6===0?nt(S):""}))]}),d&&v?e("div",{class:d.x>(m.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:[f[d.d]," ",nt(d.h)]}),v.n&&v.cell?e(U,{children:[e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.visits")}),e("strong",{children:H(v.cell.visits)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.visitors")}),e("strong",{children:H(v.cell.visitors)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.pageviews")}),e("strong",{children:H(v.cell.pageviews)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.bounceRate")}),e("strong",{children:ne(v.cell.bounceRate)})]}),_>0?e("span",{class:"tip-note",children:o("rhythm.typical",{x:(v.n/_).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:Is},(u,S)=>e("span",{class:`cell q${S+1}`})),e("span",{children:o("scale.more")})]})]}):null]})}var Os={key:"timeOnPage",label:"column.time",format:t=>t?Ie(t):""},Fs={key:"bounceRate",label:"column.bounce",format:ne};var Sa=[{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"]}],cn=t=>o(`field.${t}`),Lt=6,Ca=["is","not","contains"],dn=t=>o(`filter.${t}`),ln=1;function Ta({draft:t,view:n,first:s,onChange:a,onRemove:r}){let[i,c]=h([]);return O(()=>{let l=!0,d={...n,filters:n.filters.filter(p=>p.dimension!==t.dimension)};return L.breakdown(d,t.dimension,12).then(p=>l&&c(p.rows)).catch(()=>l&&c([])),()=>{l=!1}},[t.dimension,n]),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:l=>a({...t,dimension:l.target.value,value:""}),children:Sa.map(l=>e("optgroup",{label:o(l.group),children:l.fields.map(d=>e("option",{value:d,children:cn(d)}))}))}),e("div",{class:"ops",role:"radiogroup","aria-label":o("filter.match"),children:Ca.map(l=>e("button",{type:"button",role:"radio","aria-checked":t.op===l,class:t.op===l?"op on":"op",onClick:()=>a({...t,op:l}),children:dn(l)}))}),e("button",{type:"button",class:"remove","aria-label":o("filter.removeCondition"),onClick:r,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:l=>a({...t,value:l.target.value})}),i.length?e("div",{class:"suggestions",children:i.map(l=>e("button",{type:"button",class:l.value===t.value?"suggestion on":"suggestion",onClick:()=>a({...t,value:l.value}),children:[ae(t.dimension,l.value),e("span",{children:H(Number(l.visitors||l.events||0))})]}))}):null]})]})}function Ns({view:t,onApply:n,onClose:s}){let[a,r]=h(()=>t.filters.length?t.filters.map(d=>({...d,id:ln++})):[{dimension:"page",op:"is",value:"",id:ln++}]),i=K(null);he(i),O(()=>{let d=p=>p.key==="Escape"&&s();return document.addEventListener("keydown",d),i.current?.querySelector("select, input")?.focus(),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",d),document.body.classList.remove("locked")}},[]);let c=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:i,children:e("form",{class:"drawer-form",onSubmit:d=>{d.preventDefault(),n(c.map(({dimension:p,op:m,value:f})=>({dimension:p,op:m,value:f.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,p)=>e(Ta,{draft:d,view:t,first:p===0,onChange:m=>r(a.map(f=>f.id===d.id?m:f)),onRemove:()=>r(a.filter(m=>m.id!==d.id))})),a.length<Lt?e("button",{type:"button",class:"add",onClick:()=>r([...a,{dimension:"country",op:"is",value:"",id:ln++}]),children:[e(M,{name:"plus"}),o("filter.add").replace(/^\+\s*/,"")]}):e("p",{class:"drawer-note",children:o("filter.max",{max:Lt})}),e("p",{class:"drawer-note",children:o("filter.note")})]}),e("footer",{class:"drawer-foot",children:[e("button",{type:"button",class:"ghost",onClick:()=>r([]),children:[e(M,{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(M,{name:"check"}),c.length?Y("filter.apply",c.length):o("filter.everything")]})]})]})})})}function re(t){let[n,s]=h(!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(M,{name:n?"eyeOff":"eye"})})]})}var It=["today","yesterday","7d","30d","90d","month","last_month","year","12mo","all"],Fe="30d",Us=t=>It.includes(t)?o(`period.${t}`):o("period.30d");function Ma(t,n,s){return new Date(Date.UTC(t,n,s)).toISOString().slice(0,10)}function _e(t,n){if(t===n)return pe(t);let s=t.slice(0,4)===n.slice(0,4);return o("calendar.range",{from:pe(t,!s),to:pe(n)})}function zs({y:t,m:n,start:s,end:a,hoverDay:r,today:i,onDay:c,onHover:l}){let p=(new Date(Date.UTC(t,n,1)).getUTCDay()+6)%7,m=new Date(Date.UTC(t,n+1,0)).getUTCDate(),f=a||(s&&r?r:""),b=s&&f?s<f?s:f:s,g=s&&f&&s<f?f:s;return e("div",{class:"month",children:[e("div",{class:"month-title",children:hs(t,n)}),e("div",{class:"month-grid",role:"grid",children:[St("short").map(_=>e("span",{class:"weekday",children:_.slice(0,2)})),Array.from({length:p},()=>e("span",{})),Array.from({length:m},(_,v)=>{let u=Ma(t,n,v+1),S=b&&g&&u>=b&&u<=g,E=!!b&&(u===b||u===g);return e("button",{type:"button",class:`day${S?" in":""}${E?" edge":""}${u===i?" today":""}`,disabled:u>i,"aria-pressed":E,"aria-label":pe(u),onClick:()=>c(u),onPointerEnter:()=>l(u),children:v+1})})]})]})}function js({from:t,to:n,today:s,onApply:a,onCancel:r,applyLabel:i}){let[c,l]=h(t),[d,p]=h(n),[m,f]=h(""),[b,g]=s.split("-").map(Number),_=(n||s).split("-").map(Number),[v,u]=h([_[0],_[1]-1]),S=P=>{if(!c||d)l(P),p("");else{let[D,F]=P<c?[P,c]:[c,P];l(D),p(F)}},[E,y]=v,R=new Date(Date.UTC(E,y-1,1)),w=new Date(Date.UTC(E,y,1)),x=w.getUTCFullYear()>b||w.getUTCFullYear()===b&&w.getUTCMonth()>=g-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:()=>u([E,y-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:()=>u([E,y+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:()=>f(""),children:[e(zs,{y:R.getUTCFullYear(),m:R.getUTCMonth(),start:c,end:d,hoverDay:m,today:s,onDay:S,onHover:f}),e(zs,{y:w.getUTCFullYear(),m:w.getUTCMonth(),start:c,end:d,hoverDay:m,today:s,onDay:S,onHover:f})]}),e("div",{class:"cal-foot",children:[e("span",{class:"cal-sel",children:c?d?_e(c,d):o("calendar.open",{from:pe(c)}):o("calendar.pick")}),e("button",{type:"button",class:"ghost",onClick:r,children:o("common.cancel")}),e("button",{type:"button",class:"solid",disabled:!c,onClick:()=>a(c,d||c),children:i??o("calendar.apply")})]})]})}function Be(){let[t,n]=h(!1),s=K(null);return O(()=>{if(!t)return;let a=r=>{(r instanceof KeyboardEvent?r.key==="Escape":!s.current?.contains(r.target))&&n(!1)};return document.addEventListener("pointerdown",a),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("keydown",a)}},[t]),{open:t,setOpen:n,root:s}}var qe=()=>e("svg",{class:"chev",viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 6l4 4 4-4"})});function Ks({period:t,from:n,to:s,today:a,onPeriod:r,onRange:i}){let{open:c,setOpen:l,root:d}=Be(),p=n&&s?_e(n,s):Us(t);return e("div",{class:"picker",ref:d,children:[e("button",{type:"button",class:"picker-button","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>l(!c),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:p}),e(qe,{})]}),c?e("div",{class:"flyout",role:"dialog","aria-label":o("calendar.dialog"),children:[e("ul",{class:"presets",children:It.map(m=>e("li",{children:e("button",{type:"button",class:!n&&t===m?"preset on":"preset",onClick:()=>{r(m),l(!1)},children:Us(m)})}))}),e(js,{from:n,to:s,today:a,onCancel:()=>l(!1),onApply:(m,f)=>{i(m,f),l(!1)}})]}):null]})}var Ea=["previous","year","custom","off"];function Bs({mode:t,from:n,to:s,today:a,allTime:r,onChange:i}){let{open:c,setOpen:l,root:d}=Be(),[p,m]=h(!1),f=t==="custom"&&n&&s?_e(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":c,onClick:()=>{m(t==="custom"),l(!c)},children:[e("span",{class:"compare-vs",children:o("compare.vs")}),e("span",{children:f}),e(qe,{})]}),c?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")}),Ea.map(b=>e("li",{children:e("button",{type:"button",class:(p?b==="custom":t===b)?"preset on":"preset",disabled:r&&b!=="off",onClick:()=>{if(b==="custom")return m(!0);i(b),l(!1)},children:o(`compare.${b}`)})})),r?e("li",{class:"presets-note",children:o("compare.allTime")}):null]}),p&&!r?e(js,{from:n,to:s,today:a,applyLabel:o("compare.apply"),onCancel:()=>l(!1),onApply:(b,g)=>{i("custom",b,g),l(!1)}}):null]}):null]})}function qs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function pn({onAdded:t,onCancel:n}){let[s,a]=h("here"),[r,i]=h(""),[c,l]=h(""),[d,p]=h(""),[m,f]=h(""),[b,g]=h(!1),[_,v]=h(""),[u,S]=h(!1);return e("form",{class:"sheet-body link-form",onSubmit:y=>{if(y.preventDefault(),S(!0),v(""),s==="connect"&&!b){L.connect(d.trim()).then(w=>location.assign(w.authorize)).catch(w=>{v(w.message),S(!1)});return}let R=s==="here"?{name:r.trim(),hostnames:c,timezone:qs()}:{name:r.trim(),remote:{url:d.trim(),token:m.trim()}};L.addSite(R).then(w=>t(w.site)).catch(w=>{v(w.message),S(!1)})},children:[e("div",{class:"ops add-mode",role:"radiogroup","aria-label":o("sites.addTitle"),children:["here","connect"].map(y=>e("button",{type:"button",role:"radio","aria-checked":s===y,class:s===y?"op on":"op",onClick:()=>a(y),children:o(y==="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:c,onInput:y=>l(y.target.value)}),e("span",{class:"field-hint",children:o("sites.domainsHint")})]}):e(U,{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:y=>p(y.target.value)})]}),b?e(U,{children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("sites.connectToken")}),e(re,{class:"value",required:!0,autoComplete:"off",placeholder:"rl_...",value:m,onInput:y=>f(y.target.value)}),e("span",{class:"field-hint",children:o("sites.connectTokenHint")})]}),e("button",{type:"button",class:"text-button",onClick:()=>g(!1),children:o("sites.useSignIn")})]}):e("button",{type:"button",class:"text-button",onClick:()=>g(!0),children:o("sites.useToken")})]}),s==="connect"&&!b?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:r,onInput:y=>i(y.target.value)}),s==="here"?e("span",{class:"field-hint",children:o("sites.timezoneHint",{zone:qs().replace(/_/g," ")})}):null]}),e("div",{class:"settings-actions",children:[_?e("span",{class:"settings-error",children:_}):null,n?e("button",{type:"button",class:"ghost",onClick:n,children:o("common.cancel")}):null,e("button",{type:"submit",class:"solid",disabled:u||(s==="here"?!c.trim():!d.trim()||b&&!m.trim()),children:[e(M,{name:"plus"}),o(s==="here"?"sites.add":"sites.connect")]})]})]})}function Vs({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(pn,{onAdded:t})]})})}function Gs({sites:t,current:n,canAdd:s,onPick:a,onAdd:r,onAll:i}){let{open:c,setOpen:l,root:d}=Be();return e("div",{class:"site-menu",ref:d,children:[e("button",{type:"button",class:"site-button","aria-haspopup":"menu","aria-expanded":c,onClick:()=>l(!c),children:[e("span",{class:"site-button-name",children:n?.name??"Runlight"}),e(qe,{})]}),c?e("div",{class:"site-flyout",role:"menu","aria-label":o("app.site"),children:[t.map(p=>e("button",{type:"button",role:"menuitemradio","aria-checked":p.id===n?.id,class:p.id===n?.id?"site-option on":"site-option",onClick:()=>{l(!1),p.id!==n?.id&&a(p.id)},children:[e("span",{class:"site-option-text",children:[e("span",{class:"site-option-name",children:p.name}),p.hostnames[0]&&p.hostnames[0]!==p.name?e("span",{class:"site-option-host",children:p.hostnames[0]}):null]}),p.id===n?.id?e(M,{name:"check"}):null]})),i&&t.length>1?e(U,{children:[e("hr",{}),e("button",{type:"button",role:"menuitem",class:"site-option site-add",onClick:()=>{l(!1),i()},children:[e(M,{name:"list"}),e("span",{children:o("sites.all")})]})]}):null,s?e(U,{children:[e("hr",{}),e("button",{type:"button",role:"menuitem",class:"site-option site-add",onClick:()=>{l(!1),r()},children:[e(M,{name:"plus"}),e("span",{children:o("sites.addTitle")})]})]}):null]}):null]})}function Ws({sites:t,view:n,onPick:s,onClose:a}){let[r,i]=h({});O(()=>{for(let l of t)L.stats({...n,site:l.id,filters:[]}).then(d=>i(p=>({...p,[l.id]:d.stats}))).catch(()=>i(d=>({...d,[l.id]:null})))},[]);let c=[...t].sort((l,d)=>(r[d.id]?.visitors??-1)-(r[l.id]?.visitors??-1));return e(se,{title:o("sites.all"),wide:!0,onClose:a,children:e("div",{class:"sheet-body all-sites",children:e("table",{class:"all-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:o("sites.name")}),e("th",{children:o("metric.visitors")}),e("th",{children:o("metric.visits")}),e("th",{children:o("metric.pageviews")}),e("th",{children:o("metric.bounceRate")}),e("th",{children:o("metric.visitDuration")})]})}),e("tbody",{children:c.map(l=>{let d=r[l.id];return e("tr",{children:[e("td",{children:e("button",{type:"button",class:"name",onClick:()=>s(l.id),children:e("span",{class:"name-text",children:l.name})})}),e("td",{children:d?H(d.visitors):d===null?"?":"\u2026"}),e("td",{children:d?H(d.visits):""}),e("td",{children:d?H(d.pageviews):""}),e("td",{children:d?ne(d.bounceRate):""}),e("td",{children:d?Ie(d.visitDuration):""})]})})})]})})})}var Aa=["password","passw0rd","123456","qwerty","azerty","letmein","welcome","admin","runlight","iloveyou","abc123","monkey","dragon","football","baseball","sunshine","princess","shadow","master"];function Ys(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 c=0;c<t.length;c++){let l=t.charCodeAt(c),d=t.charCodeAt(c-1),p=!1;for(let b=1;b<=4&&!p;b++)p=c-1-b>=0&&t[c]===t[c-b]&&t[c-1]===t[c-1-b];let m=c>0&&l===d,f=c>1&&l-d===d-t.charCodeAt(c-2)&&Math.abs(l-d)===1;a+=p?0:m||f?.25:1}let r=a*Math.log2(Math.max(s,10)),i=t.toLowerCase();for(let c of[...Aa,...n.map(l=>l.toLowerCase()).filter(l=>l.length>=3)])r-=(i.split(c).length-1)*c.length*3;return r<40?1:r<60?2:r<80?3:4}function De({icon:t,title:n,tone:s,action:a,children:r}){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(M,{name:t})}),e("div",{class:"callout-box-text",children:[e("strong",{children:n}),e("p",{children:r})]}),a?e("div",{class:"callout-box-action",children:a}):null]})}function Pa(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 rt(t){let n=[],s=/\*\*([^*]+)\*\*|`([^`]+)`/g,a=0;for(let r=s.exec(t);r;r=s.exec(t))r.index>a&&n.push(t.slice(a,r.index)),n.push(r[1]!==void 0?e("strong",{children:r[1]}):e("code",{children:r[2]})),a=r.index+r[0].length;return a<t.length&&n.push(t.slice(a)),n}function Ra({text:t}){let n=[],s=t.replace(/\r/g,"").split(`
|
|
4
|
-
`);for(let a=0;a<s.length;){let r=s[a];if(!r.trim()){a++;continue}if(/^\s*[-*] /.test(r)||/^\s*\d+[.)] /.test(r)){let c=/^\s*\d/.test(r),l=[];for(;a<s.length&&(/^\s*[-*] /.test(s[a])||/^\s*\d+[.)] /.test(s[a]));)l.push(s[a++].replace(/^\s*(?:[-*]|\d+[.)]) /,""));n.push(c?e("ol",{children:l.map(d=>e("li",{children:rt(d)}))}):e("ul",{children:l.map(d=>e("li",{children:rt(d)}))}));continue}if(r.trim().startsWith("|")){let c=[];for(;a<s.length&&s[a].trim().startsWith("|");){let p=s[a++].trim().replace(/^\||\|$/g,"").split("|").map(m=>m.trim());p.every(m=>/^:?-{2,}:?$/.test(m))||c.push(p)}let[l,...d]=c;n.push(e("div",{class:"reply-table",children:e("table",{children:[l?e("thead",{children:e("tr",{children:l.map(p=>e("th",{children:rt(p)}))})}):null,e("tbody",{children:d.map(p=>e("tr",{children:p.map(m=>e("td",{children:rt(m)}))}))})]})}));continue}let i=[];for(;a<s.length&&s[a].trim()&&!/^\s*(?:[-*]|\d+[.)]) /.test(s[a])&&!s[a].trim().startsWith("|");)i.push(s[a++].replace(/^#+\s*/,""));n.push(e("p",{children:rt(i.join(" "))}))}return e("div",{class:"reply",children:n})}var La=["assistant.ask1","assistant.ask2","assistant.ask3","assistant.ask4"];function Zs({site:t,view:n,owner:s,onSetup:a,onClose:r}){let i=`runlight_assistant:${t.id}`,c=K(null);he(c);let[l,d]=h(null),[p,m]=h(()=>{try{let y=JSON.parse(sessionStorage.getItem(i)??"[]");for(;y.length&&y[y.length-1].role==="user";)y.pop();return y}catch{return[]}}),[f,b]=h(""),[g,_]=h(!1),v=K(null),u=K(0),S=K(null);O(()=>{L.assistant().then(d).catch(()=>d({configured:!1}));let y=R=>R.key==="Escape"&&r();return document.addEventListener("keydown",y),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",y),document.body.classList.remove("locked")}},[]),O(()=>{try{sessionStorage.setItem(i,JSON.stringify(p.slice(-40)))}catch{}v.current?.scrollTo({top:v.current.scrollHeight,behavior:"smooth"})},[p,g]),O(()=>{l?.configured&&S.current?.focus()},[l?.configured]);let E=y=>{let R=y.trim();if(!R||g)return;let w=[...p,{role:"user",content:R}];m(w),b(""),_(!0);let x=u.current;L.ask(t.id,w.filter(P=>!P.error).map(({role:P,content:D})=>({role:P,content:D})),Pa(n),Z()).then(P=>x===u.current&&m([...w,{role:"assistant",content:P.reply||o("assistant.empty"),checked:P.tools.length}])).catch(P=>x===u.current&&m([...w,{role:"assistant",content:P.message,error:!0}])).finally(()=>x===u.current&&_(!1))};return e("div",{class:"scrim",onPointerDown:y=>y.target===y.currentTarget&&r(),children:e("div",{class:"drawer assistant",role:"dialog","aria-modal":"true","aria-labelledby":"assistant-title",ref:c,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",onClick:()=>{u.current++,_(!1),m([])},children:[e(M,{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:v,"aria-live":"polite",children:[l&&!l.configured?e("div",{class:"assistant-empty",children:[e("span",{class:"assistant-mark","aria-hidden":"true",children:e(M,{name:"robot"})}),e("p",{children:o(s?"assistant.setupOwner":"assistant.setupViewer")}),s?e("button",{type:"button",class:"solid",onClick:a,children:[e(M,{name:"key"}),o("assistant.setup")]}):null]}):p.length===0?e("div",{class:"assistant-empty",children:[e("span",{class:"assistant-mark","aria-hidden":"true",children:e(M,{name:"robot"})}),e("p",{children:o("assistant.intro")}),e("div",{class:"assistant-suggestions",children:La.map(y=>e("button",{type:"button",class:"ghost",disabled:!l,onClick:()=>E(o(y)),children:o(y)}))})]}):p.map(y=>e("div",{class:`message ${y.role}${y.error?" error":""}`,children:[y.role==="user"?e("p",{children:y.content}):e(Ra,{text:y.content}),y.checked?e("span",{class:"message-meta",children:Y("assistant.checked",y.checked)}):null]})),g?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]}),l?.configured?e("form",{class:"drawer-foot assistant-ask",onSubmit:y=>{y.preventDefault(),E(f)},children:[e("textarea",{ref:S,class:"value",rows:2,"aria-label":o("assistant.placeholder"),placeholder:o("assistant.placeholder"),value:f,onInput:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&!y.isComposing&&(y.preventDefault(),E(f))}}),e("button",{type:"submit",class:"solid",disabled:g||!f.trim(),"aria-label":o("assistant.send"),children:e(M,{name:"send"})})]}):null]})})}function Js({owner:t}){let[n,s]=h(null),[a,r]=h({provider:"anthropic",model:"",baseUrl:"",key:""}),[i,c]=h(""),[l,d]=h(!1),[p,m]=h(!1),[f,b]=h(null),[g,_]=h(!1),[v,u]=h(!1),[S,E]=h(""),[y,R]=h(""),[w,x]=h({}),P=()=>{E(""),u(!0),L.assistantModels({provider:a.provider,baseUrl:a.baseUrl,key:a.key}).then(C=>{b(C.models),_(!1),a.model||r(T=>({...T,model:C.models.some(N=>N.id===k?.model)?k.model:C.models[0]?.id??""}))}).catch(C=>E(C.message)).finally(()=>u(!1))},D=()=>L.assistant().then(C=>{s(C),r({provider:C.provider||"anthropic",model:C.model??"",baseUrl:C.baseUrl??"",key:""}),R(String(C.viewerDaily??""))}).catch(C=>c(C.message));if(O(()=>{D()},[]),!t)return e("p",{class:"settings-text",children:o("assistant.ownersOnly")});if(!n)return i?e("p",{class:"settings-error",children:i}):null;let F=n.providers??[],k=F.find(C=>C.id===a.provider),A=n.provider===a.provider,$=C=>{C.preventDefault(),c(""),d(!1),m(!0),L.saveAssistant(a).then(()=>(d(!0),D())).catch(T=>c(T.message)).finally(()=>m(!1))};return e(U,{children:[e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("assistant.settingsIntro")}),e(De,{icon:"eye",title:o("assistant.privacyTitle"),children:o("assistant.privacy")}),n.encrypted?null:e(De,{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:C=>{let T=C.target.value;r({provider:T,model:T===n.provider?n.model??"":"",baseUrl:T===n.provider?n.baseUrl??"":"",key:""}),b(null),E(""),d(!1)},children:F.map(C=>e("option",{value:C.id,children:C.name}))})]}),k&&(k.key!=="yes"||!k.baseUrl)?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.address")}),e("input",{class:"value",type:"url",placeholder:k.baseUrl||"https://api.example.com/v1",value:a.baseUrl,onInput:C=>r({...a,baseUrl:C.target.value})}),e("span",{class:"field-hint",children:o(k.key==="no"?"assistant.addressLocal":"assistant.addressHint")})]}):null,k?.key!=="no"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.key")}),e(re,{class:"value",autoComplete:"off",placeholder:A&&n.keySaved?o("mail.keepSaved"):"",value:a.key,onInput:C=>r({...a,key:C.target.value})})]}):null,e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.model")}),e("div",{class:"model-row",children:[f&&!g?e("select",{class:"value",value:a.model,onChange:C=>r({...a,model:C.target.value}),children:[a.model?null:e("option",{value:"",children:o("assistant.pickModel")}),a.model&&!f.some(C=>C.id===a.model)?e("option",{value:a.model,children:a.model}):null,f.map(C=>e("option",{value:C.id,children:C.name===C.id?C.id:`${C.name} (${C.id})`}))]}):e("input",{class:"value",type:"text",spellcheck:!1,"aria-label":o("assistant.model"),placeholder:k?.model||o("assistant.modelPlaceholder"),value:a.model,onInput:C=>r({...a,model:C.target.value})}),e("button",{type:"button",class:"ghost",disabled:v,onClick:P,children:[e(M,{name:"refresh"}),o(v?"assistant.loadingModels":"assistant.loadModels")]})]}),f?e("button",{type:"button",class:"text-button",onClick:()=>_(!g),children:o(g?"assistant.chooseFromList":"assistant.typeModel")}):e("span",{class:"field-hint",children:k?.model?o("assistant.modelDefault",{model:k.model}):o("assistant.modelHint")}),S?e("span",{class:"settings-error",children:S}):null]}),e("div",{class:"settings-actions",children:[e("button",{type:"submit",class:"solid",disabled:p,children:[e(M,{name:"save"}),o("settings.save")]}),l?e("span",{class:"settings-ok",children:o("settings.saved")}):null,i?e("span",{class:"settings-error",children:i}):null]})]}),n.configured?e("form",{class:"settings-group",onSubmit:C=>{C.preventDefault(),x({}),L.saveAssistantLimit(Number(y)).then(()=>x({saved:!0})).catch(T=>x({error:T.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:y,onInput:C=>R(C.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(M,{name:"save"}),o("settings.save")]}),w.saved?e("span",{class:"settings-ok",children:o("settings.saved")}):null,w.error?e("span",{class:"settings-error",children:w.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(te,{name:k?.name??"",onDelete:()=>{L.removeAssistant().then(D)}})})]})}):null]})}var Ia=(t,n)=>{let s=`mail.field.${t}`,a=o(s);return a===s?n:a};function Da({site:t,admin:n}){let[s,a]=h(null),[r,i]=h(!1),[c,l]=h({}),[d,p]=h(""),[m,f]=h(!1),[b,g]=h(""),[_,v]=h(""),u=()=>L.mail(t.remote?t.id:void 0).then(w=>{a(w),l({service:w.service||"ses",from:w.from,fromName:w.fromName,...w.fields})}).catch(w=>p(w.message));if(O(()=>{u()},[]),!s)return d?e("p",{class:"settings-error",children:d}):null;let S=s.services.find(w=>w.id===s.service);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?.name??s.service}),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(M,{name:"external"}),o("sites.openRemote")]})]});let E=s.services.find(w=>w.id===c.service)??s.services[0],y=w=>{w.preventDefault(),p(""),f(!0),L.saveMail(c).then(()=>(i(!1),u())).catch(x=>p(x.message)).finally(()=>f(!1))},R=w=>{w.preventDefault(),p(""),v(""),f(!0),L.testMail(b.trim(),Z()).then(()=>v(o("mail.testSent",{to:b.trim()}))).catch(x=>p(x.message)).finally(()=>f(!1))};return!n&&!s.source?e("p",{class:"settings-note",children:o("mail.adminOnly")}):r||!s.source?e("form",{class:"goal-form",onSubmit:y,children:[s.encrypted?null:e(De,{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:c.service,onChange:w=>l({...c,service:w.target.value}),children:s.services.map(w=>e("option",{value:w.id,children:w.name}))})]}),E.fields.map(w=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:[Ia(w.name,w.label),w.optional?e("span",{class:"optional",children:[" ",o("mail.optional")]}):null]}),w.options?e("select",{class:"value",value:c[w.name]||w.options[0],onChange:x=>l({...c,[w.name]:x.target.value}),children:w.options.map(x=>e("option",{value:x,children:x}))}):w.secret?e(re,{class:"value",autoComplete:"off",spellcheck:!1,placeholder:s.saved.includes(w.name)&&s.service===E.id?o("mail.keepSaved"):w.placeholder??"",value:c[w.name]??"",onInput:x=>l({...c,[w.name]:x.target.value})}):e("input",{class:"value",type:"text",autoComplete:"off",spellcheck:!1,placeholder:w.placeholder??"",value:c[w.name]??"",onInput:x=>l({...c,[w.name]:x.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:c.from??"",onInput:w=>l({...c,from:w.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:c.fromName??"",onInput:w=>l({...c,fromName:w.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:m,children:[e(M,{name:"check"}),o("mail.save")]}),s.source?e("button",{type:"button",class:"ghost",onClick:()=>i(!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?.name??s.service}),e("span",{class:"share-meta",children:o(s.source==="code"?"mail.fromCode":"mail.fromLine",{from:s.fromName?`${s.fromName} <${s.from}>`:s.from})})]}),s.source==="dashboard"&&n?e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(!0),children:[e(M,{name:"edit"}),o("mail.change")]}),e(te,{name:S?.name??"",onDelete:()=>{L.removeMail().then(u)}})]}):null]})}),e("form",{class:"domain-add",onSubmit:R,children:[e("input",{class:"value",type:"email",placeholder:o("mail.testTo"),value:b,onInput:w=>g(w.target.value)}),e("button",{type:"submit",class:"solid",disabled:m||!b.trim(),children:[e(M,{name:"send"}),o("mail.test")]})]}),_?e("p",{class:"settings-ok-text",children:[e(M,{name:"check"}),_]}):null,d?e("p",{class:"settings-error",children:d}):null]})}function $a(t){return t?new Intl.DateTimeFormat(Z(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t):o("reports.never")}function Xs({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(Da,{site:t,admin:n})]})}function Qs({site:t,onSetUp:n}){let[s,a]=h(null),[r,i]=h(null),[c,l]=h(""),[d,p]=h("weekly"),[m,f]=h(Z()),[b,g]=h(""),[_,v]=h(""),[u,S]=h(""),E=()=>L.reports(t.id).then(x=>i(x.reports)).catch(x=>g(x.message));O(()=>{E(),L.mail(t.remote?t.id:void 0).then(x=>a(!!x.source)).catch(()=>a(!1))},[t.id]);let y=x=>{x.preventDefault(),g(""),L.addReport(t.id,{email:c.trim(),frequency:d,lang:m,origin:`${location.origin}${de}`}).then(()=>(l(""),E())).catch(P=>g(P.message))},R=x=>{g(""),v(""),S(x.id),L.sendReport(t.id,x.id).then(()=>v(o("reports.sampleSent",{to:x.email}))).catch(P=>g(P.message)).finally(()=>S(""))},w=x=>Pe.find(([P])=>P===x)?.[1]??x;return e(U,{children:[s===!1?e("div",{class:"settings-group",children:e(De,{icon:"send",tone:"warn",title:o("reports.needsMailTitle"),action:t.remote?null:e("button",{type:"button",class:"ghost",onClick:n,children:[e(M,{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})})]}),r&&r.length?e("ul",{class:"domain-list",children:r.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 ",w(x.lang)," \xB7 ",o("reports.lastSent",{when:$a(x.lastSentAt)})]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",disabled:!s||u===x.id,onClick:()=>R(x),children:[e(M,{name:"send"}),o("reports.sample")]}),e(te,{name:x.email,onDelete:()=>{L.deleteReport(t.id,x.id).then(E)}})]})]}))}):r?e(V,{size:"card",icon:"send",title:o("reports.emptyTitle"),hint:o("reports.none")}):null,_?e("p",{class:"settings-ok-text",children:[e(M,{name:"check"}),_]}):null,e("form",{class:"report-add",onSubmit:y,children:[e("input",{class:"value",type:"email",placeholder:o("reports.emailPlaceholder"),value:c,onInput:x=>l(x.target.value)}),e("select",{class:"value",value:d,"aria-label":o("reports.frequency"),onChange:x=>p(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:m,"aria-label":o("reports.language"),onChange:x=>f(x.target.value),children:Pe.map(([x,P])=>e("option",{value:x,children:P}))}),e("button",{type:"submit",class:"solid",disabled:!c.trim(),children:[e(M,{name:"plus"}),o("reports.add")]})]}),b?e("p",{class:"settings-error",children:b}):null,e("p",{class:"field-hint",children:o("reports.when")})]})]})}var eo=t=>o(t.kind==="page"?"funnels.stepPage":"funnels.stepEvent",{match:t.match});function to({funnel:t}){let n=Math.max(1,t.steps[0]?.visits??0);return e("ol",{class:"funnel",children:t.steps.map((s,a)=>{let r=s.visits??0,i=a===0?r: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:eo(s)}),e("span",{class:"num",children:H(r)})]}),e("div",{class:"funnel-track",children:e("span",{class:"funnel-fill",style:{width:`${r/n*100}%`}})}),a>0?e("span",{class:"funnel-rate",children:o("funnels.wentOn",{pct:i?ne(r/i):ne(0)})}):null]})})})}function no({site:t,view:n}){let[s,a]=h(null),[r,i]=h(null),[c,l]=h(""),d=()=>L.funnels({...n,site:t.id}).then(p=>a(p.funnels)).catch(p=>l(p.message));return O(()=>{d()},[t.id]),r?e(Ha,{site:t,funnel:r==="new"?null:r,onDone:()=>{i(null),d()}}):e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("funnels.intro")}),s&&s.length?e("ul",{class:"domain-list goal-list",children:s.map(p=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:p.name}),e("span",{class:"share-meta",children:p.steps.map(eo).join(" \u2192 ")})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(p),children:[e(M,{name:"edit"}),o("goals.edit")]}),e(te,{name:p.name,onDelete:()=>{L.deleteFunnel(t.id,p.id).then(d)}})]})]}))}):s?e(V,{size:"card",icon:"funnel",title:o("funnels.emptyTitle"),hint:o("funnels.none")}):null,c?e("p",{class:"settings-error",children:c}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"solid",onClick:()=>i("new"),children:[e(M,{name:"plus"}),o("funnels.add")]})})]})}function Ha({site:t,funnel:n,onDone:s}){let[a,r]=h(n?.name??""),[i,c]=h(n?.steps.map(f=>({kind:f.kind,match:f.match}))??[{kind:"page",match:""},{kind:"page",match:""}]),[l,d]=h(""),p=(f,b)=>c(i.map((g,_)=>_===f?{...g,...b}:g));return e("form",{class:"settings-group",onSubmit:f=>{f.preventDefault(),d(""),L.saveFunnel(t.id,n?.id??null,{name:a.trim(),steps:i}).then(s).catch(b=>d(b.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:f=>r(f.target.value)})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("funnels.steps")}),e("ol",{class:"funnel-steps",children:i.map((f,b)=>e("li",{children:[e("span",{class:"funnel-step",children:b+1}),e("select",{class:"value",value:f.kind,"aria-label":o("funnels.kind"),onChange:g=>p(b,{kind:g.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:f.kind==="page"?"/pricing":"Signup",value:f.match,onInput:g=>p(b,{match:g.target.value})}),e("button",{type:"button",class:"remove","aria-label":o("funnels.removeStep"),disabled:i.length<=2,onClick:()=>c(i.filter((g,_)=>_!==b)),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")}),i.length<8?e("div",{children:e("button",{type:"button",class:"ghost",onClick:()=>c([...i,{kind:"page",match:""}]),children:[e(M,{name:"plus"}),o("funnels.addStep")]})}):null]}),e("div",{class:"settings-actions",children:[l?e("span",{class:"settings-error",children:l}):null,e("button",{type:"button",class:"ghost",onClick:s,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",children:[e(M,{name:"save"}),o(n?"funnels.save":"funnels.create")]})]})]})}var Oa=["USD","EUR","GBP","CAD","AUD","NZD","JPY","CHF","SEK","NOK","DKK","PLN","BRL","MXN","INR","SGD","HKD","ZAR"];function hn(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 so(t){return t.valueMode==="fixed"?o("goals.value.each",{amount:Oe(t.value,t.currency)}):t.valueMode==="prop"?o("goals.value.fromProp",{prop:t.valueProp,currency:t.currency}):""}function Fa(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])=>Oe(a,s)).join(" + ")}function oo({view:t,readOnly:n,onAdd:s}){let[a,r]=h(null),[i,c]=h(""),[l,d]=h(null),[p,m]=h([]),[f,b]=h("goals");if(O(()=>{let u=!0;return c(""),L.goals(t).then(S=>u&&r(S.goals)).catch(S=>u&&c(S.message)),L.funnels(t).then(S=>u&&m(S.funnels)).catch(()=>{}),()=>{u=!1}},[t]),n&&a&&a.length===0&&p.length===0)return null;if(f==="funnels"&&p.length)return e("section",{class:n?"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")})]}),n?null:e("button",{type:"button",class:"box-button icon-only",title:o("goals.add"),"aria-label":o("goals.add"),onClick:s,children:e(M,{name:"plus"})})]})]}),p.map(u=>e("div",{class:"funnel-block",children:[e("h3",{class:"funnel-name",children:u.name}),e(to,{funnel:u})]}))]});let g=Math.max(1,...(a??[]).map(u=>u.conversions)),_=a?Fa(a):"",v=[...a??[]].sort((u,S)=>S.conversions-u.conversions||u.name.localeCompare(S.name));return e("section",{class:n?"panel full":"panel",children:[e("header",{class:"panel-head",children:[e("h2",{children:[o("panel.conversions")," ",_?e("span",{class:"aside",children:o("goals.revenueAside",{amount:_})}):null]}),e("div",{class:"head-tools",children:[p.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,n?null:e("button",{type:"button",class:p.length?"box-button icon-only":"box-button",title:o("goals.add"),"aria-label":o("goals.add"),onClick:s,children:[e(M,{name:"plus"}),p.length?null:o("goals.add")]})]})]}),i?e("p",{class:"empty",children:i}):null,!a&&!i?e("p",{class:"empty",children:o("common.loading")}):null,a&&a.length===0?e(V,{icon:"target",title:o("goals.emptyTitle"),hint:o("goals.emptyHint")}):null,a&&a.length?e(U,{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:v.map(u=>e("li",{children:[e("span",{class:"bar",style:{width:`${u.conversions/g*100}%`}}),e("button",{type:"button",class:"name",title:hn(u),onClick:()=>d(u.id),children:[e("span",{class:"name-text",children:u.name}),u.valueMode!=="none"&&u.revenue?e("span",{class:"goal-money",children:Oe(u.revenue,u.currency)}):null]}),e("span",{class:"extra",children:ne(u.rate)}),e("span",{class:"num",children:H(u.conversions)})]}))})]})}):null,l?e(Na,{view:t,id:l,onClose:()=>d(null)}):null]})}function un({title:t,rows:n,dimension:s,currency:a,valued:r}){let i=Math.max(1,...n.map(c=>c.conversions));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(V,{size:"line",icon:"chart",title:o("empty.mini")}):null,e("ol",{class:"rows",children:n.map(c=>e("li",{children:[e("span",{class:"bar",style:{width:`${c.conversions/i*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:ae(s,c.value)||o("goals.unknown")})}),r?e("span",{class:"extra",children:Oe(c.revenue,a)}):null,e("span",{class:"num",children:H(c.conversions)})]}))})]})}function Na({view:t,id:n,onClose:s}){let[a,r]=h(null),[i,c]=h("");O(()=>{L.goal(t,n).then(r).catch(m=>c(m.message))},[t,n]);let l=a?.goal,d=!!(l&&l.valueMode!=="none"),p=l?[{key:"conversions",slot:1,label:o("goals.conversions"),format:H},...d?[{key:"revenue",slot:4,label:o("goals.revenue"),format:m=>Oe(m,l.currency)}]:[]]:[];return e(se,{title:l?.name??o("common.loading"),sub:l?hn(l):void 0,wide:!0,onClose:s,children:e("div",{class:"sheet-body",children:[i?e("p",{class:"failure",children:i}):null,a&&l?e(U,{children:[e("div",{class:"goal-tiles",children:[e("div",{children:[e("span",{children:o("goals.conversions")}),e("strong",{children:H(a.totals.conversions)})]}),e("div",{children:[e("span",{children:o("goals.converted")}),e("strong",{children:H(a.totals.visitors)})]}),e("div",{children:[e("span",{children:o("goals.rate")}),e("strong",{children:ne(a.totals.rate)})]}),d?e("div",{children:[e("span",{children:o("goals.revenue")}),e("strong",{children:Oe(a.totals.revenue,l.currency)})]}):null]}),e("h3",{class:"mini-title",children:o(d?"goals.overTimeValued":"goals.overTime")}),e("div",{class:"link-chart",children:e(Ke,{points:a.series,metrics:p,interval:a.range.interval,timezone:a.range.timezone,height:240})}),e("div",{class:"mini-grid three",children:[e(un,{title:"goals.byChannel",rows:a.channels,dimension:"channel",currency:l.currency,valued:d}),e(un,{title:"goals.bySource",rows:a.sources,dimension:"source",currency:l.currency,valued:d}),e(un,{title:"goals.byPage",rows:a.pages,dimension:"page",currency:l.currency,valued:d})]})]}):null]})})}var Ua={name:"",kind:"event",match:"",clickBy:"selector",valueMode:"none",value:0,valueProp:"revenue",currency:"USD"};function mn({value:t,options:n,onChange:s,label:a}){return e("div",{class:"ops",role:"radiogroup","aria-label":a,children:n.map(([r,i])=>e("button",{type:"button",role:"radio","aria-checked":t===r,class:t===r?"op on":"op",onClick:()=>s(r),children:o(i)}))})}function za({site:t,goal:n,view:s,onDone:a}){let[r,i]=h(()=>n?{...n}:{...Ua,currency:ja()}),[c,l]=h(""),[d,p]=h(!1),[m,f]=h([]),[b,g]=h(!1),_=K(null),v=R=>i(w=>({...w,...R}));O(()=>{if(r.kind==="click")return f([]);L.breakdown({...s,period:"90d",from:"",to:"",filters:[]},r.kind==="event"?"event":"page",50).then(R=>f(R.rows.map(w=>w.value).filter(Boolean))).catch(()=>f([]))},[r.kind]),O(()=>{let R=w=>{if(!_.current||w.source!==_.current)return;let x=w.data;x?.runlight!=="pick"||typeof x.selector!="string"||(g(!1),v({match:x.selector.slice(0,500),clickBy:"selector",...r.name?{}:{name:(x.text||"").slice(0,60)}}))};return window.addEventListener("message",R),()=>window.removeEventListener("message",R)},[r.name]);let u=t.hostnames[0],S=()=>{if(!u)return;g(!0);let R=window.open("about:blank","runlight-pick");_.current=R,L.pickTicket(t.id,location.origin).then(({ticket:w})=>{R&&(R.location.href=`https://${u}/?runlight=pick&runlight_lang=${Z().slice(0,2)}&runlight_ticket=${encodeURIComponent(w)}`)}).catch(w=>{R?.close(),g(!1),l(w.message)})},E=R=>{R.preventDefault(),l(""),p(!0),(n?L.updateGoal(t.id,n.id,r):L.createGoal(t.id,r)).then(a).catch(w=>l(w.message)).finally(()=>p(!1))},y="goal-suggestions";return e("form",{class:"goal-form",onSubmit:E,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:r.name,placeholder:o("goals.namePlaceholder"),onInput:R=>v({name:R.target.value})})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.counts")}),e(mn,{label:o("goals.counts"),value:r.kind,options:[["event","goals.kind.event"],["page","goals.kind.page"],["click","goals.kind.click"]],onChange:R=>v({kind:R,match:"",...R!=="event"&&r.valueMode==="prop"?{valueMode:"fixed"}:{}})})]}),r.kind==="click"?e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.clickOn")}),e(mn,{label:o("goals.clickOn"),value:r.clickBy==="link"?"link":"selector",options:[["selector","goals.click.selector"],["link","goals.click.link"]],onChange:R=>v({clickBy:R,match:""})})]}):null,e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o(r.kind==="event"?"goals.match.event":r.kind==="page"?"goals.match.page":r.clickBy==="link"?"goals.match.link":"goals.match.selector")}),e("div",{class:"match-row",children:[e("input",{class:"value",type:"text",spellcheck:!1,list:m.length?y:void 0,value:r.match,placeholder:r.kind==="event"?"Signup":r.kind==="page"?"/thanks*":r.clickBy==="link"?"https://buy.stripe.com/*":"#signup, .buy-button",onInput:R=>v({match:R.target.value})}),r.kind==="click"&&r.clickBy!=="link"&&u?e("button",{type:"button",class:"ghost",onClick:S,children:[e(M,{name:"target"}),o(b?"goals.picking":"goals.pick")]}):null]}),e("datalist",{id:y,children:m.map(R=>e("option",{value:R}))}),e("span",{class:"field-hint",children:o(r.kind==="event"?"goals.hint.event":r.kind==="page"?"goals.hint.page":r.clickBy==="link"?"goals.hint.link":"goals.hint.selector")})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.valueLabel")}),e(mn,{label:o("goals.valueLabel"),value:r.valueMode,options:[["none","goals.value.none"],["fixed","goals.value.fixed"],...r.kind==="event"?[["prop","goals.value.prop"]]:[]],onChange:R=>v({valueMode:R})})]}),r.valueMode!=="none"?e("div",{class:"value-row",children:[r.valueMode==="fixed"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.amount")}),e("input",{class:"value",type:"number",min:"0",step:"0.01",value:String(r.value||""),onInput:R=>v({value:Number(R.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:r.valueProp,onInput:R=>v({valueProp:R.target.value})})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.currency")}),e("select",{class:"value",value:r.currency,onChange:R=>v({currency:R.target.value}),children:Oa.map(R=>e("option",{value:R,children:R}))})]})]}):null,r.valueMode==="prop"?e("div",{class:"code small",children:e("pre",{children:e("code",{children:`runlight("${r.kind==="event"&&r.match?r.match:"Purchase"}", { ${r.valueProp||"revenue"}: 49.99 })`})})}):null,c?e("p",{class:"settings-error",children:c}):null,e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:d,children:[e(M,{name:"check"}),o(n?"goals.save":"goals.create")]}),e("button",{type:"button",class:"ghost",onClick:a,children:o("goals.cancel")})]})]})}function ja(){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 ao({site:t,view:n}){let[s,a]=h(null),[r,i]=h(null),[c,l]=h(""),d=()=>L.goals({...n,site:t.id}).then(m=>a(m.goals)).catch(m=>l(m.message));O(()=>{d()},[t.id]);let p=Ae(()=>s??[],[s]);return r?e("div",{class:"settings-group",children:e(za,{site:t,view:n,goal:r==="new"?null:r,onDone:()=>{i(null),d()}})}):e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("goals.intro")}),p.length?e("ul",{class:"domain-list goal-list",children:p.map(m=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:m.name}),e("span",{class:"share-meta",children:[hn(m),so(m)?` \xB7 ${so(m)}`:""]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(m),children:[e(M,{name:"edit"}),o("goals.edit")]}),e(te,{name:m.name,onDelete:()=>{L.deleteGoal(t.id,m.id).then(d)}})]})]}))}):s?e(V,{size:"card",icon:"target",title:o("goals.emptyTitle"),hint:o("goals.none")}):null,c?e("p",{class:"settings-error",children:c}):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:()=>i("new"),children:[e(M,{name:"plus"}),o("goals.add")]})})]})}var ro=[{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:[]}],io=t=>t.code&&be(t.code,t.params)||t.reason,Ve={running:!1,done:0,total:null,links:0,clicks:0,skipped:0,failed:[],finished:!1,stopped:!1,error:""};function lo({site:t}){let[n,s]=h("umami"),[a,r]=h({}),[i,c]=h("key"),[l,d]=h(Ve),p=K(!1),m=K(null),f=ro.find(u=>u.id===n),b=n==="umami"?[...f.fields,...i==="key"?[{name:"apiKey",label:"import.apiKey",type:"password"}]:[{name:"username",label:"import.username"},{name:"password",label:"import.password",type:"password"}]]:f.fields,g=async()=>{p.current=!1;let u={...Ve,running:!0};d(u);let S=Object.fromEntries(b.map(y=>[y.name,a[y.name]??""])),E=null;try{do{let y=await L.importStep(t.id,n,S,E,u.done);E=y.cursor,u={...u,done:y.done,total:y.total,links:u.links+y.links,clicks:u.clicks+y.clicks,skipped:u.skipped+y.skipped,failed:[...u.failed,...y.failed.map(R=>({slug:R.slug,reason:io(R)}))]},d(u)}while(E&&!p.current);d({...u,running:!1,finished:!E,stopped:!!E})}catch(y){d({...u,running:!1,error:y instanceof Error?y.message:String(y)})}},_=async u=>{d({...Ve,running:!0});try{let S=at(await u.text()),E=await L.importLinks(t.id,S);d({...Ve,finished:!0,links:E.created,done:S.length,total:S.length,failed:E.failed.map(y=>({slug:`#${y.row}`,reason:io(y)}))})}catch(S){d({...Ve,error:S instanceof Error?S.message:String(S)})}},v=l.total?Math.min(100,Math.round(l.done/l.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:ro.map(u=>e("button",{type:"button",role:"radio","aria-checked":n===u.id,class:n===u.id?"source on":"source",disabled:l.running,onClick:()=>{s(u.id),d(Ve)},children:[e("strong",{children:u.id==="csv"?o("import.csv"):u.name}),e("span",{children:o(`import.history.${u.history}`)})]}))})]}),e("p",{class:"field-hint",children:o(f.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(u=>e("button",{type:"button",role:"radio","aria-checked":i===u,class:i===u?"op on":"op",onClick:()=>c(u),children:o(u==="key"?"import.withKey":"import.withPassword")}))})]}):null,b.map(u=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o(u.label)}),u.type==="password"?e(re,{class:"value",autoComplete:"off",spellcheck:!1,placeholder:u.placeholder,value:a[u.name]??"",onInput:S=>r({...a,[u.name]:S.target.value})}):e("input",{class:"value",type:u.type??"text",autoComplete:"off",spellcheck:!1,placeholder:u.placeholder,value:a[u.name]??"",onInput:S=>r({...a,[u.name]:S.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(U,{children:[e("button",{type:"button",class:"solid",disabled:l.running,onClick:()=>m.current?.click(),children:[e(M,{name:"upload"}),o("import.chooseFile")]}),e("input",{ref:m,type:"file",accept:".csv,text/csv",hidden:!0,onChange:u=>{let S=u.target.files?.[0];S&&_(S),u.target.value=""}})]}):l.running?e("button",{type:"button",class:"ghost",onClick:()=>p.current=!0,children:[e(M,{name:"x"}),o("import.stop")]}):e("button",{type:"button",class:"solid",onClick:()=>{g()},children:[e(M,{name:"upload"}),o("import.start")]})}),l.running||l.finished||l.stopped||l.error?e("div",{class:"import-progress","aria-live":"polite",children:[l.running?e(U,{children:[e("div",{class:"progress-bar",children:e("span",{class:v===null?"progress-fill indeterminate":"progress-fill",style:v===null?void 0:{width:`${v}%`}})}),e("span",{class:"field-hint",children:[l.total?o("import.running",{done:H(l.done),total:H(l.total)}):Y("import.soFar",l.links,{n:H(l.links)}),l.clicks?` \xB7 ${Y("links.total",l.clicks,{n:H(l.clicks)})}`:""]})]}):null,l.error?e("p",{class:"settings-error",children:l.error}):null,l.finished?e("p",{class:"settings-ok-text",children:[e(M,{name:"check"}),o("import.done",{links:H(l.links),clicks:H(l.clicks),skipped:H(l.skipped)})]}):null,l.stopped?e("p",{class:"field-hint",children:o("import.stopped",{done:H(l.done),total:H(l.total??l.done)})}):null,l.failed.length?e("div",{class:"import-result",children:[e("strong",{children:o("import.failed")}),l.failed.slice(0,20).map(u=>e("span",{children:[u.slug,": ",u.reason]}))]}):null]}):null]})}function co(t){let n=s=>t.includes(s);return n("created_at")&&n("url_path")?"umami":n("time")&&(n("path")||n("url"))?"runlight":null}function po(t,n){let s=(n==="umami"?t.created_at:t.time)?.trim()??"";if(!s)return NaN;if(/^\d+(\.\d+)?$/.test(s)){let r=Number(s);return r<1e12?Math.round(r*1e3):Math.round(r)}let a=s.replace(" ","T");return Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(a)||!/T\d/.test(a)?a:`${a}Z`)}var Se={running:!1,done:0,total:0,pageviews:0,events:0,visits:0,finished:!1,stopped:!1,error:""},Ka=t=>t.toLowerCase().replace(/^https?:\/\//,"").replace(/^www\./,"").replace(/\/.*$/,"");function mo({site:t}){let[n,s]=h("umami");return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("visits.intro")}),e(De,{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(Va,{site:t}):e(qa,{site:t})]})}function Ba(t,n){let s=t.map(i=>({row:i,ts:po(i,n)})).filter(i=>Number.isFinite(i.ts));s.sort((i,c)=>i.ts-c.ts);let a=[],r=0;for(;r<s.length;){let i=Math.min(r+2e3,s.length);for(;i<s.length&&i>r&&s[i].ts===s[i-1].ts;)i--;if(i===r)return null;a.push(s.slice(r,i).map(c=>c.row)),r=i}return a}function qa({site:t}){let[n,s]=h(null),[a,r]=h({...Se,skipped:0}),i=K(null),c=K(!1),l=async m=>{s(null),r({...Se,skipped:0});let f=at(await m.text()),b=co(Object.keys(f[0]??{}));if(!b||!f.length){r({...Se,skipped:0,error:o("error.import_csv_format")});return}s({name:m.name,rows:f,format:b})},d=async()=>{if(!n)return;c.current=!1;let m=Ba(n.rows,n.format);if(!m){r({...Se,skipped:0,error:o("visits.csvMoment",{max:H(2e3)})});return}let f=n.rows.length-m.reduce((g,_)=>g+_.length,0),b={...Se,skipped:f,running:!0,total:n.rows.length};r(b);try{for(let _ of m){if(c.current)break;let v=await L.importCsvVisits(t.id,_);b={...b,done:b.done+_.length,pageviews:b.pageviews+v.pageviews,events:b.events+v.events,visits:b.visits+v.visits,skipped:b.skipped+v.skipped},r(b)}let g=b.done+f>=n.rows.length;r({...b,running:!1,finished:g,stopped:!g})}catch(g){r({...b,running:!1,error:g instanceof Error?g.message:String(g)})}},p=a.total?Math.min(100,Math.round(a.done/a.total*100)):0;return e(U,{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:()=>c.current=!0,children:[e(M,{name:"x"}),o("import.stop")]}):e(U,{children:[e("button",{type:"button",class:n?"ghost":"solid",onClick:()=>i.current?.click(),children:[e(M,{name:"upload"}),o(n?"visits.csvOther":"visits.csvChoose")]}),n?e("button",{type:"button",class:"solid",onClick:()=>{d()},children:[e(M,{name:"upload"}),o("visits.start")]}):null]}),e("input",{ref:i,type:"file",accept:".csv,text/csv",hidden:!0,onChange:m=>{let f=m.target.files?.[0];f&&l(f),m.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:H(n.rows.length)})}):null,a.running||a.finished||a.stopped||a.error?e("div",{class:"import-progress","aria-live":"polite",children:[a.running?e(U,{children:[e("div",{class:"progress-bar",children:e("span",{class:"progress-fill",style:{width:`${p}%`}})}),e("span",{class:"field-hint",children:o("visits.csvRunning",{done:H(a.done),total:H(a.total),pageviews:H(a.pageviews)})})]}):null,a.error?e("p",{class:"settings-error",children:a.error}):null,a.finished?e("p",{class:"settings-ok-text",children:[e(M,{name:"check"}),o("visits.done",{pageviews:H(a.pageviews),visits:H(a.visits),events:H(a.events)})]}):null,(a.finished||a.stopped)&&a.skipped?e("p",{class:"field-hint",children:o("visits.csvSkipped",{n:H(a.skipped)})}):null,a.stopped?e("p",{class:"field-hint",children:o("visits.csvStopped")}):null]}):null]})}function Va({site:t}){let[n,s]=h({}),[a,r]=h("key"),[i,c]=h(null),[l,d]=h(""),[p,m]=h(!1),[f,b]=h(Se),g=K(!1),_=a==="key"?["url","apiKey"]:["url","username","password"],v=()=>Object.fromEntries(_.map(x=>[x,n[x]??""])),u=()=>{c(null),d("")},S=(x,P)=>{s({...n,[x]:P}),u()},E=async()=>{m(!0),b(Se);try{let x=await L.umamiWebsites(v());c(x.websites);let P=x.websites.find(D=>t.hostnames.includes(Ka(D.domain)));d(P?.id??x.websites[0]?.id??"")}catch(x){b({...Se,error:x instanceof Error?x.message:String(x)})}finally{m(!1)}},y=async()=>{g.current=!1;let x={...Se,running:!0};b(x);let P=null;try{do{let D=await L.importVisits(t.id,v(),l,P);P=D.cursor,x={...x,done:D.done,total:D.total,pageviews:x.pageviews+D.pageviews,events:x.events+D.events,visits:x.visits+D.visits},b(x)}while(P&&!g.current);b({...x,running:!1,finished:!P,stopped:!!P})}catch(D){b({...x,running:!1,error:D instanceof Error?D.message:String(D)})}},R=f.total?Math.min(100,Math.round(f.done/f.total*100)):0,w=x=>o(x==="url"?"import.url":x==="apiKey"?"import.apiKey":x==="username"?"import.username":"import.password");return e(U,{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:f.running,onClick:()=>{r(x),u()},children:o(x==="key"?"import.withKey":"import.withPassword")}))})]}),_.map(x=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:w(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:f.running,onInput:P=>S(x,P.target.value)}):e(re,{class:"value",autoComplete:"off",spellcheck:!1,value:n[x]??"",disabled:f.running,onInput:P=>S(x,P.target.value)})]})),e("p",{class:"field-hint",children:o("import.umamiHelp")}),i?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("visits.website")}),i.length?e("select",{class:"value",value:l,disabled:f.running,onChange:x=>d(x.target.value),children:i.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:!i||!l?e("button",{type:"button",class:"solid",disabled:p||!n.url,onClick:()=>{E()},children:[e(M,{name:"refresh"}),o("visits.find")]}):f.running?e("button",{type:"button",class:"ghost",onClick:()=>g.current=!0,children:[e(M,{name:"x"}),o("import.stop")]}):e("button",{type:"button",class:"solid",onClick:()=>{y()},children:[e(M,{name:"upload"}),o("visits.start")]})}),f.running||f.finished||f.stopped||f.error?e("div",{class:"import-progress","aria-live":"polite",children:[f.running?e(U,{children:[e("div",{class:"progress-bar",children:e("span",{class:"progress-fill",style:{width:`${R}%`}})}),e("span",{class:"field-hint",children:o("visits.running",{done:H(f.done),total:H(f.total),pageviews:H(f.pageviews)})})]}):null,f.error?e("p",{class:"settings-error",children:f.error}):null,f.finished?e("p",{class:"settings-ok-text",children:[e(M,{name:"check"}),o("visits.done",{pageviews:H(f.pageviews),visits:H(f.visits),events:H(f.events)})]}):null,f.stopped?e("p",{class:"field-hint",children:o("visits.stopped")}):null]}):null]})}function ho(t){let{domain:n,host:s,origin:a,base:r,linkPath:i}=t;return`Set up a custom short link domain for Runlight, the analytics in this project.
|
|
3
|
+
`&&d++,s.push(a),a="",s.some(m=>m.trim())&&n.push(s),s=[]):a+=p}s.push(a),s.some(d=>d.trim())&&n.push(s);let[i,...c]=n;if(!i)return[];let l=i.map(d=>d.trim().toLowerCase().replace(/^/,""));return c.map(d=>Object.fromEntries(l.map((p,m)=>[p,(d[m]??"").trim()])))}var At=100;function te({name:t,onDelete:n,label:s,confirm:a,icon:r="trash",hint:i}){let[c,l]=h(!1);return F(()=>{if(!c)return;let d=setTimeout(()=>l(!1),4e3);return()=>clearTimeout(d)},[c]),e("button",{type:"button",class:c?"copy inline danger armed":"copy inline danger",title:c?i??o("app.confirmDelete",{name:t}):void 0,onClick:()=>c?n():l(!0),children:[e(C,{name:r}),c?a??o("links.confirm"):s??o("links.delete")]})}function fa({view:t,site:n,readOnly:s,onClose:a,onChanged:r}){let[i,c]=h(null),[l,d]=h(""),[p,m]=h([]),[f,b]=h(""),[g,k]=h(""),[v,u]=h("newest"),[_,T]=h(At);F(()=>{let M=setTimeout(()=>b(g),120);return()=>clearTimeout(M)},[g]),F(()=>T(At),[f,v]);let[y,P]=h(null),[w,x]=h(null),[A,$]=h(null),N=K(null),S=()=>{L.links(t).then(M=>{c(M.links),d(M.prefix),m(M.domains)}).catch(M=>{c(I=>I??[]),$({text:M.message,failures:[]})})};F(S,[t]);let E=Ae(()=>{let M=f.trim().toLowerCase();return(i??[]).filter(B=>!M||`${B.name} ${B.slug} ${B.url} ${B.domain}`.toLowerCase().includes(M)).sort((B,ae)=>v==="clicks"?(ae.clicks??0)-(B.clicks??0)||ae.createdAt-B.createdAt:v==="newest"?ae.createdAt-B.createdAt:B.name.localeCompare(ae.name))},[i,f,v]),H=()=>{S(),r()},R=async M=>{try{let I=at(await M.text());if(!I.some(ve=>ve.url||ve.destination_url)){$({text:o("links.importNoUrl"),failures:[]});return}let B=await L.importLinks(n,I),ae=B.failed.map(ve=>({row:ve.row,reason:ve.code&&be(ve.code,ve.params)||ve.reason}));$({text:Y("links.importDone",B.created,{n:O(B.created)}),failures:ae}),H()}catch(I){$({text:I.message,failures:[]})}};return w?e(Ms,{view:t,id:w,prefix:l,domains:p,onClose:()=>x(null)}):y?e(Ts,{site:n,prefix:l,domains:p,link:y==="new"?void 0:y,onClose:()=>P(null),onSaved:H}):e(se,{title:o("panel.links"),sub:i?f?`${O(E.length)} / ${O(i.length)}`:O(i.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:g,onInput:M=>k(M.target.value)}),e("select",{class:"field","aria-label":o("links.sortBy"),value:v,onChange:M=>u(M.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(U,{children:[e("button",{type:"button",class:"ghost",title:o("links.importHelp"),onClick:()=>N.current?.click(),children:[e(C,{name:"upload"}),o("links.import")]}),e("input",{ref:N,type:"file",accept:".csv,text/csv",hidden:!0,onChange:M=>{let I=M.target.files?.[0];I&&R(I),M.target.value=""}}),e("button",{type:"button",class:"solid",onClick:()=>P("new"),children:[e(C,{name:"plus"}),o("links.new")]})]})]}),A?e("div",{class:"import-result",children:[e("strong",{children:A.text}),A.failures.slice(0,8).map(M=>e("span",{children:o("links.importFailed",{row:M.row,reason:M.reason})}))]}):null,e("div",{class:"sheet-body",children:[i&&i.length===0?e(G,{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:E.slice(0,_).map(M=>{let I=Pt(M,l,p);return e("tr",{children:[e("td",{class:"sheet-name",children:e("button",{type:"button",class:"link-cell",onClick:()=>x(M.id),children:[e("span",{class:"link-name",children:M.name}),e("span",{class:"link-short",children:ye(I)}),e("span",{class:"link-dest",children:ye(M.url)}),e("span",{class:"link-date",children:o("links.createdOn",{date:Ss(M)})})]})}),e("td",{class:"numeric lead",children:[O(M.clicks??0),e("span",{class:"link-unit",children:o("links.clicks")})]}),e("td",{class:"numeric link-actions",children:[e(rn,{text:I,small:!0}),s?null:e(U,{children:[e("button",{type:"button",class:"copy inline",onClick:()=>P(M),children:[e(C,{name:"edit"}),o("links.editButton")]}),e(te,{name:M.name,hint:o("links.confirmDelete",{name:M.name}),onDelete:()=>L.deleteLink(n,M.id).then(H,B=>$({text:B.message,failures:[]}))})]})]})]})})})}),E.length>_?e("div",{class:"more-row",children:[e("span",{class:"field-hint",children:o("links.showing",{shown:O(_),total:O(E.length)})}),e("button",{type:"button",class:"more",onClick:()=>T(_+At),children:[e(C,{name:"plus"}),o("links.showMore",{n:At})]})]}):null]})]})}function Es({view:t,site:n,readOnly:s}){let[a,r]=h(null),[i,c]=h(""),[l,d]=h([]),[p,m]=h(null),[f,b]=h(0),[g,k]=h("newest");F(()=>{let T=!0;return L.links(t).then(y=>{T&&(r(y.links),c(y.prefix),d(y.domains))}).catch(()=>T&&r([])),()=>{T=!1}},[t,f]);let v=[...a??[]].sort((T,y)=>g==="newest"?y.createdAt-T.createdAt:(y.clicks??0)-(T.clicks??0)||y.createdAt-T.createdAt).slice(0,10),u=Math.max(1,...v.map(T=>T.clicks??0)),_=(a??[]).reduce((T,y)=>T+(y.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:[Y("links.total",_,{n:O(_)}),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:g==="newest"?"tab on":"tab","aria-pressed":g==="newest",onClick:()=>k("newest"),children:o("links.sortNewest")}),e("button",{type:"button",class:g==="clicks"?"tab on":"tab","aria-pressed":g==="clicks",onClick:()=>k("clicks"),children:o("links.sortClicks")})]}),s?null:e(U,{children:[a?.length?e("button",{type:"button",class:"box-button",onClick:()=>m("manage"),children:[e(C,{name:"list"}),o("links.manage")]}):null,e("button",{type:"button",class:"box-button solid",onClick:()=>m("new"),children:[e(C,{name:"plus"}),o("links.new")]})]})]})]}),a&&a.length===0?e(G,{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("p",{class:"empty",children:o("common.loading")}),e("ol",{class:"rows",children:v.map(T=>e("li",{children:[e("span",{class:"bar",style:{width:`${(T.clicks??0)/u*100}%`}}),e("button",{type:"button",class:"name",title:ye(Pt(T,i,l)),onClick:()=>m({id:T.id}),children:[e("span",{class:"name-text",children:T.name}),e("span",{class:"link-slug",children:["/",T.slug]})]}),e("span",{class:"num",children:O(T.clicks??0)})]}))})]}),a&&a.length>v.length?e("button",{type:"button",class:"more",onClick:()=>m("manage"),children:[e(C,{name:"expand"}),o("panel.more")]}):null,p==="new"?e(Ts,{site:n,prefix:i,domains:l,onClose:()=>m(null),onSaved:()=>b(T=>T+1)}):p==="manage"?e(fa,{view:t,site:n,readOnly:s,onClose:()=>m(null),onChanged:()=>b(T=>T+1)}):p?e(Ms,{view:t,id:p.id,prefix:i,domains:l,onClose:()=>m(null)}):null]})}function As({view:t,event:n,onClose:s}){let[a,r]=h(null),[i,c]=h(null),[l,d]=h("");F(()=>{let f=!0;return L.eventProps(t,n,a).then(b=>f&&c(b)).catch(b=>f&&d(b.message)),()=>{f=!1}},[n,a,t]);let p=i?.rows??[],m=Math.max(1,...p.map(f=>f.events));return e(se,{title:n,sub:o("props.title"),wide:!0,onClose:s,children:e("div",{class:"sheet-body props-body",children:[i&&i.keys.length>1?e("div",{class:"ops props-keys",role:"radiogroup","aria-label":o("props.title"),children:i.keys.map(f=>e("button",{type:"button",role:"radio","aria-checked":i.key===f.key,class:i.key===f.key?"op on":"op",onClick:()=>r(f.key),children:f.key}))}):null,l?e("p",{class:"settings-error",children:l}):null,i&&i.keys.length===0?e(G,{icon:"list",title:o("props.emptyTitle"),hint:o("props.none")}):null,i&&i.key?e(U,{children:e("div",{class:"table",children:[e("div",{class:"cols",children:[e("span",{children:i.key}),e("span",{class:"extra",children:o("column.visitors")}),e("span",{class:"num-head",children:o("column.events")})]}),e("ol",{class:"rows",children:p.map(f=>e("li",{children:[e("span",{class:"bar",style:{width:`${f.events/m*100}%`}}),e("span",{class:"name",title:f.value,children:e("span",{class:"name-text",children:f.value})}),e("span",{class:"extra",children:O(f.visitors)}),e("span",{class:"num",children:O(f.events)})]}))})]})}):null,!i&&!l?e("p",{class:"empty",children:o("common.loading")}):null]})})}var va=[2,3,4,5,6,7,8],ln=(t,n)=>`${t}\0${n}`;function Ps({view:t,onClose:n}){let[s,a]=h(5),[r,i]=h(""),[c,l]=h(""),[d,p]=h(null),[m,f]=h(null),[b,g]=h([]),[k,v]=h(""),[u,_]=h(new Map),T=K(null);F(()=>{L.breakdown(t,"page",100).then(A=>g(A.rows.map($=>$.value))).catch(()=>{})},[t]),F(()=>{let A=!0;return v(""),L.journeys(t,{steps:s,start:r,end:c,through:d}).then($=>A&&f($)).catch($=>A&&v($.message)),()=>{A=!1}},[t,s,r,c,d]),ts(()=>{let A=T.current;if(!A||!m)return;let $=()=>{let S=A.getBoundingClientRect(),E=new Map;for(let H of A.querySelectorAll("[data-box]")){let R=H.getBoundingClientRect();E.set(H.dataset.box,{x1:R.left-S.left,x2:R.right-S.left,y:R.top-S.top+R.height/2})}_(E)};$();let N=new ResizeObserver($);return N.observe(A),()=>N.disconnect()},[m]);let y=m?.columns??[],P=Math.max(1,...(m?.links??[]).map(A=>A.visits)),w=A=>A?Ke(A):o("journeys.other"),x=(A,$)=>p(d&&d.step===A&&d.value===$?null:$?{step:A,value:$}:null);return e(se,{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:A=>{let $=Number(A.target.value);a($),d&&d.step>=$&&p(null)},children:va.map(A=>e("option",{value:String(A),children:o("journeys.stepCount",{n:A})}))})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.start")}),e("select",{class:"value",value:r,onChange:A=>{i(A.target.value),p(null)},children:[e("option",{value:"",children:o("journeys.anyPage")}),b.map(A=>e("option",{value:A,children:A}))]})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("journeys.end")}),e("select",{class:"value",value:c,onChange:A=>l(A.target.value),children:[e("option",{value:"",children:o("journeys.anyPage")}),b.map(A=>e("option",{value:A,children:A}))]})]})]}),d?e("p",{class:"journey-following",children:[o("journeys.following",{page:Ke(d.value),step:d.step+1}),e("button",{type:"button",class:"copy inline",onClick:()=>p(null),children:[e(C,{name:"x"}),o("common.clearAll")]})]}):null,m?.sampled?e("p",{class:"field-hint",children:o("journeys.sampled",{n:O(m.sampled)})}):null,k?e("p",{class:"settings-error",children:k}):null,m?m.visits===0?e(G,{icon:"arrive",title:o("journeys.emptyTitle"),hint:o("journeys.none")}):e("div",{class:"journey-scroll",children:e("div",{class:"journey-grid",ref:T,style:{gridTemplateColumns:`repeat(${y.length}, minmax(150px, 1fr))`},children:[e("svg",{class:"journey-links","aria-hidden":"true",children:m.links.map(A=>{let $=u.get(ln(A.step,A.from)),N=u.get(ln(A.step+1,A.to));if(!$||!N)return null;let S=($.x2+N.x1)/2,E=d?d.step===A.step&&d.value===A.from||d.step===A.step+1&&d.value===A.to:!1;return e("path",{class:E?"lit":"",d:`M${$.x2},${$.y} C${S},${$.y} ${S},${N.y} ${N.x1},${N.y}`,style:{strokeWidth:Math.max(1.5,A.visits/P*16)}})})}),y.map((A,$)=>e("div",{class:"journey-column",children:[e("p",{class:"journey-step",children:[o("journeys.step",{n:$+1}),e("span",{children:O(A.visits)})]}),A.items.map(N=>e("button",{type:"button","data-box":ln($,N.value),class:`journey-page${N.value?"":" other"}${d&&d.step===$&&d.value===N.value?" on":""}`,title:N.value?o("journeys.follow",{page:Ke(N.value)}):void 0,disabled:!N.value,onClick:()=>x($,N.value),children:[e("span",{class:"journey-name",children:w(N.value)}),e("span",{class:"journey-count",children:[O(N.visits),e("span",{class:"journey-share",children:[Math.round(N.visits/A.visits*100),"%"]})]})]})),A.left?e("p",{class:"journey-left",children:o("journeys.left",{n:O(A.left)})}):null]}))]})}):e("p",{class:"empty",children:o("common.loading")})]})})}var Rs=8,Ls=1e3;function re(t,n){return n?t==="country"?`${fe(n)} ${ge(n)}`.trim():t==="region"?`${fe(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"?Ke(n):n:o("common.none")}function ba({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} ${ne(s.n/n)}`).join(", "),children:t.map(s=>e("span",{class:`mix-part s${s.slot}`,style:{flexGrow:String(s.n)},title:`${s.name}: ${ne(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:ne(s.n/n)})]}))})]})}function ya({rows:t,tab:n,onFilter:s,onDetail:a}){let r=n.column??"visitors",i=Math.max(1,...t.map(l=>Number(l[r]??0))),c=l=>n.colors?.[l]??(n.groups?n.groups.slots[n.groups.of(l)]:void 0);return e("ol",{class:"rows",children:t.map(l=>{let d=Number(l[r]??0),p=re(n.dimension,l.value),m=c(l.value),f=e(U,{children:[m!==void 0?e("span",{class:`swatch s${m}`}):null,e("span",{class:"name-text",children:p})]});return e("li",{children:[e("span",{class:"bar",style:{width:`${d/i*100}%`}}),n.filterable?e("button",{type:"button",class:"name",title:o("panel.filterBy",{name:p}),onClick:()=>s(n.dimension,l.value),children:f}):e("span",{class:"name",children:f}),n.extra?e("span",{class:"extra",children:n.extra.format(Number(l[n.extra.key]??0))}):null,a?e("button",{type:"button",class:"row-detail",title:o("props.open",{name:p}),"aria-label":o("props.open",{name:p}),onClick:()=>a(l.value),children:e(C,{name:"list"})}):null,e("span",{class:"num",children:O(d)})]})})})}function xa({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 wa=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 Ds(t){let n=i=>c=>Number(c[i]??0),s=(i,c)=>({label:i,value:l=>O(n(c)(l)),by:n(c)}),a=i=>({label:"column.share",value:(c,l)=>l?ne(n(i)(c)/l):"",by:n(i)}),r={label:"column.bounce",value:i=>ne(i.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:i=>i.timeOnPage?Ie(i.timeOnPage):"",by:n("timeOnPage")},{label:"column.scroll",value:i=>i.scrollDepth?`${i.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"),r]:wa.has(t.dimension)?[s("column.visitors","visitors"),s("column.visits","visits"),s("column.pageviews","pageviews"),r,{label:"column.duration",value:i=>Ie(i.visitDuration??0),by:n("visitDuration")},a("visitors")]:[s("column.visitors","visitors")]}function ka({rows:t,tab:n,onFilter:s}){let a=n.column??"visitors",r=Ds(n),i=t.reduce((b,g)=>b+Number(g[a]??0),0),c=Math.max(1,...t.map(b=>Number(b[a]??0))),[l,d]=h(null),p=b=>d(l?.by===b?{by:b,descending:!l.descending}:{by:b,descending:b>=0}),m=l?[...t].sort((b,g)=>{let k=l.by<0?re(n.dimension,b.value).localeCompare(re(n.dimension,g.value),void 0,{numeric:!0,sensitivity:"base"}):r[l.by].by(b)-r[l.by].by(g);return l.descending?-k:k}):t,f=(b,g,k)=>e("th",{class:k?"numeric":void 0,"aria-sort":l?.by===g?l.descending?"descending":"ascending":void 0,children:e("button",{type:"button",class:l?.by===g?"sort on":"sort",onClick:()=>p(g),children:[b,e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:l?.by===g&&!l.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:[f(o(n.label),-1,!1),r.map((b,g)=>f(o(b.label),g,!0))]})}),e("tbody",{children:m.map(b=>{let g=re(n.dimension,b.value);return e("tr",{children:[e("td",{class:"sheet-name",children:[e("span",{class:"bar",style:{width:`${Number(b[a]??0)/c*100}%`}}),n.filterable?e("button",{type:"button",class:"name",title:o("panel.filterBy",{name:g}),onClick:()=>s(n.dimension,b.value),children:e("span",{class:"name-text",children:g})}):e("span",{class:"name",children:e("span",{class:"name-text",children:g})})]}),r.map((k,v)=>e("td",{class:v===0?"numeric lead":"numeric",children:k.value(b,i)}))]})})})]})}function _a({title:t,tab:n,view:s,onFilter:a,onClose:r}){let i=K(null);he(i);let[c,l]=h(null),[d,p]=h(""),m=K(null);F(()=>{L.breakdown(s,n.dimension,Ls).then(k=>l(k.rows)).catch(()=>l([]));let g=k=>k.key==="Escape"&&r();return document.addEventListener("keydown",g),document.body.classList.add("locked"),m.current?.focus(),()=>{document.removeEventListener("keydown",g),document.body.classList.remove("locked")}},[]);let f=d.trim().toLowerCase(),b=(c??[]).filter(g=>!f||re(n.dimension,g.value).toLowerCase().includes(f));return e("div",{class:"scrim center",onPointerDown:g=>g.target===g.currentTarget&&r(),children:e("div",{class:Ds(n).length>3?"list-sheet wide":"list-sheet",role:"dialog","aria-modal":"true","aria-label":`${o(t)}: ${o(n.label)}`,ref:i,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 g=le(s);g.set("dimension",n.dimension),g.set("limit",String(Ls)),g.set("format","csv"),je("breakdown",g).catch(()=>{})},children:[e(C,{name:"upload"}),o("export.csv")]}),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("div",{class:"sheet-search",children:[e("input",{ref:m,class:"value",type:"search",placeholder:o("common.search"),"aria-label":o("common.search"),value:d,onInput:g=>p(g.target.value)}),e("span",{class:"sheet-tools",children:[d?e("button",{type:"button",class:"sheet-clear","aria-label":o("common.clearAll"),onClick:()=>{p(""),m.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:c?f?`${O(b.length)} / ${O(c.length)}`:O(c.length):""})]})]}),e("div",{class:"sheet-body",children:[c?null:e("p",{class:"empty",children:o("common.loading")}),c&&b.length===0?f?e(G,{size:"line",icon:"list",title:o("empty.search",{q:f})}):e(G,{size:"line",icon:"chart",title:o("empty.mini")}):null,b.length?e(ka,{rows:b,tab:n,onFilter:(g,k)=>{a(g,k),r()}}):null]})]})})}function $s({title:t,tabs:n,view:s,onFilter:a,wide:r,map:i}){let[c,l]=h(0),[d,p]=h(!1),[m,f]=h(!1),[b,g]=h(!1),[k,v]=h(!1),[u,_]=h(null),[T,y]=h(null),[P,w]=h(""),[x,A]=h(!1),$=n[c]??n[0],N=$.column??"visitors";F(()=>{let R=!0;w("");let M=setTimeout(()=>R&&A(!0),300);return L.breakdown(s,$.dimension,50).then(I=>R&&y(I.rows)).catch(I=>R&&w(I.message)).finally(()=>{clearTimeout(M),R&&A(!1)}),()=>{R=!1,clearTimeout(M)}},[s,$.dimension]);let S=T??[],E=!P&&T!==null&&S.length===0,H=[];if($.colors)H=S.filter(R=>$.colors[R.value]!==void 0).map(R=>({name:re($.dimension,R.value),n:Number(R[N]??0),slot:$.colors[R.value]}));else if($.groups){let R=new Map;for(let M of S)R.set($.groups.of(M.value),(R.get($.groups.of(M.value))??0)+Number(M[N]??0));H=Object.entries($.groups.slots).map(([M,I])=>({name:o(M),n:R.get(M)??0,slot:I}))}return e("section",{class:`${r?"panel wide":"panel"}${x&&T?" stale":""}`,"aria-busy":x,children:[e("header",{class:"panel-head",children:[e("h2",{children:o(t)}),e("div",{class:"head-tools",children:[n.length>1&&!d?e("nav",{class:"tabs","aria-label":o("panel.views",{title:o(t)}),children:n.map((R,M)=>e("button",{type:"button",class:M===c?"tab on":"tab","aria-pressed":M===c,onClick:()=>{l(M),y(null)},children:o(R.label)}))}):null,t==="panel.pages"&&!E?e("button",{type:"button",class:"tool",title:o("journeys.open"),"aria-label":o("journeys.open"),onClick:()=>g(!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,i&&!E?e(U,{children:[e("button",{type:"button",class:d?"tool on":"tool","aria-label":o(d?"panel.showList":"panel.showMap"),title:o(d?"panel.showList":"panel.showMap"),onClick:()=>p(!d),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:()=>f(!0),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4"})})})]}):null]})]}),m?e(_s,{view:s,onFilter:a,onClose:()=>f(!1)}):null,b?e(Ps,{view:s,onClose:()=>g(!1)}):null,u?e(As,{view:s,event:u,onClose:()=>_(null)}):null,k?e(_a,{title:t,tab:$,view:s,onFilter:a,onClose:()=>v(!1)}):null,E?e(G,{icon:Rt[t]?.icon??"chart",title:o(Rt[t]?.title??"panel.empty"),hint:Rt[t]?o(Rt[t].hint):void 0}):d?e(an,{view:s,onFilter:a}):e(U,{children:[H.length>0?e(ba,{parts:H}):null,e("div",{class:"table",children:[e(xa,{tab:$}),P?e("p",{class:"empty",children:P}):null,!T&&!P?e("p",{class:"empty",children:o("common.loading")}):null,e(ya,{rows:S.slice(0,Rs),tab:$,onFilter:a,onDetail:$.dimension==="event"?_:void 0})]}),S.length>Rs?e("button",{type:"button",class:"more",onClick:()=>v(!0),children:[e(C,{name:"expand"}),o("panel.more")]}):null]}),i&&ms?e("a",{class:"geo-credit",href:"https://db-ip.com",target:"_blank",rel:"noopener",children:de("panel.geoCredit",{name:e("span",{children:"DB-IP"})})}):null]})}var Rt={"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"}},Is=6;function Hs({view:t,wide:n}){let[s,a]=h(null),[r,i]=h([]),[c,l]=h(""),[d,p]=h(null),m=K(null);F(()=>{let u=!0;return l(""),L.rhythm(t).then(_=>{u&&(a(_.grid),i(_.cells??[]))}).catch(_=>u&&l(_.message)),()=>{u=!1}},[t]);let f=St("short"),b=s?Math.max(0,...s.flat()):0,g=null;if(s&&b>0)for(let u=0;u<7&&!g;u++){let _=s[u].indexOf(b);_>=0&&(g=[u,_])}let k=s?s.flat().reduce((u,_)=>u+_,0)/168:0,v=d&&s?{n:s[d.d][d.h],cell:r[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")}),g?e("span",{class:"aside",children:o("rhythm.busiest",{when:`${f[g[0]]} ${nt(g[1])}`})}):null]}),c?e("p",{class:"empty",children:c}):null,!s&&!c?e("p",{class:"empty",children:o("common.loading")}):null,s&&b===0?e(G,{icon:"clock",title:o("empty.rhythm.title"),hint:o("empty.rhythm.hint")}):null,s&&b>0?e("div",{class:"rhythm",role:"table","aria-label":o("rhythm.table"),ref:m,onPointerLeave:()=>p(null),children:[s.map((u,_)=>e("div",{class:"rhythm-row",role:"row",children:[e("span",{class:"rhythm-day",role:"rowheader",children:f[_]}),u.map((T,y)=>e("span",{role:"cell","aria-label":Y("rhythm.cell",T,{when:`${f[_]} ${nt(y)}`,n:O(T)}),class:`cell q${T===0||b===0?0:Math.max(1,Math.ceil(T/b*Is))}${d?.d===_&&d.h===y?" hot":""}`,onPointerEnter:P=>{let w=m.current?.getBoundingClientRect(),x=P.currentTarget.getBoundingClientRect();w&&p({d:_,h:y,x:x.left-w.left+x.width/2,y:x.top-w.top})}}))]})),e("div",{class:"rhythm-row hours","aria-hidden":"true",children:[e("span",{class:"rhythm-day"}),Array.from({length:24},(u,_)=>e("span",{class:"hour",children:_%6===0?nt(_):""}))]}),d&&v?e("div",{class:d.x>(m.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:[f[d.d]," ",nt(d.h)]}),v.n&&v.cell?e(U,{children:[e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.visits")}),e("strong",{children:O(v.cell.visits)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.visitors")}),e("strong",{children:O(v.cell.visitors)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.pageviews")}),e("strong",{children:O(v.cell.pageviews)})]}),e("span",{class:"tip-row",children:[e("span",{class:"tip-label",children:o("metric.bounceRate")}),e("strong",{children:ne(v.cell.bounceRate)})]}),k>0?e("span",{class:"tip-note",children:o("rhythm.typical",{x:(v.n/k).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:Is},(u,_)=>e("span",{class:`cell q${_+1}`})),e("span",{children:o("scale.more")})]})]}):null]})}var Os={key:"timeOnPage",label:"column.time",format:t=>t?Ie(t):""},Fs={key:"bounceRate",label:"column.bounce",format:ne};var Sa=[{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"]}],dn=t=>o(`field.${t}`),Lt=6,Ca=["is","not","contains"],pn=t=>o(`filter.${t}`),cn=1;function Ta({draft:t,view:n,first:s,onChange:a,onRemove:r}){let[i,c]=h([]);return F(()=>{let l=!0,d={...n,filters:n.filters.filter(p=>p.dimension!==t.dimension)};return L.breakdown(d,t.dimension,12).then(p=>l&&c(p.rows)).catch(()=>l&&c([])),()=>{l=!1}},[t.dimension,n]),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:l=>a({...t,dimension:l.target.value,value:""}),children:Sa.map(l=>e("optgroup",{label:o(l.group),children:l.fields.map(d=>e("option",{value:d,children:dn(d)}))}))}),e("div",{class:"ops",role:"radiogroup","aria-label":o("filter.match"),children:Ca.map(l=>e("button",{type:"button",role:"radio","aria-checked":t.op===l,class:t.op===l?"op on":"op",onClick:()=>a({...t,op:l}),children:pn(l)}))}),e("button",{type:"button",class:"remove","aria-label":o("filter.removeCondition"),onClick:r,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:l=>a({...t,value:l.target.value})}),i.length?e("div",{class:"suggestions",children:i.map(l=>e("button",{type:"button",class:l.value===t.value?"suggestion on":"suggestion",onClick:()=>a({...t,value:l.value}),children:[re(t.dimension,l.value),e("span",{children:O(Number(l.visitors||l.events||0))})]}))}):null]})]})}function Ns({view:t,onApply:n,onClose:s}){let[a,r]=h(()=>t.filters.length?t.filters.map(d=>({...d,id:cn++})):[{dimension:"page",op:"is",value:"",id:cn++}]),i=K(null);he(i),F(()=>{let d=p=>p.key==="Escape"&&s();return document.addEventListener("keydown",d),i.current?.querySelector("select, input")?.focus(),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",d),document.body.classList.remove("locked")}},[]);let c=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:i,children:e("form",{class:"drawer-form",onSubmit:d=>{d.preventDefault(),n(c.map(({dimension:p,op:m,value:f})=>({dimension:p,op:m,value:f.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,p)=>e(Ta,{draft:d,view:t,first:p===0,onChange:m=>r(a.map(f=>f.id===d.id?m:f)),onRemove:()=>r(a.filter(m=>m.id!==d.id))})),a.length<Lt?e("button",{type:"button",class:"add",onClick:()=>r([...a,{dimension:"country",op:"is",value:"",id:cn++}]),children:[e(C,{name:"plus"}),o("filter.add").replace(/^\+\s*/,"")]}):e("p",{class:"drawer-note",children:o("filter.max",{max:Lt})}),e("p",{class:"drawer-note",children:o("filter.note")})]}),e("footer",{class:"drawer-foot",children:[e("button",{type:"button",class:"ghost",onClick:()=>r([]),children:[e(C,{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(C,{name:"check"}),c.length?Y("filter.apply",c.length):o("filter.everything")]})]})]})})})}function ie(t){let[n,s]=h(!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(C,{name:n?"eyeOff":"eye"})})]})}var It=["today","yesterday","7d","30d","90d","month","last_month","year","12mo","all"],Ne="30d",Us=t=>It.includes(t)?o(`period.${t}`):o("period.30d");function Ma(t,n,s){return new Date(Date.UTC(t,n,s)).toISOString().slice(0,10)}function _e(t,n){if(t===n)return pe(t);let s=t.slice(0,4)===n.slice(0,4);return o("calendar.range",{from:pe(t,!s),to:pe(n)})}function zs({y:t,m:n,start:s,end:a,hoverDay:r,today:i,onDay:c,onHover:l}){let p=(new Date(Date.UTC(t,n,1)).getUTCDay()+6)%7,m=new Date(Date.UTC(t,n+1,0)).getUTCDate(),f=a||(s&&r?r:""),b=s&&f?s<f?s:f:s,g=s&&f&&s<f?f:s;return e("div",{class:"month",children:[e("div",{class:"month-title","aria-hidden":"true",children:on(t,n)}),e("div",{class:"month-grid",role:"group","aria-label":on(t,n),children:[St("short").map(k=>e("span",{class:"weekday","aria-hidden":"true",children:k.slice(0,2)})),Array.from({length:p},()=>e("span",{"aria-hidden":"true"})),Array.from({length:m},(k,v)=>{let u=Ma(t,n,v+1),_=b&&g&&u>=b&&u<=g,T=!!b&&(u===b||u===g);return e("button",{type:"button",class:`day${_?" in":""}${T?" edge":""}${u===i?" today":""}`,disabled:u>i,"aria-pressed":T,"aria-label":pe(u),onClick:()=>c(u),onPointerEnter:()=>l(u),children:v+1})})]})]})}function js({from:t,to:n,today:s,onApply:a,onCancel:r,applyLabel:i}){let[c,l]=h(t),[d,p]=h(n),[m,f]=h(""),[b,g]=s.split("-").map(Number),k=(n||s).split("-").map(Number),[v,u]=h([k[0],k[1]-1]),_=A=>{if(!c||d)l(A),p("");else{let[$,N]=A<c?[A,c]:[c,A];l($),p(N)}},[T,y]=v,P=new Date(Date.UTC(T,y-1,1)),w=new Date(Date.UTC(T,y,1)),x=w.getUTCFullYear()>b||w.getUTCFullYear()===b&&w.getUTCMonth()>=g-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:()=>u([T,y-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:()=>u([T,y+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:()=>f(""),children:[e(zs,{y:P.getUTCFullYear(),m:P.getUTCMonth(),start:c,end:d,hoverDay:m,today:s,onDay:_,onHover:f}),e(zs,{y:w.getUTCFullYear(),m:w.getUTCMonth(),start:c,end:d,hoverDay:m,today:s,onDay:_,onHover:f})]}),e("div",{class:"cal-foot",children:[e("span",{class:"cal-sel",children:c?d?_e(c,d):o("calendar.open",{from:pe(c)}):o("calendar.pick")}),e("button",{type:"button",class:"ghost",onClick:r,children:o("common.cancel")}),e("button",{type:"button",class:"solid",disabled:!c,onClick:()=>a(c,d||c),children:i??o("calendar.apply")})]})]})}function qe(){let[t,n]=h(!1),s=K(null);return F(()=>{if(!t)return;let a=r=>{(r instanceof KeyboardEvent?r.key==="Escape":!s.current?.contains(r.target))&&n(!1)};return document.addEventListener("pointerdown",a),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("keydown",a)}},[t]),{open:t,setOpen:n,root:s}}var Ve=()=>e("svg",{class:"chev",viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 6l4 4 4-4"})});function Ks({period:t,from:n,to:s,today:a,onPeriod:r,onRange:i}){let{open:c,setOpen:l,root:d}=qe(),p=n&&s?_e(n,s):Us(t);return e("div",{class:"picker",ref:d,children:[e("button",{type:"button",class:"picker-button","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>l(!c),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:p}),e(Ve,{})]}),c?e("div",{class:"flyout",role:"dialog","aria-label":o("calendar.dialog"),children:[e("ul",{class:"presets",children:It.map(m=>e("li",{children:e("button",{type:"button",class:!n&&t===m?"preset on":"preset",onClick:()=>{r(m),l(!1)},children:Us(m)})}))}),e(js,{from:n,to:s,today:a,onCancel:()=>l(!1),onApply:(m,f)=>{i(m,f),l(!1)}})]}):null]})}var Ea=["previous","year","custom","off"];function Bs({mode:t,from:n,to:s,today:a,allTime:r,onChange:i}){let{open:c,setOpen:l,root:d}=qe(),[p,m]=h(!1),f=t==="custom"&&n&&s?_e(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":c,onClick:()=>{m(t==="custom"),l(!c)},children:[e("span",{class:"compare-vs",children:o("compare.vs")}),e("span",{children:f}),e(Ve,{})]}),c?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")}),Ea.map(b=>e("li",{children:e("button",{type:"button",class:(p?b==="custom":t===b)?"preset on":"preset",disabled:r&&b!=="off",onClick:()=>{if(b==="custom")return m(!0);i(b),l(!1)},children:o(`compare.${b}`)})})),r?e("li",{class:"presets-note",children:o("compare.allTime")}):null]}),p&&!r?e(js,{from:n,to:s,today:a,applyLabel:o("compare.apply"),onCancel:()=>l(!1),onApply:(b,g)=>{i("custom",b,g),l(!1)}}):null]}):null]})}function qs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function un({onAdded:t,onCancel:n}){let[s,a]=h("here"),[r,i]=h(""),[c,l]=h(""),[d,p]=h(""),[m,f]=h(""),[b,g]=h(!1),[k,v]=h(""),[u,_]=h(!1);return e("form",{class:"sheet-body link-form",onSubmit:y=>{if(y.preventDefault(),_(!0),v(""),s==="connect"&&!b){L.connect(d.trim()).then(w=>location.assign(w.authorize)).catch(w=>{v(w.message),_(!1)});return}let P=s==="here"?{name:r.trim(),hostnames:c,timezone:qs()}:{name:r.trim(),remote:{url:d.trim(),token:m.trim()}};L.addSite(P).then(w=>t(w.site)).catch(w=>{v(w.message),_(!1)})},children:[e("div",{class:"ops add-mode",role:"radiogroup","aria-label":o("sites.addTitle"),children:["here","connect"].map(y=>e("button",{type:"button",role:"radio","aria-checked":s===y,class:s===y?"op on":"op",onClick:()=>a(y),children:o(y==="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:c,onInput:y=>l(y.target.value)}),e("span",{class:"field-hint",children:o("sites.domainsHint")})]}):e(U,{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:y=>p(y.target.value)})]}),b?e(U,{children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("sites.connectToken")}),e(ie,{class:"value",required:!0,autoComplete:"off",placeholder:"rl_...",value:m,onInput:y=>f(y.target.value)}),e("span",{class:"field-hint",children:o("sites.connectTokenHint")})]}),e("button",{type:"button",class:"text-button",onClick:()=>g(!1),children:o("sites.useSignIn")})]}):e("button",{type:"button",class:"text-button",onClick:()=>g(!0),children:o("sites.useToken")})]}),s==="connect"&&!b?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:r,onInput:y=>i(y.target.value)}),s==="here"?e("span",{class:"field-hint",children:o("sites.timezoneHint",{zone:qs().replace(/_/g," ")})}):null]}),e("div",{class:"settings-actions",children:[k?e("span",{class:"settings-error",children:k}):null,n?e("button",{type:"button",class:"ghost",onClick:n,children:o("common.cancel")}):null,e("button",{type:"submit",class:"solid",disabled:u||(s==="here"?!c.trim():!d.trim()||b&&!m.trim()),children:[e(C,{name:"plus"}),o(s==="here"?"sites.add":"sites.connect")]})]})]})}function Vs({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(un,{onAdded:t})]})})}function Gs({sites:t,current:n,canAdd:s,onPick:a,onAdd:r,onAll:i}){let{open:c,setOpen:l,root:d}=qe();return e("div",{class:"site-menu",ref:d,children:[e("button",{type:"button",class:"site-button","aria-haspopup":"menu","aria-expanded":c,onClick:()=>l(!c),children:[e("span",{class:"site-button-name",children:n?.name??"Runlight"}),e(Ve,{})]}),c?e("div",{class:"site-flyout",role:"menu","aria-label":o("app.site"),children:[t.map(p=>e("button",{type:"button",role:"menuitemradio","aria-checked":p.id===n?.id,class:p.id===n?.id?"site-option on":"site-option",onClick:()=>{l(!1),p.id!==n?.id&&a(p.id)},children:[e("span",{class:"site-option-text",children:[e("span",{class:"site-option-name",children:p.name}),p.hostnames[0]&&p.hostnames[0]!==p.name?e("span",{class:"site-option-host",children:p.hostnames[0]}):null]}),p.id===n?.id?e(C,{name:"check"}):null]})),i&&t.length>1?e(U,{children:[e("hr",{}),e("button",{type:"button",role:"menuitem",class:"site-option site-add",onClick:()=>{l(!1),i()},children:[e(C,{name:"list"}),e("span",{children:o("sites.all")})]})]}):null,s?e(U,{children:[e("hr",{}),e("button",{type:"button",role:"menuitem",class:"site-option site-add",onClick:()=>{l(!1),r()},children:[e(C,{name:"plus"}),e("span",{children:o("sites.addTitle")})]})]}):null]}):null]})}function Ws({sites:t,view:n,onPick:s,onClose:a}){let[r,i]=h({});F(()=>{for(let l of t)L.stats({...n,site:l.id,filters:[]}).then(d=>i(p=>({...p,[l.id]:d.stats}))).catch(()=>i(d=>({...d,[l.id]:null})))},[]);let c=[...t].sort((l,d)=>(r[d.id]?.visitors??-1)-(r[l.id]?.visitors??-1));return e(se,{title:o("sites.all"),wide:!0,onClose:a,children:e("div",{class:"sheet-body all-sites",children:e("table",{class:"all-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:o("sites.name")}),e("th",{children:o("metric.visitors")}),e("th",{children:o("metric.visits")}),e("th",{children:o("metric.pageviews")}),e("th",{children:o("metric.bounceRate")}),e("th",{children:o("metric.visitDuration")})]})}),e("tbody",{children:c.map(l=>{let d=r[l.id];return e("tr",{children:[e("td",{children:e("button",{type:"button",class:"name",onClick:()=>s(l.id),children:e("span",{class:"name-text",children:l.name})})}),e("td",{children:d?O(d.visitors):d===null?"?":"\u2026"}),e("td",{children:d?O(d.visits):""}),e("td",{children:d?O(d.pageviews):""}),e("td",{children:d?ne(d.bounceRate):""}),e("td",{children:d?Ie(d.visitDuration):""})]})})})]})})})}var Aa=["password","passw0rd","123456","qwerty","azerty","letmein","welcome","admin","runlight","iloveyou","abc123","monkey","dragon","football","baseball","sunshine","princess","shadow","master"];function Ys(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 c=0;c<t.length;c++){let l=t.charCodeAt(c),d=t.charCodeAt(c-1),p=!1;for(let b=1;b<=4&&!p;b++)p=c-1-b>=0&&t[c]===t[c-b]&&t[c-1]===t[c-1-b];let m=c>0&&l===d,f=c>1&&l-d===d-t.charCodeAt(c-2)&&Math.abs(l-d)===1;a+=p?0:m||f?.25:1}let r=a*Math.log2(Math.max(s,10)),i=t.toLowerCase();for(let c of[...Aa,...n.map(l=>l.toLowerCase()).filter(l=>l.length>=3)])r-=(i.split(c).length-1)*c.length*3;return r<40?1:r<60?2:r<80?3:4}function De({icon:t,title:n,tone:s,action:a,children:r}){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(C,{name:t})}),e("div",{class:"callout-box-text",children:[e("strong",{children:n}),e("p",{children:r})]}),a?e("div",{class:"callout-box-action",children:a}):null]})}function Pa(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 rt(t){let n=[],s=/\*\*([^*]+)\*\*|`([^`]+)`/g,a=0;for(let r=s.exec(t);r;r=s.exec(t))r.index>a&&n.push(t.slice(a,r.index)),n.push(r[1]!==void 0?e("strong",{children:r[1]}):e("code",{children:r[2]})),a=r.index+r[0].length;return a<t.length&&n.push(t.slice(a)),n}function Ra({text:t}){let n=[],s=t.replace(/\r/g,"").split(`
|
|
4
|
+
`);for(let a=0;a<s.length;){let r=s[a];if(!r.trim()){a++;continue}if(/^\s*[-*] /.test(r)||/^\s*\d+[.)] /.test(r)){let c=/^\s*\d/.test(r),l=[];for(;a<s.length&&(/^\s*[-*] /.test(s[a])||/^\s*\d+[.)] /.test(s[a]));)l.push(s[a++].replace(/^\s*(?:[-*]|\d+[.)]) /,""));n.push(c?e("ol",{children:l.map(d=>e("li",{children:rt(d)}))}):e("ul",{children:l.map(d=>e("li",{children:rt(d)}))}));continue}if(r.trim().startsWith("|")){let c=[];for(;a<s.length&&s[a].trim().startsWith("|");){let p=s[a++].trim().replace(/^\||\|$/g,"").split("|").map(m=>m.trim());p.every(m=>/^:?-{2,}:?$/.test(m))||c.push(p)}let[l,...d]=c;n.push(e("div",{class:"reply-table",children:e("table",{children:[l?e("thead",{children:e("tr",{children:l.map(p=>e("th",{children:rt(p)}))})}):null,e("tbody",{children:d.map(p=>e("tr",{children:p.map(m=>e("td",{children:rt(m)}))}))})]})}));continue}let i=[];for(;a<s.length&&s[a].trim()&&!/^\s*(?:[-*]|\d+[.)]) /.test(s[a])&&!s[a].trim().startsWith("|");)i.push(s[a++].replace(/^#+\s*/,""));n.push(e("p",{children:rt(i.join(" "))}))}return e("div",{class:"reply",children:n})}var La=["assistant.ask1","assistant.ask2","assistant.ask3","assistant.ask4"];function Zs({site:t,view:n,owner:s,onSetup:a,onClose:r}){let i=`runlight_assistant:${t.id}`,c=K(null);he(c);let[l,d]=h(null),[p,m]=h(()=>{try{let y=JSON.parse(sessionStorage.getItem(i)??"[]");for(;y.length&&y[y.length-1].role==="user";)y.pop();return y}catch{return[]}}),[f,b]=h(""),[g,k]=h(!1),v=K(null),u=K(0),_=K(null);F(()=>{L.assistant().then(d).catch(()=>d({configured:!1}));let y=P=>P.key==="Escape"&&r();return document.addEventListener("keydown",y),document.body.classList.add("locked"),()=>{document.removeEventListener("keydown",y),document.body.classList.remove("locked")}},[]),F(()=>{try{sessionStorage.setItem(i,JSON.stringify(p.slice(-40)))}catch{}v.current?.scrollTo({top:v.current.scrollHeight,behavior:"smooth"})},[p,g]),F(()=>{l?.configured&&_.current?.focus()},[l?.configured]);let T=y=>{let P=y.trim();if(!P||g)return;let w=[...p,{role:"user",content:P}];m(w),b(""),k(!0);let x=u.current;L.ask(t.id,w.filter(A=>!A.error).map(({role:A,content:$})=>({role:A,content:$})),Pa(n),Z()).then(A=>x===u.current&&m([...w,{role:"assistant",content:A.reply||o("assistant.empty"),checked:A.tools.length}])).catch(A=>x===u.current&&m([...w,{role:"assistant",content:A.message,error:!0}])).finally(()=>x===u.current&&k(!1))};return e("div",{class:"scrim",onPointerDown:y=>y.target===y.currentTarget&&r(),children:e("div",{class:"drawer assistant",role:"dialog","aria-modal":"true","aria-labelledby":"assistant-title",ref:c,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",onClick:()=>{u.current++,k(!1),m([])},children:[e(C,{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:v,"aria-live":"polite",children:[l&&!l.configured?e("div",{class:"assistant-empty",children:[e("span",{class:"assistant-mark","aria-hidden":"true",children:e(C,{name:"robot"})}),e("p",{children:o(s?"assistant.setupOwner":"assistant.setupViewer")}),s?e("button",{type:"button",class:"solid",onClick:a,children:[e(C,{name:"key"}),o("assistant.setup")]}):null]}):p.length===0?e("div",{class:"assistant-empty",children:[e("span",{class:"assistant-mark","aria-hidden":"true",children:e(C,{name:"robot"})}),e("p",{children:o("assistant.intro")}),e("div",{class:"assistant-suggestions",children:La.map(y=>e("button",{type:"button",class:"ghost",disabled:!l,onClick:()=>T(o(y)),children:o(y)}))})]}):p.map(y=>e("div",{class:`message ${y.role}${y.error?" error":""}`,children:[y.role==="user"?e("p",{children:y.content}):e(Ra,{text:y.content}),y.checked?e("span",{class:"message-meta",children:Y("assistant.checked",y.checked)}):null]})),g?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]}),l?.configured?e("form",{class:"drawer-foot assistant-ask",onSubmit:y=>{y.preventDefault(),T(f)},children:[e("textarea",{ref:_,class:"value",rows:2,"aria-label":o("assistant.placeholder"),placeholder:o("assistant.placeholder"),value:f,onInput:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&!y.isComposing&&(y.preventDefault(),T(f))}}),e("button",{type:"submit",class:"solid",disabled:g||!f.trim(),"aria-label":o("assistant.send"),children:e(C,{name:"send"})})]}):null]})})}function Js({owner:t}){let[n,s]=h(null),[a,r]=h({provider:"anthropic",model:"",baseUrl:"",key:""}),[i,c]=h(""),[l,d]=h(!1),[p,m]=h(!1),[f,b]=h(null),[g,k]=h(!1),[v,u]=h(!1),[_,T]=h(""),[y,P]=h(""),[w,x]=h({}),[A,$]=h(""),N=()=>{T(""),u(!0),L.assistantModels({provider:a.provider,baseUrl:a.baseUrl,key:a.key}).then(I=>{b(I.models),k(!1),a.model||r(B=>({...B,model:I.models.some(ae=>ae.id===H?.model)?H.model:I.models[0]?.id??""}))}).catch(I=>T(I.message)).finally(()=>u(!1))},S=()=>L.assistant().then(I=>{s(I),r({provider:I.provider||"anthropic",model:I.model??"",baseUrl:I.baseUrl??"",key:""}),P(String(I.viewerDaily??""))}).catch(I=>c(I.message));if(F(()=>{S()},[]),!t)return e("p",{class:"settings-text",children:o("assistant.ownersOnly")});if(!n)return i?e("p",{class:"settings-error",children:i}):null;let E=n.providers??[],H=E.find(I=>I.id===a.provider),R=n.provider===a.provider,M=I=>{I.preventDefault(),c(""),d(!1),m(!0),L.saveAssistant(a).then(()=>(d(!0),S())).catch(B=>c(B.message)).finally(()=>m(!1))};return e(U,{children:[e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("assistant.settingsIntro")}),e(De,{icon:"eye",title:o("assistant.privacyTitle"),children:o("assistant.privacy")}),n.encrypted?null:e(De,{icon:"key",tone:"warn",title:o("assistant.notEncryptedTitle"),children:o("assistant.notEncrypted")})]}),e("form",{class:"settings-group",onSubmit:M,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.provider")}),e("select",{class:"value",value:a.provider,onChange:I=>{let B=I.target.value;r({provider:B,model:B===n.provider?n.model??"":"",baseUrl:B===n.provider?n.baseUrl??"":"",key:""}),b(null),T(""),d(!1)},children:E.map(I=>e("option",{value:I.id,children:I.name}))})]}),H&&(H.key!=="yes"||!H.baseUrl)?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.address")}),e("input",{class:"value",type:"url",placeholder:H.baseUrl||"https://api.example.com/v1",value:a.baseUrl,onInput:I=>r({...a,baseUrl:I.target.value})}),e("span",{class:"field-hint",children:o(H.key==="no"?"assistant.addressLocal":"assistant.addressHint")})]}):null,H?.key!=="no"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.key")}),e(ie,{class:"value",autoComplete:"off",placeholder:R&&n.keySaved?o("mail.keepSaved"):"",value:a.key,onInput:I=>r({...a,key:I.target.value})})]}):null,e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("assistant.model")}),e("div",{class:"model-row",children:[f&&!g?e("select",{class:"value",value:a.model,onChange:I=>r({...a,model:I.target.value}),children:[a.model?null:e("option",{value:"",children:o("assistant.pickModel")}),a.model&&!f.some(I=>I.id===a.model)?e("option",{value:a.model,children:a.model}):null,f.map(I=>e("option",{value:I.id,children:I.name===I.id?I.id:`${I.name} (${I.id})`}))]}):e("input",{class:"value",type:"text",spellcheck:!1,"aria-label":o("assistant.model"),placeholder:H?.model||o("assistant.modelPlaceholder"),value:a.model,onInput:I=>r({...a,model:I.target.value})}),e("button",{type:"button",class:"ghost",disabled:v,onClick:N,children:[e(C,{name:"refresh"}),o(v?"assistant.loadingModels":"assistant.loadModels")]})]}),f?e("button",{type:"button",class:"text-button",onClick:()=>k(!g),children:o(g?"assistant.chooseFromList":"assistant.typeModel")}):e("span",{class:"field-hint",children:H?.model?o("assistant.modelDefault",{model:H.model}):o("assistant.modelHint")}),_?e("span",{class:"settings-error",children:_}):null]}),e("div",{class:"settings-actions",children:[e("button",{type:"submit",class:"solid",disabled:p,children:[e(C,{name:"save"}),o("settings.save")]}),l?e("span",{class:"settings-ok",children:o("settings.saved")}):null,i?e("span",{class:"settings-error",children:i}):null]})]}),n.configured?e("form",{class:"settings-group",onSubmit:I=>{I.preventDefault(),x({}),L.saveAssistantLimit(Number(y)).then(()=>x({saved:!0})).catch(B=>x({error:B.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:y,onInput:I=>P(I.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(C,{name:"save"}),o("settings.save")]}),w.saved?e("span",{class:"settings-ok",children:o("settings.saved")}):null,w.error?e("span",{class:"settings-error",children:w.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(te,{name:H?.name??"",onDelete:()=>{$(""),L.removeAssistant().then(S).catch(I=>$(I.message))}})}),A?e("span",{class:"settings-error",children:A}):null]})}):null]})}var Ia=(t,n)=>{let s=`mail.field.${t}`,a=o(s);return a===s?n:a};function Da({site:t,admin:n}){let[s,a]=h(null),[r,i]=h(!1),[c,l]=h({}),[d,p]=h(""),[m,f]=h(!1),[b,g]=h(""),[k,v]=h(""),u=()=>L.mail(t.remote?t.id:void 0).then(w=>{a(w),l({service:w.service||"ses",from:w.from,fromName:w.fromName,...w.fields})}).catch(w=>p(w.message));if(F(()=>{u()},[]),!s)return d?e("p",{class:"settings-error",children:d}):null;let _=s.services.find(w=>w.id===s.service);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:_?.name??s.service}),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(C,{name:"external"}),o("sites.openRemote")]})]});let T=s.services.find(w=>w.id===c.service)??s.services[0],y=w=>{w.preventDefault(),p(""),f(!0),L.saveMail(c).then(()=>(i(!1),u())).catch(x=>p(x.message)).finally(()=>f(!1))},P=w=>{w.preventDefault(),p(""),v(""),f(!0),L.testMail(b.trim(),Z()).then(()=>v(o("mail.testSent",{to:b.trim()}))).catch(x=>p(x.message)).finally(()=>f(!1))};return!n&&!s.source?e("p",{class:"settings-note",children:o("mail.adminOnly")}):r||!s.source?e("form",{class:"goal-form",onSubmit:y,children:[s.encrypted?null:e(De,{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:c.service,onChange:w=>l({...c,service:w.target.value}),children:s.services.map(w=>e("option",{value:w.id,children:w.name}))})]}),T.fields.map(w=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:[Ia(w.name,w.label),w.optional?e("span",{class:"optional",children:[" ",o("mail.optional")]}):null]}),w.options?e("select",{class:"value",value:c[w.name]||w.options[0],onChange:x=>l({...c,[w.name]:x.target.value}),children:w.options.map(x=>e("option",{value:x,children:x}))}):w.secret?e(ie,{class:"value",autoComplete:"off",spellcheck:!1,placeholder:s.saved.includes(w.name)&&s.service===T.id?o("mail.keepSaved"):w.placeholder??"",value:c[w.name]??"",onInput:x=>l({...c,[w.name]:x.target.value})}):e("input",{class:"value",type:"text",autoComplete:"off",spellcheck:!1,placeholder:w.placeholder??"",value:c[w.name]??"",onInput:x=>l({...c,[w.name]:x.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:c.from??"",onInput:w=>l({...c,from:w.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:c.fromName??"",onInput:w=>l({...c,fromName:w.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:m,children:[e(C,{name:"check"}),o("mail.save")]}),s.source?e("button",{type:"button",class:"ghost",onClick:()=>i(!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:_?.name??s.service}),e("span",{class:"share-meta",children:o(s.source==="code"?"mail.fromCode":"mail.fromLine",{from:s.fromName?`${s.fromName} <${s.from}>`:s.from})})]}),s.source==="dashboard"&&n?e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(!0),children:[e(C,{name:"edit"}),o("mail.change")]}),e(te,{name:_?.name??"",onDelete:()=>{L.removeMail().then(u)}})]}):null]})}),e("form",{class:"domain-add",onSubmit:P,children:[e("input",{class:"value",type:"email",placeholder:o("mail.testTo"),value:b,onInput:w=>g(w.target.value)}),e("button",{type:"submit",class:"solid",disabled:m||!b.trim(),children:[e(C,{name:"send"}),o("mail.test")]})]}),k?e("p",{class:"settings-ok-text",children:[e(C,{name:"check"}),k]}):null,d?e("p",{class:"settings-error",children:d}):null]})}function $a(t){return t?new Intl.DateTimeFormat(Z(),{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t):o("reports.never")}function Xs({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(Da,{site:t,admin:n})]})}function Qs({site:t,onSetUp:n}){let[s,a]=h(null),[r,i]=h(null),[c,l]=h(""),[d,p]=h("weekly"),[m,f]=h(Z()),[b,g]=h(""),[k,v]=h(""),[u,_]=h(""),T=()=>L.reports(t.id).then(x=>i(x.reports)).catch(x=>g(x.message));F(()=>{T(),L.mail(t.remote?t.id:void 0).then(x=>a(!!x.source)).catch(()=>a(!1))},[t.id]);let y=x=>{x.preventDefault(),g(""),L.addReport(t.id,{email:c.trim(),frequency:d,lang:m}).then(()=>(l(""),T())).catch(A=>g(A.message))},P=x=>{g(""),v(""),_(x.id),L.sendReport(t.id,x.id).then(()=>v(o("reports.sampleSent",{to:x.email}))).catch(A=>g(A.message)).finally(()=>_(""))},w=x=>Pe.find(([A])=>A===x)?.[1]??x;return e(U,{children:[s===!1?e("div",{class:"settings-group",children:e(De,{icon:"send",tone:"warn",title:o("reports.needsMailTitle"),action:t.remote?null:e("button",{type:"button",class:"ghost",onClick:n,children:[e(C,{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})})]}),r&&r.length?e("ul",{class:"domain-list",children:r.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 ",w(x.lang)," \xB7 ",o("reports.lastSent",{when:$a(x.lastSentAt)})]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",disabled:!s||u===x.id,onClick:()=>P(x),children:[e(C,{name:"send"}),o("reports.sample")]}),e(te,{name:x.email,onDelete:()=>{L.deleteReport(t.id,x.id).then(T)}})]})]}))}):r?e(G,{size:"card",icon:"send",title:o("reports.emptyTitle"),hint:o("reports.none")}):null,k?e("p",{class:"settings-ok-text",children:[e(C,{name:"check"}),k]}):null,e("form",{class:"report-add",onSubmit:y,children:[e("input",{class:"value",type:"email",placeholder:o("reports.emailPlaceholder"),value:c,onInput:x=>l(x.target.value)}),e("select",{class:"value",value:d,"aria-label":o("reports.frequency"),onChange:x=>p(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:m,"aria-label":o("reports.language"),onChange:x=>f(x.target.value),children:Pe.map(([x,A])=>e("option",{value:x,children:A}))}),e("button",{type:"submit",class:"solid",disabled:!c.trim(),children:[e(C,{name:"plus"}),o("reports.add")]})]}),b?e("p",{class:"settings-error",children:b}):null,e("p",{class:"field-hint",children:o("reports.when")})]})]})}var eo=t=>o(t.kind==="page"?"funnels.stepPage":"funnels.stepEvent",{match:t.match});function to({funnel:t}){let n=Math.max(1,t.steps[0]?.visits??0);return e("ol",{class:"funnel",children:t.steps.map((s,a)=>{let r=s.visits??0,i=a===0?r: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:eo(s)}),e("span",{class:"num",children:O(r)})]}),e("div",{class:"funnel-track",children:e("span",{class:"funnel-fill",style:{width:`${r/n*100}%`}})}),a>0?e("span",{class:"funnel-rate",children:o("funnels.wentOn",{pct:i?ne(r/i):ne(0)})}):null]})})})}function no({site:t,view:n}){let[s,a]=h(null),[r,i]=h(null),[c,l]=h(""),d=()=>L.funnels({...n,site:t.id}).then(p=>a(p.funnels)).catch(p=>l(p.message));return F(()=>{d()},[t.id]),r?e(Ha,{site:t,funnel:r==="new"?null:r,onDone:()=>{i(null),d()}}):e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("funnels.intro")}),s&&s.length?e("ul",{class:"domain-list goal-list",children:s.map(p=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:p.name}),e("span",{class:"share-meta",children:p.steps.map(eo).join(" \u2192 ")})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(p),children:[e(C,{name:"edit"}),o("goals.edit")]}),e(te,{name:p.name,onDelete:()=>{L.deleteFunnel(t.id,p.id).then(d)}})]})]}))}):s?e(G,{size:"card",icon:"funnel",title:o("funnels.emptyTitle"),hint:o("funnels.none")}):null,c?e("p",{class:"settings-error",children:c}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"solid",onClick:()=>i("new"),children:[e(C,{name:"plus"}),o("funnels.add")]})})]})}function Ha({site:t,funnel:n,onDone:s}){let[a,r]=h(n?.name??""),[i,c]=h(n?.steps.map(f=>({kind:f.kind,match:f.match}))??[{kind:"page",match:""},{kind:"page",match:""}]),[l,d]=h(""),p=(f,b)=>c(i.map((g,k)=>k===f?{...g,...b}:g));return e("form",{class:"settings-group",onSubmit:f=>{f.preventDefault(),d(""),L.saveFunnel(t.id,n?.id??null,{name:a.trim(),steps:i}).then(s).catch(b=>d(b.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:f=>r(f.target.value)})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("funnels.steps")}),e("ol",{class:"funnel-steps",children:i.map((f,b)=>e("li",{children:[e("span",{class:"funnel-step",children:b+1}),e("select",{class:"value",value:f.kind,"aria-label":o("funnels.kind"),onChange:g=>p(b,{kind:g.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:f.kind==="page"?"/pricing":"Signup",value:f.match,onInput:g=>p(b,{match:g.target.value})}),e("button",{type:"button",class:"remove","aria-label":o("funnels.removeStep"),disabled:i.length<=2,onClick:()=>c(i.filter((g,k)=>k!==b)),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")}),i.length<8?e("div",{children:e("button",{type:"button",class:"ghost",onClick:()=>c([...i,{kind:"page",match:""}]),children:[e(C,{name:"plus"}),o("funnels.addStep")]})}):null]}),e("div",{class:"settings-actions",children:[l?e("span",{class:"settings-error",children:l}):null,e("button",{type:"button",class:"ghost",onClick:s,children:o("common.cancel")}),e("button",{type:"submit",class:"solid",children:[e(C,{name:"save"}),o(n?"funnels.save":"funnels.create")]})]})]})}var Oa=["USD","EUR","GBP","CAD","AUD","NZD","JPY","CHF","SEK","NOK","DKK","PLN","BRL","MXN","INR","SGD","HKD","ZAR"];function gn(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 so(t){return t.valueMode==="fixed"?o("goals.value.each",{amount:Fe(t.value,t.currency)}):t.valueMode==="prop"?o("goals.value.fromProp",{prop:t.valueProp,currency:t.currency}):""}function Fa(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])=>Fe(a,s)).join(" + ")}function oo({view:t,readOnly:n,onAdd:s}){let[a,r]=h(null),[i,c]=h(""),[l,d]=h(null),[p,m]=h([]),[f,b]=h("goals");if(F(()=>{let u=!0;return c(""),L.goals(t).then(_=>u&&r(_.goals)).catch(_=>u&&c(_.message)),L.funnels(t).then(_=>u&&m(_.funnels)).catch(()=>{}),()=>{u=!1}},[t]),n&&a&&a.length===0&&p.length===0)return null;if(f==="funnels"&&p.length)return e("section",{class:n?"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")})]}),n?null:e("button",{type:"button",class:"box-button icon-only",title:o("goals.add"),"aria-label":o("goals.add"),onClick:s,children:e(C,{name:"plus"})})]})]}),p.map(u=>e("div",{class:"funnel-block",children:[e("h3",{class:"funnel-name",children:u.name}),e(to,{funnel:u})]}))]});let g=Math.max(1,...(a??[]).map(u=>u.conversions)),k=a?Fa(a):"",v=[...a??[]].sort((u,_)=>_.conversions-u.conversions||u.name.localeCompare(_.name));return e("section",{class:n?"panel full":"panel",children:[e("header",{class:"panel-head",children:[e("h2",{children:[o("panel.conversions")," ",k?e("span",{class:"aside",children:o("goals.revenueAside",{amount:k})}):null]}),e("div",{class:"head-tools",children:[p.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,n?null:e("button",{type:"button",class:p.length?"box-button icon-only":"box-button",title:o("goals.add"),"aria-label":o("goals.add"),onClick:s,children:[e(C,{name:"plus"}),p.length?null:o("goals.add")]})]})]}),i?e("p",{class:"empty",children:i}):null,!a&&!i?e("p",{class:"empty",children:o("common.loading")}):null,a&&a.length===0?e(G,{icon:"target",title:o("goals.emptyTitle"),hint:o("goals.emptyHint")}):null,a&&a.length?e(U,{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:v.map(u=>e("li",{children:[e("span",{class:"bar",style:{width:`${u.conversions/g*100}%`}}),e("button",{type:"button",class:"name",title:gn(u),onClick:()=>d(u.id),children:[e("span",{class:"name-text",children:u.name}),u.valueMode!=="none"&&u.revenue?e("span",{class:"goal-money",children:Fe(u.revenue,u.currency)}):null]}),e("span",{class:"extra",children:ne(u.rate)}),e("span",{class:"num",children:O(u.conversions)})]}))})]})}):null,l?e(Na,{view:t,id:l,onClose:()=>d(null)}):null]})}function mn({title:t,rows:n,dimension:s,currency:a,valued:r}){let i=Math.max(1,...n.map(c=>c.conversions));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(G,{size:"line",icon:"chart",title:o("empty.mini")}):null,e("ol",{class:"rows",children:n.map(c=>e("li",{children:[e("span",{class:"bar",style:{width:`${c.conversions/i*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:re(s,c.value)||o("goals.unknown")})}),r?e("span",{class:"extra",children:Fe(c.revenue,a)}):null,e("span",{class:"num",children:O(c.conversions)})]}))})]})}function Na({view:t,id:n,onClose:s}){let[a,r]=h(null),[i,c]=h("");F(()=>{L.goal(t,n).then(r).catch(m=>c(m.message))},[t,n]);let l=a?.goal,d=!!(l&&l.valueMode!=="none"),p=l?[{key:"conversions",slot:1,label:o("goals.conversions"),format:O},...d?[{key:"revenue",slot:4,label:o("goals.revenue"),format:m=>Fe(m,l.currency)}]:[]]:[];return e(se,{title:l?.name??o("common.loading"),sub:l?gn(l):void 0,wide:!0,onClose:s,children:e("div",{class:"sheet-body",children:[i?e("p",{class:"failure",children:i}):null,a&&l?e(U,{children:[e("div",{class:"goal-tiles",children:[e("div",{children:[e("span",{children:o("goals.conversions")}),e("strong",{children:O(a.totals.conversions)})]}),e("div",{children:[e("span",{children:o("goals.converted")}),e("strong",{children:O(a.totals.visitors)})]}),e("div",{children:[e("span",{children:o("goals.rate")}),e("strong",{children:ne(a.totals.rate)})]}),d?e("div",{children:[e("span",{children:o("goals.revenue")}),e("strong",{children:Fe(a.totals.revenue,l.currency)})]}):null]}),e("h3",{class:"mini-title",children:o(d?"goals.overTimeValued":"goals.overTime")}),e("div",{class:"link-chart",children:e(Be,{points:a.series,metrics:p,interval:a.range.interval,timezone:a.range.timezone,height:240})}),e("div",{class:"mini-grid three",children:[e(mn,{title:"goals.byChannel",rows:a.channels,dimension:"channel",currency:l.currency,valued:d}),e(mn,{title:"goals.bySource",rows:a.sources,dimension:"source",currency:l.currency,valued:d}),e(mn,{title:"goals.byPage",rows:a.pages,dimension:"page",currency:l.currency,valued:d})]})]}):null]})})}var Ua={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(([r,i])=>e("button",{type:"button",role:"radio","aria-checked":t===r,class:t===r?"op on":"op",onClick:()=>s(r),children:o(i)}))})}function za({site:t,goal:n,view:s,onDone:a}){let[r,i]=h(()=>n?{...n}:{...Ua,currency:ja()}),[c,l]=h(""),[d,p]=h(!1),[m,f]=h([]),[b,g]=h(!1),k=K(null),v=P=>i(w=>({...w,...P}));F(()=>{if(r.kind==="click")return f([]);L.breakdown({...s,period:"90d",from:"",to:"",filters:[]},r.kind==="event"?"event":"page",50).then(P=>f(P.rows.map(w=>w.value).filter(Boolean))).catch(()=>f([]))},[r.kind]),F(()=>{let P=w=>{if(!k.current||w.source!==k.current)return;let x=w.data;x?.runlight!=="pick"||typeof x.selector!="string"||(g(!1),v({match:x.selector.slice(0,500),clickBy:"selector",...r.name?{}:{name:(x.text||"").slice(0,60)}}))};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[r.name]);let u=t.hostnames[0],_=()=>{if(!u)return;g(!0);let P=window.open("about:blank","runlight-pick");k.current=P,L.pickTicket(t.id,location.origin).then(({ticket:w})=>{P&&(P.location.href=`https://${u}/?runlight=pick&runlight_lang=${Z().slice(0,2)}&runlight_ticket=${encodeURIComponent(w)}`)}).catch(w=>{P?.close(),g(!1),l(w.message)})},T=P=>{P.preventDefault(),l(""),p(!0),(n?L.updateGoal(t.id,n.id,r):L.createGoal(t.id,r)).then(a).catch(w=>l(w.message)).finally(()=>p(!1))},y="goal-suggestions";return e("form",{class:"goal-form",onSubmit:T,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:r.name,placeholder:o("goals.namePlaceholder"),onInput:P=>v({name:P.target.value})})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.counts")}),e(hn,{label:o("goals.counts"),value:r.kind,options:[["event","goals.kind.event"],["page","goals.kind.page"],["click","goals.kind.click"]],onChange:P=>v({kind:P,match:"",...P!=="event"&&r.valueMode==="prop"?{valueMode:"fixed"}:{}})})]}),r.kind==="click"?e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.clickOn")}),e(hn,{label:o("goals.clickOn"),value:r.clickBy==="link"?"link":"selector",options:[["selector","goals.click.selector"],["link","goals.click.link"]],onChange:P=>v({clickBy:P,match:""})})]}):null,e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o(r.kind==="event"?"goals.match.event":r.kind==="page"?"goals.match.page":r.clickBy==="link"?"goals.match.link":"goals.match.selector")}),e("div",{class:"match-row",children:[e("input",{class:"value",type:"text",spellcheck:!1,list:m.length?y:void 0,value:r.match,placeholder:r.kind==="event"?"Signup":r.kind==="page"?"/thanks*":r.clickBy==="link"?"https://buy.stripe.com/*":"#signup, .buy-button",onInput:P=>v({match:P.target.value})}),r.kind==="click"&&r.clickBy!=="link"&&u?e("button",{type:"button",class:"ghost",onClick:_,children:[e(C,{name:"target"}),o(b?"goals.picking":"goals.pick")]}):null]}),e("datalist",{id:y,children:m.map(P=>e("option",{value:P}))}),e("span",{class:"field-hint",children:o(r.kind==="event"?"goals.hint.event":r.kind==="page"?"goals.hint.page":r.clickBy==="link"?"goals.hint.link":"goals.hint.selector")})]}),e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.valueLabel")}),e(hn,{label:o("goals.valueLabel"),value:r.valueMode,options:[["none","goals.value.none"],["fixed","goals.value.fixed"],...r.kind==="event"?[["prop","goals.value.prop"]]:[]],onChange:P=>v({valueMode:P})})]}),r.valueMode!=="none"?e("div",{class:"value-row",children:[r.valueMode==="fixed"?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.amount")}),e("input",{class:"value",type:"number",min:"0",step:"0.01",value:String(r.value||""),onInput:P=>v({value:Number(P.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:r.valueProp,onInput:P=>v({valueProp:P.target.value})})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("goals.currency")}),e("select",{class:"value",value:r.currency,onChange:P=>v({currency:P.target.value}),children:Oa.map(P=>e("option",{value:P,children:P}))})]})]}):null,r.valueMode==="prop"?e("div",{class:"code small",children:e("pre",{children:e("code",{children:`runlight("${r.kind==="event"&&r.match?r.match:"Purchase"}", { ${r.valueProp||"revenue"}: 49.99 })`})})}):null,c?e("p",{class:"settings-error",children:c}):null,e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:d,children:[e(C,{name:"check"}),o(n?"goals.save":"goals.create")]}),e("button",{type:"button",class:"ghost",onClick:a,children:o("goals.cancel")})]})]})}function ja(){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 ao({site:t,view:n}){let[s,a]=h(null),[r,i]=h(null),[c,l]=h(""),d=()=>L.goals({...n,site:t.id}).then(m=>a(m.goals)).catch(m=>l(m.message));F(()=>{d()},[t.id]);let p=Ae(()=>s??[],[s]);return r?e("div",{class:"settings-group",children:e(za,{site:t,view:n,goal:r==="new"?null:r,onDone:()=>{i(null),d()}})}):e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("goals.intro")}),p.length?e("ul",{class:"domain-list goal-list",children:p.map(m=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:m.name}),e("span",{class:"share-meta",children:[gn(m),so(m)?` \xB7 ${so(m)}`:""]})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",onClick:()=>i(m),children:[e(C,{name:"edit"}),o("goals.edit")]}),e(te,{name:m.name,onDelete:()=>{L.deleteGoal(t.id,m.id).then(d)}})]})]}))}):s?e(G,{size:"card",icon:"target",title:o("goals.emptyTitle"),hint:o("goals.none")}):null,c?e("p",{class:"settings-error",children:c}):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:()=>i("new"),children:[e(C,{name:"plus"}),o("goals.add")]})})]})}var ro=[{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:[]}],io=t=>t.code&&be(t.code,t.params)||t.reason,Ge={running:!1,done:0,total:null,links:0,clicks:0,skipped:0,failed:[],finished:!1,stopped:!1,error:""};function lo({site:t}){let[n,s]=h("umami"),[a,r]=h({}),[i,c]=h("key"),[l,d]=h(Ge),p=K(!1),m=K(null),f=ro.find(u=>u.id===n),b=n==="umami"?[...f.fields,...i==="key"?[{name:"apiKey",label:"import.apiKey",type:"password"}]:[{name:"username",label:"import.username"},{name:"password",label:"import.password",type:"password"}]]:f.fields,g=async()=>{p.current=!1;let u={...Ge,running:!0};d(u);let _=Object.fromEntries(b.map(y=>[y.name,a[y.name]??""])),T=null;try{do{let y=await L.importStep(t.id,n,_,T,u.done);T=y.cursor,u={...u,done:y.done,total:y.total,links:u.links+y.links,clicks:u.clicks+y.clicks,skipped:u.skipped+y.skipped,failed:[...u.failed,...y.failed.map(P=>({slug:P.slug,reason:io(P)}))]},d(u)}while(T&&!p.current);d({...u,running:!1,finished:!T,stopped:!!T})}catch(y){d({...u,running:!1,error:y instanceof Error?y.message:String(y)})}},k=async u=>{d({...Ge,running:!0});try{let _=at(await u.text()),T=await L.importLinks(t.id,_);d({...Ge,finished:!0,links:T.created,done:_.length,total:_.length,failed:T.failed.map(y=>({slug:`#${y.row}`,reason:io(y)}))})}catch(_){d({...Ge,error:_ instanceof Error?_.message:String(_)})}},v=l.total?Math.min(100,Math.round(l.done/l.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:ro.map(u=>e("button",{type:"button",role:"radio","aria-checked":n===u.id,class:n===u.id?"source on":"source",disabled:l.running,onClick:()=>{s(u.id),d(Ge)},children:[e("strong",{children:u.id==="csv"?o("import.csv"):u.name}),e("span",{children:o(`import.history.${u.history}`)})]}))})]}),e("p",{class:"field-hint",children:o(f.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(u=>e("button",{type:"button",role:"radio","aria-checked":i===u,class:i===u?"op on":"op",onClick:()=>c(u),children:o(u==="key"?"import.withKey":"import.withPassword")}))})]}):null,b.map(u=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o(u.label)}),u.type==="password"?e(ie,{class:"value",autoComplete:"off",spellcheck:!1,placeholder:u.placeholder,value:a[u.name]??"",onInput:_=>r({...a,[u.name]:_.target.value})}):e("input",{class:"value",type:u.type??"text",autoComplete:"off",spellcheck:!1,placeholder:u.placeholder,value:a[u.name]??"",onInput:_=>r({...a,[u.name]:_.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(U,{children:[e("button",{type:"button",class:"solid",disabled:l.running,onClick:()=>m.current?.click(),children:[e(C,{name:"upload"}),o("import.chooseFile")]}),e("input",{ref:m,type:"file",accept:".csv,text/csv",hidden:!0,onChange:u=>{let _=u.target.files?.[0];_&&k(_),u.target.value=""}})]}):l.running?e("button",{type:"button",class:"ghost",onClick:()=>p.current=!0,children:[e(C,{name:"x"}),o("import.stop")]}):e("button",{type:"button",class:"solid",onClick:()=>{g()},children:[e(C,{name:"upload"}),o("import.start")]})}),l.running||l.finished||l.stopped||l.error?e("div",{class:"import-progress","aria-live":"polite",children:[l.running?e(U,{children:[e("div",{class:"progress-bar",children:e("span",{class:v===null?"progress-fill indeterminate":"progress-fill",style:v===null?void 0:{width:`${v}%`}})}),e("span",{class:"field-hint",children:[l.total?o("import.running",{done:O(l.done),total:O(l.total)}):Y("import.soFar",l.links,{n:O(l.links)}),l.clicks?` \xB7 ${Y("links.total",l.clicks,{n:O(l.clicks)})}`:""]})]}):null,l.error?e("p",{class:"settings-error",children:l.error}):null,l.finished?e("p",{class:"settings-ok-text",children:[e(C,{name:"check"}),o("import.done",{links:O(l.links),clicks:O(l.clicks),skipped:O(l.skipped)})]}):null,l.stopped?e("p",{class:"field-hint",children:o("import.stopped",{done:O(l.done),total:O(l.total??l.done)})}):null,l.failed.length?e("div",{class:"import-result",children:[e("strong",{children:o("import.failed")}),l.failed.slice(0,20).map(u=>e("span",{children:[u.slug,": ",u.reason]}))]}):null]}):null]})}function co(t){let n=s=>t.includes(s);return n("created_at")&&n("url_path")?"umami":n("time")&&(n("path")||n("url"))?"runlight":null}function po(t,n){let s=(n==="umami"?t.created_at:t.time)?.trim()??"";if(!s)return NaN;if(/^\d+(\.\d+)?$/.test(s)){let r=Number(s);return r<1e12?Math.round(r*1e3):Math.round(r)}let a=s.replace(" ","T");return Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(a)||!/T\d/.test(a)?a:`${a}Z`)}var Se={running:!1,done:0,total:0,pageviews:0,events:0,visits:0,finished:!1,stopped:!1,error:""},Ka=t=>t.toLowerCase().replace(/^https?:\/\//,"").replace(/^www\./,"").replace(/\/.*$/,"");function mo({site:t}){let[n,s]=h("umami");return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("visits.intro")}),e(De,{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(Va,{site:t}):e(qa,{site:t})]})}function Ba(t,n){let s=t.map(i=>({row:i,ts:po(i,n)})).filter(i=>Number.isFinite(i.ts));s.sort((i,c)=>i.ts-c.ts);let a=[],r=0;for(;r<s.length;){let i=Math.min(r+2e3,s.length);for(;i<s.length&&i>r&&s[i].ts===s[i-1].ts;)i--;if(i===r)return null;a.push(s.slice(r,i).map(c=>c.row)),r=i}return a}function qa({site:t}){let[n,s]=h(null),[a,r]=h({...Se,skipped:0}),i=K(null),c=K(!1),l=async m=>{s(null),r({...Se,skipped:0});let f=at(await m.text()),b=co(Object.keys(f[0]??{}));if(!b||!f.length){r({...Se,skipped:0,error:o("error.import_csv_format")});return}s({name:m.name,rows:f,format:b})},d=async()=>{if(!n)return;c.current=!1;let m=Ba(n.rows,n.format);if(!m){r({...Se,skipped:0,error:o("visits.csvMoment",{max:O(2e3)})});return}let f=n.rows.length-m.reduce((k,v)=>k+v.length,0),b={...Se,skipped:f,running:!0,total:n.rows.length};r(b);let g;try{for(let v of m){if(c.current)break;let u=await L.importCsvVisits(t.id,v,g);g=u.secret??g,b={...b,done:b.done+v.length,pageviews:b.pageviews+u.pageviews,events:b.events+u.events,visits:b.visits+u.visits,skipped:b.skipped+u.skipped},r(b)}let k=b.done+f>=n.rows.length;r({...b,running:!1,finished:k,stopped:!k})}catch(k){r({...b,running:!1,error:k instanceof Error?k.message:String(k)})}},p=a.total?Math.min(100,Math.round(a.done/a.total*100)):0;return e(U,{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:()=>c.current=!0,children:[e(C,{name:"x"}),o("import.stop")]}):e(U,{children:[e("button",{type:"button",class:n?"ghost":"solid",onClick:()=>i.current?.click(),children:[e(C,{name:"upload"}),o(n?"visits.csvOther":"visits.csvChoose")]}),n?e("button",{type:"button",class:"solid",onClick:()=>{d()},children:[e(C,{name:"upload"}),o("visits.start")]}):null]}),e("input",{ref:i,type:"file",accept:".csv,text/csv",hidden:!0,onChange:m=>{let f=m.target.files?.[0];f&&l(f),m.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(U,{children:[e("div",{class:"progress-bar",children:e("span",{class:"progress-fill",style:{width:`${p}%`}})}),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(C,{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 Va({site:t}){let[n,s]=h({}),[a,r]=h("key"),[i,c]=h(null),[l,d]=h(""),[p,m]=h(!1),[f,b]=h(Se),g=K(!1),k=a==="key"?["url","apiKey"]:["url","username","password"],v=()=>Object.fromEntries(k.map(x=>[x,n[x]??""])),u=()=>{c(null),d("")},_=(x,A)=>{s({...n,[x]:A}),u()},T=async()=>{m(!0),b(Se);try{let x=await L.umamiWebsites(v());c(x.websites);let A=x.websites.find($=>t.hostnames.includes(Ka($.domain)));d(A?.id??x.websites[0]?.id??"")}catch(x){b({...Se,error:x instanceof Error?x.message:String(x)})}finally{m(!1)}},y=async()=>{g.current=!1;let x={...Se,running:!0};b(x);let A=null;try{do{let $=await L.importVisits(t.id,v(),l,A);A=$.cursor,x={...x,done:$.done,total:$.total,pageviews:x.pageviews+$.pageviews,events:x.events+$.events,visits:x.visits+$.visits},b(x)}while(A&&!g.current);b({...x,running:!1,finished:!A,stopped:!!A})}catch($){b({...x,running:!1,error:$ instanceof Error?$.message:String($)})}},P=f.total?Math.min(100,Math.round(f.done/f.total*100)):0,w=x=>o(x==="url"?"import.url":x==="apiKey"?"import.apiKey":x==="username"?"import.username":"import.password");return e(U,{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:f.running,onClick:()=>{r(x),u()},children:o(x==="key"?"import.withKey":"import.withPassword")}))})]}),k.map(x=>e("label",{class:"field-row",children:[e("span",{class:"field-label",children:w(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:f.running,onInput:A=>_(x,A.target.value)}):e(ie,{class:"value",autoComplete:"off",spellcheck:!1,value:n[x]??"",disabled:f.running,onInput:A=>_(x,A.target.value)})]})),e("p",{class:"field-hint",children:o("import.umamiHelp")}),i?e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("visits.website")}),i.length?e("select",{class:"value",value:l,disabled:f.running,onChange:x=>d(x.target.value),children:i.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:!i||!l?e("button",{type:"button",class:"solid",disabled:p||!n.url,onClick:()=>{T()},children:[e(C,{name:"refresh"}),o("visits.find")]}):f.running?e("button",{type:"button",class:"ghost",onClick:()=>g.current=!0,children:[e(C,{name:"x"}),o("import.stop")]}):e("button",{type:"button",class:"solid",onClick:()=>{y()},children:[e(C,{name:"upload"}),o("visits.start")]})}),f.running||f.finished||f.stopped||f.error?e("div",{class:"import-progress","aria-live":"polite",children:[f.running?e(U,{children:[e("div",{class:"progress-bar",children:e("span",{class:"progress-fill",style:{width:`${P}%`}})}),e("span",{class:"field-hint",children:o("visits.running",{done:O(f.done),total:O(f.total),pageviews:O(f.pageviews)})})]}):null,f.error?e("p",{class:"settings-error",children:f.error}):null,f.finished?e("p",{class:"settings-ok-text",children:[e(C,{name:"check"}),o("visits.done",{pageviews:O(f.pageviews),visits:O(f.visits),events:O(f.events)})]}):null,f.stopped?e("p",{class:"field-hint",children:o("visits.stopped")}):null]}):null]})}function ho(t){let{domain:n,host:s,origin:a,base:r,linkPath:i}=t;return`Set up a custom short link domain for Runlight, the analytics in this project.
|
|
5
5
|
|
|
6
6
|
Runlight's dashboard runs at ${a}${r}. Short links are served by this app at ${a}${i}/<slug>. I want them also served at the root of ${n}, like https://${n}/<slug>.
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ Please do these steps, and tell me anything I have to do by hand:
|
|
|
11
11
|
|
|
12
12
|
2. Hosting. Make this 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) and proxy it to the app the same way as the main domain.
|
|
13
13
|
|
|
14
|
-
3. App. In the app's middleware
|
|
14
|
+
3. App. In the app's middleware, answer requests for link domains before anything else. In Next.js 16 and later that is proxy.ts:
|
|
15
15
|
|
|
16
16
|
import { rl } from "@/lib/runlight";
|
|
17
17
|
|
|
@@ -21,6 +21,8 @@ Please do these steps, and tell me anything I have to do by hand:
|
|
|
21
21
|
// ...whatever the middleware already does
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
In Next.js 15 and earlier it is middleware.ts, with the same body in export async function middleware(request: Request) instead. 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, D1) works.
|
|
25
|
+
|
|
24
26
|
Keep any middleware that is already there; this goes first. It returns null for every other host, so the rest of the site is unaffected.
|
|
25
27
|
|
|
26
28
|
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).
|
|
@@ -64,18 +66,24 @@ The dashboard should live at ${s} on this site (it is at ${n}${s} here).
|
|
|
64
66
|
|
|
65
67
|
6. Set RUNLIGHT_TOKEN to a long random string in the environment; open ${s}?token=<that string> once to sign in to the dashboard.
|
|
66
68
|
|
|
67
|
-
7. Optional, to see AI agents like ChatGPT and Claude reading pages: in the middleware
|
|
69
|
+
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.
|
|
68
70
|
|
|
69
71
|
Keep the site's existing behaviour unchanged otherwise.
|
|
70
|
-
`}var vo=(t,n)=>`${n}${t.path}`;function Ga({site:t,share:n,home:s,onChanged:a}){let[r,i]=h(!1),[c,l]=h(n.name),[d,p]=h(!1),[m,f]=h("");return e("li",{children:[e("div",{class:"domain-main",children:[r?e("form",{class:"share-rename",onSubmit:g=>{g.preventDefault(),f(""),L.renameShare(t,n.id,c).then(()=>{i(!1),a()}).catch(_=>f(_.message))},children:[e("input",{class:"value",type:"text",value:c,maxLength:100,autoFocus:!0,onInput:g=>l(g.target.value)}),e("button",{type:"submit",class:"solid",children:[e(M,{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:pe(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(vo(n,s)).then(()=>{p(!0),setTimeout(()=>p(!1),1600)}).catch(()=>{}),children:[e(M,{name:d?"check":"copy"}),d?o("install.copied"):o("install.copy")]}),e("a",{class:"copy inline",href:vo(n,s),target:"_blank",rel:"noopener noreferrer",children:[e(M,{name:"external"}),o("share.open")]}),r?null:e("button",{type:"button",class:"copy inline",onClick:()=>i(!0),children:[e(M,{name:"edit"}),o("share.rename")]}),e(te,{name:n.name||o("share.unnamed"),onDelete:()=>{L.deleteShare(t,n.id).then(a).catch(g=>f(g.message))}})]}),m?e("span",{class:"settings-error",children:m}):null]})}function bo({site:t}){let[n,s]=h(null),[a,r]=h(""),[i,c]=h(""),l=()=>L.shares(t.id).then(p=>s(p.shares)).catch(p=>c(p.message));O(()=>{l()},[t.id]);let d=p=>{p.preventDefault(),c(""),L.createShare(t.id,a.trim()).then(()=>(r(""),l())).catch(m=>c(m.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(p=>e(Ga,{site:t.id,share:p,home:t.remote?new URL(t.remote).origin:location.origin,onChanged:()=>{l()}},p.id))}):n?e(V,{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:p=>r(p.target.value)}),e("button",{type:"submit",class:"solid",children:[e(M,{name:"share"}),o("share.create")]})]}),i?e("span",{class:"settings-error",children:i}):null]})}var yo=t=>pe(new Date(t).toISOString().slice(0,10));function xo({sites:t}){let[n,s]=h(null),[a,r]=h(""),[i,c]=h(""),[l,d]=h(null),[p,m]=h(""),f=`${location.origin}${de}/mcp`,b=u=>t.find(S=>S.id===u)?.name??u,g=()=>L.tokens().then(u=>s(u.tokens)).catch(u=>m(u.message));O(()=>{g()},[]);let _=u=>{u.preventDefault(),m("");let S=a.trim();L.createToken(S,i).then(E=>(d({name:S,secret:E.secret}),r(""),g())).catch(E=>m(E.message))},v=l?.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(ue,{children:f}),l?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:[e("strong",{children:l.name})," ",o("tokens.once")]}),e(ue,{children:l.secret}),e("p",{class:"settings-text",children:o("tokens.claudeCode")}),e(ue,{children:`claude mcp add --transport http runlight ${f} --header "Authorization: Bearer ${v}"`}),e("p",{class:"settings-text",children:o("tokens.json")}),e(ue,{children:JSON.stringify({mcpServers:{runlight:{url:f,headers:{Authorization:`Bearer ${v}`}}}},null,2)}),e("button",{type:"button",class:"ghost token-done",onClick:()=>d(null),children:[e(M,{name:"check"}),o("tokens.done")]})]}):null,n&&n.length?e("ul",{class:"domain-list share-list",children:n.map(u=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:u.name}),e("span",{class:"share-meta",children:[`rl_\u2026${u.hint}`," \xB7 ",u.site?o("tokens.siteOnly",{site:b(u.site)}):o("tokens.allSites"),u.scope==="manage"?` \xB7 ${o("tokens.manages")}`:u.scope==="embed"?` \xB7 ${o("tokens.embeds")}`:""," \xB7 ",o("links.createdOn",{date:yo(u.createdAt)})," \xB7 ",u.lastUsedAt?o("tokens.used",{date:yo(u.lastUsedAt)}):o("tokens.never")]})]}),e("div",{class:"domain-actions",children:e(te,{name:u.name,onDelete:()=>{L.deleteToken(u.id).then(g)}})})]},u.id))}):n?e(V,{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:_,children:[e("input",{class:"value",type:"text",maxLength:100,required:!0,placeholder:o("tokens.namePlaceholder"),value:a,onInput:u=>r(u.target.value)}),t.length>1?e("select",{class:"value",value:i,"aria-label":o("tokens.scope"),onChange:u=>c(u.target.value),children:[e("option",{value:"",children:o("tokens.allSites")}),t.map(u=>e("option",{value:u.id,children:o("tokens.siteOnly",{site:u.name})}))]}):null,e("button",{type:"submit",class:"solid",children:[e(M,{name:"key"}),o("tokens.create")]})]}),p?e("span",{class:"settings-error",children:p}):null]})}var wo="runlight_theme",gn=new Set;function Wa(){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 Ge(){try{let t=localStorage.getItem(wo);if(t==="light"||t==="dark"||t==="system")return t}catch{}return Wa()}function ko(){let t=Ge();return t==="system"?matchMedia("(prefers-color-scheme: dark)").matches:t==="dark"}function fn(){let t=Ge();t==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t}function it(t){try{localStorage.setItem(wo,t)}catch{}fn();for(let n of gn)n()}function _o(t){return gn.add(t),()=>gn.delete(t)}var So=[["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"]];function Ya({sections:t,section:n,site:s,onPick:a}){let{open:r,setOpen:i,root:c}=Be();return e("div",{class:"section-menu",ref:c,children:[e("button",{type:"button",class:"section-button","aria-haspopup":"menu","aria-expanded":r,onClick:()=>i(!r),children:[e("span",{children:o(t.find(([l])=>l===n)[1])}),e(qe,{})]}),r?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(([l,d])=>e("button",{type:"button",role:"menuitemradio","aria-checked":l===n,class:l===n?"site-option on":"site-option",onClick:()=>{i(!1),a(l)},children:[e("span",{class:"site-option-text",children:e("span",{class:"site-option-name",children:o(d)})}),l===n?e(M,{name:"check"}):null]}))]}):null]})}function Za(){try{return Intl.supportedValuesOf("timeZone")}catch{return["UTC"]}}function Ja(t){let n=Math.round((t-Date.now())/1e3),s=new Intl.RelativeTimeFormat(Z(),{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[r,i]=h(!1);if(a){let c=r?o("install.copied"):o("install.copy");return e("button",{type:"button",class:r?"copy-icon done":"copy-icon",title:c,"aria-label":c,onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1600)}).catch(()=>{})},children:e(M,{name:r?"check":"copy"})})}return e("button",{type:"button",class:s?`copy ${s}`:"copy",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1600)}).catch(()=>{})},children:[e(M,{name:r?"check":n?"sparkle":"copy"}),r?o("install.copied"):n??o("install.copy")]})}function ue({children:t}){return e("div",{class:"code",children:[e("pre",{children:e("code",{children:t})}),e(ct,{text:t})]})}function lt({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 Xa({site:t,admin:n,onSaved:s,onLanguage:a,onDeleted:r}){let[i,c]=h(t.name),[l,d]=h(t.hostnames.join(", ")),[p,m]=h(t.timezone),[f,b]=h("idle"),[g,_]=h(""),[v,u]=h(Ge()),S=Za(),E=oe.managed&&l.split(/[\s,]+/).filter(Boolean).join(",")!==t.hostnames.join(","),y=i.trim()!==t.name||p!==t.timezone||E,R=w=>{w.preventDefault(),b("saving"),_(""),L.updateSite(t.id,{name:i.trim(),timezone:p,...E?{hostnames:l}:{}}).then(x=>{s(x.site),b("saved")}).catch(x=>{_(x.message),b("idle")})};return e(U,{children:[t.remote?e(tr,{site:t}):null,e("form",{class:"settings-group",onSubmit:R,children:[e(lt,{label:o("settings.siteName"),children:e("input",{class:"value",type:"text",maxLength:80,value:i,onInput:w=>c(w.target.value)})}),oe.managed&&!t.remote?e(lt,{label:o("sites.domains"),hint:o("sites.domainsHint"),children:e("input",{class:"value",type:"text",value:l,onInput:w=>d(w.target.value)})}):null,t.remote&&!t.manage?null:e(lt,{label:o("settings.timezone"),hint:o("settings.timezoneHint"),children:e("select",{class:"value",value:p,onChange:w=>m(w.target.value),children:(S.includes(p)?S:[p,...S]).map(w=>e("option",{value:w,children:w.replace(/_/g," ")}))})}),e("div",{class:"settings-actions",children:[g?e("span",{class:"settings-error",children:g}):null,f==="saved"&&!y?e("span",{class:"settings-ok",children:o("settings.saved")}):null,e("button",{type:"submit",class:"solid",disabled:!y||f==="saving"||!i.trim(),children:[e(M,{name:"save"}),o(f==="saving"?"settings.saving":"settings.save")]})]})]}),e("div",{class:"settings-group",children:[e(lt,{label:o("settings.language"),hint:o("settings.languageHint"),children:e("select",{class:"value",value:Z(),onChange:w=>a(w.target.value),children:Pe.map(([w,x])=>e("option",{value:w,children:x}))})}),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(w=>e("button",{type:"button",role:"radio","aria-checked":v===w,class:v===w?"op on":"op",onClick:()=>{it(w),u(w)},children:o(w==="system"?"settings.themeSystem":w==="light"?"settings.themeLight":"settings.themeDark")}))}),e("span",{class:"field-hint",children:o("settings.languageHint")})]})]}),oe.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(te,{name:t.name,...t.remote?{label:o("sites.disconnectButton"),confirm:o("sites.confirmDisconnect"),hint:o("sites.disconnectName",{name:t.name}),icon:"unlink"}:{},onDelete:()=>{L.deleteSite(t.id).then(()=>r(t.id)).catch(w=>_(w.message))}})})]})}):null]})}var Qa=[6,12,24,36,60];function er({site:t,onSaved:n}){let s=t.retentionMonths??null,a=!!t.remote&&t.retentionMonths===void 0,[r,i]=h(s),[c,l]=h("idle"),[d,p]=h(""),m=g=>g%12===0?o("data.years",{n:g/12}):o("data.months",{n:g}),f=r===null||s!==null&&r>=s?null:(()=>{let g=new Date;return g.setMonth(g.getMonth()-r),g.toLocaleDateString(Z(),{day:"numeric",month:"long",year:"numeric"})})();return e(U,{children:[e("form",{class:"settings-group",onSubmit:g=>{g.preventDefault(),l("saving"),p(""),L.updateSite(t.id,{retentionMonths:r}).then(_=>{n({..._.site,retentionMonths:r}),l("saved")}).catch(_=>{p(_.message),l("idle")})},children:[e(lt,{label:o("data.retention"),hint:o("data.retentionHint"),children:e("select",{class:"value",disabled:a,value:r===null?"":String(r),onChange:g=>{let _=g.target.value;i(_?Number(_):null),l("idle")},children:[e("option",{value:"",children:o("data.forever")}),Qa.map(g=>e("option",{value:String(g),children:m(g)}))]})}),a?e("p",{class:"settings-warning",children:o("data.unreachable",{url:t.remote})}):null,f?e("p",{class:"settings-warning",children:o("data.deletesBefore",{date:f})}):null,e("div",{class:"settings-actions",children:[d?e("span",{class:"settings-error",children:d}):null,c==="saved"&&r===s?e("span",{class:"settings-ok",children:o("settings.saved")}):null,e("button",{type:"submit",class:"solid",disabled:r===s||c==="saving",children:[e(M,{name:"save"}),o(c==="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:()=>{ze("export",new URLSearchParams({site:t.id,period:"all"})).catch(g=>p(g.message))},children:[e(M,{name:"download"}),o("data.download")]})})]})})]})}var Co=new URLSearchParams(location.search).get("connected")==="1",To=t=>{try{return new URL(t).host}catch{return t}};function tr({site:t}){let[n,s]=h(""),[a,r]=h(!1),i=()=>{s(""),r(!0),L.connect(t.remote,t.remoteSite).then(c=>location.assign(c.authorize)).catch(c=>{s(c.message),r(!1)})};return e("div",{class:"remote-callout",children:[Co?e("p",{class:"settings-ok-text",role:"status",children:[e(M,{name:"check"}),o("sites.connected",{host:To(t.remote)})]}):null,e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(M,{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:i,children:[e(M,{name:"key"}),o("sites.reconnect")]}):t.manage?e("a",{class:"box-button",href:t.remote,target:"_blank",rel:"noopener",children:[e(M,{name:"external"}),o("sites.openRemote")]}):e("button",{type:"button",class:"box-button solid",disabled:a,onClick:i,children:[e(M,{name:"key"}),o("sites.allowChanges")]})]}),t.connection==="refused"&&!Co?e("p",{class:"settings-error",children:o("sites.refused",{host:To(t.remote)})}):null,n?e("p",{class:"settings-error",children:n}):null]})}function nr({site:t}){let[n,s]=h(""),[a,r]=h("");O(()=>{L.observeKey(t.id).then(c=>s(c.key)).catch(c=>r(c.message))},[t.id]);let i=()=>L.newObserveKey(t.id).then(c=>s(c.key)).catch(c=>r(c.message));return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:e("strong",{children:o("pluginKey.title")})}),e("p",{class:"settings-text",children:o("pluginKey.intro")}),n?e(ue,{children:n}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"ghost",onClick:()=>{i()},children:[e(M,{name:"refresh"}),o("pluginKey.replace")]})}),a?e("span",{class:"settings-error",children:a}):null]})}function sr({site:t}){let[n,s]=h(""),[a,r]=h(""),i=()=>L.createToken(o("embedKey.name"),t.id,"embed").then(c=>{r(""),s(c.secret)}).catch(c=>r(c.message));return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:e("strong",{children:o("embedKey.title")})}),e("p",{class:"settings-text",children:o("embedKey.intro")}),n?e(U,{children:[e("p",{class:"settings-text",children:o("tokens.once")}),e(ue,{children:n})]}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"ghost",onClick:()=>{i()},children:[e(M,{name:"key"}),o(n?"embedKey.another":"embedKey.make")]})}),a?e("span",{class:"settings-error",children:a}):null]})}function or({site:t}){let[n,s]=h("visits");return e(U,{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(mo,{site:t}):e(lo,{site:t})]})}function vn({site:t,sites:n}){let[s,a]=h(()=>{try{return localStorage.getItem("runlight_ignore")==="1"}catch{return!1}}),r=location.origin,i=n.length>1||oe.managed,l=`<script defer src="${`${r}${de}/s.js${oe.managed?`?site=${encodeURIComponent(t.id)}`:""}`}"${i?` data-site="${t.id}"`:""}><\/script>`,d=t.hostnames[0],p=d?`https://${d}/?runlight=ignore`:"",m=()=>{try{s?localStorage.removeItem("runlight_ignore"):localStorage.setItem("runlight_ignore","1"),a(!s)}catch{}};return e(U,{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:Ja(t.lastSeen)}):o("install.none")]}),e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(M,{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:oe.managed?go({script:l,host:d}):fo({origin:location.origin,base:de,site:i?t.id:void 0})})]}),e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:ce("install.script",{tag:e("code",{children:"</head>"})})}),e(ue,{children:l}),e("p",{class:"settings-text",children:o("install.events")}),e(ue,{children:'<button data-runlight="Signup" data-runlight-plan="pro">Sign up</button>'}),e("p",{class:"settings-text",children:o("install.eventsJs")}),e(ue,{children:'runlight("Newsletter signup", { source: "footer" })'}),oe.managed?null:e(U,{children:[e("p",{class:"settings-text",children:o("install.agents")}),e(ue,{children:`// proxy.ts (middleware.ts before Next.js 16)
|
|
72
|
+
`}var vo=(t,n)=>`${n}${t.path}`;function Ga({site:t,share:n,home:s,onChanged:a}){let[r,i]=h(!1),[c,l]=h(n.name),[d,p]=h(!1),[m,f]=h("");return e("li",{children:[e("div",{class:"domain-main",children:[r?e("form",{class:"share-rename",onSubmit:g=>{g.preventDefault(),f(""),L.renameShare(t,n.id,c).then(()=>{i(!1),a()}).catch(k=>f(k.message))},children:[e("input",{class:"value",type:"text",value:c,maxLength:100,autoFocus:!0,onInput:g=>l(g.target.value)}),e("button",{type:"submit",class:"solid",children:[e(C,{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:pe(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(vo(n,s)).then(()=>{p(!0),setTimeout(()=>p(!1),1600)}).catch(()=>{}),children:[e(C,{name:d?"check":"copy"}),d?o("install.copied"):o("install.copy")]}),e("a",{class:"copy inline",href:vo(n,s),target:"_blank",rel:"noopener noreferrer",children:[e(C,{name:"external"}),o("share.open")]}),r?null:e("button",{type:"button",class:"copy inline",onClick:()=>i(!0),children:[e(C,{name:"edit"}),o("share.rename")]}),e(te,{name:n.name||o("share.unnamed"),onDelete:()=>{L.deleteShare(t,n.id).then(a).catch(g=>f(g.message))}})]}),m?e("span",{class:"settings-error",children:m}):null]})}function bo({site:t}){let[n,s]=h(null),[a,r]=h(""),[i,c]=h(""),l=()=>L.shares(t.id).then(p=>s(p.shares)).catch(p=>c(p.message));F(()=>{l()},[t.id]);let d=p=>{p.preventDefault(),c(""),L.createShare(t.id,a.trim()).then(()=>(r(""),l())).catch(m=>c(m.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(p=>e(Ga,{site:t.id,share:p,home:t.remote?new URL(t.remote).origin:location.origin,onChanged:()=>{l()}},p.id))}):n?e(G,{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:p=>r(p.target.value)}),e("button",{type:"submit",class:"solid",children:[e(C,{name:"share"}),o("share.create")]})]}),i?e("span",{class:"settings-error",children:i}):null]})}var yo=t=>pe(new Date(t).toISOString().slice(0,10));function xo({sites:t}){let[n,s]=h(null),[a,r]=h(""),[i,c]=h(""),[l,d]=h(null),[p,m]=h(""),f=`${location.origin}${me}/mcp`,b=u=>t.find(_=>_.id===u)?.name??u,g=()=>L.tokens().then(u=>s(u.tokens)).catch(u=>m(u.message));F(()=>{g()},[]);let k=u=>{u.preventDefault(),m("");let _=a.trim();L.createToken(_,i).then(T=>(d({name:_,secret:T.secret}),r(""),g())).catch(T=>m(T.message))},v=l?.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(ce,{children:f}),l?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:[e("strong",{children:l.name})," ",o("tokens.once")]}),e(ce,{children:l.secret}),e("p",{class:"settings-text",children:o("tokens.claudeCode")}),e(ce,{children:`claude mcp add --transport http runlight ${f} --header "Authorization: Bearer ${v}"`}),e("p",{class:"settings-text",children:o("tokens.json")}),e(ce,{children:JSON.stringify({mcpServers:{runlight:{url:f,headers:{Authorization:`Bearer ${v}`}}}},null,2)}),e("button",{type:"button",class:"ghost token-done",onClick:()=>d(null),children:[e(C,{name:"check"}),o("tokens.done")]})]}):null,n&&n.length?e("ul",{class:"domain-list share-list",children:n.map(u=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:u.name}),e("span",{class:"share-meta",children:[`rl_\u2026${u.hint}`," \xB7 ",u.site?o("tokens.siteOnly",{site:b(u.site)}):o("tokens.allSites"),u.scope==="manage"?` \xB7 ${o("tokens.manages")}`:u.scope==="embed"?` \xB7 ${o("tokens.embeds")}`:""," \xB7 ",o("links.createdOn",{date:yo(u.createdAt)})," \xB7 ",u.lastUsedAt?o("tokens.used",{date:yo(u.lastUsedAt)}):o("tokens.never")]})]}),e("div",{class:"domain-actions",children:e(te,{name:u.name,onDelete:()=>{m(""),L.deleteToken(u.id).then(g).catch(_=>m(_.message))}})})]},u.id))}):n?e(G,{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:k,children:[e("input",{class:"value",type:"text",maxLength:100,required:!0,placeholder:o("tokens.namePlaceholder"),value:a,onInput:u=>r(u.target.value)}),t.length>1?e("select",{class:"value",value:i,"aria-label":o("tokens.scope"),onChange:u=>c(u.target.value),children:[e("option",{value:"",children:o("tokens.allSites")}),t.map(u=>e("option",{value:u.id,children:o("tokens.siteOnly",{site:u.name})}))]}):null,e("button",{type:"submit",class:"solid",children:[e(C,{name:"key"}),o("tokens.create")]})]}),p?e("span",{class:"settings-error",children:p}):null]})}var wo="runlight_theme",fn=new Set;function Wa(){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 We(){try{let t=localStorage.getItem(wo);if(t==="light"||t==="dark"||t==="system")return t}catch{}return Wa()}function ko(){let t=We();return t==="system"?matchMedia("(prefers-color-scheme: dark)").matches:t==="dark"}function vn(){let t=We();t==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=t}function it(t){try{localStorage.setItem(wo,t)}catch{}vn();for(let n of fn)n()}function _o(t){return fn.add(t),()=>fn.delete(t)}var So=[["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"]];function Ya({sections:t,section:n,site:s,onPick:a}){let{open:r,setOpen:i,root:c}=qe();return e("div",{class:"section-menu",ref:c,children:[e("button",{type:"button",class:"section-button","aria-haspopup":"menu","aria-expanded":r,onClick:()=>i(!r),children:[e("span",{children:o(t.find(([l])=>l===n)[1])}),e(Ve,{})]}),r?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(([l,d])=>e("button",{type:"button",role:"menuitemradio","aria-checked":l===n,class:l===n?"site-option on":"site-option",onClick:()=>{i(!1),a(l)},children:[e("span",{class:"site-option-text",children:e("span",{class:"site-option-name",children:o(d)})}),l===n?e(C,{name:"check"}):null]}))]}):null]})}function Za(){try{return Intl.supportedValuesOf("timeZone")}catch{return["UTC"]}}function Ja(t){let n=Math.round((t-Date.now())/1e3),s=new Intl.RelativeTimeFormat(Z(),{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[r,i]=h(!1);if(a){let c=r?o("install.copied"):o("install.copy");return e("button",{type:"button",class:r?"copy-icon done":"copy-icon",title:c,"aria-label":c,onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1600)}).catch(()=>{})},children:e(C,{name:r?"check":"copy"})})}return e("button",{type:"button",class:s?`copy ${s}`:"copy",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1600)}).catch(()=>{})},children:[e(C,{name:r?"check":n?"sparkle":"copy"}),r?o("install.copied"):n??o("install.copy")]})}function ce({children:t}){return e("div",{class:"code",children:[e("pre",{children:e("code",{children:t})}),e(ct,{text:t})]})}function lt({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 Xa({site:t,admin:n,onSaved:s,onLanguage:a,onDeleted:r}){let[i,c]=h(t.name),[l,d]=h(t.hostnames.join(", ")),[p,m]=h(t.timezone),[f,b]=h("idle"),[g,k]=h(""),[v,u]=h(We()),_=Za(),T=oe.managed&&l.split(/[\s,]+/).filter(Boolean).join(",")!==t.hostnames.join(","),y=i.trim()!==t.name||p!==t.timezone||T,P=w=>{w.preventDefault(),b("saving"),k(""),L.updateSite(t.id,{name:i.trim(),timezone:p,...T?{hostnames:l}:{}}).then(x=>{s(x.site),b("saved")}).catch(x=>{k(x.message),b("idle")})};return e(U,{children:[t.remote?e(tr,{site:t}):null,e("form",{class:"settings-group",onSubmit:P,children:[e(lt,{label:o("settings.siteName"),children:e("input",{class:"value",type:"text",maxLength:80,value:i,onInput:w=>c(w.target.value)})}),oe.managed&&!t.remote?e(lt,{label:o("sites.domains"),hint:o("sites.domainsHint"),children:e("input",{class:"value",type:"text",value:l,onInput:w=>d(w.target.value)})}):null,t.remote&&!t.manage?null:e(lt,{label:o("settings.timezone"),hint:o("settings.timezoneHint"),children:e("select",{class:"value",value:p,onChange:w=>m(w.target.value),children:(_.includes(p)?_:[p,..._]).map(w=>e("option",{value:w,children:w.replace(/_/g," ")}))})}),e("div",{class:"settings-actions",children:[g?e("span",{class:"settings-error",children:g}):null,f==="saved"&&!y?e("span",{class:"settings-ok",children:o("settings.saved")}):null,e("button",{type:"submit",class:"solid",disabled:!y||f==="saving"||!i.trim(),children:[e(C,{name:"save"}),o(f==="saving"?"settings.saving":"settings.save")]})]})]}),e("div",{class:"settings-group",children:[e(lt,{label:o("settings.language"),hint:o("settings.languageHint"),children:e("select",{class:"value",value:Z(),onChange:w=>a(w.target.value),children:Pe.map(([w,x])=>e("option",{value:w,children:x}))})}),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(w=>e("button",{type:"button",role:"radio","aria-checked":v===w,class:v===w?"op on":"op",onClick:()=>{it(w),u(w)},children:o(w==="system"?"settings.themeSystem":w==="light"?"settings.themeLight":"settings.themeDark")}))}),e("span",{class:"field-hint",children:o("settings.languageHint")})]})]}),oe.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(te,{name:t.name,...t.remote?{label:o("sites.disconnectButton"),confirm:o("sites.confirmDisconnect"),hint:o("sites.disconnectName",{name:t.name}),icon:"unlink"}:{},onDelete:()=>{L.deleteSite(t.id).then(()=>r(t.id)).catch(w=>k(w.message))}})})]})}):null]})}var Qa=[6,12,24,36,60];function er({site:t,onSaved:n}){let s=t.retentionMonths??null,a=!!t.remote&&t.retentionMonths===void 0,[r,i]=h(s),[c,l]=h("idle"),[d,p]=h(""),m=g=>g%12===0?o("data.years",{n:g/12}):o("data.months",{n:g}),f=r===null||s!==null&&r>=s?null:(()=>{let g=new Date;return g.setMonth(g.getMonth()-r),g.toLocaleDateString(Z(),{day:"numeric",month:"long",year:"numeric"})})();return e(U,{children:[e("form",{class:"settings-group",onSubmit:g=>{g.preventDefault(),l("saving"),p(""),L.updateSite(t.id,{retentionMonths:r}).then(k=>{n({...k.site,retentionMonths:r}),l("saved")}).catch(k=>{p(k.message),l("idle")})},children:[e(lt,{label:o("data.retention"),hint:o("data.retentionHint"),children:e("select",{class:"value",disabled:a,value:r===null?"":String(r),onChange:g=>{let k=g.target.value;i(k?Number(k):null),l("idle")},children:[e("option",{value:"",children:o("data.forever")}),Qa.map(g=>e("option",{value:String(g),children:m(g)}))]})}),a?e("p",{class:"settings-warning",children:o("data.unreachable",{url:t.remote})}):null,f?e("p",{class:"settings-warning",children:o("data.deletesBefore",{date:f})}):null,e("div",{class:"settings-actions",children:[d?e("span",{class:"settings-error",children:d}):null,c==="saved"&&r===s?e("span",{class:"settings-ok",children:o("settings.saved")}):null,e("button",{type:"submit",class:"solid",disabled:r===s||c==="saving",children:[e(C,{name:"save"}),o(c==="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:()=>{je("export",new URLSearchParams({site:t.id,period:"all"})).catch(g=>p(g.message))},children:[e(C,{name:"download"}),o("data.download")]})})]})})]})}var Co=new URLSearchParams(location.search).get("connected")==="1",To=t=>{try{return new URL(t).host}catch{return t}};function tr({site:t}){let[n,s]=h(""),[a,r]=h(!1),i=()=>{s(""),r(!0),L.connect(t.remote,t.remoteSite).then(c=>location.assign(c.authorize)).catch(c=>{s(c.message),r(!1)})};return e("div",{class:"remote-callout",children:[Co?e("p",{class:"settings-ok-text",role:"status",children:[e(C,{name:"check"}),o("sites.connected",{host:To(t.remote)})]}):null,e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(C,{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:i,children:[e(C,{name:"key"}),o("sites.reconnect")]}):t.manage?e("a",{class:"box-button",href:t.remote,target:"_blank",rel:"noopener",children:[e(C,{name:"external"}),o("sites.openRemote")]}):e("button",{type:"button",class:"box-button solid",disabled:a,onClick:i,children:[e(C,{name:"key"}),o("sites.allowChanges")]})]}),t.connection==="refused"&&!Co?e("p",{class:"settings-error",children:o("sites.refused",{host:To(t.remote)})}):null,n?e("p",{class:"settings-error",children:n}):null]})}function nr({site:t}){let[n,s]=h(""),[a,r]=h("");F(()=>{L.observeKey(t.id).then(c=>s(c.key)).catch(c=>r(c.message))},[t.id]);let i=()=>L.newObserveKey(t.id).then(c=>s(c.key)).catch(c=>r(c.message));return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:e("strong",{children:o("pluginKey.title")})}),e("p",{class:"settings-text",children:o("pluginKey.intro")}),n?e(ce,{children:n}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"ghost",onClick:()=>{i()},children:[e(C,{name:"refresh"}),o("pluginKey.replace")]})}),a?e("span",{class:"settings-error",children:a}):null]})}function sr({site:t}){let[n,s]=h(""),[a,r]=h(""),i=()=>L.createToken(o("embedKey.name"),t.id,"embed").then(c=>{r(""),s(c.secret)}).catch(c=>r(c.message));return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:e("strong",{children:o("embedKey.title")})}),e("p",{class:"settings-text",children:o("embedKey.intro")}),n?e(U,{children:[e("p",{class:"settings-text",children:o("tokens.once")}),e(ce,{children:n})]}):null,e("div",{class:"settings-actions start",children:e("button",{type:"button",class:"ghost",onClick:()=>{i()},children:[e(C,{name:"key"}),o(n?"embedKey.another":"embedKey.make")]})}),a?e("span",{class:"settings-error",children:a}):null]})}function or({site:t}){let[n,s]=h("visits");return e(U,{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(mo,{site:t}):e(lo,{site:t})]})}function bn({site:t,sites:n}){let[s,a]=h(()=>{try{return localStorage.getItem("runlight_ignore")==="1"}catch{return!1}}),r=location.origin,i=n.length>1||oe.managed,l=`<script defer src="${`${r}${me}/s.js${oe.managed?`?site=${encodeURIComponent(t.id)}`:""}`}"${i?` data-site="${t.id}"`:""}><\/script>`,d=t.hostnames[0],p=d?`https://${d}/?runlight=ignore`:"",m=()=>{try{s?localStorage.removeItem("runlight_ignore"):localStorage.setItem("runlight_ignore","1"),a(!s)}catch{}};return e(U,{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:Ja(t.lastSeen)}):o("install.none")]}),e("div",{class:"prompt-row",children:[e("span",{class:"callout-icon","aria-hidden":"true",children:e(C,{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:oe.managed?go({script:l,host:d}):fo({origin:location.origin,base:me,site:i?t.id:void 0})})]}),e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:de("install.script",{tag:e("code",{children:"</head>"})})}),e(ce,{children:l}),e("p",{class:"settings-text",children:o("install.events")}),e(ce,{children:'<button data-runlight="Signup" data-runlight-plan="pro">Sign up</button>'}),e("p",{class:"settings-text",children:o("install.eventsJs")}),e(ce,{children:'runlight("Newsletter signup", { source: "footer" })'}),oe.managed?null:e(U,{children:[e("p",{class:"settings-text",children:o("install.agents")}),e(ce,{children:`// proxy.ts, in Next.js 16 and later
|
|
71
73
|
import { rl } from "@/lib/runlight";
|
|
72
74
|
export function proxy(request: Request) {
|
|
73
75
|
void rl.observe(request);
|
|
74
|
-
}`})]})]}),e(nr,{site:t}),e(sr,{site:t}),e("div",{class:"settings-group",children:e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("install.ignore")}),oe.managed?null:e(U,{children:[e("span",{class:"settings-text",children:o(s?"install.ignored":"install.counted")}),e("div",{children:e("button",{type:"button",class:"ghost",onClick:m,children:[e(M,{name:s?"refresh":"x"}),o(s?"install.trackButton":"install.ignoreButton")]})})]}),p?e("span",{class:oe.managed?"settings-text":"field-hint",children:ce(oe.managed?"install.ignoreServer":"install.ignoreElsewhere",{link:e("a",{href:p,target:"_blank",rel:"noopener",children:p})})}):null]})})]})}function ar(t,n){let[s,a]=h(null),r=()=>{a(null),L.checkLinkDomain(t,n).then(i=>a({working:i.working,reason:i.code&&be(i.code,i.params)||i.reason,target:i.target})).catch(i=>a({working:!1,reason:i.message}))};return O(r,[n]),{state:s,check:r}}var rr=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 ir(t){let n=t.split("."),s=rr.has(n.slice(-2).join("."))?3:2;return n.length<=s?"@":n.slice(0,n.length-s).join(".")}function lr({domain:t,target:n,onCheck:s}){let a=ir(t),r=a==="@",i=/^[\d.]+$/.test(n.host)||n.host.includes(":")||n.host==="localhost"||n.host.endsWith(".localhost"),c=r?n.addresses.length?n.addresses.map(l=>({type:l.includes(":")?"AAAA":"A",value:l})):[{type:"ALIAS",value:n.host}]:[{type:"CNAME",value:n.host}];return e("div",{class:"domain-setup",children:[c.map(l=>e("div",{class:"dns-record",children:[e("span",{class:"dns-field",children:[e("span",{class:"dns-label",children:o("links.recordType")}),e("code",{children:l.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:l.value}),e(ct,{iconOnly:!0,text:l.value})]})]})]})),e("ol",{class:"setup-steps",children:[e("li",{children:o(c[0].type==="ALIAS"?"links.doDnsAlias":"links.doDns")}),e("li",{children:o("links.doHttps",{domain:t})}),e("li",{children:o("links.doCheck")})]}),i?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(M,{name:"refresh"}),o("links.recheck")]}),e("a",{class:"copy inline",href:"https://runlight.sh/docs/links/#custom-domains",target:"_blank",rel:"noopener",children:[e(M,{name:"external"}),o("links.guide")]})]})]})}function cr({site:t,domain:n,fallbackHost:s,onRemove:a}){let{state:r,check:i}=ar(t,n),c=r?r.target??{host:s,addresses:[]}:null,[l,d]=h(null),p=l??(r!==null&&!r.working);return e("li",{class:"domain-row",children:[e("div",{class:"domain-main",children:[e("span",{class:"domain-name",children:n}),e("span",{class:r?r.working?"domain-status ok":"domain-status bad":"domain-status",children:[r?e("span",{class:r.working?"beat on":"beat off","aria-hidden":"true"}):null,r?r.working?o("links.working"):o("links.notWorking",{reason:r.reason}):o("links.checking")]})]}),e("div",{class:"domain-actions",children:[c?e("button",{type:"button",class:p?"copy inline on":"copy inline","aria-expanded":p,onClick:()=>d(!p),children:[e(M,{name:"list"}),o("links.setup")]}):null,e("button",{type:"button",class:"copy inline danger",onClick:a,children:[e(M,{name:"trash"}),o("links.removeDomain")]})]}),p&&c?e(lr,{domain:n,target:c,onCheck:i}):null]})}function dr({site:t}){let n=t.remote?new URL(t.remote):null,s=n?n.hostname:location.hostname,a=n?n.host:location.host,[r,i]=h(null),[c,l]=h(""),[d,p]=h(""),m=()=>L.linkDomains(t.id).then(b=>i(b.domains)).catch(b=>p(b.message));O(()=>{m()},[t.id]);let f=b=>{b.preventDefault(),p(""),L.addLinkDomain(t.id,c).then(()=>(l(""),m())).catch(g=>p(g.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(M,{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:ho({domain:c.trim()||r?.[0]||"t.example.com",host:s,origin:n?n.origin:location.origin,base:n?n.pathname.replace(/\/$/,""):de,linkPath:"/go"})})]}),e("ol",{class:"steps",children:[e("li",{children:ce("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`})})}),(r??[]).map(b=>e(cr,{site:t.id,domain:b,fallbackHost:s,onRemove:()=>L.removeLinkDomain(t.id,b).then(m).catch(g=>p(g.message))}))]}),e("p",{class:"field-hint domain-note",children:o("links.removeNote",{fallback:`${a}/go`})}),e("form",{class:"domain-add",onSubmit:f,children:[e("input",{class:"value",type:"text",placeholder:o("links.domainPlaceholder"),value:c,onInput:b=>l(b.target.value)}),e("button",{type:"submit",class:"solid",disabled:!c.trim(),children:[e(M,{name:"globe"}),o("links.addDomain")]})]}),d?e("span",{class:"settings-error",children:d}):null]})}function Mo({site:t,sites:n,view:s,start:a,onClose:r,onSaved:i,onLanguage:c,onDeleted:l,onDemoted:d,me:p}){let m=Qe?p?.role==="owner"||p?.role==="admin":!0,f=t.remote?t.manage?So.filter(([u])=>["general","goals","funnels","mail","email","sharing","links","data","assistant"].includes(u)):[["general","settings.general"],["assistant","settings.assistant"]]:So,b=p&&m?[...f,["people","settings.people"]]:f,[g,_]=h(a&&b.some(([u])=>u===a)?a:"general"),v=K(null);return he(v),O(()=>{let u=S=>S.key==="Escape"&&r();return document.addEventListener("keydown",u),document.body.classList.add("locked"),v.current?.querySelector(".settings-nav button")?.focus(),()=>{document.removeEventListener("keydown",u),document.body.classList.remove("locked")}},[]),e("div",{class:"scrim center",onPointerDown:u=>u.target===u.currentTarget&&r(),children:e("div",{class:"settings",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",ref:v,children:[e("nav",{class:"settings-nav","aria-label":o("settings.title"),children:[e("h2",{id:"settings-title",children:o("settings.title")}),e("p",{class:"settings-site",children:t.name}),b.map(([u,S])=>e("button",{type:"button",class:g===u?"settings-tab on":"settings-tab","aria-current":g===u?"page":void 0,onClick:()=>_(u),children:o(S)}))]}),e("div",{class:"settings-body",children:[e("header",{class:"settings-head",children:[e("h3",{children:o(b.find(([u])=>u===g)[1])}),e(Ya,{sections:b,section:g,site:t.name,onPick:_}),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("div",{class:"settings-content",children:g==="general"?e(Xa,{site:t,admin:m,onSaved:i,onLanguage:c,onDeleted:l}):g==="install"?e(vn,{site:t,sites:n}):g==="goals"?e(ao,{site:t,view:s}):g==="funnels"?e(no,{site:t,view:s}):g==="email"?e(Qs,{site:t,onSetUp:()=>_("mail")}):g==="mail"?e(Xs,{site:t,admin:m}):g==="sharing"?e(bo,{site:t}):g==="people"&&p?e(Eo,{me:p,onDemoted:d}):g==="api"?e(xo,{sites:n}):g==="links"?e(dr,{site:t}):g==="data"?e(er,{site:t,onSaved:i}):g==="assistant"?e(Js,{owner:m}):e(or,{site:t})})]})]})})}var Po=[-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],Ro=[-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],pr=0,xe=(t,n)=>(t>>>n&1)!==0;function Lo(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 Ao=t=>Math.floor(Lo(t)/8)-Po[t]*Ro[t];function ur(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,r=[6];for(let i=n-7;r.length<s;i-=a)r.splice(1,0,i);return r}function bn(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 mr(t){let n=new Array(t).fill(0);n[t-1]=1;let s=1;for(let a=0;a<t;a++){for(let r=0;r<t;r++)n[r]=bn(n[r],s),r+1<t&&(n[r]^=n[r+1]);s=bn(s,2)}return n}function hr(t,n){let s=new Array(n.length).fill(0);for(let a of t){let r=a^s.shift();s.push(0),n.forEach((i,c)=>s[c]^=bn(i,r))}return s}function gr(t){let n=t.length,s=0,a=[];for(let c=0;c<n;c++)a.push(t[c]);for(let c=0;c<n;c++)a.push(t.map(l=>l[c]));for(let c of a){let l=1;for(let p=1;p<=n;p++)p<n&&c[p]===c[p-1]?l++:(l>=5&&(s+=3+(l-5)),l=1);let d=c.map(p=>p?"1":"0").join("");for(let p of["10111010000","00001011101"])for(let m=d.indexOf(p);m>=0;m=d.indexOf(p,m+1))s+=40}for(let c=0;c+1<n;c++)for(let l=0;l+1<n;l++){let d=t[c][l];d===t[c][l+1]&&d===t[c+1][l]&&d===t[c+1][l+1]&&(s+=3)}let r=t.reduce((c,l)=>c+l.filter(Boolean).length,0),i=n*n;return s+=(Math.ceil(Math.abs(r*20-i*10)/i)-1)*10,s}var fr=[(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 vr(t,n){let s=Array.from(new TextEncoder().encode(t)),a=1;for(;a<=40&&!(4+(a<=9?8:16)+s.length*8<=Ao(a)*8);a++);if(a>40)throw new RangeError("Too much text for a QR code");let r=Ao(a)*8,i=[],c=(k,A)=>{for(let $=A-1;$>=0;$--)i.push(k>>>$&1)};c(4,4),c(s.length,a<=9?8:16);for(let k of s)c(k,8);c(0,Math.min(4,r-i.length)),c(0,(8-i.length%8)%8);for(let k=236;i.length<r;k^=253)c(k,8);let l=[];for(let k=0;k<i.length;k+=8)l.push(i.slice(k,k+8).reduce((A,$)=>A<<1|$,0));let d=Ro[a],p=Po[a],m=Math.floor(Lo(a)/8),f=d-m%d,b=Math.floor(m/d),g=mr(p),_=[];for(let k=0,A=0;k<d;k++){let $=l.slice(A,A+b-p+(k<f?0:1));A+=$.length;let C=hr($,g);k<f&&$.push(0),_.push([...$,...C])}let v=[];for(let k=0;k<_[0].length;k++)_.forEach((A,$)=>{(k!==b-p||$>=f)&&v.push(A[k])});let u=a*4+17,S=Array.from({length:u},()=>new Array(u).fill(!1)),E=Array.from({length:u},()=>new Array(u).fill(!1)),y=(k,A,$)=>{S[A][k]=$,E[A][k]=!0};for(let k=0;k<u;k++)y(6,k,k%2===0),y(k,6,k%2===0);for(let[k,A]of[[3,3],[u-4,3],[3,u-4]])for(let $=-4;$<=4;$++)for(let C=-4;C<=4;C++){let T=k+C,N=A+$;if(T>=0&&T<u&&N>=0&&N<u){let W=Math.max(Math.abs(C),Math.abs($));y(T,N,W!==2&&W!==4)}}let R=ur(a,u),w=R.length-1;R.forEach((k,A)=>R.forEach(($,C)=>{if(!(A===0&&C===0||A===0&&C===w||A===w&&C===0))for(let T=-2;T<=2;T++)for(let N=-2;N<=2;N++)y(k+N,$+T,Math.max(Math.abs(N),Math.abs(T))!==1)}));let x=k=>{let A=pr<<3|k,$=A;for(let T=0;T<10;T++)$=$<<1^($>>>9)*1335;let C=(A<<10|$)^21522;for(let T=0;T<=5;T++)y(8,T,xe(C,T));y(8,7,xe(C,6)),y(8,8,xe(C,7)),y(7,8,xe(C,8));for(let T=9;T<15;T++)y(14-T,8,xe(C,T));for(let T=0;T<8;T++)y(u-1-T,8,xe(C,T));for(let T=8;T<15;T++)y(8,u-15+T,xe(C,T));y(8,u-8,!0)};if(x(0),a>=7){let k=a;for(let $=0;$<12;$++)k=k<<1^(k>>>11)*7973;let A=a<<12|k;for(let $=0;$<18;$++){let C=u-11+$%3,T=Math.floor($/3);y(C,T,xe(A,$)),y(T,C,xe(A,$))}}let P=0;for(let k=u-1;k>=1;k-=2){k===6&&(k=5);for(let A=0;A<u;A++)for(let $=0;$<2;$++){let C=k-$,N=(k+1&2)===0?u-1-A:A;!E[N][C]&&P<v.length*8&&(S[N][C]=xe(v[P>>>3],7-(P&7)),P++)}}let D=k=>{for(let A=0;A<u;A++)for(let $=0;$<u;$++)!E[A][$]&&fr[k]($,A)&&(S[A][$]=!S[A][$])},F=n??-1;if(F<0){let k=1/0;for(let A=0;A<8;A++){D(A),x(A);let $=gr(S);$<k&&(k=$,F=A),D(A)}}return D(F),x(F),S}function Io(t){let n=vr(t),s=n.length+8,a="";return n.forEach((r,i)=>r.forEach((c,l)=>c&&(a+=`M${l+4},${i+4}h1v1h-1z`))),{size:s,path:a}}var Do=t=>pe(new Date(t).toISOString().slice(0,10));function Oo({me:t,onClose:n}){let[s,a]=h(""),[r,i]=h(""),[c,l]=h(""),d=Ys(r,[t.email.split("@")[0],t.email]),p=c.length>0&&c!==r,[m,f]=h("idle"),[b,g]=h(""),_=u=>{u.preventDefault(),f("saving"),g(""),L.changePassword(s,r).then(()=>{f("saved"),a(""),i(""),l("")}).catch(S=>{g(S.message),f("idle")})},v=(u,S)=>{u(S.target.value),g("")};return e(se,{title:o("account.title"),sub:t.email,onClose:n,children:[e("form",{class:"sheet-body link-form",onSubmit:_,children:[e("p",{class:"settings-text",children:o(`account.${t.role}`)}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.current")}),e(re,{class:"value",autoComplete:"current-password",required:!0,value:s,onInput:u=>v(a,u)})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.next")}),e(re,{class:"value",autoComplete:"new-password",minLength:10,required:!0,value:r,onInput:u=>v(i,u),"aria-describedby":"password-strength"}),r?e("span",{class:"strength",id:"password-strength","data-score":d,"aria-live":"polite",children:[e("span",{class:"strength-bar","aria-hidden":"true",children:[1,2,3,4].map(u=>e("span",{class:d>=u?"on":""}))}),e("span",{class:"strength-label",children:o(`account.strength${d}`)})]}):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(re,{class:"value",autoComplete:"new-password",required:!0,value:c,"aria-invalid":p,onInput:u=>v(l,u)}),p?e("span",{class:"field-hint field-bad",children:o("account.mismatch")}):null]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:m==="saving"||!s||r.length<10||c!==r,children:[e(M,{name:"save"}),o("account.save")]}),m==="saved"?e("span",{class:"settings-ok",children:o("account.saved")}):null,b?e("span",{class:"settings-error",children:b}):null]})]}),e(br,{me:t})]})}function br({me:t}){let[n,s]=h(!!t.twoFactor),[a,r]=h(t.recoveryLeft??0),[i,c]=h(null),[l,d]=h(""),[p,m]=h(null),[f,b]=h(""),[g,_]=h(null),[v,u]=h(!1),[S,E]=h(""),[y,R]=h(!1),w=(k,A)=>{E(""),R(!0),k.then(A).catch($=>E($.message)).finally(()=>R(!1))},x=k=>{k.preventDefault(),i==="start"&&w(L.twoFactorStart(l),A=>{m(A),c(null),d("")}),i==="recovery"&&w(L.twoFactorRecovery(l),A=>{_(A.recovery),r(A.recovery.length),c(null),d("")}),i==="disable"&&w(L.twoFactorDisable(l),()=>{s(!1),c(null),d("")})},P=k=>{k.preventDefault(),w(L.twoFactorConfirm(f).catch(A=>{throw A instanceof Re&&A.code==="twofactor_restart"&&(m(null),b("")),A}),A=>{_(A.recovery),r(A.recovery.length),s(!0),m(null),b("")})},D=p?Io(p.uri):null,F=()=>{let k=new Blob([`Runlight recovery codes for ${t.email}
|
|
76
|
+
}`}),e(ce,{children:`// middleware.ts, in Next.js 15 and earlier
|
|
77
|
+
import { rl } from "@/lib/runlight";
|
|
78
|
+
export async function middleware(request: Request) {
|
|
79
|
+
void rl.observe(request);
|
|
80
|
+
}
|
|
81
|
+
// From Next.js 15.5, so it can reach a SQLite or Postgres store; before that, middleware only runs on the edge.
|
|
82
|
+
export const config = { runtime: "nodejs" };`})]})]}),e(nr,{site:t}),e(sr,{site:t}),e("div",{class:"settings-group",children:e("div",{class:"field-row",children:[e("span",{class:"field-label",children:o("install.ignore")}),oe.managed?null:e(U,{children:[e("span",{class:"settings-text",children:o(s?"install.ignored":"install.counted")}),e("div",{children:e("button",{type:"button",class:"ghost",onClick:m,children:[e(C,{name:s?"refresh":"x"}),o(s?"install.trackButton":"install.ignoreButton")]})})]}),p?e("span",{class:oe.managed?"settings-text":"field-hint",children:de(oe.managed?"install.ignoreServer":"install.ignoreElsewhere",{link:e("a",{href:p,target:"_blank",rel:"noopener",children:p})})}):null]})})]})}function ar(t,n){let[s,a]=h(null),r=()=>{a(null),L.checkLinkDomain(t,n).then(i=>a({working:i.working,reason:i.code&&be(i.code,i.params)||i.reason,target:i.target})).catch(i=>a({working:!1,reason:i.message}))};return F(r,[n]),{state:s,check:r}}var rr=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 ir(t){let n=t.split("."),s=rr.has(n.slice(-2).join("."))?3:2;return n.length<=s?"@":n.slice(0,n.length-s).join(".")}function lr({domain:t,target:n,onCheck:s}){let a=ir(t),r=a==="@",i=/^[\d.]+$/.test(n.host)||n.host.includes(":")||n.host==="localhost"||n.host.endsWith(".localhost"),c=r?n.addresses.length?n.addresses.map(l=>({type:l.includes(":")?"AAAA":"A",value:l})):[{type:"ALIAS",value:n.host}]:[{type:"CNAME",value:n.host}];return e("div",{class:"domain-setup",children:[c.map(l=>e("div",{class:"dns-record",children:[e("span",{class:"dns-field",children:[e("span",{class:"dns-label",children:o("links.recordType")}),e("code",{children:l.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:l.value}),e(ct,{iconOnly:!0,text:l.value})]})]})]})),e("ol",{class:"setup-steps",children:[e("li",{children:o(c[0].type==="ALIAS"?"links.doDnsAlias":"links.doDns")}),e("li",{children:o("links.doHttps",{domain:t})}),e("li",{children:o("links.doCheck")})]}),i?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(C,{name:"refresh"}),o("links.recheck")]}),e("a",{class:"copy inline",href:"https://runlight.sh/docs/links/#custom-domains",target:"_blank",rel:"noopener",children:[e(C,{name:"external"}),o("links.guide")]})]})]})}function cr({site:t,domain:n,fallbackHost:s,onRemove:a}){let{state:r,check:i}=ar(t,n),c=r?r.target??{host:s,addresses:[]}:null,[l,d]=h(null),p=l??(r!==null&&!r.working);return e("li",{class:"domain-row",children:[e("div",{class:"domain-main",children:[e("span",{class:"domain-name",children:n}),e("span",{class:r?r.working?"domain-status ok":"domain-status bad":"domain-status",children:[r?e("span",{class:r.working?"beat on":"beat off","aria-hidden":"true"}):null,r?r.working?o("links.working"):o("links.notWorking",{reason:r.reason}):o("links.checking")]})]}),e("div",{class:"domain-actions",children:[c?e("button",{type:"button",class:p?"copy inline on":"copy inline","aria-expanded":p,onClick:()=>d(!p),children:[e(C,{name:"list"}),o("links.setup")]}):null,e("button",{type:"button",class:"copy inline danger",onClick:a,children:[e(C,{name:"trash"}),o("links.removeDomain")]})]}),p&&c?e(lr,{domain:n,target:c,onCheck:i}):null]})}function dr({site:t}){let n=t.remote?new URL(t.remote):null,s=n?n.hostname:location.hostname,a=n?n.host:location.host,[r,i]=h(null),[c,l]=h(""),[d,p]=h(""),m=()=>L.linkDomains(t.id).then(b=>i(b.domains)).catch(b=>p(b.message));F(()=>{m()},[t.id]);let f=b=>{b.preventDefault(),p(""),L.addLinkDomain(t.id,c).then(()=>(l(""),m())).catch(g=>p(g.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(C,{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:ho({domain:c.trim()||r?.[0]||"t.example.com",host:s,origin:n?n.origin:location.origin,base:n?n.pathname.replace(/\/$/,""):me,linkPath:"/go"})})]}),e("ol",{class:"steps",children:[e("li",{children:de("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`})})}),(r??[]).map(b=>e(cr,{site:t.id,domain:b,fallbackHost:s,onRemove:()=>L.removeLinkDomain(t.id,b).then(m).catch(g=>p(g.message))}))]}),e("p",{class:"field-hint domain-note",children:o("links.removeNote",{fallback:`${a}/go`})}),e("form",{class:"domain-add",onSubmit:f,children:[e("input",{class:"value",type:"text",placeholder:o("links.domainPlaceholder"),value:c,onInput:b=>l(b.target.value)}),e("button",{type:"submit",class:"solid",disabled:!c.trim(),children:[e(C,{name:"globe"}),o("links.addDomain")]})]}),d?e("span",{class:"settings-error",children:d}):null]})}function Mo({site:t,sites:n,view:s,start:a,onClose:r,onSaved:i,onLanguage:c,onDeleted:l,onDemoted:d,me:p}){let m=Qe?p?.role==="owner"||p?.role==="admin":!0,f=t.remote?t.manage?So.filter(([u])=>["general","goals","funnels","mail","email","sharing","links","data","assistant"].includes(u)):[["general","settings.general"],["assistant","settings.assistant"]]:So,b=p&&m?[...f,["people","settings.people"]]:f,[g,k]=h(a&&b.some(([u])=>u===a)?a:"general"),v=K(null);return he(v),F(()=>{let u=_=>_.key==="Escape"&&r();return document.addEventListener("keydown",u),document.body.classList.add("locked"),v.current?.querySelector(".settings-nav button")?.focus(),()=>{document.removeEventListener("keydown",u),document.body.classList.remove("locked")}},[]),e("div",{class:"scrim center",onPointerDown:u=>u.target===u.currentTarget&&r(),children:e("div",{class:"settings",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",ref:v,children:[e("nav",{class:"settings-nav","aria-label":o("settings.title"),children:[e("h2",{id:"settings-title",children:o("settings.title")}),e("p",{class:"settings-site",children:t.name}),b.map(([u,_])=>e("button",{type:"button",class:g===u?"settings-tab on":"settings-tab","aria-current":g===u?"page":void 0,onClick:()=>k(u),children:o(_)}))]}),e("div",{class:"settings-body",children:[e("header",{class:"settings-head",children:[e("h3",{children:o(b.find(([u])=>u===g)[1])}),e(Ya,{sections:b,section:g,site:t.name,onPick:k}),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("div",{class:"settings-content",children:g==="general"?e(Xa,{site:t,admin:m,onSaved:i,onLanguage:c,onDeleted:l}):g==="install"?e(bn,{site:t,sites:n}):g==="goals"?e(ao,{site:t,view:s}):g==="funnels"?e(no,{site:t,view:s}):g==="email"?e(Qs,{site:t,onSetUp:()=>k("mail")}):g==="mail"?e(Xs,{site:t,admin:m}):g==="sharing"?e(bo,{site:t}):g==="people"&&p?e(Eo,{me:p,onDemoted:d}):g==="api"?e(xo,{sites:n}):g==="links"?e(dr,{site:t}):g==="data"?e(er,{site:t,onSaved:i}):g==="assistant"?e(Js,{owner:m}):e(or,{site:t})})]})]})})}var Po=[-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],Ro=[-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],pr=0,xe=(t,n)=>(t>>>n&1)!==0;function Lo(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 Ao=t=>Math.floor(Lo(t)/8)-Po[t]*Ro[t];function ur(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,r=[6];for(let i=n-7;r.length<s;i-=a)r.splice(1,0,i);return r}function yn(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 mr(t){let n=new Array(t).fill(0);n[t-1]=1;let s=1;for(let a=0;a<t;a++){for(let r=0;r<t;r++)n[r]=yn(n[r],s),r+1<t&&(n[r]^=n[r+1]);s=yn(s,2)}return n}function hr(t,n){let s=new Array(n.length).fill(0);for(let a of t){let r=a^s.shift();s.push(0),n.forEach((i,c)=>s[c]^=yn(i,r))}return s}function gr(t){let n=t.length,s=0,a=[];for(let c=0;c<n;c++)a.push(t[c]);for(let c=0;c<n;c++)a.push(t.map(l=>l[c]));for(let c of a){let l=1;for(let p=1;p<=n;p++)p<n&&c[p]===c[p-1]?l++:(l>=5&&(s+=3+(l-5)),l=1);let d=c.map(p=>p?"1":"0").join("");for(let p of["10111010000","00001011101"])for(let m=d.indexOf(p);m>=0;m=d.indexOf(p,m+1))s+=40}for(let c=0;c+1<n;c++)for(let l=0;l+1<n;l++){let d=t[c][l];d===t[c][l+1]&&d===t[c+1][l]&&d===t[c+1][l+1]&&(s+=3)}let r=t.reduce((c,l)=>c+l.filter(Boolean).length,0),i=n*n;return s+=(Math.ceil(Math.abs(r*20-i*10)/i)-1)*10,s}var fr=[(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 vr(t,n){let s=Array.from(new TextEncoder().encode(t)),a=1;for(;a<=40&&!(4+(a<=9?8:16)+s.length*8<=Ao(a)*8);a++);if(a>40)throw new RangeError("Too much text for a QR code");let r=Ao(a)*8,i=[],c=(S,E)=>{for(let H=E-1;H>=0;H--)i.push(S>>>H&1)};c(4,4),c(s.length,a<=9?8:16);for(let S of s)c(S,8);c(0,Math.min(4,r-i.length)),c(0,(8-i.length%8)%8);for(let S=236;i.length<r;S^=253)c(S,8);let l=[];for(let S=0;S<i.length;S+=8)l.push(i.slice(S,S+8).reduce((E,H)=>E<<1|H,0));let d=Ro[a],p=Po[a],m=Math.floor(Lo(a)/8),f=d-m%d,b=Math.floor(m/d),g=mr(p),k=[];for(let S=0,E=0;S<d;S++){let H=l.slice(E,E+b-p+(S<f?0:1));E+=H.length;let R=hr(H,g);S<f&&H.push(0),k.push([...H,...R])}let v=[];for(let S=0;S<k[0].length;S++)k.forEach((E,H)=>{(S!==b-p||H>=f)&&v.push(E[S])});let u=a*4+17,_=Array.from({length:u},()=>new Array(u).fill(!1)),T=Array.from({length:u},()=>new Array(u).fill(!1)),y=(S,E,H)=>{_[E][S]=H,T[E][S]=!0};for(let S=0;S<u;S++)y(6,S,S%2===0),y(S,6,S%2===0);for(let[S,E]of[[3,3],[u-4,3],[3,u-4]])for(let H=-4;H<=4;H++)for(let R=-4;R<=4;R++){let M=S+R,I=E+H;if(M>=0&&M<u&&I>=0&&I<u){let B=Math.max(Math.abs(R),Math.abs(H));y(M,I,B!==2&&B!==4)}}let P=ur(a,u),w=P.length-1;P.forEach((S,E)=>P.forEach((H,R)=>{if(!(E===0&&R===0||E===0&&R===w||E===w&&R===0))for(let M=-2;M<=2;M++)for(let I=-2;I<=2;I++)y(S+I,H+M,Math.max(Math.abs(I),Math.abs(M))!==1)}));let x=S=>{let E=pr<<3|S,H=E;for(let M=0;M<10;M++)H=H<<1^(H>>>9)*1335;let R=(E<<10|H)^21522;for(let M=0;M<=5;M++)y(8,M,xe(R,M));y(8,7,xe(R,6)),y(8,8,xe(R,7)),y(7,8,xe(R,8));for(let M=9;M<15;M++)y(14-M,8,xe(R,M));for(let M=0;M<8;M++)y(u-1-M,8,xe(R,M));for(let M=8;M<15;M++)y(8,u-15+M,xe(R,M));y(8,u-8,!0)};if(x(0),a>=7){let S=a;for(let H=0;H<12;H++)S=S<<1^(S>>>11)*7973;let E=a<<12|S;for(let H=0;H<18;H++){let R=u-11+H%3,M=Math.floor(H/3);y(R,M,xe(E,H)),y(M,R,xe(E,H))}}let A=0;for(let S=u-1;S>=1;S-=2){S===6&&(S=5);for(let E=0;E<u;E++)for(let H=0;H<2;H++){let R=S-H,I=(S+1&2)===0?u-1-E:E;!T[I][R]&&A<v.length*8&&(_[I][R]=xe(v[A>>>3],7-(A&7)),A++)}}let $=S=>{for(let E=0;E<u;E++)for(let H=0;H<u;H++)!T[E][H]&&fr[S](H,E)&&(_[E][H]=!_[E][H])},N=n??-1;if(N<0){let S=1/0;for(let E=0;E<8;E++){$(E),x(E);let H=gr(_);H<S&&(S=H,N=E),$(E)}}return $(N),x(N),_}function Io(t){let n=vr(t),s=n.length+8,a="";return n.forEach((r,i)=>r.forEach((c,l)=>c&&(a+=`M${l+4},${i+4}h1v1h-1z`))),{size:s,path:a}}var Do=t=>pe(new Date(t).toISOString().slice(0,10));function Oo({me:t,onClose:n}){let[s,a]=h(""),[r,i]=h(""),[c,l]=h(""),d=Ys(r,[t.email.split("@")[0],t.email]),p=c.length>0&&c!==r,[m,f]=h("idle"),[b,g]=h(""),k=u=>{u.preventDefault(),f("saving"),g(""),L.changePassword(s,r).then(()=>{f("saved"),a(""),i(""),l("")}).catch(_=>{g(_.message),f("idle")})},v=(u,_)=>{u(_.target.value),g("")};return e(se,{title:o("account.title"),sub:t.email,onClose:n,children:[e("form",{class:"sheet-body link-form",onSubmit:k,children:[e("p",{class:"settings-text",children:o(`account.${t.role}`)}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.current")}),e(ie,{class:"value",autoComplete:"current-password",required:!0,value:s,onInput:u=>v(a,u)})]}),e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("account.next")}),e(ie,{class:"value",autoComplete:"new-password",minLength:10,required:!0,value:r,onInput:u=>v(i,u),"aria-describedby":"password-strength"}),r?e("span",{class:"strength",id:"password-strength","data-score":d,"aria-live":"polite",children:[e("span",{class:"strength-bar","aria-hidden":"true",children:[1,2,3,4].map(u=>e("span",{class:d>=u?"on":""}))}),e("span",{class:"strength-label",children:o(`account.strength${d}`)})]}):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(ie,{class:"value",autoComplete:"new-password",required:!0,value:c,"aria-invalid":p,onInput:u=>v(l,u)}),p?e("span",{class:"field-hint field-bad",children:o("account.mismatch")}):null]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:m==="saving"||!s||r.length<10||c!==r,children:[e(C,{name:"save"}),o("account.save")]}),m==="saved"?e("span",{class:"settings-ok",children:o("account.saved")}):null,b?e("span",{class:"settings-error",children:b}):null]})]}),e(br,{me:t})]})}function br({me:t}){let[n,s]=h(!!t.twoFactor),[a,r]=h(t.recoveryLeft??0),[i,c]=h(null),[l,d]=h(""),[p,m]=h(null),[f,b]=h(""),[g,k]=h(null),[v,u]=h(!1),[_,T]=h(""),[y,P]=h(!1),w=(S,E)=>{T(""),P(!0),S.then(E).catch(H=>T(H.message)).finally(()=>P(!1))},x=S=>{S.preventDefault(),i==="start"&&w(L.twoFactorStart(l),E=>{m(E),c(null),d("")}),i==="recovery"&&w(L.twoFactorRecovery(l),E=>{k(E.recovery),r(E.recovery.length),c(null),d("")}),i==="disable"&&w(L.twoFactorDisable(l),()=>{s(!1),c(null),d("")})},A=S=>{S.preventDefault(),w(L.twoFactorConfirm(f).catch(E=>{throw E instanceof Re&&E.code==="twofactor_restart"&&(m(null),b("")),E}),E=>{k(E.recovery),r(E.recovery.length),s(!0),m(null),b("")})},$=p?Io(p.uri):null,N=()=>{let S=new Blob([`Runlight recovery codes for ${t.email}
|
|
75
83
|
|
|
76
84
|
${g.join(`
|
|
77
85
|
`)}
|
|
78
86
|
|
|
79
87
|
Each code works once.
|
|
80
|
-
`],{type:"text/plain"}),
|
|
81
|
-
`)).then(()=>u(!0)).catch(()=>{})},children:[e(M,{name:v?"check":"copy"}),o(v?"install.copied":"twofa.copy")]}),e("button",{type:"button",class:"solid",onClick:()=>_(null),children:[e(M,{name:"check"}),o("twofa.saved")]})]})]}):p&&D?e("form",{class:"twofactor-setup",onSubmit:P,children:[e("p",{class:"settings-text",children:o("twofa.scan")}),e("div",{class:"qr",children:e("svg",{viewBox:`0 0 ${D.size} ${D.size}`,role:"img","aria-label":o("twofa.qr"),"shape-rendering":"crispEdges",children:[e("rect",{width:D.size,height:D.size,fill:"#ffffff"}),e("path",{d:D.path,fill:"#000000"})]})}),e("p",{class:"field-hint",children:o("twofa.manual")}),e(ue,{children:p.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:f,onInput:k=>b(k.target.value)})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:y||f.replace(/\s/g,"").length!==6,children:[e(M,{name:"check"}),o("twofa.confirm")]}),e("button",{type:"button",class:"ghost",onClick:()=>{m(null),E("")},children:o("common.cancel")})]})]}):i?e("form",{class:"twofactor-setup",onSubmit:x,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("twofa.password")}),e(re,{class:"value",autoComplete:"current-password",required:!0,value:l,onInput:k=>d(k.target.value)})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:i==="disable"?"solid danger":"solid",disabled:y||!l,children:[e(M,{name:i==="disable"?"x":"check"}),o(i==="start"?"twofa.continue":i==="recovery"?"twofa.newCodes":"twofa.turnOff")]}),e("button",{type:"button",class:"ghost",onClick:()=>{c(null),E("")},children:o("common.cancel")})]})]}):e("div",{class:"settings-actions start",children:n?e(U,{children:[e("button",{type:"button",class:"ghost",onClick:()=>c("recovery"),children:[e(M,{name:"refresh"}),o("twofa.newCodes")]}),e("button",{type:"button",class:"ghost",onClick:()=>c("disable"),children:[e(M,{name:"x"}),o("twofa.turnOff")]})]}):e("button",{type:"button",class:"solid",onClick:()=>c("start"),children:[e(M,{name:"key"}),o("twofa.turnOn")]})}),S?e("p",{class:"settings-error",children:S}):null]})}function $o({icon:t,label:n,onConfirm:s,onCancel:a}){let[r,i]=h(""),[c,l]=h(!1),[d,p]=h("");return e("form",{class:"reset-twofactor",onSubmit:f=>{f.preventDefault(),l(!0),p(""),s(r).catch(b=>p(b.message)).finally(()=>l(!1))},children:[e(re,{class:"value",autoComplete:"current-password",required:!0,placeholder:o("twofa.password"),value:r,onInput:f=>i(f.target.value)}),e("button",{type:"submit",class:"copy inline armed",disabled:c||!r,children:[e(M,{name:t}),n]}),e("button",{type:"button",class:"copy inline",onClick:a,children:o("common.cancel")}),d?e("span",{class:"settings-error",children:d}):null]})}var Ho=["admin","member","viewer"],Dt=t=>o(`people.${t}`);function Eo({me:t,onDemoted:n}){let[s,a]=h(null),[r,i]=h([]),[c,l]=h(""),[d,p]=h("member"),[m,f]=h(null),[b,g]=h(""),[_,v]=h(!1),[u,S]=h(null),[E,y]=h(null),[R,w]=h(null),x=()=>L.people().then(k=>{a(k.people),i(k.invites??[])}).catch(k=>g(k.message));O(()=>{x()},[]);let P=k=>(f(k),x()),D=k=>{k.preventDefault(),g(""),v(!0),L.addPerson(c.trim(),d).then(A=>(l(""),P(A))).catch(A=>g(A.message)).finally(()=>v(!1))},F=(k,A)=>{let $=k===t.id&&A!=="admin";return $&&R!==A?w(A):(w(null),L.setRole(k,A).then(()=>$?n(A):x()).catch(C=>g(C.message)))};return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("people.intro")}),m?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:m.emailed?o("people.emailed",{email:m.invite.email}):m.mailError?o("people.mailFailed",{email:m.invite.email,error:(m.mailCode&&be(m.mailCode,m.mailParams)||m.mailError).replace(/\.$/,"")}):o("people.noMail",{email:m.invite.email})}),e("div",{class:"invite-link",children:e(ue,{children:m.link})}),e("p",{class:"field-hint",children:o("people.linkHint")}),e("button",{type:"button",class:"ghost token-done",onClick:()=>f(null),children:[e(M,{name:"check"}),o("tokens.done")]})]}):null,s?e("ul",{class:"domain-list share-list",children:[s.map(k=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:[k.email,k.id===t.id?e("span",{class:"people-you",children:o("people.you")}):null,k.twoFactor?e("span",{class:"people-you",children:o("people.twoFactor")}):null]}),e("span",{class:"share-meta",children:o("links.createdOn",{date:Do(k.createdAt)})})]}),e("div",{class:"domain-actions",children:u===k.id?e($o,{icon:"reset",label:o("people.resetTwoFactor"),onCancel:()=>S(null),onConfirm:A=>L.resetTwoFactor(k.id,A).then(()=>(S(null),g(""),x()))}):E===k.id?e($o,{icon:"key",label:o("people.handOverConfirm"),onCancel:()=>y(null),onConfirm:A=>L.handOver(k.id,A).then(()=>(y(null),g(""),n("admin"),x()))}):k.role==="owner"?e("span",{class:"people-owner",children:o("people.owner")}):e(U,{children:[t.role==="owner"&&k.role==="admin"?e("button",{type:"button",class:"copy inline",title:o("people.handOverHint"),onClick:()=>y(k.id),children:[e(M,{name:"key"}),o("people.handOver")]}):null,k.twoFactor&&k.id!==t.id?e("button",{type:"button",class:"copy inline",title:o("people.resetTwoFactorHint"),onClick:()=>S(k.id),children:[e(M,{name:"reset"}),o("people.resetTwoFactor")]}):null,k.id===t.id&&R?e("span",{class:"confirm-demote",children:[e("span",{class:"settings-text",children:o("people.demoteSelf")}),e("button",{type:"button",class:"copy inline armed",onClick:()=>{F(k.id,R)},children:o("people.demoteConfirm",{role:Dt(R)})}),e("button",{type:"button",class:"copy inline",onClick:()=>w(null),children:o("common.cancel")})]}):e("select",{class:"value people-role",value:k.role,"aria-label":o("people.role"),onChange:A=>{F(k.id,A.target.value)},children:Ho.map(A=>e("option",{value:A,children:Dt(A)}))}),k.id===t.id?null:e(te,{name:k.email,onDelete:()=>{L.removePerson(k.id).then(x).catch(A=>g(A.message))}})]})})]},k.id)),r.map(k=>e("li",{class:"invited",children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:[k.email,e("span",{class:"people-you",children:o("people.invited")})]}),e("span",{class:"share-meta",children:o("people.invitedMeta",{role:Dt(k.role),date:Do(k.expiresAt)})})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",disabled:_,onClick:()=>{v(!0),L.resendInvite(k.id).then(P).catch(A=>g(A.message)).finally(()=>v(!1))},children:[e(M,{name:"send"}),o("people.resend")]}),e(te,{name:k.email,onDelete:()=>{L.cancelInvite(k.id).then(x).catch(A=>g(A.message))}})]})]},k.id))]}):null,e("p",{class:"field-hint domain-note",children:o("people.roles")}),e("form",{class:"domain-add token-add",onSubmit:D,children:[e("input",{class:"value",type:"email",required:!0,placeholder:o("people.emailPlaceholder"),value:c,onInput:k=>l(k.target.value)}),e("select",{class:"value",value:d,"aria-label":o("people.role"),onChange:k=>p(k.target.value),children:Ho.map(k=>e("option",{value:k,children:Dt(k)}))}),e("button",{type:"submit",class:"solid",disabled:_,children:[e(M,{name:"send"}),o("people.invite")]})]}),b?e("span",{class:"settings-error",children:b}):null]})}var yr=1e4;function xr(t){let n=Math.round((t-Date.now())/1e3),s=new Intl.RelativeTimeFormat(Z(),{numeric:"auto",style:"short"});return Math.abs(n)<60?s.format(Math.min(0,n),"second"):s.format(Math.round(n/60),"minute")}function wr(t){return new Intl.DateTimeFormat(Z(),{hour:"numeric",minute:"2-digit"}).format(t)}function kr({minutes:t}){let[n,s]=h(null),a=Math.max(1,...t),r=t.reduce((c,l)=>c+l,0),i=Math.floor(Date.now()/6e4)*6e4-(t.length-1)*6e4;return e("section",{class:"minutes",children:[e("p",{class:"minutes-note",children:n===null?Y("live.total",r,{n:ke(r)}):Y("live.minute",t[n]??0,{n:ke(t[n]??0),time:wr(i+n*6e4)})}),e("div",{class:"minute-bars",onPointerLeave:()=>s(null),children:t.map((c,l)=>e("span",{class:n===l?"minute on":"minute",onPointerEnter:()=>s(l),children:e("span",{class:"minute-bar",style:{height:`${c?Math.max(4,c/a*100):0}%`}})}))}),e("div",{class:"minute-axis",children:[e("span",{children:o("live.ago30")}),e("span",{children:o("live.nowLabel")})]})]})}function yn({title:t,rows:n,dimension:s}){let a=Math.max(1,...n.map(r=>r.visitors));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(V,{size:"line",icon:"monitor",title:o("live.nobody")}):null,e("ol",{class:"rows",children:n.map(r=>e("li",{children:[e("span",{class:"bar",style:{width:`${r.visitors/a*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:s==="country"?`${fe(r.value)} ${ge(r.value)}`:ae(s,r.value)})}),e("span",{class:"num",children:H(r.visitors)})]}))})]})}function _r({recent:t}){return e("section",{class:"feed",children:[e("h3",{children:o("live.feed")}),t.length===0?e(V,{size:"line",icon:"clock",title:o("live.quiet")}):null,e("ol",{children:t.map(n=>{let s=[n.city,n.country?ge(n.country):""].filter(Boolean).join(", "),r={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},i=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?fe(n.country):"\xB7"}),e("span",{class:"feed-text",children:ce(i,r)}),e("span",{class:"feed-time",children:xr(n.ts)})]})})})]})}function Fo({site:t,onClose:n}){let[s,a]=h(null);return O(()=>{let r=!0,i=()=>L.realtime(t).then(l=>r&&a(l)).catch(()=>{});i();let c=setInterval(i,yr);return()=>{r=!1,clearInterval(c)}},[t]),e(se,{title:o("live.title"),sub:o("live.sub"),wide:!0,onClose:n,children:e("div",{class:"live-body",children:s?e(U,{children:[e("p",{class:"live-count",children:[e("span",{class:s.visitors>0?"beat on":"beat","aria-hidden":"true"}),ce(new Intl.PluralRules(Z()).select(s.visitors)==="one"?"live.now_one":"live.now_other",{n:e("strong",{children:ke(s.visitors)})}),e("span",{class:"live-hint",children:o("live.nowHint")})]}),e(kr,{minutes:s.minutes}),e("div",{class:"mini-grid three",children:[e(yn,{title:"live.pages",rows:s.pages,dimension:"path"}),e(yn,{title:"live.sources",rows:s.sources,dimension:"source"}),e(yn,{title:"live.countries",rows:s.countries,dimension:"country"})]}),e(_r,{recent:s.recent})]}):e("p",{class:"empty",children:o("common.loading")})})})}var dt="off";function $t(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 No(){let t=new URLSearchParams(location.search),n=[];for(let l of t.getAll("filter")){let[d,p,...m]=l.split(":");d&&(p==="is"||p==="not"||p==="contains")&&n.push({dimension:d,op:p,value:m.join(":")})}let s=["previous","year","custom","off"].includes(t.get("compare")??"")?t.get("compare"):dt,a=$t(t.get("compare_from")),r=$t(t.get("compare_to")),i=$t(t.get("from")),c=$t(t.get("to"));return{site:t.get("site")??"",period:t.get("period")==="custom"&&!(i&&c)?Fe:t.get("period")??Fe,...i&&c?{from:i,to:c}:{from:"",to:""},filters:n,compare:t.get("period")==="all"?"off":s==="custom"&&!(a&&r)?dt:s,compareFrom:a,compareTo:r}}function Uo(){let t=(new URLSearchParams(location.search).get("chart")??"").split(",").filter(n=>vs(n));return t.length?t.slice(0,Mt):["visitors"]}function Sr(t,n){if(Le)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!==Fe&&s.set("period",t.period);for(let r of t.filters)s.append("filter",`${r.dimension}:${r.op}:${r.value}`);t.compare!==dt&&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 Cr(t){try{return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date)}catch{return new Date().toISOString().slice(0,10)}}var Tr=t=>It.includes(t);function Mr({now:t,before:n,lowerIsBetter:s,compared:a}){let r=sn(t,n);if(r===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(r===null)return e("span",{class:"delta"});let i=Math.abs(r)<.005,c=s?r<0:r>0;return e("span",{class:`delta ${i?"flat":c?"up":"down"}`,title:o("delta.title"),children:i?o("delta.none"):`${r>0?"\u2191":"\u2193"} ${Math.abs(Math.round(r*100))}%`})}function Er({site:t}){let[n,s]=h(null),a=n===t.id,r=(t.name.replace(/^www\./,"")[0]??"R").toUpperCase();return a?e("span",{class:"avatar letter","aria-hidden":"true",children:r}):e("img",{class:"avatar",src:`${de}/api/icon?site=${encodeURIComponent(t.id)}`,alt:"",width:40,height:40,onError:()=>s(t.id)})}function Ar({site:t,ready:n}){let[s,a]=h(null);O(()=>{let c=!0,l=()=>L.realtime(t).then(p=>c&&a(p.visitors)).catch(()=>{});l();let d=setInterval(l,3e4);return()=>{c=!1,clearInterval(d)}},[t]);let[r,i]=h(!1);return s===null?null:n?e(U,{children:[e("button",{type:"button",class:"live",title:o("app.live.title"),onClick:()=>i(!0),children:[e("span",{class:s>0?"beat on":"beat","aria-hidden":"true"}),Y("app.live",s,{n:ke(s)})]}),r?e(Fo,{site:t,onClose:()=>i(!1)}):null]}):e("span",{class:"live",children:[e("span",{class:"beat","aria-hidden":"true"}),Y("app.live",s,{n:ke(s)})]})}function Pr({view:t,stats:n,previous:s,compare:a}){let r=Tr(t.period)?t.period:Fe,i=t.from?t.from===t.to?o("when.day",{day:_e(t.from,t.to)}):o("when.range",{range:_e(t.from,t.to)}):o(`when.${r}`),c=t.compare==="off"||!a?"":t.compare==="year"?o("headline.lastYear"):t.compare==="custom"?_e(a.from,a.to):t.from?o("before.range"):o(`before.${r}`),l=sn(n.visitors,s?.visitors),d={who:e("strong",{children:Y("headline.who",n.visitors,{n:ke(n.visitors)})}),verb:Y(t.filters.length?"headline.matched":"headline.visited",n.visitors),when:i,against:c,change:l===null?"":e("span",{class:l>0?"up":"down",children:o(l>0?"headline.more":"headline.fewer",{pct:Math.abs(Math.round(l*100))})})},p=l===null||!c?"headline.plain":Math.abs(l)<.005?"headline.same":l>0?"headline.up":"headline.down";return e("p",{class:"headline",children:ce(p,d)})}function Rr(){let[,t]=h(Z()),[n,s]=h(null),[a,r]=h(No),[i,c]=h(Uo),[l,d]=h(null),[p,m]=h([]),[f,b]=h(void 0),[g,_]=h(""),[v,u]=h(()=>{let I=new URLSearchParams(location.search).get("connect_error");return I===null?null:{key:/^[a-z]+$/.test(I)&&rs(`sites.connectError.${I}`)?`sites.connectError.${I}`:"sites.connectError.failed",error:!0}}),[S,E]=h(!1),[y,R]=h(!1),[w,x]=h(()=>new URLSearchParams(location.search).get("settings")==="general"?"general":null),[P,D]=h(!1),[F,k]=h(null),[A,$]=h(!1),[C,T]=h(!1),N=()=>{Qe&&L.account().then(I=>k(I.account)).catch(()=>{})};O(N,[]);let W=Qe?F?.role==="owner"||F?.role==="admin":!0,le=Xe||F?.role==="viewer",[ve,Ko]=h(!1);O(()=>ds(()=>Ko(!0)),[]);let wn=I=>_(I instanceof Re&&I.status===401?"signed-out":Je&&I instanceof Re&&I.status===404?o("share.gone"):I.message);O(()=>{L.sites().then(I=>s(I.sites)).catch(wn)},[]),O(()=>{Sr(a,i)},[a,i]);let[kn,_n]=h(!1),Ht=oe.managed&&!n?.length;O(()=>{if(Ht)return;let I=!0,z=setTimeout(()=>I&&_n(!0),300);return Promise.all([L.stats(a),L.series(a)]).then(([B,Te])=>{I&&(_(""),d(B),m(Te.points),b(Te.previous))}).catch(B=>I&&wn(B)).finally(()=>{clearTimeout(z),I&&_n(!1)}),()=>{I=!1,clearTimeout(z)}},[a,Ht]);let Ce=Zt(I=>r(z=>({...z,...I})),[]),Bo=Zt((I,z)=>r(B=>({...B,filters:[...B.filters.filter(Te=>Te.dimension!==I),{dimension:I,op:"is",value:z}].slice(-Lt)})),[]),qo=I=>c(z=>{if(z.includes(I))return z.length>1?z.filter(Te=>Te!==I):z;let B=[...z,I];return B.length>Mt?B.slice(B.length-Mt):B}),Sn=!a.from&&a.period===Fe&&!a.filters.length&&a.compare===dt&&i.join(",")==="visitors";O(()=>{let I=()=>{r(No()),c(Uo())};return window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)},[]);let Ot=()=>{Sn||history.pushState(null,"",location.href),r(I=>({site:I.site,period:Fe,from:"",to:"",filters:[],compare:dt,compareFrom:"",compareTo:""})),c(["visitors"]),window.scrollTo({top:0,behavior:"smooth"})},Cn=I=>{xt(I,!0).then(()=>t(I)).catch(z=>_(z.message))},G=n?.find(I=>I.id===a.site)??n?.[0],$e=!!(G&&G.lastSeen==null&&!Xe&&!G.remote),Tn=!!(G?.remote&&!G.manage);O(()=>{if(!$e)return;let I=setInterval(()=>{L.sites().then(z=>{s(z.sites),z.sites.find(B=>B.id===G?.id)?.lastSeen!=null&&r(B=>({...B}))}).catch(()=>{})},5e3);return()=>clearInterval(I)},[$e,G?.id]);let Vo=Ae($r,[]),Mn=Cr(G?.timezone??"UTC");if(ve)return e(jo,{});if(g==="signed-out")return e("main",{class:"signed-out",children:[e("h1",{children:"Runlight"}),tn?e("p",{children:ce("app.sessionEnded",{link:e("a",{href:`${tn}?next=${encodeURIComponent(location.pathname+location.search)}`,children:o("app.signInAgain")})})}):e("p",{children:ce("app.signedOut",{token:e("code",{children:"?token="}),env:e("code",{children:"RUNLIGHT_TOKEN"})})})]});let En=I=>{s(z=>[...z??[],I].sort((B,Te)=>B.name.localeCompare(Te.name))),D(!1),r(z=>({...z,site:I.id,filters:[]}))};if(n&&n.length===0&&oe.managed)return e(Vs,{onAdded:En});if(Ht)return e("main",{"aria-busy":"true"});let An=Ct.filter(I=>i.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:Ot,children:G?e(Er,{site:G}):e("span",{class:"avatar letter"})}),e("div",{class:"identity-text",children:[n&&(n.length>1||oe.managed&&!le)?e(Gs,{sites:n,current:G,canAdd:oe.managed&&!le,onPick:I=>Ce({site:I,filters:[]}),onAdd:()=>D(!0),onAll:()=>T(!0)}):e("h1",{children:e("button",{type:"button",class:"home",title:o("app.home"),onClick:Ot,children:G?.name??"Runlight"})}),G?e(Ar,{site:G.id,ready:G.lastSeen!=null}):null]}),G&&!le?e("button",{type:"button",class:"gear","aria-label":o("settings.open"),title:o("settings.open"),onClick:()=>x("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:$e,children:[Sn?null:e("button",{type:"button",class:"reset-button",onClick:Ot,title:o("view.resetHint"),children:[e(M,{name:"reset"}),o("view.reset")]}),G&&!Xe?e("button",{type:"button",class:"filter-button assistant-button","aria-label":o("assistant.open"),title:o("assistant.open"),onClick:()=>R(!0),children:e(M,{name:"robot"})}):null,e("button",{type:"button",class:a.filters.length?"filter-button on":"filter-button",onClick:()=>E(!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(Ks,{period:a.period,from:a.from,to:a.to,today:Mn,onPeriod:I=>Ce(I==="all"?{period:I,from:"",to:"",compare:"off",compareFrom:"",compareTo:""}:{period:I,from:"",to:""}),onRange:(I,z)=>Ce({from:I,to:z})}),e(Bs,{mode:a.compare,from:a.compareFrom,to:a.compareTo,today:Mn,allTime:a.period==="all"&&!a.from,onChange:(I,z="",B="")=>Ce({compare:I,compareFrom:z,compareTo:B})})]})]}),$e?null:l?e(Pr,{view:a,stats:l.stats,previous:l.previous,compare:l.compare}):e("p",{class:"headline",children:"\xA0"}),a.filters.length?e("div",{class:"filters",children:[a.filters.map(I=>e("span",{class:"filter",children:[e("span",{class:"filter-dim",children:cn(I.dimension)}),dn(I.op)," ",e("strong",{children:ae(I.dimension,I.value)}),e("button",{type:"button","aria-label":o("filter.remove"),onClick:()=>Ce({filters:a.filters.filter(z=>z!==I)}),children:"\xD7"})]})),a.filters.length>1?e("button",{type:"button",class:"clear",onClick:()=>Ce({filters:[]}),children:[e(M,{name:"x"}),o("common.clearAll")]}):null]}):null]}),v?e("p",{class:v.error?"failure dismissable":"failure dismissable notice",role:"alert",children:[v.key?o(v.key):v.text,e("button",{type:"button",class:"remove","aria-label":o("common.close"),title:o("common.close"),onClick:()=>u(null),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}):null,g?e("p",{class:"failure",children:g}):null,w&&G&&n?e(Mo,{site:G,sites:n,view:a,start:w,onClose:()=>{x(null),r(I=>({...I})),N()},onSaved:I=>{s(z=>(z??[]).map(B=>B.id===I.id?{...B,...I}:B)),r(z=>({...z}))},onLanguage:Cn,onDemoted:I=>{I!=="admin"&&(x(null),u({text:o(I==="member"?"people.demotedMember":"people.demoted"),error:!1})),N()},me:F,onDeleted:I=>{x(null);let z=(n??[]).filter(B=>B.id!==I);s(z),r(B=>({...B,site:z[0]?.id??"",filters:[]}))}}):null,C&&n?e(Ws,{sites:n,view:a,onClose:()=>T(!1),onPick:I=>{T(!1),Ce({site:I,filters:[]})}}):null,A&&F?e(Oo,{me:F,onClose:()=>{$(!1),N()}}):null,P?e(se,{title:o("sites.addTitle"),onClose:()=>D(!1),children:e(pn,{onAdded:En,onCancel:()=>D(!1)})}):null,S?e(Ns,{view:a,onApply:I=>Ce({filters:I}),onClose:()=>E(!1)}):null,y&&G?e(Zs,{site:G,view:a,owner:W,onSetup:()=>{R(!1),x("assistant")},onClose:()=>R(!1)}):null,$e&&G&&n?e("section",{class:"welcome",children:[e("h2",{children:o("welcome.title",{name:G.name})}),e("p",{class:"welcome-lead",children:[e("span",{class:"beat wait","aria-hidden":"true"}),o("welcome.lead")]}),e("div",{class:"welcome-steps",children:e(vn,{site:G,sites:n})})]}):null,e("section",{class:kn?"overview stale":"overview",hidden:$e,"aria-busy":kn,children:[e("div",{class:"metrics",children:Ct.map(I=>{let z=i.includes(I.key),B=l?.stats[I.key];return e("button",{type:"button",class:`metric s${I.slot}${z?" on":""}`,"aria-pressed":z,onClick:()=>qo(I.key),title:gs(I),children:[e("span",{class:"metric-label",children:[e("span",{class:`swatch s${I.slot}`}),Tt(I)]}),e("span",{class:"metric-value",children:B===void 0?"\xA0":I.format(B)}),e("span",{class:"metric-foot",children:l?e(Mr,{now:l.stats[I.key],before:l.previous?.[I.key],lowerIsBetter:I.lowerIsBetter,compared:!!l.previous?.visits}):null})]})})}),e("div",{class:"chart-head",children:e("span",{class:"chart-note",children:[An.length>1?o("chart.scaled"):o("chart.pick"),l?.compare?` ${o("chart.dashed",{range:_e(l.compare.from,l.compare.to)})}`:""]})}),l?e(Ke,{points:p,previous:f,metrics:An.map(ws),interval:l.range.interval,timezone:l.range.timezone}):e("div",{class:"chart"})]}),e("div",{class:"board",hidden:$e,children:[Vo.map((I,z)=>I.title==="panel.rhythm"?e(Hs,{view:a,wide:I.wide}):e($s,{title:I.title,tabs:I.tabs,view:a,onFilter:Bo,wide:I.wide,map:I.title==="panel.locations"},z)),G&&!Xe&&!Tn?e(Es,{view:a,site:G.id,readOnly:le}):null,G?e(oo,{view:a,readOnly:le||Tn,onAdd:()=>x("goals")}):null]}),e("footer",{class:"foot",children:[e("a",{href:"https://runlight.sh",class:"powered",...Le?{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"})]}),ce("foot.powered",{name:e("span",{children:"Runlight"})})]}),e("span",{class:"foot-range",children:l?`${_e(l.range.from,l.range.to)} \xB7 ${l.range.timezone}`:""}),e("label",{class:"language",children:[e("span",{class:"visually-hidden",children:o("foot.language")}),e("select",{value:Z(),onChange:I=>Cn(I.target.value),children:Pe.map(([I,z])=>e("option",{value:I,children:z}))})]}),e(Hr,{}),e("button",{type:"button",class:"sign-out",title:o("export.title"),onClick:()=>{ze("export",ie(a)).catch(I=>_(I.message))},children:o("export.zip")}),F?e("button",{type:"button",class:"sign-out",onClick:()=>$(!0),children:o("account.title")}):null,en?e("a",{class:"sign-out",href:en,children:o("app.signOut")}):null]})]})}var Lr={"Organic Search":1,Social:2,Direct:3,Email:4,Referral:5,"Paid Search":6,AI:7,Campaign:8},Ir={desktop:1,mobile:2,tablet:3},Dr=new Set(["ChatGPT-User","Claude-User","Perplexity-User","MistralAI-User","meta-externalfetcher"]);function $r(){let t={filterable:!0};return[{title:"panel.pages",wide:!0,tabs:[{dimension:"page",label:"tab.top",...t,extra:Os},{dimension:"entry",label:"tab.entry",...t,extra:Fs},{dimension:"exit",label:"tab.exit",...t}]},{title:"panel.sources",tabs:[{dimension:"channel",label:"tab.channels",...t,colors:Lr},{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=>Dr.has(n)?"ai.live":"ai.crawl",slots:{"ai.live":7,"ai.crawl":1}}},{dimension:"ai_page",label:"tab.pages",column:"fetches"}]},{title:"panel.devices",tabs:[{dimension:"device",label:"tab.device",...t,colors:Ir},{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 jo(){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"},Le),children:[e(M,{name:"refresh"}),o("embed.reload")]})]})}var xn=["light","dark","system"],zo=t=>o(t==="light"?"theme.light":t==="dark"?"theme.dark":"theme.system");function Hr(){let[,t]=h(0);O(()=>_o(()=>t(i=>i+1)),[]);let n=Ge(),s=xn[(xn.indexOf(n)+1)%xn.length];O(()=>{let i=c=>{(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="d"&&(c.preventDefault(),it(ko()?"light":"dark"))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]);let a=/Mac|iPhone|iPad/.test(navigator.platform),r=o("theme.cycle",{current:zo(n),next:zo(s)});return e("button",{type:"button",class:"theme","aria-label":r,"aria-keyshortcuts":a?"Meta+Shift+D":"Control+Shift+D",title:`${r} (${a?"\u2318\u21E7D":"Ctrl+Shift+D"})`,onClick:()=>it(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();var Or=document.getElementById("app");xt(as()).catch(()=>xt("en")).finally(()=>Kn(Le&&!ls?e(jo,{}):e(Rr,{}),Or));
|
|
88
|
+
`],{type:"text/plain"}),E=document.createElement("a");E.href=URL.createObjectURL(S),E.download="runlight-recovery-codes.txt",E.click(),URL.revokeObjectURL(E.href)};return e("div",{class:"sheet-body 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?Y("twofa.on",a):o("twofa.off")})]}),g?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:o("twofa.codesIntro")}),e("ol",{class:"recovery-codes",children:g.map(S=>e("li",{children:e("code",{children:S})}))}),e("div",{class:"settings-actions start",children:[e("button",{type:"button",class:"ghost",onClick:N,children:[e(C,{name:"download"}),o("twofa.download")]}),e("button",{type:"button",class:"ghost",onClick:()=>{navigator.clipboard?.writeText(g.join(`
|
|
89
|
+
`)).then(()=>u(!0)).catch(()=>{})},children:[e(C,{name:v?"check":"copy"}),o(v?"install.copied":"twofa.copy")]}),e("button",{type:"button",class:"solid",onClick:()=>k(null),children:[e(C,{name:"check"}),o("twofa.saved")]})]})]}):p&&$?e("form",{class:"twofactor-setup",onSubmit:A,children:[e("p",{class:"settings-text",children:o("twofa.scan")}),e("div",{class:"qr",children:e("svg",{viewBox:`0 0 ${$.size} ${$.size}`,role:"img","aria-label":o("twofa.qr"),"shape-rendering":"crispEdges",children:[e("rect",{width:$.size,height:$.size,fill:"#ffffff"}),e("path",{d:$.path,fill:"#000000"})]})}),e("p",{class:"field-hint",children:o("twofa.manual")}),e(ce,{children:p.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:f,onInput:S=>b(S.target.value)})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:"solid",disabled:y||f.replace(/\s/g,"").length!==6,children:[e(C,{name:"check"}),o("twofa.confirm")]}),e("button",{type:"button",class:"ghost",onClick:()=>{m(null),T("")},children:o("common.cancel")})]})]}):i?e("form",{class:"twofactor-setup",onSubmit:x,children:[e("label",{class:"field-row",children:[e("span",{class:"field-label",children:o("twofa.password")}),e(ie,{class:"value",autoComplete:"current-password",required:!0,value:l,onInput:S=>d(S.target.value)})]}),e("div",{class:"settings-actions start",children:[e("button",{type:"submit",class:i==="disable"?"solid danger":"solid",disabled:y||!l,children:[e(C,{name:i==="disable"?"x":"check"}),o(i==="start"?"twofa.continue":i==="recovery"?"twofa.newCodes":"twofa.turnOff")]}),e("button",{type:"button",class:"ghost",onClick:()=>{c(null),T("")},children:o("common.cancel")})]})]}):e("div",{class:"settings-actions start",children:n?e(U,{children:[e("button",{type:"button",class:"ghost",onClick:()=>c("recovery"),children:[e(C,{name:"refresh"}),o("twofa.newCodes")]}),e("button",{type:"button",class:"ghost",onClick:()=>c("disable"),children:[e(C,{name:"x"}),o("twofa.turnOff")]})]}):e("button",{type:"button",class:"solid",onClick:()=>c("start"),children:[e(C,{name:"key"}),o("twofa.turnOn")]})}),_?e("p",{class:"settings-error",children:_}):null]})}function $o({icon:t,label:n,onConfirm:s,onCancel:a}){let[r,i]=h(""),[c,l]=h(!1),[d,p]=h("");return e("form",{class:"reset-twofactor",onSubmit:f=>{f.preventDefault(),l(!0),p(""),s(r).catch(b=>p(b.message)).finally(()=>l(!1))},children:[e(ie,{class:"value",autoComplete:"current-password",required:!0,placeholder:o("twofa.password"),value:r,onInput:f=>i(f.target.value)}),e("button",{type:"submit",class:"copy inline armed",disabled:c||!r,children:[e(C,{name:t}),n]}),e("button",{type:"button",class:"copy inline",onClick:a,children:o("common.cancel")}),d?e("span",{class:"settings-error",children:d}):null]})}var Ho=["admin","member","viewer"],Dt=t=>o(`people.${t}`);function Eo({me:t,onDemoted:n}){let[s,a]=h(null),[r,i]=h([]),[c,l]=h(""),[d,p]=h("member"),[m,f]=h(null),[b,g]=h(""),[k,v]=h(!1),[u,_]=h(null),[T,y]=h(null),[P,w]=h(null),x=()=>L.people().then(S=>{a(S.people),i(S.invites??[])}).catch(S=>g(S.message));F(()=>{x()},[]);let A=S=>(f(S),x()),$=S=>{S.preventDefault(),g(""),v(!0),L.addPerson(c.trim(),d).then(E=>(l(""),A(E))).catch(E=>g(E.message)).finally(()=>v(!1))},N=(S,E)=>{let H=S===t.id&&E!=="admin";return H&&P!==E?w(E):(w(null),L.setRole(S,E).then(()=>H?n(E):x()).catch(R=>g(R.message)))};return e("div",{class:"settings-group",children:[e("p",{class:"settings-text",children:o("people.intro")}),m?e("div",{class:"token-made",children:[e("p",{class:"settings-text",children:m.emailed?o("people.emailed",{email:m.invite.email}):m.mailError?o("people.mailFailed",{email:m.invite.email,error:(m.mailCode&&be(m.mailCode,m.mailParams)||m.mailError).replace(/\.$/,"")}):o("people.noMail",{email:m.invite.email})}),e("div",{class:"invite-link",children:e(ce,{children:m.link})}),e("p",{class:"field-hint",children:o("people.linkHint")}),e("button",{type:"button",class:"ghost token-done",onClick:()=>f(null),children:[e(C,{name:"check"}),o("tokens.done")]})]}):null,s?e("ul",{class:"domain-list share-list",children:[s.map(S=>e("li",{children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:[S.email,S.id===t.id?e("span",{class:"people-you",children:o("people.you")}):null,S.twoFactor?e("span",{class:"people-you",children:o("people.twoFactor")}):null]}),e("span",{class:"share-meta",children:o("links.createdOn",{date:Do(S.createdAt)})})]}),e("div",{class:"domain-actions",children:u===S.id?e($o,{icon:"reset",label:o("people.resetTwoFactor"),onCancel:()=>_(null),onConfirm:E=>L.resetTwoFactor(S.id,E).then(()=>(_(null),g(""),x()))}):T===S.id?e($o,{icon:"key",label:o("people.handOverConfirm"),onCancel:()=>y(null),onConfirm:E=>L.handOver(S.id,E).then(()=>(y(null),g(""),n("admin"),x()))}):S.role==="owner"?e("span",{class:"people-owner",children:o("people.owner")}):e(U,{children:[t.role==="owner"&&S.role==="admin"?e("button",{type:"button",class:"copy inline",title:o("people.handOverHint"),onClick:()=>y(S.id),children:[e(C,{name:"key"}),o("people.handOver")]}):null,S.twoFactor&&S.id!==t.id?e("button",{type:"button",class:"copy inline",title:o("people.resetTwoFactorHint"),onClick:()=>_(S.id),children:[e(C,{name:"reset"}),o("people.resetTwoFactor")]}):null,S.id===t.id&&P?e("span",{class:"confirm-demote",children:[e("span",{class:"settings-text",children:o("people.demoteSelf")}),e("button",{type:"button",class:"copy inline armed",onClick:()=>{N(S.id,P)},children:o("people.demoteConfirm",{role:Dt(P)})}),e("button",{type:"button",class:"copy inline",onClick:()=>w(null),children:o("common.cancel")})]}):e("select",{class:"value people-role",value:S.role,"aria-label":o("people.role"),onChange:E=>{N(S.id,E.target.value)},children:Ho.map(E=>e("option",{value:E,children:Dt(E)}))}),S.id===t.id?null:e(te,{name:S.email,onDelete:()=>{L.removePerson(S.id).then(x).catch(E=>g(E.message))}})]})})]},S.id)),r.map(S=>e("li",{class:"invited",children:[e("div",{class:"domain-main",children:[e("span",{class:"share-name",children:[S.email,e("span",{class:"people-you",children:o("people.invited")})]}),e("span",{class:"share-meta",children:o("people.invitedMeta",{role:Dt(S.role),date:Do(S.expiresAt)})})]}),e("div",{class:"domain-actions",children:[e("button",{type:"button",class:"copy inline",disabled:k,onClick:()=>{v(!0),L.resendInvite(S.id).then(A).catch(E=>g(E.message)).finally(()=>v(!1))},children:[e(C,{name:"send"}),o("people.resend")]}),e(te,{name:S.email,onDelete:()=>{L.cancelInvite(S.id).then(x).catch(E=>g(E.message))}})]})]},S.id))]}):null,e("p",{class:"field-hint domain-note",children:o("people.roles")}),e("form",{class:"domain-add token-add",onSubmit:$,children:[e("input",{class:"value",type:"email",required:!0,placeholder:o("people.emailPlaceholder"),value:c,onInput:S=>l(S.target.value)}),e("select",{class:"value",value:d,"aria-label":o("people.role"),onChange:S=>p(S.target.value),children:Ho.map(S=>e("option",{value:S,children:Dt(S)}))}),e("button",{type:"submit",class:"solid",disabled:k,children:[e(C,{name:"send"}),o("people.invite")]})]}),b?e("span",{class:"settings-error",children:b}):null]})}var yr=1e4;function xr(t){let n=Math.round((t-Date.now())/1e3),s=new Intl.RelativeTimeFormat(Z(),{numeric:"auto",style:"short"});return Math.abs(n)<60?s.format(Math.min(0,n),"second"):s.format(Math.round(n/60),"minute")}function wr(t){return new Intl.DateTimeFormat(Z(),{hour:"numeric",minute:"2-digit"}).format(t)}function kr({minutes:t}){let[n,s]=h(null),a=Math.max(1,...t),r=t.reduce((c,l)=>c+l,0),i=Math.floor(Date.now()/6e4)*6e4-(t.length-1)*6e4;return e("section",{class:"minutes",children:[e("p",{class:"minutes-note",children:n===null?Y("live.total",r,{n:ke(r)}):Y("live.minute",t[n]??0,{n:ke(t[n]??0),time:wr(i+n*6e4)})}),e("div",{class:"minute-bars",onPointerLeave:()=>s(null),children:t.map((c,l)=>e("span",{class:n===l?"minute on":"minute",onPointerEnter:()=>s(l),children:e("span",{class:"minute-bar",style:{height:`${c?Math.max(4,c/a*100):0}%`}})}))}),e("div",{class:"minute-axis",children:[e("span",{children:o("live.ago30")}),e("span",{children:o("live.nowLabel")})]})]})}function xn({title:t,rows:n,dimension:s}){let a=Math.max(1,...n.map(r=>r.visitors));return e("section",{class:"mini",children:[e("h3",{children:o(t)}),n.length===0?e(G,{size:"line",icon:"monitor",title:o("live.nobody")}):null,e("ol",{class:"rows",children:n.map(r=>e("li",{children:[e("span",{class:"bar",style:{width:`${r.visitors/a*100}%`}}),e("span",{class:"name",children:e("span",{class:"name-text",children:s==="country"?`${fe(r.value)} ${ge(r.value)}`:re(s,r.value)})}),e("span",{class:"num",children:O(r.visitors)})]}))})]})}function _r({recent:t}){return e("section",{class:"feed",children:[e("h3",{children:o("live.feed")}),t.length===0?e(G,{size:"line",icon:"clock",title:o("live.quiet")}):null,e("ol",{children:t.map(n=>{let s=[n.city,n.country?ge(n.country):""].filter(Boolean).join(", "),r={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},i=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?fe(n.country):"\xB7"}),e("span",{class:"feed-text",children:de(i,r)}),e("span",{class:"feed-time",children:xr(n.ts)})]})})})]})}function Fo({site:t,onClose:n}){let[s,a]=h(null);return F(()=>{let r=!0,i=()=>L.realtime(t).then(l=>r&&a(l)).catch(()=>{});i();let c=setInterval(i,yr);return()=>{r=!1,clearInterval(c)}},[t]),e(se,{title:o("live.title"),sub:o("live.sub"),wide:!0,onClose:n,children:e("div",{class:"live-body",children:s?e(U,{children:[e("p",{class:"live-count",children:[e("span",{class:s.visitors>0?"beat on":"beat","aria-hidden":"true"}),de(new Intl.PluralRules(Z()).select(s.visitors)==="one"?"live.now_one":"live.now_other",{n:e("strong",{children:ke(s.visitors)})}),e("span",{class:"live-hint",children:o("live.nowHint")})]}),e(kr,{minutes:s.minutes}),e("div",{class:"mini-grid three",children:[e(xn,{title:"live.pages",rows:s.pages,dimension:"path"}),e(xn,{title:"live.sources",rows:s.sources,dimension:"source"}),e(xn,{title:"live.countries",rows:s.countries,dimension:"country"})]}),Oe?null:e(_r,{recent:s.recent})]}):e("p",{class:"empty",children:o("common.loading")})})})}var dt="off";function $t(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 No(){let t=new URLSearchParams(location.search),n=[];for(let l of t.getAll("filter")){let[d,p,...m]=l.split(":");d&&(p==="is"||p==="not"||p==="contains")&&n.push({dimension:d,op:p,value:m.join(":")})}let s=["previous","year","custom","off"].includes(t.get("compare")??"")?t.get("compare"):dt,a=$t(t.get("compare_from")),r=$t(t.get("compare_to")),i=$t(t.get("from")),c=$t(t.get("to"));return{site:t.get("site")??"",period:t.get("period")==="custom"&&!(i&&c)?Ne:t.get("period")??Ne,...i&&c?{from:i,to:c}:{from:"",to:""},filters:n,compare:t.get("period")==="all"?"off":s==="custom"&&!(a&&r)?dt:s,compareFrom:a,compareTo:r}}function Uo(){let t=(new URLSearchParams(location.search).get("chart")??"").split(",").filter(n=>vs(n));return t.length?t.slice(0,Mt):["visitors"]}function Sr(t,n){if(Le)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!==Ne&&s.set("period",t.period);for(let r of t.filters)s.append("filter",`${r.dimension}:${r.op}:${r.value}`);t.compare!==dt&&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 Cr(t){try{return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date)}catch{return new Date().toISOString().slice(0,10)}}var Tr=t=>It.includes(t);function Mr({now:t,before:n,lowerIsBetter:s,compared:a}){let r=sn(t,n);if(r===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(r===null)return e("span",{class:"delta"});let i=Math.abs(r)<.005,c=s?r<0:r>0;return e("span",{class:`delta ${i?"flat":c?"up":"down"}`,title:o("delta.title"),children:i?o("delta.none"):`${r>0?"\u2191":"\u2193"} ${Math.abs(Math.round(r*100))}%`})}function Er({site:t}){let[n,s]=h(null),a=n===t.id,r=(t.name.replace(/^www\./,"")[0]??"R").toUpperCase();return a?e("span",{class:"avatar letter","aria-hidden":"true",children:r}):e("img",{class:"avatar",src:`${me}/api/icon?site=${encodeURIComponent(t.id)}`,alt:"",width:40,height:40,onError:()=>s(t.id)})}function Ar({site:t,ready:n}){let[s,a]=h(null);F(()=>{let c=!0,l=()=>L.realtime(t).then(p=>c&&a(p.visitors)).catch(()=>{});l();let d=setInterval(l,3e4);return()=>{c=!1,clearInterval(d)}},[t]);let[r,i]=h(!1);return s===null?null:n?e(U,{children:[e("button",{type:"button",class:"live",title:o("app.live.title"),onClick:()=>i(!0),children:[e("span",{class:s>0?"beat on":"beat","aria-hidden":"true"}),Y("app.live",s,{n:ke(s)})]}),r?e(Fo,{site:t,onClose:()=>i(!1)}):null]}):e("span",{class:"live",children:[e("span",{class:"beat","aria-hidden":"true"}),Y("app.live",s,{n:ke(s)})]})}function Pr({view:t,stats:n,previous:s,compare:a}){let r=Tr(t.period)?t.period:Ne,i=t.from?t.from===t.to?o("when.day",{day:_e(t.from,t.to)}):o("when.range",{range:_e(t.from,t.to)}):o(`when.${r}`),c=t.compare==="off"||!a?"":t.compare==="year"?o("headline.lastYear"):t.compare==="custom"?_e(a.from,a.to):t.from?o("before.range"):o(`before.${r}`),l=sn(n.visitors,s?.visitors),d={who:e("strong",{children:Y("headline.who",n.visitors,{n:ke(n.visitors)})}),verb:Y(t.filters.length?"headline.matched":"headline.visited",n.visitors),when:i,against:c,change:l===null?"":e("span",{class:l>0?"up":"down",children:o(l>0?"headline.more":"headline.fewer",{pct:Math.abs(Math.round(l*100))})})},p=l===null||!c?"headline.plain":Math.abs(l)<.005?"headline.same":l>0?"headline.up":"headline.down";return e("p",{class:"headline",children:de(p,d)})}function Rr(){let[,t]=h(Z()),[n,s]=h(null),[a,r]=h(No),[i,c]=h(Uo),[l,d]=h(null),[p,m]=h([]),[f,b]=h(void 0),[g,k]=h(""),[v,u]=h(()=>{let D=new URLSearchParams(location.search).get("connect_error");return D===null?null:{key:/^[a-z]+$/.test(D)&&is(`sites.connectError.${D}`)?`sites.connectError.${D}`:"sites.connectError.failed",error:!0}}),[_,T]=h(!1),[y,P]=h(!1),[w,x]=h(()=>new URLSearchParams(location.search).get("settings")==="general"?"general":null),[A,$]=h(!1),[N,S]=h(null),[E,H]=h(!1),[R,M]=h(!1),I=()=>{Qe&&L.account().then(D=>S(D.account)).catch(()=>{})};F(I,[]);let B=Qe?N?.role==="owner"||N?.role==="admin":!0,ae=Oe||N?.role==="viewer",[ve,Ko]=h(!1);F(()=>ps(()=>Ko(!0)),[]);let kn=D=>k(D instanceof Re&&D.status===401?"signed-out":Xe&&D instanceof Re&&D.status===404?o("share.gone"):D.message);F(()=>{L.sites().then(D=>{s(D.sites),r(z=>z.site&&!D.sites.some(q=>q.id===z.site)?{...z,site:D.sites[0]?.id??""}:z)}).catch(kn)},[]),F(()=>{Sr(a,i)},[a,i]);let[_n,Sn]=h(!1),Ht=oe.managed&&!n?.length;F(()=>{if(Ht)return;let D=!0,z=setTimeout(()=>D&&Sn(!0),300);return Promise.all([L.stats(a),L.series(a)]).then(([q,Te])=>{D&&(k(""),d(q),m(Te.points),b(Te.previous))}).catch(q=>D&&kn(q)).finally(()=>{clearTimeout(z),D&&Sn(!1)}),()=>{D=!1,clearTimeout(z)}},[a,Ht]);let Ce=Zt(D=>r(z=>({...z,...D})),[]),Bo=Zt((D,z)=>r(q=>({...q,filters:[...q.filters.filter(Te=>Te.dimension!==D),{dimension:D,op:"is",value:z}].slice(-Lt)})),[]),qo=D=>c(z=>{if(z.includes(D))return z.length>1?z.filter(Te=>Te!==D):z;let q=[...z,D];return q.length>Mt?q.slice(q.length-Mt):q}),Cn=!a.from&&a.period===Ne&&!a.filters.length&&a.compare===dt&&i.join(",")==="visitors";F(()=>{let D=()=>{r(No()),c(Uo())};return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[]);let Ot=()=>{Cn||history.pushState(null,"",location.href),r(D=>({site:D.site,period:Ne,from:"",to:"",filters:[],compare:dt,compareFrom:"",compareTo:""})),c(["visitors"]),window.scrollTo({top:0,behavior:"smooth"})},Tn=D=>{xt(D,!0).then(()=>t(D)).catch(z=>k(z.message))},W=n?.find(D=>D.id===a.site)??n?.[0],$e=!!(W&&W.lastSeen==null&&!Oe&&!W.remote),Mn=!!(W?.remote&&!W.manage);F(()=>{if(!$e)return;let D=setInterval(()=>{L.sites().then(z=>{s(z.sites),z.sites.find(q=>q.id===W?.id)?.lastSeen!=null&&r(q=>({...q}))}).catch(()=>{})},5e3);return()=>clearInterval(D)},[$e,W?.id]);let Vo=Ae($r,[]),En=Cr(W?.timezone??"UTC");if(ve)return e(jo,{});if(g==="signed-out")return e("main",{class:"signed-out",children:[e("h1",{children:"Runlight"}),tn?e("p",{children:de("app.sessionEnded",{link:e("a",{href:`${tn}?next=${encodeURIComponent(location.pathname+location.search)}`,children:o("app.signInAgain")})})}):e("p",{children:de("app.signedOut",{token:e("code",{children:"?token="}),env:e("code",{children:"RUNLIGHT_TOKEN"})})})]});let An=D=>{s(z=>[...z??[],D].sort((q,Te)=>q.name.localeCompare(Te.name))),$(!1),r(z=>({...z,site:D.id,filters:[]}))};if(n&&n.length===0&&oe.managed)return e(Vs,{onAdded:An});if(Ht)return e("main",{"aria-busy":"true"});let Pn=Ct.filter(D=>i.includes(D.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:Ot,children:W?e(Er,{site:W}):e("span",{class:"avatar letter"})}),e("div",{class:"identity-text",children:[n&&(n.length>1||oe.managed&&!ae)?e(Gs,{sites:n,current:W,canAdd:oe.managed&&!ae,onPick:D=>Ce({site:D,filters:[]}),onAdd:()=>$(!0),onAll:()=>M(!0)}):e("h1",{children:e("button",{type:"button",class:"home",title:o("app.home"),onClick:Ot,children:W?.name??"Runlight"})}),W?e(Ar,{site:W.id,ready:W.lastSeen!=null}):null]}),W&&!ae?e("button",{type:"button",class:"gear","aria-label":o("settings.open"),title:o("settings.open"),onClick:()=>x("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:$e,children:[Cn?null:e("button",{type:"button",class:"reset-button",onClick:Ot,title:o("view.resetHint"),children:[e(C,{name:"reset"}),o("view.reset")]}),W&&!Oe?e("button",{type:"button",class:"filter-button assistant-button","aria-label":o("assistant.open"),title:o("assistant.open"),onClick:()=>P(!0),children:e(C,{name:"robot"})}):null,e("button",{type:"button",class:a.filters.length?"filter-button on":"filter-button",onClick:()=>T(!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(Ks,{period:a.period,from:a.from,to:a.to,today:En,onPeriod:D=>Ce(D==="all"?{period:D,from:"",to:"",compare:"off",compareFrom:"",compareTo:""}:{period:D,from:"",to:""}),onRange:(D,z)=>Ce({from:D,to:z})}),e(Bs,{mode:a.compare,from:a.compareFrom,to:a.compareTo,today:En,allTime:a.period==="all"&&!a.from,onChange:(D,z="",q="")=>Ce({compare:D,compareFrom:z,compareTo:q})})]})]}),$e?null:l?e(Pr,{view:a,stats:l.stats,previous:l.previous,compare:l.compare}):e("p",{class:"headline",children:"\xA0"}),a.filters.length?e("div",{class:"filters",children:[a.filters.map(D=>e("span",{class:"filter",children:[e("span",{class:"filter-dim",children:dn(D.dimension)}),pn(D.op)," ",e("strong",{children:re(D.dimension,D.value)}),e("button",{type:"button","aria-label":o("filter.remove"),onClick:()=>Ce({filters:a.filters.filter(z=>z!==D)}),children:"\xD7"})]})),a.filters.length>1?e("button",{type:"button",class:"clear",onClick:()=>Ce({filters:[]}),children:[e(C,{name:"x"}),o("common.clearAll")]}):null]}):null]}),v?e("p",{class:v.error?"failure dismissable":"failure dismissable notice",role:"alert",children:[v.key?o(v.key):v.text,e("button",{type:"button",class:"remove","aria-label":o("common.close"),title:o("common.close"),onClick:()=>u(null),children:e("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e("path",{d:"M4 4l8 8M12 4l-8 8"})})})]}):null,g?e("p",{class:"failure",children:g}):null,w&&W&&n?e(Mo,{site:W,sites:n,view:a,start:w,onClose:()=>{x(null),r(D=>({...D})),I()},onSaved:D=>{s(z=>(z??[]).map(q=>q.id===D.id?{...q,...D}:q)),r(z=>({...z}))},onLanguage:Tn,onDemoted:D=>{D!=="admin"&&(x(null),u({text:o(D==="member"?"people.demotedMember":"people.demoted"),error:!1})),I()},me:N,onDeleted:D=>{x(null);let z=(n??[]).filter(q=>q.id!==D);s(z),r(q=>({...q,site:z[0]?.id??"",filters:[]}))}}):null,R&&n?e(Ws,{sites:n,view:a,onClose:()=>M(!1),onPick:D=>{M(!1),Ce({site:D,filters:[]})}}):null,E&&N?e(Oo,{me:N,onClose:()=>{H(!1),I()}}):null,A?e(se,{title:o("sites.addTitle"),onClose:()=>$(!1),children:e(un,{onAdded:An,onCancel:()=>$(!1)})}):null,_?e(Ns,{view:a,onApply:D=>Ce({filters:D}),onClose:()=>T(!1)}):null,y&&W?e(Zs,{site:W,view:a,owner:B,onSetup:()=>{P(!1),x("assistant")},onClose:()=>P(!1)}):null,$e&&W&&n?e("section",{class:"welcome",children:[e("h2",{children:o("welcome.title",{name:W.name})}),e("p",{class:"welcome-lead",children:[e("span",{class:"beat wait","aria-hidden":"true"}),o("welcome.lead")]}),e("div",{class:"welcome-steps",children:e(bn,{site:W,sites:n})})]}):null,e("section",{class:_n?"overview stale":"overview",hidden:$e,"aria-busy":_n,children:[e("div",{class:"metrics",children:Ct.map(D=>{let z=i.includes(D.key),q=l?.stats[D.key];return e("button",{type:"button",class:`metric s${D.slot}${z?" on":""}`,"aria-pressed":z,onClick:()=>qo(D.key),title:gs(D),children:[e("span",{class:"metric-label",children:[e("span",{class:`swatch s${D.slot}`}),Tt(D)]}),e("span",{class:"metric-value",children:q===void 0?"\xA0":D.format(q)}),e("span",{class:"metric-foot",children:l?e(Mr,{now:l.stats[D.key],before:l.previous?.[D.key],lowerIsBetter:D.lowerIsBetter,compared:!!l.previous?.visits}):null})]})})}),e("div",{class:"chart-head",children:e("span",{class:"chart-note",children:[Pn.length>1?o("chart.scaled"):o("chart.pick"),l?.compare?` ${o("chart.dashed",{range:_e(l.compare.from,l.compare.to)})}`:""]})}),l?e(Be,{points:p,previous:f,metrics:Pn.map(ws),interval:l.range.interval,timezone:l.range.timezone}):e("div",{class:"chart"})]}),e("div",{class:"board",hidden:$e,children:[Vo.map((D,z)=>D.title==="panel.rhythm"?e(Hs,{view:a,wide:D.wide}):e($s,{title:D.title,tabs:D.tabs,view:a,onFilter:Bo,wide:D.wide,map:D.title==="panel.locations"},z)),W&&!Oe&&!Mn?e(Es,{view:a,site:W.id,readOnly:ae}):null,W?e(oo,{view:a,readOnly:ae||Mn,onAdd:()=>x("goals")}):null]}),e("footer",{class:"foot",children:[e("a",{href:"https://runlight.sh",class:"powered",...Le?{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"})]}),de("foot.powered",{name:e("span",{children:"Runlight"})})]}),e("span",{class:"foot-range",children:l?`${_e(l.range.from,l.range.to)} \xB7 ${l.range.timezone}`:""}),e("label",{class:"language",children:[e("span",{class:"visually-hidden",children:o("foot.language")}),e("select",{value:Z(),onChange:D=>Tn(D.target.value),children:Pe.map(([D,z])=>e("option",{value:D,children:z}))})]}),e(Hr,{}),e("button",{type:"button",class:"sign-out",title:o("export.title"),onClick:()=>{je("export",le(a)).catch(D=>k(D.message))},children:o("export.zip")}),N?e("button",{type:"button",class:"sign-out",onClick:()=>H(!0),children:o("account.title")}):null,en?e("a",{class:"sign-out",href:en,children:o("app.signOut")}):null]})]})}var Lr={"Organic Search":1,Social:2,Direct:3,Email:4,Referral:5,"Paid Search":6,AI:7,Campaign:8},Ir={desktop:1,mobile:2,tablet:3},Dr=new Set(["ChatGPT-User","Claude-User","Perplexity-User","MistralAI-User","meta-externalfetcher"]);function $r(){let t={filterable:!0};return[{title:"panel.pages",wide:!0,tabs:[{dimension:"page",label:"tab.top",...t,extra:Os},{dimension:"entry",label:"tab.entry",...t,extra:Fs},{dimension:"exit",label:"tab.exit",...t}]},{title:"panel.sources",tabs:[{dimension:"channel",label:"tab.channels",...t,colors:Lr},{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=>Dr.has(n)?"ai.live":"ai.crawl",slots:{"ai.live":7,"ai.crawl":1}}},{dimension:"ai_page",label:"tab.pages",column:"fetches"}]},{title:"panel.devices",tabs:[{dimension:"device",label:"tab.device",...t,colors:Ir},{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 jo(){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"},Le),children:[e(C,{name:"refresh"}),o("embed.reload")]})]})}var wn=["light","dark","system"],zo=t=>o(t==="light"?"theme.light":t==="dark"?"theme.dark":"theme.system");function Hr(){let[,t]=h(0);F(()=>_o(()=>t(i=>i+1)),[]);let n=We(),s=wn[(wn.indexOf(n)+1)%wn.length];F(()=>{let i=c=>{(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="d"&&(c.preventDefault(),it(ko()?"light":"dark"))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]);let a=/Mac|iPhone|iPad/.test(navigator.platform),r=o("theme.cycle",{current:zo(n),next:zo(s)});return e("button",{type:"button",class:"theme","aria-label":r,"aria-keyshortcuts":a?"Meta+Shift+D":"Control+Shift+D",title:`${r} (${a?"\u2318\u21E7D":"Ctrl+Shift+D"})`,onClick:()=>it(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"})]})})}vn();var Or=document.getElementById("app");xt(rs()).catch(()=>xt("en")).finally(()=>Bn(Le&&!cs?e(jo,{}):e(Rr,{}),Or));
|