pleasenobugs 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.
@@ -0,0 +1,2 @@
1
+ var PleaseNoBugs=function(v){"use strict";var Zt=Object.defineProperty;var Gn=v=>{throw TypeError(v)};var Qt=(v,N,f)=>N in v?Zt(v,N,{enumerable:!0,configurable:!0,writable:!0,value:f}):v[N]=f;var Yn=(v,N,f)=>Qt(v,typeof N!="symbol"?N+"":N,f),rn=(v,N,f)=>N.has(v)||Gn("Cannot "+f);var C=(v,N,f)=>(rn(v,N,"read from private field"),f?f.call(v):N.get(v)),W=(v,N,f)=>N.has(v)?Gn("Cannot add the same private member more than once"):N instanceof WeakSet?N.add(v):N.set(v,f),F=(v,N,f,le)=>(rn(v,N,"write to private field"),le?le.call(v,f):N.set(v,f),f),Y=(v,N,f)=>(rn(v,N,"access private method"),f);var ne,B,te,Z,re,ae,oe,ie,se,ge,H,Jn,X;var N,f,le,J,an,on,sn,Ie,xe,de,ln,Le,Ee,je,ye={},we=[],Zn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ke=Array.isArray;function R(e,n){for(var t in n)e[t]=n[t];return e}function Oe(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Qn(e,n,t){var r,a,o,d={};for(o in n)o=="key"?r=n[o]:o=="ref"?a=n[o]:d[o]=n[o];if(arguments.length>2&&(d.children=arguments.length>3?N.call(arguments,2):t),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)d[o]===void 0&&(d[o]=e.defaultProps[o]);return Se(e,d,r,a,null)}function Se(e,n,t,r,a){var o={type:e,props:n,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++le,__i:-1,__u:0};return a==null&&f.vnode!=null&&f.vnode(o),o}function ce(e){return e.children}function Te(e,n){this.props=e,this.context=n}function ee(e,n){if(n==null)return e.__?ee(e.__,e.__i+1):null;for(var t;n<e.__k.length;n++)if((t=e.__k[n])!=null&&t.__e!=null)return t.__e;return typeof e.type=="function"?ee(e):null}function Xn(e){if(e.__P&&e.__d){var n=e.__v,t=n.__e,r=[],a=[],o=R({},n);o.__v=n.__v+1,f.vnode&&f.vnode(o),Fe(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[t]:null,r,t??ee(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,fn(r,o,a),n.__e=n.__=null,o.__e!=t&&dn(o)}}function dn(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(n){if(n!=null&&n.__e!=null)return e.__e=e.__c.base=n.__e}),dn(e)}function cn(e){(!e.__d&&(e.__d=!0)&&J.push(e)&&!Me.__r++||an!=f.debounceRendering)&&((an=f.debounceRendering)||on)(Me)}function Me(){try{for(var e,n=1;J.length;)J.length>n&&J.sort(sn),e=J.shift(),n=J.length,Xn(e)}finally{J.length=Me.__r=0}}function pn(e,n,t,r,a,o,d,c,b,l,u){var m,s,_,w,P,k,x=r&&r.__k||we,g=n.length;for(b=et(t,n,x,b,g),m=0;m<g;m++)(_=t.__k[m])!=null&&(s=_.__i!=-1&&x[_.__i]||ye,_.__i=m,k=Fe(e,_,s,a,o,d,c,b,l,u),w=_.__e,_.ref&&s.ref!=_.ref&&(s.ref&&Be(s.ref,null,_),u.push(_.ref,_.__c||w,_)),P==null&&w!=null&&(P=w),4&_.__u?(b=un(_,b,e),s.__e&&(s.__e=null)):typeof _.type=="function"&&k!==void 0?b=k:w&&(b=w.nextSibling),_.__u&=-7);return t.__e=P,b}function et(e,n,t,r,a){var o,d,c,b,l,u=t.length,m=u,s=0;for(e.__k=new Array(a),o=0;o<a;o++)(d=n[o])!=null&&typeof d!="boolean"&&typeof d!="function"?(typeof d=="string"||typeof d=="number"||typeof d=="bigint"||d.constructor==String?d=e.__k[o]=Se(null,d,null,null,null):ke(d)?d=e.__k[o]=Se(ce,{children:d},null,null,null):d.constructor===void 0&&d.__b>0?d=e.__k[o]=Se(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):e.__k[o]=d,b=o+s,d.__=e,d.__b=e.__b+1,c=null,(l=d.__i=nt(d,t,b,m))!=-1&&(m--,(c=t[l])&&(c.__u|=2)),c==null||c.__v==null?(l==-1&&(a>u?s--:a<u&&s++),typeof d.type!="function"&&(d.__u|=4)):l!=b&&(l==b-1?s--:l==b+1?s++:(l>b?s--:s++,d.__u|=4))):e.__k[o]=null;if(m)for(o=0;o<u;o++)(c=t[o])!=null&&!(2&c.__u)&&(c.__e==r&&(r=ee(c)),mn(c,c));return r}function un(e,n,t){var r,a;if(typeof e.type=="function"){for(r=e.__k,a=0;r&&a<r.length;a++)r[a]&&(r[a].__=e,n=un(r[a],n,t));return n}e.__e!=n&&(n&&e.type&&!n.parentNode&&(n=ee(e)),n=t.insertBefore(e.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function nt(e,n,t,r){var a,o,d,c=e.key,b=e.type,l=n[t],u=l!=null&&(2&l.__u)==0;if(l===null&&c==null||u&&c==l.key&&b==l.type)return t;if(r>(u?1:0)){for(a=t-1,o=t+1;a>=0||o<n.length;)if((l=n[d=a>=0?a--:o++])!=null&&!(2&l.__u)&&c==l.key&&b==l.type)return d}return-1}function _n(e,n,t){n[0]=="-"?e.setProperty(n,t??""):e[n]=t==null?"":typeof t!="number"||Zn.test(n)?t:t+"px"}function Ne(e,n,t,r,a){var o,d;e:if(n=="style")if(typeof t=="string")e.style.cssText=t;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(n in r)t&&n in t||_n(e.style,n,"");if(t)for(n in t)r&&t[n]==r[n]||_n(e.style,n,t[n])}else if(n[0]=="o"&&n[1]=="n")o=n!=(n=n.replace(ln,"$1")),d=n.toLowerCase(),n=d in e||n=="onFocusOut"||n=="onFocusIn"?d.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+o]=t,t?r?t[de]=r[de]:(t[de]=Le,e.addEventListener(n,o?je:Ee,o)):e.removeEventListener(n,o?je:Ee,o);else{if(a=="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 e)try{e[n]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&n[4]!="-"?e.removeAttribute(n):e.setAttribute(n,n=="popover"&&t==1?"":t))}}function bn(e){return function(n){if(this.l){var t=this.l[n.type+e];if(n[xe]==null)n[xe]=Le++;else if(n[xe]<t[de])return;return t(f.event?f.event(n):n)}}}function Fe(e,n,t,r,a,o,d,c,b,l){var u,m,s,_,w,P,k,x,g,h,S,T,D,L,O,V,A=n.type;if(n.constructor!==void 0)return null;128&t.__u&&(b=!!(32&t.__u),o=[c=n.__e=t.__e]),(u=f.__b)&&u(n);e:if(typeof A=="function"){m=d.length;try{if(g=n.props,h=A.prototype&&A.prototype.render,S=(u=A.contextType)&&r[u.__c],T=u?S?S.props.value:u.__:r,t.__c?x=(s=n.__c=t.__c).__=s.__E:(h?n.__c=s=new A(g,T):(n.__c=s=new Te(g,T),s.constructor=A,s.render=rt),S&&S.sub(s),s.state||(s.state={}),s.__n=r,_=s.__d=!0,s.__h=[],s._sb=[]),h&&s.__s==null&&(s.__s=s.state),h&&A.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=R({},s.__s)),R(s.__s,A.getDerivedStateFromProps(g,s.__s))),w=s.props,P=s.state,s.__v=n,_)h&&A.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),h&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(h&&A.getDerivedStateFromProps==null&&g!==w&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(g,T),n.__v==t.__v||!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(g,s.__s,T)===!1){n.__v!=t.__v&&(s.props=g,s.state=s.__s,s.__d=!1),n.__e=t.__e,n.__k=t.__k,n.__k.some(function(j){j&&(j.__=n)}),we.push.apply(s.__h,s._sb),s._sb=[],s.__h.length&&d.push(s),c=ee(t);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(g,s.__s,T),h&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(w,P,k)})}if(s.context=T,s.props=g,s.__P=e,s.__e=!1,D=f.__r,L=0,h)s.state=s.__s,s.__d=!1,D&&D(n),u=s.render(s.props,s.state,s.context),we.push.apply(s.__h,s._sb),s._sb=[];else do s.__d=!1,D&&D(n),u=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++L<25);s.state=s.__s,s.getChildContext!=null&&(r=R(R({},r),s.getChildContext())),h&&!_&&s.getSnapshotBeforeUpdate!=null&&(k=s.getSnapshotBeforeUpdate(w,P)),O=u!=null&&u.type===ce&&u.key==null?gn(u.props.children):u,c=pn(e,ke(O)?O:[O],n,t,r,a,o,d,c,b,l),s.base=n.__e,n.__u&=-161,s.__h.length&&d.push(s),x&&(s.__E=s.__=null)}catch(j){if(d.length=m,n.__v=null,b||o!=null){if(j.then){for(n.__u|=b?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),n.__e=c}else if(o!=null)for(V=o.length;V--;)Oe(o[V])}else n.__e=t.__e;n.__k==null&&(n.__k=t.__k||[]),j.then||hn(n),f.__e(j,n,t)}}else o==null&&n.__v==t.__v?(n.__k=t.__k,n.__e=t.__e):c=n.__e=tt(t.__e,n,t,r,a,o,d,b,l);return(u=f.diffed)&&u(n),128&n.__u?void 0:c}function hn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(hn))}function fn(e,n,t){for(var r=0;r<t.length;r++)Be(t[r],t[++r],t[++r]);f.__c&&f.__c(n,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(o){o.call(a)})}catch(o){f.__e(o,a.__v)}})}function gn(e){return typeof e!="object"||e==null||e.__b>0?e:ke(e)?e.map(gn):e.constructor!==void 0?null:R({},e)}function tt(e,n,t,r,a,o,d,c,b){var l,u,m,s,_,w,P,k=t.props||ye,x=n.props,g=n.type;if(g=="svg"?a="http://www.w3.org/2000/svg":g=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),o!=null){for(l=0;l<o.length;l++)if((_=o[l])&&"setAttribute"in _==!!g&&(g?_.localName==g:_.nodeType==3)){e=_,o[l]=null;break}}if(e==null){if(g==null)return document.createTextNode(x);e=document.createElementNS(a,g,x.is&&x),c&&(f.__m&&f.__m(n,o),c=!1),o=null}if(g==null)k===x||c&&e.data==x||(e.data=x);else{if(o=g=="textarea"&&x.defaultValue!=null?null:o&&N.call(e.childNodes),!c&&o!=null)for(k={},l=0;l<e.attributes.length;l++)k[(_=e.attributes[l]).name]=_.value;for(l in k)_=k[l],l=="dangerouslySetInnerHTML"?m=_:l=="children"||l in x||l=="value"&&"defaultValue"in x||l=="checked"&&"defaultChecked"in x||Ne(e,l,null,_,a);for(l in x)_=x[l],l=="children"?s=_:l=="dangerouslySetInnerHTML"?u=_:l=="value"?w=_:l=="checked"?P=_:c&&typeof _!="function"||k[l]===_||Ne(e,l,_,k[l],a);if(u)c||m&&(u.__html==m.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),n.__k=[];else if(m&&(e.innerHTML=""),pn(n.type=="template"?e.content:e,ke(s)?s:[s],n,t,r,g=="foreignObject"?"http://www.w3.org/1999/xhtml":a,o,d,o?o[0]:t.__k&&ee(t,0),c,b),o!=null)for(l=o.length;l--;)Oe(o[l]);c&&g!="textarea"||(l="value",g=="progress"&&w==null?e.removeAttribute("value"):w!=null&&(w!==e[l]||g=="progress"&&!w||g=="option"&&w!=k[l])&&Ne(e,l,w,k[l],a),l="checked",P!=null&&P!=e[l]&&Ne(e,l,P,k[l],a))}return e}function Be(e,n,t){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&n==null||(e.__u=e(n))}else e.current=n}catch(a){f.__e(a,t)}}function mn(e,n,t){var r,a;if(f.unmount&&f.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Be(r,null,n)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){f.__e(o,n)}r.base=r.__P=r.__n=null}if(r=e.__k)for(a=0;a<r.length;a++)r[a]&&mn(r[a],n,t||typeof e.type!="function");t||Oe(e.__e),e.__c=e.__=e.__e=void 0}function rt(e,n,t){return this.constructor(e,t)}function pe(e,n,t){var r,a,o,d;n==document&&(n=document.documentElement),f.__&&f.__(e,n),a=(r=!1)?null:n.__k,o=[],d=[],Fe(n,e=n.__k=Qn(ce,null,[e]),a||ye,ye,n.namespaceURI,a?null:n.firstChild?N.call(n.childNodes):null,o,a?a.__e:n.firstChild,r,d),fn(o,e,d),e.props.children=null}N=we.slice,f={__e:function(e,n,t,r){for(var a,o,d;n=n.__;)if((a=n.__c)&&!a.__)try{if((o=a.constructor)&&o.getDerivedStateFromError!=null&&(a.setState(o.getDerivedStateFromError(e)),d=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,r||{}),d=a.__d),d)return a.__E=a}catch(c){e=c}throw e}},le=0,Te.prototype.setState=function(e,n){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=R({},this.state),typeof e=="function"&&(e=e(R({},t),this.props)),e&&R(t,e),e!=null&&this.__v&&(n&&this._sb.push(n),cn(this))},Te.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),cn(this))},Te.prototype.render=ce,J=[],on=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,sn=function(e,n){return e.__v.__b-n.__v.__b},Me.__r=0,Ie=Math.random().toString(8),xe="__d"+Ie,de="__a"+Ie,ln=/(PointerCapture)$|Capture$/i,Le=0,Ee=bn(!1),je=bn(!0);var at=0;function i(e,n,t,r,a,o){n||(n={});var d,c,b=n;if("ref"in b)for(c in b={},n)c=="ref"?d=n[c]:b[c]=n[c];var l={type:e,props:b,key:t,ref:d,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--at,__i:-1,__u:0,__source:a,__self:o};if(typeof e=="function"&&(d=e.defaultProps))for(c in d)b[c]===void 0&&(b[c]=d[c]);return f.vnode&&f.vnode(l),l}var ue,$,He,vn,_e=0,xn=[],q=f,yn=q.__b,wn=q.__r,kn=q.diffed,Sn=q.__c,Tn=q.unmount,Mn=q.__;function We(e,n){q.__h&&q.__h($,e,_e||n),_e=0;var t=$.__H||($.__H={__:[],__h:[]});return e>=t.__.length&&t.__.push({}),t.__[e]}function I(e){return _e=1,ot(Cn,e)}function ot(e,n,t){var r=We(ue++,2);if(r.t=e,!r.__c&&(r.__=[Cn(void 0,n),function(c){var b=r.__N?r.__N[0]:r.__[0],l=r.t(b,c);b!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=$,!$.__f)){var a=function(c,b,l){if(!r.__c.__H)return!0;var u=!1,m=r.__c.props!==c;if(r.__c.__H.__.some(function(_){if(_.__N){u=!0;var w=_.__[0];_.__=_.__N,_.__N=void 0,w!==_.__[0]&&(m=!0)}}),o){var s=o.call(this,c,b,l);return u?s||m:s}return!u||m};$.__f=!0;var o=$.shouldComponentUpdate,d=$.componentWillUpdate;$.componentWillUpdate=function(c,b,l){if(this.__e){var u=o;o=void 0,a(c,b,l),o=u}d&&d.call(this,c,b,l)},$.shouldComponentUpdate=a}return r.__N||r.__}function Pe(e,n){var t=We(ue++,3);!q.__s&&zn(t.__H,n)&&(t.__=e,t.u=n,$.__H.__h.push(t))}function Nn(e){return _e=5,be(function(){return{current:e}},[])}function be(e,n){var t=We(ue++,7);return zn(t.__H,n)&&(t.__=e(),t.__H=n,t.__h=e),t.__}function it(e,n){return _e=8,be(function(){return e},n)}function st(){for(var e;e=xn.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(ze),n.__h.some(Ue),n.__h=[]}catch(t){n.__h=[],q.__e(t,e.__v)}}}q.__b=function(e){$=null,yn&&yn(e)},q.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),Mn&&Mn(e,n)},q.__r=function(e){wn&&wn(e),ue=0;var n=($=e.__c).__H;n&&(He===$?(n.__h=[],$.__h=[],n.__.some(function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0})):(n.__h.some(ze),n.__h.some(Ue),n.__h=[],ue=0)),He=$},q.diffed=function(e){kn&&kn(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(xn.push(n)!==1&&vn===q.requestAnimationFrame||((vn=q.requestAnimationFrame)||lt)(st)),n.__H.__.some(function(t){t.u&&(t.__H=t.u,t.u=void 0)})),He=$=null},q.__c=function(e,n){n.some(function(t){try{t.__h.some(ze),t.__h=t.__h.filter(function(r){return!r.__||Ue(r)})}catch(r){n.some(function(a){a.__h&&(a.__h=[])}),n=[],q.__e(r,t.__v)}}),Sn&&Sn(e,n)},q.unmount=function(e){Tn&&Tn(e);var n,t=e.__c;t&&t.__H&&(t.__H.__.some(function(r){try{ze(r)}catch(a){n=a}}),t.__H=void 0,n&&q.__e(n,t.__v))};var Pn=typeof requestAnimationFrame=="function";function lt(e){var n,t=function(){clearTimeout(r),Pn&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(t,35);Pn&&(n=requestAnimationFrame(t))}function ze(e){var n=$,t=e.__c;typeof t=="function"&&(e.__c=void 0,t()),$=n}function Ue(e){var n=$;e.__c=e.__(),$=n}function zn(e,n){return!e||e.length!==n.length||n.some(function(t,r){return t!==e[r]})}function Cn(e,n){return typeof n=="function"?n(e):n}function Ve(e){return e.replace(/\s+/g,"").toUpperCase()}const dt=24,ct=30*24*60*60*1e3,pt=5*60*1e3;function ut(e){return["PleaseNoBugs login",`Project: ${e.project}`,`Origin: ${An(e.origin)}`,`Issued: ${new Date(e.issued).toISOString()}`].join(`
2
+ `)}function An(e){try{return new URL(e).origin}catch{return e}}function $n(e,n=Date.now()){return Number.isFinite(e)&&e<=n+pt&&n-e<=ct}function _t(e){return`Nimiq ${bt(JSON.stringify(e))}`}function bt(e){const n=new TextEncoder().encode(e);let t="";for(const r of n)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const ht=["aan","als","bij","dan","dat","deze","die","dit","een","heb","het","ik","is","kan","kun","maar","met","mijn","niet","ook","van","voor","wil","word","wordt","zijn","zou","graag","meer","moet","and","are","but","can","for","have","more","not","should","that","the","this","want","when","with","would","you","your","aber","auch","bitte","dass","denn","ein","eine","einen","gerne","ich","ist","kann","mehr","mein","meine","nicht","oder","sein","sollte","und","wenn","werden","wird","wollen","möchte","app"];function Dn(e=[]){const n=new Set([...ht,...[...e].map(a=>a.toLowerCase())]),t=new WeakMap,r=a=>new Set(a.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu," ").split(/\s+/).filter(o=>o.length>=4&&!n.has(o)));return function(o,d,c=3){const b=r(d);return b.size<2?[]:o.map(l=>{let u=t.get(l);u||(u=r(l.text),t.set(l,u));let m=0;for(const s of b)u.has(s)&&m++;return{post:l,shared:m}}).filter(l=>l.shared>=2).sort((l,u)=>u.shared-l.shared||u.post.votes-l.post.votes).slice(0,c).map(l=>l.post)}}function qn(e,n){const t=[...e];return n==="new"?t.sort((r,a)=>a.at-r.at):t.sort((r,a)=>a.votes-r.votes||a.at-r.at)}class he extends Error{constructor(n,t){super(t??n),this.reason=n,this.name="SignerError"}}const ft=2e3;function Re(){return typeof window<"u"&&!!window.nimiq}function gt(e){return window.nimiq?Promise.resolve(window.nimiq):new Promise((n,t)=>{const r=Date.now(),a=setInterval(()=>{window.nimiq?(clearInterval(a),n(window.nimiq)):Date.now()-r>e&&(clearInterval(a),t(new he("no_wallet","Not running inside Nimiq Pay")))},50)})}function In(e=ft){return async n=>{const t=await gt(e),r=await t.listAccounts();if(!Array.isArray(r)||!r.length)throw new he("no_account");const a=await t.sign(n);if(!a||!("signature"in a))throw new he("declined",a&&"error"in a?a.error.message:void 0);return{address:r[0],publicKey:a.publicKey,signature:a.signature}}}function Ln(e){const n=e.server.replace(/\/+$/,""),t=e.project,r=An(e.origin??(typeof location<"u"?location.origin:"")),a=e.signer===null?void 0:e.signer??(Re()?In():void 0),o=e.fetch??globalThis.fetch.bind(globalThis),d=e.storage===void 0?mt():e.storage,c=`pleasenobugs.proof.${t}.${r}`;let b=s(),l=null,u=!1;function m(){if(u||!e.appLogin)return null;const h=typeof e.appLogin=="function"?e.appLogin():e.appLogin;return h?{...h,origin:r,issued:0}:null}function s(){try{const h=d?.getItem(c);if(!h)return null;const S=JSON.parse(h);return $n(S.issued)?S:null}catch{return null}}function _(h){b=h;try{h?d?.setItem(c,JSON.stringify(h)):d?.removeItem(c)}catch{}}function w(){const h=m();return h||(b&&!$n(b.issued)&&_(null),b)}function P(){const h=m();return h?Promise.resolve({ok:!0,data:Ve(h.address)}):a?l||(l=(async()=>{try{const S=Date.now(),T=await a(ut({project:t,origin:r,issued:S}));return _({...T,origin:r,issued:S}),{ok:!0,data:Ve(T.address)}}catch(S){return S instanceof he&&S.reason==="no_wallet"?{ok:!1,status:0,error:"no_signer"}:{ok:!1,status:0,error:"declined"}}finally{l=null}})(),l):Promise.resolve({ok:!1,status:0,error:"no_signer"})}async function k(h,S,T){const D=async A=>{const j={};T.body!==void 0&&(j["content-type"]="application/json"),A&&(j.authorization=_t(A));let y;try{y=await o(`${n}${S}`,{method:h,headers:j,...T.body!==void 0?{body:JSON.stringify(T.body)}:{}})}catch{return{ok:!1,status:0,error:"network"}}const K=await y.json().catch(()=>null);if(y.ok)return{ok:!0,data:K};const Ce=K&&typeof K.error=="string"?K.error:"internal";return{ok:!1,status:y.status,error:Ce,body:K}};if(T.auth==="none")return D(null);let L=w();if(!L&&T.auth==="required"){const A=await P();if(!A.ok)return A;L=w()}const O=await D(L);if(O.ok||O.status!==401||!L)return O;if(L.message!==void 0?u=!0:_(null),T.auth==="optional")return D(null);const V=await P();return V.ok?D(w()):V}const x=(h="")=>`/v1/projects/${encodeURIComponent(t)}${h}`,g=h=>x(`/posts/${encodeURIComponent(h)}`);return{project:t,get canSign(){return!!a||m()!==null},address(){const h=w();return h?Ve(h.address):null},signIn:P,signOut(){_(null)},board:()=>k("GET",x("/posts"),{auth:"optional"}),me:()=>k("GET",x("/me"),{auth:"required"}),answers:()=>k("GET",x("/answers"),{auth:"required"}),post:h=>k("POST",x("/posts"),{body:h,auth:"required"}),vote:(h,S)=>k("POST",`${g(h)}/vote`,{body:{up:S},auth:"required"}),remove:h=>k("DELETE",g(h),{auth:"required"}),setName:h=>k("PUT",x("/me"),{body:{name:h},auth:"required"}),manage:(h,S)=>k("POST",`${g(h)}/manage`,{body:S,auth:"required"})}}function mt(){try{const e=globalThis.localStorage,n="__pleasenobugs__";return e.setItem(n,"1"),e.removeItem(n),e}catch{return null}}const vt=["en","nl","de"],En={"board.title":{en:"Feedback",nl:"Feedback",de:"Feedback"},"board.open":{en:"Feedback",nl:"Feedback",de:"Feedback"},"board.close":{en:"Close",nl:"Sluiten",de:"Schließen"},"board.back":{en:"Back",nl:"Terug",de:"Zurück"},"board.top":{en:"Top",nl:"Top",de:"Top"},"board.new":{en:"New",nl:"Nieuw",de:"Neu"},"board.order":{en:"Order",nl:"Volgorde",de:"Reihenfolge"},"board.all":{en:"All",nl:"Alles",de:"Alles"},"board.bugs":{en:"Bugs",nl:"Bugs",de:"Bugs"},"board.ideas":{en:"Ideas",nl:"Ideeën",de:"Ideen"},"board.kindBug":{en:"Bug",nl:"Bug",de:"Bug"},"board.kindIdea":{en:"Idea",nl:"Idee",de:"Idee"},"board.statusOpen":{en:"Open",nl:"Open",de:"Offen"},"board.statusPlanned":{en:"Planned",nl:"Gepland",de:"Geplant"},"board.statusDone":{en:"Done",nl:"Klaar",de:"Fertig"},"board.statusDeclined":{en:"Not doing",nl:"Doen we niet",de:"Machen wir nicht"},"board.anon":{en:"Anonymous",nl:"Anoniem",de:"Anonym"},"board.byYou":{en:"You",nl:"Jij",de:"Du"},"board.reply":{en:"{app} says",nl:"{app} zegt",de:"{app} sagt"},"board.upvote":{en:"I want this too",nl:"Dit wil ik ook",de:"Will ich auch"},"board.emptyTitle":{en:"Nothing here yet. Tell us what is broken or what you miss.",nl:"Hier staat nog niets. Vertel wat er stuk is of wat je mist.",de:"Hier steht noch nichts. Sag uns, was kaputt ist oder was dir fehlt."},"board.emptyFiltered":{en:"Nothing of that kind yet.",nl:"Nog niets van deze soort.",de:"Von dieser Sorte noch nichts."},"board.write":{en:"Write feedback",nl:"Feedback schrijven",de:"Feedback schreiben"},"board.loadFailed":{en:"Could not reach the board.",nl:"Kon het bord niet bereiken.",de:"Das Board war nicht erreichbar."},"board.retry":{en:"Try again",nl:"Opnieuw",de:"Nochmal"},"board.page":{en:"Page {n}",nl:"Pagina {n}",de:"Seite {n}"},"board.signIn":{en:"Sign in with your wallet",nl:"Inloggen met je wallet",de:"Mit deiner Wallet anmelden"},"board.needWallet":{en:"Open {app} in Nimiq Pay to post and vote.",nl:"Open {app} in Nimiq Pay om te posten en te stemmen.",de:"Öffne {app} in Nimiq Pay, um zu posten und abzustimmen."},"board.composeTitle":{en:"Your feedback",nl:"Jouw feedback",de:"Dein Feedback"},"board.whatKind":{en:"What is it?",nl:"Wat is het?",de:"Was ist es?"},"board.placeholder":{en:"What is broken, or what do you miss?",nl:"Wat is er stuk, of wat mis je?",de:"Was ist kaputt, oder was fehlt dir?"},"board.public":{en:"Everybody using {app} can read this.",nl:"Iedereen die {app} gebruikt kan dit lezen.",de:"Jeder, der {app} nutzt, kann das lesen."},"board.showName":{en:"Show my name",nl:"Mijn naam tonen",de:"Meinen Namen zeigen"},"board.namePlaceholder":{en:"Your name",nl:"Je naam",de:"Dein Name"},"board.anonNote":{en:"Nobody on the board sees who wrote it, and your wallet address is never shown. The server does know your wallet: votes and the daily limit are counted per wallet.",nl:"Niemand op het bord ziet wie het schreef, en je wallet-adres wordt nooit getoond. De server kent je wallet wel: stemmen en de daglimiet tellen per wallet.",de:"Niemand auf dem Board sieht, wer es geschrieben hat, und deine Wallet-Adresse wird nie gezeigt. Der Server kennt deine Wallet schon: Stimmen und das Tageslimit zählen pro Wallet."},"board.send":{en:"Put it on the board",nl:"Op het bord zetten",de:"Aufs Board setzen"},"board.left":{en:"{n} of {max} left today",nl:"Nog {n} van {max} vandaag",de:"Noch {n} von {max} heute"},"board.noneLeft":{en:"That is today’s {max}. Back tomorrow.",nl:"Dat waren de {max} van vandaag. Morgen weer.",de:"Das waren die {max} für heute. Morgen wieder."},"board.likeThis":{en:"Said already, maybe?",nl:"Misschien al gezegd?",de:"Vielleicht schon gesagt?"},"board.likeThisNote":{en:"Back one of these instead and it counts for more.",nl:"Steun er liever een van deze, dan telt het zwaarder.",de:"Unterstütz lieber eins davon, dann zählt es mehr."},"board.failed":{en:"That did not go through. Try again.",nl:"Dat ging niet door. Probeer het opnieuw.",de:"Das ist nicht durchgegangen. Versuch es noch mal."},"board.failedFull":{en:"Not posted: that was today’s {max}. Back tomorrow.",nl:"Niet geplaatst: dat waren de {max} van vandaag. Morgen weer.",de:"Nicht gepostet: das waren die {max} für heute. Morgen wieder."},"board.sent":{en:"Feedback sent!",nl:"Feedback verstuurd!",de:"Feedback gesendet!"},"board.delete":{en:"Throw away",nl:"Weggooien",de:"Wegwerfen"},"board.deleteTitle":{en:"Throw this away?",nl:"Deze weggooien?",de:"Das hier wegwerfen?"},"board.deleteNote":{en:"It leaves the board for everybody, with its votes.",nl:"Hij gaat voor iedereen van het bord, met stemmen en al.",de:"Es verschwindet für alle vom Board, samt Stimmen."},"board.cancel":{en:"Cancel",nl:"Annuleren",de:"Abbrechen"},"board.manage":{en:"Answer this",nl:"Hier antwoord op geven",de:"Darauf antworten"},"board.setStatus":{en:"Where it stands",nl:"Waar het staat",de:"Wo es steht"},"board.replyLabel":{en:"Your answer",nl:"Jouw antwoord",de:"Deine Antwort"},"board.replyPlaceholder":{en:"Say something back",nl:"Zeg er iets over",de:"Sag was dazu"},"board.hide":{en:"Take off the board",nl:"Van het bord halen",de:"Vom Board nehmen"},"board.unhide":{en:"Put it back",nl:"Terugzetten",de:"Zurückstellen"},"board.hidden":{en:"Off the board",nl:"Van het bord",de:"Vom Board"},"board.save":{en:"Save",nl:"Opslaan",de:"Speichern"},"board.context":{en:"Sent with",nl:"Meegestuurd",de:"Mitgeschickt"},"time.now":{en:"just now",nl:"zojuist",de:"gerade eben"},"time.min":{en:"{n}m ago",nl:"{n}m geleden",de:"vor {n} Min."},"time.hour":{en:"{n}h ago",nl:"{n}u geleden",de:"vor {n} Std."},"time.day":{en:"{n}d ago",nl:"{n}d geleden",de:"vor {n} Tg."}};function xt(e){const n=[e,typeof window<"u"?window.nimiqPay?.language:void 0,typeof document<"u"?document.documentElement.lang:void 0,typeof navigator<"u"?navigator.language:void 0];for(const t of n)if(t)return t.slice(0,2).toLowerCase();return"en"}function yt(e,n={}){const t=vt.includes(e)?e:"en";return(r,a)=>{let o=n[r]??En[r][t]??En[r].en;if(a)for(const[d,c]of Object.entries(a))o=o.split(`{${d}}`).join(String(c));return o}}const Ke=6e4,Ge=60*Ke,Ye=24*Ge,wt=7*Ye,jn=new Map;function kt(e,n,t=Date.now()){const r=Math.max(0,t-e);if(r>=wt){let a=jn.get(n);return a||(a=new Intl.DateTimeFormat(n,{day:"numeric",month:"short"}),jn.set(n,a)),{date:a.format(new Date(e)).replace(".","")}}return r<Ke?{key:"time.now",vars:{n:"0"}}:r<Ge?{key:"time.min",vars:{n:String(Math.floor(r/Ke))}}:r<Ye?{key:"time.hour",vars:{n:String(Math.floor(r/Ge))}}:{key:"time.day",vars:{n:String(Math.floor(r/Ye))}}}const U=(e,n,t=!1)=>i("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:t?"none":"currentColor","stroke-width":"2.25","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n}),St=({size:e=22})=>U(e,i("path",{d:"M15 5l-7 7 7 7"})),Tt=({size:e=22})=>U(e,i("path",{d:"M6 6l12 12M18 6L6 18"})),Mt=({size:e=20})=>U(e,i("path",{d:"M12 5v14M5 12h14"})),Nt=({size:e=18})=>U(e,i("path",{d:"M4 7h16M9 7V4.5h6V7M6.5 7l1 12.5h9l1-12.5M10 11v5M14 11v5"})),Pt=({size:e=14})=>U(e,i("path",{d:"M12 6.5l7.2 9a1 1 0 0 1-.78 1.6H5.58a1 1 0 0 1-.78-1.6L12 6.5z"}),!0),zt=({size:e=20})=>U(e,i("path",{d:"M4 5.5h16v10H9l-5 4v-14z"})),Ct=({size:e=12})=>U(e,i("path",{d:"M8 9h8v5a4 4 0 0 1-8 0V9zM9.5 9a2.5 2.5 0 0 1 5 0M4 12h4M16 12h4M5 7l3 2M19 7l-3 2M5 18l3-2M19 18l-3-2"})),At=({size:e=12})=>U(e,i("path",{d:"M9 18h6M10 21h4M12 3a6 6 0 0 0-3.5 10.9V16h7v-2.1A6 6 0 0 0 12 3z"})),$t=({size:e=12})=>U(e,i("path",{d:"M12 7v5l3 2M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18z"})),Dt=({size:e=12})=>U(e,i("path",{d:"M5 12.5l4.5 4.5L19 7.5"})),qt=({size:e=12})=>U(e,i("path",{d:"M7 7l10 10M17 7L7 17"})),fe={bug:{icon:()=>i(Ct,{}),label:"board.kindBug"},idea:{icon:()=>i(At,{}),label:"board.kindIdea"}},It={planned:{icon:()=>i($t,{}),label:"board.statusPlanned"},done:{icon:()=>i(Dt,{}),label:"board.statusDone"},declined:{icon:()=>i(qt,{}),label:"board.statusDeclined"}};function On({tone:e,icon:n,label:t}){return i("span",{class:"badge",children:[i("span",{class:`badge__dot badge__dot--${e}`,children:n()}),t]})}function Fn({votes:e,voted:n,onVote:t,t:r}){return i("button",{type:"button",class:"vote","aria-label":r("board.upvote"),"aria-pressed":n,onClick:a=>{a.stopPropagation(),t(!n)},children:[i(Pt,{}),i("span",{children:e})]})}function Lt({post:e,appName:n,t,locale:r,onVote:a,onDelete:o,onManage:d}){const c=fe[e.kind],b=It[e.status],l=kt(e.at,r);return i("li",{class:`card${d?" card--owner":""}${e.hidden?" card--hidden":""}`,onClick:d,role:d?"button":void 0,tabIndex:d?0:void 0,"aria-label":d?t("board.manage"):void 0,onKeyDown:d?u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),d())}:void 0,children:[i("div",{class:"card__head",children:[i(On,{tone:e.kind,icon:c.icon,label:t(c.label)}),b&&i(On,{tone:e.status,icon:b.icon,label:t(b.label)}),e.hidden&&i("span",{class:"card__off",children:t("board.hidden")}),i("span",{class:"card__when",children:"date"in l?l.date:t(l.key,l.vars)})]}),i("p",{class:"card__text",children:e.text}),e.reply&&i("div",{class:"card__reply",children:[i("span",{class:"card__reply-who",children:t("board.reply",{app:n})}),i("p",{class:"card__reply-text",children:e.reply.text})]}),i("div",{class:"card__foot",children:[i("span",{class:"card__who",children:e.mine?t("board.byYou"):e.who??t("board.anon")}),o&&i("button",{type:"button",class:"icon-btn card__bin","aria-label":t("board.delete"),onClick:u=>{u.stopPropagation(),o()},children:i(Nt,{})}),i(Fn,{votes:e.votes,voted:e.voted,onVote:a,t})]})]})}function Et({t:e,kinds:n,posts:t,likeThis:r,left:a,perDay:o,textMax:d,name:c,appName:b,onVote:l,onSend:u}){const[m,s]=I(n[0]),[_,w]=I(""),[P,k]=I(!1),[x,g]=I(c),[h,S]=I(!1),[T,D]=I(null),L=be(()=>r(t,_),[t,_,r]),O=_.trim(),V=a!==null&&a<=0,A=P&&!x.trim(),j=async()=>{S(!0),D(null);const y=await u({kind:m,text:O,anon:!P,name:x.trim()});y&&(D(y.key?{key:y.key,vars:y.vars}:null),S(!1))};return i("div",{class:"compose",children:[n.length>1&&i(ce,{children:[i("span",{class:"label",children:e("board.whatKind")}),i("div",{class:"kinds",role:"radiogroup","aria-label":e("board.whatKind"),children:n.map(y=>i("button",{type:"button",role:"radio","aria-checked":m===y,class:"chip-pick",onClick:()=>s(y),children:[i("span",{class:`badge__dot badge__dot--${y}`,children:fe[y].icon()}),e(fe[y].label)]},y))})]}),i("p",{class:"public",children:e("board.public",{app:b})}),i("textarea",{class:"field",value:_,maxLength:d,placeholder:e("board.placeholder"),"aria-label":e("board.placeholder"),onInput:y=>{w(y.target.value),D(null)}}),i("span",{class:"count",children:d-_.length}),L.length>0&&i("div",{class:"alike",children:[i("span",{class:"label",children:e("board.likeThis")}),i("p",{class:"alike__note",children:e("board.likeThisNote")}),i("ul",{class:"alike__list",children:L.map(y=>i("li",{class:"alike__row",children:[i("span",{class:`badge__dot badge__dot--${y.kind}`,"aria-label":e(fe[y.kind].label),children:fe[y.kind].icon()}),i("span",{class:"alike__text",children:y.text}),i(Fn,{votes:y.votes,voted:y.voted,onVote:K=>l(y.id,K),t:e})]},y.id))})]}),i("div",{class:"switch-row",children:[i("span",{class:"switch-row__label",id:"pnb-show-name",children:e("board.showName")}),i("button",{type:"button",role:"switch",class:"switch","aria-checked":P,"aria-labelledby":"pnb-show-name",onClick:()=>k(!P)})]}),P&&i("input",{class:"input",value:x,maxLength:dt,placeholder:e("board.namePlaceholder"),"aria-label":e("board.namePlaceholder"),onInput:y=>g(y.target.value)}),i("p",{class:"note",children:e("board.anonNote")}),i("div",{class:"send",children:[i("button",{type:"button",class:"btn",disabled:!O||V||h||A,"aria-busy":h,onClick:()=>void j(),children:h?i("span",{class:"spinner"}):e("board.send")}),i("span",{class:`left${T?" left--bad":""}`,role:"status",children:T?e(T.key,T.vars):a===null?"":V?e("board.noneLeft",{max:o}):e("board.left",{n:a,max:o})})]})]})}function Bn({label:e,onClose:n,children:t}){return Pe(()=>{const r=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),i("div",{class:"scrim",onClick:n,children:i("div",{class:"sheet",role:"dialog","aria-modal":"true","aria-label":e,onClick:r=>r.stopPropagation(),children:t})})}function jt({t:e,onConfirm:n,onClose:t}){return i(Bn,{label:e("board.deleteTitle"),onClose:t,children:[i("h2",{class:"sheet__title",children:e("board.deleteTitle")}),i("p",{class:"sheet__quote",children:e("board.deleteNote")}),i("div",{class:"sheet__actions",children:[i("button",{type:"button",class:"btn btn--danger",onClick:n,children:e("board.delete")}),i("button",{type:"button",class:"text-btn",onClick:t,children:e("board.cancel")})]})]})}const Ot=[{status:"open",label:"board.statusOpen"},{status:"planned",label:"board.statusPlanned"},{status:"done",label:"board.statusDone"},{status:"declined",label:"board.statusDeclined"}];function Ft({t:e,post:n,replyMax:t,onSave:r,onClose:a}){const[o,d]=I(n.status),[c,b]=I(n.reply?.text??""),[l,u]=I(!!n.hidden),m=n.context?Object.entries(n.context):[];return i(Bn,{label:e("board.manage"),onClose:a,children:[i("h2",{class:"sheet__title",children:e("board.manage")}),i("p",{class:"sheet__quote",children:n.text}),m.length>0&&i("dl",{class:"context","aria-label":e("board.context"),children:m.map(([s,_])=>i("div",{children:[i("dt",{children:s}),i("dd",{children:_})]},s))}),i("span",{class:"label",style:{display:"block",marginTop:"20px",marginBottom:"8px"},children:e("board.setStatus")}),i("div",{class:"states",role:"radiogroup","aria-label":e("board.setStatus"),children:Ot.map(s=>i("button",{type:"button",role:"radio","aria-checked":o===s.status,class:"chip-pick",onClick:()=>d(s.status),children:e(s.label)},s.status))}),i("span",{class:"label",style:{display:"block",marginTop:"20px",marginBottom:"8px"},children:e("board.replyLabel")}),i("textarea",{class:"field",style:{minHeight:"96px"},value:c,maxLength:t,placeholder:e("board.replyPlaceholder"),"aria-label":e("board.replyLabel"),onInput:s=>b(s.target.value)}),i("button",{type:"button",class:"hide-btn","aria-pressed":l,onClick:()=>u(!l),children:e(l?"board.unhide":"board.hide")}),i("div",{class:"sheet__actions",children:i("button",{type:"button",class:"btn",onClick:()=>r({status:o,reply:c.trim(),hidden:l}),children:e("board.save")})})]})}const Je=15,Bt=2600;function Hn({client:e,t:n,locale:t,appName:r,suggestName:a,context:o,noise:d,onClose:c,onPosted:b}){const[l,u]=I(null),[m,s]=I(!1),[_,w]=I("board"),[P,k]=I("top"),[x,g]=I("all"),[h,S]=I(1),[T,D]=I(null),[L,O]=I(null),[V,A]=I(!1),j=Nn(null),y=(d??[]).join("|"),K=be(()=>Dn(y?y.split("|"):[]),[y]),Ce=Nn(!1),G=it(async()=>{const p=await e.board();p.ok?(Ce.current=!0,u(p.data),s(!1)):Ce.current||s(!0)},[e]);Pe(()=>{G()},[G]),Pe(()=>{if(!L)return;const p=setTimeout(()=>O(null),Bt);return()=>clearTimeout(p)},[L]),Pe(()=>{const p=j.current;if(!p)return;let M=p.scrollTop,z=0;const E=()=>{const ve=p.scrollTop,tn=ve-M;if(M=ve,ve<48){z=0,A(!1);return}z=Math.sign(tn)===Math.sign(z)?z+tn:tn,z>24?A(!0):z<-8&&A(!1)};return p.addEventListener("scroll",E,{passive:!0}),()=>p.removeEventListener("scroll",E)},[_,l]);const Ae=r??l?.project.name??"",Q=l?.project.rules,$e=!!l?.me?.owner,me=l?.posts??[],Vn=be(()=>{const p=me.filter(M=>$e||!M.hidden);return qn(x==="all"?p:p.filter(M=>M.kind===x),P)},[me,x,P,$e]),Xe=Math.max(1,Math.ceil(Vn.length/Je)),en=Math.min(h,Xe),Rn=Vn.slice((en-1)*Je,en*Je),De=(p,M)=>u(z=>z&&{...z,posts:z.posts.map(E=>E.id===p?{...E,...M}:E)}),qe=p=>{p==="no_signer"?O(n("board.needWallet",{app:Ae})):p!=="declined"&&O(n("board.failed"))},Kn=async(p,M)=>{const z=me.find(ve=>ve.id===p);if(!z)return;De(p,{votes:Math.max(0,z.votes+(M?1:-1)),voted:M});const E=await e.vote(p,M);E.ok?(De(p,{votes:E.data.votes,voted:E.data.voted}),l?.me||G()):(De(p,{votes:z.votes,voted:z.voted}),qe(E.error))},Kt=async p=>{const M=Ht(),z=p.kind==="bug"?{...o,host:Re()?"nimiq-pay":"browser"}:void 0,E=await e.post({id:M,kind:p.kind,text:p.text,anon:p.anon,context:z});return E.ok?(!p.anon&&p.name&&p.name!==l?.me?.name&&await e.setName(p.name),w("board"),k("new"),g("all"),S(1),O(n("board.sent")),b?.({id:M,kind:p.kind}),await G(),null):E.error==="declined"?{key:null}:E.error==="no_signer"?{key:"board.needWallet",vars:{app:Ae}}:E.error==="too_many"?(G(),{key:"board.failedFull",vars:{max:Q?.perDay??5}}):{key:"board.failed"}},Gt=async()=>{const p=await e.signIn();p.ok?await G():qe(p.error)},Yt=async p=>{D(null),u(z=>z&&{...z,posts:z.posts.filter(E=>E.id!==p.id)});const M=await e.remove(p.id);M.ok||qe(M.error),G()},Jt=async(p,M)=>{D(null),De(p.id,{status:M.status,hidden:M.hidden||void 0,reply:M.reply?{text:M.reply,at:Date.now()}:void 0});const z=await e.manage(p.id,M);z.ok||qe(z.error),G()},nn=Q?.kinds??["bug","idea"];return _==="compose"&&Q?i("div",{class:"app",children:[i("header",{class:"bar",children:[i("button",{type:"button",class:"icon-btn","aria-label":n("board.back"),onClick:()=>w("board"),children:i(St,{})}),i("h2",{class:"bar__title",children:n("board.composeTitle")}),i("span",{})]}),i("div",{class:"scroll",ref:j,style:{paddingBottom:"24px"},children:i(Et,{t:n,kinds:nn,posts:me,likeThis:K,left:l?.me?l.me.left:null,perDay:Q.perDay,textMax:Q.textMax,name:l?.me?.name??a??"",appName:Ae,onVote:Kn,onSend:Kt})}),L&&i("div",{class:"toast",role:"status",children:L})]}):i("div",{class:"app",children:[i("header",{class:"bar",children:[c?i("button",{type:"button",class:"icon-btn","aria-label":n("board.close"),onClick:c,children:i(Tt,{})}):i("span",{}),i("h2",{class:"bar__title",children:n("board.title")}),i("button",{type:"button",class:"icon-btn","aria-label":n("board.write"),disabled:!Q,onClick:()=>w("compose"),children:i(Mt,{})})]}),nn.length>1&&i("div",{class:"filters",children:["all",...nn].map(p=>i("button",{type:"button",class:"chip-pick","aria-pressed":x===p,onClick:()=>{g(p),S(1)},children:n(p==="all"?"board.all":p==="bug"?"board.bugs":"board.ideas")},p))}),i("div",{class:"scroll",ref:j,children:[m?i("div",{class:"empty",children:[i("p",{children:n("board.loadFailed")}),i("button",{type:"button",class:"text-btn",onClick:()=>void G(),children:n("board.retry")})]}):l?Rn.length===0?i("p",{class:"empty",children:n(me.length===0?"board.emptyTitle":"board.emptyFiltered")}):i("ul",{class:"list",children:Rn.map(p=>i(Lt,{post:p,appName:Ae,t:n,locale:t,onVote:M=>void Kn(p.id,M),onDelete:p.mine||$e?()=>D({kind:"delete",post:p}):void 0,onManage:$e?()=>D({kind:"manage",post:p}):void 0},p.id))}):i("div",{class:"empty","aria-busy":"true",children:i("span",{class:"spinner",style:{display:"inline-block"}})}),Xe>1&&i("nav",{class:"pager",children:Array.from({length:Xe},(p,M)=>M+1).map(p=>i("button",{type:"button","aria-current":p===en?"page":void 0,"aria-label":n("board.page",{n:p}),onClick:()=>{S(p),j.current?.scrollTo({top:0})},children:p},p))}),l&&!l.me&&e.canSign&&i("div",{class:"sign-in",children:i("button",{type:"button",class:"text-btn",onClick:()=>void Gt(),children:n("board.signIn")})})]}),i("div",{class:`order${V?" order--away":""}`,children:i("div",{class:"order__pill",role:"tablist","aria-label":n("board.order"),children:["top","new"].map(p=>i("button",{type:"button",role:"tab",class:"order__tab","aria-selected":P===p,onClick:()=>{k(p),S(1)},children:n(p==="top"?"board.top":"board.new")},p))})}),L&&i("div",{class:"toast",role:"status",children:L}),T?.kind==="delete"&&i(jt,{t:n,onConfirm:()=>void Yt(T.post),onClose:()=>D(null)}),T?.kind==="manage"&&Q&&i(Ft,{t:n,post:T.post,replyMax:Q.replyMax,onSave:p=>void Jt(T.post,p),onClose:()=>D(null)})]})}function Ht(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`p-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}const Wt=':host{--pnb-bg: #ffffff;--pnb-surface: #f4f4f7;--pnb-surface-2: #e8e8ef;--pnb-sunken: #e8e8ef;--pnb-line: #dcdce5;--pnb-text: #1b1b24;--pnb-text-quiet: #5a5a6b;--pnb-accent: #2563eb;--pnb-on-accent: #ffffff;--pnb-danger: #d23b2f;--pnb-bug: #e5484d;--pnb-idea: #e9a00b;--pnb-planned: #3e7bfa;--pnb-done: #2f9e66;--pnb-declined: #8b8d98;--pnb-radius: 8px;--pnb-radius-sheet: 16px;--pnb-shadow: 0 6px 16px rgba(0, 0, 0, .18);--pnb-scrim: rgba(10, 10, 20, .5);--pnb-font: inherit;--pnb-z: 2147483000;--pnb-inset-top: env(safe-area-inset-top, 0px);--pnb-inset-bottom: env(safe-area-inset-bottom, 0px);display:block;font-family:var(--pnb-font);color:var(--pnb-text);-webkit-tap-highlight-color:transparent}@media (prefers-color-scheme: dark){:host(:not([theme])),:host([theme="auto"]){--pnb-bg: #15151c;--pnb-surface: #22222c;--pnb-surface-2: #2e2e3a;--pnb-sunken: #0d0d12;--pnb-line: #383846;--pnb-text: #f2f2f7;--pnb-text-quiet: #a9a9ba;--pnb-accent: #6b93ff;--pnb-on-accent: #0b0b12;--pnb-danger: #ff6b5e;--pnb-shadow: 0 6px 16px rgba(0, 0, 0, .45);--pnb-scrim: rgba(0, 0, 0, .6)}}:host([theme="dark"]){--pnb-bg: #15151c;--pnb-surface: #22222c;--pnb-surface-2: #2e2e3a;--pnb-sunken: #0d0d12;--pnb-line: #383846;--pnb-text: #f2f2f7;--pnb-text-quiet: #a9a9ba;--pnb-accent: #6b93ff;--pnb-on-accent: #0b0b12;--pnb-danger: #ff6b5e;--pnb-shadow: 0 6px 16px rgba(0, 0, 0, .45);--pnb-scrim: rgba(0, 0, 0, .6)}:host([theme="shitti"]){--pnb-bg: #292a56;--pnb-surface: #5656ac;--pnb-surface-2: #454689;--pnb-sunken: #1a1a32;--pnb-line: #6d6dc5;--pnb-text: #ffffff;--pnb-text-quiet: rgba(255, 255, 255, .78);--pnb-accent: #1fc7d4;--pnb-on-accent: #12132b;--pnb-danger: #ff7a6b;--pnb-shadow: 0 6px 16px rgba(0, 0, 0, .28);--pnb-scrim: rgba(10, 10, 30, .6)}*,*:before,*:after{box-sizing:border-box}button,input,textarea{font:inherit;color:inherit}button{cursor:pointer;border:0;background:none;padding:0}:focus-visible{outline:2px solid var(--pnb-accent);outline-offset:2px}.app{--_top: 0px;--_bottom: 0px;position:relative;display:flex;flex-direction:column;height:100%;min-height:320px;background:var(--pnb-bg);overflow:hidden}.bar{display:grid;grid-template-columns:48px 1fr 48px;align-items:center;min-height:56px;padding:0 4px;padding-top:var(--_top);flex-shrink:0}.bar__title{margin:0;text-align:center;font-size:18px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.icon-btn{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;color:var(--pnb-text)}.icon-btn:active{background:var(--pnb-surface)}.filters{display:flex;gap:8px;padding:4px 16px 12px;flex-shrink:0;flex-wrap:wrap}.chip-pick{display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:999px;background:var(--pnb-surface);color:var(--pnb-text-quiet);font-size:14px;font-weight:700}.chip-pick[aria-pressed=true],.chip-pick[aria-checked=true]{background:var(--pnb-text);color:var(--pnb-bg)}.scroll{flex:1;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:0 16px calc(96px + var(--_bottom))}.list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}.empty{margin:48px auto 0;max-width:280px;text-align:center;color:var(--pnb-text-quiet);line-height:1.45}.empty .text-btn{margin-top:12px}.card{position:relative;padding:16px;border-radius:var(--pnb-radius);background:var(--pnb-surface);border:1px solid var(--pnb-line)}.card--owner{cursor:pointer}.card--hidden{opacity:.6}.card__head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.badge{display:inline-flex;align-items:center;gap:6px;padding:4px 10px 4px 4px;border-radius:999px;background:var(--pnb-surface-2);font-size:12px;font-weight:700}.badge__dot{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;color:#fff}.badge__dot--bug{background:var(--pnb-bug)}.badge__dot--idea{background:var(--pnb-idea)}.badge__dot--planned{background:var(--pnb-planned)}.badge__dot--done{background:var(--pnb-done)}.badge__dot--declined{background:var(--pnb-declined)}.card__off{font-size:12px;font-weight:700;color:var(--pnb-danger)}.card__when{margin-left:auto;font-size:12px;color:var(--pnb-text-quiet)}.card__text{margin:12px 0 0;font-size:16px;line-height:1.4;overflow-wrap:anywhere;white-space:pre-wrap}.card__reply{margin-top:12px;padding:10px 12px;border-radius:var(--pnb-radius);background:var(--pnb-bg);border-left:3px solid var(--pnb-accent)}.card__reply-who{font-size:12px;font-weight:700;color:var(--pnb-text-quiet)}.card__reply-text{margin:4px 0 0;font-size:14px;line-height:1.4;overflow-wrap:anywhere;white-space:pre-wrap}.card__foot{display:flex;align-items:center;gap:8px;margin-top:12px}.card__who{flex:1;min-width:0;font-size:14px;color:var(--pnb-text-quiet);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.card__bin{width:36px;height:36px;color:var(--pnb-text-quiet)}.vote{display:inline-flex;align-items:center;gap:6px;min-width:56px;height:36px;padding:0 12px;border-radius:999px;background:var(--pnb-surface-2);font-size:14px;font-weight:700;justify-content:center}.vote[aria-pressed=true]{background:var(--pnb-accent);color:var(--pnb-on-accent)}.order{position:absolute;left:0;right:0;bottom:calc(20px + var(--_bottom));display:flex;justify-content:center;pointer-events:none;transition:transform .22s ease,opacity .16s ease}.order--away{transform:translateY(80px);opacity:0}.order__pill{pointer-events:auto;display:grid;grid-template-columns:1fr 1fr;width:min(240px,calc(100% - 32px));height:48px;padding:4px;border-radius:999px;background:var(--pnb-sunken);box-shadow:var(--pnb-shadow)}.order__tab{border-radius:999px;font-weight:700;font-size:15px;color:var(--pnb-text-quiet)}.order__tab[aria-selected=true]{background:var(--pnb-surface);color:var(--pnb-text)}.pager{display:flex;justify-content:center;gap:6px;margin-top:20px}.pager button{min-width:36px;height:36px;border-radius:999px;color:var(--pnb-text-quiet);font-weight:700}.pager button[aria-current=page]{background:var(--pnb-surface);color:var(--pnb-text)}.sign-in{display:flex;justify-content:center;margin-top:16px}.sign-in .text-btn{font-size:14px;text-decoration:underline;text-underline-offset:3px}.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;height:48px;padding:0 24px;border-radius:999px;background:var(--pnb-accent);color:var(--pnb-on-accent);font-size:16px;font-weight:700}.btn:disabled{opacity:.45;cursor:default}.btn--danger{background:var(--pnb-danger);color:#fff}.text-btn{display:inline-block;padding:12px 16px;font-weight:700;color:var(--pnb-text-quiet)}.spinner{width:20px;height:20px;border-radius:50%;border:2.5px solid currentColor;border-right-color:transparent;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.compose{display:flex;flex-direction:column;gap:8px;padding-bottom:24px}.label{margin-top:12px;font-size:14px;font-weight:700}.kinds{display:flex;gap:8px}.chip-pick .badge__dot{width:20px;height:20px}.public{margin:12px 0 0;font-size:14px;color:var(--pnb-text-quiet)}.field{width:100%;min-height:140px;padding:12px 14px;border-radius:var(--pnb-radius);border:1px solid var(--pnb-line);background:var(--pnb-surface);font-size:16px;line-height:1.4;resize:vertical}.field:focus{outline:none;border-color:var(--pnb-accent)}.input{width:100%;height:44px;padding:0 14px;border-radius:var(--pnb-radius);border:1px solid var(--pnb-line);background:var(--pnb-surface);font-size:16px}.input:focus{outline:none;border-color:var(--pnb-accent)}.count{align-self:flex-end;font-size:12px;color:var(--pnb-text-quiet)}.alike{margin-top:8px;padding:12px;border-radius:var(--pnb-radius);background:var(--pnb-surface)}.alike__note{margin:4px 0 8px;font-size:13px;color:var(--pnb-text-quiet)}.alike__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}.alike__row{display:flex;align-items:center;gap:12px}.alike__text{flex:1;min-width:0;font-size:14px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.switch-row{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:16px}.switch-row__label{font-weight:700}.switch{position:relative;flex-shrink:0;width:48px;height:28px;border-radius:999px;background:var(--pnb-surface-2);border:1px solid var(--pnb-line);transition:background .16s ease}.switch:after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:var(--pnb-text-quiet);transition:transform .16s ease,background .16s ease}.switch[aria-checked=true]{background:var(--pnb-accent);border-color:var(--pnb-accent)}.switch[aria-checked=true]:after{transform:translate(20px);background:var(--pnb-on-accent)}.note{margin:4px 0 0;font-size:12px;line-height:1.45;color:var(--pnb-text-quiet)}.send{display:flex;flex-direction:column;align-items:center;gap:8px;margin-top:20px}.left{font-size:13px;color:var(--pnb-text-quiet);text-align:center}.left--bad{color:var(--pnb-danger)}.scrim{position:absolute;inset:0;z-index:10;display:flex;align-items:flex-end;background:var(--pnb-scrim);animation:fade-in .18s ease}.sheet{width:100%;max-height:90%;overflow-y:auto;padding:24px 24px calc(24px + var(--_bottom));border-radius:var(--pnb-radius-sheet) var(--pnb-radius-sheet) 0 0;background:var(--pnb-bg);animation:rise .22s cubic-bezier(.2,.8,.2,1)}.sheet__title{margin:0;font-size:20px;font-weight:700}.sheet__quote{margin:8px 0 0;color:var(--pnb-text-quiet);overflow-wrap:anywhere}.sheet__actions{display:flex;flex-direction:column;align-items:center;gap:4px;margin-top:24px}.states{display:flex;flex-wrap:wrap;gap:8px}.context{margin:12px 0 0;padding:10px 12px;border-radius:var(--pnb-radius);background:var(--pnb-surface);font-size:13px;line-height:1.5}.context dt{font-weight:700;display:inline}.context dd{display:inline;margin:0 0 0 4px;color:var(--pnb-text-quiet)}.hide-btn{margin-top:16px;font-weight:700;color:var(--pnb-danger)}.toast{position:absolute;left:16px;right:16px;bottom:calc(84px + var(--_bottom));z-index:20;padding:14px 16px;border-radius:var(--pnb-radius);background:var(--pnb-text);color:var(--pnb-bg);font-weight:700;text-align:center;box-shadow:var(--pnb-shadow);animation:rise .22s cubic-bezier(.2,.8,.2,1)}.overlay{position:fixed;inset:0;z-index:var(--pnb-z);animation:slide-up .28s cubic-bezier(.2,.8,.2,1)}.overlay .app{--_top: var(--pnb-inset-top);--_bottom: var(--pnb-inset-bottom)}.overlay--leaving{animation:slide-down .22s cubic-bezier(.4,0,1,1) forwards}.fab{position:fixed;right:calc(16px + env(safe-area-inset-right,0px));bottom:calc(16px + var(--pnb-inset-bottom));z-index:calc(var(--pnb-z) - 1);display:inline-flex;align-items:center;gap:8px;height:44px;padding:0 16px 0 12px;border-radius:999px;background:var(--pnb-accent);color:var(--pnb-on-accent);font-weight:700;font-size:15px;box-shadow:var(--pnb-shadow)}@keyframes fade-in{0%{opacity:0}}@keyframes rise{0%{transform:translateY(24px);opacity:0}}@keyframes slide-up{0%{transform:translateY(100%)}}@keyframes slide-down{to{transform:translateY(100%)}}@media (prefers-reduced-motion: reduce){.overlay,.overlay--leaving,.scrim,.sheet,.toast{animation:none}.order{transition:opacity .16s ease}.order--away{transform:none}.spinner{animation-duration:1.6s}}',Ze="please-no-bugs";class Qe extends HTMLElement{constructor(){super(...arguments);W(this,H);W(this,ne,null);W(this,B,null);W(this,te,null);W(this,Z,"");W(this,re);W(this,ae);W(this,oe);W(this,ie);W(this,se);W(this,ge)}get signer(){return C(this,re)}set signer(t){F(this,re,t),F(this,Z,""),Y(this,H,X).call(this)}get appLogin(){return C(this,ae)}set appLogin(t){F(this,ae,t),F(this,Z,""),Y(this,H,X).call(this)}get context(){return C(this,oe)}set context(t){F(this,oe,t),Y(this,H,X).call(this)}get noise(){return C(this,ie)}set noise(t){F(this,ie,t),Y(this,H,X).call(this)}get strings(){return C(this,se)}set strings(t){F(this,se,t),Y(this,H,X).call(this)}connectedCallback(){if(!C(this,ne)){F(this,ne,this.attachShadow({mode:"open"}));const t=document.createElement("style");t.textContent=Wt,F(this,B,document.createElement("div")),C(this,B).style.height="100%",C(this,ne).append(t,C(this,B))}Y(this,H,X).call(this)}disconnectedCallback(){C(this,B)&&pe(null,C(this,B))}attributeChangedCallback(t){(t==="project"||t==="server")&&F(this,Z,""),t==="accent"&&Y(this,H,Jn).call(this),Y(this,H,X).call(this)}close(){this.dispatchEvent(new CustomEvent("pleasenobugs:close",{bubbles:!0,composed:!0}))}}ne=new WeakMap,B=new WeakMap,te=new WeakMap,Z=new WeakMap,re=new WeakMap,ae=new WeakMap,oe=new WeakMap,ie=new WeakMap,se=new WeakMap,ge=new WeakMap,H=new WeakSet,Jn=function(){const t=this.getAttribute("accent");t?(this.style.setProperty("--pnb-accent",t),this.style.setProperty("--pnb-on-accent",Un(t))):(this.style.removeProperty("--pnb-accent"),this.style.removeProperty("--pnb-on-accent"))},X=function(){if(!C(this,B)||!this.isConnected)return;const t=this.getAttribute("project"),r=this.getAttribute("server");if(!t||!r){pe(null,C(this,B)),clearTimeout(C(this,ge)),F(this,ge,setTimeout(()=>{(!this.getAttribute("project")||!this.getAttribute("server"))&&console.warn("[pleasenobugs] <please-no-bugs> needs both a `project` and a `server` attribute.")},1e3));return}const a=`${r}|${t}`;(!C(this,te)||C(this,Z)!==a)&&(F(this,te,Ln({server:r,project:t,signer:C(this,re),appLogin:C(this,ae)})),F(this,Z,a));const o=xt(this.getAttribute("lang")),d=this.getAttribute("mode")??"inline",c={client:C(this,te),t:yt(o,C(this,se)),locale:o,appName:this.getAttribute("app-name")??void 0,suggestName:this.getAttribute("name")??void 0,context:C(this,oe),noise:C(this,ie),onPosted:b=>this.dispatchEvent(new CustomEvent("pleasenobugs:posted",{detail:b,bubbles:!0,composed:!0}))};d==="floating"?pe(i(Ut,{app:c,label:c.t("board.open")}),C(this,B)):d==="overlay"?pe(i(Wn,{app:c,onGone:()=>this.close()}),C(this,B)):pe(i(Hn,{...c}),C(this,B))},Yn(Qe,"observedAttributes",["project","server","mode","lang","theme","accent","app-name","name"]);function Wn({app:e,onGone:n}){const[t,r]=I(!1);return i("div",{class:`overlay${t?" overlay--leaving":""}`,onAnimationEnd:o=>{t&&o.target===o.currentTarget&&n()},children:i(Hn,{...e,onClose:()=>{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n();r(!0)}})})}function Ut({app:e,label:n}){const[t,r]=I(!1);return t?i(Wn,{app:e,onGone:()=>r(!1)}):i("button",{type:"button",class:"fab",onClick:()=>r(!0),children:[i(zt,{}),n]})}function Un(e){const n=e.trim().replace("#",""),t=n.length===3?[...n].map(o=>o+o).join(""):n.slice(0,6);if(!/^[0-9a-f]{6}$/i.test(t))return"#ffffff";const r=o=>{const d=parseInt(t.slice(o,o+2),16)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4},a=.2126*r(0)+.7152*r(2)+.0722*r(4);return 1.05/(a+.05)>=(a+.05)/.05?"#ffffff":"#111118"}function Vt(){typeof customElements<"u"&&!customElements.get(Ze)&&customElements.define(Ze,Qe)}Vt();function Rt(e){const n=document.createElement(Ze);n.setAttribute("mode","overlay"),n.setAttribute("project",e.project),n.setAttribute("server",e.server),e.lang&&n.setAttribute("lang",e.lang),e.theme&&n.setAttribute("theme",e.theme),e.accent&&n.setAttribute("accent",e.accent),e.appName&&n.setAttribute("app-name",e.appName),e.name&&n.setAttribute("name",e.name),n.signer=e.signer,n.appLogin=e.appLogin,n.context=e.context,n.noise=e.noise,n.strings=e.strings;const t=()=>n.remove();return n.addEventListener("pleasenobugs:close",t,{once:!0}),document.body.append(n),()=>n.close()}return v.PleaseNoBugsElement=Qe,v.SignerError=he,v.createClient=Ln,v.createMatcher=Dn,v.insideNimiqPay=Re,v.nimiqPaySigner=In,v.open=Rt,v.readableOn=Un,v.sortPosts=qn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),v}({});
@@ -0,0 +1,125 @@
1
+ import { type Answer, type AppLogin, type BoardRead, type ErrorCode, type Me, type PostContext, type PostKind, type PostStatus } from '@pleasenobugs/core';
2
+ import { type Signer } from './signer.js';
3
+ export { insideNimiqPay, nimiqPaySigner, SignerError, type Signer, type SignedMessage } from './signer.js';
4
+ export { createMatcher, sortPosts } from '@pleasenobugs/core';
5
+ export type * from '@pleasenobugs/core';
6
+ export interface ClientOptions {
7
+ /** The API, e.g. `https://feedback.example.com` (no `/v1`). */
8
+ server: string;
9
+ /** The project id from the dashboard or `create-project`. */
10
+ project: string;
11
+ /**
12
+ * How to get a signature. Defaults to Nimiq Pay's own wallet when running
13
+ * inside it; outside Nimiq Pay, without one, the board is read-only.
14
+ *
15
+ * `null` means never ask, even inside Nimiq Pay: for a background read (a
16
+ * badge, a bell) that must not put a wallet prompt in front of somebody who
17
+ * did not tap anything.
18
+ */
19
+ signer?: Signer | null;
20
+ /**
21
+ * Your app's own wallet login, reused so nobody signs twice. Only works on a
22
+ * project whose owner listed that exact message (`loginMessages`). A
23
+ * function is read on every request, so a login or logout in your app is
24
+ * picked up without recreating the client.
25
+ *
26
+ * Tried before the signer. If the server refuses it, the client stops using
27
+ * it for this session and falls back to the signer.
28
+ */
29
+ appLogin?: AppLogin | null | (() => AppLogin | null | undefined);
30
+ /** The origin written into the signed message. Defaults to this page's. */
31
+ origin?: string;
32
+ /**
33
+ * Where the proof is remembered between visits, so somebody signs once a
34
+ * month rather than once a visit. Defaults to `localStorage`; `null` keeps
35
+ * it in memory only.
36
+ */
37
+ storage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'> | null;
38
+ /** For tests and unusual runtimes. */
39
+ fetch?: typeof fetch;
40
+ }
41
+ /**
42
+ * Every call answers one of these rather than throwing, so a caller handles a
43
+ * refusal with an `if` instead of a try. `network` is the server not
44
+ * answering at all, `no_signer` is "there is no wallet to ask", `declined` is
45
+ * the user saying no to the signature.
46
+ */
47
+ export type Result<T> = {
48
+ ok: true;
49
+ data: T;
50
+ } | {
51
+ ok: false;
52
+ status: number;
53
+ error: ErrorCode | 'network' | 'no_signer' | 'declined';
54
+ body?: unknown;
55
+ };
56
+ /**
57
+ * A talking-to-the-server object for one project. Everything the widget does
58
+ * goes through this, so anything the widget can do, a developer building their
59
+ * own UI can do too.
60
+ *
61
+ * **It signs as late as possible.** Reading never asks the wallet: a stored
62
+ * proof is sent if there is one and the board comes back as a stranger's if
63
+ * there is not. The first *write* is what asks, because that is the moment the
64
+ * user has a reason to tap "sign". After that the proof is remembered for its
65
+ * lifetime (30 days).
66
+ *
67
+ * **A refused proof is retried once, freshly signed.** A proof can stop working
68
+ * without the client knowing (the owner changed the project's origins, the
69
+ * server restarted with a different clock), and the honest response to that is
70
+ * to ask the wallet again, not to fail a vote.
71
+ *
72
+ * @example
73
+ * const client = createClient({ server: 'https://feedback.example.com', project: 'k7q2m9xw4p' });
74
+ * const board = await client.board();
75
+ * if (board.ok) render(sortPosts(board.data.posts, 'top'));
76
+ * await client.post({ id: crypto.randomUUID(), kind: 'idea', text: 'Dark mode' });
77
+ */
78
+ export declare function createClient(options: ClientOptions): {
79
+ /** The project this client talks to. */
80
+ project: string;
81
+ /** Whether the user can be signed in at all: a signer, or an app login. */
82
+ readonly canSign: boolean;
83
+ /** The signed-in address, if a proof is stored. */
84
+ address(): string | null;
85
+ signIn: () => Promise<Result<string>>;
86
+ /** Forget the stored proof. The next write asks the wallet again. */
87
+ signOut(): void;
88
+ /** The whole board, plus `me` when signed in. Never prompts. */
89
+ board: () => Promise<Result<BoardRead>>;
90
+ me: () => Promise<Result<Me>>;
91
+ answers: () => Promise<Result<{
92
+ answers: Answer[];
93
+ }>>;
94
+ post: (p: {
95
+ id: string;
96
+ kind: PostKind;
97
+ text: string;
98
+ anon?: boolean;
99
+ context?: PostContext;
100
+ }) => Promise<Result<{
101
+ ok: true;
102
+ left: number;
103
+ }>>;
104
+ vote: (id: string, up: boolean) => Promise<Result<{
105
+ ok: true;
106
+ votes: number;
107
+ voted: boolean;
108
+ }>>;
109
+ remove: (id: string) => Promise<Result<{
110
+ ok: true;
111
+ }>>;
112
+ setName: (name: string) => Promise<Result<{
113
+ ok: true;
114
+ name?: string;
115
+ }>>;
116
+ manage: (id: string, change: {
117
+ status?: PostStatus;
118
+ reply?: string;
119
+ hidden?: boolean;
120
+ }) => Promise<Result<{
121
+ ok: true;
122
+ }>>;
123
+ };
124
+ export type Client = ReturnType<typeof createClient>;
125
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EAEd,KAAK,EAAE,EACP,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA+C,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC9D,mBAAmB,oBAAoB,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACjE,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,GAAG,IAAI,CAAC;IACrE,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAChB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACrB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa;IAiI/C,wCAAwC;;IAExC,2EAA2E;;IAI3E,mDAAmD;eACxC,MAAM,GAAG,IAAI;kBAhFP,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAqFxC,qEAAqE;;IAKrE,gEAAgE;;;;iBAG9B,MAAM,EAAE;;cAEhC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,WAAW,CAAA;KAAE;YAC7E,IAAI;cAAQ,MAAM;;eACvB,MAAM,MAAM,OAAO;YACd,IAAI;eAAS,MAAM;eAAS,OAAO;;iBAItC,MAAM;YAAmB,IAAI;;oBAC1B,MAAM;YACN,IAAI;eAAS,MAAM;;iBACtB,MAAM,UAAU;QAAE,MAAM,CAAC,EAAE,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;YACtE,IAAI;;EAEvB;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { AppLogin, PostContext } from '@pleasenobugs/core';
2
+ import { type Strings } from './i18n.js';
3
+ import type { Signer } from './signer.js';
4
+ export declare const TAG = "please-no-bugs";
5
+ /**
6
+ * `<please-no-bugs>`: the whole board as one tag.
7
+ *
8
+ * Three ways to show it, picked by the `mode` attribute:
9
+ *
10
+ * - `inline` (default): fills the element. Give it a height, or it grows with
11
+ * its contents.
12
+ * - `floating`: a small button in the corner that opens the board over the
13
+ * whole screen. The "paste one line and done" route.
14
+ * - `overlay`: the board over the whole screen, now. What {@link open} uses.
15
+ *
16
+ * Attributes: `project` and `server` (both required), `mode`, `lang`,
17
+ * `theme` (`auto` | `light` | `dark` | `shitti`), `accent` (a colour),
18
+ * `app-name`, `name` (a display name to suggest).
19
+ *
20
+ * Properties, for things an attribute cannot carry: `signer`, `appLogin`,
21
+ * `context`, `noise`, `strings`.
22
+ *
23
+ * Events: `pleasenobugs:posted` (`detail: { id, kind }`) and
24
+ * `pleasenobugs:close`.
25
+ *
26
+ * **It renders into a shadow root**, so the host app's CSS cannot reach in and
27
+ * break it and its CSS cannot leak out. Theming goes through the `--pnb-*`
28
+ * custom properties, which do cross that boundary on purpose.
29
+ */
30
+ export declare class PleaseNoBugsElement extends HTMLElement {
31
+ #private;
32
+ static observedAttributes: string[];
33
+ /** How to sign outside Nimiq Pay. Inside it the widget signs by itself. */
34
+ get signer(): Signer | undefined;
35
+ set signer(v: Signer | undefined);
36
+ /**
37
+ * Your app's own wallet login, so nobody signs twice: `{ address, publicKey,
38
+ * signature, message }`. Needs the project to list that message. Set it to
39
+ * null on logout.
40
+ */
41
+ get appLogin(): AppLogin | null | undefined;
42
+ set appLogin(v: AppLogin | null | undefined);
43
+ /** Sent with every bug report, to owners only: `{ version: '1.4.0' }`. */
44
+ get context(): PostContext | undefined;
45
+ set context(v: PostContext | undefined);
46
+ /** Words common in your app, so "said already?" ignores them: `['nim', 'wallet']`. */
47
+ get noise(): string[] | undefined;
48
+ set noise(v: string[] | undefined);
49
+ /** Override any string, or supply a language: `{ 'board.title': 'Ideas box' }`. */
50
+ get strings(): Strings | undefined;
51
+ set strings(v: Strings | undefined);
52
+ connectedCallback(): void;
53
+ disconnectedCallback(): void;
54
+ attributeChangedCallback(name: string): void;
55
+ /** Close an overlay: slide it away, then tell the page. */
56
+ close(): void;
57
+ }
58
+ /**
59
+ * Black or white, whichever reads better on `color`. So `accent="#ffd400"`
60
+ * gets dark text and `accent="#1f2348"` gets white, without the developer
61
+ * having to know there was a question.
62
+ */
63
+ export declare function readableOn(color: string): string;
64
+ /** Register the element once, however many times the script is loaded. */
65
+ export declare function define(): void;
66
+ declare global {
67
+ interface HTMLElementTagNameMap {
68
+ 'please-no-bugs': PleaseNoBugsElement;
69
+ }
70
+ }
71
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/element.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAY,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C,eAAO,MAAM,GAAG,mBAAmB,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;;IAClD,MAAM,CAAC,kBAAkB,WAAgF;IAazG,2EAA2E;IAC3E,IAAI,MAAM,IAGI,MAAM,GAAG,SAAS,CAD/B;IACD,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAI/B;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAGI,QAAQ,GAAG,IAAI,GAAG,SAAS,CAD1C;IACD,IAAI,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EAK1C;IAED,0EAA0E;IAC1E,IAAI,OAAO,IAGI,WAAW,GAAG,SAAS,CADrC;IACD,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW,GAAG,SAAS,EAGrC;IAED,sFAAsF;IACtF,IAAI,KAAK,IAGI,MAAM,EAAE,GAAG,SAAS,CADhC;IACD,IAAI,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,EAGhC;IAED,mFAAmF;IACnF,IAAI,OAAO,IAGI,OAAO,GAAG,SAAS,CADjC;IACD,IAAI,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,EAGjC;IAED,iBAAiB;IAYjB,oBAAoB;IAIpB,wBAAwB,CAAC,IAAI,EAAE,MAAM;IAMrC,2DAA2D;IAC3D,KAAK;CA4DN;AAoCD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWhD;AAED,0EAA0E;AAC1E,wBAAgB,MAAM,SAIrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,mBAAmB,CAAC;KACvC;CACF"}