feedkeeper 0.47.5 → 0.47.7
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.
- package/package.json +1 -1
- package/server/dist/feeds/content/patterns/boilerplate/en.js +4 -0
- package/server/dist/securityHeaders.js +1 -0
- package/server/package.json +1 -1
- package/web/dist/assets/index-Bx_W11qP.css +2 -0
- package/web/dist/assets/{index-eKFZZfLk.js → index-CMZF4lyi.js} +9 -9
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-DWh9ZM11.css +0 -2
|
@@ -91,17 +91,17 @@ function ts(e,t){this.v=e,this.k=t}function ns(e,t){(t==null||t>e.length)&&(t=e.
|
|
|
91
91
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}
|
|
92
92
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
93
93
|
function os(e,t){return rs(e)||is(e,t)||ss(e,t)||as()}function ss(e,t){if(e){if(typeof e==`string`)return ns(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ns(e,t):void 0}}function cs(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ts;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}cs.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},cs.prototype.next=function(e){return this._invoke(`next`,e)},cs.prototype.throw=function(e){return this._invoke(`throw`,e)},cs.prototype.return=function(e){return this._invoke(`return`,e)};var ls=Object.entries,us=Object.setPrototypeOf,ds=Object.isFrozen,fs=Object.getPrototypeOf,ps=Object.getOwnPropertyDescriptor,ms=Object.freeze,hs=Object.seal,gs=Object.create,_s=typeof Reflect<`u`&&Reflect,vs=_s.apply,ys=_s.construct;ms||=function(e){return e},hs||=function(e){return e},vs||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ys||=function(e){return new e(...[...arguments].slice(1))};var bs=Ws(Array.prototype.forEach);Array.prototype.indexOf;var xs=Ws(Array.prototype.lastIndexOf),Ss=Ws(Array.prototype.pop),Cs=Ws(Array.prototype.push),ws=Ws(Array.prototype.slice),Ts=Ws(Array.prototype.splice),Es=Array.isArray,Ds=Gs(Set),Os=Ws(Set.prototype.add),ks=Ws(Set.prototype.has),As=Ws(String.prototype.toLowerCase),js=Ws(String.prototype.toString),Ms=Ws(String.prototype.match),Ns=Ws(String.prototype.replace),Ps=Ws(String.prototype.indexOf),Fs=Ws(String.prototype.trim),Is=Ws(Number.prototype.toString),Ls=Ws(Boolean.prototype.toString),Rs=typeof BigInt>`u`?null:Ws(BigInt.prototype.toString),zs=typeof Symbol>`u`?null:Ws(Symbol.prototype.toString),Bs=Ws(Object.prototype.hasOwnProperty),Vs=Ws(Object.prototype.toString),Hs=Ws(RegExp.prototype.test),Us=Gs(TypeError);function Ws(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return vs(e,t,n)}}function Gs(e){return function(){return ys(e,[...arguments])}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:As;if(us&&us(e,null),!Es(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ds(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ks(e){for(let t=0;t<e.length;t++)Bs(e,t)||(e[t]=null);return e}function qs(e){let t=gs(null);for(let r of ls(e)){var n=os(r,2);let i=n[0],a=n[1];Bs(e,i)&&(t[i]=Es(a)?Ks(a):a&&typeof a==`object`&&a.constructor===Object?qs(a):a)}return t}function Js(e){switch(typeof e){case`string`:return e;case`number`:return Is(e);case`boolean`:return Ls(e);case`bigint`:return Rs?Rs(e):`0`;case`symbol`:return zs?zs(e):`Symbol()`;case`undefined`:return Vs(e);case`function`:case`object`:{if(e===null)return Vs(e);let t=e,n=Ys(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Vs(e)}return Vs(e)}default:return Vs(e)}}function Ys(e,t){for(;e!==null;){let n=ps(e,t);if(n){if(n.get)return Ws(n.get);if(typeof n.value==`function`)return Ws(n.value)}e=fs(e)}function n(){return null}return n}function Xs(e,t){for(;e!==null;){let n=ps(e,t);if(n)return n.get?Ws(n.get):null;e=fs(e)}return null}function Zs(e){try{return Hs(e,``),!0}catch{return!1}}var Qs=ms(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),$s=ms(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),ec=ms([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),tc=ms([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),nc=ms(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),rc=ms([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),ic=ms([`#text`]),ac=ms(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),oc=ms(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),sc=ms(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),cc=ms([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),lc=hs(/{{[\w\W]*|^[\w\W]*}}/g),uc=hs(/<%[\w\W]*|^[\w\W]*%>/g),dc=hs(/\${[\w\W]*/g),fc=hs(/^data-[\-\w.\u00B7-\uFFFF]+$/),pc=hs(/^aria-[\-\w]+$/),mc=hs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),hc=hs(/^(?:\w+script|data):/i),gc=hs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),_c=hs(/^html$/i),vc=hs(/^[a-z][.\w]*(-[.\w]+)+$/i),yc=hs(/<[/\w!]/g),bc=hs(/<[/\w]/g),xc=hs(/<\/no(script|embed|frames)/i),Sc=hs(/\/>/i),Cc={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wc=ms(K({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),Tc=function(){return typeof window>`u`?null:window},Ec=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Dc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Oc=function(e,t,n,r){return Bs(e,t)&&Es(e[t])?K(r.base?qs(r.base):{},e[t],r.transform):n},kc=function(e,t,n){let r=Bs(e,t)?e[t]:void 0;return r&&typeof r==`object`?qs(r):n()};function Ac(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tc(),t=e=>Ac(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==Cc.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Ys(d,`cloneNode`),p=Ys(d,`remove`),m=Ys(d,`removeAttributeNode`),h=Ys(d,`nextSibling`),g=Ys(d,`childNodes`),_=Ys(d,`parentNode`),v=Ys(d,`shadowRoot`),y=Ys(d,`attributes`),b=o&&o.prototype?Ys(o.prototype,`nodeType`):null,x=o&&o.prototype?Ys(o.prototype,`nodeName`):null,S=o&&o.prototype?Ys(o.prototype,`ownerDocument`):null,C=function(e){return b?b(e):e.nodeType},w=function(e){return x?x(e):e.nodeName},T=Xs(d,`namespaceURI`),E=function(e){return T?T(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let D,O=``,k,A=!1,j=0,ee=function(){if(j>0)throw Us(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},te=function(e){ee(),j++;try{return D.createHTML(e)}finally{j--}},ne=function(e){ee(),j++;try{return D.createScriptURL(e)}finally{j--}},re=function(){return A||=(k=Ec(u,i),!0),k},M=n,ie=M.implementation,ae=M.createNodeIterator,oe=M.createDocumentFragment,se=M.getElementsByTagName,ce=r.importNode,N=Dc();t.isSupported=typeof ls==`function`&&typeof _==`function`&&ie&&ie.createHTMLDocument!==void 0;let le=lc,ue=uc,de=dc,fe=fc,pe=pc,me=hc,he=gc,ge=vc,P=mc,F=null,_e=K({},[...Qs,...$s,...ec,...nc,...ic]),I=null,ve=K({},[...ac,...oc,...sc,...cc]),ye=Object.seal(gs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),be=null,L=null,xe=Object.seal(gs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Se=!0,Ce=!0,we=!1,Te=!0,Ee=!1,De=!0,Oe=!1,ke=!1,Ae=null,je=null,Me=!1,Ne=!1,Pe=!1,Fe=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve=null,He={},Ue=null,We=K({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ge=null,Ke=K({},[`audio`,`video`,`img`,`source`,`image`,`track`]),qe=null,Je=K({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ye=`http://www.w3.org/1998/Math/MathML`,Xe=`http://www.w3.org/2000/svg`,R=`http://www.w3.org/1999/xhtml`,Ze=R,Qe=!1,$e=null,et=K({},[Ye,Xe,R],js),tt=ms([`mi`,`mo`,`mn`,`ms`,`mtext`]),nt=K({},tt),rt=ms([`annotation-xml`]),it=K({},rt),at=K({},[`title`,`style`,`font`,`a`,`script`]),ot=null,st=[`application/xhtml+xml`,`text/html`],ct=null,z=null,lt=n.createElement(`form`),ut=function(e){return e instanceof RegExp||e instanceof Function},dt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(z&&z===e)return;e&&typeof e==`object`||(e={}),e=qs(e),ot=st.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ct=ot===`application/xhtml+xml`?js:As,F=Oc(e,`ALLOWED_TAGS`,_e,{transform:ct}),I=Oc(e,`ALLOWED_ATTR`,ve,{transform:ct}),$e=Oc(e,`ALLOWED_NAMESPACES`,et,{transform:js}),qe=Oc(e,`ADD_URI_SAFE_ATTR`,Je,{transform:ct,base:Je}),Ge=Oc(e,`ADD_DATA_URI_TAGS`,Ke,{transform:ct,base:Ke}),Ue=Oc(e,`FORBID_CONTENTS`,We,{transform:ct}),be=Oc(e,`FORBID_TAGS`,qs({}),{transform:ct}),L=Oc(e,`FORBID_ATTR`,qs({}),{transform:ct}),He=Bs(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?qs(e.USE_PROFILES):e.USE_PROFILES:!1,Se=e.ALLOW_ARIA_ATTR!==!1,Ce=e.ALLOW_DATA_ATTR!==!1,we=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Te=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=e.SAFE_FOR_TEMPLATES||!1,De=e.SAFE_FOR_XML!==!1,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,P=Zs(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:mc,Ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:R,nt=kc(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>K({},tt)),it=kc(e,`HTML_INTEGRATION_POINTS`,()=>K({},rt));let t=kc(e,`CUSTOM_ELEMENT_HANDLING`,()=>gs(null));if(ye=gs(null),Bs(t,`tagNameCheck`)&&ut(t.tagNameCheck)&&(ye.tagNameCheck=t.tagNameCheck),Bs(t,`attributeNameCheck`)&&ut(t.attributeNameCheck)&&(ye.attributeNameCheck=t.attributeNameCheck),Bs(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(ye.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),hs(ye),Ee&&(Ce=!1),Pe&&(Ne=!0),He&&(F=K({},ic),I=gs(null),He.html===!0&&(K(F,Qs),K(I,ac)),He.svg===!0&&(K(F,$s),K(I,oc),K(I,cc)),He.svgFilters===!0&&(K(F,ec),K(I,oc),K(I,cc)),He.mathMl===!0&&(K(F,nc),K(I,sc),K(I,cc))),xe.tagCheck=null,xe.attributeCheck=null,Bs(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?xe.tagCheck=e.ADD_TAGS:Es(e.ADD_TAGS)&&(F===_e&&(F=qs(F)),K(F,e.ADD_TAGS,ct))),Bs(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?xe.attributeCheck=e.ADD_ATTR:Es(e.ADD_ATTR)&&(I===ve&&(I=qs(I)),K(I,e.ADD_ATTR,ct))),Bs(e,`ADD_FORBID_CONTENTS`)&&Es(e.ADD_FORBID_CONTENTS)&&(Ue===We&&(Ue=qs(Ue)),K(Ue,e.ADD_FORBID_CONTENTS,ct)),ze&&(F[`#text`]=!0),Oe&&K(F,[`html`,`head`,`body`]),F.table&&(K(F,[`tbody`]),delete be.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Us(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Us(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=D;D=e.TRUSTED_TYPES_POLICY;try{O=te(``)}catch(e){throw D=t,e}}else e.TRUSTED_TYPES_POLICY===null?(D=void 0,O=``):(D===void 0&&(D=re()),D&&typeof O==`string`&&(O=te(``)));ms&&ms(e),z=e},ft=K({},[...$s,...ec,...tc]),pt=K({},[...nc,...rc]),mt=function(e,t,n){return t.namespaceURI===R?e===`svg`:t.namespaceURI===Ye?e===`svg`&&(n===`annotation-xml`||nt[n]):!!ft[e]},ht=function(e,t,n){return t.namespaceURI===R?e===`math`:t.namespaceURI===Xe?e===`math`&&it[n]:!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Xe&&!it[n]||t.namespaceURI===Ye&&!nt[n]?!1:!pt[e]&&(at[e]||!ft[e])},_t=function(e){let t=E(e),n=As(w(e)),r=_(e),i,a;return r&&C(r)===Cc.element?(i={namespaceURI:E(r)},a=As(w(r))):(i={namespaceURI:Ze},a=`template`),$e[t]?t===Xe?mt(n,i,a):t===Ye?ht(n,i,a):t===R?gt(n,i,a):!!(ot===`application/xhtml+xml`&&$e[t]):!1},vt=function(e){Cs(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw Us(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},yt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},bt=function(e){wt(e);let t=g(e);t&&bs(ws(t),e=>{try{p(e)}catch{}});let n=C(e)===Cc.element?y(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&yt(e,r,i)}},xt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}Cs(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ne||Pe)try{vt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},St=function(e){let t=y(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||I[ct(i)]||yt(e,r,i)}},Ct=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&C(e)===Cc.element){let t=v(e);zt(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},wt=function(e){Ct(e,e=>{C(e)===Cc.element&&St(e)})},Tt=function(e){let t=[];return Ct(e,e=>{t.push(e)},!0),t},Et=function(e,t){let n=Ds();bs(Tt(e),e=>{C(e)===Cc.element&&Os(n,e)}),bs(t,e=>{C(e)===Cc.element&&!ks(n,e)&&St(e)})},Dt=function(e,n){let r=!1;return bs(t.removed,t=>{t.element&&(r||=t.element===e,wt(t.element))}),Et(e,n),r},Ot=function(e,t){let n=Ve,r=null,i=()=>(r||(r=Ds(),bs(t,e=>{Os(r,e)})),r);for(let t=0;;t++){let r=Tt(e),a=[e],o=!1;if(bs(r,e=>{C(e)===Cc.documentFragment?Cs(a,e):!o&&!ks(n,e)&&(o=ks(i(),e))}),!o)return;if(t>=8)throw Us(`the tree kept changing during in-place sanitization; refusing to return it`);bs(a,(t,n)=>{kt(t,n>0,e,i())})}},kt=function(e,t,n,r){let i=Pt(e),a;for(;a=i.nextNode();)ks(r,a)&&!ks(Ve,a)&&(t&&Vt(N.uponSanitizeShadowNode,a,null),Kt(a,n),$t(a,n),zt(a.content)&&en(a.content))},At=function(e){Ve&&Os(Ve,e)},jt=function(e,t){return De?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Mt=function(e){De&&Ct(e,e=>{let t=C(e);if(t===Cc.processingInstruction||t===Cc.comment&&Hs(bc,e.data)){try{p(e)}catch{}return!1}if(t===Cc.element){let t=e,n=ct(w(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&jt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Nt=function(e){let t=null,r=null;if(Me)e=`<remove></remove>`+e;else{let t=Ms(e,/^[\r\n\t ]+/);r=t&&t[0]}ot===`application/xhtml+xml`&&Ze===R&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=D?te(e):e;if(Ze===R)try{t=new l().parseFromString(i,ot)}catch{}if(!t||!t.documentElement){t=ie.createDocument(Ze,`template`,null);try{t.documentElement.innerHTML=Qe?O:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ze===R?se.call(t,Oe?`html`:`body`)[0]:Oe?t.documentElement:a},Pt=function(e){let t=S?S(e):e.ownerDocument;return ae.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ft=function(e){return e=Ns(e,le,` `),e=Ns(e,ue,` `),e=Ns(e,de,` `),e},It=function(e){Lt(e);let t=e.querySelectorAll?.call(e,`template`);t&&bs(t,e=>{zt(e.content)&&It(e.content)})},Lt=function(e){e.normalize();let t=S?S(e):e.ownerDocument,n=ae.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Ft(r.data),r=n.nextNode()},Rt=function(e){let t=x?x(e):null;return typeof t!=`string`||ct(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==y(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==b(e)||e.childNodes!==g(e)},zt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return b(e)===Cc.documentFragment}catch{return!1}},Bt=function(e){if(!b||typeof e!=`object`||!e)return!1;try{return typeof b(e)==`number`}catch{return!1}};function Vt(e,n,r){e.length!==0&&bs(e,e=>{e.call(t,n,r,z)})}let Ht=function(e,t){return!!(De&&e.hasChildNodes()&&!Bt(e.firstElementChild)&&Hs(yc,e.textContent)&&Hs(yc,e.innerHTML)||De&&wc[t]&&C(e)===Cc.element&&E(e)===R&&(Bt(e.firstElementChild)||typeof e.textContent==`string`&&Hs(yc,e.textContent))||e.nodeType===Cc.processingInstruction||De&&e.nodeType===Cc.comment&&Hs(bc,e.data))},Ut=function(e,t){return e instanceof RegExp?Hs(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Wt=function(e,t,n){if(!be[t]&&Yt(t)&&Ut(ye.tagNameCheck,t))return!1;if(ze&&!Ue[t]&&!Ue[As(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return vt(e),!0},B=function(e,t,n,r){return e.length===0?t:t===n||t===r?qs(t):t},Gt=function(e,t){return e===t||_(e)!==null?!1:(Be&&wt(e),!0)},Kt=function(e,n){if(At(e),Vt(N.beforeSanitizeElements,e,null),Gt(e,n))return!0;if(Rt(e))return vt(e),!0;let r=ct(w(e));if(F=B(N.uponSanitizeElement,F,_e,Ae),Vt(N.uponSanitizeElement,e,{tagName:r,allowedTags:F}),Gt(e,n))return!0;if(Ht(e,r))return vt(e),!0;if(be[r]||!(xe.tagCheck instanceof Function&&xe.tagCheck(r))&&!F[r]){let t=Wt(e,r,n);return t===!1&&(Vt(N.afterSanitizeElements,e,null),Gt(e,n))?!0:t}if(C(e)===Cc.element&&!_t(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Hs(xc,e.innerHTML))return vt(e),!0;if(Ee&&e.nodeType===Cc.text){let n=Ft(e.textContent);e.textContent!==n&&(Cs(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Vt(N.afterSanitizeElements,e,null),Gt(e,n)},qt=function(e,t,r){if(L[t]||jt(t,e)||Ie&&(t===`id`||t===`name`)&&(r in n||r in lt))return!1;let i=I[t]||xe.attributeCheck instanceof Function&&xe.attributeCheck(t,e);return Ce&&Hs(fe,t)||Se&&Hs(pe,t)?!0:i?qe[t]||Hs(P,Ns(r,he,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ps(r,`data:`)===0&&Ge[e]||we&&!Hs(me,Ns(r,he,``))?!0:!r:Yt(e)&&Ut(ye.tagNameCheck,e)&&Ut(ye.attributeNameCheck,t,e)||t===`is`&&ye.allowCustomizedBuiltInElements&&Ut(ye.tagNameCheck,r)},Jt=K({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Yt=function(e){return!Jt[As(e)]&&Hs(ge,e)},Xt=function(e,t,n,r){if(D&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return te(r);case`TrustedScriptURL`:return ne(r)}return r},Zt=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Rt(e)||(vt(e),!1)}catch{return xt(t,e),!1}},Qt=function(e,t){return De&&Hs(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:As(e)===`attributename`&&Ms(t,`href`)!==null},$t=function(e,n){if(Vt(N.beforeSanitizeAttributes,e,null),Gt(e,n))return;let r=e.attributes;if(!r||Rt(e))return;I=B(N.uponSanitizeAttribute,I,ve,je);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=ct(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=ct(s),d=l,f=s===`value`?d:Fs(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Vt(N.uponSanitizeAttribute,e,i),f=i.attrValue,Le&&(u===`id`||u===`name`)&&Ps(f,Re)!==0&&(xt(s,e,n),f=Re+f,p=!0),Qt(s,f)?xt(s,e,n):i.forceKeepAttr||(i.keepAttr?!Te&&Hs(Sc,f)?xt(s,e,n):(Ee&&(f=Ft(f)),qt(o,u,f)?(f=Xt(o,u,c,f),f!==d&&Zt(e,s,c,f)&&p&&Ss(t.removed)):xt(s,e,n)):xt(s,e,n))}Vt(N.afterSanitizeAttributes,e,null),Gt(e,n)},en=function(e){let t=null,n=Pt(e);for(Vt(N.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Vt(N.uponSanitizeShadowNode,t,null),Kt(t,e),$t(t,e),zt(t.content)&&en(t.content),C(t)===Cc.element){let e=v(t);zt(e)&&(tn(e),en(e))}Ee&&Lt(e),Vt(N.afterSanitizeShadowDOM,e,null)},tn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){en(e.shadow);continue}let n=e.node,r=C(n)===Cc.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=x?x(n):null;if(typeof e==`string`&&ct(e)===`template`){let e=n.content;zt(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);zt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Qe=!e,Qe&&(e=`<!-->`),typeof e!=`string`&&!Bt(e)&&(e=Js(e),typeof e!=`string`))throw Us(`dirty is not a string, aborting`);if(!t.isSupported)return e;ke?(F=Ae,I=je):dt(n),(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&(F=qs(F)),N.uponSanitizeAttribute.length>0&&(I=qs(I)),t.removed=[];let c=Be&&typeof e!=`string`&&Bt(e),l=[],u=Ve;if(c){Mt(e);let t=w(e);if(typeof t==`string`){let n=ct(t);if(!F[n]||be[n])throw bt(e),Us(`root node is forbidden and cannot be sanitized in-place`)}if(Rt(e))throw bt(e),Us(`root node is clobbered and cannot be sanitized in-place`);l=Tt(e),Ve=Ds()}else if(Bt(e))i=Nt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Cc.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),tn(i);else{if(!Ne&&!Ee&&!Oe&&e.indexOf(`<`)===-1)return D&&Fe?te(e):e;if(i=Nt(e),!i)return Ne?null:Fe?O:``}i&&Me&&vt(i.firstChild);let d=c?e:i;try{c&&tn(e);let t=Pt(d);for(;o=t.nextNode();)Kt(o,d),$t(o,d),zt(o.content)&&en(o.content);c&&Ot(e,l)}catch(t){throw c&&(bt(e),Dt(e,l)),t}finally{Ve=u}if(c){if(Dt(e,l))throw Us(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Ee&&It(e),e}if(Ne){if(Ee&&It(i),Pe)for(s=oe.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=ce.call(r,s,!0)),s}let f=Oe?i.outerHTML:i.innerHTML;return Oe&&F[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Hs(_c,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
94
|
-
`+f),Ee&&(f=Ft(f)),D&&Fe?te(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dt(e),ke=!0,Ae=F,je=I},t.clearConfig=function(){z=null,ke=!1,Ae=null,je=null,D=k,O=``},t.isValidAttribute=function(e,t,n){z||dt({});let r=ct(e),i=ct(t);return typeof n==`string`&&(Qt(t,n)||!Te&&Hs(Sc,n))?!1:qt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Bs(N,e)&&Cs(N[e],t)},t.removeHook=function(e,t){if(Bs(N,e)){if(t!==void 0){let n=xs(N[e],t);return n===-1?void 0:Ts(N[e],n,1)[0]}return Ss(N[e])}},t.removeHooks=function(e){Bs(N,e)&&(N[e]=[])},t.removeAllHooks=function(){N=Dc()},t}var jc=Ac();function Mc(e,t){try{let n=new URL(e,t||void 0);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function Nc(e){if(!e)return``;try{return new URL(e).pathname.split(`/`).filter(Boolean).at(-1)?.toLowerCase()?.replace(/[-_]\d{2,4}x\d{2,4}(?=\.\w+$)/,``).replace(/\.(?:webp|jpeg)$/,`.jpg`)??``}catch{return``}}var Pc={USE_PROFILES:{html:!0},ALLOWED_ATTR:[`href`,`src`,`alt`,`title`,`width`,`height`,`data-media`,`data-source`],ALLOW_DATA_ATTR:!1,FORBID_TAGS:[`form`,`input`,`button`,`textarea`,`select`,`style`,`video`,`audio`,`source`]};function Fc(e,t){return e.getAttribute(`width`)===`1`&&e.getAttribute(`height`)===`1`||!!(t&&/feedsportal\.com|feedburner\.com|pixel\.wp\.com|statcounter\.com/i.test(t))}function Ic(e){let t=Number(e.getAttribute(`width`)),n=Number(e.getAttribute(`height`));return t>0&&t<160||n>0&&n<100}function Lc(e,t){if(!e)return null;let n=jc.sanitize(e,Pc),r=new DOMParser().parseFromString(n,`text/html`);for(let e of r.querySelectorAll(`img`)){let n=r.createRange();if(n.selectNodeContents(r.body),n.setEndBefore(e),n.toString().trim().length>160)return null;let i=Mc(e.getAttribute(`src`)??``,t);if(i&&!Fc(e,i)&&!Ic(e))return i}return null}function Rc(e,t={}){if(!e)return``;let n=jc.sanitize(e,Pc),r=new DOMParser().parseFromString(n,`text/html`),i=t.heroImageUrl?Mc(t.heroImageUrl,t.baseUrl):null,a=Nc(i),o=r.body.textContent?.trim().length??0,s=null,c=null;Array.from(r.querySelectorAll(`img`)).forEach((e,n)=>{let l=Mc(e.getAttribute(`src`)??``,t.baseUrl),u=Nc(l),d=!1;if(n===0&&i?.includes(`/archive/images/`)&&l?.includes(`/archive/images/`)){let t=r.createRange();t.selectNodeContents(r.body),t.setEndBefore(e),d=!t.toString().trim()}let f=!!(i&&l&&(l===i||a&&u===a||d||n===0&&o<400)),p=!1;if(l&&l===c&&s){let t=r.createRange();t.setStartAfter(s),t.setEndBefore(e),p=!t.toString().trim()}if(!l||Fc(e,l)||f||p){let t=f?e.getAttribute(`alt`)?.trim():null,n=e.closest(`p`);e.remove(),t&&t.length>=15&&n&&n.textContent?.trim()===t&&!n.querySelector(`img`)&&n.remove()}else e.setAttribute(`src`,l),e.removeAttribute(`loading`),s=e,c=l}),r.querySelectorAll(`a`).forEach(e=>{let n=Mc(e.getAttribute(`href`)??``,t.baseUrl);n?(e.setAttribute(`href`,n),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):e.removeAttribute(`href`)}),t.paywallLabel&&r.querySelectorAll(`a[data-media="paywall"]`).forEach(e=>{e.textContent=t.paywallLabel??``}),r.querySelectorAll(`p, div, figure, a`).forEach(e=>{!e.textContent?.trim()&&!e.querySelector(`img`)&&e.remove()});let l=Array.from(r.body.childNodes);if(l.some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())&&!r.body.querySelector(`p`)){let e=r.createElement(`p`);l.forEach(t=>e.appendChild(t)),r.body.appendChild(e)}return jc.sanitize(r.body.innerHTML,Pc)}function zc(e){return e?Math.max(1,Math.ceil(e.trim().split(/\s+/).length/200)):1}var Bc=[{titleKey:`shortcuts.groups.library`,entries:[{keys:[`J`,`/`,`↓`],labelKey:`shortcuts.nextItem`},{keys:[`K`,`/`,`↑`],labelKey:`shortcuts.previousItem`},{keys:[`Enter`,`/`,`O`],labelKey:`shortcuts.openArticle`},{keys:[`M`],labelKey:`shortcuts.toggleRead`},{keys:[`S`],labelKey:`shortcuts.toggleSaved`},{keys:[`V`],labelKey:`shortcuts.openOriginal`},{keys:[`/`],labelKey:`shortcuts.search`},{keys:[`R`],labelKey:`shortcuts.refresh`},{keys:[`Shift`,`A`],labelKey:`shortcuts.markAllRead`},{keys:[`?`],labelKey:`shortcuts.showShortcuts`}]},{titleKey:`shortcuts.groups.article`,entries:[{keys:[`J`,`/`,`→`],labelKey:`shortcuts.nextArticle`},{keys:[`K`,`/`,`←`],labelKey:`shortcuts.previousArticle`},{keys:[`S`],labelKey:`shortcuts.toggleSaved`},{keys:[`M`],labelKey:`shortcuts.toggleRead`},{keys:[`V`],labelKey:`shortcuts.openOriginal`},{keys:[`R`],labelKey:`shortcuts.toggleFullText`},{keys:[`Esc`],labelKey:`shortcuts.close`}]}];function Vc(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.isContentEditable)return!0;let n=t.tagName?.toUpperCase();return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`}function Hc(e){return e.metaKey||e.ctrlKey||e.altKey}function Uc(e){if(!e)return!1;try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?!1:(window.open(t.href,`_blank`,`noopener,noreferrer`),!0)}catch{return!1}}var Wc=new Map;function Gc(e){let t=Wc.get(e);return t||(t=new Promise(t=>{let n=new Image;n.onload=()=>t(n.naturalWidth>0&&n.naturalHeight>0),n.onerror=()=>t(!1),n.src=e}),Wc.set(e,t)),t}function Kc(e){let t=5381n;for(let n of e)t=BigInt.asUintN(64,t*33n+BigInt(n.codePointAt(0)??0));return`hsl(${Number(t%360n)} 33% 43.5%)`}function qc({feedId:e,iconUrl:t,siteUrl:n,feedUrl:r,articleUrl:i,fallbackName:a,className:o}){let s=JSON.stringify([e,t,n,r,i]),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let a=!1;l(null);async function o(){if(e){let t=`/api/feeds/${e}/icon`;await Gc(t)?a||l({key:s,url:t}):a||d(s);return}let o=new Set;t&&/^https?:\/\//i.test(t)&&o.add(t);for(let e of[n,r,i])if(e)try{let t=new URL(e);(t.protocol===`https:`||t.protocol===`http:`)&&o.add(`${t.origin}/favicon.ico`)}catch{}for(let e of o)if(await Gc(e)){a||l({key:s,url:e});return}a||d(s)}return o(),()=>{a=!0}},[s]),!c||c.key!==s?a&&u===s?(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`${o} inline-grid place-items-center font-semibold text-white`,style:{backgroundColor:Kc(a),fontSize:`0.58em`},children:Array.from(a.trim())[0]?.toUpperCase()??`?`}):null:(0,W.jsx)(`img`,{src:c.url,alt:``,className:o,loading:`lazy`,onError:()=>{Wc.set(c.url,Promise.resolve(!1)),l(null)}})}function Jc({text:e}){let t=(0,_.useMemo)(()=>!e||!ko(e)?e:Jo(e).map((e,t)=>e.kind===`wbr`?(0,W.jsx)(`wbr`,{},t):e.kind===`nb`?(0,W.jsx)(`span`,{className:`nb`,children:e.value},t):(0,W.jsx)(_.Fragment,{children:e.value},t)),[e]);return(0,W.jsx)(W.Fragment,{children:t})}function Yc(e){let t=Math.max(0,Math.round(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${r}:${String(i).padStart(2,`0`)}`}function Xc(e){if(!e)return null;try{let t=new URL(e);if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.toLowerCase(),r=t.pathname.split(`/`).filter(Boolean),i=null;return n===`youtu.be`?i=r[0]??null:(n===`youtube.com`||n===`www.youtube.com`||n===`m.youtube.com`||n===`music.youtube.com`||n===`youtube-nocookie.com`||n===`www.youtube-nocookie.com`)&&(t.pathname===`/watch`?i=t.searchParams.get(`v`):r.length>=2&&[`embed`,`shorts`,`live`,`v`].includes(r[0])&&(i=r[1])),i&&/^[A-Za-z0-9_-]{6,32}$/.test(i)?i:null}catch{return null}}function Zc({item:e}){let{t}=z(),n=mo(),r=(0,_.useRef)(null),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),c=(0,_.useRef)(null),l=(0,_.useRef)(0),u=e.enclosure_type?.toLowerCase().startsWith(`video/`)??!1,d=e.enclosure_url?null:Xc(e.link);if((0,_.useEffect)(()=>{s(!1)},[e.id]),(0,_.useEffect)(()=>{let t=!0;if(a([]),c.current=null,l.current=0,e.chapters_url&&u)return U.itemChapters(e.id).then(e=>{t&&a(e.chapters)}).catch(()=>{t&&a([])}),()=>{t=!1}},[e.id,e.chapters_url,u]),d){let n=e.image_url&&!/^https?:\/\/(?:www\.)?youtube\.com\/v\//i.test(e.image_url)?e.image_url:`https://i.ytimg.com/vi/${d}/hqdefault.jpg`;return(0,W.jsx)(`div`,{className:`mb-6 rounded-xl border border-[var(--c-border)] bg-black overflow-hidden aspect-video relative`,children:o?(0,W.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${d}?autoplay=1&rel=0`,title:e.title??`YouTube Video`,className:`w-full h-full border-0`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),"aria-label":t(`player.play`),className:`group relative w-full h-full block cursor-pointer`,children:[(0,W.jsx)(`img`,{src:n,alt:``,className:`w-full h-full object-cover group-hover:scale-[1.02] transition-transform duration-200`}),(0,W.jsx)(`span`,{className:`absolute inset-0 bg-black/20 group-hover:bg-black/30 transition-colors flex items-center justify-center`,children:(0,W.jsx)(`span`,{className:`w-16 h-16 rounded-full bg-black/60 backdrop-blur-md border border-white/25 text-white flex items-center justify-center shadow-lg group-hover:scale-105 transition-transform`,children:(0,W.jsx)(`svg`,{className:`w-7 h-7 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`polygon`,{points:`6 4 20 12 6 20 6 4`})})})})]})})}if(!e.enclosure_url)return null;if(!u){let r=n.currentItem?.id===e.id,a=r&&n.isPlaying,o=r&&n.duration>0?n.duration:e.enclosure_duration_seconds??0,s=r?n.currentTime:e.media_position&&!e.media_position.completed?e.media_position.positionSeconds:0,c=r?n.chapters:i;return(0,W.jsxs)(`div`,{className:`mb-6 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n.togglePlay(e),"aria-label":t(a?`player.pause`:`player.play`),className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:a?(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-4 h-4 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:o>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`input`,{type:`range`,min:0,max:o,value:Math.min(s,o),onChange:t=>{r||n.playItem(e),n.seek(Number(t.target.value))},className:`w-full accent-[var(--c-blue3)] cursor-pointer`}),(0,W.jsxs)(`div`,{className:`flex justify-between text-xs font-mono text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`span`,{children:Yc(s)}),(0,W.jsx)(`span`,{children:Yc(o)})]})]}):(0,W.jsx)(`span`,{className:`text-sm text-[var(--c-text-muted)]`,children:t(`player.play`)})}),r&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>n.skip(30),className:`rounded-lg px-2 py-1 text-xs font-semibold text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:`+30s`})]}),c.length>0&&(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-[var(--c-border)]/60`,children:[(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.06em] text-[var(--c-text-muted)] mb-2`,children:t(`reader.chapters`)}),(0,W.jsx)(`ul`,{className:`max-h-48 overflow-y-auto flex flex-col gap-1`,children:c.map((t,i)=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{r||n.playItem(e),n.seek(t.startTime)},className:`w-full text-left px-2 py-1.5 rounded-lg text-sm hover:bg-[var(--c-surface-hover)] flex items-center gap-3 transition-colors cursor-pointer`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-[var(--c-text-muted)] shrink-0`,children:Yc(t.startTime)}),(0,W.jsx)(`span`,{className:`truncate text-[var(--c-text)]`,children:t.title})]})},`${t.startTime}-${i}`))})]})]})}let f=(t,n=!1)=>{let r=Number.isFinite(t.duration)&&t.duration>0?Math.round(t.duration):e.enclosure_duration_seconds??null,i=n?0:Math.max(0,Math.round(t.currentTime));l.current=Date.now(),U.setMediaPosition(e.id,{positionSeconds:i,durationSeconds:r,completed:n,updatedAt:new Date().toISOString()}).catch(()=>{})},p=t=>{if(c.current===e.id)return;c.current=e.id;let n=e.media_position;n&&!n.completed&&n.positionSeconds>0&&(!Number.isFinite(t.duration)||n.positionSeconds<t.duration-2)&&(t.currentTime=n.positionSeconds)},m=e=>{e.paused||Date.now()-l.current<1e4||f(e,!1)},h=e=>{let t=r.current;t&&(t.currentTime=e,t.play().catch(()=>{}))};return(0,W.jsxs)(`div`,{className:`mb-6 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-4`,children:[(0,W.jsx)(`video`,{ref:r,controls:!0,preload:`metadata`,src:e.enclosure_url,onLoadedMetadata:e=>p(e.currentTarget),onTimeUpdate:e=>m(e.currentTarget),onPause:e=>f(e.currentTarget,!1),onEnded:e=>f(e.currentTarget,!0),className:`w-full rounded-lg max-h-96 bg-black`}),i.length>0&&(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-[var(--c-border)]/60`,children:[(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.06em] text-[var(--c-text-muted)] mb-2`,children:t(`reader.chapters`)}),(0,W.jsx)(`ul`,{className:`max-h-48 overflow-y-auto flex flex-col gap-1`,children:i.map((e,t)=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>h(e.startTime),className:`w-full text-left px-2 py-1.5 rounded-lg text-sm hover:bg-[var(--c-surface-hover)] flex items-center gap-3 transition-colors cursor-pointer`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-[var(--c-text-muted)] shrink-0`,children:Yc(e.startTime)}),(0,W.jsx)(`span`,{className:`truncate text-[var(--c-text)]`,children:e.title})]})},`${e.startTime}-${t}`))})]})]})}function Qc({item:e,isOpen:t,onClose:n,onToggleBookmark:r,onToggleRead:i,onNext:a,onPrevious:o,onItemUpdated:s,hasNext:c=!1,hasPrev:l=!1}){let{t:u,i18n:d}=z(),[f,p]=(0,_.useState)(61),m=(0,_.useRef)(null),h=(0,_.useCallback)(e=>{if(m.current?.disconnect(),!e)return;let t=()=>p(e.offsetHeight);t(),m.current=new ResizeObserver(t),m.current.observe(e)},[]),[g,v]=(0,_.useState)(!1),y=(0,_.useRef)(new Set),[b,x]=(0,_.useState)(new Set),S=e!==null&&b.has(e.id),C=(0,_.useRef)(e?.id??null);C.current=t?e?.id??null:null;let[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null),O=e?.author||E,[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(!1),te=e?.feed_full_text_mode===`never`,[ne,re]=(0,_.useState)(null),M=e?.link?Mc(e.link):null;(0,_.useEffect)(()=>{T(!!e?.full_content_html),A(null),ee(!1)},[e?.id,e?.full_content_html]),(0,_.useEffect)(()=>{D(null)},[e?.id]),(0,_.useEffect)(()=>{t&&e&&M&&localStorage.getItem(`feedkeeper_auto_reader_mode`)!==`false`&&!e.full_content_html&&!te&&navigator.onLine&&ie()},[t,e?.id]),(0,_.useEffect)(()=>{if(t){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}},[t]);let ie=(0,_.useCallback)(async()=>{if(!e||y.current.has(e.id))return;if(e.full_content_html){T(e=>!e);return}if(!M)return;let t=e;y.current.add(t.id),x(new Set(y.current)),A(null),ee(!1);try{let e=await U.extractContent(t.id),n={id:t.id,full_content_html:e.full_content_html};s?.(n),C.current===t.id&&(e.byline&&D(e.byline),T(!0))}catch(e){C.current===t.id&&(e instanceof va&&e.code===`consent_wall`?ee(!0):e instanceof va&&e.status===0?A(u(`common.offlineAction`)):e instanceof va&&e.code===`full_text_disabled`||(console.error(`Failed to extract full text:`,e),A(u(`reader.extractionFailed`))))}finally{y.current.delete(t.id),x(new Set(y.current))}},[e,M,u,s]);(0,_.useEffect)(()=>{if(!t||!e)return;let s=e;function u(e){document.querySelector(`[data-shortcuts-modal]`)||Vc(e.target)||Vc(document.activeElement)||Hc(e)||(e.key===`Escape`?(e.preventDefault(),n()):(e.key===`j`||e.key===`J`||e.key===`ArrowRight`)&&c&&a?(e.preventDefault(),a()):(e.key===`k`||e.key===`K`||e.key===`ArrowLeft`)&&l&&o?(e.preventDefault(),o()):e.key===`s`||e.key===`S`?(e.preventDefault(),r(s)):e.key===`m`||e.key===`M`?(e.preventDefault(),i(s)):e.key===`r`||e.key===`R`?(e.preventDefault(),ie()):(e.key===`v`||e.key===`V`||e.key===`o`||e.key===`O`)&&M&&(e.preventDefault(),Uc(M)))}return window.addEventListener(`keydown`,u),()=>window.removeEventListener(`keydown`,u)},[t,e,M,c,l,a,o,n,r,i,ie]);let ae=(0,_.useMemo)(()=>e?.published_at?new Date(e.published_at):null,[e?.published_at]),oe=(0,_.useMemo)(()=>ae?new Intl.DateTimeFormat(d.resolvedLanguage,{dateStyle:`medium`}).format(ae):``,[ae,d.resolvedLanguage]),se=(0,_.useMemo)(()=>ae?new Intl.DateTimeFormat(d.resolvedLanguage,{timeStyle:`short`}).format(ae):``,[ae,d.resolvedLanguage]),ce=w?e?.full_content_html:e?.content_html,N=(0,_.useMemo)(()=>e?.image_url??Lc(ce??``,e?.link),[e?.image_url,ce,e?.link]);(0,_.useEffect)(()=>{if(re(null),!t||!N)return;let e=!1,n=new Image;return n.onload=()=>{!e&&n.naturalWidth>0&&n.naturalHeight>0&&re({src:N,width:n.naturalWidth,height:n.naturalHeight})},n.src=N,()=>{e=!0}},[t,N]);let le=ne?.src===N?ne:null,ue=le!==null&&le.width<=320&&le.height<=240,de=(0,_.useMemo)(()=>e&&ce?$o(Rc(ce,{heroImageUrl:N,baseUrl:e.link,paywallLabel:u(`reader.paywallRead`)})):``,[e,ce,N,u]),fe=(0,_.useMemo)(()=>zc((ce??e?.content_snippet??``).replace(/<[^>]+>/g,` `)),[ce,e?.content_snippet]);return!t||!e?null:(0,es.createPortal)((0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,W.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-xs transition-opacity animate-fade-in`,onClick:n,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{className:`relative z-10 w-full sm:max-w-2xl md:max-w-3xl h-full h-[100dvh] bg-[var(--c-surface)] shadow-2xl flex flex-col border-0 sm:border-l border-[var(--c-border)] animate-drawer-in`,role:`dialog`,"aria-modal":`true`,"aria-label":e.title??u(`items.title`),children:[(0,W.jsxs)(`header`,{ref:h,className:`absolute inset-x-0 top-0 z-20 px-4 py-3 border-b border-[var(--c-border)] backdrop-blur-md transform-gpu flex items-center justify-between gap-3`,style:{paddingTop:`max(0.75rem, env(safe-area-inset-top, 0px))`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`},children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pr-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,W.jsx)(qc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.feed_title})]}),(0,W.jsx)(`button`,{type:`button`,onClick:n,title:u(`reader.close`),"aria-label":u(`reader.close`),className:`w-9 h-9 -mr-1 rounded-xl text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/60 active:scale-95 transition-all cursor-pointer flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-6 h-6`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,W.jsxs)(`main`,{className:`flex-1 overflow-y-auto overscroll-contain transform-gpu`,style:{paddingTop:f},children:[le&&!ue&&!(!e?.enclosure_url&&Xc(e?.link))&&(0,W.jsx)(`img`,{src:le.src,alt:``,className:`block w-full max-h-[380px] object-cover`,onError:()=>re(null)}),(0,W.jsx)(`div`,{className:`px-5 sm:px-10 py-6 sm:py-8`,style:{paddingBottom:`max(2rem, env(safe-area-inset-bottom, 0px))`},children:(0,W.jsxs)(`article`,{className:`max-w-prose mx-auto`,children:[(0,W.jsxs)(`div`,{className:`flow-root`,children:[le&&ue&&(0,W.jsx)(`div`,{className:`float-right ml-4 mb-3 sm:ml-6 rounded-xl overflow-hidden border border-[var(--c-border)] bg-[var(--c-bg)] shadow-xs`,style:{width:le.width,maxWidth:`42%`},children:(0,W.jsx)(`img`,{src:le.src,alt:``,className:`block w-full h-auto`,onError:()=>re(null)})}),(0,W.jsx)(`h1`,{lang:Ao(e.title),className:`text-2xl sm:text-3xl font-bold font-['Manrope'] text-[var(--c-text)] leading-snug tracking-tight mb-3${Ao(e.title)===`ja`?` ja-phrases`:``}`,children:e.title?(0,W.jsx)(Jc,{text:e.title}):null})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-[var(--c-text-muted)] pb-5 border-b border-[var(--c-border)] mb-6 font-medium`,children:[O&&(0,W.jsx)(`span`,{children:O}),oe&&(0,W.jsxs)(W.Fragment,{children:[O&&(0,W.jsx)(`span`,{children:`•`}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,W.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,W.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,W.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,W.jsx)(`span`,{children:oe})]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,W.jsx)(`span`,{children:se})]})]}),(O||oe)&&(0,W.jsx)(`span`,{children:`•`}),(0,W.jsx)(`span`,{children:u(`reader.readingTime`,{count:fe})})]}),j&&(0,W.jsxs)(`div`,{className:`mb-6 p-4 rounded-xl border border-[var(--c-border)] bg-[var(--c-bg)] text-sm text-[var(--c-text-muted)] flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{children:u(`reader.consentWall`)}),M&&(0,W.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,className:`btn-primary text-sm whitespace-nowrap self-start sm:self-center`,children:u(`reader.readOriginal`)})]}),k&&(0,W.jsxs)(`div`,{className:`mb-6 p-4 rounded-xl bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400 text-xs flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{children:k}),M&&(0,W.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,className:`underline font-semibold whitespace-nowrap hover:opacity-80`,children:u(`reader.openOriginal`)})]}),(0,W.jsx)(Zc,{item:e}),de?(0,W.jsx)(`div`,{className:`reader-content`,lang:Ao(e.content_snippet??e.title),dangerouslySetInnerHTML:{__html:de}}):e.content_snippet?(0,W.jsx)(`div`,{className:`reader-content`,lang:Ao(e.content_snippet),children:e.content_snippet.split(`
|
|
94
|
+
`+f),Ee&&(f=Ft(f)),D&&Fe?te(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dt(e),ke=!0,Ae=F,je=I},t.clearConfig=function(){z=null,ke=!1,Ae=null,je=null,D=k,O=``},t.isValidAttribute=function(e,t,n){z||dt({});let r=ct(e),i=ct(t);return typeof n==`string`&&(Qt(t,n)||!Te&&Hs(Sc,n))?!1:qt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Bs(N,e)&&Cs(N[e],t)},t.removeHook=function(e,t){if(Bs(N,e)){if(t!==void 0){let n=xs(N[e],t);return n===-1?void 0:Ts(N[e],n,1)[0]}return Ss(N[e])}},t.removeHooks=function(e){Bs(N,e)&&(N[e]=[])},t.removeAllHooks=function(){N=Dc()},t}var jc=Ac();function Mc(e,t){try{let n=new URL(e,t||void 0);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function Nc(e){if(!e)return``;try{return new URL(e).pathname.split(`/`).filter(Boolean).at(-1)?.toLowerCase()?.replace(/[-_]\d{2,4}x\d{2,4}(?=\.\w+$)/,``).replace(/\.(?:webp|jpeg)$/,`.jpg`)??``}catch{return``}}var Pc={USE_PROFILES:{html:!0},ALLOWED_ATTR:[`href`,`src`,`alt`,`title`,`width`,`height`,`data-media`,`data-source`],ALLOW_DATA_ATTR:!1,FORBID_TAGS:[`form`,`input`,`button`,`textarea`,`select`,`style`,`video`,`audio`,`source`]};function Fc(e,t){return e.getAttribute(`width`)===`1`&&e.getAttribute(`height`)===`1`||!!(t&&/feedsportal\.com|feedburner\.com|pixel\.wp\.com|statcounter\.com/i.test(t))}function Ic(e){let t=Number(e.getAttribute(`width`)),n=Number(e.getAttribute(`height`));return t>0&&t<160||n>0&&n<100}function Lc(e,t){if(!e)return null;let n=jc.sanitize(e,Pc),r=new DOMParser().parseFromString(n,`text/html`);for(let e of r.querySelectorAll(`img`)){let n=r.createRange();if(n.selectNodeContents(r.body),n.setEndBefore(e),n.toString().trim().length>160)return null;let i=Mc(e.getAttribute(`src`)??``,t);if(i&&!Fc(e,i)&&!Ic(e))return i}return null}function Rc(e,t={}){if(!e)return``;let n=jc.sanitize(e,Pc),r=new DOMParser().parseFromString(n,`text/html`),i=t.heroImageUrl?Mc(t.heroImageUrl,t.baseUrl):null,a=Nc(i),o=r.body.textContent?.trim().length??0,s=null,c=null;Array.from(r.querySelectorAll(`img`)).forEach((e,n)=>{let l=Mc(e.getAttribute(`src`)??``,t.baseUrl),u=Nc(l),d=!1;if(n===0&&i?.includes(`/archive/images/`)&&l?.includes(`/archive/images/`)){let t=r.createRange();t.selectNodeContents(r.body),t.setEndBefore(e),d=!t.toString().trim()}let f=!!(i&&l&&(l===i||a&&u===a||d||n===0&&o<400)),p=!1;if(l&&l===c&&s){let t=r.createRange();t.setStartAfter(s),t.setEndBefore(e),p=!t.toString().trim()}if(!l||Fc(e,l)||f||p){let t=f?e.getAttribute(`alt`)?.trim():null,n=e.closest(`p`);e.remove(),t&&t.length>=15&&n&&n.textContent?.trim()===t&&!n.querySelector(`img`)&&n.remove()}else e.setAttribute(`src`,l),e.removeAttribute(`loading`),s=e,c=l}),r.querySelectorAll(`a`).forEach(e=>{let n=Mc(e.getAttribute(`href`)??``,t.baseUrl);n?(e.setAttribute(`href`,n),e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):e.removeAttribute(`href`)}),t.paywallLabel&&r.querySelectorAll(`a[data-media="paywall"]`).forEach(e=>{e.textContent=t.paywallLabel??``}),r.querySelectorAll(`p, div, figure, a`).forEach(e=>{!e.textContent?.trim()&&!e.querySelector(`img`)&&e.remove()});let l=Array.from(r.body.childNodes);if(l.some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())&&!r.body.querySelector(`p`)){let e=r.createElement(`p`);l.forEach(t=>e.appendChild(t)),r.body.appendChild(e)}return jc.sanitize(r.body.innerHTML,Pc)}function zc(e){return e?Math.max(1,Math.ceil(e.trim().split(/\s+/).length/200)):1}var Bc=[{titleKey:`shortcuts.groups.library`,entries:[{keys:[`J`,`/`,`↓`],labelKey:`shortcuts.nextItem`},{keys:[`K`,`/`,`↑`],labelKey:`shortcuts.previousItem`},{keys:[`Enter`,`/`,`O`],labelKey:`shortcuts.openArticle`},{keys:[`M`],labelKey:`shortcuts.toggleRead`},{keys:[`S`],labelKey:`shortcuts.toggleSaved`},{keys:[`V`],labelKey:`shortcuts.openOriginal`},{keys:[`/`],labelKey:`shortcuts.search`},{keys:[`R`],labelKey:`shortcuts.refresh`},{keys:[`Shift`,`A`],labelKey:`shortcuts.markAllRead`},{keys:[`?`],labelKey:`shortcuts.showShortcuts`}]},{titleKey:`shortcuts.groups.article`,entries:[{keys:[`J`,`/`,`→`],labelKey:`shortcuts.nextArticle`},{keys:[`K`,`/`,`←`],labelKey:`shortcuts.previousArticle`},{keys:[`S`],labelKey:`shortcuts.toggleSaved`},{keys:[`M`],labelKey:`shortcuts.toggleRead`},{keys:[`V`],labelKey:`shortcuts.openOriginal`},{keys:[`R`],labelKey:`shortcuts.toggleFullText`},{keys:[`Esc`],labelKey:`shortcuts.close`}]}];function Vc(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.isContentEditable)return!0;let n=t.tagName?.toUpperCase();return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`}function Hc(e){return e.metaKey||e.ctrlKey||e.altKey}function Uc(e){if(!e)return!1;try{let t=new URL(e);return t.protocol!==`http:`&&t.protocol!==`https:`?!1:(window.open(t.href,`_blank`,`noopener,noreferrer`),!0)}catch{return!1}}var Wc=new Map;function Gc(e){let t=Wc.get(e);return t||(t=new Promise(t=>{let n=new Image;n.onload=()=>t(n.naturalWidth>0&&n.naturalHeight>0),n.onerror=()=>t(!1),n.src=e}),Wc.set(e,t)),t}function Kc(e){let t=5381n;for(let n of e)t=BigInt.asUintN(64,t*33n+BigInt(n.codePointAt(0)??0));return`hsl(${Number(t%360n)} 33% 43.5%)`}function qc({feedId:e,iconUrl:t,siteUrl:n,feedUrl:r,articleUrl:i,fallbackName:a,className:o}){let s=JSON.stringify([e,t,n,r,i]),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let a=!1;l(null);async function o(){if(e){let t=`/api/feeds/${e}/icon`;await Gc(t)?a||l({key:s,url:t}):a||d(s);return}let o=new Set;t&&/^https?:\/\//i.test(t)&&o.add(t);for(let e of[n,r,i])if(e)try{let t=new URL(e);(t.protocol===`https:`||t.protocol===`http:`)&&o.add(`${t.origin}/favicon.ico`)}catch{}for(let e of o)if(await Gc(e)){a||l({key:s,url:e});return}a||d(s)}return o(),()=>{a=!0}},[s]),!c||c.key!==s?a&&u===s?(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`${o} inline-grid place-items-center font-semibold text-white`,style:{backgroundColor:Kc(a),fontSize:`0.58em`},children:Array.from(a.trim())[0]?.toUpperCase()??`?`}):null:(0,W.jsx)(`img`,{src:c.url,alt:``,className:o,loading:`lazy`,onError:()=>{Wc.set(c.url,Promise.resolve(!1)),l(null)}})}function Jc({text:e}){let t=(0,_.useMemo)(()=>!e||!ko(e)?e:Jo(e).map((e,t)=>e.kind===`wbr`?(0,W.jsx)(`wbr`,{},t):e.kind===`nb`?(0,W.jsx)(`span`,{className:`nb`,children:e.value},t):(0,W.jsx)(_.Fragment,{children:e.value},t)),[e]);return(0,W.jsx)(W.Fragment,{children:t})}function Yc(e){let t=Math.max(0,Math.round(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`:`${r}:${String(i).padStart(2,`0`)}`}function Xc(e){if(!e)return null;try{let t=new URL(e);if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.toLowerCase(),r=t.pathname.split(`/`).filter(Boolean),i=null;return n===`youtu.be`?i=r[0]??null:(n===`youtube.com`||n===`www.youtube.com`||n===`m.youtube.com`||n===`music.youtube.com`||n===`youtube-nocookie.com`||n===`www.youtube-nocookie.com`)&&(t.pathname===`/watch`?i=t.searchParams.get(`v`):r.length>=2&&[`embed`,`shorts`,`live`,`v`].includes(r[0])&&(i=r[1])),i&&/^[A-Za-z0-9_-]{6,32}$/.test(i)?i:null}catch{return null}}function Zc({item:e}){let{t}=z(),n=mo(),r=(0,_.useRef)(null),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),c=(0,_.useRef)(null),l=(0,_.useRef)(0),u=e.enclosure_type?.toLowerCase().startsWith(`video/`)??!1,d=e.enclosure_url?null:Xc(e.link);if((0,_.useEffect)(()=>{s(!1)},[e.id]),(0,_.useEffect)(()=>{let t=!0;if(a([]),c.current=null,l.current=0,e.chapters_url&&u)return U.itemChapters(e.id).then(e=>{t&&a(e.chapters)}).catch(()=>{t&&a([])}),()=>{t=!1}},[e.id,e.chapters_url,u]),d){let n=e.image_url&&!/^https?:\/\/(?:www\.)?youtube\.com\/v\//i.test(e.image_url)?e.image_url:`https://i.ytimg.com/vi/${d}/hqdefault.jpg`;return(0,W.jsx)(`div`,{className:`mb-6 rounded-xl border border-[var(--c-border)] bg-black overflow-hidden aspect-video relative`,children:o?(0,W.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${d}?autoplay=1&rel=0`,title:e.title??`YouTube Video`,className:`w-full h-full border-0`,referrerPolicy:`strict-origin-when-cross-origin`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0}):(0,W.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),"aria-label":t(`player.play`),className:`group relative w-full h-full block cursor-pointer`,children:[(0,W.jsx)(`img`,{src:n,alt:``,className:`w-full h-full object-cover group-hover:scale-[1.02] transition-transform duration-200`}),(0,W.jsx)(`span`,{className:`absolute inset-0 bg-black/20 group-hover:bg-black/30 transition-colors flex items-center justify-center`,children:(0,W.jsx)(`span`,{className:`w-16 h-16 rounded-full bg-black/60 backdrop-blur-md border border-white/25 text-white flex items-center justify-center shadow-lg group-hover:scale-105 transition-transform`,children:(0,W.jsx)(`svg`,{className:`w-7 h-7 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`polygon`,{points:`6 4 20 12 6 20 6 4`})})})})]})})}if(!e.enclosure_url)return null;if(!u){let r=n.currentItem?.id===e.id,a=r&&n.isPlaying,o=r&&n.duration>0?n.duration:e.enclosure_duration_seconds??0,s=r?n.currentTime:e.media_position&&!e.media_position.completed?e.media_position.positionSeconds:0,c=r?n.chapters:i;return(0,W.jsxs)(`div`,{className:`mb-6 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>n.togglePlay(e),"aria-label":t(a?`player.pause`:`player.play`),className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:a?(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-4 h-4 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:o>0?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`input`,{type:`range`,min:0,max:o,value:Math.min(s,o),onChange:t=>{r||n.playItem(e),n.seek(Number(t.target.value))},className:`w-full accent-[var(--c-blue3)] cursor-pointer`}),(0,W.jsxs)(`div`,{className:`flex justify-between text-xs font-mono text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`span`,{children:Yc(s)}),(0,W.jsx)(`span`,{children:Yc(o)})]})]}):(0,W.jsx)(`span`,{className:`text-sm text-[var(--c-text-muted)]`,children:t(`player.play`)})}),r&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>n.skip(30),className:`rounded-lg px-2 py-1 text-xs font-semibold text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:`+30s`})]}),c.length>0&&(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-[var(--c-border)]/60`,children:[(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.06em] text-[var(--c-text-muted)] mb-2`,children:t(`reader.chapters`)}),(0,W.jsx)(`ul`,{className:`max-h-48 overflow-y-auto flex flex-col gap-1`,children:c.map((t,i)=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{r||n.playItem(e),n.seek(t.startTime)},className:`w-full text-left px-2 py-1.5 rounded-lg text-sm hover:bg-[var(--c-surface-hover)] flex items-center gap-3 transition-colors cursor-pointer`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-[var(--c-text-muted)] shrink-0`,children:Yc(t.startTime)}),(0,W.jsx)(`span`,{className:`truncate text-[var(--c-text)]`,children:t.title})]})},`${t.startTime}-${i}`))})]})]})}let f=(t,n=!1)=>{let r=Number.isFinite(t.duration)&&t.duration>0?Math.round(t.duration):e.enclosure_duration_seconds??null,i=n?0:Math.max(0,Math.round(t.currentTime));l.current=Date.now(),U.setMediaPosition(e.id,{positionSeconds:i,durationSeconds:r,completed:n,updatedAt:new Date().toISOString()}).catch(()=>{})},p=t=>{if(c.current===e.id)return;c.current=e.id;let n=e.media_position;n&&!n.completed&&n.positionSeconds>0&&(!Number.isFinite(t.duration)||n.positionSeconds<t.duration-2)&&(t.currentTime=n.positionSeconds)},m=e=>{e.paused||Date.now()-l.current<1e4||f(e,!1)},h=e=>{let t=r.current;t&&(t.currentTime=e,t.play().catch(()=>{}))};return(0,W.jsxs)(`div`,{className:`mb-6 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-4`,children:[(0,W.jsx)(`video`,{ref:r,controls:!0,preload:`metadata`,src:e.enclosure_url,onLoadedMetadata:e=>p(e.currentTarget),onTimeUpdate:e=>m(e.currentTarget),onPause:e=>f(e.currentTarget,!1),onEnded:e=>f(e.currentTarget,!0),className:`w-full rounded-lg max-h-96 bg-black`}),i.length>0&&(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-[var(--c-border)]/60`,children:[(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.06em] text-[var(--c-text-muted)] mb-2`,children:t(`reader.chapters`)}),(0,W.jsx)(`ul`,{className:`max-h-48 overflow-y-auto flex flex-col gap-1`,children:i.map((e,t)=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>h(e.startTime),className:`w-full text-left px-2 py-1.5 rounded-lg text-sm hover:bg-[var(--c-surface-hover)] flex items-center gap-3 transition-colors cursor-pointer`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-[var(--c-text-muted)] shrink-0`,children:Yc(e.startTime)}),(0,W.jsx)(`span`,{className:`truncate text-[var(--c-text)]`,children:e.title})]})},`${e.startTime}-${t}`))})]})]})}function Qc({item:e,isOpen:t,onClose:n,onToggleBookmark:r,onToggleRead:i,onNext:a,onPrevious:o,onItemUpdated:s,hasNext:c=!1,hasPrev:l=!1}){let{t:u,i18n:d}=z(),[f,p]=(0,_.useState)(61),m=(0,_.useRef)(null),h=(0,_.useCallback)(e=>{if(m.current?.disconnect(),!e)return;let t=()=>p(e.offsetHeight);t(),m.current=new ResizeObserver(t),m.current.observe(e)},[]),[g,v]=(0,_.useState)(!1),y=(0,_.useRef)(new Set),[b,x]=(0,_.useState)(new Set),S=e!==null&&b.has(e.id),C=(0,_.useRef)(e?.id??null);C.current=t?e?.id??null:null;let[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null),O=e?.author||E,[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(!1),te=e?.feed_full_text_mode===`never`,[ne,re]=(0,_.useState)(null),M=e?.link?Mc(e.link):null;(0,_.useEffect)(()=>{T(!!e?.full_content_html),A(null),ee(!1)},[e?.id,e?.full_content_html]),(0,_.useEffect)(()=>{D(null)},[e?.id]);let ie=!e?.enclosure_url&&!!Xc(e?.link),ae=ie||!!e?.enclosure_url;(0,_.useEffect)(()=>{t&&e&&M&&!ae&&localStorage.getItem(`feedkeeper_auto_reader_mode`)!==`false`&&!e.full_content_html&&!te&&navigator.onLine&&oe({silent:!0})},[t,e?.id]),(0,_.useEffect)(()=>{if(t){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}},[t]);let oe=(0,_.useCallback)(async({silent:t=!1}={})=>{if(!e||y.current.has(e.id))return;if(e.full_content_html){T(e=>!e);return}if(!M)return;let n=e;y.current.add(n.id),x(new Set(y.current)),A(null),ee(!1);try{let e=await U.extractContent(n.id),t={id:n.id,full_content_html:e.full_content_html};s?.(t),C.current===n.id&&(e.byline&&D(e.byline),T(!0))}catch(e){C.current===n.id&&(e instanceof va&&e.code===`consent_wall`?ee(!0):!t&&e instanceof va&&e.status===0?A(u(`common.offlineAction`)):!t&&!(e instanceof va&&e.code===`full_text_disabled`)&&A(u(`reader.extractionFailed`)))}finally{y.current.delete(n.id),x(new Set(y.current))}},[e,M,u,s]);(0,_.useEffect)(()=>{if(!t||!e)return;let s=e;function u(e){document.querySelector(`[data-shortcuts-modal]`)||Vc(e.target)||Vc(document.activeElement)||Hc(e)||(e.key===`Escape`?(e.preventDefault(),n()):(e.key===`j`||e.key===`J`||e.key===`ArrowRight`)&&c&&a?(e.preventDefault(),a()):(e.key===`k`||e.key===`K`||e.key===`ArrowLeft`)&&l&&o?(e.preventDefault(),o()):e.key===`s`||e.key===`S`?(e.preventDefault(),r(s)):e.key===`m`||e.key===`M`?(e.preventDefault(),i(s)):e.key===`r`||e.key===`R`?(e.preventDefault(),oe()):(e.key===`v`||e.key===`V`||e.key===`o`||e.key===`O`)&&M&&(e.preventDefault(),Uc(M)))}return window.addEventListener(`keydown`,u),()=>window.removeEventListener(`keydown`,u)},[t,e,M,c,l,a,o,n,r,i,oe]);let se=(0,_.useMemo)(()=>e?.published_at?new Date(e.published_at):null,[e?.published_at]),ce=(0,_.useMemo)(()=>se?new Intl.DateTimeFormat(d.resolvedLanguage,{dateStyle:`medium`}).format(se):``,[se,d.resolvedLanguage]),N=(0,_.useMemo)(()=>se?new Intl.DateTimeFormat(d.resolvedLanguage,{timeStyle:`short`}).format(se):``,[se,d.resolvedLanguage]),le=w?e?.full_content_html:e?.content_html,ue=(0,_.useMemo)(()=>e?.image_url??Lc(le??``,e?.link),[e?.image_url,le,e?.link]);(0,_.useEffect)(()=>{if(re(null),!t||!ue)return;let e=!1,n=new Image;return n.onload=()=>{!e&&n.naturalWidth>0&&n.naturalHeight>0&&re({src:ue,width:n.naturalWidth,height:n.naturalHeight})},n.src=ue,()=>{e=!0}},[t,ue]);let de=ne?.src===ue?ne:null,fe=de!==null&&de.width<=320&&de.height<=240,pe=(0,_.useMemo)(()=>e&&le?$o(Rc(le,{heroImageUrl:ue,baseUrl:e.link,paywallLabel:u(`reader.paywallRead`)})):``,[e,le,ue,u]),me=(0,_.useMemo)(()=>zc((le??e?.content_snippet??``).replace(/<[^>]+>/g,` `)),[le,e?.content_snippet]);return!t||!e?null:(0,es.createPortal)((0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,W.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-xs transition-opacity animate-fade-in`,onClick:n,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{className:`relative z-10 w-full sm:max-w-2xl md:max-w-3xl h-full h-[100dvh] bg-[var(--c-surface)] shadow-2xl flex flex-col border-0 sm:border-l border-[var(--c-border)] animate-drawer-in`,role:`dialog`,"aria-modal":`true`,"aria-label":e.title??u(`items.title`),children:[(0,W.jsxs)(`header`,{ref:h,className:`absolute inset-x-0 top-0 z-20 px-4 py-3 border-b border-[var(--c-border)] backdrop-blur-md transform-gpu flex items-center justify-between gap-3`,style:{paddingTop:`max(0.75rem, env(safe-area-inset-top, 0px))`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`},children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pr-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,W.jsx)(qc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.feed_title})]}),(0,W.jsx)(`button`,{type:`button`,onClick:n,title:u(`reader.close`),"aria-label":u(`reader.close`),className:`w-9 h-9 -mr-1 rounded-xl text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/60 active:scale-95 transition-all cursor-pointer flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-6 h-6`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,W.jsxs)(`main`,{className:`flex-1 overflow-y-auto overscroll-contain transform-gpu`,style:{paddingTop:f},children:[de&&!fe&&!(!e?.enclosure_url&&Xc(e?.link))&&(0,W.jsx)(`img`,{src:de.src,alt:``,className:`block w-full max-h-[380px] object-cover`,onError:()=>re(null)}),(0,W.jsx)(`div`,{className:`px-5 sm:px-10 py-6 sm:py-8`,style:{paddingBottom:`max(2rem, env(safe-area-inset-bottom, 0px))`},children:(0,W.jsxs)(`article`,{className:`max-w-prose mx-auto`,children:[(0,W.jsxs)(`div`,{className:`flow-root`,children:[de&&fe&&(0,W.jsx)(`div`,{className:`float-right ml-4 mb-3 sm:ml-6 rounded-xl overflow-hidden border border-[var(--c-border)] bg-[var(--c-bg)] shadow-xs`,style:{width:de.width,maxWidth:`42%`},children:(0,W.jsx)(`img`,{src:de.src,alt:``,className:`block w-full h-auto`,onError:()=>re(null)})}),(0,W.jsx)(`h1`,{lang:Ao(e.title),className:`text-2xl sm:text-3xl font-bold font-['Manrope'] text-[var(--c-text)] leading-snug tracking-tight mb-3${Ao(e.title)===`ja`?` ja-phrases`:``}`,children:e.title?(0,W.jsx)(Jc,{text:e.title}):null})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-[var(--c-text-muted)] pb-5 border-b border-[var(--c-border)] mb-6 font-medium`,children:[O&&(0,W.jsx)(`span`,{children:O}),ce&&(0,W.jsxs)(W.Fragment,{children:[O&&(0,W.jsx)(`span`,{children:`•`}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,W.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,W.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,W.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,W.jsx)(`span`,{children:ce})]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,W.jsx)(`span`,{children:N})]})]}),!ae&&!j&&(w||!!e.full_content_html||me>1)&&(0,W.jsxs)(W.Fragment,{children:[(O||ce)&&(0,W.jsx)(`span`,{children:`•`}),(0,W.jsx)(`span`,{children:u(`reader.readingTime`,{count:me})})]})]}),(0,W.jsx)(Zc,{item:e}),pe?(0,W.jsx)(`div`,{className:`reader-content`,lang:Ao(e.content_snippet??e.title),dangerouslySetInnerHTML:{__html:pe}}):e.content_snippet?(0,W.jsx)(`div`,{className:`reader-content`,lang:Ao(e.content_snippet),children:e.content_snippet.split(`
|
|
95
95
|
|
|
96
|
-
`).map((e,t)=>(0,W.jsx)(`p`,{children:(0,W.jsx)(Jc,{text:e})},t))}):(0,W.jsx)(`p`,{className:`text-[var(--c-text-muted)] italic`,children:u(`items.noItems`)}),(0,W.jsxs)(`div`,{className:`mt-12 pt-6 border-t border-[var(--c-border)]/60 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:o,disabled:!l,title:u(`reader.previous`),"aria-label":u(`reader.previous`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:a,disabled:!c,title:u(`reader.next`),"aria-label":u(`reader.next`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`9 18 15 12 9 6`})})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&(!te||e.full_content_html)&&(0,W.jsx)(`button`,{type:`button`,onClick:ie,disabled:S,title:u(w?`reader.togglePreview`:`reader.toggleFullText`),"aria-label":u(w?`reader.togglePreview`:`reader.toggleFullText`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${w?`bg-[var(--c-blue1)]/15 border-[var(--c-blue1)]/40 text-[var(--c-blue1)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40`}`,children:S?(0,W.jsx)(`svg`,{className:`w-4 h-4 animate-spin text-[var(--c-blue1)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,strokeDasharray:`32`,strokeDashoffset:`12`})}):(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`}),(0,W.jsx)(`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`})]})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),"aria-label":e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(e),title:e.read?u(`reader.markUnread`):u(`reader.markRead`),"aria-label":e.read?u(`reader.markUnread`):u(`reader.markRead`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.read?`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:async()=>{if(M)try{await navigator.clipboard.writeText(M),v(!0),setTimeout(()=>v(!1),2e3)}catch{}},title:u(g?`reader.linkCopied`:`reader.copyLink`),"aria-label":u(`reader.copyLink`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95 cursor-pointer relative`,children:g?(0,W.jsx)(`svg`,{className:`w-4 h-4 text-emerald-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,W.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),M&&(0,W.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,title:u(`reader.openOriginal`),"aria-label":u(`reader.openOriginal`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,W.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,W.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]})})]})]})]})})]})]})]}),document.body)}var $c=`feedkeeper:extensions-changed`,el=[`login`,`menu`,`page`],tl=/^[a-z0-9][a-z0-9-]{0,63}$/,nl=(e,t)=>typeof e==`string`&&e.trim().length>0&&e.length<=t,rl=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function il(e){return rl(e)?typeof e.id==`string`&&tl.test(e.id)&&nl(e.label,80)&&nl(e.description,300)&&nl(e.group,60)&&(e.shortLabel===void 0||nl(e.shortLabel,40))&&(e.icon===void 0||Array.isArray(e.icon)&&e.icon.length<=8&&e.icon.every(e=>typeof e==`string`&&e.length<=400))&&(e.admin===void 0||typeof e.admin==`boolean`)&&typeof e.mount==`function`:!1}function al(e,t,n){let r=rl(e)&&rl(e.settings)?e.settings:{},i=new Set(Array.isArray(r.hidden)?r.hidden.filter(e=>typeof e==`string`&&t.includes(e)):[]),a=new Set(t),o=[];for(let e of Array.isArray(r.sections)?r.sections:[])il(e)&&!a.has(e.id)&&(a.add(e.id),(!e.admin||n)&&o.push(e));return{hidden:i,sections:o}}function ol(e){let t=[];for(let n of e){let e=n.group??``,r=t.find(t=>t.group===e);r?r.sections.push(n):t.push({group:e,sections:[n]})}return t}function sl(e,t){if(typeof e==`string`)return e;if(!rl(e))return null;let n=t.toLowerCase();for(let t of[n,n.split(`-`)[0],`en`]){let n=Object.entries(e).find(([e])=>e.toLowerCase()===t)?.[1];if(typeof n==`string`)return n}return Object.values(e).find(e=>typeof e==`string`)??null}function cl(e){return/[\u0000-\u001f\\]/.test(e)||e.length>500?!1:/^\/(?![/\\])/.test(e)||/^https?:\/\/[^\s/]+/i.test(e)}function ll(e,t,n){let r=rl(e)&&Array.isArray(e.footerLinks)?e.footerLinks:[],i=[];for(let e of r.slice(0,8)){if(!rl(e))continue;let r=sl(e.label,t),a=sl(e.href,t);if(!r||!nl(r,60)||!a||!cl(a)||n&&Array.isArray(e.placements)&&!e.placements.some(e=>e===n&&el.includes(e)))continue;let o=typeof e.icon==`string`&&cl(e.icon)?e.icon:null;i.push({label:r,href:a,newTab:e.newTab===!0||/^https?:/i.test(a),icon:o})}return i}function ul(e){let t=rl(e)?e.loginForm:void 0;return rl(t)&&typeof t.mount==`function`?t:null}function dl(e){let t=rl(e)?e.passwordCard:void 0;return!rl(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function fl(e){let t=rl(e)?e.onboarding:void 0;return rl(t)&&typeof t.mount==`function`?t:null}function pl(e){if(typeof e!=`string`||e.length>500)return null;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password?t.toString():null}catch{return null}}function ml(e,t,n){let r=rl(e)&&rl(e.starterPacks)?e.starterPacks:{},i=Array.isArray(r.packs)?r.packs:[],a=new Map;if(r.replace!==!0)for(let e of t)a.set(e.id,e);for(let e of i.slice(0,12))rl(e)&&typeof e.id==`string`&&tl.test(e.id)&&Array.isArray(e.feeds)&&a.set(e.id,e);let o=[];for(let e of a.values()){let t=sl(e.title,n);if(!t||!nl(t,60))continue;let r=[];for(let t of e.feeds.slice(0,20)){if(!rl(t)||!nl(t.title,80))continue;let e=pl(t.url);if(!e)continue;let i=sl(t.description,n);r.push({title:t.title,url:e,lang:typeof t.lang==`string`?t.lang.toLowerCase().split(`-`)[0]:``,description:i&&nl(i,200)?i:``})}r.length>0&&o.push({id:e.id,title:t,description:sl(e.description,n)??``,feeds:r})}return o}function hl(e){let t=rl(e)?e.articlesNotice:void 0;return!rl(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function gl(e,t){let n=rl(e)&&rl(e.meta)?e.meta:{},r=sl(n.title,t)?.trim()??null,i=sl(n.description,t)?.trim()??null;return{title:r&&nl(r,80)?r:null,description:i&&nl(i,300)?i:null}}function _l(e,t){if(!rl(e)||!Array.isArray(e.pages))return[];let n=[],r=new Set;for(let i of e.pages){if(!rl(i)||typeof i.id!=`string`||!tl.test(i.id)||r.has(i.id))continue;let e=sl(i.label,t);if(nl(e,40)&&typeof i.mount==`function`&&!(!Array.isArray(i.icon)||!i.icon.length||i.icon.length>8||!i.icon.every(e=>nl(e,400)))&&(n.push({id:i.id,label:e,icon:i.icon,mount:i.mount}),r.add(i.id),n.length===3))break}return n}var vl=0;function yl(e){let t=()=>{vl++,e()};return window.addEventListener($c,t),()=>window.removeEventListener($c,t)}function bl(){return(0,_.useSyncExternalStore)(yl,()=>vl),window.feedkeeperExtensions}function xl(){let{pageId:e}=vr(),{user:t}=lo(),{i18n:n}=z(),r=n.resolvedLanguage||`en`,i=_l(bl(),r).find(({id:t})=>t===e);return t&&i?(0,W.jsx)(Sl,{page:i,userId:t.id,language:r},t.id):null}function Sl({page:{mount:e},userId:t,language:n}){let r=(0,_.useRef)(null),[i,a]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!r.current)return;let i=r.current,o=!0,s;try{s=e(i,{userId:t,language:n,appendText:Cl,openArticle:(e,t)=>{o&&a({item:e,onChange:t})}})}catch(e){console.error(`Could not mount extension page`,e),i.replaceChildren()}return()=>{o=!1,typeof s==`function`&&s(),i.replaceChildren(),a(null)}},[e,t,n]);function o(e){i&&i.item.id===e.id&&(i.onChange(e),a(t=>t?.item.id===e.id?{...t,item:{...t.item,...e}}:t))}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{ref:r}),i&&(0,W.jsx)(Qc,{item:i.item,isOpen:!0,onClose:()=>a(null),onItemUpdated:e=>o({...i.item,...e}),onToggleRead:e=>{ya(`read`,e.id,!e.read).then(()=>{no(),o({...e,read:!e.read})}).catch(console.error)},onToggleBookmark:e=>{ya(`bookmark`,e.id,!e.bookmarked).then(()=>o({...e,bookmarked:!e.bookmarked})).catch(console.error)}})]})}function Cl(e,t){Ao(t)&&(e.lang=`ja`);for(let n of Jo(t))if(n.kind===`wbr`)e.append(document.createElement(`wbr`));else if(n.kind===`nb`){let t=document.createElement(`span`);t.className=`nb`,t.textContent=n.value,e.append(t)}else e.append(n.value)}var wl=`M435.6,124.8l0,-73.2l-435.6,0l-0,816l92.4,-0l0,-381.6l325.2,0l-0,-74.4l-325.2,0l0,-286.8l343.2,0zM1065.6,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM1722,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM2396.4,830.4l0,-830.4l-90,0l0,278.4c-18,-8.4,-97.2,-39.6,-188.4,-39.6c-164.4,0,-262.8,106.8,-262.8,306c0,242.4,86.4,337.2,279.6,337.2c121.2,-0,216,-32.4,261.6,-51.6zm-90,-48c-21.6,12,-84,33.6,-171.6,33.6c-129.6,0,-188.4,-78,-188.4,-271.2c0,-159.6,63.6,-238.8,189.6,-238.8c72,0,146.4,28.8,170.4,38.4l0,438zM3187.2,867.6l-386.4,-427.2l355.2,-388.8l-120,0l-340.8,388.8l367.2,427.2l124.8,-0zm-494.4,-0l-0,-816l-92.4,0l0,816l92.4,-0zM3776.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM4432.8,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM5133.6,544.8c0,-210,-92.4,-306,-282,-306c-118.8,0,-231.6,36,-260.4,50.4l-0,832.8l90,0l0,-280.8c16.8,13.2,99.6,40.8,187.2,40.8c165.6,0,265.2,-92.4,265.2,-337.2zm-93.6,0c0,194.4,-57.6,271.2,-188.4,271.2c-69.6,0,-141.6,-25.2,-170.4,-37.2l0,-439.2c18,-8.4,81.6,-33.6,171.6,-33.6c120,0,187.2,68.4,187.2,238.8zM5792.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM6256.8,313.2l0,-68.4c-9.6,-1.2,-50.4,-6,-66,-6c-106.8,0,-223.2,39.6,-240,48l-0,580.8l90,-0l0,-531.6c16.8,-6,90,-28.8,158.4,-28.8c14.4,0,45.6,3.6,57.6,6z`;function Tl(){return(0,W.jsx)(`svg`,{className:`wordmark`,viewBox:`0 0 6257 1122`,role:`img`,"aria-label":`FeedKeeper`,children:(0,W.jsx)(`path`,{d:wl})})}function El({size:e=28}){return(0,W.jsxs)(`span`,{className:`brand-lockup`,style:{"--m":`${e}px`},children:[(0,W.jsx)(`img`,{src:`/logo.svg`,alt:``}),(0,W.jsx)(Tl,{})]})}var Dl=({isActive:e})=>`relative z-10 flex h-full items-center gap-2 rounded-lg px-3 text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${e?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`;function Ol({onItemsClick:e,pages:t}){let{t:n,i18n:r}=z(),i=dr(),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(null),c=t.map(({id:e,label:t})=>e+t).join(`|`);return(0,_.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=e.querySelector(`a[aria-current="page"]`);s(t?{left:t.offsetLeft,width:t.offsetWidth}:null)};t();let n=new ResizeObserver(t);return e.querySelectorAll(`a`).forEach(e=>n.observe(e)),()=>n.disconnect()},[i.pathname,r.resolvedLanguage,c]),(0,W.jsxs)(`nav`,{ref:a,className:`relative hidden h-9 items-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-0.5 md:flex`,children:[o&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0.5 left-0 rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-[transform,width] duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{width:o.width,transform:`translateX(${o.left}px)`}}),t.map(({id:e,label:t,icon:n})=>(0,W.jsxs)(Mi,{to:`/extensions/${e}`,className:Dl,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:n.map(e=>(0,W.jsx)(`path`,{d:e},e))}),t]},e)),(0,W.jsxs)(Mi,{to:`/items`,onClick:e,className:Dl,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),n(`nav.items`)]}),(0,W.jsxs)(Mi,{to:`/feeds`,className:Dl,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,W.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,W.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),n(`nav.feeds`)]})]})}function kl({label:e}){return(0,W.jsx)(`kbd`,{className:`inline-flex min-w-7 items-center justify-center rounded-md border border-[var(--c-border)] bg-[var(--c-surface-hover)] px-2 py-0.5 font-sans text-xs font-semibold text-[var(--c-text)] shadow-xs`,children:e})}function Al({isOpen:e,onClose:t}){let{t:n}=z(),r=(0,_.useId)();return(0,_.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),e?(0,W.jsx)(`div`,{"data-shortcuts-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs animate-fade-in`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":r,className:`card w-full max-w-2xl max-h-[85vh] overflow-y-auto p-5 sm:p-6 shadow-2xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[var(--c-border)] pb-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{id:r,className:`text-lg font-semibold text-[var(--c-text)]`,children:n(`shortcuts.title`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:n(`shortcuts.subtitle`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`common.close`),title:n(`common.close`),className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-[var(--c-border)] text-[var(--c-text-muted)] transition-colors hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,W.jsx)(`div`,{className:`mt-5 grid gap-6 sm:grid-cols-2`,children:Bc.map(e=>(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`mb-2.5 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:n(e.titleKey)}),(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)]`,children:e.entries.map(t=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-[var(--c-text)]`,children:n(t.labelKey)}),(0,W.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:t.keys.map((e,n)=>t.keys.length>1&&e===`/`?(0,W.jsx)(`span`,{className:`px-0.5 text-xs text-[var(--c-text-muted)]`,children:`/`},`${n}-${e}`):(0,W.jsx)(kl,{label:e},`${n}-${e}`))})]},`${e.titleKey}:${t.labelKey}`))})]},e.titleKey))})]})}):null}var jl=`fk_theme`,Ml=new Set,Nl=(()=>{try{let e=localStorage.getItem(jl);return e===`light`||e===`dark`?e:`system`}catch{return`system`}})();function Pl(e){return Ml.add(e),()=>Ml.delete(e)}function Fl(){return Nl}function Il(e){Nl=e,e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e);try{e===`system`?localStorage.removeItem(jl):localStorage.setItem(jl,e)}catch{}Ml.forEach(e=>e())}function Ll({standalone:e,hasPrompt:t,userAgent:n,maxTouchPoints:r}){if(e)return`installed`;if(t)return`prompt`;if(/iPhone|iPad|iPod/.test(n)||/Macintosh/.test(n)&&r>1)return`ios`;let i=/Safari\//.test(n)&&!/Chrome|Chromium|CriOS|FxiOS|Edg|OPR|Firefox/.test(n);return/Macintosh/.test(n)&&i?`mac-safari`:`unsupported`}var Rl=null,zl=!1,Bl=new Set,Vl=()=>Bl.forEach(e=>e());function Hl(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Rl=e,Vl()}),window.addEventListener(`appinstalled`,()=>{Rl=null,zl=!0,Vl()})}function Ul(e){Bl.add(e);let t=window.matchMedia(`(display-mode: standalone)`);return t.addEventListener(`change`,e),()=>{Bl.delete(e),t.removeEventListener(`change`,e)}}function Wl(){return Ll({standalone:zl||window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,hasPrompt:Rl!==null,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints??0})}async function Gl(){let e=Rl;if(!e)return;Rl=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`accepted`&&(zl=!0),Vl()}function Kl(e,t){let n=e.trim().split(/\s+/).filter(Boolean);return n.length===0?t.charAt(0).toUpperCase()||`?`:(n[0].charAt(0)+(n.length>1?n[n.length-1].charAt(0):``)).toUpperCase()}function ql({user:e,className:t=``}){let n=Ca(e),[r,i]=(0,_.useState)(null);return(0,W.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full border border-[var(--c-border)] bg-[var(--c-mobile-nav-active)] font-semibold tracking-wide text-[var(--c-text)] ${t}`,children:n&&r!==n?(0,W.jsx)(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,onError:()=>i(n)}):(0,W.jsx)(`span`,{"aria-hidden":`true`,children:Kl(e.display_name,e.email)})})}var Jl={login:`mt-4 justify-center text-xs`,menu:`border-t border-[var(--c-border)] px-3 py-2.5 text-xs`,page:`mt-10 border-t border-[var(--c-border)] pt-4 text-xs`};function Yl({placement:e}){let{t,i18n:n}=z(),r=ll(bl(),n.resolvedLanguage||`en`,e);return r.length===0?null:(0,W.jsx)(`nav`,{"aria-label":t(`nav.footerLinks`),className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[var(--c-text-muted)] ${Jl[e]}`,children:r.map((e,t)=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-3`,children:[t>0&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`opacity-50`,children:`•`}),(0,W.jsxs)(`a`,{href:e.href,...e.newTab?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`transition-colors hover:text-[var(--c-text)] hover:underline`,children:[e.icon&&(0,W.jsx)(`img`,{src:e.icon,alt:``,width:14,height:14,className:`mr-1.5 inline-block align-[-2px]`}),e.label]})]},`${e.href}-${t}`))})}var Xl={light:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,W.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]}),dark:(0,W.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`}),system:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,W.jsx)(`path`,{d:`M12 3a9 9 0 0 1 0 18Z`,fill:`currentColor`,stroke:`none`})]})},Zl=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium text-[var(--c-text)] transition-colors hover:bg-[var(--c-surface-hover)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer`;function Ql({onOpenShortcuts:e}){let{t}=z(),{user:n,logout:r}=lo(),i=dr(),a=(0,_.useSyncExternalStore)(Pl,Fl),o=(0,_.useSyncExternalStore)(Ul,Wl),[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useId)();if((0,_.useEffect)(()=>c(!1),[i.pathname]),(0,_.useEffect)(()=>{if(!s)return;let e=e=>{l.current?.contains(e.target)||c(!1)},t=e=>{e.key===`Escape`&&(c(!1),u.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[s]),!n)return null;let f={light:t(`settings.themeLight`),dark:t(`settings.themeDark`),system:t(`settings.themeSystem`)};return(0,W.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,W.jsx)(`button`,{ref:u,type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-controls":d,"aria-label":t(`nav.account`),title:n.display_name||n.email,className:`flex rounded-full transition-shadow cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--c-blue3)] ${s||i.pathname.startsWith(`/settings`)?`ring-2 ring-[var(--c-blue3)] ring-offset-2 ring-offset-[var(--c-surface)]`:`hover:ring-2 hover:ring-[var(--c-border)] hover:ring-offset-2 hover:ring-offset-[var(--c-surface)]`}`,children:(0,W.jsx)(ql,{user:n,className:`h-9 w-9 text-xs`})}),s&&(0,W.jsxs)(`div`,{id:d,className:`card animate-fade-in absolute right-0 top-full z-50 mt-2 w-72 max-w-[calc(100vw-2rem)] p-1.5 shadow-xl`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 pt-2 pb-3`,children:[(0,W.jsx)(ql,{user:n,className:`h-10 w-10 text-sm`}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-semibold text-[var(--c-text)]`,children:n.display_name||n.email}),n.display_name&&(0,W.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:n.email})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-[var(--c-border)] px-3 py-3`,children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t(`settings.theme`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-xl border border-[var(--c-border)] p-0.5`,role:`group`,"aria-label":t(`settings.theme`),children:Object.keys(Xl).map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Il(e),"aria-pressed":a===e,className:`flex h-8 items-center justify-center gap-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${a===e?`border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)] shadow-sm`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,W.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:Xl[e]}),f[e]]},e))})]}),(0,W.jsxs)(`div`,{className:`flex flex-col border-t border-[var(--c-border)] pt-1.5`,children:[(0,W.jsxs)(Mi,{to:`/settings`,className:`${Zl} max-md:hidden`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,W.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),t(`nav.settings`)]}),e&&(0,W.jsxs)(`button`,{type:`button`,className:`${Zl} hidden md:flex justify-between`,onClick:()=>{c(!1),e()},children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`}),(0,W.jsx)(`path`,{d:`M6 10h.01M10 10h.01M14 10h.01M18 10h.01M8 14h8`})]}),t(`shortcuts.title`)]}),(0,W.jsx)(`kbd`,{className:`rounded border border-[var(--c-border)] bg-[var(--c-surface-hover)] px-1.5 py-0.5 text-[11px] font-semibold text-[var(--c-text-muted)]`,children:`?`})]}),o===`prompt`&&(0,W.jsxs)(`button`,{type:`button`,className:Zl,onClick:()=>{c(!1),Gl()},children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,W.jsx)(`path`,{d:`M5 21h14`})]}),t(`settings.installApp`)]}),(0,W.jsxs)(`button`,{type:`button`,className:`${Zl} text-[var(--c-danger)]! hover:bg-[var(--c-danger-bg)]!`,onClick:()=>{c(!1),r()},children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,W.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,W.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]}),t(`nav.logout`)]})]}),(0,W.jsx)(Yl,{placement:`menu`})]})]})}function $l(e){return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}}function eu(){return(0,_.useSyncExternalStore)($l,()=>navigator.onLine,()=>!0)}function tu(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(na,ta,()=>0);return eu()?null:(0,W.jsxs)(`div`,{role:`status`,className:`border-b px-4 py-2 text-center text-sm text-[var(--c-text-muted)]`,style:{borderColor:`var(--c-border)`,backgroundColor:`var(--c-surface)`},children:[e(`common.offlineBanner`),t>0&&` ${e(`common.offlinePending`,{count:t})}`]})}function nu(){let{t:e}=z(),{refresh:t}=lo();return(0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-[var(--c-bg)] px-6 text-center`,children:[(0,W.jsx)(`img`,{src:`/logo.svg`,alt:``,className:`h-12 w-12`}),(0,W.jsx)(`h1`,{className:`text-xl font-semibold`,style:{fontFamily:`Manrope, sans-serif`},children:e(`common.offlineTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`common.offlineText`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void t(),className:`btn-primary`,children:e(`common.retry`)})]})}var q=[],ru=1,iu=new Set,au=()=>iu.forEach(e=>e());function ou(e){return iu.add(e),()=>iu.delete(e)}function su(){return q}function cu(e){q=q.filter(t=>t.id!==e),au()}function lu(e,t){let n=ru++;q=[...q.slice(-2),{id:n,type:e,message:t}],au(),window.setTimeout(()=>cu(n),e===`error`?7e3:4e3)}var J={success:e=>lu(`success`,e),error:e=>lu(`error`,e),info:e=>lu(`info`,e)};function uu(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(ou,su);return(0,W.jsx)(`div`,{"aria-live":`polite`,className:`pointer-events-none fixed inset-x-0 bottom-[calc(6.5rem+env(safe-area-inset-bottom,0px))] z-[60] flex flex-col items-center gap-2 px-4 md:bottom-6`,children:t.map(t=>(0,W.jsxs)(`div`,{role:t.type===`error`?`alert`:`status`,className:`card animate-fade-in pointer-events-auto flex w-full max-w-md items-start gap-3 px-4 py-3 text-sm`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,W.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-white ${t.type===`error`?`bg-[var(--c-danger)]`:t.type===`info`?`bg-[var(--c-text-muted)]`:`bg-[var(--c-green3)]`}`,"aria-hidden":`true`,children:(0,W.jsx)(`svg`,{className:`h-3 w-3`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:t.type===`error`?(0,W.jsx)(`path`,{d:`M12 7v6M12 17h.01`}):t.type===`info`?(0,W.jsx)(`path`,{d:`M12 7h.01M12 11v6`}):(0,W.jsx)(`path`,{d:`m5 12 5 5 9-10`})})}),(0,W.jsx)(`p`,{className:`min-w-0 flex-1 text-[var(--c-text)]`,children:t.message}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>cu(t.id),"aria-label":e(`common.close`),className:`-mr-1 shrink-0 rounded p-0.5 text-[var(--c-text-muted)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},t.id))})}var du=[.75,1,1.25,1.5,2],fu=[null,15,30,60];function pu(){let{t:e}=z(),t=mo(),[n,r]=(0,_.useState)(!1),i=t.currentItem;if(!i)return null;let a=t.duration>0?t.duration:i.enclosure_duration_seconds??0,o=a>0?Math.min(100,Math.max(0,t.currentTime/a*100)):0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{role:`region`,"aria-label":e(`player.nowPlaying`),className:`fixed bottom-[78px] md:bottom-4 left-3 right-3 md:left-auto md:right-6 md:w-[420px] z-40 rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)]/95 backdrop-blur-md shadow-xl overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`h-0.5 w-full bg-[var(--c-border)]`,children:(0,W.jsx)(`div`,{className:`h-full bg-[var(--c-blue3)] transition-all duration-200`,style:{width:`${o}%`}})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3.5 py-2.5`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex min-w-0 flex-1 items-center gap-3 text-left cursor-pointer`,children:[i.image_url?(0,W.jsx)(`img`,{src:i.image_url,alt:``,className:`h-10 w-10 rounded-lg object-cover shrink-0 border border-[var(--c-border)]`}):(0,W.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-[var(--c-surface-hover)] border border-[var(--c-border)] flex items-center justify-center shrink-0 text-[var(--c-text-muted)]`,children:(0,W.jsxs)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M3 18v-6a9 9 0 0 1 18 0v6`}),(0,W.jsx)(`path`,{d:`M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z`})]})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-[var(--c-text)]`,children:i.title}),(0,W.jsxs)(`div`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:[i.feed_title??``,a>0?` · ${Yc(t.currentTime)} / ${Yc(a)}`:``]})]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.skip(-15),"aria-label":e(`player.back15`),className:`hidden sm:flex h-8 w-8 items-center justify-center rounded-full text-xs font-semibold text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:`-15`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.togglePlay(),"aria-label":t.isPlaying?e(`player.pause`):e(`player.play`),className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:t.isPlaying?(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-4 h-4 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.stop(),"aria-label":e(`common.close`),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]}),n&&(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/60 backdrop-blur-xs p-0 sm:p-4`,onClick:()=>r(!1),children:(0,W.jsxs)(`div`,{className:`w-full sm:max-w-md rounded-t-2xl sm:rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)] p-5 shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-[0.08em] text-[var(--c-text-muted)]`,children:e(`player.nowPlaying`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(!1),"aria-label":e(`common.close`),className:`h-8 w-8 rounded-full flex items-center justify-center text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),i.image_url&&(0,W.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,W.jsx)(`img`,{src:i.image_url,alt:``,className:`w-48 h-48 rounded-2xl object-cover border border-[var(--c-border)] shadow-md`})}),(0,W.jsx)(`h2`,{className:`text-lg font-bold text-[var(--c-text)] leading-snug text-center mb-1`,children:i.title}),(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)] text-center mb-5`,children:i.feed_title}),a>0&&(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`input`,{type:`range`,min:0,max:a,value:Math.min(t.currentTime,a),onChange:e=>t.seek(Number(e.target.value)),className:`w-full accent-[var(--c-blue3)] cursor-pointer`}),(0,W.jsxs)(`div`,{className:`flex justify-between text-xs font-mono text-[var(--c-text-muted)] mt-1`,children:[(0,W.jsx)(`span`,{children:Yc(t.currentTime)}),(0,W.jsx)(`span`,{children:Yc(a)})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-6 mb-5`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.skip(-15),className:`px-3 py-1.5 rounded-lg text-sm font-semibold text-[var(--c-text)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:`-15s`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.togglePlay(),className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:t.isPlaying?(0,W.jsxs)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-5 h-5 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.skip(30),className:`px-3 py-1.5 rounded-lg text-sm font-semibold text-[var(--c-text)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:`+30s`})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-[var(--c-border)] pt-4 mb-4`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-1`,children:du.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>t.setRate(e),className:`rounded-md px-2 py-1 text-xs font-semibold cursor-pointer ${t.playbackRate===e?`bg-[var(--c-blue3)] text-white`:`bg-[var(--c-surface-hover)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[e,`x`]},e))}),(0,W.jsx)(`div`,{className:`flex items-center gap-1`,children:fu.map(n=>{let r=n===null?t.sleepRemainingSec===null:t.sleepRemainingSec!==null&&Math.ceil(t.sleepRemainingSec/60)<=n&&Math.ceil(t.sleepRemainingSec/60)>(n===15?0:n===30?15:30);return(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.setSleepTimer(n),className:`rounded-md px-2 py-1 text-xs font-medium cursor-pointer ${r?`bg-[var(--c-blue3)]/20 text-[var(--c-text)] border border-[var(--c-blue3)]/50`:`bg-[var(--c-surface-hover)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:n===null?e(`player.sleepOff`):`${n}m`},String(n))})})]}),t.chapters.length>0&&(0,W.jsxs)(`div`,{className:`border-t border-[var(--c-border)] pt-3`,children:[(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.06em] text-[var(--c-text-muted)] mb-2`,children:e(`reader.chapters`)}),(0,W.jsx)(`ul`,{className:`max-h-44 overflow-y-auto flex flex-col gap-1`,children:t.chapters.map((e,n)=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>t.seek(e.startTime),className:`w-full text-left px-2 py-1.5 rounded-lg text-sm hover:bg-[var(--c-surface-hover)] flex items-center gap-3 cursor-pointer`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-[var(--c-text-muted)] shrink-0`,children:Yc(e.startTime)}),(0,W.jsx)(`span`,{className:`truncate text-[var(--c-text)]`,children:e.title})]})},`${e.startTime}-${n}`))})]})]})})]})}function mu(){let{t:e,i18n:t}=z(),n=_l(bl(),t.resolvedLanguage||`en`),r=dr(),[i,a]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=e=>{Vc(e.target)||Hc(e)||e.key===`?`&&(e.preventDefault(),a(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,_.useEffect)(()=>{let e=()=>void za(),t=()=>document.visibilityState===`visible`&&e();return e(),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},[]),(0,_.useEffect)(()=>{let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>void eo(),800)},n=()=>document.visibilityState===`visible`&&t();t();let r=window.setInterval(t,12e4);window.addEventListener(`online`,t),document.addEventListener(`visibilitychange`,n);let i=ro(t);return()=>{window.clearTimeout(e),window.clearInterval(r),window.removeEventListener(`online`,t),document.removeEventListener(`visibilitychange`,n),i()}},[]),(0,_.useEffect)(()=>{r.pathname!==`/items`&&(window.scrollTo({top:0,left:0,behavior:`instant`}),requestAnimationFrame(()=>{window.scrollTo({top:0,left:0,behavior:`instant`})}))},[r.pathname]);let o=()=>{r.pathname===`/items`&&(Ka(),window.scrollTo({top:0,left:0,behavior:`smooth`}))},s=n.findIndex(({id:e})=>r.pathname===`/extensions/${e}`),c=s>=0?s:n.length+(r.pathname.startsWith(`/feeds`)?1:r.pathname.startsWith(`/settings`)?2:0);return(0,W.jsxs)(`div`,{className:`min-h-screen flex flex-col`,children:[(0,W.jsx)(`header`,{"data-app-header":!0,className:`sticky top-0 z-30 backdrop-blur-md border-b`,style:{borderColor:`var(--c-border)`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`,paddingTop:`env(safe-area-inset-top, 0px)`},children:(0,W.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-3 flex items-center justify-between gap-4`,children:[(0,W.jsx)(Mi,{to:`/items`,onClick:o,className:`flex items-center gap-2.5 shrink-0 hover:opacity-85 transition-opacity`,children:(0,W.jsx)(El,{size:28})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(Ol,{onItemsClick:o,pages:n}),(0,W.jsx)(Ql,{onOpenShortcuts:()=>a(!0)})]})]})}),(0,W.jsx)(tu,{}),(0,W.jsx)(`main`,{className:`flex-1 max-w-5xl w-full mx-auto px-4 pt-4 pb-24 md:py-6`,children:(0,W.jsx)(`div`,{className:`animate-page-fade`,children:(0,W.jsx)(Vr,{})},r.pathname)}),(0,W.jsx)(uu,{}),(0,W.jsx)(pu,{}),(0,W.jsx)(Al,{isOpen:i,onClose:()=>a(!1)}),(0,W.jsx)(`nav`,{className:`mobile-bottom-nav md:hidden fixed left-3 right-3 max-w-sm mx-auto z-40 pointer-events-auto no-drag select-none`,"aria-label":e(`nav.menu`),children:(0,W.jsxs)(`div`,{className:`relative flex items-center justify-between p-1.5 rounded-full border backdrop-blur-2xl backdrop-saturate-180 transition-all duration-300 no-drag select-none`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 80%, transparent)`,borderColor:`var(--c-border)`,borderWidth:`1px`,boxShadow:`0 2px 12px -4px rgba(0, 0, 0, 0.3)`},onContextMenu:e=>e.preventDefault(),children:[(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`absolute top-1.5 bottom-1.5 left-1.5 rounded-full bg-[var(--c-mobile-nav-active)] border border-[var(--c-mobile-nav-active-border)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] pointer-events-none no-drag`,style:{width:`calc((100% - 0.75rem) / ${3+n.length})`,transform:`translateX(calc(${c} * 100%))`}}),n.map(({id:e,label:t,icon:n})=>(0,W.jsx)(Mi,{to:`/extensions/${e}`,draggable:!1,className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:e})=>(0,W.jsxs)(`span`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 ${e?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] font-medium`}`,children:[(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:n.map(e=>(0,W.jsx)(`path`,{d:e},e))}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight text-center`,children:t})]})},e)),(0,W.jsx)(Mi,{to:`/items`,onClick:o,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,W.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,W.jsx)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.items`)})]})}),(0,W.jsx)(Mi,{to:`/feeds`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,W.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,W.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,W.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,W.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.feeds`)})]})}),(0,W.jsx)(Mi,{to:`/settings`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,W.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,W.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,W.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.settings`)})]})})]})})]})}function hu(){let{t:e}=z(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);async function f(r){r.preventDefault(),d(!0),l(null);try{await U.onboard({email:n,password:o,displayName:i}),await t()}catch{l(e(`common.error`))}finally{d(!1)}}return(0,W.jsx)(`div`,{className:`min-h-screen flex items-center justify-center px-4`,children:(0,W.jsxs)(`div`,{className:`card p-8 w-full max-w-md`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,W.jsx)(`h1`,{className:`mb-3`,children:(0,W.jsx)(El,{size:44})}),(0,W.jsx)(`p`,{className:`text-sm mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.subtitle`)})]}),(0,W.jsxs)(`form`,{onSubmit:f,className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.emailLabel`)}),(0,W.jsx)(`input`,{type:`email`,required:!0,className:`input`,value:n,onChange:e=>r(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.displayNameLabel`)}),(0,W.jsx)(`input`,{type:`text`,required:!0,className:`input`,value:i,onChange:e=>a(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.passwordLabel`)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,className:`input`,value:o,onChange:e=>s(e.target.value)}),(0,W.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.passwordHint`)})]}),c&&(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:c}),(0,W.jsx)(`button`,{type:`submit`,disabled:u,className:`btn-primary`,children:e(`onboarding.submit`)})]}),(0,W.jsxs)(`div`,{className:`mt-6 pt-4 border-t text-sm`,style:{borderColor:`var(--c-border)`},children:[(0,W.jsx)(`p`,{className:`font-medium`,children:e(`onboarding.orUseCli`)}),(0,W.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`onboarding.cliHint`)})]})]})})}function gu(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Y(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function _u(){return vu.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var vu={stubThis:e=>e};function yu(e){let{id:t}=e;return{...e,id:Y(t),transports:e.transports,type:e.type}}function bu(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var xu=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function Su({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new xu({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new xu({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new xu({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new xu({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new xu({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new xu({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new xu({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new xu({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!bu(t))return new xu({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new xu({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new xu({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new xu({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var Cu=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},wu=[`cross-platform`,`platform`];function Tu(e){if(e&&!(wu.indexOf(e)<0))return e}async function Eu(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!_u())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:Y(t.challenge),user:{...t.user,id:Y(t.user.id)},excludeCredentials:t.excludeCredentials?.map(yu)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=Cu.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw Su({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){Du(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=gu(e))}catch(e){Du(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=gu(c.getAuthenticatorData())}catch(e){Du(`getAuthenticatorData()`,e)}return{id:o,rawId:gu(s),response:{attestationObject:gu(c.attestationObject),clientDataJSON:gu(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:Tu(a.authenticatorAttachment)}}function Du(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Ou(){if(!_u())return ku.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?ku.stubThis(new Promise(e=>e(!1))):ku.stubThis(e.isConditionalMediationAvailable())}var ku={stubThis:e=>e};function Au({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new xu({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new xu({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!bu(t))return new xu({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new xu({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new xu({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function ju(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!_u())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(yu));let a={...t,challenge:Y(t.challenge),allowCredentials:i},o={};if(n){if(!await Ou())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=Cu.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Au({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=gu(u.userHandle)),{id:c,rawId:gu(l),response:{authenticatorData:gu(u.authenticatorData),clientDataJSON:gu(u.clientDataJSON),signature:gu(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Tu(s.authenticatorAttachment)}}async function Mu(e,t,n=`POST`,r){let i=await fetch(`/api/auth/security${e}`,{method:n,signal:r,credentials:`same-origin`,headers:{"Content-Type":`application/json`},...t===void 0?{}:{body:JSON.stringify(t)}}),a=i.status===204?void 0:await i.json();if(!i.ok)throw new va(i.status,a.error,a);return a}async function Nu(){let e=await Mu(`/reauth/passkey/options`,{}),t=await ju({optionsJSON:e.publicKey});return(await Mu(`/reauth/passkey/verify`,{challengeId:e.challengeId,credential:t})).reauthToken}async function Pu(e,t){let n=await Mu(`/passkeys/register/options`,{reauthToken:e}),r=await Eu({optionsJSON:n.publicKey});await Mu(`/passkeys/register/verify`,{challengeId:n.challengeId,credential:r,name:t})}function Fu(e){let t,n;function r(){t?.abort(),t=void 0,clearTimeout(n)}async function i(a=!0){if(t&&a)return;r();let o=new AbortController,{signal:s}=o;t=o;let c=!1;try{if(a){let t=await window.PublicKeyCredential?.isConditionalMediationAvailable?.().catch(()=>!1)??!1;if(s.aborted||(e.onAutofill(t),!t))return}let t=await Mu(`/passkeys/options`,{},`POST`,s);if(s.aborted)return;a&&(n=setTimeout(()=>{r(),i()},24e4));let o=await navigator.credentials.get({signal:s,...a?{mediation:`conditional`}:{},publicKey:{...t.publicKey,extensions:t.publicKey.extensions,challenge:Y(t.publicKey.challenge),allowCredentials:a?[]:t.publicKey.allowCredentials?.map(e=>({type:`public-key`,id:Y(e.id),transports:e.transports}))}});if(s.aborted||!o)return;clearTimeout(n),c=!0,e.onSelect();let l=o.response,u={id:o.id,rawId:gu(o.rawId),type:o.type,clientExtensionResults:o.getClientExtensionResults(),response:{clientDataJSON:gu(l.clientDataJSON),authenticatorData:gu(l.authenticatorData),signature:gu(l.signature),userHandle:l.userHandle?gu(l.userHandle):null}};await Mu(`/passkeys/verify`,{challengeId:t.challengeId,credential:u},`POST`,s),s.aborted||await e.onSuccess()}catch(t){s.aborted||(c||!a?e.onError(t):t instanceof Error&&t.name===`NotAllowedError`||e.onAutofill(!1))}finally{t===o&&(clearTimeout(n),t=void 0)}}return{start:i,stop:r}}function Iu({name:e,mount:t}){let n=(0,_.useRef)(null),r=z().i18n.resolvedLanguage;return(0,_.useEffect)(()=>{let r=n.current;if(!r)return;let i;try{i=t(r)}catch(t){console.error(`[extensions] "${e}" failed to open`,t)}return()=>{try{typeof i==`function`&&i()}catch(t){console.error(`[extensions] "${e}" failed to close`,t)}r.replaceChildren()}},[e,r]),(0,W.jsx)(`div`,{ref:n,className:`min-w-0`})}function Lu(){let{t:e}=z(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),f=(0,_.useRef)(void 0),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)(`https://github.com/visualfusion/feedkeeper`),[w,T]=(0,_.useState)(null),E=ul(bl()),D=E?.mount,O=(0,_.useEffectEvent)(async()=>{await j(),y(!1)}),k=(0,_.useEffectEvent)(()=>{g(e(`login.error`)),y(!1)});(0,_.useEffect)(()=>{if(!c||i||D)return;let e=Fu({onAutofill:d,onSelect:()=>{y(!0),g(null)},onSuccess:O,onError:k});f.current=e,e.start();let t=()=>{e.start()},n=()=>{e.stop(),y(!1)};return window.addEventListener(`pagehide`,n),window.addEventListener(`pageshow`,t),()=>{e.stop(),f.current=void 0,window.removeEventListener(`pagehide`,n),window.removeEventListener(`pageshow`,t)}},[c,i,D]),(0,_.useEffect)(()=>{Mu(`/config`,void 0,`GET`).then(e=>l(e.passkeys)).catch(()=>{}),U.getConfig().then(e=>{e&&(x(e.showGithubLink),e.githubUrl&&C(e.githubUrl),e.loginSubtitle&&T(e.loginSubtitle))}).catch(()=>{})},[]);async function A(t){if(t.preventDefault(),!v){f.current?.stop(),y(!0),g(null);try{i?await Mu(`/mfa`,{challengeId:i,code:o}):await U.login(n,p),await j()}catch(t){t instanceof va&&t.code===`mfa_required`?(a(t.data.challengeId),m(``)):(g(e(`login.error`)),f.current?.start())}finally{y(!1)}}}async function j(){let e=new URLSearchParams(window.location.search).get(`next`);e?.startsWith(`/oauth/authorize?`)?window.location.assign(e):await t()}return(0,W.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center px-4`,children:[(0,W.jsxs)(`div`,{className:`card p-8 w-full max-w-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,W.jsx)(`h1`,{className:`mb-3`,children:(0,W.jsx)(El,{size:44})}),(0,W.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:w??e(`login.subtitle`)})]}),E?(0,W.jsx)(Iu,{name:`login-form`,mount:E.mount}):(0,W.jsxs)(`form`,{onSubmit:A,className:`flex flex-col gap-4`,children:[!i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`login-email`,className:`text-sm font-medium block mb-1`,children:e(`login.emailLabel`)}),(0,W.jsx)(`input`,{id:`login-email`,name:`username`,type:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,className:`input`,value:n,onChange:e=>r(e.target.value),onFocus:()=>{v||f.current?.start()}})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`login-password`,className:`text-sm font-medium block mb-1`,children:e(`login.passwordLabel`)}),(0,W.jsx)(`input`,{type:`password`,id:`login-password`,name:`password`,autoComplete:`current-password`,required:!0,className:`input`,value:p,onChange:e=>m(e.target.value)})]})]}),i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`label`,{htmlFor:`mfa-code`,children:e(`security.code`)}),(0,W.jsx)(`input`,{id:`mfa-code`,className:`input`,autoFocus:!0,autoComplete:`one-time-code`,value:o,onChange:e=>s(e.target.value),required:!0}),(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{a(void 0),s(``)},children:e(`security.cancel`)})]}),c&&!i&&u===!1&&(0,W.jsx)(`button`,{type:`button`,className:`text-sm underline`,disabled:v,onClick:()=>void f.current?.start(!1),children:e(`security.signInPasskey`)}),h&&(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:h}),(0,W.jsx)(`button`,{type:`submit`,disabled:v,className:`btn-primary`,children:e(`login.submit`)})]})]}),(0,W.jsx)(Yl,{placement:`login`}),b&&(0,W.jsx)(`div`,{className:`mt-4 text-center`,children:(0,W.jsxs)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-[var(--c-text-muted)] hover:text-[var(--c-text)] transition-colors opacity-80 hover:opacity-100`,children:[(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z`})}),(0,W.jsx)(`span`,{children:e(`login.viewOnGithub`)})]})})]})}function Ru({className:e=``,size:t=`md`,center:n=!0}){let{t:r}=z(),i=(0,W.jsx)(`div`,{className:`rounded-full animate-spin border-[var(--c-border)] border-t-[var(--c-blue1)] dark:border-t-white/80 ${{sm:`w-5 h-5 border-2`,md:`w-8 h-8 border-[2.5px]`,lg:`w-10 h-10 border-3`}[t]} ${e}`,role:`status`,"aria-label":r(`common.loading`)});return n?(0,W.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[45vh] w-full py-12 animate-fade-in`,children:i}):i}function zu({label:e,items:t,className:n=``}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useId)();return(0,_.useLayoutEffect)(()=>{if(!r||!c.current)return;let e=c.current.getBoundingClientRect();o(window.innerHeight-e.bottom<48*t.length+24)},[r,t.length]),(0,_.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&(i(!1),c.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,W.jsxs)(`div`,{ref:s,className:`relative ${n}`,children:[(0,W.jsx)(`button`,{ref:c,type:`button`,onClick:e=>{e.stopPropagation(),i(e=>!e)},"aria-label":e,title:e,"aria-expanded":r,"aria-controls":l,className:`flex h-9 w-9 items-center justify-center rounded-lg text-[var(--c-text-muted)] transition-colors hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer ${r?`bg-[var(--c-surface-hover)] text-[var(--c-text)]`:``}`,children:(0,W.jsxs)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.8`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.8`}),(0,W.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.8`})]})}),r&&(0,W.jsx)(`div`,{id:l,className:`card animate-fade-in absolute right-0 z-40 w-64 p-1.5 ${a?`bottom-full mb-2`:`top-full mt-2`}`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:t.map(e=>(0,W.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:t=>{t.stopPropagation(),i(!1),e.onSelect()},className:`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-default ${e.danger?`text-[var(--c-danger)] hover:bg-[var(--c-danger-bg)]`:`text-[var(--c-text)] hover:bg-[var(--c-surface-hover)]`}`,children:[e.icon&&(0,W.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center ${e.danger?``:`text-[var(--c-text-muted)]`}`,children:e.icon}),e.label]},e.label))})]})}function Bu(){let{user:e}=lo(),t=e?.capabilities;return{syncAllowed:!t||t.features.sync===!0,manageUrl:t?.manageUrl??null}}function Vu({value:e,onChange:t,options:n,placeholder:r,className:i=``,size:a=`md`,disabled:o=!1,ariaLabel:s}){let{t:c}=z(),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(-1),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useId)(),g=n.find(t=>t.value===e);(0,_.useEffect)(()=>{function e(e){p.current&&!p.current.contains(e.target)&&u(!1)}if(l)return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[l]),(0,_.useEffect)(()=>{if(l){let t=n.findIndex(t=>t.value===e);f(t>=0?t:0)}},[l,e,n]),(0,_.useEffect)(()=>{if(l&&d>=0&&m.current){let e=m.current.querySelector(`[data-index="${d}"]`);e&&e.scrollIntoView({block:`nearest`})}},[d,l]);function v(e){o||(l?e.key===`Escape`?(e.preventDefault(),u(!1)):e.key===`ArrowDown`?(e.preventDefault(),f(e=>e<n.length-1?e+1:0)):e.key===`ArrowUp`?(e.preventDefault(),f(e=>e>0?e-1:n.length-1)):e.key===`Home`?(e.preventDefault(),f(0)):e.key===`End`?(e.preventDefault(),f(n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d>=0&&d<n.length&&(t(n[d].value),u(!1))):(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(!0)))}let y=[];n.forEach((e,t)=>{let n=e.group??null,r=y.find(e=>e.groupName===n);r||(r={groupName:n,items:[]},y.push(r)),r.items.push({opt:e,index:t})});let b=a===`sm`;return(0,W.jsxs)(`div`,{ref:p,className:`relative inline-block ${i}`,onKeyDown:v,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(!1)},children:[(0,W.jsxs)(`button`,{type:`button`,id:h,role:`combobox`,"aria-label":s,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?`${h}-listbox`:void 0,"aria-activedescendant":l&&d>=0?`${h}-option-${d}`:void 0,disabled:o,onClick:()=>!o&&u(e=>!e),className:`w-full flex items-center justify-between gap-2 text-left font-normal transition-colors cursor-pointer select-none rounded-lg border bg-[var(--c-surface)] text-[var(--c-text)] shadow-xs hover:border-[var(--c-blue3)] focus:outline-none focus:border-[var(--c-blue3)] ${l?`border-[var(--c-blue3)]`:`border-[var(--c-border)]`} ${b?`px-2.5 py-1 text-xs min-h-[30px]`:`px-3 py-1.5 text-sm min-h-[38px]`} ${o?`opacity-50 cursor-not-allowed`:``}`,children:[(0,W.jsx)(`span`,{className:`truncate flex items-center gap-1.5`,children:g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`truncate`,children:g.label}),g.badge!==void 0&&(0,W.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:g.badge})]}):(0,W.jsx)(`span`,{style:{color:`var(--c-text-muted)`},children:r??`—`})}),(0,W.jsx)(`svg`,{className:`shrink-0 transition-transform duration-200 opacity-60 ${l?`rotate-180`:``} ${b?`w-3 h-3`:`w-3.5 h-3.5`}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),l&&(0,W.jsx)(`div`,{className:`absolute left-0 mt-1 w-full min-w-[180px] max-w-xs sm:max-w-none rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] shadow-lg z-50 overflow-hidden`,style:{backdropFilter:`blur(8px)`},children:(0,W.jsx)(`ul`,{ref:m,id:`${h}-listbox`,role:`listbox`,"aria-labelledby":h,className:`max-h-60 overflow-y-auto py-1 text-[var(--c-text)] focus:outline-none`,children:n.length===0?(0,W.jsx)(`li`,{className:`px-3 py-2 text-xs italic`,style:{color:`var(--c-text-muted)`},children:r??c(`common.noOptions`)}):y.map((n,r)=>(0,W.jsxs)(`li`,{role:`group`,"aria-label":n.groupName??void 0,children:[n.groupName&&(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider select-none border-t first:border-t-0`,style:{borderColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.groupName}),(0,W.jsx)(`ul`,{role:`presentation`,children:n.items.map(({opt:n,index:r})=>{let i=n.value===e,a=r===d;return(0,W.jsxs)(`li`,{id:`${h}-option-${r}`,"data-index":r,role:`option`,"aria-selected":i,onClick:()=>{t(n.value),u(!1)},onMouseEnter:()=>f(r),className:`flex items-center justify-between gap-2 cursor-pointer select-none transition-colors ${b?`px-2.5 py-1.5 text-xs`:`px-3 py-2 text-sm`} ${a?`bg-[var(--c-border)]/40 text-[var(--c-text)]`:`text-[var(--c-text)]`} ${i?`font-medium bg-[var(--c-blue1)]/10`:``}`,children:[(0,W.jsxs)(`span`,{className:`truncate flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:n.label}),n.badge!==void 0&&(0,W.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.badge})]}),i&&(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,style:{color:`var(--c-blue3)`},viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})]},n.value)})})]},n.groupName??`ungrouped-${r}`))})})]})}function Hu(e){if(!e)return!1;try{let t=new URL(e).hostname.toLowerCase();return t===`reddit.com`||t.endsWith(`.reddit.com`)}catch{return!1}}function Uu(e,t,n){let r=/^feed_http_(\d{3})$/.exec(t);if(r){let t=Number(r[1]);return t===404||t===410?e(`feeds.errors.notFound`,{status:t}):t===401||t===403?e(`feeds.errors.refused`,{status:t}):t===429?Hu(n)?e(`feeds.errors.redditLimited`):e(`feeds.errors.limited`):e(t>=400&&t<500&&t!==408&&t!==425?`feeds.errors.rejected`:`feeds.errors.unavailable`,{status:t})}return t===`feed_timeout`?e(`feeds.errors.timeout`):t===`feed_network_error`?e(`feeds.errors.network`):t===`feed_invalid_or_unavailable`?e(`feeds.errors.invalidFeed`):t}var Wu=[[`day`,864e5],[`hour`,36e5],[`minute`,6e4]];function Gu(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e.getTime()-n;for(let[e,t]of Wu)if(Math.abs(i)>=t)return r.format(Math.round(i/t),e);return r.format(0,`minute`)}function Ku({children:e,className:t=`h-4 w-4`}){return(0,W.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e})}var qu=({className:e})=>(0,W.jsxs)(Ku,{className:e,children:[(0,W.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.64-6.36`}),(0,W.jsx)(`path`,{d:`M21 3v6h-6`})]}),Ju=()=>(0,W.jsx)(Ku,{children:(0,W.jsx)(`path`,{d:`M2 12l4 4 6-7M10 16l2 0 8-9`})}),Yu=()=>(0,W.jsxs)(Ku,{children:[(0,W.jsx)(`path`,{d:`M12 20h9`}),(0,W.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),X=()=>(0,W.jsx)(Ku,{children:(0,W.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),Xu=({className:e})=>(0,W.jsx)(Ku,{className:e,children:(0,W.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),Z=()=>(0,W.jsxs)(Ku,{children:[(0,W.jsx)(`path`,{d:`M12 15V3M7 8l5-5 5 5`}),(0,W.jsx)(`path`,{d:`M5 21h14`})]}),Q=()=>(0,W.jsxs)(Ku,{children:[(0,W.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,W.jsx)(`path`,{d:`M5 21h14`})]}),Zu=()=>(0,W.jsx)(Ku,{children:(0,W.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}),Qu=()=>(0,W.jsxs)(Ku,{className:`h-4 w-4`,children:[(0,W.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,W.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),$u=()=>(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[6,12,18].flatMap(e=>[9,15].map(t=>(0,W.jsx)(`circle`,{cx:t,cy:e,r:`1.5`},`${t}-${e}`)))}),ed=()=>(0,W.jsx)(Ku,{className:`h-5 w-5`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),td=()=>(0,W.jsxs)(Ku,{className:`h-3.5 w-3.5 shrink-0`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,W.jsx)(`path`,{d:`M12 8v4M12 16h.01`})]}),nd=({className:e=`h-3.5 w-3.5`})=>(0,W.jsxs)(Ku,{className:e,children:[(0,W.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,W.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]});function rd(e,t){return t<60?e(`feeds.minutesShort`,{count:t}):e(`feeds.hoursShort`,{count:Math.round(t/60)})}function id(e){try{return e?new URL(e).hostname.replace(/^www\./,``):null}catch{return null}}function ad({feed:e,folderOptions:t,intervalOptions:n,onClose:r,onSaved:i}){let{t:a}=z(),[o,s]=(0,_.useState)(e.label?.trim()||e.title?.trim()||e.url),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(e.folder_id??null),[f,p]=(0,_.useState)(e.poll_interval_minutes),[m,h]=(0,_.useState)(e.kind_override??`auto`),[g,v]=(0,_.useState)(e.full_text_mode!==`never`),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(),[C,w]=(0,_.useState)(!1);async function T(){w(!0);try{await U.updateFeed(e.id,{...c?{label:o.trim()||null}:{},folderId:u,pollIntervalMinutes:f,fullTextMode:g?`auto`:`never`,kindOverride:m===`auto`?null:m,...y===void 0?{}:{notify:y},...x===void 0?{}:{badge:x}}),no(),J.success(a(`feeds.changesSaved`)),r(),await i()}catch{J.error(a(`common.error`))}finally{w(!1)}}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-[var(--c-border)] bg-[var(--c-bg)]/60 px-4 py-4 sm:px-5`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.labelPlaceholder`),(0,W.jsx)(`input`,{type:`text`,className:`input text-sm`,placeholder:e.title??e.url,value:o,onChange:e=>{s(e.target.value),l(!0)}})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.folder`),(0,W.jsx)(Vu,{value:u?String(u):``,onChange:e=>d(e?Number(e):null),options:t,className:`w-full`,placeholder:a(`feeds.noFolder`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.interval`),(0,W.jsx)(Vu,{value:String(f),onChange:e=>p(Number(e)),options:n,className:`w-full`})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.feedKind`),(0,W.jsx)(Vu,{value:m,onChange:h,options:[{value:`auto`,label:a(`feeds.kindAuto`)},{value:`article`,label:a(`feeds.kindArticle`)},{value:`audio`,label:a(`feeds.kindAudio`)},{value:`video`,label:a(`feeds.kindVideo`)}],className:`w-full`})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:g,onChange:e=>v(e.target.checked)}),(0,W.jsxs)(`span`,{children:[a(`feeds.fullText`),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:e.full_text_blocked_at?a(`feeds.fullTextBlocked`):a(`feeds.fullTextHint`)})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:y??e.notify!==0,onChange:e=>b(e.target.checked)}),(0,W.jsxs)(`span`,{children:[a(`feeds.notify`),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.notifyHint`)})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:x??e.badge!==0,onChange:e=>S(e.target.checked)}),(0,W.jsxs)(`span`,{children:[a(`feeds.badge`),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.badgeHint`)})]})]}),(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-[var(--c-text-muted)]`,title:e.url,children:e.url}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:r,className:`btn-secondary px-3 py-1.5 text-sm`,children:a(`common.cancel`)}),(0,W.jsx)(`button`,{type:`button`,onClick:T,disabled:C,className:`btn-primary px-4 py-1.5 text-sm`,children:a(`common.save`)})]})]})}function od({feed:e,editing:t,refreshing:n,highlighted:r=!1,folderOptions:i,intervalOptions:a,onEdit:o,onRefresh:s,onMarkRead:c,onUnsubscribe:l,onSaved:u,drag:d}){let{t:f,i18n:p}=z(),{syncAllowed:m}=Bu(),h=e.label??e.title??e.url,g=id(e.site_url)??id(e.url),v=!!e.last_error,y=!e.last_polled_at,[b,x]=(0,_.useState)(!1),S=async()=>{if(!b&&e.suggested_url){x(!0);try{await U.acceptFeedMove(e.id),u(),no()}catch(e){J.error(e instanceof Error?e.message:f(`common.error`))}finally{x(!1)}}},C=[{label:f(n?`feeds.refreshing`:`feeds.refreshFeed`),icon:(0,W.jsx)(qu,{className:`h-4 w-4 ${n?`animate-spin`:``}`}),onSelect:s,disabled:n||!m},...e.unread_count>0?[{label:f(`feeds.markAllRead`),icon:(0,W.jsx)(Ju,{}),onSelect:c}]:[],{label:f(`feeds.edit`),icon:(0,W.jsx)(Yu,{}),onSelect:()=>o(!t)},{label:f(`feeds.unsubscribe`),icon:(0,W.jsx)(X,{}),onSelect:l,danger:!0}];return(0,W.jsxs)(`li`,{id:`feed-${e.id}`,draggable:!!d&&!t,onDragStart:d?.onDragStart,onDragOver:d?.onDragOver,onDragEnd:d?.onDragEnd,onDrop:d?.onDrop,className:`group/feed relative scroll-mt-28 first:rounded-t-xl last:rounded-b-xl transition-[opacity,background-color] duration-700 ${r?`bg-[var(--c-mobile-nav-active)]`:``} ${d?.isDragging?`opacity-40`:``} ${d?.isDragOver?`shadow-[inset_0_2px_0_var(--c-blue3)]`:``}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3.5 sm:px-5`,children:[d&&(0,W.jsx)(`span`,{className:`-mr-1 flex shrink-0 cursor-grab touch-none text-[var(--c-text-muted)] opacity-50 transition-opacity hover:opacity-100 group-hover/feed:opacity-80 active:cursor-grabbing`,title:f(`feeds.dragHandle`),"aria-hidden":`true`,children:(0,W.jsx)($u,{})}),(0,W.jsx)(qc,{feedId:e.id,iconUrl:e.icon_url,siteUrl:e.site_url,feedUrl:e.url,fallbackName:h,className:`h-5 w-5 shrink-0 rounded object-contain text-xs leading-none`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(v||y)&&(0,W.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${v?`bg-[var(--c-danger)]`:`bg-[var(--c-text-muted)]`}`,title:v?f(`feeds.statusFailing`,{count:e.consecutive_errors||1}):f(`feeds.statusPending`)}),(0,W.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`truncate font-semibold text-[var(--c-text)] hover:underline`,children:h}),e.notify!==0&&(0,W.jsx)(`span`,{className:`inline-flex shrink-0 items-center text-[var(--c-text-muted)]`,title:f(`feeds.notifyActive`),"aria-label":f(`feeds.notifyActive`),children:(0,W.jsx)(nd,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[g,f(`feeds.everyInterval`,{interval:rd(f,e.poll_interval_minutes)}),e.last_polled_at?f(`feeds.checkedAgo`,{time:Gu(new Date(e.last_polled_at),p.resolvedLanguage)}):f(`feeds.statusPending`)].filter(Boolean).join(` · `)}),v&&(0,W.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-xs text-[var(--c-danger)]`,title:e.last_error??void 0,children:[(0,W.jsx)(td,{}),(0,W.jsx)(`span`,{className:`line-clamp-2`,children:Uu(f,e.last_error??``,e.url)})]}),e.suggested_url&&m&&(0,W.jsx)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void S(),disabled:b,title:e.suggested_url,className:`inline-flex items-center gap-1.5 rounded-md border border-[var(--c-blue3)]/50 bg-[var(--c-blue3)]/10 px-2.5 py-1 text-xs font-medium text-[var(--c-text)] hover:bg-[var(--c-blue3)]/20 transition-colors cursor-pointer disabled:opacity-50`,children:f(b?`feeds.acceptingSuggestedMove`:`feeds.acceptSuggestedMove`)})})]}),e.unread_count>0&&(0,W.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`shrink-0 rounded-full bg-[var(--c-mobile-nav-active)] px-2.5 py-0.5 text-xs font-semibold tabular-nums text-[var(--c-text)] hover:bg-[var(--c-border)]`,title:f(`feeds.unread`,{count:e.unread_count}),children:e.unread_count}),(0,W.jsx)(zu,{label:f(`feeds.moreActions`),items:C,className:`-mr-2 shrink-0`})]}),t&&(0,W.jsx)(ad,{feed:e,folderOptions:i,intervalOptions:a,onClose:()=>o(!1),onSaved:u})]})}function sd(e,t){let n=t.toLowerCase().split(`-`)[0],r=e.feeds.filter(e=>e.lang===n||e.lang===``),i=n===`en`||n===`ja`&&r.length>0?[]:e.feeds.filter(e=>e.lang===`en`);return[...r,...i]}function cd(e,t){let n=t.toLowerCase().split(`-`)[0],r=e=>e.lang===n||e.lang===``?0:e.lang===`en`?1:2;return[...e.feeds].sort((e,t)=>r(e)-r(t))}function ld({folderOptions:e,defaultFolderId:t,initialUrl:n=``,subscribedUrls:r=[],compact:i=!1,onClose:a,onAdded:o}){let{t:s}=z(),[c,l]=(0,_.useState)(n),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(t),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)([]),y=new Set(r.map(ud));async function b(e,t){h(!0),v([]);try{let n=await U.subscribeFeed(e,t,f);l(``),d(``),await o(n)}catch(e){e instanceof va&&e.code===`multiple_feeds_found`&&e.data&&typeof e.data==`object`&&`feeds`in e.data?v(e.data.feeds):e instanceof va&&e.code===`already_subscribed`?J.error(s(`feeds.alreadySubscribed`)):e instanceof va&&(e.code===`no_feeds_found`||e.code===`invalid_feed`)?J.error(s(`feeds.noFeedsFoundOnPage`)):J.error(s(`feeds.subscribeFailed`))}finally{h(!1)}}function x(e){e.preventDefault();let t=c.trim();t&&!/^https?:\/\//i.test(t)&&(t=t.startsWith(`//`)?`https:${t}`:`https://${t}`),b(t,u.trim()||null)}return(0,W.jsxs)(`section`,{className:i?`flex flex-col gap-4`:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[!i&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:s(`feeds.addFeed`)}),(0,W.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":s(`common.close`),children:(0,W.jsx)(ed,{})})]}),(0,W.jsxs)(`form`,{onSubmit:x,className:`flex flex-col gap-3 ${i?`sm:flex-row sm:items-start`:``}`,children:[(0,W.jsx)(`input`,{type:`text`,required:!0,autoFocus:!i,placeholder:s(`feeds.urlPlaceholder`),className:i?`input sm:flex-1`:`input`,value:c,onChange:e=>{l(e.target.value),g.length&&v([])}}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[!i&&(0,W.jsx)(`input`,{type:`text`,placeholder:s(`feeds.labelPlaceholder`),className:`input sm:flex-1`,value:u,onChange:e=>d(e.target.value)}),!i&&(0,W.jsx)(Vu,{value:f?String(f):``,onChange:e=>p(e?Number(e):null),options:e,className:`w-full sm:w-52`,placeholder:s(`feeds.noFolder`)}),(0,W.jsx)(`button`,{type:`submit`,disabled:m,className:`btn-primary whitespace-nowrap`,children:s(m?`feeds.subscribing`:`feeds.subscribe`)})]})]}),g.length>0&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:s(`feeds.multipleFeedsFound`)}),(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:g.map(e=>{let t=y.has(ud(e.url));return(0,W.jsxs)(`li`,{className:`flex flex-col gap-2.5 px-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-3 ${t?`opacity-70`:``}`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`break-words text-sm font-medium`,children:e.title??e.url}),(0,W.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:e.url})]}),(0,W.jsx)(`button`,{type:`button`,disabled:m||t,onClick:()=>b(e.url,e.title||u.trim()||null),className:`btn-primary w-full shrink-0 whitespace-nowrap px-3 py-1.5 text-xs sm:w-auto`,children:s(t?`feeds.subscribed`:`feeds.subscribe`)})]},e.url)})})]})]})}function ud(e){return e.trim().replace(/\/+$/,``).toLowerCase()}function dd(){let{t:e}=z(),{manageUrl:t}=Bu();return(0,W.jsxs)(`section`,{role:`status`,className:`card flex flex-col gap-2 p-4 sm:p-5`,"aria-labelledby":`plan-notice-title`,children:[(0,W.jsx)(`h2`,{id:`plan-notice-title`,className:`text-base font-semibold`,children:e(`plan.limitedTitle`)}),(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`plan.limitedText`)}),t&&(0,W.jsx)(`a`,{href:t,className:`btn-primary self-start`,style:{textDecoration:`none`},children:e(`plan.view`)})]})}var fd={news:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,W.jsx)(`path`,{d:`M18 14h-8`}),(0,W.jsx)(`path`,{d:`M15 18h-5`}),(0,W.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),technology:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}),(0,W.jsx)(`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}),(0,W.jsx)(`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`})]}),development:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`m18 16 4-4-4-4`}),(0,W.jsx)(`path`,{d:`m6 8-4 4 4 4`}),(0,W.jsx)(`path`,{d:`m14.5 4-5 16`})]}),science:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`}),(0,W.jsx)(`path`,{d:`M8.5 2h7`}),(0,W.jsx)(`path`,{d:`M7 16h10`})]}),design:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.563-2.512 5.563-5.563C22 6.5 17.5 2 12 2Z`})]}),gaming:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`}),(0,W.jsx)(`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`}),(0,W.jsx)(`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`}),(0,W.jsx)(`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`}),(0,W.jsx)(`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`})]}),business:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`}),(0,W.jsx)(`polyline`,{points:`16 7 22 7 22 13`})]}),sport:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M6 9H4.5a2.5 2.5 0 0 1 0-5H6`}),(0,W.jsx)(`path`,{d:`M18 9h1.5a2.5 2.5 0 0 0 0-5H18`}),(0,W.jsx)(`path`,{d:`M4 22h16`}),(0,W.jsx)(`path`,{d:`M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22`}),(0,W.jsx)(`path`,{d:`M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22`}),(0,W.jsx)(`path`,{d:`M18 2H6v7a6 6 0 0 0 12 0V2Z`})]}),culture:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z`}),(0,W.jsx)(`path`,{d:`m6.2 5.3 3.1 3.9`}),(0,W.jsx)(`path`,{d:`m12.4 3.4 3.1 4`}),(0,W.jsx)(`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})]})},pd=`M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M15.97 6.37c.62-.75 1.04-1.8 0.93-2.85-.9.04-1.99.6-2.63 1.35-.57.65-1.07 1.71-.93 2.73.99.08 2.02-.48 2.63-1.23Z`;function md({id:e}){if(e===`apple`)return(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:pd})});let t=fd[e];return t?(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t}):null}async function hd(e){try{let t=(await U.listFolders()).folders.find(t=>t.name===e);return t?t.id:(await U.createFolder(e)).id}catch{return null}}function gd({onSubscribed:e}){let{t,i18n:n}=z(),{syncAllowed:r}=Bu(),i=bl(),a=fl(i),o=n.resolvedLanguage||`en`,[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(!1),d=(0,_.useMemo)(()=>ml(i,s,o).map(e=>({...e,feeds:l?cd(e,o):sd(e,o)})).filter(e=>e.feeds.length>0),[i,s,o,l]),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(new Set),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),x=(0,_.useRef)(null),S=d.find(e=>e.id===f)??d[0]??null,C=d.reduce((e,t)=>e+t.feeds.filter(e=>m.has(e.url)).length,0),w=S!==null&&S.feeds.every(e=>m.has(e.url));(0,_.useEffect)(()=>{let e=!0;return U.feedLists(o).then(t=>{e&&c(t.lists)},()=>{e&&c([])}),()=>{e=!1}},[o]);function T(e){h(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})}function E(){S&&h(e=>{let t=new Set(e);for(let e of S.feeds)w?t.delete(e.url):t.add(e.url);return t})}async function D(){let n=[];for(let e of d)for(let t of e.feeds)m.has(t.url)&&n.push({url:t.url,label:t.title,folderName:e.title});if(n.length===0)return;v({done:0,total:n.length});let r=new Map;for(let e of new Set(n.map(e=>e.folderName)))r.set(e,await hd(e));let i=0,a=0,o=0,s=new Set,c=[...n];await Promise.all(Array.from({length:Math.min(3,n.length)},async()=>{for(let e=c.shift();e;e=c.shift()){try{await U.subscribeFeed(e.url,e.label||null,r.get(e.folderName)??null),i++,s.add(e.url)}catch(t){t instanceof va&&t.code===`already_subscribed`?(i++,s.add(e.url)):a++}v({done:++o,total:n.length})}})),v(null),h(e=>new Set([...e].filter(e=>!s.has(e)))),a>0?J.error(t(`welcome.packPartial`,{added:i,failed:a})):J.success(t(`welcome.packAdded`,{count:i})),i>0&&await e()}async function O(n){let r=n.target.files?.[0];if(r){b(!0);try{let n=await U.importOpml(await r.text());n.failed>0?J.error(t(`feeds.importPartial`,{imported:n.imported,skipped:n.skipped,failed:n.failed})):J.success(t(`feeds.importSuccess`,{imported:n.imported,skipped:n.skipped})),n.imported>0&&await e()}catch{J.error(t(`feeds.importFailed`))}finally{b(!1),x.current&&(x.current.value=``)}}}async function k(n){J.success(t(`feeds.subscribedToast`,{title:n.label||n.title||n.url})),await e()}let A=g!==null||y;return r?(0,W.jsxs)(`section`,{className:`card flex flex-col gap-6 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`welcome-title`,children:[(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{id:`welcome-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.title`)}),(0,W.jsx)(`p`,{className:`max-w-xl text-xs sm:text-sm text-[var(--c-text-muted)] mt-0.5 leading-relaxed`,children:t(`welcome.intro`)})]})}),a&&(0,W.jsx)(Iu,{name:`onboarding`,mount:a.mount}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[d.length>0&&(0,W.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`polygon`,{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`})]})}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.packsTitle`)})]}),(0,W.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.packsHint`)})]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t(`welcome.packsTitle`),children:d.map(e=>{let t=e.feeds.filter(e=>m.has(e.url)).length,n=S?.id===e.id;return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:A,onClick:()=>p(e.id),className:`inline-flex items-center gap-2 rounded-full border px-3.5 py-1.5 text-xs sm:text-sm font-semibold cursor-pointer transition-all ${n?`border-[var(--c-blue1)] bg-[var(--c-blue1)] text-white shadow-xs`:`border-[var(--c-border)] bg-[var(--c-surface)] hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)] text-[var(--c-text)]`}`,children:[(0,W.jsx)(md,{id:e.id}),(0,W.jsx)(`span`,{children:e.title}),t>0&&(0,W.jsx)(`span`,{className:`rounded-full px-1.5 text-[0.625rem] font-bold leading-4 ${n?`bg-white/25 text-white`:`bg-[var(--c-blue1)] text-white`}`,children:t})]},e.id)})}),S&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2 animate-fade-in border-t border-[var(--c-border)]/60`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[S.description&&(0,W.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)]`,children:S.description}),(0,W.jsx)(`button`,{type:`button`,disabled:A,onClick:E,className:`text-xs sm:text-sm font-semibold text-[var(--c-blue1)] cursor-pointer hover:underline`,children:t(w?`welcome.deselectAll`:`welcome.selectAll`)})]}),(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)]`,children:S.feeds.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3.5 py-2.5 hover:bg-[var(--c-surface-hover)]/50 transition-colors`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:m.has(e.url),disabled:A,onChange:()=>T(e.url),className:`mt-0.5 rounded accent-[var(--c-blue1)]`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-xs sm:text-sm font-medium`,children:e.title}),e.description&&(0,W.jsx)(`span`,{className:`block text-xs text-[var(--c-text-muted)] leading-snug`,children:e.description})]}),e.lang&&(0,W.jsx)(`span`,{className:`shrink-0 text-[0.625rem] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-[var(--c-surface-hover)] text-[var(--c-text-muted)]`,children:e.lang})]})},e.url))})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:A||C===0,onClick:()=>void D(),className:`btn-primary self-start text-xs sm:text-sm font-semibold px-4 py-2`,children:g?t(`welcome.subscribingProgress`,{done:g.done,total:g.total}):t(`welcome.subscribePack`,{count:C})}),(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-xs sm:text-sm text-[var(--c-text-muted)] cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:l,disabled:A,onChange:e=>u(e.target.checked),className:`rounded accent-[var(--c-blue1)]`}),t(`welcome.allLanguages`)]})]})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`}),(0,W.jsx)(`path`,{d:`M2 12h20`})]})}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.addTitle`)})]}),(0,W.jsx)(ld,{compact:!0,folderOptions:[],defaultFolderId:null,onClose:()=>{},onAdded:k})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M21 8v13H3V8`}),(0,W.jsx)(`path`,{d:`M1 3h22v5H1z`}),(0,W.jsx)(`path`,{d:`M10 12h4`})]})}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.importTitle`)})]}),(0,W.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.importHint`)})]}),(0,W.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>x.current?.click(),className:`btn-secondary inline-flex items-center gap-2 shrink-0 text-xs sm:text-sm font-semibold px-4 py-2`,children:[(0,W.jsx)(Z,{}),t(y?`feeds.importing`:`feeds.importOpml`)]}),(0,W.jsx)(`input`,{type:`file`,ref:x,onChange:O,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]})]}):(0,W.jsx)(dd,{})}function _d({folder:e,onRenamed:t}){let{t:n}=z(),[r,i]=(0,_.useState)(e.name);async function a(){let a=r.trim();if(!a||a===e.name)i(e.name);else try{await U.updateFolder(e.id,a),J.success(n(`feeds.folderRenamed`,{name:a})),await t()}catch{i(e.name),J.error(n(`common.error`))}}return(0,W.jsx)(`input`,{className:`input h-9 min-h-0 flex-1 border-transparent bg-transparent px-2 text-sm shadow-none hover:border-[var(--c-border)] focus:border-[var(--c-border)]`,value:r,onChange:e=>i(e.target.value),onBlur:()=>void a(),onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&i(e.name)}})}function vd({folders:e,onClose:t,onChanged:n}){let{t:r}=z(),{syncAllowed:i}=Bu(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1);async function l(e){if(e.preventDefault(),a.trim()){c(!0);try{await U.createFolder(a.trim()),J.success(r(`feeds.folderCreated`,{name:a.trim()})),o(``),await n()}catch{J.error(r(`common.error`))}finally{c(!1)}}}async function u(e){if(confirm(r(`feeds.deleteFolderConfirm`,{name:e.name})))try{await U.deleteFolder(e.id),J.success(r(`feeds.folderDeleted`,{name:e.name})),await n()}catch{J.error(r(`common.error`))}}return(0,W.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`feeds.manageFolders`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--c-text-muted)]`,children:r(`feeds.renameFolderHint`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":r(`common.close`),children:(0,W.jsx)(ed,{})})]}),e.length>0&&(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:e.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,W.jsx)(_d,{folder:e,onRenamed:n},e.name),(0,W.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-[var(--c-text-muted)]`,children:r(`feeds.feedCount`,{count:e.feed_count??0})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`rounded-lg p-2 text-[var(--c-text-muted)] hover:bg-[var(--c-danger-bg)] hover:text-[var(--c-danger)] cursor-pointer`,"aria-label":r(`common.delete`),title:r(`common.delete`),children:(0,W.jsx)(X,{})})]},e.id))}),(0,W.jsxs)(`form`,{onSubmit:l,className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,disabled:!i,placeholder:r(`feeds.newFolderPlaceholder`),className:`input flex-1`,value:a,onChange:e=>o(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,disabled:s||!i||!a.trim(),title:i?void 0:r(`plan.unavailable`),className:`btn-primary whitespace-nowrap`,children:r(`feeds.addFolder`)})]})]})}function yd(e,t,n){e.deferred?J.info(n(`feeds.refreshPendingToast`,{title:t})):e.error?J.error(n(`feeds.refreshFailedToast`,{title:t,error:Uu(n,e.error)})):J.success(n(`feeds.refreshedToast`,{title:t,count:e.newItems}))}function bd(e,t){e.deferred?J.info(t(`feeds.refreshAllPendingToast`,{count:e.deferred,newItems:e.newItems})):e.errors||J.success(t(`feeds.refreshedAllToast`,{count:e.refreshed,newItems:e.newItems})),e.errors>0&&J.error(t(`feeds.failingCount`,{count:e.errors}))}var xd=[5,15,30,60,180,360,720,1440],Sd=`none`;function Cd(e,t){return!t||[e.label,e.title,e.url,e.site_url].filter(Boolean).join(` `).toLowerCase().includes(t.toLowerCase())}function wd(){let{t:e}=z(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=Li(),[b]=(0,_.useState)(()=>[v.get(`url`),v.get(`text`),v.get(`add`)].filter(Boolean).join(` `).match(/https?:\/\/[^\s]+/i)?.[0]??``);(0,_.useEffect)(()=>{(v.has(`add`)||v.has(`url`)||v.has(`text`))&&(j&&c(`add`),y({},{replace:!0}))},[]);let[x,S]=(0,_.useState)(`all`),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(null),k=(0,_.useRef)(null);async function A(){try{let[e,t]=await Promise.all([U.listFeeds(),U.listFolders().catch(()=>({folders:[]}))]);n(e),i(t.folders)}catch(e){console.error(`Failed to load feeds:`,e)}finally{o(!1)}}(0,_.useEffect)(()=>{A()},[]),(0,_.useEffect)(()=>{if(D===null)return;document.getElementById(`feed-${D}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=window.setTimeout(()=>O(null),2500);return()=>window.clearTimeout(e)},[D,t]);let{syncAllowed:j}=Bu(),ee=e=>(e.label??e.title??e.url).replace(/\s+/g,` `).trim();async function te(t){J.success(e(`feeds.subscribedToast`,{title:ee(t)})),g(``),S(`all`),await A(),O(t.id)}let ne=(0,_.useMemo)(()=>[{value:``,label:e(`feeds.noFolder`)},...r.map(e=>({value:String(e.id),label:e.name}))],[r,e]),re=(0,_.useMemo)(()=>xd.map(t=>({value:String(t),label:rd(e,t)})),[e]),M=(0,_.useMemo)(()=>{let n=new Map;for(let e of t){let t=e.folder_id??null;n.set(t,[...n.get(t)??[],e])}let i=[...r].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({key:`folder:${e.id}`,name:e.name,feeds:n.get(e.id)??[]}));return i.push({key:Sd,name:e(`feeds.uncategorized`),feeds:n.get(null)??[]}),i.filter(e=>e.feeds.length>0)},[t,r,e]),ie=(0,_.useMemo)(()=>M.filter(e=>x===`all`||x===`failing`||e.key===x).map(e=>({...e,feeds:e.feeds.filter(e=>Cd(e,h)&&(x!==`failing`||!!e.last_error))})).filter(e=>e.feeds.length>0),[M,x,h]),ae=t.reduce((e,t)=>e+t.unread_count,0),oe=t.filter(e=>e.last_error).length,se=!h&&x!==`failing`;(0,_.useEffect)(()=>{if(!C)return;let e=e=>e.preventDefault();return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[C!==null]);async function ce(){if(!C||C.from===C.over){w(null);return}let e=M.map(e=>{if(e.key!==C.group)return e.feeds;let t=[...e.feeds],[n]=t.splice(C.from,1);return t.splice(C.over,0,n),t}).flat();n(e),w(null);try{await U.reorderFeeds(e.map(e=>e.id))}catch(e){console.error(`Failed to save feed order:`,e),await A()}}async function N(t){f(e=>new Set(e).add(t));try{let r=await U.refreshFeed(t);r.feed?n(e=>e.map(e=>e.id===t?r.feed:e)):await A(),yd(r,r.feed?ee(r.feed):``,e)}catch{J.error(e(`common.error`))}finally{f(e=>{let n=new Set(e);return n.delete(t),n})}}async function le(){m(!0);try{let t=await U.refreshAllFeeds();await A(),bd(t,e)}catch{J.error(e(`common.error`))}finally{m(!1)}}async function ue(t){if(confirm(e(`feeds.unsubscribeConfirm`,{title:ee(t)})))try{await U.unsubscribeFeed(t.id),J.success(e(`feeds.unsubscribedToast`,{title:ee(t)})),await A()}catch{J.error(e(`common.error`))}}async function de(t){try{await U.markAllRead(t.id),J.success(e(`feeds.markedReadToast`,{title:ee(t)})),await A()}catch{J.error(e(`common.error`))}}function fe(){let e=document.createElement(`a`);e.href=U.exportOpmlUrl(),e.download=`feedkeeper-subscriptions.opml`,e.click()}async function pe(t){let n=t.target.files?.[0];if(n){E(!0);try{let t=await U.importOpml(await n.text());t.failed>0?J.error(e(`feeds.importPartial`,{imported:t.imported,skipped:t.skipped,failed:t.failed})):J.success(e(`feeds.importSuccess`,{imported:t.imported,skipped:t.skipped})),await A()}catch{J.error(e(`feeds.importFailed`))}finally{E(!1),k.current&&(k.current.value=``)}}}let me=[{key:`all`,label:e(`feeds.filterAll`),count:t.length},...M.map(e=>({key:e.key,label:e.name,count:e.feeds.length})),...oe>0?[{key:`failing`,label:e(`feeds.filterFailing`),count:oe,danger:!0}]:[]];return(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 pb-24`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`feeds.title`)}),!a&&t.length>0&&(0,W.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.length}),` · `,e(`feeds.unread`,{count:ae}),oe>0&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`button`,{type:`button`,onClick:()=>S(`failing`),className:`text-[var(--c-danger)] hover:underline cursor-pointer`,children:e(`feeds.failingCount`,{count:oe})})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(a||t.length>0)&&(0,W.jsxs)(`button`,{type:`button`,disabled:!j,title:j?void 0:e(`plan.unavailable`),onClick:()=>c(s===`add`?null:`add`),className:`btn-primary inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,W.jsx)(Xu,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:e(`feeds.addFeed`)}),(0,W.jsx)(`span`,{className:`sm:hidden`,children:e(`feeds.addFeedShort`)})]}),(0,W.jsx)(zu,{label:e(`feeds.moreActions`),items:[{label:e(p?`feeds.refreshing`:`feeds.refreshAll`),icon:(0,W.jsx)(qu,{className:`h-4 w-4 ${p?`animate-spin`:``}`}),onSelect:le,disabled:p||!j},{label:e(`feeds.manageFolders`),icon:(0,W.jsx)(Zu,{}),onSelect:()=>c(`folders`)},{label:e(T?`feeds.importing`:`feeds.importOpml`),icon:(0,W.jsx)(Z,{}),onSelect:()=>k.current?.click(),disabled:T||!j},{label:e(`feeds.exportOpml`),icon:(0,W.jsx)(Q,{}),onSelect:fe}]}),(0,W.jsx)(`input`,{type:`file`,ref:k,onChange:pe,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]}),!j&&t.length>0&&(0,W.jsx)(dd,{}),s===`add`&&j&&(0,W.jsx)(ld,{folderOptions:ne,defaultFolderId:x.startsWith(`folder:`)?Number(x.slice(7)):null,initialUrl:b,subscribedUrls:t.map(e=>e.url),onClose:()=>c(null),onAdded:te}),s===`folders`&&(0,W.jsx)(vd,{folders:r,onClose:()=>c(null),onChanged:A}),a?(0,W.jsx)(Ru,{size:`lg`}):t.length===0?s!==`add`&&(0,W.jsx)(gd,{onSubscribed:A}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,W.jsx)(Qu,{})}),(0,W.jsx)(`input`,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:e(`feeds.searchPlaceholder`),"aria-label":e(`feeds.searchPlaceholder`),className:`input pl-9`})]}),(0,W.jsx)(`div`,{className:`-mx-4 flex gap-2 overflow-x-auto px-4 pb-1 sm:mx-0 sm:flex-wrap sm:overflow-visible sm:px-0`,role:`group`,"aria-label":e(`feeds.folder`),children:me.map(e=>{let t=x===e.key;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>S(e.key),"aria-pressed":t,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer ${t?`border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`} ${e.danger&&!t?`text-[var(--c-danger)]`:``}`,children:[e.label,e.count!==void 0&&(0,W.jsx)(`span`,{className:`text-xs tabular-nums opacity-70`,children:e.count})]},e.key)})})]}),ie.length===0?(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`feeds.noMatches`)}):(0,W.jsx)(`div`,{className:`flex flex-col gap-6 animate-page-fade`,children:ie.map(t=>{let n=t.feeds.reduce((e,t)=>e+t.unread_count,0);return(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-3 px-1`,children:[(0,W.jsx)(`h2`,{className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t.name}),(0,W.jsxs)(`span`,{className:`shrink-0 text-xs text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.feeds.length}),n>0&&` · ${e(`feeds.unread`,{count:n})}`]})]}),(0,W.jsx)(`ul`,{className:`card divide-y divide-[var(--c-border)]`,children:t.feeds.map((e,n)=>(0,W.jsx)(od,{feed:e,editing:l===e.id,refreshing:d.has(e.id),highlighted:D===e.id,folderOptions:ne,intervalOptions:re,onEdit:t=>u(t?e.id:null),onRefresh:()=>void N(e.id),onMarkRead:()=>void de(e),onUnsubscribe:()=>void ue(e),onSaved:A,drag:se&&t.feeds.length>1?{isDragging:C?.group===t.key&&C.from===n,isDragOver:C?.group===t.key&&C.over===n&&C.from!==n,onDragStart:r=>{r.dataTransfer.effectAllowed=`move`,r.dataTransfer.setData(`application/x-feedkeeper-feed`,String(e.id)),w({group:t.key,from:n,over:n})},onDragOver:e=>{C?.group===t.key&&(e.preventDefault(),C.over!==n&&w({...C,over:n}))},onDragEnd:()=>void ce(),onDrop:e=>e.preventDefault()}:void 0},e.id))})]},t.key)})})]})]})}function Td(){let[e,t]=(0,_.useState)(()=>new Date);return(0,_.useEffect)(()=>{let n=new Date(e);n.setHours(24,0,1,0);let r=window.setTimeout(()=>t(new Date),n.getTime()-Date.now());return()=>window.clearTimeout(r)},[e]),e}function Ed({className:e=``}){let{i18n:t}=z(),n=Td(),r=e=>new Intl.DateTimeFormat(t.resolvedLanguage,{weekday:`long`,day:`numeric`,month:`long`,...e?{year:`numeric`}:{}}).format(n);return(0,W.jsxs)(`time`,{dateTime:n.toLocaleDateString(`sv-SE`),className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)] ${e}`,children:[(0,W.jsx)(`span`,{className:`sm:hidden`,children:r(!1)}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:r(!0)})]})}var Dd=650;function Od(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, noscript, template, svg, [hidden], [aria-hidden='true']`).forEach(e=>e.remove()),t.content.querySelectorAll(`p, div, li, br, blockquote, section, article, h1, h2, h3, h4, h5, h6`).forEach(e=>e.after(` `)),t.content.textContent?.replace(/\s+/g,` `).trim()??``}function kd(e){let t=e.full_content_html?.trim()?Od(e.full_content_html):``,n=!t&&e.content_html?.trim()?Od(e.content_html):``,r=e.content_snippet?.replace(/\s+/g,` `).trim()??``,i=t||(n.length>=r.length?n:r);return i?i.length<=Dd?i:Ao(i)===`ja`?jo(i,Dd):`${i.slice(0,Dd).trimEnd()}…`:null}function Ad({item:e,className:t}){let n=(0,_.useMemo)(()=>kd(e),[e]);if(!n)return null;let r=Ao(n);return(0,W.jsx)(`p`,{className:r===`ja`?`${t} ja-phrases`:t,lang:r,children:(0,W.jsx)(Jc,{text:n})})}function jd(e){let t=0,n=-5;return e.map((e,r)=>{let i=/^https?:\/\//i.test(e.image_url??``),a=(e.content_snippet?.trim().length??0)>=220,o=(i||a)&&r-n>=5&&t<=1;return t=(t+(o?2:1))%3,o&&(n=r),o})}function Md(e){let t=e.map(()=>!1),n=[],r=0;return e.forEach((i,a)=>{n.push(a),r+=i?2:1,r===3&&(n.some(t=>e[t])&&n.forEach(n=>{t[n]=!e[n]}),n=[],r=0)}),t}function Nd({url:e,featured:t}){let[n,r]=(0,_.useState)(`loading`);return!e||!/^https?:\/\//i.test(e)?null:(0,W.jsx)(`div`,{className:n===`hidden`?`hidden`:`overflow-hidden border-b border-[var(--c-border)] bg-[var(--c-bg)]`,children:(0,W.jsx)(`img`,{src:e,alt:``,loading:`lazy`,className:`w-full object-cover transition-transform duration-300 group-hover:scale-[1.025] ${t?`aspect-[3/2] lg:aspect-[16/9]`:`aspect-[3/2]`} ${n===`visible`?`opacity-100`:`opacity-0`}`,onLoad:e=>{let{naturalWidth:n,naturalHeight:i}=e.currentTarget;r(n>=(t?400:160)&&i>=(t?220:100)?`visible`:`hidden`)},onError:()=>r(`hidden`)})})}function Pd({item:e,featured:t,besideFeature:n,focused:r,onOpen:i,onBookmark:a,onRead:o}){let{t:s,i18n:c}=z(),l=e.published_at?new Date(e.published_at):null,u=l&&!Number.isNaN(l.getTime())?l:null,d=u?new Intl.DateTimeFormat(c.resolvedLanguage,{dateStyle:`medium`}).format(u):null,f=u?new Intl.DateTimeFormat(c.resolvedLanguage,{timeStyle:`short`}).format(u):null;return(0,W.jsx)(`li`,{"data-item-id":e.id,className:t?`lg:col-span-2`:``,children:(0,W.jsxs)(`article`,{className:`card group relative flex h-full flex-col overflow-hidden transition-colors duration-150 hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)] ${r?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)] bg-[var(--c-surface-hover)]`:``}`,style:{opacity:e.read?.65:1},children:[(0,W.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 rounded-xl focus-visible:outline-2 focus-visible:outline-offset-[-3px] focus-visible:outline-[var(--c-blue3)]`,"aria-label":e.title||e.feed_title||s(`items.title`),onClick:()=>i(e)}),(0,W.jsx)(Nd,{url:e.image_url,featured:t},e.image_url??``),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col ${t?`p-4 sm:p-5 lg:p-6`:`p-4 sm:p-5`}`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,W.jsx)(qc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.feed_title}),(e.enclosure_url||Xc(e.link))&&(0,W.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 rounded-full border border-[var(--c-border)] px-2 py-0.5 text-[11px] font-medium tracking-normal normal-case text-[var(--c-text-muted)] shrink-0`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:e.enclosure_type?.startsWith(`video/`)||!e.enclosure_url&&Xc(e.link)?`▶`:`🎧`}),e.enclosure_duration_seconds?Yc(e.enclosure_duration_seconds):e.enclosure_type?.startsWith(`video/`)||!e.enclosure_url&&Xc(e.link)?`Video`:`Audio`]})]}),(0,W.jsx)(`h2`,{lang:Ao(e.title||e.feed_title),className:`text-[var(--c-text)] ${t?`text-lg leading-snug lg:text-2xl lg:leading-tight`:`text-lg leading-snug`} font-semibold${Ao(e.title||e.feed_title)===`ja`?` ja-phrases`:``}`,children:e.title||e.feed_title?(0,W.jsx)(Jc,{text:e.title||e.feed_title}):null}),(0,W.jsx)(Ad,{item:e,className:`mt-3 text-sm leading-relaxed text-[var(--c-text-muted)] ${t?`line-clamp-3 lg:line-clamp-4`:n?`line-clamp-3 lg:line-clamp-12`:`line-clamp-3`}`}),(0,W.jsxs)(`div`,{className:`pointer-events-none relative z-20 mt-auto flex flex-wrap items-center gap-x-3 gap-y-2 pt-5 text-xs text-[var(--c-text-muted)]`,children:[d&&(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:f??void 0,children:[(0,W.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`}),(0,W.jsx)(`path`,{d:`M8 2v4M16 2v4M3 10h18`})]}),d]}),f&&(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`path`,{d:`M12 6v6l4 2`})]}),f]}),(0,W.jsxs)(`div`,{className:`pointer-events-auto ml-auto flex items-center gap-1.5`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(e),title:e.bookmarked?s(`items.unbookmark`):s(`items.bookmark`),"aria-label":e.bookmarked?s(`items.unbookmark`):s(`items.bookmark`),className:`grid h-8 w-8 place-items-center rounded-lg border transition-colors ${e.bookmarked?`border-amber-500/40 bg-amber-500/15 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500`}`,children:(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>o(e),title:e.read?s(`items.markUnread`):s(`items.markRead`),"aria-label":e.read?s(`items.markUnread`):s(`items.markRead`),className:`grid h-8 w-8 place-items-center rounded-lg border border-[var(--c-border)] transition-colors ${e.read?`text-[var(--c-text-muted)]`:`text-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,"aria-hidden":`true`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]})]})})}function Fd({items:e,focusedItemId:t,onOpen:n,onBookmark:r,onRead:i}){let a=(0,_.useMemo)(()=>jd(e),[e]),o=(0,_.useMemo)(()=>Md(a),[a]);return(0,W.jsx)(`ul`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 sm:gap-5 animate-page-fade`,children:e.map((e,s)=>(0,W.jsx)(Pd,{item:e,featured:a[s],besideFeature:o[s],focused:t===e.id,onOpen:n,onBookmark:r,onRead:i},e.id))})}function Id(e){return e.replace(/<[^>]*>/g,` `).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/\s+/g,` `).trim()}function Ld({feed:e}){let{t}=z(),[n,r]=(0,_.useState)(!1),i=e.label?.trim()||e.title?.trim()||e.url,a=e.artwork_url||`/api/feeds/${e.id}/icon`,o=e.description?Id(e.description):``;return(0,W.jsxs)(`div`,{className:`mb-6 flex items-start gap-4 rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)] p-4 sm:p-5`,children:[(0,W.jsx)(`img`,{src:a,alt:``,className:`h-20 w-20 sm:h-24 sm:w-24 rounded-xl object-cover shrink-0 border border-[var(--c-border)] bg-[var(--c-bg)]`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{className:`text-lg sm:text-xl font-bold text-[var(--c-text)] leading-snug`,children:i}),o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`mt-1.5 text-sm text-[var(--c-text-muted)] ${n?``:`line-clamp-2`}`,children:o}),o.length>140&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`mt-1 text-xs font-medium text-[var(--c-blue3)] hover:underline cursor-pointer`,children:t(n?`common.showLess`:`common.showMore`)})]})]})]})}function Rd(e,t,n){let r=n&&n>0?n:e.enclosure_duration_seconds??0;if(r<=0)return 0;let i=t===void 0?e.media_position&&!e.media_position.completed?e.media_position.positionSeconds:0:t;return Math.min(1,Math.max(0,i/r))}function zd({feed:e,items:t,focusedItemId:n,onOpen:r,onBookmark:i,onRead:a}){let{t:o,i18n:s}=z(),c=mo();return(0,W.jsx)(`ul`,{className:`flex flex-col gap-3 animate-page-fade`,children:t.map(t=>{let l=c.currentItem?.id===t.id,u=l&&c.isPlaying,d=l&&c.duration>0?c.duration:t.enclosure_duration_seconds??0,f=l?c.currentTime:t.media_position&&!t.media_position.completed?t.media_position.positionSeconds:0,p=Rd(t,l?c.currentTime:void 0,l?c.duration:void 0),m=t.published_at?new Date(t.published_at):null,h=n===t.id;return(0,W.jsxs)(`li`,{"data-item-id":t.id,onClick:()=>r(t),className:`card flex items-center gap-3.5 p-3.5 sm:p-4 transition-colors hover:bg-[var(--c-surface-hover)] hover:border-[var(--c-blue3)]/60 cursor-pointer ${h?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)] bg-[var(--c-surface-hover)]`:``}`,style:{opacity:t.read?.65:1},children:[t.enclosure_url&&(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c.togglePlay(t)},"aria-label":o(u?`player.pause`:`player.play`),className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:u?(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-4 h-4 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(t.image_url||e?.artwork_url||t.feed_id)&&(0,W.jsx)(`img`,{src:t.image_url||e?.artwork_url||`/api/feeds/${t.feed_id}/icon`,alt:``,className:`h-12 w-12 rounded-lg object-cover shrink-0 border border-[var(--c-border)] bg-[var(--c-bg)]`,loading:`lazy`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--c-text-muted)] mb-0.5`,children:[m&&(0,W.jsx)(`span`,{children:Gu(m,s.resolvedLanguage)}),d>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`·`}),(0,W.jsx)(`span`,{className:`font-mono`,children:f>5&&d>f?o(`player.timeRemaining`,{time:Yc(d-f)}):Yc(d)})]})]}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-semibold text-[var(--c-text)] line-clamp-2`,children:t.title}),p>0&&(0,W.jsx)(`div`,{className:`mt-2 h-1 w-full max-w-xs rounded-full bg-[var(--c-border)] overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full bg-[var(--c-blue3)]`,style:{width:`${p*100}%`}})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":o(`items.bookmark`),className:`p-1.5 rounded-lg hover:bg-[var(--c-surface-hover)] cursor-pointer ${t.bookmarked?`text-amber-500`:`text-[var(--c-text-muted)]`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":t.read?o(`items.markUnread`):o(`items.markRead`),className:`p-1.5 rounded-lg text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`6`})})})]})]},t.id)})})}function Bd({items:e,focusedItemId:t,onOpen:n,onBookmark:r}){let{t:i,i18n:a}=z();return(0,W.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-5 animate-page-fade`,children:e.map(e=>{let o=e.published_at?new Date(e.published_at):null,s=e.enclosure_duration_seconds??0,c=Rd(e),l=t===e.id;return(0,W.jsxs)(`article`,{"data-item-id":e.id,onClick:()=>n(e),className:`card overflow-hidden flex flex-col cursor-pointer transition-colors hover:border-[var(--c-blue3)]/60 ${l?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)]`:``}`,style:{opacity:e.read?.65:1},children:[(0,W.jsxs)(`div`,{className:`relative aspect-video w-full bg-black overflow-hidden`,children:[e.image_url?(0,W.jsx)(`img`,{src:e.image_url,alt:``,className:`w-full h-full object-cover`,loading:`lazy`}):(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white/60`,children:(0,W.jsx)(`svg`,{className:`w-10 h-10`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),s>0&&(0,W.jsx)(`span`,{className:`absolute bottom-2 right-2 rounded-md bg-black/80 px-1.5 py-0.5 font-mono text-[11px] font-semibold text-white`,children:Yc(s)}),c>0&&(0,W.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-1 bg-white/25`,children:(0,W.jsx)(`div`,{className:`h-full bg-[var(--c-blue3)]`,style:{width:`${c*100}%`}})})]}),(0,W.jsxs)(`div`,{className:`p-3.5 flex-1 flex flex-col justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-[var(--c-text)] line-clamp-2 leading-snug min-h-[2.45rem]`,children:e.title}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`span`,{children:o?Gu(o,a.resolvedLanguage):``}),(0,W.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},"aria-label":i(`items.bookmark`),className:`p-1 rounded hover:bg-[var(--c-surface-hover)] cursor-pointer ${e.bookmarked?`text-amber-500`:``}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})})]})]})]},e.id)})})}var Vd=68,Hd=92,Ud=`input, select, textarea, [contenteditable='true'], [data-no-pull]`;function Wd(){let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Gd({children:e,disabled:t=!1,onRefresh:n}){let{t:r}=z(),i=(0,_.useRef)(null),a=(0,_.useRef)(0),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),m=(0,_.useCallback)(()=>{u||(p(!1),d(!0),s(56),n().catch(()=>p(!0)).finally(()=>{d(!1),s(0)}))},[u,n]);(0,_.useEffect)(()=>{let e=i.current;if(!e)return;let n=null;function r(){n=null,a.current=0,l(!1),s(0)}function o(e){t||u||e.touches.length!==1||window.scrollY>1||!window.matchMedia(`(any-pointer: coarse)`).matches||document.body.style.overflow===`hidden`||e.target.closest(Ud)||(n={x:e.touches[0].clientX,y:e.touches[0].clientY})}function c(e){if(!n||e.touches.length!==1)return;let t=e.touches[0].clientX-n.x,i=e.touches[0].clientY-n.y;if(window.scrollY>1||Math.abs(t)>Math.abs(i)){r();return}if(i<=0){a.current=0,s(0);return}e.preventDefault();let o=Math.min(Hd,i*.72);a.current=o,l(!0),s(o)}function d(){if(!n)return;let e=a.current>=Vd;a.current>8&&Wd(),r(),e&&m()}return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,c,{passive:!1}),e.addEventListener(`touchend`,d),e.addEventListener(`touchcancel`,r),()=>{e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,c),e.removeEventListener(`touchend`,d),e.removeEventListener(`touchcancel`,r)}},[t,u,n,m]);let h=u?1:Math.min(1,o/Vd);return(0,W.jsxs)(`div`,{ref:i,children:[(0,W.jsx)(`button`,{type:`button`,className:`sr-only focus:not-sr-only sm:hidden`,onClick:m,disabled:t||u,children:r(`items.refresh`)}),(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{height:o,transition:c?`none`:`height 220ms ease-out`},children:(0,W.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)] shadow-sm`,style:{opacity:Math.min(1,o/30),transform:`scale(${.65+h*.35})`},children:(0,W.jsxs)(`svg`,{className:`h-5 w-5 ${u?`animate-spin motion-reduce:animate-none`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:u?void 0:{transform:`rotate(${h*270}deg)`},children:[(0,W.jsx)(`path`,{d:`M18 7a8 8 0 1 0 2 5`,pathLength:`100`,strokeDasharray:`${h*100} 100`}),(0,W.jsx)(`path`,{d:`M18 3v4h-4`,opacity:h})]})})}),u&&(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:r(`items.refreshing`)}),f&&(0,W.jsx)(`p`,{className:`mb-3 text-center text-sm text-[var(--c-danger)]`,role:`alert`,children:r(`items.refreshFailed`)}),e]})}function Kd(){let{user:e}=lo(),t=hl(bl()),[n,r]=(0,_.useState)(!1),i=!!e?.intro_dismissed_at;return(0,_.useEffect)(()=>{let n=!0;if(r(!1),t&&e&&i)return Promise.resolve(!t.applies||t.applies({id:e.id,email:e.email,display_name:e.display_name??null})).then(e=>{n&&r(e===!0)}).catch(()=>{n&&r(!1)}),()=>{n=!1}},[t?.mount,t?.applies,e?.id,i]),!t||!n?null:(0,W.jsx)(Iu,{name:`articles-notice`,mount:t.mount})}function qd(){let{t:e}=z(),{user:t,setCurrentUser:n}=lo(),[r,i]=(0,_.useState)(!1);if(!t||t.intro_dismissed_at)return null;async function a(){i(!0);try{n(await U.dismissIntro())}catch{i(!1)}}let o=[{key:`views`,className:`hidden sm:flex`,icon:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,W.jsx)(`path`,{d:`M18 14h-8`}),(0,W.jsx)(`path`,{d:`M15 18h-5`}),(0,W.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]})},{key:`unread`,solid:!0,icon:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})},{key:`star`,icon:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})},{key:`folders`,icon:(0,W.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}];return(0,W.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-5 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`intro-title`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{id:`intro-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.title`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.subtitle`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:a,disabled:r,"aria-label":e(`common.close`),className:`shrink-0 rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsx)(ed,{})})]}),(0,W.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:o.map(t=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3.5 rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 ${t.className??``}`,children:[(0,W.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)]`,children:(0,W.jsx)(`svg`,{className:t.solid?`h-3.5 w-3.5`:`h-4 w-4`,viewBox:`0 0 24 24`,fill:t.solid?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:t.solid?2.2:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t.icon})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.${t.key}Title`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.${t.key}Text`)})]})]},t.key))}),(0,W.jsx)(`button`,{type:`button`,onClick:a,disabled:r,className:`btn-primary self-start`,children:e(`intro.done`)})]})}var Jd=50;function Yd(){return(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,W.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]})}var Xd=`(max-width: 639px)`;function Zd(){return(0,_.useSyncExternalStore)(e=>{let t=window.matchMedia(Xd);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Xd).matches)}function Qd(){let{t:e,i18n:t}=z(),[n,r]=Li(),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),{syncAllowed:u}=Bu(),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(!0),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),E=(0,_.useRef)(0),D=(0,_.useRef)(0),O=(0,_.useRef)(!1),[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(()=>{try{return localStorage.getItem(`feedkeeper_items_view`)===`newspaper`?`newspaper`:`list`}catch{return`list`}}),te=Zd()?`newspaper`:j;function ne(e){if(e!==j){Ka(),ee(e),window.scrollTo({top:0,behavior:`instant`});try{localStorage.setItem(`feedkeeper_items_view`,e)}catch{}}}let re=`feedkeeper_filter_scope`,M=`feedkeeper_filter_unread`,ie=`feedkeeper_filter_bookmarked`,ae=n.get(`article`),oe=(()=>{let e=n.get(`feed`);if(e)return`feed:${e}`;let t=n.get(`folder`);if(t)return`folder:${t}`;try{let e=localStorage.getItem(re);if(e)return e}catch{}return``})(),se=(()=>{try{let e=localStorage.getItem(M);if(e!==null)return e===`true`}catch{}return!0})(),ce=(()=>{if(n.get(`saved`)===`1`)return!0;if(n.get(`article`))return!1;try{let e=localStorage.getItem(ie);if(e!==null)return e===`true`}catch{}return!1})(),[N,le]=(0,_.useState)(oe),[ue,de]=(0,_.useState)(se),[fe,pe]=(0,_.useState)(ce),me=ue&&!fe,[he,ge]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),_e=(0,_.useRef)(null),I=(0,_.useRef)(null),ve=(0,_.useRef)(null),[ye,be]=(0,_.useState)(61),[L,xe]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=document.querySelector(`[data-app-header]`);if(!e)return;let t=new ResizeObserver(()=>be(e.getBoundingClientRect().height));return t.observe(e),()=>t.disconnect()},[]),(0,_.useEffect)(()=>{function e(){let e=ve.current?.getBoundingClientRect().top;xe(window.scrollY>0&&e!==void 0&&e<=ye+1)}return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[ye]),(0,_.useEffect)(()=>{P&&_e.current?.focus()},[P]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 640px)`),t=()=>{e.matches&&F(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);function Se(){F(!1),requestAnimationFrame(()=>I.current?.focus())}function Ce(e){Ka(),ge(e)}function we(){Ka(),de(e=>{let t=!e;try{localStorage.setItem(M,String(t))}catch{}return t})}function Te(){Ka(),pe(e=>{let t=!e;try{localStorage.setItem(ie,String(t))}catch{}return t})}(0,_.useEffect)(()=>{if(h||O.current)return;let e=Wa(),t=requestAnimationFrame(()=>{e>0&&window.scrollTo({top:e,behavior:`instant`}),O.current=!0});return()=>cancelAnimationFrame(t)},[h]),(0,_.useEffect)(()=>{function e(){O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY)}return window.addEventListener(`scroll`,e,{passive:!0}),()=>{O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY),window.removeEventListener(`scroll`,e)}},[]),(0,_.useEffect)(()=>{let e=n.get(`feed`),t=n.get(`folder`);if(e){let t=`feed:${e}`;t!==N&&Ka(),le(t);try{localStorage.setItem(re,t)}catch{}}else if(t){let e=`folder:${t}`;e!==N&&Ka(),le(e);try{localStorage.setItem(re,e)}catch{}}else if(oe&&!n.toString()){let e=new URLSearchParams(n);oe.startsWith(`feed:`)?e.set(`feed`,oe.slice(5)):oe.startsWith(`folder:`)&&e.set(`folder`,oe.slice(7)),r(e,{replace:!0})}},[n]);function Ee(e){Ka(),le(e);try{e?localStorage.setItem(re,e):localStorage.removeItem(re)}catch{}let t=new URLSearchParams(n);t.delete(`feed`),t.delete(`folder`),e.startsWith(`feed:`)?t.set(`feed`,e.slice(5)):e.startsWith(`folder:`)&&t.set(`folder`,e.slice(7)),r(t,{replace:!0})}(0,_.useEffect)(()=>{Promise.all([U.listFeeds(),U.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]).then(([e,t])=>{a(e),f(t.folders),l(t.ok),s(!0)}).catch(e=>console.error(`Failed to load initial feeds/folders:`,e))},[]),(0,_.useEffect)(()=>{o&&N&&(N.startsWith(`feed:`)?!i.some(e=>`feed:${e.id}`===N):N.startsWith(`folder:`)&&c&&!d.some(e=>`folder:${e.id}`===N))&&Ee(``)},[o,c,i,d,N]);let De=N.startsWith(`feed:`)?Number(N.slice(5)):void 0,Oe=De===void 0?void 0:i.find(e=>e.id===De),ke=Oe?Oe.kind_override??Oe.detected_kind??`article`:`article`,Ae=N.startsWith(`folder:`)?Number(N.slice(7)):void 0,je=!he&&!fe&&De===void 0&&Ae===void 0,Me=je&&i.length>0&&i.every(e=>!e.last_polled_at);async function Ne(){try{let[e,t]=await Promise.all([U.listFeeds(),U.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]);return e.length===0&&(n.has(`folder`)||n.has(`feed`))&&(r({},{replace:!0}),le(``)),a(e),f(t.folders),l(t.ok),s(!0),e}catch(e){return console.error(`Failed to reload feeds:`,e),null}}async function Pe(){await Ne(),await Fe(),no()}async function Fe(){let e=++E.current;g(!0),y(!1),C(!1),x(!1);try{let t=await U.listItems({feedId:De,folderId:Ae,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Jd});e===E.current&&(m(t),D.current=t.length,T(t.length===Jd))}catch(t){e===E.current&&(console.error(`Failed to load items:`,t),y(!0))}finally{e===E.current&&g(!1)}}async function Ie(){if(b||!w)return;let e=E.current,t=me||fe?p.filter(e=>(!me||!e.read)&&(!fe||e.bookmarked)).length:D.current;x(!0),C(!1);try{let n=await U.listItems({feedId:De,folderId:Ae,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Jd,offset:t});e===E.current&&(D.current=t+n.length,m(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.filter(e=>!t.has(e.id))]}),T(n.length===Jd))}catch(t){e===E.current&&(console.error(`Failed to load more items:`,t),C(!0))}finally{e===E.current&&x(!1)}}let Le=(0,_.useRef)(Ie);Le.current=Ie;let Re=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=Re.current;if(!e||!w||S||b||v)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Le.current()},{rootMargin:`600px 0px`});return t.observe(e),()=>t.disconnect()},[w,S,b,v,p.length]),(0,_.useEffect)(()=>{m([]),g(!0),T(!1),x(!1);let e=setTimeout(()=>{Fe()},200);return()=>{clearTimeout(e),E.current++}},[N,ue,fe,he]),(0,_.useEffect)(()=>{if(!Me)return;let e=0,t=setInterval(()=>{e++,Ne().then(e=>{e?.some(e=>e.last_polled_at)&&Fe()}),e>=45&&clearInterval(t)},4e3);return()=>clearInterval(t)},[Me]);let ze=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(ae){let e=p.find(e=>e.id===Number(ae));A(e??null),e&&!e.read&&ze.current!==e.id&&(ze.current=e.id,U.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)))}else A(null)},[ae,p]);function Be(e){$e(e.id),A(e),e.read||(U.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)),A({...e,read:!0}));let t=new URLSearchParams(n);t.set(`article`,String(e.id)),r(t)}function Ve(){A(null);let e=new URLSearchParams(n);e.delete(`article`),r(e)}let He=k?p.findIndex(e=>e.id===k.id):-1,Ue=He>=0&&He<p.length-1,We=He>0;function Ge(){Ue&&Be(p[He+1])}function Ke(){We&&Be(p[He-1])}async function qe(t){try{await t()}catch(t){if(!(t instanceof va&&t.status===0))throw t;J.error(e(`common.offlineAction`))}}async function Je(e){let t=!e.read;e.read?await U.markUnread(e.id):await U.markRead(e.id),no(),m(n=>n.map(n=>n.id===e.id?{...n,read:t}:n)),k?.id===e.id&&A(e=>e?{...e,read:t}:null)}async function Ye(e){let t=!e.bookmarked;e.bookmarked?await U.unbookmarkItem(e.id):await U.bookmarkItem(e.id),window.setTimeout(()=>void Ba({force:!0}),t?2e4:0),m(n=>fe&&!t&&k?.id!==e.id?n.filter(t=>t.id!==e.id):n.map(n=>n.id===e.id?{...n,bookmarked:t}:n)),k?.id===e.id&&A(e=>e?{...e,bookmarked:t}:null)}async function Xe(){await qe(async()=>{await U.markAllRead({feedId:De,folderId:Ae}),await Fe(),no()})}let[R,Ze]=(0,_.useState)(!1),[Qe,$e]=(0,_.useState)(null),et=(0,_.useRef)(null);async function tt(){Ze(!0);try{let t=await U.refreshAllFeeds();await Fe(),bd(t,e)}catch{J.error(e(`items.refreshFailed`))}finally{Ze(!1)}}(0,_.useEffect)(()=>{k||Qe==null||document.querySelector(`[data-item-id="${Qe}"]`)?.scrollIntoView?.({block:`nearest`,behavior:`smooth`})},[Qe,k]),(0,_.useEffect)(()=>{if(k)return;function e(e){if(document.querySelector(`[role="dialog"], [data-shortcuts-modal]`)||Vc(e.target)||Vc(document.activeElement)||Hc(e))return;if(e.key===`/`){e.preventDefault(),et.current&&et.current.offsetParent!==null?(et.current.focus(),et.current.select()):F(!0);return}if((e.key===`r`||e.key===`R`)&&!R&&u){e.preventDefault(),tt();return}if(e.key===`A`&&e.shiftKey){e.preventDefault(),Xe();return}if(p.length===0)return;let t=Qe==null?-1:p.findIndex(e=>e.id===Qe),n=t>=0?p[t]:null;if(e.key===`j`||e.key===`J`||e.key===`ArrowDown`){e.preventDefault();let n=t<0?0:Math.min(t+1,p.length-1);$e(p[n].id)}else if(e.key===`k`||e.key===`K`||e.key===`ArrowUp`){e.preventDefault();let n=t<=0?0:t-1;$e(p[n].id)}else(e.key===`Enter`||e.key===`o`||e.key===`O`)&&n?(e.preventDefault(),Be(n)):(e.key===`m`||e.key===`M`)&&n?(e.preventDefault(),Je(n)):(e.key===`s`||e.key===`S`)&&n?(e.preventDefault(),Ye(n)):(e.key===`v`||e.key===`V`)&&n&&(e.preventDefault(),Uc(n.link))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let nt=new Intl.DateTimeFormat(t.resolvedLanguage,{dateStyle:`medium`}),rt=new Intl.DateTimeFormat(t.resolvedLanguage,{timeStyle:`short`}),it=(0,_.useMemo)(()=>{let t=[{value:``,label:e(`items.allFeeds`)}];if(d.length>0)for(let n of d)t.push({value:`folder:${n.id}`,label:n.name,group:e(`feeds.folderGroup`),badge:n.unread_count});for(let n of i)t.push({value:`feed:${n.id}`,label:n.label??n.title??n.url,group:e(`feeds.feedGroup`),badge:n.unread_count});return t},[d,i,e]),at=N?it.find(e=>e.value===N)?.label??e(`items.title`):e(`items.allFeeds`);function ot(e){m(t=>t.map(t=>t.id===e.id?{...t,...e}:t)),A(t=>t?.id===e.id?{...t,...e}:t)}let st=(0,W.jsxs)(`div`,{className:`flex flex-col gap-5 sm:gap-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 sm:gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`sr-only`,children:at}),(0,W.jsx)(Ed,{className:`block`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`relative hidden h-11 w-[220px] shrink-0 grid-cols-2 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-1 sm:grid`,role:`group`,"aria-label":e(`items.viewMode`),children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-1 left-1 w-[calc((100%-0.5rem)/2)] rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{transform:j===`newspaper`?`translateX(100%)`:`translateX(0)`}}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ne(`list`),title:e(`items.listView`),"aria-label":e(`items.listView`),"aria-pressed":j===`list`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`list`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`list`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M8 6h12M8 12h12M8 18h12`}),(0,W.jsx)(`circle`,{cx:`4`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,W.jsx)(`circle`,{cx:`4`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,W.jsx)(`circle`,{cx:`4`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.listView`)})]}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ne(`newspaper`),title:e(`items.newspaperView`),"aria-label":e(`items.newspaperView`),"aria-pressed":j===`newspaper`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`newspaper`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`newspaper`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,W.jsx)(`path`,{d:`M18 14h-8`}),(0,W.jsx)(`path`,{d:`M15 18h-5`}),(0,W.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.newspaperView`)})]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:tt,disabled:R||!u,title:e(u?R?`items.refreshing`:`items.refresh`:`plan.unavailable`),"aria-label":e(R?`items.refreshing`:`items.refresh`),className:`btn-secondary hidden h-11 w-11 shrink-0 items-center justify-center p-0! sm:flex`,children:(0,W.jsx)(qu,{className:`h-5 w-5 ${R?`animate-spin motion-reduce:animate-none`:``}`})}),(0,W.jsx)(`button`,{type:`button`,onClick:Xe,title:e(`feeds.markAllRead`),"aria-label":e(`feeds.markAllRead`),className:`btn-secondary flex h-11 w-11 shrink-0 items-center justify-center p-0!`,children:(0,W.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M3 12l4 4 6-7M11 16l3 0 7-8`})})})]})]}),(0,W.jsxs)(`div`,{ref:ve,className:`sticky z-20 py-2`,style:{top:ye},children:[L&&(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute -top-px bottom-0 left-1/2 w-screen -translate-x-1/2 border-y border-[var(--c-border)] backdrop-blur-md`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`}}),(0,W.jsxs)(`div`,{className:`items-toolbar relative z-10 flex items-center gap-2 sm:gap-3 ${P?`items-toolbar-open`:``}`,children:[(0,W.jsx)(`div`,{className:`items-toolbar-scope min-w-0 flex-1 sm:flex-none sm:w-64`,inert:P,children:(0,W.jsx)(Vu,{value:N,onChange:Ee,options:it,className:`w-full`,placeholder:e(`items.allFeeds`)})}),(0,W.jsxs)(`div`,{className:`relative hidden sm:block flex-1 min-w-0`,children:[(0,W.jsx)(`input`,{ref:et,type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input w-full pl-9 pr-3`,value:he,onChange:e=>Ce(e.target.value)}),(0,W.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none opacity-45 text-[var(--c-text-muted)]`,children:(0,W.jsx)(Yd,{})})]}),(0,W.jsxs)(`div`,{className:`items-toolbar-search relative h-[38px] min-w-0 overflow-hidden sm:hidden`,children:[(0,W.jsx)(`button`,{ref:I,type:`button`,onClick:()=>F(!0),"aria-label":e(`items.searchPlaceholder`),"aria-controls":`mobile-article-search`,"aria-expanded":P,title:e(`items.searchPlaceholder`),"aria-hidden":P,tabIndex:P?-1:0,className:`absolute inset-y-0 left-0 z-10 flex w-[38px] items-center justify-center rounded-lg border transition-opacity duration-150 ${P?`pointer-events-none opacity-0`:he?`border-[var(--c-blue3)] bg-[var(--c-surface-hover)] text-[var(--c-text)] opacity-100`:`border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] opacity-100`}`,children:(0,W.jsx)(Yd,{})}),(0,W.jsxs)(`div`,{className:`flex h-full min-w-0 items-center gap-2 transition-opacity duration-200 ${P?`opacity-100 delay-75`:`pointer-events-none opacity-0`}`,inert:!P,children:[(0,W.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,W.jsx)(Yd,{})}),(0,W.jsx)(`input`,{id:`mobile-article-search`,ref:_e,type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input min-w-0 flex-1 pl-9`,value:he,onChange:e=>Ce(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Se()}}),(0,W.jsx)(`button`,{type:`button`,onClick:Se,"aria-label":e(`common.close`),title:e(`common.close`),className:`w-[38px] h-[38px] rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] flex items-center justify-center shrink-0 cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]}),(0,W.jsxs)(`div`,{className:`items-toolbar-filters flex items-center gap-1.5 sm:gap-2 shrink-0`,inert:P,children:[(0,W.jsx)(`button`,{type:`button`,onClick:Te,title:e(fe?`items.all`:`items.bookmarkedOnly`),"aria-label":e(`items.bookmarkedOnly`),"aria-pressed":fe,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${fe?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:fe?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:we,disabled:fe,title:e(fe?`items.unreadIgnoredInSaved`:ue?`items.all`:`items.unreadOnly`),"aria-label":e(`items.unreadOnly`),"aria-pressed":me,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40 ${me?`bg-[var(--c-surface-hover)] border-[var(--c-blue3)] text-[var(--c-text)] shadow-xs`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:me?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]}),(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[{token:`has:audio`,label:e(`items.filterAudio`)},{token:`has:video`,label:e(`items.filterVideo`)},{token:`has:notes`,label:e(`items.filterNotes`)}].map(({token:e,label:t})=>{let n=RegExp(`(?:^|\\s)${e}(?:\\s|$)`,`i`).test(he);return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>{let t=he.replace(RegExp(`(?:^|\\s)${e}(?=\\s|$)`,`gi`),` `).replace(/\s+/g,` `).trim();Ce(n?t:t?`${t} ${e}`:e)},className:`rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors cursor-pointer ${n?`border-[var(--c-blue3)] bg-[var(--c-blue3)]/15 text-[var(--c-text)]`:`border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]/60`}`,children:t},e)})})]}),o&&i.length>0&&!u&&(0,W.jsx)(dd,{}),o&&i.length>0&&!v&&(0,W.jsx)(qd,{}),o&&i.length>0&&!v&&(0,W.jsx)(Kd,{}),p.length>0&&Oe?.last_error&&(0,W.jsxs)(`div`,{role:`status`,className:`mb-4 flex items-center gap-2 rounded-lg border px-3.5 py-2.5 text-sm text-[var(--c-danger)]`,style:{borderColor:`var(--c-border)`,background:`var(--c-surface)`},children:[(0,W.jsx)(td,{}),(0,W.jsx)(`span`,{children:Uu(e,Oe.last_error,Oe.url)})]}),v?(0,W.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,W.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`items.loadFailed`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void Fe(),className:`btn-secondary`,children:e(`common.retry`)})]}):h&&p.length===0?(0,W.jsx)(Ru,{size:`lg`}):p.length===0&&o&&i.length===0?(0,W.jsx)(gd,{onSubscribed:Pe}):p.length===0&&Me?(0,W.jsxs)(`div`,{role:`status`,className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,W.jsx)(Ru,{size:`lg`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`welcome.fetchingTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`welcome.fetchingHint`)})]}):p.length===0&&!he&&!fe&&Oe?.last_error?(0,W.jsxs)(`div`,{role:`status`,className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,W.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-[var(--c-danger)]/10 text-[var(--c-danger)]`,children:(0,W.jsx)(td,{})}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`items.feedUnavailableTitle`)}),(0,W.jsx)(`p`,{className:`max-w-md text-sm text-[var(--c-text-muted)]`,children:Uu(e,Oe.last_error,Oe.url)})]}):p.length===0&&je&&me&&i.length>0?(0,W.jsxs)(`div`,{className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`items.allReadTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`items.allReadHint`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(!1),className:`btn-secondary mt-1`,children:e(`items.all`)})]}):p.length===0?(0,W.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(fe&&!he?`items.noSaved`:he?`items.noResults`:`items.noItems`)}):Oe&&!he&&ke===`audio`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ld,{feed:Oe}),(0,W.jsx)(zd,{feed:Oe,items:p,focusedItemId:Qe,onOpen:Be,onBookmark:Ye,onRead:Je})]}):Oe&&!he&&ke===`video`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ld,{feed:Oe}),(0,W.jsx)(Bd,{items:p,focusedItemId:Qe,onOpen:Be,onBookmark:Ye})]}):te===`newspaper`?(0,W.jsx)(Fd,{items:p,focusedItemId:Qe,onOpen:Be,onBookmark:Ye,onRead:Je}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-4 sm:gap-5 animate-page-fade`,children:p.map(t=>{let n=t.published_at?new Date(t.published_at):null,r=Qe===t.id;return(0,W.jsx)(`li`,{"data-item-id":t.id,onClick:()=>Be(t),className:`card overflow-hidden p-4 sm:p-0 transition-colors duration-150 hover:bg-[var(--c-surface-hover)] hover:border-[var(--c-blue3)]/60 cursor-pointer group/card ${r?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)] bg-[var(--c-surface-hover)]`:``}`,style:{opacity:t.read?.6:1},children:(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-stretch justify-between gap-3 sm:gap-0`,children:[t.image_url&&(0,W.jsx)(`div`,{className:`order-first w-[calc(100%+2rem)] -mx-4 -mt-4 sm:m-0 sm:w-52 sm:min-w-52 h-48 sm:h-auto sm:self-stretch overflow-hidden shrink-0 border-b sm:border-b-0 sm:border-r bg-[var(--c-bg)] group transition-opacity hover:opacity-90 block`,style:{borderColor:`var(--c-border)`},children:(0,W.jsx)(`img`,{src:t.image_url,alt:``,className:`w-full h-full object-cover group-hover:scale-105 transition-transform duration-200`,loading:`lazy`,onError:e=>{let t=e.currentTarget.parentElement;t&&(t.style.display=`none`)}})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 sm:p-5 sm:pr-3 flex flex-col justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,W.jsx)(qc,{feedId:t.feed_id,iconUrl:t.feed_icon_url,siteUrl:t.feed_site_url,feedUrl:t.feed_url,articleUrl:t.link,className:`w-3.5 h-3.5 rounded-xs shrink-0 object-contain`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.feed_title}),(t.enclosure_url||Xc(t.link))&&(0,W.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 rounded-full border border-[var(--c-border)] px-2 py-0.5 text-[11px] font-medium tracking-normal normal-case text-[var(--c-text-muted)] shrink-0`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:t.enclosure_type?.startsWith(`video/`)||!t.enclosure_url&&Xc(t.link)?`▶`:`🎧`}),t.enclosure_duration_seconds?Yc(t.enclosure_duration_seconds):t.enclosure_type?.startsWith(`video/`)||!t.enclosure_url&&Xc(t.link)?`Video`:`Audio`]})]}),(0,W.jsx)(`h2`,{lang:Ao(t.title),className:`text-lg leading-snug font-semibold text-[var(--c-text)]${Ao(t.title)===`ja`?` ja-phrases`:``}`,children:t.title?(0,W.jsx)(Jc,{text:t.title}):null}),(0,W.jsx)(Ad,{item:t,className:`mt-3 text-sm leading-relaxed line-clamp-3 text-[var(--c-text-muted)]`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs pt-5`,style:{color:`var(--c-text-muted)`},children:[(0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 min-w-0`,children:n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,W.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,W.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,W.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,W.jsx)(`span`,{children:nt.format(n)})]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,W.jsx)(`span`,{children:rt.format(n)})]})]})}),(0,W.jsxs)(`div`,{className:`flex sm:hidden items-center gap-2 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ye(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Je(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]}),(0,W.jsxs)(`div`,{className:`hidden sm:flex items-center gap-2 pt-5 pr-5 shrink-0 self-start`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ye(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Je(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})},t.id)})}),!v&&p.length>0&&(w||S)&&(S?(0,W.jsx)(`button`,{type:`button`,onClick:()=>{Ie()},className:`btn-secondary self-center`,children:e(`common.retry`)}):(0,W.jsx)(`div`,{ref:Re,className:`flex min-h-12 items-center justify-center`,children:b&&(0,W.jsx)(Ru,{size:`sm`})})),(0,W.jsx)(Qc,{item:k,isOpen:!!k,onClose:Ve,onToggleBookmark:Ye,onToggleRead:Je,onNext:Ge,onPrevious:Ke,onItemUpdated:ot,hasNext:Ue,hasPrev:We})]});return(0,W.jsx)(Gd,{disabled:h||!u||!!k||P,onRefresh:tt,children:st})}function $d(e,t){let n=Math.min(e,t);return{sx:Math.round((e-n)/2),sy:Math.round((t-n)/2),size:n}}async function ef(e){let t=await createImageBitmap(e);try{let{sx:e,sy:n,size:r}=$d(t.width,t.height),i=document.createElement(`canvas`);i.width=256,i.height=256;let a=i.getContext(`2d`);if(!a)throw Error(`canvas_unavailable`);return a.fillStyle=`#ffffff`,a.fillRect(0,0,256,256),a.imageSmoothingQuality=`high`,a.drawImage(t,e,n,r,r,0,0,256,256),await new Promise((e,t)=>{i.toBlob(n=>n?e(n):t(Error(`encode_failed`)),`image/jpeg`,.88)})}finally{t.close()}}function tf({title:e,description:t,children:n,footer:r}){return(0,W.jsxs)(`section`,{className:`card`,children:[(e||t)&&(0,W.jsxs)(`header`,{className:`px-5 pt-5 pb-1 sm:px-6`,children:[e&&(0,W.jsx)(`h3`,{className:`text-base font-semibold`,children:e}),t&&(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]}),(0,W.jsx)(`div`,{className:`divide-y divide-[var(--c-border)]`,children:n}),r&&(0,W.jsx)(`footer`,{className:`flex flex-wrap items-center justify-end gap-3 border-t border-[var(--c-border)] px-5 py-4 sm:px-6`,children:r})]})}function nf({label:e,hint:t,htmlFor:n,children:r,stacked:i=!1,inline:a=!1}){return(0,W.jsxs)(`div`,{className:`flex gap-3 px-5 py-4 sm:px-6 ${i?`flex-col`:a?`flex-row items-center justify-between gap-4 sm:gap-6`:`flex-col sm:flex-row sm:items-center sm:justify-between sm:gap-6`}`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:n,className:`text-sm font-medium`,children:e}),t&&(0,W.jsx)(`p`,{className:`mt-0.5 text-sm text-[var(--c-text-muted)]`,children:t})]}),r&&(0,W.jsx)(`div`,{className:i?``:`shrink-0`,children:r})]})}function rf({children:e}){return(0,W.jsx)(`div`,{className:`px-5 py-4 sm:px-6`,children:e})}function af({id:e,checked:t,onChange:n,label:r}){return(0,W.jsxs)(`label`,{className:`relative inline-flex cursor-pointer items-center`,children:[(0,W.jsx)(`input`,{id:e,type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.target.checked),"aria-label":r}),(0,W.jsx)(`span`,{className:`h-6 w-11 rounded-full bg-[var(--c-border)] transition-colors peer-checked:bg-[var(--c-blue1)] peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--c-blue3)] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform after:content-[''] peer-checked:after:translate-x-5`})]})}function of({message:e}){return e?(0,W.jsx)(`p`,{role:`status`,className:`text-sm ${e.type===`error`?`text-danger`:`text-[var(--c-green3)]`}`,children:e.text}):null}function sf({title:e,description:t}){return(0,W.jsxs)(`div`,{className:`mb-5`,children:[(0,W.jsx)(`h2`,{className:`text-xl font-semibold`,children:e}),t&&(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]})}var cf=o(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),lf=o((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),uf=o((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),df=o(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),ff=o(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),pf=o((e=>{var t=lf().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),mf=o((e=>{var t=lf().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),hf=o((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),gf=o((e=>{var t=uf(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),_f=o((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),vf=o((e=>{var t=_f();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),yf=o(((e,t)=>{var n=vf();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),bf=o((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),xf=o((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
97
|
-
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),
|
|
98
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),
|
|
99
|
-
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),
|
|
96
|
+
`).map((e,t)=>(0,W.jsx)(`p`,{children:(0,W.jsx)(Jc,{text:e})},t))}):(0,W.jsx)(`p`,{className:`text-[var(--c-text-muted)] italic`,children:u(`items.noItems`)}),j&&(0,W.jsxs)(`div`,{className:`mt-6 p-4 rounded-xl border border-[var(--c-border)] bg-[var(--c-bg)] text-sm text-[var(--c-text-muted)] flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{children:u(`reader.consentWall`)}),M&&(0,W.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,className:`btn-primary text-sm whitespace-nowrap self-start sm:self-center`,children:u(`reader.readOriginal`)})]}),k&&!ie&&(0,W.jsxs)(`div`,{className:`mt-6 p-4 rounded-xl border border-[var(--c-border)] bg-[var(--c-bg)] text-sm text-[var(--c-text-muted)] flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{children:k}),M&&(0,W.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,className:`btn-secondary text-sm whitespace-nowrap self-start sm:self-center`,children:u(`reader.readOriginal`)})]}),(0,W.jsxs)(`div`,{className:`mt-12 pt-6 border-t border-[var(--c-border)]/60 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:o,disabled:!l,title:u(`reader.previous`),"aria-label":u(`reader.previous`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:a,disabled:!c,title:u(`reader.next`),"aria-label":u(`reader.next`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`9 18 15 12 9 6`})})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&!ae&&(!te||e.full_content_html)&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>void oe(),disabled:S,title:u(w?`reader.togglePreview`:`reader.toggleFullText`),"aria-label":u(w?`reader.togglePreview`:`reader.toggleFullText`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${w?`bg-[var(--c-blue1)]/15 border-[var(--c-blue1)]/40 text-[var(--c-blue1)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40`}`,children:S?(0,W.jsx)(`svg`,{className:`w-4 h-4 animate-spin text-[var(--c-blue1)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,strokeDasharray:`32`,strokeDashoffset:`12`})}):(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`}),(0,W.jsx)(`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`})]})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),"aria-label":e.bookmarked?u(`reader.unbookmark`):u(`reader.bookmark`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(e),title:e.read?u(`reader.markUnread`):u(`reader.markRead`),"aria-label":e.read?u(`reader.markUnread`):u(`reader.markRead`),className:`w-10 h-10 rounded-xl border flex items-center justify-center transition-all active:scale-95 cursor-pointer ${e.read?`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:async()=>{if(M)try{await navigator.clipboard.writeText(M),v(!0),setTimeout(()=>v(!1),2e3)}catch{}},title:u(g?`reader.linkCopied`:`reader.copyLink`),"aria-label":u(`reader.copyLink`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95 cursor-pointer relative`,children:g?(0,W.jsx)(`svg`,{className:`w-4 h-4 text-emerald-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}):(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`}),(0,W.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}),M&&(0,W.jsx)(`a`,{href:M,target:`_blank`,rel:`noreferrer noopener`,title:u(`reader.openOriginal`),"aria-label":u(`reader.openOriginal`),className:`w-10 h-10 rounded-xl border border-[var(--c-border)] flex items-center justify-center text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:bg-[var(--c-border)]/40 transition-all active:scale-95`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,W.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,W.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]})})]})]})]})})]})]})]}),document.body)}var $c=`feedkeeper:extensions-changed`,el=[`login`,`menu`,`page`],tl=/^[a-z0-9][a-z0-9-]{0,63}$/,nl=(e,t)=>typeof e==`string`&&e.trim().length>0&&e.length<=t,rl=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function il(e){return rl(e)?typeof e.id==`string`&&tl.test(e.id)&&nl(e.label,80)&&nl(e.description,300)&&nl(e.group,60)&&(e.shortLabel===void 0||nl(e.shortLabel,40))&&(e.icon===void 0||Array.isArray(e.icon)&&e.icon.length<=8&&e.icon.every(e=>typeof e==`string`&&e.length<=400))&&(e.admin===void 0||typeof e.admin==`boolean`)&&typeof e.mount==`function`:!1}function al(e,t,n){let r=rl(e)&&rl(e.settings)?e.settings:{},i=new Set(Array.isArray(r.hidden)?r.hidden.filter(e=>typeof e==`string`&&t.includes(e)):[]),a=new Set(t),o=[];for(let e of Array.isArray(r.sections)?r.sections:[])il(e)&&!a.has(e.id)&&(a.add(e.id),(!e.admin||n)&&o.push(e));return{hidden:i,sections:o}}function ol(e){let t=[];for(let n of e){let e=n.group??``,r=t.find(t=>t.group===e);r?r.sections.push(n):t.push({group:e,sections:[n]})}return t}function sl(e,t){if(typeof e==`string`)return e;if(!rl(e))return null;let n=t.toLowerCase();for(let t of[n,n.split(`-`)[0],`en`]){let n=Object.entries(e).find(([e])=>e.toLowerCase()===t)?.[1];if(typeof n==`string`)return n}return Object.values(e).find(e=>typeof e==`string`)??null}function cl(e){return/[\u0000-\u001f\\]/.test(e)||e.length>500?!1:/^\/(?![/\\])/.test(e)||/^https?:\/\/[^\s/]+/i.test(e)}function ll(e,t,n){let r=rl(e)&&Array.isArray(e.footerLinks)?e.footerLinks:[],i=[];for(let e of r.slice(0,8)){if(!rl(e))continue;let r=sl(e.label,t),a=sl(e.href,t);if(!r||!nl(r,60)||!a||!cl(a)||n&&Array.isArray(e.placements)&&!e.placements.some(e=>e===n&&el.includes(e)))continue;let o=typeof e.icon==`string`&&cl(e.icon)?e.icon:null;i.push({label:r,href:a,newTab:e.newTab===!0||/^https?:/i.test(a),icon:o})}return i}function ul(e){let t=rl(e)?e.loginForm:void 0;return rl(t)&&typeof t.mount==`function`?t:null}function dl(e){let t=rl(e)?e.passwordCard:void 0;return!rl(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function fl(e){let t=rl(e)?e.onboarding:void 0;return rl(t)&&typeof t.mount==`function`?t:null}function pl(e){if(typeof e!=`string`||e.length>500)return null;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password?t.toString():null}catch{return null}}function ml(e,t,n){let r=rl(e)&&rl(e.starterPacks)?e.starterPacks:{},i=Array.isArray(r.packs)?r.packs:[],a=new Map;if(r.replace!==!0)for(let e of t)a.set(e.id,e);for(let e of i.slice(0,12))rl(e)&&typeof e.id==`string`&&tl.test(e.id)&&Array.isArray(e.feeds)&&a.set(e.id,e);let o=[];for(let e of a.values()){let t=sl(e.title,n);if(!t||!nl(t,60))continue;let r=[];for(let t of e.feeds.slice(0,20)){if(!rl(t)||!nl(t.title,80))continue;let e=pl(t.url);if(!e)continue;let i=sl(t.description,n);r.push({title:t.title,url:e,lang:typeof t.lang==`string`?t.lang.toLowerCase().split(`-`)[0]:``,description:i&&nl(i,200)?i:``})}r.length>0&&o.push({id:e.id,title:t,description:sl(e.description,n)??``,feeds:r})}return o}function hl(e){let t=rl(e)?e.articlesNotice:void 0;return!rl(t)||typeof t.mount!=`function`?null:{mount:t.mount,...typeof t.applies==`function`?{applies:t.applies}:{}}}function gl(e,t){let n=rl(e)&&rl(e.meta)?e.meta:{},r=sl(n.title,t)?.trim()??null,i=sl(n.description,t)?.trim()??null;return{title:r&&nl(r,80)?r:null,description:i&&nl(i,300)?i:null}}function _l(e,t){if(!rl(e)||!Array.isArray(e.pages))return[];let n=[],r=new Set;for(let i of e.pages){if(!rl(i)||typeof i.id!=`string`||!tl.test(i.id)||r.has(i.id))continue;let e=sl(i.label,t);if(nl(e,40)&&typeof i.mount==`function`&&!(!Array.isArray(i.icon)||!i.icon.length||i.icon.length>8||!i.icon.every(e=>nl(e,400)))&&(n.push({id:i.id,label:e,icon:i.icon,mount:i.mount}),r.add(i.id),n.length===3))break}return n}var vl=0;function yl(e){let t=()=>{vl++,e()};return window.addEventListener($c,t),()=>window.removeEventListener($c,t)}function bl(){return(0,_.useSyncExternalStore)(yl,()=>vl),window.feedkeeperExtensions}function xl(){let{pageId:e}=vr(),{user:t}=lo(),{i18n:n}=z(),r=n.resolvedLanguage||`en`,i=_l(bl(),r).find(({id:t})=>t===e);return t&&i?(0,W.jsx)(Sl,{page:i,userId:t.id,language:r},t.id):null}function Sl({page:{mount:e},userId:t,language:n}){let r=(0,_.useRef)(null),[i,a]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(!r.current)return;let i=r.current,o=!0,s;try{s=e(i,{userId:t,language:n,appendText:Cl,openArticle:(e,t)=>{o&&a({item:e,onChange:t})}})}catch(e){console.error(`Could not mount extension page`,e),i.replaceChildren()}return()=>{o=!1,typeof s==`function`&&s(),i.replaceChildren(),a(null)}},[e,t,n]);function o(e){i&&i.item.id===e.id&&(i.onChange(e),a(t=>t?.item.id===e.id?{...t,item:{...t.item,...e}}:t))}return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{ref:r}),i&&(0,W.jsx)(Qc,{item:i.item,isOpen:!0,onClose:()=>a(null),onItemUpdated:e=>o({...i.item,...e}),onToggleRead:e=>{ya(`read`,e.id,!e.read).then(()=>{no(),o({...e,read:!e.read})}).catch(console.error)},onToggleBookmark:e=>{ya(`bookmark`,e.id,!e.bookmarked).then(()=>o({...e,bookmarked:!e.bookmarked})).catch(console.error)}})]})}function Cl(e,t){Ao(t)&&(e.lang=`ja`);for(let n of Jo(t))if(n.kind===`wbr`)e.append(document.createElement(`wbr`));else if(n.kind===`nb`){let t=document.createElement(`span`);t.className=`nb`,t.textContent=n.value,e.append(t)}else e.append(n.value)}var wl=`M435.6,124.8l0,-73.2l-435.6,0l-0,816l92.4,-0l0,-381.6l325.2,0l-0,-74.4l-325.2,0l0,-286.8l343.2,0zM1065.6,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM1722,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM2396.4,830.4l0,-830.4l-90,0l0,278.4c-18,-8.4,-97.2,-39.6,-188.4,-39.6c-164.4,0,-262.8,106.8,-262.8,306c0,242.4,86.4,337.2,279.6,337.2c121.2,-0,216,-32.4,261.6,-51.6zm-90,-48c-21.6,12,-84,33.6,-171.6,33.6c-129.6,0,-188.4,-78,-188.4,-271.2c0,-159.6,63.6,-238.8,189.6,-238.8c72,0,146.4,28.8,170.4,38.4l0,438zM3187.2,867.6l-386.4,-427.2l355.2,-388.8l-120,0l-340.8,388.8l367.2,427.2l124.8,-0zm-494.4,-0l-0,-816l-92.4,0l0,816l92.4,-0zM3776.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM4432.8,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM5133.6,544.8c0,-210,-92.4,-306,-282,-306c-118.8,0,-231.6,36,-260.4,50.4l-0,832.8l90,0l0,-280.8c16.8,13.2,99.6,40.8,187.2,40.8c165.6,0,265.2,-92.4,265.2,-337.2zm-93.6,0c0,194.4,-57.6,271.2,-188.4,271.2c-69.6,0,-141.6,-25.2,-170.4,-37.2l0,-439.2c18,-8.4,81.6,-33.6,171.6,-33.6c120,0,187.2,68.4,187.2,238.8zM5792.4,576l0,-31.2c0,-198,-98.4,-306,-259.2,-306c-165.6,0,-264,105.6,-264,306c0,228,63.6,337.2,268.8,337.2c108,-0,200.4,-30,226.8,-46.8l0,-73.2c-16.8,16.8,-115.2,55.2,-205.2,55.2c-144,0,-199.2,-82.8,-201.6,-241.2l434.4,0zm-87.6,-60l-346.8,0c2.4,-136.8,62.4,-213.6,174,-213.6c112.8,0,170.4,91.2,172.8,213.6zM6256.8,313.2l0,-68.4c-9.6,-1.2,-50.4,-6,-66,-6c-106.8,0,-223.2,39.6,-240,48l-0,580.8l90,-0l0,-531.6c16.8,-6,90,-28.8,158.4,-28.8c14.4,0,45.6,3.6,57.6,6z`;function Tl(){return(0,W.jsx)(`svg`,{className:`wordmark`,viewBox:`0 0 6257 1122`,role:`img`,"aria-label":`FeedKeeper`,children:(0,W.jsx)(`path`,{d:wl})})}function El({size:e=28}){return(0,W.jsxs)(`span`,{className:`brand-lockup`,style:{"--m":`${e}px`},children:[(0,W.jsx)(`img`,{src:`/logo.svg`,alt:``}),(0,W.jsx)(Tl,{})]})}var Dl=({isActive:e})=>`relative z-10 flex h-full items-center gap-2 rounded-lg px-3 text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${e?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`;function Ol({onItemsClick:e,pages:t}){let{t:n,i18n:r}=z(),i=dr(),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(null),c=t.map(({id:e,label:t})=>e+t).join(`|`);return(0,_.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=e.querySelector(`a[aria-current="page"]`);s(t?{left:t.offsetLeft,width:t.offsetWidth}:null)};t();let n=new ResizeObserver(t);return e.querySelectorAll(`a`).forEach(e=>n.observe(e)),()=>n.disconnect()},[i.pathname,r.resolvedLanguage,c]),(0,W.jsxs)(`nav`,{ref:a,className:`relative hidden h-9 items-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-0.5 md:flex`,children:[o&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0.5 left-0 rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-[transform,width] duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{width:o.width,transform:`translateX(${o.left}px)`}}),t.map(({id:e,label:t,icon:n})=>(0,W.jsxs)(Mi,{to:`/extensions/${e}`,className:Dl,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:n.map(e=>(0,W.jsx)(`path`,{d:e},e))}),t]},e)),(0,W.jsxs)(Mi,{to:`/items`,onClick:e,className:Dl,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),n(`nav.items`)]}),(0,W.jsxs)(Mi,{to:`/feeds`,className:Dl,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,W.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,W.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),n(`nav.feeds`)]})]})}function kl({label:e}){return(0,W.jsx)(`kbd`,{className:`inline-flex min-w-7 items-center justify-center rounded-md border border-[var(--c-border)] bg-[var(--c-surface-hover)] px-2 py-0.5 font-sans text-xs font-semibold text-[var(--c-text)] shadow-xs`,children:e})}function Al({isOpen:e,onClose:t}){let{t:n}=z(),r=(0,_.useId)();return(0,_.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),e?(0,W.jsx)(`div`,{"data-shortcuts-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs animate-fade-in`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":r,className:`card w-full max-w-2xl max-h-[85vh] overflow-y-auto p-5 sm:p-6 shadow-2xl`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-[var(--c-border)] pb-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{id:r,className:`text-lg font-semibold text-[var(--c-text)]`,children:n(`shortcuts.title`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:n(`shortcuts.subtitle`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`common.close`),title:n(`common.close`),className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-[var(--c-border)] text-[var(--c-text-muted)] transition-colors hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),(0,W.jsx)(`div`,{className:`mt-5 grid gap-6 sm:grid-cols-2`,children:Bc.map(e=>(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`mb-2.5 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:n(e.titleKey)}),(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)]`,children:e.entries.map(t=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-[var(--c-text)]`,children:n(t.labelKey)}),(0,W.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:t.keys.map((e,n)=>t.keys.length>1&&e===`/`?(0,W.jsx)(`span`,{className:`px-0.5 text-xs text-[var(--c-text-muted)]`,children:`/`},`${n}-${e}`):(0,W.jsx)(kl,{label:e},`${n}-${e}`))})]},`${e.titleKey}:${t.labelKey}`))})]},e.titleKey))})]})}):null}var jl=`fk_theme`,Ml=new Set,Nl=(()=>{try{let e=localStorage.getItem(jl);return e===`light`||e===`dark`?e:`system`}catch{return`system`}})();function Pl(e){return Ml.add(e),()=>Ml.delete(e)}function Fl(){return Nl}function Il(e){Nl=e,e===`system`?document.documentElement.removeAttribute(`data-theme`):document.documentElement.setAttribute(`data-theme`,e);try{e===`system`?localStorage.removeItem(jl):localStorage.setItem(jl,e)}catch{}Ml.forEach(e=>e())}function Ll({standalone:e,hasPrompt:t,userAgent:n,maxTouchPoints:r}){if(e)return`installed`;if(t)return`prompt`;if(/iPhone|iPad|iPod/.test(n)||/Macintosh/.test(n)&&r>1)return`ios`;let i=/Safari\//.test(n)&&!/Chrome|Chromium|CriOS|FxiOS|Edg|OPR|Firefox/.test(n);return/Macintosh/.test(n)&&i?`mac-safari`:`unsupported`}var Rl=null,zl=!1,Bl=new Set,Vl=()=>Bl.forEach(e=>e());function Hl(){window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),Rl=e,Vl()}),window.addEventListener(`appinstalled`,()=>{Rl=null,zl=!0,Vl()})}function Ul(e){Bl.add(e);let t=window.matchMedia(`(display-mode: standalone)`);return t.addEventListener(`change`,e),()=>{Bl.delete(e),t.removeEventListener(`change`,e)}}function Wl(){return Ll({standalone:zl||window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,hasPrompt:Rl!==null,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints??0})}async function Gl(){let e=Rl;if(!e)return;Rl=null,await e.prompt();let{outcome:t}=await e.userChoice;t===`accepted`&&(zl=!0),Vl()}function Kl(e,t){let n=e.trim().split(/\s+/).filter(Boolean);return n.length===0?t.charAt(0).toUpperCase()||`?`:(n[0].charAt(0)+(n.length>1?n[n.length-1].charAt(0):``)).toUpperCase()}function ql({user:e,className:t=``}){let n=Ca(e),[r,i]=(0,_.useState)(null);return(0,W.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full border border-[var(--c-border)] bg-[var(--c-mobile-nav-active)] font-semibold tracking-wide text-[var(--c-text)] ${t}`,children:n&&r!==n?(0,W.jsx)(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,onError:()=>i(n)}):(0,W.jsx)(`span`,{"aria-hidden":`true`,children:Kl(e.display_name,e.email)})})}var Jl={login:`mt-4 justify-center text-xs`,menu:`border-t border-[var(--c-border)] px-3 py-2.5 text-xs`,page:`mt-10 border-t border-[var(--c-border)] pt-4 text-xs`};function Yl({placement:e}){let{t,i18n:n}=z(),r=ll(bl(),n.resolvedLanguage||`en`,e);return r.length===0?null:(0,W.jsx)(`nav`,{"aria-label":t(`nav.footerLinks`),className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[var(--c-text-muted)] ${Jl[e]}`,children:r.map((e,t)=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-3`,children:[t>0&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`opacity-50`,children:`•`}),(0,W.jsxs)(`a`,{href:e.href,...e.newTab?{target:`_blank`,rel:`noopener noreferrer`}:{},className:`transition-colors hover:text-[var(--c-text)] hover:underline`,children:[e.icon&&(0,W.jsx)(`img`,{src:e.icon,alt:``,width:14,height:14,className:`mr-1.5 inline-block align-[-2px]`}),e.label]})]},`${e.href}-${t}`))})}var Xl={light:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,W.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41`})]}),dark:(0,W.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`}),system:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,W.jsx)(`path`,{d:`M12 3a9 9 0 0 1 0 18Z`,fill:`currentColor`,stroke:`none`})]})},Zl=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium text-[var(--c-text)] transition-colors hover:bg-[var(--c-surface-hover)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer`;function Ql({onOpenShortcuts:e}){let{t}=z(),{user:n,logout:r}=lo(),i=dr(),a=(0,_.useSyncExternalStore)(Pl,Fl),o=(0,_.useSyncExternalStore)(Ul,Wl),[s,c]=(0,_.useState)(!1),l=(0,_.useRef)(null),u=(0,_.useRef)(null),d=(0,_.useId)();if((0,_.useEffect)(()=>c(!1),[i.pathname]),(0,_.useEffect)(()=>{if(!s)return;let e=e=>{l.current?.contains(e.target)||c(!1)},t=e=>{e.key===`Escape`&&(c(!1),u.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[s]),!n)return null;let f={light:t(`settings.themeLight`),dark:t(`settings.themeDark`),system:t(`settings.themeSystem`)};return(0,W.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,W.jsx)(`button`,{ref:u,type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,"aria-controls":d,"aria-label":t(`nav.account`),title:n.display_name||n.email,className:`flex rounded-full transition-shadow cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--c-blue3)] ${s||i.pathname.startsWith(`/settings`)?`ring-2 ring-[var(--c-blue3)] ring-offset-2 ring-offset-[var(--c-surface)]`:`hover:ring-2 hover:ring-[var(--c-border)] hover:ring-offset-2 hover:ring-offset-[var(--c-surface)]`}`,children:(0,W.jsx)(ql,{user:n,className:`h-9 w-9 text-xs`})}),s&&(0,W.jsxs)(`div`,{id:d,className:`card animate-fade-in absolute right-0 top-full z-50 mt-2 w-72 max-w-[calc(100vw-2rem)] p-1.5 shadow-xl`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3 pt-2 pb-3`,children:[(0,W.jsx)(ql,{user:n,className:`h-10 w-10 text-sm`}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-semibold text-[var(--c-text)]`,children:n.display_name||n.email}),n.display_name&&(0,W.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:n.email})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-[var(--c-border)] px-3 py-3`,children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t(`settings.theme`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-xl border border-[var(--c-border)] p-0.5`,role:`group`,"aria-label":t(`settings.theme`),children:Object.keys(Xl).map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>Il(e),"aria-pressed":a===e,className:`flex h-8 items-center justify-center gap-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${a===e?`border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)] shadow-sm`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,W.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:Xl[e]}),f[e]]},e))})]}),(0,W.jsxs)(`div`,{className:`flex flex-col border-t border-[var(--c-border)] pt-1.5`,children:[(0,W.jsxs)(Mi,{to:`/settings`,className:`${Zl} max-md:hidden`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,W.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),t(`nav.settings`)]}),e&&(0,W.jsxs)(`button`,{type:`button`,className:`${Zl} hidden md:flex justify-between`,onClick:()=>{c(!1),e()},children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`}),(0,W.jsx)(`path`,{d:`M6 10h.01M10 10h.01M14 10h.01M18 10h.01M8 14h8`})]}),t(`shortcuts.title`)]}),(0,W.jsx)(`kbd`,{className:`rounded border border-[var(--c-border)] bg-[var(--c-surface-hover)] px-1.5 py-0.5 text-[11px] font-semibold text-[var(--c-text-muted)]`,children:`?`})]}),o===`prompt`&&(0,W.jsxs)(`button`,{type:`button`,className:Zl,onClick:()=>{c(!1),Gl()},children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,W.jsx)(`path`,{d:`M5 21h14`})]}),t(`settings.installApp`)]}),(0,W.jsxs)(`button`,{type:`button`,className:`${Zl} text-[var(--c-danger)]! hover:bg-[var(--c-danger-bg)]!`,onClick:()=>{c(!1),r()},children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,W.jsx)(`polyline`,{points:`16 17 21 12 16 7`}),(0,W.jsx)(`line`,{x1:`21`,y1:`12`,x2:`9`,y2:`12`})]}),t(`nav.logout`)]})]}),(0,W.jsx)(Yl,{placement:`menu`})]})]})}function $l(e){return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}}function eu(){return(0,_.useSyncExternalStore)($l,()=>navigator.onLine,()=>!0)}function tu(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(na,ta,()=>0);return eu()?null:(0,W.jsxs)(`div`,{role:`status`,className:`border-b px-4 py-2 text-center text-sm text-[var(--c-text-muted)]`,style:{borderColor:`var(--c-border)`,backgroundColor:`var(--c-surface)`},children:[e(`common.offlineBanner`),t>0&&` ${e(`common.offlinePending`,{count:t})}`]})}function nu(){let{t:e}=z(),{refresh:t}=lo();return(0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-[var(--c-bg)] px-6 text-center`,children:[(0,W.jsx)(`img`,{src:`/logo.svg`,alt:``,className:`h-12 w-12`}),(0,W.jsx)(`h1`,{className:`text-xl font-semibold`,style:{fontFamily:`Manrope, sans-serif`},children:e(`common.offlineTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`common.offlineText`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void t(),className:`btn-primary`,children:e(`common.retry`)})]})}var q=[],ru=1,iu=new Set,au=()=>iu.forEach(e=>e());function ou(e){return iu.add(e),()=>iu.delete(e)}function su(){return q}function cu(e){q=q.filter(t=>t.id!==e),au()}function lu(e,t){let n=ru++;q=[...q.slice(-2),{id:n,type:e,message:t}],au(),window.setTimeout(()=>cu(n),e===`error`?7e3:4e3)}var J={success:e=>lu(`success`,e),error:e=>lu(`error`,e),info:e=>lu(`info`,e)};function uu(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(ou,su);return(0,W.jsx)(`div`,{"aria-live":`polite`,className:`pointer-events-none fixed inset-x-0 bottom-[calc(6.5rem+env(safe-area-inset-bottom,0px))] z-[60] flex flex-col items-center gap-2 px-4 md:bottom-6`,children:t.map(t=>(0,W.jsxs)(`div`,{role:t.type===`error`?`alert`:`status`,className:`card animate-fade-in pointer-events-auto flex w-full max-w-md items-start gap-3 px-4 py-3 text-sm`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:[(0,W.jsx)(`span`,{className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-white ${t.type===`error`?`bg-[var(--c-danger)]`:t.type===`info`?`bg-[var(--c-text-muted)]`:`bg-[var(--c-green3)]`}`,"aria-hidden":`true`,children:(0,W.jsx)(`svg`,{className:`h-3 w-3`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,children:t.type===`error`?(0,W.jsx)(`path`,{d:`M12 7v6M12 17h.01`}):t.type===`info`?(0,W.jsx)(`path`,{d:`M12 7h.01M12 11v6`}):(0,W.jsx)(`path`,{d:`m5 12 5 5 9-10`})})}),(0,W.jsx)(`p`,{className:`min-w-0 flex-1 text-[var(--c-text)]`,children:t.message}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>cu(t.id),"aria-label":e(`common.close`),className:`-mr-1 shrink-0 rounded p-0.5 text-[var(--c-text-muted)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},t.id))})}var du=[.75,1,1.25,1.5,2],fu=[null,15,30,60];function pu(){let{t:e}=z(),t=mo(),[n,r]=(0,_.useState)(!1),i=t.currentItem;if(!i)return null;let a=t.duration>0?t.duration:i.enclosure_duration_seconds??0,o=a>0?Math.min(100,Math.max(0,t.currentTime/a*100)):0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{role:`region`,"aria-label":e(`player.nowPlaying`),className:`fixed bottom-[78px] md:bottom-4 left-3 right-3 md:left-auto md:right-6 md:w-[420px] z-40 rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)]/95 backdrop-blur-md shadow-xl overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`h-0.5 w-full bg-[var(--c-border)]`,children:(0,W.jsx)(`div`,{className:`h-full bg-[var(--c-blue3)] transition-all duration-200`,style:{width:`${o}%`}})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-3.5 py-2.5`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex min-w-0 flex-1 items-center gap-3 text-left cursor-pointer`,children:[i.image_url?(0,W.jsx)(`img`,{src:i.image_url,alt:``,className:`h-10 w-10 rounded-lg object-cover shrink-0 border border-[var(--c-border)]`}):(0,W.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-[var(--c-surface-hover)] border border-[var(--c-border)] flex items-center justify-center shrink-0 text-[var(--c-text-muted)]`,children:(0,W.jsxs)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M3 18v-6a9 9 0 0 1 18 0v6`}),(0,W.jsx)(`path`,{d:`M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z`})]})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-[var(--c-text)]`,children:i.title}),(0,W.jsxs)(`div`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:[i.feed_title??``,a>0?` · ${Yc(t.currentTime)} / ${Yc(a)}`:``]})]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.skip(-15),"aria-label":e(`player.back15`),className:`hidden sm:flex h-8 w-8 items-center justify-center rounded-full text-xs font-semibold text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:`-15`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.togglePlay(),"aria-label":t.isPlaying?e(`player.pause`):e(`player.play`),className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:t.isPlaying?(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-4 h-4 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.stop(),"aria-label":e(`common.close`),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]}),n&&(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end sm:items-center justify-center bg-black/60 backdrop-blur-xs p-0 sm:p-4`,onClick:()=>r(!1),children:(0,W.jsxs)(`div`,{className:`w-full sm:max-w-md rounded-t-2xl sm:rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)] p-5 shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-[0.08em] text-[var(--c-text-muted)]`,children:e(`player.nowPlaying`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(!1),"aria-label":e(`common.close`),className:`h-8 w-8 rounded-full flex items-center justify-center text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]}),i.image_url&&(0,W.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,W.jsx)(`img`,{src:i.image_url,alt:``,className:`w-48 h-48 rounded-2xl object-cover border border-[var(--c-border)] shadow-md`})}),(0,W.jsx)(`h2`,{className:`text-lg font-bold text-[var(--c-text)] leading-snug text-center mb-1`,children:i.title}),(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)] text-center mb-5`,children:i.feed_title}),a>0&&(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`input`,{type:`range`,min:0,max:a,value:Math.min(t.currentTime,a),onChange:e=>t.seek(Number(e.target.value)),className:`w-full accent-[var(--c-blue3)] cursor-pointer`}),(0,W.jsxs)(`div`,{className:`flex justify-between text-xs font-mono text-[var(--c-text-muted)] mt-1`,children:[(0,W.jsx)(`span`,{children:Yc(t.currentTime)}),(0,W.jsx)(`span`,{children:Yc(a)})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-6 mb-5`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.skip(-15),className:`px-3 py-1.5 rounded-lg text-sm font-semibold text-[var(--c-text)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:`-15s`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.togglePlay(),className:`flex h-12 w-12 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:t.isPlaying?(0,W.jsxs)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-5 h-5 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.skip(30),className:`px-3 py-1.5 rounded-lg text-sm font-semibold text-[var(--c-text)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:`+30s`})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-[var(--c-border)] pt-4 mb-4`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-1`,children:du.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>t.setRate(e),className:`rounded-md px-2 py-1 text-xs font-semibold cursor-pointer ${t.playbackRate===e?`bg-[var(--c-blue3)] text-white`:`bg-[var(--c-surface-hover)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[e,`x`]},e))}),(0,W.jsx)(`div`,{className:`flex items-center gap-1`,children:fu.map(n=>{let r=n===null?t.sleepRemainingSec===null:t.sleepRemainingSec!==null&&Math.ceil(t.sleepRemainingSec/60)<=n&&Math.ceil(t.sleepRemainingSec/60)>(n===15?0:n===30?15:30);return(0,W.jsx)(`button`,{type:`button`,onClick:()=>t.setSleepTimer(n),className:`rounded-md px-2 py-1 text-xs font-medium cursor-pointer ${r?`bg-[var(--c-blue3)]/20 text-[var(--c-text)] border border-[var(--c-blue3)]/50`:`bg-[var(--c-surface-hover)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:n===null?e(`player.sleepOff`):`${n}m`},String(n))})})]}),t.chapters.length>0&&(0,W.jsxs)(`div`,{className:`border-t border-[var(--c-border)] pt-3`,children:[(0,W.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.06em] text-[var(--c-text-muted)] mb-2`,children:e(`reader.chapters`)}),(0,W.jsx)(`ul`,{className:`max-h-44 overflow-y-auto flex flex-col gap-1`,children:t.chapters.map((e,n)=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>t.seek(e.startTime),className:`w-full text-left px-2 py-1.5 rounded-lg text-sm hover:bg-[var(--c-surface-hover)] flex items-center gap-3 cursor-pointer`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-[var(--c-text-muted)] shrink-0`,children:Yc(e.startTime)}),(0,W.jsx)(`span`,{className:`truncate text-[var(--c-text)]`,children:e.title})]})},`${e.startTime}-${n}`))})]})]})})]})}function mu(){let{t:e,i18n:t}=z(),n=_l(bl(),t.resolvedLanguage||`en`),r=dr(),[i,a]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=e=>{Vc(e.target)||Hc(e)||e.key===`?`&&(e.preventDefault(),a(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,_.useEffect)(()=>{let e=()=>void za(),t=()=>document.visibilityState===`visible`&&e();return e(),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},[]),(0,_.useEffect)(()=>{let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>void eo(),800)},n=()=>document.visibilityState===`visible`&&t();t();let r=window.setInterval(t,12e4);window.addEventListener(`online`,t),document.addEventListener(`visibilitychange`,n);let i=ro(t);return()=>{window.clearTimeout(e),window.clearInterval(r),window.removeEventListener(`online`,t),document.removeEventListener(`visibilitychange`,n),i()}},[]),(0,_.useEffect)(()=>{r.pathname!==`/items`&&(window.scrollTo({top:0,left:0,behavior:`instant`}),requestAnimationFrame(()=>{window.scrollTo({top:0,left:0,behavior:`instant`})}))},[r.pathname]);let o=()=>{r.pathname===`/items`&&(Ka(),window.scrollTo({top:0,left:0,behavior:`smooth`}))},s=n.findIndex(({id:e})=>r.pathname===`/extensions/${e}`),c=s>=0?s:n.length+(r.pathname.startsWith(`/feeds`)?1:r.pathname.startsWith(`/settings`)?2:0);return(0,W.jsxs)(`div`,{className:`min-h-screen flex flex-col`,children:[(0,W.jsx)(`header`,{"data-app-header":!0,className:`sticky top-0 z-30 backdrop-blur-md border-b`,style:{borderColor:`var(--c-border)`,backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`,paddingTop:`env(safe-area-inset-top, 0px)`},children:(0,W.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-3 flex items-center justify-between gap-4`,children:[(0,W.jsx)(Mi,{to:`/items`,onClick:o,className:`flex items-center gap-2.5 shrink-0 hover:opacity-85 transition-opacity`,children:(0,W.jsx)(El,{size:28})}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(Ol,{onItemsClick:o,pages:n}),(0,W.jsx)(Ql,{onOpenShortcuts:()=>a(!0)})]})]})}),(0,W.jsx)(tu,{}),(0,W.jsx)(`main`,{className:`flex-1 max-w-5xl w-full mx-auto px-4 pt-4 pb-24 md:py-6`,children:(0,W.jsx)(`div`,{className:`animate-page-fade`,children:(0,W.jsx)(Vr,{})},r.pathname)}),(0,W.jsx)(uu,{}),(0,W.jsx)(pu,{}),(0,W.jsx)(Al,{isOpen:i,onClose:()=>a(!1)}),(0,W.jsx)(`nav`,{className:`mobile-bottom-nav md:hidden fixed left-3 right-3 max-w-sm mx-auto z-40 pointer-events-auto no-drag select-none`,"aria-label":e(`nav.menu`),children:(0,W.jsxs)(`div`,{className:`relative flex items-center justify-between p-1.5 rounded-full border backdrop-blur-2xl backdrop-saturate-180 transition-all duration-300 no-drag select-none`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 80%, transparent)`,borderColor:`var(--c-border)`,borderWidth:`1px`,boxShadow:`0 2px 12px -4px rgba(0, 0, 0, 0.3)`},onContextMenu:e=>e.preventDefault(),children:[(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`absolute top-1.5 bottom-1.5 left-1.5 rounded-full bg-[var(--c-mobile-nav-active)] border border-[var(--c-mobile-nav-active-border)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] pointer-events-none no-drag`,style:{width:`calc((100% - 0.75rem) / ${3+n.length})`,transform:`translateX(calc(${c} * 100%))`}}),n.map(({id:e,label:t,icon:n})=>(0,W.jsx)(Mi,{to:`/extensions/${e}`,draggable:!1,className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:e})=>(0,W.jsxs)(`span`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 ${e?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] font-medium`}`,children:[(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:n.map(e=>(0,W.jsx)(`path`,{d:e},e))}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight text-center`,children:t})]})},e)),(0,W.jsx)(Mi,{to:`/items`,onClick:o,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,W.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,W.jsx)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M4 6h16M4 12h16M4 18h12`})}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.items`)})]})}),(0,W.jsx)(Mi,{to:`/feeds`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,W.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,W.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M4 11a9 9 0 0 1 9 9`}),(0,W.jsx)(`path`,{d:`M4 4a16 16 0 0 1 16 16`}),(0,W.jsx)(`circle`,{cx:`5`,cy:`19`,r:`1`})]}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.feeds`)})]})}),(0,W.jsx)(Mi,{to:`/settings`,draggable:!1,onDragStart:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),className:`relative z-10 flex-1 min-w-0 no-drag select-none`,children:({isActive:t})=>(0,W.jsxs)(`div`,{className:`h-[54px] w-full rounded-full flex flex-col items-center justify-center gap-0.5 transition-colors duration-200 cursor-pointer no-drag select-none ${t?`text-[var(--c-text)] font-semibold`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] font-medium`}`,children:[(0,W.jsxs)(`svg`,{className:`w-5 h-5 transition-transform duration-200 pointer-events-none ${t?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,W.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`})]}),(0,W.jsx)(`span`,{className:`text-[11px] leading-tight tracking-tight pointer-events-none select-none`,children:e(`nav.settings`)})]})})]})})]})}function hu(){let{t:e}=z(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1);async function f(r){r.preventDefault(),d(!0),l(null);try{await U.onboard({email:n,password:o,displayName:i}),await t()}catch{l(e(`common.error`))}finally{d(!1)}}return(0,W.jsx)(`div`,{className:`min-h-screen flex items-center justify-center px-4`,children:(0,W.jsxs)(`div`,{className:`card p-8 w-full max-w-md`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,W.jsx)(`h1`,{className:`mb-3`,children:(0,W.jsx)(El,{size:44})}),(0,W.jsx)(`p`,{className:`text-sm mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.subtitle`)})]}),(0,W.jsxs)(`form`,{onSubmit:f,className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.emailLabel`)}),(0,W.jsx)(`input`,{type:`email`,required:!0,className:`input`,value:n,onChange:e=>r(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.displayNameLabel`)}),(0,W.jsx)(`input`,{type:`text`,required:!0,className:`input`,value:i,onChange:e=>a(e.target.value)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-sm font-medium block mb-1`,children:e(`onboarding.passwordLabel`)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,className:`input`,value:o,onChange:e=>s(e.target.value)}),(0,W.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:e(`onboarding.passwordHint`)})]}),c&&(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:c}),(0,W.jsx)(`button`,{type:`submit`,disabled:u,className:`btn-primary`,children:e(`onboarding.submit`)})]}),(0,W.jsxs)(`div`,{className:`mt-6 pt-4 border-t text-sm`,style:{borderColor:`var(--c-border)`},children:[(0,W.jsx)(`p`,{className:`font-medium`,children:e(`onboarding.orUseCli`)}),(0,W.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`onboarding.cliHint`)})]})]})})}function gu(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Y(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function _u(){return vu.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var vu={stubThis:e=>e};function yu(e){let{id:t}=e;return{...e,id:Y(t),transports:e.transports,type:e.type}}function bu(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var xu=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function Su({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new xu({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new xu({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new xu({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new xu({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new xu({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new xu({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new xu({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new xu({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!bu(t))return new xu({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new xu({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new xu({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new xu({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var Cu=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},wu=[`cross-platform`,`platform`];function Tu(e){if(e&&!(wu.indexOf(e)<0))return e}async function Eu(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!_u())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:Y(t.challenge),user:{...t.user,id:Y(t.user.id)},excludeCredentials:t.excludeCredentials?.map(yu)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=Cu.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw Su({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){Du(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=gu(e))}catch(e){Du(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=gu(c.getAuthenticatorData())}catch(e){Du(`getAuthenticatorData()`,e)}return{id:o,rawId:gu(s),response:{attestationObject:gu(c.attestationObject),clientDataJSON:gu(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:Tu(a.authenticatorAttachment)}}function Du(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Ou(){if(!_u())return ku.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?ku.stubThis(new Promise(e=>e(!1))):ku.stubThis(e.isConditionalMediationAvailable())}var ku={stubThis:e=>e};function Au({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new xu({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new xu({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!bu(t))return new xu({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new xu({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new xu({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function ju(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!_u())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(yu));let a={...t,challenge:Y(t.challenge),allowCredentials:i},o={};if(n){if(!await Ou())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=Cu.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Au({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=gu(u.userHandle)),{id:c,rawId:gu(l),response:{authenticatorData:gu(u.authenticatorData),clientDataJSON:gu(u.clientDataJSON),signature:gu(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Tu(s.authenticatorAttachment)}}async function Mu(e,t,n=`POST`,r){let i=await fetch(`/api/auth/security${e}`,{method:n,signal:r,credentials:`same-origin`,headers:{"Content-Type":`application/json`},...t===void 0?{}:{body:JSON.stringify(t)}}),a=i.status===204?void 0:await i.json();if(!i.ok)throw new va(i.status,a.error,a);return a}async function Nu(){let e=await Mu(`/reauth/passkey/options`,{}),t=await ju({optionsJSON:e.publicKey});return(await Mu(`/reauth/passkey/verify`,{challengeId:e.challengeId,credential:t})).reauthToken}async function Pu(e,t){let n=await Mu(`/passkeys/register/options`,{reauthToken:e}),r=await Eu({optionsJSON:n.publicKey});await Mu(`/passkeys/register/verify`,{challengeId:n.challengeId,credential:r,name:t})}function Fu(e){let t,n;function r(){t?.abort(),t=void 0,clearTimeout(n)}async function i(a=!0){if(t&&a)return;r();let o=new AbortController,{signal:s}=o;t=o;let c=!1;try{if(a){let t=await window.PublicKeyCredential?.isConditionalMediationAvailable?.().catch(()=>!1)??!1;if(s.aborted||(e.onAutofill(t),!t))return}let t=await Mu(`/passkeys/options`,{},`POST`,s);if(s.aborted)return;a&&(n=setTimeout(()=>{r(),i()},24e4));let o=await navigator.credentials.get({signal:s,...a?{mediation:`conditional`}:{},publicKey:{...t.publicKey,extensions:t.publicKey.extensions,challenge:Y(t.publicKey.challenge),allowCredentials:a?[]:t.publicKey.allowCredentials?.map(e=>({type:`public-key`,id:Y(e.id),transports:e.transports}))}});if(s.aborted||!o)return;clearTimeout(n),c=!0,e.onSelect();let l=o.response,u={id:o.id,rawId:gu(o.rawId),type:o.type,clientExtensionResults:o.getClientExtensionResults(),response:{clientDataJSON:gu(l.clientDataJSON),authenticatorData:gu(l.authenticatorData),signature:gu(l.signature),userHandle:l.userHandle?gu(l.userHandle):null}};await Mu(`/passkeys/verify`,{challengeId:t.challengeId,credential:u},`POST`,s),s.aborted||await e.onSuccess()}catch(t){s.aborted||(c||!a?e.onError(t):t instanceof Error&&t.name===`NotAllowedError`||e.onAutofill(!1))}finally{t===o&&(clearTimeout(n),t=void 0)}}return{start:i,stop:r}}function Iu({name:e,mount:t}){let n=(0,_.useRef)(null),r=z().i18n.resolvedLanguage;return(0,_.useEffect)(()=>{let r=n.current;if(!r)return;let i;try{i=t(r)}catch(t){console.error(`[extensions] "${e}" failed to open`,t)}return()=>{try{typeof i==`function`&&i()}catch(t){console.error(`[extensions] "${e}" failed to close`,t)}r.replaceChildren()}},[e,r]),(0,W.jsx)(`div`,{ref:n,className:`min-w-0`})}function Lu(){let{t:e}=z(),{refresh:t}=lo(),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),f=(0,_.useRef)(void 0),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)(`https://github.com/visualfusion/feedkeeper`),[w,T]=(0,_.useState)(null),E=ul(bl()),D=E?.mount,O=(0,_.useEffectEvent)(async()=>{await j(),y(!1)}),k=(0,_.useEffectEvent)(()=>{g(e(`login.error`)),y(!1)});(0,_.useEffect)(()=>{if(!c||i||D)return;let e=Fu({onAutofill:d,onSelect:()=>{y(!0),g(null)},onSuccess:O,onError:k});f.current=e,e.start();let t=()=>{e.start()},n=()=>{e.stop(),y(!1)};return window.addEventListener(`pagehide`,n),window.addEventListener(`pageshow`,t),()=>{e.stop(),f.current=void 0,window.removeEventListener(`pagehide`,n),window.removeEventListener(`pageshow`,t)}},[c,i,D]),(0,_.useEffect)(()=>{Mu(`/config`,void 0,`GET`).then(e=>l(e.passkeys)).catch(()=>{}),U.getConfig().then(e=>{e&&(x(e.showGithubLink),e.githubUrl&&C(e.githubUrl),e.loginSubtitle&&T(e.loginSubtitle))}).catch(()=>{})},[]);async function A(t){if(t.preventDefault(),!v){f.current?.stop(),y(!0),g(null);try{i?await Mu(`/mfa`,{challengeId:i,code:o}):await U.login(n,p),await j()}catch(t){t instanceof va&&t.code===`mfa_required`?(a(t.data.challengeId),m(``)):(g(e(`login.error`)),f.current?.start())}finally{y(!1)}}}async function j(){let e=new URLSearchParams(window.location.search).get(`next`);e?.startsWith(`/oauth/authorize?`)?window.location.assign(e):await t()}return(0,W.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center px-4`,children:[(0,W.jsxs)(`div`,{className:`card p-8 w-full max-w-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center mb-6 text-center`,children:[(0,W.jsx)(`h1`,{className:`mb-3`,children:(0,W.jsx)(El,{size:44})}),(0,W.jsx)(`p`,{className:`text-xs mt-1`,style:{color:`var(--c-text-muted)`},children:w??e(`login.subtitle`)})]}),E?(0,W.jsx)(Iu,{name:`login-form`,mount:E.mount}):(0,W.jsxs)(`form`,{onSubmit:A,className:`flex flex-col gap-4`,children:[!i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`login-email`,className:`text-sm font-medium block mb-1`,children:e(`login.emailLabel`)}),(0,W.jsx)(`input`,{id:`login-email`,name:`username`,type:`email`,autoComplete:`username webauthn`,required:!0,autoFocus:!0,className:`input`,value:n,onChange:e=>r(e.target.value),onFocus:()=>{v||f.current?.start()}})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{htmlFor:`login-password`,className:`text-sm font-medium block mb-1`,children:e(`login.passwordLabel`)}),(0,W.jsx)(`input`,{type:`password`,id:`login-password`,name:`password`,autoComplete:`current-password`,required:!0,className:`input`,value:p,onChange:e=>m(e.target.value)})]})]}),i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`label`,{htmlFor:`mfa-code`,children:e(`security.code`)}),(0,W.jsx)(`input`,{id:`mfa-code`,className:`input`,autoFocus:!0,autoComplete:`one-time-code`,value:o,onChange:e=>s(e.target.value),required:!0}),(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{a(void 0),s(``)},children:e(`security.cancel`)})]}),c&&!i&&u===!1&&(0,W.jsx)(`button`,{type:`button`,className:`text-sm underline`,disabled:v,onClick:()=>void f.current?.start(!1),children:e(`security.signInPasskey`)}),h&&(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:h}),(0,W.jsx)(`button`,{type:`submit`,disabled:v,className:`btn-primary`,children:e(`login.submit`)})]})]}),(0,W.jsx)(Yl,{placement:`login`}),b&&(0,W.jsx)(`div`,{className:`mt-4 text-center`,children:(0,W.jsxs)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-[var(--c-text-muted)] hover:text-[var(--c-text)] transition-colors opacity-80 hover:opacity-100`,children:[(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z`})}),(0,W.jsx)(`span`,{children:e(`login.viewOnGithub`)})]})})]})}function Ru({className:e=``,size:t=`md`,center:n=!0}){let{t:r}=z(),i=(0,W.jsx)(`div`,{className:`rounded-full animate-spin border-[var(--c-border)] border-t-[var(--c-blue1)] dark:border-t-white/80 ${{sm:`w-5 h-5 border-2`,md:`w-8 h-8 border-[2.5px]`,lg:`w-10 h-10 border-3`}[t]} ${e}`,role:`status`,"aria-label":r(`common.loading`)});return n?(0,W.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center min-h-[45vh] w-full py-12 animate-fade-in`,children:i}):i}function zu({label:e,items:t,className:n=``}){let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useId)();return(0,_.useLayoutEffect)(()=>{if(!r||!c.current)return;let e=c.current.getBoundingClientRect();o(window.innerHeight-e.bottom<48*t.length+24)},[r,t.length]),(0,_.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&(i(!1),c.current?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,W.jsxs)(`div`,{ref:s,className:`relative ${n}`,children:[(0,W.jsx)(`button`,{ref:c,type:`button`,onClick:e=>{e.stopPropagation(),i(e=>!e)},"aria-label":e,title:e,"aria-expanded":r,"aria-controls":l,className:`flex h-9 w-9 items-center justify-center rounded-lg text-[var(--c-text-muted)] transition-colors hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] cursor-pointer ${r?`bg-[var(--c-surface-hover)] text-[var(--c-text)]`:``}`,children:(0,W.jsxs)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.8`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.8`}),(0,W.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.8`})]})}),r&&(0,W.jsx)(`div`,{id:l,className:`card animate-fade-in absolute right-0 z-40 w-64 p-1.5 ${a?`bottom-full mb-2`:`top-full mt-2`}`,style:{boxShadow:`0 16px 40px -12px rgba(0, 0, 0, 0.35)`},children:t.map(e=>(0,W.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:t=>{t.stopPropagation(),i(!1),e.onSelect()},className:`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-default ${e.danger?`text-[var(--c-danger)] hover:bg-[var(--c-danger-bg)]`:`text-[var(--c-text)] hover:bg-[var(--c-surface-hover)]`}`,children:[e.icon&&(0,W.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center ${e.danger?``:`text-[var(--c-text-muted)]`}`,children:e.icon}),e.label]},e.label))})]})}function Bu(){let{user:e}=lo(),t=e?.capabilities;return{syncAllowed:!t||t.features.sync===!0,manageUrl:t?.manageUrl??null}}function Vu({value:e,onChange:t,options:n,placeholder:r,className:i=``,size:a=`md`,disabled:o=!1,ariaLabel:s}){let{t:c}=z(),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(-1),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useId)(),g=n.find(t=>t.value===e);(0,_.useEffect)(()=>{function e(e){p.current&&!p.current.contains(e.target)&&u(!1)}if(l)return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[l]),(0,_.useEffect)(()=>{if(l){let t=n.findIndex(t=>t.value===e);f(t>=0?t:0)}},[l,e,n]),(0,_.useEffect)(()=>{if(l&&d>=0&&m.current){let e=m.current.querySelector(`[data-index="${d}"]`);e&&e.scrollIntoView({block:`nearest`})}},[d,l]);function v(e){o||(l?e.key===`Escape`?(e.preventDefault(),u(!1)):e.key===`ArrowDown`?(e.preventDefault(),f(e=>e<n.length-1?e+1:0)):e.key===`ArrowUp`?(e.preventDefault(),f(e=>e>0?e-1:n.length-1)):e.key===`Home`?(e.preventDefault(),f(0)):e.key===`End`?(e.preventDefault(),f(n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d>=0&&d<n.length&&(t(n[d].value),u(!1))):(e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(!0)))}let y=[];n.forEach((e,t)=>{let n=e.group??null,r=y.find(e=>e.groupName===n);r||(r={groupName:n,items:[]},y.push(r)),r.items.push({opt:e,index:t})});let b=a===`sm`;return(0,W.jsxs)(`div`,{ref:p,className:`relative inline-block ${i}`,onKeyDown:v,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(!1)},children:[(0,W.jsxs)(`button`,{type:`button`,id:h,role:`combobox`,"aria-label":s,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?`${h}-listbox`:void 0,"aria-activedescendant":l&&d>=0?`${h}-option-${d}`:void 0,disabled:o,onClick:()=>!o&&u(e=>!e),className:`w-full flex items-center justify-between gap-2 text-left font-normal transition-colors cursor-pointer select-none rounded-lg border bg-[var(--c-surface)] text-[var(--c-text)] shadow-xs hover:border-[var(--c-blue3)] focus:outline-none focus:border-[var(--c-blue3)] ${l?`border-[var(--c-blue3)]`:`border-[var(--c-border)]`} ${b?`px-2.5 py-1 text-xs min-h-[30px]`:`px-3 py-1.5 text-sm min-h-[38px]`} ${o?`opacity-50 cursor-not-allowed`:``}`,children:[(0,W.jsx)(`span`,{className:`truncate flex items-center gap-1.5`,children:g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`truncate`,children:g.label}),g.badge!==void 0&&(0,W.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:g.badge})]}):(0,W.jsx)(`span`,{style:{color:`var(--c-text-muted)`},children:r??`—`})}),(0,W.jsx)(`svg`,{className:`shrink-0 transition-transform duration-200 opacity-60 ${l?`rotate-180`:``} ${b?`w-3 h-3`:`w-3.5 h-3.5`}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]}),l&&(0,W.jsx)(`div`,{className:`absolute left-0 mt-1 w-full min-w-[180px] max-w-xs sm:max-w-none rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] shadow-lg z-50 overflow-hidden`,style:{backdropFilter:`blur(8px)`},children:(0,W.jsx)(`ul`,{ref:m,id:`${h}-listbox`,role:`listbox`,"aria-labelledby":h,className:`max-h-60 overflow-y-auto py-1 text-[var(--c-text)] focus:outline-none`,children:n.length===0?(0,W.jsx)(`li`,{className:`px-3 py-2 text-xs italic`,style:{color:`var(--c-text-muted)`},children:r??c(`common.noOptions`)}):y.map((n,r)=>(0,W.jsxs)(`li`,{role:`group`,"aria-label":n.groupName??void 0,children:[n.groupName&&(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider select-none border-t first:border-t-0`,style:{borderColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.groupName}),(0,W.jsx)(`ul`,{role:`presentation`,children:n.items.map(({opt:n,index:r})=>{let i=n.value===e,a=r===d;return(0,W.jsxs)(`li`,{id:`${h}-option-${r}`,"data-index":r,role:`option`,"aria-selected":i,onClick:()=>{t(n.value),u(!1)},onMouseEnter:()=>f(r),className:`flex items-center justify-between gap-2 cursor-pointer select-none transition-colors ${b?`px-2.5 py-1.5 text-xs`:`px-3 py-2 text-sm`} ${a?`bg-[var(--c-border)]/40 text-[var(--c-text)]`:`text-[var(--c-text)]`} ${i?`font-medium bg-[var(--c-blue1)]/10`:``}`,children:[(0,W.jsxs)(`span`,{className:`truncate flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:n.label}),n.badge!==void 0&&(0,W.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.2 rounded-full font-medium shrink-0`,style:{backgroundColor:`var(--c-border)`,color:`var(--c-text-muted)`},children:n.badge})]}),i&&(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,style:{color:`var(--c-blue3)`},viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})]},n.value)})})]},n.groupName??`ungrouped-${r}`))})})]})}function Hu(e){if(!e)return!1;try{let t=new URL(e).hostname.toLowerCase();return t===`reddit.com`||t.endsWith(`.reddit.com`)}catch{return!1}}function Uu(e,t,n){let r=/^feed_http_(\d{3})$/.exec(t);if(r){let t=Number(r[1]);return t===404||t===410?e(`feeds.errors.notFound`,{status:t}):t===401||t===403?e(`feeds.errors.refused`,{status:t}):t===429?Hu(n)?e(`feeds.errors.redditLimited`):e(`feeds.errors.limited`):e(t>=400&&t<500&&t!==408&&t!==425?`feeds.errors.rejected`:`feeds.errors.unavailable`,{status:t})}return t===`feed_timeout`?e(`feeds.errors.timeout`):t===`feed_network_error`?e(`feeds.errors.network`):t===`feed_invalid_or_unavailable`?e(`feeds.errors.invalidFeed`):t}var Wu=[[`day`,864e5],[`hour`,36e5],[`minute`,6e4]];function Gu(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e.getTime()-n;for(let[e,t]of Wu)if(Math.abs(i)>=t)return r.format(Math.round(i/t),e);return r.format(0,`minute`)}function Ku({children:e,className:t=`h-4 w-4`}){return(0,W.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e})}var qu=({className:e})=>(0,W.jsxs)(Ku,{className:e,children:[(0,W.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.64-6.36`}),(0,W.jsx)(`path`,{d:`M21 3v6h-6`})]}),Ju=()=>(0,W.jsx)(Ku,{children:(0,W.jsx)(`path`,{d:`M2 12l4 4 6-7M10 16l2 0 8-9`})}),Yu=()=>(0,W.jsxs)(Ku,{children:[(0,W.jsx)(`path`,{d:`M12 20h9`}),(0,W.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),X=()=>(0,W.jsx)(Ku,{children:(0,W.jsx)(`path`,{d:`M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6`})}),Xu=({className:e})=>(0,W.jsx)(Ku,{className:e,children:(0,W.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),Z=()=>(0,W.jsxs)(Ku,{children:[(0,W.jsx)(`path`,{d:`M12 15V3M7 8l5-5 5 5`}),(0,W.jsx)(`path`,{d:`M5 21h14`})]}),Q=()=>(0,W.jsxs)(Ku,{children:[(0,W.jsx)(`path`,{d:`M12 3v12M7 10l5 5 5-5`}),(0,W.jsx)(`path`,{d:`M5 21h14`})]}),Zu=()=>(0,W.jsx)(Ku,{children:(0,W.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}),Qu=()=>(0,W.jsxs)(Ku,{className:`h-4 w-4`,children:[(0,W.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,W.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),$u=()=>(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:[6,12,18].flatMap(e=>[9,15].map(t=>(0,W.jsx)(`circle`,{cx:t,cy:e,r:`1.5`},`${t}-${e}`)))}),ed=()=>(0,W.jsx)(Ku,{className:`h-5 w-5`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),td=()=>(0,W.jsxs)(Ku,{className:`h-3.5 w-3.5 shrink-0`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,W.jsx)(`path`,{d:`M12 8v4M12 16h.01`})]}),nd=({className:e=`h-3.5 w-3.5`})=>(0,W.jsxs)(Ku,{className:e,children:[(0,W.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,W.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]});function rd(e,t){return t<60?e(`feeds.minutesShort`,{count:t}):e(`feeds.hoursShort`,{count:Math.round(t/60)})}function id(e){try{return e?new URL(e).hostname.replace(/^www\./,``):null}catch{return null}}function ad({feed:e,folderOptions:t,intervalOptions:n,onClose:r,onSaved:i}){let{t:a}=z(),[o,s]=(0,_.useState)(e.label?.trim()||e.title?.trim()||e.url),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(e.folder_id??null),[f,p]=(0,_.useState)(e.poll_interval_minutes),[m,h]=(0,_.useState)(e.kind_override??`auto`),[g,v]=(0,_.useState)(e.full_text_mode!==`never`),[y,b]=(0,_.useState)(),[x,S]=(0,_.useState)(),[C,w]=(0,_.useState)(!1);async function T(){w(!0);try{await U.updateFeed(e.id,{...c?{label:o.trim()||null}:{},folderId:u,pollIntervalMinutes:f,fullTextMode:g?`auto`:`never`,kindOverride:m===`auto`?null:m,...y===void 0?{}:{notify:y},...x===void 0?{}:{badge:x}}),no(),J.success(a(`feeds.changesSaved`)),r(),await i()}catch{J.error(a(`common.error`))}finally{w(!1)}}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-[var(--c-border)] bg-[var(--c-bg)]/60 px-4 py-4 sm:px-5`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.labelPlaceholder`),(0,W.jsx)(`input`,{type:`text`,className:`input text-sm`,placeholder:e.title??e.url,value:o,onChange:e=>{s(e.target.value),l(!0)}})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.folder`),(0,W.jsx)(Vu,{value:u?String(u):``,onChange:e=>d(e?Number(e):null),options:t,className:`w-full`,placeholder:a(`feeds.noFolder`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.interval`),(0,W.jsx)(Vu,{value:String(f),onChange:e=>p(Number(e)),options:n,className:`w-full`})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-xs font-medium text-[var(--c-text-muted)]`,children:[a(`feeds.feedKind`),(0,W.jsx)(Vu,{value:m,onChange:h,options:[{value:`auto`,label:a(`feeds.kindAuto`)},{value:`article`,label:a(`feeds.kindArticle`)},{value:`audio`,label:a(`feeds.kindAudio`)},{value:`video`,label:a(`feeds.kindVideo`)}],className:`w-full`})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:g,onChange:e=>v(e.target.checked)}),(0,W.jsxs)(`span`,{children:[a(`feeds.fullText`),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:e.full_text_blocked_at?a(`feeds.fullTextBlocked`):a(`feeds.fullTextHint`)})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:y??e.notify!==0,onChange:e=>b(e.target.checked)}),(0,W.jsxs)(`span`,{children:[a(`feeds.notify`),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.notifyHint`)})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer select-none items-start gap-2.5 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 rounded`,checked:x??e.badge!==0,onChange:e=>S(e.target.checked)}),(0,W.jsxs)(`span`,{children:[a(`feeds.badge`),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--c-text-muted)]`,children:a(`feeds.badgeHint`)})]})]}),(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-[var(--c-text-muted)]`,title:e.url,children:e.url}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:r,className:`btn-secondary px-3 py-1.5 text-sm`,children:a(`common.cancel`)}),(0,W.jsx)(`button`,{type:`button`,onClick:T,disabled:C,className:`btn-primary px-4 py-1.5 text-sm`,children:a(`common.save`)})]})]})}function od({feed:e,editing:t,refreshing:n,highlighted:r=!1,folderOptions:i,intervalOptions:a,onEdit:o,onRefresh:s,onMarkRead:c,onUnsubscribe:l,onSaved:u,drag:d}){let{t:f,i18n:p}=z(),{syncAllowed:m}=Bu(),h=e.label??e.title??e.url,g=id(e.site_url)??id(e.url),v=!!e.last_error,y=!e.last_polled_at,[b,x]=(0,_.useState)(!1),S=async()=>{if(!b&&e.suggested_url){x(!0);try{await U.acceptFeedMove(e.id),u(),no()}catch(e){J.error(e instanceof Error?e.message:f(`common.error`))}finally{x(!1)}}},C=[{label:f(n?`feeds.refreshing`:`feeds.refreshFeed`),icon:(0,W.jsx)(qu,{className:`h-4 w-4 ${n?`animate-spin`:``}`}),onSelect:s,disabled:n||!m},...e.unread_count>0?[{label:f(`feeds.markAllRead`),icon:(0,W.jsx)(Ju,{}),onSelect:c}]:[],{label:f(`feeds.edit`),icon:(0,W.jsx)(Yu,{}),onSelect:()=>o(!t)},{label:f(`feeds.unsubscribe`),icon:(0,W.jsx)(X,{}),onSelect:l,danger:!0}];return(0,W.jsxs)(`li`,{id:`feed-${e.id}`,draggable:!!d&&!t,onDragStart:d?.onDragStart,onDragOver:d?.onDragOver,onDragEnd:d?.onDragEnd,onDrop:d?.onDrop,className:`group/feed relative scroll-mt-28 first:rounded-t-xl last:rounded-b-xl transition-[opacity,background-color] duration-700 ${r?`bg-[var(--c-mobile-nav-active)]`:``} ${d?.isDragging?`opacity-40`:``} ${d?.isDragOver?`shadow-[inset_0_2px_0_var(--c-blue3)]`:``}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3.5 sm:px-5`,children:[d&&(0,W.jsx)(`span`,{className:`-mr-1 flex shrink-0 cursor-grab touch-none text-[var(--c-text-muted)] opacity-50 transition-opacity hover:opacity-100 group-hover/feed:opacity-80 active:cursor-grabbing`,title:f(`feeds.dragHandle`),"aria-hidden":`true`,children:(0,W.jsx)($u,{})}),(0,W.jsx)(qc,{feedId:e.id,iconUrl:e.icon_url,siteUrl:e.site_url,feedUrl:e.url,fallbackName:h,className:`h-5 w-5 shrink-0 rounded object-contain text-xs leading-none`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(v||y)&&(0,W.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${v?`bg-[var(--c-danger)]`:`bg-[var(--c-text-muted)]`}`,title:v?f(`feeds.statusFailing`,{count:e.consecutive_errors||1}):f(`feeds.statusPending`)}),(0,W.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`truncate font-semibold text-[var(--c-text)] hover:underline`,children:h}),e.notify!==0&&(0,W.jsx)(`span`,{className:`inline-flex shrink-0 items-center text-[var(--c-text-muted)]`,title:f(`feeds.notifyActive`),"aria-label":f(`feeds.notifyActive`),children:(0,W.jsx)(nd,{className:`h-3.5 w-3.5`})})]}),(0,W.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[g,f(`feeds.everyInterval`,{interval:rd(f,e.poll_interval_minutes)}),e.last_polled_at?f(`feeds.checkedAgo`,{time:Gu(new Date(e.last_polled_at),p.resolvedLanguage)}):f(`feeds.statusPending`)].filter(Boolean).join(` · `)}),v&&(0,W.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1.5 text-xs text-[var(--c-danger)]`,title:e.last_error??void 0,children:[(0,W.jsx)(td,{}),(0,W.jsx)(`span`,{className:`line-clamp-2`,children:Uu(f,e.last_error??``,e.url)})]}),e.suggested_url&&m&&(0,W.jsx)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void S(),disabled:b,title:e.suggested_url,className:`inline-flex items-center gap-1.5 rounded-md border border-[var(--c-blue3)]/50 bg-[var(--c-blue3)]/10 px-2.5 py-1 text-xs font-medium text-[var(--c-text)] hover:bg-[var(--c-blue3)]/20 transition-colors cursor-pointer disabled:opacity-50`,children:f(b?`feeds.acceptingSuggestedMove`:`feeds.acceptSuggestedMove`)})})]}),e.unread_count>0&&(0,W.jsx)(ji,{to:`/items?feed=${e.id}`,draggable:!1,className:`shrink-0 rounded-full bg-[var(--c-mobile-nav-active)] px-2.5 py-0.5 text-xs font-semibold tabular-nums text-[var(--c-text)] hover:bg-[var(--c-border)]`,title:f(`feeds.unread`,{count:e.unread_count}),children:e.unread_count}),(0,W.jsx)(zu,{label:f(`feeds.moreActions`),items:C,className:`-mr-2 shrink-0`})]}),t&&(0,W.jsx)(ad,{feed:e,folderOptions:i,intervalOptions:a,onClose:()=>o(!1),onSaved:u})]})}function sd(e,t){let n=t.toLowerCase().split(`-`)[0],r=e.feeds.filter(e=>e.lang===n||e.lang===``),i=n===`en`||n===`ja`&&r.length>0?[]:e.feeds.filter(e=>e.lang===`en`);return[...r,...i]}function cd(e,t){let n=t.toLowerCase().split(`-`)[0],r=e=>e.lang===n||e.lang===``?0:e.lang===`en`?1:2;return[...e.feeds].sort((e,t)=>r(e)-r(t))}function ld({folderOptions:e,defaultFolderId:t,initialUrl:n=``,subscribedUrls:r=[],compact:i=!1,onClose:a,onAdded:o}){let{t:s}=z(),[c,l]=(0,_.useState)(n),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(t),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)([]),y=new Set(r.map(ud));async function b(e,t){h(!0),v([]);try{let n=await U.subscribeFeed(e,t,f);l(``),d(``),await o(n)}catch(e){e instanceof va&&e.code===`multiple_feeds_found`&&e.data&&typeof e.data==`object`&&`feeds`in e.data?v(e.data.feeds):e instanceof va&&e.code===`already_subscribed`?J.error(s(`feeds.alreadySubscribed`)):e instanceof va&&(e.code===`no_feeds_found`||e.code===`invalid_feed`)?J.error(s(`feeds.noFeedsFoundOnPage`)):J.error(s(`feeds.subscribeFailed`))}finally{h(!1)}}function x(e){e.preventDefault();let t=c.trim();t&&!/^https?:\/\//i.test(t)&&(t=t.startsWith(`//`)?`https:${t}`:`https://${t}`),b(t,u.trim()||null)}return(0,W.jsxs)(`section`,{className:i?`flex flex-col gap-4`:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[!i&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:s(`feeds.addFeed`)}),(0,W.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":s(`common.close`),children:(0,W.jsx)(ed,{})})]}),(0,W.jsxs)(`form`,{onSubmit:x,className:`flex flex-col gap-3 ${i?`sm:flex-row sm:items-start`:``}`,children:[(0,W.jsx)(`input`,{type:`text`,required:!0,autoFocus:!i,placeholder:s(`feeds.urlPlaceholder`),className:i?`input sm:flex-1`:`input`,value:c,onChange:e=>{l(e.target.value),g.length&&v([])}}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[!i&&(0,W.jsx)(`input`,{type:`text`,placeholder:s(`feeds.labelPlaceholder`),className:`input sm:flex-1`,value:u,onChange:e=>d(e.target.value)}),!i&&(0,W.jsx)(Vu,{value:f?String(f):``,onChange:e=>p(e?Number(e):null),options:e,className:`w-full sm:w-52`,placeholder:s(`feeds.noFolder`)}),(0,W.jsx)(`button`,{type:`submit`,disabled:m,className:`btn-primary whitespace-nowrap`,children:s(m?`feeds.subscribing`:`feeds.subscribe`)})]})]}),g.length>0&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:s(`feeds.multipleFeedsFound`)}),(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:g.map(e=>{let t=y.has(ud(e.url));return(0,W.jsxs)(`li`,{className:`flex flex-col gap-2.5 px-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-3 ${t?`opacity-70`:``}`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`p`,{className:`break-words text-sm font-medium`,children:e.title??e.url}),(0,W.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:e.url})]}),(0,W.jsx)(`button`,{type:`button`,disabled:m||t,onClick:()=>b(e.url,e.title||u.trim()||null),className:`btn-primary w-full shrink-0 whitespace-nowrap px-3 py-1.5 text-xs sm:w-auto`,children:s(t?`feeds.subscribed`:`feeds.subscribe`)})]},e.url)})})]})]})}function ud(e){return e.trim().replace(/\/+$/,``).toLowerCase()}function dd(){let{t:e}=z(),{manageUrl:t}=Bu();return(0,W.jsxs)(`section`,{role:`status`,className:`card flex flex-col gap-2 p-4 sm:p-5`,"aria-labelledby":`plan-notice-title`,children:[(0,W.jsx)(`h2`,{id:`plan-notice-title`,className:`text-base font-semibold`,children:e(`plan.limitedTitle`)}),(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`plan.limitedText`)}),t&&(0,W.jsx)(`a`,{href:t,className:`btn-primary self-start`,style:{textDecoration:`none`},children:e(`plan.view`)})]})}var fd={news:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,W.jsx)(`path`,{d:`M18 14h-8`}),(0,W.jsx)(`path`,{d:`M15 18h-5`}),(0,W.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),technology:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`}),(0,W.jsx)(`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`}),(0,W.jsx)(`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`})]}),development:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`m18 16 4-4-4-4`}),(0,W.jsx)(`path`,{d:`m6 8-4 4 4 4`}),(0,W.jsx)(`path`,{d:`m14.5 4-5 16`})]}),science:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`}),(0,W.jsx)(`path`,{d:`M8.5 2h7`}),(0,W.jsx)(`path`,{d:`M7 16h10`})]}),design:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}),(0,W.jsx)(`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.563-2.512 5.563-5.563C22 6.5 17.5 2 12 2Z`})]}),gaming:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`}),(0,W.jsx)(`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`}),(0,W.jsx)(`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`}),(0,W.jsx)(`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`}),(0,W.jsx)(`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`})]}),business:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`}),(0,W.jsx)(`polyline`,{points:`16 7 22 7 22 13`})]}),sport:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M6 9H4.5a2.5 2.5 0 0 1 0-5H6`}),(0,W.jsx)(`path`,{d:`M18 9h1.5a2.5 2.5 0 0 0 0-5H18`}),(0,W.jsx)(`path`,{d:`M4 22h16`}),(0,W.jsx)(`path`,{d:`M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22`}),(0,W.jsx)(`path`,{d:`M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22`}),(0,W.jsx)(`path`,{d:`M18 2H6v7a6 6 0 0 0 12 0V2Z`})]}),culture:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z`}),(0,W.jsx)(`path`,{d:`m6.2 5.3 3.1 3.9`}),(0,W.jsx)(`path`,{d:`m12.4 3.4 3.1 4`}),(0,W.jsx)(`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})]})},pd=`M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M15.97 6.37c.62-.75 1.04-1.8 0.93-2.85-.9.04-1.99.6-2.63 1.35-.57.65-1.07 1.71-.93 2.73.99.08 2.02-.48 2.63-1.23Z`;function md({id:e}){if(e===`apple`)return(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:pd})});let t=fd[e];return t?(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t}):null}async function hd(e){try{let t=(await U.listFolders()).folders.find(t=>t.name===e);return t?t.id:(await U.createFolder(e)).id}catch{return null}}function gd({onSubscribed:e}){let{t,i18n:n}=z(),{syncAllowed:r}=Bu(),i=bl(),a=fl(i),o=n.resolvedLanguage||`en`,[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(!1),d=(0,_.useMemo)(()=>ml(i,s,o).map(e=>({...e,feeds:l?cd(e,o):sd(e,o)})).filter(e=>e.feeds.length>0),[i,s,o,l]),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(new Set),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(!1),x=(0,_.useRef)(null),S=d.find(e=>e.id===f)??d[0]??null,C=d.reduce((e,t)=>e+t.feeds.filter(e=>m.has(e.url)).length,0),w=S!==null&&S.feeds.every(e=>m.has(e.url));(0,_.useEffect)(()=>{let e=!0;return U.feedLists(o).then(t=>{e&&c(t.lists)},()=>{e&&c([])}),()=>{e=!1}},[o]);function T(e){h(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})}function E(){S&&h(e=>{let t=new Set(e);for(let e of S.feeds)w?t.delete(e.url):t.add(e.url);return t})}async function D(){let n=[];for(let e of d)for(let t of e.feeds)m.has(t.url)&&n.push({url:t.url,label:t.title,folderName:e.title});if(n.length===0)return;v({done:0,total:n.length});let r=new Map;for(let e of new Set(n.map(e=>e.folderName)))r.set(e,await hd(e));let i=0,a=0,o=0,s=new Set,c=[...n];await Promise.all(Array.from({length:Math.min(3,n.length)},async()=>{for(let e=c.shift();e;e=c.shift()){try{await U.subscribeFeed(e.url,e.label||null,r.get(e.folderName)??null),i++,s.add(e.url)}catch(t){t instanceof va&&t.code===`already_subscribed`?(i++,s.add(e.url)):a++}v({done:++o,total:n.length})}})),v(null),h(e=>new Set([...e].filter(e=>!s.has(e)))),a>0?J.error(t(`welcome.packPartial`,{added:i,failed:a})):J.success(t(`welcome.packAdded`,{count:i})),i>0&&await e()}async function O(n){let r=n.target.files?.[0];if(r){b(!0);try{let n=await U.importOpml(await r.text());n.failed>0?J.error(t(`feeds.importPartial`,{imported:n.imported,skipped:n.skipped,failed:n.failed})):J.success(t(`feeds.importSuccess`,{imported:n.imported,skipped:n.skipped})),n.imported>0&&await e()}catch{J.error(t(`feeds.importFailed`))}finally{b(!1),x.current&&(x.current.value=``)}}}async function k(n){J.success(t(`feeds.subscribedToast`,{title:n.label||n.title||n.url})),await e()}let A=g!==null||y;return r?(0,W.jsxs)(`section`,{className:`card flex flex-col gap-6 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`welcome-title`,children:[(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{id:`welcome-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.title`)}),(0,W.jsx)(`p`,{className:`max-w-xl text-xs sm:text-sm text-[var(--c-text-muted)] mt-0.5 leading-relaxed`,children:t(`welcome.intro`)})]})}),a&&(0,W.jsx)(Iu,{name:`onboarding`,mount:a.mount}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[d.length>0&&(0,W.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`polygon`,{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`})]})}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.packsTitle`)})]}),(0,W.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.packsHint`)})]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t(`welcome.packsTitle`),children:d.map(e=>{let t=e.feeds.filter(e=>m.has(e.url)).length,n=S?.id===e.id;return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":n,disabled:A,onClick:()=>p(e.id),className:`inline-flex items-center gap-2 rounded-full border px-3.5 py-1.5 text-xs sm:text-sm font-semibold cursor-pointer transition-all ${n?`border-[var(--c-blue1)] bg-[var(--c-blue1)] text-white shadow-xs`:`border-[var(--c-border)] bg-[var(--c-surface)] hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)] text-[var(--c-text)]`}`,children:[(0,W.jsx)(md,{id:e.id}),(0,W.jsx)(`span`,{children:e.title}),t>0&&(0,W.jsx)(`span`,{className:`rounded-full px-1.5 text-[0.625rem] font-bold leading-4 ${n?`bg-white/25 text-white`:`bg-[var(--c-blue1)] text-white`}`,children:t})]},e.id)})}),S&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2 animate-fade-in border-t border-[var(--c-border)]/60`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[S.description&&(0,W.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)]`,children:S.description}),(0,W.jsx)(`button`,{type:`button`,disabled:A,onClick:E,className:`text-xs sm:text-sm font-semibold text-[var(--c-blue1)] cursor-pointer hover:underline`,children:t(w?`welcome.deselectAll`:`welcome.selectAll`)})]}),(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)]`,children:S.feeds.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-3.5 py-2.5 hover:bg-[var(--c-surface-hover)]/50 transition-colors`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:m.has(e.url),disabled:A,onChange:()=>T(e.url),className:`mt-0.5 rounded accent-[var(--c-blue1)]`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate text-xs sm:text-sm font-medium`,children:e.title}),e.description&&(0,W.jsx)(`span`,{className:`block text-xs text-[var(--c-text-muted)] leading-snug`,children:e.description})]}),e.lang&&(0,W.jsx)(`span`,{className:`shrink-0 text-[0.625rem] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-[var(--c-surface-hover)] text-[var(--c-text-muted)]`,children:e.lang})]})},e.url))})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:A||C===0,onClick:()=>void D(),className:`btn-primary self-start text-xs sm:text-sm font-semibold px-4 py-2`,children:g?t(`welcome.subscribingProgress`,{done:g.done,total:g.total}):t(`welcome.subscribePack`,{count:C})}),(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-xs sm:text-sm text-[var(--c-text-muted)] cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:l,disabled:A,onChange:e=>u(e.target.checked),className:`rounded accent-[var(--c-blue1)]`}),t(`welcome.allLanguages`)]})]})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col gap-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`}),(0,W.jsx)(`path`,{d:`M2 12h20`})]})}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.addTitle`)})]}),(0,W.jsx)(ld,{compact:!0,folderOptions:[],defaultFolderId:null,onClose:()=>{},onAdded:k})]}),(0,W.jsxs)(`div`,{className:`rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 sm:p-5 flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-[var(--c-blue1)]/10 text-[var(--c-blue1)] flex items-center justify-center shrink-0`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M21 8v13H3V8`}),(0,W.jsx)(`path`,{d:`M1 3h22v5H1z`}),(0,W.jsx)(`path`,{d:`M10 12h4`})]})}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:t(`welcome.importTitle`)})]}),(0,W.jsx)(`p`,{className:`text-xs sm:text-sm text-[var(--c-text-muted)] mt-1 ml-9.5`,children:t(`welcome.importHint`)})]}),(0,W.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>x.current?.click(),className:`btn-secondary inline-flex items-center gap-2 shrink-0 text-xs sm:text-sm font-semibold px-4 py-2`,children:[(0,W.jsx)(Z,{}),t(y?`feeds.importing`:`feeds.importOpml`)]}),(0,W.jsx)(`input`,{type:`file`,ref:x,onChange:O,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]})]}):(0,W.jsx)(dd,{})}function _d({folder:e,onRenamed:t}){let{t:n}=z(),[r,i]=(0,_.useState)(e.name);async function a(){let a=r.trim();if(!a||a===e.name)i(e.name);else try{await U.updateFolder(e.id,a),J.success(n(`feeds.folderRenamed`,{name:a})),await t()}catch{i(e.name),J.error(n(`common.error`))}}return(0,W.jsx)(`input`,{className:`input h-9 min-h-0 flex-1 border-transparent bg-transparent px-2 text-sm shadow-none hover:border-[var(--c-border)] focus:border-[var(--c-border)]`,value:r,onChange:e=>i(e.target.value),onBlur:()=>void a(),onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&i(e.name)}})}function vd({folders:e,onClose:t,onChanged:n}){let{t:r}=z(),{syncAllowed:i}=Bu(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(!1);async function l(e){if(e.preventDefault(),a.trim()){c(!0);try{await U.createFolder(a.trim()),J.success(r(`feeds.folderCreated`,{name:a.trim()})),o(``),await n()}catch{J.error(r(`common.error`))}finally{c(!1)}}}async function u(e){if(confirm(r(`feeds.deleteFolderConfirm`,{name:e.name})))try{await U.deleteFolder(e.id),J.success(r(`feeds.folderDeleted`,{name:e.name})),await n()}catch{J.error(r(`common.error`))}}return(0,W.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-4 p-4 sm:p-5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-base font-semibold`,children:r(`feeds.manageFolders`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--c-text-muted)]`,children:r(`feeds.renameFolderHint`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,"aria-label":r(`common.close`),children:(0,W.jsx)(ed,{})})]}),e.length>0&&(0,W.jsx)(`ul`,{className:`divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:e.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,W.jsx)(_d,{folder:e,onRenamed:n},e.name),(0,W.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-[var(--c-text-muted)]`,children:r(`feeds.feedCount`,{count:e.feed_count??0})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`rounded-lg p-2 text-[var(--c-text-muted)] hover:bg-[var(--c-danger-bg)] hover:text-[var(--c-danger)] cursor-pointer`,"aria-label":r(`common.delete`),title:r(`common.delete`),children:(0,W.jsx)(X,{})})]},e.id))}),(0,W.jsxs)(`form`,{onSubmit:l,className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,disabled:!i,placeholder:r(`feeds.newFolderPlaceholder`),className:`input flex-1`,value:a,onChange:e=>o(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,disabled:s||!i||!a.trim(),title:i?void 0:r(`plan.unavailable`),className:`btn-primary whitespace-nowrap`,children:r(`feeds.addFolder`)})]})]})}function yd(e,t,n){e.deferred?J.info(n(`feeds.refreshPendingToast`,{title:t})):e.error?J.error(n(`feeds.refreshFailedToast`,{title:t,error:Uu(n,e.error)})):J.success(n(`feeds.refreshedToast`,{title:t,count:e.newItems}))}function bd(e,t){e.deferred?J.info(t(`feeds.refreshAllPendingToast`,{count:e.deferred,newItems:e.newItems})):e.errors||J.success(t(`feeds.refreshedAllToast`,{count:e.refreshed,newItems:e.newItems})),e.errors>0&&J.error(t(`feeds.failingCount`,{count:e.errors}))}var xd=[5,15,30,60,180,360,720,1440],Sd=`none`;function Cd(e,t){return!t||[e.label,e.title,e.url,e.site_url].filter(Boolean).join(` `).toLowerCase().includes(t.toLowerCase())}function wd(){let{t:e}=z(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(new Set),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),[v,y]=Li(),[b]=(0,_.useState)(()=>[v.get(`url`),v.get(`text`),v.get(`add`)].filter(Boolean).join(` `).match(/https?:\/\/[^\s]+/i)?.[0]??``);(0,_.useEffect)(()=>{(v.has(`add`)||v.has(`url`)||v.has(`text`))&&(j&&c(`add`),y({},{replace:!0}))},[]);let[x,S]=(0,_.useState)(`all`),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(!1),[D,O]=(0,_.useState)(null),k=(0,_.useRef)(null);async function A(){try{let[e,t]=await Promise.all([U.listFeeds(),U.listFolders().catch(()=>({folders:[]}))]);n(e),i(t.folders)}catch(e){console.error(`Failed to load feeds:`,e)}finally{o(!1)}}(0,_.useEffect)(()=>{A()},[]),(0,_.useEffect)(()=>{if(D===null)return;document.getElementById(`feed-${D}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=window.setTimeout(()=>O(null),2500);return()=>window.clearTimeout(e)},[D,t]);let{syncAllowed:j}=Bu(),ee=e=>(e.label??e.title??e.url).replace(/\s+/g,` `).trim();async function te(t){J.success(e(`feeds.subscribedToast`,{title:ee(t)})),g(``),S(`all`),await A(),O(t.id)}let ne=(0,_.useMemo)(()=>[{value:``,label:e(`feeds.noFolder`)},...r.map(e=>({value:String(e.id),label:e.name}))],[r,e]),re=(0,_.useMemo)(()=>xd.map(t=>({value:String(t),label:rd(e,t)})),[e]),M=(0,_.useMemo)(()=>{let n=new Map;for(let e of t){let t=e.folder_id??null;n.set(t,[...n.get(t)??[],e])}let i=[...r].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>({key:`folder:${e.id}`,name:e.name,feeds:n.get(e.id)??[]}));return i.push({key:Sd,name:e(`feeds.uncategorized`),feeds:n.get(null)??[]}),i.filter(e=>e.feeds.length>0)},[t,r,e]),ie=(0,_.useMemo)(()=>M.filter(e=>x===`all`||x===`failing`||e.key===x).map(e=>({...e,feeds:e.feeds.filter(e=>Cd(e,h)&&(x!==`failing`||!!e.last_error))})).filter(e=>e.feeds.length>0),[M,x,h]),ae=t.reduce((e,t)=>e+t.unread_count,0),oe=t.filter(e=>e.last_error).length,se=!h&&x!==`failing`;(0,_.useEffect)(()=>{if(!C)return;let e=e=>e.preventDefault();return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[C!==null]);async function ce(){if(!C||C.from===C.over){w(null);return}let e=M.map(e=>{if(e.key!==C.group)return e.feeds;let t=[...e.feeds],[n]=t.splice(C.from,1);return t.splice(C.over,0,n),t}).flat();n(e),w(null);try{await U.reorderFeeds(e.map(e=>e.id))}catch(e){console.error(`Failed to save feed order:`,e),await A()}}async function N(t){f(e=>new Set(e).add(t));try{let r=await U.refreshFeed(t);r.feed?n(e=>e.map(e=>e.id===t?r.feed:e)):await A(),yd(r,r.feed?ee(r.feed):``,e)}catch{J.error(e(`common.error`))}finally{f(e=>{let n=new Set(e);return n.delete(t),n})}}async function le(){m(!0);try{let t=await U.refreshAllFeeds();await A(),bd(t,e)}catch{J.error(e(`common.error`))}finally{m(!1)}}async function ue(t){if(confirm(e(`feeds.unsubscribeConfirm`,{title:ee(t)})))try{await U.unsubscribeFeed(t.id),J.success(e(`feeds.unsubscribedToast`,{title:ee(t)})),await A()}catch{J.error(e(`common.error`))}}async function de(t){try{await U.markAllRead(t.id),J.success(e(`feeds.markedReadToast`,{title:ee(t)})),await A()}catch{J.error(e(`common.error`))}}function fe(){let e=document.createElement(`a`);e.href=U.exportOpmlUrl(),e.download=`feedkeeper-subscriptions.opml`,e.click()}async function pe(t){let n=t.target.files?.[0];if(n){E(!0);try{let t=await U.importOpml(await n.text());t.failed>0?J.error(e(`feeds.importPartial`,{imported:t.imported,skipped:t.skipped,failed:t.failed})):J.success(e(`feeds.importSuccess`,{imported:t.imported,skipped:t.skipped})),await A()}catch{J.error(e(`feeds.importFailed`))}finally{E(!1),k.current&&(k.current.value=``)}}}let me=[{key:`all`,label:e(`feeds.filterAll`),count:t.length},...M.map(e=>({key:e.key,label:e.name,count:e.feeds.length})),...oe>0?[{key:`failing`,label:e(`feeds.filterFailing`),count:oe,danger:!0}]:[]];return(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 pb-24`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`feeds.title`)}),!a&&t.length>0&&(0,W.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.length}),` · `,e(`feeds.unread`,{count:ae}),oe>0&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`button`,{type:`button`,onClick:()=>S(`failing`),className:`text-[var(--c-danger)] hover:underline cursor-pointer`,children:e(`feeds.failingCount`,{count:oe})})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(a||t.length>0)&&(0,W.jsxs)(`button`,{type:`button`,disabled:!j,title:j?void 0:e(`plan.unavailable`),onClick:()=>c(s===`add`?null:`add`),className:`btn-primary inline-flex items-center gap-1.5 whitespace-nowrap`,children:[(0,W.jsx)(Xu,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:e(`feeds.addFeed`)}),(0,W.jsx)(`span`,{className:`sm:hidden`,children:e(`feeds.addFeedShort`)})]}),(0,W.jsx)(zu,{label:e(`feeds.moreActions`),items:[{label:e(p?`feeds.refreshing`:`feeds.refreshAll`),icon:(0,W.jsx)(qu,{className:`h-4 w-4 ${p?`animate-spin`:``}`}),onSelect:le,disabled:p||!j},{label:e(`feeds.manageFolders`),icon:(0,W.jsx)(Zu,{}),onSelect:()=>c(`folders`)},{label:e(T?`feeds.importing`:`feeds.importOpml`),icon:(0,W.jsx)(Z,{}),onSelect:()=>k.current?.click(),disabled:T||!j},{label:e(`feeds.exportOpml`),icon:(0,W.jsx)(Q,{}),onSelect:fe}]}),(0,W.jsx)(`input`,{type:`file`,ref:k,onChange:pe,accept:`.opml,.xml,text/xml,application/xml`,className:`hidden`})]})]}),!j&&t.length>0&&(0,W.jsx)(dd,{}),s===`add`&&j&&(0,W.jsx)(ld,{folderOptions:ne,defaultFolderId:x.startsWith(`folder:`)?Number(x.slice(7)):null,initialUrl:b,subscribedUrls:t.map(e=>e.url),onClose:()=>c(null),onAdded:te}),s===`folders`&&(0,W.jsx)(vd,{folders:r,onClose:()=>c(null),onChanged:A}),a?(0,W.jsx)(Ru,{size:`lg`}):t.length===0?s!==`add`&&(0,W.jsx)(gd,{onSubscribed:A}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,W.jsx)(Qu,{})}),(0,W.jsx)(`input`,{type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:e(`feeds.searchPlaceholder`),"aria-label":e(`feeds.searchPlaceholder`),className:`input pl-9`})]}),(0,W.jsx)(`div`,{className:`-mx-4 flex gap-2 overflow-x-auto px-4 pb-1 sm:mx-0 sm:flex-wrap sm:overflow-visible sm:px-0`,role:`group`,"aria-label":e(`feeds.folder`),children:me.map(e=>{let t=x===e.key;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>S(e.key),"aria-pressed":t,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors cursor-pointer ${t?`border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)]`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)]`} ${e.danger&&!t?`text-[var(--c-danger)]`:``}`,children:[e.label,e.count!==void 0&&(0,W.jsx)(`span`,{className:`text-xs tabular-nums opacity-70`,children:e.count})]},e.key)})})]}),ie.length===0?(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`feeds.noMatches`)}):(0,W.jsx)(`div`,{className:`flex flex-col gap-6 animate-page-fade`,children:ie.map(t=>{let n=t.feeds.reduce((e,t)=>e+t.unread_count,0);return(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-3 px-1`,children:[(0,W.jsx)(`h2`,{className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t.name}),(0,W.jsxs)(`span`,{className:`shrink-0 text-xs text-[var(--c-text-muted)]`,children:[e(`feeds.feedCount`,{count:t.feeds.length}),n>0&&` · ${e(`feeds.unread`,{count:n})}`]})]}),(0,W.jsx)(`ul`,{className:`card divide-y divide-[var(--c-border)]`,children:t.feeds.map((e,n)=>(0,W.jsx)(od,{feed:e,editing:l===e.id,refreshing:d.has(e.id),highlighted:D===e.id,folderOptions:ne,intervalOptions:re,onEdit:t=>u(t?e.id:null),onRefresh:()=>void N(e.id),onMarkRead:()=>void de(e),onUnsubscribe:()=>void ue(e),onSaved:A,drag:se&&t.feeds.length>1?{isDragging:C?.group===t.key&&C.from===n,isDragOver:C?.group===t.key&&C.over===n&&C.from!==n,onDragStart:r=>{r.dataTransfer.effectAllowed=`move`,r.dataTransfer.setData(`application/x-feedkeeper-feed`,String(e.id)),w({group:t.key,from:n,over:n})},onDragOver:e=>{C?.group===t.key&&(e.preventDefault(),C.over!==n&&w({...C,over:n}))},onDragEnd:()=>void ce(),onDrop:e=>e.preventDefault()}:void 0},e.id))})]},t.key)})})]})]})}function Td(){let[e,t]=(0,_.useState)(()=>new Date);return(0,_.useEffect)(()=>{let n=new Date(e);n.setHours(24,0,1,0);let r=window.setTimeout(()=>t(new Date),n.getTime()-Date.now());return()=>window.clearTimeout(r)},[e]),e}function Ed({className:e=``}){let{i18n:t}=z(),n=Td(),r=e=>new Intl.DateTimeFormat(t.resolvedLanguage,{weekday:`long`,day:`numeric`,month:`long`,...e?{year:`numeric`}:{}}).format(n);return(0,W.jsxs)(`time`,{dateTime:n.toLocaleDateString(`sv-SE`),className:`truncate text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)] ${e}`,children:[(0,W.jsx)(`span`,{className:`sm:hidden`,children:r(!1)}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:r(!0)})]})}var Dd=650;function Od(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, noscript, template, svg, [hidden], [aria-hidden='true']`).forEach(e=>e.remove()),t.content.querySelectorAll(`p, div, li, br, blockquote, section, article, h1, h2, h3, h4, h5, h6`).forEach(e=>e.after(` `)),t.content.textContent?.replace(/\s+/g,` `).trim()??``}function kd(e){let t=e.full_content_html?.trim()?Od(e.full_content_html):``,n=!t&&e.content_html?.trim()?Od(e.content_html):``,r=e.content_snippet?.replace(/\s+/g,` `).trim()??``,i=t||(n.length>=r.length?n:r);return i?i.length<=Dd?i:Ao(i)===`ja`?jo(i,Dd):`${i.slice(0,Dd).trimEnd()}…`:null}function Ad({item:e,className:t}){let n=(0,_.useMemo)(()=>kd(e),[e]);if(!n)return null;let r=Ao(n);return(0,W.jsx)(`p`,{className:r===`ja`?`${t} ja-phrases`:t,lang:r,children:(0,W.jsx)(Jc,{text:n})})}function jd(e){let t=0,n=-5;return e.map((e,r)=>{let i=/^https?:\/\//i.test(e.image_url??``),a=(e.content_snippet?.trim().length??0)>=220,o=(i||a)&&r-n>=5&&t<=1;return t=(t+(o?2:1))%3,o&&(n=r),o})}function Md(e){let t=e.map(()=>!1),n=[],r=0;return e.forEach((i,a)=>{n.push(a),r+=i?2:1,r===3&&(n.some(t=>e[t])&&n.forEach(n=>{t[n]=!e[n]}),n=[],r=0)}),t}function Nd({url:e,featured:t}){let[n,r]=(0,_.useState)(`loading`);return!e||!/^https?:\/\//i.test(e)?null:(0,W.jsx)(`div`,{className:n===`hidden`?`hidden`:`overflow-hidden border-b border-[var(--c-border)] bg-[var(--c-bg)]`,children:(0,W.jsx)(`img`,{src:e,alt:``,loading:`lazy`,className:`w-full object-cover transition-transform duration-300 group-hover:scale-[1.025] ${t?`aspect-[3/2] lg:aspect-[16/9]`:`aspect-[3/2]`} ${n===`visible`?`opacity-100`:`opacity-0`}`,onLoad:e=>{let{naturalWidth:n,naturalHeight:i}=e.currentTarget;r(n>=(t?400:160)&&i>=(t?220:100)?`visible`:`hidden`)},onError:()=>r(`hidden`)})})}function Pd({item:e,featured:t,besideFeature:n,focused:r,onOpen:i,onBookmark:a,onRead:o}){let{t:s,i18n:c}=z(),l=e.published_at?new Date(e.published_at):null,u=l&&!Number.isNaN(l.getTime())?l:null,d=u?new Intl.DateTimeFormat(c.resolvedLanguage,{dateStyle:`medium`}).format(u):null,f=u?new Intl.DateTimeFormat(c.resolvedLanguage,{timeStyle:`short`}).format(u):null;return(0,W.jsx)(`li`,{"data-item-id":e.id,className:t?`lg:col-span-2`:``,children:(0,W.jsxs)(`article`,{className:`card group relative flex h-full flex-col overflow-hidden transition-colors duration-150 hover:border-[var(--c-blue3)] hover:bg-[var(--c-surface-hover)] ${r?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)] bg-[var(--c-surface-hover)]`:``}`,style:{opacity:e.read?.65:1},children:[(0,W.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 rounded-xl focus-visible:outline-2 focus-visible:outline-offset-[-3px] focus-visible:outline-[var(--c-blue3)]`,"aria-label":e.title||e.feed_title||s(`items.title`),onClick:()=>i(e)}),(0,W.jsx)(Nd,{url:e.image_url,featured:t},e.image_url??``),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col ${t?`p-4 sm:p-5 lg:p-6`:`p-4 sm:p-5`}`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,W.jsx)(qc,{feedId:e.feed_id,iconUrl:e.feed_icon_url,siteUrl:e.feed_site_url,feedUrl:e.feed_url,articleUrl:e.link,className:`h-3.5 w-3.5 shrink-0 rounded-xs object-contain`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.feed_title}),(e.enclosure_url||Xc(e.link))&&(0,W.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 rounded-full border border-[var(--c-border)] px-2 py-0.5 text-[11px] font-medium tracking-normal normal-case text-[var(--c-text-muted)] shrink-0`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:e.enclosure_type?.startsWith(`video/`)||!e.enclosure_url&&Xc(e.link)?`▶`:`🎧`}),e.enclosure_duration_seconds?Yc(e.enclosure_duration_seconds):e.enclosure_type?.startsWith(`video/`)||!e.enclosure_url&&Xc(e.link)?`Video`:`Audio`]})]}),(0,W.jsx)(`h2`,{lang:Ao(e.title||e.feed_title),className:`text-[var(--c-text)] ${t?`text-lg leading-snug lg:text-2xl lg:leading-tight`:`text-lg leading-snug`} font-semibold${Ao(e.title||e.feed_title)===`ja`?` ja-phrases`:``}`,children:e.title||e.feed_title?(0,W.jsx)(Jc,{text:e.title||e.feed_title}):null}),(0,W.jsx)(Ad,{item:e,className:`mt-3 text-sm leading-relaxed text-[var(--c-text-muted)] ${t?`line-clamp-3 lg:line-clamp-4`:n?`line-clamp-3 lg:line-clamp-12`:`line-clamp-3`}`}),(0,W.jsxs)(`div`,{className:`pointer-events-none relative z-20 mt-auto flex flex-wrap items-center gap-x-3 gap-y-2 pt-5 text-xs text-[var(--c-text-muted)]`,children:[d&&(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:f??void 0,children:[(0,W.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`}),(0,W.jsx)(`path`,{d:`M8 2v4M16 2v4M3 10h18`})]}),d]}),f&&(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`h-3.5 w-3.5 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`path`,{d:`M12 6v6l4 2`})]}),f]}),(0,W.jsxs)(`div`,{className:`pointer-events-auto ml-auto flex items-center gap-1.5`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(e),title:e.bookmarked?s(`items.unbookmark`):s(`items.bookmark`),"aria-label":e.bookmarked?s(`items.unbookmark`):s(`items.bookmark`),className:`grid h-8 w-8 place-items-center rounded-lg border transition-colors ${e.bookmarked?`border-amber-500/40 bg-amber-500/15 text-amber-500`:`border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500`}`,children:(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>o(e),title:e.read?s(`items.markUnread`):s(`items.markRead`),"aria-label":e.read?s(`items.markUnread`):s(`items.markRead`),className:`grid h-8 w-8 place-items-center rounded-lg border border-[var(--c-border)] transition-colors ${e.read?`text-[var(--c-text-muted)]`:`text-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:e.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,"aria-hidden":`true`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]})]})})}function Fd({items:e,focusedItemId:t,onOpen:n,onBookmark:r,onRead:i}){let a=(0,_.useMemo)(()=>jd(e),[e]),o=(0,_.useMemo)(()=>Md(a),[a]);return(0,W.jsx)(`ul`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 sm:gap-5 animate-page-fade`,children:e.map((e,s)=>(0,W.jsx)(Pd,{item:e,featured:a[s],besideFeature:o[s],focused:t===e.id,onOpen:n,onBookmark:r,onRead:i},e.id))})}var Id={"&":`&`,"<":`<`,">":`>`,""":`"`,"'":`'`};function Ld(e){return e.replace(/<[^>]*>/g,` `).replace(/&(amp|lt|gt|quot|#39);/g,e=>Id[e]??e).replace(/\s+/g,` `).trim()}function Rd({feed:e}){let{t}=z(),[n,r]=(0,_.useState)(!1),i=e.label?.trim()||e.title?.trim()||e.url,a=e.artwork_url||`/api/feeds/${e.id}/icon`,o=e.description?Ld(e.description):``;return(0,W.jsxs)(`div`,{className:`mb-6 flex items-start gap-4 rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)] p-4 sm:p-5`,children:[(0,W.jsx)(`img`,{src:a,alt:``,className:`h-20 w-20 sm:h-24 sm:w-24 rounded-xl object-cover shrink-0 border border-[var(--c-border)] bg-[var(--c-bg)]`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{className:`text-lg sm:text-xl font-bold text-[var(--c-text)] leading-snug`,children:i}),o&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`mt-1.5 text-sm text-[var(--c-text-muted)] ${n?``:`line-clamp-2`}`,children:o}),o.length>140&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`mt-1 text-xs font-medium text-[var(--c-blue3)] hover:underline cursor-pointer`,children:t(n?`common.showLess`:`common.showMore`)})]})]})]})}function zd(e,t,n){let r=n&&n>0?n:e.enclosure_duration_seconds??0;if(r<=0)return 0;let i=t===void 0?e.media_position&&!e.media_position.completed?e.media_position.positionSeconds:0:t;return Math.min(1,Math.max(0,i/r))}function Bd({feed:e,items:t,focusedItemId:n,onOpen:r,onBookmark:i,onRead:a}){let{t:o,i18n:s}=z(),c=mo();return(0,W.jsx)(`ul`,{className:`flex flex-col gap-3 animate-page-fade`,children:t.map(t=>{let l=c.currentItem?.id===t.id,u=l&&c.isPlaying,d=l&&c.duration>0?c.duration:t.enclosure_duration_seconds??0,f=l?c.currentTime:t.media_position&&!t.media_position.completed?t.media_position.positionSeconds:0,p=zd(t,l?c.currentTime:void 0,l?c.duration:void 0),m=t.published_at?new Date(t.published_at):null,h=n===t.id;return(0,W.jsxs)(`li`,{"data-item-id":t.id,onClick:()=>r(t),className:`card flex items-center gap-3.5 p-3.5 sm:p-4 transition-colors hover:bg-[var(--c-surface-hover)] hover:border-[var(--c-blue3)]/60 cursor-pointer ${h?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)] bg-[var(--c-surface-hover)]`:``}`,style:{opacity:t.read?.65:1},children:[t.enclosure_url&&(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c.togglePlay(t)},"aria-label":o(u?`player.pause`:`player.play`),className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--c-blue3)] text-white hover:opacity-90 cursor-pointer`,children:u?(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,W.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`}),(0,W.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`})]}):(0,W.jsx)(`svg`,{className:`w-4 h-4 translate-x-0.5`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),(t.image_url||e?.artwork_url||t.feed_id)&&(0,W.jsx)(`img`,{src:t.image_url||e?.artwork_url||`/api/feeds/${t.feed_id}/icon`,alt:``,className:`h-12 w-12 rounded-lg object-cover shrink-0 border border-[var(--c-border)] bg-[var(--c-bg)]`,loading:`lazy`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--c-text-muted)] mb-0.5`,children:[m&&(0,W.jsx)(`span`,{children:Gu(m,s.resolvedLanguage)}),d>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`·`}),(0,W.jsx)(`span`,{className:`font-mono`,children:f>5&&d>f?o(`player.timeRemaining`,{time:Yc(d-f)}):Yc(d)})]})]}),(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-semibold text-[var(--c-text)] line-clamp-2`,children:t.title}),p>0&&(0,W.jsx)(`div`,{className:`mt-2 h-1 w-full max-w-xs rounded-full bg-[var(--c-border)] overflow-hidden`,children:(0,W.jsx)(`div`,{className:`h-full bg-[var(--c-blue3)]`,style:{width:`${p*100}%`}})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(t),"aria-label":o(`items.bookmark`),className:`p-1.5 rounded-lg hover:bg-[var(--c-surface-hover)] cursor-pointer ${t.bookmarked?`text-amber-500`:`text-[var(--c-text-muted)]`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":t.read?o(`items.markUnread`):o(`items.markRead`),className:`p-1.5 rounded-lg text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`6`})})})]})]},t.id)})})}function Vd({items:e,focusedItemId:t,onOpen:n,onBookmark:r}){let{t:i,i18n:a}=z();return(0,W.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-5 animate-page-fade`,children:e.map(e=>{let o=e.published_at?new Date(e.published_at):null,s=e.enclosure_duration_seconds??0,c=zd(e),l=t===e.id;return(0,W.jsxs)(`article`,{"data-item-id":e.id,onClick:()=>n(e),className:`card overflow-hidden flex flex-col cursor-pointer transition-colors hover:border-[var(--c-blue3)]/60 ${l?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)]`:``}`,style:{opacity:e.read?.65:1},children:[(0,W.jsxs)(`div`,{className:`relative aspect-video w-full bg-black overflow-hidden`,children:[e.image_url?(0,W.jsx)(`img`,{src:e.image_url,alt:``,className:`w-full h-full object-cover`,loading:`lazy`}):(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white/60`,children:(0,W.jsx)(`svg`,{className:`w-10 h-10`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}),s>0&&(0,W.jsx)(`span`,{className:`absolute bottom-2 right-2 rounded-md bg-black/80 px-1.5 py-0.5 font-mono text-[11px] font-semibold text-white`,children:Yc(s)}),c>0&&(0,W.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-1 bg-white/25`,children:(0,W.jsx)(`div`,{className:`h-full bg-[var(--c-blue3)]`,style:{width:`${c*100}%`}})})]}),(0,W.jsxs)(`div`,{className:`p-3.5 flex-1 flex flex-col justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-[var(--c-text)] line-clamp-2 leading-snug min-h-[2.45rem]`,children:e.title}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`span`,{children:o?Gu(o,a.resolvedLanguage):``}),(0,W.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},"aria-label":i(`items.bookmark`),className:`p-1 rounded hover:bg-[var(--c-surface-hover)] cursor-pointer ${e.bookmarked?`text-amber-500`:``}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:e.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})})]})]})]},e.id)})})}var Hd=68,Ud=92,Wd=`input, select, textarea, [contenteditable='true'], [data-no-pull]`;function Gd(){let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Kd({children:e,disabled:t=!1,onRefresh:n}){let{t:r}=z(),i=(0,_.useRef)(null),a=(0,_.useRef)(0),[o,s]=(0,_.useState)(0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),m=(0,_.useCallback)(()=>{u||(p(!1),d(!0),s(56),n().catch(()=>p(!0)).finally(()=>{d(!1),s(0)}))},[u,n]);(0,_.useEffect)(()=>{let e=i.current;if(!e)return;let n=null;function r(){n=null,a.current=0,l(!1),s(0)}function o(e){t||u||e.touches.length!==1||window.scrollY>1||!window.matchMedia(`(any-pointer: coarse)`).matches||document.body.style.overflow===`hidden`||e.target.closest(Wd)||(n={x:e.touches[0].clientX,y:e.touches[0].clientY})}function c(e){if(!n||e.touches.length!==1)return;let t=e.touches[0].clientX-n.x,i=e.touches[0].clientY-n.y;if(window.scrollY>1||Math.abs(t)>Math.abs(i)){r();return}if(i<=0){a.current=0,s(0);return}e.preventDefault();let o=Math.min(Ud,i*.72);a.current=o,l(!0),s(o)}function d(){if(!n)return;let e=a.current>=Hd;a.current>8&&Gd(),r(),e&&m()}return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,c,{passive:!1}),e.addEventListener(`touchend`,d),e.addEventListener(`touchcancel`,r),()=>{e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,c),e.removeEventListener(`touchend`,d),e.removeEventListener(`touchcancel`,r)}},[t,u,n,m]);let h=u?1:Math.min(1,o/Hd);return(0,W.jsxs)(`div`,{ref:i,children:[(0,W.jsx)(`button`,{type:`button`,className:`sr-only focus:not-sr-only sm:hidden`,onClick:m,disabled:t||u,children:r(`items.refresh`)}),(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`relative flex items-center justify-center overflow-hidden`,style:{height:o,transition:c?`none`:`height 220ms ease-out`},children:(0,W.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)] shadow-sm`,style:{opacity:Math.min(1,o/30),transform:`scale(${.65+h*.35})`},children:(0,W.jsxs)(`svg`,{className:`h-5 w-5 ${u?`animate-spin motion-reduce:animate-none`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:u?void 0:{transform:`rotate(${h*270}deg)`},children:[(0,W.jsx)(`path`,{d:`M18 7a8 8 0 1 0 2 5`,pathLength:`100`,strokeDasharray:`${h*100} 100`}),(0,W.jsx)(`path`,{d:`M18 3v4h-4`,opacity:h})]})})}),u&&(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:r(`items.refreshing`)}),f&&(0,W.jsx)(`p`,{className:`mb-3 text-center text-sm text-[var(--c-danger)]`,role:`alert`,children:r(`items.refreshFailed`)}),e]})}function qd(){let{user:e}=lo(),t=hl(bl()),[n,r]=(0,_.useState)(!1),i=!!e?.intro_dismissed_at;return(0,_.useEffect)(()=>{let n=!0;if(r(!1),t&&e&&i)return Promise.resolve(!t.applies||t.applies({id:e.id,email:e.email,display_name:e.display_name??null})).then(e=>{n&&r(e===!0)}).catch(()=>{n&&r(!1)}),()=>{n=!1}},[t?.mount,t?.applies,e?.id,i]),!t||!n?null:(0,W.jsx)(Iu,{name:`articles-notice`,mount:t.mount})}function Jd(){let{t:e}=z(),{user:t,setCurrentUser:n}=lo(),[r,i]=(0,_.useState)(!1);if(!t||t.intro_dismissed_at)return null;async function a(){i(!0);try{n(await U.dismissIntro())}catch{i(!1)}}let o=[{key:`views`,className:`hidden sm:flex`,icon:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,W.jsx)(`path`,{d:`M18 14h-8`}),(0,W.jsx)(`path`,{d:`M15 18h-5`}),(0,W.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]})},{key:`unread`,solid:!0,icon:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})},{key:`star`,icon:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})},{key:`folders`,icon:(0,W.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z`})}];return(0,W.jsxs)(`section`,{className:`card animate-fade-in flex flex-col gap-5 p-5 sm:p-7 shadow-xs`,"aria-labelledby":`intro-title`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h2`,{id:`intro-title`,className:`text-xl sm:text-2xl font-bold tracking-tight text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.title`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.subtitle`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:a,disabled:r,"aria-label":e(`common.close`),className:`shrink-0 rounded-lg p-1 text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)] cursor-pointer`,children:(0,W.jsx)(ed,{})})]}),(0,W.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:o.map(t=>(0,W.jsxs)(`li`,{className:`flex items-start gap-3.5 rounded-2xl border border-[var(--c-border)]/80 bg-[var(--c-surface-hover)]/25 p-4 ${t.className??``}`,children:[(0,W.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)]`,children:(0,W.jsx)(`svg`,{className:t.solid?`h-3.5 w-3.5`:`h-4 w-4`,viewBox:`0 0 24 24`,fill:t.solid?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:t.solid?2.2:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t.icon})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-[var(--c-text)]`,style:{fontFamily:`Manrope, sans-serif`},children:e(`intro.${t.key}Title`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs sm:text-sm leading-relaxed text-[var(--c-text-muted)]`,children:e(`intro.${t.key}Text`)})]})]},t.key))}),(0,W.jsx)(`button`,{type:`button`,onClick:a,disabled:r,className:`btn-primary self-start`,children:e(`intro.done`)})]})}var Yd=50;function Xd(){return(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,W.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]})}var Zd=`(max-width: 639px)`;function Qd(){return(0,_.useSyncExternalStore)(e=>{let t=window.matchMedia(Zd);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(Zd).matches)}function $d(){let{t:e,i18n:t}=z(),[n,r]=Li(),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),{syncAllowed:u}=Bu(),[d,f]=(0,_.useState)([]),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(!0),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),E=(0,_.useRef)(0),D=(0,_.useRef)(0),O=(0,_.useRef)(!1),[k,A]=(0,_.useState)(null),[j,ee]=(0,_.useState)(()=>{try{return localStorage.getItem(`feedkeeper_items_view`)===`newspaper`?`newspaper`:`list`}catch{return`list`}}),te=Qd()?`newspaper`:j;function ne(e){if(e!==j){Ka(),ee(e),window.scrollTo({top:0,behavior:`instant`});try{localStorage.setItem(`feedkeeper_items_view`,e)}catch{}}}let re=`feedkeeper_filter_scope`,M=`feedkeeper_filter_unread`,ie=`feedkeeper_filter_bookmarked`,ae=n.get(`article`),oe=(()=>{let e=n.get(`feed`);if(e)return`feed:${e}`;let t=n.get(`folder`);if(t)return`folder:${t}`;try{let e=localStorage.getItem(re);if(e)return e}catch{}return``})(),se=(()=>{try{let e=localStorage.getItem(M);if(e!==null)return e===`true`}catch{}return!0})(),ce=(()=>{if(n.get(`saved`)===`1`)return!0;if(n.get(`article`))return!1;try{let e=localStorage.getItem(ie);if(e!==null)return e===`true`}catch{}return!1})(),[N,le]=(0,_.useState)(oe),[ue,de]=(0,_.useState)(se),[fe,pe]=(0,_.useState)(ce),me=ue&&!fe,[he,ge]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),_e=(0,_.useRef)(null),I=(0,_.useRef)(null),ve=(0,_.useRef)(null),[ye,be]=(0,_.useState)(61),[L,xe]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=document.querySelector(`[data-app-header]`);if(!e)return;let t=new ResizeObserver(()=>be(e.getBoundingClientRect().height));return t.observe(e),()=>t.disconnect()},[]),(0,_.useEffect)(()=>{function e(){let e=ve.current?.getBoundingClientRect().top;xe(window.scrollY>0&&e!==void 0&&e<=ye+1)}return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[ye]),(0,_.useEffect)(()=>{P&&_e.current?.focus()},[P]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 640px)`),t=()=>{e.matches&&F(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);function Se(){F(!1),requestAnimationFrame(()=>I.current?.focus())}function Ce(e){Ka(),ge(e)}function we(){Ka(),de(e=>{let t=!e;try{localStorage.setItem(M,String(t))}catch{}return t})}function Te(){Ka(),pe(e=>{let t=!e;try{localStorage.setItem(ie,String(t))}catch{}return t})}(0,_.useEffect)(()=>{if(h||O.current)return;let e=Wa(),t=requestAnimationFrame(()=>{e>0&&window.scrollTo({top:e,behavior:`instant`}),O.current=!0});return()=>cancelAnimationFrame(t)},[h]),(0,_.useEffect)(()=>{function e(){O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY)}return window.addEventListener(`scroll`,e,{passive:!0}),()=>{O.current&&document.body.style.overflow!==`hidden`&&Ga(window.scrollY),window.removeEventListener(`scroll`,e)}},[]),(0,_.useEffect)(()=>{let e=n.get(`feed`),t=n.get(`folder`);if(e){let t=`feed:${e}`;t!==N&&Ka(),le(t);try{localStorage.setItem(re,t)}catch{}}else if(t){let e=`folder:${t}`;e!==N&&Ka(),le(e);try{localStorage.setItem(re,e)}catch{}}else if(oe&&!n.toString()){let e=new URLSearchParams(n);oe.startsWith(`feed:`)?e.set(`feed`,oe.slice(5)):oe.startsWith(`folder:`)&&e.set(`folder`,oe.slice(7)),r(e,{replace:!0})}},[n]);function Ee(e){Ka(),le(e);try{e?localStorage.setItem(re,e):localStorage.removeItem(re)}catch{}let t=new URLSearchParams(n);t.delete(`feed`),t.delete(`folder`),e.startsWith(`feed:`)?t.set(`feed`,e.slice(5)):e.startsWith(`folder:`)&&t.set(`folder`,e.slice(7)),r(t,{replace:!0})}(0,_.useEffect)(()=>{Promise.all([U.listFeeds(),U.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]).then(([e,t])=>{a(e),f(t.folders),l(t.ok),s(!0)}).catch(e=>console.error(`Failed to load initial feeds/folders:`,e))},[]),(0,_.useEffect)(()=>{o&&N&&(N.startsWith(`feed:`)?!i.some(e=>`feed:${e.id}`===N):N.startsWith(`folder:`)&&c&&!d.some(e=>`folder:${e.id}`===N))&&Ee(``)},[o,c,i,d,N]);let De=N.startsWith(`feed:`)?Number(N.slice(5)):void 0,Oe=De===void 0?void 0:i.find(e=>e.id===De),ke=Oe?Oe.kind_override??Oe.detected_kind??`article`:`article`,Ae=N.startsWith(`folder:`)?Number(N.slice(7)):void 0,je=!he&&!fe&&De===void 0&&Ae===void 0,Me=je&&i.length>0&&i.every(e=>!e.last_polled_at);async function Ne(){try{let[e,t]=await Promise.all([U.listFeeds(),U.listFolders().then(e=>({...e,ok:!0})).catch(()=>({folders:[],ok:!1}))]);return e.length===0&&(n.has(`folder`)||n.has(`feed`))&&(r({},{replace:!0}),le(``)),a(e),f(t.folders),l(t.ok),s(!0),e}catch(e){return console.error(`Failed to reload feeds:`,e),null}}async function Pe(){await Ne(),await Fe(),no()}async function Fe(){let e=++E.current;g(!0),y(!1),C(!1),x(!1);try{let t=await U.listItems({feedId:De,folderId:Ae,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Yd});e===E.current&&(m(t),D.current=t.length,T(t.length===Yd))}catch(t){e===E.current&&(console.error(`Failed to load items:`,t),y(!0))}finally{e===E.current&&g(!1)}}async function Ie(){if(b||!w)return;let e=E.current,t=me||fe?p.filter(e=>(!me||!e.read)&&(!fe||e.bookmarked)).length:D.current;x(!0),C(!1);try{let n=await U.listItems({feedId:De,folderId:Ae,unreadOnly:me,bookmarkedOnly:fe,search:he||void 0,limit:Yd,offset:t});e===E.current&&(D.current=t+n.length,m(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.filter(e=>!t.has(e.id))]}),T(n.length===Yd))}catch(t){e===E.current&&(console.error(`Failed to load more items:`,t),C(!0))}finally{e===E.current&&x(!1)}}let Le=(0,_.useRef)(Ie);Le.current=Ie;let Re=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=Re.current;if(!e||!w||S||b||v)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Le.current()},{rootMargin:`600px 0px`});return t.observe(e),()=>t.disconnect()},[w,S,b,v,p.length]),(0,_.useEffect)(()=>{m([]),g(!0),T(!1),x(!1);let e=setTimeout(()=>{Fe()},200);return()=>{clearTimeout(e),E.current++}},[N,ue,fe,he]),(0,_.useEffect)(()=>{if(!Me)return;let e=0,t=setInterval(()=>{e++,Ne().then(e=>{e?.some(e=>e.last_polled_at)&&Fe()}),e>=45&&clearInterval(t)},4e3);return()=>clearInterval(t)},[Me]);let ze=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(ae){let e=p.find(e=>e.id===Number(ae));A(e??null),e&&!e.read&&ze.current!==e.id&&(ze.current=e.id,U.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)))}else A(null)},[ae,p]);function Be(e){$e(e.id),A(e),e.read||(U.markRead(e.id).then(no).catch(()=>{}),m(t=>t.map(t=>t.id===e.id?{...t,read:!0}:t)),A({...e,read:!0}));let t=new URLSearchParams(n);t.set(`article`,String(e.id)),r(t)}function Ve(){A(null);let e=new URLSearchParams(n);e.delete(`article`),r(e)}let He=k?p.findIndex(e=>e.id===k.id):-1,Ue=He>=0&&He<p.length-1,We=He>0;function Ge(){Ue&&Be(p[He+1])}function Ke(){We&&Be(p[He-1])}async function qe(t){try{await t()}catch(t){if(!(t instanceof va&&t.status===0))throw t;J.error(e(`common.offlineAction`))}}async function Je(e){let t=!e.read;e.read?await U.markUnread(e.id):await U.markRead(e.id),no(),m(n=>n.map(n=>n.id===e.id?{...n,read:t}:n)),k?.id===e.id&&A(e=>e?{...e,read:t}:null)}async function Ye(e){let t=!e.bookmarked;e.bookmarked?await U.unbookmarkItem(e.id):await U.bookmarkItem(e.id),window.setTimeout(()=>void Ba({force:!0}),t?2e4:0),m(n=>fe&&!t&&k?.id!==e.id?n.filter(t=>t.id!==e.id):n.map(n=>n.id===e.id?{...n,bookmarked:t}:n)),k?.id===e.id&&A(e=>e?{...e,bookmarked:t}:null)}async function Xe(){await qe(async()=>{await U.markAllRead({feedId:De,folderId:Ae}),await Fe(),no()})}let[R,Ze]=(0,_.useState)(!1),[Qe,$e]=(0,_.useState)(null),et=(0,_.useRef)(null);async function tt(){Ze(!0);try{let t=await U.refreshAllFeeds();await Fe(),bd(t,e)}catch{J.error(e(`items.refreshFailed`))}finally{Ze(!1)}}(0,_.useEffect)(()=>{k||Qe==null||document.querySelector(`[data-item-id="${Qe}"]`)?.scrollIntoView?.({block:`nearest`,behavior:`smooth`})},[Qe,k]),(0,_.useEffect)(()=>{if(k)return;function e(e){if(document.querySelector(`[role="dialog"], [data-shortcuts-modal]`)||Vc(e.target)||Vc(document.activeElement)||Hc(e))return;if(e.key===`/`){e.preventDefault(),et.current&&et.current.offsetParent!==null?(et.current.focus(),et.current.select()):F(!0);return}if((e.key===`r`||e.key===`R`)&&!R&&u){e.preventDefault(),tt();return}if(e.key===`A`&&e.shiftKey){e.preventDefault(),Xe();return}if(p.length===0)return;let t=Qe==null?-1:p.findIndex(e=>e.id===Qe),n=t>=0?p[t]:null;if(e.key===`j`||e.key===`J`||e.key===`ArrowDown`){e.preventDefault();let n=t<0?0:Math.min(t+1,p.length-1);$e(p[n].id)}else if(e.key===`k`||e.key===`K`||e.key===`ArrowUp`){e.preventDefault();let n=t<=0?0:t-1;$e(p[n].id)}else(e.key===`Enter`||e.key===`o`||e.key===`O`)&&n?(e.preventDefault(),Be(n)):(e.key===`m`||e.key===`M`)&&n?(e.preventDefault(),Je(n)):(e.key===`s`||e.key===`S`)&&n?(e.preventDefault(),Ye(n)):(e.key===`v`||e.key===`V`)&&n&&(e.preventDefault(),Uc(n.link))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let nt=new Intl.DateTimeFormat(t.resolvedLanguage,{dateStyle:`medium`}),rt=new Intl.DateTimeFormat(t.resolvedLanguage,{timeStyle:`short`}),it=(0,_.useMemo)(()=>{let t=[{value:``,label:e(`items.allFeeds`)}];if(d.length>0)for(let n of d)t.push({value:`folder:${n.id}`,label:n.name,group:e(`feeds.folderGroup`),badge:n.unread_count});for(let n of i)t.push({value:`feed:${n.id}`,label:n.label??n.title??n.url,group:e(`feeds.feedGroup`),badge:n.unread_count});return t},[d,i,e]),at=N?it.find(e=>e.value===N)?.label??e(`items.title`):e(`items.allFeeds`);function ot(e){m(t=>t.map(t=>t.id===e.id?{...t,...e}:t)),A(t=>t?.id===e.id?{...t,...e}:t)}let st=(0,W.jsxs)(`div`,{className:`flex flex-col gap-5 sm:gap-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 sm:gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`sr-only`,children:at}),(0,W.jsx)(Ed,{className:`block`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0`,children:[(!Oe||!!he||ke!==`audio`&&ke!==`video`)&&(0,W.jsxs)(`div`,{className:`relative hidden h-11 w-[220px] shrink-0 grid-cols-2 rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] p-1 sm:grid`,role:`group`,"aria-label":e(`items.viewMode`),children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-1 left-1 w-[calc((100%-0.5rem)/2)] rounded-lg border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] shadow-sm transition-transform duration-300 ease-[cubic-bezier(0.25,1,0.5,1)] motion-reduce:transition-none`,style:{transform:j===`newspaper`?`translateX(100%)`:`translateX(0)`}}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ne(`list`),title:e(`items.listView`),"aria-label":e(`items.listView`),"aria-pressed":j===`list`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`list`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`list`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M8 6h12M8 12h12M8 18h12`}),(0,W.jsx)(`circle`,{cx:`4`,cy:`6`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,W.jsx)(`circle`,{cx:`4`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,W.jsx)(`circle`,{cx:`4`,cy:`18`,r:`1`,fill:`currentColor`,stroke:`none`})]}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.listView`)})]}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ne(`newspaper`),title:e(`items.newspaperView`),"aria-label":e(`items.newspaperView`),"aria-pressed":j===`newspaper`,className:`relative z-10 flex h-full min-w-0 items-center justify-center gap-1.5 rounded-lg text-xs sm:text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${j===`newspaper`?`text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:[(0,W.jsxs)(`svg`,{className:`h-4 w-4 transition-transform duration-200 motion-reduce:transition-none ${j===`newspaper`?`scale-105`:``}`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2`}),(0,W.jsx)(`path`,{d:`M18 14h-8`}),(0,W.jsx)(`path`,{d:`M15 18h-5`}),(0,W.jsx)(`path`,{d:`M10 6h8v4h-8V6Z`})]}),(0,W.jsx)(`span`,{className:`hidden sm:inline`,children:e(`items.newspaperView`)})]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:tt,disabled:R||!u,title:e(u?R?`items.refreshing`:`items.refresh`:`plan.unavailable`),"aria-label":e(R?`items.refreshing`:`items.refresh`),className:`btn-secondary hidden h-11 w-11 shrink-0 items-center justify-center p-0! sm:flex`,children:(0,W.jsx)(qu,{className:`h-5 w-5 ${R?`animate-spin motion-reduce:animate-none`:``}`})}),(0,W.jsx)(`button`,{type:`button`,onClick:Xe,title:e(`feeds.markAllRead`),"aria-label":e(`feeds.markAllRead`),className:`btn-secondary flex h-11 w-11 shrink-0 items-center justify-center p-0!`,children:(0,W.jsx)(`svg`,{className:`h-5 w-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M3 12l4 4 6-7M11 16l3 0 7-8`})})})]})]}),(0,W.jsxs)(`div`,{ref:ve,className:`sticky z-20 py-2`,style:{top:ye},children:[L&&(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute -top-px bottom-0 left-1/2 w-screen -translate-x-1/2 border-y border-[var(--c-border)] backdrop-blur-md`,style:{backgroundColor:`color-mix(in srgb, var(--c-surface) 85%, transparent)`}}),(0,W.jsxs)(`div`,{className:`items-toolbar relative z-10 flex items-center gap-2 sm:gap-3 ${P?`items-toolbar-open`:``}`,children:[(0,W.jsx)(`div`,{className:`items-toolbar-scope min-w-0 flex-1 sm:flex-none sm:w-64`,inert:P,children:(0,W.jsx)(Vu,{value:N,onChange:Ee,options:it,className:`w-full`,placeholder:e(`items.allFeeds`)})}),(0,W.jsxs)(`div`,{className:`relative hidden sm:block flex-1 min-w-0`,children:[(0,W.jsx)(`input`,{ref:et,type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input w-full pl-9 pr-3`,value:he,onChange:e=>Ce(e.target.value)}),(0,W.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none opacity-45 text-[var(--c-text-muted)]`,children:(0,W.jsx)(Xd,{})})]}),(0,W.jsxs)(`div`,{className:`items-toolbar-search relative h-[38px] min-w-0 overflow-hidden sm:hidden`,children:[(0,W.jsx)(`button`,{ref:I,type:`button`,onClick:()=>F(!0),"aria-label":e(`items.searchPlaceholder`),"aria-controls":`mobile-article-search`,"aria-expanded":P,title:e(`items.searchPlaceholder`),"aria-hidden":P,tabIndex:P?-1:0,className:`absolute inset-y-0 left-0 z-10 flex w-[38px] items-center justify-center rounded-lg border transition-opacity duration-150 ${P?`pointer-events-none opacity-0`:he?`border-[var(--c-blue3)] bg-[var(--c-surface-hover)] text-[var(--c-text)] opacity-100`:`border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] opacity-100`}`,children:(0,W.jsx)(Xd,{})}),(0,W.jsxs)(`div`,{className:`flex h-full min-w-0 items-center gap-2 transition-opacity duration-200 ${P?`opacity-100 delay-75`:`pointer-events-none opacity-0`}`,inert:!P,children:[(0,W.jsx)(`span`,{className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--c-text-muted)] opacity-60`,children:(0,W.jsx)(Xd,{})}),(0,W.jsx)(`input`,{id:`mobile-article-search`,ref:_e,type:`search`,placeholder:e(`items.searchPlaceholder`),"aria-label":e(`items.searchPlaceholder`),className:`input min-w-0 flex-1 pl-9`,value:he,onChange:e=>Ce(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Se()}}),(0,W.jsx)(`button`,{type:`button`,onClick:Se,"aria-label":e(`common.close`),title:e(`common.close`),className:`w-[38px] h-[38px] rounded-lg border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] flex items-center justify-center shrink-0 cursor-pointer`,children:(0,W.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]}),(0,W.jsxs)(`div`,{className:`items-toolbar-filters flex items-center gap-1.5 sm:gap-2 shrink-0`,inert:P,children:[(0,W.jsx)(`button`,{type:`button`,onClick:Te,title:e(fe?`items.all`:`items.bookmarkedOnly`),"aria-label":e(`items.bookmarkedOnly`),"aria-pressed":fe,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${fe?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:fe?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:we,disabled:fe,title:e(fe?`items.unreadIgnoredInSaved`:ue?`items.all`:`items.unreadOnly`),"aria-label":e(`items.unreadOnly`),"aria-pressed":me,className:`w-[38px] h-[38px] rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-40 ${me?`bg-[var(--c-surface-hover)] border-[var(--c-blue3)] text-[var(--c-text)] shadow-xs`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:me?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]}),(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[{token:`has:audio`,label:e(`items.filterAudio`)},{token:`has:video`,label:e(`items.filterVideo`)},{token:`has:notes`,label:e(`items.filterNotes`)}].map(({token:e,label:t})=>{let n=RegExp(`(?:^|\\s)${e}(?:\\s|$)`,`i`).test(he);return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":n,onClick:()=>{let t=he.replace(RegExp(`(?:^|\\s)${e}(?=\\s|$)`,`gi`),` `).replace(/\s+/g,` `).trim();Ce(n?t:t?`${t} ${e}`:e)},className:`rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors cursor-pointer ${n?`border-[var(--c-blue3)] bg-[var(--c-blue3)]/15 text-[var(--c-text)]`:`border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]/60`}`,children:t},e)})})]}),o&&i.length>0&&!u&&(0,W.jsx)(dd,{}),o&&i.length>0&&!v&&(0,W.jsx)(Jd,{}),o&&i.length>0&&!v&&(0,W.jsx)(qd,{}),p.length>0&&Oe?.last_error&&(0,W.jsxs)(`div`,{role:`status`,className:`mb-4 flex items-center gap-2 rounded-lg border px-3.5 py-2.5 text-sm text-[var(--c-danger)]`,style:{borderColor:`var(--c-border)`,background:`var(--c-surface)`},children:[(0,W.jsx)(td,{}),(0,W.jsx)(`span`,{children:Uu(e,Oe.last_error,Oe.url)})]}),v?(0,W.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3`,children:[(0,W.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(`items.loadFailed`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void Fe(),className:`btn-secondary`,children:e(`common.retry`)})]}):h&&p.length===0?(0,W.jsx)(Ru,{size:`lg`}):p.length===0&&o&&i.length===0?(0,W.jsx)(gd,{onSubscribed:Pe}):p.length===0&&Me?(0,W.jsxs)(`div`,{role:`status`,className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,W.jsx)(Ru,{size:`lg`}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`welcome.fetchingTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`welcome.fetchingHint`)})]}):p.length===0&&!he&&!fe&&Oe?.last_error?(0,W.jsxs)(`div`,{role:`status`,className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,W.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-[var(--c-danger)]/10 text-[var(--c-danger)]`,children:(0,W.jsx)(td,{})}),(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`items.feedUnavailableTitle`)}),(0,W.jsx)(`p`,{className:`max-w-md text-sm text-[var(--c-text-muted)]`,children:Uu(e,Oe.last_error,Oe.url)})]}):p.length===0&&je&&me&&i.length>0?(0,W.jsxs)(`div`,{className:`card flex flex-col items-center gap-3 px-6 py-12 text-center`,children:[(0,W.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`items.allReadTitle`)}),(0,W.jsx)(`p`,{className:`max-w-sm text-sm text-[var(--c-text-muted)]`,children:e(`items.allReadHint`)}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(!1),className:`btn-secondary mt-1`,children:e(`items.all`)})]}):p.length===0?(0,W.jsx)(`p`,{style:{color:`var(--c-text-muted)`},children:e(fe&&!he?`items.noSaved`:he?`items.noResults`:`items.noItems`)}):Oe&&!he&&ke===`audio`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Rd,{feed:Oe}),(0,W.jsx)(Bd,{feed:Oe,items:p,focusedItemId:Qe,onOpen:Be,onBookmark:Ye,onRead:Je})]}):Oe&&!he&&ke===`video`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Rd,{feed:Oe}),(0,W.jsx)(Vd,{items:p,focusedItemId:Qe,onOpen:Be,onBookmark:Ye})]}):te===`newspaper`?(0,W.jsx)(Fd,{items:p,focusedItemId:Qe,onOpen:Be,onBookmark:Ye,onRead:Je}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-4 sm:gap-5 animate-page-fade`,children:p.map(t=>{let n=t.published_at?new Date(t.published_at):null,r=Qe===t.id;return(0,W.jsx)(`li`,{"data-item-id":t.id,onClick:()=>Be(t),className:`card overflow-hidden p-4 sm:p-0 transition-colors duration-150 hover:bg-[var(--c-surface-hover)] hover:border-[var(--c-blue3)]/60 cursor-pointer group/card ${r?`ring-2 ring-[var(--c-blue3)] border-[var(--c-blue3)] bg-[var(--c-surface-hover)]`:``}`,style:{opacity:t.read?.6:1},children:(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-stretch justify-between gap-3 sm:gap-0`,children:[t.image_url&&(0,W.jsx)(`div`,{className:`order-first w-[calc(100%+2rem)] -mx-4 -mt-4 sm:m-0 sm:w-52 sm:min-w-52 h-48 sm:h-auto sm:self-stretch overflow-hidden shrink-0 border-b sm:border-b-0 sm:border-r bg-[var(--c-bg)] group transition-opacity hover:opacity-90 block`,style:{borderColor:`var(--c-border)`},children:(0,W.jsx)(`img`,{src:t.image_url,alt:``,className:`w-full h-full object-cover group-hover:scale-105 transition-transform duration-200`,loading:`lazy`,onError:e=>{let t=e.currentTarget.parentElement;t&&(t.style.display=`none`)}})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 sm:p-5 sm:pr-3 flex flex-col justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex min-w-0 items-center gap-2 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:[(0,W.jsx)(qc,{feedId:t.feed_id,iconUrl:t.feed_icon_url,siteUrl:t.feed_site_url,feedUrl:t.feed_url,articleUrl:t.link,className:`w-3.5 h-3.5 rounded-xs shrink-0 object-contain`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.feed_title}),(t.enclosure_url||Xc(t.link))&&(0,W.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 rounded-full border border-[var(--c-border)] px-2 py-0.5 text-[11px] font-medium tracking-normal normal-case text-[var(--c-text-muted)] shrink-0`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:t.enclosure_type?.startsWith(`video/`)||!t.enclosure_url&&Xc(t.link)?`▶`:`🎧`}),t.enclosure_duration_seconds?Yc(t.enclosure_duration_seconds):t.enclosure_type?.startsWith(`video/`)||!t.enclosure_url&&Xc(t.link)?`Video`:`Audio`]})]}),(0,W.jsx)(`h2`,{lang:Ao(t.title),className:`text-lg leading-snug font-semibold text-[var(--c-text)]${Ao(t.title)===`ja`?` ja-phrases`:``}`,children:t.title?(0,W.jsx)(Jc,{text:t.title}):null}),(0,W.jsx)(Ad,{item:t,className:`mt-3 text-sm leading-relaxed line-clamp-3 text-[var(--c-text-muted)]`})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs pt-5`,style:{color:`var(--c-text-muted)`},children:[(0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5 min-w-0`,children:n&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,W.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,W.jsx)(`line`,{x1:`8`,y1:`2`,x2:`8`,y2:`6`}),(0,W.jsx)(`line`,{x1:`3`,y1:`10`,x2:`21`,y2:`10`})]}),(0,W.jsx)(`span`,{children:nt.format(n)})]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsxs)(`svg`,{className:`w-3.5 h-3.5 shrink-0 opacity-70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,W.jsx)(`polyline`,{points:`12 6 12 12 16 14`})]}),(0,W.jsx)(`span`,{children:rt.format(n)})]})]})}),(0,W.jsxs)(`div`,{className:`flex sm:hidden items-center gap-2 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ye(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Je(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-8 h-8 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})]}),(0,W.jsxs)(`div`,{className:`hidden sm:flex items-center gap-2 pt-5 pr-5 shrink-0 self-start`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Ye(t)},title:t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),"aria-label":t.bookmarked?e(`items.unbookmark`):e(`items.bookmark`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.bookmarked?`bg-amber-500/15 border-amber-500/40 text-amber-500`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-amber-500 hover:border-amber-500/30`}`,children:(0,W.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:t.bookmarked?`currentColor`:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`})})}),(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),Je(t)},title:t.read?e(`items.markUnread`):e(`items.markRead`),"aria-label":t.read?e(`items.markUnread`):e(`items.markRead`),className:`w-9 h-9 rounded-lg border flex items-center justify-center shrink-0 transition-colors cursor-pointer ${t.read?`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-text-muted)] hover:text-[var(--c-text)] hover:border-[var(--c-blue3)]`:`bg-[var(--c-surface)] border-[var(--c-border)] text-[var(--c-blue1)] hover:border-[var(--c-blue3)]`}`,children:(0,W.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 24 24`,fill:t.read?`none`:`currentColor`,stroke:`currentColor`,strokeWidth:`2.2`,children:(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})})})]})]})},t.id)})}),!v&&p.length>0&&(w||S)&&(S?(0,W.jsx)(`button`,{type:`button`,onClick:()=>{Ie()},className:`btn-secondary self-center`,children:e(`common.retry`)}):(0,W.jsx)(`div`,{ref:Re,className:`flex min-h-12 items-center justify-center`,children:b&&(0,W.jsx)(Ru,{size:`sm`})})),(0,W.jsx)(Qc,{item:k,isOpen:!!k,onClose:Ve,onToggleBookmark:Ye,onToggleRead:Je,onNext:Ge,onPrevious:Ke,onItemUpdated:ot,hasNext:Ue,hasPrev:We})]});return(0,W.jsx)(Kd,{disabled:h||!u||!!k||P,onRefresh:tt,children:st})}function ef(e,t){let n=Math.min(e,t);return{sx:Math.round((e-n)/2),sy:Math.round((t-n)/2),size:n}}async function tf(e){let t=await createImageBitmap(e);try{let{sx:e,sy:n,size:r}=ef(t.width,t.height),i=document.createElement(`canvas`);i.width=256,i.height=256;let a=i.getContext(`2d`);if(!a)throw Error(`canvas_unavailable`);return a.fillStyle=`#ffffff`,a.fillRect(0,0,256,256),a.imageSmoothingQuality=`high`,a.drawImage(t,e,n,r,r,0,0,256,256),await new Promise((e,t)=>{i.toBlob(n=>n?e(n):t(Error(`encode_failed`)),`image/jpeg`,.88)})}finally{t.close()}}function nf({title:e,description:t,children:n,footer:r}){return(0,W.jsxs)(`section`,{className:`card`,children:[(e||t)&&(0,W.jsxs)(`header`,{className:`px-5 pt-5 pb-1 sm:px-6`,children:[e&&(0,W.jsx)(`h3`,{className:`text-base font-semibold`,children:e}),t&&(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]}),(0,W.jsx)(`div`,{className:`divide-y divide-[var(--c-border)]`,children:n}),r&&(0,W.jsx)(`footer`,{className:`flex flex-wrap items-center justify-end gap-3 border-t border-[var(--c-border)] px-5 py-4 sm:px-6`,children:r})]})}function rf({label:e,hint:t,htmlFor:n,children:r,stacked:i=!1,inline:a=!1}){return(0,W.jsxs)(`div`,{className:`flex gap-3 px-5 py-4 sm:px-6 ${i?`flex-col`:a?`flex-row items-center justify-between gap-4 sm:gap-6`:`flex-col sm:flex-row sm:items-center sm:justify-between sm:gap-6`}`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`label`,{htmlFor:n,className:`text-sm font-medium`,children:e}),t&&(0,W.jsx)(`p`,{className:`mt-0.5 text-sm text-[var(--c-text-muted)]`,children:t})]}),r&&(0,W.jsx)(`div`,{className:i?``:`shrink-0`,children:r})]})}function af({children:e}){return(0,W.jsx)(`div`,{className:`px-5 py-4 sm:px-6`,children:e})}function of({id:e,checked:t,onChange:n,label:r}){return(0,W.jsxs)(`label`,{className:`relative inline-flex cursor-pointer items-center`,children:[(0,W.jsx)(`input`,{id:e,type:`checkbox`,className:`peer sr-only`,checked:t,onChange:e=>n(e.target.checked),"aria-label":r}),(0,W.jsx)(`span`,{className:`h-6 w-11 rounded-full bg-[var(--c-border)] transition-colors peer-checked:bg-[var(--c-blue1)] peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-[var(--c-blue3)] after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform after:content-[''] peer-checked:after:translate-x-5`})]})}function sf({message:e}){return e?(0,W.jsx)(`p`,{role:`status`,className:`text-sm ${e.type===`error`?`text-danger`:`text-[var(--c-green3)]`}`,children:e.text}):null}function cf({title:e,description:t}){return(0,W.jsxs)(`div`,{className:`mb-5`,children:[(0,W.jsx)(`h2`,{className:`text-xl font-semibold`,children:e}),t&&(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:t})]})}var lf=o(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),uf=o((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),df=o((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),ff=o(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),pf=o(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),mf=o((e=>{var t=uf().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),hf=o((e=>{var t=uf().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),gf=o((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),_f=o((e=>{var t=df(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),vf=o((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),yf=o((e=>{var t=vf();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),bf=o(((e,t)=>{var n=yf();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),xf=o((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Sf=o((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
97
|
+
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Cf=o((e=>{var t=xf(),n=Sf();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),wf=o((e=>{var t=uf(),n=_f(),r=df(),i=Cf(),a=xf(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Tf=o((e=>{var t=uf(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Ef=o(((e,t)=>{var n=Cf();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Df=o(((e,t)=>{var n=Cf(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Of=o(((e,t)=>{var n=Cf();function r(e){this.mode=n.BYTE,this.data=typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),kf=o(((e,t)=>{var n=Cf(),r=uf();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
98
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Af=o(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),jf=o((e=>{var t=Cf(),n=Ef(),r=Df(),i=Of(),a=kf(),o=Sf(),s=uf(),c=Af();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
99
|
+
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Mf=o((e=>{var t=uf(),n=df(),r=ff(),i=pf(),a=mf(),o=hf(),s=gf(),c=_f(),l=bf(),u=wf(),d=Tf(),f=Cf(),p=jf();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
100
100
|
The chosen QR Code version cannot contain this amount of data.
|
|
101
101
|
Minimum version required to store current data is: `+c+`.
|
|
102
|
-
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),
|
|
103
|
-
`;return typeof a==`function`&&a(null,p),p}})),Ff=c(o((e=>{var t=cf(),n=jf(),r=Nf(),i=Pf();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function If({status:e,onSuccess:t,onCancel:n}){let{t:r}=z(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),g=(0,_.useRef)(null);(0,_.useEffect)(()=>{g.current?.focus()},[]);async function v(){p(!0),h(``);try{t(await Nu())}catch{h(r(`security.passkeyCancelled`))}finally{p(!1)}}async function y(e){if(e.preventDefault(),i.trim()||c.trim()){p(!0),h(``);try{t((await Mu(u?`/reauth/email/confirm`:`/reauth`,{password:i,code:o,emailCode:c})).reauthToken)}catch{h(r(`security.invalidCredentials`))}finally{p(!1)}}}async function b(){p(!0),h(``);try{await Mu(`/reauth/email`,{}),d(!0)}catch{h(r(`security.failed`))}finally{p(!1)}}return typeof document>`u`?null:(0,es.createPortal)((0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,W.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-xs animate-fade-in`,onClick:f?void 0:n,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{className:`relative z-10 w-full max-w-md rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)] p-6 shadow-2xl animate-scale-in`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`reauth-modal-title`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 mb-2`,children:[(0,W.jsx)(`h2`,{id:`reauth-modal-title`,className:`text-lg font-bold text-[var(--c-text)]`,children:r(`security.confirmTitle`)}),(0,W.jsx)(`button`,{type:`button`,onClick:n,disabled:f,className:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] p-1 rounded-lg`,"aria-label":r(`security.cancel`),children:(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)] mb-5`,children:r(`security.reauth`)}),m&&(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--c-danger)] mb-4 p-2.5 rounded-lg bg-[var(--c-danger-bg)] border border-[var(--c-danger-border)]`,children:m}),e.passkeys.length>0&&(0,W.jsxs)(`div`,{className:`mb-5`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn-primary w-full flex items-center justify-center gap-2 py-2.5 font-medium`,onClick:v,disabled:f,children:[(0,W.jsxs)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,W.jsx)(`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`}),(0,W.jsx)(`path`,{d:`m21 2-9.6 9.6M15.5 7.5l3 3M18.5 4.5l3 3`})]}),r(`security.usePasskey`)]}),(0,W.jsxs)(`div`,{className:`relative my-4 flex items-center justify-center`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,W.jsx)(`div`,{className:`w-full border-t border-[var(--c-border)]`})}),(0,W.jsx)(`span`,{className:`relative bg-[var(--c-surface)] px-3 text-xs uppercase tracking-wider text-[var(--c-text-muted)]`,children:r(`security.orPassword`)})]})]}),(0,W.jsxs)(`form`,{onSubmit:y,className:`flex flex-col gap-3`,children:[!u&&(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-[var(--c-text-muted)]`,children:[r(`security.password`),(0,W.jsx)(`input`,{ref:g,className:`input text-sm text-[var(--c-text)]`,type:`password`,autoComplete:`current-password`,disabled:f,value:i,onChange:e=>a(e.target.value),placeholder:r(`security.password`),"aria-label":r(`security.password`),required:!e.emailReauthEnabled})]}),e.totpEnabled&&(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-[var(--c-text-muted)]`,children:[r(`security.code`),(0,W.jsx)(`input`,{className:`input text-sm text-[var(--c-text)]`,autoComplete:`one-time-code`,inputMode:`numeric`,disabled:f,value:o,onChange:e=>s(e.target.value),placeholder:r(`security.code`),"aria-label":r(`security.code`)})]}),e.emailReauthEnabled&&!u&&(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary self-start text-xs`,disabled:f,onClick:b,children:r(`security.sendEmail`)}),u&&(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-[var(--c-text-muted)]`,children:[r(`security.emailCode`),(0,W.jsx)(`input`,{ref:g,className:`input text-sm text-[var(--c-text)]`,autoComplete:`one-time-code`,inputMode:`numeric`,disabled:f,value:c,onChange:e=>l(e.target.value),placeholder:r(`security.emailCode`),"aria-label":r(`security.emailCode`),required:!0})]}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2.5 mt-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary text-sm`,onClick:n,disabled:f,children:r(`security.cancel`)}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary text-sm`,disabled:f||!i.trim()&&!c.trim(),children:r(`security.confirmAction`)})]})]})]})]}),document.body)}function Lf(){let{t:e}=z(),[t,n]=(0,_.useState)(),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),b=async()=>{let e=await Mu(`/`,void 0,`GET`);n(e)};(0,_.useEffect)(()=>{b().catch(()=>f(e(`security.failed`)))},[e]);function x(){return new Promise((e,t)=>{y({resolve:e,reject:t})})}function S(e){let t=v;y(null),t&&t.resolve(e)}function C(){let e=v;y(null),e&&e.reject(Error(`cancelled`))}async function w(t,n){f(``),m(``);let r;try{r=await x()}catch{return}g(!0);let i=!1;try{await t(r),i=!0,n&&m(e(n)),await b()}catch(t){f(e(i?`security.refreshFailed`:t instanceof Error&&t.message===`last_passkey`?`security.lastPasskey`:`security.failed`))}finally{g(!1)}}return t?(0,W.jsxs)(tf,{title:e(`security.title`),description:e(`security.intro`),children:[p&&(0,W.jsx)(`div`,{className:`px-5 pt-3 pb-1 sm:px-6`,children:(0,W.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2.5 rounded-xl border border-[var(--c-success-border)] bg-[var(--c-success-bg)] px-3.5 py-2.5 text-sm font-medium text-[var(--c-green3)]`,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z`,clipRule:`evenodd`})}),(0,W.jsx)(`span`,{children:p})]})}),d&&(0,W.jsx)(`div`,{className:`px-5 pt-3 pb-1 sm:px-6`,children:(0,W.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-2.5 rounded-xl border border-[var(--c-danger-border)] bg-[var(--c-danger-bg)] px-3.5 py-2.5 text-sm font-medium text-[var(--c-danger)]`,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-8-5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-4.5A.75.75 0 0 1 10 5Zm0 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z`,clipRule:`evenodd`})}),(0,W.jsx)(`span`,{children:d})]})}),(0,W.jsxs)(rf,{children:[(0,W.jsx)(`h3`,{className:`font-semibold mb-3`,children:e(`security.passkeys`)}),!!t.passkeys.length&&(0,W.jsx)(`ul`,{className:`mb-4 divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:t.passkeys.map(t=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere] text-sm font-medium`,children:t.name}),(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary shrink-0 text-sm`,disabled:h,"aria-label":e(`security.removeNamed`,{name:t.name}),onClick:()=>void w(async e=>{await Mu(`/passkeys/${encodeURIComponent(t.id)}`,{reauthToken:e},`DELETE`)},`security.passkeyRemoved`),children:e(`security.remove`)})]},t.id))}),t.passkeysEnabled?(0,W.jsxs)(`form`,{className:`grid grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(0,1fr)_auto]`,onSubmit:e=>{if(e.preventDefault(),!h&&r.trim()){let e=r.trim();w(async t=>{await Pu(t,e),i(``)},`security.passkeyAdded`)}},children:[(0,W.jsxs)(`label`,{className:`min-w-0 text-sm font-medium`,children:[e(`security.passkeyName`),(0,W.jsx)(`input`,{className:`input mt-2`,value:r,maxLength:100,disabled:h,onChange:e=>i(e.target.value),placeholder:e(`security.passkeyName`),"aria-label":e(`security.passkeyName`)})]}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary whitespace-nowrap`,disabled:h||!r.trim(),children:e(`security.addPasskey`)})]}):(0,W.jsx)(`p`,{children:e(`security.httpsRequired`)})]}),(0,W.jsxs)(rf,{children:[(0,W.jsx)(`h3`,{className:`font-semibold mb-3`,children:e(`security.twoFactor`)}),(0,W.jsx)(`p`,{className:`text-sm mb-3`,children:e(t.totpEnabled?`security.enabled`:`security.disabled`)}),(0,W.jsx)(`p`,{className:`text-sm mb-3`,children:e(`security.revocationHint`)}),!s&&(0,W.jsx)(`button`,{className:`btn-secondary`,disabled:h||l.length>0,onClick:()=>void w(async e=>{if(t.totpEnabled)await Mu(`/totp/disable`,{reauthToken:e});else{let t=await Mu(`/totp/setup`,{reauthToken:e});c({...t,qr:await Ff.toDataURL(t.uri)})}},t.totpEnabled?`security.updated`:`security.authenticatorStarted`),children:e(t.totpEnabled?`security.disable`:`security.enable`)}),s&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 mt-3`,children:[(0,W.jsx)(`p`,{children:e(`security.scan`)}),(0,W.jsx)(`img`,{src:s.qr,alt:e(`security.qrAlt`),width:200,height:200}),(0,W.jsx)(`code`,{className:`break-all select-all`,children:s.secret}),(0,W.jsx)(`input`,{className:`input`,value:a,autoComplete:`one-time-code`,inputMode:`numeric`,onChange:e=>o(e.target.value),"aria-label":e(`security.code`),placeholder:e(`security.code`)}),(0,W.jsxs)(`div`,{className:`flex gap-3`,children:[(0,W.jsx)(`button`,{className:`btn-primary`,disabled:h,onClick:async()=>{g(!0),f(``);try{let t=await Mu(`/totp/confirm`,{challengeId:s.challengeId,code:a});u(t.recoveryCodes),c(void 0),o(``),m(e(`security.updated`)),await b()}catch{f(e(`security.failed`))}finally{g(!1)}},children:e(`security.confirm`)}),(0,W.jsx)(`button`,{className:`btn-secondary`,disabled:h,onClick:()=>{c(void 0),o(``)},children:e(`security.cancel`)})]})]}),t.totpEnabled&&!l.length&&(0,W.jsx)(`button`,{className:`btn-secondary ml-3`,disabled:h,onClick:()=>void w(async e=>{let t=await Mu(`/recovery-codes`,{reauthToken:e});u(t.recoveryCodes)}),children:e(`security.newRecovery`)}),!!l.length&&(0,W.jsxs)(`div`,{className:`mt-4`,role:`status`,children:[(0,W.jsx)(`p`,{className:`mb-3`,children:e(`security.saveRecovery`)}),(0,W.jsx)(`pre`,{className:`select-all whitespace-pre-wrap`,children:l.join(`
|
|
104
|
-
`)}),(0,W.jsx)(`button`,{className:`btn-secondary mt-3`,onClick:()=>u([]),children:e(`security.saved`)})]})]}),v&&(0,W.jsx)(If,{status:t,onSuccess:S,onCancel:C})]}):d?(0,W.jsx)(`p`,{role:`alert`,children:d}):null}function Rf(){let{t:e}=z(),{user:t,setCurrentUser:n}=lo(),[r,i]=(0,_.useState)(t?.display_name??``),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),d=(0,_.useRef)(null);if(!t)return null;let f=r.trim();async function p(t){t.preventDefault(),u(null),o(!0);try{let t=await U.updateProfile(f);n(t),i(t.display_name),u({type:`success`,text:e(`settings.profileSaved`)})}catch{u({type:`error`,text:e(`common.error`)})}finally{o(!1)}}async function m(t){let r=t.target.files?.[0];if(t.target.value=``,r){u(null),c(!0);try{n(await U.uploadAvatar(await ef(r)))}catch(t){u({type:`error`,text:t instanceof va?e(`common.error`):e(`settings.avatarUnreadable`)})}finally{c(!1)}}}async function h(){u(null),c(!0);try{n(await U.deleteAvatar())}catch{u({type:`error`,text:e(`common.error`)})}finally{c(!1)}}return(0,W.jsxs)(tf,{title:e(`settings.profileTitle`),children:[(0,W.jsxs)(rf,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsx)(ql,{user:t,className:`h-16 w-16 text-xl transition-opacity ${s?`opacity-50`:``}`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate font-semibold`,children:t.display_name||t.email}),(0,W.jsx)(`p`,{className:`truncate text-sm text-[var(--c-text-muted)]`,children:t.email}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary px-3 py-1.5 text-sm`,disabled:s,onClick:()=>d.current?.click(),children:t.avatar_updated_at?e(`settings.avatarChange`):e(`settings.avatarUpload`)}),t.avatar_updated_at&&(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary px-3 py-1.5 text-sm text-danger`,disabled:s,onClick:h,children:e(`settings.avatarRemove`)})]})]}),(0,W.jsx)(`input`,{ref:d,type:`file`,accept:`image/*`,className:`hidden`,onChange:m})]}),(0,W.jsx)(`p`,{className:`mt-3 text-xs text-[var(--c-text-muted)]`,children:e(`settings.avatarHint`)})]}),(0,W.jsx)(`form`,{onSubmit:p,children:(0,W.jsxs)(nf,{label:e(`settings.displayNameLabel`),htmlFor:`profile-name`,stacked:!0,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,W.jsx)(`input`,{id:`profile-name`,className:`input sm:max-w-sm`,required:!0,maxLength:100,autoComplete:`name`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,disabled:a||!f||f===t.display_name,className:`btn-primary self-start`,children:e(`common.save`)})]}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsx)(of,{message:l})})]})})]})}function zf(){let{t:e}=z(),[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1);async function d(s){if(s.preventDefault(),c(null),r!==a)c({type:`error`,text:e(`settings.passwordMismatch`)});else{u(!0);try{await U.changePassword(t,r),c({type:`success`,text:e(`settings.passwordChanged`)}),n(``),i(``),o(``)}catch(t){c({type:`error`,text:t instanceof va&&t.status===401?e(`settings.incorrectPassword`):e(`common.error`)})}finally{u(!1)}}}return(0,W.jsx)(`form`,{onSubmit:d,children:(0,W.jsx)(tf,{title:e(`settings.changePasswordTitle`),description:e(`settings.passwordHint`),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(of,{message:s}),(0,W.jsx)(`button`,{type:`submit`,disabled:l,className:`btn-primary`,children:e(`settings.changePasswordButton`)})]}),children:(0,W.jsx)(rf,{children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(`input`,{type:`password`,required:!0,autoComplete:`current-password`,placeholder:e(`settings.currentPasswordLabel`),"aria-label":e(`settings.currentPasswordLabel`),className:`input`,value:t,onChange:e=>n(e.target.value)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,autoComplete:`new-password`,placeholder:e(`settings.newPasswordLabel`),"aria-label":e(`settings.newPasswordLabel`),className:`input`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,autoComplete:`new-password`,placeholder:e(`settings.confirmPasswordLabel`),"aria-label":e(`settings.confirmPasswordLabel`),className:`input`,value:a,onChange:e=>o(e.target.value)})]})})})})}function Bf(){let{user:e}=lo(),t=dl(bl()),[n,r]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let n=!0;if(r(null),t&&e)return Promise.resolve(!t.applies||t.applies({id:e.id,email:e.email,display_name:e.display_name??null})).then(e=>{n&&r(e===!0)}).catch(()=>{n&&r(!1)}),()=>{n=!1}},[t?.mount,t?.applies,e?.id]),t?n===null?null:n?(0,W.jsx)(Iu,{name:`password-card`,mount:t.mount}):(0,W.jsx)(zf,{}):(0,W.jsx)(zf,{})}function $(){return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(Rf,{}),(0,W.jsx)(Bf,{}),(0,W.jsx)(Lf,{})]})}var Vf=[{value:`de`,label:`Deutsch`},{value:`en`,label:`English`},{value:`ja`,label:`日本語`},{value:`ru`,label:`Русский`}];function Hf(){let{t:e,i18n:t}=z();return(0,W.jsx)(Vu,{value:t.resolvedLanguage??`de`,onChange:e=>{Rt(e),t.changeLanguage(e)},options:Vf,className:`w-44`,ariaLabel:e(`settings.language`)})}function Uf(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(Pl,Fl),n=[{value:`light`,label:e(`settings.themeLight`)},{value:`dark`,label:e(`settings.themeDark`)},{value:`system`,label:e(`settings.themeSystem`)}];return(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-xl border border-[var(--c-border)] p-0.5`,role:`group`,"aria-label":e(`settings.theme`),children:n.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>Il(e.value),"aria-pressed":t===e.value,className:`h-8 rounded-lg px-3 text-sm font-medium transition-colors cursor-pointer ${t===e.value?`border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)] shadow-sm`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:e.label},e.value))})}function Wf(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(Ul,Wl);return t===`installed`||t===`unsupported`?null:(0,W.jsx)(nf,{label:e(`settings.installApp`),hint:e(t===`ios`?`settings.installAppIos`:t===`mac-safari`?`settings.installAppMacSafari`:`settings.installAppHint`),children:t===`prompt`&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>void Gl(),className:`btn-primary whitespace-nowrap`,children:e(`settings.installAppButton`)})})}function Gf(){let{t:e,i18n:t}=z(),n=(0,_.useSyncExternalStore)(Ul,Wl),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{Ya().then(i).catch(()=>i(`unsupported`))},[]),r===null)return(0,W.jsx)(nf,{label:e(`settings.notifications`)});if(r===`unsupported`){let t=e(n===`ios`?`settings.notificationsIos`:`settings.notificationsUnsupported`);return(0,W.jsx)(nf,{label:e(`settings.notifications`),hint:t})}async function s(t){o(!0);try{t?i(await Za()):(await Qa(),i(`off`))}catch{J.error(e(`common.error`))}finally{o(!1)}}async function c(){try{let{delivered:n}=await U.sendTestPush(t.resolvedLanguage??`en`);n===0&&J.error(e(`settings.notificationsTestFailed`))}catch{J.error(e(`common.error`))}}return(0,W.jsx)(nf,{label:e(`settings.notifications`),hint:e(r===`blocked`?`settings.notificationsBlocked`:`settings.notificationsHint`),htmlFor:`notifications-toggle`,inline:!0,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r===`on`&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>void c(),className:`btn-secondary px-3 py-1.5 text-sm`,children:e(`settings.notificationsTest`)}),(0,W.jsx)(af,{id:`notifications-toggle`,label:e(`settings.notifications`),checked:r===`on`,onChange:e=>!a&&r!==`blocked`&&void s(e)})]})})}function Kf(){let{t:e}=z(),[t,n]=(0,_.useState)(da),[r,i]=(0,_.useState)(null);(0,_.useEffect)(()=>{pa().then(e=>i(e?ga(e).length:null))},[t]);async function a(e){if(n(e),fa(e),!e){await Va(),i(null);return}let t=await Ba({force:!0});t!==null&&i(t)}return(0,W.jsx)(nf,{label:e(`settings.offlineSaved`),hint:`${e(`settings.offlineSavedHint`)}${t&&r!==null?` ${e(`settings.offlineSavedCount`,{count:r})}`:``}`,htmlFor:`offline-saved-toggle`,inline:!0,children:(0,W.jsx)(af,{id:`offline-saved-toggle`,label:e(`settings.offlineSaved`),checked:t,onChange:e=>void a(e)})})}function qf(){let{t:e}=z(),[t,n]=(0,_.useState)(()=>localStorage.getItem(`feedkeeper_auto_reader_mode`)!==`false`);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(tf,{title:e(`settings.appearanceTitle`),children:[(0,W.jsx)(nf,{label:e(`settings.theme`),hint:e(`settings.themeHint`),children:(0,W.jsx)(Uf,{})}),(0,W.jsx)(nf,{label:e(`settings.language`),hint:e(`settings.languageHint`),children:(0,W.jsx)(Hf,{})})]}),(0,W.jsxs)(tf,{title:e(`settings.readingTitle`),children:[(0,W.jsx)(nf,{label:e(`settings.autoReaderMode`),hint:e(`settings.autoReaderModeHint`),htmlFor:`auto-reader-toggle`,inline:!0,children:(0,W.jsx)(af,{id:`auto-reader-toggle`,label:e(`settings.autoReaderMode`),checked:t,onChange:e=>{n(e),localStorage.setItem(`feedkeeper_auto_reader_mode`,e?`true`:`false`)}})}),(0,W.jsx)(Kf,{}),(0,W.jsx)(Gf,{}),(0,W.jsx)(Wf,{})]})]})}function Jf(){let{t:e}=z(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null);(0,_.useEffect)(()=>{U.listMutedKeywords().then(e=>n(e.keywords)).catch(()=>{})},[]);async function l(t){if(t.preventDefault(),r.trim()){o(!0),c(null);try{let e=await U.addMutedKeyword(r.trim());n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),i(``)}catch{c(e(`common.error`))}finally{o(!1)}}}async function u(t){try{await U.deleteMutedKeyword(t),n(e=>e.filter(e=>e.id!==t))}catch{c(e(`common.error`))}}return(0,W.jsx)(tf,{title:e(`settings.mutedKeywordsTitle`),description:e(`settings.mutedKeywordsHint`),children:(0,W.jsxs)(rf,{children:[(0,W.jsxs)(`form`,{onSubmit:l,className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,placeholder:e(`settings.mutedKeywordPlaceholder`),"aria-label":e(`settings.mutedKeywordPlaceholder`),className:`input flex-1`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,disabled:a||!r.trim(),className:`btn-primary whitespace-nowrap`,children:e(`settings.addMutedKeyword`)})]}),s&&(0,W.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:s}),t.length>0?(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:t.map(t=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-[var(--c-border)] bg-[var(--c-bg)] py-1 pl-3 pr-1 text-sm`,children:[t.keyword,(0,W.jsx)(`button`,{type:`button`,onClick:()=>u(t.id),title:e(`settings.removeMutedKeyword`),"aria-label":`${e(`settings.removeMutedKeyword`)}: ${t.keyword}`,className:`flex h-6 w-6 items-center justify-center rounded-full text-[var(--c-text-muted)] hover:bg-[var(--c-danger-bg)] hover:text-[var(--c-danger)] cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},t.id))}):(0,W.jsx)(`p`,{className:`mt-4 text-sm text-[var(--c-text-muted)]`,children:e(`settings.noMutedKeywords`)})]})})}function Yf({value:e}){let{t}=z(),[n,r]=(0,_.useState)(!1);return(0,W.jsx)(`button`,{type:`button`,onClick:async()=>{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)},className:`btn-secondary shrink-0 px-3 py-1.5 text-sm`,children:t(n?`settings.copied`:`settings.copyToken`)})}function Xf({scope:e}){let{t}=z();return(0,W.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${e===`write`?`bg-[var(--c-danger-bg)] text-[var(--c-danger)]`:`bg-[var(--c-mobile-nav-active)] text-[var(--c-text-muted)]`}`,children:t(e===`read`?`settings.tokenReadOnly`:`settings.tokenReadWrite`)})}function Zf(){let{t:e,i18n:t}=z(),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`read`),[u,d]=(0,_.useState)(null),f=`${window.location.origin}/mcp`,p=new Intl.DateTimeFormat(t.resolvedLanguage,{dateStyle:`medium`});async function m(){let[e,t]=await Promise.all([U.listTokens(),U.listOAuthGrants()]);r(e),a(t)}(0,_.useEffect)(()=>{m()},[]);async function h(e){e.preventDefault();let{token:t}=await U.createToken(o,c);d(t),s(``),await m()}async function g(t){confirm(e(`settings.revokeTokenConfirm`,{name:t.name}))&&(await U.deleteToken(t.id),await m())}async function v(t){confirm(e(`settings.disconnectAppConfirm`,{name:t.client_name}))&&(await U.deleteOAuthGrant(t.id),await m())}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(tf,{title:e(`settings.mcpTitle`),description:e(`settings.mcpHint`),children:(0,W.jsxs)(rf,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-[var(--c-border)] bg-[var(--c-bg)] py-1.5 pl-3 pr-1.5`,children:[(0,W.jsx)(`code`,{className:`min-w-0 flex-1 truncate text-sm`,children:f}),(0,W.jsx)(Yf,{value:f})]}),(0,W.jsxs)(`div`,{className:`mt-5 rounded-xl border border-[var(--c-green3)] p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:e(`settings.mcpOauthTitle`)}),(0,W.jsx)(`span`,{className:`rounded-full bg-[var(--c-mobile-nav-active)] px-2 py-0.5 text-xs font-medium`,children:e(`settings.mcpOauthBadge`)})]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:e(`settings.mcpOauthIntro`)}),(0,W.jsxs)(`ol`,{className:`mt-3 flex list-decimal flex-col gap-1 pl-5 text-sm text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`li`,{children:e(`settings.mcpOauthStep1`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpOauthStep2`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpOauthStep3`)})]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm text-[var(--c-text-muted)]`,children:e(`settings.mcpOauthDone`)})]}),(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-[var(--c-border)] p-4`,children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:e(`settings.mcpTokenTitle`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:e(`settings.mcpTokenIntro`)}),(0,W.jsxs)(`ol`,{className:`mt-3 flex list-decimal flex-col gap-1 pl-5 text-sm text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`li`,{children:e(`settings.mcpStepToken`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpStepUrl`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpStepHeader`)})]}),(0,W.jsxs)(`div`,{className:`mt-5 border-t border-[var(--c-border)] pt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-[var(--c-text-muted)]`,children:e(`settings.mcpClaudeTitle`)}),(0,W.jsx)(`button`,{type:`button`,onClick:async()=>{let t=JSON.stringify({mcpServers:{feedkeeper:{url:f,headers:{Authorization:`Bearer ${u??`<YOUR_TOKEN>`}`}}}},null,2);await navigator.clipboard.writeText(t),alert(e(`settings.mcpConfigCopied`))},className:`btn-secondary shrink-0 px-2.5 py-1 text-xs`,children:e(`settings.mcpCopyConfig`)})]}),(0,W.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-lg bg-[var(--c-bg)] p-3 text-xs text-[var(--c-text-muted)]`,children:`{
|
|
102
|
+
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Nf=o((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||(e.color={});let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Pf=o((e=>{var t=Nf();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o!==void 0||i&&i.getContext||(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i!==void 0||n&&n.getContext||(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Ff=o((e=>{var t=Nf();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
103
|
+
`;return typeof a==`function`&&a(null,p),p}})),If=c(o((e=>{var t=lf(),n=Mf(),r=Pf(),i=Ff();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function Lf({status:e,onSuccess:t,onCancel:n}){let{t:r}=z(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),g=(0,_.useRef)(null);(0,_.useEffect)(()=>{g.current?.focus()},[]);async function v(){p(!0),h(``);try{t(await Nu())}catch{h(r(`security.passkeyCancelled`))}finally{p(!1)}}async function y(e){if(e.preventDefault(),i.trim()||c.trim()){p(!0),h(``);try{t((await Mu(u?`/reauth/email/confirm`:`/reauth`,{password:i,code:o,emailCode:c})).reauthToken)}catch{h(r(`security.invalidCredentials`))}finally{p(!1)}}}async function b(){p(!0),h(``);try{await Mu(`/reauth/email`,{}),d(!0)}catch{h(r(`security.failed`))}finally{p(!1)}}return typeof document>`u`?null:(0,es.createPortal)((0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,W.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-xs animate-fade-in`,onClick:f?void 0:n,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{className:`relative z-10 w-full max-w-md rounded-2xl border border-[var(--c-border)] bg-[var(--c-surface)] p-6 shadow-2xl animate-scale-in`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`reauth-modal-title`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 mb-2`,children:[(0,W.jsx)(`h2`,{id:`reauth-modal-title`,className:`text-lg font-bold text-[var(--c-text)]`,children:r(`security.confirmTitle`)}),(0,W.jsx)(`button`,{type:`button`,onClick:n,disabled:f,className:`text-[var(--c-text-muted)] hover:text-[var(--c-text)] p-1 rounded-lg`,"aria-label":r(`security.cancel`),children:(0,W.jsx)(`svg`,{className:`w-5 h-5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)] mb-5`,children:r(`security.reauth`)}),m&&(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--c-danger)] mb-4 p-2.5 rounded-lg bg-[var(--c-danger-bg)] border border-[var(--c-danger-border)]`,children:m}),e.passkeys.length>0&&(0,W.jsxs)(`div`,{className:`mb-5`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`btn-primary w-full flex items-center justify-center gap-2 py-2.5 font-medium`,onClick:v,disabled:f,children:[(0,W.jsxs)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,W.jsx)(`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`}),(0,W.jsx)(`path`,{d:`m21 2-9.6 9.6M15.5 7.5l3 3M18.5 4.5l3 3`})]}),r(`security.usePasskey`)]}),(0,W.jsxs)(`div`,{className:`relative my-4 flex items-center justify-center`,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,W.jsx)(`div`,{className:`w-full border-t border-[var(--c-border)]`})}),(0,W.jsx)(`span`,{className:`relative bg-[var(--c-surface)] px-3 text-xs uppercase tracking-wider text-[var(--c-text-muted)]`,children:r(`security.orPassword`)})]})]}),(0,W.jsxs)(`form`,{onSubmit:y,className:`flex flex-col gap-3`,children:[!u&&(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-[var(--c-text-muted)]`,children:[r(`security.password`),(0,W.jsx)(`input`,{ref:g,className:`input text-sm text-[var(--c-text)]`,type:`password`,autoComplete:`current-password`,disabled:f,value:i,onChange:e=>a(e.target.value),placeholder:r(`security.password`),"aria-label":r(`security.password`),required:!e.emailReauthEnabled})]}),e.totpEnabled&&(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-[var(--c-text-muted)]`,children:[r(`security.code`),(0,W.jsx)(`input`,{className:`input text-sm text-[var(--c-text)]`,autoComplete:`one-time-code`,inputMode:`numeric`,disabled:f,value:o,onChange:e=>s(e.target.value),placeholder:r(`security.code`),"aria-label":r(`security.code`)})]}),e.emailReauthEnabled&&!u&&(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary self-start text-xs`,disabled:f,onClick:b,children:r(`security.sendEmail`)}),u&&(0,W.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-[var(--c-text-muted)]`,children:[r(`security.emailCode`),(0,W.jsx)(`input`,{ref:g,className:`input text-sm text-[var(--c-text)]`,autoComplete:`one-time-code`,inputMode:`numeric`,disabled:f,value:c,onChange:e=>l(e.target.value),placeholder:r(`security.emailCode`),"aria-label":r(`security.emailCode`),required:!0})]}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2.5 mt-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary text-sm`,onClick:n,disabled:f,children:r(`security.cancel`)}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary text-sm`,disabled:f||!i.trim()&&!c.trim(),children:r(`security.confirmAction`)})]})]})]})]}),document.body)}function Rf(){let{t:e}=z(),[t,n]=(0,_.useState)(),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(null),b=async()=>{let e=await Mu(`/`,void 0,`GET`);n(e)};(0,_.useEffect)(()=>{b().catch(()=>f(e(`security.failed`)))},[e]);function x(){return new Promise((e,t)=>{y({resolve:e,reject:t})})}function S(e){let t=v;y(null),t&&t.resolve(e)}function C(){let e=v;y(null),e&&e.reject(Error(`cancelled`))}async function w(t,n){f(``),m(``);let r;try{r=await x()}catch{return}g(!0);let i=!1;try{await t(r),i=!0,n&&m(e(n)),await b()}catch(t){f(e(i?`security.refreshFailed`:t instanceof Error&&t.message===`last_passkey`?`security.lastPasskey`:`security.failed`))}finally{g(!1)}}return t?(0,W.jsxs)(nf,{title:e(`security.title`),description:e(`security.intro`),children:[p&&(0,W.jsx)(`div`,{className:`px-5 pt-3 pb-1 sm:px-6`,children:(0,W.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2.5 rounded-xl border border-[var(--c-success-border)] bg-[var(--c-success-bg)] px-3.5 py-2.5 text-sm font-medium text-[var(--c-green3)]`,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z`,clipRule:`evenodd`})}),(0,W.jsx)(`span`,{children:p})]})}),d&&(0,W.jsx)(`div`,{className:`px-5 pt-3 pb-1 sm:px-6`,children:(0,W.jsxs)(`p`,{role:`alert`,className:`flex items-center gap-2.5 rounded-xl border border-[var(--c-danger-border)] bg-[var(--c-danger-bg)] px-3.5 py-2.5 text-sm font-medium text-[var(--c-danger)]`,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-8-5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-4.5A.75.75 0 0 1 10 5Zm0 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z`,clipRule:`evenodd`})}),(0,W.jsx)(`span`,{children:d})]})}),(0,W.jsxs)(af,{children:[(0,W.jsx)(`h3`,{className:`font-semibold mb-3`,children:e(`security.passkeys`)}),!!t.passkeys.length&&(0,W.jsx)(`ul`,{className:`mb-4 divide-y divide-[var(--c-border)] rounded-xl border border-[var(--c-border)]`,children:t.passkeys.map(t=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere] text-sm font-medium`,children:t.name}),(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary shrink-0 text-sm`,disabled:h,"aria-label":e(`security.removeNamed`,{name:t.name}),onClick:()=>void w(async e=>{await Mu(`/passkeys/${encodeURIComponent(t.id)}`,{reauthToken:e},`DELETE`)},`security.passkeyRemoved`),children:e(`security.remove`)})]},t.id))}),t.passkeysEnabled?(0,W.jsxs)(`form`,{className:`grid grid-cols-1 items-end gap-3 sm:grid-cols-[minmax(0,1fr)_auto]`,onSubmit:e=>{if(e.preventDefault(),!h&&r.trim()){let e=r.trim();w(async t=>{await Pu(t,e),i(``)},`security.passkeyAdded`)}},children:[(0,W.jsxs)(`label`,{className:`min-w-0 text-sm font-medium`,children:[e(`security.passkeyName`),(0,W.jsx)(`input`,{className:`input mt-2`,value:r,maxLength:100,disabled:h,onChange:e=>i(e.target.value),placeholder:e(`security.passkeyName`),"aria-label":e(`security.passkeyName`)})]}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary whitespace-nowrap`,disabled:h||!r.trim(),children:e(`security.addPasskey`)})]}):(0,W.jsx)(`p`,{children:e(`security.httpsRequired`)})]}),(0,W.jsxs)(af,{children:[(0,W.jsx)(`h3`,{className:`font-semibold mb-3`,children:e(`security.twoFactor`)}),(0,W.jsx)(`p`,{className:`text-sm mb-3`,children:e(t.totpEnabled?`security.enabled`:`security.disabled`)}),(0,W.jsx)(`p`,{className:`text-sm mb-3`,children:e(`security.revocationHint`)}),!s&&(0,W.jsx)(`button`,{className:`btn-secondary`,disabled:h||l.length>0,onClick:()=>void w(async e=>{if(t.totpEnabled)await Mu(`/totp/disable`,{reauthToken:e});else{let t=await Mu(`/totp/setup`,{reauthToken:e});c({...t,qr:await If.toDataURL(t.uri)})}},t.totpEnabled?`security.updated`:`security.authenticatorStarted`),children:e(t.totpEnabled?`security.disable`:`security.enable`)}),s&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 mt-3`,children:[(0,W.jsx)(`p`,{children:e(`security.scan`)}),(0,W.jsx)(`img`,{src:s.qr,alt:e(`security.qrAlt`),width:200,height:200}),(0,W.jsx)(`code`,{className:`break-all select-all`,children:s.secret}),(0,W.jsx)(`input`,{className:`input`,value:a,autoComplete:`one-time-code`,inputMode:`numeric`,onChange:e=>o(e.target.value),"aria-label":e(`security.code`),placeholder:e(`security.code`)}),(0,W.jsxs)(`div`,{className:`flex gap-3`,children:[(0,W.jsx)(`button`,{className:`btn-primary`,disabled:h,onClick:async()=>{g(!0),f(``);try{let t=await Mu(`/totp/confirm`,{challengeId:s.challengeId,code:a});u(t.recoveryCodes),c(void 0),o(``),m(e(`security.updated`)),await b()}catch{f(e(`security.failed`))}finally{g(!1)}},children:e(`security.confirm`)}),(0,W.jsx)(`button`,{className:`btn-secondary`,disabled:h,onClick:()=>{c(void 0),o(``)},children:e(`security.cancel`)})]})]}),t.totpEnabled&&!l.length&&(0,W.jsx)(`button`,{className:`btn-secondary ml-3`,disabled:h,onClick:()=>void w(async e=>{let t=await Mu(`/recovery-codes`,{reauthToken:e});u(t.recoveryCodes)}),children:e(`security.newRecovery`)}),!!l.length&&(0,W.jsxs)(`div`,{className:`mt-4`,role:`status`,children:[(0,W.jsx)(`p`,{className:`mb-3`,children:e(`security.saveRecovery`)}),(0,W.jsx)(`pre`,{className:`select-all whitespace-pre-wrap`,children:l.join(`
|
|
104
|
+
`)}),(0,W.jsx)(`button`,{className:`btn-secondary mt-3`,onClick:()=>u([]),children:e(`security.saved`)})]})]}),v&&(0,W.jsx)(Lf,{status:t,onSuccess:S,onCancel:C})]}):d?(0,W.jsx)(`p`,{role:`alert`,children:d}):null}function zf(){let{t:e}=z(),{user:t,setCurrentUser:n}=lo(),[r,i]=(0,_.useState)(t?.display_name??``),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),d=(0,_.useRef)(null);if(!t)return null;let f=r.trim();async function p(t){t.preventDefault(),u(null),o(!0);try{let t=await U.updateProfile(f);n(t),i(t.display_name),u({type:`success`,text:e(`settings.profileSaved`)})}catch{u({type:`error`,text:e(`common.error`)})}finally{o(!1)}}async function m(t){let r=t.target.files?.[0];if(t.target.value=``,r){u(null),c(!0);try{n(await U.uploadAvatar(await tf(r)))}catch(t){u({type:`error`,text:t instanceof va?e(`common.error`):e(`settings.avatarUnreadable`)})}finally{c(!1)}}}async function h(){u(null),c(!0);try{n(await U.deleteAvatar())}catch{u({type:`error`,text:e(`common.error`)})}finally{c(!1)}}return(0,W.jsxs)(nf,{title:e(`settings.profileTitle`),children:[(0,W.jsxs)(af,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsx)(ql,{user:t,className:`h-16 w-16 text-xl transition-opacity ${s?`opacity-50`:``}`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate font-semibold`,children:t.display_name||t.email}),(0,W.jsx)(`p`,{className:`truncate text-sm text-[var(--c-text-muted)]`,children:t.email}),(0,W.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary px-3 py-1.5 text-sm`,disabled:s,onClick:()=>d.current?.click(),children:t.avatar_updated_at?e(`settings.avatarChange`):e(`settings.avatarUpload`)}),t.avatar_updated_at&&(0,W.jsx)(`button`,{type:`button`,className:`btn-secondary px-3 py-1.5 text-sm text-danger`,disabled:s,onClick:h,children:e(`settings.avatarRemove`)})]})]}),(0,W.jsx)(`input`,{ref:d,type:`file`,accept:`image/*`,className:`hidden`,onChange:m})]}),(0,W.jsx)(`p`,{className:`mt-3 text-xs text-[var(--c-text-muted)]`,children:e(`settings.avatarHint`)})]}),(0,W.jsx)(`form`,{onSubmit:p,children:(0,W.jsxs)(rf,{label:e(`settings.displayNameLabel`),htmlFor:`profile-name`,stacked:!0,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,W.jsx)(`input`,{id:`profile-name`,className:`input sm:max-w-sm`,required:!0,maxLength:100,autoComplete:`name`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,disabled:a||!f||f===t.display_name,className:`btn-primary self-start`,children:e(`common.save`)})]}),(0,W.jsx)(`div`,{className:`mt-2`,children:(0,W.jsx)(sf,{message:l})})]})})]})}function Bf(){let{t:e}=z(),[t,n]=(0,_.useState)(``),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(!1);async function d(s){if(s.preventDefault(),c(null),r!==a)c({type:`error`,text:e(`settings.passwordMismatch`)});else{u(!0);try{await U.changePassword(t,r),c({type:`success`,text:e(`settings.passwordChanged`)}),n(``),i(``),o(``)}catch(t){c({type:`error`,text:t instanceof va&&t.status===401?e(`settings.incorrectPassword`):e(`common.error`)})}finally{u(!1)}}}return(0,W.jsx)(`form`,{onSubmit:d,children:(0,W.jsx)(nf,{title:e(`settings.changePasswordTitle`),description:e(`settings.passwordHint`),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(sf,{message:s}),(0,W.jsx)(`button`,{type:`submit`,disabled:l,className:`btn-primary`,children:e(`settings.changePasswordButton`)})]}),children:(0,W.jsx)(af,{children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(`input`,{type:`password`,required:!0,autoComplete:`current-password`,placeholder:e(`settings.currentPasswordLabel`),"aria-label":e(`settings.currentPasswordLabel`),className:`input`,value:t,onChange:e=>n(e.target.value)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,autoComplete:`new-password`,placeholder:e(`settings.newPasswordLabel`),"aria-label":e(`settings.newPasswordLabel`),className:`input`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,autoComplete:`new-password`,placeholder:e(`settings.confirmPasswordLabel`),"aria-label":e(`settings.confirmPasswordLabel`),className:`input`,value:a,onChange:e=>o(e.target.value)})]})})})})}function $(){let{user:e}=lo(),t=dl(bl()),[n,r]=(0,_.useState)(null);return(0,_.useEffect)(()=>{let n=!0;if(r(null),t&&e)return Promise.resolve(!t.applies||t.applies({id:e.id,email:e.email,display_name:e.display_name??null})).then(e=>{n&&r(e===!0)}).catch(()=>{n&&r(!1)}),()=>{n=!1}},[t?.mount,t?.applies,e?.id]),t?n===null?null:n?(0,W.jsx)(Iu,{name:`password-card`,mount:t.mount}):(0,W.jsx)(Bf,{}):(0,W.jsx)(Bf,{})}function Vf(){return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(zf,{}),(0,W.jsx)($,{}),(0,W.jsx)(Rf,{})]})}var Hf=[{value:`de`,label:`Deutsch`},{value:`en`,label:`English`},{value:`ja`,label:`日本語`},{value:`ru`,label:`Русский`}];function Uf(){let{t:e,i18n:t}=z();return(0,W.jsx)(Vu,{value:t.resolvedLanguage??`de`,onChange:e=>{Rt(e),t.changeLanguage(e)},options:Hf,className:`w-44`,ariaLabel:e(`settings.language`)})}function Wf(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(Pl,Fl),n=[{value:`light`,label:e(`settings.themeLight`)},{value:`dark`,label:e(`settings.themeDark`)},{value:`system`,label:e(`settings.themeSystem`)}];return(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-1 rounded-xl border border-[var(--c-border)] p-0.5`,role:`group`,"aria-label":e(`settings.theme`),children:n.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>Il(e.value),"aria-pressed":t===e.value,className:`h-8 rounded-lg px-3 text-sm font-medium transition-colors cursor-pointer ${t===e.value?`border border-[var(--c-mobile-nav-active-border)] bg-[var(--c-mobile-nav-active)] text-[var(--c-text)] shadow-sm`:`text-[var(--c-text-muted)] hover:text-[var(--c-text)]`}`,children:e.label},e.value))})}function Gf(){let{t:e}=z(),t=(0,_.useSyncExternalStore)(Ul,Wl);return t===`installed`||t===`unsupported`?null:(0,W.jsx)(rf,{label:e(`settings.installApp`),hint:e(t===`ios`?`settings.installAppIos`:t===`mac-safari`?`settings.installAppMacSafari`:`settings.installAppHint`),children:t===`prompt`&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>void Gl(),className:`btn-primary whitespace-nowrap`,children:e(`settings.installAppButton`)})})}function Kf(){let{t:e,i18n:t}=z(),n=(0,_.useSyncExternalStore)(Ul,Wl),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{Ya().then(i).catch(()=>i(`unsupported`))},[]),r===null)return(0,W.jsx)(rf,{label:e(`settings.notifications`)});if(r===`unsupported`){let t=e(n===`ios`?`settings.notificationsIos`:`settings.notificationsUnsupported`);return(0,W.jsx)(rf,{label:e(`settings.notifications`),hint:t})}async function s(t){o(!0);try{t?i(await Za()):(await Qa(),i(`off`))}catch{J.error(e(`common.error`))}finally{o(!1)}}async function c(){try{let{delivered:n}=await U.sendTestPush(t.resolvedLanguage??`en`);n===0&&J.error(e(`settings.notificationsTestFailed`))}catch{J.error(e(`common.error`))}}return(0,W.jsx)(rf,{label:e(`settings.notifications`),hint:e(r===`blocked`?`settings.notificationsBlocked`:`settings.notificationsHint`),htmlFor:`notifications-toggle`,inline:!0,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r===`on`&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>void c(),className:`btn-secondary px-3 py-1.5 text-sm`,children:e(`settings.notificationsTest`)}),(0,W.jsx)(of,{id:`notifications-toggle`,label:e(`settings.notifications`),checked:r===`on`,onChange:e=>!a&&r!==`blocked`&&void s(e)})]})})}function qf(){let{t:e}=z(),[t,n]=(0,_.useState)(da),[r,i]=(0,_.useState)(null);(0,_.useEffect)(()=>{pa().then(e=>i(e?ga(e).length:null))},[t]);async function a(e){if(n(e),fa(e),!e){await Va(),i(null);return}let t=await Ba({force:!0});t!==null&&i(t)}return(0,W.jsx)(rf,{label:e(`settings.offlineSaved`),hint:`${e(`settings.offlineSavedHint`)}${t&&r!==null?` ${e(`settings.offlineSavedCount`,{count:r})}`:``}`,htmlFor:`offline-saved-toggle`,inline:!0,children:(0,W.jsx)(of,{id:`offline-saved-toggle`,label:e(`settings.offlineSaved`),checked:t,onChange:e=>void a(e)})})}function Jf(){let{t:e}=z(),[t,n]=(0,_.useState)(()=>localStorage.getItem(`feedkeeper_auto_reader_mode`)!==`false`);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(nf,{title:e(`settings.appearanceTitle`),children:[(0,W.jsx)(rf,{label:e(`settings.theme`),hint:e(`settings.themeHint`),children:(0,W.jsx)(Wf,{})}),(0,W.jsx)(rf,{label:e(`settings.language`),hint:e(`settings.languageHint`),children:(0,W.jsx)(Uf,{})})]}),(0,W.jsxs)(nf,{title:e(`settings.readingTitle`),children:[(0,W.jsx)(rf,{label:e(`settings.autoReaderMode`),hint:e(`settings.autoReaderModeHint`),htmlFor:`auto-reader-toggle`,inline:!0,children:(0,W.jsx)(of,{id:`auto-reader-toggle`,label:e(`settings.autoReaderMode`),checked:t,onChange:e=>{n(e),localStorage.setItem(`feedkeeper_auto_reader_mode`,e?`true`:`false`)}})}),(0,W.jsx)(qf,{}),(0,W.jsx)(Kf,{}),(0,W.jsx)(Gf,{})]})]})}function Yf(){let{t:e}=z(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null);(0,_.useEffect)(()=>{U.listMutedKeywords().then(e=>n(e.keywords)).catch(()=>{})},[]);async function l(t){if(t.preventDefault(),r.trim()){o(!0),c(null);try{let e=await U.addMutedKeyword(r.trim());n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),i(``)}catch{c(e(`common.error`))}finally{o(!1)}}}async function u(t){try{await U.deleteMutedKeyword(t),n(e=>e.filter(e=>e.id!==t))}catch{c(e(`common.error`))}}return(0,W.jsx)(nf,{title:e(`settings.mutedKeywordsTitle`),description:e(`settings.mutedKeywordsHint`),children:(0,W.jsxs)(af,{children:[(0,W.jsxs)(`form`,{onSubmit:l,className:`flex gap-2`,children:[(0,W.jsx)(`input`,{type:`text`,placeholder:e(`settings.mutedKeywordPlaceholder`),"aria-label":e(`settings.mutedKeywordPlaceholder`),className:`input flex-1`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`button`,{type:`submit`,disabled:a||!r.trim(),className:`btn-primary whitespace-nowrap`,children:e(`settings.addMutedKeyword`)})]}),s&&(0,W.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:s}),t.length>0?(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:t.map(t=>(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-[var(--c-border)] bg-[var(--c-bg)] py-1 pl-3 pr-1 text-sm`,children:[t.keyword,(0,W.jsx)(`button`,{type:`button`,onClick:()=>u(t.id),title:e(`settings.removeMutedKeyword`),"aria-label":`${e(`settings.removeMutedKeyword`)}: ${t.keyword}`,className:`flex h-6 w-6 items-center justify-center rounded-full text-[var(--c-text-muted)] hover:bg-[var(--c-danger-bg)] hover:text-[var(--c-danger)] cursor-pointer`,children:(0,W.jsx)(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]},t.id))}):(0,W.jsx)(`p`,{className:`mt-4 text-sm text-[var(--c-text-muted)]`,children:e(`settings.noMutedKeywords`)})]})})}function Xf({value:e}){let{t}=z(),[n,r]=(0,_.useState)(!1);return(0,W.jsx)(`button`,{type:`button`,onClick:async()=>{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)},className:`btn-secondary shrink-0 px-3 py-1.5 text-sm`,children:t(n?`settings.copied`:`settings.copyToken`)})}function Zf({scope:e}){let{t}=z();return(0,W.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${e===`write`?`bg-[var(--c-danger-bg)] text-[var(--c-danger)]`:`bg-[var(--c-mobile-nav-active)] text-[var(--c-text-muted)]`}`,children:t(e===`read`?`settings.tokenReadOnly`:`settings.tokenReadWrite`)})}function Qf(){let{t:e,i18n:t}=z(),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(`read`),[u,d]=(0,_.useState)(null),f=`${window.location.origin}/mcp`,p=new Intl.DateTimeFormat(t.resolvedLanguage,{dateStyle:`medium`});async function m(){let[e,t]=await Promise.all([U.listTokens(),U.listOAuthGrants()]);r(e),a(t)}(0,_.useEffect)(()=>{m()},[]);async function h(e){e.preventDefault();let{token:t}=await U.createToken(o,c);d(t),s(``),await m()}async function g(t){confirm(e(`settings.revokeTokenConfirm`,{name:t.name}))&&(await U.deleteToken(t.id),await m())}async function v(t){confirm(e(`settings.disconnectAppConfirm`,{name:t.client_name}))&&(await U.deleteOAuthGrant(t.id),await m())}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(nf,{title:e(`settings.mcpTitle`),description:e(`settings.mcpHint`),children:(0,W.jsxs)(af,{children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-[var(--c-border)] bg-[var(--c-bg)] py-1.5 pl-3 pr-1.5`,children:[(0,W.jsx)(`code`,{className:`min-w-0 flex-1 truncate text-sm`,children:f}),(0,W.jsx)(Xf,{value:f})]}),(0,W.jsxs)(`div`,{className:`mt-5 rounded-xl border border-[var(--c-green3)] p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:e(`settings.mcpOauthTitle`)}),(0,W.jsx)(`span`,{className:`rounded-full bg-[var(--c-mobile-nav-active)] px-2 py-0.5 text-xs font-medium`,children:e(`settings.mcpOauthBadge`)})]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:e(`settings.mcpOauthIntro`)}),(0,W.jsxs)(`ol`,{className:`mt-3 flex list-decimal flex-col gap-1 pl-5 text-sm text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`li`,{children:e(`settings.mcpOauthStep1`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpOauthStep2`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpOauthStep3`)})]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm text-[var(--c-text-muted)]`,children:e(`settings.mcpOauthDone`)})]}),(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-[var(--c-border)] p-4`,children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:e(`settings.mcpTokenTitle`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-[var(--c-text-muted)]`,children:e(`settings.mcpTokenIntro`)}),(0,W.jsxs)(`ol`,{className:`mt-3 flex list-decimal flex-col gap-1 pl-5 text-sm text-[var(--c-text-muted)]`,children:[(0,W.jsx)(`li`,{children:e(`settings.mcpStepToken`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpStepUrl`)}),(0,W.jsx)(`li`,{children:e(`settings.mcpStepHeader`)})]}),(0,W.jsxs)(`div`,{className:`mt-5 border-t border-[var(--c-border)] pt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-[var(--c-text-muted)]`,children:e(`settings.mcpClaudeTitle`)}),(0,W.jsx)(`button`,{type:`button`,onClick:async()=>{let t=JSON.stringify({mcpServers:{feedkeeper:{url:f,headers:{Authorization:`Bearer ${u??`<YOUR_TOKEN>`}`}}}},null,2);await navigator.clipboard.writeText(t),alert(e(`settings.mcpConfigCopied`))},className:`btn-secondary shrink-0 px-2.5 py-1 text-xs`,children:e(`settings.mcpCopyConfig`)})]}),(0,W.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-lg bg-[var(--c-bg)] p-3 text-xs text-[var(--c-text-muted)]`,children:`{
|
|
105
105
|
"mcpServers": {
|
|
106
106
|
"feedkeeper": {
|
|
107
107
|
"url": "${f}",
|
|
@@ -110,4 +110,4 @@ Minimum version required to store current data is: `+c+`.
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
}`})]})]})]})}),(0,W.jsx)(tf,{title:e(`settings.connectedAppsTitle`),description:e(`settings.connectedAppsHint`),children:i.length===0?(0,W.jsx)(rf,{children:(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`settings.noConnectedApps`)})}):i.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate font-medium`,children:n.client_name}),(0,W.jsx)(Xf,{scope:n.scope})]}),(0,W.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[e(`settings.tokenCreatedOn`,{date:p.format(new Date(n.created_at))}),` · `,n.last_used_at?e(`settings.tokenLastUsed`,{time:Gu(new Date(n.last_used_at),t.resolvedLanguage)}):e(`settings.tokenNeverUsed`)]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>v(n),className:`btn-secondary shrink-0 px-3 py-1.5 text-sm hover:text-[var(--c-danger)]`,children:e(`settings.disconnectApp`)})]},n.id))}),(0,W.jsxs)(tf,{title:e(`settings.tokensTitle`),description:e(`settings.tokensHint`),children:[u&&(0,W.jsx)(rf,{children:(0,W.jsxs)(`div`,{className:`rounded-xl border border-[var(--c-green3)] p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.tokenCreated`)}),(0,W.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,W.jsx)(`code`,{className:`min-w-0 flex-1 break-all text-xs`,children:u}),(0,W.jsx)(Yf,{value:u})]}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-[var(--c-text-muted)]`,children:e(`settings.tokenCreatedHint`)})]})}),(0,W.jsx)(rf,{children:(0,W.jsxs)(`form`,{onSubmit:h,className:`flex flex-col gap-3 sm:flex-row`,children:[(0,W.jsx)(`input`,{type:`text`,required:!0,placeholder:e(`settings.tokenNamePlaceholder`),"aria-label":e(`settings.tokenNamePlaceholder`),className:`input sm:flex-1`,value:o,onChange:e=>s(e.target.value)}),(0,W.jsx)(Vu,{value:c,onChange:e=>l(e),options:[{value:`read`,label:e(`settings.tokenReadOnly`)},{value:`write`,label:e(`settings.tokenReadWrite`)}],className:`sm:w-48`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary whitespace-nowrap`,children:e(`settings.createToken`)})]})}),n.length===0?(0,W.jsx)(rf,{children:(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`settings.noTokens`)})}):n.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate font-medium`,children:n.name}),(0,W.jsx)(Xf,{scope:n.scope})]}),(0,W.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[(0,W.jsxs)(`code`,{children:[n.token_prefix,`…`]}),` · `,e(`settings.tokenCreatedOn`,{date:p.format(new Date(n.created_at))}),` · `,n.last_used_at?e(`settings.tokenLastUsed`,{time:Gu(new Date(n.last_used_at),t.resolvedLanguage)}):e(`settings.tokenNeverUsed`)]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>g(n),className:`btn-secondary shrink-0 px-3 py-1.5 text-sm hover:text-[var(--c-danger)]`,children:e(`settings.deleteToken`)})]},n.id))]})]})}function Qf({pairing:e,onDone:t}){let{t:n}=z(),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(()=>Math.max(0,Math.round((new Date(e.expiresAt).getTime()-Date.now())/1e3)));(0,_.useEffect)(()=>{let t=!1;return Ff.toDataURL(e.pairingUrl,{margin:1,width:224,errorCorrectionLevel:`M`}).then(e=>{t||i(e)}),()=>{t=!0}},[e.pairingUrl]),(0,_.useEffect)(()=>{let t=window.setInterval(()=>o(Math.max(0,Math.round((new Date(e.expiresAt).getTime()-Date.now())/1e3))),1e3);return()=>window.clearInterval(t)},[e.expiresAt]);let s=a===0;return(0,W.jsx)(rf,{children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center sm:flex-row sm:items-start sm:gap-6 sm:text-left`,children:[r&&(0,W.jsx)(`img`,{src:r,alt:n(`settings.deviceQrAlt`),width:224,height:224,className:`rounded-xl bg-white p-1 ${s?`opacity-30`:``}`}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:n(`settings.devicePairHint`)}),(0,W.jsx)(`code`,{className:`select-all rounded-lg border border-[var(--c-border)] bg-[var(--c-bg)] px-3 py-2 text-lg tracking-widest`,children:e.code}),(0,W.jsx)(`p`,{className:`text-xs text-[var(--c-text-muted)]`,role:`status`,children:s?n(`settings.devicePairExpired`):n(`settings.devicePairExpires`,{minutes:Math.floor(a/60),seconds:String(a%60).padStart(2,`0`)})}),(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn-secondary self-center px-3 py-1.5 text-sm sm:self-start`,children:n(`settings.devicePairDone`)})]})]})})}function $f(){let{t:e,i18n:t}=z(),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1);async function c(){let e=await U.listDevices().catch(()=>null);e&&r(t=>(e.length>t.length&&t.length>=0&&a(null),e))}(0,_.useEffect)(()=>{c();let e=window.setInterval(()=>void c(),5e3);return()=>window.clearInterval(e)},[]);async function l(){s(!0);try{a(await U.createPairingCode())}catch{J.error(e(`common.error`))}finally{s(!1)}}async function u(t){confirm(e(`settings.deviceRevokeConfirm`,{name:t.name}))&&(await U.revokeDevice(t.id),await c())}return(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,W.jsxs)(tf,{title:e(`settings.devicesTitle`),description:e(`settings.devicesHint`),footer:(0,W.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void l(),className:`btn-primary`,children:e(`settings.deviceAdd`)}),children:[i&&(0,W.jsx)(Qf,{pairing:i,onDone:()=>{a(null),c()}}),n.length===0?(0,W.jsx)(rf,{children:(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`settings.noDevices`)})}):n.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate font-medium`,children:n.name}),(0,W.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[[n.platform,n.appVersion&&`v${n.appVersion}`].filter(Boolean).join(` · `),` · `,n.lastUsedAt?e(`settings.tokenLastUsed`,{time:Gu(new Date(n.lastUsedAt),t.resolvedLanguage)}):e(`settings.tokenNeverUsed`)]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void u(n),className:`btn-secondary shrink-0 px-3 py-1.5 text-sm hover:text-[var(--c-danger)]`,children:e(`settings.deviceRevoke`)})]},n.id))]})})}function ep(){let{t:e}=z(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`user`),[d,f]=(0,_.useState)(null);async function p(){n(await U.listUsers())}(0,_.useEffect)(()=>{p()},[]);async function m(t){t.preventDefault(),f(null);try{await U.createUser({email:r,password:s,displayName:a,role:l}),i(``),o(``),c(``),u(`user`),f({type:`success`,text:e(`settings.userCreated`)}),await p()}catch{f({type:`error`,text:e(`common.error`)})}}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(tf,{title:e(`settings.usersTitle`),children:t.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsx)(ql,{user:t,className:`h-9 w-9 text-xs`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate font-medium`,children:t.display_name}),(0,W.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:t.email})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium ${t.role===`admin`?`bg-[var(--c-blue1)] text-white`:`bg-[var(--c-mobile-nav-active)] text-[var(--c-text-muted)]`}`,children:t.role===`admin`?e(`settings.roleAdmin`):e(`settings.roleUser`)})]},t.id))}),(0,W.jsx)(`form`,{onSubmit:m,children:(0,W.jsx)(tf,{title:e(`settings.addUser`),description:e(`settings.addUserHint`),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(of,{message:d}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary`,children:e(`settings.addUser`)})]}),children:(0,W.jsx)(rf,{children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(`input`,{type:`email`,required:!0,placeholder:e(`onboarding.emailLabel`),"aria-label":e(`onboarding.emailLabel`),className:`input`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`input`,{type:`text`,required:!0,placeholder:e(`onboarding.displayNameLabel`),"aria-label":e(`onboarding.displayNameLabel`),className:`input`,value:a,onChange:e=>o(e.target.value)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,autoComplete:`new-password`,placeholder:e(`onboarding.passwordLabel`),"aria-label":e(`onboarding.passwordLabel`),className:`input`,value:s,onChange:e=>c(e.target.value)}),(0,W.jsx)(Vu,{value:l,onChange:e=>u(e),options:[{value:`user`,label:e(`settings.roleUser`)},{value:`admin`,label:e(`settings.roleAdmin`)}],className:`w-full`})]})})})})]})}function tp(e){return e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function np({id:e,value:t,max:n,onChange:r}){return(0,W.jsx)(`input`,{id:e,type:`number`,min:0,max:n,className:`input w-28 text-right tabular-nums`,value:t,onChange:e=>r(Number(e.target.value))})}function rp(){let{t:e,i18n:t}=z(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(30),[o,s]=(0,_.useState)(90),[c,l]=(0,_.useState)(1e3),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),y=new Intl.NumberFormat(t.resolvedLanguage);(0,_.useEffect)(()=>{U.getRetention().then(e=>{r(e.stats),a(e.settings.retentionReadDays),s(e.settings.retentionMaxDays),l(e.settings.retentionMaxItemsPerFeed),d(e.settings.autoCleanupEnabled)}).catch(()=>{})},[]);async function b(t){t.preventDefault(),p(!0),v(null);try{let t=await U.updateRetention({retentionReadDays:i,retentionMaxDays:o,retentionMaxItemsPerFeed:c,autoCleanupEnabled:u});r(t.stats),v({type:`success`,text:e(`settings.retentionSaved`)})}catch{v({type:`error`,text:e(`common.error`)})}finally{p(!1)}}async function x(){h(!0),v(null);try{let t=await U.runCleanup();r(t.stats),v({type:`success`,text:e(`settings.cleanupSuccess`,{total:t.result.totalDeleted,before:(t.result.sizeBefore/1024/1024).toFixed(2),after:(t.result.sizeAfter/1024/1024).toFixed(2)})})}catch{v({type:`error`,text:e(`common.error`)})}finally{h(!1)}}let S=n?[{label:e(`settings.statTotalItems`),value:y.format(n.totalItems)},{label:e(`settings.statReadItems`),value:y.format(n.readItems)},{label:e(`settings.statFeedsCount`),value:y.format(n.feedsCount)},{label:e(`settings.statDbSize`),value:tp(n.databaseSizeBytes)}]:[];return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[S.length>0&&(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:S.map(e=>(0,W.jsxs)(`div`,{className:`card px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-xs text-[var(--c-text-muted)]`,children:e.label}),(0,W.jsx)(`p`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:e.value})]},e.label))}),(0,W.jsx)(`form`,{onSubmit:b,children:(0,W.jsxs)(tf,{title:e(`settings.retentionTitle`),description:e(`settings.retentionHint`),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(of,{message:g}),(0,W.jsx)(`button`,{type:`button`,disabled:m,onClick:x,className:`btn-secondary`,children:e(m?`settings.cleaning`:`settings.runCleanupNow`)}),(0,W.jsx)(`button`,{type:`submit`,disabled:f,className:`btn-primary`,children:e(`settings.saveRetention`)})]}),children:[(0,W.jsx)(nf,{label:e(`settings.autoCleanupLabel`),htmlFor:`auto-cleanup`,inline:!0,children:(0,W.jsx)(af,{id:`auto-cleanup`,label:e(`settings.autoCleanupLabel`),checked:u,onChange:d})}),(0,W.jsx)(nf,{label:e(`settings.retentionReadDaysLabel`),hint:e(`settings.retentionReadDaysHint`),htmlFor:`retention-read`,children:(0,W.jsx)(np,{id:`retention-read`,value:i,max:3650,onChange:a})}),(0,W.jsx)(nf,{label:e(`settings.retentionMaxDaysLabel`),hint:e(`settings.retentionMaxDaysHint`),htmlFor:`retention-max`,children:(0,W.jsx)(np,{id:`retention-max`,value:o,max:3650,onChange:s})}),(0,W.jsx)(nf,{label:e(`settings.retentionMaxItemsLabel`),hint:e(`settings.retentionMaxItemsHint`),htmlFor:`retention-items`,children:(0,W.jsx)(np,{id:`retention-items`,value:c,max:1e5,onChange:l})})]})})]})}var ip=e=>(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e}),ap=[`M4 6h16M4 12h16M4 18h10`],op=`(min-width: 768px)`;function sp(){return(0,_.useSyncExternalStore)(e=>{let t=window.matchMedia(op);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(op).matches,()=>!0)}function cp(){let{t:e}=z(),{user:t}=lo(),[n,r]=Li(),i=mr(),a=dr(),o=sp(),s=bl(),c=[{id:`account`,label:e(`settings.sectionAccount`),description:e(`settings.sectionAccountHint`),icon:ip((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,W.jsx)(`path`,{d:`M4 21a8 8 0 0 1 16 0`})]})),render:()=>(0,W.jsx)($,{})},{id:`general`,label:e(`settings.sectionGeneral`),description:e(`settings.sectionGeneralHint`),icon:ip((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})),render:()=>(0,W.jsx)(qf,{})},{id:`filters`,label:e(`settings.sectionFilters`),description:e(`settings.sectionFiltersHint`),icon:ip((0,W.jsx)(`path`,{d:`M3 5h18l-7 8v6l-4 2v-8Z`})),render:()=>(0,W.jsx)(Jf,{})},{id:`devices`,label:e(`settings.sectionDevices`),description:e(`settings.sectionDevicesHint`),icon:ip((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{x:`7`,y:`2`,width:`10`,height:`20`,rx:`2.5`}),(0,W.jsx)(`path`,{d:`M11 18h2`})]})),render:()=>(0,W.jsx)($f,{})},{id:`mcp`,label:e(`settings.sectionMcp`),description:e(`settings.sectionMcpHint`),icon:ip((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M9 7V3M15 7V3M6 7h12v4a6 6 0 0 1-12 0Z`}),(0,W.jsx)(`path`,{d:`M12 17v4`})]})),render:()=>(0,W.jsx)(Zf,{})},{id:`users`,label:e(`settings.sectionUsers`),description:e(`settings.sectionUsersHint`),icon:ip((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,W.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 7M21.5 20a6.5 6.5 0 0 0-4-6`})]})),admin:!0,render:()=>(0,W.jsx)(ep,{})},{id:`database`,label:e(`settings.sectionDatabase`),description:e(`settings.sectionDatabaseHint`),icon:ip((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,W.jsx)(`path`,{d:`M4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3`})]})),admin:!0,render:()=>(0,W.jsx)(rp,{})}],l=t?.role===`admin`,{hidden:u,sections:d}=al(s,c.map(e=>e.id),l),f=d.map(e=>({id:e.id,label:e.label,description:e.description,group:e.group,icon:ip((0,W.jsx)(W.Fragment,{children:(e.icon??ap).map(e=>(0,W.jsx)(`path`,{d:e},e))})),render:()=>(0,W.jsx)(Iu,{name:`settings-${e.id}`,mount:e.mount})})),p=[...c.filter(e=>!u.has(e.id)&&(!e.admin||l)),...f],m=p.find(e=>e.id===n.get(`tab`)),h=m??p[0],g=e=>{r(e===p[0].id?{}:{tab:e},{replace:!0}),window.scrollTo({top:0})},v=e=>{i({search:`?tab=${encodeURIComponent(e)}`},{state:{fromList:!0}}),window.scrollTo({top:0})},y=()=>{a.state?.fromList?i(-1):i({search:``},{replace:!0}),window.scrollTo({top:0})},b=e=>{let t=e.id===h.id;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),"aria-current":t?`page`:void 0,className:`inline-flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors cursor-pointer focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${t?`bg-[var(--c-mobile-nav-active)] text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)]`}`,children:[e.icon,e.label]},e.id)},x=e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>v(e.id),className:`flex w-full items-center gap-3.5 px-4 py-3.5 text-left cursor-pointer transition-colors hover:bg-[var(--c-surface-hover)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)]`,children:[(0,W.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)]`,children:e.icon}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-[var(--c-text)]`,children:e.label}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs leading-snug text-[var(--c-text-muted)]`,children:e.description})]}),(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id),S=p.filter(e=>e.admin&&!e.group),C=ol(f),w=`mt-5 mb-1 px-3 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,T=[{key:`main`,sections:p.filter(e=>!e.admin&&!e.group)},...S.length>0?[{key:`admin`,heading:e(`settings.adminGroup`),sections:S}]:[],...C.map(({group:e,sections:t})=>({key:e,heading:e,sections:t}))];return o?(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`settings.title`)}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[13rem_minmax(0,1fr)] gap-10`,children:[(0,W.jsxs)(`nav`,{className:`sticky top-24 flex flex-col gap-0.5 self-start`,"aria-label":e(`settings.title`),children:[p.filter(e=>!e.admin&&!e.group).map(b),S.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:w,children:e(`settings.adminGroup`)}),S.map(b)]}),C.map(({group:e,sections:t})=>(0,W.jsxs)(_.Fragment,{children:[(0,W.jsx)(`p`,{className:w,children:e}),t.map(b)]},e))]}),(0,W.jsxs)(`div`,{className:`min-w-0 animate-page-fade`,children:[(0,W.jsx)(sf,{title:h.label,description:h.description}),h.render(),(0,W.jsx)(Yl,{placement:`page`})]},h.id)]})]}):m?(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:y,className:`-ml-1 inline-flex w-fit items-center gap-1 rounded-lg px-1 py-1 text-sm font-medium text-[var(--c-text-muted)] cursor-pointer hover:text-[var(--c-text)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)]`,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`m15 6-6 6 6 6`})}),e(`settings.title`)]}),(0,W.jsxs)(`div`,{className:`min-w-0 animate-page-fade`,children:[(0,W.jsx)(sf,{title:m.label,description:m.description}),m.render(),(0,W.jsx)(Yl,{placement:`page`})]},m.id)]}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`settings.title`)}),(0,W.jsx)(`nav`,{className:`flex flex-col gap-6`,"aria-label":e(`settings.title`),children:T.map(t=>(0,W.jsxs)(`section`,{"aria-label":t.heading??e(`settings.title`),children:[t.heading&&(0,W.jsx)(`h2`,{className:`mb-2 px-1 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t.heading}),(0,W.jsx)(`ul`,{className:`card divide-y divide-[var(--c-border)] overflow-hidden p-0`,children:t.sections.map(x)})]},t.key))})]})}function lp(){return document.getElementById(`splash`)?.classList.contains(`splash-hidden`)===!1}function up(){let e=document.getElementById(`splash`);if(!e||e.classList.contains(`splash-hidden`))return;e.classList.add(`splash-hidden`);let t=()=>e.remove();e.addEventListener(`transitionend`,t,{once:!0}),window.setTimeout(t,500)}function dp(){let{t:e,i18n:t}=z(),n=gl(bl(),t.resolvedLanguage||`en`);return(0,_.useLayoutEffect)(()=>{document.documentElement.lang=t.resolvedLanguage||`en`,window.dispatchEvent(new Event($c))},[t.resolvedLanguage]),(0,_.useEffect)(()=>{let t=n.title??e(`common.metaTitle`),r=n.description??e(`common.metaDescription`);document.title=t;let i=document.querySelector(`meta[name="description"]`);i&&i.setAttribute(`content`,r);let a=document.querySelector(`meta[property="og:title"]`);a&&a.setAttribute(`content`,t);let o=document.querySelector(`meta[property="og:description"]`);o&&o.setAttribute(`content`,r);let s=document.querySelector(`meta[name="twitter:title"]`);s&&s.setAttribute(`content`,t);let c=document.querySelector(`meta[name="twitter:description"]`);c&&c.setAttribute(`content`,r)},[t.resolvedLanguage,e,n.title,n.description]),null}function fp({children:e}){let{user:t,loading:n,needsOnboarding:r,unreachable:i}=lo();return(0,_.useEffect)(()=>{n||up()},[n]),n?lp()?null:(0,W.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-[var(--c-bg)] z-50`,children:(0,W.jsx)(Ru,{size:`lg`,center:!1})}):i?(0,W.jsx)(nu,{}):r?(0,W.jsx)(hu,{}):t?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(Lu,{})}function pp(){return(0,_.useEffect)(()=>{`scrollRestoration`in window.history&&(window.history.scrollRestoration=`manual`)},[]),(0,W.jsxs)(Ai,{children:[(0,W.jsx)(dp,{}),(0,W.jsx)(co,{children:(0,W.jsx)(fo,{children:(0,W.jsx)(fp,{children:(0,W.jsx)(Wr,{children:(0,W.jsxs)(Hr,{element:(0,W.jsx)(mu,{}),children:[(0,W.jsx)(Hr,{index:!0,element:(0,W.jsx)(Br,{to:`/items`,replace:!0})}),(0,W.jsx)(Hr,{path:`/items`,element:(0,W.jsx)(Qd,{})}),(0,W.jsx)(Hr,{path:`/feeds`,element:(0,W.jsx)(wd,{})}),(0,W.jsx)(Hr,{path:`/settings`,element:(0,W.jsx)(cp,{})}),(0,W.jsx)(Hr,{path:`/extensions/:pageId`,element:(0,W.jsx)(xl,{})}),(0,W.jsx)(Hr,{path:`*`,element:(0,W.jsx)(Br,{to:`/items`,replace:!0})})]})})})})})]})}Hl(),io(),(0,v.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(_.StrictMode,{children:(0,W.jsx)(pp,{})}));
|
|
113
|
+
}`})]})]})]})}),(0,W.jsx)(nf,{title:e(`settings.connectedAppsTitle`),description:e(`settings.connectedAppsHint`),children:i.length===0?(0,W.jsx)(af,{children:(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`settings.noConnectedApps`)})}):i.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate font-medium`,children:n.client_name}),(0,W.jsx)(Zf,{scope:n.scope})]}),(0,W.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[e(`settings.tokenCreatedOn`,{date:p.format(new Date(n.created_at))}),` · `,n.last_used_at?e(`settings.tokenLastUsed`,{time:Gu(new Date(n.last_used_at),t.resolvedLanguage)}):e(`settings.tokenNeverUsed`)]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>v(n),className:`btn-secondary shrink-0 px-3 py-1.5 text-sm hover:text-[var(--c-danger)]`,children:e(`settings.disconnectApp`)})]},n.id))}),(0,W.jsxs)(nf,{title:e(`settings.tokensTitle`),description:e(`settings.tokensHint`),children:[u&&(0,W.jsx)(af,{children:(0,W.jsxs)(`div`,{className:`rounded-xl border border-[var(--c-green3)] p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:e(`settings.tokenCreated`)}),(0,W.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,W.jsx)(`code`,{className:`min-w-0 flex-1 break-all text-xs`,children:u}),(0,W.jsx)(Xf,{value:u})]}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-[var(--c-text-muted)]`,children:e(`settings.tokenCreatedHint`)})]})}),(0,W.jsx)(af,{children:(0,W.jsxs)(`form`,{onSubmit:h,className:`flex flex-col gap-3 sm:flex-row`,children:[(0,W.jsx)(`input`,{type:`text`,required:!0,placeholder:e(`settings.tokenNamePlaceholder`),"aria-label":e(`settings.tokenNamePlaceholder`),className:`input sm:flex-1`,value:o,onChange:e=>s(e.target.value)}),(0,W.jsx)(Vu,{value:c,onChange:e=>l(e),options:[{value:`read`,label:e(`settings.tokenReadOnly`)},{value:`write`,label:e(`settings.tokenReadWrite`)}],className:`sm:w-48`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary whitespace-nowrap`,children:e(`settings.createToken`)})]})}),n.length===0?(0,W.jsx)(af,{children:(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`settings.noTokens`)})}):n.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate font-medium`,children:n.name}),(0,W.jsx)(Zf,{scope:n.scope})]}),(0,W.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[(0,W.jsxs)(`code`,{children:[n.token_prefix,`…`]}),` · `,e(`settings.tokenCreatedOn`,{date:p.format(new Date(n.created_at))}),` · `,n.last_used_at?e(`settings.tokenLastUsed`,{time:Gu(new Date(n.last_used_at),t.resolvedLanguage)}):e(`settings.tokenNeverUsed`)]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>g(n),className:`btn-secondary shrink-0 px-3 py-1.5 text-sm hover:text-[var(--c-danger)]`,children:e(`settings.deleteToken`)})]},n.id))]})]})}function $f({pairing:e,onDone:t}){let{t:n}=z(),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(()=>Math.max(0,Math.round((new Date(e.expiresAt).getTime()-Date.now())/1e3)));(0,_.useEffect)(()=>{let t=!1;return If.toDataURL(e.pairingUrl,{margin:1,width:224,errorCorrectionLevel:`M`}).then(e=>{t||i(e)}),()=>{t=!0}},[e.pairingUrl]),(0,_.useEffect)(()=>{let t=window.setInterval(()=>o(Math.max(0,Math.round((new Date(e.expiresAt).getTime()-Date.now())/1e3))),1e3);return()=>window.clearInterval(t)},[e.expiresAt]);let s=a===0;return(0,W.jsx)(af,{children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center sm:flex-row sm:items-start sm:gap-6 sm:text-left`,children:[r&&(0,W.jsx)(`img`,{src:r,alt:n(`settings.deviceQrAlt`),width:224,height:224,className:`rounded-xl bg-white p-1 ${s?`opacity-30`:``}`}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:n(`settings.devicePairHint`)}),(0,W.jsx)(`code`,{className:`select-all rounded-lg border border-[var(--c-border)] bg-[var(--c-bg)] px-3 py-2 text-lg tracking-widest`,children:e.code}),(0,W.jsx)(`p`,{className:`text-xs text-[var(--c-text-muted)]`,role:`status`,children:s?n(`settings.devicePairExpired`):n(`settings.devicePairExpires`,{minutes:Math.floor(a/60),seconds:String(a%60).padStart(2,`0`)})}),(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn-secondary self-center px-3 py-1.5 text-sm sm:self-start`,children:n(`settings.devicePairDone`)})]})]})})}function ep(){let{t:e,i18n:t}=z(),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!1);async function c(){let e=await U.listDevices().catch(()=>null);e&&r(t=>(e.length>t.length&&t.length>=0&&a(null),e))}(0,_.useEffect)(()=>{c();let e=window.setInterval(()=>void c(),5e3);return()=>window.clearInterval(e)},[]);async function l(){s(!0);try{a(await U.createPairingCode())}catch{J.error(e(`common.error`))}finally{s(!1)}}async function u(t){confirm(e(`settings.deviceRevokeConfirm`,{name:t.name}))&&(await U.revokeDevice(t.id),await c())}return(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:(0,W.jsxs)(nf,{title:e(`settings.devicesTitle`),description:e(`settings.devicesHint`),footer:(0,W.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void l(),className:`btn-primary`,children:e(`settings.deviceAdd`)}),children:[i&&(0,W.jsx)($f,{pairing:i,onDone:()=>{a(null),c()}}),n.length===0?(0,W.jsx)(af,{children:(0,W.jsx)(`p`,{className:`text-sm text-[var(--c-text-muted)]`,children:e(`settings.noDevices`)})}):n.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate font-medium`,children:n.name}),(0,W.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-[var(--c-text-muted)]`,children:[[n.platform,n.appVersion&&`v${n.appVersion}`].filter(Boolean).join(` · `),` · `,n.lastUsedAt?e(`settings.tokenLastUsed`,{time:Gu(new Date(n.lastUsedAt),t.resolvedLanguage)}):e(`settings.tokenNeverUsed`)]})]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void u(n),className:`btn-secondary shrink-0 px-3 py-1.5 text-sm hover:text-[var(--c-danger)]`,children:e(`settings.deviceRevoke`)})]},n.id))]})})}function tp(){let{t:e}=z(),[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`user`),[d,f]=(0,_.useState)(null);async function p(){n(await U.listUsers())}(0,_.useEffect)(()=>{p()},[]);async function m(t){t.preventDefault(),f(null);try{await U.createUser({email:r,password:s,displayName:a,role:l}),i(``),o(``),c(``),u(`user`),f({type:`success`,text:e(`settings.userCreated`)}),await p()}catch{f({type:`error`,text:e(`common.error`)})}}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(nf,{title:e(`settings.usersTitle`),children:t.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-5 py-3.5 sm:px-6`,children:[(0,W.jsx)(ql,{user:t,className:`h-9 w-9 text-xs`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate font-medium`,children:t.display_name}),(0,W.jsx)(`p`,{className:`truncate text-xs text-[var(--c-text-muted)]`,children:t.email})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium ${t.role===`admin`?`bg-[var(--c-blue1)] text-white`:`bg-[var(--c-mobile-nav-active)] text-[var(--c-text-muted)]`}`,children:t.role===`admin`?e(`settings.roleAdmin`):e(`settings.roleUser`)})]},t.id))}),(0,W.jsx)(`form`,{onSubmit:m,children:(0,W.jsx)(nf,{title:e(`settings.addUser`),description:e(`settings.addUserHint`),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(sf,{message:d}),(0,W.jsx)(`button`,{type:`submit`,className:`btn-primary`,children:e(`settings.addUser`)})]}),children:(0,W.jsx)(af,{children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,W.jsx)(`input`,{type:`email`,required:!0,placeholder:e(`onboarding.emailLabel`),"aria-label":e(`onboarding.emailLabel`),className:`input`,value:r,onChange:e=>i(e.target.value)}),(0,W.jsx)(`input`,{type:`text`,required:!0,placeholder:e(`onboarding.displayNameLabel`),"aria-label":e(`onboarding.displayNameLabel`),className:`input`,value:a,onChange:e=>o(e.target.value)}),(0,W.jsx)(`input`,{type:`password`,required:!0,minLength:10,autoComplete:`new-password`,placeholder:e(`onboarding.passwordLabel`),"aria-label":e(`onboarding.passwordLabel`),className:`input`,value:s,onChange:e=>c(e.target.value)}),(0,W.jsx)(Vu,{value:l,onChange:e=>u(e),options:[{value:`user`,label:e(`settings.roleUser`)},{value:`admin`,label:e(`settings.roleAdmin`)}],className:`w-full`})]})})})})]})}function np(e){return e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function rp({id:e,value:t,max:n,onChange:r}){return(0,W.jsx)(`input`,{id:e,type:`number`,min:0,max:n,className:`input w-28 text-right tabular-nums`,value:t,onChange:e=>r(Number(e.target.value))})}function ip(){let{t:e,i18n:t}=z(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(30),[o,s]=(0,_.useState)(90),[c,l]=(0,_.useState)(1e3),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(null),y=new Intl.NumberFormat(t.resolvedLanguage);(0,_.useEffect)(()=>{U.getRetention().then(e=>{r(e.stats),a(e.settings.retentionReadDays),s(e.settings.retentionMaxDays),l(e.settings.retentionMaxItemsPerFeed),d(e.settings.autoCleanupEnabled)}).catch(()=>{})},[]);async function b(t){t.preventDefault(),p(!0),v(null);try{let t=await U.updateRetention({retentionReadDays:i,retentionMaxDays:o,retentionMaxItemsPerFeed:c,autoCleanupEnabled:u});r(t.stats),v({type:`success`,text:e(`settings.retentionSaved`)})}catch{v({type:`error`,text:e(`common.error`)})}finally{p(!1)}}async function x(){h(!0),v(null);try{let t=await U.runCleanup();r(t.stats),v({type:`success`,text:e(`settings.cleanupSuccess`,{total:t.result.totalDeleted,before:(t.result.sizeBefore/1024/1024).toFixed(2),after:(t.result.sizeAfter/1024/1024).toFixed(2)})})}catch{v({type:`error`,text:e(`common.error`)})}finally{h(!1)}}let S=n?[{label:e(`settings.statTotalItems`),value:y.format(n.totalItems)},{label:e(`settings.statReadItems`),value:y.format(n.readItems)},{label:e(`settings.statFeedsCount`),value:y.format(n.feedsCount)},{label:e(`settings.statDbSize`),value:np(n.databaseSizeBytes)}]:[];return(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[S.length>0&&(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:S.map(e=>(0,W.jsxs)(`div`,{className:`card px-4 py-3`,children:[(0,W.jsx)(`p`,{className:`text-xs text-[var(--c-text-muted)]`,children:e.label}),(0,W.jsx)(`p`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:e.value})]},e.label))}),(0,W.jsx)(`form`,{onSubmit:b,children:(0,W.jsxs)(nf,{title:e(`settings.retentionTitle`),description:e(`settings.retentionHint`),footer:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(sf,{message:g}),(0,W.jsx)(`button`,{type:`button`,disabled:m,onClick:x,className:`btn-secondary`,children:e(m?`settings.cleaning`:`settings.runCleanupNow`)}),(0,W.jsx)(`button`,{type:`submit`,disabled:f,className:`btn-primary`,children:e(`settings.saveRetention`)})]}),children:[(0,W.jsx)(rf,{label:e(`settings.autoCleanupLabel`),htmlFor:`auto-cleanup`,inline:!0,children:(0,W.jsx)(of,{id:`auto-cleanup`,label:e(`settings.autoCleanupLabel`),checked:u,onChange:d})}),(0,W.jsx)(rf,{label:e(`settings.retentionReadDaysLabel`),hint:e(`settings.retentionReadDaysHint`),htmlFor:`retention-read`,children:(0,W.jsx)(rp,{id:`retention-read`,value:i,max:3650,onChange:a})}),(0,W.jsx)(rf,{label:e(`settings.retentionMaxDaysLabel`),hint:e(`settings.retentionMaxDaysHint`),htmlFor:`retention-max`,children:(0,W.jsx)(rp,{id:`retention-max`,value:o,max:3650,onChange:s})}),(0,W.jsx)(rf,{label:e(`settings.retentionMaxItemsLabel`),hint:e(`settings.retentionMaxItemsHint`),htmlFor:`retention-items`,children:(0,W.jsx)(rp,{id:`retention-items`,value:c,max:1e5,onChange:l})})]})})]})}var ap=e=>(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e}),op=[`M4 6h16M4 12h16M4 18h10`],sp=`(min-width: 768px)`;function cp(){return(0,_.useSyncExternalStore)(e=>{let t=window.matchMedia(sp);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(sp).matches,()=>!0)}function lp(){let{t:e}=z(),{user:t}=lo(),[n,r]=Li(),i=mr(),a=dr(),o=cp(),s=bl(),c=[{id:`account`,label:e(`settings.sectionAccount`),description:e(`settings.sectionAccountHint`),icon:ap((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`12`,cy:`8`,r:`4`}),(0,W.jsx)(`path`,{d:`M4 21a8 8 0 0 1 16 0`})]})),render:()=>(0,W.jsx)(Vf,{})},{id:`general`,label:e(`settings.sectionGeneral`),description:e(`settings.sectionGeneralHint`),icon:ap((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})),render:()=>(0,W.jsx)(Jf,{})},{id:`filters`,label:e(`settings.sectionFilters`),description:e(`settings.sectionFiltersHint`),icon:ap((0,W.jsx)(`path`,{d:`M3 5h18l-7 8v6l-4 2v-8Z`})),render:()=>(0,W.jsx)(Yf,{})},{id:`devices`,label:e(`settings.sectionDevices`),description:e(`settings.sectionDevicesHint`),icon:ap((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`rect`,{x:`7`,y:`2`,width:`10`,height:`20`,rx:`2.5`}),(0,W.jsx)(`path`,{d:`M11 18h2`})]})),render:()=>(0,W.jsx)(ep,{})},{id:`mcp`,label:e(`settings.sectionMcp`),description:e(`settings.sectionMcpHint`),icon:ap((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M9 7V3M15 7V3M6 7h12v4a6 6 0 0 1-12 0Z`}),(0,W.jsx)(`path`,{d:`M12 17v4`})]})),render:()=>(0,W.jsx)(Qf,{})},{id:`users`,label:e(`settings.sectionUsers`),description:e(`settings.sectionUsersHint`),icon:ap((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,W.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 7M21.5 20a6.5 6.5 0 0 0-4-6`})]})),admin:!0,render:()=>(0,W.jsx)(tp,{})},{id:`database`,label:e(`settings.sectionDatabase`),description:e(`settings.sectionDatabaseHint`),icon:ap((0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,W.jsx)(`path`,{d:`M4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3`})]})),admin:!0,render:()=>(0,W.jsx)(ip,{})}],l=t?.role===`admin`,{hidden:u,sections:d}=al(s,c.map(e=>e.id),l),f=d.map(e=>({id:e.id,label:e.label,description:e.description,group:e.group,icon:ap((0,W.jsx)(W.Fragment,{children:(e.icon??op).map(e=>(0,W.jsx)(`path`,{d:e},e))})),render:()=>(0,W.jsx)(Iu,{name:`settings-${e.id}`,mount:e.mount})})),p=[...c.filter(e=>!u.has(e.id)&&(!e.admin||l)),...f],m=p.find(e=>e.id===n.get(`tab`)),h=m??p[0],g=e=>{r(e===p[0].id?{}:{tab:e},{replace:!0}),window.scrollTo({top:0})},v=e=>{i({search:`?tab=${encodeURIComponent(e)}`},{state:{fromList:!0}}),window.scrollTo({top:0})},y=()=>{a.state?.fromList?i(-1):i({search:``},{replace:!0}),window.scrollTo({top:0})},b=e=>{let t=e.id===h.id;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>g(e.id),"aria-current":t?`page`:void 0,className:`inline-flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors cursor-pointer focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)] ${t?`bg-[var(--c-mobile-nav-active)] text-[var(--c-text)]`:`text-[var(--c-text-muted)] hover:bg-[var(--c-surface-hover)] hover:text-[var(--c-text)]`}`,children:[e.icon,e.label]},e.id)},x=e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>v(e.id),className:`flex w-full items-center gap-3.5 px-4 py-3.5 text-left cursor-pointer transition-colors hover:bg-[var(--c-surface-hover)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)]`,children:[(0,W.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[var(--c-border)] bg-[var(--c-surface)] text-[var(--c-text)]`,children:e.icon}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block text-sm font-semibold text-[var(--c-text)]`,children:e.label}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs leading-snug text-[var(--c-text-muted)]`,children:e.description})]}),(0,W.jsx)(`svg`,{className:`h-4 w-4 shrink-0 text-[var(--c-text-muted)]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id),S=p.filter(e=>e.admin&&!e.group),C=ol(f),w=`mt-5 mb-1 px-3 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,T=[{key:`main`,sections:p.filter(e=>!e.admin&&!e.group)},...S.length>0?[{key:`admin`,heading:e(`settings.adminGroup`),sections:S}]:[],...C.map(({group:e,sections:t})=>({key:e,heading:e,sections:t}))];return o?(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`settings.title`)}),(0,W.jsxs)(`div`,{className:`grid grid-cols-[13rem_minmax(0,1fr)] gap-10`,children:[(0,W.jsxs)(`nav`,{className:`sticky top-24 flex flex-col gap-0.5 self-start`,"aria-label":e(`settings.title`),children:[p.filter(e=>!e.admin&&!e.group).map(b),S.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:w,children:e(`settings.adminGroup`)}),S.map(b)]}),C.map(({group:e,sections:t})=>(0,W.jsxs)(_.Fragment,{children:[(0,W.jsx)(`p`,{className:w,children:e}),t.map(b)]},e))]}),(0,W.jsxs)(`div`,{className:`min-w-0 animate-page-fade`,children:[(0,W.jsx)(cf,{title:h.label,description:h.description}),h.render(),(0,W.jsx)(Yl,{placement:`page`})]},h.id)]})]}):m?(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:y,className:`-ml-1 inline-flex w-fit items-center gap-1 rounded-lg px-1 py-1 text-sm font-medium text-[var(--c-text-muted)] cursor-pointer hover:text-[var(--c-text)] focus-visible:outline-2 focus-visible:outline-[var(--c-blue3)]`,children:[(0,W.jsx)(`svg`,{className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`m15 6-6 6 6 6`})}),e(`settings.title`)]}),(0,W.jsxs)(`div`,{className:`min-w-0 animate-page-fade`,children:[(0,W.jsx)(cf,{title:m.label,description:m.description}),m.render(),(0,W.jsx)(Yl,{placement:`page`})]},m.id)]}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`settings.title`)}),(0,W.jsx)(`nav`,{className:`flex flex-col gap-6`,"aria-label":e(`settings.title`),children:T.map(t=>(0,W.jsxs)(`section`,{"aria-label":t.heading??e(`settings.title`),children:[t.heading&&(0,W.jsx)(`h2`,{className:`mb-2 px-1 text-xs font-semibold tracking-[0.08em] uppercase text-[var(--c-text-muted)]`,children:t.heading}),(0,W.jsx)(`ul`,{className:`card divide-y divide-[var(--c-border)] overflow-hidden p-0`,children:t.sections.map(x)})]},t.key))})]})}function up(){return document.getElementById(`splash`)?.classList.contains(`splash-hidden`)===!1}function dp(){let e=document.getElementById(`splash`);if(!e||e.classList.contains(`splash-hidden`))return;e.classList.add(`splash-hidden`);let t=()=>e.remove();e.addEventListener(`transitionend`,t,{once:!0}),window.setTimeout(t,500)}function fp(){let{t:e,i18n:t}=z(),n=gl(bl(),t.resolvedLanguage||`en`);return(0,_.useLayoutEffect)(()=>{document.documentElement.lang=t.resolvedLanguage||`en`,window.dispatchEvent(new Event($c))},[t.resolvedLanguage]),(0,_.useEffect)(()=>{let t=n.title??e(`common.metaTitle`),r=n.description??e(`common.metaDescription`);document.title=t;let i=document.querySelector(`meta[name="description"]`);i&&i.setAttribute(`content`,r);let a=document.querySelector(`meta[property="og:title"]`);a&&a.setAttribute(`content`,t);let o=document.querySelector(`meta[property="og:description"]`);o&&o.setAttribute(`content`,r);let s=document.querySelector(`meta[name="twitter:title"]`);s&&s.setAttribute(`content`,t);let c=document.querySelector(`meta[name="twitter:description"]`);c&&c.setAttribute(`content`,r)},[t.resolvedLanguage,e,n.title,n.description]),null}function pp({children:e}){let{user:t,loading:n,needsOnboarding:r,unreachable:i}=lo();return(0,_.useEffect)(()=>{n||dp()},[n]),n?up()?null:(0,W.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-[var(--c-bg)] z-50`,children:(0,W.jsx)(Ru,{size:`lg`,center:!1})}):i?(0,W.jsx)(nu,{}):r?(0,W.jsx)(hu,{}):t?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(Lu,{})}function mp(){return(0,_.useEffect)(()=>{`scrollRestoration`in window.history&&(window.history.scrollRestoration=`manual`)},[]),(0,W.jsxs)(Ai,{children:[(0,W.jsx)(fp,{}),(0,W.jsx)(co,{children:(0,W.jsx)(fo,{children:(0,W.jsx)(pp,{children:(0,W.jsx)(Wr,{children:(0,W.jsxs)(Hr,{element:(0,W.jsx)(mu,{}),children:[(0,W.jsx)(Hr,{index:!0,element:(0,W.jsx)(Br,{to:`/items`,replace:!0})}),(0,W.jsx)(Hr,{path:`/items`,element:(0,W.jsx)($d,{})}),(0,W.jsx)(Hr,{path:`/feeds`,element:(0,W.jsx)(wd,{})}),(0,W.jsx)(Hr,{path:`/settings`,element:(0,W.jsx)(lp,{})}),(0,W.jsx)(Hr,{path:`/extensions/:pageId`,element:(0,W.jsx)(xl,{})}),(0,W.jsx)(Hr,{path:`*`,element:(0,W.jsx)(Br,{to:`/items`,replace:!0})})]})})})})})]})}Hl(),io(),(0,v.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(_.StrictMode,{children:(0,W.jsx)(mp,{})}));
|