1import{G as l,d}from"./base.Cl0vBHyv.js";import{primeActivity as c,isFavorited as h,invalidateActivity as f}from"./activity-state.CJo4d2d0.js";import"./assets.UILKF1Ac.js";const p=s=>`<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true"><path d="M12 20s-7-4.4-7-9.3A3.7 3.7 0 0 1 12 7.6 3.7 3.7 0 0 1 19 10.7c0 4.9-7 9.3-7 9.3z" fill="${s?"currentColor":"none"}" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/></svg>`,u=` 2 .pill { display:inline-flex; align-items:center; gap:6px; cursor:pointer; font-family:var(--font-body); 3 font-size:12.5px; font-weight:600; color:var(--muted); background:var(--panel); 4 border:1.5px solid var(--line); border-radius:999px; padding:5px 11px; 5 transition:color .15s ease, border-color .15s ease; } 6 .pill:hover, .pill.on { color:var(--brand); border-color:var(--brand); } 7 .pill svg { flex:none; } 8 .pill .c { font-variant-numeric: tabular-nums; } 9 /* sow-179: icon-only, count stacked below, for the Editorial/Journal sticky action rail. */ 10 .pill.rail { flex-direction:column; gap:2px; width:38px; height:38px; padding:0; justify-content:center; 11 border-radius:7px; font-size:10.5px; } 12`;class v extends l{render(){const e=this.dataset?.gbtiTargetType,o=this.dataset?.gbtiTargetSlug,i=this.dataset?.gbtiSize==="rail";if(this._count===void 0){const r=parseInt(this.dataset?.gbtiCount||"0",10);this._count=Number.isFinite(r)&&r>0?r:0}this._faved===void 0&&(this._faved=!1),this.client&&!this._primed&&(this._primed=!0,c(this.client).then(r=>{this._touched||!this.isConnected||(this._faved=h(r,{type:e,slug:o}),this.render())}).catch(()=>{this._primed=!1}));const t=Math.max(0,this._count),n=this.client?this._faved?"Remove favorite":"Add favorite":"Sign in to favorite",a=`${n}${t>0?`, ${t} so far`:""}`;this.set(this.css(u)+`<button class="pill ${i?"rail":""} ${this._faved?"on":""}" type="button" aria-pressed="${this._faved}" aria-label="${a}" data-tooltip="${n}">${p(this._faved)}${t>0?`<span class="c">${t}</span>`:""}</button>`),this.on(".pill","click",()=>this._onClick(e,o))}_onClick(e,o){if(!this.client){window.location.href="/membership/";return}this._toggle(e,o)}async _toggle(e,o){const i=!this._faved;this._touched=!0,this._faved=i,this._count=Math.max(0,this._count+(i?1:-1)),this.render();try{const t=await this.client.toggleFavorite({targetType:e,targetSlug:o,on:i});f(this.client),t&&typeof t.favorited=="boolean"&&t.favorited!==i&&(this._count=Math.max(0,this._count-(i?1:-1)),this._faved=t.favorited,this.render())}catch(t){this._faved=!i,this._count=Math.max(0,this._count+(i?-1:1)),this.render(),(t?.code==="not-authenticated"||t?.code==="membership-required")&&(window.location.href="/membership/")}}}d("gbti-favorite",v);export{v as GbtiFavorite};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.